ipv4: Invalidate nexthop cache nh_saddr more correctly.
[GitHub/LineageOS/android_kernel_samsung_universal7580.git] / include / net / ip_fib.h
index a1a85803591363bfc2550fb9bd171de4c09c024d..cd92b923a578fa0a13171d50f2c12abdd9c1a92d 100644 (file)
@@ -62,6 +62,7 @@ struct fib_nh {
        int                     nh_oif;
        __be32                  nh_gw;
        __be32                  nh_saddr;
+       int                     nh_saddr_genid;
 };
 
 /*
@@ -141,12 +142,19 @@ struct fib_result_nl {
 
 #endif /* CONFIG_IP_ROUTE_MULTIPATH */
 
-#define FIB_RES_SADDR(res)             (FIB_RES_NH(res).nh_saddr)
+extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
+
+#define FIB_RES_SADDR(net, res)                                \
+       ((FIB_RES_NH(res).nh_saddr_genid ==             \
+         atomic_read(&(net)->ipv4.dev_addr_genid)) ?   \
+        FIB_RES_NH(res).nh_saddr :                     \
+        fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
 #define FIB_RES_GW(res)                        (FIB_RES_NH(res).nh_gw)
 #define FIB_RES_DEV(res)               (FIB_RES_NH(res).nh_dev)
 #define FIB_RES_OIF(res)               (FIB_RES_NH(res).nh_oif)
 
-#define FIB_RES_PREFSRC(res)           ((res).fi->fib_prefsrc ? : FIB_RES_SADDR(res))
+#define FIB_RES_PREFSRC(net, res)      ((res).fi->fib_prefsrc ? : \
+                                        FIB_RES_SADDR(net, res))
 
 struct fib_table {
        struct hlist_node tb_hlist;