From f369bf27b2a56f2631746941f5dbe28d12a66fe9 Mon Sep 17 00:00:00 2001 From: Nils Nieuwejaar Date: Tue, 3 Mar 2020 11:14:55 -0800 Subject: [PATCH] Only allocate ifindex_map[] slot on device registration --- kernel/pf_ring.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/kernel/pf_ring.c b/kernel/pf_ring.c index 85eeb44b77..61bac39c01 100644 --- a/kernel/pf_ring.c +++ b/kernel/pf_ring.c @@ -8404,14 +8404,6 @@ static int ring_notifier(struct notifier_block *this, unsigned long msg, void *d return NOTIFY_DONE; } - dev_index = map_ifindex(dev->ifindex); - - if(dev_index < 0) { - printk("[PF_RING] %s %s: unable to map interface index %d\n", __FUNCTION__, - dev->name, dev->ifindex); - return NOTIFY_DONE; - } - switch (msg) { case NETDEV_POST_INIT: case NETDEV_PRE_UP: @@ -8421,6 +8413,13 @@ static int ring_notifier(struct notifier_block *this, unsigned long msg, void *d case NETDEV_REGISTER: debug_printk(2, "%s: [REGISTER][ifindex: %u]\n", dev->name, dev->ifindex); + dev_index = map_ifindex(dev->ifindex); + if(dev_index < 0) { + printk("[PF_RING] %s %s: unable to map interface index %d\n", __FUNCTION__, + dev->name, dev->ifindex); + break; + } + /* safety check */ list_for_each_safe(ptr, tmp_ptr, &ring_aware_device_list) { dev_ptr = list_entry(ptr, pf_ring_device, device_list);