netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH nf-next 1/2] netfilter: flowtable: fix nft_flow_route miss FLOWI_FLAG_ANYSRC flag
@ 2022-05-26  1:25 wenxu
  2022-05-26  1:25 ` [PATCH nf-next 2/2] netfilter: flowtable: fix nft_flow_route use saddr for nat case wenxu
  2022-05-31 21:34 ` [PATCH nf-next 1/2] netfilter: flowtable: fix nft_flow_route miss FLOWI_FLAG_ANYSRC flag Pablo Neira Ayuso
  0 siblings, 2 replies; 4+ messages in thread
From: wenxu @ 2022-05-26  1:25 UTC (permalink / raw)
  To: pablo, sven.auhagen; +Cc: netfilter-devel, wenxu

From: wenxu <wenxu@chinatelecom.cn>

The nf_flow_tabel get route through ip_route_output_key.
When the saddr is not local one, the FLOWI_FLAG_ANYSRC
flag should be setten. Without this flag, the route lookup
for other_dst will failed.

Fixes: 3412e1641828 (netfilter: flowtable: nft_flow_route use more data for reverse route)
Signed-off-by: wenxu <wenxu@chinatelecom.cn>
---
 net/netfilter/nft_flow_offload.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/netfilter/nft_flow_offload.c b/net/netfilter/nft_flow_offload.c
index a16cf47..20e5f37 100644
--- a/net/netfilter/nft_flow_offload.c
+++ b/net/netfilter/nft_flow_offload.c
@@ -237,6 +237,7 @@ static int nft_flow_route(const struct nft_pktinfo *pkt,
 		fl.u.ip4.flowi4_iif = this_dst->dev->ifindex;
 		fl.u.ip4.flowi4_tos = RT_TOS(ip_hdr(pkt->skb)->tos);
 		fl.u.ip4.flowi4_mark = pkt->skb->mark;
+		fl.u.ip4.flowi4_flags = FLOWI_FLAG_ANYSRC;
 		break;
 	case NFPROTO_IPV6:
 		fl.u.ip6.daddr = ct->tuplehash[dir].tuple.src.u3.in6;
@@ -245,6 +246,7 @@ static int nft_flow_route(const struct nft_pktinfo *pkt,
 		fl.u.ip6.flowi6_iif = this_dst->dev->ifindex;
 		fl.u.ip6.flowlabel = ip6_flowinfo(ipv6_hdr(pkt->skb));
 		fl.u.ip6.flowi6_mark = pkt->skb->mark;
+		fl.u.ip6.flowi6_flags = FLOWI_FLAG_ANYSRC;
 		break;
 	}
 
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH nf-next 2/2] netfilter: flowtable: fix nft_flow_route use saddr for nat case
  2022-05-26  1:25 [PATCH nf-next 1/2] netfilter: flowtable: fix nft_flow_route miss FLOWI_FLAG_ANYSRC flag wenxu
@ 2022-05-26  1:25 ` wenxu
  2022-05-31 21:34   ` Pablo Neira Ayuso
  2022-05-31 21:34 ` [PATCH nf-next 1/2] netfilter: flowtable: fix nft_flow_route miss FLOWI_FLAG_ANYSRC flag Pablo Neira Ayuso
  1 sibling, 1 reply; 4+ messages in thread
From: wenxu @ 2022-05-26  1:25 UTC (permalink / raw)
  To: pablo, sven.auhagen; +Cc: netfilter-devel, wenxu

From: wenxu <wenxu@chinatelecom.cn>

For snat and dnat case the saddr should get from reverse tuple.

Fixes: 3412e1641828 (netfilter: flowtable: nft_flow_route use more data for reverse route)
Signed-off-by: wenxu <wenxu@chinatelecom.cn>
---
 net/netfilter/nft_flow_offload.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/netfilter/nft_flow_offload.c b/net/netfilter/nft_flow_offload.c
index 20e5f37..a25c88b 100644
--- a/net/netfilter/nft_flow_offload.c
+++ b/net/netfilter/nft_flow_offload.c
@@ -232,7 +232,7 @@ static int nft_flow_route(const struct nft_pktinfo *pkt,
 	switch (nft_pf(pkt)) {
 	case NFPROTO_IPV4:
 		fl.u.ip4.daddr = ct->tuplehash[dir].tuple.src.u3.ip;
-		fl.u.ip4.saddr = ct->tuplehash[dir].tuple.dst.u3.ip;
+		fl.u.ip4.saddr = ct->tuplehash[!dir].tuple.src.u3.ip;
 		fl.u.ip4.flowi4_oif = nft_in(pkt)->ifindex;
 		fl.u.ip4.flowi4_iif = this_dst->dev->ifindex;
 		fl.u.ip4.flowi4_tos = RT_TOS(ip_hdr(pkt->skb)->tos);
@@ -241,7 +241,7 @@ static int nft_flow_route(const struct nft_pktinfo *pkt,
 		break;
 	case NFPROTO_IPV6:
 		fl.u.ip6.daddr = ct->tuplehash[dir].tuple.src.u3.in6;
-		fl.u.ip6.saddr = ct->tuplehash[dir].tuple.dst.u3.in6;
+		fl.u.ip6.saddr = ct->tuplehash[!dir].tuple.src.u3.in6;
 		fl.u.ip6.flowi6_oif = nft_in(pkt)->ifindex;
 		fl.u.ip6.flowi6_iif = this_dst->dev->ifindex;
 		fl.u.ip6.flowlabel = ip6_flowinfo(ipv6_hdr(pkt->skb));
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH nf-next 1/2] netfilter: flowtable: fix nft_flow_route miss FLOWI_FLAG_ANYSRC flag
  2022-05-26  1:25 [PATCH nf-next 1/2] netfilter: flowtable: fix nft_flow_route miss FLOWI_FLAG_ANYSRC flag wenxu
  2022-05-26  1:25 ` [PATCH nf-next 2/2] netfilter: flowtable: fix nft_flow_route use saddr for nat case wenxu
@ 2022-05-31 21:34 ` Pablo Neira Ayuso
  1 sibling, 0 replies; 4+ messages in thread
From: Pablo Neira Ayuso @ 2022-05-31 21:34 UTC (permalink / raw)
  To: wenxu; +Cc: sven.auhagen, netfilter-devel

Applied to nf, thanks

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH nf-next 2/2] netfilter: flowtable: fix nft_flow_route use saddr for nat case
  2022-05-26  1:25 ` [PATCH nf-next 2/2] netfilter: flowtable: fix nft_flow_route use saddr for nat case wenxu
@ 2022-05-31 21:34   ` Pablo Neira Ayuso
  0 siblings, 0 replies; 4+ messages in thread
From: Pablo Neira Ayuso @ 2022-05-31 21:34 UTC (permalink / raw)
  To: wenxu; +Cc: sven.auhagen, netfilter-devel

Also applied.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-31 21:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-26  1:25 [PATCH nf-next 1/2] netfilter: flowtable: fix nft_flow_route miss FLOWI_FLAG_ANYSRC flag wenxu
2022-05-26  1:25 ` [PATCH nf-next 2/2] netfilter: flowtable: fix nft_flow_route use saddr for nat case wenxu
2022-05-31 21:34   ` Pablo Neira Ayuso
2022-05-31 21:34 ` [PATCH nf-next 1/2] netfilter: flowtable: fix nft_flow_route miss FLOWI_FLAG_ANYSRC flag Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).