]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Pull request #3825: tcp_reassembler: Fix missing VLAN ids in TCP pseudopkts
authorSteven Baigal (sbaigal) <sbaigal@cisco.com>
Fri, 28 Apr 2023 17:38:41 +0000 (17:38 +0000)
committerSteven Baigal (sbaigal) <sbaigal@cisco.com>
Fri, 28 Apr 2023 17:38:41 +0000 (17:38 +0000)
Merge in SNORT/snort3 from ~CHSHERWI/snort3:vlan_fix2 to master

Squashed commit of the following:

commit d89e24f57bca7d1f9af03858b5c7069d84039fce
Author: Chris Sherwin <chsherwi@cisco.com>
Date:   Thu Apr 27 15:15:15 2023 -0400

    stream tcp: Populate TCP pseudopackets with VLAN ids in TCP reassembler to avoid
        issues with secondary flow creation / expected flow cache

src/network_inspectors/rna/rna_app_discovery.cc
src/stream/tcp/tcp_reassembler.cc

index 7843cfc4a61a78724087987e91c0231f5b36b7dc..920837e49ecead78a984441d788145238e369d8b 100644 (file)
@@ -357,7 +357,7 @@ void RnaAppDiscovery::discover_client(const Packet* p, DiscoveryFilter& filter,
     rt->update_last_seen();
 
     const uint8_t* mac;
-    if ( layer::get_eth_layer(p) )
+    if ( !(p->packet_flags & PKT_REBUILT_STREAM ) && layer::get_eth_layer(p) )
     {
         if ( p->is_from_server() )
             mac = layer::get_eth_layer(p)->ether_dst;
index 27fbc04ce02983db011c5433cb837f227339d675..9f516fcb0491494f5e5bad30ed4612c813286555 100644 (file)
@@ -551,6 +551,15 @@ Packet* TcpReassembler::initialize_pdu(
     pdu->data = nullptr;
     pdu->ip_proto_next = (IpProtocol)p->flow->ip_proto;
 
+
+    if ( p->proto_bits & PROTO_BIT__VLAN ) 
+    {
+        memcpy( pdu->layers, p->layers, p->num_layers * sizeof(Layer));
+        pdu->num_layers = p->num_layers;
+        pdu->proto_bits |= PROTO_BIT__VLAN;
+        pdu->vlan_idx = p->vlan_idx;
+    }
+
     return pdu;
 }