IPF 4.1.24 doesn't log properly IPv6 packets containing extension headers.
I think the attached patch could fix it a little, but I can't test it for
some reasons and I'm not sure.

-Mirek
<------------------------------------------------------------------------->
diff -ru ip_fil4.1.24-orig/ip_log.c ip_fil4.1.24/ip_log.c
--- ip_fil4.1.24-orig/ip_log.c  Wed Jun  6 10:05:43 2007
+++ ip_fil4.1.24/ip_log.c       Sat Aug  4 17:52:31 2007
@@ -268,7 +268,10 @@

        ipfl.fl_nattag.ipt_num[0] = 0;
        ifp = fin->fin_ifp;
-       hlen = fin->fin_hlen;
+       if (fin->fin_exthdr != NULL)
+               hlen = (char *)fin->fin_dp - (char *)fin->fin_ip;
+       else
+               hlen = fin->fin_hlen;
        /*
         * calculate header size.
         */
diff -ru ip_fil4.1.24-orig/tools/ipmon.c ip_fil4.1.24/tools/ipmon.c
--- ip_fil4.1.24-orig/tools/ipmon.c     Sun May 27 13:12:12 2007
+++ ip_fil4.1.24/tools/ipmon.c  Sat Aug  4 17:52:46 2007
@@ -1001,6 +1001,9 @@
        iplog_t *ipl;
 #ifdef USE_INET6
        ip6_t *ip6;
+       int     go;
+       u_short ehl;
+       struct  ip6_ext *ehp;
 #endif

        ipl = (iplog_t *)buf;
@@ -1109,6 +1112,26 @@
                s = (u_32_t *)&ip6->ip6_src;
                d = (u_32_t *)&ip6->ip6_dst;
                plen = hl + ntohs(ip6->ip6_plen);
+               go = 1;
+               ehp = (struct ip6_ext *)((char *)ip6 + hl);
+               do {
+                   switch (p) {
+                       case IPPROTO_HOPOPTS:
+                       case IPPROTO_MOBILITY:
+                       case IPPROTO_DSTOPTS:
+                       case IPPROTO_ROUTING:
+                       case IPPROTO_AH:
+                           p = ehp->ip6e_nxt;
+                           ehl = 8 + (ehp->ip6e_len << 3);
+                           hl += ehl;
+                           ehp = (struct ip6_ext *)((char *)ehp + ehl);
+                           break;
+                       case IPPROTO_FRAGMENT:
+                           hl += sizeof(ip6_frag_t);
+                       default:
+                           go = 0;
+                   }
+               } while (go);
 #else
                sprintf(t, "ipv6");
                goto printipflog;
<------------------------------------------------------------------------->

Reply via email to