Print both values of changing address length in sockname family syscalls

* net.c (decode_sockname): Print both user and kernel address lengths
when the value changes.
* tests/net-y-unix.c (main): Update expected output.
* tests/net-yy-unix.c (main): Likewise.
* tests/net.expected: Likewise.
This commit is contained in:
Дмитрий Левин 2016-07-09 21:52:58 +00:00
parent 36df8223a1
commit eca8b5b26a
4 changed files with 35 additions and 28 deletions

2
net.c
View File

@ -225,7 +225,7 @@ decode_sockname(struct tcb *tcp)
tprintf(", [%d]", ulen);
} else {
decode_sockaddr(tcp, tcp->u_arg[1], ulen > rlen ? rlen : ulen);
if (ulen < rlen)
if (ulen != rlen)
tprintf(", [%d->%d]", ulen, rlen);
else
tprintf(", [%d]", rlen);

View File

@ -84,8 +84,8 @@ main(int ac, const char **av)
if (getsockname(listen_fd, listen_sa, len))
perror_msg_and_fail("getsockname");
printf("getsockname(%d<socket:[%lu]>, {sa_family=AF_UNIX"
", sun_path=\"%s\"}, [%u]) = 0\n", listen_fd, listen_inode,
av[1], (unsigned) *len);
", sun_path=\"%s\"}, [%d->%d]) = 0\n", listen_fd, listen_inode,
av[1], (int) sizeof(addr), (int) *len);
int connect_fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (connect_fd < 0)
@ -108,8 +108,9 @@ main(int ac, const char **av)
perror_msg_and_fail("accept");
unsigned long accept_inode = inode_of_sockfd(accept_fd);
printf("accept(%d<socket:[%lu]>, {sa_family=AF_UNIX}"
", [%u]) = %d<socket:[%lu]>\n",
listen_fd, listen_inode, (unsigned) *len,
", [%d->%d]) = %d<socket:[%lu]>\n",
listen_fd, listen_inode,
(int) sizeof(addr), (int) *len,
accept_fd, accept_inode);
memset(listen_sa, 0, sizeof(addr));
@ -117,8 +118,8 @@ main(int ac, const char **av)
if (getpeername(connect_fd, listen_sa, len))
perror_msg_and_fail("getpeername");
printf("getpeername(%d<socket:[%lu]>, {sa_family=AF_UNIX"
", sun_path=\"%s\"}, [%u]) = 0\n", connect_fd, connect_inode,
av[1], (unsigned) *len);
", sun_path=\"%s\"}, [%d->%d]) = 0\n", connect_fd, connect_inode,
av[1], (int) sizeof(addr), (int) *len);
char text[] = "text";
assert(sendto(connect_fd, text, sizeof(text) - 1, MSG_DONTWAIT, NULL, 0)
@ -161,8 +162,9 @@ main(int ac, const char **av)
if (getsockname(listen_fd, listen_sa, len))
perror_msg_and_fail("getsockname");
printf("getsockname(%d<socket:[%lu]>, {sa_family=AF_UNIX"
", sun_path=\"%s\"}, [%u]) = 0\n",
listen_fd, listen_inode, av[1], (unsigned) *len);
", sun_path=\"%s\"}, [%d->%d]) = 0\n",
listen_fd, listen_inode, av[1],
(int) sizeof(addr), (int) *len);
if (connect(connect_fd, listen_sa, *len))
perror_msg_and_fail("connect");
@ -179,8 +181,9 @@ main(int ac, const char **av)
const char * const sun_path1 =
((struct sockaddr_un *) accept_sa) -> sun_path + 1;
printf("accept(%d<socket:[%lu]>, {sa_family=AF_UNIX"
", sun_path=@\"%s\"}, [%u]) = %d<socket:[%lu]>\n",
listen_fd, listen_inode, sun_path1, (unsigned) *len,
", sun_path=@\"%s\"}, [%d->%d]) = %d<socket:[%lu]>\n",
listen_fd, listen_inode, sun_path1,
(int) sizeof(addr), (int) *len,
accept_fd, accept_inode);
memset(listen_sa, 0, sizeof(addr));
@ -188,16 +191,18 @@ main(int ac, const char **av)
if (getpeername(connect_fd, listen_sa, len))
perror_msg_and_fail("getpeername");
printf("getpeername(%d<socket:[%lu]>, {sa_family=AF_UNIX"
", sun_path=\"%s\"}, [%u]) = 0\n",
connect_fd, connect_inode, av[1], (unsigned) *len);
", sun_path=\"%s\"}, [%d->%d]) = 0\n",
connect_fd, connect_inode, av[1],
(int) sizeof(addr), (int) *len);
memset(accept_sa, 0, sizeof(addr));
*len = sizeof(addr);
if (getsockname(connect_fd, accept_sa, len))
perror_msg_and_fail("getsockname");
printf("getsockname(%d<socket:[%lu]>, {sa_family=AF_UNIX"
", sun_path=@\"%s\"}, [%u]) = 0\n",
connect_fd, connect_inode, sun_path1, (unsigned) *len);
", sun_path=@\"%s\"}, [%d->%d]) = 0\n",
connect_fd, connect_inode, sun_path1,
(int) sizeof(addr), (int) *len);
assert(sendto(connect_fd, text, sizeof(text) - 1, MSG_DONTWAIT, NULL, 0)
== sizeof(text) - 1);

View File

@ -85,8 +85,8 @@ main(int ac, const char **av)
if (getsockname(listen_fd, listen_sa, len))
perror_msg_and_fail("getsockname");
printf("getsockname(%d<UNIX:[%lu,\"%s\"]>, {sa_family=AF_UNIX"
", sun_path=\"%s\"}, [%u]) = 0\n", listen_fd, listen_inode,
av[1], av[1], (unsigned) *len);
", sun_path=\"%s\"}, [%d->%d]) = 0\n", listen_fd, listen_inode,
av[1], av[1], (int) sizeof(addr), (int) *len);
int connect_fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (connect_fd < 0)
@ -109,8 +109,8 @@ main(int ac, const char **av)
perror_msg_and_fail("accept");
unsigned long accept_inode = inode_of_sockfd(accept_fd);
printf("accept(%d<UNIX:[%lu,\"%s\"]>, {sa_family=AF_UNIX}"
", [%u]) = %d<UNIX:[%lu->%lu,\"%s\"]>\n",
listen_fd, listen_inode, av[1], (unsigned) *len,
", [%d->%d]) = %d<UNIX:[%lu->%lu,\"%s\"]>\n",
listen_fd, listen_inode, av[1], (int) sizeof(addr), (int) *len,
accept_fd, accept_inode, connect_inode, av[1]);
memset(listen_sa, 0, sizeof(addr));
@ -118,8 +118,9 @@ main(int ac, const char **av)
if (getpeername(connect_fd, listen_sa, len))
perror_msg_and_fail("getpeername");
printf("getpeername(%d<UNIX:[%lu->%lu]>, {sa_family=AF_UNIX"
", sun_path=\"%s\"}, [%u]) = 0\n", connect_fd, connect_inode,
accept_inode, av[1], (unsigned) *len);
", sun_path=\"%s\"}, [%d->%d]) = 0\n",
connect_fd, connect_inode,
accept_inode, av[1], (int) sizeof(addr), (int) *len);
char text[] = "text";
assert(sendto(connect_fd, text, sizeof(text) - 1, MSG_DONTWAIT, NULL, 0)
@ -164,8 +165,8 @@ main(int ac, const char **av)
if (getsockname(listen_fd, listen_sa, len))
perror_msg_and_fail("getsockname");
printf("getsockname(%d<UNIX:[%lu,\"%s\"]>, {sa_family=AF_UNIX"
", sun_path=\"%s\"}, [%u]) = 0\n", listen_fd, listen_inode,
av[1], av[1], (unsigned) *len);
", sun_path=\"%s\"}, [%d->%d]) = 0\n", listen_fd, listen_inode,
av[1], av[1], (int) sizeof(addr), (int) *len);
if (connect(connect_fd, listen_sa, *len))
perror_msg_and_fail("connect");
@ -182,8 +183,9 @@ main(int ac, const char **av)
const char * const sun_path1 =
((struct sockaddr_un *) accept_sa) -> sun_path + 1;
printf("accept(%d<UNIX:[%lu,\"%s\"]>, {sa_family=AF_UNIX"
", sun_path=@\"%s\"}, [%u]) = %d<UNIX:[%lu->%lu,\"%s\"]>\n",
listen_fd, listen_inode, av[1], sun_path1, (unsigned) *len,
", sun_path=@\"%s\"}, [%d->%d]) = %d<UNIX:[%lu->%lu,\"%s\"]>\n",
listen_fd, listen_inode, av[1], sun_path1,
(int) sizeof(addr), (int) *len,
accept_fd, accept_inode, connect_inode, av[1]);
memset(listen_sa, 0, sizeof(addr));
@ -191,8 +193,8 @@ main(int ac, const char **av)
if (getpeername(connect_fd, listen_sa, len))
perror_msg_and_fail("getpeername");
printf("getpeername(%d<UNIX:[%lu->%lu,@\"%s\"]>, {sa_family=AF_UNIX"
", sun_path=\"%s\"}, [%u]) = 0\n", connect_fd, connect_inode,
accept_inode, sun_path1, av[1], (unsigned) *len);
", sun_path=\"%s\"}, [%d->%d]) = 0\n", connect_fd, connect_inode,
accept_inode, sun_path1, av[1], (int) sizeof(addr), (int) *len);
assert(sendto(connect_fd, text, sizeof(text) - 1, MSG_DONTWAIT, NULL, 0)
== sizeof(text) - 1);

View File

@ -3,5 +3,5 @@
[1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +bind\(0, \{sa_family=AF_(LOCAL|UNIX|FILE), sun_path="net-local-stream"\}, 19\) += 0
[1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +listen\(0, 5\) += 0
[1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +getsockname\(0, \{sa_family=AF_(LOCAL|UNIX|FILE), sun_path="net-local-stream"\}, \[19\]\) += 0
[1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +accept\(0, \{sa_family=AF_(LOCAL|UNIX|FILE)\}, \[2\]\) += 1
[1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +accept\(0, \{sa_family=AF_(LOCAL|UNIX|FILE)\}, \[19->2\]\) += 1
[1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +connect\(1, \{sa_family=AF_(LOCAL|UNIX|FILE), sun_path="net-local-stream"\}, 19\) += 0