This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] [BZ #21812] getifaddrs() Don't return ifa entries with NULL names



On 15/06/2018 10:29, Daniel Alvarez wrote:
> 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>

We don't use DCO, instead we use copyright assignments. However the
change below seems to fit as a trivial change. 

Patch looks good and I can't think in a easy way to add testcase which
is guarantee to be reproducible (maybe by using a network namespace and
force inject an interface so kernel will set NLM_F_DUMP_INTR?).

> ---
>  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 */
>  
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]