summaryrefslogtreecommitdiff
path: root/sys/netinet
diff options
context:
space:
mode:
authorAngelos D. Keromytis <angelos@cvs.openbsd.org>2000-09-20 19:11:10 +0000
committerAngelos D. Keromytis <angelos@cvs.openbsd.org>2000-09-20 19:11:10 +0000
commit7a7287079d5b646997b9a902697cbacc1f74d5c5 (patch)
treeeb749df7260aff5f51795b21981ce0205b8b9ef6 /sys/netinet
parent52af272e9459618b0ddbe7123c1a2431a1226e86 (diff)
Don't use LOOPBACK addresses when trying to determine source address
to use in locally-generated ICMP messages (thanks to fcusack@fcusack.com)
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/ip_icmp.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c
index 4f0d260381d..8f3070a5627 100644
--- a/sys/netinet/ip_icmp.c
+++ b/sys/netinet/ip_icmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_icmp.c,v 1.23 2000/09/20 17:02:39 provos Exp $ */
+/* $OpenBSD: ip_icmp.c,v 1.24 2000/09/20 19:11:09 angelos Exp $ */
/* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */
/*
@@ -529,6 +529,7 @@ icmp_reflect(m)
struct in_addr t;
struct mbuf *opts = 0;
int optlen = (ip->ip_hl << 2) - sizeof(struct ip);
+ struct ifnet *ifp;
if (!in_canforward(ip->ip_src) &&
((ip->ip_src.s_addr & IN_CLASSA_NET) !=
@@ -559,8 +560,15 @@ icmp_reflect(m)
* The following happens if the packet was not addressed to us,
* and was received on an interface with no IP address.
*/
- if (ia == (struct in_ifaddr *)0)
- ia = in_ifaddr.tqh_first;
+ if (ia == (struct in_ifaddr *)0) {
+ for (ia = in_ifaddr.tqh_first; ia; ia = ia->ia_list.tqe_next) {
+ struct in_addr addr = ia->ia_addr.sin_addr;
+ INADDR_TO_IFP(addr, ifp);
+ if ((ifp == NULL) || (ifp->if_flags & IFF_LOOPBACK))
+ continue;
+ break;
+ }
+ }
t = ia->ia_addr.sin_addr;
ip->ip_src = t;
ip->ip_ttl = MAXTTL;