Skip to content

Commit 499b249

Browse files
vladimirolteandavem330
authored andcommitted
net: dsa: tag_ksz: do not rely on skb_mac_header() in TX paths
skb_mac_header() will no longer be available in the TX path when reverting commit 6d1ccff ("net: reset mac header in dev_start_xmit()"). As preparation for that, let's use skb_eth_hdr() to get to the Ethernet header's MAC DA instead, helper which assumes this header is located at skb->data (assumption which holds true here). Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Simon Horman <simon.horman@corigine.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent eabb149 commit 499b249

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

net/dsa/tag_ksz.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,18 @@ static struct sk_buff *ksz_common_rcv(struct sk_buff *skb,
120120
static struct sk_buff *ksz8795_xmit(struct sk_buff *skb, struct net_device *dev)
121121
{
122122
struct dsa_port *dp = dsa_slave_to_port(dev);
123+
struct ethhdr *hdr;
123124
u8 *tag;
124-
u8 *addr;
125125

126126
if (skb->ip_summed == CHECKSUM_PARTIAL && skb_checksum_help(skb))
127127
return NULL;
128128

129129
/* Tag encoding */
130130
tag = skb_put(skb, KSZ_INGRESS_TAG_LEN);
131-
addr = skb_mac_header(skb);
131+
hdr = skb_eth_hdr(skb);
132132

133133
*tag = 1 << dp->index;
134-
if (is_link_local_ether_addr(addr))
134+
if (is_link_local_ether_addr(hdr->h_dest))
135135
*tag |= KSZ8795_TAIL_TAG_OVERRIDE;
136136

137137
return skb;
@@ -273,8 +273,8 @@ static struct sk_buff *ksz9477_xmit(struct sk_buff *skb,
273273
u16 queue_mapping = skb_get_queue_mapping(skb);
274274
u8 prio = netdev_txq_to_tc(dev, queue_mapping);
275275
struct dsa_port *dp = dsa_slave_to_port(dev);
276+
struct ethhdr *hdr;
276277
__be16 *tag;
277-
u8 *addr;
278278
u16 val;
279279

280280
if (skb->ip_summed == CHECKSUM_PARTIAL && skb_checksum_help(skb))
@@ -284,13 +284,13 @@ static struct sk_buff *ksz9477_xmit(struct sk_buff *skb,
284284
ksz_xmit_timestamp(dp, skb);
285285

286286
tag = skb_put(skb, KSZ9477_INGRESS_TAG_LEN);
287-
addr = skb_mac_header(skb);
287+
hdr = skb_eth_hdr(skb);
288288

289289
val = BIT(dp->index);
290290

291291
val |= FIELD_PREP(KSZ9477_TAIL_TAG_PRIO, prio);
292292

293-
if (is_link_local_ether_addr(addr))
293+
if (is_link_local_ether_addr(hdr->h_dest))
294294
val |= KSZ9477_TAIL_TAG_OVERRIDE;
295295

296296
*tag = cpu_to_be16(val);
@@ -337,7 +337,7 @@ static struct sk_buff *ksz9893_xmit(struct sk_buff *skb,
337337
u16 queue_mapping = skb_get_queue_mapping(skb);
338338
u8 prio = netdev_txq_to_tc(dev, queue_mapping);
339339
struct dsa_port *dp = dsa_slave_to_port(dev);
340-
u8 *addr;
340+
struct ethhdr *hdr;
341341
u8 *tag;
342342

343343
if (skb->ip_summed == CHECKSUM_PARTIAL && skb_checksum_help(skb))
@@ -347,13 +347,13 @@ static struct sk_buff *ksz9893_xmit(struct sk_buff *skb,
347347
ksz_xmit_timestamp(dp, skb);
348348

349349
tag = skb_put(skb, KSZ_INGRESS_TAG_LEN);
350-
addr = skb_mac_header(skb);
350+
hdr = skb_eth_hdr(skb);
351351

352352
*tag = BIT(dp->index);
353353

354354
*tag |= FIELD_PREP(KSZ9893_TAIL_TAG_PRIO, prio);
355355

356-
if (is_link_local_ether_addr(addr))
356+
if (is_link_local_ether_addr(hdr->h_dest))
357357
*tag |= KSZ9893_TAIL_TAG_OVERRIDE;
358358

359359
return ksz_defer_xmit(dp, skb);

0 commit comments

Comments
 (0)