diff options
author | Cyrill Gorcunov <gorcunov@gmail.com> | 2019-04-18 12:57:16 +0300 |
---|---|---|
committer | Andrei Vagin <avagin@gmail.com> | 2019-09-07 15:59:48 +0300 |
commit | bd4a52e82e4fd9c60857970a23f038fa16b94fbc (patch) | |
tree | fecf444390339adb2c22862f61d309178df2f9c4 /test | |
parent | b61b260412ce2722924589f63a6cccf281ceb0df (diff) |
test: socket_udplite -- Test shudowned sockets
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/zdtm/static/socket_udplite.c | 60 |
1 files changed, 58 insertions, 2 deletions
diff --git a/test/zdtm/static/socket_udplite.c b/test/zdtm/static/socket_udplite.c index d2510ef2f..229005a10 100644 --- a/test/zdtm/static/socket_udplite.c +++ b/test/zdtm/static/socket_udplite.c @@ -28,9 +28,9 @@ static char buf[8]; int main(int argc, char **argv) { - int ret, sk1, sk2; + int ret, sk1, sk2, sk3, sk4; socklen_t len = sizeof(struct sockaddr_in); - struct sockaddr_in addr1, addr2, addr; + struct sockaddr_in addr1, addr2, addr3, addr4, addr; test_init(argc, argv); @@ -74,6 +74,62 @@ int main(int argc, char **argv) return 1; } + sk3 = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDPLITE); + if (sk3 < 0) { + pr_perror("Can't create socket"); + return 1; + } + + memset(&addr3, 0, sizeof(addr3)); + addr3.sin_family = AF_INET; + addr3.sin_addr.s_addr = inet_addr("127.0.0.1"); + addr3.sin_port = htons(port + 2); + + ret = bind(sk3, (struct sockaddr *)&addr3, len); + if (ret < 0) { + pr_perror("Can't bind socket"); + return 1; + } + + sk4 = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDPLITE); + if (sk4 < 0) { + pr_perror("Can't create socket"); + return 1; + } + + memset(&addr4, 0, sizeof(addr4)); + addr4.sin_family = AF_INET; + addr4.sin_addr.s_addr = inet_addr("0.0.0.0"); + addr4.sin_port = htons(0); + + ret = bind(sk4, (struct sockaddr *)&addr4, len); + if (ret < 0) { + pr_perror("Can't bind socket"); + return 1; + } + + ret = connect(sk4, (struct sockaddr *)&addr3, len); + if (ret < 0) { + pr_perror("Can't connect"); + return 1; + } + + ret = connect(sk3, (struct sockaddr *)&addr4, len); + if (ret < 0) { + pr_perror("Can't connect"); + return 1; + } + + if (shutdown(sk4, SHUT_RDWR)) { + pr_perror("Can't shutdown socket"); + return 1; + } + + if (shutdown(sk3, SHUT_RDWR)) { + pr_perror("Can't shutdown socket"); + return 1; + } + test_daemon(); test_waitsig(); |