From: wenxu <wenxu@xxxxxxxxx> Add dst_neigh_lookup support for ipv6 Fixes: 5c27d8d76ce8 ("netfilter: nf_flow_table_offload: add IPv6 support") Signed-off-by: wenxu <wenxu@xxxxxxxxx> --- net/netfilter/nf_flow_table_offload.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/net/netfilter/nf_flow_table_offload.c b/net/netfilter/nf_flow_table_offload.c index aa40d58..2ce6001 100644 --- a/net/netfilter/nf_flow_table_offload.c +++ b/net/netfilter/nf_flow_table_offload.c @@ -164,20 +164,26 @@ static int flow_offload_eth_src(struct net *net, static int flow_offload_eth_dst(struct net *net, const struct flow_offload *flow, enum flow_offload_tuple_dir dir, - struct nf_flow_rule *flow_rule) + struct nf_flow_rule *flow_rule, + bool ipv6) { - const struct in_addr *dst_addr_v4 = &flow->tuplehash[!dir].tuple.src_v4; struct flow_action_entry *entry0 = flow_action_entry_next(flow_rule); struct flow_action_entry *entry1 = flow_action_entry_next(flow_rule); const struct dst_entry *dst_cache; unsigned char ha[ETH_ALEN]; struct neighbour *n; + const void *daddr; u32 mask, val; u8 nud_state; u16 val16; dst_cache = flow->tuplehash[dir].tuple.dst_cache; - n = dst_neigh_lookup(dst_cache, dst_addr_v4); + if (ipv6) + daddr = &flow->tuplehash[!dir].tuple.src_v6; + else + daddr = &flow->tuplehash[!dir].tuple.src_v4; + + n = dst_neigh_lookup(dst_cache, daddr); if (!n) return -ENOENT; @@ -431,7 +437,7 @@ int nf_flow_rule_route_ipv4(struct net *net, const struct flow_offload *flow, struct nf_flow_rule *flow_rule) { if (flow_offload_eth_src(net, flow, dir, flow_rule) < 0 || - flow_offload_eth_dst(net, flow, dir, flow_rule) < 0) + flow_offload_eth_dst(net, flow, dir, flow_rule, true) < 0) return -1; if (flow->flags & FLOW_OFFLOAD_SNAT) { @@ -457,7 +463,7 @@ int nf_flow_rule_route_ipv6(struct net *net, const struct flow_offload *flow, struct nf_flow_rule *flow_rule) { if (flow_offload_eth_src(net, flow, dir, flow_rule) < 0 || - flow_offload_eth_dst(net, flow, dir, flow_rule) < 0) + flow_offload_eth_dst(net, flow, dir, flow_rule, false) < 0) return -1; if (flow->flags & FLOW_OFFLOAD_SNAT) { -- 1.8.3.1