summaryrefslogtreecommitdiff
path: root/sys/net/if_vlan.c
AgeCommit message (Collapse)Author
2023-04-26Also set TSO flag on vlan interfaces.Jan Klemkow
with tweaks from bluhm, claudio and dlg I fine with it from claudio looks good to me from dlg ok bluhm
2023-04-22revert vlan(4) inherits TSO flagsDavid Gwynne
tb reports amd64 RAMDISK doesn't build with it. also, vlan_flags_from_parent doesn't look right right. it iterates over ifnetlist, which is all interfaces in the system, but appears to assume they're all vlan interfaces and so uses a vlan_softc * to inspect their if_softc pointers.
2023-04-21vlan(4) inherits TSO flagsJan Klemkow
tested by Hrvoje Popovski with tweaks from bluhm and claudio encouraged from deraadt ok bluhm
2023-02-02Use binary or to set the ether_vtag which makes the code the sameClaudio Jeker
as in the other case as argument to vlan_inject(). Result is the same. OK dlg@ kn@ mvs@
2022-08-10Remove netlock assertion from vlan_ioctl(). Now (*if_ioctl)() calledVitaliy Makkoveev
without netlock for SIOC{G,S}IFMEDIA commands. ok bluhm@
2021-08-30remove a bunch of forward-only structs that were found with ctfconv.Jasper Lievisse Adriaanse
ok mpi@
2021-08-19implement reception of "VLAN 0 priority tagged" packets.David Gwynne
according to 802.1Q, vlan 0 on the wire is special and should be interpreted as if it was a packet received on the parent interface, but you get the packet priority information encoded in the vlan header. historically we drop vlan tagged packets that don't have a vlan interface configured for the received tag number. historically we have deviated from 802.1Q by allowing for the configuration of a vlan subinterface with the vnetid "unset". this works just like any other vlan interface, but it uses tag 0 on the wire. however, if you're in a situation where you're receiving vlan tagged 0 packets that really are part of the same layer 2 ethernet domain as the parent inteface, this doesnt work well. landry@ is in such a situation at work where the network is sending his OpenBSD boxes packets with VLAN tag 0. sometimes. most of the time the packets are untagged, which is expected, but sometimes they have a VLAN header set. this causes problems, particularly with arp. this diff does the smallest possible change to enable reception of these vlan 0 priority tagged packets. if an "unset" vlan interface is not configured on the parent, then vlan 0 tagged packets get their header stripped and continue stack processing as if they didnt have the tag at all. landry has been running this for months. ok sthen@ claudio@
2021-06-09whitespace tweak. no functional change.David Gwynne
2021-02-25we don't have to cast to caddr_t when calling m_copydata anymore.David Gwynne
the first cut of this diff was made with coccinelle using this spatch: @rule@ type caddr_t; expression m, off, len, cp; @@ -m_copydata(m, off, len, (caddr_t)cp) +m_copydata(m, off, len, cp) i had fix it's opinionated idea of formatting by hand though, so i'm not sure it was worth it. ok deraadt@ bluhm@
2021-01-21vlan(4): convert ifunit() to if_unit(9)mvs
ok dlg@ kn@
2020-07-22move vlan_input into ether_input, instead of via an input handler.David Gwynne
this means there's a consistent order of processing of service delimited (vlan and svlan) packets and bridging of packets. vlan and svlan get to look at a packet first. it's only if they decline a packet that a bridge can handle it. this allows operators to slice vlans out for processing separate to the "native" vlan handling if they want. while here, this fixes up a bug in vlan_input if m_pullup needed to prepend an mbuf. this has been in snaps as part of a larger diff for over a week.
2020-02-01replace vlan instance SRP lists with SMR_SLISTsJonathan Matthew
As vlan instances obtained from the lists are passed to if_vinput(), which may sleep (with PF locking enabled), we only traverse the vlan lists inside the SMR critical section, and keep the existing reference counting in place. ok visa@ sashan@
2019-11-07turn the linkstate hooks into a task list, like the detach hooks.David Gwynne
this is largely mechanical, except for carp. this moves the addition of the carp link state hook after we're committed to using the new interface as a carpdev. because the add can't fail, we avoid a complicated unwind dance. also, this tweaks the carp linkstate hook so it only updates the relevant carp interface, not all of the carpdevs on the parent. hrvoje popovski has tested an early version of this diff and it's generally ok, but there's some splasserts that this diff fires that i'll fix in an upcoming diff. ok claudio@
2019-11-06replace the hooks used with if_detachhooks with a task list.David Gwynne
the main semantic change is that things registering detach hooks have to allocate and set a task structure that then gets added to the list. this means if the task is allocated up front (eg, as part of carps softc or bridges port structure), it avoids the possibility that adding a hook can fail. a lot of drivers weren't checking for failure, and unwinding state in the event of failure in other parts was error prone. while doing this i discovered that the list operations have to be in a particular order, but drivers weren't doing that consistently either. this diff wraps the list ops up so you have to seriously go out of your way to screw them up. ive also sprinkled some NET_ASSERT_LOCKED around the list operations so we can make sure there's no potential for the list to be corrupted, especially while it's being run. hrvoje popovski has tested this a bit, and some issues he discovered have been fixed. ok sashan@
2019-11-04in vlan_clone_destroy take NET_LOCK when calling vlan_down and mark it dead.David Gwynne
2019-11-04make the parent promisc when a promisc vlan interface is brought up.David Gwynne
this has been reported by a bunch of people including chris@, jon williams on bugs@, and ze loff on misc@
2019-04-27fix up some rxprio handling while hereDavid Gwynne
we should swap the value off the wire for 802.1P, not the rxhprio config value. try and avoid toctou issues by copying the sc_rxprio value to a local.
2019-04-27don't increment noproto on the parent interface when there's no childDavid Gwynne
it's not atomic is the main reason. this simplifies leaving the function too.
2019-04-27use unsigned int, not u_int, and uintXX_t, not u_intXX_tDavid Gwynne
2019-04-27rename sc_prio to sc_txprioDavid Gwynne
2019-04-27remove sc_proto, it isn't used.David Gwynne
2019-04-27rename softc members so theyre prefixed with sc.David Gwynne
makes vlan more consistent with the rest of the tree, but no functional change.
2019-04-27get rid of ifv_linkmib and a bunch of useless macrosDavid Gwynne
2019-04-27fix some whitespace.David Gwynne
2019-04-27call vlan_softc variables sc, not ifv. no functional change.David Gwynne
2019-04-27whitespace tweaks. no functional change.David Gwynne
2019-04-27rename struct ifvlan to struct vlan_softcDavid Gwynne
this makes it more consistent with the rest of the tree, but has no functional change.
2019-04-27move the struct ifvlan (the vlan softc) definition into if_vlan.c.David Gwynne
nothing needs to see inside it, so it can move. the next steps are to rename it to vlan_softc and all the variables to sc to make the driver move consistent with the rest of the tree. ok visa@ mpi@
2019-04-22use if_vinput instead of if_input, thereby bypassing ifiqs on vlansDavid Gwynne
ifiqs on vlans are mostly just overhead. this improves vlan input speeds a lot, depending on your setup. i havent seen any speed regression with this.
2019-04-19use the factored out txhprio and rxhprio checksDavid Gwynne
reduces code duplication and chance for error.
2019-04-19add support for configuring rxprio.David Gwynne
vlan already used the 802.1p prio in packets to set the mbuf prio. this maintains that as the default. ok claudio@
2019-02-15Use `ifidx' when storing an interface index.Martin Pieuchot
ok dlg@
2019-02-14mpw.h is no longer needed.Martin Pieuchot
2019-01-23remove special casing for IFT_MPLSTUNNEL now mpw is IFT_ETHER.David Gwynne
2019-01-09implement an if_enqueue handler for vlan(4)David Gwynne
this allows vlan packets to bypass the ifq handling, which allows packets to be encapsulated concurrently by any context. the code falls back to ifqs if hfsc is enabled on the vlan interface, otherwise it encaps the packet immedate and enqueues it on the parent interface. hrove popovski has seen a performance bump in certain configurations from this change. ok mpi@ no objections claudio@
2018-11-16use txprio, not link0 and llprio, to set the dot1p field in the header.David Gwynne
if you're using llprio and link0, you'll need to update your config. ok claudio@
2018-07-11Fix comment about VLAN encapsulation and checksum offloadStefan Fritsch
Document that some chips actually could do hardware checksum offload for encapsulated packets, though that would need special handling in those drivers. discussions and ok naddy@
2018-04-03use link0 to use llprio in transmitted packets, regardless of mbuf prio.David Gwynne
some ISPs now provide services over vlans, but require vlan packets going to the internet have their priority set to 1 (ie, 0 on the wire) or they will be dropped. configuring this on openbsd requires config in several places, eg, pf rules to set the prio on ip packets, llprio on the pppoe interface for it's management frames, and the llprio on the vlan interface if you're using dhclient on it. this has the side effect that you can no longer use priority queuing, and can be error prone to get right. using link0 to flatteng the priority for isp transit is simple to configure, and allows priority queuing. a man page update is coming. ok henning@
2018-02-19Remove almost unused `flags' argument of suser().Martin Pieuchot
The account flag `ASU' will no longer be set but that makes suser() mpsafe since it no longer mess with a per-process field. No objection from millert@, ok tedu@, bluhm@
2018-01-09Creating a cloned interface could return ENOMEM due to temporaryAlexander Bluhm
memory shortage. As it is invoked from a system call, it should not fail and wait instead. OK visa@ mpi@
2017-06-22Fix the remaining ';;'s in sys/Tom Cosgrove
2017-05-31make vlan use their parents lladdr all the time, not just when theyre up.David Gwynne
krw@ has been having issues with dhclient on vlan interfaces because i made them only configure the lladdr when they were brought up. dhclient likes to read the mac address and then bring them up. this makes vlan copy the parents lladdr onto the vlan interface when the parent is configured. this probably helps with v6 addresses on vlan interfaces too. the new code still supports configuring a custom lladdr on a vlan interface. this can be done both before and after a parent is configured, and if a parent is removed. while here, if the parent is reconfigured while the vlan is up, dont error if the new parent is the same as the current one. this should make running netstart again less noisy. ok krw@
2017-05-29Pass SIOCGIFMEDIA to vlan's parent interface.Martin Pieuchot
ok krw@, dlg@
2017-01-24A space here, a space there. Soon we're talking real whitespaceKenneth R Westerback
rectification.
2017-01-24add support for multiple transmit ifqueues per network interface.David Gwynne
an ifq to transmit a packet is picked by the current traffic conditioner (ie, priq or hfsc) by providing an index into an array of ifqs. by default interfaces get a single ifq but can ask for more using if_attach_queues(). the vast majority of our drivers still think there's a 1:1 mapping between interfaces and transmit queues, so their if_start routines take an ifnet pointer instead of a pointer to the ifqueue struct. instead of changing all the drivers in the tree, drivers can opt into using an if_qstart routine and setting the IFXF_MPSAFE flag. the stack provides a compatability wrapper from the new if_qstart handler to the previous if_start handlers if IFXF_MPSAFE isnt set. enabling hfsc on an interface configures it to transmit everything through the first ifq. any other ifqs are left configured as priq, but unused, when hfsc is enabled. getting this in now so everyone can kick the tyres. ok mpi@ visa@ (who provided some tweaks for cnmac).
2017-01-23Flag pseudo-interfaces as such in order to call add_net_randomness()Martin Pieuchot
only once per packet. Fix a regression introduced when if_input() started to be called by every pseudo-driver. ok claudio@, dlg@
2017-01-22move counting if_opackets next to counting if_obytes in if_enqueue.David Gwynne
this means packets are consistently counted in one place, unlike the many and various ways that drivers thought they should do it. ok mpi@ deraadt@
2016-10-10ensure prepended ethernet headers are placed on ETHER_ALIGN boundaries,David Gwynne
even if m_prepend allocates a new mbuf in front of the current one. this is done by asking M_PREPEND for ETHER_HDR_LEN + ETHER_ALIGN bytes, and then calling m_adj(ETHER_ALIGN) after. in the case M_PREPEND does not allocate a new mbuf and ends up with the same layout as before. in the allocation case, the requested length is provided on a long boundary. an ETHER_HDR_LEN request would therefore be 6 bytes allocated on a long boundary, when we want it to be at ETHER_ALIGN. by asking for ETHER_HDR_LEN plus ETHER_ALIGN, we can m_adj ETHER_ALIGN off to get us to the ETHER_ALIGN offset. ok yasuoka@ mikeb@
2016-09-03Add support for a multipoint-to-multipoint mode in vxlan(4). In thisReyk Floeter
mode, vxlan(4) must be configured to accept any virtual network identifier with "vnetid any" and added to a bridge(4) or switch(4). This way the driver will dynamically learn the tunnel endpoints and their vnetids for the responses and can be used to dynamically bridge between VXLANs. It is also being used in combination with switch(4) and the OpenFlow tunnel classifiers. With input from yasuoka@ goda@ OK deraadt@ dlg@
2016-05-18rework the srp api so it takes an srp_ref struct that the caller provides.David Gwynne
the srp_ref struct is used to track the location of the callers hazard pointer so later calls to srp_follow and srp_enter already know what to clear. this in turn means most of the caveats around using srps go away. specifically, you can now: - switch cpus while holding an srp ref - ie, you can sleep while holding an srp ref - you can take and release srp refs in any order the original intent was to simplify use of the api when dealing with complicated data structures. the caller now no longer has to track the location of the srp a value was fetched from, the srp_ref effectively does that for you. srp lists have been refactored to use srp_refs instead of srpl_iter structs. this is in preparation of using srps inside the ART code. ART is a complicated data structure, and lookups require overlapping holds of srp references. ok mpi@ jmatthew@