summaryrefslogtreecommitdiffstats
path: root/sys/netinet/if_ether.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* kernel: use gettime(9)/getuptime(9) in lieu of time_second(9)/time_uptime(9)cheloha2020-06-241-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | time_second(9) and time_uptime(9) are widely used in the kernel to quickly get the system UTC or system uptime as a time_t. However, time_t is 64-bit everywhere, so it is not generally safe to use them on 32-bit platforms: you have a split-read problem if your hardware cannot perform atomic 64-bit reads. This patch replaces time_second(9) with gettime(9), a safer successor interface, throughout the kernel. Similarly, time_uptime(9) is replaced with getuptime(9). There is a performance cost on 32-bit platforms in exchange for eliminating the split-read problem: instead of two register reads you now have a lockless read loop to pull the values from the timehands. This is really not *too* bad in the grand scheme of things, but compared to what we were doing before it is several times slower. There is no performance cost on 64-bit (__LP64__) platforms. With input from visa@, dlg@, and tedu@. Several bugs squashed by visa@. ok kettenis@
* Avoid NULL dereference in arpinvalidate() and nd6_invalidate() bykrw2019-11-071-1/+3
| | | | | | making RTM_INVALIDATE code path perform same check as RTM_DELETE does. ok mpi@
* tsleep(9) -> tsleep_nsec(9)mpi2019-10-161-2/+3
| | | | ok cheloha@, visa@
* Introduce ETHER_IS_BROADCAST/ANYADDR/EQ() and use them where appropriate.mpi2019-07-171-3/+3
| | | | ok dlg@, sthen@, millert@
* In arp_rtrequest and nd6_rtrequest return early if the RTF_MPLS flag isclaudio2019-06-131-2/+3
| | | | | | | | set. These mpls routes use the rt_llinfo structure to store the MPLS label and would confuse the arp and nd6 code. OK bluhm@ anton@ Reported-by: syzbot+927e93a362f3ae33dd9c@syzkaller.appspotmail.com
* Refresh arp entries that are about to expire. Once their life time is lessclaudio2019-01-201-32/+32
| | | | | | | | then 1/8 of net.inet.ip.arptimeout the system will send out a arp request about every 30 seconds until either the entry is updated or expired. Not refreshing arp entries will result in packet drop every time a entry expires which is not ideal for important gateway entries. Came up with this after a discussion with deraadt@. OK benno@ deraadt@
* MH_ALIGN -> m_align. In revarprequest() set the ph_rtableid so thatclaudio2018-11-301-3/+4
| | | | | the function is doing the same initialisation as arprequest(). OK bluhm@
* Push the KERNEL_LOCK() inside route_input().mpi2018-06-111-3/+1
| | | | ok visa@, tb@
* When reusing an mbuf to send an ARP response, don't forget to clearstsp2018-03-311-4/+9
| | | | | | | | | | | | | | | | | the mbuf packet header. Otherwise, stale mbuf state related to the ARP request packet might affect the fate of the ARP reply packet. For example, I observed that for an ARP request to a carp IP, where the underlying carpdev interface is part of a bridge, ARP replies were always sent out on the carpdev interface, even if the corresponding ARP request was received not on the carpdev but on a different bridge member interface. This happened because the M_PROTO1 mbuf flag was set on the ARP request mbuf when it left the bridge towards carp, and was still set on the ARP reply, which reused the same mbuf, sent back towards the bridge. The bridge's loop detection saw the M_PROTO1 flag and prevented the ARP reply from entering the bridge, so the reply was instead sent out directly on the carpdev... ok bluhm@ mpi@
* Mbuf data is used as struct ether_header before it has been madebluhm2018-03-131-31/+25
| | | | | | | | continuous. The length of the hardware and protocol address are provided in the network packet and have to be checked first. So enforce that we only deal with internet over ethernet arp headers with the address length filled correctly. found by Maxime Villard; OK claudio@
* Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsipmpi2018-01-161-2/+2
| | | | | | of IFF* flags. inputs from jmc@, ok bluhm@, visa@
* There was an issue that dynamic path MTU discovery together withbluhm2018-01-151-1/+2
| | | | | | ARP or ND timeout could delete local routes. Put an assert into arptfree() and nd6_free() so this cannot happen again. OK mpi@
* Remove NET_LOCK()'s argument.mpi2017-08-111-4/+3
| | | | Tested by Hrvoje Popovski, ok bluhm@
* Switch installer to Allotment Routing Table (ART).florian2017-07-301-3/+1
| | | | | | Prompted by a bugreport by naddy that IPv6 autoconfiguration is broken in the installer. OK mpi, "go for it" deraadt
* Add an error argument to rtm_send() instead of rerolling it insidempi2017-07-281-2/+2
| | | | | | rtdeletemsg(). ok bluhm@
* Prefix functions dealing with routing messages with 'rtm_' and keepmpi2017-03-061-2/+2
| | | | | | | | | 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@
* Introduce the NET_LOCK() a rwlock used to serialize accesses to the partsmpi2016-12-191-4/+4
| | | | | | | | | | | 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@
* Make rtable_iterate(9) mpsafe by using the new SRPL_NEXT(9).mpi2016-11-201-3/+1
| | | | ok dlg@, jmatthew@
* ARP and NDP timeouts mess with the routing table, so they need a processmpi2016-11-071-2/+2
| | | | | | context. Convert them to timeout_set_proc(9).
* all pools have their ipl set via pool_setipl, so fold it into pool_init.dlg2016-09-151-4/+3
| | | | | | | | | | | | | | | | | | | | | | 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);
* Rename rtable_mpath_next() into rtable_iterate() and make it do a propermpi2016-09-071-10/+5
| | | | | | | | | 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@
* pool_setipl for various netinet and netinet6 bitsdlg2016-09-061-1/+2
| | | | | | thank you to everyone who helped reviewed these diffs ok mpi@
* Make the ``rt_gwroute'' pointer of RTF_GATEWAY entries immutable.mpi2016-08-221-13/+29
| | | | | | | | | | | 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@
* Prevent a use-after-free by not updating an ARP entry that has beenmpi2016-07-141-3/+16
| | | | | | | | | | | | | 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@
* Move ARP processing back to the KERNEL_LOCK()ed task until the racempi2016-07-131-3/+26
| | | | | | | triggered by updating a cached, but removed from the table, entry is properly fixed. Diff from dlg@, prodding deraadt@
* Introduce RTF_MULTICAST and flag corresponding IPv6 routes as suchmpi2016-07-131-2/+2
| | | | | | instead of abusing RTF_CLONING. Fix a leak reporeted by Aaron Riekenberg on misc@, ok sthen@
* Revert the introduction of ``rt_addr''.mpi2016-07-111-2/+2
| | | | | | 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.
* Add sysctl for arp timers: net.inet.ip.arptimeout (expire timer for resolvedchris2016-06-281-3/+3
| | | | | | entries) and net.inet.ip.arpdown (expire timer for unresolved entries) ok mpi@
* Store the source address associated with a route in its own chunk ofmpi2016-06-141-2/+2
| | | | | | | | | 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@
* Add the "llprio" field to struct ifnet, and the corresponding keywordvgross2016-06-101-1/+3
| | | | | | | | | 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@
* Move logic to send ARP replies to arpreply().mpi2016-06-061-39/+48
| | | | ok florian@, dlg@
* Get rid of the ``enaddr'' argument of carp_iamatch().mpi2016-06-061-2/+2
| | | | | | | It was only checked in balancing mode, which is currently broken, and is no longer needed. Discusssed with bluhm@ and Florian Riehm.
* set rt_expire times against time_uptime, not time_second.dlg2016-06-031-15/+8
| | | | | | | | | | | 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@
* Stop creating and inserting a route entry for ARP and ND automagically.mpi2016-05-311-42/+21
| | | | | | Callers MUST do a route lookup before sending a packet. Tested by Hrvoje Popovski, ok visa@, bluhm@
* Pass a 'struct in_addr *' to arplookup() instead of always dereferencingmpi2016-05-231-10/+9
| | | | one.
* Shorten en error string.mpi2016-05-231-4/+3
|
* Remove some superflous if_get(9)/if_put(9) dances now that ARP inputmpi2016-05-181-24/+11
| | | | | | routines are call directly by ether_input(). ok visa@, dlg@
* Move the code to update an ARP cache into its own function.mpi2016-05-181-106/+115
| | | | ok visa@
* Remove unused arguments from rt_checkgate().mpi2016-04-271-3/+2
| | | | | 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.
* Implement proxy ARP for ART based on mpath support.mpi2016-03-301-2/+14
| | | | | | Since mpath is not enabled in RAMDISK, proxy ARP won't work there either. ok bluhm@
* Ensure that a found proxy ARP entry has the correct flag.mpi2016-03-241-1/+7
| | | | ok bluhm@
* Do not remove RTF_STATIC L2 entries from the routing table.mpi2016-03-071-2/+3
| | | | | | | | | | | 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@
* remove the arp_inuse and arp_allocated countersdlg2016-01-211-5/+2
| | | | | | | | | | | | | | | | | 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@
* Grab the KERNEL_LOCK before delivering a message to the routing socketmpi2016-01-141-2/+5
| | | | | | | | when an ARP resolution has been done. Should hopefully fix the "receive 1" panic reported by benno@ on bugs@. ok claudio@, phessler@, benno@, bluhm@
* Get rid of the arp and revarp input queues.mpi2016-01-081-30/+16
| | | | | | | 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@
* rm a bit more trailers code. no longer accept them as alias for ethernet.tedu2015-12-171-9/+1
| | | | ok mpi
* Since we want to print the interface names in the log messages it isclaudio2015-12-021-3/+12
| | | | | | required to do the if_get/if_put dance around the log() calls. These were the last users of rt_ifp. OK mpi@ bluhm@
* More rt_ifp killing. There checks in in_arpinput() to verify that theclaudio2015-12-021-5/+4
| | | | | | | | | 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@
* There is no reason for this carp magic in arpresolve. rt->rt_ifp has toclaudio2015-12-021-6/+1
| | | | | be the same as ifp or something is very broken. So remove this including one more rt_ifp. OK mpi@
* When destroying an interface, we have to wait until all referencesbluhm2015-12-021-2/+2
| | | | | | | | | 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@