[PATCH v2 2/8] tests: check decoding of NETLINK_SOCK_DIAG AF_NETLINK messages
Dmitry V. Levin
ldv at altlinux.org
Fri Jun 16 00:53:54 UTC 2017
On Thu, Jun 15, 2017 at 12:30:48PM +0800, JingPiao Chen wrote:
> * tests/netlink_sock_diag.c: Include <linux/netlink_diag.h>.
> (test_netlink_diag_req, test_netlink_diag_msg): New functions.
> (main): Use them.
Thanks, applied with the following changes:
> + *req = (struct netlink_diag_req) {
> + .sdiag_family = AF_NETLINK,
> + .sdiag_protocol = NDIAG_PROTO_ALL,
> + .ndiag_ino = 0xfacefeed,
> + .ndiag_show = NDIAG_SHOW_MEMINFO,
> + .ndiag_cookie = { 0xdeadbeef, 0xbadc0ded },
> + };
As ndiag_cookie is the last field of the structure, removed trailing comma.
> + rc = sendto(fd, nlh, nlh->nlmsg_len, MSG_DONTWAIT, NULL, 0);
> +
> + printf("sendto(%d, {{len=%u, type=SOCK_DIAG_BY_FAMILY"
> + ", flags=NLM_F_REQUEST, seq=0, pid=0}"
> + ", {sdiag_family=AF_NETLINK, sdiag_protocol=NDIAG_PROTO_ALL"
> + ", ndiag_ino=%u, ndiag_show=NDIAG_SHOW_MEMINFO"
> + ", ndiag_cookie=[%u, %u]}}, %u, MSG_DONTWAIT, NULL, 0) = %s\n",
> + fd, nlh->nlmsg_len, 0xfacefeed, 0xdeadbeef,
> + 0xbadc0ded, nlh->nlmsg_len, sprintrc(rc));
Added another case with a different sdiag_protocol for better coverage.
> + /* short read of netlink_diag_req */
> + nlh = nlh0 - (sizeof(*req) - 1);
Stripped extra space.
> + *msg = (struct netlink_diag_msg) {
> + .ndiag_family = AF_NETLINK,
> + .ndiag_type = SOCK_RAW,
> + .ndiag_protocol = NETLINK_ROUTE,
> + .ndiag_state = NETLINK_CONNECTED,
> + .ndiag_portid = 0xbadc0ded,
> + .ndiag_dst_portid = 0xdeadbeef,
> + .ndiag_dst_group = 0xfacefeed,
> + .ndiag_ino = 0xdaeefacd,
> + .ndiag_cookie = { 0xbadc0ded, 0xdeadbeef },
> + };
As ndiag_cookie is the last field of the structure, removed trailing comma.
--
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20170616/a1a2d242/attachment.bin>
More information about the Strace-devel
mailing list