]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: Cleanup zebra_static CLANG/SA issues.
authorDonald Sharp <sharpd@cumulusnetworks.com>
Sun, 13 Nov 2016 03:12:13 +0000 (22:12 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 17 Jan 2017 23:45:02 +0000 (18:45 -0500)
When compiling using CLANG's SA, cleanup the
SA issues found.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
zebra/kernel_netlink.c
zebra/zebra_fpm.c
zebra/zebra_fpm_netlink.c
zebra/zebra_static.c
zebra/zebra_static.h
zebra/zebra_vty.c
zebra/zserv.c

index 20c4b5afe2d8fe1c48d6f6cafd2f535276cd25f1..02da17af63a56a6724c1f9862046c2c4858ccb58 100644 (file)
@@ -337,7 +337,12 @@ addattr_l (struct nlmsghdr *n, unsigned int maxlen, int type,
   rta = (struct rtattr *) (((char *) n) + NLMSG_ALIGN (n->nlmsg_len));
   rta->rta_type = type;
   rta->rta_len = len;
-  memcpy (RTA_DATA (rta), data, alen);
+
+  if (data)
+    memcpy (RTA_DATA (rta), data, alen);
+  else
+    assert (len == 0);
+
   n->nlmsg_len = NLMSG_ALIGN (n->nlmsg_len) + RTA_ALIGN (len);
 
   return 0;
@@ -358,7 +363,12 @@ rta_addattr_l (struct rtattr *rta, unsigned int maxlen, int type,
   subrta = (struct rtattr *) (((char *) rta) + RTA_ALIGN (rta->rta_len));
   subrta->rta_type = type;
   subrta->rta_len = len;
-  memcpy (RTA_DATA (subrta), data, alen);
+
+  if (data)
+    memcpy (RTA_DATA (subrta), data, alen);
+  else
+    assert (len == 0);
+
   rta->rta_len = NLMSG_ALIGN (rta->rta_len) + RTA_ALIGN (len);
 
   return 0;
index 80512c71f62c7bf541837d68b941a4e6daad13a5..8b337152b4936266496d2b429671aba079195b69 100644 (file)
@@ -1622,14 +1622,16 @@ zfpm_init_message_format (const char *format)
 {
   int have_netlink, have_protobuf;
 
-  have_netlink = have_protobuf = 0;
-
 #ifdef HAVE_NETLINK
   have_netlink = 1;
+#else
+  have_netlink = 0;
 #endif
 
 #ifdef HAVE_PROTOBUF
   have_protobuf = 1;
+#else
+  have_protobuf = 0;
 #endif
 
   zfpm_g->message_format = ZFPM_MSG_FORMAT_NONE;
index 0d9f809328a09140228404b1b2ba1f600be58a3f..2c781899f4cea5b5f8075887315f61cdd9df0428 100644 (file)
@@ -251,10 +251,15 @@ netlink_route_info_fill (netlink_route_info_t *ri, int cmd,
    * particularly in our communication with the FPM.
    */
   if (cmd == RTM_DELROUTE && !rib)
-    goto skip;
+    return 1;
 
-  if (rib)
-    ri->rtm_protocol = netlink_proto_from_route_type (rib->type);
+  if (!rib)
+    {
+      zfpm_debug ("%s: Expected non-NULL rib pointer", __PRETTY_FUNCTION__);
+      return 0;
+    }
+
+  ri->rtm_protocol = netlink_proto_from_route_type (rib->type);
 
   if ((rib->flags & ZEBRA_FLAG_BLACKHOLE) || (rib->flags & ZEBRA_FLAG_REJECT))
     discard = 1;
@@ -279,9 +284,7 @@ netlink_route_info_fill (netlink_route_info_t *ri, int cmd,
   ri->metric = &rib->metric;
 
   if (discard)
-    {
-      goto skip;
-    }
+    return 1;
 
   for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
     {
@@ -307,7 +310,6 @@ netlink_route_info_fill (netlink_route_info_t *ri, int cmd,
       return 0;
     }
 
- skip:
   return 1;
 }
 
index b323950064f2021d40509973ce60a5d0c7e14852..7d104f30d98a7e0fc494d1df56fed30fb8f254e3 100644 (file)
@@ -50,6 +50,8 @@ static_install_route (afi_t afi, safi_t safi, struct prefix *p, struct static_ro
   if (! table)
     return;
 
+  memset (&nh_p, 0, sizeof (nh_p));
+
   /* Lookup existing route */
   rn = route_node_get (table, p);
   RNODE_FOREACH_RIB (rn, rib)
index 5e3177e3b82176b6f21ae91d88b1742fccdcfe03..233436f02d59dd52dda5e2323be2286bcfd1d10b 100644 (file)
@@ -31,6 +31,14 @@ struct static_nh_label
   mpls_label_t label[2];
 };
 
+typedef enum {
+  STATIC_IFINDEX,
+  STATIC_IPV4_GATEWAY,
+  STATIC_BLACKHOLE,
+  STATIC_IPV6_GATEWAY,
+  STATIC_IPV6_GATEWAY_IFINDEX,
+} zebra_static_types;
+
 /* Static route information. */
 struct static_route
 {
@@ -48,12 +56,7 @@ struct static_route
   route_tag_t tag;
 
   /* Flag for this static route's type. */
-  u_char type;
-#define STATIC_IFINDEX               1
-#define STATIC_IPV4_GATEWAY          2
-#define STATIC_BLACKHOLE             3
-#define STATIC_IPV6_GATEWAY          4
-#define STATIC_IPV6_GATEWAY_IFINDEX  5
+  zebra_static_types type;
 
   /*
    * Nexthop value.
index 0ff54f0cbb9e0be9e1ace0f623b4a9a1de4e83c1..113b063913361ca80b9342000e6a00b020557405 100644 (file)
@@ -2282,6 +2282,14 @@ static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd)
               case STATIC_BLACKHOLE:
                 vty_out (vty, " Null0");
                 break;
+             case STATIC_IPV6_GATEWAY:
+               vty_out (vty, " %s", inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ));
+               break;
+             case STATIC_IPV6_GATEWAY_IFINDEX:
+               vty_out (vty, " %s %s",
+                        inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ),
+                        ifindex2ifname_vrf (si->ifindex, si->vrf_id));
+               break;
               }
 
             /* flags are incompatible with STATIC_BLACKHOLE */
@@ -3591,6 +3599,9 @@ static_config_ipv6 (struct vty *vty)
 
            switch (si->type)
              {
+             case STATIC_IPV4_GATEWAY:
+                vty_out (vty, " %s", inet_ntoa (si->addr.ipv4));
+                break;
              case STATIC_IPV6_GATEWAY:
                vty_out (vty, " %s", inet_ntop (AF_INET6, &si->addr.ipv6, buf, BUFSIZ));
                break;
index a736577a3c548aa803970d8559366d845f827f6b..6a15b9a2513b50352406ccaa69d0755bda68bb40 100644 (file)
@@ -1519,7 +1519,7 @@ zread_ipv6_delete (struct zserv *client, u_short length, struct zebra_vrf *zvrf)
   struct stream *s;
   struct zapi_ipv6 api;
   struct in6_addr nexthop;
-  union g_addr *pnexthop;
+  union g_addr *pnexthop = NULL;
   unsigned long ifindex;
   struct prefix p;