diff options
author | Paul Jakma <paul@opensourcerouting.org> | 2014-09-19 15:42:23 +0200 |
---|---|---|
committer | Daniel Walton <dwalton@cumulusnetworks.com> | 2016-05-26 20:57:39 +0200 |
commit | 1f9a9fffc1cbbdea2b50540cc316b96200d6e48c (patch) | |
tree | ff85e2555401d13df41925a99ccc85927a0bacd6 /bgpd | |
parent | zebra: fix rtnh_len in the rt_netlink messages for multipath case (diff) | |
download | frr-1f9a9fffc1cbbdea2b50540cc316b96200d6e48c.tar.xz frr-1f9a9fffc1cbbdea2b50540cc316b96200d6e48c.zip |
Fix most compiler warnings in default GCC build.
Fix lots of warnings. Some const and type-pun breaks strict-aliasing
warnings left but much reduced.
* bgp_advertise.h: (struct bgp_advertise_fifo) is functionally identical to
(struct fifo), so just use that. Makes it clearer the beginning of
(struct bgp_advertise) is compatible with with (struct fifo), which seems
to be enough for gcc.
Add a BGP_ADV_FIFO_HEAD macro to contain the right cast to try shut up
type-punning breaks strict aliasing warnings.
* bgp_packet.c: Use BGP_ADV_FIFO_HEAD.
(bgp_route_refresh_receive) fix an interesting logic error in
(!ok || (ret != BLAH)) where ret is only well-defined if ok.
* bgp_vty.c: Peer commands should use bgp_vty_return to set their return.
* jhash.{c,h}: Can take const on * args without adding issues & fix warnings.
* libospf.h: LSA sequence numbers use the unsigned range of values, and
constants need to be set to unsigned, or it causes warnings in ospf6d.
* md5.h: signedness of caddr_t is implementation specific, change to an
explicit (uint_8 *), fix sign/unsigned comparison warnings.
* vty.c: (vty_log_fixed) const on level is well-intentioned, but not going
to fly given iov_base.
* workqueue.c: ALL_LIST_ELEMENTS_RO tests for null pointer, which is always
true for address of static variable. Correct but pointless warning in
this case, but use a 2nd pointer to shut it up.
* ospf6_route.h: Add a comment about the use of (struct prefix) to stuff 2
different 32 bit IDs into in (struct ospf6_route), and the resulting
type-pun strict-alias breakage warnings this causes. Need to use 2
different fields to fix that warning?
general:
* remove unused variables, other than a few cases where they serve a
sufficiently useful documentary purpose (e.g. for code that needs
fixing), or they're required dummies. In those cases, try mark them as
unused.
* Remove dead code that can't be reached.
* Quite a few 'no ...' forms of vty commands take arguments, but do not
check the argument matches the command being negated. E.g., should
'distance X <prefix>' succeed if previously 'distance Y <prefix>' was set?
Or should it be required that the distance match the previously configured
distance for the prefix?
Ultimately, probably better to be strict about this. However, changing
from slack to strict might expose problems in command aliases and tools.
* Fix uninitialised use of variables.
* Fix sign/unsigned comparison warnings by making signedness of types consistent.
* Mark functions as static where their use is restricted to the same compilation
unit.
* Add required headers
* Move constants defined in headers into code.
* remove dead, unused functions that have no debug purpose.
(cherry picked from commit 7aa9dcef80b2ce50ecaa77653d87c8b84e009c49)
Conflicts:
bgpd/bgp_advertise.h
bgpd/bgp_mplsvpn.c
bgpd/bgp_nexthop.c
bgpd/bgp_packet.c
bgpd/bgp_route.c
bgpd/bgp_routemap.c
bgpd/bgp_vty.c
lib/command.c
lib/if.c
lib/jhash.c
lib/workqueue.c
ospf6d/ospf6_lsa.c
ospf6d/ospf6_neighbor.h
ospf6d/ospf6_spf.c
ospf6d/ospf6_top.c
ospfd/ospf_api.c
zebra/router-id.c
zebra/rt_netlink.c
zebra/rt_netlink.h
Diffstat (limited to 'bgpd')
-rw-r--r-- | bgpd/bgp_mplsvpn.c | 9 | ||||
-rw-r--r-- | bgpd/bgp_packet.c | 6 | ||||
-rw-r--r-- | bgpd/bgp_route.c | 8 | ||||
-rw-r--r-- | bgpd/bgp_routemap.c | 3 | ||||
-rw-r--r-- | bgpd/bgp_vty.c | 12 | ||||
-rw-r--r-- | bgpd/bgpd.c | 11 | ||||
-rw-r--r-- | bgpd/bgpd.h | 4 |
7 files changed, 36 insertions, 17 deletions
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index 31ec6947a..2510e2e04 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -130,6 +130,15 @@ bgp_nlri_parse_vpnv4 (struct peer *peer, struct attr *attr, pnt += BGP_ADDPATH_ID_LEN; } + if (prefixlen < 88) + { + zlog_err ("prefix length is less than 88: %d", prefixlen); + return -1; + } + + /* XXX: Not doing anything with the label */ + decode_label (pnt); + /* Fetch prefix length. */ prefixlen = *pnt++; p.family = afi2family (packet->afi); diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index 08082161f..025cfbaee 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -1862,8 +1862,8 @@ bgp_route_refresh_receive (struct peer *peer, bgp_size_t size) if (orf_type == ORF_TYPE_PREFIX || orf_type == ORF_TYPE_PREFIX_OLD) { - u_char *p_pnt = stream_pnt (s); - u_char *p_end = stream_pnt (s) + orf_len; + uint8_t *p_pnt = stream_pnt (s); + uint8_t *p_end = stream_pnt (s) + orf_len; struct orf_prefix orfp; u_char common = 0; u_int32_t seq; @@ -1956,7 +1956,7 @@ bgp_route_refresh_receive (struct peer *peer, bgp_size_t size) (common & ORF_COMMON_PART_DENY ? 0 : 1 ), (common & ORF_COMMON_PART_REMOVE ? 0 : 1)); - if (!ok || (ret != CMD_SUCCESS)) + if (!ok || (ok && ret != CMD_SUCCESS)) { zlog_info ("%s Received misformatted prefixlist ORF." " Remove All pfxlist", peer->host); diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 581d9db89..74969e0ec 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -13399,6 +13399,7 @@ bgp_distance_unset (struct vty *vty, const char *distance_str, const char *ip_str, const char *access_list_str) { int ret; + int distance; struct prefix_ipv4 p; struct bgp_node *rn; struct bgp_distance *bdistance; @@ -13418,6 +13419,13 @@ bgp_distance_unset (struct vty *vty, const char *distance_str, } bdistance = rn->info; + distance = atoi(distance_str); + + if (bdistance->distance != distance) + { + vty_out (vty, "Distance does not match configured%s", VTY_NEWLINE); + return CMD_WARNING; + } if (bdistance->access_list) XFREE(MTYPE_AS_LIST, bdistance->access_list); diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index ad154389e..ab22a455d 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -2100,6 +2100,7 @@ static route_map_result_t route_match_ipv6_next_hop (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { + struct in6_addr *addr = rule; struct bgp_info *bgp_info; if (type == RMAP_BGP) @@ -2109,7 +2110,7 @@ route_match_ipv6_next_hop (void *rule, struct prefix *prefix, if (!bgp_info->attr->extra) return RMAP_NOMATCH; - if (IPV6_ADDR_SAME (&bgp_info->attr->extra->mp_nexthop_global, rule)) + if (IPV6_ADDR_SAME (&bgp_info->attr->extra->mp_nexthop_global, addr)) return RMAP_MATCH; if (bgp_info->attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL && diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index ad04308f0..825f5954c 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -4662,6 +4662,7 @@ static int peer_weight_set_vty (struct vty *vty, const char *ip_str, const char *weight_str) { + int ret; struct peer *peer; unsigned long weight; @@ -4671,23 +4672,22 @@ peer_weight_set_vty (struct vty *vty, const char *ip_str, VTY_GET_INTEGER_RANGE("weight", weight, weight_str, 0, 65535); - peer_weight_set (peer, weight); - - return CMD_SUCCESS; + ret = peer_weight_set (peer, weight); + return bgp_vty_return (vty, ret); } static int peer_weight_unset_vty (struct vty *vty, const char *ip_str) { + int ret; struct peer *peer; peer = peer_and_group_lookup_vty (vty, ip_str); if (! peer) return CMD_WARNING; - peer_weight_unset (peer); - - return CMD_SUCCESS; + ret = peer_weight_unset (peer); + return bgp_vty_return (vty, ret); } DEFUN (neighbor_weight, diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 61bed4fc5..36ab3e5fa 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -4421,7 +4421,7 @@ peer_port_unset (struct peer *peer) } /* neighbor weight. */ -void +int peer_weight_set (struct peer *peer, u_int16_t weight) { struct peer_group *group; @@ -4431,7 +4431,7 @@ peer_weight_set (struct peer *peer, u_int16_t weight) peer->weight = weight; if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) - return; + return 0; /* peer-group member updates. */ group = peer->group; @@ -4439,9 +4439,10 @@ peer_weight_set (struct peer *peer, u_int16_t weight) { peer->weight = group->conf->weight; } + return 1; } -void +int peer_weight_unset (struct peer *peer) { struct peer_group *group; @@ -4456,7 +4457,7 @@ peer_weight_unset (struct peer *peer) UNSET_FLAG (peer->config, PEER_CONFIG_WEIGHT); if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) - return; + return 0; /* peer-group member updates. */ group = peer->group; @@ -4464,7 +4465,7 @@ peer_weight_unset (struct peer *peer) { peer->weight = 0; } - return; + return 1; } int diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 20f23e73c..1e7a00628 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -1268,8 +1268,8 @@ extern int peer_default_originate_unset (struct peer *, afi_t, safi_t); extern int peer_port_set (struct peer *, u_int16_t); extern int peer_port_unset (struct peer *); -extern void peer_weight_set (struct peer *, u_int16_t); -extern void peer_weight_unset (struct peer *); +extern int peer_weight_set (struct peer *, u_int16_t); +extern int peer_weight_unset (struct peer *); extern int peer_timers_set (struct peer *, u_int32_t, u_int32_t); extern int peer_timers_unset (struct peer *); |