summaryrefslogtreecommitdiff
path: root/sys/dev/netmap
Commit message (Collapse)AuthorAgeFilesLines
* netmap: Tell the compiler to avoid reloading ring indicesMark Johnston2023-02-011-4/+4
| | | | | | | | | | | | | | | | | Per the removed comments these fields should be loaded only once, since they can in principle be modified concurrently, though this would be a violation of the userspace contract with netmap. No functional change intended. Reviewed by: vmaffione MFC after: 1 week Sponsored by: Zenarmor Sponsored by: OPNsense Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D38061 (cherry picked from commit 56c438fcd4a755f0abe8254779c39a0c4b530c75)
* netmap: Correct a commentMark Johnston2023-02-011-1/+1
| | | | | | | | | | | Reviewed by: vmaffione MFC after: 1 week Sponsored by: Zenarmor Sponsored by: OPNsense Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D38063 (cherry picked from commit 854b2f302dcc73dfef2e4458d382f8149ce9167c)
* netmap: Fix a queue length check in the generic port rx pathMark Johnston2023-02-011-1/+1
| | | | | | | | | | | | | | | The check is ok by default, since the default value of netmap_generic_ringsize is 1024. But we should check against the configured "ring" size. Reviewed by: vmaffione MFC after: 1 week Sponsored by: Zenarmor Sponsored by: OPNsense Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D38062 (cherry picked from commit 539437c8281d24450bacded3734276acd9983e90)
* netmap: several typo fixesVincenzo Maffione2022-12-3111-33/+33
| | | | | | No functional changes intended. (cherry picked from commit 45c67e8f6b56b9744f01142747fadf291fe3fad2)
* netmap: drop compatibility FreeBSD codeVincenzo Maffione2022-12-314-117/+1
| | | | | | | | | | | Netmap users on FreeBSD are not supposed to import code from the github netmap repository anymore. They should use the code that is available in the src repo. We can therefore drop the compatibility code. MFC after: 7 days (cherry picked from commit 3da494d3246e30a19d2107c8bb8a293ffd5a9da6)
* netmap: monitor: add missing netmap_adapter_put()Vincenzo Maffione2022-12-311-0/+2
| | | | | | MFC after: 7 days (cherry picked from commit 95fc11577d117327e7d99a589e86ba15d0599654)
* debug_put_get: don't crash on null pointersVincenzo Maffione2022-12-311-3/+6
| | | | | | MFC after: 7 days (cherry picked from commit 92e8b4a6301cc4ff4481e981c95c5b30b2a44506)
* monitor: fix cb restore when monitored adapter unregistersVincenzo Maffione2022-12-311-6/+6
| | | | | | | | | | netmap_monitor_stop() called nm_monitor_none() after the head of the zero-copy monitors had been reset, thus thinking that there was nothing left to do. MFC after: 7 days (cherry picked from commit b41818a28a6dba6d33076fbb789442308e57a124)
* netmap_update_config: update na->name to cope with reconfigurationsVincenzo Maffione2022-12-243-1/+6
| | | | | | MFC after: 1 week (cherry picked from commit 4ad57c7afaca3fd94b67c00706e210f0373b8e62)
* netmap(4): Remove a double word in a source code commentGordon Bergling2022-09-071-1/+1
| | | | | | - s/the the/the/ (cherry picked from commit 591a9b5ea339feda45cd0dafaac4b581495a57d2)
* Fix unused variable warning in if_re_netmap.hDimitry Andric2022-07-241-2/+1
| | | | | | | | | | | | | | | With clang 15, the following -Werror warning is produced: sys/dev/netmap/if_re_netmap.h:179:8: error: variable 'n' set but not used [-Werror,-Wunused-but-set-variable] u_int n; ^ The 'n' variable appears to have been a debugging aid that has never been used for anything, so remove it. MFC after: 3 days (cherry picked from commit 8bfedf5852bcb846bfdd2a54989d65cdbb16f7ef)
* netmap: add a tunable for the maximum number of VALE switchesVincenzo Maffione2022-03-203-7/+14
| | | | | | | | | | The new dev.netmap.max_bridges sysctl tunable can be set in loader.conf(5) to change the default maximum number of VALE switches that can be created. Current defaults is 8. MFC after: 2 weeks (cherry picked from commit dd6ab49a9aebb5fbb85973d9a859d24daa5e2165)
* netmap: Fix TOCTOU vulnerability in nmreq_copyinVincenzo Maffione2022-03-191-34/+17
| | | | | | | | | | | | The total size of the user-provided nmreq was first computed and then trusted during the copyin. This might lead to kernel memory corruption and escape from jails/containers. Reported by: Lucas Leong (@_wmliang_) of Trend Micro Zero Day Initiative Security: CVE-2022-23084 MFC after: 3 days (cherry picked from commit 393729916564ed13f966e09129a24e6931898d12)
* netmap: Fix integer overflow in nmreq_copyinVincenzo Maffione2022-03-191-2/+12
| | | | | | | | | | | | An unsanitized field in an option could be abused, causing an integer overflow followed by kernel memory corruption. This might be used to escape jails/containers. Reported by: Reno Robert and Lucas Leong (@_wmliang_) of Trend Micro Zero Day Initiative Security: CVE-2022-23085 (cherry picked from commit 694ea59c7021c25417e6d516362d2f59b4e2c343)
* netmap: monitor: add a flag to distinguish packet directionVincenzo Maffione2021-09-261-2/+6
| | | | | | | | | | The netmap monitor intercepts any TX/RX packets on the monitored port. However, before this change there was no way to tell whether an intercepted packet was being transmitted or received on the monitored port. A TXMON flag in the netmap slot has been added for this purpose. (cherry picked from commit 660a47cb991d5a7ca69cd8dd9c09a5288d49e405)
* netmap: don't use linux type struct device *Vincenzo Maffione2021-04-191-2/+2
| | | | | | | | | | | Such type cannot be used in code that is in common between FreeBSD and Linux. Use the FreeBSD type instead. MFC after: 3 days Reported by: markj Differential Revision: https://reviews.freebsd.org/D29677 (cherry picked from commit 70275a6735df8a514f48be77418491f2f8dba817)
* netmap: fix issues in nm_os_extmem_create()Vincenzo Maffione2021-03-231-6/+10
| | | | | | | | | | | | - Call vm_object_reference() before vm_map_lookup_done(). - Use vm_mmap_to_errno() to convert vm_map_* return values to errno. - Fix memory leak of e->obj. Reported by: markj Reviewed by: markj MFC after: 1 week (cherry picked from commit ee7ffaa2e6e08b63efb4673610875d40964d5058)
* netmap: fix memory leak in NETMAP_REQ_PORT_INFO_GETVincenzo Maffione2021-03-181-0/+4
| | | | | | | | | | | | | | The netmap_ioctl() function has a reference counting bug in case of NETMAP_REQ_PORT_INFO_GET command. When `hdr->nr_name[0] == '\0'`, the function does not decrease the refcount of "nmd", which is increased by netmap_mem_find(), causing a refcount leak. Reported by: Xiyu Yang <sherllyyang00@gmail.com> Submitted by: Carl Smith <carl.smith@alliedtelesis.co.nz> MFC after: 3 days PR: 254311 (cherry picked from commit 0ab5902e8ad93d0a9341dcce386b6c571ee02173)
* netmap: Stop printing a line to the dmesg in netmap_init()Mark Johnston2021-03-121-0/+2
| | | | | | | | | | | | netmap is compiled into the kernel by default so initialization was always reported, and netmap uses a formatting convention not used in the rest of the kernel. Reviewed by: vmaffione Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D29099 (cherry picked from commit fef845097190f0ecb783d6c75a9398c4e4a4c0e1)
* netmap: simplify parameter passingVincenzo Maffione2021-01-314-44/+45
| | | | | | Changes imported from the netmap github. (cherry picked from commit ee0005f11f2b38a714bc66b7d79832108f6fee77)
* netmap: vtnet: fix RX initialization after netmap_reset()Vincenzo Maffione2021-01-111-7/+12
| | | | | | | At device reset, we must not publish those netmap receive buffers that are owned by userspace (nm_kr_rxspace). MFC after: 1 week
* netmap: restore hwofs and support it in iflibVincenzo Maffione2021-01-101-13/+34
| | | | | | | | | | | | | | | | Restore the hwofs functionality temporarily disabled by 7ba6ecf216fb15e8b147db2 to prevent issues with iflib. This patch brings the necessary changes to iflib to enable howfs to allow interface restarts without disrupting netmap applications actively using its rings. After this change, it becomes possible for multiple non-cooperating netmap applications to use non-overlapping subsets of the available netmap rings without clashing with each other. PR: 252453 MFC after: 1 week
* netmap: vtnet: enable/disable krings on any interface reinitVincenzo Maffione2021-01-102-6/+4
| | | | | | | See 3d65fd97e85ab807f3b for a detailed explanation. PR: 252453 MFC after: 1 week
* netmap: vtnet: stop krings during interface resetVincenzo Maffione2021-01-091-1/+7
| | | | | | | | Similarly to what done for iflib in 1d238b07d5d4d9660ae0e, this patch prevents access to the krings during the interface reset triggered by netmap_register(). MFC after: 1 week
* netmap: refactor netmap_resetVincenzo Maffione2021-01-091-45/+20
| | | | | | | | | | | | | | | | The netmap_reset() function is meant to be called by the driver when they initialize (or re-initialize) a hardware ring. However, since the introduction of support for opening (in netmap mode) a subset of the available rings, netmap_reset() may be called multiple times on actively used rings, causing both kring and netmap ring to transition to an inconsistent state. This changes improves the situation by resetting all the indices fields of the kring to 0, as expected after the reinitialization of a hardware ring. PR: 252518 MFC after: 1 week
* netmap: iflib: stop krings during interface resetVincenzo Maffione2021-01-091-1/+1
| | | | | | | | | | | | | | | | | When different processes open separate subsets of the available rings of a same netmap interface, a device reset may be performed while one of the processes is actively using some rings (e.g., caused by another process executing a nmport_open()). With this patch, such situation will cause the active process to get a POLLERR, so that it can have a chance to detect the situation. We also guarantee that no process is running a txsync or rxsync (ioctl or poll) while an iflib device reset is in progress. PR: 252453 MFC after: 1 week
* netmap: fix mutex double unlock bugVincenzo Maffione2020-10-221-1/+0
| | | | | | | | | | https://github.com/luigirizzo/netmap/pull/733 Submitted by: brian90013 MFC after: 3 days Notes: svn path=/head/; revision=366952
* netmap: use FreeBSD guards for epoch callsVincenzo Maffione2020-08-241-1/+5
| | | | | | | | | | EPOCH calls are FreeBSD specific. Use guards to protect these, so that the code can compile under Linux. MFC after: 1 week Notes: svn path=/head/; revision=364731
* netmap: fix parsing of legacy nmr->nr_ringidVincenzo Maffione2020-08-181-2/+2
| | | | | | | | | | | | | | | | Code was checking for NETMAP_{SW,HW}_RING in req->nr_ringid which had already been masked by NETMAP_RING_MASK. Therefore, the comparisons always failed and set NR_REG_ALL_NIC. Check against the original nmr structure. Submitted by: bpoole@packetforensics.com Reported by: bpoole@packetforensics.com Reviewed by: giuseppe.lettieri@unipi.it Approved by: vmaffione MFC after: 1 week Notes: svn path=/head/; revision=364341
* netmap: vtnet: fix races in vtnet_netmap_reg()Vincenzo Maffione2020-06-141-47/+11
| | | | | | | | | | | | | | | | | | | | | The nm_register callback needs to call nm_set_native_flags() or nm_clear_native_flags() once the device has been stopped. However, in the current implementation this is not true, as the device is stopped by vtnet_init_locked(). This causes race conditions where the driver crashes as soon as it dequeues netmap buffers assuming they are mbufs (or the other way around). To fix the issue, we extend vtnet_init_locked() with a second argument that, if not zero, will set/clear the netmap flags. This results in a huge simplification of the nm_register callback itself. Also, use netmap_reset() to check if a ring is going to be re-initialized in netmap mode. MFC after: 1 week Notes: svn path=/head/; revision=362183
* netmap: introduce netmap_kring_on()Vincenzo Maffione2020-06-112-19/+18
| | | | | | | | | | | | This function returns NULL if the ring identified by queue id and direction is in netmap mode. Otherwise return the corresponding kring. Use this function to replace vtnet_netmap_queue_on(). MFC after: 1 week Notes: svn path=/head/; revision=362076
* netmap: vtnet: clean up rxsync disabled logsVincenzo Maffione2020-06-031-4/+2
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=361760
* netmap: vtnet: fix race condition in rxsyncVincenzo Maffione2020-06-031-3/+18
| | | | | | | | | | | | This change prevents a race that happens when rxsync dequeues N-1 rx packets (with N being the size of the netmap rx ring). In this situation, the loop exits without re-enabling the rx interrupts, thus causing the VQ to stall. MFC after: 1 week Notes: svn path=/head/; revision=361759
* netmap: vtnet: add vtnrx_nm_refill index to receive queuesVincenzo Maffione2020-06-031-20/+30
| | | | | | | | | | | | | | | The new index tracks the next netmap slot that is going to be enqueued into the virtqueue. The index is necessary to prevent the receive VQ and the netmap rx ring from going out of sync, considering that we never enqueue N slots, but at most N-1. This change fixes a bug that causes the VQ and the netmap ring to go out of sync after N-1 packets have been received. MFC after: 1 week Notes: svn path=/head/; revision=361758
* netmap: vale: fix disabled logsVincenzo Maffione2020-06-031-2/+2
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=361747
* netmap: vtnet: remove leftover memory barriersVincenzo Maffione2020-06-031-2/+0
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=361746
* netmap: if_vtnet: avoid netmap ring wraparoundVincenzo Maffione2020-06-011-2/+2
| | | | | | | | | | | netmap assumes the one "slot" is left unused to distinguish the empty ring and full ring conditions. This assumption was violated by vtnet_netmap_rxq_populate(). MFC after: 1 week Notes: svn path=/head/; revision=361698
* netmap: if_vtnet: replace vtnet_free_used()Vincenzo Maffione2020-06-011-38/+2
| | | | | | | | | | | The functionality contained in this function is duplicated, as it is already available in vtnet_txq_free_mbufs() and vtnet_rxq_free_mbufs(). MFC after: 1 week Notes: svn path=/head/; revision=361697
* netmap: vtnet: fix RX virtqueue initialization bugVincenzo Maffione2020-06-011-7/+19
| | | | | | | | | | | | | | | | The vtnet_netmap_rxq_populate() function erroneously assumed that kring->nr_hwcur = 0, i.e. the kring was in the initial state. However, this is not always the case: for example, when a vtnet reinit is triggered by some changes in the interface flags or capenable. This patch changes the behaviour of vtnet_netmap_kring_refill() so that it always starts publishing the netmap buffers starting from the current value of kring->nr_hwcur. MFC after: 1 week Notes: svn path=/head/; revision=361696
* Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)Pawel Biernacki2020-02-261-1/+2
| | | | | | | | | | | | | | | | | | | r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are still not MPSAFE (or already are but aren’t properly marked). Use it in preparation for a general review of all nodes. This is non-functional change that adds annotations to SYSCTL_NODE and SYSCTL_PROC nodes using one of the soon-to-be-required flags. Mark all obvious cases as MPSAFE. All entries that haven't been marked as MPSAFE before are by default marked as NEEDGIANT Approved by: kib (mentor, blanket) Commented by: kib, gallatin, melifaro Differential Revision: https://reviews.freebsd.org/D23718 Notes: svn path=/head/; revision=358333
* Use NET_TASK_INIT() and NET_GROUPTASK_INIT() for drivers that processGleb Smirnoff2020-02-111-3/+4
| | | | | | | | | | incoming packets in taskqueue context. Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D23518 Notes: svn path=/head/; revision=357772
* netmap: improve netmap(4) and vale(4) man pagesVincenzo Maffione2020-02-071-2/+0
| | | | | | | | | | | | Clean up obsolete sysctl descriptions and add missing ones. PR: 243838 Reviewed by: bcr MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D23546 Notes: svn path=/head/; revision=357663
* netmap_mem_unmap: fix NULL pointer dereferenceVincenzo Maffione2020-01-261-1/+2
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=357159
* In netmap() call ether_input() within the network epoch.Gleb Smirnoff2020-01-231-0/+5
| | | | Notes: svn path=/head/; revision=357008
* netmap: disable passthrough with no hypervisor supportVincenzo Maffione2020-01-132-1/+3
| | | | | | | | | | | | | | | The netmap passthrough subsystem requires proper support in the hypervisor. In particular, two PCI device ids (from the Red Hat PCI vendor id 0x1b36) need to be assigned to the two netmap virtual devices. We then disable these devices until the ids have not been assigned, in order to avoid conflicts with other virtual devices emulated by upstream QEMU. PR: 241774 MFC after: 3 days Notes: svn path=/head/; revision=356704
* Make page busy state deterministic on free. Pages must be xbusy whenJeff Roberson2019-12-221-4/+1
| | | | | | | | | | | | | | | | | | | removed from objects including calls to free. Pages must not be xbusy when freed and not on an object. Strengthen assertions to match these expectations. In practice very little code had to change busy handling to meet these rules but we can now make stronger guarantees to busy holders and avoid conditionally dropping busy in free. Refine vm_page_remove() and vm_page_replace() semantics now that we have stronger guarantees about busy state. This removes redundant and potentially problematic code that has proliferated. Discussed with: markj Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D22822 Notes: svn path=/head/; revision=356002
* add valectl to the system commandsVincenzo Maffione2019-10-311-1/+1
| | | | | | | | | | | | | | The valectl(4) program is used to manage vale(4) switches. Add it to the system commands so that it can be used right away. This program was previously called vale-ctl, and stored in tools/tools/netmap Reviewed by: hrs, bcr, lwhsu, kevans MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D22146 Notes: svn path=/head/; revision=354229
* netmap: enter NET_EPOCH on generic txsyncVincenzo Maffione2019-10-281-0/+9
| | | | | | | | | | | | | | | | After r353292, netmap generic adapter on if_vlan interfaces panics on asserting the NET_EPOCH. In more detail, this happens when nm_os_generic_xmit_frame() is called, that is in the generic txsync routine. Fix the issue by entering the NET_EPOCH during the generic txsync. We amortize the cost of entering/exiting over a whole batch of transmissions. PR: 241489 Reported by: Aleksandr Fedorov <aleksandr.fedorov@itglobal.com> Notes: svn path=/head/; revision=354137
* netmap: minor misc improvementsVincenzo Maffione2019-10-203-4/+5
| | | | | | | | | | | - use ring->head rather than ring->cur in lb(8) - use strlcat() rather than strncat() - fix bandwidth computation in pkt-gen(8) MFC after: 1 week Notes: svn path=/head/; revision=353775
* tap: add support for virtio-net offloadsVincenzo Maffione2019-10-181-304/+6
| | | | | | | | | | | | | | | | | | | | | | | | This patch is part of an effort to make bhyve networking (in particular TCP) faster. The key strategy to enhance TCP throughput is to let the whole packet datapath work with TSO/LRO packets (up to 64KB each), so that the per-packet overhead is amortized over a large number of bytes. This capability is supported in the guest by means of the vtnet(4) driver, which is able to handle TSO/LRO packets leveraging the virtio-net header (see struct virtio_net_hdr and struct virtio_net_hdr_mrg_rxbuf). A bhyve VM exchanges packets with the host through a network backend, which can be vale(4) or if_tap(4). While vale(4) supports TSO/LRO packets, if_tap(4) does not. This patch extends if_tap(4) with the ability to understand the virtio-net header, so that a tapX interface can process TSO/LRO packets. A couple of ioctl commands have been added to configure and probe the virtio-net header. Once the virtio-net header is set, the tapX interface acquires all the IFCAP capabilities necessary for TSO/LRO. Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D21263 Notes: svn path=/head/; revision=353741