Skip to content

Conversation

@crosser
Copy link
Contributor

@crosser crosser commented Aug 15, 2025

This typedef that exists in the real linux/socket.h is masked by the fake_libc_include hierarchy. Having it in place allows to successfully parse a large number of Linux kernel headers necessary for netlink operations. This is very useful for Python projects that communicate with the kernel over netlink socket. In particular, this project:

https://github.com/ionos-cloud/netlinklib/tree/main/netlinklib

plans to use pyparser for parsing strcts defined in the kernel headers.

#include "_fake_defines.h"
#include "_fake_typedefs.h"

typedef unsigned short __kernel_sa_family_t;
Copy link
Owner

Choose a reason for hiding this comment

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

typedefs typically go into _fake_defines.h

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It can be moved to _fake_defines.h, no problem.

@@ -1,2 +1,9 @@
#ifndef _LINUX_SOCKET_H
Copy link
Owner

Choose a reason for hiding this comment

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

Why are these needed? All fake includes share a single ifndef guard

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They won't be needed if the typedef goes to _fake_defines.h

@crosser crosser force-pushed the better-linux-socket branch from ced7b02 to bb74d6b Compare August 18, 2025 17:45
memory_order_acq_rel,
memory_order_seq_cst
} memory_order;
typedef unsigned short __kernel_sa_family_t;
Copy link
Owner

Choose a reason for hiding this comment

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

Nit: could you please move next to other socket typedefs (search for "socket" in this file)? Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

✔️

This typedef that exists in the real `linux/socket.h` is masked by the
`fake_libc_include` hierarchy. Having it in place allows to successfully
parse a large number of Linux kernel headers necessary for netlink
operations. This is very useful for Python projects that communicate
with the kernel over netlink socket. In particular, this project:

https://github.com/ionos-cloud/netlinklib/tree/main/netlinklib

plans to use pyparser for parsing strcts defined in the kernel headers.

Signed-off-by: Eugene Crosser <crosser@average.org>
@crosser crosser force-pushed the better-linux-socket branch from bb74d6b to 359212b Compare August 18, 2025 20:12
Copy link
Owner

@eliben eliben left a comment

Choose a reason for hiding this comment

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

Thanks!

@eliben eliben merged commit 7b24736 into eliben:main Aug 18, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants