diff -ur v2.4.26/linux/Documentation/filesystems/proc.txt linux/Documentation/filesystems/proc.txt --- v2.4.26/linux/Documentation/filesystems/proc.txt 2003-06-14 08:41:59.000000000 +0300 +++ linux/Documentation/filesystems/proc.txt 2004-03-28 18:54:37.681460472 +0300 @@ -1550,6 +1550,18 @@ (external addresses can still be spoofed), without the need for additional firewall rules. +forward_shared +-------------- + +Integer value determines if a source validation should allow forwarding +of packets with local source address. 1 means yes, 0 means no. By default +the flag is disabled and such packets are not forwarded. + +If you enable this flag on internal network, the router will forward +packets from internal hosts with shared IP addresses no matter how +the rp_filter is set. This flag is activated only if it is enabled +both in specific device section and in "all" section. + secure_redirects ---------------- diff -ur v2.4.26/linux/Documentation/networking/ip-sysctl.txt linux/Documentation/networking/ip-sysctl.txt --- v2.4.26/linux/Documentation/networking/ip-sysctl.txt 2004-03-28 16:23:57.000000000 +0300 +++ linux/Documentation/networking/ip-sysctl.txt 2004-03-28 18:54:37.682460320 +0300 @@ -385,6 +385,17 @@ forwarding - BOOLEAN Enable IP forwarding on this interface. +forward_shared - BOOLEAN + Integer value determines if a source validation should allow + forwarding of packets with local source address. 1 means yes, + 0 means no. By default the flag is disabled and such packets + are not forwarded. + + If you enable this flag on internal network, the router will forward + packets from internal hosts with shared IP addresses no matter how + the rp_filter is set. This flag is activated only if it is + enabled both in specific device section and in "all" section. + mc_forwarding - BOOLEAN Do multicast routing. The kernel needs to be compiled with CONFIG_MROUTE and a multicast routing daemon is required. diff -ur v2.4.26/linux/include/linux/inetdevice.h linux/include/linux/inetdevice.h --- v2.4.26/linux/include/linux/inetdevice.h 2004-03-28 16:23:57.000000000 +0300 +++ linux/include/linux/inetdevice.h 2004-03-28 18:54:37.683460168 +0300 @@ -22,6 +22,7 @@ int arp_ignore; int medium_id; int force_igmp_version; + int forward_shared; void *sysctl; }; @@ -76,6 +77,8 @@ #define IN_DEV_ARP_ANNOUNCE(in_dev) (max(ipv4_devconf.arp_announce, (in_dev)->cnf.arp_announce)) #define IN_DEV_ARP_IGNORE(in_dev) (max(ipv4_devconf.arp_ignore, (in_dev)->cnf.arp_ignore)) +#define IN_DEV_FORWARD_SHARED(in_dev) ((in_dev)->cnf.forward_shared && ipv4_devconf.forward_shared) + struct in_ifaddr { struct in_ifaddr *ifa_next; diff -ur v2.4.26/linux/include/linux/sysctl.h linux/include/linux/sysctl.h --- v2.4.26/linux/include/linux/sysctl.h 2004-03-28 16:23:57.000000000 +0300 +++ linux/include/linux/sysctl.h 2004-03-28 18:55:09.558614408 +0300 @@ -364,6 +364,7 @@ NET_IPV4_CONF_FORCE_IGMP_VERSION=17, NET_IPV4_CONF_ARP_ANNOUNCE=18, NET_IPV4_CONF_ARP_IGNORE=19, + NET_IPV4_CONF_FORWARD_SHARED=20, }; /* /proc/sys/net/ipv4/netfilter */ diff -ur v2.4.26/linux/include/net/ip_fib.h linux/include/net/ip_fib.h --- v2.4.26/linux/include/net/ip_fib.h 2001-11-13 03:24:05.000000000 +0200 +++ linux/include/net/ip_fib.h 2004-03-28 18:54:37.685459864 +0300 @@ -203,7 +203,7 @@ extern int inet_rtm_getroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg); extern int inet_dump_fib(struct sk_buff *skb, struct netlink_callback *cb); extern int fib_validate_source(u32 src, u32 dst, u8 tos, int oif, - struct net_device *dev, u32 *spec_dst, u32 *itag); + struct net_device *dev, u32 *spec_dst, u32 *itag, int our); extern void fib_select_multipath(const struct rt_key *key, struct fib_result *res); /* Exported by fib_semantics.c */ diff -ur v2.4.26/linux/net/ipv4/devinet.c linux/net/ipv4/devinet.c --- v2.4.26/linux/net/ipv4/devinet.c 2004-03-28 16:23:57.000000000 +0300 +++ linux/net/ipv4/devinet.c 2004-03-28 18:55:35.175720016 +0300 @@ -1134,7 +1134,7 @@ static struct devinet_sysctl_table { struct ctl_table_header *sysctl_header; - ctl_table devinet_vars[20]; + ctl_table devinet_vars[21]; ctl_table devinet_dev[2]; ctl_table devinet_conf_dir[2]; ctl_table devinet_proto_dir[2]; @@ -1189,6 +1189,9 @@ {NET_IPV4_CONF_ARP_IGNORE, "arp_ignore", &ipv4_devconf.arp_ignore, sizeof(int), 0644, NULL, &proc_dointvec}, + {NET_IPV4_CONF_FORWARD_SHARED, "forward_shared", + &ipv4_devconf.forward_shared, sizeof(int), 0644, NULL, + &proc_dointvec}, {NET_IPV4_CONF_FORCE_IGMP_VERSION, "force_igmp_version", &ipv4_devconf.force_igmp_version, sizeof(int), 0644, NULL, &proc_dointvec}, diff -ur v2.4.26/linux/net/ipv4/fib_frontend.c linux/net/ipv4/fib_frontend.c --- v2.4.26/linux/net/ipv4/fib_frontend.c 2003-08-25 22:06:13.000000000 +0300 +++ linux/net/ipv4/fib_frontend.c 2004-03-28 18:54:37.687459560 +0300 @@ -204,13 +204,15 @@ */ int fib_validate_source(u32 src, u32 dst, u8 tos, int oif, - struct net_device *dev, u32 *spec_dst, u32 *itag) + struct net_device *dev, u32 *spec_dst, u32 *itag, + int our) { struct in_device *in_dev; struct rt_key key; struct fib_result res; int no_addr, rpf; int ret; + int fwdsh = 0; key.dst = src; key.src = dst; @@ -225,6 +227,7 @@ if (in_dev) { no_addr = in_dev->ifa_list == NULL; rpf = IN_DEV_RPFILTER(in_dev); + fwdsh = IN_DEV_FORWARD_SHARED(in_dev); } read_unlock(&inetdev_lock); @@ -233,7 +236,12 @@ if (fib_lookup(&key, &res)) goto last_resort; - if (res.type != RTN_UNICAST) + if (fwdsh) { + fwdsh = (res.type == RTN_LOCAL && !our); + if (fwdsh) + rpf = 0; + } + if (res.type != RTN_UNICAST && !fwdsh) goto e_inval_res; *spec_dst = FIB_RES_PREFSRC(res); fib_combine_itag(itag, &res); @@ -253,6 +261,8 @@ if (rpf) goto e_inval; key.oif = dev->ifindex; + if (fwdsh) + key.iif = loopback_dev.ifindex; ret = 0; if (fib_lookup(&key, &res) == 0) { diff -ur v2.4.26/linux/net/ipv4/route.c linux/net/ipv4/route.c --- v2.4.26/linux/net/ipv4/route.c 2003-11-28 22:04:14.000000000 +0200 +++ linux/net/ipv4/route.c 2004-03-28 18:54:37.689459256 +0300 @@ -1324,7 +1324,7 @@ goto e_inval; spec_dst = inet_select_addr(dev, 0, RT_SCOPE_LINK); } else if (fib_validate_source(saddr, 0, tos, 0, - dev, &spec_dst, &itag) < 0) + dev, &spec_dst, &itag, our) < 0) goto e_inval; rth = dst_alloc(&ipv4_dst_ops); @@ -1488,7 +1488,7 @@ int result; result = fib_validate_source(saddr, daddr, tos, loopback_dev.ifindex, - dev, &spec_dst, &itag); + dev, &spec_dst, &itag, 1); if (result < 0) goto martian_source; if (result) @@ -1515,7 +1515,7 @@ } err = fib_validate_source(saddr, daddr, tos, FIB_RES_OIF(res), dev, - &spec_dst, &itag); + &spec_dst, &itag, 0); if (err < 0) goto martian_source; @@ -1599,7 +1599,7 @@ spec_dst = inet_select_addr(dev, 0, RT_SCOPE_LINK); else { err = fib_validate_source(saddr, 0, tos, 0, dev, &spec_dst, - &itag); + &itag, 1); if (err < 0) goto martian_source; if (err)