new iptables policy match
Subsystems (2)
Hello.
I'm testing the new iptables policy match on a snapshot kernel (2.6.15-git7). This is my simple network diagram:
eth1 eth0 eth0
eth1
10.1.2.0/24===172.16.1.247..[ipsec tunnel]..172.16.1.226===10.1.1.0/24
-----2.6.15-git7 linux box----- --------2.4/KLIPS box----------
I have setup a simple ipsec tunnel between the two linux boxes. So far, so good. I'm pinging from 10.1.2.1 (a system connected to the 10.1.2.0/24 net) to 10.1.1.1 (a system connected to the 10.1.1.0/24 net). This is iptables -L -v output:
root@Calimero:/tmp/RACOON# iptables -L -v Chain INPUT (policy ACCEPT 70672 packets, 15M bytes) pkts bytes target prot opt in out source destination
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination 19 1140 ACCEPT all -- any any anywhere anywhere
policy match dir out pol ipsec strict [0] [1] [2] [3] mode
tunnel tunnel-dst 10.1.1.0/24 tunnel-src 10.1.2.0/24
0 0 DROP all -- any any anywhere anywhere
policy match dir in pol ipsec strict [0] [1] [2] [3] mode tunnel
tunnel-dst 10.1.2.0/24 tunnel-src 10.1.1.0/24
0 0 ACCEPT all -- any any 10.1.2.0/24
10.1.1.0/24
19 1140 ACCEPT all -- any any 10.1.1.0/24
10.1.2.0/24
Chain OUTPUT (policy ACCEPT 39941 packets, 7146K bytes)
pkts bytes target prot opt in out source destination
As you can see the 2nd rule should drop ipsec packets but they aren't dropped:
I'm getting back the echo reply packets from 10.1.1.1 to 10.1.2.1 Also the 3rd rule counter doesn't increment.
Deleting the 1st and 2nd rule counter are fine:
root@Calimero:/tmp/RACOON# iptables -L -v Chain INPUT (policy ACCEPT 73891 packets, 15M bytes) pkts bytes target prot opt in out source destination
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination 66 3960 ACCEPT all -- any any 10.1.2.0/24
10.1.1.0/24
66 3960 ACCEPT all -- any any 10.1.1.0/24
10.1.2.0/24
Chain OUTPUT (policy ACCEPT 41881 packets, 7285K bytes)
pkts bytes target prot opt in out source destination
I know that this patches are "work in progress" and my apologies if this is a know problem, but I would like to know is this is a know issue.
PS: I'm using iptables v1.3.4-20060109 on Slackware 10.2
Quoted 17 lines · Marco Berizzi
Hello.
I'm testing the new iptables policy match on a snapshot kernel (2.6.15-git7). This is my simple network diagram:eth1 eth0 eth0 eth1
10.1.2.0/24===172.16.1.247..[ipsec tunnel]..172.16.1.226===10.1.1.0/24 -----2.6.15-git7 linux box-----
--------2.4/KLIPS box----------I have setup a simple ipsec tunnel between the two linux boxes. So far, so good. I'm pinging from 10.1.2.1 (a system connected to the 10.1.2.0/24 net) to 10.1.1.1 (a system connected to the 10.1.1.0/24 net). This is iptables -L -v output:
root@Calimero:/tmp/RACOON# iptables -L -v Chain INPUT (policy ACCEPT 70672 packets, 15M bytes) pkts bytes target prot opt in out source destination
Quoted 6 lines
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination 19 1140 ACCEPT all -- any any anywhereanywhere policy match dir out pol ipsec strict [0] [1] [2] [3] mode tunnel tunnel-dst 10.1.1.0/24 tunnel-src 10.1.2.0/24
0 0 DROP all -- any any anywhere
anywhere policy match dir in pol ipsec strict [0] [1] [2] [3] mode tunnel tunnel-dst 10.1.2.0/24 tunnel-src 10.1.1.0/24
How did you add these rules? It looks like you used "--next" multiple times without specifying a policy element ..
Quoted 26 lines · Patrick McHardy
Quoted 18 lines · Marco Berizzi
Hello.
I'm testing the new iptables policy match on a snapshot kernel (2.6.15-git7). This is my simple network diagram:eth1 eth0 eth0
eth1
10.1.2.0/24===172.16.1.247..[ipsec tunnel]..172.16.1.226===10.1.1.0/24
-----2.6.15-git7 linux box----- --------2.4/KLIPS
box----------I have setup a simple ipsec tunnel between the two linux boxes. So far, so good. I'm pinging from 10.1.2.1 (a system connected to the 10.1.2.0/24 net) to 10.1.1.1 (a system connected to the 10.1.1.0/24 net). This is iptables -L -v output:
root@Calimero:/tmp/RACOON# iptables -L -v Chain INPUT (policy ACCEPT 70672 packets, 15M bytes) pkts bytes target prot opt in out source destinationQuoted 6 lines
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination 19 1140 ACCEPT all -- any any anywhereanywhere policy match dir out pol ipsec strict [0] [1] [2] [3] mode tunnel tunnel-dst 10.1.1.0/24 tunnel-src 10.1.2.0/24
0 0 DROP all -- any any anywhere
anywhere policy match dir in pol ipsec strict [0] [1] [2] [3] mode tunnel tunnel-dst 10.1.2.0/24 tunnel-src 10.1.1.0/24
Quoted 2 lines
How did you add these rules? It looks like you used "--next" multiple times without specifying a policy element ..
This is the command:
iptables -P FORWARD DROP
iptables -A FORWARD -m policy --next --dir out --next --pol ipsec --next --mode tunnel --tunnel-src 10.1.2.0/24 --tunnel-dst 10.1.1.0/24 --strict -j ACCEPT iptables -A FORWARD -m policy --next --dir in --next --pol ipsec --next --mode tunnel --tunnel-dst 10.1.2.0/24 --tunnel-src 10.1.1.0/24 --strict -j DROP
Are they wrong?
Quoted 25 lines · Marco Berizzi
Quoted 10 lines · Patrick McHardy
Quoted 6 lines
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination 19 1140 ACCEPT all -- any any anywhereanywhere policy match dir out pol ipsec strict [0] [1] [2] [3] mode tunnel tunnel-dst 10.1.1.0/24 tunnel-src 10.1.2.0/24
0 0 DROP all -- any any anywhere
anywhere policy match dir in pol ipsec strict [0] [1] [2] [3] mode tunnel tunnel-dst 10.1.2.0/24 tunnel-src 10.1.1.0/24How did you add these rules? It looks like you used "--next" multiple times without specifying a policy element ..
This is the command:
iptables -P FORWARD DROP
iptables -A FORWARD -m policy --next --dir out --next --pol ipsec --next --mode tunnel
--tunnel-src 10.1.2.0/24 --tunnel-dst 10.1.1.0/24 --strict -j ACCEPT iptables -A FORWARD -m policy --next --dir in --next --pol ipsec --next --mode tunnel
--tunnel-dst 10.1.2.0/24 --tunnel-src 10.1.1.0/24 --strict -j DROP
Quoted 1 line
Are they wrong?
Yes, --next is needed only if your policy has multiple elements, like "--mode tunnel --tunnel-src 1.2.3.4/32 --next --mode transform". I'll fix up the userspace part to reject this incorrect use.
Quoted 26 lines · Patrick McHardy
Quoted 25 lines · Marco Berizzi
Quoted 10 lines · Patrick McHardy
Quoted 6 lines
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination 19 1140 ACCEPT all -- any any anywhereanywhere policy match dir out pol ipsec strict [0] [1] [2] [3] mode tunnel tunnel-dst 10.1.1.0/24 tunnel-src 10.1.2.0/24
0 0 DROP all -- any any anywhere
anywhere policy match dir in pol ipsec strict [0] [1] [2] [3] mode tunnel tunnel-dst 10.1.2.0/24 tunnel-src 10.1.1.0/24How did you add these rules? It looks like you used "--next" multiple times without specifying a policy element ..
This is the command:
iptables -P FORWARD DROP
iptables -A FORWARD -m policy --next --dir out --next --pol ipsec --next --mode tunnel
--tunnel-src 10.1.2.0/24 --tunnel-dst 10.1.1.0/24 --strict -j ACCEPT iptables -A FORWARD -m policy --next --dir in --next --pol ipsec --next --mode tunnel
--tunnel-dst 10.1.2.0/24 --tunnel-src 10.1.1.0/24 --strict -j DROP
Quoted 5 lines
Quoted 1 line
Are they wrong?
Yes, --next is needed only if your policy has multiple elements, like "--mode tunnel --tunnel-src 1.2.3.4/32 --next --mode transform". I'll fix up the userspace part to reject this incorrect use.
Ok, my fault sorry. Here is my corrected (I hope) iptables rules:
iptables -P FORWARD DROP
iptables -F
iptables -A FORWARD -m policy --dir out --pol ipsec --mode tunnel --tunnel-src 10.1.2.0/24 --tunnel-dst 10.1.1.0/24 -j DROP iptables -A FORWARD -m policy --dir in --pol ipsec --mode tunnel --tunnel-dst 10.1.2.0/24 --tunnel-src 10.1.1.0/24 -j DROP
iptables -A FORWARD -m policy --dir in --pol ipsec --mode tunnel --tunnel-src 10.1.2.0/24 --tunnel-dst 10.1.1.0/24 -j DROP iptables -A FORWARD -m policy --dir out --pol ipsec --mode tunnel --tunnel-dst 10.1.2.0/24 --tunnel-src 10.1.1.0/24 -j DROP
iptables -A FORWARD -s 10.1.2.0/24 -d 10.1.1.10/24 -j ACCEPT iptables -A FORWARD -d 10.1.2.0/24 -s 10.1.1.10/24 -j ACCEPT
iptables -L -v output:
root@Calimero:/tmp/RACOON# iptables -L -v Chain INPUT (policy ACCEPT 11574 packets, 2434K bytes) pkts bytes target prot opt in out source destination
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination 0 0 DROP all -- any any anywhere anywhere
policy match dir out pol ipsec mode tunnel tunnel-dst
10.1.1.0/24 tunnel-src 10.1.2.0/24
0 0 DROP all -- any any anywhere anywhere
policy match dir in pol ipsec mode tunnel tunnel-dst 10.1.2.0/24
tunnel-src 10.1.1.0/24
0 0 DROP all -- any any anywhere anywhere
policy match dir in pol ipsec mode tunnel tunnel-dst 10.1.1.0/24
tunnel-src 10.1.2.0/24
0 0 DROP all -- any any anywhere anywhere
policy match dir out pol ipsec mode tunnel tunnel-dst
10.1.2.0/24 tunnel-src 10.1.1.0/24
1074 64440 ACCEPT all -- any any 10.1.2.0/24 10.1.1.0/24 1074 64440 ACCEPT all -- any any 10.1.1.0/24 10.1.2.0/24
Chain OUTPUT (policy ACCEPT 5983 packets, 933K bytes)
pkts bytes target prot opt in out source destination
Ipsec policy match are never matched: I can ping-pong from-to both sites. I'm not understand what is wrong.
Quoted 35 lines · Marco Berizzi
Ok, my fault sorry. Here is my corrected (I hope) iptables rules:
iptables -P FORWARD DROP
iptables -Fiptables -A FORWARD -m policy --dir out --pol ipsec --mode tunnel --tunnel-src 10.1.2.0/24 --tunnel-dst 10.1.1.0/24 -j DROP iptables -A FORWARD -m policy --dir in --pol ipsec --mode tunnel --tunnel-dst 10.1.2.0/24 --tunnel-src 10.1.1.0/24 -j DROP
iptables -A FORWARD -m policy --dir in --pol ipsec --mode tunnel --tunnel-src 10.1.2.0/24 --tunnel-dst 10.1.1.0/24 -j DROP iptables -A FORWARD -m policy --dir out --pol ipsec --mode tunnel --tunnel-dst 10.1.2.0/24 --tunnel-src 10.1.1.0/24 -j DROP
iptables -A FORWARD -s 10.1.2.0/24 -d 10.1.1.10/24 -j ACCEPT iptables -A FORWARD -d 10.1.2.0/24 -s 10.1.1.10/24 -j ACCEPT
iptables -L -v output:
root@Calimero:/tmp/RACOON# iptables -L -v Chain INPUT (policy ACCEPT 11574 packets, 2434K bytes) pkts bytes target prot opt in out source destinationChain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination 0 0 DROP all -- any any anywhereanywhere policy match dir out pol ipsec mode tunnel tunnel-dst 10.1.1.0/24 tunnel-src 10.1.2.0/24
0 0 DROP all -- any any anywhere
anywhere policy match dir in pol ipsec mode tunnel tunnel-dst 10.1.2.0/24 tunnel-src 10.1.1.0/24
0 0 DROP all -- any any anywhere
anywhere policy match dir in pol ipsec mode tunnel tunnel-dst 10.1.1.0/24 tunnel-src 10.1.2.0/24
0 0 DROP all -- any any anywhere
anywhere policy match dir out pol ipsec mode tunnel tunnel-dst 10.1.2.0/24 tunnel-src 10.1.1.0/24
Quoted 8 lines
1074 64440 ACCEPT all -- any any 10.1.2.0/24 10.1.1.0/24 1074 64440 ACCEPT all -- any any 10.1.1.0/24 10.1.2.0/24Chain OUTPUT (policy ACCEPT 5983 packets, 933K bytes)
pkts bytes target prot opt in out source destinationIpsec policy match are never matched: I can ping-pong from-to both sites. I'm not understand what is wrong.
What does "ip xfrm policy" show?
Quoted 40 lines · Patrick McHardy
Quoted 38 lines · Marco Berizzi
Ok, my fault sorry. Here is my corrected (I hope) iptables rules:
iptables -P FORWARD DROP
iptables -Fiptables -A FORWARD -m policy --dir out --pol ipsec --mode tunnel --tunnel-src 10.1.2.0/24 --tunnel-dst 10.1.1.0/24 -j DROP iptables -A FORWARD -m policy --dir in --pol ipsec --mode tunnel --tunnel-dst 10.1.2.0/24 --tunnel-src 10.1.1.0/24 -j DROP
iptables -A FORWARD -m policy --dir in --pol ipsec --mode tunnel --tunnel-src 10.1.2.0/24 --tunnel-dst 10.1.1.0/24 -j DROP iptables -A FORWARD -m policy --dir out --pol ipsec --mode tunnel --tunnel-dst 10.1.2.0/24 --tunnel-src 10.1.1.0/24 -j DROP
iptables -A FORWARD -s 10.1.2.0/24 -d 10.1.1.10/24 -j ACCEPT iptables -A FORWARD -d 10.1.2.0/24 -s 10.1.1.10/24 -j ACCEPT
iptables -L -v output:
root@Calimero:/tmp/RACOON# iptables -L -v Chain INPUT (policy ACCEPT 11574 packets, 2434K bytes) pkts bytes target prot opt in out source destinationChain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination 0 0 DROP all -- any any anywhereanywhere policy match dir out pol ipsec mode tunnel tunnel-dst 10.1.1.0/24 tunnel-src 10.1.2.0/24
0 0 DROP all -- any any anywhere
anywhere policy match dir in pol ipsec mode tunnel tunnel-dst 10.1.2.0/24 tunnel-src 10.1.1.0/24
0 0 DROP all -- any any anywhere
anywhere policy match dir in pol ipsec mode tunnel tunnel-dst 10.1.1.0/24 tunnel-src 10.1.2.0/24
0 0 DROP all -- any any anywhere
anywhere policy match dir out pol ipsec mode tunnel tunnel-dst 10.1.2.0/24 tunnel-src 10.1.1.0/241074 64440 ACCEPT all -- any any 10.1.2.0/24 10.1.1.0/24 1074 64440 ACCEPT all -- any any 10.1.1.0/24 10.1.2.0/24
Quoted 7 lines
Quoted 5 lines
Chain OUTPUT (policy ACCEPT 5983 packets, 933K bytes)
pkts bytes target prot opt in out source destinationIpsec policy match are never matched: I can ping-pong from-to both sites. I'm not understand what is wrong.
What does "ip xfrm policy" show?
root@Calimero:/usr/src/linux-2.6.15/net/ipv4/netfilter# ip xfrm policy
src 10.1.1.0/24 dst 10.1.2.0/24
dir in priority 2344
tmpl src 172.16.1.226 dst 172.16.1.247
proto comp reqid 16386 mode tunnel
level use
tmpl src 0.0.0.0 dst 0.0.0.0
proto esp reqid 16385 mode transport
src 10.1.2.0/24 dst 10.1.1.0/24
dir out priority 2344
tmpl src 172.16.1.247 dst 172.16.1.226
proto comp reqid 16386 mode tunnel
tmpl src 0.0.0.0 dst 0.0.0.0
proto esp reqid 16385 mode transport
src 10.1.1.0/24 dst 10.1.2.0/24
dir fwd priority 2344
tmpl src 172.16.1.226 dst 172.16.1.247
proto comp reqid 16386 mode tunnel
level use
tmpl src 0.0.0.0 dst 0.0.0.0
proto esp reqid 16385 mode transport
src 0.0.0.0/0 dst 0.0.0.0/0
dir in priority 0
src 0.0.0.0/0 dst 0.0.0.0/0
dir in priority 0
src 0.0.0.0/0 dst 0.0.0.0/0
dir in priority 0
src 0.0.0.0/0 dst 0.0.0.0/0
dir out priority 0
src 0.0.0.0/0 dst 0.0.0.0/0
dir out priority 0
src 0.0.0.0/0 dst 0.0.0.0/0
dir out priority 0Quoted 20 lines · Marco Berizzi
Quoted 12 lines · Patrick McHardy
Quoted 10 lines · Marco Berizzi
Ok, my fault sorry. Here is my corrected (I hope) iptables rules:
iptables -P FORWARD DROP
iptables -Fiptables -A FORWARD -m policy --dir out --pol ipsec --mode tunnel --tunnel-src 10.1.2.0/24 --tunnel-dst 10.1.1.0/24 -j DROP iptables -A FORWARD -m policy --dir in --pol ipsec --mode tunnel --tunnel-dst 10.1.2.0/24 --tunnel-src 10.1.1.0/24 -j DROP
Quoted 5 lines
Quoted 5 lines
iptables -A FORWARD -m policy --dir in --pol ipsec --mode tunnel --tunnel-src 10.1.2.0/24 --tunnel-dst 10.1.1.0/24 -j DROP iptables -A FORWARD -m policy --dir out --pol ipsec --mode tunnel --tunnel-dst 10.1.2.0/24 --tunnel-src 10.1.1.0/24 -j DROP
Quoted 4 lines
root@Calimero:/usr/src/linux-2.6.15/net/ipv4/netfilter# ip xfrm policy
src 10.1.1.0/24 dst 10.1.2.0/24
dir in priority 2344
tmpl src 172.16.1.226 dst 172.16.1.247These are the addresses you need to use for --tunnel-src/dst, not the outer addresses. Those can be match with -s and -d are usual.
Quoted 21 lines · Patrick McHardy
Quoted 20 lines · Marco Berizzi
Quoted 17 lines · Patrick McHardy
Quoted 15 lines · Marco Berizzi
Ok, my fault sorry. Here is my corrected (I hope) iptables rules:
iptables -P FORWARD DROP
iptables -Fiptables -A FORWARD -m policy --dir out --pol ipsec --mode tunnel --tunnel-src 10.1.2.0/24 --tunnel-dst 10.1.1.0/24 -j DROP iptables -A FORWARD -m policy --dir in --pol ipsec --mode tunnel --tunnel-dst 10.1.2.0/24 --tunnel-src 10.1.1.0/24 -j DROP
iptables -A FORWARD -m policy --dir in --pol ipsec --mode tunnel --tunnel-src 10.1.2.0/24 --tunnel-dst 10.1.1.0/24 -j DROP iptables -A FORWARD -m policy --dir out --pol ipsec --mode tunnel --tunnel-dst 10.1.2.0/24 --tunnel-src 10.1.1.0/24 -j DROP
Quoted 7 lines
Quoted 4 lines
root@Calimero:/usr/src/linux-2.6.15/net/ipv4/netfilter# ip xfrm policy src 10.1.1.0/24 dst 10.1.2.0/24 dir in priority 2344 tmpl src 172.16.1.226 dst 172.16.1.247These are the addresses you need to use for --tunnel-src/dst, not the outer addresses. Those can be match with -s and -d are usual.
Aha! ;-)) It's working. Thanks a lot. Perhaps _IMHO_ this should be clarified in iptables man page. After all --tunnel-src/dst are the two IPsec endpoint addresses. Right?
Thanks again and sorry for wasting your time.
Ciao.
PS: I'm compiling right now 2.6.15-git8 with your latest patch: Check policy length in policy match strict mode.
Quoted 10 lines · Marco Berizzi
Quoted 2 lines · Patrick McHardy
These are the addresses you need to use for --tunnel-src/dst, not the outer addresses. Those can be match with -s and -d are usual.
Aha! ;-)) It's working. Thanks a lot. Perhaps _IMHO_ this should be clarified in iptables man page. After all --tunnel-src/dst are the two IPsec endpoint addresses. Right?
Yes. I don't see how it could be made any clearer, but feel free to send a suggestion :)
--tunnel-src addr[/mask]
Matches the source address of a tunnel. Only valid with
--mode tunnel.
--tunnel-dst addr[/mask]
Matches the destination address of a tunnel. Only valid
with --mode tunnel.
Quoted 15 lines · Patrick McHardy
Quoted 10 lines · Marco Berizzi
Quoted 2 lines · Patrick McHardy
These are the addresses you need to use for --tunnel-src/dst, not the outer addresses. Those can be match with -s and -d are usual.
Aha! ;-)) It's working. Thanks a lot. Perhaps _IMHO_ this should be clarified in iptables man page. After all --tunnel-src/dst are the two IPsec endpoint addresses. Right?
Yes. I don't see how it could be made any clearer, but feel free to send a suggestion :)
Quoted 7 lines
--tunnel-src addr[/mask]
Matches the source address of a tunnel. Only valid with
--mode tunnel.--tunnel-dst addr[/mask]
Matches the destination address of a tunnel. Only valid with
--mode tunnel.
Ok. Here is my suggestion:
--tunnel-src addr[/mask]
matches the source end-point address of the SA. Only valid with --mode tunnel
--tunnel-dst addr[/mask]
matches the destination end-point address of the SA. Only valid with --mode tunnel
Quoted 9 lines · Marco Berizzi
Ok. Here is my suggestion:
--tunnel-src addr[/mask]
matches the source end-point address of the SA. Only valid with --mode tunnel--tunnel-dst addr[/mask]
matches the destination end-point address of the SA. Only valid with --mode tunnel
Thanks, I've updated the man-page.
Quoted 4 lines · Patrick McHardy
Yes, --next is needed only if your policy has multiple elements, like "--mode tunnel --tunnel-src 1.2.3.4/32 --next --mode transform". I'll fix up the userspace part to reject this incorrect use.
The second of those patches (Revision 6395 -- Move empty policy element check to also catch last element) has broken compatibility with previous versions of policy match.
Previously, the following command succeeded and matched any traffic that is to be subsequently transformed:
gw:~ # iptables -A foo -m policy --pol ipsec --dir out -j ACCEPT iptables v1.3.4: policy match: empty policy element Try `iptables -h' or 'iptables --help' for more information. gw:~ #
Is this incompatibility intentional? If so, I need to change Shorewall accordingly.
Thanks,
-Tom
Signature · 4 lines
Tom Eastep \ Nothing is foolproof to a sufficiently talented fool Shoreline, \ http://shorewall.net Washington USA \ [email protected] PGP Public Key \ https://lists.shorewall.net/teastep.pgp.key
Quoted 15 lines · Tom Eastep
Quoted 3 lines · Patrick McHardy
Yes, --next is needed only if your policy has multiple elements, like "--mode tunnel --tunnel-src 1.2.3.4/32 --next --mode transform". I'll fix up the userspace part to reject this incorrect use.
The second of those patches (Revision 6395 -- Move empty policy element check to also catch last element) has broken compatibility with previous versions of policy match.
Previously, the following command succeeded and matched any traffic that is to be subsequently transformed:
Quoted 7 lines
gw:~ # iptables -A foo -m policy --pol ipsec --dir out -j ACCEPT iptables v1.3.4: policy match: empty policy element Try `iptables -h' or 'iptables --help' for more information. gw:~ #
Is this incompatibility intentional? If so, I need to change Shorewall accordingly.
Its a bug, thanks for catching this. I've fixed it up in SVN.
Quoted 6 lines · Marco Berizzi
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination 19 1140 ACCEPT all -- any any anywhereanywhere policy match dir out pol ipsec strict [0] [1] [2] [3] mode tunnel tunnel-dst 10.1.1.0/24 tunnel-src 10.1.2.0/24
0 0 DROP all -- any any anywhere
anywhere policy match dir in pol ipsec strict [0] [1] [2] [3] mode tunnel tunnel-dst 10.1.2.0/24 tunnel-src 10.1.1.0/24
There was actually a real problem, the first rule should never have matched because its length doesn't match the number of used transforms. I've fixed it with this patch (and added the additional checks to the userspace part).
[NETFILTER]: Check policy length in policy match strict mode
---
commit d98b092ef1a291d2fd31cbf1152bd16cca2e925d
tree bceb1f3d982e680b9ab3eb02e04e07a401bcd5db
parent a4fc7ab1d065a9dd89ed0e74439ef87d4a16e980
author Patrick McHardy <[email protected]> Thu, 12 Jan 2006 10:38:26 +0100 committer Patrick McHardy <[email protected]> Thu, 12 Jan 2006 10:38:26 +0100
net/ipv4/netfilter/ipt_policy.c | 2 +- net/ipv6/netfilter/ip6t_policy.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
net/ipv4/netfilter/ipt_policy.c +1 -1
@@ -89,7 +89,7 @@ match_policy_out(const struct sk_buff *sreturn 0 ; } -return strict ?1 :0 ; +return strict ? i == info->len :0 ; } static int match(const struct sk_buff *skb,
net/ipv6/netfilter/ip6t_policy.c +1 -1
@@ -91,7 +91,7 @@ match_policy_out(const struct sk_buff *sreturn 0 ; } -return strict ?1 :0 ; +return strict ? i == info->len :0 ; } static int match(const struct sk_buff *skb,