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