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.
master-4.0.x
Murat Balaban 7 years ago committed by Victor Julien
parent 17295591ee
commit 4a271c8c88

@ -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++;

Loading…
Cancel
Save