summaryrefslogtreecommitdiff
path: root/sys/net/route.c
AgeCommit message (Collapse)Author
2016-11-21Kill rtioctl() stub, returning EOPNOTSUPP since tree import.Martin Pieuchot
ok jsg@
2016-11-15Properly initialize ``ifa''.Martin Pieuchot
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@
2016-11-14Reflect interface priorities when inserting RTF_CONNECTED routes.Martin Pieuchot
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@
2016-11-14Automatically create a default lo(4) interface per rdomain.Martin Pieuchot
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@
2016-11-09Do not call splsoftnet() recursively, this won't work with a lock.Martin Pieuchot
Timers configured via rt_timer_add(9) always run at IPL_SOFTNET, so assert that rather than calling splsoftnet(). ok bluhm@
2016-11-08Use rtalloc(9) instead of ifa_ifwithnet().Martin Pieuchot
ifa_ifwithnet() checks if a given address is directly connected. This function predates the introduction of the BSD routing table. Nowdays we can check if the route for the given address is marked as RTF_GATEWAY. This works on OpenBSD because we always install RTF_CONNECTED routes for subnets a and RTF_HOST route per p2p link. ok vgross@
2016-10-06Remove redundant comments that say a function must be called atAlexander Bluhm
splsoftnet() if the function does a splsoftassert(IPL_SOFTNET) anyway.
2016-10-05rt_timer_timer() needs a process context because it messes with theMartin Pieuchot
routing table. Found the hardway by Chris Jackman.
2016-10-04Correct the flag checks inside rt_ifa_addlocal(9) and rt_ifa_dellocal(9).Martin Pieuchot
There's no need to insert an RTF_LOCAL route if it is already there, not if a route with the same destination exist. This fixes a KASSERT() triggered by adding an alias for an address already present in the ARP cache as reported by weerd@ and Peter J. Philipp. This should also fix a KASSERT() triggered by a NDP change reported by Sebastien Marie. ok bluhm@
2016-09-17*** empty log message ***Peter Hessler
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-13Stop creating a BFD descriptor when the route is created.Martin Pieuchot
Since our BFD implementation relies on the existence of routes, it is much easier to set the BFD parameters with RTM_CHANGE, especially if something bad happen. Discussed with and ok phessler@, claudio@
2016-09-08Call bfd_rtfree() when the route entry has been removed from the table,Martin Pieuchot
not before. ok claudio@
2016-09-07Only free the old cached next hop route if the new one is valid.Martin Pieuchot
Leaving a NULL pointer on a RTF_GATEWAY is no longer supported, and a KASSERT() triggers. Found the hardway by and ok sthen@
2016-09-04Do not assume that an interface index of a route is still valid inAlexander Bluhm
rtrequest_delete(). The inpcb has a cache of the route that still exists when the interface has been detached. kassert triggered from tcp timeout by awolk@; OK mpi@
2016-09-04Purge routes attached to an address when this address is removed.Martin Pieuchot
This is done to stop using stale ifa attached to routes, which is the easiest way to make rtisvalid(9) MP-safe. sthen@ and henning@ like it, ok claudio@
2016-09-04Make it possible to toggle RTF_BFD via RTM_CHANGE and fix some minor thingsClaudio Jeker
in bfd.c. Make bfd_rtfree() a void function. OK phessler@
2016-09-03Add in the (disabled) kernel glue for BFDPeter Hessler
OK claudio@, henning@
2016-09-01Disable the RTF_UP kassert check in rtisvalid() for now as it canAlexander Bluhm
be triggered from userland. A gateway route is simply not valid if its gwroute is not up. OK phessler@
2016-09-01Move the RTF_LOCAL check that only makes sense for userland toMartin Pieuchot
route_output(). ok claudio@
2016-08-31Do not flush RTF_CLONED children when adding a new route.Martin Pieuchot
New RTF_CLONING routes don't have children, but the kernel might end up removing routes from a compatible route. This bug has been introduced with the support for multiple RTF_CLONING routes. Also make sure to release possible RTF_CACHED route *before* flushing RTF_CLONED children when deleting a route. KASSERT() reported by akfaew, sthen@ and martijn@ ok benno@
2016-08-30pool_setiplDavid Gwynne
ok claudio@ mpi@
2016-08-22Use rtalloc(9) instead of ifa_ifwithnet() to find an interfaceMartin Pieuchot
when adding a route to gateway to ensure a most specific match. This makes "# route add" coherent to "# route get" even with p2p interfaces. Fix a problem reported by Mart Tõnso. This also fix rttest20 after the introduction of RTF_CACHED. ok vgross@
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-08-19Do not seroize a struct needed for RTM_RESOLVE in the hot path.Martin Pieuchot
ok phessler@, bluhm@, tedu@, natano@
2016-08-16Mask the ``prio'' prior to comparing it to RTP_LOCAL.Martin Pieuchot
This allows rt_if_remove() to remove RTF_BROACAST routes from down interfaces. Issue reported by Dimitris Papastamos on bugs@ ok dlg@, claudio@, phessler@
2016-07-22Check for errors when deleting routes inside rtable_walk() and abortMartin Pieuchot
the walk if a route cannot be deleted. Prevent an infinite recursion reported by Dimitris Papastamos. ok claudio@
2016-07-19Return EAGAIN for every deleted route when detaching an interface.Martin Pieuchot
Previously the code was "too clever" and returned EAGAIN only for cloning route assuming that other deletion did not modify the tree. Analysed by and ok dlg@
2016-07-11Path MTU discovery was slightly broken. I took two ICMP packetsAlexander Bluhm
to create and change the dynamic route. This behavior was introduced in net/route.c rev 1.269 when the gateway route allocation was moved from rt_setgateway() to _rtalloc(). So rtrequest(RTM_ADD) could return a route without a valid gateway route. To fix this, call rt_setgwroute() from _rtalloc() and rt_setgateway(). OK mpi@
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-14Pass the configured ``ifa'' to rt_sendaddrmsg() instead of getting it viaMartin Pieuchot
``rt->rt_ifa'' later.
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-08Revert previous, it breaks regression tests.Martin Pieuchot
2016-06-07Use rtalloc(9) instead of ifa_ifwithnet() to find an interfaceMartin Pieuchot
when adding a route to gateway to ensure a most specific match. This makes "# route add" coherent to "# route get" even with p2p interfaces. Fix a problem reported by Mart Tõnso. ok vgross@
2016-06-03Remove superfluous parenthesis to shut up clang, from David Hill.Martin Pieuchot
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-06-01s/stall/stale/ in a comment about old interfaces.David Gwynne
ok mpi@
2016-05-31Flush dynamic route entries attached to an interface when its link stateMartin Pieuchot
becomes DOWN. This follows the same reasonning as for L2 (cloned) entries. Hopefully enough to fix tedu@'s stale RTF_DYNAMIC routes when switching WiFi network during suspend/resume. ok sthen@
2016-05-31Plug a route entry leak triggered under memory pressure.Martin Pieuchot
Help to track the leak from Hrvoje Popovski, ok bluhm@
2016-05-02Simplify life for routing table implementations by requiring that rtable_walkJonathan Matthew
callbacks return EAGAIN if they modify the routing table. While we're here, simplify life for rtable_walk callers by moving the loop that restarts the walk on EAGAIN into rtable_walk itself. Flushing cloned routes on interface state changes becomes a bit more inefficient, but this can be improved later. ok mpi@ dlg@
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-26Always include the route priority in routing messages.Martin Pieuchot
From Florian Riehm, ok bluhm@
2016-03-26Do not populate RTAX_NETMASK when sending a routing message for RTF_HOSTMartin Pieuchot
entries. This is a noop with the radix routing table because rt_mask() is always NULL for RTF_HOST entries, but it preserves the old behavior with ART. With the ART routing table host entry always have a prefix length equals to the length of the address. Fix a regression reported by semarie@. ok semarie@, bluhm@
2016-03-07Sync no-argument function declaration and definition by adding (void).Christian Weisgerber
ok mpi@ millert@
2016-02-26L2 entries are always in the first table of a routing domain, this fixesTheo de Raadt
a regression introduced during 5.7 and 5.8 as reported by Jean-Daniel Dupas on misc@ diff provided by mpi, ok claudio
2016-02-24Fix ECMP routing by passing the correct destination address to theMartin Pieuchot
hash routine. Bug reported and fix analysed by Jean-Daniel Dupas <jddupas AT xooloo DOT net> ok deraadt@
2015-12-21Pass the destination and mask to rtable_mpath_reprio() in order to notMartin Pieuchot
use ``rt_node'' with ART.
2015-12-11Do not pass a NULL ifp pointer to rtdeletemsg().Martin Pieuchot
ok visa@
2015-12-09Do not trigger a KASSERT() if the route we're trying to remove does notMartin Pieuchot
exist and we get another matching one instead. This bug has been here since the KAME area and recently exposed by a refactoring at n2k15. The problem is that rtrequest(9) does not check on which interface the route entry is attached when issuing a RTM_DELETE. So the kernel would end up deleting the route attached on a different ifp when in_ifinit() fails. This fix is currently a workaround, a better fix is in the pipeline. Reported by Laurence Tratt <laurie AT tratt DOT net>, thanks!
2015-12-09Do not trigger a KASSERT() when destroying/detaching an interface withMartin Pieuchot
RTF_CLONED routes attached. In thise case if_get(9) can return NULL inside rtflushclone1() because ifdetach() starts by clearing the interface pointer in the index map. So it is perfectly correct to bail and we're not going to leak any route entry because we're garbage collecting all of them. Reported by daniel@ and Aaron Miller <aaron DOT miller04 AT gmail DOT com>