diff mbox series

[ovs-dev] datapath: Fix build errors for 4.9.172+ kernels

Message ID 1558396723-2843-1-git-send-email-pkusunyifeng@gmail.com
State Superseded
Headers show
Series [ovs-dev] datapath: Fix build errors for 4.9.172+ kernels | expand

Commit Message

Yifeng Sun May 20, 2019, 11:58 p.m. UTC
4.9.172+ kernel backported upstream patch 70b095c843266
("ipv6: remove dependency of nf_defrag_ipv6 on ipv6 module")
and this caused compilation errors of OVS kernel module.

This patch fixes it by checking and using new functions
introduced by the upstream patch.

Travis tests passed at
https://travis-ci.org/yifsun/ovs-travis/builds/535047469
with latest Linux kernel version.

Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
---
 datapath/linux/compat/nf_conntrack_reasm.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

Comments

Yifeng Sun May 21, 2019, 6:06 p.m. UTC | #1
Forgot to put reported-by.

Reported-by: Ilya Maximets <i.maximets@samsung.com>


On Mon, May 20, 2019 at 4:58 PM Yifeng Sun <pkusunyifeng@gmail.com> wrote:
>
> 4.9.172+ kernel backported upstream patch 70b095c843266
> ("ipv6: remove dependency of nf_defrag_ipv6 on ipv6 module")
> and this caused compilation errors of OVS kernel module.
>
> This patch fixes it by checking and using new functions
> introduced by the upstream patch.
>
> Travis tests passed at
> https://travis-ci.org/yifsun/ovs-travis/builds/535047469
> with latest Linux kernel version.
>
> Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
> ---
>  datapath/linux/compat/nf_conntrack_reasm.c | 22 +++++++++++++++++++++-
>  1 file changed, 21 insertions(+), 1 deletion(-)
>
> diff --git a/datapath/linux/compat/nf_conntrack_reasm.c b/datapath/linux/compat/nf_conntrack_reasm.c
> index 9d77d982712c..ac5ec6dd30ab 100644
> --- a/datapath/linux/compat/nf_conntrack_reasm.c
> +++ b/datapath/linux/compat/nf_conntrack_reasm.c
> @@ -41,6 +41,7 @@
>  #include <net/inet_frag.h>
>
>  #include <net/ipv6.h>
> +#include <net/ipv6_frag.h>
>  #include <net/protocol.h>
>  #include <net/transp_v6.h>
>  #include <net/rawv6.h>
> @@ -138,8 +139,12 @@ static void nf_ct_frag6_expire(unsigned long data)
>  #ifdef HAVE_INET_FRAGS_RND
>         ip6_expire_frag_queue(net, fq, &nf_frags);
>  #else
> +#ifdef HAVE_IPV6_FRAG_H
> +       ip6frag_expire_frag_queue(net, fq);
> +#else
>         ip6_expire_frag_queue(net, fq);
>  #endif
> +#endif /* HAVE_INET_FRAGS_RND */
>  }
>
>  #ifdef HAVE_INET_FRAGS_RND
> @@ -673,6 +678,16 @@ static struct pernet_operations nf_ct_net_ops = {
>         .exit = nf_ct_net_exit,
>  };
>
> +#ifdef HAVE_IPV6_FRAG_H
> +static const struct rhashtable_params nfct_rhash_params = {
> +       .head_offset            = offsetof(struct inet_frag_queue, node),
> +       .hashfn                 = ip6frag_key_hashfn,
> +       .obj_hashfn             = ip6frag_obj_hashfn,
> +       .obj_cmpfn              = ip6frag_obj_cmpfn,
> +       .automatic_shrinking    = true,
> +};
> +#endif
> +
>  int rpl_nf_ct_frag6_init(void)
>  {
>         int ret = 0;
> @@ -684,9 +699,14 @@ int rpl_nf_ct_frag6_init(void)
>         nf_frags.hashfn = nf_hashfn;
>         nf_frags.match = ip6_frag_match;
>  #else
> +#ifdef HAVE_IPV6_FRAG_H
> +       nf_frags.rhash_params = nfct_rhash_params;
> +       nf_frags.constructor = ip6frag_init;
> +#else
>         nf_frags.rhash_params = ip6_rhash_params;
> -#endif
>         nf_frags.constructor = ip6_frag_init;
> +#endif
> +#endif /* HAVE_INET_FRAGS_RND */
>         nf_frags.destructor = NULL;
>         nf_frags.qsize = sizeof(struct frag_queue);
>         nf_frags.frag_expire = nf_ct_frag6_expire;
> --
> 2.7.4
>
Yi-Hung Wei May 23, 2019, 8:55 p.m. UTC | #2
On Tue, May 21, 2019 at 11:07 AM Yifeng Sun <pkusunyifeng@gmail.com> wrote:
>
> Forgot to put reported-by.
>
> Reported-by: Ilya Maximets <i.maximets@samsung.com>
>
>
> On Mon, May 20, 2019 at 4:58 PM Yifeng Sun <pkusunyifeng@gmail.com> wrote:
> >
> > 4.9.172+ kernel backported upstream patch 70b095c843266
> > ("ipv6: remove dependency of nf_defrag_ipv6 on ipv6 module")
> > and this caused compilation errors of OVS kernel module.
> >
> > This patch fixes it by checking and using new functions
> > introduced by the upstream patch.
> >
> > Travis tests passed at
> > https://travis-ci.org/yifsun/ovs-travis/builds/535047469
> > with latest Linux kernel version.
> >
> > Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
> > ---

Hi Yifeng,

Thanks for the patch. It does resolve the kernel build issue on
4.9.172+ kernel. But it introduce some regression on this kmod system
traffic test ("60: conntrack - IPv6 fragmentation"). The following is
the stack trace of a kernel panic on my RHEL 7.4 VM with
3.10.0-693.11.6 kernel when running the test. I can also reproduce
that on my RHEL 7.3, 7.5, and Ubuntu 16.04 vm with older kernel
4.4.0-76. Can you help to check on that?

Thanks,

-Yi-Hung

[ 1205.692224] BUG: unable to handle kernel NULL pointer dereference
at           (null)
[ 1205.692475] IP: [<          (null)>]           (null)
[ 1205.692625] PGD 800000008ec2b067 PUD 8ec40067 PMD 0
[ 1205.692848] Oops: 0010 [#1] SMP
[ 1205.692996] Modules linked in: vport_vxlan(OE) vport_stt(OE)
vport_lisp(OE) vport_geneve(OE) openvswitch(OE) tunnel6 nf_nat_ipv6
nf_nat_ipv4 nf_nat_tftp nf_conntrack_tftp nf_nat_ftp nf_conntrack_ftp
nf_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_conntrack_ipv4
nf_defrag_ipv4 nf_conntrack_netlink nfnetlink veth nf_conntrack
netconsole vmw_vsock_vmci_transport vsock snd_seq_midi
snd_seq_midi_event iosf_mbi crc32_pclmul ghash_clmulni_intel ppdev
aesni_intel lrw gf128mul glue_helper ablk_helper cryptd vmw_balloon
snd_ens1371 pcspkr joydev snd_rawmidi snd_ac97_codec ac97_bus snd_seq
btusb btrtl btbcm btintel snd_seq_device bluetooth snd_pcm uvcvideo
videobuf2_vmalloc videobuf2_memops videobuf2_core snd_timer videodev
snd sg soundcore nfit vmw_vmci rfkill libnvdimm i2c_piix4 shpchp
parport_pc parport ip_tables xfs libcrc32c sr_mod cdrom ata_generic
pata_acpi vmwgfx sd_mod crc_t10dif crct10dif_generic drm_kms_helper
syscopyarea crct10dif_pclmul crct10dif_common sysfillrect crc32c_intel
sysimgblt fb_sys_fops ttm ahci libahci drm serio_raw ata_piix mptspi
libata scsi_transport_spi e1000 mptscsih mptbase i2c_core dm_mirror
dm_region_hash dm_log dm_mod [last unloaded: nf_defrag_ipv4]
[ 1205.698388] CPU: 0 PID: 24995 Comm: handler1 Tainted: G
OE  ------------   3.10.0-693.11.6.el7.x86_64 #1
[ 1205.698553] Hardware name: VMware, Inc. VMware Virtual
Platform/440BX Desktop Reference Platform, BIOS 6.00 05/19/2017
[ 1205.698754] task: ffff88013694eeb0 ti: ffff880092b90000 task.ti:
ffff880092b90000
[ 1205.698888] RIP: 0010:[<0000000000000000>]  [<          (null)>]
       (null)
[ 1205.699179] RSP: 0018:ffff880092b93628  EFLAGS: 00010286
[ 1205.703437] RAX: ffff880092885100 RBX: ffffffffc06aeb40 RCX: 0000000000000000
[ 1205.707960] RDX: 0000000000000000 RSI: ffff880092b936a8 RDI: ffff880092885100
[ 1205.712422] RBP: ffff880092b93678 R08: 000000000001b980 R09: 0000000000000000
[ 1205.716603] R10: ffff880092885100 R11: 0000000026dc0df7 R12: ffff880092a4f500
[ 1205.720941] R13: ffffffffc06b2b40 R14: ffffffffc06af3a8 R15: ffff880092885100
[ 1205.725137] FS:  00007efc826f4700(0000) GS:ffff880139600000(0000)
knlGS:0000000000000000
[ 1205.729200] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 1205.734162] CR2: 0000000000000000 CR3: 00000000928bc000 CR4: 00000000001607f0
[ 1205.738677] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 1205.744574] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
[ 1205.749340] Call Trace:
[ 1205.753257]  [<ffffffff81616191>] ? inet_frag_find+0x101/0x2f0
[ 1205.757449]  [<ffffffffc06993a1>]
rpl_nf_ct_frag6_gather+0x2e1/0xd30 [openvswitch]
[ 1205.761476]  [<ffffffffc0673292>] ovs_ct_execute+0x3a2/0xa10 [openvswitch]
[ 1205.765509]  [<ffffffffc067e0d1>] ? __add_action+0x71/0x80 [openvswitch]
[ 1205.769486]  [<ffffffffc067fd62>] ? ovs_nla_add_action+0x12/0x30
[openvswitch]
[ 1205.773421]  [<ffffffffc06741de>] ? ovs_ct_copy_action+0x7fe/0xb80
[openvswitch]
[ 1205.777285]  [<ffffffffc06708f2>] do_execute_actions+0x862/0xcb0
[openvswitch]
[ 1205.781506]  [<ffffffffc067df64>] ? reserve_sfa_size+0x34/0x130 [openvswitch]
[ 1205.785716]  [<ffffffffc06808c8>] ?
__ovs_nla_copy_actions+0x188/0xaa0 [openvswitch]
[ 1205.789952]  [<ffffffff815759ad>] ? __alloc_skb+0x8d/0x2d0
[ 1205.794109]  [<ffffffff81574801>] ? skb_tx_error+0x31/0x50
[ 1205.799056]  [<ffffffff8157597d>] ? __alloc_skb+0x5d/0x2d0
[ 1205.803200]  [<ffffffff811e23d5>] ? __kmalloc+0x55/0x230
[ 1205.807333]  [<ffffffffc067dee3>] ?
nla_alloc_flow_actions+0x23/0x70 [openvswitch]
[ 1205.811574]  [<ffffffffc0670f8c>] ovs_execute_actions+0x4c/0x140
[openvswitch]
[ 1205.815642]  [<ffffffffc0677a7b>]
ovs_packet_cmd_execute+0x2cb/0x300 [openvswitch]
[ 1205.819749]  [<ffffffff815c173a>] genl_family_rcv_msg+0x20a/0x430
[ 1205.823684]  [<ffffffff815c1960>] ? genl_family_rcv_msg+0x430/0x430
[ 1205.827724]  [<ffffffff815c19f1>] genl_rcv_msg+0x91/0xd0
[ 1205.831652]  [<ffffffff815bf969>] netlink_rcv_skb+0xa9/0xc0
[ 1205.835506]  [<ffffffff815bfe98>] genl_rcv+0x28/0x40
[ 1205.839493]  [<ffffffff815bf052>] netlink_unicast+0xf2/0x1b0
[ 1205.843256]  [<ffffffff815bf42f>] netlink_sendmsg+0x31f/0x6a0
[ 1205.847293]  [<ffffffff812b6f25>] ? sock_has_perm+0x75/0x90
[ 1205.850982]  [<ffffffff8156c580>] sock_sendmsg+0xb0/0xf0
[ 1205.854562]  [<ffffffff81207e22>] ? chrdev_open+0xb2/0x1b0
[ 1205.858070]  [<ffffffff8156ce29>] ___sys_sendmsg+0x3a9/0x3c0
[ 1205.862165]  [<ffffffff8119320e>] ? lru_cache_add+0xe/0x10
[ 1205.865334]  [<ffffffff811be298>] ? page_add_new_anon_rmap+0xb8/0x170
[ 1205.868365]  [<ffffffff811b3f98>] ? handle_mm_fault+0x858/0xfa0
[ 1205.871567]  [<ffffffff8124d983>] ? ep_poll+0x123/0x360
[ 1205.875485]  [<ffffffff8156d5f1>] __sys_sendmsg+0x51/0x90
[ 1205.879731]  [<ffffffff8156d642>] SyS_sendmsg+0x12/0x20
[ 1205.882434]  [<ffffffff816b89fd>] system_call_fastpath+0x16/0x1b
Yifeng Sun May 23, 2019, 8:57 p.m. UTC | #3
Thanks YiHung, I will check it out.
Yifeng

On Thu, May 23, 2019 at 1:55 PM Yi-Hung Wei <yihung.wei@gmail.com> wrote:
>
> On Tue, May 21, 2019 at 11:07 AM Yifeng Sun <pkusunyifeng@gmail.com> wrote:
> >
> > Forgot to put reported-by.
> >
> > Reported-by: Ilya Maximets <i.maximets@samsung.com>
> >
> >
> > On Mon, May 20, 2019 at 4:58 PM Yifeng Sun <pkusunyifeng@gmail.com> wrote:
> > >
> > > 4.9.172+ kernel backported upstream patch 70b095c843266
> > > ("ipv6: remove dependency of nf_defrag_ipv6 on ipv6 module")
> > > and this caused compilation errors of OVS kernel module.
> > >
> > > This patch fixes it by checking and using new functions
> > > introduced by the upstream patch.
> > >
> > > Travis tests passed at
> > > https://travis-ci.org/yifsun/ovs-travis/builds/535047469
> > > with latest Linux kernel version.
> > >
> > > Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
> > > ---
>
> Hi Yifeng,
>
> Thanks for the patch. It does resolve the kernel build issue on
> 4.9.172+ kernel. But it introduce some regression on this kmod system
> traffic test ("60: conntrack - IPv6 fragmentation"). The following is
> the stack trace of a kernel panic on my RHEL 7.4 VM with
> 3.10.0-693.11.6 kernel when running the test. I can also reproduce
> that on my RHEL 7.3, 7.5, and Ubuntu 16.04 vm with older kernel
> 4.4.0-76. Can you help to check on that?
>
> Thanks,
>
> -Yi-Hung
>
> [ 1205.692224] BUG: unable to handle kernel NULL pointer dereference
> at           (null)
> [ 1205.692475] IP: [<          (null)>]           (null)
> [ 1205.692625] PGD 800000008ec2b067 PUD 8ec40067 PMD 0
> [ 1205.692848] Oops: 0010 [#1] SMP
> [ 1205.692996] Modules linked in: vport_vxlan(OE) vport_stt(OE)
> vport_lisp(OE) vport_geneve(OE) openvswitch(OE) tunnel6 nf_nat_ipv6
> nf_nat_ipv4 nf_nat_tftp nf_conntrack_tftp nf_nat_ftp nf_conntrack_ftp
> nf_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_conntrack_ipv4
> nf_defrag_ipv4 nf_conntrack_netlink nfnetlink veth nf_conntrack
> netconsole vmw_vsock_vmci_transport vsock snd_seq_midi
> snd_seq_midi_event iosf_mbi crc32_pclmul ghash_clmulni_intel ppdev
> aesni_intel lrw gf128mul glue_helper ablk_helper cryptd vmw_balloon
> snd_ens1371 pcspkr joydev snd_rawmidi snd_ac97_codec ac97_bus snd_seq
> btusb btrtl btbcm btintel snd_seq_device bluetooth snd_pcm uvcvideo
> videobuf2_vmalloc videobuf2_memops videobuf2_core snd_timer videodev
> snd sg soundcore nfit vmw_vmci rfkill libnvdimm i2c_piix4 shpchp
> parport_pc parport ip_tables xfs libcrc32c sr_mod cdrom ata_generic
> pata_acpi vmwgfx sd_mod crc_t10dif crct10dif_generic drm_kms_helper
> syscopyarea crct10dif_pclmul crct10dif_common sysfillrect crc32c_intel
> sysimgblt fb_sys_fops ttm ahci libahci drm serio_raw ata_piix mptspi
> libata scsi_transport_spi e1000 mptscsih mptbase i2c_core dm_mirror
> dm_region_hash dm_log dm_mod [last unloaded: nf_defrag_ipv4]
> [ 1205.698388] CPU: 0 PID: 24995 Comm: handler1 Tainted: G
> OE  ------------   3.10.0-693.11.6.el7.x86_64 #1
> [ 1205.698553] Hardware name: VMware, Inc. VMware Virtual
> Platform/440BX Desktop Reference Platform, BIOS 6.00 05/19/2017
> [ 1205.698754] task: ffff88013694eeb0 ti: ffff880092b90000 task.ti:
> ffff880092b90000
> [ 1205.698888] RIP: 0010:[<0000000000000000>]  [<          (null)>]
>        (null)
> [ 1205.699179] RSP: 0018:ffff880092b93628  EFLAGS: 00010286
> [ 1205.703437] RAX: ffff880092885100 RBX: ffffffffc06aeb40 RCX: 0000000000000000
> [ 1205.707960] RDX: 0000000000000000 RSI: ffff880092b936a8 RDI: ffff880092885100
> [ 1205.712422] RBP: ffff880092b93678 R08: 000000000001b980 R09: 0000000000000000
> [ 1205.716603] R10: ffff880092885100 R11: 0000000026dc0df7 R12: ffff880092a4f500
> [ 1205.720941] R13: ffffffffc06b2b40 R14: ffffffffc06af3a8 R15: ffff880092885100
> [ 1205.725137] FS:  00007efc826f4700(0000) GS:ffff880139600000(0000)
> knlGS:0000000000000000
> [ 1205.729200] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [ 1205.734162] CR2: 0000000000000000 CR3: 00000000928bc000 CR4: 00000000001607f0
> [ 1205.738677] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> [ 1205.744574] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
> [ 1205.749340] Call Trace:
> [ 1205.753257]  [<ffffffff81616191>] ? inet_frag_find+0x101/0x2f0
> [ 1205.757449]  [<ffffffffc06993a1>]
> rpl_nf_ct_frag6_gather+0x2e1/0xd30 [openvswitch]
> [ 1205.761476]  [<ffffffffc0673292>] ovs_ct_execute+0x3a2/0xa10 [openvswitch]
> [ 1205.765509]  [<ffffffffc067e0d1>] ? __add_action+0x71/0x80 [openvswitch]
> [ 1205.769486]  [<ffffffffc067fd62>] ? ovs_nla_add_action+0x12/0x30
> [openvswitch]
> [ 1205.773421]  [<ffffffffc06741de>] ? ovs_ct_copy_action+0x7fe/0xb80
> [openvswitch]
> [ 1205.777285]  [<ffffffffc06708f2>] do_execute_actions+0x862/0xcb0
> [openvswitch]
> [ 1205.781506]  [<ffffffffc067df64>] ? reserve_sfa_size+0x34/0x130 [openvswitch]
> [ 1205.785716]  [<ffffffffc06808c8>] ?
> __ovs_nla_copy_actions+0x188/0xaa0 [openvswitch]
> [ 1205.789952]  [<ffffffff815759ad>] ? __alloc_skb+0x8d/0x2d0
> [ 1205.794109]  [<ffffffff81574801>] ? skb_tx_error+0x31/0x50
> [ 1205.799056]  [<ffffffff8157597d>] ? __alloc_skb+0x5d/0x2d0
> [ 1205.803200]  [<ffffffff811e23d5>] ? __kmalloc+0x55/0x230
> [ 1205.807333]  [<ffffffffc067dee3>] ?
> nla_alloc_flow_actions+0x23/0x70 [openvswitch]
> [ 1205.811574]  [<ffffffffc0670f8c>] ovs_execute_actions+0x4c/0x140
> [openvswitch]
> [ 1205.815642]  [<ffffffffc0677a7b>]
> ovs_packet_cmd_execute+0x2cb/0x300 [openvswitch]
> [ 1205.819749]  [<ffffffff815c173a>] genl_family_rcv_msg+0x20a/0x430
> [ 1205.823684]  [<ffffffff815c1960>] ? genl_family_rcv_msg+0x430/0x430
> [ 1205.827724]  [<ffffffff815c19f1>] genl_rcv_msg+0x91/0xd0
> [ 1205.831652]  [<ffffffff815bf969>] netlink_rcv_skb+0xa9/0xc0
> [ 1205.835506]  [<ffffffff815bfe98>] genl_rcv+0x28/0x40
> [ 1205.839493]  [<ffffffff815bf052>] netlink_unicast+0xf2/0x1b0
> [ 1205.843256]  [<ffffffff815bf42f>] netlink_sendmsg+0x31f/0x6a0
> [ 1205.847293]  [<ffffffff812b6f25>] ? sock_has_perm+0x75/0x90
> [ 1205.850982]  [<ffffffff8156c580>] sock_sendmsg+0xb0/0xf0
> [ 1205.854562]  [<ffffffff81207e22>] ? chrdev_open+0xb2/0x1b0
> [ 1205.858070]  [<ffffffff8156ce29>] ___sys_sendmsg+0x3a9/0x3c0
> [ 1205.862165]  [<ffffffff8119320e>] ? lru_cache_add+0xe/0x10
> [ 1205.865334]  [<ffffffff811be298>] ? page_add_new_anon_rmap+0xb8/0x170
> [ 1205.868365]  [<ffffffff811b3f98>] ? handle_mm_fault+0x858/0xfa0
> [ 1205.871567]  [<ffffffff8124d983>] ? ep_poll+0x123/0x360
> [ 1205.875485]  [<ffffffff8156d5f1>] __sys_sendmsg+0x51/0x90
> [ 1205.879731]  [<ffffffff8156d642>] SyS_sendmsg+0x12/0x20
> [ 1205.882434]  [<ffffffff816b89fd>] system_call_fastpath+0x16/0x1b
diff mbox series

Patch

diff --git a/datapath/linux/compat/nf_conntrack_reasm.c b/datapath/linux/compat/nf_conntrack_reasm.c
index 9d77d982712c..ac5ec6dd30ab 100644
--- a/datapath/linux/compat/nf_conntrack_reasm.c
+++ b/datapath/linux/compat/nf_conntrack_reasm.c
@@ -41,6 +41,7 @@ 
 #include <net/inet_frag.h>
 
 #include <net/ipv6.h>
+#include <net/ipv6_frag.h>
 #include <net/protocol.h>
 #include <net/transp_v6.h>
 #include <net/rawv6.h>
@@ -138,8 +139,12 @@  static void nf_ct_frag6_expire(unsigned long data)
 #ifdef HAVE_INET_FRAGS_RND
 	ip6_expire_frag_queue(net, fq, &nf_frags);
 #else
+#ifdef HAVE_IPV6_FRAG_H
+	ip6frag_expire_frag_queue(net, fq);
+#else
 	ip6_expire_frag_queue(net, fq);
 #endif
+#endif /* HAVE_INET_FRAGS_RND */
 }
 
 #ifdef HAVE_INET_FRAGS_RND
@@ -673,6 +678,16 @@  static struct pernet_operations nf_ct_net_ops = {
 	.exit = nf_ct_net_exit,
 };
 
+#ifdef HAVE_IPV6_FRAG_H
+static const struct rhashtable_params nfct_rhash_params = {
+	.head_offset		= offsetof(struct inet_frag_queue, node),
+	.hashfn			= ip6frag_key_hashfn,
+	.obj_hashfn		= ip6frag_obj_hashfn,
+	.obj_cmpfn		= ip6frag_obj_cmpfn,
+	.automatic_shrinking	= true,
+};
+#endif
+
 int rpl_nf_ct_frag6_init(void)
 {
 	int ret = 0;
@@ -684,9 +699,14 @@  int rpl_nf_ct_frag6_init(void)
 	nf_frags.hashfn = nf_hashfn;
 	nf_frags.match = ip6_frag_match;
 #else
+#ifdef HAVE_IPV6_FRAG_H
+	nf_frags.rhash_params = nfct_rhash_params;
+	nf_frags.constructor = ip6frag_init;
+#else
 	nf_frags.rhash_params = ip6_rhash_params;
-#endif
 	nf_frags.constructor = ip6_frag_init;
+#endif
+#endif /* HAVE_INET_FRAGS_RND */
 	nf_frags.destructor = NULL;
 	nf_frags.qsize = sizeof(struct frag_queue);
 	nf_frags.frag_expire = nf_ct_frag6_expire;