Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 May 2003 09:10:09 +0200
From:      Vincent Jardin <vjardin@wanadoo.fr>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   kern/51831: ATM/HARP BPF support
Message-ID:  <200305060910.09348.vjardin@wanadoo.fr>
Resent-Message-ID: <200305060710.h467ANlf080671@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         51831
>Category:       kern
>Synopsis:       ATM/HARP BPF support
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          wish
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 06 00:10:23 PDT 2003
>Closed-Date:
>Last-Modified:
>Originator:     Vincent Jardin
>Release:        Patch for FreeBSD 4.x, 5.x and later
>Organization:
Vincent Jardin <vjardin@free.fr>
>Environment:
n/a
>Description:
Currently, the NBMA interfaces of the HARP/ATM stack do not support tcpdu=
mp=20
whereas
FreeBSD's tcpdump already support Classical IP (see DLT_ATM_CLIP).

>How-To-Repeat:
        tcpdump -ni atm0
>Fix:

        Currently, I am using the following patch on FreeBSD 4.7:
netatm/atm_cm.c:
--- atm_cm.c.orig  Sat Aug 28 02:48:34 1999
+++ atm_cm.c       Sun Apr 20 03:37:34 2003
@@ -37,6 +37,8 @@
=20
 #include <netatm/kern_include.h>
=20
+#include <net/bpf.h>
+
 #ifndef lint
 __RCSID("@(#) $FreeBSD: src/sys/netatm/atm_cm.c,v 1.6 1999/08/28 00:48:3=
4=20
peter Exp $");
 #endif
@@ -2877,6 +2879,17 @@
                 * Locate packet's connection
                 */
                cop =3D cvp->cvc_conn;
+
+               /*
+                * Send the packet to the interface's bpf if this vc has =
one.
+                */                    =20
+               if (cvp->cvc_vcc && cvp->cvc_vcc->vc_nif) {
+                       struct ifnet *ifp =3D (struct ifnet=20
*)cvp->cvc_vcc->vc_nif;
+
+                       if (ifp->if_bpf)
+                               bpf_mtap(ifp, m);
+               }
+
                switch (cop->co_mpx) {
=20
                case ATM_ENC_NULL:


netatm/atm_device.c:
--- atm_device.c.orig      Mon Apr 21 02:45:20 2003
+++ atm_device.c           Tue May  6 08:58:17 2003
@@ -37,6 +37,8 @@
=20
 #include <netatm/kern_include.h>
=20
+#include <net/bpf.h>
+
 #ifndef lint
 __RCSID("@(#) $FreeBSD: src/sys/netatm/atm_device.c,v 1.5 1999/08/28 00:=
48:35=20
peter Exp $");
 #endif
@@ -351,6 +353,16 @@
                                tok, state );
                        KB_FREEALL((KBuffer *)arg1);
                        break;
+               }
+
+               /*
+                * Send the packet to the interface's bpf if this vc has =
one.
+                */
+               if (cvcp->cvc_vcc && cvcp->cvc_vcc->vc_nif) {
+                       struct ifnet *ifp =3D (struct ifnet=20
*)cvcp->cvc_vcc->vc_nif;
+
+                       if (ifp->if_bpf)
+                               bpf_mtap(ifp, (KBuffer *)arg1);
                }
=20
                /*


netatm/atm_if.c:
--- atm_if.c.orig  Thu Apr 17 01:28:43 2003
+++ atm_if.c       Tue May  6 09:01:42 2003
@@ -37,6 +37,8 @@
=20
 #include <netatm/kern_include.h>
=20
+#include <net/bpf.h>
+
 #ifndef lint
 __RCSID("@(#) $FreeBSD: src/sys/netatm/atm_if.c,v 1.5 1999/08/28 00:48:3=
5=20
peter Exp $");
 #endif
@@ -51,8 +53,10 @@
  */
 static int     atm_physif_ioctl __P((int, caddr_t, caddr_t));
 #if (defined(BSD) && (BSD >=3D 199306))
+#if defined(__FreeBSD__) && (__FreeBSD_version < 440000)
 static int     atm_netif_rtdel __P((struct radix_node *, void *));
 #endif
+#endif
 static int     atm_if_ioctl __P((struct ifnet *, u_long, caddr_t));
 static int     atm_ifparse __P((char *, char *, int, int *));
=20
@@ -762,6 +766,13 @@
        if_attach(ifp);
=20
        /*
+        * Add to BPF interface list
+        * DLT_ATM_RFC1483 cannot be used because both NULL and LLC/SNAP =
could
+        * be provisionned.
+        */
+       bpfattach(ifp, DLT_ATM_CLIP, T_ATM_LLC_MAX_LEN);
+
+       /*
         * Add to physical interface list
         */
        LINK2TAIL(nip, struct atm_nif, pip->pif_nif, nif_pnext);
@@ -807,11 +818,14 @@
        struct atm_nif  *nip;
 {
        struct atm_ncm  *ncp;
-       int             s, i;
+       int             s;
        struct ifnet    *ifp =3D &nip->nif_if;
+#if defined(__FreeBSD__) && (__FreeBSD_version < 440000)
+       int i;
        struct ifaddr   *ifa;
        struct in_ifaddr        *ia;
        struct radix_node_head  *rnh;
+#endif

        s =3D splimp();
@@ -823,6 +837,7 @@
                (void) (*ncp->ncm_stat)(NCM_DETACH, nip, 0);
        }
=20
+#if !defined(__FreeBSD__) || (__FreeBSD_version < 440000)
        /*
         * Mark interface down
         */
@@ -864,6 +879,20 @@
         * Remove from system interface list (ie. if_detach())
         */
        TAILQ_REMOVE(&ifnet, ifp, if_link);
+#else
+       /*
+        * Remove from BPF interface list
+        */
+       bpfdetach(ifp);
+
+       /*
+        * Free all interface routes and addresses,
+        * Delete all remaining routes using this interface,
+        * then remove from system interface list
+        */
+       if_detach(ifp);
+
+#endif /* (__FreeBSD_version < 440000) */
=20
        /*
         * Remove from physical interface list
@@ -874,6 +903,7 @@
 }
=20
=20
+#if defined(__FreeBSD__) && (__FreeBSD_version < 440000)
 /*
  * Delete Routes for a Network Interface
  *=20
@@ -917,6 +947,7 @@
=20
        return (0);
 }
+#endif /* __FreeBSD_version < 440000 */
=20
=20
 /*

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200305060910.09348.vjardin>