]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
vlan/QinQ: add vlan_qinq counter 840/head
authorVictor Julien <victor@inliniac.net>
Tue, 11 Feb 2014 08:44:26 +0000 (09:44 +0100)
committerVictor Julien <victor@inliniac.net>
Tue, 11 Feb 2014 08:44:26 +0000 (09:44 +0100)
This patch introduces a new counter "decoder.vlan_qinq". It counts
packets that have more than two stacked vlan layers.

Packets with 2 vlan layers will both increment "decoder.vlan" and
"decoder.vlan_qinq".

src/decode-vlan.c
src/decode.c
src/decode.h

index 29dc908922c6517e4a75c6bcdcc1aa0c62053883..b3decaef2d699902dab26c52a8f121e380dd60cc 100644 (file)
@@ -60,7 +60,10 @@ int DecodeVLAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, u
 {
     uint32_t proto;
 
-    SCPerfCounterIncr(dtv->counter_vlan, tv->sc_perf_pca);
+    if (p->vlan_idx == 0)
+        SCPerfCounterIncr(dtv->counter_vlan, tv->sc_perf_pca);
+    else if (p->vlan_idx == 1)
+        SCPerfCounterIncr(dtv->counter_vlan_qinq, tv->sc_perf_pca);
 
     if(len < VLAN_HEADER_LEN)    {
         ENGINE_SET_INVALID_EVENT(p, VLAN_HEADER_TOO_SMALL);
index 74a36763c2964c654bc45e04224098b09fc245da..c7c0b4ccd944383cc200a5a41009943f0152b5c9 100644 (file)
@@ -393,6 +393,8 @@ void DecodeRegisterPerfCounters(DecodeThreadVars *dtv, ThreadVars *tv)
                                                SC_PERF_TYPE_UINT64, "NULL");
     dtv->counter_vlan = SCPerfTVRegisterCounter("decoder.vlan", tv,
                                                SC_PERF_TYPE_UINT64, "NULL");
+    dtv->counter_vlan_qinq = SCPerfTVRegisterCounter("decoder.vlan_qinq", tv,
+                                               SC_PERF_TYPE_UINT64, "NULL");
     dtv->counter_teredo = SCPerfTVRegisterCounter("decoder.teredo", tv,
                                                SC_PERF_TYPE_UINT64, "NULL");
     dtv->counter_ipv4inipv6 = SCPerfTVRegisterCounter("decoder.ipv4_in_ipv6", tv,
index f17606086c0bc0ce1a2ac92228b1020d3a9de33f..ea813fecf909c6889ff1c926f9fb0df200a0ba67 100644 (file)
@@ -580,6 +580,7 @@ typedef struct DecodeThreadVars_
     uint16_t counter_ppp;
     uint16_t counter_gre;
     uint16_t counter_vlan;
+    uint16_t counter_vlan_qinq;
     uint16_t counter_pppoe;
     uint16_t counter_teredo;
     uint16_t counter_ipv4inipv6;