summaryrefslogtreecommitdiff
path: root/sys/net/route.c
AgeCommit message (Collapse)Author
2014-06-16Revert "Always create a local route for every configured IPv4 address",Martin Pieuchot
it introduces a regression with default routes & p2p interfaces. Problem reported by naddy@
2014-06-11Always create a local route for every configured IPv4 address on theMartin Pieuchot
machine and restore the original behavior of RTM_ADD and RTM_DELETE by always generating one message per locally configured address. Tested by krw@, jca@ and florian@
2014-06-11Flag local routes as such and make them use the highest possibleMartin Pieuchot
priority. Tested by krw@, jca@ and florian@
2014-05-27Big refactoring of the radix code (mainly rn_addroute but also partClaudio Jeker
of rn_delete was changed). The mpath code gets a much better rn_mpath_next() function that allows looping through the dupedkey list based on prio, any or only active routes. This solves the issues seen with failed deletes of down routes. Commit this now so that it gets tested. Both sthen@ and blambert@ agree.
2014-05-27Reserve the highest route priority for kernel-managed routes and preventMartin Pieuchot
userland from playing with the local and broadcast flags. ok claudio@
2014-05-21Fix IPsec route addition broken since the removal of the link-layerMartin Pieuchot
addresses from the per-ifp list. While here document why enc(4) needs a link-layer address, or at least something that seems to be one. Found the hard way and fix tested by naddy@, ok mikeb@, henning@
2014-04-29If you plan to write an obfuscated-by-design kernel / userlandMartin Pieuchot
interface, I suggest you have a look at the link-layer sockaddr interface: /* * A Link-Level Sockaddr may specify the interface in one of two * ways: either by means of a system-provided index number (computed * anew and possibly differently on every reboot), or by a human-readable * string such as "il0" (for managerial convenience). [...] */ ifa_ifwithnet() was not only checking for the sdl_index in order to get the corresponding ifp for AF_LINK sockaddr, it was also iterating over all the addresses on your system! But in this case, the `address' field of "struct sockaddr_dl" is an interface name set by link_addr(3). How can this work? Well because the kernel allocates an empty `netmask' field for each interface's lladdr, so that you can abuse a network comparison function to reimplement strcmp(3)... So when the userland does not specify an interface index, try harder to see if it passed an ifp name, but at least be explicit and use ifunit(). Found the hard way by/ok sthen@
2014-04-25Remove rti_ifp from rt_addrinfo, one less ifp pointer, say yay!Martin Pieuchot
This pointer was only needed by rt_getifa() to find an address, so turn it into a local variable. ok henning@, bluhm@
2014-04-23You don't want to use ifa_ifwithroute(), it exists for to the routingMartin Pieuchot
crazyness only.
2014-04-22ifa_ifwithroute() is the only magic place where an AF_LINK sockaddrMartin Pieuchot
can be given to ifa_ifwithnet(). Handle this specific case directly and let ifa_ifwithnet() do only one thing: iterate on all the addresses of all the interfaces in a given routing domain to return the most specific matching address. ok mikeb@
2014-04-11Fix tree breakage.Kenneth R Westerback
With r1.160 route.c needs #include <net/if_dl.h> because bsd.rd and friends don't pull in netmpls/mpls.h which is how bsd[.mp] get it. ok deraadt@ guenther@
2014-04-10Don't use ifa_ifwithnet() with obvious sockaddr_dl argument. ThisMartin Pieuchot
function should not deal with link-layer addresses and here there's no reason to do it. ok mikeb@
2014-04-10Retire rtinit() an use rt_ifa_add(9) and rt_ifa_del(9) to manageMartin Pieuchot
connected routes to prefixes/hosts. Since the introduction of rt_ifa_addloop(9) and rt_ifa_delloop(9), rtinit() was just a wrapper, so use the underlying functions directly and document them. Inputs from and ok mikeb@, manpage tweaks from jmc@
2014-04-03Introduce rt_ifa_{add,del}loop() to replace in6_{add,rem}loop().Martin Pieuchot
Move these functions to a more generic place and make them reuse existing code, they'll be soon used in IPv4 too. Tested by André Lucas, Vigdis and sthen@, thanks! ok sthen@
2014-03-27Stop mixing interface address flags with routing entry ones.Martin Pieuchot
Instead of always copying ifa_flags to the routing entry flags when creating a route by calling rtinit(), explicitly pass the RTF_CLONING flag when required. This means ifa_flags are now *only* used to check if an address has an associated route that was created by the kernel auto-magically. ok benno@
2014-03-21rt_timer* spring cleanup.Martin Pieuchot
Rename and document rt_timer_count() into rt_timer_queue_count() to be consistent with the other functions. Remove unused argument from rt_timer_queue_destroy(), clean the definitions and finally use the same order in NAME and DESCRIPTION as requested by jmc@. ok henning@
2014-03-18Rename rt_gettable() into rtable_get(), swap its arguments to beMartin Pieuchot
coherent with the existing rtable_* functions and document it. While here fix some other manpage glitches pointed out by jmc@.
2014-03-12RTAX_IFP points to the "struct sockaddr_dl" corresponding to theMartin Pieuchot
link-layer address of an interface. This ugly structure is used to export the interface's name and index, not only the link-layer address as its name might suggest. So instead reaching this descriptor by forcing and abusing the position of the link-layer "struct ifaddr" in the per-interface list, use the if_sadl pointer directly. ok mikeb@, henning@
2014-02-12Remove an old and unused define that should not be used.Martin Pieuchot
2014-02-12Remove an old comment about bsdi4 and make it clear that netmasks areMartin Pieuchot
not needed for routes to host. ok bluhm@, claudio@
2014-01-23Merge two chunks of code to inform listeners of a route change into aMartin Pieuchot
new function, rt_sendmsg(). While here, in the v6 cases, pass the same rtableid that was used for the request instead of dereferencing a pointer after checking for it to be NULL. ok krw@ on a previous version, ok bluhm@
2014-01-22Remove genmask support from the kernel. rtmsgs with RTA_GENMASK set willClaudio Jeker
now cause a EINVAL. The RTA_GENMASK and RTAX_GENMASK defines are kept for compatibility reasons. OK benno@ and agreed by dlg@
2014-01-10replace the rest of the obsolete radix macrosTed Unangst
sprinkle 0 -> NULL where obvious ok millert mpi
2014-01-09replace Bcopy macro with memmove and memcpy. ok mpiTed Unangst
2013-10-20rt_mpath_next() was always called with 0 in the last argument. So drop it.Claudio Jeker
OK henning@
2013-10-17The header file netinet/in_var.h included netinet6/in6_var.h. ThisAlexander Bluhm
created a bunch of useless dependencies. Remove this implicit inclusion and do an explicit #include <netinet6/in6_var.h> when it is needed. OK mpi@ henning@
2013-08-28Remove unused argument from *rtrequest()Martin Pieuchot
ok krw@, mikeb@
2013-03-28code that calls timeout functions should include timeout.hTed Unangst
slipped by on i386, but the zaurus doesn't automagically pick it up. spotted by patrick
2013-03-28no need for a lot of code to include proc.hTed Unangst
2013-03-07Remove the IFAFREE() macro, the ifafree() function it was calling alreadyMartin Pieuchot
check for the reference counter. ok mikeb@, miod@, pelikan@, kettenis@, krw@
2012-09-20Fix a pair of typos in comments.Bret Lambert
ok claudio@
2012-09-19Make rt_lookup return a pointer to an rtentry struct instead ofBret Lambert
to a radix_node struct. The radix tree pushdown continues. ok claudio@
2012-09-19More radix internals pushdown; place rn_mpath_next, which accepts andBret Lambert
returns radix_node pointers, inside a new rt_mpath_next, which accepts and returns rtentry pointers, and start using that instead. ok claudio@
2012-09-18Wrap rtable_add() and rtable_l2set() calls inside ifioctl() inside softnet,Bret Lambert
as functions that modify routing information shouldn't be interruptable by network traffic. Also make sure that both of those functions assert that they are called at softnet. I'm reasonably sure that there shouldn't be any, but if there is any codepath that was missed, we're going to be here for another 4 days to deal with any fallout. While here, move the multitude of "int s" declarations inside ifioctl to the beginning of the function. okay claudio@
2012-07-13Use NULL instead of 0 in pointer context. approvedz blambert@Claudio Jeker
2012-05-09backout 1.134 since it introduced a use-after-free for routing entries;Markus Friedl
ok blambert@ sthen@ henning@ claudio@
2011-12-06Remove needless temporary variable for greater clarity.Bret Lambert
testing sthen@ ok sthen@ henning@ dlg@
2011-12-06don't duplicate rtfree actions taken by rtrequest1() in rtdeletemsg()Bret Lambert
testing sthen@ ok sthen@ henning@ dlg@
2011-12-06simplify the somewhat-tangled conditional maze in rt_getifa()Bret Lambert
testing sthen@ ok sthen@ henning@ dlg@
2011-07-22fix typos, martin pelikanHenning Brauer
2011-07-04LINK_STATE cleanup. It is no longer needed to special case carp(4).Claudio Jeker
LINK_STATE_IS_UP() does the trick now for all cases. OK henning@ deraadt@
2011-04-04previous commit replaced a malloc(new) with malloc(sizeof(*new)) whichBret Lambert
leads to corrupted memory; backout to await a better fix
2011-04-04stop using the stupid R_Malloc/Bcopy/Free macros, and just start usingBret Lambert
malloc/bcopy/free, the way He Who Must Not Be Named intended. "yes please" claudio@
2010-11-16If the interface address referenced by a cloning route did not pointAlexander Bluhm
to an interface any more, the kernel crashed with a null pointer dereference. This situation could be created by a strange sequence of route and ifconfig commands. Now when a cloning route references a stale interface address and rtrequest1(RTM_RESOLVE) has to create a cloned route, it does a lookup for a valid interface address with the same ip address. The new interface address and its interface are used for the new cloned route and they replace the old ones at the cloning route. ok claudio@, henning@
2010-08-25Let rtable_add() return usefull errnos so that the ioctl handler and theClaudio Jeker
rtsock code can return a more reasonable error to the user. OK henning
2010-08-24Only do the link state checking and RTF_UP dance if the routing table isClaudio Jeker
rn_mpath_capable(). Move code down into the mpath specific block. Not all routing tables support multipath and therefor priorities.
2010-07-09Add support for using IPsec in multiple rdomains.Reyk Floeter
This allows to run isakmpd/iked/ipsecctl in multiple rdomains independently (with "route exec"); the kernel will pickup the rdomain from the process context of the pfkey socket and load the flows and SAs into the matching rdomain encap routing table. The network stack also needs to pass the rdomain to the ipsec stack to lookup the correct rdomain that belongs to an interface/mbuf/... You can now run individual IPsec configs per rdomain or create IPsec VPNs between multiple rdomains on the same machine ;). Note that a primary enc(4) in addition to enc0 interface is required per rdomain, eg. enc1 rdomain 1. Test by some people, mostly on existing "rdomain 0" setups. Was in snaps for some days and people didn't complain. ok claudio@ naddy@
2010-07-09Add the rtableid to struct rttimer and therefor make it available toClaudio Jeker
the callback functions. This fixes a problem where dynamic routes in different tables would not get deleted because the callback was doing the remove on the wrong table. OK henning@
2010-07-02remove prototype of okaytoclone, which got removed in 1.117Jonathan Gray
2010-07-01Allow to specify an alternative enc(4) interface for an SA. AllReyk Floeter
traffic for this SA will appear on the specified enc interface instead of enc0 and can be filtered and monitored separately. This will allow to group individual ipsec policies to virtual interfaces and simplifies monitoring and pf filtering with many ipsec policies a lot. This diff includes the following changes: - Store the enc interface unit (default 0) in the TDB of an SA and pass it to the enc_getif() lookup when running the bpf or pf_test() handlers. - Add the pfkey SADB_X_EXT_TAP extension to communicate the encX interface unit for a specified SA between userland and kernel. - Update enc(4) again to use an allocate array instead of the TAILQ to lookup the matching enc interface in enc_getif() quickly. Discussed with many, tested by a few, will need more testing & review. ok deraadt@