IP table bind allowed only if table exists 43/12643/2
authorNeale Ranns <neale.ranns@cisco.com>
Thu, 17 May 2018 13:34:24 +0000 (06:34 -0700)
committerDave Barach <openvpp@barachs.net>
Fri, 18 May 2018 12:15:27 +0000 (12:15 +0000)
Change-Id: If01400e3434b25b2da36ba28ceb8444b216d0e38
Signed-off-by: Neale Ranns <neale.ranns@cisco.com>
src/vnet/interface_api.c
test/test_gbp.py
test/test_srv6.py

index 8d982e3..9a1838f 100644 (file)
@@ -381,31 +381,16 @@ ip_table_bind (fib_protocol_t fproto,
       msrc = MFIB_SOURCE_CLI;
     }
 
-  /*
-   * This is temporary whilst I do the song and dance with the CSIT version
-   */
-  if (0 != table_id)
-    {
-      fib_index = fib_table_find_or_create_and_lock (fproto, table_id, src);
-      mfib_index =
-       mfib_table_find_or_create_and_lock (fproto, table_id, msrc);
-    }
-  else
-    {
-      fib_index = 0;
-      mfib_index = 0;
-    }
-
   /*
    * This if table does not exist = error is what we want in the end.
    */
-  /* fib_index = fib_table_find (fproto, table_id); */
-  /* mfib_index = mfib_table_find (fproto, table_id); */
+  fib_index = fib_table_find (fproto, table_id);
+  mfib_index = mfib_table_find (fproto, table_id);
 
-  /* if (~0 == fib_index || ~0 == mfib_index) */
-  /*   { */
-  /*     return (VNET_API_ERROR_NO_SUCH_FIB); */
-  /*   } */
+  if (~0 == fib_index || ~0 == mfib_index)
+    {
+      return (VNET_API_ERROR_NO_SUCH_FIB);
+    }
 
   if (FIB_PROTOCOL_IP6 == fproto)
     {
@@ -513,15 +498,6 @@ ip_table_bind (fib_protocol_t fproto,
       ip4_main.mfib_index_by_sw_if_index[sw_if_index] = mfib_index;
     }
 
-  /*
-   * Temporary. undo the locks from the find and create at the staart
-   */
-  if (0 != table_id)
-    {
-      fib_table_unlock (fib_index, fproto, src);
-      mfib_table_unlock (mfib_index, fproto, msrc);
-    }
-
   return (0);
 }
 
index 3d9ebbc..fe19ae6 100644 (file)
@@ -413,6 +413,8 @@ class TestGBP(VppTestCase):
 
         nat_table = VppIpTable(self, 20)
         nat_table.add_vpp_config()
+        nat_table = VppIpTable(self, 20, is_ip6=True)
+        nat_table.add_vpp_config()
 
         #
         # Bridge Domains
index fda24b4..b64d3bc 100644 (file)
@@ -5,7 +5,7 @@ import binascii
 from socket import AF_INET6
 
 from framework import VppTestCase, VppTestRunner
-from vpp_ip_route import VppIpRoute, VppRoutePath, DpoProto
+from vpp_ip_route import VppIpRoute, VppRoutePath, DpoProto, VppIpTable
 from vpp_srv6 import SRv6LocalSIDBehaviors, VppSRv6LocalSID, VppSRv6Policy, \
     SRv6PolicyType, VppSRv6Steering, SRv6PolicySteeringTypes
 
@@ -127,6 +127,8 @@ class TestSRv6(VppTestCase):
             self.logger.debug("Tear down interface %s" % (i.name))
             i.admin_down()
             i.unconfig()
+            i.set_table_ip4(0)
+            i.set_table_ip6(0)
 
     @unittest.skipUnless(0, "PC to fix")
     def test_SRv6_T_Encaps(self):
@@ -856,6 +858,8 @@ class TestSRv6(VppTestCase):
         # source interface in global FIB (0)
         # destination interfaces in global and vrf
         vrf_1 = 1
+        ipt = VppIpTable(self, vrf_1, is_ip6=True)
+        ipt.add_vpp_config()
         self.setup_interfaces(ipv6=[True, True, True],
                               ipv6_table_id=[0, 0, vrf_1])
 
@@ -1007,6 +1011,8 @@ class TestSRv6(VppTestCase):
         # source interface in global FIB (0)
         # destination interfaces in global and vrf
         vrf_1 = 1
+        ipt = VppIpTable(self, vrf_1)
+        ipt.add_vpp_config()
         self.setup_interfaces(ipv6=[True, False, False],
                               ipv4=[False, True, True],
                               ipv6_table_id=[0, 0, 0],