diff -ur v2.4.25/linux/Documentation/filesystems/proc.txt linux/Documentation/filesystems/proc.txt --- v2.4.25/linux/Documentation/filesystems/proc.txt 2003-06-14 08:41:59.000000000 +0300 +++ linux/Documentation/filesystems/proc.txt 2004-02-19 01:36:53.406998896 +0200 @@ -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.25/linux/Documentation/networking/ip-sysctl.txt linux/Documentation/networking/ip-sysctl.txt --- v2.4.25/linux/Documentation/networking/ip-sysctl.txt 2003-06-14 08:41:59.000000000 +0300 +++ linux/Documentation/networking/ip-sysctl.txt 2004-02-19 01:36:53.407998744 +0200 @@ -489,6 +489,16 @@ Alpha 1/1024s. See the HZ define in /usr/include/asm/param.h for the exact value on your system. +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. + Alexey Kuznetsov. kuznet@ms2.inr.ac.ru diff -ur v2.4.25/linux/include/linux/inetdevice.h linux/include/linux/inetdevice.h --- v2.4.25/linux/include/linux/inetdevice.h 2004-02-19 00:23:39.000000000 +0200 +++ linux/include/linux/inetdevice.h 2004-02-19 01:37:10.211444232 +0200 @@ -20,6 +20,7 @@ int arp_filter; int medium_id; int force_igmp_version; + int rp_filter_mask; void *sysctl; }; @@ -61,6 +62,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.25/linux/include/linux/sysctl.h linux/include/linux/sysctl.h --- v2.4.25/linux/include/linux/sysctl.h 2004-02-19 00:23:39.000000000 +0200 +++ linux/include/linux/sysctl.h 2004-02-19 01:37:29.927446944 +0200 @@ -360,6 +360,7 @@ NET_IPV4_CONF_ARPFILTER=13, NET_IPV4_CONF_MEDIUM_ID=14, NET_IPV4_CONF_FORCE_IGMP_VERSION=17, + NET_IPV4_CONF_RP_FILTER_MASK=18, }; /* /proc/sys/net/ipv4/netfilter */ diff -ur v2.4.25/linux/net/ipv4/devinet.c linux/net/ipv4/devinet.c --- v2.4.25/linux/net/ipv4/devinet.c 2004-02-19 00:23:39.000000000 +0200 +++ linux/net/ipv4/devinet.c 2004-02-19 01:37:43.125440544 +0200 @@ -1057,7 +1057,7 @@ static struct devinet_sysctl_table { struct ctl_table_header *sysctl_header; - ctl_table devinet_vars[18]; + ctl_table devinet_vars[19]; ctl_table devinet_dev[2]; ctl_table devinet_conf_dir[2]; ctl_table devinet_proto_dir[2]; @@ -1094,6 +1094,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.25/linux/net/ipv4/fib_frontend.c linux/net/ipv4/fib_frontend.c --- v2.4.25/linux/net/ipv4/fib_frontend.c 2003-08-25 22:06:13.000000000 +0300 +++ linux/net/ipv4/fib_frontend.c 2004-02-19 01:36:53.405999048 +0200 @@ -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;