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 19:07:35.665188968 +0300 @@ -1550,6 +1550,16 @@ (external addresses can still be spoofed), without the need for additional firewall rules. +rp_filter_mask +-------------- + +Integer value representing bitmask of the mediums for which the reverse path +protection is disabled. If the source validation results in reverse path +to interface with medium_id value in the 1..31 range the access is +allowed if the corresponding bit is set in the bitmask. The bitmask value +is considered only when rp_filter is enabled. By default the bitmask is +empty preserving the original rp_filter semantic. + 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 19:09:46.708267392 +0300 @@ -530,6 +530,16 @@ The max value from conf/{all,interface}/arp_ignore is used when ARP request is received on the {interface} +rp_filter_mask - INTEGER + + Integer value representing bitmask of the mediums for which the + reverse path protection is disabled. If the source validation + results in reverse path to interface with medium_id value in + the 1..31 range the access is allowed if the corresponding bit + is set in the bitmask. The bitmask value is considered only when + rp_filter is enabled. By default the bitmask is empty preserving + the original rp_filter semantic. + tag - INTEGER Allows you to write a number, which can be used as required. Default value is 0. 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 19:07:35.667188664 +0300 @@ -22,6 +22,7 @@ int arp_ignore; int medium_id; int force_igmp_version; + int rp_filter_mask; void *sysctl; }; @@ -65,6 +66,7 @@ #define IN_DEV_SEC_REDIRECTS(in_dev) (ipv4_devconf.secure_redirects || (in_dev)->cnf.secure_redirects) #define IN_DEV_IDTAG(in_dev) ((in_dev)->cnf.tag) #define IN_DEV_MEDIUM_ID(in_dev) ((in_dev)->cnf.medium_id) +#define IN_DEV_RPFILTER_MASK(in_dev) ((in_dev)->cnf.rp_filter_mask) #define IN_DEV_RX_REDIRECTS(in_dev) \ ((IN_DEV_FORWARD(in_dev) && \ 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 19:07:57.263905464 +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_RP_FILTER_MASK=20, }; /* /proc/sys/net/ipv4/netfilter */ 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 19:08:11.901680184 +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]; @@ -1171,6 +1171,9 @@ {NET_IPV4_CONF_MEDIUM_ID, "medium_id", &ipv4_devconf.medium_id, sizeof(int), 0644, NULL, &proc_dointvec}, + {NET_IPV4_CONF_RP_FILTER_MASK, "rp_filter_mask", + &ipv4_devconf.rp_filter_mask, sizeof(int), 0644, NULL, + &proc_dointvec}, {NET_IPV4_CONF_BOOTP_RELAY, "bootp_relay", &ipv4_devconf.bootp_relay, 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 19:07:35.670188208 +0300 @@ -210,6 +210,7 @@ struct rt_key key; struct fib_result res; int no_addr, rpf; + unsigned rpf_mask = 0; int ret; key.dst = src; @@ -225,6 +226,7 @@ if (in_dev) { no_addr = in_dev->ifa_list == NULL; rpf = IN_DEV_RPFILTER(in_dev); + rpf_mask = IN_DEV_RPFILTER_MASK(in_dev); } read_unlock(&inetdev_lock); @@ -247,6 +249,17 @@ fib_res_put(&res); return ret; } + if (rpf_mask && rpf) { + int omi = 0; + + read_lock(&inetdev_lock); + in_dev = __in_dev_get(FIB_RES_DEV(res)); + if (in_dev) + omi = IN_DEV_MEDIUM_ID(in_dev); + read_unlock(&inetdev_lock); + if (omi >= 1 && omi <= 31 && ((1 << omi) & rpf_mask)) + rpf = 0; + } fib_res_put(&res); if (no_addr) goto last_resort;