diff options
author | melifaro <melifaro@FreeBSD.org> | 2016-01-09 16:34:37 +0000 |
---|---|---|
committer | melifaro <melifaro@FreeBSD.org> | 2016-01-09 16:34:37 +0000 |
commit | e4b451498bd9c31c5330b5eaae43284928764ed6 (patch) | |
tree | 579c8d1b294a8ca74c13716078c336d35c2125b0 /sys/net/if_fwsubr.c | |
parent | b67974b0beac9df3e1c67251c921e86f82779f70 (diff) | |
download | FreeBSD-src-e4b451498bd9c31c5330b5eaae43284928764ed6.zip FreeBSD-src-e4b451498bd9c31c5330b5eaae43284928764ed6.tar.gz |
Finish r275196: do not dereference rtentry in if_output() routines.
The only piece of information that is required is rt_flags subset.
In particular, if_loop() requires RTF_REJECT and RTF_BLACKHOLE flags
to check if this particular mbuf needs to be dropped (and what
error should be returned).
Note that if_loop() will always return EHOSTUNREACH for "reject" routes
regardless of RTF_HOST flag existence. This is due to upcoming routing
changes where RTF_HOST value won't be available as lookup result.
All other functions require RTF_GATEWAY flag to check if they need
to return EHOSTUNREACH instead of EHOSTDOWN error.
There are 11 places where non-zero 'struct route' is passed to if_output().
For most of the callers (forwarding, bpf, arp) does not care about exact
error value. In fact, the only place where this result is propagated
is ip_output(). (ip6_output() passes NULL route to nd6_output_ifp()).
Given that, add 3 new 'struct route' flags (RT_REJECT, RT_BLACKHOLE and
RT_IS_GW) and inline function (rt_update_ro_flags()) to copy necessary
rte flags to ro_flags. Call this function in ip_output() after looking up/
verifying rte.
Reviewed by: ae
Diffstat (limited to 'sys/net/if_fwsubr.c')
-rw-r--r-- | sys/net/if_fwsubr.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/sys/net/if_fwsubr.c b/sys/net/if_fwsubr.c index 626b1cb..a070f61 100644 --- a/sys/net/if_fwsubr.c +++ b/sys/net/if_fwsubr.c @@ -106,9 +106,8 @@ firewire_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, } #if defined(INET) || defined(INET6) - if (ro != NULL && ro->ro_rt != NULL && - (ro->ro_rt->rt_flags & RTF_GATEWAY) != 0) - is_gw = 1; + if (ro != NULL) + is_gw = (ro->ro_flags & RT_HAS_GW) != 0; #endif /* * For unicast, we make a tag to store the lladdr of the @@ -145,10 +144,6 @@ firewire_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, * doesn't fit into the arp model. */ if (unicast) { - is_gw = 0; - if (ro != NULL && ro->ro_rt != NULL && - (ro->ro_rt->rt_flags & RTF_GATEWAY) != 0) - is_gw = 1; error = arpresolve(ifp, is_gw, m, dst, (u_char *) destfw, NULL); if (error) return (error == EWOULDBLOCK ? 0 : error); |