]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
log-pcap: remove tunnel locks 7445/head
authorVictor Julien <vjulien@oisf.net>
Mon, 30 May 2022 19:08:19 +0000 (21:08 +0200)
committerVictor Julien <vjulien@oisf.net>
Tue, 31 May 2022 07:42:15 +0000 (09:42 +0200)
The tunnel lock mutex only "protects" the tunnel synchronization,
not the packet data, length or datalink fields.

src/log-pcap.c
src/stream-tcp-list.c

index 6510dc69adbd29c58d52d7c28fef9f5d2675e04d..982c3acaa2baa95d8b1df4add11f2197fb8d62d7 100644 (file)
@@ -424,9 +424,7 @@ static int PcapLogOpenHandles(PcapLogData *pl, const Packet *p)
     int datalink = p->datalink;
     if (IS_TUNNEL_PKT(p) && !IS_TUNNEL_ROOT_PKT(p)) {
         Packet *real_p = p->root;
-        SCMutexLock(&real_p->tunnel_mutex);
         datalink = real_p->datalink;
-        SCMutexUnlock(&real_p->tunnel_mutex);
     }
     if (pl->pcap_dead_handle == NULL) {
         SCLogDebug("Setting pcap-log link type to %u", datalink);
@@ -616,11 +614,9 @@ static int PcapLog (ThreadVars *t, void *thread_data, const Packet *p)
     pl->h->ts.tv_usec = p->ts.tv_usec;
     if (IS_TUNNEL_PKT(p) && !IS_TUNNEL_ROOT_PKT(p)) {
         rp = p->root;
-        SCMutexLock(&rp->tunnel_mutex);
         pl->h->caplen = GET_PKT_LEN(rp);
         pl->h->len = GET_PKT_LEN(rp);
         len = sizeof(*pl->h) + GET_PKT_LEN(rp);
-        SCMutexUnlock(&rp->tunnel_mutex);
     } else {
         pl->h->caplen = GET_PKT_LEN(p);
         pl->h->len = GET_PKT_LEN(p);
@@ -705,11 +701,9 @@ static int PcapLog (ThreadVars *t, void *thread_data, const Packet *p)
             pl->h->ts.tv_usec = p->ts.tv_usec;
             if (IS_TUNNEL_PKT(p) && !IS_TUNNEL_ROOT_PKT(p)) {
                 rp = p->root;
-                SCMutexLock(&rp->tunnel_mutex);
                 pl->h->caplen = GET_PKT_LEN(rp);
                 pl->h->len = GET_PKT_LEN(rp);
                 len = sizeof(*pl->h) + GET_PKT_LEN(rp);
-                SCMutexUnlock(&rp->tunnel_mutex);
             } else {
                 pl->h->caplen = GET_PKT_LEN(p);
                 pl->h->len = GET_PKT_LEN(p);
@@ -720,13 +714,11 @@ static int PcapLog (ThreadVars *t, void *thread_data, const Packet *p)
 
     if (IS_TUNNEL_PKT(p) && !IS_TUNNEL_ROOT_PKT(p)) {
         rp = p->root;
-        SCMutexLock(&rp->tunnel_mutex);
 #ifdef HAVE_LIBLZ4
         ret = PcapWrite(pl, comp, GET_PKT_DATA(rp), len);
 #else
         ret = PcapWrite(pl, NULL, GET_PKT_DATA(rp), len);
 #endif
-        SCMutexUnlock(&rp->tunnel_mutex);
     } else {
 #ifdef HAVE_LIBLZ4
         ret = PcapWrite(pl, comp, GET_PKT_DATA(p), len);
index 19558587d1e31facbee147678443fee8e76f76f5..708a9cb49063b334ef45421268d117b3305d218c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2016 Open Information Security Foundation
+/* Copyright (C) 2007-2022 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free
@@ -621,9 +621,7 @@ static void StreamTcpSegmentAddPacketData(
 
     if (IS_TUNNEL_PKT(p) && !IS_TUNNEL_ROOT_PKT(p)) {
         Packet *rp = p->root;
-        SCMutexLock(&rp->tunnel_mutex);
         StreamTcpSegmentAddPacketDataDo(seg, rp, p);
-        SCMutexUnlock(&rp->tunnel_mutex);
     } else {
         StreamTcpSegmentAddPacketDataDo(seg, p, p);
     }