diff -urp v2.6.36/linux/Documentation/networking/ip-sysctl.txt linux/Documentation/networking/ip-sysctl.txt --- v2.6.36/linux/Documentation/networking/ip-sysctl.txt 2010-10-22 11:34:27.000000000 +0300 +++ linux/Documentation/networking/ip-sysctl.txt 2010-10-22 11:42:40.237176553 +0300 @@ -933,6 +933,14 @@ disable_xfrm - BOOLEAN +hidden - BOOLEAN + Hide addresses attached to this device from other devices. + Such addresses will never be selected by source address autoselection + mechanism, host does not answer broadcast ARP requests for them, + does not announce them as source address of ARP requests, but they + are still reachable via IP. This flag is activated only if it is + enabled both in specific device section and in "all" section. + tag - INTEGER Allows you to write a number, which can be used as required. Default value is 0. diff -urp v2.6.36/linux/include/linux/inetdevice.h linux/include/linux/inetdevice.h --- v2.6.36/linux/include/linux/inetdevice.h 2010-05-17 10:49:00.000000000 +0300 +++ linux/include/linux/inetdevice.h 2010-10-22 11:42:40.237176553 +0300 @@ -31,6 +31,7 @@ enum IPV4_DEVCONF_FORCE_IGMP_VERSION, IPV4_DEVCONF_ARP_ANNOUNCE, IPV4_DEVCONF_ARP_IGNORE, + IPV4_DEVCONF_HIDDEN, IPV4_DEVCONF_PROMOTE_SECONDARIES, IPV4_DEVCONF_ARP_ACCEPT, IPV4_DEVCONF_ARP_NOTIFY, @@ -126,6 +127,7 @@ static inline void ipv4_devconf_setall(s SECURE_REDIRECTS) #define IN_DEV_IDTAG(in_dev) IN_DEV_CONF_GET(in_dev, TAG) #define IN_DEV_MEDIUM_ID(in_dev) IN_DEV_CONF_GET(in_dev, MEDIUM_ID) +#define IN_DEV_HIDDEN(in_dev) IN_DEV_ANDCONF((in_dev), HIDDEN) #define IN_DEV_PROMOTE_SECONDARIES(in_dev) \ IN_DEV_ORCONF((in_dev), \ PROMOTE_SECONDARIES) diff -urp v2.6.36/linux/net/ipv4/arp.c linux/net/ipv4/arp.c --- v2.6.36/linux/net/ipv4/arp.c 2010-10-22 11:34:38.000000000 +0300 +++ linux/net/ipv4/arp.c 2010-10-23 12:48:20.946274306 +0300 @@ -71,6 +71,8 @@ * sending (e.g. insert 8021q tag). * Harald Welte : convert to make use of jenkins hash * Jesper D. Brouer: Proxy ARP PVLAN RFC 3069 support. + * Julian Anastasov: "hidden" flag: hide the + * interface and don't reply for it */ #include @@ -336,7 +338,9 @@ static void arp_solicit(struct neighbour struct net_device *dev = neigh->dev; __be32 target = *(__be32*)neigh->primary_key; int probes = atomic_read(&neigh->probes); - struct in_device *in_dev; + struct in_device *in_dev, *in_dev2; + struct net_device *dev2 = NULL; + int mode; rcu_read_lock(); in_dev = __in_dev_get_rcu(dev); @@ -344,17 +348,30 @@ static void arp_solicit(struct neighbour rcu_read_unlock(); return; } - switch (IN_DEV_ARP_ANNOUNCE(in_dev)) { + mode = IN_DEV_ARP_ANNOUNCE(in_dev); + if (mode != 2 && skb && + (dev2 = ip_dev_find(dev_net(dev), ip_hdr(skb)->saddr)) != NULL && + (saddr = ip_hdr(skb)->saddr, + in_dev2 = __in_dev_get_rcu(dev2)) != NULL && + IN_DEV_HIDDEN(in_dev2)) { + saddr = 0; + goto get; + } + + switch (mode) { default: case 0: /* By default announce any local IP */ + if (saddr) + break; if (skb && inet_addr_type(dev_net(dev), ip_hdr(skb)->saddr) == RTN_LOCAL) saddr = ip_hdr(skb)->saddr; break; case 1: /* Restrict announcements of saddr in same subnet */ if (!skb) break; - saddr = ip_hdr(skb)->saddr; - if (inet_addr_type(dev_net(dev), saddr) == RTN_LOCAL) { + if (saddr || + (saddr = ip_hdr(skb)->saddr, + inet_addr_type(dev_net(dev), saddr) == RTN_LOCAL)) { /* saddr should be known to target */ if (inet_addr_onlink(in_dev, target, saddr)) break; @@ -364,6 +381,10 @@ static void arp_solicit(struct neighbour case 2: /* Avoid secondary IPs, get a primary/preferred one */ break; } + +get: + if (dev2) + dev_put(dev2); rcu_read_unlock(); if (!saddr) @@ -440,6 +461,23 @@ static int arp_filter(__be32 sip, __be32 return flag; } +static int arp_hidden(u32 tip, struct net_device *dev) +{ + struct net_device *dev2 = NULL; + struct in_device *in_dev2; + int ret = 0; + + if (!IPV4_DEVCONF_ALL(dev_net(dev), HIDDEN)) + return 0; + + if ((dev2 = ip_dev_find(dev_net(dev), tip)) && dev2 != dev && + (in_dev2 = __in_dev_get_rcu(dev2)) && IN_DEV_HIDDEN(in_dev2)) + ret = 1; + if (dev2) + dev_put(dev2); + return ret; +} + /* OBSOLETE FUNCTIONS */ /* @@ -856,6 +894,7 @@ static int arp_process(struct sk_buff *s if (sip == 0) { if (arp->ar_op == htons(ARPOP_REQUEST) && inet_addr_type(net, tip) == RTN_LOCAL && + !arp_hidden(tip, dev) && !arp_ignore(in_dev, sip, tip)) arp_send(ARPOP_REPLY, ETH_P_ARP, sip, dev, tip, sha, dev->dev_addr, sha); @@ -875,6 +914,8 @@ static int arp_process(struct sk_buff *s dont_send |= arp_ignore(in_dev,sip,tip); if (!dont_send && IN_DEV_ARPFILTER(in_dev)) dont_send |= arp_filter(sip,tip,dev); + if (!dont_send && skb->pkt_type != PACKET_HOST) + dont_send |= arp_hidden(tip,dev); if (!dont_send) { n = neigh_event_ns(&arp_tbl, sha, &sip, dev); if (n) { diff -urp v2.6.36/linux/net/ipv4/devinet.c linux/net/ipv4/devinet.c --- v2.6.36/linux/net/ipv4/devinet.c 2010-10-22 11:34:38.000000000 +0300 +++ linux/net/ipv4/devinet.c 2010-10-22 11:42:40.247176832 +0300 @@ -897,7 +897,8 @@ no_in_dev: continue; for_primary_ifa(in_dev) { - if (ifa->ifa_scope != RT_SCOPE_LINK && + if (!IN_DEV_HIDDEN(in_dev) && + ifa->ifa_scope != RT_SCOPE_LINK && ifa->ifa_scope <= scope) { addr = ifa->ifa_local; goto out_unlock; @@ -1410,6 +1411,7 @@ static struct devinet_sysctl_table { DEVINET_SYSCTL_RW_ENTRY(BOOTP_RELAY, "bootp_relay"), DEVINET_SYSCTL_RW_ENTRY(LOG_MARTIANS, "log_martians"), DEVINET_SYSCTL_RW_ENTRY(TAG, "tag"), + DEVINET_SYSCTL_RW_ENTRY(HIDDEN, "hidden"), DEVINET_SYSCTL_RW_ENTRY(ARPFILTER, "arp_filter"), DEVINET_SYSCTL_RW_ENTRY(ARP_ANNOUNCE, "arp_announce"), DEVINET_SYSCTL_RW_ENTRY(ARP_IGNORE, "arp_ignore"),