public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Daniel Alvarez <dalvarez@redhat.com>
To: libc-alpha@sourceware.org
Cc: Daniel Alvarez <dalvarez@redhat.com>, Jakub Sitnicki <jkbs@redhat.com>
Subject: [PATCH] [BZ #21812] getifaddrs() Don't return ifa entries with NULL names
Date: Fri, 15 Jun 2018 13:29:00 -0000	[thread overview]
Message-ID: <20180615132915.83940-1-dalvarez@redhat.com> (raw)

Due to bug 21812, a lookup operation in map_newlink() turns out
into an insert because of holes in the interface part of the map.
This leads to incorrectly set the name of the interface to NULL when
the interface is not present for the address being processed (most
likely because the interface was added between the RTM_GETLINK and
RTM_GETADDR calls to the kernel). When such changes are detected
by the kernel, it'll mark the dump as "inconsistent" by setting
NLM_F_DUMP_INTR flag on the next netlink message.

This patch checks this condition and retries the whole operation.
Hopes are that next time the interface corresponding to the address
entry is present in the list and correct name is returned.

Signed-off-by: Daniel Alvarez <dalvarez@redhat.com>
Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
---
 sysdeps/unix/sysv/linux/ifaddrs.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/sysdeps/unix/sysv/linux/ifaddrs.c b/sysdeps/unix/sysv/linux/ifaddrs.c
index 32381f54e4..5659c9605b 100644
--- a/sysdeps/unix/sysv/linux/ifaddrs.c
+++ b/sysdeps/unix/sysv/linux/ifaddrs.c
@@ -370,6 +370,14 @@ getifaddrs_internal (struct ifaddrs **ifap)
 	  if ((pid_t) nlh->nlmsg_pid != nh.pid || nlh->nlmsg_seq != nlp->seq)
 	    continue;
 
+      /* If the dump got interrupted, we can't relay on the results so
+         try again. */
+      if (nlh->nlmsg_flags & NLM_F_DUMP_INTR)
+        {
+          result = -EAGAIN;
+          goto exit_free;
+        }
+
 	  if (nlh->nlmsg_type == NLMSG_DONE)
 	    break;		/* ok */
 
-- 
2.15.1 (Apple Git-101)

             reply	other threads:[~2018-06-15 13:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-15 13:29 Daniel Alvarez [this message]
2018-06-15 19:12 ` Adhemerval Zanella
2018-06-29  6:58   ` Daniel Alvarez Sanchez
2018-06-29  9:38     ` Florian Weimer
2018-06-29  8:22 ` Florian Weimer
  -- strict thread matches above, loose matches on Subject: below --
2017-07-24 20:58 Daniel Alvarez
2017-08-29 10:37 ` Florian Weimer

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=20180615132915.83940-1-dalvarez@redhat.com \
    --to=dalvarez@redhat.com \
    --cc=jkbs@redhat.com \
    --cc=libc-alpha@sourceware.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).