IGMP: coverity fixes and remove checks for scapy IGMPv3 76/11276/3
authorNeale Ranns <neale.ranns@cisco.com>
Wed, 21 Mar 2018 23:34:28 +0000 (16:34 -0700)
committerDamjan Marion <dmarion.lists@gmail.com>
Fri, 23 Mar 2018 03:55:54 +0000 (03:55 +0000)
Change-Id: Ic2eddc803f9ba8215e37388a686004830211cf6f
Signed-off-by: Neale Ranns <neale.ranns@cisco.com>
src/plugins/igmp/igmp.c
src/plugins/igmp/igmp.h
test/test_igmp.py

index 97baae5..e98e976 100644 (file)
@@ -206,7 +206,7 @@ ip4_lookup (ip4_address_t * a, igmp_membership_report_v3_t * igmp, u16 n,
 
   for (i = 0; i < n; i++)
     {
-      if ((!ip4_address_compare (a, &group_ptr (igmp, l)->dst_address)) &&
+      if ((!ip4_address_compare (a, &(group_ptr (igmp, l)->dst_address))) &&
          (type == group_ptr (igmp, l)->type))
        {
          rv = 1;
@@ -549,12 +549,11 @@ igmp_timer_process (vlib_main_t * vm, vlib_node_runtime_t * rt,
   igmp_main_t *im = &igmp_main;
   uword *event_data = 0, event_type;
   f64 time_start;
-  u8 enabled = 0;
   igmp_timer_t *timer = NULL;
 
   while (1)
     {
-      if (enabled)
+      if (NULL != timer)
        vlib_process_wait_for_event_or_clock (vm,
                                              timer->exp_time - time_start);
       else
@@ -571,14 +570,11 @@ igmp_timer_process (vlib_main_t * vm, vlib_node_runtime_t * rt,
       DBG ("time: %f", vlib_time_now (vm));
 
       /* timer expired */
-      timer->func (vm, rt, im, timer);
+      if (NULL != timer)
+       timer->func (vm, rt, im, timer);
 
     next_timer:
       timer = igmp_get_next_timer (im);
-      if (timer == NULL)
-       enabled = 0;
-      else
-       enabled = 1;
     }
   return 0;
 }
index c98cbd1..0dcf11f 100644 (file)
@@ -36,7 +36,7 @@
 #define DBG(...)
 #endif /* IGMP_DBG */
 
-#define group_ptr(p, l) ((igmp_membership_group_v3_t *)((void*)p + l))
+#define group_ptr(p, l) ((igmp_membership_group_v3_t *)((char*)p + l))
 
 enum
 {
index 62b1c96..e741e6b 100644 (file)
@@ -13,17 +13,6 @@ from scapy.contrib.igmpv3 import *
 from scapy.contrib.igmp import *
 
 
-def checkIGMPv3():
-    try:
-        tmp = IGMPv3()
-        tmp = IGMPv3mr()
-        tmp = IGMPv3gr()
-        tmp = IGMPv3mq()
-    except NameError:
-        return False
-    return True
-
-
 class TestIgmp(VppTestCase):
     """ IGMP Test Case """
 
@@ -52,7 +41,6 @@ class TestIgmp(VppTestCase):
         self.pg_enable_capture(self.pg_interfaces)
         self.pg_start()
 
-    @unittest.skipUnless(checkIGMPv3(), "missing scapy igmpv3 implementation")
     def test_igmp_parse_report(self):
         """ IGMP parse Membership Report """
 
@@ -148,7 +136,6 @@ class TestIgmp(VppTestCase):
         self.assertEqual(igmp.type, 0x11)
         self.assertEqual(igmp.gaddr, "0.0.0.0")
 
-    @unittest.skipUnless(checkIGMPv3(), "missing scapy igmpv3 implementation")
     def test_igmp_send_query(self):
         """ IGMP send General Query """
 
@@ -178,7 +165,7 @@ class TestIgmp(VppTestCase):
         self.sleep(10)
         self.assertFalse(self.vapi.igmp_dump())
 
-    @unittest.skipUnless(checkIGMPv3(), "missing scapy igmpv3 implementation")
+    @unittest.skipUnless(running_extended_tests(), "part of extended tests")
     def test_igmp_src_exp(self):
         """ IGMP per source timer """
 
@@ -238,7 +225,6 @@ class TestIgmp(VppTestCase):
         self.logger.error(self.vapi.cli("sh igmp config"))
         self.assertFalse(self.vapi.igmp_dump())
 
-    @unittest.skipUnless(checkIGMPv3(), "missing scapy igmpv3 implementation")
     def test_igmp_query_resp(self):
         """ IGMP General Query response """
 
@@ -281,7 +267,6 @@ class TestIgmp(VppTestCase):
         self.assertEqual(len(capture[0][IGMPv3gr].srcaddrs), 1)
         self.assertEqual(capture[0][IGMPv3gr].srcaddrs[0], "10.1.1.1")
 
-    @unittest.skipUnless(checkIGMPv3(), "missing scapy igmpv3 implementation")
     def test_igmp_listen(self):
         """ IGMP listen (S,G)s """