netlink: implement decoding of INET_DIAG_CLASS_ID attribute

This is a new netlink attribute introduced by linux kernel commit
v4.14-rc1~130^2~207.

* linux/inet_diag.h (INET_DIAG_CLASS_ID): New enum.
* netlink_inet_diag.c (inet_diag_msg_nla_decoders): Add
INET_DIAG_CLASS_ID.
* xlat/inet_diag_attrs.in: Add INET_DIAG_CLASS_ID.
* xlat/inet_diag_extended_flags.in: Add 1<<(INET_DIAG_CLASS_ID-1).
* tests/nlattr_inet_diag_msg.c (main): Check INET_DIAG_CLASS_ID
decoding.
This commit is contained in:
Дмитрий Левин 2017-09-16 17:44:29 +00:00
parent 52231be034
commit 2baaf7302e
5 changed files with 10 additions and 1 deletions

View File

@ -106,6 +106,7 @@ enum {
INET_DIAG_PAD,
INET_DIAG_MARK,
INET_DIAG_BBRINFO,
INET_DIAG_CLASS_ID,
};
/* INET_DIAG_MEM */

View File

@ -388,7 +388,8 @@ static const nla_decoder_t inet_diag_msg_nla_decoders[] = {
[INET_DIAG_PEERS] = NULL, /* unimplemented */
[INET_DIAG_PAD] = NULL,
[INET_DIAG_MARK] = decode_nla_u32,
[INET_DIAG_BBRINFO] = decode_tcp_bbr_info
[INET_DIAG_BBRINFO] = decode_tcp_bbr_info,
[INET_DIAG_CLASS_ID] = decode_nla_u32
};
DECL_NETLINK_DIAG_DECODER(decode_inet_diag_msg)

View File

@ -182,6 +182,11 @@ main(void)
INET_DIAG_MARK, pattern, mark,
printf("%u", mark));
TEST_NLATTR_OBJECT(fd, nlh0, hdrlen,
init_inet_diag_msg, print_inet_diag_msg,
INET_DIAG_CLASS_ID, pattern, mark,
printf("%u", mark));
static const uint8_t shutdown = 0xcd;
TEST_NLATTR(fd, nlh0, hdrlen,
init_inet_diag_msg, print_inet_diag_msg, INET_DIAG_SHUTDOWN,

View File

@ -16,3 +16,4 @@ INET_DIAG_PEERS
INET_DIAG_PAD
INET_DIAG_MARK
INET_DIAG_BBRINFO
INET_DIAG_CLASS_ID

View File

@ -15,3 +15,4 @@
1<<(INET_DIAG_PAD-1)
1<<(INET_DIAG_MARK-1)
1<<(INET_DIAG_BBRINFO-1)
1<<(INET_DIAG_CLASS_ID-1)