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
fix(driver): correctly retrieve src ip+port from UDP recvmsg
and recvfrom
#1123
Conversation
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
the fix is really small ~20 lines all the other stuff are comments and tests :) |
/cc @LucaGuerra |
I'd also bump driver schema minor version since this impacts what we send to userspace. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
LGTM label has been added. Git tree hash: 95577cb45521e1ba515a0e31189d2ee8961b465b
|
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it> Co-authored-by: Federico Di Pierro <nierro92@gmail.com>
Done, thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for this 🙏
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Andreagit97, FedeDP, LucaGuerra The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind bug
Any specific area of the project related to this PR?
/area driver-kmod
/area driver-bpf
Does this PR require a change in the driver versions?
/version driver-API-version-patch
/version driver-SCHEMA-version-patch
What this PR does / why we need it:
This PR fixes a regression in the old drivers (bpf, kmod).
Some months ago I introduced this patch Andreagit97@1bc30f3 to obtain the correct tuple from the kernel in TCP connections. Unfortunately, this broke the tuple collection with UDP connections :/ The syscall involved are
recvfrom
,recvmsg
TL;DR; when collecting
recvfrom
orrecvmsg
with TCP connections we shouldn't rely on userspace structs to obtain information on the tuple, we need to check it directly in the kernel because userspace structs could be empty. On the other side with UDP, we always need to check the tuple in userspace structs because IP src and port src are never written in kernel structs, the network packet directly populates userspace structs https://github.com/torvalds/linux/blob/e338142b39cf40155054f95daa28d210d2ee1b2d/net/ipv4/udp.c#L1921The fix is quite simple. As a first attempt, we try to read IP src and port src from the kernel, if the port is invalid (0) we fall back to userspace structs. Unfortunately with UDP connections, there could be cases in which also userspace struct will be empty because maybe the user is using
recvfrom
withsrc_addr==NULL
, in this case, we cannot recover IP src and port src, or at least I didn't find a reliable way to do that :(I added some tests to check the expected output. As you can notice there are still some GTEST_SKIP(), because the behavior is not ideal, but at least we fixed the regression. In the next future, we need to adapt these network syscalls between the 3 drivers.
Which issue(s) this PR fixes:
Special notes for your reviewer:
Does this PR introduce a user-facing change?: