]> 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>
Thu, 22 Dec 2016 01:26:15 +0000 (20:26 -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 5dd08ca782d6d6953163c4110f6092808c602ff2..771bd837d858f0200b47f8d05fc6b42504e66323 100644 (file)
@@ -255,10 +255,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;
@@ -283,9 +288,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))
     {
@@ -311,7 +314,6 @@ netlink_route_info_fill (netlink_route_info_t *ri, int cmd,
       return 0;
     }
 
- skip:
   return 1;
 }
 
index e6ae9c71d47a63fb42d05a406f7016c9d2babbf8..d55ec055e67458d99e3a273ee6871a7bc48b6af5 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 1fe55b072e4046e3b5e64cfdd4470e6b21f7e431..0c802fd3dc1d4e254bcc81066110213c09060799 100644 (file)
@@ -2283,6 +2283,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 */
@@ -3595,6 +3603,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 bdfa03e1eee665fb06ff9cb08a2398df4d05cd4d..38680a312e5042cda321906e2d2f0594219e216e 100644 (file)
@@ -1518,7 +1518,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;