diff options
author | 2002-06-24 23:57:28 +0000 | |
---|---|---|
committer | 2002-06-24 23:57:28 +0000 | |
commit | 531d77110a886c7316b9ed47e8324a3757828ab1 (patch) | |
tree | 725dfa24f5a4209f4ed6f73f539ff825b1a3e4ae | |
parent | Provide dummy d_kqfilter() routine so that this compiles, until this driver (diff) | |
download | wireguard-openbsd-531d77110a886c7316b9ed47e8324a3757828ab1.tar.xz wireguard-openbsd-531d77110a886c7316b9ed47e8324a3757828ab1.zip |
skip routing table lookup if multicasting/broadcasting and the outgoing
interface is specified by setsockopt. from freebsd4, sync with kame
(it makes difference when you run routed with RIPv2 enabled - no need for
224/4 route)
-rw-r--r-- | sys/netinet/ip_output.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index aa228f2faee..c5809942299 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_output.c,v 1.148 2002/06/04 21:48:14 jasoni Exp $ */ +/* $OpenBSD: ip_output.c,v 1.149 2002/06/24 23:57:28 itojun Exp $ */ /* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */ /* @@ -210,6 +210,12 @@ ip_output(struct mbuf *m0, ...) ifp = ia->ia_ifp; mtu = ifp->if_mtu; ip->ip_ttl = 1; + } else if ((IN_MULTICAST(ip->ip_dst.s_addr) || + (ip->ip_dst.s_addr == INADDR_BROADCAST)) && + imo != NULL && imo->imo_multicast_ifp != NULL) { + ifp = imo->imo_multicast_ifp; + mtu = ifp->if_mtu; + IFP_TO_IA(ifp, ia); } else { if (ro->ro_rt == 0) rtalloc(ro); @@ -366,6 +372,12 @@ ip_output(struct mbuf *m0, ...) ifp = ia->ia_ifp; mtu = ifp->if_mtu; ip->ip_ttl = 1; + } else if ((IN_MULTICAST(ip->ip_dst.s_addr) || + (ip->ip_dst.s_addr == INADDR_BROADCAST)) && + imo != NULL && imo->imo_multicast_ifp != NULL) { + ifp = imo->imo_multicast_ifp; + mtu = ifp->if_mtu; + IFP_TO_IA(ifp, ia); } else { if (ro->ro_rt == 0) rtalloc(ro); @@ -408,16 +420,22 @@ ip_output(struct mbuf *m0, ...) /* * See if the caller provided any multicast options */ - if (imo != NULL) { + if (imo != NULL) ip->ip_ttl = imo->imo_multicast_ttl; - if (imo->imo_multicast_ifp != NULL) { - ifp = imo->imo_multicast_ifp; - mtu = ifp->if_mtu; - } - } else + else ip->ip_ttl = IP_DEFAULT_MULTICAST_TTL; /* + * if we don't know the outgoing ifp yet, we can't generate + * output + */ + if (!ifp) { + ipstat.ips_noroute++; + error = EHOSTUNREACH; + goto bad; + } + + /* * Confirm that the outgoing interface supports multicast, * but only if the packet actually is going out on that * interface (i.e., no IPsec is applied). |