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

af-xdp: detach XDP program early v8 #9384

Closed
wants to merge 1 commit into from

Conversation

joser12345678
Copy link
Contributor

To mitigate a bug with AF_XDP sockets in high traffic scenarios, the XDP program must be detatched before the sockets are closed. This issue happens when large ammounts of traffic are sent to suricata and the XDP program is not removed before AF_XDP sockets are closed. I believe this is a race condition bug as detailed here: https://bugzilla.kernel.org/show_bug.cgi?id=217712

Further investigation shows this may be a bug exclusive to the driver/AMD processor combination.

This commit addresses the bug by ensuring the first thread to run the deinit function removes the XDP program, which fixes the bug as detailed in the bugzilla link.

Bug #6238

Make sure these boxes are signed before submitting your Pull Request -- thank you.

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

Describe changes:
Added a RunModeAFXDPRemoveProg function to remove an AF_XDP program before closing sockets as this prevents the crash when receiving high traffic volume and shutting down suricata. Also fixed error for building and an error with an unread return value.
previous PR #9369

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

To use a pull request use a branch name like pr/N where N is the
pull request number.

Alternatively, SV_BRANCH may also be a link to an
OISF/suricata-verify pull-request.

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

To mitigate a bug with AF_XDP sockets in high traffic scenarios, the XDP program must be detatched before
the sockets are closed. This issue happens when large ammounts of traffic are sent to suricata and
the XDP program is not removed before AF_XDP sockets are closed. I believe this is a race
condition bug as detailed here: https://bugzilla.kernel.org/show_bug.cgi?id=217712

Further investigation shows this may be a bug exclusive to the driver/AMD processor combination.

This commit addresses the bug by ensuring the first thread to run the deinit function
removes the XDP program, which fixes the bug as detailed in the bugzilla link.

Bug OISF#6238
@github-actions
Copy link

NOTE: This PR may contain new authors:

Joseph Reilly <joser17@vt.edu>

@codecov
Copy link

codecov bot commented Aug 14, 2023

Codecov Report

Merging #9384 (9ac23da) into master (8770431) will decrease coverage by 0.25%.
Report is 54 commits behind head on master.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9384      +/-   ##
==========================================
- Coverage   82.42%   82.17%   -0.25%     
==========================================
  Files         968      968              
  Lines      274011   274198     +187     
==========================================
- Hits       225845   225326     -519     
- Misses      48166    48872     +706     
Flag Coverage Δ
fuzzcorpus 64.04% <0.00%> (-0.61%) ⬇️
suricata-verify 60.88% <66.66%> (+0.03%) ⬆️
unittests 62.88% <33.33%> (-0.04%) ⬇️

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

@catenacyber
Copy link
Contributor

@regit is this your domain of expertise ?

@regit
Copy link
Contributor

regit commented Aug 30, 2023

@regit is this your domain of expertise ?

I ve looked at af_xdp but I don't have a big experience on it. I can look at MR if you want to.

@catenacyber
Copy link
Contributor

Or is it @lukashino who knows best ?

@victorjulien
Copy link
Member

@rmcconnell-r7 @giannitedesco could you have another look? Thanks!

Copy link
Contributor

@giannitedesco giannitedesco left a comment

Choose a reason for hiding this comment

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

Looks good to me. There's a missing newline at end of file introduced but apart from that.

I'm unable to speak to the bug itself since we don't have AMD to repro, but the workaround looks reasonable.

@victorjulien
Copy link
Member

@joser12345678 can you make sure to sign the CLA with the email address you use as the git author? Waiting for that, but we're ready to go after that. Thanks!

@joser12345678
Copy link
Contributor Author

@victorjulien done!

@victorjulien victorjulien added this to the 8.0 milestone Nov 20, 2023
@victorjulien
Copy link
Member

Merged in #9847, thanks!

@victorjulien
Copy link
Member

Thanks for your contribution @joser12345678 🎉

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.

5 participants