From: Abhishek Sachan Date: Thu, 22 Aug 2019 06:25:36 +0000 (+0530) Subject: net/af_packet: fix stale sockets X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=7c3bcc7b6dc14623bd17960fa3236e6fa9e2711b;p=dpdk.git net/af_packet: fix stale sockets af_packet driver is leaving stale socket after device is removed. Ring buffers are memory mapped when device is added using rte_dev_probe. There is no corresponding munmap call when device is removed/closed. This commit fixes the issue by calling munmap from rte_pmd_af_packet_remove(). Bugzilla ID: 339 Fixes: e6ee4db01b4d ("af_packet: make the device detachable") Cc: stable@dpdk.org Signed-off-by: Abhishek Sachan Reviewed-by: John W. Linville --- diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c index 82bf2cd581..6df09f2828 100644 --- a/drivers/net/af_packet/rte_eth_af_packet.c +++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -972,6 +972,7 @@ rte_pmd_af_packet_remove(struct rte_vdev_device *dev) { struct rte_eth_dev *eth_dev = NULL; struct pmd_internals *internals; + struct tpacket_req *req; unsigned q; PMD_LOG(INFO, "Closing AF_PACKET ethdev on numa socket %u", @@ -992,7 +993,10 @@ rte_pmd_af_packet_remove(struct rte_vdev_device *dev) return rte_eth_dev_release_port(eth_dev); internals = eth_dev->data->dev_private; + req = &internals->req; for (q = 0; q < internals->nb_queues; q++) { + munmap(internals->rx_queue[q].map, + 2 * req->tp_block_size * req->tp_block_nr); rte_free(internals->rx_queue[q].rd); rte_free(internals->tx_queue[q].rd); }