From vjardin@wanadoo.fr  Tue May  6 00:10:06 2003
Return-Path: <vjardin@wanadoo.fr>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 3EDA437B401
	for <FreeBSD-gnats-submit@freebsd.org>; Tue,  6 May 2003 00:10:06 -0700 (PDT)
Received: from mwinf0102.wanadoo.fr (smtp8.wanadoo.fr [193.252.22.30])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 09E2943F75
	for <FreeBSD-gnats-submit@freebsd.org>; Tue,  6 May 2003 00:10:05 -0700 (PDT)
	(envelope-from vjardin@wanadoo.fr)
Received: from venus.vincentjardin.net (AVelizy-102-1-5-134.abo.wanadoo.fr [80.13.229.134])
	by mwinf0102.wanadoo.fr (SMTP Server) with ESMTP id 913AF1BFFFBF
	for <FreeBSD-gnats-submit@freebsd.org>; Tue,  6 May 2003 09:10:03 +0200 (CEST)
Message-Id: <200305060910.09348.vjardin@wanadoo.fr>
Date: Tue, 6 May 2003 09:10:09 +0200
From: Vincent Jardin <vjardin@wanadoo.fr>
Reply-To: Vincent Jardin <vjardin@free.fr>
To: FreeBSD-gnats-submit@freebsd.org
Subject: ATM/HARP BPF support

>Number:         51831
>Category:       kern
>Synopsis:       ATM/HARP BPF support
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    harti
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          wish
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 06 00:10:23 PDT 2003
>Closed-Date:    Fri Jul 25 00:58:27 PDT 2003
>Last-Modified:  Fri Jul 25 00:58:27 PDT 2003
>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:

From: Vincent Jardin <vjardin@wanadoo.fr>
To: freebsd-gnats-submit@FreeBSD.org, vjardin@free.fr
Cc:  
Subject: Re: kern/51831: ATM/HARP BPF support
Date: Tue, 6 May 2003 09:25:39 +0200

 For example, now you can get the LLC/SNAP header with tcpdump:
 
 su-2.05b# atm add pvc hva1 3 40 AAL5 SNAP IP atm0 1.1.2.3
 su-2.05b# atm show ipvcc
 Net Intf  VPI   VCI  State   Flags IP Address
 atm0        1    40  ACTIVE  PM    1.1.2.2
 atm0        3    40  ACTIVE  PLM   1.1.2.3
 su-2.05b# atm show vcc
 Interface  VPI   VCI  AAL   Type Dir    State    Encaps   Owner
 hva1         1    40  AAL5  PVC  InOut  ACTIVE   Null     IP
 hva1         3    40  AAL5  PVC  InOut  ACTIVE   LLC/SNAP IP
 su-2.05b# ifconfig atm0
 atm0: flags=3D43<UP,BROADCAST,RUNNING> mtu 9180
         inet 1.1.1.1 netmask 0xffff0000 broadcast 1.1.255.255
         ether 00:19:e1:6a:a3:f2
 
 $ ping 1.1.2.3
 
 su-2.05b# tcpdump -nXi atm0
 tcpdump: listening on atm0
 09:22:20.540119 1.1.1.1 > 1.1.2.3: icmp: echo request
 0x0000   aaaa 0300 0000 0800 4500 0054 05c6 0000        ........E..T....
 0x0010   4001 6fde 0101 0101 0101 0203 0800 cc1b        @.o.............
 0x0020   f702 1500 ac62 b73e c93c 0800 0809 0a0b        .....b.>.<......
 0x0030   0c0d 0e0f 1011 1213 1415 1617 1819 1a1b        ................
 0x0040   1c1d 1e1f 2021 2223 2425 2627 2829 2a2b        .....!"#$%&'()*+
 0x0050   2c2d 2e2f 3031 3233 3435 3637                  ,-./01234567
 
 su-2.05b# tcpdump -nvi atm0
 tcpdump: listening on atm0
 09:22:25.590190 snap 0:0:0:8:0 1.1.1.1 > 1.1.2.3: icmp: echo request (ttl=
  64,=20
 id 1493, len 84)
 
 
Responsible-Changed-From-To: freebsd-bugs->harti 
Responsible-Changed-By: phk 
Responsible-Changed-When: Tue May 6 10:37:01 PDT 2003 
Responsible-Changed-Why:  
Hi Harti, this sounds like your area... 

http://www.freebsd.org/cgi/query-pr.cgi?pr=51831 
State-Changed-From-To: open->closed 
State-Changed-By: harti 
State-Changed-When: Fri Jul 25 00:58:08 PDT 2003 
State-Changed-Why:  
Committed to -current. MFC in 2 weeks. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=51831 
>Unformatted:
