From: Murat Balaban Date: Wed, 27 Feb 2019 17:09:13 +0000 (-0800) Subject: netmap: refresh netmap_if address after each NIOCREGIF X-Git-Tag: suricata-4.0.7~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4a271c8c886fe5f2cd7c6e75007f307c7e87cbfb;p=thirdparty%2Fsuricata.git netmap: refresh netmap_if address after each NIOCREGIF 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. --- diff --git a/src/source-netmap.c b/src/source-netmap.c index cf0b443183..aaf4e9f3d5 100644 --- a/src/source-netmap.c +++ b/src/source-netmap.c @@ -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++;