summaryrefslogtreecommitdiffstats
path: root/sys/netinet/ip_icmp.c
diff options
context:
space:
mode:
authorandre <andre@FreeBSD.org>2004-02-02 22:17:09 +0000
committerandre <andre@FreeBSD.org>2004-02-02 22:17:09 +0000
commitb302b73b2f51eb9e91f3450ba38de23267e78c4d (patch)
tree4a257bcf7ba7822db39db6fa826a2c076e904137 /sys/netinet/ip_icmp.c
parent47cec231e3011299954763f8283c9ce5f07ec678 (diff)
downloadFreeBSD-src-b302b73b2f51eb9e91f3450ba38de23267e78c4d.zip
FreeBSD-src-b302b73b2f51eb9e91f3450ba38de23267e78c4d.tar.gz
More verbose description of the source ip address selection for ICMP replies.
Reviewed by: bms
Diffstat (limited to 'sys/netinet/ip_icmp.c')
-rw-r--r--sys/netinet/ip_icmp.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c
index 220c624..340efd4 100644
--- a/sys/netinet/ip_icmp.c
+++ b/sys/netinet/ip_icmp.c
@@ -632,15 +632,21 @@ icmp_reflect(m)
}
t = ip->ip_dst;
ip->ip_dst = ip->ip_src;
+
/*
- * If the incoming packet was addressed directly to us,
- * use dst as the src for the reply. Otherwise (broadcast
- * or anonymous), use the address which corresponds
- * to the incoming interface.
+ * Source selection for ICMP replies:
+ *
+ * If the incoming packet was addressed directly to one of our
+ * own addresses, use dst as the src for the reply.
*/
LIST_FOREACH(ia, INADDR_HASH(t.s_addr), ia_hash)
if (t.s_addr == IA_SIN(ia)->sin_addr.s_addr)
goto match;
+ /*
+ * If the incoming packet was addressed to one of our broadcast
+ * addresses, use the first non-broadcast address which corresponds
+ * to the incoming interface.
+ */
if (m->m_pkthdr.rcvif != NULL &&
m->m_pkthdr.rcvif->if_flags & IFF_BROADCAST) {
TAILQ_FOREACH(ifa, &m->m_pkthdr.rcvif->if_addrhead, ifa_link) {
@@ -652,8 +658,13 @@ icmp_reflect(m)
goto match;
}
}
+ /*
+ * If the packet was transiting through us, use the address of
+ * the interface that is the closest to the packet source.
+ * When we don't have a route back to the packet source, stop here
+ * and drop the packet.
+ */
ia = ip_rtaddr(ip->ip_dst);
- /* We need a route to do anything useful. */
if (ia == NULL) {
m_freem(m);
icmpstat.icps_noroute++;
OpenPOWER on IntegriCloud