Given that my patch _was_ correct, I could not explain why Path MTU discovery
would ever work with ipf and state tables. I found the reaosn:
We use the content of the "old" ip packet that is encapsulated in the
icmp error packet. However, when ipf is called, ip_len and ip_off are
already in host byte order. From the old packet, the offset is
used in fr_makefrip(), and because the DF bit is set, but interpreted
wrong, teh "off" variable is iven a value. Therefor, the packet is
considered a fragment and the short flag is never set.

The following patch fixes this (it includes the old patch).


--- ip_state.c.orig     Sat Jun  7 13:55:55 2003
+++ ip_state.c  Tue Nov 25 21:47:01 2003
@@ -1210,6 +1207,10 @@
 
        oip = (ip_t *)((char *)ic + ICMPERR_ICMPHLEN);
        ohlen = oip->ip_hl << 2;
+       /*
+        * Check if the at least the old IP header (with options) and
+        * 8 bytes of payload is present.
+        */
        if (fin->fin_plen < ICMPERR_MAXPKTLEN + ohlen - sizeof(*oip))
                return NULL;
 
@@ -1344,8 +1345,14 @@
         */
        savelen = oip->ip_len;
        oip->ip_len = len;
+       /* oip->ip_off is still in network byte order. fix it */
+       oip->ip_off = ntohs(oip->ip_off);
        fr_makefrip(ohlen, oip, &ofin);
+       /* put old values of ip_len and ip_of back as we don't know
+        * if we have to forward the packet (or process it again.
+        */
        oip->ip_len = savelen;
+       oip->ip_off = htons(oip->ip_off);
        READ_ENTER(&ipf_state);
        for (isp = &ips_table[hv]; (is = *isp); isp = &is->is_hnext) {
                /*
@@ -1353,8 +1360,11 @@
                 * encapsulated packet was allowed through the
                 * other way around. Note that the minimal amount
                 * of info present does not allow for checking against
-                * tcp internals such as seq and ack numbers.
+                * tcp internals such as seq and ack numbers. Only the ports
+                * are knonw to be present.
+                * That is why we must clear the SHORT flag in this case.
                 */
+               ofin.fin_fl &= ~FI_SHORT;
                if ((is->is_p == pr) && (is->is_v == 4) &&
                    fr_matchsrcdst(is, src, dst, &ofin, tcp)) {
                        fr = is->is_rule;

Reply via email to