summaryrefslogtreecommitdiff
path: root/sys/netinet/if_ether.c
AgeCommit message (Collapse)Author
2017-03-06Prefix functions dealing with routing messages with 'rtm_' and keepMartin Pieuchot
them all in net/rtsock.c. This allows to easily spot which functions are doing a copyout(9) when dealing with the routing midlayer. ok phessler@, bluhm@, dhill@, krw@, claudio@
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-20Make rtable_iterate(9) mpsafe by using the new SRPL_NEXT(9).Martin Pieuchot
ok dlg@, jmatthew@
2016-11-07ARP and NDP timeouts mess with the routing table, so they need a processMartin Pieuchot
context. Convert them to timeout_set_proc(9).
2016-09-15all pools have their ipl set via pool_setipl, so fold it into pool_init.David Gwynne
the ioff argument to pool_init() is unused and has been for many years, so this replaces it with an ipl argument. because the ipl will be set on init we no longer need pool_setipl. most of these changes have been done with coccinelle using the spatch below. cocci sucks at formatting code though, so i fixed that by hand. the manpage and subr_pool.c bits i did myself. ok tedu@ jmatthew@ @ipl@ expression pp; expression ipl; expression s, a, o, f, m, p; @@ -pool_init(pp, s, a, o, f, m, p); -pool_setipl(pp, ipl); +pool_init(pp, s, a, ipl, f, m, p);
2016-09-07Rename rtable_mpath_next() into rtable_iterate() and make it do a properMartin Pieuchot
reference count. rtable_iterate() frees the passed ``rt'' and returns the next one on the multipath list or NULL if there's none. ok dlg@
2016-09-06pool_setipl for various netinet and netinet6 bitsDavid Gwynne
thank you to everyone who helped reviewed these diffs ok mpi@
2016-08-22Make the ``rt_gwroute'' pointer of RTF_GATEWAY entries immutable.Martin Pieuchot
This means that no protection is needed to guarantee that the next hop route wont be modified by CPU1 while CPU0 is dereferencing it in a L2 resolution functions. While here also fix an ``ifa'' leak resulting in RTF_GATEWAY being always invalid. dlg@ likes it, inputs and ok bluhm@
2016-07-14Prevent a use-after-free by not updating an ARP entry that has beenMartin Pieuchot
removed from the table. Currently the storage for L2 addresses is freed when an entry is removed from the table. That means that we cannot access this chunk of memory between RTM_DELETE and rtfree(9). Note that this doesn't apply to MPLS because the associated storage is currently released by the last rtfree(9). ok mikeb@
2016-07-13Move ARP processing back to the KERNEL_LOCK()ed task until the raceMartin Pieuchot
triggered by updating a cached, but removed from the table, entry is properly fixed. Diff from dlg@, prodding deraadt@
2016-07-13Introduce RTF_MULTICAST and flag corresponding IPv6 routes as suchMartin Pieuchot
instead of abusing RTF_CLONING. Fix a leak reporeted by Aaron Riekenberg on misc@, ok sthen@
2016-07-11Revert the introduction of ``rt_addr''.Martin Pieuchot
Being able to add route entries without configured addresses is a nice feature but this is not my fight. So I'd rather no add another pointer to ``struct rtentry'' if I'm not removing another one.
2016-06-28Add sysctl for arp timers: net.inet.ip.arptimeout (expire timer for resolvedChris Cappuccio
entries) and net.inet.ip.arpdown (expire timer for unresolved entries) ok mpi@
2016-06-14Store the source address associated with a route in its own chunk ofMartin Pieuchot
memory. This will allow to unlink 'sruct rtentry' and 'struct ifaddr' to be able to add route entries without needing an address. ok sthen@, visa@, florian@
2016-06-10Add the "llprio" field to struct ifnet, and the corresponding keywordVincent Gross
to ifconfig. "llprio" allows one to set the priority of packets that do not go through pf(4), as the case is for arp(4) or bpf(4). ok sthen@ mikeb@
2016-06-06Move logic to send ARP replies to arpreply().Martin Pieuchot
ok florian@, dlg@
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-06-03set rt_expire times against time_uptime, not time_second.David Gwynne
time_second is unix time so it can be affected by clock changes. time_uptime is monotonic so it isnt affected by clock changes. that in turn means route expiries wont jump with clock changes if set against time_uptime. the expiry is translated into unix time for export to userland though. ok mpi@
2016-05-31Stop creating and inserting a route entry for ARP and ND automagically.Martin Pieuchot
Callers MUST do a route lookup before sending a packet. Tested by Hrvoje Popovski, ok visa@, bluhm@
2016-05-23Pass a 'struct in_addr *' to arplookup() instead of always dereferencingMartin Pieuchot
one.
2016-05-23Shorten en error string.Martin Pieuchot
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-05-18Move the code to update an ARP cache into its own function.Martin Pieuchot
ok visa@
2016-04-27Remove unused arguments from rt_checkgate().Martin Pieuchot
Since the rtalloc(9) rewrite no route lookup is done in this function so there's no need for a destination or a rtable ID.
2016-03-30Implement proxy ARP for ART based on mpath support.Martin Pieuchot
Since mpath is not enabled in RAMDISK, proxy ARP won't work there either. ok bluhm@
2016-03-24Ensure that a found proxy ARP entry has the correct flag.Martin Pieuchot
ok bluhm@
2016-03-07Do not remove RTF_STATIC L2 entries from the routing table.Martin Pieuchot
This restore the previous behavior without looking at the reference counter of route entries. Static entries might not have a cloning route to re-create them and when their timer expires they were completly gone as found the hardway by matthieu@. ok matthieu@
2016-01-21remove the arp_inuse and arp_allocated countersDavid Gwynne
we can get the same info from the arp pool: # vmstat -m | grep -e ^arp -e ^Name Name Size Requests Fail InUse Pgreq Pgrel Npage Hiwat Minpg Maxpg Idle arp 56 84 0 6 1 0 1 1 0 8 0 Requests and InUse end up being the same: # pstat -d d arp_allocated arp_allocated at 0xffffffff81942084: 84 # pstat -d d arp_inuse arp_inuse at 0xffffffff81942098: 6 ok bluhm@ claudio@ mpi@
2016-01-14Grab the KERNEL_LOCK before delivering a message to the routing socketMartin Pieuchot
when an ARP resolution has been done. Should hopefully fix the "receive 1" panic reported by benno@ on bugs@. ok claudio@, phessler@, benno@, bluhm@
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-17rm a bit more trailers code. no longer accept them as alias for ethernet.Ted Unangst
ok mpi
2015-12-02Since we want to print the interface names in the log messages it isClaudio Jeker
required to do the if_get/if_put dance around the log() calls. These were the last users of rt_ifp. OK mpi@ bluhm@
2015-12-02More rt_ifp killing. There checks in in_arpinput() to verify that theClaudio Jeker
arp packet was recieved on the interface we expected. This is because multicast and broadcast packets are sometimes forwarded on multiple local interfaces. So simplify the checks and make them more generic at the same time (in the SIN_PROXY case). For SIN_PROXY only the interface holding the proxy arp route will answer to the requests. OK mpi@
2015-12-02There is no reason for this carp magic in arpresolve. rt->rt_ifp has toClaudio Jeker
be the same as ifp or something is very broken. So remove this including one more rt_ifp. OK mpi@
2015-12-02When destroying an interface, we have to wait until all referencesAlexander Bluhm
are not used anymore. This has to be done before any interface fields become invalid. As the route delete request cannot call if_get() anymore, pass down the interface. Split rtrequest_delete() into a separate function that may take an existing inteface. OK mpi@
2015-12-02Kill the RT_REPORT flag to rtalloc() and stop sending RTM_MISS messagesClaudio Jeker
for failed route lookups. This is something that was maybe useful in the 90is but in this modern times it is just annoying and nothing expect it anyway. OK mpi@, sthen@
2015-12-02Do not delete a conflicting & cloned route entry in the hot path.Martin Pieuchot
Deleting a RTF_CLONED entry without deleting its corresponding RTF_CLONING entry wont help as it will be cloned the next time arplookup() is executed. ok claudio@
2015-12-01Remove backward compatibility for "older version of routed and gated".Martin Pieuchot
ok millert@, bluhm@
2015-11-20This no longer depends on bridge.h, fewer "#ifdef NBRIDGE", say yeah!Martin Pieuchot
2015-11-20Fewer uses of rt_ifp.Martin Pieuchot
Tested by and ok sthen@,
2015-11-18Factorize the bits to check if a L2 route is connected, wether it isMartin Pieuchot
attached to a carp(4) or bridge(4) member, to not dereference rt_ifp directly. ok visa@
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-13Sore the index of the interface used for revarp instead of a pointer toMartin Pieuchot
its descriptor. Get rid of a if_ref(). ok dlg@
2015-11-06In in_arpinput() do not make an extra route lookup to check wetherAlexander Bluhm
the sender address is a local IP. The arplookup() does this route lookup anyway, so just check its result. OK mpi@
2015-11-05In in_arpinput() replace the loops over the interface addressesAlexander Bluhm
with route lookups. Check wether ARP sender or target protocol address is a local IP address. Remove the loop that checks wether any IPv4 address is configured on the receiving interface. input, test, OK mpi@
2015-11-04use ml_purge to flush the arp hold lists instead of dequeue/free loops.David Gwynne
this is an interesting change because the loops have to decrement the global hold count too. they looked like this: while ((mh = ml_dequeue(&la->la_ml)) != NULL) { la_hold_total--; m_freem(mh); } because ml_purge returns how many mbufs were freed, we can do this: la_hold_total -= ml_purge(&la->la_ml); ok mpi@ bluhm@
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-11-02Rename the list of arp entries to arp_list. This is consistent toAlexander Bluhm
the other arp variables and nd6. Convert a hand-crafted loop to LIST_FOREACH_SAFE. OK mpi@
2015-11-01Replace the nd6 llinfo malloc(9) with pool_get(9) like arp does.Alexander Bluhm
OK mpi@
2015-10-27RIP arp_ifinit().Martin Pieuchot