Skip to content

Commit adfc631

Browse files
committed
Fix compilation for 5.9: workaround ref_module unexport
compat.h:173:21: error: implicit declaration of function ‘ref_module’ [-Werror=implicit-function-declaration] # define use_module ref_module ^ ipt_NETFLOW.c:5488:3: note: in expansion of macro ‘use_module’ use_module(THIS_MODULE, netlink_m); ^~~~~~~~~~ Fixes #153. Reported-by: https://github.com/rcmcronny
1 parent 1153f73 commit adfc631

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

ipt_NETFLOW.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5459,13 +5459,12 @@ static struct pernet_operations natevents_net_ops = {
54595459
#endif /* since 2.6.31 */
54605460

54615461
static DEFINE_MUTEX(events_lock);
5462+
static struct module *netlink_m;
54625463
/* Both functions may be called multiple times. */
54635464
static void register_ct_events(void)
54645465
{
54655466
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)
54665467
#define NETLINK_M "nf_conntrack_netlink"
5467-
struct module *netlink_m;
5468-
static int referenced = 0;
54695468
#endif
54705469

54715470
printk(KERN_INFO "ipt_NETFLOW: enable natevents.\n");
@@ -5478,14 +5477,19 @@ static void register_ct_events(void)
54785477
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0)
54795478
!rcu_dereference(nf_conntrack_event_cb) ||
54805479
#endif
5481-
!(netlink_m = find_module(NETLINK_M))) {
5480+
!find_module(NETLINK_M)) {
54825481
printk("Loading " NETLINK_M "\n");
54835482
request_module(NETLINK_M);
5483+
54845484
}
54855485
/* Reference netlink module to prevent it's unsafe unload before us. */
5486-
if (!referenced && (netlink_m = find_module(NETLINK_M))) {
5487-
referenced++;
5486+
if (!netlink_m && (netlink_m = find_module(NETLINK_M))) {
5487+
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,9,0)
54885488
use_module(THIS_MODULE, netlink_m);
5489+
#else
5490+
if (!try_module_get(netlink_m))
5491+
netlink_m = NULL;
5492+
#endif
54895493
}
54905494

54915495
/* Register ct events callback. */
@@ -5513,6 +5517,10 @@ static void unregister_ct_events(void)
55135517
#else /* < v3.2 */
55145518
unset_notifier_cb();
55155519
#endif /* v3.2 */
5520+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,0)
5521+
module_put(netlink_m);
5522+
netlink_m = NULL;
5523+
#endif
55165524
rcu_assign_pointer(saved_event_cb, NULL);
55175525
#else /* < v2.6.31 */
55185526
nf_conntrack_unregister_notifier(&ctnl_notifier);

0 commit comments

Comments
 (0)