summaryrefslogtreecommitdiffstats
path: root/sys/netinet/ip_carp.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Start refcounting interface groups with 1. if_creategroup() returnsbluhm2021-02-081-5/+2
| | | | | | | a new object that is already refcounted, so carp attach does not reach into internal structures. Add kasserts to detect counter overflow or underflow. OK mvs@
* carp(4): convert ifunit() to if_unit(9)mvs2021-01-211-3/+6
| | | | ok dlg@ bluhm@
* - fix use after free, when packet gets dropped.sashan2021-01-041-5/+3
| | | | | | patch submitted by Ralf Horstmann from ackstorm.de OK dlg@
* Don't treat an error if carppeer is an unicast and the peer is down.yasuoka2020-07-281-2/+4
| | | | ok kn
* After the previous commit, src/regress/sys/netinet/carp triggeredbluhm2020-07-281-3/+3
| | | | | an uvm fault. Check that ifp0 is not NULL. OK sashan@ mvs@
* Use interface index instead of pointer to `ifnet' in carp(4).mvs2020-07-241-54/+90
| | | | ok sashan@
* move carp_input into ether_input, instead of via an input handler.dlg2020-07-221-22/+6
| | | | | | | | carp_input is only tried after vlan and bridge handling is done, and after the ethernet packet doesnt match the parent interfaces mac address. this has been in snaps as part of a larger diff for over a week.
* don't count packets in the carp protocol handling against an interface.dlg2020-05-211-7/+1
| | | | | | | these packets have generally already been counted on the interface because that's where they were sent or received from. the protocol handling side of things already counts things like packets, which you see with netstat -sp carp.
* implement a carp_transmit that bypasses the ifq on output.dlg2020-05-211-41/+65
| | | | | | | | | | | | this is modelled on vlan_transmit, and basically enqueues the packet directly on the parent interface. even though carp is generally not used to transmit packets, we run dhcp relays on it at work and hit a situation where we unecessarily dropped packets because it's ifq maxlen was 1. i've been running this for a month in production. ok jmatthew@
* remove some trailing whitespace. no functional change.dlg2020-04-291-5/+5
|
* void being too clever about setting/clearing ifpromisc on the parent.dlg2019-11-081-8/+6
| | | | | | ifpromisc() already refcounts, so carp doesn't have to do it implicitly with the carpdev list. there's no functional change, the code just gets a bit simpler.
* convert interface address change hooks to tasks and a task_list.dlg2019-11-081-6/+6
| | | | | | | | | | | | | | | this follows what's been done for detach and link state hooks, and makes handling of hooks generally more robust. address hooks are a bit different to detach/link state hooks in that there's only a few things that register hooks (carp, pf, vxlan), but a lot of places to run the hooks (lots of ipv4 and ipv6 address configuration). an address hook cookie was in struct pfi_kif, which is part of the pf abi. rather than break pfctl -sI, this maintains the void * used for the cookie and uses it to store a task, which is then used as intended with the new api.
* turn the linkstate hooks into a task list, like the detach hooks.dlg2019-11-071-47/+27
| | | | | | | | | | | | | | | 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@
* replace the hooks used with if_detachhooks with a task list.dlg2019-11-061-14/+8
| | | | | | | | | | | | | | | | | | | | | | | | 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@
* Use mallocarray(9) & put some free(9) sizes for M_IPMOPTS allocations.mpi2019-06-101-5/+5
| | | | ok semarie@, visa@
* a first cut at converting some virtual ethernet interfaces to if_vinputdlg2019-04-231-8/+4
| | | | | | | | | | this let's input processing bypass ifiqs. there's a performance benefit from this, and it will let me tweak the backpressure detection mechanism that ifiqs use without impacting on a stack of virtual interfaces. ive tested all of these except mpw, which i will end up testing soon anyway.
* Switch from timeout_add with tvtohz to just timeout_add_tv. Now this changeclaudio2018-12-171-7/+7
| | | | | | | will reduce the sleep time by one tick which doesn't matter in the common case. The code never passes a true 0 timeval to timeout_add_tv so the code will always sleep for at least 1 tick which is good enough. OK kn@, florian@, visa@, cheloha@
* Use m_align() and while there reorder the pkthdr initalisation a bit.claudio2018-12-041-8/+6
| | | | | This also makes the IPv4 and IPv6 code more similar. OK phessler@
* Turn carp_ourether() mp-safe, this is a requirement for taking bridge(4)mpi2018-09-241-16/+15
| | | | | | out of the KERNEL_LOCK(). ok visa@, bluhm@
* Remove DELAY(1000) from carp_send_arp() / carp_send_na() since it is not clearfriehm2018-07-101-3/+1
| | | | | | | why it was necessary. OK bluhm@ 'ok but watch for fallouts' mpi@
* All places that call carp_lsdrop() use the interface pointer already.bluhm2018-05-211-17/+10
| | | | | | | | It does not make sense to call if_get() again, just pass ifp as parameter. Move the IFT_CARP check into the function instead of doing it everywhere. Replace the inverted match variable logic with simple returns. OK mpi@ friehm@
* The function carp_prepare_ad() never fails. The error handling inbluhm2018-03-211-9/+5
| | | | | | the caller would leak a mbuf. Convert carp_prepare_ad() to a void function and remove the error check. reported by Maxime Villard; OK mpi@
* Remove almost unused `flags' argument of suser().mpi2018-02-191-3/+3
| | | | | | | 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@
* Unbreak carp(4) MAC check in bridge_process().mpi2018-02-071-3/+6
| | | | | | | Introduce bridge_ourether() and move carp(4)-specific SRPL code inside carp_ourether(). ok bluhm@
* Use a workaround for detached parent in carp_proto_input_c().mpi2018-01-251-4/+13
| | | | | | | | | | | | | | A NULL dereference can happen since processing protocol layer is deffered to a second task. In other words the NET_LOCK() is released then regrabbed between ip_input() and carp_proto_input(). The same workaround is already in use in carp_output() due to deffered processing in case of IPsec. The real fix is to make carp(4) MP-safe and use if_get(9) there, any taker? Found & fix tested by Hrvoje Popovski.
* have carp use standard detach hooks instead of getting special handlingdlg2018-01-121-24/+31
| | | | | | | | | | | | | if_deactivate looked for carp parent interfaces and called carp_ifdetach to have children interfaces unplug themselves. this diff has the carp interfaces register detach hooks on the parent instead. the effect is the same, but using the standard every other interface uses. while im here i shuffle the order the hooks carp_set_ifp are estabilshed so it will fail if they arent allocated. ok visa@ mpi@
* unbreak configurations using carppeersdlg2018-01-121-2/+9
| | | | | | | | | | | | | ip_carp.c r1.322 removed the ability to receive carp protocol packets on !IFT_CARP interfaces. however, carppeers cause the carp protocol packets to be directed to a unicast address on another interface, which definitely is not mapped back to a carp interface. this brings back the ability to get carp packets on parent interfaces. it is a bit different to a backout because it only allows carp parents to be ethernet interfaces. mpi@ told me carp regress tests were failing.
* restrict carp to configuring ethernet interfaces as carpdevs.dlg2018-01-121-5/+5
| | | | | | | | previously the driver only cared that a carp interface wasnt configured as a carpdev. because the code only really works on ethernet, it makes sense to restrict it. ok visa@ mpi@
* carp_ourether gets passed the parent interface, not the carp interface.dlg2018-01-111-2/+2
|
* get rid of struct carp_if by moving the srpl into struct ifnet if_carp.dlg2018-01-101-72/+55
| | | | | | | | | | | | | currently carp uses a struct carp_if to hold an srp list head, which is accessed by both if_carp in struct ifnet, and via the if input handlers list. this gets rid of some indirection by making if_carp itself the list head, rather than a pointer to the list head via a struct carp_if. it also makes accessing the list consistent by only using if_carp to get to it. ok mpi@
* simplify the input interface type check in carp_proto_input_if.dlg2018-01-101-3/+2
| | | | | | | | | carp6_proto_input_if only handles packets "received" on real carp interfaces, which the ethernet stack goes to a lot of trouble to provide. since carp assumes ethernet, carp_proto_input_if can assume the packets will come in right too. ok mpi@
* Creating a cloned interface could return ENOMEM due to temporarybluhm2018-01-091-5/+2
| | | | | | memory shortage. As it is invoked from a system call, it should not fail and wait instead. OK visa@ mpi@
* Replace non mp-safe carp_iamatch6() with mp-safe carp_iamatch().mpi2017-11-231-17/+1
| | | | | | | They have the same functionnality since friehm@ cleaned up balancing code. ok florian@, visa@, patrick@, bluhm@, jmatthew@
* Move the addrhook disestablish from carpdetach() to carp_clone_destroy()patrick2017-11-211-4/+3
| | | | | | | | | | 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@
* Sprinkle some NET_ASSERT_LOCKED(), const and co to prepare runningmpi2017-11-201-2/+6
| | | | | | pr_input handlers without KERNEL_LOCK(). ok visa@
* Handle the case where the parent of a carp(4) is being destroyedmpi2017-10-161-2/+9
| | | | | | | | while packets where being passed to IPsec tasks. Found the hardway by Hrvoje Popovski. ok phessler@, claudio@
* Reduces the scope of the NET_LOCK() in sysctl(2) path.mpi2017-10-091-2/+7
| | | | | | Exposes per-CPU counters to real parrallelism. ok visa@, bluhm@, jca@
* Remove NET_LOCK()'s argument.mpi2017-08-111-12/+7
| | | | Tested by Hrvoje Popovski, ok bluhm@
* Fix the remaining ';;'s in sys/tom2017-06-221-2/+2
|
* When dealing with mbuf pointers passed down as function parameters,bluhm2017-06-191-3/+3
| | | | | | | 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@
* Carp balancing ip does not work since there is a mac filter infriehm2017-05-301-10/+42
| | | | | | | ether_input(). Now we use mbuf tags instead of modifying the MAC address. ok mpi@
* Leaving IP multicast group requires the NET_LOCK().mpi2017-05-281-1/+5
| | | | | | Grab the lock before calling carpdetach(). ok bluhm@
* Fix the carp mode 'balancing ip-stealth'. Set the link state UPbluhm2017-05-271-14/+15
| | | | | if at least one vhid is in state MASTER. from Florian Riehm; OK florian@
* If m is not a continuous mbuf cluster, m_pullup() in pr_input maybluhm2017-05-041-3/+3
| | | | | | | 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@
* Pass down the address family through the pr_input calls. Thisbluhm2017-04-141-3/+3
| | | | | allows to simplify code used for both IPv4 and IPv6. OK mikeb@ deraadt@
* Partially revert previous mallocarray conversions that containdhill2017-04-111-3/+3
| | | | | | | | | constants. The consensus is that if both operands are constant, we don't need mallocarray. Reminded by tedu@ ok deraadt@
* Use mallocarray to allocate multicast group memberships.dhill2017-04-091-3/+3
| | | | ok deraadt@
* When building counter memory in preparation to copy to userland, alwaysderaadt2017-04-051-1/+2
| | | | | | zero the buffers first. All the current objects appear to be safe, however future changes might introduce structure pads. Discussed with guenther, ok bluhm
* Replace manual loop with SRPL_FOREACH_SAFE_LOCKED macro.bluhm2017-03-231-5/+2
| | | | OK mpi@
* carp(4) code is always executed in the 'softnet' thread, so removempi2017-03-171-7/+1
| | | | | | unneeded splnet()/splx() dance. ok mikeb@, bluhm@