netlink: add a basic netlink attribute parser of AF_NETLINK diag
* linux/netlink_diag.h (NETLINK_DIAG_*): New enum. * netlink_sock_diag.c: Include "xlat/netlink_diag_attrs.h". (decode_netlink_diag_msg): Use decode_nlattr. * xlat/netlink_diag_attrs.in: New file. Co-authored-by: Fabien Siron <fabien.siron@epita.fr>
This commit is contained in:
parent
4817a2925d
commit
4c511a1c99
@ -23,6 +23,14 @@ struct netlink_diag_msg {
|
||||
uint32_t ndiag_cookie[2];
|
||||
};
|
||||
|
||||
enum {
|
||||
NETLINK_DIAG_MEMINFO,
|
||||
NETLINK_DIAG_GROUPS,
|
||||
NETLINK_DIAG_RX_RING,
|
||||
NETLINK_DIAG_TX_RING,
|
||||
NETLINK_DIAG_FLAGS,
|
||||
};
|
||||
|
||||
#define NDIAG_SHOW_MEMINFO 0x00000001
|
||||
#define NDIAG_SHOW_GROUPS 0x00000002
|
||||
#define NDIAG_SHOW_RING_CFG 0x00000004 /* deprecated since 4.6 */
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "xlat/tcp_states.h"
|
||||
#include "xlat/tcp_state_flags.h"
|
||||
|
||||
#include "xlat/netlink_diag_attrs.h"
|
||||
#include "xlat/netlink_diag_show.h"
|
||||
#include "xlat/netlink_states.h"
|
||||
|
||||
@ -200,7 +201,8 @@ decode_netlink_diag_msg(struct tcb *const tcp,
|
||||
const kernel_ulong_t len)
|
||||
{
|
||||
struct netlink_diag_msg msg = { .ndiag_family = family };
|
||||
const size_t offset = sizeof(msg.ndiag_family);
|
||||
size_t offset = sizeof(msg.ndiag_family);
|
||||
bool decode_nla = false;
|
||||
|
||||
PRINT_FIELD_XVAL("{", msg, ndiag_family, addrfams, "AF_???");
|
||||
tprints(", ");
|
||||
@ -219,10 +221,18 @@ decode_netlink_diag_msg(struct tcb *const tcp,
|
||||
PRINT_FIELD_U(", ", msg, ndiag_dst_group);
|
||||
PRINT_FIELD_U(", ", msg, ndiag_ino);
|
||||
PRINT_FIELD_COOKIE(", ", msg, ndiag_cookie);
|
||||
decode_nla = true;
|
||||
}
|
||||
} else
|
||||
tprints("...");
|
||||
tprints("}");
|
||||
|
||||
offset = NLA_ALIGN(sizeof(msg));
|
||||
if (decode_nla && len > offset) {
|
||||
tprints(", ");
|
||||
decode_nlattr(tcp, addr + offset, len - offset,
|
||||
netlink_diag_attrs, "NETLINK_DIAG_???");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
6
xlat/netlink_diag_attrs.in
Normal file
6
xlat/netlink_diag_attrs.in
Normal file
@ -0,0 +1,6 @@
|
||||
#unconditional
|
||||
NETLINK_DIAG_MEMINFO
|
||||
NETLINK_DIAG_GROUPS
|
||||
NETLINK_DIAG_RX_RING
|
||||
NETLINK_DIAG_TX_RING
|
||||
NETLINK_DIAG_FLAGS
|
Loading…
x
Reference in New Issue
Block a user