zebra: Cleanup zebra_static CLANG/SA issues.

When compiling using CLANG's SA, cleanup the
SA issues found.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2016-11-12 22:12:13 -05:00
parent 27bc3ae3d4
commit 8e7702bc34
7 changed files with 48 additions and 18 deletions

View 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;

View 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;

View 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;
}

View 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)

View 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.

View 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;

View 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;