]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
netmap: refresh netmap_if address after each NIOCREGIF
authorMurat Balaban <murat@sunnyvalley.io>
Wed, 27 Feb 2019 17:09:13 +0000 (09:09 -0800)
committerVictor Julien <victor@inliniac.net>
Thu, 7 Mar 2019 07:41:49 +0000 (08:41 +0100)
With the introduction of netmap "partial opening" feature
netmap requires that we get a new NETMAP_IF pointer after
every `NIOCREGIF` registration. Because this allocates an
independent instance of `struct netmap_if`. If one
separately opens hw rings and sw rings he/she'll get two
`struct netmap_if`, one with the valid hw rings, and the other
with valid sw rings.

Because of that we get a new netmap_if pointer after each
NIOCREGIF.

Also removing netmap_if struct from NetmapDevice since
it's no more required.

Ticket #2855.

src/source-netmap.c

index cf0b443183d33d898b46d8384263ba3295534394..aaf4e9f3d59f3363106bf9570675735f30227c9b 100644 (file)
@@ -175,7 +175,6 @@ typedef struct NetmapDevice_
     char ifname[IFNAMSIZ];
     void *mem;
     size_t memsize;
-    struct netmap_if *nif;
     int rings_cnt;
     int rx_rings_cnt;
     int tx_rings_cnt;
@@ -278,6 +277,7 @@ static int NetmapOpen(char *ifname, int promisc, NetmapDevice **pdevice, int ver
 {
     NetmapDevice *pdev = NULL;
     struct nmreq nm_req;
+    struct netmap_if *nifp = NULL;
 
     *pdevice = NULL;
 
@@ -395,14 +395,14 @@ static int NetmapOpen(char *ifname, int promisc, NetmapDevice **pdevice, int ver
                            strerror(errno));
                 break;
             }
-            pdev->nif = NETMAP_IF(pdev->mem, nm_req.nr_offset);
         }
+        nifp = NETMAP_IF(pdev->mem, nm_req.nr_offset);
 
         if ((i < pdev->rx_rings_cnt) || (i == pdev->rings_cnt)) {
-            pring->rx = NETMAP_RXRING(pdev->nif, i);
+            pring->rx = NETMAP_RXRING(nifp, i);
         }
         if ((i < pdev->tx_rings_cnt) || (i == pdev->rings_cnt)) {
-            pring->tx = NETMAP_TXRING(pdev->nif, i);
+            pring->tx = NETMAP_TXRING(nifp, i);
         }
         SCSpinInit(&pring->tx_lock, 0);
         success_cnt++;