From 62e0464d73a35f9b469936029a500534c6dc9d6e Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 28 Jan 2021 13:53:03 -0500 Subject: [PATCH] bgpd: Remove #if 0 code Remove all dead #if 0 code from bgpd. Signed-off-by: Donald Sharp --- bgpd/bgp_fsm.c | 13 ------------ bgpd/bgp_pbr.c | 13 ------------ bgpd/bgp_route.c | 42 -------------------------------------- bgpd/bgp_updgrp.c | 3 --- bgpd/bgp_updgrp.h | 6 ------ bgpd/bgp_updgrp_packet.c | 37 --------------------------------- bgpd/rfapi/rfapi.c | 17 --------------- bgpd/rfapi/rfapi_private.h | 3 --- 8 files changed, 134 deletions(-) diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index 29573a1957..b69e2d71b6 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -1420,19 +1420,6 @@ int bgp_stop(struct peer *peer) peer->update_time = 0; -/* Until we are sure that there is no problem about prefix count - this should be commented out.*/ -#if 0 - /* Reset prefix count */ - peer->pcount[AFI_IP][SAFI_UNICAST] = 0; - peer->pcount[AFI_IP][SAFI_MULTICAST] = 0; - peer->pcount[AFI_IP][SAFI_LABELED_UNICAST] = 0; - peer->pcount[AFI_IP][SAFI_MPLS_VPN] = 0; - peer->pcount[AFI_IP6][SAFI_UNICAST] = 0; - peer->pcount[AFI_IP6][SAFI_MULTICAST] = 0; - peer->pcount[AFI_IP6][SAFI_LABELED_UNICAST] = 0; -#endif /* 0 */ - if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE) && !(CHECK_FLAG(peer->flags, PEER_FLAG_DELETE))) { peer_delete(peer); diff --git a/bgpd/bgp_pbr.c b/bgpd/bgp_pbr.c index 4f22f5bcfe..171522f8ae 100644 --- a/bgpd/bgp_pbr.c +++ b/bgpd/bgp_pbr.c @@ -2845,19 +2845,6 @@ static void bgp_pbr_handle_entry(struct bgp *bgp, struct bgp_path_info *path, zlog_warn("PBR: Sample action Ignored"); } } -#if 0 - if (api->actions[i].u.za.filter - & TRAFFIC_ACTION_DISTRIBUTE) { - if (BGP_DEBUG(pbr, PBR)) { - bgp_pbr_print_policy_route(api); - zlog_warn("PBR: Distribute action Applies"); - } - continue_loop = 0; - /* continue forwarding entry as before - * no action - */ - } -#endif /* XXX to confirm behaviour of traffic action. for now , ignore */ /* terminate action: run other filters */ break; diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 76d500f2df..0ac9a42dc5 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -12314,22 +12314,6 @@ struct bgp_table_stats { double total_space; }; -#if 0 -#define TALLY_SIGFIG 100000 -static unsigned long -ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval) -{ - unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG); - unsigned long res = (newtot * TALLY_SIGFIG) / count; - unsigned long ret = newtot / count; - - if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2)) - return ret + 1; - else - return ret; -} -#endif - static void bgp_table_stats_rn(struct bgp_dest *dest, struct bgp_dest *top, struct bgp_table_stats *ts, unsigned int space) { @@ -12344,13 +12328,6 @@ static void bgp_table_stats_rn(struct bgp_dest *dest, struct bgp_dest *top, ts->counts[BGP_STATS_PREFIXES]++; ts->counts[BGP_STATS_TOTPLEN] += rn_p->prefixlen; -#if 0 - ts->counts[BGP_STATS_AVGPLEN] - = ravg_tally (ts->counts[BGP_STATS_PREFIXES], - ts->counts[BGP_STATS_AVGPLEN], - rn_p->prefixlen); -#endif - /* check if the prefix is included by any other announcements */ while (pdest && !bgp_dest_has_bgp_path_info_data(pdest)) pdest = bgp_dest_parent_nolock(pdest); @@ -12387,16 +12364,6 @@ static void bgp_table_stats_rn(struct bgp_dest *dest, struct bgp_dest *top, ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops; ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size; -#if 0 - ts->counts[BGP_STATS_ASPATH_AVGHOPS] - = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], - ts->counts[BGP_STATS_ASPATH_AVGHOPS], - hops); - ts->counts[BGP_STATS_ASPATH_AVGSIZE] - = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT], - ts->counts[BGP_STATS_ASPATH_AVGSIZE], - size); -#endif if (highest > ts->counts[BGP_STATS_ASN_HIGHEST]) ts->counts[BGP_STATS_ASN_HIGHEST] = highest; } @@ -12506,15 +12473,6 @@ static int bgp_table_stats_single(struct vty *vty, struct bgp *bgp, afi_t afi, continue; switch (i) { -#if 0 - case BGP_STATS_ASPATH_AVGHOPS: - case BGP_STATS_ASPATH_AVGSIZE: - case BGP_STATS_AVGPLEN: - vty_out (vty, "%-30s: ", table_stats_strs[i]); - vty_out (vty, "%12.2f", - (float)ts.counts[i] / (float)TALLY_SIGFIG); - break; -#endif case BGP_STATS_ASPATH_TOTHOPS: case BGP_STATS_ASPATH_TOTSIZE: if (!json) { diff --git a/bgpd/bgp_updgrp.c b/bgpd/bgp_updgrp.c index 059e05ef71..621a14014f 100644 --- a/bgpd/bgp_updgrp.c +++ b/bgpd/bgp_updgrp.c @@ -909,7 +909,6 @@ static void update_subgroup_add_peer(struct update_subgroup *subgrp, bpacket_add_peer(pkt, paf); - bpacket_queue_sanity_check(SUBGRP_PKTQ(subgrp)); if (BGP_DEBUG(update_groups, UPDATE_GROUPS)) zlog_debug("peer %s added to subgroup s%" PRIu64, paf->peer->host, subgrp->id); @@ -1229,8 +1228,6 @@ static int update_subgroup_copy_packets(struct update_subgroup *dest, pkt = bpacket_next(pkt); } - bpacket_queue_sanity_check(SUBGRP_PKTQ(dest)); - return count; } diff --git a/bgpd/bgp_updgrp.h b/bgpd/bgp_updgrp.h index 7261933dc9..694636ef3d 100644 --- a/bgpd/bgp_updgrp.h +++ b/bgpd/bgp_updgrp.h @@ -109,12 +109,6 @@ struct bpacket { struct bpacket_queue { TAILQ_HEAD(pkt_queue, bpacket) pkts; -#if 0 - /* A dummy packet that is used to thread all peers that have - completed their work */ - struct bpacket sentinel; -#endif - unsigned int conf_max_count; unsigned int curr_count; unsigned int hwm_count; diff --git a/bgpd/bgp_updgrp_packet.c b/bgpd/bgp_updgrp_packet.c index 866bf8178a..0a3ecc584e 100644 --- a/bgpd/bgp_updgrp_packet.c +++ b/bgpd/bgp_updgrp_packet.c @@ -87,39 +87,6 @@ void bpacket_queue_init(struct bpacket_queue *q) TAILQ_INIT(&(q->pkts)); } -/* - * bpacket_queue_sanity_check - */ -void bpacket_queue_sanity_check(struct bpacket_queue __attribute__((__unused__)) - * q) -{ -#if 0 - struct bpacket *pkt; - - pkt = bpacket_queue_last (q); - assert (pkt); - assert (!pkt->buffer); - - /* - * Make sure the count of packets is correct. - */ - int num_pkts = 0; - - pkt = bpacket_queue_first (q); - while (pkt) - { - num_pkts++; - - if (num_pkts > q->curr_count) - assert (0); - - pkt = TAILQ_NEXT (pkt, pkt_train); - } - - assert (num_pkts == q->curr_count); -#endif -} - /* * bpacket_queue_add_packet * @@ -168,7 +135,6 @@ struct bpacket *bpacket_queue_add(struct bpacket_queue *q, struct stream *s, else bpacket_attr_vec_arr_reset(&pkt->arr); bpacket_queue_add_packet(q, pkt); - bpacket_queue_sanity_check(q); return pkt; } @@ -176,7 +142,6 @@ struct bpacket *bpacket_queue_add(struct bpacket_queue *q, struct stream *s, * Fill in the new information into the current sentinel and create a * new sentinel. */ - bpacket_queue_sanity_check(q); last_pkt = bpacket_queue_last(q); assert(last_pkt->buffer == NULL); last_pkt->buffer = s; @@ -190,7 +155,6 @@ struct bpacket *bpacket_queue_add(struct bpacket_queue *q, struct stream *s, pkt->ver++; bpacket_queue_add_packet(q, pkt); - bpacket_queue_sanity_check(q); return last_pkt; } @@ -290,7 +254,6 @@ static int bpacket_queue_compact(struct bpacket_queue *q) num_deleted++; } - bpacket_queue_sanity_check(q); return num_deleted; } diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c index f7bbd44512..8c455c6ea5 100644 --- a/bgpd/rfapi/rfapi.c +++ b/bgpd/rfapi/rfapi.c @@ -578,9 +578,6 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */ struct bgp_attr_encap_subtlv *encaptlv; char buf[PREFIX_STRLEN]; char buf2[RD_ADDRSTRLEN]; -#if 0 /* unused? */ - struct prefix pfx_buf; -#endif struct rfapi_nexthop *lnh = NULL; /* local nexthop */ struct rfapi_vn_option *vo; @@ -603,20 +600,6 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */ return; } -#if 0 /* unused? */ - if ((safi == SAFI_MPLS_VPN) && (flags & RFAPI_AHR_SET_PFX_TO_NEXTHOP)) - { - - if (rfapiRaddr2Qprefix (nexthop, &pfx_buf)) - { - vnc_zlog_debug_verbose - ("%s: can't set pfx to vn addr, not adding SAFI_MPLS_VPN route", - __func__); - return; - } - p = &pfx_buf; - } -#endif for (vo = options_vn; vo; vo = vo->next) { if (RFAPI_VN_OPTION_TYPE_L2ADDR == vo->type) { l2o = &vo->v.l2addr; diff --git a/bgpd/rfapi/rfapi_private.h b/bgpd/rfapi/rfapi_private.h index e24d62def4..af56367955 100644 --- a/bgpd/rfapi/rfapi_private.h +++ b/bgpd/rfapi/rfapi_private.h @@ -289,9 +289,6 @@ add_vnc_route(struct rfapi_descriptor *rfd, /* cookie + UN addr for VPN */ uint8_t type, uint8_t sub_type, int flags); #define RFAPI_AHR_NO_TUNNEL_SUBTLV 0x00000001 #define RFAPI_AHR_RFPOPT_IS_VNCTLV 0x00000002 /* hack! */ -#if 0 /* unused? */ -# define RFAPI_AHR_SET_PFX_TO_NEXTHOP 0x00000004 -#endif extern void del_vnc_route(struct rfapi_descriptor *rfd, struct peer *peer, struct bgp *bgp, safi_t safi, const struct prefix *p, -- 2.39.5