kernel: fix corrupted ethernet header on bridge multicast-to-unicast
[openwrt/openwrt.git] / target / linux / generic / pending-6.1 / 684-net-bridge-fix-corrupted-ethernet-header-on-multicas.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Sun, 5 May 2024 20:36:56 +0200
3 Subject: [PATCH] net: bridge: fix corrupted ethernet header on
4 multicast-to-unicast
5
6 The change from skb_copy to pskb_copy unfortunately changed the data
7 copying to omit the ethernet header, since it was pulled before reaching
8 this point. Fix this by calling __skb_push/pull around pskb_copy.
9
10 Fixes: 59c878cbcdd8 ("net: bridge: fix multicast-to-unicast with fraglist GSO")
11 Signed-off-by: Felix Fietkau <nbd@nbd.name>
12 ---
13
14 --- a/net/bridge/br_forward.c
15 +++ b/net/bridge/br_forward.c
16 @@ -253,6 +253,7 @@ static void maybe_deliver_addr(struct ne
17 {
18 struct net_device *dev = BR_INPUT_SKB_CB(skb)->brdev;
19 const unsigned char *src = eth_hdr(skb)->h_source;
20 + struct sk_buff *nskb;
21
22 if (!should_deliver(p, skb))
23 return;
24 @@ -261,12 +262,16 @@ static void maybe_deliver_addr(struct ne
25 if (skb->dev == p->dev && ether_addr_equal(src, addr))
26 return;
27
28 - skb = pskb_copy(skb, GFP_ATOMIC);
29 - if (!skb) {
30 + __skb_push(skb, ETH_HLEN);
31 + nskb = pskb_copy(skb, GFP_ATOMIC);
32 + __skb_pull(skb, ETH_HLEN);
33 + if (!nskb) {
34 DEV_STATS_INC(dev, tx_dropped);
35 return;
36 }
37
38 + skb = nskb;
39 + __skb_pull(skb, ETH_HLEN);
40 if (!is_broadcast_ether_addr(addr))
41 memcpy(eth_hdr(skb)->h_dest, addr, ETH_ALEN);
42