summaryrefslogtreecommitdiff
path: root/sys/net/if_trunk.c
AgeCommit message (Collapse)Author
2015-11-21dont check IFF_OACTIVE to see if the port is busy.David Gwynne
dont check if its busy at all, actually. fine with reyk@
2015-11-20dont play with IFF_OACTIVE needlessly.David Gwynne
only a driver sets or clears it, and trunk never sets it. therefore it never needs to clear it.
2015-11-12Prefix flowid with ph_ and print it in m_print().Martin Pieuchot
ok dlg@
2015-10-25arp_ifinit() is no longer required.Martin Pieuchot
2015-10-08Make sure that when trunk_port_ioctl is called to set a newMike Belopuhov
lladdr the trunk port is already on the list. OK mpi
2015-10-08if the mbuf has a valid flowid, use it instead of using siphash24David Gwynne
and a bunch of header fields we have to parse the mbuf for. siphash24 is about 20% of the cost of sending a udp packet on a trunk interface with tcpbench on my box. if there's a flowid set we get all that back. ok mpi@ mikeb@ sthen@
2015-10-05Factor LACP frame processing out to a separate taskMike Belopuhov
This is slightly refactored version of the diff by jmatthew@ that makes use of a single per-trunk task but retains per-port mbuf queues. Running LACP frame processing in a task context allows a simple way to synchronize changes to the trunk ports and trunk itself performed from the ioctl, timeout and task contexts with a kernel lock. OK mpi
2015-09-29add sizes to some of the simpler free callsTheo de Raadt
ok mpi
2015-09-28Remove "if_tp" from the "struct ifnet".Martin Pieuchot
Instead of violating a layer of abstraction by keeping per pseudo-driver informations in "struct ifnet", the port trunk is now passed as a cookie to the interface input handler (ifih). The time of per pseudo-driver hack in the network stack is over! ok mikeb@
2015-09-24add a comment explaining how we serialize when switching trunkproto;Mike Belopuhov
requested by mpi@
2015-09-24Avoid a theoretical m_pullup(9) mishandling by delegating the mbufMike Belopuhov
reclaiming to the PDU and marker input routines. m_pullup may return a pointer to the newly allocated mbuf. In this case m_freem is called by the trunk_input, not by the proto specific code and pointer to the mbuf is not passed by reference. Therefore m_freem will either be called on the middle element of the chain (when the m_pullup call succeeds) or on the stale pointer (when it frees the chain in the failure case). Fortunately we should never hit this case as the receive path uniformly uses contiguous chunks of memory. Verified with and ok blambert, ok mpi
2015-09-23Serialize trunk changes with input handler insertion and removal.Mike Belopuhov
This moves around calls to if_ih_insert and if_ih_remove to ensure that we either have completed port initialization or are going to tear the port configuration down and don't want any input processes to get hold of the port. When trunk_port_destroy is called from the ioctl this would wait for all input processes to finish and release their references to be able to disestablish the input handler and ensure full control of the port. When switching trunkproto it is required for the ioctl context to be able to touch all trunk ports and the protocol (tr_psc). The easiest way do this is to disestablish all input handlers (while making sure they all complete) and then reestablish them after the trunk reconfiguration is completed. This avoids getting trunk a separate locking protocol of its own. ok mpi, suggested by and ok dlg
2015-09-23Keep track of an active port in the failover trunk to avoid listMike Belopuhov
iterations and additional locking protection in the future. Suggested by and ok mpi
2015-09-23Remove trunk watchdog code since it doesn't do anything usefulMike Belopuhov
and we want to limit the number of different places where we access trunk port pointers. trunk_watchdog should be never called as we don't set up it's if_timer and trunk_port_watchdog just calls the if_watchdog from the underlying interface. It's possible that this is no longer needed due to if_slowtimo/ if_watchdog changes done earlier. ok mpi
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-17Drop promiscuously received packets if the trunk(4) interface is notMartin Pieuchot
in promiscuous mode. The long story is that claudio@ had his ssh session reset multiple times in the hackroom because czarkoff@'s machine was sending reset. We figured out that the packet was reaching pf because of this missing check. pf would then not find any state and sent a reset. Analyzed with and ok phessler@, claudio@
2015-07-02Unify the check for up & running between all pseudo-drivers.Martin Pieuchot
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-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-24Increment if_ipackets in if_input().Martin Pieuchot
Note that pseudo-drivers not using if_input() are not affected by this conversion. ok mikeb@, kettenis@, claudio@, dlg@
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-15Fix a double free in the destroy path triggered when a second process,Martin Pieuchot
in my case dhclient(8), races with ifconfig(8) to free the descriptors of the joined multicast groups. While here reduce the difference with carp(4). ok dms@
2015-06-09Convert trunk(4) to if_input().Martin Pieuchot
ok 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-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-14Allocate the input packet handler as part of the trunk_port structureMartin Pieuchot
since they have the same lifetime. Requested by and ok dlg@
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-03-14Remove some includes include-what-you-use claims don'tJonathan Gray
have any direct symbols used. Tested for indirect use by compiling amd64/i386/sparc64 kernels. ok tedu@ deraadt@
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-04use siphash for trunk loadbalancing. ok deraadtTed Unangst
2014-12-01Make every interface with a watchdog register it's own slow timeoutMike Belopuhov
This removes the system wide if_slowtimo timeout and lets every interface with a valid if_watchdog method register it's own in order to get rid of the ifnet loop in the softclock context and avoid further complications with concurrent access to the ifnet list. ok deraadt, input and ok mpi, looked at by claudio
2014-11-18move arc4random prototype to systm.h. more appropriate for most codeTed Unangst
to include that than rdnvar.h. ok deraadt dlg
2014-07-22Fewer <netinet/in_systm.h> !Martin Pieuchot
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-09bpf code surgery / shuffling / simplification.Henning Brauer
the various bpf_mtap_* are very similiar, they differ in what (and to some extent how) they prepend something, and what copy function they pass to bpf_catchpacket. use an internal _bpf_mtap as "backend" for bpf_mtap and friends. extend bpf_mtap_hdr so that it covers all common cases: if dlen is 0, nothing gets prepended. copy function can be given, if NULL the default bpf_mcopy is used. adjust the existing bpf_mtap_hdr users to pass a NULL ptr for the copy fn. re-implement bpf_mtap_af as simple wrapper for bpf_mtap_hdr. re-implement bpf_mtap_ether using bpf_map_hdr re-implement bpf_mtap_pflog as trivial bpf_mtap_hdr wrapper ok bluhm benno
2014-03-10if_lladdr -> if_sadl, no functional change.Martin Pieuchot
ok mikeb@
2013-11-21Remove unneeded include.Martin Pieuchot
ok deraadt@
2013-11-18Convert trunk(4) to use a detachhook, discussed at b2k13 with many.Martin Pieuchot
While here add a comment explaining detach hooks' order of execution when destroying/detaching an interface.
2013-06-20Revert previous and unbreak asr, the new include should be protected.Martin Pieuchot
Reported by naddy@
2013-06-20Allocate the various hook head descriptors as part of the ifnetMartin Pieuchot
structure rather than doing various M_WAITOK allocations during the *attach() functions, we always rely on them anyway. ok mikeb@, uebayasi@
2013-05-11Set trunk(4)'s MTU to that of the first trunkport. Allows trunk to work withStuart Henderson
jumbo/baby-jumbo frames. To avoid problems with mismatches between trunkports, any additional ports must have the same MTU as already set on the trunk(4). Based on changes made in FreeBSD. Tested by myself and jj@, ok reyk@
2013-04-02Instead of storing the link-level address of every interface in a globalMartin Pieuchot
array indexed by interface numbers, add a new field to the interface descriptor pointing to it. claudio@ and todd@ like it, ok mikeb@
2013-03-28no need for a lot of code to include proc.hTed Unangst
2013-02-25trunk_bcast_start sent packets on all its member interfaces by copyingDavid Gwynne
the mbuf it just sent on the previous interface. this is bad because the previous interface could have modified the mbuf chain, which can make the subsequent m_copym()s panic. this copies the dance that rtsock.c does for broadcasting mbufs which copies the mbuf before transmit, except for the last interface which it handles outside the loop. tested by halex@ who verified it fixes his panic. ok claudio@ deraadt@
2011-10-28Take more care to ensure all callbacks are initialized. In particularKenneth R Westerback
tr_linkstate() was not initialized in trunk_rr_attach(), and tr_init() and tr_stop() were missing in trunk_lb_attach(). Fixes crash triggered by changing trunkproto, reported by Anders Berggren on bugs@. ok mpf henning
2011-01-28Fix another memory leak by replacing m_free() with m_freem() in trunk'sReyk Floeter
broadcast mode. ok blambert@ mikeb@
2010-11-12avoid pointer arithmetic on void *David Hill
no change in .o ok claudio