VPP-142 - Follow up fix for shared_count in indirect adjacencies 78/2078/1
authorJohn Lo <loj@cisco.com>
Mon, 25 Jul 2016 18:34:48 +0000 (14:34 -0400)
committerJohn Lo <loj@cisco.com>
Mon, 25 Jul 2016 18:34:48 +0000 (14:34 -0400)
Change-Id: Ia2d0351ffd40c75cbf9611e00a7e111189ad70b5
Signed-off-by: John Lo <loj@cisco.com>
vnet/vnet/ip/ip4_forward.c
vnet/vnet/ip/ip6_forward.c

index 97e472b..d2e761f 100644 (file)
@@ -455,8 +455,11 @@ ip4_add_del_route_next_hop (ip4_main_t * im,
 
       ip4_add_del_route (im, &a);
 
-      /* adjust share count. This cannot be the only use of the adjacency */
-      nh_adj->share_count += is_del ? -1 : 1;
+      /* adjust share count. This cannot be the only use of the adjacency 
+         unless next hop is an indiect adj where share count is already
+         incremented */
+      if (next_hop_sw_if_index != ~0) 
+       nh_adj->share_count += is_del ? -1 : 1;
         
       goto done;
     }
index 80156e0..823daa6 100644 (file)
@@ -516,8 +516,12 @@ ip6_add_del_route_next_hop (ip6_main_t * im,
     a.n_add_adj = 0;
 
     ip6_add_del_route (im, &a);
-    /* adjust share count. This cannot be the only use of the adjacency */
-    nh_adj->share_count += is_del ? -1 : 1;
+
+    /* adjust share count. This cannot be the only use of the adjacency 
+       unless next hop is an indiect adj where share count is already
+       incremented */
+    if (next_hop_sw_if_index != ~0) 
+      nh_adj->share_count += is_del ? -1 : 1;
 
     goto done;
   }