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