From: Petr Vorel <pvorel@suse.cz>
To: Li Min <limin154@huawei.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH]utils/sctp: bugfix for testlib/sctputil.h
Date: Thu, 20 Jul 2023 17:26:07 +0200 [thread overview]
Message-ID: <20230720152607.GA1339322@pevik> (raw)
In-Reply-To: <20230721071831.83546-1-limin154@huawei.com>
Hi Li,
> 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.
How this can happen? Running tests too quickly one after the other?
Or what is different on your SUT? I'm not sure if it's good idea to always test
with SO_REUSEADDR and SO_REUSEPORT.
> 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;
What is this unused variable for?
> +
> + if(setsockopt(sk, SOL_SOCKET, SO_REUSEADDR, &true_const, sizeof(int))){
> + printf("set addr err\n");
Besides missing spaces in if (if (..) { ), we have SAFE_SETSOCKOPT().
Or tst_brkm(TWARN, ...) could be used (we don't use printf directly in LTP).
Kind regards,
Petr
> + }
> +
> + if(setsockopt(sk, SOL_SOCKET, SO_REUSEPORT, &true_const, sizeof(int))){
> + printf("set port err\n");
> + }
> if (sk == -1) {
> if (errno == EAFNOSUPPORT)
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2023-07-20 15:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2023-08-29 10:25 ` Richard Palethorpe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230720152607.GA1339322@pevik \
--to=pvorel@suse.cz \
--cc=limin154@huawei.com \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox