linux-sctp.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: ltp@lists.linux.it,
	Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>,
	Neil Horman <nhorman@tuxdriver.com>,
	Vlad Yasevich <vyasevich@gmail.com>,
	linux-sctp@vger.kernel.org
Subject: Re: [PATCH 2/2] sctputil.h: TCONF on EAFNOSUPPORT
Date: Thu, 17 Feb 2022 12:45:22 +0100	[thread overview]
Message-ID: <Yg41Uk3IxfBRX+i8@pevik> (raw)
In-Reply-To: <Yg4bt2V6rrircZ+x@yuki>

Hi Cyril, all,

> Hi!
> > diff --git a/utils/sctp/testlib/sctputil.h b/utils/sctp/testlib/sctputil.h
> > index 1e21760bec..c4bedb47cf 100644
> > --- a/utils/sctp/testlib/sctputil.h
> > +++ b/utils/sctp/testlib/sctputil.h
> > @@ -133,9 +133,14 @@ extern int TST_CNT;
> >  static inline int test_socket(int domain, int type, int protocol)
> >  {
> >  	int sk = socket(domain, type, protocol);
> > +	int res = TBROK;

> > -	if (sk == -1)
> > -		tst_brkm(TBROK, tst_exit, "socket: %s", strerror(errno));
> > +	if (sk == -1) {
> > +		if (errno == EAFNOSUPPORT)
> > +			res = TCONF;
> > +
> > +		tst_brkm(res, tst_exit, "socket: %s", strerror(errno));
> > +	}

> I would keep the messages separated here, i.e. do something as:

> 	if (errno == EAFNOSUPPORT)
> 		tst_brkm(TBROK | TERRNO, "socket(%i, %i, %i) not supported",
> 			 domain, type, protocol);

> 	tst_brkm(TBROK | TERRNO, "socket()");
+1


> Btw this code actually duplicates the safe_socket() function we do have
> already, so it may as well be easier to just replace the test_socket()
> with SAFE_SOCKET() in the tests...
I originally wanted to use safe_macros.h in sctputil.h to replace these
test_{bind,connect,listen,socket} with their SAFE_*() variants.

But it leads into dependency many redefinition problems due mixing
<netinet/in.h> and <linux/in.h>, e.g.:

/usr/include/netinet/in.h:68:5: error: redeclaration of enumerator ‘IPPROTO_GRE’
   68 |     IPPROTO_GRE = 47,      /* General Routing Encapsulation.  */
/usr/include/linux/in.h:55:3: note: previous definition of ‘IPPROTO_GRE’ with type ‘enum <anonymous>’
   55 |   IPPROTO_GRE = 47,             /* Cisco GRE tunnels (rfc 1701,1702)    */
      |   ^~~~~~~~~~~
in utils/sctp/func_tests/test_1_to_1_rtoinfo.c, which requires <linux/in.h> for
at least IPPROTO_SCTP which is not in <netinet/in.h>.

IPPROTO_SCTP is also in <linux/sctp.h>, but it also requires <netinet/sctp.h>
for sctp_recvmsg() and it creates another redefinition conflict due using
<netinet/sctp.h> with <linux/sctp.h> => dependency hell :).

FYI test_1_to_1_rtoinfo.c uses test_socket() and sctputil.h.

Sure this is solvable via either using lapi headers which would load only one of
them and with adding extra definitions or simple just adding the missing
definitions into sctputil.h.

But IMHO a cleaner solution is to rewrite test one by one (which would take
time), but we're waiting reply from SCTP maintainers where (and who) is going to
maintain these tests which deserve a massive cleanup...

Thus for now, I'll follow your other suggestions and merge so that we have IPv6
fixes in.

Kind regards,
Petr

  reply	other threads:[~2022-02-17 11:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-03 17:05 [PATCH 0/2] Fix SCTP tests on systems with disabled IPv6 Petr Vorel
2022-02-03 17:05 ` [PATCH 1/2] sctputil.h: Fix some formatting Petr Vorel
2022-02-17  9:42   ` Cyril Hrubis
2022-02-17  9:45   ` Cyril Hrubis
2022-02-03 17:05 ` [PATCH 2/2] sctputil.h: TCONF on EAFNOSUPPORT Petr Vorel
2022-02-17  9:56   ` Cyril Hrubis
2022-02-17 11:45     ` Petr Vorel [this message]
2022-02-17 12:18     ` Petr Vorel

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=Yg41Uk3IxfBRX+i8@pevik \
    --to=pvorel@suse.cz \
    --cc=chrubis@suse.cz \
    --cc=linux-sctp@vger.kernel.org \
    --cc=ltp@lists.linux.it \
    --cc=marcelo.leitner@gmail.com \
    --cc=nhorman@tuxdriver.com \
    --cc=vyasevich@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).