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

Expose some of ETH_P_* consts to ease raw socket creation #95389

Closed
noamcohen97 opened this issue Jul 28, 2022 · 4 comments
Closed

Expose some of ETH_P_* consts to ease raw socket creation #95389

noamcohen97 opened this issue Jul 28, 2022 · 4 comments
Labels
type-feature A feature request or enhancement

Comments

@noamcohen97
Copy link
Contributor

Feature or enhancement

Expose some of ETH_P_* consts to ease raw socket creation

Pitch

Creating a raw socket requires setting protocol to one of the ETH_P_* constants, which are not exposed by the socket module as for now.
I suggest we expose some of those values in the socket module.

@tiran
Copy link
Member

tiran commented Aug 1, 2022

It would help us understand your cause if you could provide real-world examples for each of the constants. How are they used?

@noamcohen97
Copy link
Contributor Author

As stated in manpage packet(7), in the socket() syscall, when family=AF_PACKET and socket_type=SOCK_RAW,
protocol is the IEEE 802.3 protocol number in network byte order (on of ETH_P_* constants).
When protocol is set to htons(ETH_P_ALL), then all protocols are received.

@arhadthedev
Copy link
Member

socket_type=SOCK_RAW

Is running root Python a good idea? If no, should we add features that encourage unsafe practices?

@noamcohen97
Copy link
Contributor Author

running root Python

root is not required, the CAP_NET_RAW capability alone is sufficient.
SOCK_RAW is already supported in Python

erlend-aasland added a commit that referenced this issue Nov 7, 2022
…95390)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

4 participants