On Wed, May 18, 2016 at 04:45:50PM +0000, Fabien Siron wrote:
[...]
> --- /dev/null
> +++ b/tests/net-yy-netlink.c
> @@ -0,0 +1,81 @@
> +/*
> + * This file is part of net-yy-unix strace test.

Really?  It looks more like a netlink test.

> +     const int fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_SOCK_DIAG);

NETLINK_SOCK_DIAG is not defined on old systems, a fallback definition
is needed, see tests/netlink_unix_diag.c for an example.

> +     if (fd < 0)
> +             perror_msg_and_skip("socket");
> +     const unsigned long inode = inode_of_sockfd(fd);
> +     printf("socket(AF_NETLINK, SOCK_RAW, NETLINK_SOCK_DIAG) = "
> +            "%d<NETLINK:[%lu]>\n", fd, inode);
> +
> +     if (bind(fd, sa, *len))
> +             perror_msg_and_skip("bind");
> +     printf("bind(%d<NETLINK:[%lu]>, {sa_family=AF_NETLINK, pid=%u, "
> +            "groups=00000000}, %u) = 0\n", fd, inode, magic,
> +            (unsigned) *len);
> +
> +     assert(sendto(fd, text, sizeof(text) - 1, MSG_DONTWAIT, NULL, 0)
> +            == sizeof(text) - 1);
> +     printf("sendto(%d<NETLINK:[SOCK_DIAG:%u]>, \"%s\", %u, MSG_DONTWAIT"
> +            ", NULL, 0) = %u\n", fd, magic, text,
> +            (unsigned) sizeof(text) - 1, (unsigned) sizeof(text) - 1);

There is a problem with this sendto call: on some systems it fails with
EINVAL.  I'd suggest replacing it with some other call, e.g. recvmsg:

        assert(recvmsg(fd, NULL, MSG_DONTWAIT) == -1);
        printf("recvmsg(%d<NETLINK:[SOCK_DIAG:%u]>, NULL, MSG_DONTWAIT)"
               " = -1 %s (%m)\n", fd, magic, errno2name());

> --- /dev/null
> +++ b/tests/net-yy-netlink.test
> @@ -0,0 +1,47 @@
> +#!/bin/sh
> +#
> +# Check decoding of ip:port pairs associated with socket descriptors

Really?  ip:port pairs for netlink sockets?

> +     if (socket(AF_NETLINK, SOCK_RAW, NETLINK_SOCK_DIAG))

Another file that uses NETLINK_SOCK_DIAG, it also needs a fallback definition.


-- 
ldv

Attachment: pgpg1nDdo8Qr_.pgp
Description: PGP signature

------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to