| Message ID | 20261103213430.2850-1-marek@lysk.ai |
|---|---|
| State | New |
| Headers | show |
| Series | [nf-next] netfilter: flowtable: tunnel device poisons h_source of fast-path frames | expand |
> When a flow enters an IP tunnel, the forward path discovered by > dev_fill_forward_path() starts with a DEV_PATH_TUN entry for the tunnel > device, followed by whatever carries the outer packet. > nft_dev_path_info() handles DEV_PATH_TUN in the same switch case as the > Ethernet-like path types and copies path->dev->dev_addr into > info->h_source if it is still unset. For a tunnel device dev_addr is not > an Ethernet address: ip6_tunnel stores the 16-byte local IPv6 there and > ip_tunnel the 4-byte local IPv4. The tunnel entry is the first one on > the path, so its "address" wins and poisons h_source: every fast-path > frame is transmitted with the first bytes of the tunnel local IP address > as the Ethernet source MAC. > > Seen on a DS-Lite setup, LAN -> ip6tnl (IPv4 inside IPv6) -> PPPoE -> > 802.1Q VLAN -> Ethernet, with conntrack flows offloaded through an > nftables flowtable ('flow add @ft'). The first packets of a flow, still > on the slow path, and the fast-path packets of the same flow differ only > in the Ethernet source address: > > slow path: d8:58:d7:00:2e:bd > 80:ac:ac:39:ef:c2, 802.1Q vlan 35, > PPPoE [ses 0x454] IP6 2a01:110f:4328:c400::1 > > 2a01:1000:0:1::2216 next-header IPIP, 192.0.0.2.40010 > > 1.1.1.1.53 > fast path: 2a:01:11:0f:43:28 > 80:ac:ac:39:ef:c2, same frame otherwise > > As you can see 2a:01:11:0f:43:28 is the start of 2a01:110f:4328:c400::1, > the tunnel local address. The PPPoE endpoint binds the session to the > subscriber MAC and silently drops the frames, the effect is that every > TCP/UDP flow dies the moment it is offloaded, while ICMP, which is never > offloaded, keeps working. Received traffic is unaffected. > > Do not let DEV_PATH_TUN poison h_source: skip the assignment for it. The > real link-layer device appears later on the same path and provides the > correct address; for a path with no Ethernet device the address stays > zero as before. > > Fixes: ab427db17885 ("netfilter: flowtable: Add IPIP rx sw acceleration") > Signed-off-by: Marek Majkowski <marek@lysk.ai> Hi Marek, thx for testing the series and fixing this issue (I guess this is occurring since the PPPoE path forces the xmit_type to FLOW_OFFLOAD_XMIT_DIRECT). Since the issue is related even to IPIP or IP6IP6 tunnels, what about targeting nf branch instead? Reviewed-by: Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com> > --- > Found while testing this series on a Turris Omnia (Debian, armhf) behind > a DS-Lite ISP: with the series applied, IPv4 flows through the ip6tnl > were offloaded but no fast-path frame ever got past the PPPoE > concentrator. The problem is in the existing DEV_PATH_TUN handling, so > it applies to net-next with or without this series; with the fix the > series works here (tested: UDP flows with a fixed source port, TCP, bulk > downloads through the tunnel). Without the series the same wrong MAC > should affect ipip and ip6ip6 tunnels in front of PPPoE. Since you actually tested the series available in [0], can you please provide your tested-by tag? Thanks. Regards, Lorenzo [0] https://lore.kernel.org/netdev/20261103-flowtable-sw-accel-ip6ip-sit-v3-0-60b5f063f1df@oss.qualcomm.com/ > > net/netfilter/nf_flow_table_path.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/net/netfilter/nf_flow_table_path.c b/net/netfilter/nf_flow_table_path.c > index 841f09943..4ca6e09c7 100644 > --- a/net/netfilter/nf_flow_table_path.c > +++ b/net/netfilter/nf_flow_table_path.c > @@ -121,7 +121,12 @@ static int nft_dev_path_info(struct net_device_path_stack *stack, > case DEV_PATH_PPPOE: > case DEV_PATH_TUN: > info->dev = path->dev; > - if (is_zero_ether_addr(info->h_source)) > + /* A tunnel device has no Ethernet address: its dev_addr > + * is the tunnel local IP address. Take h_source from the > + * real link-layer device further down the path. > + */ > + if (path->type != DEV_PATH_TUN && > + is_zero_ether_addr(info->h_source)) > memcpy(info->h_source, path->dev->dev_addr, ETH_ALEN); > > if (path->type == DEV_PATH_ETHERNET || > -- > 2.39.5 >
diff --git a/net/netfilter/nf_flow_table_path.c b/net/netfilter/nf_flow_table_path.c index 841f09943..4ca6e09c7 100644 --- a/net/netfilter/nf_flow_table_path.c +++ b/net/netfilter/nf_flow_table_path.c @@ -121,7 +121,12 @@ static int nft_dev_path_info(struct net_device_path_stack *stack, case DEV_PATH_PPPOE: case DEV_PATH_TUN: info->dev = path->dev; - if (is_zero_ether_addr(info->h_source)) + /* A tunnel device has no Ethernet address: its dev_addr + * is the tunnel local IP address. Take h_source from the + * real link-layer device further down the path. + */ + if (path->type != DEV_PATH_TUN && + is_zero_ether_addr(info->h_source)) memcpy(info->h_source, path->dev->dev_addr, ETH_ALEN); if (path->type == DEV_PATH_ETHERNET ||
When a flow enters an IP tunnel, the forward path discovered by dev_fill_forward_path() starts with a DEV_PATH_TUN entry for the tunnel device, followed by whatever carries the outer packet. nft_dev_path_info() handles DEV_PATH_TUN in the same switch case as the Ethernet-like path types and copies path->dev->dev_addr into info->h_source if it is still unset. For a tunnel device dev_addr is not an Ethernet address: ip6_tunnel stores the 16-byte local IPv6 there and ip_tunnel the 4-byte local IPv4. The tunnel entry is the first one on the path, so its "address" wins and poisons h_source: every fast-path frame is transmitted with the first bytes of the tunnel local IP address as the Ethernet source MAC. Seen on a DS-Lite setup, LAN -> ip6tnl (IPv4 inside IPv6) -> PPPoE -> 802.1Q VLAN -> Ethernet, with conntrack flows offloaded through an nftables flowtable ('flow add @ft'). The first packets of a flow, still on the slow path, and the fast-path packets of the same flow differ only in the Ethernet source address: slow path: d8:58:d7:00:2e:bd > 80:ac:ac:39:ef:c2, 802.1Q vlan 35, PPPoE [ses 0x454] IP6 2a01:110f:4328:c400::1 > 2a01:1000:0:1::2216 next-header IPIP, 192.0.0.2.40010 > 1.1.1.1.53 fast path: 2a:01:11:0f:43:28 > 80:ac:ac:39:ef:c2, same frame otherwise As you can see 2a:01:11:0f:43:28 is the start of 2a01:110f:4328:c400::1, the tunnel local address. The PPPoE endpoint binds the session to the subscriber MAC and silently drops the frames, the effect is that every TCP/UDP flow dies the moment it is offloaded, while ICMP, which is never offloaded, keeps working. Received traffic is unaffected. Do not let DEV_PATH_TUN poison h_source: skip the assignment for it. The real link-layer device appears later on the same path and provides the correct address; for a path with no Ethernet device the address stays zero as before. Fixes: ab427db17885 ("netfilter: flowtable: Add IPIP rx sw acceleration") Signed-off-by: Marek Majkowski <marek@lysk.ai> --- Found while testing this series on a Turris Omnia (Debian, armhf) behind a DS-Lite ISP: with the series applied, IPv4 flows through the ip6tnl were offloaded but no fast-path frame ever got past the PPPoE concentrator. The problem is in the existing DEV_PATH_TUN handling, so it applies to net-next with or without this series; with the fix the series works here (tested: UDP flows with a fixed source port, TCP, bulk downloads through the tunnel). Without the series the same wrong MAC should affect ipip and ip6ip6 tunnels in front of PPPoE. net/netfilter/nf_flow_table_path.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)