summaryrefslogtreecommitdiff
path: root/sys/netinet/ip_carp.c
AgeCommit message (Collapse)Author
2017-11-23Replace non mp-safe carp_iamatch6() with mp-safe carp_iamatch().Martin Pieuchot
They have the same functionnality since friehm@ cleaned up balancing code. ok florian@, visa@, patrick@, bluhm@, jmatthew@
2017-11-21Move the addrhook disestablish from carpdetach() to carp_clone_destroy()Patrick Wildt
to make it symmetric to the addrhook establish which is being done in carp_clone_create(). This fixes the issue that carp does not recognize address changes on the carp after an interface has detached, which could cause issues like carp not recovering or even panics. Unfortunately there are more bugs lurking in carp. ok bluhm@
2017-11-20Sprinkle some NET_ASSERT_LOCKED(), const and co to prepare runningMartin Pieuchot
pr_input handlers without KERNEL_LOCK(). ok visa@
2017-10-16Handle the case where the parent of a carp(4) is being destroyedMartin Pieuchot
while packets where being passed to IPsec tasks. Found the hardway by Hrvoje Popovski. ok phessler@, claudio@
2017-10-09Reduces the scope of the NET_LOCK() in sysctl(2) path.Martin Pieuchot
Exposes per-CPU counters to real parrallelism. ok visa@, bluhm@, jca@
2017-08-11Remove NET_LOCK()'s argument.Martin Pieuchot
Tested by Hrvoje Popovski, ok bluhm@
2017-06-22Fix the remaining ';;'s in sys/Tom Cosgrove
2017-06-19When dealing with mbuf pointers passed down as function parameters,Alexander Bluhm
bugs could easily result in use-after-free or double free. Introduce m_freemp() which automatically resets the pointer before freeing it. So we have less dangling pointers in the kernel. OK krw@ mpi@ claudio@
2017-05-30Carp balancing ip does not work since there is a mac filter infriehm
ether_input(). Now we use mbuf tags instead of modifying the MAC address. ok mpi@
2017-05-28Leaving IP multicast group requires the NET_LOCK().Martin Pieuchot
Grab the lock before calling carpdetach(). ok bluhm@
2017-05-27Fix the carp mode 'balancing ip-stealth'. Set the link state UPAlexander Bluhm
if at least one vhid is in state MASTER. from Florian Riehm; OK florian@
2017-05-04If m is not a continuous mbuf cluster, m_pullup() in pr_input mayAlexander Bluhm
change the pointer. Then *mp keeps the invalid pointer and it might be used. Fix the potential use after free and also reset *mp in other places to have less dangling pointers to freed mbufs. OK mpi@ mikeb@
2017-04-14Pass down the address family through the pr_input calls. ThisAlexander Bluhm
allows to simplify code used for both IPv4 and IPv6. OK mikeb@ deraadt@
2017-04-11Partially revert previous mallocarray conversions that containDavid Hill
constants. The consensus is that if both operands are constant, we don't need mallocarray. Reminded by tedu@ ok deraadt@
2017-04-09Use mallocarray to allocate multicast group memberships.David Hill
ok deraadt@
2017-04-05When building counter memory in preparation to copy to userland, alwaysTheo de Raadt
zero the buffers first. All the current objects appear to be safe, however future changes might introduce structure pads. Discussed with guenther, ok bluhm
2017-03-23Replace manual loop with SRPL_FOREACH_SAFE_LOCKED macro.Alexander Bluhm
OK mpi@
2017-03-17carp(4) code is always executed in the 'softnet' thread, so removeMartin Pieuchot
unneeded splnet()/splx() dance. ok mikeb@, bluhm@
2017-02-20carp(4) percpu countersJeremie Courreges-Anglas
ok florian@
2017-01-29Change the IPv4 pr_input function to the way IPv6 is implemented,Alexander Bluhm
to get rid of struct ip6protosw and some wrapper functions. It is more consistent to have less different structures. The divert_input functions cannot be called anyway, so remove them. OK visa@ mpi@
2017-01-25Since raw_input() and route_input() are gone from pr_input, we canAlexander Bluhm
make the variable parameters of the protocol input functions fixed. Also add the proto to make it similar to IPv6. OK mpi@ guenther@ millert@
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@
2016-12-20Prevent grabing the NET_LOCK() twice in the ioctl(2) and input path.Martin Pieuchot
While here remove two redundant splsoftnet()/splx() dances. inputs and ok bluhm@
2016-12-19Introduce the NET_LOCK() a rwlock used to serialize accesses to the partsMartin Pieuchot
of the network stack that are not yet ready to be executed in parallel or where new sleeping points are not possible. This first pass replace all the entry points leading to ip_output(). This is done to not introduce new sleeping points when trying to acquire ART's write lock, needed when a new L2 entry is created via the RT_RESOLVE. Inputs from and ok bluhm@, ok dlg@
2016-11-20Rename SRPL_ENTER() to SRPL_FIRST() and SRPL_NEXT() to SRPL_FOLLOW().Martin Pieuchot
This allows us to introduce SRPL_NEXT() that can be used to start iterating on an arbitrary member of an srp list, hence without calling SRPL_ENTER(). ok dlg@, jmatthew@
2016-10-25Accept CARP advertisement packets whose destination is not for multicast.YASUOKA Masahiko
When both "carppeer" and "real mac-address" are used at once and the BACKUP is to take over the new MASTER, the present MASTER receives such packets. Found by and diff from nagasaka at iij. ok henning bluhm
2016-10-04Convert timeouts that need a process context to timeout_set_proc(9).Martin Pieuchot
The current reason is that rtalloc_mpath(9) inside ip_output() might end up inserting a RTF_CLONED route and that require a write lock. ok kettenis@, bluhm@
2016-07-25fix revision 1.290 of sys/netinet/ip_carp.c.Sebastian Benoit
diff from jsg@ ok deraadt@, benno@
2016-07-19Fix the check supposed to prevent 'ip' and 'ip-stealth' balancing modesMartin Pieuchot
from leaking the multicast address. beck@ found the hard way that this made his second CARP master use a wrong MAC address. This is part of a bigger diff from Florian Riehm who is currently working on a proper solution to fix balancing modes. ok beck@, bluhm@
2016-06-06Get rid of the ``enaddr'' argument of carp_iamatch().Martin Pieuchot
It was only checked in balancing mode, which is currently broken, and is no longer needed. Discusssed with bluhm@ and Florian Riehm.
2016-05-30Insert a hack to deal with interfaces removing the VLAN header beforeMartin Pieuchot
the packet has been feed to the pseudo-interfaces input handlers. To fix that without introducing a layer violation we should be able to disable HW-vlan on parent when in use with different pseudo-interfaces. In the case of bridge(4) for example it makes no sense to let the interface remove the VLAN header if the kernel has to add it back for every packet. Fix issues reported by sebastia@ and markus@ From dlg@, ok claudio@
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@
2016-04-13We're always ready! So send IFQ_SET_READY() to the bitbucket.Martin Pieuchot
2016-02-23provide m_dup_pkt() for doing fast deep mbuf copies with a specified alignmentDavid Gwynne
if a physical interface receives a multicast/broadcast packet and has carp interfaces on it, that packet needs to be copied for reception by each of those carp interfaces. previously it was using m_copym2, but that doesn't respect the alignment of the source packet. this meant the ip header in the copies were aligned incorrectly for the network stack, which breaks strict alignment archs. m_dup_pkt lets carp specify that the payload needs an ETHER_ALIGN adjustment, so the ip header inside will be aligned correctly. reported and tested by anthony eden who hit this on armv7 i reproduced the problem on sparc64 and verified the fix on amd64 and sparc64 ok mpi@ mikeb@ deraadt@
2016-01-21Introduce in{,6}_hasmulti(), two functions to check in the hot path ifMartin Pieuchot
an interface joined a specific multicast group. ok phessler@, visa@, dlg@
2016-01-12Prevent a NULL-reference if SIOCGVH is issued without carpdev argument.Martin Pieuchot
Problem reported by and diff tested by Fabian Raetz, thanks! ok benno@, bluhm@
2015-12-19Make carp_output() mpsafe.Martin Pieuchot
This is needed in order to fully unlock ARP processing with carp(4) interfaces as found the hardway by sthen@. ok sthen@, dlg@
2015-12-03Use SRPL_HEAD() and SRPL_ENTRY() to be consistent with and allow toMartin Pieuchot
fallback to a SLIST. ok dlg@, jasper@
2015-11-18Make use of srp_enter()/srp_leave() in carp_iamatch() in preparationMartin Pieuchot
for unlocking the ARP input path. ok dlg@
2015-11-12IFQ_DROP means a drop because enqueue on the send q failed, not cos txDavid Gwynne
later failed.
2015-11-02Remove leftovers from previous carp(4)-to-relayd(8) conversion diff.Martin Pieuchot
Pointed by and ok reyk@
2015-11-02Retire ARP load-balacing, thanks for all the fish!Martin Pieuchot
One of the keys of our MP work relies on making OpenBSD's kernel simpler! In this case turning ARP processing MP-safe is quite complicated due to the way carp(4) is hooked in arpinput() and nowadays you'd better run kitchensinkd(9) anyway :) ok bluhm@, claudio@, reyk@
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-22Do not pass an ``ia'' just to dereference ``ia_ifp''.Martin Pieuchot
ok claudio@, bluhm@, jsg@
2015-10-14Init a variable in the recently added carp_vhe_match() function clangJonathan Gray
and mpi believe could be used uninitialised. ok mpi@
2015-10-05Revert if_oqdrops accounting changes done in kernel, per request from mpi@.Masao Uebayashi
(Especially adding IF_DROP() after IFQ_ENQUEUE() was completely wrong because IFQ_ENQUEUE() already does it. Oops.) After this revert, the situation becomes: - if_snd.ifq_drops is incremented in either IFQ_ENQUEUE() or IF_DROP(), but it is not shown to userland, and - if_data.ifi_oqdrops is shown to userland, but it is not incremented by anyone.
2015-10-05Don't count IF_DROP()'ed packets as if_oerrors too.Masao Uebayashi
mpi@ plans to clean-up IF_DROP()'s, but fix consistent use of it for now. OK dlg@
2015-09-28Factors ou the route hashing code to implement Equal-Cost Multi-PathMartin Pieuchot
for ART. While here sync the two remaining mix() macros. ok chris@, dlg@
2015-09-27make carp_input mpsafe.David Gwynne
there are three data structures involved here: the list of carp interfaces on a parent interface (struct carp_if) is now accessed via the if_ih cookie. its lifetime is managed by the if_ih_insert and if_ih_remove calls. the second is the interfaces (struct carp_softc) in the list above. these has been moved from being access via a TAILQ to an SRPL. modifications to the list are serialised by the kernel lock. the third is the list of vhost entries (struct carp_vhost_entry). these used to be in a LIST on each carp_softc, but have been moved to being accessed vian an SRPL. modifications to the list are serialised by the kernel lock. written at l2k15 tested by mpi@ and hrvoje popovski ok mpi@
2015-09-12consistently name the ifnet * that refers to the parent interfaceDavid Gwynne
ifp0, and the ifnet * that refers to the carp interface ifp. this makes it easier for me to read. it's probably not the right name for ifp0, but at least it's consistent. ok sthen@ bluhm@ mpi@ claudio@