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