kern/101162: [patch] ng_netflow 802.11Q VLAN Tag support
CoolDavid (Tseng Guo-Fu)
cooldavid at cdpa.nsysu.edu.tw
Tue Aug 1 11:10:11 UTC 2006
>Number: 101162
>Category: kern
>Synopsis: [patch] ng_netflow 802.11Q VLAN Tag support
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Tue Aug 01 11:10:10 GMT 2006
>Closed-Date:
>Last-Modified:
>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 at 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 at 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:
>Unformatted:
More information about the freebsd-bugs
mailing list