Skip to contentSkip to conversation

raw.patch needs defrag at LOCAL_OUT

DISCUSSION Harald Welte 2 participants 3 messages Nov 1, 2003

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

Hi Jozsef!

I'm not sure if this bug was already discovered in the recent discussion, but the raw.patch moves ip_ct_gather_frags() to a seperate netfilter hook entry.

However, that hook entry is only called from PRE_ROUTING and not from LOCAL_OUT, resulting in ip_conntrack_in() seeing fragmented packets e.g. in case of NFS.

I'll prepare a fix (need it working for my own NFS server).

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
#1 lore raw
Quoted 1 line · Harald Welte

I'll prepare a fix (need it working for my own NFS server).

please see the attached fix (I didn't bother to merge it with patch-o-matic, since IIRC you also have pending changes left)

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
net/ipv4/netfilter/ip_conntrack_standalone.c +12 -2
@@ -257,6 +257,9 @@
 static struct nf_hook_ops ip_conntrack_in_ops
 = { { NULL, NULL }, ip_conntrack_in, PF_INET, NF_IP_PRE_ROUTING,
 	NF_IP_PRI_CONNTRACK };
+static struct nf_hook_ops ip_conntrack_defrag_local_out_ops
+= { { NULL, NULL }, ip_conntrack_defrag, PF_INET, NF_IP_LOCAL_OUT,
+	NF_IP_PRI_CONNTRACK_DEFRAG };
 static struct nf_hook_ops ip_conntrack_local_out_ops
 = { { NULL, NULL }, ip_conntrack_local, PF_INET, NF_IP_LOCAL_OUT,
 	NF_IP_PRI_CONNTRACK };
@@ -375,13 +378,18 @@
 
 	ret = nf_register_hook(&ip_conntrack_defrag_ops);
 	if (ret < 0) {
-		printk("ip_conntrack: can't register pre-routing hook to defrag.\n");
+		printk("ip_conntrack: can't register pre_routing defrag hook.\n");
 		goto cleanup_proc;
 	}
+	ret = nf_register_hook(&ip_conntrack_defrag_local_out_ops);
+	if (ret < 0) {
+		printk("ip_conntrack: can't register local_out defrag hook.\n");
+		goto cleanup_defragops;
+	}
 	ret = nf_register_hook(&ip_conntrack_in_ops);
 	if (ret < 0) {
 		printk("ip_conntrack: can't register pre-routing hook.\n");
-		goto cleanup_defragops;
+		goto cleanup_defraglocalops;
 	}
 	ret = nf_register_hook(&ip_conntrack_local_out_ops);
 	if (ret < 0) {
@@ -419,6 +427,8 @@
 	nf_unregister_hook(&ip_conntrack_local_out_ops);
  cleanup_inops:
 	nf_unregister_hook(&ip_conntrack_in_ops);
+ cleanup_defraglocalops:
+	nf_unregister_hook(&ip_conntrack_defrag_local_out_ops);
  cleanup_defragops:
 	nf_unregister_hook(&ip_conntrack_defrag_ops);
  cleanup_proc:
net/ipv4/netfilter/ip_conntrack_core.c +9 -0
@@ -812,9 +890,18 @@
 	int set_reply;
 	int ret;
 
+	/* Never happen */
+	if ((*pskb)->nh.iph->frag_off & htons(IP_OFFSET)) {
+		if (net_ratelimit()) {
+		printk(KERN_ERR "ip_conntrack_in: Frag of proto %u (hook=%u)\n",
+		       (*pskb)->nh.iph->protocol, hooknum);
+		}
+		return NF_DROP;
+	}
+
 	/* FIXME: Do this right please. --RR */
 	(*pskb)->nfcache |= NFC_UNKNOWN;
 
 /* Doesn't cover locally-generated broadcast, so not worth it. */
 #if 0
 	/* Ignore broadcast: no `connection'. */
#2 lore raw
In reply to Harald Welte
Quoted 7 lines · Harald Welte

I'm not sure if this bug was already discovered in the recent discussion, but the raw.patch moves ip_ct_gather_frags() to a seperate netfilter hook entry.

However, that hook entry is only called from PRE_ROUTING and not from LOCAL_OUT, resulting in ip_conntrack_in() seeing fragmented packets e.g. in case of NFS.

Ouch! It seems I'm completely dense nowadays. :-(((

Quoted 1 line

I'll prepare a fix (need it working for my own NFS server).

Thank you,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics

          H-1525 Budapest 114, POB. 49, Hungary