summaryrefslogtreecommitdiff
path: root/sys/net/if_ethersubr.c
AgeCommit message (Collapse)Author
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@
2015-04-07Do not pass an `ifp' argument to interface input handlers since itMartin Pieuchot
might be overwritten by pseudo-drivers. ok dlg@, henning@
2015-03-17Merge two "#ifdef NCARP" chunks.Martin Pieuchot
"Look safe" henning@, ok florian@
2015-02-16avoid double vlan-header or vlan-header for non-vlan(4) interfacesMarkus Friedl
(will panic) in bridge context; ok henning@
2015-02-09move the init of the if_input from ether_ifattach to if_attach.David Gwynne
ok mpi@
2015-02-08Introduce if_input() a function to pass packets dequeued from aMartin Pieuchot
recieving ring to the stack. if_input() is at the moment a drop-in replacement for ether_input_mbuf() but will let us stack pseudo-driver in a nice way in order to no longer call ether_input() recursively. ok pelikan@, reyk@, blambert@, henning@
2015-02-06earlier rev 1.112 sys/net/if_vlan.c corrects the mapping of 802.1pSebastian Benoit
prio from the vlan header to our pf priority levels. This fixes the mapping on the ouput path. ok henning
2015-01-08Factorize various duplicated chunks of (old and horrible) code, checkingMartin Pieuchot
for the validity of a given outgoing route entry into a single function. This change is inspired from FreeBSD r111767. The function introduced here, rt_checkgate(), should hopefully die in a near future. Why should it die? Well, it is way too late to do such validity checks: if your kernel can ends up in ether_output() with an invalid route, please do not let it try to find a new one that might do the job. Go read this function if you're wondering why you're getting messages like: "arpresolve: X.X.X.X: route without link local address" Since this horrible logic has survived 20 years of copy & past and small modifications for workarounds without a single clear commit message, let's assume it is full of dragons and try to play safe. This factorization is not intended to change any behavior. With much inputs from bluhm@, tested by weerd@ and florian@ on setups with p2p IPv6 interfaces. ok bluhm@, benno@, florian@
2014-12-19unifdef INET in net code as a precursor to removing the pretend option.Ted Unangst
long live the one true internet. ok henning mikeb
2014-12-08There's no good reason to keep into "struct ifnet" a pointer that's onlyMartin Pieuchot
used by enc(4) devices to attach their routes. ok sthen@, mikeb@
2014-12-04use siphash for trunk loadbalancing. ok deraadtTed Unangst
2014-12-01reconvert (rereconvert?) to memcpy except in the one case where memmoveTed Unangst
is needed. more thoroughly reviewed. ok deraadt
2014-11-29restore the "hot" memcpy that existed before recent conversion flipflopTed Unangst
2014-11-20Yet more #include de-duplication.Kenneth R Westerback
ok deraadt@ tedu@
2014-11-19bulk convert memcpy to memmove. at least one bcopy conversion was wrong,Ted Unangst
so use the safer function. can be converted back to memcpy if necessary, but later and only after more careful inspection.
2014-11-06fix mac address selection with unnumbered carpdevsHenning Brauer
IP-traffic over a carp interface with the underlaying carpdev being unnumbered (in the numbered case usually the ifp is the carpdev to begin with) went out with the carpdev's mac address istead of the carp interface's one due to a carp hack in ether_output exchanging the carp ifp for its carpdev ones one. move the source mac selection to before that. fixes unnumbered carp use in environments with strict mac address regimes like some exchange points. issue found by your's truly the hard way. ok mpi dlg
2014-11-01Rename rtalloc1() into rtalloc(9) and convert its flags to only enableMartin Pieuchot
functionnality instead of a mix of enable/disable. ok bluhm@, jca@
2014-10-07remove preliminary AOE (ata over ethernet) support. not finished afterTed Unangst
many years and wide spread demand for support never materialized. time to pack it in.
2014-07-12add a size argument to free. will be used soon, but for now default to 0.Ted Unangst
after discussions with beck deraadt kettenis.
2014-07-08pull the rx ring accounting out of the mbuf layer now that its all doneDavid Gwynne
via if_rxring things. this effectively deprecates the third argument for MCLGETI and m_clget and makes the mbuf layer no longer care about interfaces and simplifies the allocation paths. the timeout used to measure livelock has been moved to net/if.c. ok mpi@
2014-04-22NULL is cooler than 0 when pointers are concernedHenning Brauer
ok gcc & md5 (aka no binary change)
2014-04-22we used to handle the vlan tag etc insertion very very very late,Henning Brauer
on al already ass embed ethernet frame, which meant: -copy (most of) the existing ethernet header into a ether_vlan_header on the stack -fill the extra fields in ether_vlan_header -set the ether type -m_adj() to make room for the extra space ether_vlan_header needs -m_copyback the ether_vlan_header into the mbuf that involves moving data around, which isn't all that cheap. cleaner & easier to have ether_output prepend the ether_vlan_header instead of the regular ethernet header, which makes the vlan tagging essentially free in most cases. help & ok reyk, naddy; waste of time bikeshedding tech@
2014-04-21g/c hdrcmplt var, we can just set the esrc ptr earlier and re-set it inHenning Brauer
the pseudo_AF_HDRCMPLT case, ok claudio reyk
2014-04-21__inline -> inlineHenning Brauer
2014-04-20factor our ether_addheader for readability; there's more to come thereHenning Brauer
ok claudio reyk
2014-04-20ether_output: instead of assembling the ethernet header and then callingHenning Brauer
carp_rewrite_lladdr to overwrite the src lladdr, get the intended src lladdr before assembling the ethernet header. carp_rewrite_lladdr -> carp_get_srclladdr ok reyk claudio
2014-04-20ether_output: instead of using an esrc buffer in which we copy the intendedHenning Brauer
src lladdr just to copy it from the esrc buffer into the ethernet header a few lines later, use an esrc pointer to figure out where to copy the src lladdr from. ok claudio reyk
2014-04-14"struct pkthdr" holds a routing table ID, not a routing domain one.Martin Pieuchot
Avoid the confusion by using an appropriate name for the variable. Note that since routing domain IDs are a subset of the set of routing table IDs, the following idiom is correct: rtableid = rdomain But to get the routing domain ID corresponding to a given routing table ID, you must call rtable_l2(9). claudio@ likes it, ok mikeb@
2014-03-26bcmp -> memcmpMartin Pieuchot
2014-03-26No need to check here if the destination address is ours, because inMartin Pieuchot
such case loouput() is called not ether_output(). ok claudio@, mikeb@
2014-02-17Convert bcopy()s to memcpy()s.Martin Pieuchot
ok pelikan@, tedu@