--- sys/netinet/myloop_masklen.h +++ sys/netinet/myloop_masklen.h @@ -0,0 +1,7 @@ +#include "opt_myloop_masklen.h" + +#ifndef MYLOOP_MASKLEN +#define IN_MY_LOOP(i) (((u_int32_t)(i) & IN_CLASSA_NET) == (IN_LOOPBACKNET << IN_CLASSA_NSHIFT)) +#else +#define IN_MY_LOOP(i) (((u_int32_t)(i) & (INADDR_BROADCAST << (32 - MYLOOP_MASKLEN))) == (IN_LOOPBACKNET << IN_CLASSA_NSHIFT)) +#endif --- sys/netinet/in.c +++ sys/netinet/in.c @@ -48,6 +48,7 @@ #include #include +#include #include #include @@ -112,11 +113,11 @@ register u_long i = ntohl(in.s_addr); register u_long net; - if (IN_EXPERIMENTAL(i) || IN_MULTICAST(i)) + if (IN_EXPERIMENTAL(i) || IN_MULTICAST(i) || IN_MY_LOOP(i)) return (0); if (IN_CLASSA(i)) { net = i & IN_CLASSA_NET; - if (net == 0 || net == (IN_LOOPBACKNET << IN_CLASSA_NSHIFT)) + if (net == 0) return (0); } return (1); --- sys/netinet/ip_icmp.c +++ sys/netinet/ip_icmp.c @@ -50,6 +50,7 @@ #define _IP_VHL #include +#include #include #include #include @@ -612,8 +613,7 @@ int optlen = (IP_VHL_HL(ip->ip_vhl) << 2) - sizeof(struct ip); if (!in_canforward(ip->ip_src) && - ((ntohl(ip->ip_src.s_addr) & IN_CLASSA_NET) != - (IN_LOOPBACKNET << IN_CLASSA_NSHIFT))) { + !IN_MY_LOOP(ntohl(ip->ip_src.s_addr))) { m_freem(m); /* Bad return address */ goto done; /* Ip_output() will check for broadcast */ } --- sys/netinet/ip_input.c +++ sys/netinet/ip_input.c @@ -65,6 +65,7 @@ #include #include +#include #include #include #include @@ -347,8 +348,9 @@ } /* 127/8 must not appear on wire - RFC1122 */ - if ((ntohl(ip->ip_dst.s_addr) >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET || - (ntohl(ip->ip_src.s_addr) >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET) { + /* Local change: 127/MYLOOP_MASKLEN */ + if (IN_MY_LOOP(ntohl(ip->ip_dst.s_addr)) || + IN_MY_LOOP(ntohl(ip->ip_src.s_addr))) { if ((m->m_pkthdr.rcvif->if_flags & IFF_LOOPBACK) == 0) { ipstat.ips_badaddr++; goto bad; --- sys/i386/conf/LINT +++ sys/i386/conf/LINT @@ -425,6 +425,11 @@ # mchain library. It can be either loaded as KLD or compiled into kernel options LIBMCHAIN #mbuf management library +# Usually kernel must to drop any external packet with src in 127/8 +# But it is useful in clusters narrow this mask in kernel to use +# some nets in 127/8 for kernels interoperate in cluster. +options MYLOOP_MASKLEN=8 + # netgraph(4). Enable the base netgraph code with the NETGRAPH option. # Individual node types can be enabled with the corresponding option # listed below; however, this is not strictly necessary as netgraph --- sys/netinet/ip_output.c +++ sys/netinet/ip_output.c @@ -57,6 +57,7 @@ #include #include +#include #include #include #include @@ -772,8 +773,9 @@ ip_fw_fwd_addr = NULL; pass: /* 127/8 must not appear on wire - RFC1122. */ - if ((ntohl(ip->ip_dst.s_addr) >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET || - (ntohl(ip->ip_src.s_addr) >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET) { + /* Local change: 127/MYLOOP_MASKLEN */ + if (IN_MY_LOOP(ntohl(ip->ip_dst.s_addr)) || + IN_MY_LOOP(ntohl(ip->ip_src.s_addr))) { if ((ifp->if_flags & IFF_LOOPBACK) == 0) { ipstat.ips_badaddr++; error = EADDRNOTAVAIL; --- sys/conf/options +++ sys/conf/options @@ -297,6 +297,8 @@ TCPDEBUG TCP_DROP_SYNFIN opt_tcp_input.h XBONEHACK +# For interconnect beetween kernels in claster +MYLOOP_MASKLEN MBUF_STRESS_TEST opt_mbuf_stress_test.h # Netgraph(4). Use option NETGRAPH to enable the base netgraph code.