diff -urN v2.5.67/linux/Documentation/filesystems/proc.txt linux/Documentation/filesystems/proc.txt --- v2.5.67/linux/Documentation/filesystems/proc.txt Tue Mar 18 23:09:46 2003 +++ linux/Documentation/filesystems/proc.txt Sat Apr 12 17:51:54 2003 @@ -1436,6 +1436,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 -urN v2.5.67/linux/Documentation/networking/ip-sysctl.txt linux/Documentation/networking/ip-sysctl.txt --- v2.5.67/linux/Documentation/networking/ip-sysctl.txt Tue Feb 25 01:56:45 2003 +++ linux/Documentation/networking/ip-sysctl.txt Sat Apr 12 17:51:54 2003 @@ -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 -urN v2.5.67/linux/include/linux/inetdevice.h linux/include/linux/inetdevice.h --- v2.5.67/linux/include/linux/inetdevice.h Mon Nov 11 23:43:52 2002 +++ linux/include/linux/inetdevice.h Sat Apr 12 17:51:54 2003 @@ -21,6 +21,7 @@ int medium_id; int no_xfrm; int no_policy; + int rp_filter_mask; void *sysctl; }; @@ -52,6 +53,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 -urN v2.5.67/linux/include/linux/sysctl.h linux/include/linux/sysctl.h --- v2.5.67/linux/include/linux/sysctl.h Tue Feb 25 01:56:55 2003 +++ linux/include/linux/sysctl.h Sat Apr 12 17:51:54 2003 @@ -355,6 +355,7 @@ NET_IPV4_CONF_MEDIUM_ID=14, NET_IPV4_CONF_NOXFRM=15, NET_IPV4_CONF_NOPOLICY=16, + NET_IPV4_CONF_RP_FILTER_MASK=17, }; /* /proc/sys/net/ipv6 */ diff -urN v2.5.67/linux/net/ipv4/devinet.c linux/net/ipv4/devinet.c --- v2.5.67/linux/net/ipv4/devinet.c Wed Apr 9 01:21:26 2003 +++ linux/net/ipv4/devinet.c Sat Apr 12 17:53:00 2003 @@ -1123,7 +1123,7 @@ static struct devinet_sysctl_table { struct ctl_table_header *sysctl_header; - ctl_table devinet_vars[17]; + ctl_table devinet_vars[18]; ctl_table devinet_dev[2]; ctl_table devinet_conf_dir[2]; ctl_table devinet_proto_dir[2]; @@ -1206,6 +1206,14 @@ .ctl_name = NET_IPV4_CONF_MEDIUM_ID, .procname = "medium_id", .data = &ipv4_devconf.medium_id, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dointvec, + }, + { + .ctl_name = NET_IPV4_CONF_RP_FILTER_MASK, + .procname = "rp_filter_mask", + .data = &ipv4_devconf.rp_filter_mask, .maxlen = sizeof(int), .mode = 0644, .proc_handler = &proc_dointvec, diff -urN v2.5.67/linux/net/ipv4/fib_frontend.c linux/net/ipv4/fib_frontend.c --- v2.5.67/linux/net/ipv4/fib_frontend.c Thu Oct 17 03:43:21 2002 +++ linux/net/ipv4/fib_frontend.c Sat Apr 12 17:51:54 2003 @@ -168,6 +168,7 @@ .iif = oif }; struct fib_result res; int no_addr, rpf; + unsigned rpf_mask = 0; int ret; no_addr = rpf = 0; @@ -176,6 +177,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); @@ -197,6 +199,17 @@ ret = FIB_RES_NH(res).nh_scope >= RT_SCOPE_HOST; 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)