Skip to content

Commit 098e13f

Browse files
whispererindarknessummakynes
authored andcommitted
ipvs: fix dependency on nf_defrag_ipv6
ipvs relies on nf_defrag_ipv6 module to manage IPv6 fragmentation, but lacks proper Kconfig dependencies and does not explicitly request defrag features. As a result, if netfilter hooks are not loaded, when IPv6 fragmented packet are handled by ipvs only the first fragment makes through. Fix it properly declaring the dependency on Kconfig and registering netfilter hooks on ip_vs_add_service() and ip_vs_new_dest(). Reported-by: Li Shuang <shuali@redhat.com> Signed-off-by: Andrea Claudi <aclaudi@redhat.com> Acked-by: Julian Anastasov <ja@ssi.bg> Acked-by: Simon Horman <horms@verge.net.au> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 8d29d16 commit 098e13f

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

net/netfilter/ipvs/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ config IP_VS_IPV6
2929
bool "IPv6 support for IPVS"
3030
depends on IPV6 = y || IP_VS = IPV6
3131
select IP6_NF_IPTABLES
32+
select NF_DEFRAG_IPV6
3233
---help---
3334
Add IPv6 support to IPVS.
3435

net/netfilter/ipvs/ip_vs_core.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,14 +1536,12 @@ ip_vs_try_to_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,
15361536
/* sorry, all this trouble for a no-hit :) */
15371537
IP_VS_DBG_PKT(12, af, pp, skb, iph->off,
15381538
"ip_vs_in: packet continues traversal as normal");
1539-
if (iph->fragoffs) {
1540-
/* Fragment that couldn't be mapped to a conn entry
1541-
* is missing module nf_defrag_ipv6
1542-
*/
1543-
IP_VS_DBG_RL("Unhandled frag, load nf_defrag_ipv6\n");
1539+
1540+
/* Fragment couldn't be mapped to a conn entry */
1541+
if (iph->fragoffs)
15441542
IP_VS_DBG_PKT(7, af, pp, skb, iph->off,
15451543
"unhandled fragment");
1546-
}
1544+
15471545
*verdict = NF_ACCEPT;
15481546
return 0;
15491547
}

net/netfilter/ipvs/ip_vs_ctl.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#ifdef CONFIG_IP_VS_IPV6
4444
#include <net/ipv6.h>
4545
#include <net/ip6_route.h>
46+
#include <net/netfilter/ipv6/nf_defrag_ipv6.h>
4647
#endif
4748
#include <net/route.h>
4849
#include <net/sock.h>
@@ -895,6 +896,7 @@ ip_vs_new_dest(struct ip_vs_service *svc, struct ip_vs_dest_user_kern *udest,
895896
{
896897
struct ip_vs_dest *dest;
897898
unsigned int atype, i;
899+
int ret = 0;
898900

899901
EnterFunction(2);
900902

@@ -905,6 +907,10 @@ ip_vs_new_dest(struct ip_vs_service *svc, struct ip_vs_dest_user_kern *udest,
905907
atype & IPV6_ADDR_LINKLOCAL) &&
906908
!__ip_vs_addr_is_local_v6(svc->ipvs->net, &udest->addr.in6))
907909
return -EINVAL;
910+
911+
ret = nf_defrag_ipv6_enable(svc->ipvs->net);
912+
if (ret)
913+
return ret;
908914
} else
909915
#endif
910916
{
@@ -1228,6 +1234,10 @@ ip_vs_add_service(struct netns_ipvs *ipvs, struct ip_vs_service_user_kern *u,
12281234
ret = -EINVAL;
12291235
goto out_err;
12301236
}
1237+
1238+
ret = nf_defrag_ipv6_enable(ipvs->net);
1239+
if (ret)
1240+
goto out_err;
12311241
}
12321242
#endif
12331243

0 commit comments

Comments
 (0)