ss: Use rtnl_dump_filter in handle_netlink_request
Subsystems (3)
PATCH v2 1/1 ss: Use rtnl_dump_filter in handle_netlink_request
Replaced handling netlink messages by rtnl_dump_filter from lib/libnetlink.c, also:
- removed unused dump_fp arg;
- added MAGIC_SEQ #define for 123456 seq id;
- silently exit if ENOENT errno is caused for NETLINK_SOCK_DIAG proto in lib/libnetlink.c: rtnl_duml_filter_l(...) function. This fix was added in a3fd8e58c1787af186f5c4b234ff974544f840b6 by Eric for misc/ss.c
Signed-off-by Vadim Kochan <[email protected]>
--- include/libnetlink.h | 1 + lib/libnetlink.c | 5 ++ misc/ss.c | 128 +++++++++++++++------------------------------------ 3 files changed, 42 insertions(+), 92 deletions(-)
include/libnetlink.h +1 -0
@@ -18,6 +18,7 @@ struct rtnl_handlestruct sockaddr_nl peer;__u32 seq;__u32 dump; +int proto; };extern int rcvbuf;
lib/libnetlink.c +5 -0
@@ -43,6 +43,7 @@ int rtnl_open_byproto(struct rtnl_handle *rth, unsigned subscriptions,memset (rth,0 ,sizeof (*rth)); + rth->proto = protocol; rth->fd =socket (AF_NETLINK ,SOCK_RAW |SOCK_CLOEXEC , protocol);if (rth->fd <0 ) {perror ("Cannot open netlink socket" );
@@ -245,6 +246,10 @@ int rtnl_dump_filter_l(struct rtnl_handle *rth, "ERROR truncated\n"); }else { errno = -err->error; +if (rth->proto ==NETLINK_SOCK_DIAG && + errno ==ENOENT ) +return -1 ; +perror ("RTNETLINK answers" ); }return -1 ;
misc/ss.c +36 -92
235 lines not on this page · raw message
Signature · 1 line
2.1.3