From nobody@FreeBSD.org  Tue Aug  1 11:06:18 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 9EAA616A4DA
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  1 Aug 2006 11:06:18 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 4F67243D4C
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  1 Aug 2006 11:06:18 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k71B6InI060565
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 1 Aug 2006 11:06:18 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id k71B6IKi060564;
	Tue, 1 Aug 2006 11:06:18 GMT
	(envelope-from nobody)
Message-Id: <200608011106.k71B6IKi060564@www.freebsd.org>
Date: Tue, 1 Aug 2006 11:06:18 GMT
From: CoolDavid(Tseng Guo-Fu) <cooldavid@cdpa.nsysu.edu.tw>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] ng_netflow 802.11Q VLAN Tag support
X-Send-Pr-Version: www-2.3

>Number:         101162
>Category:       kern
>Synopsis:       [netgraph] [patch] ng_netflow 802.11Q VLAN Tag support
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    glebius
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Aug 01 11:10:10 GMT 2006
>Closed-Date:    Thu Jan 25 21:36:30 GMT 2007
>Last-Modified:  Thu Jan 25 21:40:18 GMT 2007
>Originator:     CoolDavid(Tseng Guo-Fu)
>Release:        FreeBSD 5.5-STABLE i386
>Organization:
Campus Dorm-Net Promotion Association of National Sun Yat-sen University ,Kaohsiung, 80424 , Taiwan
>Environment:
FreeBSD netflow.cdpa.nsysu.edu.tw 5.5-STABLE FreeBSD 5.5-STABLE #0: Tue Aug 1 12:09:34 UTC 2006 root@netflow.cdpa.nsysu.edu.tw:/usr/src/sys/i386/compile/NETFLOW i386
>Description:
Some network device sends Port-Mirror data with 802.11Q VLAN tag.
The original version of ng_netflow didn't check the VLAN proto in ethernet header.

>How-To-Repeat:
Any packet received from NIC encapsulated with VALN tag will be ignored.

>Fix:
root@netflow[/usr/src/sys/netgraph/netflow]# diff -Naur /root/netflow.org /usr/src/sys/netgraph/netflow
diff -Naur /root/netflow.org/ng_netflow.c /usr/src/sys/netgraph/netflow/ng_netflow.c
--- /root/netflow.org/ng_netflow.c      Tue Aug  1 17:04:39 2006
+++ /usr/src/sys/netgraph/netflow/ng_netflow.c  Tue Aug  1 17:57:41 2006
@@ -42,6 +42,7 @@
 #include <net/ethernet.h>
 #include <net/if_arp.h>
 #include <net/if_var.h>
+#include <net/if_vlan_var.h>
 #include <net/bpf.h>
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
@@ -494,6 +495,7 @@
        case DLT_EN10MB:        /* Ethernet */
            {
                struct ether_header *eh;
+               struct ether_vlan_header *evh;
                uint16_t etype;

                M_CHECK(sizeof(struct ether_header));
@@ -507,6 +509,14 @@
                        eh = mtod(m, struct ether_header *);
                        ip = (struct ip *)(eh + 1);
                        break;
+               case ETHERTYPE_VLAN:
+                       M_CHECK(sizeof(struct ether_vlan_header) - sizeof(struct ether_header));
+                       evh = mtod(m, struct ether_vlan_header *);
+                       if(ntohs(evh->evl_proto) == ETHERTYPE_IP) {
+                               M_CHECK(sizeof(struct ip));
+                               ip = (struct ip *)(evh + 1);
+                               break;
+                       }
                default:
                        goto bypass;    /* pass this frame */
                }
@@ -540,9 +550,17 @@
        case DLT_EN10MB:
            {
                struct ether_header *eh;
+               struct ether_vlan_header *evh;

-               eh = mtod(m, struct ether_header *);
-               ip = (struct ip *)(eh + 1);
+               //log(LOG_CRIT, "ng_netflow: vlan->ip.\n");
+               eh  = mtod(m, struct ether_header *);
+               if(ntohs(eh->ether_type) == ETHERTYPE_IP) {
+                       ip = (struct ip *)(eh + 1);
+               }
+               else { //Must be vlan
+                       evh = mtod(m, struct ether_vlan_header *);
+                       ip = (struct ip *)(evh + 1);
+               }
                break;
             }
        case DLT_RAW:

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->glebius 
Responsible-Changed-By: glebius 
Responsible-Changed-When: Fri Aug 11 13:41:53 UTC 2006 
Responsible-Changed-Why:  
I will look into this one. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=101162 

From: Gleb Smirnoff <glebius@cell.sick.ru>
To: CoolDavid <cooldavid@cdpa.nsysu.edu.tw>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: kern/101162 [netgraph] [patch] ng_netflow 802.11Q VLAN Tag support
Date: Wed, 11 Oct 2006 15:36:23 +0400

 --wRokNccIwvMzawGl
 Content-Type: text/plain; charset=koi8-r
 Content-Disposition: inline
 
   Hello, Tseng!
 
   I've edited your patch to make it more clean and style(9) compliant.
 Can you please try out the attached patch and confirm that it works
 as you need it?
 
   By the way, I'd recommend you to upgrade your NetFlow generator box
 to RELENG_6. The NetFlow engine in RELENG_6 is much more robust than
 in RELENG_5.
 
 -- 
 Totus tuus, Glebius.
 GLEBIUS-RIPN GLEB-RIPE
 
 --wRokNccIwvMzawGl
 Content-Type: text/plain; charset=koi8-r
 Content-Disposition: attachment; filename="ng_netflow.vlan.diff"
 
 Index: ng_netflow.c
 ===================================================================
 RCS file: /home/ncvs/src/sys/netgraph/netflow/ng_netflow.c,v
 retrieving revision 1.12
 diff -u -p -r1.12 ng_netflow.c
 --- ng_netflow.c	14 Jan 2006 12:26:32 -0000	1.12
 +++ ng_netflow.c	11 Oct 2006 11:28:44 -0000
 @@ -42,6 +42,7 @@ static const char rcs_id[] =
  #include <net/ethernet.h>
  #include <net/if_arp.h>
  #include <net/if_var.h>
 +#include <net/if_vlan_var.h>
  #include <net/bpf.h>
  #include <netinet/in.h>
  #include <netinet/in_systm.h>
 @@ -514,6 +515,19 @@ ng_netflow_rcvdata (hook_p hook, item_p 
  			eh = mtod(m, struct ether_header *);
  			ip = (struct ip *)(eh + 1);
  			break;
 +		case ETHERTYPE_VLAN:
 +		    {
 +			struct ether_vlan_header *evh;
 +
 +			M_CHECK(sizeof(struct ether_vlan_header) -
 +			    sizeof(struct ether_header));
 +			evh = mtod(m, struct ether_vlan_header *);
 +			if (ntohs(evh->evl_proto) == ETHERTYPE_IP) {
 +				M_CHECK(sizeof(struct ip));
 +				ip = (struct ip *)(evh + 1);
 +				break;
 +			}
 +		    }
  		default:
  			goto bypass;	/* pass this frame */
  		}
 @@ -551,7 +565,21 @@ ng_netflow_rcvdata (hook_p hook, item_p 
  		struct ether_header *eh;
  
  		eh = mtod(m, struct ether_header *);
 -		ip = (struct ip *)(eh + 1);
 +		switch (ntohs(eh->ether_type)) {
 +		case ETHERTYPE_IP:
 +			ip = (struct ip *)(eh + 1);
 +			break;
 +		case ETHERTYPE_VLAN:
 +		    {
 +			struct ether_vlan_header *evh;
 +
 +			evh = mtod(m, struct ether_vlan_header *);
 +			ip = (struct ip *)(evh + 1);
 +			break;
 +		     }
 +		default:
 +			panic("ng_netflow entered deadcode");
 +		}
  		break;
  	     }
  	case DLT_RAW:
 
 --wRokNccIwvMzawGl--
State-Changed-From-To: open->feedback 
State-Changed-By: glebius 
State-Changed-When: Wed Oct 11 12:36:58 UTC 2006 
State-Changed-Why:  
Put the PR into feedback state. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=101162 

From: Gleb Smirnoff <glebius@cell.sick.ru>
To: cooldavid@cooldavid.org
Cc: bug-followup@FreeBSD.org
Subject: Re: kern/101162 [netgraph] [patch] ng_netflow 802.11Q VLAN Tag support
Date: Wed, 11 Oct 2006 19:05:26 +0400

   Hello, Tseng!
 
 On Wed, Oct 11, 2006 at 10:57:04PM +0800, cooldavid wrote:
 c>   I've patched my ng_netflow module according to your diff file.
 c> And it works fine! Please reference my diff file in attachment.
 
 Yes, your submission will be noted in commit message.
 
 c> PS: You may notice that changed two extra constant value.
 c>     In order to fit the network scale.
 c>     Otherwish the flow data will lost alot.
 
 I'm sorry, can't understand the P.S. paragraph. Can you describe
 the problem in other words, or show the diff? I can't understand
 whether my patch works or not.
 
 -- 
 Totus tuus, Glebius.
 GLEBIUS-RIPN GLEB-RIPE
State-Changed-From-To: feedback->patched 
State-Changed-By: glebius 
State-Changed-When: Wed Oct 11 15:25:38 UTC 2006 
State-Changed-Why:  
Committed to HEAD, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=101162 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/101162: commit references a PR
Date: Wed, 11 Oct 2006 15:27:33 +0000 (UTC)

 glebius     2006-10-11 15:27:13 UTC
 
   FreeBSD src repository
 
   Modified files:
     sys/netgraph/netflow ng_netflow.c 
   Log:
   Recognize 802.1q frames in Ethernet input and process them.
   
   PR:             kern/101162
   Submitted by:   CoolDavid (Tseng Guo-Fu) <cooldavid cdpa.nsysu.edu.tw>
   
   Revision  Changes    Path
   1.13      +29 -1     src/sys/netgraph/netflow/ng_netflow.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: glebius 
State-Changed-When: Thu Jan 25 21:35:56 UTC 2007 
State-Changed-Why:  
Merged to RELENG_6. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=101162 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/101162: commit references a PR
Date: Thu, 25 Jan 2007 21:35:53 +0000 (UTC)

 glebius     2007-01-25 21:35:43 UTC
 
   FreeBSD src repository
 
   Modified files:        (Branch: RELENG_6)
     sys/netgraph/netflow ng_netflow.c 
   Log:
   MFC 1.13:
     Recognize 802.1q frames in Ethernet input and process them.
   
     PR:           kern/101162
     Submitted by: CoolDavid (Tseng Guo-Fu) <cooldavid cdpa.nsysu.edu.tw>
   
   Revision  Changes    Path
   1.9.2.4   +29 -1     src/sys/netgraph/netflow/ng_netflow.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
>Unformatted:
