6683a53f765e82eb972deece008b409b8ba7aa13
[openwrt/staging/jow.git] / target / linux / generic / pending-5.15 / 704-01-netfilter-nft_flow_offload-skip-dst-neigh-lookup-for.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Fri, 6 May 2022 12:43:58 +0200
3 Subject: [PATCH] netfilter: nft_flow_offload: skip dst neigh lookup for
4 ppp devices
5
6 The dst entry does not contain a valid hardware address, so skip the lookup
7 in order to avoid running into errors here.
8 The proper hardware address is filled in from nft_dev_path_info
9
10 Signed-off-by: Felix Fietkau <nbd@nbd.name>
11 ---
12
13 --- a/net/netfilter/nft_flow_offload.c
14 +++ b/net/netfilter/nft_flow_offload.c
15 @@ -36,6 +36,15 @@ static void nft_default_forward_path(str
16 route->tuple[dir].xmit_type = nft_xmit_type(dst_cache);
17 }
18
19 +static bool nft_is_valid_ether_device(const struct net_device *dev)
20 +{
21 + if (!dev || (dev->flags & IFF_LOOPBACK) || dev->type != ARPHRD_ETHER ||
22 + dev->addr_len != ETH_ALEN || !is_valid_ether_addr(dev->dev_addr))
23 + return false;
24 +
25 + return true;
26 +}
27 +
28 static int nft_dev_fill_forward_path(const struct nf_flow_route *route,
29 const struct dst_entry *dst_cache,
30 const struct nf_conn *ct,
31 @@ -47,6 +56,9 @@ static int nft_dev_fill_forward_path(con
32 struct neighbour *n;
33 u8 nud_state;
34
35 + if (!nft_is_valid_ether_device(dev))
36 + goto out;
37 +
38 n = dst_neigh_lookup(dst_cache, daddr);
39 if (!n)
40 return -1;
41 @@ -60,6 +72,7 @@ static int nft_dev_fill_forward_path(con
42 if (!(nud_state & NUD_VALID))
43 return -1;
44
45 +out:
46 return dev_fill_forward_path(dev, ha, stack);
47 }
48
49 @@ -78,15 +91,6 @@ struct nft_forward_info {
50 enum flow_offload_xmit_type xmit_type;
51 };
52
53 -static bool nft_is_valid_ether_device(const struct net_device *dev)
54 -{
55 - if (!dev || (dev->flags & IFF_LOOPBACK) || dev->type != ARPHRD_ETHER ||
56 - dev->addr_len != ETH_ALEN || !is_valid_ether_addr(dev->dev_addr))
57 - return false;
58 -
59 - return true;
60 -}
61 -
62 static void nft_dev_path_info(const struct net_device_path_stack *stack,
63 struct nft_forward_info *info,
64 unsigned char *ha, struct nf_flowtable *flowtable)