6ca6e8
commit 2b3d020055bea4fbbfc0ca2362d46038487c6dfd
6ca6e8
Author: Fabian Vogt <fvogt@suse.de>
6ca6e8
Date:   Wed Jul 27 11:44:07 2022 +0200
6ca6e8
6ca6e8
    nscd: Fix netlink cache invalidation if epoll is used [BZ #29415]
6ca6e8
    
6ca6e8
    Processes cache network interface information such as whether IPv4 or IPv6
6ca6e8
    are enabled. This is only checked again if the "netlink timestamp" provided
6ca6e8
    by nscd changed, which is triggered by netlink socket activity.
6ca6e8
    
6ca6e8
    However, in the epoll handler for the netlink socket, it was missed to
6ca6e8
    assign the new timestamp to the nscd database. The handler for plain poll
6ca6e8
    did that properly, copy that over.
6ca6e8
    
6ca6e8
    This bug caused that e.g. processes which started before network
6ca6e8
    configuration got unusuable addresses from getaddrinfo, like IPv6 only even
6ca6e8
    though only IPv4 is available:
6ca6e8
    https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1041
6ca6e8
    
6ca6e8
    It's a bit hard to reproduce, so I verified this by checking the timestamp
6ca6e8
    on calls to __check_pf manually. Without this patch it's stuck at 1, now
6ca6e8
    it's increasing on network changes as expected.
6ca6e8
    
6ca6e8
    Signed-off-by: Fabian Vogt <fvogt@suse.de>
6ca6e8
    (cherry picked from commit 02ca25fef2785974011e9c5beecc99b900b69fd7)
6ca6e8
6ca6e8
diff --git a/nscd/connections.c b/nscd/connections.c
6ca6e8
index 3f0bda4e97edb9df..bc941715cff47c49 100644
6ca6e8
--- a/nscd/connections.c
6ca6e8
+++ b/nscd/connections.c
6ca6e8
@@ -2285,7 +2285,8 @@ main_loop_epoll (int efd)
6ca6e8
 					     sizeof (buf))) != -1)
6ca6e8
 	      ;
6ca6e8
 
6ca6e8
-	    __bump_nl_timestamp ();
6ca6e8
+	    dbs[hstdb].head->extra_data[NSCD_HST_IDX_CONF_TIMESTAMP]
6ca6e8
+	      = __bump_nl_timestamp ();
6ca6e8
 	  }
6ca6e8
 # endif
6ca6e8
 	else