diff --git a/include/Makefile.am b/include/Makefile.am index 82684a1..d5ce186 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -145,6 +145,7 @@ noinst_HEADERS = \ linux-private/linux/netfilter/nfnetlink_queue.h \ linux-private/linux/netlink.h \ linux-private/linux/pkt_cls.h \ + linux-private/linux/sock_diag.h \ linux-private/linux/tc_act/tc_mirred.h \ linux-private/linux/pkt_sched.h \ linux-private/linux/rtnetlink.h \ diff --git a/include/linux-private/linux/sock_diag.h b/include/linux-private/linux/sock_diag.h new file mode 100644 index 0000000..b00e29e --- /dev/null +++ b/include/linux-private/linux/sock_diag.h @@ -0,0 +1,26 @@ +#ifndef _UAPI__SOCK_DIAG_H__ +#define _UAPI__SOCK_DIAG_H__ + +#include + +#define SOCK_DIAG_BY_FAMILY 20 + +struct sock_diag_req { + __u8 sdiag_family; + __u8 sdiag_protocol; +}; + +enum { + SK_MEMINFO_RMEM_ALLOC, + SK_MEMINFO_RCVBUF, + SK_MEMINFO_WMEM_ALLOC, + SK_MEMINFO_SNDBUF, + SK_MEMINFO_FWD_ALLOC, + SK_MEMINFO_WMEM_QUEUED, + SK_MEMINFO_OPTMEM, + SK_MEMINFO_BACKLOG, + + SK_MEMINFO_VARS, +}; + +#endif /* _UAPI__SOCK_DIAG_H__ */ diff --git a/include/netlink-private/types.h b/include/netlink-private/types.h index 4ba13f7..b4dc8ac 100644 --- a/include/netlink-private/types.h +++ b/include/netlink-private/types.h @@ -1001,7 +1001,7 @@ struct idiagnl_msg { struct idiagnl_meminfo * idiag_meminfo; struct idiagnl_vegasinfo * idiag_vegasinfo; struct tcp_info idiag_tcpinfo; - uint32_t idiag_skmeminfo[IDIAG_SK_MEMINFO_VARS]; + uint32_t idiag_skmeminfo[SK_MEMINFO_VARS]; }; struct idiagnl_req { diff --git a/include/netlink/idiag/idiagnl.h b/include/netlink/idiag/idiagnl.h index d7434cd..64bccd7 100644 --- a/include/netlink/idiag/idiagnl.h +++ b/include/netlink/idiag/idiagnl.h @@ -13,6 +13,7 @@ #define NETLINK_IDIAGNL_H_ #include +#include #ifdef __cplusplus extern "C" { @@ -74,22 +75,16 @@ enum { */ #define IDIAG_ATTR_ALL ((1<idiag_skmeminfo[IDIAG_SK_MEMINFO_RMEM_ALLOC]); + msg->idiag_skmeminfo[SK_MEMINFO_RMEM_ALLOC]); nl_dump(p, "\trcv buf: %s\n", - nl_size2str(msg->idiag_skmeminfo[IDIAG_SK_MEMINFO_RCVBUF], + nl_size2str(msg->idiag_skmeminfo[SK_MEMINFO_RCVBUF], buf, sizeof(buf))); nl_dump(p, "\twmem alloc: %d\n", - msg->idiag_skmeminfo[IDIAG_SK_MEMINFO_WMEM_ALLOC]); + msg->idiag_skmeminfo[SK_MEMINFO_WMEM_ALLOC]); nl_dump(p, "\tsnd buf: %s\n", - nl_size2str(msg->idiag_skmeminfo[IDIAG_SK_MEMINFO_SNDBUF], + nl_size2str(msg->idiag_skmeminfo[SK_MEMINFO_SNDBUF], buf, sizeof(buf))); nl_dump(p, "\tfwd alloc: %d\n", - msg->idiag_skmeminfo[IDIAG_SK_MEMINFO_FWD_ALLOC]); + msg->idiag_skmeminfo[SK_MEMINFO_FWD_ALLOC]); nl_dump(p, "\twmem queued: %s\n", - nl_size2str(msg->idiag_skmeminfo[IDIAG_SK_MEMINFO_WMEM_QUEUED], + nl_size2str(msg->idiag_skmeminfo[SK_MEMINFO_WMEM_QUEUED], buf, sizeof(buf))); nl_dump(p, "\topt mem: %d\n", - msg->idiag_skmeminfo[IDIAG_SK_MEMINFO_OPTMEM]); + msg->idiag_skmeminfo[SK_MEMINFO_OPTMEM]); nl_dump(p, "\tbacklog: %d\n", - msg->idiag_skmeminfo[IDIAG_SK_MEMINFO_BACKLOG]); + msg->idiag_skmeminfo[SK_MEMINFO_BACKLOG]); nl_dump(p, "]\n\n"); } @@ -586,7 +586,8 @@ static struct nla_policy ext_policy[IDIAG_ATTR_MAX] = { [IDIAG_ATTR_CONG] = { .type = NLA_STRING }, [IDIAG_ATTR_TOS] = { .type = NLA_U8 }, [IDIAG_ATTR_TCLASS] = { .type = NLA_U8 }, - [IDIAG_ATTR_SKMEMINFO] = { .minlen = (sizeof(uint32_t) * IDIAG_SK_MEMINFO_VARS) }, + /* Older kernel doesn't have SK_MEMINFO_BACKLOG */ + [IDIAG_ATTR_SKMEMINFO] = { .minlen = (sizeof(uint32_t) * (SK_MEMINFO_OPTMEM + 1)) }, [IDIAG_ATTR_SHUTDOWN] = { .type = NLA_U8 }, };