vppinfra: fix coverity issue CID 323952
[vpp.git] / test / test_neighbor.py
index 64be36d..24737da 100644 (file)
@@ -4,7 +4,7 @@ import unittest
 import os
 from socket import AF_INET, AF_INET6, inet_pton
 
-from framework import tag_fixme_vpp_workers
+from framework import tag_fixme_vpp_workers, tag_fixme_ubuntu2204, tag_fixme_debian11
 from framework import VppTestCase, VppTestRunner
 from vpp_neighbor import VppNeighbor, find_nbr
 from vpp_ip_route import (
@@ -1762,6 +1762,10 @@ class ARPTestCase(VppTestCase):
         #
         self.pg2.configure_ipv4_neighbors()
 
+        cntr = self.statistics.get_err_counter(
+            "/err/arp-reply/l3_dst_address_not_local"
+        )
+
         for op in ["is-at", "who-has"]:
             p1 = [
                 (
@@ -1793,10 +1797,8 @@ class ARPTestCase(VppTestCase):
 
         # they are all dropped because the subnet's don't match
         self.assertEqual(
-            4,
-            self.statistics.get_err_counter(
-                "/err/arp-reply/IP4 destination address not local to subnet"
-            ),
+            cntr + 4,
+            self.statistics.get_err_counter("/err/arp-reply/l3_dst_address_not_local"),
         )
 
     def test_arp_incomplete2(self):
@@ -2067,6 +2069,28 @@ class ARPTestCase(VppTestCase):
         for rx in rxs:
             self.verify_arp_req(rx, self.pg1.local_mac, "10.0.1.2", "10.0.1.128")
 
+        # apply an attached prefix to the interface
+        # since there's no local address in this prefix,
+        # any other address is used
+        p3 = (
+            Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
+            / IP(src=self.pg1.remote_ip4, dst="10.0.2.128")
+            / Raw(b"0x5" * 100)
+        )
+
+        VppIpRoute(
+            self,
+            "10.0.2.0",
+            24,
+            [VppRoutePath("0.0.0.0", self.pg1.sw_if_index)],
+        ).add_vpp_config()
+
+        rxs = self.send_and_expect(self.pg0, [p3], self.pg1)
+        for rx in rxs:
+            self.verify_arp_req(
+                rx, self.pg1.local_mac, self.pg1.local_ip4, "10.0.2.128"
+            )
+
         # cleanup
         conn3.remove_vpp_config()
         conn2.remove_vpp_config()
@@ -2194,6 +2218,7 @@ class NeighborStatsTestCase(VppTestCase):
         self.assertEqual(NUM_PKTS + 16, nd1.get_stats()["packets"])
 
 
+@tag_fixme_ubuntu2204
 class NeighborAgeTestCase(VppTestCase):
     """ARP/ND Aging"""
 
@@ -2244,6 +2269,14 @@ class NeighborAgeTestCase(VppTestCase):
         self.assertEqual(arp.psrc, sip)
         self.assertEqual(arp.pdst, dip)
 
+    def verify_ip_neighbor_config(self, af, max_number, max_age, recycle):
+        config = self.vapi.ip_neighbor_config_get(af)
+
+        self.assertEqual(config.af, af)
+        self.assertEqual(config.max_number, max_number)
+        self.assertEqual(config.max_age, max_age)
+        self.assertEqual(config.recycle, recycle)
+
     def test_age(self):
         """Aging/Recycle"""
 
@@ -2259,6 +2292,13 @@ class NeighborAgeTestCase(VppTestCase):
         #
         self.pg_enable_capture(self.pg_interfaces)
 
+        #
+        # Verify neighbor configuration defaults
+        #
+        self.verify_ip_neighbor_config(
+            af=vaf.ADDRESS_IP4, max_number=50000, max_age=0, recycle=False
+        )
+
         #
         # Set the neighbor configuration:
         #   limi = 200
@@ -2268,6 +2308,9 @@ class NeighborAgeTestCase(VppTestCase):
         self.vapi.ip_neighbor_config(
             af=vaf.ADDRESS_IP4, max_number=200, max_age=0, recycle=False
         )
+        self.verify_ip_neighbor_config(
+            af=vaf.ADDRESS_IP4, max_number=200, max_age=0, recycle=False
+        )
 
         self.vapi.cli("sh ip neighbor-config")
 
@@ -2295,6 +2338,9 @@ class NeighborAgeTestCase(VppTestCase):
         self.vapi.ip_neighbor_config(
             af=vaf.ADDRESS_IP4, max_number=200, max_age=0, recycle=True
         )
+        self.verify_ip_neighbor_config(
+            af=vaf.ADDRESS_IP4, max_number=200, max_age=0, recycle=True
+        )
 
         # now new additions are allowed
         VppNeighbor(
@@ -2318,6 +2364,9 @@ class NeighborAgeTestCase(VppTestCase):
         self.vapi.ip_neighbor_config(
             af=vaf.ADDRESS_IP4, max_number=200, max_age=2, recycle=True
         )
+        self.verify_ip_neighbor_config(
+            af=vaf.ADDRESS_IP4, max_number=200, max_age=2, recycle=True
+        )
 
         self.vapi.cli("sh ip4 neighbor-sorted")
 
@@ -2396,6 +2445,9 @@ class NeighborAgeTestCase(VppTestCase):
         self.vapi.ip_neighbor_config(
             af=vaf.ADDRESS_IP4, max_number=200, max_age=1000, recycle=True
         )
+        self.verify_ip_neighbor_config(
+            af=vaf.ADDRESS_IP4, max_number=200, max_age=1000, recycle=True
+        )
 
         #
         # load up some neighbours again, then disable the aging
@@ -2411,6 +2463,9 @@ class NeighborAgeTestCase(VppTestCase):
         self.vapi.ip_neighbor_config(
             af=vaf.ADDRESS_IP4, max_number=200, max_age=0, recycle=False
         )
+        self.verify_ip_neighbor_config(
+            af=vaf.ADDRESS_IP4, max_number=200, max_age=0, recycle=False
+        )
 
         self.virtual_sleep(10)
         self.assertTrue(