use of mangle table enforced for ROUTE target
PATCH 1/1 use of mangle table enforced for ROUTE target
Hi all,
Here is a patch against the current CVS tree to enforce the use of the mangle table for the ROUTE target.
The mangle table is the natural place for this target. Since this target may crash the kernel if it is used inside the nat table (the interaction with nat is not well understood), I now force the use of the mangle table for the target.
A patch against the Netfilter Extension HOWTO will soon follow to reflect this change.
Cédric de Launois
patch-o-matic/extra/ROUTE.patch +10 -8
@@ -21,16 +21,12 @@ +#endif /*_IPT_ROUTE_H_target*/ diff -Nru linux.orig/net/ipv4/netfilter/ipt_ROUTE.c linux/net/ipv4/netfilter/ipt_ROUTE.c --- linux.orig/net/ipv4/netfilter/ipt_ROUTE.c Thu Jan 1 01:00:00 1970 -+++ linux/net/ipv4/netfilter/ipt_ROUTE.c Thu Jun 20 14:22:59 2002 -@@ -0,0 +1,267 @@ ++++ linux/net/ipv4/netfilter/ipt_ROUTE.c Fri Sep 20 14:23:26 2002 +@@ -0,0 +1,269 @@ +/* -+ * This is a module which is used for directly resending a received packet to ++ * This is a module which is used for directly sending a received packet to + * an interface specified by the user. -+ * This module is particularly useful when the destination IP address is an -+ * address owned by the router itself. Packets with such addresses are locally -+ * delivered by the kernel and cannot be forwarded using the standard routing -+ * mechanisms. -+ ++ * + * Based on code from: ipt_MIRROR.c and various sources. + * + * Copyright (C) 2002 Cedric de Launois <[email protected]>
@@ -252,6 +248,12 @@ + unsigned int targinfosize, + unsigned int hook_mask) +{ ++ if (strcmp(tablename, "mangle") != 0) { ++ printk("ipt_ROUTE: bad table `%s', use the `mangle' table.\n", ++ tablename); ++ return 0; ++ } ++ + if (hook_mask & ~(1 << NF_IP_PRE_ROUTING)) { + printk("ipt_ROUTE: bad hook\n"); + return 0;
patch-o-matic/extra/ROUTE.patch.help +6 -4
@@ -1,13 +1,15 @@ Author: Cédric de Launois <[email protected]> Status: In Development/Works for me - This option adds a `ROUTE' target, which allows you to directly resend + This option adds a `ROUTE' target, which allows you to directly send a received packet through a specified interface, even and especially if the packet IP address is one of the router itself. Those packets are locally delivered and cannot be forwarded to another computer using the standard routing mechanisms. - ROUTE target v1.2.7 options: + This target is to be used inside the mangle table. + + ROUTE target options: --iface name Send the packet directly through iface name. --ifindex index Send the packet directly through iface index.
@@ -18,8 +20,8 @@ computer having the same IP as the router and hosting the ssh service, thanks to this ROUTE target and an ipip tunnel. - # iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 22 -j ROUTE --iface tunl1 - # iptables -A PREROUTING -t nat -i tunl1 --j ROUTE --iface eth0 + # iptables -A PREROUTING -t mangle -i eth0 -p tcp --dport 22 -j ROUTE --iface tunl1 + # iptables -A PREROUTING -t mangle -i tunl1 --j ROUTE --iface eth0