From 6b9ff6b7a79345d668d945a6920b604b1551f6d9 Mon Sep 17 00:00:00 2001 From: "George V. Neville-Neil" Date: Thu, 17 Apr 2008 12:50:42 +0000 Subject: [PATCH] Clean up the code that checks the types of address so that it is done by understandable macros. Fix the bug that prevented the system from responding on interfaces with link local addresses assigned. PR: 120958 Submitted by: James Snow MFC after: 2 weeks --- sys/netinet/in.h | 2 ++ sys/netinet/ip_icmp.c | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/netinet/in.h b/sys/netinet/in.h index c470dc4a09bf..b969bdf5634b 100644 --- a/sys/netinet/in.h +++ b/sys/netinet/in.h @@ -383,6 +383,8 @@ __END_DECLS #define IN_BADCLASS(i) (((u_int32_t)(i) & 0xf0000000) == 0xf0000000) #define IN_LINKLOCAL(i) (((u_int32_t)(i) & 0xffff0000) == 0xa9fe0000) +#define IN_LOOPBACK(i) (((u_int32_t)(i) & 0xff000000) == 0x7f000000) +#define IN_ZERONET(i) (((u_int32_t)(i) & 0xff000000) == 0) #define IN_PRIVATE(i) ((((u_int32_t)(i) & 0xff000000) == 0x0a000000) || \ (((u_int32_t)(i) & 0xfff00000) == 0xac100000) || \ diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c index 8df3523a8d5f..98aeee8d3dd5 100644 --- a/sys/netinet/ip_icmp.c +++ b/sys/netinet/ip_icmp.c @@ -622,13 +622,14 @@ icmp_reflect(struct mbuf *m) struct mbuf *opts = 0; int optlen = (ip->ip_hl << 2) - sizeof(struct ip); - if (!in_canforward(ip->ip_src) && - ((ntohl(ip->ip_src.s_addr) & IN_CLASSA_NET) != - (IN_LOOPBACKNET << IN_CLASSA_NSHIFT))) { + if (IN_MULTICAST(ntohl(ip->ip_src.s_addr)) || + IN_EXPERIMENTAL(ntohl(ip->ip_src.s_addr)) || + IN_ZERONET(ntohl(ip->ip_src.s_addr)) ) { m_freem(m); /* Bad return address */ icmpstat.icps_badaddr++; goto done; /* Ip_output() will check for broadcast */ } + t = ip->ip_dst; ip->ip_dst = ip->ip_src;