Skip to content

Commit 21cf377

Browse files
LinoSanfilippo333davem330
authored andcommitted
net: dsa: ensure linearized SKBs in case of tail taggers
The function skb_put() that is used by tail taggers to make room for the DSA tag must only be called for linearized SKBS. However in case that the slave device inherited features like NETIF_F_HW_SG or NETIF_F_FRAGLIST the SKB passed to the slaves transmit function may not be linearized. Avoid those SKBs by clearing the NETIF_F_HW_SG and NETIF_F_FRAGLIST flags for tail taggers. Furthermore since the tagging protocol can be changed at runtime move the code for setting up the slaves features into dsa_slave_setup_tagger(). Suggested-by: Vladimir Oltean <[email protected]> Signed-off-by: Lino Sanfilippo <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9f061b9 commit 21cf377

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

net/dsa/slave.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1808,6 +1808,7 @@ void dsa_slave_setup_tagger(struct net_device *slave)
18081808
struct dsa_slave_priv *p = netdev_priv(slave);
18091809
const struct dsa_port *cpu_dp = dp->cpu_dp;
18101810
struct net_device *master = cpu_dp->master;
1811+
const struct dsa_switch *ds = dp->ds;
18111812

18121813
slave->needed_headroom = cpu_dp->tag_ops->needed_headroom;
18131814
slave->needed_tailroom = cpu_dp->tag_ops->needed_tailroom;
@@ -1819,6 +1820,14 @@ void dsa_slave_setup_tagger(struct net_device *slave)
18191820
slave->needed_tailroom += master->needed_tailroom;
18201821

18211822
p->xmit = cpu_dp->tag_ops->xmit;
1823+
1824+
slave->features = master->vlan_features | NETIF_F_HW_TC;
1825+
if (ds->ops->port_vlan_add && ds->ops->port_vlan_del)
1826+
slave->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
1827+
slave->hw_features |= NETIF_F_HW_TC;
1828+
slave->features |= NETIF_F_LLTX;
1829+
if (slave->needed_tailroom)
1830+
slave->features &= ~(NETIF_F_SG | NETIF_F_FRAGLIST);
18221831
}
18231832

18241833
static struct lock_class_key dsa_slave_netdev_xmit_lock_key;
@@ -1881,11 +1890,6 @@ int dsa_slave_create(struct dsa_port *port)
18811890
if (slave_dev == NULL)
18821891
return -ENOMEM;
18831892

1884-
slave_dev->features = master->vlan_features | NETIF_F_HW_TC;
1885-
if (ds->ops->port_vlan_add && ds->ops->port_vlan_del)
1886-
slave_dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
1887-
slave_dev->hw_features |= NETIF_F_HW_TC;
1888-
slave_dev->features |= NETIF_F_LLTX;
18891893
slave_dev->ethtool_ops = &dsa_slave_ethtool_ops;
18901894
if (!is_zero_ether_addr(port->mac))
18911895
ether_addr_copy(slave_dev->dev_addr, port->mac);

0 commit comments

Comments
 (0)