summaryrefslogtreecommitdiff
path: root/sys/net/route.c
AgeCommit message (Collapse)Author
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>
2015-12-05remove old lint annotationsTed Unangst
2015-12-04Move the KERNEL_LOCK from rt_match() to rtable_match().Martin Pieuchot
ok claudio@
2015-12-03Get rid of rt_mask() and stop allocating a "struct sockaddr" for everyMartin Pieuchot
route entry in ART. rt_plen() now represents the prefix length of a route entry and should be used instead. For now use a "struct sockaddr_in6" to represent the mask when needed, this should be then replaced by the prefix length and RTA_NETMASK only used for compatibility with userland. ok claudio@
2015-12-03Remove broadcast matching from ifa_ifwithaddr(), use in_broadcast() whereVincent Gross
required. ok bluhm@ mpi@.
2015-12-03Remove unused ``rt_tableid'' field from "struct rtentry".Martin Pieuchot
This reduces the size of the structure by 8 bytes on amd64 now that we are using an index instead of a pointer for reaching interfaces.
2015-12-03Store an interface index instead of a pointer in the "struct rtentry".Martin Pieuchot
These indexes are unique and should be used with if_get() to get a pointer to the corresponding ``ifp''. Such pointer is guaranteed to be valid in a MP environment until if_put() is called. ok claudio@, sthen@
2015-12-02rtable_delete() does not use its prio parameter, so delete it.Alexander Bluhm
OK mpi@
2015-12-02When destroying an interface, we have to wait until all referencesAlexander Bluhm
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@
2015-12-02Kill the RT_REPORT flag to rtalloc() and stop sending RTM_MISS messagesClaudio Jeker
for failed route lookups. This is something that was maybe useful in the 90is but in this modern times it is just annoying and nothing expect it anyway. OK mpi@, sthen@
2015-12-02allocate route labels as M_RTABLE instead of M_TEMPBret Lambert
ok claudio@, mpi@
2015-12-02Move multipath Hash-Threshold selection mechanism inside rtable_match().Martin Pieuchot
This will helps for unlocking the routing table and will prevent further mistake by keeping the multipath logic inside the rtable_* API. ok dlg@, claudio@
2015-12-01Kill redundant or unused arguments in rtredirect().Martin Pieuchot
ok bluhm@
2015-11-27Protect the growth of the routing table arrays used by rtable_get()Martin Pieuchot
with SRPs. This is a simplified version of the dynamically sizeable array of pointers used by if_get() because routing table heads are never freed. ok dlg@
2015-11-23Include <sys/atomic.h> when atomic operations are used.Martin Pieuchot
This has been masked because <sys/srp.h> is pulled unconditionally. ok dlg@
2015-11-20Initialise the ifidx to 0 (no interface) in rtredirect() to avoid usingJonathan Gray
ifidx uninitialised for the gateway not directly reachable case. ok mpi@
2015-11-18Do not dereference rt_ifp to call if_rtrequest.Martin Pieuchot
This only happens under KERNEL_LOCK() so we know for sure that the interface attached to a route entry is valid.
2015-11-18Revert previous workaround now that multipath route selection has beenMartin Pieuchot
fixed. ok sthen@, dlg@
2015-11-18Multipath selection should be done before caching the next hop.Martin Pieuchot
Fix a regression introduced by rtalloc(9) rewrite where only the first route of a multipath chain had a valid next hop and could be used. ok sthen@, dlg@
2015-11-17Unbreak next-hop caching on multipath setups.Martin Pieuchot
When multiple gateways are in use, the next-hop entrie might not be on the same interface. This is due to the fact that ARP entries are unique and attached to their cloning interface. Found the hard way by and ok dlg@
2015-11-11Remove an XXX that no longer makes sense, rt_ifp is now always the sameMartin Pieuchot
as rt_ifa->ifa_ifp.
2015-11-09Rewrite rtalloc(9) to consider RTF_GATEWAY entries without valid next-Martin Pieuchot
hop route as invalid. Previously when such entrie was returned by rtalloc(9) a second route lookup was done in rt_checkgate() very late in the journey of a packet. In other words a single rtalloc(9) call can now result in multiple route lookups if a RTF_GATEWAY entry is returned. This is a step towards always calling L2 output functions with valid destination information. Tested by various including jmc@, naddy@, Hrvoje Popovski
2015-11-04rtfree(9) accepts NULL pointers.Martin Pieuchot
2015-11-02Merge rtable_mpath_match() into rtable_lookup().Martin Pieuchot
ok bluhm@
2015-10-30Rename rtrequest1() to rtrequest().Alexander Bluhm
OK mpi@
2015-10-25I should not have committed this chunk. Spotted by krw@Martin Pieuchot
2015-10-25Simple sizes for free(9).Martin Pieuchot
ok claudio@
2015-10-25Merge rtable_mpath_conflict() into rtable_insert().Martin Pieuchot
ok claudio@
2015-10-25Introduce if_rtrequest() the successor of ifa_rtrequest().Martin Pieuchot
L2 resolution depends on the protocol (encoded in the route entry) and an ``ifp''. Not having to care about an ``ifa'' makes our life easier in our MP effort. Fewer dependencies between data structures implies fewer headaches. Discussed with bluhm@, ok claudio@
2015-10-25Instead of doing the the if_get() dance for rt_missmsg(), change theAlexander Bluhm
function to take an interface index. discussed with mpi@; OK claudio@
2015-10-24Some rt_ifp to rt_ifidx conversions.Martin Pieuchot
ok bluhm@
2015-10-23Update route entries reference counters atomically.Martin Pieuchot
This allows us to only grab the KERNEL_LOCK when the last reference of an entry has been dropped. For symmetry also grab the KERNEL_LOCK inside rtalloc(9). ok dlg@, bluhm@
2015-10-22Use only one refcounting mechanism for route entries.Martin Pieuchot
ok bluhm@, dlg@, claudio@
2015-10-22Only check for rt_ifp now that it is alays the same as rt_ifa->ifa_ifp.Martin Pieuchot
ok millert@, bluhm@
2015-10-22Kill dead code, ifa is specified and won't change.Martin Pieuchot
ok bluhm@
2015-10-22Inspired by satosin(), use inline functions to convert sockaddr dl.Alexander Bluhm
Instead of casts they check wether the incoming object has the expected type. So introduce satosdl() and sdltosa() in the kernel. OK mpi@
2015-10-21u_short -> unsigned int for rtableid.Martin Pieuchot
2015-10-16If a DOWN route entry is passed to a L2 output function, be dumb andMartin Pieuchot
simply use it. In most of the cases doing a route lookup at this point is a noop as it will return you the same DOWN entry you already have. The exception is the case where the route has been removed from tree since your kernel looked for it. So what? It's just a blue packet. Note that this "exception" can only happen if your sending path does not run under the KERNEL_LOCK. ok mikeb@
2015-10-14Reset the RTF_CONNECTED flag when cloning an entry.Martin Pieuchot
While here check for RTF_CLONED insted of RTM_RESOLVE when adding an entry. Found while debugging naddy@'s NFS vs em(4) vs rtisvalid(9) issue.
2015-10-14Rewrite the logic around the dymanic array of routing tables to helpMartin Pieuchot
turning rtable_get(9) MP-safe. Use only one per-AF array, as suggested by claudio@, pointing to an array of pointers to the routing table heads. Routing tables are now allocated/initialized per-AF. This will let us allocate routing table on-demand instead of always having an AF_INET, AF_MPLS and AF_INET table as soon as a new rtableID is used. This also get rid of the "void ***" madness. ok dlg@, jmatthew@
2015-10-13Make sure RTF_LOCAL route entries are UP when added to the tree.Martin Pieuchot
This is required to maintain the original BSD behavior of locally configured addresses being always reacheable. Some interfaces are^w^W^Wem(4) is special and generally has a DOWN link state when configured by netstart(8). As a result all the route entries cloned/added before its link state goes to UP are also marked as DOWN. Note that this problem was not present when local addresses were attached to lo0. ok mikeb@
2015-10-07Initialize the routing table before domains.Martin Pieuchot
The routing table is not an optional component of the network stack and initializing it inside the "routing domain" requires some ugly introspection in the domain interface. This put the rtable* layer at the same level of the if* level. These two subsystem are organized around the two global data structure used in the network stack: - the global &ifnet list, to be used in process context only, and - the routing table which can be read in interrupt context. This change makes the rtable_* layer domain-aware and extends the "struct domain" such that INET, INET6 and MPLS can specify the length of the binary key used in lookups. This allows us to keep, or move towards, AF-free route and rtable layers. While here stop the madness and pass the size of the maximum key length in *byte* to rn_inithead0(). ok claudio@, mikeb@
2015-10-07Move route entry debug helpers where they belong.Martin Pieuchot
2015-10-07Move the reference counting of a newly created route entry insideMartin Pieuchot
rtable_insert(). inputs and ok bluhm@