Fix coverity issues in DPDK code, fixes VPP-189 98/2398/2
authorDamjan Marion <damarion@cisco.com>
Tue, 16 Aug 2016 11:25:59 +0000 (13:25 +0200)
committerDave Barach <openvpp@barachs.net>
Tue, 16 Aug 2016 13:00:16 +0000 (13:00 +0000)
Change-Id: Ie2ebb29451200158504bda8c616d57821edbd749
Signed-off-by: Damjan Marion <damarion@cisco.com>
vnet/vnet/devices/dpdk/dpdk_priv.h
vnet/vnet/devices/dpdk/format.c
vnet/vnet/devices/dpdk/init.c

index ac49943..d4d1422 100644 (file)
@@ -36,7 +36,6 @@
 #define foreach_eal_double_hyphen_predicate_arg \
 _(no-shconf)                                    \
 _(no-hpet)                                      \
-_(no-pci)                                       \
 _(no-huge)                                      \
 _(vmware-tsc-map)                               \
 _(virtio-vhost)
index 2d41221..075f357 100644 (file)
@@ -657,7 +657,7 @@ static inline u8 * format_dpdk_pkt_types (u8 * s, va_list * va)
 
 static inline u8 * format_dpdk_pkt_offload_flags (u8 * s, va_list * va)
 {
-  u16 *ol_flags = va_arg (*va, u16 *);
+  u64 *ol_flags = va_arg (*va, u64 *);
   uword indent = format_get_indent (s) + 2;
 
   if (!*ol_flags)
index b690dec..239ae3b 100644 (file)
@@ -1042,14 +1042,18 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input)
         ;
       else if (unformat (input, "enable-vhost-user"))
         conf->use_virtio_vhost = 0;
+      else if (unformat (input, "no-pci"))
+       {
+         no_pci = 1;
+         tmp = format (0, "--no-pci%c", 0);
+         vec_add1 (conf->eal_init_args, tmp);
+       }
       else if (unformat (input, "poll-sleep %d", &dm->poll_sleep))
         ;
 
 #define _(a)                                    \
       else if (unformat(input, #a))             \
         {                                       \
-          if (!strncmp(#a, "no-pci", 6))        \
-            no_pci = 1;                         \
           tmp = format (0, "--%s%c", #a, 0);    \
           vec_add1 (conf->eal_init_args, tmp);    \
         }
@@ -1170,8 +1174,11 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input)
           struct stat sb_numa, sb_nonnuma;
 
           p = format(p, numa_path, c);
-          stat(numa_path, &sb_numa);
-          stat(nonnuma_path, &sb_nonnuma);
+          if (stat(numa_path, &sb_numa) < 0)
+            sb_numa.st_mode = 0;
+
+          if (stat(nonnuma_path, &sb_nonnuma) < 0)
+            sb_nonnuma.st_mode = 0;
 
           if (S_ISDIR(sb_numa.st_mode)) {
             path = (char*)format((u8*)path, "%s%s", p, suffix);
@@ -1609,10 +1616,15 @@ dpdk_process (vlib_main_t * vm,
              if (nlink > 0) {
                  vnet_hw_interface_t * bhi;
                  ethernet_interface_t * bei;
+                 int rv;
+
                  /* Get MAC of 1st slave link */
                  rte_eth_macaddr_get(slink[0], (struct ether_addr *)addr);
                  /* Set MAC of bounded interface to that of 1st slave link */
-                 rte_eth_bond_mac_address_set(i, (struct ether_addr *)addr);
+                 rv = rte_eth_bond_mac_address_set(i, (struct ether_addr *)addr);
+                 if (rv < 0)
+                   clib_warning("Failed to set MAC address");
+
                  /* Populate MAC of bonded interface in VPP hw tables */
                  bhi = vnet_get_hw_interface(
                      vnm, dm->devices[i].vlib_hw_if_index);