public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH]utils/sctp: bugfix for testlib/sctputil.h
@ 2023-07-21  7:18 Li Min via ltp
  2023-07-20 15:26 ` Petr Vorel
  0 siblings, 1 reply; 3+ messages in thread
From: Li Min via ltp @ 2023-07-21  7:18 UTC (permalink / raw)
  To: ltp

The socket is created and bound immediately without waiting for the handshake after close(sk).
"bind(): errno=EADDRINUSE(98): Address already in use" may be reported.
Use SO_REUSEPORT to allow multiple sockets to be bound to the same port.

Signed-off-by: Min Li <limin154@huawei.com>
---
 utils/sctp/testlib/sctputil.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/utils/sctp/testlib/sctputil.h b/utils/sctp/testlib/sctputil.h
index 176d623f0..b51a3f9b0 100644
--- a/utils/sctp/testlib/sctputil.h
+++ b/utils/sctp/testlib/sctputil.h
@@ -133,6 +133,15 @@ extern int TST_CNT;
 static inline int test_socket(int domain, int type, int protocol)
 {
 	int sk = socket(domain, type, protocol);
+	int true_const=1;
+
+	if(setsockopt(sk, SOL_SOCKET, SO_REUSEADDR, &true_const, sizeof(int))){
+		printf("set addr err\n");
+	}
+
+	if(setsockopt(sk, SOL_SOCKET, SO_REUSEPORT, &true_const, sizeof(int))){
+		printf("set port err\n");
+	}

 	if (sk == -1) {
 		if (errno == EAFNOSUPPORT)
--
2.33.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

end of thread, other threads:[~2023-08-29 10:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-21  7:18 [LTP] [PATCH]utils/sctp: bugfix for testlib/sctputil.h Li Min via ltp
2023-07-20 15:26 ` Petr Vorel
2023-08-29 10:25   ` Richard Palethorpe

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