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

Pkt ptrs/v39 #10796

Closed
wants to merge 49 commits into from
Closed

Pkt ptrs/v39 #10796

wants to merge 49 commits into from

Conversation

victorjulien
Copy link
Member

Redo much of the header pointer logic, cleaning up macro's and unifying various pointers that are mutually exclusive into unions.

Reduces size of the Packet struct from almost 600 bytes to around 450 bytes.

Includes #10762
Replaces #10791

To match function naming style.
Improve readability by setting up data/data_len once before
passing on to the other decoders.

Work in preparation of other decoder changes.
In preparation of future Packet structure changes.
In preparation of making them union members.
Take less space in the TCPVars for tracking if SACKOK is set.

Reduces size by 16 bytes.
No longer use a pointer, but rather an offset.
Addresses are pulled from embedded IPv4 header directly.
Embeded hlen was unused.
Remove unused L4 header pointers.
Only used in tests. For the tests, switch to getting headers from embedded IPv6 header.
Was only set, never checked.
Use a flag to indicate a calculated csum is available.

Allows packet reset to just use memset.
@victorjulien victorjulien mentioned this pull request Apr 10, 2024
Copy link

codecov bot commented Apr 10, 2024

Codecov Report

Attention: Patch coverage is 93.06931% with 154 lines in your changes are missing coverage. Please review.

Project coverage is 82.79%. Comparing base (d9148d1) to head (2acf8df).
Report is 49 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10796      +/-   ##
==========================================
+ Coverage   82.73%   82.79%   +0.06%     
==========================================
  Files         927      926       -1     
  Lines      247785   247691      -94     
==========================================
+ Hits       204996   205076      +80     
+ Misses      42789    42615     -174     
Flag Coverage Δ
fuzzcorpus 64.18% <70.97%> (+<0.01%) ⬆️
suricata-verify 62.00% <67.08%> (+0.01%) ⬆️
unittests 62.23% <72.45%> (+0.04%) ⬆️

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

@suricata-qa
Copy link

Information: QA ran without warnings.

Pipeline 19989

@victorjulien victorjulien mentioned this pull request Apr 11, 2024
@catenacyber
Copy link
Contributor

Is there a redmine ticket for this ?

Copy link
Contributor

@catenacyber catenacyber left a comment

Choose a reason for hiding this comment

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

Thanks for the work Victor :-)

  • CI : 🟢
  • Code : checking now
  • Commits segmentation : looks ok
  • Commit messages : do we need tickets ?
    One line with For the tests, switch to getting headers from embedded IPv6 header. is a bit too long and may be its own and only line.
  • Git ID set : looks fine for me
  • CLA : you already contributed :-p
  • Doc update : not needed
  • Redmine ticket : 🟠 to do ?
  • Rustfmt : not needed
  • Tests : how do you compute the size of the Packet struct ?
  • Dependencies added: none

@catenacyber
Copy link
Contributor

decode: implement IP_GET_IPPROTO as inline func

Why ? Code readability ?

@catenacyber
Copy link
Contributor

decode: turn PKT_IS_IPV4/PKT_IS_IPV6 into functions

Bad commit title: this creates a rapport, but PKT_IS_IPV4 still exists as a macro and is used as such by PacketIsIPv4

@catenacyber
Copy link
Contributor

@jasonish what do you think about the commit 15c2da9 ? It is about defrag

} \
} while(0)
#define DEBUG_VALIDATE_PACKET(p) \
do { \
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you add a do while wrapper ?

Copy link
Member Author

Choose a reason for hiding this comment

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

many macro's have it, but this commit didn't add it

@catenacyber
Copy link
Contributor

decode: clean up pointer list

Not a good title, would prefer something like style cleanup to say that this does not change code

@victorjulien
Copy link
Member Author

decode: implement IP_GET_IPPROTO as inline func

Why ? Code readability ?

Yeah, mostly. Plus the type checking. But the many and often nested macro calls have often made code hard to follow.

@victorjulien
Copy link
Member Author

Is there a redmine ticket for this ?

Just added https://redmine.openinfosecfoundation.org/issues/6938

Comment on lines -311 to +318
ip_hdr_offset = frag->ip_hdr_offset;
ip_hdr_offset = tracker->ip_hdr_offset;

/* This is the start of the fragmentable portion of the
* first packet. All fragment offsets are relative to
* this. */
fragmentable_offset = frag->ip_hdr_offset + frag->hlen;
fragmentable_offset = tracker->ip_hdr_offset + frag->hlen;
Copy link
Member

Choose a reason for hiding this comment

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

Need to look closer, but could this be a possible behaviour change not covered by a unit test? 2 overlapping packets with offset 0. Instead of looking at the packet for each fragment, this will look at what was last set in the tracker.

@victorjulien victorjulien marked this pull request as draft April 13, 2024 06:13
@catenacyber catenacyber added the needs rebase Needs rebase to master label Apr 17, 2024
@victorjulien victorjulien mentioned this pull request Apr 18, 2024
@victorjulien
Copy link
Member Author

Comments addressed in #10926.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs rebase Needs rebase to master
4 participants