summaryrefslogtreecommitdiffstats
path: root/sys/net/route.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Copy the user provided sockaddr into a normalized sockaddr in rtrequest()claudio2019-06-131-16/+59
| | | | | | | | | | 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
* Make rt_mpls_set() be more strict in what it accepts. Also ensure thatclaudio2019-05-111-3/+8
| | | | | | | | | | 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
* Found some historical code. Don't cast the pointer for bzero to a different type,deraadt2019-03-031-2/+2
| | | | | and definately don't do this to the length: (unsigned)(cplim2 - cp2) ok claudio
* Remove KASSERT() for now. It triggers when destroying lo(4) of a rdomainclaudio2019-02-151-2/+1
| | | | | 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
* change rt_ifa_add and rt_ifa_del so they take an rdomain argument.dlg2019-02-131-29/+36
| | | | | | | | | | | | 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@
* remove the implict RTF_MPATH flag that rt_ifa_add() sets on new routes.dlg2019-02-101-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Change rtable_mpath_reprio() to take the prefixlen as argument instead ofclaudio2018-11-231-5/+5
| | | | | the network mask. This saves converting the prefixlen to a mask and back. OK phessler@, benno@
* Make sure the L2 entry is cloned before dereferencing its parent.mpi2018-09-271-6/+3
| | | | | | | | | | | 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@
* superfluous newlinehenning2018-07-111-2/+1
|
* Factorize MPLS setup/teardown into two functions.mpi2018-06-251-28/+41
| | | | ok claudio@
* Push the KERNEL_LOCK() inside route_input().mpi2018-06-111-7/+3
| | | | ok visa@, tb@
* Remove unused rtentry parameter.florian2018-04-241-3/+3
| | | | | Input bluhm OK benno, kn, claudio
* Always reallocate a new memory chunk when changing the gateway of ampi2018-02-221-3/+6
| | | | | | | | route entry. This makes sure we pass the correct size to free(9). Reproted by and ok dlg@
* Removing an RTF_CLONING route entry should not invalidate an RTF_CACHEDmpi2018-02-201-9/+14
| | | | | | entry that has been cloned from a different RTF_CLONING route. Bug report & ok friehm@
* If the kernel fails to clone an entry, report rtrequest(9) error.mpi2018-02-101-11/+16
| | | | ok claudio@, jmatthew@
* When multiple RTF_CLONING routes for the same subnet are present, usempi2018-02-081-4/+34
| | | | | | | | | 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@
* Move the cloning bits in their own function.mpi2018-01-021-34/+42
| | | | | | | | | | 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@
* Revert 1.353, this breaks mpe(4). Also it seems not complete since rt_ifa_delclaudio2017-11-291-2/+5
| | | | | | | 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@
* Restart the iteration when a multipath list is re-ordered to make surempi2017-09-051-28/+28
| | | | | | | | | | | 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@
* Remove NET_LOCK()'s argument.mpi2017-08-111-4/+3
| | | | Tested by Hrvoje Popovski, ok bluhm@
* Move a sanity check that only makes sense for userland where it belongs.mpi2017-08-021-11/+1
| | | | ok bluhm@, florian@
* Enable mpath support in the Allotment Routing Table (ART) on the ramdisk.florian2017-07-301-9/+1
| | | | OK mpi
* Switch installer to Allotment Routing Table (ART).florian2017-07-301-5/+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-11/+5
| | | | | | rtdeletemsg(). ok bluhm@
* Export RTAX_IFP, RTAX_IFA and RTAX_LABEL to userland in rtdeletemsg().mpi2017-07-271-6/+8
| | | | | | Reduce differences with rtm_miss(). ok claudio@, bluhm@
* rt_getifa() is only needed for routing commands submited by userland.mpi2017-07-241-125/+3
| | | | | | | | 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@
* Replace rtrequest(RTM_DELETE...) rtrequest_delete() and do not evenmpi2017-06-091-27/+15
| | | | | | | | | 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@
* Grab the KERNEL_LOCK() around rtm*() functions. Routing sockets globalsmpi2017-06-071-3/+7
| | | | | | | | | | | 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@
* In ifa_ifwithroute() the rtalloc() needs to be done against the rdomainclaudio2017-05-271-2/+2
| | | | | so use rtable_l2() to get the right id. Fixes adding routes to rtables. OK mpi@ phessler@
* Replace remaining splsoftassert(IPL_SOFTNET) by NET_ASSERT_LOCKED().mpi2017-05-161-4/+4
| | | | ok visa@
* Use the rt_rmx defines that hide the struct rt_kmetrics indirection.bluhm2017-04-191-2/+2
| | | | | No binary change. OK mpi@
* Prefix functions dealing with routing messages with 'rtm_' and keepmpi2017-03-061-34/+9
| | | | | | | | | 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@
* Allow MPLS switching and VPLS across rdomains.renato2017-03-021-6/+2
| | | | OK claudio@ mpi@
* Use rtable_match() rather than rtalloc(9) when adding a new route.mpi2017-02-281-2/+3
| | | | | | | rtalloc(9) should be reserved for the hot path otherwise it's hard to interpret the value of the 'use' counter. ok claudio@
* Replace manual loops with FOREACH macro.bluhm2017-02-151-14/+10
| | | | OK mikeb@
* Always allocate counters memory using type M_COUNTERS.jca2017-02-051-2/+2
| | | | | | | 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@
* A space here, a space there. Soon we're talking real whitespacekrw2017-01-241-20/+20
| | | | rectification.
* when we lose link, do not delete entries that have the RTF_BFD flag setphessler2017-01-241-2/+2
| | | | OK mpi@
* use per-cpu counters for rtstat.dlg2017-01-201-9/+11
| | | | ok mpi@
* remove the BFD flag on a route *before* we actually delete the routephessler2017-01-191-6/+6
| | | | should fix a panic reported by Hrvoje Popovski
* Introduce the NET_LOCK() a rwlock used to serialize accesses to the partsmpi2016-12-191-5/+5
| | | | | | | | | | | 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@
* Insert RTF_CLONED routes at a higher priority than their partent tompi2016-12-171-12/+18
| | | | | | | | prevent a mpath conflict for /32 RTF_CLONING routes. Found the hardway by jsing@ on Google Compute Engine. ok bluhm@, jsing@
* Make 'route add default' show a nicer error message if the providedstsp2016-12-141-2/+2
| | | | | | gateway is not reachable (e.g. not on a local subnet). ok millert@ mikeb@ mpi@ (and shrugs by jca@)
* Since net/route.c r1.337 interface priority factors into route prioritystsp2016-12-041-2/+2
| | | | | | | when RTF_CONNECTED routes are added to the routing table. Specify a route priority calculated in the same way when deleting such routes. Makes route add and delete code paths consistent again. ok mpi@
* Assert that rt_match() is always called at IPL_SOFTNET rather thanmpi2016-12-021-4/+4
| | | | calling splsoftnet() recursively.
* m_free() and m_freem() test for NULL. Simplify callers which had their ownjsg2016-11-291-3/+2
| | | | | | NULL tests. ok mpi@
* Kill rtioctl() stub, returning EOPNOTSUPP since tree import.mpi2016-11-211-7/+1
| | | | ok jsg@
* Properly initialize ``ifa''.mpi2016-11-151-1/+2
| | | | | | | | | | Note that dereferencing ``rt_ifa'' after calling rtfree(9) is generally not safe. In this case we rely on the fact that rtredirect() is still serialized with interface ioctl(2)s. This function cries for a rewrite. Reported by and ok jsg@
* Reflect interface priorities when inserting RTF_CONNECTED routes.mpi2016-11-141-2/+2
| | | | | | | | | | | | | | | | When multiple RTF_CLONING routes exist for a given subnet, bringing one of the interfaces up/down could make impossible to insert new ARP/NDP entries. In this case the first RTF_CONNECTED route of the multipath list no longer corresponded to the wired interface because it had the same priority as the carp(4) route. This is another regression of supporting multiple RTF_CONNECTED routes. Fix a bug with a CARP setup reported by stsp@ ok stsp@
* Automatically create a default lo(4) interface per rdomain.mpi2016-11-141-3/+1
| | | | | | | | | | | | | | | | | | In order to stop abusing lo0 for all rdomains, a new loopback interface will be created every time a rdomain is created. The unit number will be the same as the rdomain, i.e. lo1 will be attached to rdomain 1. If this loopback interface is already in use it wont be possible to create the corresponding rdomain. In order to know which lo(4) interface is attached to a rdomain, its index is stored in the rtable/rdomain map. This is a long overdue since the introduction of rtable/rdomain. It also fixes a recent regression due to resetting the rdomain of an incoming packet reported by semarie@, Andreas Bartelt and Nils Frohberg. ok claudio@