public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls/setsockopt05: associate receiver with destination address
@ 2020-08-24 12:10 Jan Stancek
  2020-08-24 14:42 ` Martin Doucha
  0 siblings, 1 reply; 14+ messages in thread
From: Jan Stancek @ 2020-08-24 12:10 UTC (permalink / raw)
  To: ltp

to avoid sporadic ECONNREFUSED errors:
  safe_net.c:202: BROK: setsockopt05.c:70: send(6, 0x3ffcaf7d828, 4000, 32768) failed: ECONNREFUSED (111)

Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
 testcases/kernel/syscalls/setsockopt/setsockopt05.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/setsockopt/setsockopt05.c b/testcases/kernel/syscalls/setsockopt/setsockopt05.c
index e78ef236e337..469e5a64bf71 100644
--- a/testcases/kernel/syscalls/setsockopt/setsockopt05.c
+++ b/testcases/kernel/syscalls/setsockopt/setsockopt05.c
@@ -37,6 +37,7 @@ static void setup(void)
 	int real_uid = getuid();
 	int real_gid = getgid();
 	int sock;
+	int port = TST_GET_UNUSED_PORT(AF_INET, SOCK_DGRAM);
 	struct ifreq ifr;
 
 	SAFE_UNSHARE(CLONE_NEWUSER);
@@ -45,14 +46,14 @@ static void setup(void)
 	SAFE_FILE_PRINTF("/proc/self/uid_map", "0 %d 1", real_uid);
 	SAFE_FILE_PRINTF("/proc/self/gid_map", "0 %d 1", real_gid);
 
-	tst_init_sockaddr_inet_bin(&addr, INADDR_LOOPBACK, 12345);
+	tst_init_sockaddr_inet_bin(&addr, INADDR_LOOPBACK, port);
 	sock = SAFE_SOCKET(AF_INET, SOCK_DGRAM, 0);
 	strcpy(ifr.ifr_name, "lo");
 	ifr.ifr_mtu = 1500;
 	SAFE_IOCTL(sock, SIOCSIFMTU, &ifr);
 	ifr.ifr_flags = IFF_UP;
 	SAFE_IOCTL(sock, SIOCSIFFLAGS, &ifr);
-	SAFE_CLOSE(sock);
+	SAFE_BIND(sock, (struct sockaddr *)&addr, sizeof(struct sockaddr));
 }
 
 static void run(void)
-- 
2.18.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-08-27 17:55 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-24 12:10 [LTP] [PATCH] syscalls/setsockopt05: associate receiver with destination address Jan Stancek
2020-08-24 14:42 ` Martin Doucha
2020-08-24 15:01   ` Jan Stancek
2020-08-24 15:21     ` Martin Doucha
2020-08-24 16:11       ` Jan Stancek
2020-08-25  9:43         ` Martin Doucha
2020-08-25 13:38           ` Jan Stancek
2020-08-26 10:08             ` Martin Doucha
2020-08-26 10:20               ` Martin Doucha
2020-08-26 10:39             ` [LTP] [PATCH] " Martin Doucha
2020-08-27 12:14               ` [LTP] [PATCH v2] " Jan Stancek
2020-08-27 15:55                 ` Martin Doucha
2020-08-27 15:58                   ` Jan Stancek
2020-08-27 17:55                     ` Jan Stancek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox