summaryrefslogtreecommitdiff
path: root/sys/net/route.c
AgeCommit message (Collapse)Author
2017-01-24A space here, a space there. Soon we're talking real whitespaceKenneth R Westerback
rectification.
2017-01-24when we lose link, do not delete entries that have the RTF_BFD flag setPeter Hessler
OK mpi@
2017-01-20use per-cpu counters for rtstat.David Gwynne
ok mpi@
2017-01-19remove the BFD flag on a route *before* we actually delete the routePeter Hessler
should fix a panic reported by Hrvoje Popovski
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-12-17Insert RTF_CLONED routes at a higher priority than their partent toMartin Pieuchot
prevent a mpath conflict for /32 RTF_CLONING routes. Found the hardway by jsing@ on Google Compute Engine. ok bluhm@, jsing@
2016-12-14Make 'route add default' show a nicer error message if the providedStefan Sperling
gateway is not reachable (e.g. not on a local subnet). ok millert@ mikeb@ mpi@ (and shrugs by jca@)
2016-12-04Since net/route.c r1.337 interface priority factors into route priorityStefan Sperling
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@
2016-12-02Assert that rt_match() is always called at IPL_SOFTNET rather thanMartin Pieuchot
calling splsoftnet() recursively.
2016-11-29m_free() and m_freem() test for NULL. Simplify callers which had their ownJonathan Gray
NULL tests. ok mpi@
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@