New: ip_conntrack_in: Frag of proto 17
Quoted 1 line · David S. Miller
If this is true, we need to fix this soon.
Agreed.
I think I've seen something similar in the past, though it was some broken code in my experimental tree ;). ip_conntrack on an NFS server has always had a bad history, I have to admit :(
Big question number 1:
First of all, why would a local loopback nfs mount do any fragmenting in the first place? 'lo' has a MTU of 16k, so why would any piece of code in the output path build fragments, even with rsize/wsize=8192?
The conntrack message basically means that at NF_IP_PRE_ROUTING we suddenly see fragmented packets. This "can never happen" since at the same PRE_ROUTING hook we defragment just before
via ip_conntrack_defrag() -> ip_ct_gather_frags() -> ip_defrag()
Big question number 2:
How can a fragment survive ip_defrag() ?
Big question number 3:
What is this magic 8k limit? ip_conntrack doesn't impose any arbitrary size limitations to packets... and we just use the normal defragmentation code.
I'm more than puzzled about this, need to do some testing.
Signature · 5 lines
- Harald Welte <[email protected]> http://www.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
Quoted 8 lines · Harald Welte
The conntrack message basically means that at
NF_IP_PRE_ROUTINGwe suddenly see fragmented packets. This "can never happen" since at the samePRE_ROUTINGhook we defragment just before
viaip_conntrack_defrag()->ip_ct_gather_frags()->ip_defrag()Big question number 2:
How can a fragment surviveip_defrag()?
Pretty simple:
static unsigned int ip_conntrack_defrag(unsigned int hooknum,
struct sk_buff **pskb, const struct net_device *in, const struct net_device *out, int (*okfn)(struct sk_buff *))
{
/* Previously seen (loopback)? Ignore. Do this before
fragment check. */
if ((*pskb)->nfct)
return NF_ACCEPT;I'll send a patch later.
Regards
Patrick
Quoted 6 lines · Harald Welte
The conntrack message basically means that at
NF_IP_PRE_ROUTINGwe suddenly see fragmented packets. This "can never happen" since at the samePRE_ROUTINGhook we defragment just before
viaip_conntrack_defrag()->ip_ct_gather_frags()->ip_defrag()
Here is the patch. Untracked and already tracked (loopback) packets are not defragmented, but the check in ip_conntrack_in for untracked/already tracked is after the check for fragments. This patch moves it up.
# This is a BitKeeper generated diff -Nru style patch. #
# ChangeSet
# 2004/09/29 01:26:22+02:00 [email protected]
# [NETFILTER]: move check for already tracked/untracked before fragment check
#
# Signed-off-by: Patrick McHardy <[email protected]>
#
# net/ipv4/netfilter/ip_conntrack_core.c # 2004/09/29 01:25:49+02:00 [email protected] +6 -6 # [NETFILTER]: move check for already tracked/untracked before fragment check # # Signed-off-by: Patrick McHardy <[email protected]> # diff -Nru a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c --- a/net/ipv4/netfilter/ip_conntrack_core.c 2004-09-29 01:27:34 +02:00 +++ b/net/ipv4/netfilter/ip_conntrack_core.c 2004-09-29 01:27:34 +02:00 @@ -688,6 +688,12 @@ int set_reply; int ret;
+ /* Previously seen (loopback or untracked)? Ignore. */
+ if ((*pskb)->nfct) {
+ CONNTRACK_STAT_INC(ignore);
+ return NF_ACCEPT;
+ }
+
/* Never happen */
if ((*pskb)->nh.iph->frag_off & htons(IP_OFFSET)) {
if (net_ratelimit()) {
@@ -714,12 +720,6 @@
(*pskb)->sk, (*pskb)->pkt_type);
}
#endif
-
- /* Previously seen (loopback or untracked)? Ignore. */
- if ((*pskb)->nfct) {
- CONNTRACK_STAT_INC(ignore);
- return NF_ACCEPT;
- }
proto = ip_ct_find_proto((*pskb)->nh.iph->protocol);
David S. Miller
AppliedQuoted 9 lines · On Wed, 29 Sep 2004 01:35:53 +0200 Patrick McHardy <[email protected]> wrote:
Quoted 6 lines · Harald Welte
The conntrack message basically means that at
NF_IP_PRE_ROUTINGwe suddenly see fragmented packets. This "can never happen" since at the samePRE_ROUTINGhook we defragment just before
viaip_conntrack_defrag()->ip_ct_gather_frags()->ip_defrag()
Quoted 4 lines
Here is the patch. Untracked and already tracked (loopback) packets are not defragmented, but the check in
ip_conntrack_infor untracked/already tracked is after the check for fragments. This patch moves it up.
Applied, thanks a lot Patrick.
Quoted 9 lines · Patrick McHardy
Quoted 6 lines · Harald Welte
The conntrack message basically means that at
NF_IP_PRE_ROUTINGwe suddenly see fragmented packets. This "can never happen" since at the samePRE_ROUTINGhook we defragment just before
viaip_conntrack_defrag()->ip_ct_gather_frags()->ip_defrag()
Quoted 4 lines
Here is the patch. Untracked and already tracked (loopback) packets are not defragmented, but the check in
ip_conntrack_infor untracked/already tracked is after the check for fragments. This patch moves it up.
Sometimes I feel like I'm blind. Thanks, Patrick.
Signature · 5 lines
- Harald Welte <[email protected]> http://www.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
Quoted 6 lines · Harald Welte
Quoted 4 lines
Here is the patch. Untracked and already tracked (loopback) packets are not defragmented, but the check in
ip_conntrack_infor untracked/already tracked is after the check for fragments. This patch moves it up.Sometimes I feel like I'm blind. Thanks, Patrick.
Hmm..
loopback traffic is seen twice by netfilter, once when being sent, once when being received. If a packet larger than the loopback MTU is sent this will get fragmented (by conntrack) and then reinjected.. has it been fixed so the reinjected traffic (which is the same skbuff) has it's conntrack state cleared?
I remember this issue coming up before wrt NAT where loopback packets were seen as NEW twice, but I don't remember what the fix was.
Regards
Henrik
Quoted 3 lines · Henrik Nordstrom
will get fragmented (by conntrack) and then reinjected.. has it been fixed so the reinjected traffic (which is the same skbuff) has it's conntrack state cleared?
no, the nfct remains the same, so we just ignore it from conntrack point of view (NF_ACCEPT very early, see patrick's patch).
Quoted 2 lines
I remember this issue coming up before wrt NAT where loopback packets were seen as NEW twice, but I don't remember what the fix was.
No, this shouldn't happen (now anymore?), since the nfct of LOCAL_OUT/POST_ROUTING is still present in PRE_ROUTING/LOCAL_IN.
I am not sure whether we can make this 'optimiziation'. Thinking of TCP window tracking and someone having packet filter rules for the loopback device... But at the moment I cannot think why conntrack'ing the packet twice would make any difference at all.
NAT on loopback connections. *sigh*. I think this is beyond my imagination at this point.
Most firewalls I've deployed have NOTRACK rules for loopback traffic, so I tend not to see those issues.
Quoted 2 lines
Regards
Henrik
Signature · 5 lines
- Harald Welte <[email protected]> http://www.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