-
Notifications
You must be signed in to change notification settings - Fork 66
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: build on v6.6+ kernel #415
Conversation
I'm sorry for the silence. I'll review and likely merge next Saturday. |
Hmm. Ok, but it seems the new formal way to access the header is through (Notes moved to the review) |
src/mod/common/nl/nl_common.c
Outdated
@@ -14,7 +14,7 @@ char *get_iname(struct genl_info *info) | |||
|
|||
struct joolnlhdr *get_jool_hdr(struct genl_info *info) | |||
{ | |||
return info->userhdr; | |||
return (struct joolnlhdr *)(info->genlhdr + GENL_HDRLEN); |
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.
struct genlmsghdr
is a four byte structure (excluding unlikely padding and slop), which means if you add a number to a genlmsghdr pointer, you will actually sum four times the indicated amount.
In other words, you're returning the equivalent of
((u8 *)info->genlhdr) + 4 * GENL_HDRLEN
When (according to genl_info_userhdr()
) you actually want to return
((u8 *)info->genlhdr) + GENL_HDRLEN
Try compiling the following userspace program to see the difference:
#include <stdio.h>
#include <linux/genetlink.h>
int main(int argc, char **argv)
{
struct genlmsghdr base;
struct genlmsghdr *ptr;
ptr = &base;
printf("ptr : %p\n", ptr);
/* Prints the location right next to base. */
printf("ptr + 1 : %p\n", ptr + 1);
/* Prints a location far to base's right */
printf("ptr + GENL_HDRLEN: %p\n", ptr + GENL_HDRLEN);
return 0;
}
(Dump that into a file called pointer-test.c, then run something like gcc pointer-test.c && ./a.out
)
Note, we have helper macros to define code that should be compiled differently depending on linked kernel version. Sample usage. |
As a note, there is a patch from canonical/ubuntu for this: https://git.launchpad.net/ubuntu/+source/jool/tree/debian/patches/0002-Linux-6.6-support.patch?h=applied/ubuntu/devel |
Just to be clear: I'm waiting for a patch because I think it's rude to overwrite people's contributions. (Though admittedly I've done it in the past.) I'll wait until Saturday. Alternatively, if you just want me to push the fix ASAP, just say so. |
Commit bffcc6882a "genetlink: remove userhdr from struct genl_info" caused the build to fail since the field no longer exists. Replace with run-time calculation of the header offset. Signed-off-by: Tj <linux@iamtj>
dc47f66
to
032b9d8
Compare
I've been away for a few days; thanks for the review. Looking at it now I'm not quite sure what I was thinking but assume I copied from Maybe the Canonical patch makes more sense since it makes clear that internal kernel structure changed at version 6.6. |
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.
I object this change. this will cause ABI breakage and not ever noticed by future compiler errors.
@ydahhrk this one is nice ! |
Commit bffcc6882a "genetlink: remove userhdr from struct genl_info" caused the build to fail since the field no longer exists.
Replace with run-time calculation of the header offset.