Skip to contentSkip to conversation

REJECT target / need-fragment ?

DISCUSSION Florian Lohoff 5 participants 8 messages Mar 14, 2005 – Apr 15, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,
i'd like to reject packets based on their size and send back and icmp-must-fragment with a configurable size. As i can see no such possibility is there currently. The REJECT target itself does not offer this.

Should i add this functionality to REJECT or rather write another module.

BTW: The ip stack has function like this:

	icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
				  htonl(dst_pmtu(&rt->u.dst)));

May i use this from iptables target modules ?

Flo

Signature · 2 lines
Florian Lohoff                  [email protected]             +49-171-2280134
                        Heisenberg may have been here.
#1 lore raw
Quoted 7 lines · Florian Lohoff

Hi,
i'd like to reject packets based on their size and send back and icmp-must-fragment with a configurable size. As i can see no such possibility is there currently. The REJECT target itself does not offer this.

Quoted 8 lines

Should i add this functionality to REJECT or rather write another module.

BTW: The ip stack has function like this:

	icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
				  htonl(dst_pmtu(&rt->u.dst)));

Search this list, or the netfilter-users list. I once posted a module that does just that.

M4

#2 lore raw
In reply to Florian Lohoff
Quoted 9 lines · Florian Lohoff

Hi,
i'd like to reject packets based on their size and send back and icmp-must-fragment with a configurable size. As i can see no such possibility is there currently. The REJECT target itself does not offer this.

Should i add this functionality to REJECT or rather write another module.

Quoted 6 lines

BTW: The ip stack has function like this:

	icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
				  htonl(dst_pmtu(&rt->u.dst)));

May i use this from iptables target modules ?

Yes, but adding yet another target that does something already done elsewhere is not a good idea. You could try to extend ipt_REJECT in a way similar to Rusty's patch "Add bitops to ipt_MARK without breaking compatbility".

Regards
Patrick

#3 lore raw
Quoted 11 lines · Patrick McHardy
Quoted 5 lines · Florian Lohoff

Hi,
i'd like to reject packets based on their size and send back and icmp-must-fragment with a configurable size. As i can see no such possibility is there currently. The REJECT target itself does not offer this.

Yes, but adding yet another target that does something already done elsewhere is not a good idea. You could try to extend ipt_REJECT in a way similar to Rusty's patch "Add bitops to ipt_MARK without breaking compatbility".

Ok - Had a boring network change this morning - results:

- iptables current svn patch (manpage, libipt_REJECT.c)
- kernel 2.6.11.6 patch (ipt_REJECT.[ch])

All with revisions so if i got it right should "not break compatibility"

Compiles and works for me ...

flo@touch:~$ sudo iptables -v -L
Chain INPUT (policy ACCEPT 485K packets, 145M bytes)
 pkts bytes target     prot opt in     out     source               destination 
   44 63243 PMTU       all  --  any    any     anywhere             anywhere    length 1001:1500

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination

Chain OUTPUT (policy ACCEPT 647K packets, 791M bytes)
pkts bytes target prot opt in out source destination

Chain PMTU (1 references)

 pkts bytes target     prot opt in     out     source               destination 
   44 63243 REJECT     all  --  any    any     anywhere             anywhere    reject-with icmp-frag-needed pmtu 1000

Comments ?

Flo

Signature · 2 lines
Florian Lohoff                  [email protected]             +49-171-2280134
                        Heisenberg may have been here.
libipt_REJECT.man +4 -0
Index: extensions/libipt_REJECT.man
===================================================================
@@ -21,6 +21,7 @@
 .B " icmp-net-prohibited"
 .B " icmp-host-prohibited or"
 .B " icmp-admin-prohibited (*)"
+.B " icmp-frag-needed"
 .fi
 which return the appropriate ICMP error message (\fBport-unreachable\fP is
 the default).  The option
@@ -31,4 +32,7 @@
 (113/tcp) probes which frequently occur when sending mail to broken mail
 hosts (which won't accept your mail otherwise).
 .TP
+.BI "--pmtu " "size"
+The next-hop MTU the icmp-frag-needed is sent back with.
+.TP
 (*) Using icmp-admin-prohibited with kernels that do not support it will result in a plain DROP instead of REJECT
libipt_REJECT.c +120 -3

171 lines not on this page · raw message

include/linux/netfilter_ipv4/ipt_REJECT.h +7 -1
diff -Nur linux-2.6.11.6.vanilla/include/linux/netfilter_ipv4/ipt_REJECT.h linux-2.6.11.6/include/linux/netfilter_ipv4/ipt_REJECT.h
@@ -10,11 +10,17 @@
 	IPT_ICMP_NET_PROHIBITED,
 	IPT_ICMP_HOST_PROHIBITED,
 	IPT_TCP_RESET,
-	IPT_ICMP_ADMIN_PROHIBITED
+	IPT_ICMP_ADMIN_PROHIBITED,
+	IPT_ICMP_FRAG_NEEDED
 };
 
 struct ipt_reject_info {
 	enum ipt_reject_with with;      /* reject type */
 };
 
+struct ipt_reject_info_v1 {
+	enum ipt_reject_with with;      /* reject type */
+	u_int16_t value;
+};
+
 #endif /*_IPT_REJECT_H*/
net/ipv4/netfilter/ipt_REJECT.c +110 -23

193 lines not on this page · raw message

#4 lore raw
Quoted 8 lines · Florian Lohoff
Quoted 6 lines · Patrick McHardy
Quoted 5 lines · Florian Lohoff

Hi,
i'd like to reject packets based on their size and send back and icmp-must-fragment with a configurable size. As i can see no such possibility is there currently. The REJECT target itself does not offer this.

Quoted 6 lines
Quoted 4 lines

Yes, but adding yet another target that does something already done elsewhere is not a good idea. You could try to extend ipt_REJECT in a way similar to Rusty's patch "Add bitops to ipt_MARK without breaking compatbility".

Ok - Had a boring network change this morning - results:

thanks, looks fine to me. I've applied the userspace part and put the kernel part into my list of pending patches.

Signature · 5 lines
- Harald Welte <[email protected]>                 http://netfilter.org/
============================================================================
  "Fragmentation is like classful addressing -- an interesting early
   architectural error that shows how much experimentation was going
   on while IP was being designed."                    -- Paul Vixie
#5 lore raw
Quoted 4 lines · Harald Welte

thanks, looks fine to me. I've applied the userspace part and put the kernel part into my list of pending patches.

The kernel part needs an intialization in _v1 for the pmtu value - Otherwise we leak the short pmtu as it gets used uninitialized. Probably 1500 is a good value.

Flo

Signature · 2 lines
Florian Lohoff                  [email protected]             +49-171-2280134
                        Heisenberg may have been here.
#6 lore raw
Quoted 10 lines · Florian Lohoff
Quoted 4 lines · Harald Welte

thanks, looks fine to me. I've applied the userspace part and put the kernel part into my list of pending patches.

The kernel part needs an intialization in _v1 for the pmtu value - Otherwise we leak the short pmtu as it gets used uninitialized. Probably 1500 is a good value.

Hi Florian,

FYI, You may want to check the compilation of svn iptables against a 2.4 kernel.

By applying the 2.6 kernel patch you mailed in this thread to 2.4 and fixing up the two rejects, it's possible to compile iptables svn against a 2.4 kernel, but the 2.4 kernel ipt_REJECT target compile fails because 2.4 doesn't have a revision field in ipt_target.

Removing the .revision initialization lines from ipt_REJECT.c gets the module to compile, but still with warnings:

gcc -D__KERNEL__ -I/home/debby/kernel/linux-2.4.30/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fomit-frame-pointer -pipe -mpreferred-stack-boundary=2 -march=i686 -DMODULE -DMODVERSIONS -include /home/debby/kernel/linux-2.4.30/include/linux/modversions.h -nostdinc -iwithprefix include -DKBUILD_BASENAME=ipt_REJECT -c -o ipt_REJECT.o ipt_REJECT.c
ipt_REJECT.c:481: warning: initialization from incompatible pointer type ipt_REJECT.c:488: warning: initialization from incompatible pointer type

I don't know what the correct fix is for 2.4.

Regards,
Filip

#7 lore raw
Quoted 7 lines · Filip Sneppe
Quoted 6 lines · Florian Lohoff
Quoted 4 lines · Harald Welte

thanks, looks fine to me. I've applied the userspace part and put the kernel part into my list of pending patches.

Quoted 8 lines
Quoted 4 lines

The kernel part needs an intialization in _v1 for the pmtu value - Otherwise we leak the short pmtu as it gets used uninitialized. Probably 1500 is a good value.

Hi Florian,

FYI, You may want to check the compilation of svn iptables against a 2.4 kernel.

I've now pulled out the changes. Please re-submit after confirming that

1) you can compile iptables with the pmtu patch against old (non-pmtu) 2.6 kernel
2) you can compile iptables with the pmtu patch against old (non-pmtu) 2.6 kernel
3) you can compile old non-pmtu iptables without pmtu patch against new (pmtu) 2.6 kernel

Thanks!

Signature · 5 lines
- Harald Welte <[email protected]>                 http://netfilter.org/
============================================================================
  "Fragmentation is like classful addressing -- an interesting early
   architectural error that shows how much experimentation was going
   on while IP was being designed."                    -- Paul Vixie