netlink: decode netlink message delete flags
* netlink.c: Include "xlat/netlink_delete_flags.h". (decode_nlmsg_flags_crypto, decode_nlmsg_flags_route, decode_nlmsg_flags_xfrm): Decode delete flags. * netlink.h (NLM_F_NONREC): New macro. * xlat/netlink_delete_flags.in: New file. * tests/netlink_crypto.c (test_nlmsg_flags): Check this. * tests/netlink_route.c (test_nlmsg_flags): Likewise. * tests/netlink_xfrm.c (test_nlmsg_flags): Likewise.
This commit is contained in:
parent
695de1df13
commit
b56c8dbcfb
10
netlink.c
10
netlink.c
@ -34,6 +34,7 @@
|
||||
#include <linux/rtnetlink.h>
|
||||
#include <linux/xfrm.h>
|
||||
#include "xlat/netlink_ack_flags.h"
|
||||
#include "xlat/netlink_delete_flags.h"
|
||||
#include "xlat/netlink_flags.h"
|
||||
#include "xlat/netlink_get_flags.h"
|
||||
#include "xlat/netlink_new_flags.h"
|
||||
@ -242,6 +243,9 @@ decode_nlmsg_flags_crypto(const uint16_t type)
|
||||
switch (type) {
|
||||
case CRYPTO_MSG_NEWALG:
|
||||
return netlink_new_flags;
|
||||
case CRYPTO_MSG_DELALG:
|
||||
case CRYPTO_MSG_DELRNG:
|
||||
return netlink_delete_flags;
|
||||
case CRYPTO_MSG_GETALG:
|
||||
return netlink_get_flags;
|
||||
}
|
||||
@ -252,11 +256,14 @@ decode_nlmsg_flags_crypto(const uint16_t type)
|
||||
static const struct xlat *
|
||||
decode_nlmsg_flags_route(const uint16_t type)
|
||||
{
|
||||
/* RTM_DELACTION uses NLM_F_ROOT flags */
|
||||
if (type == RTM_DELACTION)
|
||||
return netlink_get_flags;
|
||||
switch (type & 3) {
|
||||
case 0:
|
||||
return netlink_new_flags;
|
||||
case 1:
|
||||
return netlink_delete_flags;
|
||||
case 2:
|
||||
return netlink_get_flags;
|
||||
}
|
||||
@ -280,6 +287,9 @@ decode_nlmsg_flags_xfrm(const uint16_t type)
|
||||
case XFRM_MSG_NEWSADINFO:
|
||||
case XFRM_MSG_NEWSPDINFO:
|
||||
return netlink_new_flags;
|
||||
case XFRM_MSG_DELSA:
|
||||
case XFRM_MSG_DELPOLICY:
|
||||
return netlink_delete_flags;
|
||||
case XFRM_MSG_GETSA:
|
||||
case XFRM_MSG_GETPOLICY:
|
||||
case XFRM_MSG_GETAE:
|
||||
|
@ -36,6 +36,9 @@
|
||||
# define NETLINK_SOCK_DIAG 4
|
||||
#endif
|
||||
|
||||
#ifndef NLM_F_NONREC
|
||||
# define NLM_F_NONREC 0x100
|
||||
#endif
|
||||
#ifndef NLM_F_CAPPED
|
||||
# define NLM_F_CAPPED 0x100
|
||||
#endif
|
||||
|
@ -78,9 +78,17 @@ test_nlmsg_flags(const int fd)
|
||||
fd, nlh.nlmsg_len, (unsigned) sizeof(nlh), sprintrc(rc));
|
||||
|
||||
nlh.nlmsg_type = CRYPTO_MSG_DELALG;
|
||||
nlh.nlmsg_flags = NLM_F_REPLACE;
|
||||
nlh.nlmsg_flags = NLM_F_ECHO | NLM_F_NONREC;
|
||||
rc = sendto(fd, &nlh, sizeof(nlh), MSG_DONTWAIT, NULL, 0);
|
||||
printf("sendto(%d, {len=%u, type=CRYPTO_MSG_DELALG"
|
||||
", flags=NLM_F_ECHO|NLM_F_NONREC, seq=0, pid=0}"
|
||||
", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
|
||||
fd, nlh.nlmsg_len, (unsigned) sizeof(nlh), sprintrc(rc));
|
||||
|
||||
nlh.nlmsg_type = CRYPTO_MSG_UPDATEALG;
|
||||
nlh.nlmsg_flags = NLM_F_REPLACE;
|
||||
rc = sendto(fd, &nlh, sizeof(nlh), MSG_DONTWAIT, NULL, 0);
|
||||
printf("sendto(%d, {len=%u, type=CRYPTO_MSG_UPDATEALG"
|
||||
", flags=%#x /* NLM_F_??? */, seq=0, pid=0}"
|
||||
", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
|
||||
fd, nlh.nlmsg_len, NLM_F_REPLACE,
|
||||
|
@ -132,13 +132,12 @@ test_nlmsg_flags(const int fd)
|
||||
fd, nlh.nlmsg_len, (unsigned) sizeof(nlh), sprintrc(rc));
|
||||
|
||||
nlh.nlmsg_type = RTM_DELLINK;
|
||||
nlh.nlmsg_flags = NLM_F_REPLACE;
|
||||
nlh.nlmsg_flags = NLM_F_NONREC;
|
||||
rc = sendto(fd, &nlh, sizeof(nlh), MSG_DONTWAIT, NULL, 0);
|
||||
printf("sendto(%d, {len=%u, type=RTM_DELLINK"
|
||||
", flags=%#x /* NLM_F_??? */, seq=0, pid=0}"
|
||||
", flags=NLM_F_NONREC, seq=0, pid=0}"
|
||||
", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
|
||||
fd, nlh.nlmsg_len, NLM_F_REPLACE,
|
||||
(unsigned) sizeof(nlh), sprintrc(rc));
|
||||
fd, nlh.nlmsg_len, (unsigned) sizeof(nlh), sprintrc(rc));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -76,9 +76,17 @@ test_nlmsg_flags(const int fd)
|
||||
fd, nlh.nlmsg_len, (unsigned) sizeof(nlh), sprintrc(rc));
|
||||
|
||||
nlh.nlmsg_type = XFRM_MSG_DELSA;
|
||||
nlh.nlmsg_flags = NLM_F_ECHO | NLM_F_REPLACE;
|
||||
nlh.nlmsg_flags = NLM_F_ECHO | NLM_F_NONREC;
|
||||
rc = sendto(fd, &nlh, sizeof(nlh), MSG_DONTWAIT, NULL, 0);
|
||||
printf("sendto(%d, {len=%u, type=XFRM_MSG_DELSA"
|
||||
", flags=NLM_F_ECHO|NLM_F_NONREC, seq=0, pid=0}"
|
||||
", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
|
||||
fd, nlh.nlmsg_len, (unsigned) sizeof(nlh), sprintrc(rc));
|
||||
|
||||
nlh.nlmsg_type = XFRM_MSG_ALLOCSPI;
|
||||
nlh.nlmsg_flags = NLM_F_ECHO | NLM_F_REPLACE;
|
||||
rc = sendto(fd, &nlh, sizeof(nlh), MSG_DONTWAIT, NULL, 0);
|
||||
printf("sendto(%d, {len=%u, type=XFRM_MSG_ALLOCSPI"
|
||||
", flags=NLM_F_ECHO|%#x, seq=0, pid=0}"
|
||||
", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
|
||||
fd, nlh.nlmsg_len, NLM_F_REPLACE,
|
||||
|
1
xlat/netlink_delete_flags.in
Normal file
1
xlat/netlink_delete_flags.in
Normal file
@ -0,0 +1 @@
|
||||
NLM_F_NONREC
|
Loading…
Reference in New Issue
Block a user