@@ -161,6 +161,7 @@ enum {
INET_DIAG_SK_BPF_STORAGES,
INET_DIAG_CGROUP_ID,
INET_DIAG_SOCKOPT,
+ INET_DIAG_BPF_MAP,
__INET_DIAG_MAX,
};
@@ -62,4 +62,12 @@ enum {
#define SK_DIAG_BPF_STORAGE_MAX (__SK_DIAG_BPF_STORAGE_MAX - 1)
+enum {
+ SK_DIAG_BPF_MAP_NONE,
+ SK_DIAG_BPF_MAP_IDS,
+ __SK_DIAG_BPF_MAP_MAX,
+};
+
+#define SK_DIAG_BPF_MAP_MAX (__SK_DIAG_BPF_MAP_MAX - 1)
+
#endif /* __SOCK_DIAG_H__ */
@@ -42,6 +42,7 @@ enum {
UNIX_DIAG_MEMINFO,
UNIX_DIAG_SHUTDOWN,
UNIX_DIAG_UID,
+ UNIX_DIAG_BPF_MAP,
__UNIX_DIAG_MAX,
};
@@ -121,6 +121,7 @@ static int show_tipcinfo;
static int show_tos;
static int show_cgroup;
static int show_inet_sockopt;
+static int show_bpf_map;
int oneline;
enum col_id {
@@ -3377,6 +3378,28 @@ static void parse_diag_msg(struct nlmsghdr *nlh, struct sockstat *s)
memcpy(s->remote.data, r->id.idiag_dst, s->local.bytelen);
}
+static void print_bpf_map(struct rtattr *tb)
+{
+ if (tb) {
+ struct rtattr *sockmap[SK_DIAG_BPF_MAP_MAX + 1] = { 0 };
+
+ parse_rtattr_nested(sockmap, SK_DIAG_BPF_MAP_MAX, tb);
+ if (sockmap[SK_DIAG_BPF_MAP_IDS]) {
+ __u32 *maps = RTA_DATA(sockmap[SK_DIAG_BPF_MAP_IDS]);
+ int len = RTA_PAYLOAD(sockmap[SK_DIAG_BPF_MAP_IDS]);
+
+ out(" sockmap:");
+ out(" %d", *maps);
+ maps++;
+ for (len -= 4; len > 0; len -= 4) {
+ out(",");
+ out(" %d", *maps);
+ maps++;
+ }
+ }
+ }
+}
+
static int inet_show_sock(struct nlmsghdr *nlh,
struct sockstat *s)
{
@@ -3470,6 +3493,9 @@ static int inet_show_sock(struct nlmsghdr *nlh,
}
}
+ if (show_bpf_map)
+ print_bpf_map(tb[INET_DIAG_BPF_MAP]);
+
if (show_mem || (show_tcpinfo && s->type != IPPROTO_UDP)) {
if (!oneline)
out("\n\t");
@@ -4153,6 +4179,9 @@ static int unix_show_sock(struct nlmsghdr *nlh, void *arg)
}
}
+ if (show_bpf_map)
+ print_bpf_map(tb[UNIX_DIAG_BPF_MAP]);
+
return 0;
}
@@ -5469,6 +5498,8 @@ static int scan_state(const char *state)
#define OPT_INET_SOCKOPT 262
+#define OPT_BPF_MAP 263
+
static const struct option long_opts[] = {
{ "numeric", 0, 0, 'n' },
{ "resolve", 0, 0, 'r' },
@@ -5513,6 +5544,7 @@ static const struct option long_opts[] = {
{ "mptcp", 0, 0, 'M' },
{ "oneline", 0, 0, 'O' },
{ "inet-sockopt", 0, 0, OPT_INET_SOCKOPT },
+ { "bpf-map", 0, 0, OPT_BPF_MAP },
{ 0 }
};
@@ -5715,6 +5747,9 @@ int main(int argc, char *argv[])
case OPT_INET_SOCKOPT:
show_inet_sockopt = 1;
break;
+ case OPT_BPF_MAP:
+ show_bpf_map = 1;
+ break;
case 'h':
help();
case '?':