aboutsummaryrefslogtreecommitdiff
path: root/sys/net/if_epair.c
Commit message (Collapse)AuthorAgeFilesLines
* net: Revert vnet/epair cleanup race mitigationKristof Provost2020-12-011-8/+2
| | | | | | | | | | | Revert the mitigation code for the vnet/epair cleanup race (done in r365457). r368237 introduced a more reliable fix. MFC after: 2 weeks Sponsored by: Modirum MDPay Notes: svn path=/head/; revision=368238
* net: mitigate vnet / epair cleanup racesKristof Provost2020-09-081-2/+8
| | | | | | | | | | | | | | | | | | | | | There's a race where dying vnets move their interfaces back to their original vnet, and if_epair cleanup (where deleting one interface also deletes the other end of the epair). This is commonly triggered by the pf tests, but also by cleanup of vnet jails. As we've not yet been able to fix the root cause of the issue work around the panic by not dereferencing a NULL softc in epair_qflush() and by not re-attaching DYING interfaces. This isn't a full fix, but makes a very common panic far less likely. PR: 244703, 238870 Reviewed by: lutz_donnerhacke.de MFC after: 4 days Differential Revision: https://reviews.freebsd.org/D26324 Notes: svn path=/head/; revision=365457
* net: clean up empty lines in .c and .h filesMateusz Guzik2020-09-011-6/+5
| | | | Notes: svn path=/head/; revision=365071
* Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)Pawel Biernacki2020-02-261-3/+5
| | | | | | | | | | | | | | | | | | | 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
* epair: Do not abuse params to register the second interfaceKristof Provost2020-01-281-22/+20
| | | | | | | | | | | | | | | if_epair used the 'params' argument to pass a pointer to the b interface through if_clone_create(). This pointer can be controlled by userspace, which means it could be abused to trigger a panic. While this requires PRIV_NET_IFCREATE privileges those are assigned to vnet jails, which means that vnet jails could panic the system. Reported by: Ilja Van Sprundel <ivansprundel@ioactive.com> MFC after: 3 days Notes: svn path=/head/; revision=357233
* Use the new VNET_DEFINE_STATIC macro when we are defining static VNETAndrew Turner2018-07-241-1/+1
| | | | | | | | | | | variables. Reviewed by: bz Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D16147 Notes: svn path=/head/; revision=336676
* epair(4): make sure we do not duplicate MAC addressesEugene Grosbein2018-07-231-2/+13
| | | | | | | | | | | in case of reused if_index. PR: 229957 Tested by: O. Hartmann <ohartmann@walstatt.org> Approved by: avg (mentor) Notes: svn path=/head/; revision=336628
* Improve MAC address uniqueness on if_epair(4).Luca Pizzamiglio2018-05-231-8/+24
| | | | | | | | | | | | | | | | As reported in PR184149, it can happen that epair devices can have the same MAC address. This solution is based on a 32-bit hash, obtained combining the if_index of the a interface and the hostid. If the hostid is zero, a random number is used. PR: 184149 Reviewed by: wollman, eugen Approved by: cognet Differential Revision: https://reviews.freebsd.org/D15329 Notes: svn path=/head/; revision=334094
* net: fix set but not usedMatt Macy2018-05-191-3/+3
| | | | Notes: svn path=/head/; revision=333864
* sys: general adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-0/+2
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. No functional change intended. Notes: svn path=/head/; revision=326272
* epair: Fix panic on unloadKristof Provost2017-11-011-4/+12
| | | | | | | | | | | | | | | The VNET_SYSUNINIT() callback is executed after the MOD_UNLOAD. That means that netisr_unregister() has already been called when netisr_unregister_vnet() gets calls, leading to an assertion failure. Restore the expected order of operations by performing everything that was done in MOD_UNLOAD to a SYSUNINIT() (that will be called after the VNET_SYSUNINIT()). Differential Revision: https://reviews.freebsd.org/D12771 Notes: svn path=/head/; revision=325283
* Fixed typo in comment found while reading commit email for fix ofPatrick Kelsey2017-04-081-1/+1
| | | | | | | | | | | other typo in same comment. ned -> need MFC after: 3 days Notes: svn path=/head/; revision=316634
* Fixed typo in comment.Patrick Kelsey2017-04-081-1/+1
| | | | | | | | | patckets -> packets MFC after: 3 days Notes: svn path=/head/; revision=316633
* Correct handling of ALTQ with epair(4) interfaces but presenting that ↵Ermal Luçi2017-03-241-2/+4
| | | | | | | | | | ALTQ(9) is supported. Approved by: ae MFC after: 2 weeks Notes: svn path=/head/; revision=315877
* Back out r314471. In https://reviews.freebsd.org/D1858 it was clearWarner Losh2017-03-011-2/+0
| | | | | | | | | | | | that this shouldn't go in. I was unaware when I merged the pull request. I don't wish to upset the status quo, so backout per project practice. Pull Request: https://github.com/freebsd/freebsd/pull/92 Noted by: hrs@ Notes: svn path=/head/; revision=314480
* Fix VNET - DAD detected duplicate IPv6 addressWarner Losh2017-03-011-0/+2
| | | | | | | | | | | Assign a hopefully unique, locally administered etheraddr. - for epairNa & epairNb Submitted by: Catalin <sslevil@users.noreply.github.com> Pull Request: https://github.com/freebsd/freebsd/pull/92 Notes: svn path=/head/; revision=314471
* Teach netisr_get_cpuid() to limit a given value to supported by netisr.Andrey V. Elsukov2016-08-171-2/+2
| | | | | | | | | | | | Use netisr_get_cpuid() in netisr_select_cpuid() to limit cpuid value returned by protocol to be sure that it is not greather than nws_count. PR: 211836 Reviewed by: adrian MFC after: 3 days Notes: svn path=/head/; revision=304313
* Get closer to a VIMAGE network stack teardown from top to bottom ratherBjoern A. Zeeb2016-06-211-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | than removing the network interfaces first. This change is rather larger and convoluted as the ordering requirements cannot be separated. Move the pfil(9) framework to SI_SUB_PROTO_PFIL, move Firewalls and related modules to their own SI_SUB_PROTO_FIREWALL. Move initialization of "physical" interfaces to SI_SUB_DRIVERS, move virtual (cloned) interfaces to SI_SUB_PSEUDO. Move Multicast to SI_SUB_PROTO_MC. Re-work parts of multicast initialisation and teardown, not taking the huge amount of memory into account if used as a module yet. For interface teardown we try to do as many of them as we can on SI_SUB_INIT_IF, but for some this makes no sense, e.g., when tunnelling over a higher layer protocol such as IP. In that case the interface has to go along (or before) the higher layer protocol is shutdown. Kernel hhooks need to go last on teardown as they may be used at various higher layers and we cannot remove them before we cleaned up the higher layers. For interface teardown there are multiple paths: (a) a cloned interface is destroyed (inside a VIMAGE or in the base system), (b) any interface is moved from a virtual network stack to a different network stack ("vmove"), or (c) a virtual network stack is being shut down. All code paths go through if_detach_internal() where we, depending on the vmove flag or the vnet state, make a decision on how much to shut down; in case we are destroying a VNET the individual protocol layers will cleanup their own parts thus we cannot do so again for each interface as we end up with, e.g., double-frees, destroying locks twice or acquiring already destroyed locks. When calling into protocol cleanups we equally have to tell them whether they need to detach upper layer protocols ("ulp") or not (e.g., in6_ifdetach()). Provide or enahnce helper functions to do proper cleanup at a protocol rather than at an interface level. Approved by: re (hrs) Obtained from: projects/vnet Reviewed by: gnn, jhb Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D6747 Notes: svn path=/head/; revision=302054
* Introduce a per-VNET flag to enable/disable netisr prcessing on that VNET.Bjoern A. Zeeb2016-06-031-0/+6
| | | | | | | | | | | | | | | | | | | | | | | Add accessor functions to toggle the state per VNET. The base system (vnet0) will always enable itself with the normal registration. We will share the registered protocol handlers in all VNETs minimising duplication and management. Upon disabling netisr processing for a VNET drain the netisr queue from packets for that VNET. Update netisr consumers to (de)register on a per-VNET start/teardown using VNET_SYS(UN)INIT functionality. The change should be transparent for non-VIMAGE kernels. Reviewed by: gnn (, hiren) Obtained from: projects/vnet MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D6691 Notes: svn path=/head/; revision=301270
* sys/net*: minor spelling fixes.Pedro F. Giffuni2016-05-031-1/+1
| | | | | | | No functional change. Notes: svn path=/head/; revision=298995
* These files were getting sys/malloc.h and vm/uma.h with header pollutionGleb Smirnoff2016-02-011-0/+1
| | | | | | | via sys/mbuf.h Notes: svn path=/head/; revision=295126
* Fix a panic which was reproducible by an infinite loop ofHiroki Sato2015-09-021-8/+8
| | | | | | | | | | "ifconfig epair0 create && ifconfig epair0a destroy". This was caused by an uninitialized function pointer in softc->media. Notes: svn path=/head/; revision=287402
* Virtualize if_epair(4). An if_xname check for both "a" and "b" interfacesHiroki Sato2014-10-101-6/+30
| | | | | | | | | is added to return EEXIST when only "b" interface exists---this can happen when epair<N>b is moved to a vnet jail and then "ifconfig epair<N> create" is invoked there. Notes: svn path=/head/; revision=272889
* Mechanically convert to if_inc_counter().Gleb Smirnoff2014-09-191-13/+13
| | | | Notes: svn path=/head/; revision=271867
* Remove ifq_drops from struct ifqueue. Now queue drops are accounted inGleb Smirnoff2014-09-191-1/+1
| | | | | | | | | | | | | struct ifnet if_oqdrops. Some netgraph modules used ifqueue w/o ifnet. Accounting of queue drops is simply removed from them. There were no API to read this statistic. Sponsored by: Netflix Sponsored by: Nginx, Inc. Notes: svn path=/head/; revision=271856
* Since 32-bit if_baudrate isn't enough to describe a baud rate of a 10 GbitGleb Smirnoff2014-03-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | interface, in the r241616 a crutch was provided. It didn't work well, and finally we decided that it is time to break ABI and simply make if_baudrate a 64-bit value. Meanwhile, the entire struct if_data was reviewed. o Remove the if_baudrate_pf crutch. o Make all fields of struct if_data fixed machine independent size. The notion of data (packet counters, etc) are by no means MD. And it is a bug that on amd64 we've got a 64-bit counters, while on i386 32-bit, which at modern speeds overflow within a second. This also removes quite a lot of COMPAT_FREEBSD32 code. o Give 16 bit for the ifi_datalen field. This field was provided to make future changes to if_data less ABI breaking. Unfortunately the 8 bit size of it had effectively limited sizeof if_data to 256 bytes. o Give 32 bits to ifi_mtu and ifi_metric. o Give 64 bits to the rest of fields, since they are counters. __FreeBSD_version bumped. Discussed with: emax Sponsored by: Netflix Sponsored by: Nginx, Inc. Notes: svn path=/head/; revision=263102
* The r48589 promised to remove implicit inclusion of if_var.h soon. PrepareGleb Smirnoff2013-10-261-0/+1
| | | | | | | | | | | to this event, adding if_var.h to files that do need it. Also, include all includes that now are included due to implicit pollution via if_var.h Sponsored by: Netflix Sponsored by: Nginx, Inc. Notes: svn path=/head/; revision=257176
* Utilize new macro to initialize if_baudrate().Gleb Smirnoff2012-10-181-2/+2
| | | | Notes: svn path=/head/; revision=241677
* Make the "struct if_clone" opaque to users of the cloning API. UsersGleb Smirnoff2012-10-161-18/+17
| | | | | | | | | | | | | | | now use function calls: if_clone_simple() if_clone_advanced() to initialize a cloner, instead of macros that initialize if_clone structure. Discussed with: brooks, bz, 1 year ago Notes: svn path=/head/; revision=241610
* Revert previous commit...Kevin Lo2012-10-101-1/+1
| | | | | | | Pointyhat to: kevlo (myself) Notes: svn path=/head/; revision=241394
* Prefer NULL over 0 for pointersKevin Lo2012-10-091-1/+1
| | | | Notes: svn path=/head/; revision=241370
* In epair_clone_destroy(), when destroying the second half, we have toMikolaj Golub2012-07-091-18/+20
| | | | | | | | | | | | | | | | switch to its vnet before calling ether_ifdetach(). Otherwise if the second half resides in a different vnet, if_detach() silently fails leaving a stale pointer in V_ifnet list, and the system crashes trying to access this pointer later. Another solution could be not to allow to destroy epair unless both ends are in the home vnet. Discussed with: bz Tested by: delphij Notes: svn path=/head/; revision=238309
* Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs.Ed Schouten2011-11-071-1/+1
| | | | | | | | | The SYSCTL_NODE macro defines a list that stores all child-elements of that node. If there's no SYSCTL_DECL macro anywhere else, there's no reason why it shouldn't be static. Notes: svn path=/head/; revision=227309
* Allow for vlan(4) interfaces with MTU of 1500 bytes to be configuredMarko Zec2011-05-241-0/+4
| | | | | | | | | | | on top of epair(4) virtual interfaces, since there's no physical hardware associated with epair interfaces which would imply any constraints on MTU sizes. MFC after: 3 days Notes: svn path=/head/; revision=222247
* Let epair(4) virtual interfaces report fake link / media status,Marko Zec2011-05-241-0/+37
| | | | | | | | | | | | | by borrowing the skeleton of if_media manipulation and reporting code from if_lagg(4). The main motivation behind this change is to allow for epair(4) interfaces to participate in STP if_bridge(4) configurations. Reviewed by: bz MFC after: 3 days Notes: svn path=/head/; revision=222246
* Add a missing ';' and change the debugging sysctl from xint to int.Bjoern A. Zeeb2010-11-211-2/+2
| | | | | | | | Submitted by: Mikolaj Golub (to.my.trociny gmail.com) MFC after: 3 days Notes: svn path=/head/; revision=215641
* MFp4 CH=183259:Bjoern A. Zeeb2010-09-021-2/+2
| | | | | | | | | | No reason to use if_free_type() as we don't change our type. Just if_free() is fine. MFC after: 3 days Notes: svn path=/head/; revision=212152
* MFp4 CH=182972:Bjoern A. Zeeb2010-08-271-0/+4
| | | | | | | | | | Add explicit linkstate UP/DOWN for the epair. This is needed by carp(4) and other things to work. MFC after: 5 days Notes: svn path=/head/; revision=211904
* Update several places that iterate over CPUs to use CPU_FOREACH().John Baldwin2010-06-111-12/+3
| | | | Notes: svn path=/head/; revision=209059
* Rework reference counting in case we queue into the netisr,Bjoern A. Zeeb2010-03-061-20/+71
| | | | | | | | | | | | | | | | | | | | or overflow the netisr queue and fall back to the interface queue so that we can garuantee that the ifnet pointer stays valid. Formerly we ended up with reference counts <= 0 in case the netisr had returned ENOBUFS. The idea is to track any packet in the netisr queue and only change the refount on edge operations for the fallback interface queue. This also avoids problems in case the if_snd.ifq_len lies to us. Also rework refount assertions to make sure they trigger if we go below 1. Formerly a negative refence count did not trigger the assert as the refcount variable is u_int. Sponsored by: ISPsystem MFC after: 5 days Notes: svn path=/head/; revision=204805
* Correct a typo.Bjoern A. Zeeb2010-01-101-1/+1
| | | | | | | MFC after: 5 days Notes: svn path=/head/; revision=201995
* Merge the remainder of kern_vimage.c and vimage.h into vnet.c andRobert Watson2009-08-011-2/+2
| | | | | | | | | | | | | vnet.h, we now use jails (rather than vimages) as the abstraction for virtualization management, and what remained was specific to virtual network stacks. Minor cleanups are done in the process, and comments updated to reflect these changes. Reviewed by: bz Approved by: re (vimage blanket) Notes: svn path=/head/; revision=196019
* Update epair(4) to the new netisr implementation and polishBjoern A. Zeeb2009-07-261-105/+273
| | | | | | | | | | | | | | | | | | | things a bit: - use dpcpu data to track the ifps with packets queued up, - per-cpu locking and driver flags - along with .nh_drainedcpu and NETISR_POLICY_CPU. - Put the mbufs in flight reference count, preventing interfaces from going away, under INVARIANTS as this is a general problem of the stack and should be solved in if.c/netisr but still good to verify the internal queuing logic. - Permit changing the MTU to virtually everythinkg like we do for loopback. Hook epair(4) up to the build. Approved by: re (kib) Notes: svn path=/head/; revision=195892
* Merge from p4: CH154790,154793,154874Bjoern A. Zeeb2009-06-241-0/+728
Import if_epair(4), a virtual cross-over Ethernet-like interface pair. Note these files are 1:1 from p4 and not yet connected to the build not knowing about the new netisr interface. Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=194927