summaryrefslogtreecommitdiff
path: root/sys/net/if_ethersubr.c
AgeCommit message (Collapse)Author
2016-10-11Strengthen Ethernet packet length checks on input; ok dlgMike Belopuhov
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-07-12Directly drop packets filtered by bpf(4) instead of going through theMartin Pieuchot
input handlers. ok dlg@
2016-06-08Move ND resoluton logic from nd6_output() to nd6_storelladdr() andMartin Pieuchot
rename it to nd6_resolve(). This allows us to get rid of non-Ethernet hacks by moving Ethernet specific logic in the appropriate layer. ok sthen@
2016-05-31Ensure that a valid route entry is passed to ether_output() if L2Martin Pieuchot
resolution is required. This will allow us to enforce that no route entry is inserted in the routing table after ether_output(). This is now possible because if_output() is no longer called with a NULL route argument. Tested by Hrvoje Popovski, ok visa@, bluhm@
2016-05-18Remove some superflous if_get(9)/if_put(9) dances now that ARP inputMartin Pieuchot
routines are call directly by ether_input(). ok visa@, dlg@
2016-04-01Building kernels with PPPOE_SERVER enabled has been broken for at leastJonathan Gray
eleven years, remove it. Despite what the wildly outdated time(9) claims, there is no longer globally visible "struct timeval mono_time" or "struct timeval time". ok mpi@ sthen@ mikeb@
2016-03-01enm_ac in ether_multi is set but never used. so we dont need it.David Gwynne
2016-01-22Always check destination MAC address of received unicast packets, notStefan Fritsch
only when in promiscuous mode This necessary for NICs like virtio, where the unicast MAC filter is 'best effort' only. ok dlg@ encouragement from mpi@
2016-01-08Get rid of the arp and revarp input queues.Martin Pieuchot
Packets of types ARP and REVARP are now processed in the softnet task, directly from ether_input() and without holding the KERNEL_LOCK. Tested by many, ok dlg@
2015-12-02Rework the MPLS handling. Remove the lookup loops since nothing is usingClaudio Jeker
them and they make everything so much harder with no gain. Remove the ifp argument from mpls_input since it is not needed. On the input side the lookup side is modified a bit when it comes to BOS handling. Tested in a L3VPN setup with ldpd and bgpd. Commiting now so we can move on with cleaning up rt_ifp usage. If this breaks L2VPN I will fix it once reported. OK mpi@
2015-10-25Introduce if_rtrequest() the successor of ifa_rtrequest().Martin Pieuchot
L2 resolution depends on the protocol (encoded in the route entry) and an ``ifp''. Not having to care about an ``ifa'' makes our life easier in our MP effort. Fewer dependencies between data structures implies fewer headaches. Discussed with bluhm@, ok claudio@
2015-10-22Inspired by satosin(), use inline functions to convert sockaddr dl.Alexander Bluhm
Instead of casts they check wether the incoming object has the expected type. So introduce satosdl() and sdltosa() in the kernel. OK mpi@
2015-09-29add sizes to some of the simpler free callsTheo de Raadt
ok mpi
2015-09-27Welcome etheranyaddr, cousin of etherbroadcastaddr.Stefan Sperling
Can be used to check if a MAC address is all zeros. Will be used by iwm(4) soon. ok kettenis@
2015-09-17instead of leaking rarp packets, break from the switch statementDavid Gwynne
so packets can get enqueued for the arp netisr to process. fixes jsgs nfs mountroot problem.
2015-09-13queue revarps to softnet so we can defer processing to a context withDavid Gwynne
the kernel lock. "do it" claudio@ mpi@
2015-09-12Introduce if_input_local() a function to feed local traffic back toMartin Pieuchot
the protocol queues. It basically does what looutput() was doing but having a generic function will allow us to get rid of the loopback hack overwwritting the rt_ifp field of RTF_LOCAL routes. ok mikeb@, dlg@, claudio@
2015-09-10pass a cookie argument to interface input handlers that can be usedMike Belopuhov
to pass additional context or transient data with the similar life time. ok mpi, suggestions, hand holding and ok from dlg
2015-09-10move the if input handler list to an SRP list.David Gwynne
instead of having every driver that manipulates the ifih list understand SRPLs, this moves that processing into if_ih_insert and if_ih_remove functions. we rely on the kernel lock to serialise the modifications to the list. tested by mpi@ ok mpi@ claudio@ mikeb@
2015-07-29Don't use mpls_input() as input handler anymore and instead call itRafael Zalamena
directly. Also protect non mp-safe functions while at it. ok mpi@.
2015-07-20Kill NETISR_MPLS, from now on we will use interface input handlers to dealRafael Zalamena
with MPLS packets. ok mpi@, claudio@
2015-07-18Packets that make it to ether_input that have M_VLANTAG set must be dropped.Claudio Jeker
vlan(4) clears M_VLANTAG when a tag matches but if the tag is still there it means that the vlan is not configured on the interface. Found with mpi@ and rzalamena@ while discussing various vlan troubles.
2015-07-17Fix MPLS routing when receiving packet with multiple labels.rzalamena
ok claudio@, phessler@, mpi@
2015-07-15m_freem() can handle NULL, do not check for this condition beforehands.Theo de Raadt
ok stsp mpi
2015-07-02most of the destinations for mbufs in ether_input are mpsafe except forDavid Gwynne
pipex and bridge. this puts KERNEL_LOCK/KERNEL_UNLOCK around the pipex chunk till we can give it some mp love. ok yasuoka@ mpi@
2015-07-02Move back rdomain's check into ether_output() otherwise it triggersMartin Pieuchot
if a pseudo-interface is on a different rdomain than its parent. Sorry for the inconvenience, I hope you'll fly again with us. Regression reported by and ok semarie@, ok phessler@
2015-07-02By design if_input_process() needs to hold a reference on the receivingMartin Pieuchot
ifp in order to access its ifih handlers. So get rid of if_get() in the various ifih handlers we know the ifp is live at this point. ok dlg@
2015-06-30Get rid of the undocumented & temporary* m_copy() macro added forMartin Pieuchot
compatibility with 4.3BSD in September 1989. *Pick your own definition for "temporary". ok bluhm@, claudio@, dlg@
2015-06-30Rename if_output() into if_enqueue() to avoid confusion with commentsMartin Pieuchot
talking about (*ifp->if_output)(). ok claudio@, dlg@
2015-06-29count if_ibytes in if_input like we do for if_ipackets.David Gwynne
tweaks and ok mpi@
2015-06-25No more NBRIDGE in the Ethernet layer. Fewer layer violation, say yeah!Martin Pieuchot
2015-06-25Move brige(4)'s output hook outside of ether_output().Martin Pieuchot
This fix some weird bridge(4) configurations involving pseudo-drivers stacked on top of interfaces in a bridge. Also simplifies the loop prevention logic to match bridge's input path. Instead of using a tag per port/bridge simply flag output mbufs to make sure only one copy per bridge go through bridge_output(). ok bluhm@, claudio@
2015-06-25Check for correct rdomain in if_output() rather than in ether_output().Martin Pieuchot
Not all drivers make use of ether_output() and there's no real reason to call it when no ARP resolution is needed. But in this case we still want to make sure we're sending packets in the correct rdomain. ok bluhm@, claudio@ as part of a larger diff.
2015-06-23Pass a "struct ifnet *" instead of a "struct arpcom *" to arpresolve().Martin Pieuchot
Most of the ARP layer already take an ifp pointer and this makes clear wich chunks of code are messing with ac_enaddr. Note that our Ethernet code assume that these pointer are interchangeable since the first element of the "struct arpcom" is a "struct ifnet".
2015-06-23Adapt bridge(4) to the new if_input() framework.Martin Pieuchot
Move bridge_input() outside of ether_input() in order to duplicate packets flowing through a bridge port before applying any transformation on mbufs. This saves a various m_adj(9)/M_PREPEND(9) dances and remove the bridge(4) hack from vlan(4). Tested by mxb <mxb AT alumni DOT chalmers DOT se> and kettenis@ ok bluhm@
2015-06-16Store a unique ID, an interface index, rather than a pointer to theMartin Pieuchot
receiving interface in the packet header of every mbuf. The interface pointer should now be retrieved when necessary with if_get(). If a NULL pointer is returned by if_get(), the interface has probably been destroy/removed and the mbuf should be freed. Such mechanism will simplify garbage collection of mbufs and limit problems with dangling ifp pointers. Tested by jmatthew@ and krw@, discussed with many. ok mikeb@, bluhm@, dlg@
2015-06-08Merge multiple copies of the code doing VLAN tag insertion back intoMartin Pieuchot
vlan_start(). ok sthen@, phessler@
2015-06-08Move carp-related logic from ether_output() into carp_start().Martin Pieuchot
ok sthen@, phessler@
2015-06-02Take carp(4) out of ether_input().Martin Pieuchot
Tested by <mxb AT alumni DOT chalmers DOT se>, thanks! ok bluhm@, dlg@
2015-05-26Now that the Ethernet header is always passed as part of the mbuf, killMartin Pieuchot
the second (unused) argument of the input packet handlers. ok dlg@
2015-05-26move add_net_randomness from ether_input to the if_input task.David Gwynne
change it from feeding the ethertype of the packet (which is almost certainly an ip packet or vlan packet, so not that variable) to the number of packets about to be processed. ok deraadt@ mpi@
2015-05-19Take vlan(4) out of ether_input().Martin Pieuchot
To keep the list of input handlers short, multiple vlans share the same ifih. if_input_process() now looks if the interface of a mbuf changed to make sure the corresponding handlers are executed. This is a hack and will be improved later. ok dlg@
2015-05-15Introduce if_output(), a function do to the last steps before enqueuingMartin Pieuchot
a packet on the sending queue of an interface. Tested by many, thanks a lot! ok dlg@, claudio@
2015-05-13Get rid of the last "#if NTRUNK" by overwriting trunk ports' outputMartin Pieuchot
function. ok claudio@, reyk@
2015-05-11Take trunk(4) out of ether_input().Martin Pieuchot
Each physical interface of a trunk now gets a specific ifih (interface input handler) that runs before ether_input(). Tested by sthen@, dlg@, Theo Buehler and <mxb AT alumni.chalmers DOT se> ok sthen@, dlg@
2015-05-04Use ether_input() as default input packet handler and do the necessaryMartin Pieuchot
m_adj(9) to keep bridge(4) working while other pseudo-drivers are converted to if_input(). Tested by mxb <mxb AT alumni DOT chalmers DOT se>, thanks! ok henning@
2015-04-13Move one "#ifdef NVLAN" chunk needed only if you're running bridge(4) onMartin Pieuchot
to of vlan(4) from ether_input() to bridge_input(). One of the goal of the if_input() plumbing is to stop doing all possible pseudo-drivers checks on every packets. There's no reason that even if you're not running a bridge(4) you've to run this code. This change also will also makes it easier to convert vlan(4) to if_input(). Reviewed by Rafael Zalamena and mikeb@, ok markus@
2015-04-10replace the use of ifqueues for most input queues serviced by netisrDavid Gwynne
with niqueues. this change is so big because there's a lot of code that takes pointers to different input queues (eg, ether_input picks between ipv4, ipv6, pppoe, arp, and mpls input queues) and falls through to code to enqueue packets against the pointer. if i changed only one of the input queues id have to add sepearate code paths, one for ifqueues and one for niqueues in each of these places by flipping all these input queues at once i can keep the currently common code common. testing by mpi@ sthen@ and rafael zalamena ok mpi@ sthen@ claudio@ henning@
2015-04-10Run detach hook and similar before cleaning up any other resource whenMartin Pieuchot
an interface is destroyed/removed. This way we can ensure pseudo-driver changes done after attaching an interface are undone before detaching it. Note: it is safe to call if_deactivate() multiple times as the interface should not have any attached pseudo-interface after the first call. ok deraadt@, dlg@