af-packet: Always fill in vlan_id

The vlan tag will be filled in either from the extended header (for
kernel version >= 3.0) or from the packet itself.

Related to https://redmine.openinfosecfoundation.org/issues/3076
pull/4016/head
Max Fillinger 6 years ago
parent 09c54471e5
commit bcc03f172a

@ -948,7 +948,7 @@ static int AFPReadFromRing(AFPThreadVars *ptv)
}
/* get vlan id from header */
if ((!(ptv->flags & AFP_VLAN_DISABLED)) &&
if ((ptv->flags & AFP_VLAN_IN_HEADER) &&
(h.h2->tp_status & TP_STATUS_VLAN_VALID || h.h2->tp_vlan_tci)) {
p->vlan_id[0] = h.h2->tp_vlan_tci & 0x0fff;
p->vlan_idx = 1;
@ -1071,7 +1071,7 @@ static inline int AFPParsePacketV3(AFPThreadVars *ptv, struct tpacket_block_desc
p->livedev = ptv->livedev;
p->datalink = ptv->datalink;
if ((!(ptv->flags & AFP_VLAN_DISABLED)) &&
if ((ptv->flags & AFP_VLAN_IN_HEADER) &&
(ppd->tp_status & TP_STATUS_VLAN_VALID || ppd->hv1.tp_vlan_tci)) {
p->vlan_id[0] = ppd->hv1.tp_vlan_tci & 0x0fff;
p->vlan_idx = 1;
@ -2807,19 +2807,11 @@ TmEcode ReceiveAFPThreadInit(ThreadVars *tv, const void *initdata, void **data)
afpconfig->DerefFunc(afpconfig);
/* A bit strange to have this here but we only have vlan information
* during reading so we need to know if we want to keep vlan during
* the capture phase */
int vlanbool = 0;
if ((ConfGetBool("vlan.use-for-tracking", &vlanbool)) == 1 && vlanbool == 0) {
ptv->flags |= AFP_VLAN_DISABLED;
}
/* If kernel is older than 3.0, VLAN is not stripped so we don't
* get the info from packet extended header but we will use a standard
* parsing of packet data (See Linux commit bcc6d47903612c3861201cc3a866fb604f26b8b2) */
if (! SCKernelVersionIsAtLeast(3, 0)) {
ptv->flags |= AFP_VLAN_DISABLED;
if (SCKernelVersionIsAtLeast(3, 0)) {
ptv->flags |= AFP_VLAN_IN_HEADER;
}
SCReturnInt(TM_ECODE_OK);

@ -60,7 +60,7 @@ struct ebpf_timeout_config {
#define AFP_SOCK_PROTECT (1<<2)
#define AFP_EMERGENCY_MODE (1<<3)
#define AFP_TPACKET_V3 (1<<4)
#define AFP_VLAN_DISABLED (1<<5)
#define AFP_VLAN_IN_HEADER (1<<5)
#define AFP_MMAP_LOCKED (1<<6)
#define AFP_BYPASS (1<<7)
#define AFP_XDPBYPASS (1<<8)

Loading…
Cancel
Save