diff options
author | melifaro <melifaro@FreeBSD.org> | 2016-01-04 15:03:20 +0000 |
---|---|---|
committer | melifaro <melifaro@FreeBSD.org> | 2016-01-04 15:03:20 +0000 |
commit | 31d78f6810b70b03dcf590bdcd1f8520d199099d (patch) | |
tree | 97043b0fe5b60ef63af4661bdd61f9c954d3bf5b /sys/net/rtsock.c | |
parent | ff9e83788d7ed52342dcba4dff1e62fdf3cc985c (diff) | |
download | FreeBSD-src-31d78f6810b70b03dcf590bdcd1f8520d199099d.zip FreeBSD-src-31d78f6810b70b03dcf590bdcd1f8520d199099d.tar.gz |
Add rib_lookup_info() to provide API for retrieving individual route
entries data in unified format.
There are control plane functions that require information other than
just next-hop data (e.g. individual rtentry fields like flags or
prefix/mask). Given that the goal is to avoid rte reference/refcounting,
re-use rt_addrinfo structure to store most rte fields. If caller wants
to retrieve key/mask or gateway (which are sockaddrs and are allocated
separately), it needs to provide sufficient-sized sockaddrs structures
w/ ther pointers saved in passed rt_addrinfo.
Convert:
* lltable new records checks (in_lltable_rtcheck(),
nd6_is_new_addr_neighbor().
* rtsock pre-add/change route check.
* IPv6 NS ND-proxy check (RADIX_MPATH code was eliminated because
1) we don't support RTF_ANNOUNCE ND-proxy for networks and there should
not be multiple host routes for such hosts 2) if we have multiple
routes we should inspect them (which is not done). 3) the entire idea
of abusing KRT as storage for ND proxy seems odd. Userland programs
should be used for that purpose).
Diffstat (limited to 'sys/net/rtsock.c')
-rw-r--r-- | sys/net/rtsock.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 6fcbbc6..a5ca9fa 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -614,11 +614,16 @@ route_output(struct mbuf *m, struct socket *so, ...) */ if (info.rti_info[RTAX_GATEWAY] != NULL && info.rti_info[RTAX_GATEWAY]->sa_family != AF_LINK) { - struct route gw_ro; + struct rt_addrinfo ginfo; + struct sockaddr *gdst; + + bzero(&ginfo, sizeof(ginfo)); + bzero(&ss, sizeof(ss)); + ss.ss_len = sizeof(ss); + + ginfo.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&ss; + gdst = info.rti_info[RTAX_GATEWAY]; - bzero(&gw_ro, sizeof(gw_ro)); - gw_ro.ro_dst = *info.rti_info[RTAX_GATEWAY]; - rtalloc_ign_fib(&gw_ro, 0, fibnum); /* * A host route through the loopback interface is * installed for each interface adddress. In pre 8.0 @@ -629,14 +634,14 @@ route_output(struct mbuf *m, struct socket *so, ...) * AF_LINK sa_family type of the rt_gateway, and the * rt_ifp has the IFF_LOOPBACK flag set. */ - if (gw_ro.ro_rt != NULL && - gw_ro.ro_rt->rt_gateway->sa_family == AF_LINK && - gw_ro.ro_rt->rt_ifp->if_flags & IFF_LOOPBACK) { - info.rti_flags &= ~RTF_GATEWAY; - info.rti_flags |= RTF_GWFLAG_COMPAT; + if (rib_lookup_info(fibnum, gdst, NHR_REF, 0, &ginfo) == 0) { + if (ss.ss_family == AF_LINK && + ginfo.rti_ifp->if_flags & IFF_LOOPBACK) { + info.rti_flags &= ~RTF_GATEWAY; + info.rti_flags |= RTF_GWFLAG_COMPAT; + } + rib_free_info(&ginfo); } - if (gw_ro.ro_rt != NULL) - RTFREE(gw_ro.ro_rt); } switch (rtm->rtm_type) { |