diff options
Diffstat (limited to 'bgpd')
-rw-r--r-- | bgpd/bgp_advertise.h | 17 | ||||
-rw-r--r-- | bgpd/bgp_attr.c | 1 | ||||
-rw-r--r-- | bgpd/bgp_mplsvpn.c | 6 | ||||
-rw-r--r-- | bgpd/bgp_nexthop.c | 35 | ||||
-rw-r--r-- | bgpd/bgp_packet.c | 27 | ||||
-rw-r--r-- | bgpd/bgp_route.c | 23 | ||||
-rw-r--r-- | bgpd/bgp_routemap.c | 14 | ||||
-rw-r--r-- | bgpd/bgp_vty.c | 25 |
8 files changed, 62 insertions, 86 deletions
diff --git a/bgpd/bgp_advertise.h b/bgpd/bgp_advertise.h index 4ebde907..2cf2a29b 100644 --- a/bgpd/bgp_advertise.h +++ b/bgpd/bgp_advertise.h @@ -21,13 +21,6 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #ifndef _QUAGGA_BGP_ADVERTISE_H #define _QUAGGA_BGP_ADVERTISE_H -/* BGP advertise FIFO. */ -struct bgp_advertise_fifo -{ - struct bgp_advertise *next; - struct bgp_advertise *prev; -}; - /* BGP advertise attribute. */ struct bgp_advertise_attr { @@ -44,7 +37,7 @@ struct bgp_advertise_attr struct bgp_advertise { /* FIFO for advertisement. */ - struct bgp_advertise_fifo fifo; + struct fifo fifo; /* Link list for same attribute advertise. */ struct bgp_advertise *next; @@ -97,11 +90,13 @@ struct bgp_adj_in /* BGP advertisement list. */ struct bgp_synchronize { - struct bgp_advertise_fifo update; - struct bgp_advertise_fifo withdraw; - struct bgp_advertise_fifo withdraw_low; + struct fifo update; + struct fifo withdraw; + struct fifo withdraw_low; }; +#define BGP_ADV_FIFO_HEAD(F) ((struct bgp_advertise *)FIFO_HEAD(F)) + /* BGP adjacency linked list. */ #define BGP_INFO_ADD(N,A,TYPE) \ do { \ diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index fcf82551..b62a4f82 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -2110,7 +2110,6 @@ bgp_packet_mpattr_start (struct stream *s, afi_t afi, safi_t safi, case SAFI_UNICAST: case SAFI_MULTICAST: { - unsigned long sizep; struct attr_extra *attre = attr->extra; assert (attr->extra); diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index b0cf2a98..3d2dadef 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -84,7 +84,6 @@ bgp_nlri_parse_vpnv4 (struct peer *peer, struct attr *attr, struct prefix p; int psize; int prefixlen; - u_int32_t label; u_int16_t type; struct rd_as rd_as; struct rd_ip rd_ip; @@ -117,8 +116,9 @@ bgp_nlri_parse_vpnv4 (struct peer *peer, struct attr *attr, zlog_err ("prefix length is less than 88: %d", prefixlen); return -1; } - - label = decode_label (pnt); + + /* XXX: Not doing anything with the label */ + decode_label (pnt); /* Copyr label to prefix. */ tagpnt = pnt;; diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c index 5b1d13ac..6218e670 100644 --- a/bgpd/bgp_nexthop.c +++ b/bgpd/bgp_nexthop.c @@ -789,9 +789,9 @@ zlookup_read (void) uint16_t length; u_char marker; u_char version; - uint16_t command; - int nbytes; - struct in_addr raddr; + uint16_t command __attribute__((unused)); + int nbytes __attribute__((unused)); + struct in_addr raddr __attribute__((unused)); uint32_t metric; int i; u_char nexthop_num; @@ -801,6 +801,7 @@ zlookup_read (void) s = zlookup->ibuf; stream_reset (s); + /* nbytes not being checked */ nbytes = stream_read (s, zlookup->sock, 2); length = stream_getw (s); @@ -814,9 +815,11 @@ zlookup_read (void) __func__, zlookup->sock, marker, version); return NULL; } - + + /* XXX: not checking command */ command = stream_getw (s); + /* XXX: not doing anything with raddr */ raddr.s_addr = stream_get_ipv4 (s); metric = stream_getl (s); nexthop_num = stream_getc (s); @@ -901,8 +904,6 @@ zlookup_read_ipv6 (void) struct stream *s; uint16_t length; u_char version, marker; - uint16_t command; - int nbytes; struct in6_addr raddr; uint32_t metric; int i; @@ -913,10 +914,11 @@ zlookup_read_ipv6 (void) s = zlookup->ibuf; stream_reset (s); - nbytes = stream_read (s, zlookup->sock, 2); + /* XXX: ignoring nbytes, see also zread_lookup */ + stream_read (s, zlookup->sock, 2); length = stream_getw (s); - nbytes = stream_read (s, zlookup->sock, length - 2); + stream_read (s, zlookup->sock, length - 2); marker = stream_getc (s); version = stream_getc (s); @@ -926,9 +928,11 @@ zlookup_read_ipv6 (void) __func__, zlookup->sock, marker, version); return NULL; } - - command = stream_getw (s); + /* XXX: ignoring command */ + stream_getw (s); + + /* XXX: not actually doing anything with raddr */ stream_get (&raddr, s, 16); metric = stream_getl (s); @@ -1014,10 +1018,10 @@ bgp_import_check (struct prefix *p, u_int32_t *igpmetric, { struct stream *s; int ret; - u_int16_t length, command; + u_int16_t length, command __attribute__((unused)); u_char version, marker; - int nbytes; - struct in_addr addr; + int nbytes __attribute__((unused)); + struct in_addr addr __attribute__((unused)); struct in_addr nexthop; u_int32_t metric = 0; u_char nexthop_num; @@ -1063,6 +1067,7 @@ bgp_import_check (struct prefix *p, u_int32_t *igpmetric, stream_reset (s); /* Fetch length. */ + /* XXX: not using nbytes */ nbytes = stream_read (s, zlookup->sock, 2); length = stream_getw (s); @@ -1077,9 +1082,11 @@ bgp_import_check (struct prefix *p, u_int32_t *igpmetric, __func__, zlookup->sock, marker, version); return 0; } - + + /* XXX: not using command */ command = stream_getw (s); + /* XXX: not using addr */ addr.s_addr = stream_get_ipv4 (s); metric = stream_getl (s); nexthop_num = stream_getc (s); diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index 65c6cac1..0fab1b08 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -158,7 +158,7 @@ bgp_update_packet (struct peer *peer, afi_t afi, safi_t safi) snlri = peer->scratch; stream_reset (snlri); - adv = FIFO_HEAD (&peer->sync[afi][safi]->update); + adv = BGP_ADV_FIFO_HEAD (&peer->sync[afi][safi]->update); while (adv) { @@ -331,7 +331,6 @@ bgp_withdraw_packet (struct peer *peer, afi_t afi, safi_t safi) struct bgp_adj_out *adj; struct bgp_advertise *adv; struct bgp_node *rn; - unsigned long pos; bgp_size_t unfeasible_len; bgp_size_t total_attr_len; size_t mp_start = 0; @@ -342,7 +341,7 @@ bgp_withdraw_packet (struct peer *peer, afi_t afi, safi_t safi) s = peer->work; stream_reset (s); - while ((adv = FIFO_HEAD (&peer->sync[afi][safi]->withdraw)) != NULL) + while ((adv = BGP_ADV_FIFO_HEAD (&peer->sync[afi][safi]->withdraw)) != NULL) { assert (adv->rn); adj = adv->adj; @@ -595,7 +594,7 @@ bgp_write_packet (struct peer *peer) for (afi = AFI_IP; afi < AFI_MAX; afi++) for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) { - adv = FIFO_HEAD (&peer->sync[afi][safi]->withdraw); + adv = BGP_ADV_FIFO_HEAD (&peer->sync[afi][safi]->withdraw); if (adv) { s = bgp_withdraw_packet (peer, afi, safi); @@ -607,7 +606,7 @@ bgp_write_packet (struct peer *peer) for (afi = AFI_IP; afi < AFI_MAX; afi++) for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) { - adv = FIFO_HEAD (&peer->sync[afi][safi]->update); + adv = BGP_ADV_FIFO_HEAD (&peer->sync[afi][safi]->update); if (adv) { if (adv->binfo && adv->binfo->uptime < peer->synctime) @@ -663,7 +662,7 @@ bgp_write_proceed (struct peer *peer) for (afi = AFI_IP; afi < AFI_MAX; afi++) for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) - if ((adv = FIFO_HEAD (&peer->sync[afi][safi]->update)) != NULL) + if ((adv = BGP_ADV_FIFO_HEAD (&peer->sync[afi][safi]->update)) != NULL) if (adv->binfo->uptime < peer->synctime) return 1; @@ -2036,7 +2035,6 @@ bgp_route_refresh_receive (struct peer *peer, bgp_size_t size) { afi_t afi; safi_t safi; - u_char reserved; struct stream *s; /* If peer does not have the capability, send notification. */ @@ -2064,7 +2062,8 @@ bgp_route_refresh_receive (struct peer *peer, bgp_size_t size) /* Parse packet. */ afi = stream_getw (s); - reserved = stream_getc (s); + /* reserved byte */ + stream_getc (s); safi = stream_getc (s); if (BGP_DEBUG (normal, NORMAL)) @@ -2116,8 +2115,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; @@ -2157,7 +2156,7 @@ bgp_route_refresh_receive (struct peer *peer, bgp_size_t size) prefix_bgp_orf_remove_all (name); break; } - ok = ((p_end - p_pnt) >= sizeof(u_int32_t)) ; + ok = ((size_t)(p_end - p_pnt) >= sizeof(u_int32_t)) ; if (ok) { memcpy (&seq, p_pnt, sizeof (u_int32_t)); @@ -2209,8 +2208,8 @@ bgp_route_refresh_receive (struct peer *peer, bgp_size_t size) ret = prefix_bgp_orf_set (name, afi, &orfp, (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)) { if (BGP_DEBUG (normal, NORMAL)) zlog_debug ("%s Received misformatted prefixlist ORF." @@ -2246,11 +2245,9 @@ bgp_capability_msg_parse (struct peer *peer, u_char *pnt, bgp_size_t length) struct capability_mp_data mpc; struct capability_header *hdr; u_char action; - struct bgp *bgp; afi_t afi; safi_t safi; - bgp = peer->bgp; end = pnt + length; while (pnt < end) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 04cbb8ab..e7357e54 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -4525,20 +4525,11 @@ bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, struct aspath *asmerge = NULL; struct community *community = NULL; struct community *commerge = NULL; - struct in_addr nexthop; - u_int32_t med = 0; struct bgp_info *ri; struct bgp_info *new; int first = 1; unsigned long match = 0; - /* Record adding route's nexthop and med. */ - if (rinew) - { - nexthop = rinew->attr->nexthop; - med = rinew->attr->med; - } - /* ORIGIN attribute: If at least one route among routes that are aggregated has ORIGIN with the value INCOMPLETE, then the aggregated route must have the ORIGIN attribute with the value @@ -4566,11 +4557,7 @@ bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew, continue; if (! rinew && first) - { - nexthop = ri->attr->nexthop; - med = ri->attr->med; - first = 0; - } + first = 0; #ifdef AGGREGATE_NEXTHOP_CHECK if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop) @@ -11773,7 +11760,13 @@ bgp_distance_unset (struct vty *vty, const char *distance_str, } bdistance = rn->info; - + + if (bdistance->distance != distance) + { + vty_out (vty, "Distance does not match configured%s", VTY_NEWLINE); + return CMD_WARNING; + } + if (bdistance->access_list) free (bdistance->access_list); bgp_distance_free (bdistance); diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index c498f584..06b08592 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -1174,7 +1174,6 @@ route_set_metric (void *rule, struct prefix *prefix, static void * route_set_metric_compile (const char *arg) { - u_int32_t metric; unsigned long larg; char *endptr = NULL; @@ -1185,7 +1184,6 @@ route_set_metric_compile (const char *arg) larg = strtoul (arg, &endptr, 10); if (*endptr != '\0' || errno || larg > UINT32_MAX) return NULL; - metric = larg; } else { @@ -1199,7 +1197,6 @@ route_set_metric_compile (const char *arg) larg = strtoul (arg+1, &endptr, 10); if (*endptr != '\0' || errno || larg > UINT32_MAX) return NULL; - metric = larg; } return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg); @@ -1802,22 +1799,21 @@ 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; + struct in6_addr *addr = rule; struct bgp_info *bgp_info; if (type == RMAP_BGP) { - addr = rule; bgp_info = object; 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 == 32 && - IPV6_ADDR_SAME (&bgp_info->attr->extra->mp_nexthop_local, rule)) + IPV6_ADDR_SAME (&bgp_info->attr->extra->mp_nexthop_local, addr)) return RMAP_MATCH; return RMAP_NOMATCH; @@ -3430,7 +3426,7 @@ DEFUN (set_aggregator_as, "IP address of aggregator\n") { int ret; - as_t as; + as_t as __attribute__((unused)); /* dummy for VTY_GET_INTEGER_RANGE */ struct in_addr address; char *argstr; @@ -3464,7 +3460,7 @@ DEFUN (no_set_aggregator_as, "AS number of aggregator\n") { int ret; - as_t as; + as_t as __attribute__((unused)); /* dummy for VTY_GET_INTEGER_RANGE */ struct in_addr address; char *argstr; diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index a818fe7a..ca44774a 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -576,7 +576,7 @@ DEFUN (no_bgp_confederation_identifier, "AS number\n") { struct bgp *bgp; - as_t as; + as_t as __attribute__((unused)); /* Dummy for VTY_GET_INTEGER_RANGE */ bgp = vty->index; @@ -3205,7 +3205,6 @@ 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; @@ -3215,9 +3214,7 @@ peer_weight_set_vty (struct vty *vty, const char *ip_str, VTY_GET_INTEGER_RANGE("weight", weight, weight_str, 0, 65535); - ret = peer_weight_set (peer, weight); - - return CMD_SUCCESS; + return bgp_vty_return (vty, peer_weight_set (peer, weight)); } static int @@ -3229,9 +3226,7 @@ peer_weight_unset_vty (struct vty *vty, const char *ip_str) if (! peer) return CMD_WARNING; - peer_weight_unset (peer); - - return CMD_SUCCESS; + return bgp_vty_return (vty, peer_weight_unset (peer)); } DEFUN (neighbor_weight, @@ -3371,7 +3366,6 @@ static int peer_timers_connect_set_vty (struct vty *vty, const char *ip_str, const char *time_str) { - int ret; struct peer *peer; u_int32_t connect; @@ -3381,24 +3375,19 @@ peer_timers_connect_set_vty (struct vty *vty, const char *ip_str, VTY_GET_INTEGER_RANGE ("Connect time", connect, time_str, 0, 65535); - ret = peer_timers_connect_set (peer, connect); - - return CMD_SUCCESS; + return bgp_vty_return (vty, peer_timers_connect_set (peer, connect)); } static int peer_timers_connect_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; - ret = peer_timers_connect_unset (peer); - - return CMD_SUCCESS; + return bgp_vty_return (vty, peer_timers_connect_unset (peer)); } DEFUN (neighbor_timers_connect, @@ -3455,7 +3444,7 @@ peer_advertise_interval_vty (struct vty *vty, const char *ip_str, else ret = peer_advertise_interval_unset (peer); - return CMD_SUCCESS; + return bgp_vty_return (vty, ret); } DEFUN (neighbor_advertise_interval, @@ -3505,7 +3494,7 @@ peer_interface_vty (struct vty *vty, const char *ip_str, const char *str) else ret = peer_interface_unset (peer); - return CMD_SUCCESS; + return bgp_vty_return (vty, ret); } DEFUN (neighbor_interface, |