OSDN Git Service

netfilter: nft_flow_offload: fix interaction with vrf slave device
authorwenxu <wenxu@ucloud.cn>
Thu, 10 Jan 2019 06:51:35 +0000 (14:51 +0800)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 10 Jan 2019 23:55:37 +0000 (00:55 +0100)
commit10f4e765879e514e1ce7f52ed26603047af196e2
tree468409e2e06838c28b88301f678b0852acea5c20
parente2c8d550a973bb34fc28bc8d0ec996f84562fb8a
netfilter: nft_flow_offload: fix interaction with vrf slave device

In the forward chain, the iif is changed from slave device to master vrf
device. Thus, flow offload does not find a match on the lower slave
device.

This patch uses the cached route, ie. dst->dev, to update the iif and
oif fields in the flow entry.

After this patch, the following example works fine:

 # ip addr add dev eth0 1.1.1.1/24
 # ip addr add dev eth1 10.0.0.1/24
 # ip link add user1 type vrf table 1
 # ip l set user1 up
 # ip l set dev eth0 master user1
 # ip l set dev eth1 master user1

 # nft add table firewall
 # nft add flowtable f fb1 { hook ingress priority 0 \; devices = { eth0, eth1 } \; }
 # nft add chain f ftb-all {type filter hook forward priority 0 \; policy accept \; }
 # nft add rule f ftb-all ct zone 1 ip protocol tcp flow offload @fb1
 # nft add rule f ftb-all ct zone 1 ip protocol udp flow offload @fb1

Signed-off-by: wenxu <wenxu@ucloud.cn>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/net/netfilter/nf_flow_table.h
net/netfilter/nf_flow_table_core.c
net/netfilter/nft_flow_offload.c