* [PATCH 0/2] netlink: implement socket diag for netlink sockets @ 2013-03-21 9:21 Andrey Vagin 2013-03-21 9:21 ` [PATCH 1/2] net: prepare netlink code for netlink diag Andrey Vagin ` (2 more replies) 0 siblings, 3 replies; 14+ messages in thread From: Andrey Vagin @ 2013-03-21 9:21 UTC (permalink / raw) To: linux-kernel, netdev Cc: Andrey Vagin, David S. Miller, Eric Dumazet, Pavel Emelyanov, Pablo Neira Ayuso, Eric W. Biederman, Gao feng Cc: "David S. Miller" <davem@davemloft.net> Cc: Eric Dumazet <edumazet@google.com> Cc: Pavel Emelyanov <xemul@parallels.com> Cc: Pablo Neira Ayuso <pablo@netfilter.org> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Gao feng <gaofeng@cn.fujitsu.com> Signed-off-by: Andrey Vagin <avagin@openvz.org> Andrey Vagin (2): net: prepare netlink code for netlink diag netlink: Diag core and basic socket info dumping include/uapi/linux/netlink_diag.h | 40 ++++++++ net/Kconfig | 1 + net/netlink/Kconfig | 10 ++ net/netlink/Makefile | 3 + net/netlink/af_netlink.c | 59 +----------- net/netlink/af_netlink.h | 62 +++++++++++++ net/netlink/diag.c | 186 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 307 insertions(+), 54 deletions(-) create mode 100644 include/uapi/linux/netlink_diag.h create mode 100644 net/netlink/Kconfig create mode 100644 net/netlink/af_netlink.h create mode 100644 net/netlink/diag.c -- 1.8.1.4 ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 1/2] net: prepare netlink code for netlink diag 2013-03-21 9:21 [PATCH 0/2] netlink: implement socket diag for netlink sockets Andrey Vagin @ 2013-03-21 9:21 ` Andrey Vagin 2013-03-21 9:21 ` [PATCH 2/2] netlink: Diag core and basic socket info dumping Andrey Vagin 2013-03-21 9:33 ` [PATCH 0/4] ss: Get netlink sockets info via sock-diag Andrey Vagin 2 siblings, 0 replies; 14+ messages in thread From: Andrey Vagin @ 2013-03-21 9:21 UTC (permalink / raw) To: linux-kernel, netdev Cc: Andrey Vagin, David S. Miller, Eric Dumazet, Pavel Emelyanov, Pablo Neira Ayuso, Eric W. Biederman, Gao feng Move a few declarations in a header. Cc: "David S. Miller" <davem@davemloft.net> Cc: Eric Dumazet <edumazet@google.com> Cc: Pavel Emelyanov <xemul@parallels.com> Cc: Pablo Neira Ayuso <pablo@netfilter.org> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Gao feng <gaofeng@cn.fujitsu.com> Signed-off-by: Andrey Vagin <avagin@openvz.org> --- net/netlink/af_netlink.c | 59 ++++----------------------------------------- net/netlink/af_netlink.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 54 deletions(-) create mode 100644 net/netlink/af_netlink.h diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 1e3fd5b..a500ce2 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c @@ -61,28 +61,7 @@ #include <net/scm.h> #include <net/netlink.h> -#define NLGRPSZ(x) (ALIGN(x, sizeof(unsigned long) * 8) / 8) -#define NLGRPLONGS(x) (NLGRPSZ(x)/sizeof(unsigned long)) - -struct netlink_sock { - /* struct sock has to be the first member of netlink_sock */ - struct sock sk; - u32 portid; - u32 dst_portid; - u32 dst_group; - u32 flags; - u32 subscriptions; - u32 ngroups; - unsigned long *groups; - unsigned long state; - wait_queue_head_t wait; - struct netlink_callback *cb; - struct mutex *cb_mutex; - struct mutex cb_def_mutex; - void (*netlink_rcv)(struct sk_buff *skb); - void (*netlink_bind)(int group); - struct module *module; -}; +#include "af_netlink.h" struct listeners { struct rcu_head rcu; @@ -94,48 +73,20 @@ struct listeners { #define NETLINK_BROADCAST_SEND_ERROR 0x4 #define NETLINK_RECV_NO_ENOBUFS 0x8 -static inline struct netlink_sock *nlk_sk(struct sock *sk) -{ - return container_of(sk, struct netlink_sock, sk); -} - static inline int netlink_is_kernel(struct sock *sk) { return nlk_sk(sk)->flags & NETLINK_KERNEL_SOCKET; } -struct nl_portid_hash { - struct hlist_head *table; - unsigned long rehash_time; - - unsigned int mask; - unsigned int shift; - - unsigned int entries; - unsigned int max_shift; - - u32 rnd; -}; - -struct netlink_table { - struct nl_portid_hash hash; - struct hlist_head mc_list; - struct listeners __rcu *listeners; - unsigned int flags; - unsigned int groups; - struct mutex *cb_mutex; - struct module *module; - void (*bind)(int group); - int registered; -}; - -static struct netlink_table *nl_table; +struct netlink_table *nl_table; +EXPORT_SYMBOL_GPL(nl_table); static DECLARE_WAIT_QUEUE_HEAD(nl_table_wait); static int netlink_dump(struct sock *sk); -static DEFINE_RWLOCK(nl_table_lock); +DEFINE_RWLOCK(nl_table_lock); +EXPORT_SYMBOL_GPL(nl_table_lock); static atomic_t nl_table_users = ATOMIC_INIT(0); #define nl_deref_protected(X) rcu_dereference_protected(X, lockdep_is_held(&nl_table_lock)); diff --git a/net/netlink/af_netlink.h b/net/netlink/af_netlink.h new file mode 100644 index 0000000..d9acb2a --- /dev/null +++ b/net/netlink/af_netlink.h @@ -0,0 +1,62 @@ +#ifndef _AF_NETLINK_H +#define _AF_NETLINK_H + +#include <net/sock.h> + +#define NLGRPSZ(x) (ALIGN(x, sizeof(unsigned long) * 8) / 8) +#define NLGRPLONGS(x) (NLGRPSZ(x)/sizeof(unsigned long)) + +struct netlink_sock { + /* struct sock has to be the first member of netlink_sock */ + struct sock sk; + u32 portid; + u32 dst_portid; + u32 dst_group; + u32 flags; + u32 subscriptions; + u32 ngroups; + unsigned long *groups; + unsigned long state; + wait_queue_head_t wait; + struct netlink_callback *cb; + struct mutex *cb_mutex; + struct mutex cb_def_mutex; + void (*netlink_rcv)(struct sk_buff *skb); + void (*netlink_bind)(int group); + struct module *module; +}; + +static inline struct netlink_sock *nlk_sk(struct sock *sk) +{ + return container_of(sk, struct netlink_sock, sk); +} + +struct nl_portid_hash { + struct hlist_head *table; + unsigned long rehash_time; + + unsigned int mask; + unsigned int shift; + + unsigned int entries; + unsigned int max_shift; + + u32 rnd; +}; + +struct netlink_table { + struct nl_portid_hash hash; + struct hlist_head mc_list; + struct listeners __rcu *listeners; + unsigned int flags; + unsigned int groups; + struct mutex *cb_mutex; + struct module *module; + void (*bind)(int group); + int registered; +}; + +extern struct netlink_table *nl_table; +extern rwlock_t nl_table_lock; + +#endif -- 1.8.1.4 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 2/2] netlink: Diag core and basic socket info dumping 2013-03-21 9:21 [PATCH 0/2] netlink: implement socket diag for netlink sockets Andrey Vagin 2013-03-21 9:21 ` [PATCH 1/2] net: prepare netlink code for netlink diag Andrey Vagin @ 2013-03-21 9:21 ` Andrey Vagin 2013-03-21 11:46 ` Pavel Emelyanov 2013-03-21 12:52 ` Thomas Graf 2013-03-21 9:33 ` [PATCH 0/4] ss: Get netlink sockets info via sock-diag Andrey Vagin 2 siblings, 2 replies; 14+ messages in thread From: Andrey Vagin @ 2013-03-21 9:21 UTC (permalink / raw) To: linux-kernel, netdev Cc: Andrey Vagin, David S. Miller, Eric Dumazet, Pavel Emelyanov, Pablo Neira Ayuso, Eric W. Biederman, Gao feng The netlink_diag can be built as a module, just like it's done in unix sockets. The core dumping message carries the basic info about netlink sockets: family, type and protocol, portis, dst_group, dst_portid, state. Groups can be received as an optional parameter NETLINK_DIAG_GROUPS. Netlink sockets cab be filtered by protocols. The socket inode number and cookie is reserved for future per-socket info retrieving. The per-protocol filtering is also reserved for future by requiring the sdiag_protocol to be zero. The file /proc/net/netlink doesn't provide enough information for dumping netlink sockets. It doesn't provide dst_group, dst_portid, groups above 32. Cc: "David S. Miller" <davem@davemloft.net> Cc: Eric Dumazet <edumazet@google.com> Cc: Pavel Emelyanov <xemul@parallels.com> Cc: Pablo Neira Ayuso <pablo@netfilter.org> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Gao feng <gaofeng@cn.fujitsu.com> Signed-off-by: Andrey Vagin <avagin@openvz.org> --- include/uapi/linux/netlink_diag.h | 40 ++++++++ net/Kconfig | 1 + net/netlink/Kconfig | 10 ++ net/netlink/Makefile | 3 + net/netlink/diag.c | 188 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 242 insertions(+) create mode 100644 include/uapi/linux/netlink_diag.h create mode 100644 net/netlink/Kconfig create mode 100644 net/netlink/diag.c diff --git a/include/uapi/linux/netlink_diag.h b/include/uapi/linux/netlink_diag.h new file mode 100644 index 0000000..9328866 --- /dev/null +++ b/include/uapi/linux/netlink_diag.h @@ -0,0 +1,40 @@ +#ifndef __NETLINK_DIAG_H__ +#define __NETLINK_DIAG_H__ + +#include <linux/types.h> + +struct netlink_diag_req { + __u8 sdiag_family; + __u8 sdiag_protocol; + __u16 pad; + __u32 ndiag_ino; + __u32 ndiag_show; + __u32 ndiag_cookie[2]; +}; + +struct netlink_diag_msg { + __u8 ndiag_family; + __u8 ndiag_type; + __u8 ndiag_protocol; + __u8 ndiag_state; + + __u32 ndiag_portid; + __u32 ndiag_dst_portid; + __u32 ndiag_dst_group; + __u32 ndiag_ino; + __u32 ndiag_cookie[2]; +}; + +enum { + NETLINK_DIAG_MEMINFO, + NETLINK_DIAG_GROUPS, + + NETLINK_DIAG_MAX, +}; + +#define NDIAG_PROTO_ALL ((__u8) ~0) + +#define NDIAG_SHOW_MEMINFO 0x00000001 /* show memory info of a socket */ +#define NDIAG_SHOW_GROUPS 0x00000002 /* show groups of a netlink socket */ + +#endif diff --git a/net/Kconfig b/net/Kconfig index 6f676ab..2ddc904 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -217,6 +217,7 @@ source "net/dns_resolver/Kconfig" source "net/batman-adv/Kconfig" source "net/openvswitch/Kconfig" source "net/vmw_vsock/Kconfig" +source "net/netlink/Kconfig" config RPS boolean diff --git a/net/netlink/Kconfig b/net/netlink/Kconfig new file mode 100644 index 0000000..5d6e8c0 --- /dev/null +++ b/net/netlink/Kconfig @@ -0,0 +1,10 @@ +# +# Netlink Sockets +# + +config NETLINK_DIAG + tristate "NETLINK: socket monitoring interface" + default n + ---help--- + Support for NETLINK socket monitoring interface used by the ss tool. + If unsure, say Y. diff --git a/net/netlink/Makefile b/net/netlink/Makefile index bdd6ddf..e837917 100644 --- a/net/netlink/Makefile +++ b/net/netlink/Makefile @@ -3,3 +3,6 @@ # obj-y := af_netlink.o genetlink.o + +obj-$(CONFIG_NETLINK_DIAG) += netlink_diag.o +netlink_diag-y := diag.o diff --git a/net/netlink/diag.c b/net/netlink/diag.c new file mode 100644 index 0000000..5ffb1d1 --- /dev/null +++ b/net/netlink/diag.c @@ -0,0 +1,188 @@ +#include <linux/module.h> + +#include <net/sock.h> +#include <linux/netlink.h> +#include <linux/sock_diag.h> +#include <linux/netlink_diag.h> + +#include "af_netlink.h" + +static int sk_diag_dump_groups(struct sock *sk, struct sk_buff *nlskb) +{ + struct netlink_sock *nlk = nlk_sk(sk); + + if (nlk->groups == NULL) + return 0; + + return nla_put(nlskb, NETLINK_DIAG_GROUPS, NLGRPSZ(nlk->ngroups), + nlk->groups); +} + +static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, + struct netlink_diag_req *req, + u32 portid, u32 seq, u32 flags, int sk_ino) +{ + struct nlmsghdr *nlh; + struct netlink_diag_msg *rep; + struct netlink_sock *nlk = nlk_sk(sk); + + nlh = nlmsg_put(skb, portid, seq, SOCK_DIAG_BY_FAMILY, sizeof(*rep), + flags); + if (!nlh) + return -EMSGSIZE; + + rep = nlmsg_data(nlh); + rep->ndiag_family = AF_NETLINK; + rep->ndiag_type = sk->sk_type; + rep->ndiag_protocol = sk->sk_protocol; + rep->ndiag_state = sk->sk_state; + + rep->ndiag_ino = sk_ino; + rep->ndiag_portid = nlk->portid; + rep->ndiag_dst_portid = nlk->dst_portid; + rep->ndiag_dst_group = nlk->dst_group; + sock_diag_save_cookie(sk, rep->ndiag_cookie); + + if ((req->ndiag_show & NDIAG_SHOW_GROUPS) && + sk_diag_dump_groups(sk, skb)) + goto out_nlmsg_trim; + + if ((req->ndiag_show & NDIAG_SHOW_MEMINFO) && + sock_diag_put_meminfo(sk, skb, NETLINK_DIAG_MEMINFO)) + goto out_nlmsg_trim; + + return nlmsg_end(skb, nlh); + +out_nlmsg_trim: + nlmsg_cancel(skb, nlh); + return -EMSGSIZE; +} + +static int __netlink_diag_dump(struct sk_buff *skb, struct netlink_callback *cb, + int protocol, int s_num) +{ + struct netlink_table *tbl = &nl_table[protocol]; + struct nl_portid_hash *hash = &tbl->hash; + struct net *net = sock_net(skb->sk); + struct netlink_diag_req *req; + struct sock *sk; + int ret = 0, num = 0, i; + + req = nlmsg_data(cb->nlh); + + for (i = 0; i <= hash->mask; i++) { + sk_for_each(sk, &hash->table[i]) { + if (!net_eq(sock_net(sk), net)) + continue; + if (num < s_num) { + num++; + continue; + } + + if (sk_diag_fill(sk, skb, req, + NETLINK_CB(cb->skb).portid, + cb->nlh->nlmsg_seq, + NLM_F_MULTI, + sock_i_ino(sk)) < 0) { + ret = 1; + goto done; + } + + num++; + } + } + + sk_for_each_bound(sk, &tbl->mc_list) { + if (sk_hashed(sk)) + continue; + if (!net_eq(sock_net(sk), net)) + continue; + if (num < s_num) { + num++; + continue; + } + + if (sk_diag_fill(sk, skb, req, + NETLINK_CB(cb->skb).portid, + cb->nlh->nlmsg_seq, + NLM_F_MULTI, + sock_i_ino(sk)) < 0) { + ret = 1; + goto done; + } + num++; + } +done: + cb->args[0] = num; + cb->args[1] = protocol; + + return ret; +} + +static int netlink_diag_dump(struct sk_buff *skb, struct netlink_callback *cb) +{ + struct netlink_diag_req *req; + int s_num = cb->args[0]; + + req = nlmsg_data(cb->nlh); + + read_lock(&nl_table_lock); + + if (req->sdiag_protocol == NDIAG_PROTO_ALL) { + int i; + + for (i = cb->args[1]; i < MAX_LINKS; i++) { + if (__netlink_diag_dump(skb, cb, i, s_num)) + break; + s_num = 0; + } + } else { + if (req->sdiag_protocol >= MAX_LINKS) { + read_unlock(&nl_table_lock); + return -ENOENT; + } + + __netlink_diag_dump(skb, cb, req->sdiag_protocol, s_num); + } + + read_unlock(&nl_table_lock); + + return skb->len; +} + +static int netlink_diag_handler_dump(struct sk_buff *skb, struct nlmsghdr *h) +{ + int hdrlen = sizeof(struct netlink_diag_req); + struct net *net = sock_net(skb->sk); + + if (nlmsg_len(h) < hdrlen) + return -EINVAL; + + if (h->nlmsg_flags & NLM_F_DUMP) { + struct netlink_dump_control c = { + .dump = netlink_diag_dump, + }; + return netlink_dump_start(net->diag_nlsk, skb, h, &c); + } else + return -EOPNOTSUPP; +} + +static const struct sock_diag_handler netlink_diag_handler = { + .family = AF_NETLINK, + .dump = netlink_diag_handler_dump, +}; + +static int __init netlink_diag_init(void) +{ + return sock_diag_register(&netlink_diag_handler); +} + +static void __exit netlink_diag_exit(void) +{ + sock_diag_unregister(&netlink_diag_handler); +} + +module_init(netlink_diag_init); +module_exit(netlink_diag_exit); +MODULE_LICENSE("GPL"); +MODULE_ALIAS_NET_PF_PROTO_TYPE(PF_NETLINK, NETLINK_SOCK_DIAG, 16 /* AF_NETLINK */); -- 1.8.1.4 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] netlink: Diag core and basic socket info dumping 2013-03-21 9:21 ` [PATCH 2/2] netlink: Diag core and basic socket info dumping Andrey Vagin @ 2013-03-21 11:46 ` Pavel Emelyanov 2013-03-21 12:52 ` Thomas Graf 1 sibling, 0 replies; 14+ messages in thread From: Pavel Emelyanov @ 2013-03-21 11:46 UTC (permalink / raw) To: Andrey Vagin, David S. Miller Cc: linux-kernel, netdev, Eric Dumazet, Pablo Neira Ayuso, Eric W. Biederman, Gao feng On 03/21/2013 01:21 PM, Andrey Vagin wrote: > The netlink_diag can be built as a module, just like it's done in > unix sockets. > > The core dumping message carries the basic info about netlink sockets: > family, type and protocol, portis, dst_group, dst_portid, state. > > Groups can be received as an optional parameter NETLINK_DIAG_GROUPS. > > Netlink sockets cab be filtered by protocols. > > The socket inode number and cookie is reserved for future per-socket info > retrieving. The per-protocol filtering is also reserved for future by > requiring the sdiag_protocol to be zero. > > The file /proc/net/netlink doesn't provide enough information for > dumping netlink sockets. It doesn't provide dst_group, dst_portid, > groups above 32. > > Cc: "David S. Miller" <davem@davemloft.net> > Cc: Eric Dumazet <edumazet@google.com> > Cc: Pavel Emelyanov <xemul@parallels.com> > Cc: Pablo Neira Ayuso <pablo@netfilter.org> > Cc: "Eric W. Biederman" <ebiederm@xmission.com> > Cc: Gao feng <gaofeng@cn.fujitsu.com> > Signed-off-by: Andrey Vagin <avagin@openvz.org> Acked-by: Pavel Emelyanov <xemul@parallels.com> ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] netlink: Diag core and basic socket info dumping 2013-03-21 9:21 ` [PATCH 2/2] netlink: Diag core and basic socket info dumping Andrey Vagin 2013-03-21 11:46 ` Pavel Emelyanov @ 2013-03-21 12:52 ` Thomas Graf 2013-03-21 14:31 ` Andrew Vagin 1 sibling, 1 reply; 14+ messages in thread From: Thomas Graf @ 2013-03-21 12:52 UTC (permalink / raw) To: Andrey Vagin Cc: linux-kernel, netdev, David S. Miller, Eric Dumazet, Pavel Emelyanov, Pablo Neira Ayuso, Eric W. Biederman, Gao feng On 03/21/13 at 01:21pm, Andrey Vagin wrote: > diff --git a/include/uapi/linux/netlink_diag.h b/include/uapi/linux/netlink_diag.h > new file mode 100644 > index 0000000..9328866 > --- /dev/null > +++ b/include/uapi/linux/netlink_diag.h > +enum { > + NETLINK_DIAG_MEMINFO, > + NETLINK_DIAG_GROUPS, > + > + NETLINK_DIAG_MAX, > +}; Please follow the common pattern and define NETLINK_DIAG_MAX as NETLINK_DIAG_GROUPS like other by doing> [...] __NETLINK_DIAG_MAX, }; #define NETLINK_DIAG_MAX (__NETLINK_DIAG_MAX - 1) Everyone is used to do: struct nlattr *attrs[NETLINK_DIAG_MAX+1]; nla_parse([...], NETLINK_DIAG_MAX, [...] In fact, the follow-up patch to ss is buggy because of this. UNIX_DIAG_MAX suffers from the same problem which is problem the cause for this. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] netlink: Diag core and basic socket info dumping 2013-03-21 12:52 ` Thomas Graf @ 2013-03-21 14:31 ` Andrew Vagin 2013-03-21 14:41 ` Thomas Graf 0 siblings, 1 reply; 14+ messages in thread From: Andrew Vagin @ 2013-03-21 14:31 UTC (permalink / raw) To: Thomas Graf Cc: Andrey Vagin, linux-kernel, netdev, David S. Miller, Eric Dumazet, Pavel Emelyanov, Pablo Neira Ayuso, Eric W. Biederman, Gao feng On Thu, Mar 21, 2013 at 12:52:30PM +0000, Thomas Graf wrote: > On 03/21/13 at 01:21pm, Andrey Vagin wrote: > > diff --git a/include/uapi/linux/netlink_diag.h b/include/uapi/linux/netlink_diag.h > > new file mode 100644 > > index 0000000..9328866 > > --- /dev/null > > +++ b/include/uapi/linux/netlink_diag.h > > +enum { > > + NETLINK_DIAG_MEMINFO, > > + NETLINK_DIAG_GROUPS, > > + > > + NETLINK_DIAG_MAX, > > +}; > > Please follow the common pattern and define NETLINK_DIAG_MAX as > NETLINK_DIAG_GROUPS like other by doing> > > [...] > __NETLINK_DIAG_MAX, > }; > > #define NETLINK_DIAG_MAX (__NETLINK_DIAG_MAX - 1) > > Everyone is used to do: > > struct nlattr *attrs[NETLINK_DIAG_MAX+1]; > > nla_parse([...], NETLINK_DIAG_MAX, [...] > Thank you for this issue. I sent the separate patch "[PATCH] net: fix *_DIAG_MAX constants", because currently only INET_DIAG_MAX is correct. > In fact, the follow-up patch to ss is buggy because of this. > UNIX_DIAG_MAX suffers from the same problem which is problem the > cause for this. The code in ss looks like you described: struct rtattr *tb[UNIX_DIAG_MAX+1]; ... parse_rtattr(tb, UNIX_DIAG_MAX, (struct rtattr*)(r+1), nlh->nlmsg_len - NLMSG_LENGTH(sizeof(*r))); struct rtattr *tb[NETLINK_DIAG_MAX+1]; ... parse_rtattr(tb, NETLINK_DIAG_MAX, (struct rtattr*)(r+1), nlh->nlmsg_len - NLMSG_LENGTH(sizeof(*r))) I think I should only update headers... Or I don't understand something. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] netlink: Diag core and basic socket info dumping 2013-03-21 14:31 ` Andrew Vagin @ 2013-03-21 14:41 ` Thomas Graf 0 siblings, 0 replies; 14+ messages in thread From: Thomas Graf @ 2013-03-21 14:41 UTC (permalink / raw) To: Andrew Vagin Cc: Andrey Vagin, linux-kernel, netdev, David S. Miller, Eric Dumazet, Pavel Emelyanov, Pablo Neira Ayuso, Eric W. Biederman, Gao feng On 03/21/13 at 06:31pm, Andrew Vagin wrote: > The code in ss looks like you described: > struct rtattr *tb[UNIX_DIAG_MAX+1]; > ... > parse_rtattr(tb, UNIX_DIAG_MAX, (struct rtattr*)(r+1), > nlh->nlmsg_len - NLMSG_LENGTH(sizeof(*r))); > > > struct rtattr *tb[NETLINK_DIAG_MAX+1]; > ... > parse_rtattr(tb, NETLINK_DIAG_MAX, (struct rtattr*)(r+1), > nlh->nlmsg_len - NLMSG_LENGTH(sizeof(*r))) > > I think I should only update headers... Or I don't understand something. Right, fixing the headers will resolve the issue. ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 0/4] ss: Get netlink sockets info via sock-diag 2013-03-21 9:21 [PATCH 0/2] netlink: implement socket diag for netlink sockets Andrey Vagin 2013-03-21 9:21 ` [PATCH 1/2] net: prepare netlink code for netlink diag Andrey Vagin 2013-03-21 9:21 ` [PATCH 2/2] netlink: Diag core and basic socket info dumping Andrey Vagin @ 2013-03-21 9:33 ` Andrey Vagin 2013-03-21 9:33 ` [PATCH 1/4] ss: handle socket diag request in a separate function Andrey Vagin ` (4 more replies) 2 siblings, 5 replies; 14+ messages in thread From: Andrey Vagin @ 2013-03-21 9:33 UTC (permalink / raw) To: netdev; +Cc: Pavel Emelyanov, Andrey Vagin, Stephen Hemminger Cc: Stephen Hemminger <stephen@networkplumber.org> Andrey Vagin (4): ss: handle socket diag request in a separate function ss: create a frunction to print info about netlink sockets ss: show destination address for netlink sockets ss: Get netlink sockets info via sock-diag include/linux/netlink_diag.h | 40 ++++++++ misc/ss.c | 235 +++++++++++++++++++++++++++++-------------- 2 files changed, 198 insertions(+), 77 deletions(-) create mode 100644 include/linux/netlink_diag.h -- 1.7.11.7 ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 1/4] ss: handle socket diag request in a separate function 2013-03-21 9:33 ` [PATCH 0/4] ss: Get netlink sockets info via sock-diag Andrey Vagin @ 2013-03-21 9:33 ` Andrey Vagin 2013-03-21 9:33 ` [PATCH 2/4] ss: create a function to print info about netlink sockets Andrey Vagin ` (3 subsequent siblings) 4 siblings, 0 replies; 14+ messages in thread From: Andrey Vagin @ 2013-03-21 9:33 UTC (permalink / raw) To: netdev; +Cc: Pavel Emelyanov, Andrey Vagin, Stephen Hemminger It will be reused to show netlink sockets Cc: Stephen Hemminger <stephen@networkplumber.org> Signed-off-by: Andrey Vagin <avagin@openvz.org> --- misc/ss.c | 49 +++++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/misc/ss.c b/misc/ss.c index da9d32c..bde344a 100644 --- a/misc/ss.c +++ b/misc/ss.c @@ -2206,31 +2206,17 @@ static int unix_show_sock(struct nlmsghdr *nlh, struct filter *f) return 0; } -static int unix_show_netlink(struct filter *f, FILE *dump_fp) +static int handle_netlink_request(struct filter *f, FILE *dump_fp, + struct nlmsghdr *req, size_t size, + int (* show_one_sock)(struct nlmsghdr *nlh, struct filter *f)) { int fd; - struct { - struct nlmsghdr nlh; - struct unix_diag_req r; - } req; char buf[8192]; if ((fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_INET_DIAG)) < 0) return -1; - memset(&req, 0, sizeof(req)); - req.nlh.nlmsg_len = sizeof(req); - req.nlh.nlmsg_type = SOCK_DIAG_BY_FAMILY; - req.nlh.nlmsg_flags = NLM_F_ROOT|NLM_F_MATCH|NLM_F_REQUEST; - req.nlh.nlmsg_seq = 123456; - - req.r.sdiag_family = AF_UNIX; - req.r.udiag_states = f->states; - req.r.udiag_show = UDIAG_SHOW_NAME | UDIAG_SHOW_PEER | UDIAG_SHOW_RQLEN; - if (show_mem) - req.r.udiag_show |= UDIAG_SHOW_MEMINFO; - - if (send(fd, &req, sizeof(req), 0) < 0) { + if (send(fd, req, size, 0) < 0) { close(fd); return -1; } @@ -2275,13 +2261,13 @@ static int unix_show_netlink(struct filter *f, FILE *dump_fp) } else { errno = -err->error; if (errno != ENOENT) - fprintf(stderr, "UDIAG answers %d\n", errno); + fprintf(stderr, "DIAG answers %d\n", errno); } close(fd); return -1; } if (!dump_fp) { - err = unix_show_sock(h, f); + err = show_one_sock(h, f); if (err < 0) { close(fd); return err; @@ -2303,6 +2289,29 @@ close_it: return 0; } +static int unix_show_netlink(struct filter *f, FILE *dump_fp) +{ + struct { + struct nlmsghdr nlh; + struct unix_diag_req r; + } req; + + memset(&req, 0, sizeof(req)); + req.nlh.nlmsg_len = sizeof(req); + req.nlh.nlmsg_type = SOCK_DIAG_BY_FAMILY; + req.nlh.nlmsg_flags = NLM_F_ROOT|NLM_F_MATCH|NLM_F_REQUEST; + req.nlh.nlmsg_seq = 123456; + + req.r.sdiag_family = AF_UNIX; + req.r.udiag_states = f->states; + req.r.udiag_show = UDIAG_SHOW_NAME | UDIAG_SHOW_PEER | UDIAG_SHOW_RQLEN; + if (show_mem) + req.r.udiag_show |= UDIAG_SHOW_MEMINFO; + + return handle_netlink_request(f, dump_fp, &req.nlh, + sizeof(req), unix_show_sock); +} + static int unix_show(struct filter *f) { FILE *fp; -- 1.7.11.7 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 2/4] ss: create a function to print info about netlink sockets 2013-03-21 9:33 ` [PATCH 0/4] ss: Get netlink sockets info via sock-diag Andrey Vagin 2013-03-21 9:33 ` [PATCH 1/4] ss: handle socket diag request in a separate function Andrey Vagin @ 2013-03-21 9:33 ` Andrey Vagin 2013-03-21 9:33 ` [PATCH 3/4] ss: show destination address for " Andrey Vagin ` (2 subsequent siblings) 4 siblings, 0 replies; 14+ messages in thread From: Andrey Vagin @ 2013-03-21 9:33 UTC (permalink / raw) To: netdev; +Cc: Pavel Emelyanov, Andrey Vagin, Stephen Hemminger It will be reused for printing info about netlink sockets, when socket diag is used for retrieving information. Cc: Stephen Hemminger <stephen@networkplumber.org> Signed-off-by: Andrey Vagin <avagin@openvz.org> --- misc/ss.c | 130 ++++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 72 insertions(+), 58 deletions(-) diff --git a/misc/ss.c b/misc/ss.c index bde344a..962f304 100644 --- a/misc/ss.c +++ b/misc/ss.c @@ -2474,6 +2474,73 @@ static int packet_show(struct filter *f) return 0; } +static void netlink_show_one(struct filter *f, + int prot, int pid, unsigned groups, + int rq, int wq, + unsigned long long sk, unsigned long long cb) +{ + if (f->f) { + struct tcpstat tst; + tst.local.family = AF_NETLINK; + tst.remote.family = AF_NETLINK; + tst.rport = -1; + tst.lport = pid; + tst.local.data[0] = prot; + tst.remote.data[0] = 0; + if (run_ssfilter(f->f, &tst) == 0) + return; + } + + if (netid_width) + printf("%-*s ", netid_width, "nl"); + if (state_width) + printf("%-*s ", state_width, "UNCONN"); + printf("%-6d %-6d ", rq, wq); + if (resolve_services && prot == 0) + printf("%*s:", addr_width, "rtnl"); + else if (resolve_services && prot == 3) + printf("%*s:", addr_width, "fw"); + else if (resolve_services && prot == 4) + printf("%*s:", addr_width, "tcpdiag"); + else + printf("%*d:", addr_width, prot); + if (pid == -1) { + printf("%-*s ", serv_width, "*"); + } else if (resolve_services) { + int done = 0; + if (!pid) { + done = 1; + printf("%-*s ", serv_width, "kernel"); + } else if (pid > 0) { + char procname[64]; + FILE *fp; + sprintf(procname, "%s/%d/stat", + getenv("PROC_ROOT") ? : "/proc", pid); + if ((fp = fopen(procname, "r")) != NULL) { + if (fscanf(fp, "%*d (%[^)])", procname) == 1) { + sprintf(procname+strlen(procname), "/%d", pid); + printf("%-*s ", serv_width, procname); + done = 1; + } + fclose(fp); + } + } + if (!done) + printf("%-*d ", serv_width, pid); + } else { + printf("%-*d ", serv_width, pid); + } + printf("%*s*%-*s", + addr_width, "", serv_width, ""); + + if (show_details) { + printf(" sk=%llx cb=%llx groups=0x%08x", sk, cb, groups); + } + printf("\n"); + + return; +} + static int netlink_show(struct filter *f) { FILE *fp; @@ -2486,6 +2553,10 @@ static int netlink_show(struct filter *f) if (!(f->states & (1<<SS_CLOSE))) return 0; + if (!getenv("PROC_NET_NETLINK") && !getenv("PROC_ROOT") && + netlink_show_netlink(f, NULL) == 0) + return 0; + if ((fp = net_netlink_open()) == NULL) return -1; fgets(buf, sizeof(buf)-1, fp); @@ -2495,64 +2566,7 @@ static int netlink_show(struct filter *f) &sk, &prot, &pid, &groups, &rq, &wq, &cb, &rc); - if (f->f) { - struct tcpstat tst; - tst.local.family = AF_NETLINK; - tst.remote.family = AF_NETLINK; - tst.rport = -1; - tst.lport = pid; - tst.local.data[0] = prot; - tst.remote.data[0] = 0; - if (run_ssfilter(f->f, &tst) == 0) - continue; - } - - if (netid_width) - printf("%-*s ", netid_width, "nl"); - if (state_width) - printf("%-*s ", state_width, "UNCONN"); - printf("%-6d %-6d ", rq, wq); - if (resolve_services && prot == 0) - printf("%*s:", addr_width, "rtnl"); - else if (resolve_services && prot == 3) - printf("%*s:", addr_width, "fw"); - else if (resolve_services && prot == 4) - printf("%*s:", addr_width, "tcpdiag"); - else - printf("%*d:", addr_width, prot); - if (pid == -1) { - printf("%-*s ", serv_width, "*"); - } else if (resolve_services) { - int done = 0; - if (!pid) { - done = 1; - printf("%-*s ", serv_width, "kernel"); - } else if (pid > 0) { - char procname[64]; - FILE *fp; - sprintf(procname, "%s/%d/stat", - getenv("PROC_ROOT") ? : "/proc", pid); - if ((fp = fopen(procname, "r")) != NULL) { - if (fscanf(fp, "%*d (%[^)])", procname) == 1) { - sprintf(procname+strlen(procname), "/%d", pid); - printf("%-*s ", serv_width, procname); - done = 1; - } - fclose(fp); - } - } - if (!done) - printf("%-*d ", serv_width, pid); - } else { - printf("%-*d ", serv_width, pid); - } - printf("%*s*%-*s", - addr_width, "", serv_width, ""); - - if (show_details) { - printf(" sk=%llx cb=%llx groups=0x%08x", sk, cb, groups); - } - printf("\n"); + netlink_show_one(f, prot, pid, groups, rq, wq, sk, cb); } return 0; -- 1.7.11.7 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 3/4] ss: show destination address for netlink sockets 2013-03-21 9:33 ` [PATCH 0/4] ss: Get netlink sockets info via sock-diag Andrey Vagin 2013-03-21 9:33 ` [PATCH 1/4] ss: handle socket diag request in a separate function Andrey Vagin 2013-03-21 9:33 ` [PATCH 2/4] ss: create a function to print info about netlink sockets Andrey Vagin @ 2013-03-21 9:33 ` Andrey Vagin 2013-03-21 9:33 ` [PATCH 4/4] ss: Get netlink sockets info via sock-diag Andrey Vagin 2013-03-21 17:00 ` [PATCH 0/4] " Stephen Hemminger 4 siblings, 0 replies; 14+ messages in thread From: Andrey Vagin @ 2013-03-21 9:33 UTC (permalink / raw) To: netdev; +Cc: Pavel Emelyanov, Andrey Vagin, Stephen Hemminger A netlink socket may be connected to a specific group. Cc: Stephen Hemminger <stephen@networkplumber.org> Signed-off-by: Andrey Vagin <avagin@openvz.org> --- misc/ss.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/misc/ss.c b/misc/ss.c index 962f304..1af677a 100644 --- a/misc/ss.c +++ b/misc/ss.c @@ -2476,6 +2476,7 @@ static int packet_show(struct filter *f) static void netlink_show_one(struct filter *f, int prot, int pid, unsigned groups, + int state, int dst_pid, unsigned dst_group, int rq, int wq, unsigned long long sk, unsigned long long cb) { @@ -2530,8 +2531,14 @@ static void netlink_show_one(struct filter *f, } else { printf("%-*d ", serv_width, pid); } - printf("%*s*%-*s", - addr_width, "", serv_width, ""); + + if (state == NETLINK_CONNECTED) { + printf("%*d:%-*d", + addr_width, dst_group, serv_width, dst_pid); + } else { + printf("%*s*%-*s", + addr_width, "", serv_width, ""); + } if (show_details) { printf(" sk=%llx cb=%llx groups=0x%08x", sk, cb, groups); @@ -2566,7 +2573,7 @@ static int netlink_show(struct filter *f) &sk, &prot, &pid, &groups, &rq, &wq, &cb, &rc); - netlink_show_one(f, prot, pid, groups, rq, wq, sk, cb); + netlink_show_one(f, prot, pid, groups, TCP_CLOSE, 0, 0, rq, wq, sk, cb); } return 0; -- 1.7.11.7 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 4/4] ss: Get netlink sockets info via sock-diag 2013-03-21 9:33 ` [PATCH 0/4] ss: Get netlink sockets info via sock-diag Andrey Vagin ` (2 preceding siblings ...) 2013-03-21 9:33 ` [PATCH 3/4] ss: show destination address for " Andrey Vagin @ 2013-03-21 9:33 ` Andrey Vagin 2013-03-21 17:00 ` [PATCH 0/4] " Stephen Hemminger 4 siblings, 0 replies; 14+ messages in thread From: Andrey Vagin @ 2013-03-21 9:33 UTC (permalink / raw) To: netdev; +Cc: Pavel Emelyanov, Andrey Vagin, Stephen Hemminger Cc: Stephen Hemminger <stephen@networkplumber.org> Signed-off-by: Andrey Vagin <avagin@openvz.org> --- include/linux/netlink_diag.h | 40 +++++++++++++++++++++++++++++++ misc/ss.c | 56 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 include/linux/netlink_diag.h diff --git a/include/linux/netlink_diag.h b/include/linux/netlink_diag.h new file mode 100644 index 0000000..9328866 --- /dev/null +++ b/include/linux/netlink_diag.h @@ -0,0 +1,40 @@ +#ifndef __NETLINK_DIAG_H__ +#define __NETLINK_DIAG_H__ + +#include <linux/types.h> + +struct netlink_diag_req { + __u8 sdiag_family; + __u8 sdiag_protocol; + __u16 pad; + __u32 ndiag_ino; + __u32 ndiag_show; + __u32 ndiag_cookie[2]; +}; + +struct netlink_diag_msg { + __u8 ndiag_family; + __u8 ndiag_type; + __u8 ndiag_protocol; + __u8 ndiag_state; + + __u32 ndiag_portid; + __u32 ndiag_dst_portid; + __u32 ndiag_dst_group; + __u32 ndiag_ino; + __u32 ndiag_cookie[2]; +}; + +enum { + NETLINK_DIAG_MEMINFO, + NETLINK_DIAG_GROUPS, + + NETLINK_DIAG_MAX, +}; + +#define NDIAG_PROTO_ALL ((__u8) ~0) + +#define NDIAG_SHOW_MEMINFO 0x00000001 /* show memory info of a socket */ +#define NDIAG_SHOW_GROUPS 0x00000002 /* show groups of a netlink socket */ + +#endif diff --git a/misc/ss.c b/misc/ss.c index 1af677a..49312f1 100644 --- a/misc/ss.c +++ b/misc/ss.c @@ -36,6 +36,7 @@ #include <linux/sock_diag.h> #include <linux/inet_diag.h> #include <linux/unix_diag.h> +#include <linux/netlink_diag.h> int resolve_hosts = 0; int resolve_services = 1; @@ -2548,6 +2549,61 @@ static void netlink_show_one(struct filter *f, return; } +static int netlink_show_sock(struct nlmsghdr *nlh, struct filter *f) +{ + struct netlink_diag_msg *r = NLMSG_DATA(nlh); + struct rtattr *tb[NETLINK_DIAG_MAX+1]; + int rq = 0, wq = 0; + unsigned long groups = 0; + + parse_rtattr(tb, NETLINK_DIAG_MAX, (struct rtattr*)(r+1), + nlh->nlmsg_len - NLMSG_LENGTH(sizeof(*r))); + + if (tb[NETLINK_DIAG_GROUPS] && RTA_PAYLOAD(tb[NETLINK_DIAG_GROUPS])) + groups = *(unsigned long *) RTA_DATA(tb[NETLINK_DIAG_GROUPS]); + + if (tb[NETLINK_DIAG_MEMINFO]) { + const __u32 *skmeminfo; + skmeminfo = RTA_DATA(tb[NETLINK_DIAG_MEMINFO]); + + rq = skmeminfo[SK_MEMINFO_RMEM_ALLOC]; + wq = skmeminfo[SK_MEMINFO_WMEM_ALLOC]; + } + + netlink_show_one(f, r->ndiag_protocol, r->ndiag_portid, groups, + r->ndiag_state, r->ndiag_dst_portid, r->ndiag_dst_group, + rq, wq, 0, 0); + + if (show_mem) { + printf("\t"); + print_skmeminfo(tb, NETLINK_DIAG_MEMINFO); + printf("\n"); + } + + return 0; +} + +static int netlink_show_netlink(struct filter *f, FILE *dump_fp) +{ + struct { + struct nlmsghdr nlh; + struct netlink_diag_req r; + } req; + + memset(&req, 0, sizeof(req)); + req.nlh.nlmsg_len = sizeof(req); + req.nlh.nlmsg_type = SOCK_DIAG_BY_FAMILY; + req.nlh.nlmsg_flags = NLM_F_ROOT|NLM_F_MATCH|NLM_F_REQUEST; + req.nlh.nlmsg_seq = 123456; + + req.r.sdiag_family = AF_NETLINK; + req.r.sdiag_protocol = NDIAG_PROTO_ALL; + req.r.ndiag_show = NDIAG_SHOW_GROUPS | NDIAG_SHOW_MEMINFO; + + return handle_netlink_request(f, dump_fp, &req.nlh, + sizeof(req), netlink_show_sock); +} + static int netlink_show(struct filter *f) { FILE *fp; -- 1.7.11.7 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 0/4] ss: Get netlink sockets info via sock-diag 2013-03-21 9:33 ` [PATCH 0/4] ss: Get netlink sockets info via sock-diag Andrey Vagin ` (3 preceding siblings ...) 2013-03-21 9:33 ` [PATCH 4/4] ss: Get netlink sockets info via sock-diag Andrey Vagin @ 2013-03-21 17:00 ` Stephen Hemminger 4 siblings, 0 replies; 14+ messages in thread From: Stephen Hemminger @ 2013-03-21 17:00 UTC (permalink / raw) To: Andrey Vagin; +Cc: netdev, Pavel Emelyanov On Thu, 21 Mar 2013 13:33:22 +0400 Andrey Vagin <avagin@openvz.org> wrote: > Cc: Stephen Hemminger <stephen@networkplumber.org> > > Andrey Vagin (4): > ss: handle socket diag request in a separate function > ss: create a frunction to print info about netlink sockets > ss: show destination address for netlink sockets > ss: Get netlink sockets info via sock-diag > > include/linux/netlink_diag.h | 40 ++++++++ > misc/ss.c | 235 +++++++++++++++++++++++++++++-------------- > 2 files changed, 198 insertions(+), 77 deletions(-) > create mode 100644 include/linux/netlink_diag.h > Since this depends on functionality not in the upstream kernel. Resubmit this during the 3.10 merge window. At the start of the merge window, headers are synchronized with the kernel headers. ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 0/4] ss: Get netlink sockets info via sock-diag (v2)
@ 2013-06-05 8:41 Andrey Vagin
2013-06-05 8:42 ` [PATCH 3/4] ss: show destination address for netlink sockets Andrey Vagin
0 siblings, 1 reply; 14+ messages in thread
From: Andrey Vagin @ 2013-06-05 8:41 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, Andrey Vagin
On Thu, Mar 21, 2013 at 10:00:25AM -0700, Stephen Hemminger wrote:
> Since this depends on functionality not in the upstream kernel.
> Resubmit this during the 3.10 merge window. At the start of the merge
> window, headers are synchronized with the kernel headers.
Netlink socket diag is in the upstream kernel since 3.10-rc1.
v2: Update kernel headers
Andrey Vagin (4):
ss: handle socket diag request in a separate function
ss: create a function to print info about netlink sockets
ss: show destination address for netlink sockets
ss: Get netlink sockets info via sock-diag (v2)
include/linux/netlink_diag.h | 52 ++++++++++
misc/ss.c | 242 +++++++++++++++++++++++++++++--------------
2 files changed, 216 insertions(+), 78 deletions(-)
create mode 100644 include/linux/netlink_diag.h
--
1.8.2
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 3/4] ss: show destination address for netlink sockets 2013-06-05 8:41 [PATCH 0/4] ss: Get netlink sockets info via sock-diag (v2) Andrey Vagin @ 2013-06-05 8:42 ` Andrey Vagin 0 siblings, 0 replies; 14+ messages in thread From: Andrey Vagin @ 2013-06-05 8:42 UTC (permalink / raw) To: Stephen Hemminger; +Cc: netdev, Andrey Vagin A netlink socket may be connected to a specific group. Cc: Stephen Hemminger <stephen@networkplumber.org> Signed-off-by: Andrey Vagin <avagin@openvz.org> --- misc/ss.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/misc/ss.c b/misc/ss.c index 469ffd0..c8534ff 100644 --- a/misc/ss.c +++ b/misc/ss.c @@ -2674,6 +2674,7 @@ static int packet_show(struct filter *f) static void netlink_show_one(struct filter *f, int prot, int pid, unsigned groups, + int state, int dst_pid, unsigned dst_group, int rq, int wq, unsigned long long sk, unsigned long long cb) { @@ -2728,8 +2729,14 @@ static void netlink_show_one(struct filter *f, } else { printf("%-*d ", serv_width, pid); } - printf("%*s*%-*s", - addr_width, "", serv_width, ""); + + if (state == NETLINK_CONNECTED) { + printf("%*d:%-*d", + addr_width, dst_group, serv_width, dst_pid); + } else { + printf("%*s*%-*s", + addr_width, "", serv_width, ""); + } if (show_details) { printf(" sk=%llx cb=%llx groups=0x%08x", sk, cb, groups); @@ -2764,7 +2771,7 @@ static int netlink_show(struct filter *f) &sk, &prot, &pid, &groups, &rq, &wq, &cb, &rc); - netlink_show_one(f, prot, pid, groups, rq, wq, sk, cb); + netlink_show_one(f, prot, pid, groups, 0, 0, 0, rq, wq, sk, cb); } return 0; -- 1.8.1.4 ^ permalink raw reply related [flat|nested] 14+ messages in thread
end of thread, other threads:[~2013-06-05 8:44 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-03-21 9:21 [PATCH 0/2] netlink: implement socket diag for netlink sockets Andrey Vagin 2013-03-21 9:21 ` [PATCH 1/2] net: prepare netlink code for netlink diag Andrey Vagin 2013-03-21 9:21 ` [PATCH 2/2] netlink: Diag core and basic socket info dumping Andrey Vagin 2013-03-21 11:46 ` Pavel Emelyanov 2013-03-21 12:52 ` Thomas Graf 2013-03-21 14:31 ` Andrew Vagin 2013-03-21 14:41 ` Thomas Graf 2013-03-21 9:33 ` [PATCH 0/4] ss: Get netlink sockets info via sock-diag Andrey Vagin 2013-03-21 9:33 ` [PATCH 1/4] ss: handle socket diag request in a separate function Andrey Vagin 2013-03-21 9:33 ` [PATCH 2/4] ss: create a function to print info about netlink sockets Andrey Vagin 2013-03-21 9:33 ` [PATCH 3/4] ss: show destination address for " Andrey Vagin 2013-03-21 9:33 ` [PATCH 4/4] ss: Get netlink sockets info via sock-diag Andrey Vagin 2013-03-21 17:00 ` [PATCH 0/4] " Stephen Hemminger -- strict thread matches above, loose matches on Subject: below -- 2013-06-05 8:41 [PATCH 0/4] ss: Get netlink sockets info via sock-diag (v2) Andrey Vagin 2013-06-05 8:42 ` [PATCH 3/4] ss: show destination address for netlink sockets Andrey Vagin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).