All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Stancek <jstancek@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2] syscalls/setsockopt05: associate receiver with destination address
Date: Thu, 27 Aug 2020 11:58:13 -0400 (EDT)	[thread overview]
Message-ID: <452994585.10362765.1598543893067.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <1175d50f-9b07-ec6e-4840-f5b61d677753@suse.cz>



----- Original Message -----
> Hi,
> I assume that cycling through different source ports prevented the issue?

Yes, it did, it ran fine over night.

> 
> Reviewed-by: Martin Doucha <mdoucha@suse.cz>
> 
> On 27. 08. 20 14:14, Jan Stancek wrote:
> > to avoid sporadic ECONNREFUSED errors (caused by delayed ICMP):
> >   safe_net.c:202: BROK: setsockopt05.c:70: send(6, 0x3ffcaf7d828, 4000,
> >   32768) failed: ECONNREFUSED (111)
> > 
> > per man(7) udp:
> >   ECONNREFUSED
> >     No receiver was associated with the destination address.
> >     This might be caused by a previous packet sent over the socket.
> > 
> > per https://tools.ietf.org/html/rfc1122#page-78
> >   The application is also responsible to avoid confusion from a delayed
> >   ICMP
> >   error message resulting from an earlier use of the same port(s).
> > 
> > Signed-off-by: Jan Stancek <jstancek@redhat.com>
> > ---
> >  .../kernel/syscalls/setsockopt/setsockopt05.c | 23 ++++++++++++++-----
> >  1 file changed, 17 insertions(+), 6 deletions(-)
> > 
> > diff --git a/testcases/kernel/syscalls/setsockopt/setsockopt05.c
> > b/testcases/kernel/syscalls/setsockopt/setsockopt05.c
> > index e78ef236e337..0b7ff39d2663 100644
> > --- a/testcases/kernel/syscalls/setsockopt/setsockopt05.c
> > +++ b/testcases/kernel/syscalls/setsockopt/setsockopt05.c
> > @@ -31,13 +31,14 @@
> >  #define BUFSIZE 4000
> >  
> >  static struct sockaddr_in addr;
> > +static int dst_sock = -1;
> >  
> >  static void setup(void)
> >  {
> >  	int real_uid = getuid();
> >  	int real_gid = getgid();
> > -	int sock;
> >  	struct ifreq ifr;
> > +	socklen_t addrlen = sizeof(addr);
> >  
> >  	SAFE_UNSHARE(CLONE_NEWUSER);
> >  	SAFE_UNSHARE(CLONE_NEWNET);
> > @@ -45,14 +46,23 @@ 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);
> > -	sock = SAFE_SOCKET(AF_INET, SOCK_DGRAM, 0);
> > +	tst_init_sockaddr_inet_bin(&addr, INADDR_LOOPBACK, 0);
> > +	dst_sock = SAFE_SOCKET(AF_INET, SOCK_DGRAM, 0);
> > +
> >  	strcpy(ifr.ifr_name, "lo");
> >  	ifr.ifr_mtu = 1500;
> > -	SAFE_IOCTL(sock, SIOCSIFMTU, &ifr);
> > +	SAFE_IOCTL(dst_sock, SIOCSIFMTU, &ifr);
> >  	ifr.ifr_flags = IFF_UP;
> > -	SAFE_IOCTL(sock, SIOCSIFFLAGS, &ifr);
> > -	SAFE_CLOSE(sock);
> > +	SAFE_IOCTL(dst_sock, SIOCSIFFLAGS, &ifr);
> > +
> > +	SAFE_BIND(dst_sock, (struct sockaddr *)&addr, addrlen);
> > +	SAFE_GETSOCKNAME(dst_sock, (struct sockaddr*)&addr, &addrlen);
> > +}
> > +
> > +static void cleanup(void)
> > +{
> > +	if (dst_sock != -1)
> > +		SAFE_CLOSE(dst_sock);
> >  }
> >  
> >  static void run(void)
> > @@ -82,6 +92,7 @@ static void run(void)
> >  static struct tst_test test = {
> >  	.test_all = run,
> >  	.setup = setup,
> > +	.cleanup = cleanup,
> >  	.taint_check = TST_TAINT_W | TST_TAINT_D,
> >  	.needs_kconfigs = (const char *[]) {
> >  		"CONFIG_USER_NS=y",
> > 
> 
> 
> --
> Martin Doucha   mdoucha@suse.cz
> QA Engineer for Software Maintenance
> SUSE LINUX, s.r.o.
> CORSO IIa
> Krizikova 148/34
> 186 00 Prague 8
> Czech Republic
> 
> 


  reply	other threads:[~2020-08-27 15:58 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2020-08-27 17:55                     ` Jan Stancek

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=452994585.10362765.1598543893067.JavaMail.zimbra@redhat.com \
    --to=jstancek@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.