984733aeb8a2efd850ca121d522ac88c822d2901
[openwrt/staging/jow.git] / target / linux / generic / pending-5.15 / 704-02-net-fix-dev_fill_forward_path-with-pppoe-bridge.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Fri, 6 May 2022 13:54:44 +0200
3 Subject: [PATCH] net: fix dev_fill_forward_path with pppoe + bridge
4
5 When calling dev_fill_forward_path on a pppoe device, the provided destination
6 address is invalid. In order for the bridge fdb lookup to succeed, the pppoe
7 code needs to update ctx->daddr to the correct value.
8 Fix this by storing the address inside struct net_device_path_ctx
9
10 Signed-off-by: Felix Fietkau <nbd@nbd.name>
11 ---
12
13 --- a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
14 +++ b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
15 @@ -90,7 +90,6 @@ mtk_flow_get_wdma_info(struct net_device
16 {
17 struct net_device_path_ctx ctx = {
18 .dev = dev,
19 - .daddr = addr,
20 };
21 struct net_device_path path = {};
22
23 @@ -100,6 +99,7 @@ mtk_flow_get_wdma_info(struct net_device
24 if (!dev->netdev_ops->ndo_fill_forward_path)
25 return -1;
26
27 + memcpy(ctx.daddr, addr, sizeof(ctx.daddr));
28 if (dev->netdev_ops->ndo_fill_forward_path(&ctx, &path))
29 return -1;
30
31 --- a/drivers/net/ppp/pppoe.c
32 +++ b/drivers/net/ppp/pppoe.c
33 @@ -988,6 +988,7 @@ static int pppoe_fill_forward_path(struc
34 path->encap.proto = htons(ETH_P_PPP_SES);
35 path->encap.id = be16_to_cpu(po->num);
36 memcpy(path->encap.h_dest, po->pppoe_pa.remote, ETH_ALEN);
37 + memcpy(ctx->daddr, po->pppoe_pa.remote, ETH_ALEN);
38 path->dev = ctx->dev;
39 ctx->dev = dev;
40
41 --- a/include/linux/netdevice.h
42 +++ b/include/linux/netdevice.h
43 @@ -894,7 +894,7 @@ struct net_device_path_stack {
44
45 struct net_device_path_ctx {
46 const struct net_device *dev;
47 - const u8 *daddr;
48 + u8 daddr[ETH_ALEN];
49
50 int num_vlans;
51 struct {
52 --- a/net/core/dev.c
53 +++ b/net/core/dev.c
54 @@ -741,11 +741,11 @@ int dev_fill_forward_path(const struct n
55 const struct net_device *last_dev;
56 struct net_device_path_ctx ctx = {
57 .dev = dev,
58 - .daddr = daddr,
59 };
60 struct net_device_path *path;
61 int ret = 0;
62
63 + memcpy(ctx.daddr, daddr, sizeof(ctx.daddr));
64 stack->num_paths = 0;
65 while (ctx.dev && ctx.dev->netdev_ops->ndo_fill_forward_path) {
66 last_dev = ctx.dev;