tests: add check for decoding netlink get and new flags
* tests/netlink_route.c (test_nlmsg_flags): New function, checks decoding of NETLINK_ROUTE get and new flags. (main): Use it. * tests/netlink_sock_diag.c (test_nlmsg_flags): New function, checks decoding of NETLINK_SOCK_DIAG get flags. (main): Use it. * tests/netlink_xfrm.c: (test_nlmsg_flags): New function, checks decoding of NETLINK_XFRM get and new flags. (main): Use it.
This commit is contained in:
parent
fe36545586
commit
427e30ef1c
@ -50,6 +50,48 @@ test_nlmsg_type(const int fd)
|
||||
fd, nlh.nlmsg_len, (unsigned) sizeof(nlh), sprintrc(rc));
|
||||
}
|
||||
|
||||
static void
|
||||
test_nlmsg_flags(const int fd)
|
||||
{
|
||||
long rc;
|
||||
struct nlmsghdr nlh = {
|
||||
.nlmsg_len = sizeof(nlh),
|
||||
};
|
||||
|
||||
nlh.nlmsg_type = RTM_GETLINK;
|
||||
nlh.nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP;
|
||||
rc = sendto(fd, &nlh, sizeof(nlh), MSG_DONTWAIT, NULL, 0);
|
||||
printf("sendto(%d, {{len=%u, type=RTM_GETLINK"
|
||||
", flags=NLM_F_REQUEST|NLM_F_DUMP, seq=0, pid=0}}"
|
||||
", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
|
||||
fd, nlh.nlmsg_len, (unsigned) sizeof(nlh), sprintrc(rc));
|
||||
|
||||
nlh.nlmsg_type = RTM_DELACTION;
|
||||
nlh.nlmsg_flags = NLM_F_ROOT;
|
||||
rc = sendto(fd, &nlh, sizeof(nlh), MSG_DONTWAIT, NULL, 0);
|
||||
printf("sendto(%d, {{len=%u, type=RTM_DELACTION"
|
||||
", flags=NLM_F_ROOT, seq=0, pid=0}}"
|
||||
", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
|
||||
fd, nlh.nlmsg_len, (unsigned) sizeof(nlh), sprintrc(rc));
|
||||
|
||||
nlh.nlmsg_type = RTM_NEWLINK;
|
||||
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=RTM_NEWLINK"
|
||||
", flags=NLM_F_ECHO|NLM_F_REPLACE, seq=0, pid=0}}"
|
||||
", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
|
||||
fd, nlh.nlmsg_len, (unsigned) sizeof(nlh), sprintrc(rc));
|
||||
|
||||
nlh.nlmsg_type = RTM_DELLINK;
|
||||
nlh.nlmsg_flags = NLM_F_REPLACE;
|
||||
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}}"
|
||||
", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
|
||||
fd, nlh.nlmsg_len, NLM_F_REPLACE,
|
||||
(unsigned) sizeof(nlh), sprintrc(rc));
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
skip_if_unavailable("/proc/self/fd/");
|
||||
@ -57,6 +99,7 @@ int main(void)
|
||||
int fd = create_nl_socket(NETLINK_ROUTE);
|
||||
|
||||
test_nlmsg_type(fd);
|
||||
test_nlmsg_flags(fd);
|
||||
|
||||
printf("+++ exited with 0 +++\n");
|
||||
|
||||
|
@ -55,6 +55,23 @@ test_nlmsg_type(const int fd)
|
||||
fd, nlh.nlmsg_len, (unsigned) sizeof(nlh), sprintrc(rc));
|
||||
}
|
||||
|
||||
static void
|
||||
test_nlmsg_flags(const int fd)
|
||||
{
|
||||
long rc;
|
||||
struct nlmsghdr nlh = {
|
||||
.nlmsg_len = sizeof(nlh),
|
||||
.nlmsg_type = SOCK_DIAG_BY_FAMILY,
|
||||
.nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP,
|
||||
};
|
||||
|
||||
rc = sendto(fd, &nlh, sizeof(nlh), MSG_DONTWAIT, NULL, 0);
|
||||
printf("sendto(%d, {{len=%u, type=SOCK_DIAG_BY_FAMILY"
|
||||
", flags=NLM_F_REQUEST|NLM_F_DUMP, seq=0, pid=0}}"
|
||||
", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
|
||||
fd, nlh.nlmsg_len, (unsigned) sizeof(nlh), sprintrc(rc));
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
skip_if_unavailable("/proc/self/fd/");
|
||||
@ -62,6 +79,7 @@ int main(void)
|
||||
int fd = create_nl_socket(NETLINK_SOCK_DIAG);
|
||||
|
||||
test_nlmsg_type(fd);
|
||||
test_nlmsg_flags(fd);
|
||||
|
||||
printf("+++ exited with 0 +++\n");
|
||||
|
||||
|
@ -51,6 +51,40 @@ test_nlmsg_type(const int fd)
|
||||
fd, nlh.nlmsg_len, (unsigned) sizeof(nlh), sprintrc(rc));
|
||||
}
|
||||
|
||||
static void
|
||||
test_nlmsg_flags(const int fd)
|
||||
{
|
||||
long rc;
|
||||
struct nlmsghdr nlh = {
|
||||
.nlmsg_len = sizeof(nlh),
|
||||
};
|
||||
|
||||
nlh.nlmsg_type = XFRM_MSG_GETSA;
|
||||
nlh.nlmsg_flags = NLM_F_DUMP;
|
||||
rc = sendto(fd, &nlh, sizeof(nlh), MSG_DONTWAIT, NULL, 0);
|
||||
printf("sendto(%d, {{len=%u, type=XFRM_MSG_GETSA"
|
||||
", flags=NLM_F_DUMP, 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_NEWSA;
|
||||
nlh.nlmsg_flags = NLM_F_REPLACE;
|
||||
rc = sendto(fd, &nlh, sizeof(nlh), MSG_DONTWAIT, NULL, 0);
|
||||
printf("sendto(%d, {{len=%u, type=XFRM_MSG_NEWSA"
|
||||
", flags=NLM_F_REPLACE, 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_DELSA;
|
||||
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_DELSA"
|
||||
", flags=NLM_F_ECHO|%#x, seq=0, pid=0}}"
|
||||
", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
|
||||
fd, nlh.nlmsg_len, NLM_F_REPLACE,
|
||||
(unsigned) sizeof(nlh), sprintrc(rc));
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
skip_if_unavailable("/proc/self/fd/");
|
||||
@ -58,6 +92,7 @@ int main(void)
|
||||
int fd = create_nl_socket(NETLINK_XFRM);
|
||||
|
||||
test_nlmsg_type(fd);
|
||||
test_nlmsg_flags(fd);
|
||||
|
||||
printf("+++ exited with 0 +++\n");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user