From 3d55122c4a9bab65e4e9652e72155d1e20b3d27d Mon Sep 17 00:00:00 2001 From: John Sanli Date: Tue, 20 Jun 2023 13:03:01 -0700 Subject: [PATCH 239/500] net: Correct FMR Calculation in Linux 6.1 Previously FMR calculation was set to only occur in ip4ip6_tnl_xmit() Linux 6.1 replaces this with ipxip6_tnl_xmit() There is one tnl_xmit function for both ipv4 and ipv6 in this kernel. This patch ensures FMR calculation is only performed in outbound direction. Change-Id: If36e1033be7f8b9fbea4e1d9a3664c1d8b41c666 Signed-off-by: John Sanli --- net/ipv6/ip6_tunnel.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c @@ -1540,17 +1540,19 @@ ipxip6_tnl_xmit(struct sk_buff *skb, str fl6.flowi6_uid = sock_net_uid(dev_net(dev), NULL); dsfield = INET_ECN_encapsulate(dsfield, orig_dsfield); - /* try to find matching FMR */ - for (fmr = t->parms.fmrs; fmr; fmr = fmr->next) { - unsigned mshift = 32 - fmr->ip4_prefix_len; - if (ntohl(fmr->ip4_prefix.s_addr) >> mshift == - ntohl(ip_hdr(skb)->daddr) >> mshift) - break; - } + if (protocol == IPPROTO_IPIP) { + /* try to find matching FMR */ + for (fmr = t->parms.fmrs; fmr; fmr = fmr->next) { + unsigned mshift = 32 - fmr->ip4_prefix_len; + if (ntohl(fmr->ip4_prefix.s_addr) >> mshift == + ntohl(ip_hdr(skb)->daddr) >> mshift) + break; + } - /* change dstaddr according to FMR */ - if (fmr) - ip4ip6_fmr_calc(&fl6.daddr, ip_hdr(skb), skb_tail_pointer(skb), fmr, true); + /* change dstaddr according to FMR */ + if (fmr) + ip4ip6_fmr_calc(&fl6.daddr, ip_hdr(skb), skb_tail_pointer(skb), fmr, true); + } if (iptunnel_handle_offloads(skb, SKB_GSO_IPXIP6)) return -1;