summaryrefslogtreecommitdiff
path: root/sys/netinet6/in6_src.c
AgeCommit message (Collapse)Author
2024-04-21Implement rule 5.5 of RFC 6724 (Default Address Selection for IPv6)Florian Obser
Rule 5.5: Prefer addresses in a prefix advertised by the next-hop. For this we have to track the (link-local) address of the advertising router per interface address and compare it with the selected route. Rule 5.5 is useful in multi-homing setups where we have more than one prefix and default router. We have to use the source address with the correct default gateway otherwise traffic is likely going to be dropped because of BCP 38. While here refactor in6_update_ifa() a bit to make the code clearer and consistently use (var & flag) instead of (var & flag) != 0. Patiently reviewed by & OK bluhm.
2024-03-31Combine route_cache() and rtalloc_mpath() in new route_mpath().Alexander Bluhm
Fill and check the cache and call rtalloc_mpath() together. Then the caller of route_mpath() does not have to care about the uint32_t *src pointer and just pass struct in_addr. All the conversions are done inside the functions. A previous version of this diff was backed out. There was an additional rtisvalid() in rtalloc_mpath() that prevented packet output via interfaces that were not up. Now the route in the cache has to be valid, but after new lookup, rtalloc_mpath() may return invalid routes. This generates less errors in userland an preserves existing behavior. OK sashan@
2024-02-29revert "Combine route_cache() and rtalloc_mpath() in new route_mpath()"Christian Weisgerber
It breaks NFS. ok claudio@
2024-02-27Combine route_cache() and rtalloc_mpath() in new route_mpath().Alexander Bluhm
Fill and check the cache and call rtalloc_mpath() together. Then the caller of route_mpath() does not have to care about the uint32_t *src pointer and just pass struct in_addr. All the conversions are done inside the functions. ro->ro_rt is either valid or NULL. Note that some places have a stricter rtisvalid() now compared to the previous NULL check. OK claudio@
2024-02-22Make the route cache aware of multipath routing.Alexander Bluhm
Pass source address to route_cache() and store it in struct route. Cached multipath routes are only valid if source address matches. If sysctl multipath changes, increase route generation number. OK claudio@
2024-02-13Merge struct route and struct route_in6.Alexander Bluhm
Use a common struct route for both inet and inet6. Unfortunately struct sockaddr is shorter than sockaddr_in6, so netinet/in.h has to be exposed from net/route.h. Struct route has to be bsd visible for userland as netstat kvm code inspects inp_route. Internet PCB and TCP SYN cache can use a plain struct route now. All specific sockaddr types for inet and inet6 are embeded there. OK claudio@
2024-02-09Route cache function returns hit or miss.Alexander Bluhm
The route_cache() function can easily return whether it was a cache hit or miss. Then the logic to perform a route lookup gets a bit simpler. Some more complicated if (ro->ro_rt == NULL) checks still exist elsewhere. Also use route cache in in_pcbselsrc() instead of filling struct route manually. OK claudio@
2024-02-07Use the route generation number also for IPv6.Alexander Bluhm
Implement route6_cache() to check whether the cached route is still valid and otherwise fill caching parameter of struct route_in6. Also count cache hits and misses in netstat. in_pcbrtentry() uses route cache now. OK claudio@
2024-01-09Convert some struct inpcb parameter to const pointer.Alexander Bluhm
OK millert@
2023-12-15Use inpcb table mutex to set addresses.Alexander Bluhm
Protect all remaining write access to inp_faddr and inp_laddr with inpcb table mutex. Document inpcb locking for foreign and local address and port and routing table id. Reading will be made MP safe by adding per socket rw-locks in a next step. OK sashan@ mvs@
2023-12-03Rename all in6p local variables to inp.Alexander Bluhm
There exists no struct in6pcb in OpenBSD, this was an old kame idea. Calling the local variable in6p does not make sense, it is actually a struct inpcb. Also in6p is not used consistently in inet6 code. Having the same convention for IPv4 and IPv6 is less confusing. OK sashan@ mvs@
2023-12-01Make internet PCB connect more consistent.Alexander Bluhm
The public interface is in_pcbconnect(). It dispatches to in6_pcbconnect() if necessary. Call the former from tcp_connect() and udp_connect(). In in6_pcbconnect() initialization in6a = NULL is not necessary. in6_pcbselsrc() sets the pointer, but does not read the value. Pass a constant in6_addr pointer to in6_pcbselsrc() and in6_selectsrc(). It returns a reference to the address of some internal data structure. We want to be sure that in6_addr is not modified this way. IPv4 in_pcbselsrc() solves this by passing a copy of the address. OK kn@ sashan@ mvs@
2023-11-28Remove struct inpcb from in6_embedscope() parameters.Alexander Bluhm
rip6_output() did modify inp_outputopts6 temporarily to provide different ip6_pktopts to in6_embedscope(). Better pass inp_outputopts6 and inp_moptions6 as separate arguments to in6_embedscope(). Simplify the code that deals with these options in in6_embedscope(). Doucument inp_moptions and inp_moptions6 as protected by net lock. OK kn@
2022-02-22Delete unnecessary #includes of <sys/domain.h> and/or <sys/protosw.h>Philip Guenther
net/if_pppx.c pointed out by jsg@ ok gnezdo@ deraadt@ jsg@ mpi@ millert@
2021-03-10spellingJonathan Gray
ok gnezdo@ semarie@ mpi@
2020-11-07Rework source IP address setting.denis
- Move most of the processing out of rtable.c (reasonnable tb@, ok bluhm@) - Remove memory allocation, store pointer to existing ifaddr - Fix tunnel interface handling looks fine mpi@
2020-11-05Replace wrong cast with satosin.denis
Advised by bluhm@
2020-10-29Add feature to force the selection of source IP addressdenis
Based/previous work on an idea from deraadt@ Input from claudio@, djm@, deraadt@, sthen@ OK deraadt@
2016-12-02Rremoves 'struct route_in6 *' argument from in6_selectsrc().Martin Pieuchot
Move the corresponding code in in6_pcbselsrc(). This reduces differences with IPv4 and will help us to get rid of 'struct route*'. ok vgross@
2016-09-02in6_selectroute should never get a valid struct route * filled with somethingVincent Gross
else than AF_INET6. Ok florian@
2016-08-04Commit in6_selectsrc() split again, with missing assignment fixed.Vincent Gross
2016-07-22Revert in_selectsrc() refactoring, it breaks IPv6.Martin Pieuchot
Reported by Heiko on bugs@. ok stsp@, claudio@
2016-07-20Split in6_selectsrc() into a low-level part and a pcb-level part, andVincent Gross
convert in_selectsrc() prototype to match. Ok bluhm@ mpi@.
2016-07-05Expand IN6_IFF_NOTREADY, ok bluhm@Martin Pieuchot
2016-07-05Do not use ``rt_addr'' in in{6,}_selectsrc() it doesn't work with magicMartin Pieuchot
addresses set on p2p interfaces. Found the hardway by naddy@
2016-06-30Use ``rt_addr'' rather than ``rt_ifa'' to get the source addressMartin Pieuchot
corresponding to a route. ok florian@ on a previous version, input and ok bluhm@
2016-06-27Kill outdated comment. Reading the code is enough.Jeremie Courreges-Anglas
ok sthen@ bluhm@
2015-12-05Remove useless "if() else", multicast and unicast v6 route lookups areVincent Gross
actually the same. This has been introduced in r1.7 to prevent RTM_MISS storms, but we don't send this message anymore. 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-10-25Remove IPV6_NEXTHOP implementation. Source routing is considered to beFlorian Obser
a bad idea these days. kill it mpi@ general agreement in the network hackers room at u2k15
2015-10-25Use the "modern" way to check if a route entry correspond to a localMartin Pieuchot
address. Fix a regression introduced when removing the lo0 hack. ok florian@
2015-10-24Convert to rt_ifidx.Martin Pieuchot
ok bluhm@
2015-10-24Ignore Router Advertisment's current hop limit.Martin Pieuchot
Appart from the usual inet6 axe murdering exercise to keep you fit, this allows us to get rid of a lot of layer violation due to the use of per- ifp variables to store the current hop limit. Imputs from bluhm@, ok phessler@, florian@, bluhm@
2015-10-24Convert some if_ref() to if_get().Martin Pieuchot
ok claudio@
2015-10-22Use rt_ifp instead of rt_ifa->ifa_ifp.Martin Pieuchot
ok bluhm@
2015-10-19Stop checking for RTF_UP directly, call rtisvalid(9) instead.Martin Pieuchot
While here add two missing ``rtableid'' checks in in6_selectsrc(). ok bluhm@
2015-10-13Use rtisivalid(9) to check if the given (cached) route can be used.Martin Pieuchot
Note that after calling rtalloc(9) we only check if a route has been returned or not and do not check for its validity. This cannot be improved without a massive refactoring. The kernel currently *do* use !RTF_UP route due to a mismatch between the value of ifp->if_link_state and the IFF_UP|IFF_RUNNING code. I'd explain the RTF_UP flag as follow: . If a cached route entry w/o RTF_UP is passed to ip{6,}_output(), . call rtalloc(9) to see if a better entry is present in the tree. This is enough to support MPATH and route cache invalidation. ok bluhm@
2015-09-18Do not manually decrement rt's refcounter in nd6_lookup() and let theMartin Pieuchot
callers rtfree(9) it. Inputs and ok bluhm@
2015-09-11if_put after if_get for in6_src and ip6_output which got a lot easier afterClaudio Jeker
all the cleanup by mpi@ since we no longer overwrite ifps, etc. OK dlg@
2015-09-11Rewrite in6_selectroute() to no longer return an ifp.Martin Pieuchot
The returned "struct rtentry" is either the cached one or the one passed in options. ok claudio@
2015-09-11Move the multicast option parsing out of in6_selectroute().Martin Pieuchot
ok claudio@
2015-09-11Kill selectroute().Martin Pieuchot
ok claudio@
2015-09-11in6_embedscope() needs to lose some weight. Remove the last argument.Claudio Jeker
In all but two calls NULL is passed and in the other 2 cases the ifp is only used to maybe feed it to in6_selecthlim() to select the hoplimit for the link. Since in6_embedscope() only works on link-local addresses it does not matter what hop limit we select since the destination is directly reachable. OK florian@ mpi@
2015-09-10It is time to put inet6 on a diet. Use the flensing knife and cut outClaudio Jeker
the 3rd argument of in6_recoverscope() and make it return void. OK dlg@ mikeb@
2015-09-03Revert (again!) the two uses of rtisvalid(9), they break NFS!Martin Pieuchot
Found the hardway by naddy@
2015-09-03Convert ip{,6}_output() (cached) route entry checks to rtisvalid(9).Martin Pieuchot
This introduces a behavior change as we now reject !RTF_UP routes to output packets. This stricter check exposed a bug in the setup of new routes and was the reason for the previous revert. This should be now fixed by r1.229 of sys/net/route.c . ok bluhm@
2015-09-02Revert the two uses of rtisvalid(9) for the moment, it breaks dhclient(8)Martin Pieuchot
configured networks on RAMDISK kernels. The problem is that the default route installed by dhclient(8) does not have the RTF_UP flag in this environement and rtisvalid(9) doesn't allow you to use a RTF_DOWN route.
2015-09-01Convert ip{,6}_output() (cached) route entry checks to rtisvalid(9).Martin Pieuchot
ok bluhm@
2015-06-08More damned eye searing whitespace. No change to .o files.Kenneth R Westerback
2014-12-17Use an interface index instead of a pointer for multicast options.Martin Pieuchot
Output interface (port) selection for multicast traffic is not done via route lookups. Instead the output ifp is registred when setsockopt(2) is called with the IP{V6,}_MULTICAST_IF option. But since there is no mechanism to invalidate such pointer stored in a pcb when an interface is destroyed/removed, it might lead your kernel to fault. Prevent a fault upon resume reported by frantisek holop, thanks! ok mikeb@, claudio@