Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

var: Use 16-bit container for type #12272

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

jlucovsky
Copy link
Contributor

Continuation of #12253

Issue: 6855: Match sigmatch type field in var and bit structs

Link to ticket: https://redmine.openinfosecfoundation.org/issues/6855

Describe changes:

  • Increase type in flowbit, flowvar and generic var
  • Ensure type, idx, and next pointers align on each struct.

Updates:

  • Removed todo referencing issue from detect-engine-register.h

Provide values to any of the below to override the defaults.

  • To use an LibHTP, Suricata-Verify or Suricata-Update pull request,
    link to the pull request in the respective _BRANCH variable.
  • Leave unused overrides blank or remove.

SV_REPO=
SV_BRANCH=
SU_REPO=
SU_BRANCH=
LIBHTP_REPO=
LIBHTP_BRANCH=

Issue: 6855: Match sigmatch type field in var and bit structs
Copy link

codecov bot commented Dec 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.23%. Comparing base (0e4faba) to head (c4ea039).
Report is 15 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master   #12272    +/-   ##
========================================
  Coverage   83.22%   83.23%            
========================================
  Files         912      912            
  Lines      257311   257627   +316     
========================================
+ Hits       214154   214426   +272     
- Misses      43157    43201    +44     
Flag Coverage Δ
fuzzcorpus 61.08% <ø> (+0.01%) ⬆️
livemode 19.40% <ø> (-0.13%) ⬇️
pcap 44.39% <ø> (+0.03%) ⬆️
suricata-verify 62.87% <ø> (+0.03%) ⬆️
unittests 59.18% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

uint32_t idx; /* name idx */
GenericVar *next; /* right now just implement this as a list,
* in the long run we have think of something
* faster. */
uint16_t keylen;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this grows the struct with no real benefit:

master:

struct FlowVar_ {
	uint8_t                    type;                 /*     0     1 */
	uint8_t                    datatype;             /*     1     1 */
	uint16_t                   keylen;               /*     2     2 */
	uint32_t                   idx;                  /*     4     4 */
	GenericVar *               next;                 /*     8     8 */
	union {
		FlowVarTypeStr     fv_str;               /*    16    16 */
		FlowVarTypeInt     fv_int;               /*    16     4 */
	} data;                                          /*    16    16 */
	uint8_t *                  key;                  /*    32     8 */

	/* size: 40, cachelines: 1, members: 7 */
	/* last cacheline: 40 bytes */
};

this PR:

struct FlowVar_ {
	uint16_t                   type;                 /*     0     2 */
	uint8_t                    datatype;             /*     2     1 */
	uint8_t                    pad;                  /*     3     1 */
	uint32_t                   idx;                  /*     4     4 */
	GenericVar *               next;                 /*     8     8 */
	uint16_t                   keylen;               /*    16     2 */

	/* XXX 6 bytes hole, try to pack */

	union {
		FlowVarTypeStr     fv_str;               /*    24    16 */
		FlowVarTypeInt     fv_int;               /*    24     4 */
	} data;                                          /*    24    16 */
	uint8_t *                  key;                  /*    40     8 */

	/* size: 48, cachelines: 1, members: 8 */
	/* sum members: 42, holes: 1, sum holes: 6 */
	/* last cacheline: 48 bytes */
};

@suricata-qa
Copy link

Information: QA ran without warnings.

Pipeline 23915

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants