little-dude / netlink

netlink libraries for rust
Other
332 stars 89 forks source link

RFC: diag: add support for SOCK_DESTROY #283

Open anisse opened 1 year ago

anisse commented 1 year ago

Please consider this PR more like a request for comments, and a feature request for SOCK_DESTROY support. I'm not really a fan of how it's implemented, but I wanted to see if this was possible, and sent the first working version :-)

It is implemented on top of SockDiagMessage, and allows using Linux's CONFIG_INET_DIAG_DESTROY feature to close an arbitrary socket.

It was previously merged by accident in PR #279 . For an example of how to use this code, see: https://github.com/anisse/tcpkill/blob/cfd96d5dec438a3722edb25938a88aa7671fae84/src/tcpkill_netlink.rs#L21

cathay4t commented 1 year ago

@anisse We are moving splitting this project into small parts. Could you move this PR to https://github.com/rust-netlink/netlink-packet-sock-diag

For the comment part, personally, I would like hear the use case why privileged user/process need to shutdown a arbitrary socket. I don't like dead code.