interface: fix vnet_sw_interface_update_unnumbered

Unless a software interface is actually unnumbered, do not set
ip[46]_main.lookup_main.if_address_pool_index_by_sw_if_index [sw_if_index]
to ~0

Fixes this scenario:

loop create
set int state loop0 up
create sub-interface loop0 1
set interface ip addr loop0.1 192.168.1.1/24
delete sub-interface loop0.1
set int ip addr loop0 192.168.1.1/24

Type: fix

Signed-off-by: Dave Barach <dave@barachs.net>
Change-Id: I46141d862fa57d70b93d7bb0c105403708165264
diff --git a/src/vnet/interface.c b/src/vnet/interface.c
index 278cd6e..44ea52a 100644
--- a/src/vnet/interface.c
+++ b/src/vnet/interface.c
@@ -1639,13 +1639,20 @@
     }
   else
     {
-      si->flags &= ~(VNET_SW_INTERFACE_FLAG_UNNUMBERED);
-      si->unnumbered_sw_if_index = (u32) ~ 0;
+      /*
+       * Unless the interface is actually unnumbered, don't
+       * smash e.g. if_address_pool_index_by_sw_if_index
+       */
+      if (si->flags & VNET_SW_INTERFACE_FLAG_UNNUMBERED)
+	{
+	  si->flags &= ~(VNET_SW_INTERFACE_FLAG_UNNUMBERED);
+	  si->unnumbered_sw_if_index = (u32) ~0;
 
-      ip4_main.lookup_main.if_address_pool_index_by_sw_if_index
-	[unnumbered_sw_if_index] = ~0;
-      ip6_main.lookup_main.if_address_pool_index_by_sw_if_index
-	[unnumbered_sw_if_index] = ~0;
+	  ip4_main.lookup_main
+	    .if_address_pool_index_by_sw_if_index[unnumbered_sw_if_index] = ~0;
+	  ip6_main.lookup_main
+	    .if_address_pool_index_by_sw_if_index[unnumbered_sw_if_index] = ~0;
+	}
     }
 
   if (was_unnum != (si->flags & VNET_SW_INTERFACE_FLAG_UNNUMBERED))