Skip to content

Commit

Permalink
decode/tunnel: move tunnel verdicted logic
Browse files Browse the repository at this point in the history
In preparation of cleaning up thread safety, move "verdicted"
logic out of Packet::flags. Unsafe writes to "flags" can potentially
have side effects.
  • Loading branch information
victorjulien committed Mar 13, 2024
1 parent c31a6f5 commit 9bc42e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,9 @@ typedef struct Packet_
/* enum PacketDropReason::PKT_DROP_REASON_* as uint8_t for compactness */
uint8_t drop_reason;

/* has tunnel been verdicted? */
bool tunnel_verdicted;

/* tunnel/encapsulation handling */
struct Packet_ *root; /* in case of tunnel this is a ptr
* to the 'real' packet, the one we
Expand Down Expand Up @@ -801,8 +804,8 @@ static inline void TUNNEL_INCR_PKT_TPR(Packet *p)
#define UNSET_TUNNEL_PKT(p) ((p)->flags &= ~PKT_TUNNEL)
#define IS_TUNNEL_ROOT_PKT(p) (IS_TUNNEL_PKT(p) && (p)->root == NULL)

#define IS_TUNNEL_PKT_VERDICTED(p) (((p)->flags & PKT_TUNNEL_VERDICTED))
#define SET_TUNNEL_PKT_VERDICTED(p) ((p)->flags |= PKT_TUNNEL_VERDICTED)
#define IS_TUNNEL_PKT_VERDICTED(p) (p)->tunnel_verdicted
#define SET_TUNNEL_PKT_VERDICTED(p) (p)->tunnel_verdicted = true

enum DecodeTunnelProto {
DECODE_TUNNEL_ETHERNET,
Expand Down Expand Up @@ -1015,7 +1018,7 @@ void DecodeUnregisterCounters(void);
#define PKT_STREAM_NOPCAPLOG BIT_U32(12)

#define PKT_TUNNEL BIT_U32(13)
#define PKT_TUNNEL_VERDICTED BIT_U32(14)
// vacancy

/** Packet checksum is not computed (TX packet for example) */
#define PKT_IGNORE_CHECKSUM BIT_U32(15)
Expand Down
1 change: 1 addition & 0 deletions src/packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ void PacketReinit(Packet *p)
AppLayerDecoderEventsResetEvents(p->app_layer_events);
p->next = NULL;
p->prev = NULL;
p->tunnel_verdicted = false;
p->root = NULL;
p->livedev = NULL;
PACKET_RESET_CHECKSUMS(p);
Expand Down

0 comments on commit 9bc42e3

Please sign in to comment.