From: Donald Sharp Date: Sun, 13 Nov 2016 03:12:13 +0000 (-0500) Subject: zebra: Cleanup zebra_static CLANG/SA issues. X-Git-Tag: frr-3.0-branchpoint~64^2~10^2~97 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=8e7702bc34d71064e4c2f137021c4efa4c8d2f64;p=mirror%2Ffrr.git zebra: Cleanup zebra_static CLANG/SA issues. When compiling using CLANG's SA, cleanup the SA issues found. Signed-off-by: Donald Sharp --- diff --git a/zebra/kernel_netlink.c b/zebra/kernel_netlink.c index 20c4b5afe2..02da17af63 100644 --- a/zebra/kernel_netlink.c +++ b/zebra/kernel_netlink.c @@ -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; diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c index 80512c71f6..8b337152b4 100644 --- a/zebra/zebra_fpm.c +++ b/zebra/zebra_fpm.c @@ -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; diff --git a/zebra/zebra_fpm_netlink.c b/zebra/zebra_fpm_netlink.c index 5dd08ca782..771bd837d8 100644 --- a/zebra/zebra_fpm_netlink.c +++ b/zebra/zebra_fpm_netlink.c @@ -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; } diff --git a/zebra/zebra_static.c b/zebra/zebra_static.c index e6ae9c71d4..d55ec055e6 100644 --- a/zebra/zebra_static.c +++ b/zebra/zebra_static.c @@ -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) diff --git a/zebra/zebra_static.h b/zebra/zebra_static.h index 5e3177e3b8..233436f02d 100644 --- a/zebra/zebra_static.h +++ b/zebra/zebra_static.h @@ -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. diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 1fe55b072e..0c802fd3dc 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -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; diff --git a/zebra/zserv.c b/zebra/zserv.c index bdfa03e1ee..38680a312e 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -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;