diff options
| author | Ruslan Ermilov <ru@FreeBSD.org> | 2001-07-23 16:50:01 +0000 |
|---|---|---|
| committer | Ruslan Ermilov <ru@FreeBSD.org> | 2001-07-23 16:50:01 +0000 |
| commit | 38c1bc358bca6b0e6eb20e217d4d73d22fd1564b (patch) | |
| tree | d9215849ba66e316c4d21c46061257e2229a0f6c /sys | |
| parent | 7d3c25f7186e8c2e47c82a3ab8afec746f4a564f (diff) | |
Notes
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/netinet/ip_output.c | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 5d5b012a2e5c..9c0f974adaeb 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -253,14 +253,14 @@ ip_output(m0, opt, ro, flags, imo) ip->ip_ttl = 1; isbroadcast = in_broadcast(dst->sin_addr, ifp); } else if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) && - (imo != NULL) && - (imo->imo_multicast_ifp != NULL)) { + imo != NULL && imo->imo_multicast_ifp != NULL) { /* - * bypass the normal routing lookup for - * multicast packets if the interface is - * specified + * Bypass the normal routing lookup for multicast + * packets if the interface is specified. */ - /* No Operation */ + ifp = imo->imo_multicast_ifp; + IFP_TO_IA(ifp, ia); + isbroadcast = 0; /* fool gcc */ } else { /* * If this is the case, we probably don't want to allocate @@ -303,8 +303,6 @@ ip_output(m0, opt, ro, flags, imo) */ if (imo != NULL) { ip->ip_ttl = imo->imo_multicast_ttl; - if (imo->imo_multicast_ifp != NULL) - ifp = imo->imo_multicast_ifp; if (imo->imo_multicast_vif != -1) ip->ip_src.s_addr = ip_mcast_src(imo->imo_multicast_vif); @@ -325,13 +323,9 @@ ip_output(m0, opt, ro, flags, imo) * of outgoing interface. */ if (ip->ip_src.s_addr == INADDR_ANY) { - register struct in_ifaddr *ia1; - - TAILQ_FOREACH(ia1, &in_ifaddrhead, ia_link) - if (ia1->ia_ifp == ifp) { - ip->ip_src = IA_SIN(ia1)->sin_addr; - break; - } + /* Interface may have no addresses. */ + if (ia != NULL) + ip->ip_src = IA_SIN(ia)->sin_addr; } IN_LOOKUP_MULTI(ip->ip_dst, ifp, inm); @@ -394,15 +388,18 @@ ip_output(m0, opt, ro, flags, imo) * of outgoing interface. */ if (ip->ip_src.s_addr == INADDR_ANY) { - ip->ip_src = IA_SIN(ia)->sin_addr; + /* Interface may have no addresses. */ + if (ia != NULL) { + ip->ip_src = IA_SIN(ia)->sin_addr; #ifdef IPFIREWALL_FORWARD - /* Keep note that we did this - if the firewall changes - * the next-hop, our interface may change, changing the - * default source IP. It's a shame so much effort happens - * twice. Oh well. - */ - fwd_rewrite_src++; + /* Keep note that we did this - if the firewall changes + * the next-hop, our interface may change, changing the + * default source IP. It's a shame so much effort happens + * twice. Oh well. + */ + fwd_rewrite_src++; #endif /* IPFIREWALL_FORWARD */ + } } #endif /* notdef */ /* @@ -824,7 +821,7 @@ pass: } /* Record statistics for this interface address. */ - if (!(flags & IP_FORWARDING)) { + if (!(flags & IP_FORWARDING) && ia) { ia->ia_ifa.if_opackets++; ia->ia_ifa.if_obytes += m->m_pkthdr.len; } @@ -964,7 +961,7 @@ sendorfree: /* clean ipsec history once it goes out of the node */ ipsec_delaux(m); #endif - if (error == 0) { + if (error == 0 && ia) { /* Record statistics for this interface address. */ ia->ia_ifa.if_opackets++; ia->ia_ifa.if_obytes += m->m_pkthdr.len; |
