aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/netmap
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix unused variable warning in if_re_netmap.hDimitry Andric2022-07-211-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
* netmap: Remove unused devclass arguments to DRIVER_MODULE.John Baldwin2022-05-102-6/+4
|
* netmap: Move more_txspace and some_recvd under #ifdef SYNC_KLOOP_POLL.John Baldwin2022-04-091-0/+8
|
* netmap: Fix TOCTOU vulnerability in nmreq_copyinVincenzo Maffione2022-03-161-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
* netmap: Fix integer overflow in nmreq_copyinVincenzo Maffione2022-03-161-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
* netmap: add a tunable for the maximum number of VALE switchesVincenzo Maffione2022-03-063-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
* netmap: fix refcount bug in netmap allocatorVincenzo Maffione2022-03-062-5/+7
| | | | | | | | | | | | | Symptom: when a single extmem memory region is provided to netmap multiple times, for multiple interfaces, the memory region is never released by netmap once all the existing file descriptors are closed. Fix the relevant condition in netmap_mem_drop(): release the memory when the last user of netmap_adapter is gone, rather then when the last user of netmap_mem_d is gone. MFC after: 2 weeks
* netmap: fix uint32_t overflow in pool size calculationVincenzo Maffione2021-09-261-1/+1
| | | | MFC after: 1 week
* netmap: monitor: support offsets in copy modeVincenzo Maffione2021-09-261-5/+7
|
* netmap: import changes from upstreamVincenzo Maffione2021-08-223-18/+35
| | | | | | | | | | | | | | | | - make sure rings are disabled during resets - introduce netmap_update_hostrings_mode(), with support for multiple host rings - always initialize ni_bufs_head in netmap_if ni_bufs_head was not properly initialized when no external buffers were requestedx and contained the ni_bufs_head from the last request. This was causing spurious buffer frees when alternating between apps that used external buffers and apps that did not use them. - check na validitity under lock on detach - netmap_mem: fix leak on error path - nm_dispatch: fix compilation on Raspberry Pi MFC after: 2 weeks
* netmap: use safer defaults for hwbuf_lenVincenzo Maffione2021-04-181-14/+32
| | | | | | | | | | | | | | | | | | | | | | | We must make sure that incoming packets will never overflow the netmap buffers, even when the user is using the offset feature. In the typical scenario, the netmap buffer is 2KiB and, with an MTU of 1500, there are ~500 bytes available for user offsets. Unfortunately, some NICs accept incoming packets even when they are larger then the MTU. This means that the only way to stop DMA from overflowing the netmap buffers, when offsets are allowed, is to choose a hardware buffer length which is smaller than the netmap buffer length. For most NICs and for 2KiB netmap buffers, this means 1024 bytes, which is unconveniently small. The current code will select the small hardware buf size even when offsets are not in use. The main purpose of this change is to fix this bug by returning to the normal behavior for the no-offsets case. At the same time, the patch pushes the handling of the offset case to the lower level driver code, so that it can be made NIC-specific (in future patches).
* wpa: Import wpa_supplicant/hostapd commit f91680c15Cy Schubert2021-04-172-30/+12
| | | | | | | | | | | | This is the April update to vendor/wpa committed upstream 2021/04/07. This is MFV efec8223892b3e677acb46eae84ec3534989971f. Suggested by: philip Reviewed by: philip MFC after: 2 months Differential Revision: https://reviews.freebsd.org/D29744
* netmap: make sure rings are disabled during resetsVincenzo Maffione2021-04-172-12/+30
| | | | | | | | Explicitly disable ring synchronization before calling callbacks that may result in a hardware reset. Before this patch we relied on capturing the down/up events which, however, may not be issued by all drivers.
* netmap: don't use linux type struct device *Vincenzo Maffione2021-04-111-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
* netmap: vtnet: remove unused variableVincenzo Maffione2021-04-091-2/+1
| | | | Reported by: bdragon
* netmap: vtnet: add support for netmap offsetsVincenzo Maffione2021-04-071-6/+10
| | | | | Follow-up change to a6d768d845c173823785c71bb18b40074e7a8998. This change adds support for netmap offsets.
* netmap: several typo fixesVincenzo Maffione2021-04-0211-37/+37
| | | | No functional changes intended.
* netmap: fix typo bug in netmap_compute_buf_lenVincenzo Maffione2021-04-022-2/+2
|
* netmap: monitor: add a flag to distinguish packet directionVincenzo Maffione2021-03-291-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.
* netmap: add kernel support for the "offsets" featureVincenzo Maffione2021-03-2911-324/+852
| | | | | | | | | | | | | This feature enables applications to ask netmap to transmit or receive packets starting at a user-specified offset from the beginning of the netmap buffer. This is meant to ease those packet manipulation operations such as pushing or popping packet headers, that may be useful to implement software switches, routers and other packet processors. To use the feature, drivers (e.g., iflib, vtnet, etc.) must have explicit support. This change does not add support for any driver, but introduces the necessary kernel changes. However, offsets support is already included for VALE ports and pipes.
* netmap: fix issues in nm_os_extmem_create()Vincenzo Maffione2021-03-201-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
* netmap: fix memory leak in NETMAP_REQ_PORT_INFO_GETVincenzo Maffione2021-03-151-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
* netmap: Stop printing a line to the dmesg in netmap_init()Mark Johnston2021-03-051-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 MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D29099
* netmap: simplify parameter passingVincenzo Maffione2021-01-244-44/+45
| | | | Changes imported from the netmap github.
* 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