summaryrefslogtreecommitdiff
path: root/sys/net/route.c
AgeCommit message (Collapse)Author
2021-05-25As network features are not added dynamically, the domain structuresAlexander Bluhm
are constant. Having more const makes MP review easier. More pointers are mapped read-only in the kernel image. OK deraadt@ mvs@
2021-03-10spellingJonathan Gray
ok gnezdo@ semarie@ mpi@
2020-10-29Add feature to force the selection of source IP addressdenis
Based/previous work on an idea from deraadt@ Input from claudio@, djm@, deraadt@, sthen@ OK deraadt@
2020-08-13Use rtm_miss() rather than the simpler rtm_send() to send route deleteJonathan Matthew
messages, and save the route flags before deleting the route. For L2 route entries, the RTF_LLINFO flag is cleared during deletion, so saving the flags beforehand means they're correct in the routing socket message. ok mpi@
2020-07-28Add size to free(9) callskn
Those are for the gateway sockaddrs which get allocated in rt_setgate() with the same ROUNDUP(sa_len) approach. mpi already added a sizes for a few rt_gateway sockaddrs in two commits, these are the last one in route.c leaving only ifafree() behind. OK mpi
2020-06-24kernel: use gettime(9)/getuptime(9) in lieu of time_second(9)/time_uptime(9)cheloha
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@
2020-04-20Don't return stack garbage even if it is going to beKenneth R Westerback
ignored. Initialize 'error' to 0. CID 1483380 ok mpi@
2020-04-15Do not delete an existing RTF_CACHED entry with the same destinationMartin Pieuchot
address as the one trying to be inserted. Such entry must stay in the table as long as its parent route exist. If a code path tries to re-insert a route with the same destination address on the same interface it is a bug. Avoid the "route contains no arp information" problem reported by sthen@ and Laurent Salle. ok claudio@
2020-04-10Typo in comment.Martin Pieuchot
2020-03-21r1.244 introduced rt_hash() with careful checks of src for NULL atKenneth R Westerback
each dereference. r1.275 added a check at the top of the function, with an immediate "return (-1)" if src == NULL. Thus making the repeated checks in the body superfluous. CID 1452932. ok millert@ mpi@
2020-03-10The return value of rt_ifa_purge() is ignored, so stopKenneth R Westerback
returning a (possibly uninitialized) value. CID 1483466. ok millert@
2020-01-08Fix confusion around rtlabelid and rtableid in rt_ifa_add() and rt_ifa_del().Claudio Jeker
The routing labels have nothing todo with rdomains and routing tables. Remove the unneeded rdomain check. With this rtlabel on interfaces work again. OK kn@
2019-06-24Since the recent recursion fix in rtable_walk(), deleting an interfaceAlexander Bluhm
address could trigger the "rt->rt_ifidx == ifp->if_index" assertion. In rtflushclone() the ifp that is passed to rtdeletemsg() has been changed from the route interface to the ifa interface. Restore the old behavior and get the route ifp. found by regress/sys/netinet/carp; OK mpi@
2019-06-21Prevent recursions by not deleting entries inside rtable_walk(9).Martin Pieuchot
rtable_walk(9) now passes a routing entry back to the caller when a non zero value is returned and if it asked for it. This allows us to call rtdeletemsg()/rtrequest_delete() from the caller without creating a recursion because of rtflushclone(). Multicast code hasn't been adapted and is still possibly creating recursions. However multicast route entries aren't cloned so if a recursion exists it isn't because of rtflushclone(). Fix stack exhaustion triggered by the use of "-msave-args". Issue reported by Dániel Lévai on bugs@ confirmed by and ok bluhm@.
2019-06-13Copy the user provided sockaddr into a normalized sockaddr in rtrequest()Claudio Jeker
before adding it to the routing table. The rtable code is doing memcmp() of those rt_dest sockaddrs so it is important that they are stored in a canonical form. To do this struct domain is extended to include the sockaddr size for this address family. OK bluhm@ anton@ Reported-by: syzbot+10fe9cd8d0211c562ead@syzkaller.appspotmail.com
2019-05-11Make rt_mpls_set() be more strict in what it accepts. Also ensure thatClaudio Jeker
the RTF_MPLS can't be toggled without rt_mpls_set() being called. While RTF_MPLS is part of RTF_FMASK it should be excluded from the flags and mask when they are applied to the route since toggling it requires a call to rt_mpls_set(). OK bluhm@ Reported-by: syzbot+86344a9e31c27aa6f15b@syzkaller.appspotmail.com
2019-03-03Found some historical code. Don't cast the pointer for bzero to a different ↵Theo de Raadt
type, and definately don't do this to the length: (unsigned)(cplim2 - cp2) ok claudio
2019-02-15Remove KASSERT() for now. It triggers when destroying lo(4) of a rdomainClaudio Jeker
because the rtable_l2 is modified before calling rt_ifa_del. Triggered by regress test and reported by Moritz Buhl mbuhl at mbuhl dot me
2019-02-13change rt_ifa_add and rt_ifa_del so they take an rdomain argument.David Gwynne
this allows mpls interfaces (mpe, mpw) to pass the rdomain they wish the local label to be in, rather than have it implicitly forced to 0 by these functions. right now they'll pass 0, but it will soon be possible to have them rx packets in other rdomains. previously the functions used ifp->if_rdomain for the rdomain. everything other than mpls still passes ifp->if_rdomain. ok mpi@
2019-02-10remove the implict RTF_MPATH flag that rt_ifa_add() sets on new routes.David Gwynne
MPLS interfaces (ab)use rt_ifa_add for adding the local MPLS label that they listen on for incoming packets, while every other use of rt_ifa_add is for adding addresses on local interfaces. MPLS does this cos the addresses involved are in basically the same shape as ones used for setting up local addresses. It is appropriate for interfaces to want RTF_MPATH on local addresses, but in the MPLS case it means you can have multiple local things listening on the same label, which doesn't actually work. mpe in particular keeps track of in use labels to it can handle collisions, however, mpw does not. It is currently possible to have multiple mpw interfaces on the same local label, and sharing the same label as mpe or possible normal forwarding labels. Moving the RTF_MPATH flag out of rt_ifa_add means all the callers that still want it need to pass it themselves. The mpe and mpw callers are left alone without the flag, and will now get EEXIST from rt_ifa_add when a label is already in use. ok (and a huge amount of patience and help) mpi@ claudio@ is ok with the idea, but saw a much much earlier solution to the problem
2018-11-23Change rtable_mpath_reprio() to take the prefixlen as argument instead ofClaudio Jeker
the network mask. This saves converting the prefixlen to a mask and back. OK phessler@, benno@
2018-09-27Make sure the L2 entry is cloned before dereferencing its parent.Martin Pieuchot
RTF_LOCAL entries or static ARP entries don't have parents, so the logic was incorrect. Note that it might be possible to extend the logic to work with non-cloned L2 entries but the few use cases do not justify the complexity (yet). Problem reported & fix tested by Elie Bouttier. ok bluhm@, visa@, claudio@
2018-07-11superfluous newlineHenning Brauer
2018-06-25Factorize MPLS setup/teardown into two functions.Martin Pieuchot
ok claudio@
2018-06-11Push the KERNEL_LOCK() inside route_input().Martin Pieuchot
ok visa@, tb@
2018-04-24Remove unused rtentry parameter.Florian Obser
Input bluhm OK benno, kn, claudio
2018-02-22Always reallocate a new memory chunk when changing the gateway of aMartin Pieuchot
route entry. This makes sure we pass the correct size to free(9). Reproted by and ok dlg@
2018-02-20Removing an RTF_CLONING route entry should not invalidate an RTF_CACHEDMartin Pieuchot
entry that has been cloned from a different RTF_CLONING route. Bug report & ok friehm@
2018-02-10If the kernel fails to clone an entry, report rtrequest(9) error.Martin Pieuchot
ok claudio@, jmatthew@
2018-02-08When multiple RTF_CLONING routes for the same subnet are present, useMartin Pieuchot
the correct one to clone the gateway. Fix wired vs wireless on the same subnet issue as well as a more complicated setup reported by dlg@. ok jmatthew@, claudio@, dlg@
2018-01-02Move the cloning bits in their own function.Martin Pieuchot
This will be needed to select the proper cloning route in a multipath scenario. While here remove a NET_ASSERT_LOCKED(), the routing table doesn't need the lock. ok dlg@
2017-11-29Revert 1.353, this breaks mpe(4). Also it seems not complete since rt_ifa_delClaudio Jeker
still had this hack in. This needs to be revisted and better understood. It may be needed to add a mplsrdomain to mpe(4) but MPLS only in the rtable 0 is hardcoded in more places and we should fix them all. OK mpi@
2017-09-05Restart the iteration when a multipath list is re-ordered to make sureMartin Pieuchot
no entry are missed. While here do not re-ordered or send messages for route entries that are already in the expected state. Make rttest30 pass. ok gerhard@
2017-08-11Remove NET_LOCK()'s argument.Martin Pieuchot
Tested by Hrvoje Popovski, ok bluhm@
2017-08-02Move a sanity check that only makes sense for userland where it belongs.Martin Pieuchot
ok bluhm@, florian@
2017-07-30Enable mpath support in the Allotment Routing Table (ART) on the ramdisk.Florian Obser
OK mpi
2017-07-30Switch installer to Allotment Routing Table (ART).Florian Obser
Prompted by a bugreport by naddy that IPv6 autoconfiguration is broken in the installer. OK mpi, "go for it" deraadt
2017-07-28Add an error argument to rtm_send() instead of rerolling it insideMartin Pieuchot
rtdeletemsg(). ok bluhm@
2017-07-27Export RTAX_IFP, RTAX_IFA and RTAX_LABEL to userland in rtdeletemsg().Martin Pieuchot
Reduce differences with rtm_miss(). ok claudio@, bluhm@
2017-07-24rt_getifa() is only needed for routing commands submited by userland.Martin Pieuchot
So rename it to rtm_getifa(), move it where it belongs and stop calling it from rtrequest(9). Route entries created by the kernel must always specify the corresponding `ifa'. ok claudio@
2017-06-09Replace rtrequest(RTM_DELETE...) rtrequest_delete() and do not evenMartin Pieuchot
try to remove a route from the table if it is and invalid cache. This is a step towards decoupling code dealing with userland and kernel inserted routes. ok bluhm@
2017-06-07Grab the KERNEL_LOCK() around rtm*() functions. Routing sockets globalsMartin Pieuchot
aren't protected by the NET_LOCK(). While here change lock assertions in rt_{set,put}gwroute(), the NET_LOCK() is enough. Tested by Hrvoje Popovski. ok jmatthew@, claudio@
2017-05-27In ifa_ifwithroute() the rtalloc() needs to be done against the rdomainClaudio Jeker
so use rtable_l2() to get the right id. Fixes adding routes to rtables. OK mpi@ phessler@
2017-05-16Replace remaining splsoftassert(IPL_SOFTNET) by NET_ASSERT_LOCKED().Martin Pieuchot
ok visa@
2017-04-19Use the rt_rmx defines that hide the struct rt_kmetrics indirection.Alexander Bluhm
No binary change. OK mpi@
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@
2017-03-02Allow MPLS switching and VPLS across rdomains.Renato Westphal
OK claudio@ mpi@
2017-02-28Use rtable_match() rather than rtalloc(9) when adding a new route.Martin Pieuchot
rtalloc(9) should be reserved for the hot path otherwise it's hard to interpret the value of the 'use' counter. ok claudio@
2017-02-15Replace manual loops with FOREACH macro.Alexander Bluhm
OK mikeb@
2017-02-05Always allocate counters memory using type M_COUNTERS.Jeremie Courreges-Anglas
This makes the API simpler, and is probably more useful than spreading counters memory other several types, making it harder to track. Prodded by mpi, ok mpi@ stsp@