diff options
95 files changed, 1496 insertions, 739 deletions
diff --git a/.gitignore b/.gitignore index ca61140d00..8c61aeb9c5 100644 --- a/.gitignore +++ b/.gitignore @@ -102,3 +102,4 @@ compile_commands.json .dirstamp refix .vscode +.kitchen diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c index f73d6e3009..be80675b5d 100644 --- a/bgpd/bgp_aspath.c +++ b/bgpd/bgp_aspath.c @@ -132,8 +132,7 @@ static void assegment_free(struct assegment *seg) if (!seg) return; - if (seg->as) - assegment_data_free(seg->as); + assegment_data_free(seg->as); memset(seg, 0xfe, sizeof(struct assegment)); XFREE(MTYPE_AS_SEG, seg); @@ -477,7 +476,7 @@ as_t aspath_leftmost(struct aspath *aspath) } /* Return 1 if there are any 4-byte ASes in the path */ -unsigned int aspath_has_as4(struct aspath *aspath) +bool aspath_has_as4(struct aspath *aspath) { struct assegment *seg = aspath->segments; unsigned int i; @@ -485,10 +484,10 @@ unsigned int aspath_has_as4(struct aspath *aspath) while (seg) { for (i = 0; i < seg->length; i++) if (seg->as[i] > BGP_AS_MAX) - return 1; + return true; seg = seg->next; } - return 0; + return false; } /* Convert aspath structure to string expression. */ @@ -1114,16 +1113,16 @@ struct aspath *aspath_aggregate(struct aspath *as1, struct aspath *as2) /* When a BGP router receives an UPDATE with an MP_REACH_NLRI attribute, check the leftmost AS number in the AS_PATH attribute is or not the peer's AS number. */ -int aspath_firstas_check(struct aspath *aspath, as_t asno) +bool aspath_firstas_check(struct aspath *aspath, as_t asno) { if ((aspath == NULL) || (aspath->segments == NULL)) - return 0; + return false; if (aspath->segments && (aspath->segments->type == AS_SEQUENCE) && (aspath->segments->as[0] == asno)) - return 1; + return true; - return 0; + return false; } unsigned int aspath_get_first_as(struct aspath *aspath) @@ -1179,12 +1178,12 @@ int aspath_loop_check(struct aspath *aspath, as_t asno) } /* When all of AS path is private AS return 1. */ -int aspath_private_as_check(struct aspath *aspath) +bool aspath_private_as_check(struct aspath *aspath) { struct assegment *seg; if (!(aspath && aspath->segments)) - return 0; + return false; seg = aspath->segments; @@ -1193,20 +1192,20 @@ int aspath_private_as_check(struct aspath *aspath) for (i = 0; i < seg->length; i++) { if (!BGP_AS_IS_PRIVATE(seg->as[i])) - return 0; + return false; } seg = seg->next; } - return 1; + return true; } /* Return True if the entire ASPATH consist of the specified ASN */ -int aspath_single_asn_check(struct aspath *aspath, as_t asn) +bool aspath_single_asn_check(struct aspath *aspath, as_t asn) { struct assegment *seg; if (!(aspath && aspath->segments)) - return 0; + return false; seg = aspath->segments; @@ -1215,11 +1214,11 @@ int aspath_single_asn_check(struct aspath *aspath, as_t asn) for (i = 0; i < seg->length; i++) { if (seg->as[i] != asn) - return 0; + return false; } seg = seg->next; } - return 1; + return true; } /* Replace all instances of the target ASN with our own ASN */ @@ -1338,37 +1337,37 @@ struct aspath *aspath_remove_private_asns(struct aspath *aspath, as_t peer_asn) /* AS path confed check. If aspath contains confed set or sequence then return * 1. */ -int aspath_confed_check(struct aspath *aspath) +bool aspath_confed_check(struct aspath *aspath) { struct assegment *seg; if (!(aspath && aspath->segments)) - return 0; + return false; seg = aspath->segments; while (seg) { if (seg->type == AS_CONFED_SET || seg->type == AS_CONFED_SEQUENCE) - return 1; + return true; seg = seg->next; } - return 0; + return false; } /* Leftmost AS path segment confed check. If leftmost AS segment is of type AS_CONFED_SEQUENCE or AS_CONFED_SET then return 1. */ -int aspath_left_confed_check(struct aspath *aspath) +bool aspath_left_confed_check(struct aspath *aspath) { if (!(aspath && aspath->segments)) - return 0; + return false; if ((aspath->segments->type == AS_CONFED_SEQUENCE) || (aspath->segments->type == AS_CONFED_SET)) - return 1; + return true; - return 0; + return false; } /* Merge as1 to as2. as2 should be uninterned aspath. */ @@ -1605,13 +1604,13 @@ struct aspath *aspath_add_seq(struct aspath *aspath, as_t asno) /* Compare leftmost AS value for MED check. If as1's leftmost AS and as2's leftmost AS is same return 1. */ -int aspath_cmp_left(const struct aspath *aspath1, const struct aspath *aspath2) +bool aspath_cmp_left(const struct aspath *aspath1, const struct aspath *aspath2) { const struct assegment *seg1; const struct assegment *seg2; if (!(aspath1 && aspath2)) - return 0; + return false; seg1 = aspath1->segments; seg2 = aspath2->segments; @@ -1619,7 +1618,7 @@ int aspath_cmp_left(const struct aspath *aspath1, const struct aspath *aspath2) /* If both paths are originated in this AS then we do want to compare * MED */ if (!seg1 && !seg2) - return 1; + return true; /* find first non-confed segments for each */ while (seg1 && ((seg1->type == AS_CONFED_SEQUENCE) @@ -1633,12 +1632,12 @@ int aspath_cmp_left(const struct aspath *aspath1, const struct aspath *aspath2) /* Check as1's */ if (!(seg1 && seg2 && (seg1->type == AS_SEQUENCE) && (seg2->type == AS_SEQUENCE))) - return 0; + return false; if (seg1->as[0] == seg2->as[0]) - return 1; + return true; - return 0; + return false; } /* Truncate an aspath after a number of hops, and put the hops remaining diff --git a/bgpd/bgp_aspath.h b/bgpd/bgp_aspath.h index a4427714ba..f327751f33 100644 --- a/bgpd/bgp_aspath.h +++ b/bgpd/bgp_aspath.h @@ -87,7 +87,7 @@ extern struct aspath *aspath_add_seq_n(struct aspath *, as_t, unsigned); extern struct aspath *aspath_add_seq(struct aspath *, as_t); extern struct aspath *aspath_add_confed_seq(struct aspath *, as_t); extern bool aspath_cmp(const void *as1, const void *as2); -extern int aspath_cmp_left(const struct aspath *, const struct aspath *); +extern bool aspath_cmp_left(const struct aspath *, const struct aspath *); extern bool aspath_cmp_left_confed(const struct aspath *as1, const struct aspath *as2xs); extern struct aspath *aspath_delete_confed_seq(struct aspath *); @@ -106,8 +106,8 @@ extern unsigned int aspath_key_make(const void *); extern unsigned int aspath_get_first_as(struct aspath *); extern unsigned int aspath_get_last_as(struct aspath *); extern int aspath_loop_check(struct aspath *, as_t); -extern int aspath_private_as_check(struct aspath *); -extern int aspath_single_asn_check(struct aspath *, as_t asn); +extern bool aspath_private_as_check(struct aspath *); +extern bool aspath_single_asn_check(struct aspath *, as_t asn); extern struct aspath *aspath_replace_specific_asn(struct aspath *aspath, as_t target_asn, as_t our_asn); @@ -115,9 +115,9 @@ extern struct aspath *aspath_replace_private_asns(struct aspath *aspath, as_t asn, as_t peer_asn); extern struct aspath *aspath_remove_private_asns(struct aspath *aspath, as_t peer_asn); -extern int aspath_firstas_check(struct aspath *, as_t); -extern int aspath_confed_check(struct aspath *); -extern int aspath_left_confed_check(struct aspath *); +extern bool aspath_firstas_check(struct aspath *, as_t); +extern bool aspath_confed_check(struct aspath *); +extern bool aspath_left_confed_check(struct aspath *); extern unsigned long aspath_count(void); extern unsigned int aspath_count_hops(const struct aspath *); extern bool aspath_check_as_sets(struct aspath *aspath); @@ -128,7 +128,7 @@ extern as_t aspath_leftmost(struct aspath *); extern size_t aspath_put(struct stream *, struct aspath *, int); extern struct aspath *aspath_reconcile_as4(struct aspath *, struct aspath *); -extern unsigned int aspath_has_as4(struct aspath *); +extern bool aspath_has_as4(struct aspath *); /* For SNMP BGP4PATHATTRASPATHSEGMENT, might be useful for debug */ extern uint8_t *aspath_snmp_pathseg(struct aspath *, size_t *); diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index 33466957b0..a1278874c4 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -47,7 +47,7 @@ #include "bgpd/bgp_lcommunity.h" #include "bgpd/bgp_updgrp.h" #include "bgpd/bgp_encap_types.h" -#if ENABLE_BGP_VNC +#ifdef ENABLE_BGP_VNC #include "bgpd/rfapi/bgp_rfapi_cfg.h" #include "bgp_encap_types.h" #include "bgp_vnc_types.h" @@ -79,7 +79,7 @@ static const struct message attr_str[] = { {BGP_ATTR_AS_PATHLIMIT, "AS_PATHLIMIT"}, {BGP_ATTR_PMSI_TUNNEL, "PMSI_TUNNEL_ATTRIBUTE"}, {BGP_ATTR_ENCAP, "ENCAP"}, -#if ENABLE_BGP_VNC_ATTR +#ifdef ENABLE_BGP_VNC_ATTR {BGP_ATTR_VNC, "VNC"}, #endif {BGP_ATTR_LARGE_COMMUNITIES, "LARGE_COMMUNITY"}, @@ -199,7 +199,7 @@ static void cluster_finish(void) } static struct hash *encap_hash = NULL; -#if ENABLE_BGP_VNC +#ifdef ENABLE_BGP_VNC static struct hash *vnc_hash = NULL; #endif static struct hash *srv6_l3vpn_hash; @@ -247,7 +247,7 @@ void bgp_attr_flush_encap(struct attr *attr) encap_free(attr->encap_subtlvs); attr->encap_subtlvs = NULL; } -#if ENABLE_BGP_VNC +#ifdef ENABLE_BGP_VNC if (attr->vnc_subtlvs) { encap_free(attr->vnc_subtlvs); attr->vnc_subtlvs = NULL; @@ -309,7 +309,7 @@ static void *encap_hash_alloc(void *p) typedef enum { ENCAP_SUBTLV_TYPE, -#if ENABLE_BGP_VNC +#ifdef ENABLE_BGP_VNC VNC_SUBTLV_TYPE #endif } encap_subtlv_type; @@ -319,7 +319,7 @@ encap_intern(struct bgp_attr_encap_subtlv *encap, encap_subtlv_type type) { struct bgp_attr_encap_subtlv *find; struct hash *hash = encap_hash; -#if ENABLE_BGP_VNC +#ifdef ENABLE_BGP_VNC if (type == VNC_SUBTLV_TYPE) hash = vnc_hash; #endif @@ -341,7 +341,7 @@ static void encap_unintern(struct bgp_attr_encap_subtlv **encapp, if (encap->refcnt == 0) { struct hash *hash = encap_hash; -#if ENABLE_BGP_VNC +#ifdef ENABLE_BGP_VNC if (type == VNC_SUBTLV_TYPE) hash = vnc_hash; #endif @@ -368,7 +368,7 @@ static void encap_init(void) { encap_hash = hash_create(encap_hash_key_make, encap_hash_cmp, "BGP Encap Hash"); -#if ENABLE_BGP_VNC +#ifdef ENABLE_BGP_VNC vnc_hash = hash_create(encap_hash_key_make, encap_hash_cmp, "BGP VNC Hash"); #endif @@ -379,7 +379,7 @@ static void encap_finish(void) hash_clean(encap_hash, (void (*)(void *))encap_free); hash_free(encap_hash); encap_hash = NULL; -#if ENABLE_BGP_VNC +#ifdef ENABLE_BGP_VNC hash_clean(vnc_hash, (void (*)(void *))encap_free); hash_free(vnc_hash); vnc_hash = NULL; @@ -660,7 +660,7 @@ unsigned int attrhash_key_make(const void *p) MIX(transit_hash_key_make(attr->transit)); if (attr->encap_subtlvs) MIX(encap_hash_key_make(attr->encap_subtlvs)); -#if ENABLE_BGP_VNC +#ifdef ENABLE_BGP_VNC if (attr->vnc_subtlvs) MIX(encap_hash_key_make(attr->vnc_subtlvs)); #endif @@ -698,7 +698,7 @@ bool attrhash_cmp(const void *p1, const void *p2) && attr1->rmap_table_id == attr2->rmap_table_id && (attr1->encap_tunneltype == attr2->encap_tunneltype) && encap_same(attr1->encap_subtlvs, attr2->encap_subtlvs) -#if ENABLE_BGP_VNC +#ifdef ENABLE_BGP_VNC && encap_same(attr1->vnc_subtlvs, attr2->vnc_subtlvs) #endif && IPV6_ADDR_SAME(&attr1->mp_nexthop_global, @@ -780,7 +780,7 @@ static void *bgp_attr_hash_alloc(void *p) if (val->encap_subtlvs) { val->encap_subtlvs = NULL; } -#if ENABLE_BGP_VNC +#ifdef ENABLE_BGP_VNC if (val->vnc_subtlvs) { val->vnc_subtlvs = NULL; } @@ -856,7 +856,7 @@ struct attr *bgp_attr_intern(struct attr *attr) else attr->srv6_vpn->refcnt++; } -#if ENABLE_BGP_VNC +#ifdef ENABLE_BGP_VNC if (attr->vnc_subtlvs) { if (!attr->vnc_subtlvs->refcnt) attr->vnc_subtlvs = encap_intern(attr->vnc_subtlvs, @@ -1041,7 +1041,7 @@ void bgp_attr_unintern_sub(struct attr *attr) if (attr->encap_subtlvs) encap_unintern(&attr->encap_subtlvs, ENCAP_SUBTLV_TYPE); -#if ENABLE_BGP_VNC +#ifdef ENABLE_BGP_VNC if (attr->vnc_subtlvs) encap_unintern(&attr->vnc_subtlvs, VNC_SUBTLV_TYPE); #endif @@ -1125,7 +1125,7 @@ void bgp_attr_flush(struct attr *attr) encap_free(attr->encap_subtlvs); attr->encap_subtlvs = NULL; } -#if ENABLE_BGP_VNC +#ifdef ENABLE_BGP_VNC if (attr->vnc_subtlvs && !attr->vnc_subtlvs->refcnt) { encap_free(attr->vnc_subtlvs); attr->vnc_subtlvs = NULL; @@ -2265,7 +2265,7 @@ static int bgp_attr_encap(uint8_t type, struct peer *peer, /* IN */ subtype = stream_getc(BGP_INPUT(peer)); sublength = stream_getc(BGP_INPUT(peer)); length -= 2; -#if ENABLE_BGP_VNC +#ifdef ENABLE_BGP_VNC } else { subtype = stream_getw(BGP_INPUT(peer)); sublength = stream_getw(BGP_INPUT(peer)); @@ -2304,7 +2304,7 @@ static int bgp_attr_encap(uint8_t type, struct peer *peer, /* IN */ } else { attr->encap_subtlvs = tlv; } -#if ENABLE_BGP_VNC +#ifdef ENABLE_BGP_VNC } else { struct bgp_attr_encap_subtlv *stlv_last; for (stlv_last = attr->vnc_subtlvs; @@ -3019,7 +3019,7 @@ bgp_attr_parse_ret_t bgp_attr_parse(struct peer *peer, struct attr *attr, case BGP_ATTR_EXT_COMMUNITIES: ret = bgp_attr_ext_communities(&attr_args); break; -#if ENABLE_BGP_VNC_ATTR +#ifdef ENABLE_BGP_VNC_ATTR case BGP_ATTR_VNC: #endif case BGP_ATTR_ENCAP: @@ -3171,7 +3171,7 @@ done: if (attr->encap_subtlvs) attr->encap_subtlvs = encap_intern(attr->encap_subtlvs, ENCAP_SUBTLV_TYPE); -#if ENABLE_BGP_VNC +#ifdef ENABLE_BGP_VNC if (attr->vnc_subtlvs) attr->vnc_subtlvs = encap_intern(attr->vnc_subtlvs, VNC_SUBTLV_TYPE); @@ -3190,7 +3190,7 @@ done: assert(attr->transit->refcnt > 0); if (attr->encap_subtlvs) assert(attr->encap_subtlvs->refcnt > 0); -#if ENABLE_BGP_VNC +#ifdef ENABLE_BGP_VNC if (attr->vnc_subtlvs) assert(attr->vnc_subtlvs->refcnt > 0); #endif @@ -3440,7 +3440,7 @@ static void bgp_packet_mpattr_tea(struct bgp *bgp, struct peer *peer, attrhdrlen = 1 + 1; /* subTLV T + L */ break; -#if ENABLE_BGP_VNC_ATTR +#ifdef ENABLE_BGP_VNC_ATTR case BGP_ATTR_VNC: attrname = "VNC"; subtlvs = attr->vnc_subtlvs; @@ -3491,7 +3491,7 @@ static void bgp_packet_mpattr_tea(struct bgp *bgp, struct peer *peer, if (attrtype == BGP_ATTR_ENCAP) { stream_putc(s, st->type); stream_putc(s, st->length); -#if ENABLE_BGP_VNC +#ifdef ENABLE_BGP_VNC } else { stream_putw(s, st->type); stream_putw(s, st->length); @@ -3976,7 +3976,7 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer, /* Tunnel Encap attribute */ bgp_packet_mpattr_tea(bgp, peer, s, attr, BGP_ATTR_ENCAP); -#if ENABLE_BGP_VNC_ATTR +#ifdef ENABLE_BGP_VNC_ATTR /* VNC attribute */ bgp_packet_mpattr_tea(bgp, peer, s, attr, BGP_ATTR_VNC); #endif diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c index c69bc52e47..2e21c7222c 100644 --- a/bgpd/bgp_debug.c +++ b/bgpd/bgp_debug.c @@ -170,6 +170,16 @@ static const struct message bgp_notify_capability_msg[] = { {BGP_NOTIFY_CAPABILITY_MALFORMED_CODE, "/Malformed Capability Value"}, {0}}; +static const struct message bgp_notify_fsm_msg[] = { + {BGP_NOTIFY_FSM_ERR_SUBCODE_UNSPECIFIC, "/Unspecific"}, + {BGP_NOTIFY_FSM_ERR_SUBCODE_OPENSENT, + "/Receive Unexpected Message in OpenSent State"}, + {BGP_NOTIFY_FSM_ERR_SUBCODE_OPENCONFIRM, + "/Receive Unexpected Message in OpenConfirm State"}, + {BGP_NOTIFY_FSM_ERR_SUBCODE_ESTABLISHED, + "/Receive Unexpected Message in Established State"}, + {0}}; + /* Origin strings. */ const char *const bgp_origin_str[] = {"i", "e", "?"}; const char *const bgp_origin_long_str[] = {"IGP", "EGP", "incomplete"}; @@ -209,13 +219,8 @@ static void bgp_debug_list_free(struct list *list) if (list) for (ALL_LIST_ELEMENTS(list, node, nnode, filter)) { listnode_delete(list, filter); - - if (filter->p) - prefix_free(&filter->p); - - if (filter->host) - XFREE(MTYPE_BGP_DEBUG_STR, filter->host); - + prefix_free(&filter->p); + XFREE(MTYPE_BGP_DEBUG_STR, filter->host); XFREE(MTYPE_BGP_DEBUG_FILTER, filter); } } @@ -476,7 +481,8 @@ const char *bgp_notify_subcode_str(char code, char subcode) case BGP_NOTIFY_HOLD_ERR: break; case BGP_NOTIFY_FSM_ERR: - break; + return lookup_msg(bgp_notify_fsm_msg, subcode, + "Unrecognized Error Subcode"); case BGP_NOTIFY_CEASE: return lookup_msg(bgp_notify_cease_msg, subcode, "Unrecognized Error Subcode"); diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index a44effaac5..0051b8d606 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -885,6 +885,27 @@ void bgp_maxmed_update(struct bgp *bgp) } } +int bgp_fsm_error_subcode(int status) +{ + int fsm_err_subcode = BGP_NOTIFY_FSM_ERR_SUBCODE_UNSPECIFIC; + + switch (status) { + case OpenSent: + fsm_err_subcode = BGP_NOTIFY_FSM_ERR_SUBCODE_OPENSENT; + break; + case OpenConfirm: + fsm_err_subcode = BGP_NOTIFY_FSM_ERR_SUBCODE_OPENCONFIRM; + break; + case Established: + fsm_err_subcode = BGP_NOTIFY_FSM_ERR_SUBCODE_ESTABLISHED; + break; + default: + break; + } + + return fsm_err_subcode; +} + /* The maxmed onstartup timer expiry callback. */ static int bgp_maxmed_onstartup_timer(struct thread *thread) { @@ -1128,6 +1149,10 @@ int bgp_stop(struct peer *peer) peer->nsf_af_count = 0; + /* deregister peer */ + if (peer->last_reset == PEER_DOWN_UPDATE_SOURCE_CHANGE) + bgp_bfd_deregister_peer(peer); + if (peer_dynamic_neighbor(peer) && !(CHECK_FLAG(peer->flags, PEER_FLAG_DELETE))) { if (bgp_debug_neighbor_events(peer)) @@ -1451,9 +1476,8 @@ static int bgp_connect_success(struct peer *peer) flog_err_sys(EC_LIB_SOCKET, "%s: bgp_getsockname(): failed for peer %s, fd %d", __func__, peer->host, peer->fd); - bgp_notify_send( - peer, BGP_NOTIFY_FSM_ERR, - BGP_NOTIFY_SUBCODE_UNSPECIFIC); /* internal error */ + bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR, + bgp_fsm_error_subcode(peer->status)); bgp_writes_on(peer); return -1; } @@ -1653,7 +1677,8 @@ static int bgp_fsm_event_error(struct peer *peer) flog_err(EC_BGP_FSM, "%s [FSM] unexpected packet received in state %s", peer->host, lookup_msg(bgp_status_msg, peer->status, NULL)); - return bgp_stop_with_notify(peer, BGP_NOTIFY_FSM_ERR, 0); + return bgp_stop_with_notify(peer, BGP_NOTIFY_FSM_ERR, + bgp_fsm_error_subcode(peer->status)); } /* Hold timer expire. This is error of BGP connection. So cut the @@ -1931,6 +1956,7 @@ static int bgp_establish(struct peer *peer) hash_release(peer->bgp->peerhash, peer); hash_get(peer->bgp->peerhash, peer, hash_alloc_intern); + bgp_bfd_deregister_peer(peer); bgp_bfd_register_peer(peer); return ret; } @@ -2512,7 +2538,7 @@ int bgp_neighbor_graceful_restart(struct peer *peer, int peer_gr_cmd) peer->peer_gr_present_state = peer_new_state; if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) zlog_debug( - "[BGP_GR] Succesfully change the state of the peer to : %s : !", + "[BGP_GR] Successfully change the state of the peer to : %s : !", print_peer_gr_mode(peer_new_state)); return BGP_GR_SUCCESS; diff --git a/bgpd/bgp_fsm.h b/bgpd/bgp_fsm.h index 6feabbf570..4b8db161d7 100644 --- a/bgpd/bgp_fsm.h +++ b/bgpd/bgp_fsm.h @@ -121,6 +121,7 @@ extern void bgp_update_delay_end(struct bgp *); extern void bgp_maxmed_update(struct bgp *); extern int bgp_maxmed_onstartup_configured(struct bgp *); extern int bgp_maxmed_onstartup_active(struct bgp *); +extern int bgp_fsm_error_subcode(int status); /** * Start the route advertisement timer (that honors MRAI) for all the diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index 86c04b71f0..8758d0ca78 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -1532,7 +1532,10 @@ void vpn_handle_router_id_update(struct bgp *bgp, bool withdraw, ecom = bgp->vpn_policy[afi].rtlist[edir]; for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi]. export_vrf, node, vname)) { - bgp_import = bgp_lookup_by_name(vname); + if (strcmp(vname, VRF_DEFAULT_NAME) == 0) + bgp_import = bgp_get_default(); + else + bgp_import = bgp_lookup_by_name(vname); if (!bgp_import) continue; @@ -1572,7 +1575,10 @@ void vpn_handle_router_id_update(struct bgp *bgp, bool withdraw, ecom = bgp->vpn_policy[afi].rtlist[edir]; for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi]. export_vrf, node, vname)) { - bgp_import = bgp_lookup_by_name(vname); + if (strcmp(vname, VRF_DEFAULT_NAME) == 0) + bgp_import = bgp_get_default(); + else + bgp_import = bgp_lookup_by_name(vname); if (!bgp_import) continue; if (bgp_import->vpn_policy[afi].rtlist[idir]) diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c index 8759a88444..037aeec288 100644 --- a/bgpd/bgp_network.c +++ b/bgpd/bgp_network.c @@ -57,8 +57,26 @@ struct bgp_listener { union sockunion su; struct thread *thread; struct bgp *bgp; + char *name; }; +void bgp_dump_listener_info(struct vty *vty) +{ + struct listnode *node; + struct bgp_listener *listener; + + vty_out(vty, "Name fd Address\n"); + vty_out(vty, "---------------------------\n"); + for (ALL_LIST_ELEMENTS_RO(bm->listen_sockets, node, listener)) { + char buf[SU_ADDRSTRLEN]; + + vty_out(vty, "%-16s %d %s\n", + listener->name ? listener->name : VRF_DEFAULT_NAME, + listener->fd, + sockunion2str(&listener->su, buf, sizeof(buf))); + } +} + /* * Set MD5 key for the socket, for the given IPv4 peer address. * If the password is NULL or zero-length, the option will be disabled. @@ -762,6 +780,7 @@ static int bgp_listener(int sock, struct sockaddr *sa, socklen_t salen, listener = XCALLOC(MTYPE_BGP_LISTENER, sizeof(*listener)); listener->fd = sock; + listener->name = XSTRDUP(MTYPE_BGP_LISTENER, bgp->name); /* this socket needs a change of ns. record bgp back pointer */ if (bgp->vrf_id != VRF_DEFAULT && vrf_is_backend_netns()) @@ -871,6 +890,7 @@ void bgp_close_vrf_socket(struct bgp *bgp) thread_cancel(listener->thread); close(listener->fd); listnode_delete(bm->listen_sockets, listener); + XFREE(MTYPE_BGP_LISTENER, listener->name); XFREE(MTYPE_BGP_LISTENER, listener); } } @@ -892,6 +912,7 @@ void bgp_close(void) thread_cancel(listener->thread); close(listener->fd); listnode_delete(bm->listen_sockets, listener); + XFREE(MTYPE_BGP_LISTENER, listener->name); XFREE(MTYPE_BGP_LISTENER, listener); } } diff --git a/bgpd/bgp_network.h b/bgpd/bgp_network.h index 59b18f9376..018efbc08e 100644 --- a/bgpd/bgp_network.h +++ b/bgpd/bgp_network.h @@ -23,6 +23,7 @@ #define BGP_SOCKET_SNDBUF_SIZE 65536 +extern void bgp_dump_listener_info(struct vty *vty); extern int bgp_socket(struct bgp *bgp, unsigned short port, const char *address); extern void bgp_close_vrf_socket(struct bgp *bgp); diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index 0e251dced8..a7b2bc3458 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -1447,7 +1447,7 @@ static int bgp_update_receive(struct peer *peer, bgp_size_t size) peer->host, lookup_msg(bgp_status_msg, peer->status, NULL)); bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR, - BGP_NOTIFY_SUBCODE_UNSPECIFIC); + bgp_fsm_error_subcode(peer->status)); return BGP_Stop; } @@ -1859,7 +1859,7 @@ static int bgp_route_refresh_receive(struct peer *peer, bgp_size_t size) peer->host, lookup_msg(bgp_status_msg, peer->status, NULL)); bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR, - BGP_NOTIFY_SUBCODE_UNSPECIFIC); + bgp_fsm_error_subcode(peer->status)); return BGP_Stop; } @@ -2251,7 +2251,7 @@ int bgp_capability_receive(struct peer *peer, bgp_size_t size) peer->host, lookup_msg(bgp_status_msg, peer->status, NULL)); bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR, - BGP_NOTIFY_SUBCODE_UNSPECIFIC); + bgp_fsm_error_subcode(peer->status)); return BGP_Stop; } diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index bcd87eb01b..0806e1c680 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -69,6 +69,7 @@ #include "bgpd/bgp_label.h" #include "bgpd/bgp_addpath.h" #include "bgpd/bgp_mac.h" +#include "bgpd/bgp_network.h" #if ENABLE_BGP_VNC #include "bgpd/rfapi/rfapi_backend.h" @@ -2485,7 +2486,7 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn, */ if (CHECK_FLAG(rn->flags, BGP_NODE_SELECT_DEFER)) { if (BGP_DEBUG(update, UPDATE_OUT)) - zlog_debug("SELECT_DEFER falg set for route %p", rn); + zlog_debug("SELECT_DEFER flag set for route %p", rn); return; } @@ -12766,6 +12767,18 @@ static void show_bgp_peerhash_entry(struct hash_bucket *bucket, void *arg) sockunion2str(&peer->su, buf, sizeof(buf))); } +DEFUN (show_bgp_listeners, + show_bgp_listeners_cmd, + "show bgp listeners", + SHOW_STR + BGP_STR + "Display Listen Sockets and who created them\n") +{ + bgp_dump_listener_info(vty); + + return CMD_SUCCESS; +} + DEFUN (show_bgp_peerhash, show_bgp_peerhash_cmd, "show bgp peerhash", @@ -13155,6 +13168,7 @@ void bgp_route_init(void) /* show bgp ipv4 flowspec detailed */ install_element(VIEW_NODE, &show_ip_bgp_flowspec_routes_detailed_cmd); + install_element(VIEW_NODE, &show_bgp_listeners_cmd); install_element(VIEW_NODE, &show_bgp_peerhash_cmd); } diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index fc841c6c1b..8c751e4f19 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -7304,7 +7304,7 @@ ALIAS (af_label_vpn_export, DEFPY (af_nexthop_vpn_export, af_nexthop_vpn_export_cmd, - "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str", + "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]", NO_STR "Specify next hop to use for VRF advertised prefixes\n" "Between current address-family and vpn\n" @@ -7315,14 +7315,14 @@ DEFPY (af_nexthop_vpn_export, VTY_DECLVAR_CONTEXT(bgp, bgp); afi_t afi; struct prefix p; - int idx = 0; - int yes = 1; - if (argv_find(argv, argc, "no", &idx)) - yes = 0; + if (!no) { + if (!nexthop_su) { + vty_out(vty, "%% Nexthop required\n"); + return CMD_WARNING_CONFIG_FAILED; + } - if (yes) { - if (!sockunion2hostprefix(nexthop_str, &p)) + if (!sockunion2hostprefix(nexthop_su, &p)) return CMD_WARNING_CONFIG_FAILED; } @@ -7336,7 +7336,7 @@ DEFPY (af_nexthop_vpn_export, vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, bgp_get_default(), bgp); - if (yes) { + if (!no) { bgp->vpn_policy[afi].tovpn_nexthop = p; SET_FLAG(bgp->vpn_policy[afi].flags, BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); @@ -7352,14 +7352,6 @@ DEFPY (af_nexthop_vpn_export, return CMD_SUCCESS; } -ALIAS (af_nexthop_vpn_export, - af_no_nexthop_vpn_export_cmd, - "no nexthop vpn export", - NO_STR - "Specify next hop to use for VRF advertised prefixes\n" - "Between current address-family and vpn\n" - "For routes leaked from current address-family to vpn\n") - static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) { if (!strcmp(dstr, "import")) { @@ -11635,7 +11627,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, json_object_object_add( json_neigh, "gracefulRestartInfo", json_grace); } else { - vty_out(vty, " Graceful restart informations:\n"); + vty_out(vty, " Graceful restart information:\n"); if ((p->status == Established) && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { @@ -16613,8 +16605,6 @@ void bgp_vty_init(void) install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); - install_element(BGP_IPV4_NODE, &af_no_nexthop_vpn_export_cmd); - install_element(BGP_IPV6_NODE, &af_no_nexthop_vpn_export_cmd); install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 8cc4096076..267d67e46e 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -2102,8 +2102,8 @@ static int non_peergroup_deactivate_af(struct peer *peer, afi_t afi, if (peer_af_delete(peer, afi, safi) != 0) { flog_err(EC_BGP_PEER_DELETE, - "couldn't delete af structure for peer %s", - peer->host); + "couldn't delete af structure for peer %s(%s, %s)", + peer->host, afi2str(afi), safi2str(safi)); return 1; } @@ -2152,9 +2152,10 @@ int peer_deactivate(struct peer *peer, afi_t afi, safi_t safi) group = peer->group; if (peer_af_delete(peer, afi, safi) != 0) { - flog_err(EC_BGP_PEER_DELETE, - "couldn't delete af structure for peer %s", - peer->host); + flog_err( + EC_BGP_PEER_DELETE, + "couldn't delete af structure for peer %s(%s, %s)", + peer->host, afi2str(afi), safi2str(safi)); } for (ALL_LIST_ELEMENTS(group->peer, node, nnode, tmp_peer)) { @@ -4070,6 +4071,9 @@ static int peer_flag_modify(struct peer *peer, uint32_t flag, int set) /* Update flag override state accordingly. */ COND_FLAG(peer->flags_override, flag, set != invert); + if (set && flag == PEER_FLAG_CAPABILITY_ENHE) + bgp_nht_register_enhe_capability_interfaces(peer); + /* Execute flag action on peer. */ if (action.type == peer_change_reset) peer_flag_modify_action(peer, flag); @@ -4078,9 +4082,6 @@ static int peer_flag_modify(struct peer *peer, uint32_t flag, int set) return 0; } - if (set && flag == PEER_FLAG_CAPABILITY_ENHE) - bgp_nht_register_enhe_capability_interfaces(peer); - /* * Update peer-group members, unless they are explicitely overriding * peer-group configuration. diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 03d33130fe..769ac32653 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -555,7 +555,7 @@ struct bgp { struct bgp_addpath_bgp_data tx_addpath; -#if ENABLE_BGP_VNC +#ifdef ENABLE_BGP_VNC struct rfapi_cfg *rfapi_cfg; struct rfapi *rfapi; #endif @@ -1281,9 +1281,7 @@ struct peer { * - This does *not* contain the filter values, rather it contains * whether the filter in filter (struct bgp_filter) is peer-specific. */ - uint8_t filter_override[AFI_MAX][SAFI_MAX][(FILTER_MAX > RMAP_MAX) - ? FILTER_MAX - : RMAP_MAX]; + uint8_t filter_override[AFI_MAX][SAFI_MAX][FILTER_MAX]; #define PEER_FT_DISTRIBUTE_LIST (1 << 0) /* distribute-list */ #define PEER_FT_FILTER_LIST (1 << 1) /* filter-list */ #define PEER_FT_PREFIX_LIST (1 << 2) /* prefix-list */ @@ -1482,7 +1480,7 @@ struct bgp_nlri { #define BGP_ATTR_ENCAP 23 #define BGP_ATTR_LARGE_COMMUNITIES 32 #define BGP_ATTR_PREFIX_SID 40 -#if ENABLE_BGP_VNC_ATTR +#ifdef ENABLE_BGP_VNC_ATTR #define BGP_ATTR_VNC 255 #endif @@ -1501,6 +1499,12 @@ struct bgp_nlri { #define BGP_NOTIFY_CEASE 6 #define BGP_NOTIFY_CAPABILITY_ERR 7 +/* Subcodes for BGP Finite State Machine Error */ +#define BGP_NOTIFY_FSM_ERR_SUBCODE_UNSPECIFIC 0 +#define BGP_NOTIFY_FSM_ERR_SUBCODE_OPENSENT 1 +#define BGP_NOTIFY_FSM_ERR_SUBCODE_OPENCONFIRM 2 +#define BGP_NOTIFY_FSM_ERR_SUBCODE_ESTABLISHED 3 + #define BGP_NOTIFY_SUBCODE_UNSPECIFIC 0 /* BGP_NOTIFY_HEADER_ERR sub codes. */ diff --git a/bgpd/rfapi/bgp_rfapi_cfg.c b/bgpd/rfapi/bgp_rfapi_cfg.c index cad33404fa..acfab53d2b 100644 --- a/bgpd/rfapi/bgp_rfapi_cfg.c +++ b/bgpd/rfapi/bgp_rfapi_cfg.c @@ -47,7 +47,7 @@ #include "bgpd/rfapi/vnc_import_bgp.h" #include "bgpd/rfapi/vnc_debug.h" -#if ENABLE_BGP_VNC +#ifdef ENABLE_BGP_VNC #undef BGP_VNC_DEBUG_MATCH_GROUP @@ -168,7 +168,7 @@ struct rfapi_nve_group_cfg *bgp_rfapi_cfg_match_group(struct rfapi_cfg *hc, agg_unlock_node(rn_un); } -#if BGP_VNC_DEBUG_MATCH_GROUP +#ifdef BGP_VNC_DEBUG_MATCH_GROUP { char buf[PREFIX_STRLEN]; diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c index 4701d2e1fa..d87292f652 100644 --- a/bgpd/rfapi/rfapi.c +++ b/bgpd/rfapi/rfapi.c @@ -2150,7 +2150,7 @@ int rfapi_close(void *handle) vnc_zlog_debug_verbose("%s: rfd=%p", __func__, rfd); -#if RFAPI_WHO_IS_CALLING_ME +#ifdef RFAPI_WHO_IS_CALLING_ME #ifdef HAVE_GLIBC_BACKTRACE #define RFAPI_DEBUG_BACKTRACE_NENTRIES 5 { diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c index 8fbc4d9d15..2f274015fc 100644 --- a/bgpd/rfapi/rfapi_import.c +++ b/bgpd/rfapi/rfapi_import.c @@ -200,7 +200,7 @@ void rfapiCheckRouteCount(void) } } -#if DEBUG_ROUTE_COUNTERS +#ifdef DEBUG_ROUTE_COUNTERS #define VNC_ITRCCK do {rfapiCheckRouteCount();} while (0) #else #define VNC_ITRCCK @@ -458,7 +458,7 @@ int rfapiGetUnAddrOfVpnBi(struct bgp_path_info *bpi, struct prefix *p) default: if (p) p->family = 0; -#if DEBUG_ENCAP_MONITOR +#ifdef DEBUG_ENCAP_MONITOR vnc_zlog_debug_verbose( "%s: bpi->extra->vnc.import.un_family is 0, no UN addr", __func__); @@ -609,7 +609,7 @@ rfapiMonitorMoveShorter(struct agg_node *original_vpn_node, int lockoffset) RFAPI_CHECK_REFCOUNT(original_vpn_node, SAFI_MPLS_VPN, lockoffset); -#if DEBUG_MONITOR_MOVE_SHORTER +#ifdef DEBUG_MONITOR_MOVE_SHORTER { char buf[PREFIX_STRLEN]; @@ -628,7 +628,7 @@ rfapiMonitorMoveShorter(struct agg_node *original_vpn_node, int lockoffset) struct prefix pfx; if (!rfapiGetUnAddrOfVpnBi(bpi, &pfx)) { -#if DEBUG_MONITOR_MOVE_SHORTER +#ifdef DEBUG_MONITOR_MOVE_SHORTER vnc_zlog_debug_verbose( "%s: have valid UN at original node, no change", __func__); @@ -744,7 +744,7 @@ rfapiMonitorMoveShorter(struct agg_node *original_vpn_node, int lockoffset) agg_unlock_node(original_vpn_node); } -#if DEBUG_MONITOR_MOVE_SHORTER +#ifdef DEBUG_MONITOR_MOVE_SHORTER { char buf[PREFIX_STRLEN]; @@ -953,7 +953,7 @@ void rfapiImportTableRefDelByIt(struct bgp *bgp, } } -#if RFAPI_REQUIRE_ENCAP_BEEC +#ifdef RFAPI_REQUIRE_ENCAP_BEEC /* * Look for magic BGP Encapsulation Extended Community value * Format in RFC 5512 Sect. 4.5 @@ -1267,7 +1267,7 @@ rfapiRouteInfo2NextHopEntry(struct rfapi_ip_prefix *rprefix, struct rfapi_next_hop_entry *new; int have_vnc_tunnel_un = 0; -#if DEBUG_ENCAP_MONITOR +#ifdef DEBUG_ENCAP_MONITOR vnc_zlog_debug_verbose("%s: entry, bpi %p, rn %p", __func__, bpi, rn); #endif @@ -1401,7 +1401,7 @@ rfapiRouteInfo2NextHopEntry(struct rfapi_ip_prefix *rprefix, new->un_options = rfapi_encap_tlv_to_un_option(bpi->attr); -#if DEBUG_ENCAP_MONITOR +#ifdef DEBUG_ENCAP_MONITOR vnc_zlog_debug_verbose("%s: line %d: have_vnc_tunnel_un=%d", __func__, __LINE__, have_vnc_tunnel_un); #endif @@ -1448,7 +1448,7 @@ int rfapiHasNonRemovedRoutes(struct agg_node *rn) return 0; } -#if DEBUG_IT_NODES +#ifdef DEBUG_IT_NODES /* * DEBUG FUNCTION */ @@ -1517,7 +1517,7 @@ static int rfapiNhlAddNodeRoutes( struct prefix *newpfx; if (removed && !CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) { -#if DEBUG_RETURNED_NHL +#ifdef DEBUG_RETURNED_NHL vnc_zlog_debug_verbose( "%s: want holddown, this route not holddown, skip", __func__); @@ -1549,7 +1549,7 @@ static int rfapiNhlAddNodeRoutes( rfapiNexthop2Prefix(bpi->attr, &pfx_vn); } if (!skiplist_search(seen_nexthops, &pfx_vn, NULL)) { -#if DEBUG_RETURNED_NHL +#ifdef DEBUG_RETURNED_NHL char buf[PREFIX_STRLEN]; prefix2str(&pfx_vn, buf, sizeof(buf)); @@ -1561,7 +1561,7 @@ static int rfapiNhlAddNodeRoutes( } if (rfapiGetUnAddrOfVpnBi(bpi, &pfx_un)) { -#if DEBUG_ENCAP_MONITOR +#ifdef DEBUG_ENCAP_MONITOR vnc_zlog_debug_verbose( "%s: failed to get UN address of this VPN bpi", __func__); @@ -1715,7 +1715,7 @@ struct rfapi_next_hop_entry *rfapiRouteNode2NextHopList( int count = 0; struct agg_node *rib_rn; -#if DEBUG_RETURNED_NHL +#ifdef DEBUG_RETURNED_NHL { char buf[PREFIX_STRLEN]; @@ -1746,7 +1746,7 @@ struct rfapi_next_hop_entry *rfapiRouteNode2NextHopList( pfx_target_original); vnc_zlog_debug_verbose("%s: %d nexthops, answer=%p", __func__, count, answer); -#if DEBUG_RETURNED_NHL +#ifdef DEBUG_RETURNED_NHL rfapiPrintNhl(NULL, answer); #endif if (rib_rn) @@ -1806,7 +1806,7 @@ struct rfapi_next_hop_entry *rfapiRouteNode2NextHopList( vnc_zlog_debug_verbose("%s: %d nexthops, answer=%p", __func__, count, answer); -#if DEBUG_RETURNED_NHL +#ifdef DEBUG_RETURNED_NHL rfapiPrintNhl(NULL, answer); #endif return answer; @@ -1868,7 +1868,7 @@ struct rfapi_next_hop_entry *rfapiEthRouteNode2NextHopList( count = rfapiNhlAddNodeRoutes(rn, rprefix, lifetime, 0, &answer, &last, NULL, rib_rn, pfx_target_original); -#if DEBUG_ENCAP_MONITOR +#ifdef DEBUG_ENCAP_MONITOR vnc_zlog_debug_verbose("%s: node %p: %d non-holddown routes", __func__, rn, count); #endif @@ -1884,7 +1884,7 @@ struct rfapi_next_hop_entry *rfapiEthRouteNode2NextHopList( if (rib_rn) agg_unlock_node(rib_rn); -#if DEBUG_RETURNED_NHL +#ifdef DEBUG_RETURNED_NHL rfapiPrintNhl(NULL, answer); #endif @@ -2164,7 +2164,7 @@ static struct bgp_path_info *rfapiItBiIndexSearch( if (!sl) return NULL; -#if DEBUG_BI_SEARCH +#ifdef DEBUG_BI_SEARCH { char buf[RD_ADDRSTRLEN]; char buf_aux_pfx[PREFIX_STRLEN]; @@ -2185,13 +2185,13 @@ static struct bgp_path_info *rfapiItBiIndexSearch( /* threshold is a WAG */ if (sl->count < 3) { -#if DEBUG_BI_SEARCH +#ifdef DEBUG_BI_SEARCH vnc_zlog_debug_verbose("%s: short list algorithm", __func__); #endif /* if short list, linear search might be faster */ for (bpi_result = rn->info; bpi_result; bpi_result = bpi_result->next) { -#if DEBUG_BI_SEARCH +#ifdef DEBUG_BI_SEARCH { char buf[RD_ADDRSTRLEN]; @@ -2208,7 +2208,7 @@ static struct bgp_path_info *rfapiItBiIndexSearch( ->vnc.import.rd, (struct prefix *)prd)) { -#if DEBUG_BI_SEARCH +#ifdef DEBUG_BI_SEARCH vnc_zlog_debug_verbose( "%s: peer and RD same, doing aux_prefix check", __func__); @@ -2219,7 +2219,7 @@ static struct bgp_path_info *rfapiItBiIndexSearch( &bpi_result->extra->vnc.import .aux_prefix)) { -#if DEBUG_BI_SEARCH +#ifdef DEBUG_BI_SEARCH vnc_zlog_debug_verbose("%s: match", __func__); #endif @@ -2244,13 +2244,13 @@ static struct bgp_path_info *rfapiItBiIndexSearch( rc = skiplist_search(sl, (void *)&bpi_fake, (void *)&bpi_result); if (rc) { -#if DEBUG_BI_SEARCH +#ifdef DEBUG_BI_SEARCH vnc_zlog_debug_verbose("%s: no match", __func__); #endif return NULL; } -#if DEBUG_BI_SEARCH +#ifdef DEBUG_BI_SEARCH vnc_zlog_debug_verbose("%s: matched bpi=%p", __func__, bpi_result); #endif @@ -2958,7 +2958,7 @@ static void rfapiBgpInfoFilteredImportEncap( __func__); return; } -#if RFAPI_REQUIRE_ENCAP_BEEC +#ifdef RFAPI_REQUIRE_ENCAP_BEEC if (!rfapiEcommunitiesMatchBeec(attr->ecommunity)) { vnc_zlog_debug_verbose( "%s: it=%p: no match for BGP Encapsulation ecommunity", @@ -3007,7 +3007,7 @@ static void rfapiBgpInfoFilteredImportEncap( */ rn = agg_node_lookup(rt, p); -#if DEBUG_ENCAP_MONITOR +#ifdef DEBUG_ENCAP_MONITOR vnc_zlog_debug_verbose("%s: initial encap lookup(it=%p) rn=%p", __func__, import_table, rn); #endif @@ -3241,7 +3241,7 @@ static void rfapiBgpInfoFilteredImportEncap( /* * iterate over the set of monitors at this ENCAP node. */ -#if DEBUG_ENCAP_MONITOR +#ifdef DEBUG_ENCAP_MONITOR vnc_zlog_debug_verbose("%s: examining monitors at rn=%p", __func__, rn); #endif @@ -3997,7 +3997,7 @@ void rfapiProcessWithdraw(struct peer *peer, void *rfd, struct prefix *p, rc == 0; rc = skiplist_next(h->import_mac, NULL, (void **)&it, &cursor)) { -#if DEBUG_L2_EXTRA +#ifdef DEBUG_L2_EXTRA vnc_zlog_debug_verbose( "%s: calling rfapiBgpInfoFilteredImportVPN(it=%p, afi=AFI_L2VPN)", __func__, it); @@ -4408,7 +4408,7 @@ static void rfapiDeleteRemotePrefixesIt( { afi_t afi; -#if DEBUG_L2_EXTRA +#ifdef DEBUG_L2_EXTRA { char buf_pfx[PREFIX_STRLEN]; @@ -4487,7 +4487,7 @@ static void rfapiDeleteRemotePrefixesIt( if (vn) { if (!qpt_valid || !prefix_match(vn, &qpt)) { -#if DEBUG_L2_EXTRA +#ifdef DEBUG_L2_EXTRA vnc_zlog_debug_verbose( "%s: continue at vn && !qpt_valid || !prefix_match(vn, &qpt)", __func__); @@ -4502,7 +4502,7 @@ static void rfapiDeleteRemotePrefixesIt( if (un) { if (!qct_valid || !prefix_match(un, &qct)) { -#if DEBUG_L2_EXTRA +#ifdef DEBUG_L2_EXTRA vnc_zlog_debug_verbose( "%s: continue at un && !qct_valid || !prefix_match(un, &qct)", __func__); diff --git a/bgpd/rfapi/rfapi_rib.c b/bgpd/rfapi/rfapi_rib.c index b7ec35c661..3d4bdef75a 100644 --- a/bgpd/rfapi/rfapi_rib.c +++ b/bgpd/rfapi/rfapi_rib.c @@ -479,7 +479,7 @@ void rfapiRibClear(struct rfapi_descriptor *rfd) bgp = rfd->bgp; else bgp = bgp_get_default(); -#if DEBUG_L2_EXTRA +#ifdef DEBUG_L2_EXTRA vnc_zlog_debug_verbose("%s: rfd=%p", __func__, rfd); #endif @@ -1487,7 +1487,7 @@ static void rib_do_callback_onepass(struct rfapi_descriptor *rfd, afi_t afi) struct rfapi_next_hop_entry *tail = NULL; struct agg_node *rn; -#if DEBUG_L2_EXTRA +#ifdef DEBUG_L2_EXTRA vnc_zlog_debug_verbose("%s: rfd=%p, afi=%d", __func__, rfd, afi); #endif @@ -1812,7 +1812,7 @@ int rfapiRibFTDFilterRecentPrefix( if (it_rn->p.family == AF_ETHERNET) return 0; -#if DEBUG_FTD_FILTER_RECENT +#ifdef DEBUG_FTD_FILTER_RECENT { char buf_pfx[PREFIX_STRLEN]; @@ -1825,7 +1825,7 @@ int rfapiRibFTDFilterRecentPrefix( * prefix covers target address, so allow prefix */ if (prefix_match(&it_rn->p, pfx_target_original)) { -#if DEBUG_FTD_FILTER_RECENT +#ifdef DEBUG_FTD_FILTER_RECENT vnc_zlog_debug_verbose("%s: prefix covers target, allowed", __func__); #endif @@ -1840,7 +1840,7 @@ int rfapiRibFTDFilterRecentPrefix( if (trn->lock > 1) agg_unlock_node(trn); -#if DEBUG_FTD_FILTER_RECENT +#ifdef DEBUG_FTD_FILTER_RECENT vnc_zlog_debug_verbose("%s: last sent time %lu, last allowed time %lu", __func__, prefix_time, rfd->ftd_last_allowed_time); @@ -2311,7 +2311,7 @@ static int print_rib_sl(int (*fp)(void *, const char *, ...), struct vty *vty, *p = 0; rfapiFormatSeconds(ri->lifetime, str_lifetime, BUFSIZ); -#if RFAPI_REGISTRATIONS_REPORT_AGE +#ifdef RFAPI_REGISTRATIONS_REPORT_AGE rfapiFormatAge(ri->last_sent_time, str_age, BUFSIZ); #else { @@ -2451,12 +2451,12 @@ void rfapiRibShowResponses(void *stream, struct prefix *pfx_match, " %-20s %-15s %-15s %4s %-8s %-8s\n", "Prefix", "Registered VN", "Registered UN", "Cost", "Lifetime", -#if RFAPI_REGISTRATIONS_REPORT_AGE +#ifdef RFAPI_REGISTRATIONS_REPORT_AGE "Age" #else "Remaining" #endif - ); + ); } if (!printednve) { char str_vn[BUFSIZ]; diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c index 77fcf909c8..58fdc7c130 100644 --- a/bgpd/rfapi/rfapi_vty.c +++ b/bgpd/rfapi/rfapi_vty.c @@ -1123,7 +1123,7 @@ static int rfapiPrintRemoteRegBi(struct bgp *bgp, void *stream, (struct thread *)bpi->extra->vnc.import.timer; remaining = thread_timer_remain_second(t); -#if RFAPI_REGISTRATIONS_REPORT_AGE +#ifdef RFAPI_REGISTRATIONS_REPORT_AGE /* * Calculate when the timer started. Doing so here saves * us a timestamp field in "struct bgp_path_info". @@ -1311,7 +1311,7 @@ static int rfapiShowRemoteRegistrationsIt(struct bgp *bgp, void *stream, } fp(out, "%s", HVTYNL); if (show_expiring) { -#if RFAPI_REGISTRATIONS_REPORT_AGE +#ifdef RFAPI_REGISTRATIONS_REPORT_AGE agetype = "Age"; #else agetype = "Remaining"; diff --git a/bgpd/rfapi/vnc_export_bgp.c b/bgpd/rfapi/vnc_export_bgp.c index 352f5e8328..3d34d696b5 100644 --- a/bgpd/rfapi/vnc_export_bgp.c +++ b/bgpd/rfapi/vnc_export_bgp.c @@ -1189,7 +1189,7 @@ static void vnc_direct_add_rn_group_rd(struct bgp *bgp, } if (rfg->label > MPLS_LABEL_MAX) { vnc_zlog_debug_verbose( - "%s: VRF \"%s\" is missing defaul label configuration.\n", + "%s: VRF \"%s\" is missing default label configuration.\n", __func__, rfg->name); return; } diff --git a/configure.ac b/configure.ac index 901cac2318..0d56b60e72 100755 --- a/configure.ac +++ b/configure.ac @@ -122,7 +122,7 @@ AC_ARG_ENABLE([pkgsrcrcdir], pkgsrcrcdir="$enableval",) dnl XXX add --pkgsrcrcdir to autoconf standard directory list somehow AC_SUBST([pkgsrcrcdir]) -AM_CONDITIONAL([PKGSRC], [test "x$pkgsrcrcdir" != "x"]) +AM_CONDITIONAL([PKGSRC], [test "$pkgsrcrcdir" != ""]) AC_ARG_WITH([moduledir], [AS_HELP_STRING([--with-moduledir=DIR], [module directory (${libdir}/frr/modules)])], [ moduledir="$withval" @@ -197,7 +197,7 @@ AC_DEFUN([AC_C_FLAG], [{ CFLAGS="$ac_c_flag_save" AC_LANG_POP([C]) ]) - if test "${cachename}" = yes; then + if test "$cachename" = "yes"; then m4_if([$3], [], [CFLAGS="$CFLAGS $1"], [$3]) else : @@ -242,8 +242,8 @@ CC="${CC% -std=c99}" AC_C_FLAG([-std=gnu11], [CC="$ac_cc"], [CC="$CC -std=gnu11"]) dnl if the user has specified any CFLAGS, override our settings -if test "x${enable_gcov}" = "xyes"; then - if test "z$orig_cflags" = "z"; then +if test "$enable_gcov" = "yes"; then + if test "$orig_cflags" = ""; then AC_C_FLAG([-coverage]) AC_C_FLAG([-O0]) fi @@ -251,7 +251,7 @@ if test "x${enable_gcov}" = "xyes"; then LDFLAGS="${LDFLAGS} -lgcov" fi -if test "x${enable_clang_coverage}" = "xyes"; then +if test "$enable_clang_coverage" = "yes"; then AC_C_FLAG([-fprofile-instr-generate], [ AC_MSG_ERROR([$CC does not support -fprofile-instr-generate.]) ]) @@ -260,13 +260,13 @@ if test "x${enable_clang_coverage}" = "xyes"; then ]) fi -if test "x${enable_dev_build}" = "xyes"; then +if test "$enable_dev_build" = "yes"; then AC_DEFINE([DEV_BUILD], [1], [Build for development]) - if test "z$orig_cflags" = "z"; then + if test "$orig_cflags" = ""; then AC_C_FLAG([-g3]) AC_C_FLAG([-O0]) fi - if test "x${enable_lua}" = "xyes"; then + if test "$enable_lua" = "yes"; then AX_PROG_LUA([5.3]) AX_LUA_HEADERS AX_LUA_LIBS([ @@ -275,15 +275,15 @@ if test "x${enable_dev_build}" = "xyes"; then ]) fi else - if test "x${enable_lua}" = "xyes"; then + if test "$enable_lua" = "yes"; then AC_MSG_ERROR([Lua is not meant to be built/used outside of development at this time]) fi - if test "z$orig_cflags" = "z"; then + if test "$orig_cflags" = ""; then AC_C_FLAG([-g]) AC_C_FLAG([-O2]) fi fi -AM_CONDITIONAL([DEV_BUILD], [test "x$enable_dev_build" = "xyes"]) +AM_CONDITIONAL([DEV_BUILD], [test "$enable_dev_build" = "yes"]) dnl always want these CFLAGS AC_C_FLAG([-fno-omit-frame-pointer]) @@ -295,7 +295,7 @@ AC_C_FLAG([-Wmissing-declarations]) AC_C_FLAG([-Wpointer-arith]) AC_C_FLAG([-Wbad-function-cast]) AC_C_FLAG([-Wwrite-strings]) -if test x"${enable_gcc_ultra_verbose}" = x"yes" ; then +if test "$enable_gcc_ultra_verbose" = "yes" ; then AC_C_FLAG([-Wcast-qual]) AC_C_FLAG([-Wstrict-prototypes]) AC_C_FLAG([-Wmissing-noreturn]) @@ -318,7 +318,7 @@ dnl for some reason the string consts get 'promoted' to char *, dnl triggering a const to non-const conversion warning. AC_C_FLAG([-diag-disable 3179]) -if test x"${enable_werror}" = x"yes" ; then +if test "$enable_werror" = "yes" ; then WERROR="-Werror" fi AC_SUBST([WERROR]) @@ -369,7 +369,7 @@ AX_PTHREAD([ AC_SEARCH_LIBS([pthread_condattr_setclock], [], [frr_cv_pthread_condattr_setclock=yes], [frr_cv_pthread_condattr_setclock=no]) -if test "$frr_cv_pthread_condattr_setclock" = yes; then +if test "$frr_cv_pthread_condattr_setclock" = "yes"; then AC_DEFINE([HAVE_PTHREAD_CONDATTR_SETCLOCK], [1], [Have pthread.h pthread_condattr_setclock]) fi @@ -400,7 +400,7 @@ if test "$enable_shared" != "yes"; then AC_MSG_ERROR([FRR cannot be built with --disable-shared. If you want statically linked daemons, use --enable-shared --enable-static --enable-static-bin]) fi AC_SUBST([AC_LDFLAGS]) -AM_CONDITIONAL([STATIC_BIN], [test "x$enable_static_bin" = "xyes"]) +AM_CONDITIONAL([STATIC_BIN], [test "$enable_static_bin" = "yes"]) dnl $AR and $RANLIB are set by LT_INIT above AC_MSG_CHECKING([whether $AR supports D option]) @@ -451,7 +451,7 @@ AC_ARG_WITH([pkg-extra-version], ], []) AC_ARG_WITH([pkg-git-version], AS_HELP_STRING([--with-pkg-git-version], [add git information to MOTD and build version string]), - [ test "x$withval" != "xno" && with_pkg_git_version="yes" ]) + [ test "$withval" != "no" && with_pkg_git_version="yes" ]) AC_ARG_WITH([clippy], AS_HELP_STRING([--with-clippy=PATH], [use external clippy helper program])) AC_ARG_WITH([vtysh_pager], @@ -602,23 +602,23 @@ AC_ARG_WITH([crypto], AS_HELP_STRING([--with-crypto=<internal|openssl>], [choose between different implementations of cryptographic functions(default value is --with-crypto=internal)])) #if openssl, else use the internal -AS_IF([test x"${with_crypto}" = x"openssl"], [ +AS_IF([test "$with_crypto" = "openssl"], [ AC_CHECK_LIB([crypto], [EVP_DigestInit], [LIBS="$LIBS -lcrypto"], [], []) -if test $ac_cv_lib_crypto_EVP_DigestInit = no; then +if test "$ac_cv_lib_crypto_EVP_DigestInit" = "no"; then AC_MSG_ERROR([build with openssl has been specified but openssl library was not found on your system]) else AC_DEFINE([CRYPTO_OPENSSL], [1], [Compile with openssl support]) fi -], [test x"${with_crypto}" = x"internal" || test x"${with_crypto}" = x"" ], [AC_DEFINE([CRYPTO_INTERNAL], [1], [Compile with internal cryptographic implementation]) +], [test "$with_crypto" = "internal" || test "$with_crypto" = "" ], [AC_DEFINE([CRYPTO_INTERNAL], [1], [Compile with internal cryptographic implementation]) ], [AC_MSG_ERROR([Unknown value for --with-crypto])] ) -AS_IF([test "${enable_clippy_only}" != "yes"], [ +AS_IF([test "$enable_clippy_only" != "yes"], [ AC_CHECK_HEADERS([json-c/json.h]) AC_CHECK_LIB([json-c], [json_object_get], [LIBS="$LIBS -ljson-c"], [], [-lm]) -if test "$ac_cv_lib_json_c_json_object_get" = no; then +if test "$ac_cv_lib_json_c_json_object_get" = "no"; then AC_CHECK_LIB([json], [json_object_get], [LIBS="$LIBS -ljson"]) - if test "$ac_cv_lib_json_json_object_get" = no; then + if test "$ac_cv_lib_json_json_object_get" = "no"; then AC_MSG_ERROR([libjson is needed to compile]) fi fi @@ -630,8 +630,8 @@ AC_ARG_ENABLE([dev_build], AC_ARG_ENABLE([lua], AS_HELP_STRING([--enable-lua], [Build Lua scripting])) -if test x"${enable_time_check}" != x"no" ; then - if test x"${enable_time_check}" = x"yes" -o x"${enable_time_check}" = x ; then +if test "$enable_time_check" != "no" ; then + if test "$enable_time_check" = "yes" -o "$enable_time_check" = "" ; then AC_DEFINE([CONSUMED_TIME_CHECK], [5000000], [Consumed Time Check]) else AC_DEFINE_UNQUOTED([CONSUMED_TIME_CHECK], [$enable_time_check], [Consumed Time Check]) @@ -650,7 +650,7 @@ case "${enable_systemd}" in "no") ;; "yes") AC_CHECK_LIB([systemd], [sd_notify], [LIBS="$LIBS -lsystemd"]) - if test $ac_cv_lib_systemd_sd_notify = no; then + if test "$ac_cv_lib_systemd_sd_notify" = "no"; then AC_MSG_ERROR([enable systemd has been specified but systemd development env not found on your system]) else AC_DEFINE([HAVE_SYSTEMD], [1], [Compile systemd support in]) @@ -659,11 +659,11 @@ case "${enable_systemd}" in "*") ;; esac -if test "${enable_rr_semantics}" != "no" ; then +if test "$enable_rr_semantics" != "no" ; then AC_DEFINE([HAVE_V6_RR_SEMANTICS], [1], [Compile in v6 Route Replacement Semantics]) fi -if test "${enable_datacenter}" = "yes" ; then +if test "$enable_datacenter" = "yes" ; then AC_DEFINE([HAVE_DATACENTER], [1], [Compile extensions for a DataCenter]) AC_MSG_WARN([The --enable-datacenter compile time option is deprecated. Please modify the init script to pass -F datacenter to the daemons instead.]) DFLT_NAME="datacenter" @@ -671,22 +671,22 @@ else DFLT_NAME="traditional" fi -if test "${enable_fuzzing}" = "yes" ; then +if test "$enable_fuzzing" = "yes" ; then AC_DEFINE([HANDLE_ZAPI_FUZZING], [1], [Compile extensions to use with a fuzzer]) fi -if test "${enable_netlink_fuzzing}" = "yes" ; then +if test "$enable_netlink_fuzzing" = "yes" ; then AC_DEFINE([HANDLE_NETLINK_FUZZING], [1], [Compile extensions to use with a fuzzer for netlink]) fi -if test "${enable_cumulus}" = "yes" ; then +if test "$enable_cumulus" = "yes" ; then AC_DEFINE([HAVE_CUMULUS], [1], [Compile Special Cumulus Code in]) fi AC_SUBST([DFLT_NAME]) AC_DEFINE_UNQUOTED([DFLT_NAME], ["$DFLT_NAME"], [Name of the configuration default set]) -if test "${enable_shell_access}" = "yes"; then +if test "$enable_shell_access" = "yes"; then AC_DEFINE([HAVE_SHELL_ACCESS], [1], [Allow user to use ssh/telnet/bash, be aware this is considered insecure]) fi @@ -702,15 +702,15 @@ AS_IF([test "$host" = "$build"], [ FRR_PYTHON_MODULES([pytest]) -if test "${enable_doc}" != "no"; then +if test "$enable_doc" != "no"; then FRR_PYTHON_MODULES([sphinx], , [ - if test "${enable_doc}" = "yes"; then + if test "$enable_doc" = "yes"; then AC_MSG_ERROR([Documentation was explicitly requested with --enable-doc but sphinx is not available for $PYTHON. Please disable docs or install sphinx.]) fi ]) fi -AM_CONDITIONAL([DOC], [test "${enable_doc}" != "no" -a "$frr_py_mod_sphinx" != "false"]) -AM_CONDITIONAL([DOC_HTML], [test "${enable_doc_html}" = "yes"]) +AM_CONDITIONAL([DOC], [test "$enable_doc" != "no" -a "$frr_py_mod_sphinx" != "false"]) +AM_CONDITIONAL([DOC_HTML], [test "$enable_doc_html" = "yes"]) FRR_PYTHON_MOD_EXEC([sphinx], [--version], [ PYSPHINX="-m sphinx" @@ -731,35 +731,35 @@ fi # AC_MSG_CHECKING([if zebra should be configurable to send Route Advertisements]) -if test "${enable_rtadv}" != "no"; then +if test "$enable_rtadv" != "no"; then AC_MSG_RESULT([yes]) AC_DEFINE([HAVE_RTADV], [1], [Enable IPv6 Routing Advertisement support]) else AC_MSG_RESULT([no]) fi -if test x"${enable_user}" = x"no"; then +if test "$enable_user" = "no"; then enable_user="" else - if test x"${enable_user}" = x"yes" || test x"${enable_user}" = x""; then + if test "$enable_user" = "yes" || test "$enable_user" = ""; then enable_user="frr" fi AC_DEFINE_UNQUOTED([FRR_USER], ["${enable_user}"], [frr User]) fi -if test x"${enable_group}" = x"no"; then +if test "$enable_group" = "no"; then enable_group="" else - if test x"${enable_group}" = x"yes" || test x"${enable_group}" = x""; then + if test "$enable_group" = "yes" || test "$enable_group" = ""; then enable_group="frr" fi AC_DEFINE_UNQUOTED([FRR_GROUP], ["${enable_group}"], [frr Group]) fi -if test x"${enable_vty_group}" = x"yes" ; then +if test "$enable_vty_group" = "yes" ; then AC_MSG_ERROR([--enable-vty-group requires a group as argument, not yes]) -elif test x"${enable_vty_group}" != x""; then - if test x"${enable_vty_group}" != x"no"; then +elif test "$enable_vty_group" != ""; then + if test "$enable_vty_group" != "no"; then AC_DEFINE_UNQUOTED([VTY_GROUP], ["${enable_vty_group}"], [VTY Sockets Group]) fi fi @@ -784,7 +784,7 @@ case "${enable_multipath}" in ;; "") ;; - *) + *) AC_MSG_FAILURE([Please specify digit to enable multipath ARG]) ;; esac @@ -796,12 +796,12 @@ AC_DEFINE_UNQUOTED([VTYSH_PAGER], ["$VTYSH_PAGER"], [What pager to use]) dnl -------------------- dnl Enable code coverage dnl -------------------- -AM_CONDITIONAL([HAVE_GCOV], [test '!' "$enable_gcov" = no]) +AM_CONDITIONAL([HAVE_GCOV], [test "$enable_gcov" != "no"]) dnl ------------------------------------ dnl Alpine only accepts numeric versions dnl ------------------------------------ -if test "x${enable_numeric_version}" != "x" ; then +if test "$enable_numeric_version" != "" ; then VERSION="`echo ${VERSION} | tr -c -d '[[.0-9]]'`" PACKAGE_VERSION="`echo ${PACKAGE_VERSION} | tr -c -d '[[.0-9]]'`" fi @@ -810,7 +810,7 @@ dnl ----------------------------------- dnl Add extra version string to package dnl name, string and version fields. dnl ----------------------------------- -if test "x${EXTRAVERSION}" != "x" ; then +if test "$EXTRAVERSION" != "" ; then VERSION="${VERSION}${EXTRAVERSION}" PACKAGE_VERSION="${PACKAGE_VERSION}${EXTRAVERSION}" AC_SUBST(PACKAGE_EXTRAVERSION, ["${EXTRAVERSION}"]) @@ -818,17 +818,17 @@ if test "x${EXTRAVERSION}" != "x" ; then fi AC_SUBST([EXTRAVERSION]) -if test "x$with_pkg_git_version" = "xyes"; then +if test "$with_pkg_git_version" = "yes"; then if test -d "${srcdir}/.git"; then AC_DEFINE([GIT_VERSION], [1], [include git version info]) else with_pkg_git_version="no" AC_MSG_WARN([--with-pkg-git-version given, but this is not a git checkout]) fi fi -AM_CONDITIONAL([GIT_VERSION], [test "x$with_pkg_git_version" = "xyes"]) +AM_CONDITIONAL([GIT_VERSION], [test "$with_pkg_git_version" = "yes"]) AC_CHECK_TOOL([OBJCOPY], [objcopy], [:]) -if test "x${OBJCOPY}" != "x:"; then +if test "$OBJCOPY" != ":"; then AC_CACHE_CHECK([for .interp value to use], [frr_cv_interp], [ frr_cv_interp="" AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])], [ @@ -1026,7 +1026,7 @@ AC_CHECK_HEADERS([net/if_var.h], [], [], [FRR_INCLUDES]) m4_define([FRR_INCLUDES], FRR_INCLUDES -[#if HAVE_NET_IF_VAR_H +[#ifdef HAVE_NET_IF_VAR_H # include <net/if_var.h> #endif ])dnl @@ -1061,22 +1061,22 @@ FRR_INCLUDES [ #include <sys/un.h> #include <netinet/in_systm.h> -#if HAVE_NETINET_IN_VAR_H +#ifdef HAVE_NETINET_IN_VAR_H # include <netinet/in_var.h> #endif -#if HAVE_NET_IF_DL_H +#ifdef HAVE_NET_IF_DL_H # include <net/if_dl.h> #endif -#if HAVE_NET_NETOPT_H +#ifdef HAVE_NET_NETOPT_H # include <net/netopt.h> #endif #include <net/route.h> -#if HAVE_INET_ND_H +#ifdef HAVE_INET_ND_H # include <inet/nd.h> #endif #include <arpa/inet.h> /* Required for IDRP */ -#if HAVE_NETINET_IP_ICMP_H +#ifdef HAVE_NETINET_IP_ICMP_H # include <netinet/ip_icmp.h> #endif ])dnl @@ -1123,7 +1123,7 @@ case "$host_os" in AC_DEFINE([KAME], [1], [KAME IPv6]) AC_DEFINE([BSD_V6_SYSCTL], [1], [BSD v6 sysctl to turn on and off forwarding]) - if test "x${enable_pimd}" != "xno"; then + if test "$enable_pimd" != "no"; then case "$host_os" in openbsd6.0) ;; @@ -1141,7 +1141,7 @@ case "$host_os" in AC_DEFINE([BSD_V6_SYSCTL], [1], [BSD v6 sysctl to turn on and off forwarding]) ;; esac -AM_CONDITIONAL([SOLARIS], [test "${SOLARIS}" = "solaris"]) +AM_CONDITIONAL([SOLARIS], [test "$SOLARIS" = "solaris"]) AM_CONDITIONAL([LINUX], [${is_linux}]) AC_SYS_LARGEFILE @@ -1149,7 +1149,7 @@ AC_SYS_LARGEFILE dnl ------------------------ dnl Integrated REALMS option dnl ------------------------ -if test "${enable_realms}" = "yes"; then +if test "$enable_realms" = "yes"; then case "$host_os" in linux*) AC_DEFINE([SUPPORT_REALMS], [1], [Realms support]) @@ -1175,7 +1175,7 @@ AC_CHECK_FUNCS([ \ dnl ########################################################################## dnl LARGE if block spans a lot of "configure"! -if test "${enable_clippy_only}" != "yes"; then +if test "$enable_clippy_only" != "yes"; then dnl ########################################################################## # @@ -1243,15 +1243,15 @@ case "${enable_vtysh}" in LIBS="$prev_libs" AC_CHECK_HEADER([readline/history.h]) - if test $ac_cv_header_readline_history_h = no;then + if test "$ac_cv_header_readline_history_h" = "no"; then AC_MSG_ERROR([readline is too old to have readline/history.h, please update to the latest readline library.]) fi AC_CHECK_LIB([readline], [rl_completion_matches], [true], [], [$LIBREADLINE]) - if test $ac_cv_lib_readline_rl_completion_matches = no; then + if test "$ac_cv_lib_readline_rl_completion_matches" = "no"; then AC_DEFINE([rl_completion_matches], [completion_matches], [Old readline]) fi AC_CHECK_LIB([readline], [append_history], [frr_cv_append_history=yes], [frr_cv_append_history=no], [$LIBREADLINE]) - if test "$frr_cv_append_history" = yes; then + if test "$frr_cv_append_history" = "yes"; then AC_DEFINE([HAVE_APPEND_HISTORY], [1], [Have history.h append_history]) fi ;; @@ -1366,10 +1366,10 @@ case "$host_os" in ISIS_METHOD_MACRO="ISIS_METHOD_DLPI" ;; *) - if test $ac_cv_header_net_bpf_h = no; then - if test $ac_cv_header_sys_dlpi_h = no; then + if test "$ac_cv_header_net_bpf_h" = "no"; then + if test "$ac_cv_header_sys_dlpi_h" = "no"; then AC_MSG_RESULT([none]) - if test "${enable_isisd}" = yes -o "${enable_fabricd}" = yes; then + if test "$enable_isisd" = "yes" -o "$enable_fabricd" = "yes"; then AC_MSG_FAILURE([IS-IS support requested but no packet backend found]) fi AC_MSG_WARN([*** IS-IS support will not be built ***]) @@ -1401,7 +1401,7 @@ AC_CHECK_HEADERS([linux/mroute.h], [], [],[ m4_define([FRR_INCLUDES], FRR_INCLUDES -[#if HAVE_LINUX_MROUTE_H +[#ifdef HAVE_LINUX_MROUTE_H # include <linux/mroute.h> #endif ])dnl @@ -1415,7 +1415,7 @@ AC_CHECK_HEADERS([netinet/ip_mroute.h], [], [],[ m4_define([FRR_INCLUDES], FRR_INCLUDES -[#if HAVE_NETINET_IP_MROUTE_H +[#ifdef HAVE_NETINET_IP_MROUTE_H # include <netinet/ip_mroute.h> #endif ])dnl @@ -1473,7 +1473,7 @@ AC_CHECK_HEADER([netinet/tcp.h], AC_CHECK_DECLS([TCP_MD5SIG], [], [], MD5_INCLUDES)], [], FRR_INCLUDES) -if test $ac_cv_have_decl_TCP_MD5SIG = no; then +if test "$ac_cv_have_decl_TCP_MD5SIG" = "no"; then AC_CHECK_HEADER([linux/tcp.h], [m4_define([MD5_INCLUDES], FRR_INCLUDES @@ -1490,7 +1490,7 @@ AC_CHECK_LIB([resolv], [res_init]) dnl --------------------------- dnl check system has PCRE regexp dnl --------------------------- -if test "x$enable_pcreposix" = "xyes"; then +if test "$enable_pcreposix" = "yes"; then AC_CHECK_LIB([pcreposix], [regexec], [], [ AC_MSG_ERROR([--enable-pcreposix given but unable to find libpcreposix]) ]) @@ -1498,7 +1498,7 @@ fi AC_SUBST([HAVE_LIBPCREPOSIX]) dnl ########################################################################## -dnl test "${enable_clippy_only}" != "yes" +dnl test "$enable_clippy_only" != "yes" fi dnl END OF LARGE if block dnl ########################################################################## @@ -1528,17 +1528,17 @@ AC_CHECK_HEADERS([netinet6/in6.h netinet/in6_var.h \ m4_define([FRR_INCLUDES],dnl FRR_INCLUDES -[#if HAVE_NETINET6_IN6_H +[#ifdef HAVE_NETINET6_IN6_H #include <netinet6/in6.h> #endif -#if HAVE_NETINET_IN6_VAR_H +#ifdef HAVE_NETINET_IN6_VAR_H #include <netinet/in6_var.h> #endif #include <netinet/icmp6.h> -#if HAVE_NETINET6_IN6_VAR_H +#ifdef HAVE_NETINET6_IN6_VAR_H # include <netinet6/in6_var.h> #endif -#if HAVE_NETINET6_ND6_H +#ifdef HAVE_NETINET6_ND6_H # include <netinet6/nd6.h> #endif ])dnl @@ -1547,7 +1547,7 @@ dnl -------------------- dnl Daemon disable check dnl -------------------- -AS_IF([test "${enable_ldpd}" != "no"], [ +AS_IF([test "$enable_ldpd" != "no"], [ AC_DEFINE([HAVE_LDPD], [1], [ldpd]) ]) @@ -1569,7 +1569,7 @@ else esac fi -if test "$ac_cv_lib_json_c_json_object_get" = no -a "x$BFDD" = "xbfdd"; then +if test "$ac_cv_lib_json_c_json_object_get" = "no" -a "$BFDD" = "bfdd"; then AC_MSG_ERROR(["you must use json-c library to use bfdd"]) fi @@ -1580,7 +1580,7 @@ case "$host_os" in no) ;; yes) - if test "${enable_clippy_only}" != "yes"; then + if test "$enable_clippy_only" != "yes"; then if test "$c_ares_found" != "true" ; then AC_MSG_ERROR([nhrpd requires libcares. Please install c-ares and its -dev headers.]) fi @@ -1595,34 +1595,34 @@ case "$host_os" in esac ;; *) - if test "${enable_nhrpd}" = "yes"; then + if test "$enable_nhrpd" = "yes"; then AC_MSG_ERROR([nhrpd requires kernel APIs that are only present on Linux.]) fi ;; esac -if test "${enable_watchfrr}" = "no";then +if test "$enable_watchfrr" = "no";then WATCHFRR="" else WATCHFRR="watchfrr" fi OSPFCLIENT="" -if test "${enable_ospfapi}" != "no";then +if test "$enable_ospfapi" != "no";then AC_DEFINE([SUPPORT_OSPF_API], [1], [OSPFAPI]) - if test "${enable_ospfclient}" != "no";then + if test "$enable_ospfclient" != "no";then OSPFCLIENT="ospfclient" fi fi -if test "${enable_bgp_announce}" = "no";then +if test "$enable_bgp_announce" = "no";then AC_DEFINE([DISABLE_BGP_ANNOUNCE], [1], [Disable BGP installation to zebra]) else AC_DEFINE([DISABLE_BGP_ANNOUNCE], [0], [Disable BGP installation to zebra]) fi -if test "${enable_bgp_vnc}" != "no";then +if test "$enable_bgp_vnc" != "no";then AC_DEFINE([ENABLE_BGP_VNC], [1], [Enable BGP VNC support]) fi @@ -1645,15 +1645,15 @@ esac dnl ########################################################################## dnl LARGE if block -if test "${enable_clippy_only}" != "yes"; then +if test "$enable_clippy_only" != "yes"; then dnl ########################################################################## dnl ------------------ dnl check Net-SNMP library dnl ------------------ -if test "${enable_snmp}" != "" -a "${enable_snmp}" != "no"; then +if test "$enable_snmp" != "" -a "$enable_snmp" != "no"; then AC_PATH_TOOL([NETSNMP_CONFIG], [net-snmp-config], [no]) - if test x"$NETSNMP_CONFIG" = x"no"; then + if test "$NETSNMP_CONFIG" = "no"; then AC_MSG_ERROR([--enable-snmp given but unable to find net-snmp-config]) fi SNMP_LIBS="`${NETSNMP_CONFIG} --agent-libs`" @@ -1726,7 +1726,7 @@ dnl confd dnl --------------- if test "$enable_confd" != "" -a "$enable_confd" != "no"; then AC_CHECK_PROG([CONFD], [confd], [confd], [/bin/false], "${enable_confd}/bin") - if test "x$CONFD" = "x/bin/false"; then + if test "$CONFD" = "/bin/false"; then AC_MSG_ERROR([confd was not found on your system.])] fi CONFD_CFLAGS="-I${enable_confd}/include -L${enable_confd}/lib" @@ -1769,12 +1769,12 @@ fi dnl ------ dnl ZeroMQ dnl ------ -if test "x$enable_zeromq" != "xno"; then +if test "$enable_zeromq" != "no"; then PKG_CHECK_MODULES([ZEROMQ], [libzmq >= 4.0.0], [ AC_DEFINE([HAVE_ZEROMQ], [1], [Enable ZeroMQ support]) ZEROMQ=true ], [ - if test "x$enable_zeromq" = "xyes"; then + if test "$enable_zeromq" = "yes"; then AC_MSG_ERROR([configuration specifies --enable-zeromq but libzmq was not found]) fi ]) @@ -1783,7 +1783,7 @@ fi dnl ------------------------------------ dnl Enable RPKI and add librtr to libs dnl ------------------------------------ -if test "${enable_rpki}" = "yes"; then +if test "$enable_rpki" = "yes"; then PKG_CHECK_MODULES([RTRLIB], [rtrlib >= 0.5.0], [RPKI=true], [RPKI=false @@ -1827,7 +1827,7 @@ AC_CACHE_CHECK([for dlinfo(RTLD_DI_ORIGIN)], [frr_cv_rtld_di_origin], [ frr_cv_rtld_di_origin=no ]) ]) -if test "$frr_cv_rtld_di_origin" = yes; then +if test "$frr_cv_rtld_di_origin" = "yes"; then AC_DEFINE([HAVE_DLINFO_ORIGIN], [1], [Have dlinfo RTLD_DI_ORIGIN]) fi @@ -1847,12 +1847,12 @@ AC_CACHE_CHECK([for dlinfo(RTLD_DI_LINKMAP)], [frr_cv_rtld_di_linkmap], [ frr_cv_rtld_di_linkmap=no ]) ]) -if test "$frr_cv_rtld_di_linkmap" = yes; then +if test "$frr_cv_rtld_di_linkmap" = "yes"; then AC_DEFINE([HAVE_DLINFO_LINKMAP], [1], [Have dlinfo RTLD_DI_LINKMAP]) fi dnl ########################################################################## -dnl test "${enable_clippy_only}" != "yes" +dnl test "$enable_clippy_only" != "yes" fi dnl END OF LARGE if block dnl ########################################################################## @@ -2052,7 +2052,7 @@ fi dnl ------------------- dnl capabilities checks dnl ------------------- -if test "${enable_capabilities}" != "no"; then +if test "$enable_capabilities" != "no"; then AC_MSG_CHECKING([whether prctl PR_SET_KEEPCAPS is available]) AC_TRY_COMPILE([#include <sys/prctl.h>], [prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0);], [AC_MSG_RESULT([yes]) @@ -2060,11 +2060,11 @@ if test "${enable_capabilities}" != "no"; then frr_ac_keepcaps="yes"], AC_MSG_RESULT([no]) ) - if test x"${frr_ac_keepcaps}" = x"yes"; then + if test "$frr_ac_keepcaps" = "yes"; then AC_CHECK_HEADERS([sys/capability.h]) fi - if test x"${ac_cv_header_sys_capability_h}" = x"yes"; then - AC_CHECK_LIB([cap], [cap_init], + if test "$ac_cv_header_sys_capability_h" = "yes"; then + AC_CHECK_LIB([cap], [cap_init], [AC_DEFINE([HAVE_LCAPS], [1], [Capabilities]) LIBCAP="-lcap" frr_ac_lcaps="yes"] @@ -2081,14 +2081,14 @@ if test "${enable_capabilities}" != "no"; then ] ) fi - if test x"${frr_ac_scaps}" = x"yes" \ - -o x"${frr_ac_lcaps}" = x"yes"; then + if test "$frr_ac_scaps" = "yes" \ + -o "$frr_ac_lcaps" = "yes"; then AC_DEFINE([HAVE_CAPABILITIES], [1], [capabilities]) fi case "$host_os" in linux*) - if test "${enable_clippy_only}" != "yes"; then + if test "$enable_clippy_only" != "yes"; then if test "$frr_ac_lcaps" != "yes"; then AC_MSG_ERROR([libcap and/or its headers were not found. Running FRR without libcap support built in causes a huge performance penalty.]) fi @@ -2106,8 +2106,8 @@ AC_SUBST([LIBCAP]) dnl --------------------------- dnl check for glibc 'backtrace' -dnl --------------------------- -if test x"${enable_backtrace}" != x"no" ; then +dnl --------------------------- +if test "$enable_backtrace" != "no" ; then backtrace_ok=no PKG_CHECK_MODULES([UNWIND], [libunwind], [ AC_DEFINE([HAVE_LIBUNWIND], [1], [libunwind]) @@ -2134,7 +2134,7 @@ if test x"${enable_backtrace}" != x"no" ; then ]) ;; esac - if test "$backtrace_ok" = no; then + if test "$backtrace_ok" = "no"; then AC_CHECK_HEADER([execinfo.h], [ AC_SEARCH_LIBS([backtrace], [execinfo], [ AC_DEFINE([HAVE_GLIBC_BACKTRACE], [1], [Glibc backtrace]) @@ -2144,7 +2144,7 @@ if test x"${enable_backtrace}" != x"no" ; then fi fi - if test x"${enable_backtrace}" = x"yes" -a x"${backtrace_ok}" = x"no"; then + if test "$enable_backtrace" = "yes" -a "$backtrace_ok" = "no"; then dnl user explicitly requested backtrace but we failed to find support AC_MSG_FAILURE([failed to find backtrace or libunwind support]) fi @@ -2178,7 +2178,7 @@ struct mallinfo ac_x; ac_x = mallinfo (); frr_cv_mallinfo=no ]) ]) -if test "$frr_cv_mallinfo" = yes; then +if test "$frr_cv_mallinfo" = "yes"; then AC_DEFINE([HAVE_MALLINFO], [1], [mallinfo]) fi @@ -2221,7 +2221,7 @@ dnl configure date dnl ---------- dev_version=`echo $VERSION | grep dev` #don't expire deprecated code in non 'dev' branch -if test "${dev_version}" = ""; then +if test "$dev_version" = ""; then CONFDATE=0 else CONFDATE=`date '+%Y%m%d'` @@ -2232,12 +2232,12 @@ dnl ------------------------------ dnl set paths for state directory dnl ------------------------------ AC_MSG_CHECKING([directory to use for state file]) -if test "${prefix}" = "NONE"; then +if test "$prefix" = "NONE"; then frr_statedir_prefix=""; else frr_statedir_prefix=${prefix} fi -if test "${localstatedir}" = '${prefix}/var'; then +if test "$localstatedir" = '${prefix}/var'; then for FRR_STATE_DIR in ${frr_statedir_prefix}/var/run dnl ${frr_statedir_prefix}/var/adm dnl ${frr_statedir_prefix}/etc dnl @@ -2252,7 +2252,7 @@ if test "${localstatedir}" = '${prefix}/var'; then else frr_statedir=${localstatedir} fi -if test $frr_statedir = "/dev/null"; then +if test "$frr_statedir" = "/dev/null"; then AC_MSG_ERROR([STATE DIRECTORY NOT FOUND! FIX OR SPECIFY --localstatedir!]) fi AC_MSG_RESULT([${frr_statedir}]) @@ -2265,8 +2265,8 @@ AC_DEFINE_UNQUOTED([DAEMON_VTY_DIR], ["$frr_statedir%s%s"], [daemon vty director AC_DEFINE_UNQUOTED([DAEMON_DB_DIR], ["$frr_statedir"], [daemon database directory]) dnl autoconf does this, but it does it too late... -test "x$prefix" = xNONE && prefix=$ac_default_prefix -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' +test "$prefix" = "NONE" && prefix=$ac_default_prefix +test "$exec_prefix" = "NONE" && exec_prefix='${prefix}' dnl get the full path, recursing through variables... vtysh_bin="$bindir/vtysh" @@ -2298,44 +2298,44 @@ AC_DEFINE_UNQUOTED([YANG_MODELS_PATH], ["$CFG_YANGMODELS"], [path to YANG data m AC_DEFINE_UNQUOTED([WATCHFRR_SH_PATH], ["${CFG_SBIN%/}/watchfrr.sh"], [path to watchfrr.sh]) dnl various features -AM_CONDITIONAL([SUPPORT_REALMS], [test "${enable_realms}" = "yes"]) -AM_CONDITIONAL([ENABLE_BGP_VNC], [test x${enable_bgp_vnc} != xno]) +AM_CONDITIONAL([SUPPORT_REALMS], [test "$enable_realms" = "yes"]) +AM_CONDITIONAL([ENABLE_BGP_VNC], [test "$enable_bgp_vnc" != "no"]) AM_CONDITIONAL([BGP_BMP], [$bgpd_bmp]) dnl northbound AM_CONDITIONAL([SQLITE3], [$SQLITE3]) -AM_CONDITIONAL([CONFD], [test "x$enable_confd" != "x"]) -AM_CONDITIONAL([SYSREPO], [test "x$enable_sysrepo" = "xyes"]) -AM_CONDITIONAL([GRPC], [test "x$enable_grpc" = "xyes"]) -AM_CONDITIONAL([ZEROMQ], [test "x$ZEROMQ" = "xtrue"]) +AM_CONDITIONAL([CONFD], [test "$enable_confd" != ""]) +AM_CONDITIONAL([SYSREPO], [test "$enable_sysrepo" = "yes"]) +AM_CONDITIONAL([GRPC], [test "$enable_grpc" = "yes"]) +AM_CONDITIONAL([ZEROMQ], [test "$ZEROMQ" = "true"]) dnl plugins -AM_CONDITIONAL([RPKI], [test "x$RPKI" = "xtrue"]) -AM_CONDITIONAL([SNMP], [test "x$SNMP_METHOD" = "xagentx"]) +AM_CONDITIONAL([RPKI], [test "$RPKI" = "true"]) +AM_CONDITIONAL([SNMP], [test "$SNMP_METHOD" = "agentx"]) AM_CONDITIONAL([IRDP], [$IRDP]) -AM_CONDITIONAL([FPM], [test "x$enable_fpm" = "xyes"]) -AM_CONDITIONAL([HAVE_PROTOBUF], [test "x$enable_protobuf" = "xyes"]) +AM_CONDITIONAL([FPM], [test "$enable_fpm" = "yes"]) +AM_CONDITIONAL([HAVE_PROTOBUF], [test "$enable_protobuf" = "yes"]) AM_CONDITIONAL([HAVE_PROTOBUF3], [$PROTO3]) dnl daemons -AM_CONDITIONAL([VTYSH], [test "x$VTYSH" = "xvtysh"]) -AM_CONDITIONAL([ZEBRA], [test "${enable_zebra}" != "no"]) -AM_CONDITIONAL([BGPD], [test "x${enable_bgpd}" != "no"]) -AM_CONDITIONAL([RIPD], [test "${enable_ripd}" != "no"]) -AM_CONDITIONAL([OSPFD], [test "${enable_ospfd}" != "no"]) -AM_CONDITIONAL([LDPD], [test "${enable_ldpd}" != "no"]) -AM_CONDITIONAL([BFDD], [test "x$BFDD" = "xbfdd"]) -AM_CONDITIONAL([NHRPD], [test "x$NHRPD" = "xnhrpd"]) -AM_CONDITIONAL([EIGRPD], [test "${enable_eigrpd}" != "no"]) -AM_CONDITIONAL([WATCHFRR], [test "x$WATCHFRR" = "xwatchfrr"]) -AM_CONDITIONAL([OSPFCLIENT], [test "x$OSPFCLIENT" = "xospfclient"]) -AM_CONDITIONAL([RIPNGD], [test "${enable_ripngd}" != "no"]) -AM_CONDITIONAL([BABELD], [test "${enable_babeld}" != "no"]) -AM_CONDITIONAL([OSPF6D], [test "${enable_ospf6d}" != "no"]) -AM_CONDITIONAL([ISISD], [test "${enable_isisd}" != "no"]) -AM_CONDITIONAL([PIMD], [test "${enable_pimd}" != "no"]) -AM_CONDITIONAL([PBRD], [test "${enable_pbrd}" != "no"]) -AM_CONDITIONAL([SHARPD], [test "${enable_sharpd}" = "yes"]) -AM_CONDITIONAL([STATICD], [test "${enable_staticd}" != "no"]) -AM_CONDITIONAL([FABRICD], [test "${enable_fabricd}" != "no"]) -AM_CONDITIONAL([VRRPD], [test "${enable_vrrpd}" != "no"]) +AM_CONDITIONAL([VTYSH], [test "$VTYSH" = "vtysh"]) +AM_CONDITIONAL([ZEBRA], [test "$enable_zebra" != "no"]) +AM_CONDITIONAL([BGPD], [test "$enable_bgpd" != "no"]) +AM_CONDITIONAL([RIPD], [test "$enable_ripd" != "no"]) +AM_CONDITIONAL([OSPFD], [test "$enable_ospfd" != "no"]) +AM_CONDITIONAL([LDPD], [test "$enable_ldpd" != "no"]) +AM_CONDITIONAL([BFDD], [test "$BFDD" = "bfdd"]) +AM_CONDITIONAL([NHRPD], [test "$NHRPD" = "nhrpd"]) +AM_CONDITIONAL([EIGRPD], [test "$enable_eigrpd" != "no"]) +AM_CONDITIONAL([WATCHFRR], [test "$WATCHFRR" = "watchfrr"]) +AM_CONDITIONAL([OSPFCLIENT], [test "$OSPFCLIENT" = "ospfclient"]) +AM_CONDITIONAL([RIPNGD], [test "$enable_ripngd" != "no"]) +AM_CONDITIONAL([BABELD], [test "$enable_babeld" != "no"]) +AM_CONDITIONAL([OSPF6D], [test "$enable_ospf6d" != "no"]) +AM_CONDITIONAL([ISISD], [test "$enable_isisd" != "no"]) +AM_CONDITIONAL([PIMD], [test "$enable_pimd" != "no"]) +AM_CONDITIONAL([PBRD], [test "$enable_pbrd" != "no"]) +AM_CONDITIONAL([SHARPD], [test "$enable_sharpd" = "yes"]) +AM_CONDITIONAL([STATICD], [test "$enable_staticd" != "no"]) +AM_CONDITIONAL([FABRICD], [test "$enable_fabricd" != "no"]) +AM_CONDITIONAL([VRRPD], [test "$enable_vrrpd" != "no"]) AC_CONFIG_FILES([Makefile],[sed -e 's/^#AUTODERP# //' -i Makefile]) @@ -2363,7 +2363,7 @@ AC_CONFIG_COMMANDS([lib/route_types.h], [ ${PERL} "${ac_abs_top_srcdir}/lib/route_types.pl" \ < "${ac_abs_top_srcdir}/lib/route_types.txt" \ > "${dst}.tmp" - test -f "${dst}" \ + test -f "$dst" \ && diff "${dst}.tmp" "${dst}" >/dev/null 2>/dev/null \ && rm "${dst}.tmp" \ || mv "${dst}.tmp" "${dst}" @@ -2371,13 +2371,13 @@ AC_CONFIG_COMMANDS([lib/route_types.h], [ PERL="$PERL" ]) -AS_IF([test "x$with_pkg_git_version" = "xyes"], [ +AS_IF([test "$with_pkg_git_version" = "yes"], [ AC_CONFIG_COMMANDS([lib/gitversion.h], [ dst="${ac_abs_top_builddir}/lib/gitversion.h" ${PERL} "${ac_abs_top_srcdir}/lib/gitversion.pl" \ "${ac_abs_top_srcdir}" \ > "${dst}.tmp" - test -f "${dst}" \ + test -f "$dst" \ && diff "${dst}.tmp" "${dst}" >/dev/null 2>/dev/null \ && rm "${dst}.tmp" \ || mv "${dst}.tmp" "${dst}" @@ -2414,9 +2414,9 @@ zebra protobuf enabled : ${enable_protobuf:-no} The above user and group must have read/write access to the state file directory and to the config files in the config file directory." -if test "${enable_doc}" != "no" -a "$frr_py_mod_sphinx" = false; then +if test "$enable_doc" != "no" -a "$frr_py_mod_sphinx" = "false"; then AC_MSG_WARN([sphinx is missing but required to build documentation]) fi -if test "$frr_py_mod_pytest" = false; then +if test "$frr_py_mod_pytest" = "false"; then AC_MSG_WARN([pytest is missing, unit tests cannot be performed]) fi diff --git a/doc/developer/cli.rst b/doc/developer/cli.rst index 12fcb7a325..edabe61d92 100644 --- a/doc/developer/cli.rst +++ b/doc/developer/cli.rst @@ -101,7 +101,7 @@ Definition Grammar FRR uses its own grammar for defining CLI commands. The grammar draws from syntax commonly seen in \*nix manpages and should be fairly intuitive. The parser is implemented in Bison and the lexer in Flex. These may be found in -``lib/command_lex.l`` and ``lib/command_parse.y``, respectively. +``lib/command_parse.y`` and ``lib/command_lex.l``, respectively. **ProTip**: if you define a new command and find that the parser is throwing syntax or other errors, the parser is the last place you want diff --git a/doc/manpages/conf.py b/doc/manpages/conf.py index 9121d38fe0..8b9bb021a3 100644 --- a/doc/manpages/conf.py +++ b/doc/manpages/conf.py @@ -192,7 +192,7 @@ html_theme = 'default' # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +html_static_path = [] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied diff --git a/doc/user/bgp.rst b/doc/user/bgp.rst index de690adb34..85ccc277a8 100644 --- a/doc/user/bgp.rst +++ b/doc/user/bgp.rst @@ -2412,6 +2412,12 @@ Debugging Show all enabled debugs. +.. index:: show bgp listeners +.. clicmd:: show bgp listeners + + Display Listen sockets and the vrf that created them. Useful for debugging of when + listen is not working and this is considered a developer debug statement. + .. index:: [no] debug bgp neighbor-events .. clicmd:: [no] debug bgp neighbor-events diff --git a/doc/user/overview.rst b/doc/user/overview.rst index b72ceb8d38..eca521c1e5 100644 --- a/doc/user/overview.rst +++ b/doc/user/overview.rst @@ -300,6 +300,8 @@ BGP :t:`The Generalized TTL Security Mechanism (GTSM). V. Gill, J. Heasley, D. Meyer, P. Savola, C. Pingnataro. October 2007.` - :rfc:`5575` :t:`Dissemination of Flow Specification Rules. P. Marques, N. Sheth, R. Raszuk, B. Greene, J. Mauch, D. McPherson. August 2009` +- :rfc:`6608` + :t:`Subcodes for BGP Finite State Machine Error. J. Dong, M. Chen, Huawei Technologies, A. Suryanarayana, Cisco Systems. May 2012.` - :rfc:`6810` :t:`The Resource Public Key Infrastructure (RPKI) to Router Protocol. R. Bush, R. Austein. January 2013.` - :rfc:`6811` diff --git a/doc/user/pim.rst b/doc/user/pim.rst index 9876216736..36c8b44aa4 100644 --- a/doc/user/pim.rst +++ b/doc/user/pim.rst @@ -174,6 +174,13 @@ PIM interface commands allow you to configure an interface as either a Receiver or a interface that you would like to form pim neighbors on. If the interface is in a vrf, enter the interface command with the vrf keyword at the end. +.. index:: ip pim active-active +.. clicmd:: ip pim active-active + + Turn on pim active-active configuration for a Vxlan interface. This + command will not do anything if you do not have the underlying ability + of a mlag implementation. + .. index:: ip pim bfd .. clicmd:: ip pim bfd @@ -392,6 +399,11 @@ cause great confusion. Display information about interfaces PIM is using. +.. index:: show ip pim mlag [vrf NAME] interface [detail|WORD] [json] +.. clicmd:: show ip pim mlag [vrf NAME|all] interface [detail|WORD] [json] + + Display mlag interface information. + .. index:: show ip pim [vrf NAME] join [A.B.C.D [A.B.C.D]] [json] .. clicmd:: show ip pim join @@ -404,6 +416,11 @@ cause great confusion. Display information about PIM interface local-membership. +.. index:: show ip pim mlag summary [json] +.. clicmd:: show ip pim mlag summary [json] + + Display mlag information state that PIM is keeping track of. + .. index:: show ip pim neighbor .. clicmd:: show ip pim neighbor diff --git a/eigrpd/eigrp_packet.c b/eigrpd/eigrp_packet.c index 48e9a18e5a..6090a1ef13 100644 --- a/eigrpd/eigrp_packet.c +++ b/eigrpd/eigrp_packet.c @@ -749,7 +749,7 @@ static struct stream *eigrp_recv_packet(struct eigrp *eigrp, ip_len = iph->ip_len; -#if !defined(GNU_LINUX) && (OpenBSD < 200311) && (__FreeBSD_version < 1000000) +#if defined(__FreeBSD__) && (__FreeBSD_version < 1000000) /* * Kernel network code touches incoming IP header parameters, * before protocol specific processing. diff --git a/isisd/isis_pdu.c b/isisd/isis_pdu.c index cc22aa5ffd..9153512623 100644 --- a/isisd/isis_pdu.c +++ b/isisd/isis_pdu.c @@ -1652,7 +1652,7 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa) if (length != expected_length) { flog_err(EC_ISIS_PACKET, - "Exepected fixed header length = %" PRIu8 + "Expected fixed header length = %" PRIu8 " but got %" PRIu8, expected_length, length); return ISIS_ERROR; diff --git a/isisd/isis_tlvs.c b/isisd/isis_tlvs.c index df6280e5c3..5b0b709206 100644 --- a/isisd/isis_tlvs.c +++ b/isisd/isis_tlvs.c @@ -2266,7 +2266,7 @@ static int unpack_tlv_spine_leaf(enum isis_tlv_context context, sbuf_push(log, indent, "Unpacking Spine Leaf Extension TLV...\n"); if (tlv_len < 2) { - sbuf_push(log, indent, "WARNING: Unexepected TLV size\n"); + sbuf_push(log, indent, "WARNING: Unexpected TLV size\n"); stream_forward_getp(s, tlv_len); return 0; } @@ -2382,7 +2382,7 @@ static int unpack_tlv_threeway_adj(enum isis_tlv_context context, sbuf_push(log, indent, "Unpacking P2P Three-Way Adjacency TLV...\n"); if (tlv_len != 5 && tlv_len != 15) { - sbuf_push(log, indent, "WARNING: Unexepected TLV size\n"); + sbuf_push(log, indent, "WARNING: Unexpected TLV size\n"); stream_forward_getp(s, tlv_len); return 0; } diff --git a/ldpd/hello.c b/ldpd/hello.c index d17e80008e..a8d6e58cda 100644 --- a/ldpd/hello.c +++ b/ldpd/hello.c @@ -169,7 +169,7 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *msg, int af, int tlvs_rcvd; int ds_tlv; union ldpd_addr trans_addr; - uint32_t scope_id = 0; + ifindex_t scope_id = 0; uint32_t conf_seqnum; uint16_t trans_pref; int r; diff --git a/ldpd/interface.c b/ldpd/interface.c index 8b45703d22..c7d6dea518 100644 --- a/ldpd/interface.c +++ b/ldpd/interface.c @@ -109,7 +109,7 @@ ldpe_if_exit(struct iface *iface) } struct iface * -if_lookup(struct ldpd_conf *xconf, unsigned short ifindex) +if_lookup(struct ldpd_conf *xconf, ifindex_t ifindex) { struct iface *iface; diff --git a/ldpd/ldpd.h b/ldpd/ldpd.h index a5d1bb7177..006780f032 100644 --- a/ldpd/ldpd.h +++ b/ldpd/ldpd.h @@ -306,7 +306,7 @@ struct iface_af { struct iface { RB_ENTRY(iface) entry; char name[IF_NAMESIZE]; - unsigned int ifindex; + ifindex_t ifindex; struct if_addr_head addr_list; struct in6_addr linklocal; enum iface_type type; @@ -391,7 +391,7 @@ struct l2vpn_if { RB_ENTRY(l2vpn_if) entry; struct l2vpn *l2vpn; char ifname[IF_NAMESIZE]; - unsigned int ifindex; + ifindex_t ifindex; int operative; uint8_t mac[ETH_ALEN]; QOBJ_FIELDS @@ -408,7 +408,7 @@ struct l2vpn_pw { union ldpd_addr addr; uint32_t pwid; char ifname[IF_NAMESIZE]; - unsigned int ifindex; + ifindex_t ifindex; bool enabled; uint32_t remote_group; uint16_t remote_mtu; @@ -433,7 +433,7 @@ struct l2vpn { int pw_type; int mtu; char br_ifname[IF_NAMESIZE]; - unsigned int br_ifindex; + ifindex_t br_ifindex; struct l2vpn_if_head if_tree; struct l2vpn_pw_head pw_tree; struct l2vpn_pw_head pw_inactive_tree; @@ -542,7 +542,7 @@ struct kroute { union ldpd_addr nexthop; uint32_t local_label; uint32_t remote_label; - unsigned short ifindex; + ifindex_t ifindex; uint8_t route_type; uint8_t route_instance; uint16_t flags; @@ -550,7 +550,7 @@ struct kroute { struct kaddr { char ifname[IF_NAMESIZE]; - unsigned short ifindex; + ifindex_t ifindex; int af; union ldpd_addr addr; uint8_t prefixlen; @@ -559,7 +559,7 @@ struct kaddr { struct kif { char ifname[IF_NAMESIZE]; - unsigned short ifindex; + ifindex_t ifindex; int flags; int operative; uint8_t mac[ETH_ALEN]; @@ -577,7 +577,7 @@ struct acl_check { struct ctl_iface { int af; char name[IF_NAMESIZE]; - unsigned int ifindex; + ifindex_t ifindex; int state; enum iface_type type; uint16_t hello_holdtime; @@ -760,7 +760,7 @@ int sock_set_bindany(int, int); int sock_set_md5sig(int, int, union ldpd_addr *, const char *); int sock_set_ipv4_tos(int, int); int sock_set_ipv4_pktinfo(int, int); -int sock_set_ipv4_recvdstaddr(int, int); +int sock_set_ipv4_recvdstaddr(int fd, ifindex_t ifindex); int sock_set_ipv4_recvif(int, int); int sock_set_ipv4_minttl(int, int); int sock_set_ipv4_ucast_ttl(int fd, int); @@ -783,7 +783,8 @@ struct fec; const char *log_sockaddr(void *); const char *log_in6addr(const struct in6_addr *); -const char *log_in6addr_scope(const struct in6_addr *, unsigned int); +const char *log_in6addr_scope(const struct in6_addr *addr, + ifindex_t ifidx); const char *log_addr(int, const union ldpd_addr *); char *log_label(uint32_t); const char *log_time(time_t); diff --git a/ldpd/ldpe.c b/ldpd/ldpe.c index 82e52f5fe3..b34a1ecdd7 100644 --- a/ldpd/ldpe.c +++ b/ldpd/ldpe.c @@ -41,7 +41,7 @@ static int ldpe_dispatch_pfkey(struct thread *); #endif static void ldpe_setup_sockets(int, int, int, int); static void ldpe_close_sockets(int); -static void ldpe_iface_af_ctl(struct ctl_conn *, int, unsigned int); +static void ldpe_iface_af_ctl(struct ctl_conn *c, int af, ifindex_t ifidx); struct ldpd_conf *leconf; #ifdef __OpenBSD__ @@ -827,7 +827,7 @@ ldpe_stop_init_backoff(int af) } static void -ldpe_iface_af_ctl(struct ctl_conn *c, int af, unsigned int idx) +ldpe_iface_af_ctl(struct ctl_conn *c, int af, ifindex_t idx) { struct iface *iface; struct iface_af *ia; @@ -847,7 +847,7 @@ ldpe_iface_af_ctl(struct ctl_conn *c, int af, unsigned int idx) } void -ldpe_iface_ctl(struct ctl_conn *c, unsigned int idx) +ldpe_iface_ctl(struct ctl_conn *c, ifindex_t idx) { ldpe_iface_af_ctl(c, AF_INET, idx); ldpe_iface_af_ctl(c, AF_INET6, idx); diff --git a/ldpd/ldpe.h b/ldpd/ldpe.h index 5b40383db2..11650069b7 100644 --- a/ldpd/ldpe.h +++ b/ldpd/ldpe.h @@ -92,7 +92,7 @@ struct nbr { struct in_addr id; /* lsr id */ union ldpd_addr laddr; /* local address */ union ldpd_addr raddr; /* remote address */ - uint32_t raddr_scope; /* remote address scope (v6) */ + ifindex_t raddr_scope; /* remote address scope (v6) */ time_t uptime; int fd; int state; @@ -208,7 +208,7 @@ void ldpe_reset_ds_nbrs(void); void ldpe_remove_dynamic_tnbrs(int); void ldpe_stop_init_backoff(int); struct ctl_conn; -void ldpe_iface_ctl(struct ctl_conn *, unsigned int); +void ldpe_iface_ctl(struct ctl_conn *c, ifindex_t ifidx); void ldpe_adj_ctl(struct ctl_conn *); void ldpe_adj_detail_ctl(struct ctl_conn *); void ldpe_nbr_ctl(struct ctl_conn *); @@ -219,7 +219,7 @@ void mapping_list_clr(struct mapping_head *); struct iface *if_new(const char *); void ldpe_if_init(struct iface *); void ldpe_if_exit(struct iface *); -struct iface *if_lookup(struct ldpd_conf *, unsigned short); +struct iface *if_lookup(struct ldpd_conf *c, ifindex_t ifidx); struct iface *if_lookup_name(struct ldpd_conf *, const char *); void if_update_info(struct iface *, struct kif *); struct iface_af *iface_af_get(struct iface *, int); diff --git a/ldpd/logmsg.c b/ldpd/logmsg.c index a9b066a3da..2c9fbf0dae 100644 --- a/ldpd/logmsg.c +++ b/ldpd/logmsg.c @@ -59,7 +59,7 @@ log_in6addr(const struct in6_addr *addr) } const char * -log_in6addr_scope(const struct in6_addr *addr, unsigned int ifindex) +log_in6addr_scope(const struct in6_addr *addr, ifindex_t ifindex) { struct sockaddr_in6 sa_in6; diff --git a/ldpd/socket.c b/ldpd/socket.c index 997434620a..4909ea7ad8 100644 --- a/ldpd/socket.c +++ b/ldpd/socket.c @@ -329,7 +329,7 @@ sock_set_ipv4_tos(int fd, int tos) } int -sock_set_ipv4_recvif(int fd, int enable) +sock_set_ipv4_recvif(int fd, ifindex_t enable) { return (setsockopt_ifindex(AF_INET, fd, enable)); } diff --git a/lib/getopt.h b/lib/getopt.h index 138870d199..63e12e947e 100644 --- a/lib/getopt.h +++ b/lib/getopt.h @@ -111,7 +111,7 @@ struct option { #if defined(__STDC__) && __STDC__ -#if REALLY_NEED_PLAIN_GETOPT +#ifdef REALLY_NEED_PLAIN_GETOPT /* * getopt is defined in POSIX.2. Assume that if the system defines @@ -887,11 +887,8 @@ void connected_free(struct connected **connected) { struct connected *ptr = *connected; - if (ptr->address) - prefix_free(&ptr->address); - - if (ptr->destination) - prefix_free(&ptr->destination); + prefix_free(&ptr->address); + prefix_free(&ptr->destination); XFREE(MTYPE_CONNECTED_LABEL, ptr->label); diff --git a/lib/mlag.c b/lib/mlag.c index 1daf290725..733dd41ea8 100644 --- a/lib/mlag.c +++ b/lib/mlag.c @@ -81,22 +81,33 @@ char *mlag_lib_msgid_to_str(enum mlag_msg_type msg_type, char *buf, size_t size) } -int mlag_lib_decode_mlag_hdr(struct stream *s, struct mlag_msg *msg) +int mlag_lib_decode_mlag_hdr(struct stream *s, struct mlag_msg *msg, + size_t *length) { - if (s == NULL || msg == NULL) +#define LIB_MLAG_HDR_LENGTH 8 + *length = stream_get_endp(s); + + if (s == NULL || msg == NULL || *length < LIB_MLAG_HDR_LENGTH) return -1; + *length -= LIB_MLAG_HDR_LENGTH; + STREAM_GETL(s, msg->msg_type); STREAM_GETW(s, msg->data_len); STREAM_GETW(s, msg->msg_cnt); + return 0; stream_failure: return -1; } -int mlag_lib_decode_mroute_add(struct stream *s, struct mlag_mroute_add *msg) +#define MLAG_MROUTE_ADD_LENGTH \ + (VRF_NAMSIZ + INTERFACE_NAMSIZ + 4 + 4 + 4 + 4 + 1 + 1 + 4) + +int mlag_lib_decode_mroute_add(struct stream *s, struct mlag_mroute_add *msg, + size_t *length) { - if (s == NULL || msg == NULL) + if (s == NULL || msg == NULL || *length < MLAG_MROUTE_ADD_LENGTH) return -1; STREAM_GET(msg->vrf_name, s, VRF_NAMSIZ); @@ -108,14 +119,18 @@ int mlag_lib_decode_mroute_add(struct stream *s, struct mlag_mroute_add *msg) STREAM_GETC(s, msg->am_i_dual_active); STREAM_GETL(s, msg->vrf_id); STREAM_GET(msg->intf_name, s, INTERFACE_NAMSIZ); + return 0; stream_failure: return -1; } -int mlag_lib_decode_mroute_del(struct stream *s, struct mlag_mroute_del *msg) +#define MLAG_MROUTE_DEL_LENGTH (VRF_NAMSIZ + INTERFACE_NAMSIZ + 4 + 4 + 4 + 4) + +int mlag_lib_decode_mroute_del(struct stream *s, struct mlag_mroute_del *msg, + size_t *length) { - if (s == NULL || msg == NULL) + if (s == NULL || msg == NULL || *length < MLAG_MROUTE_DEL_LENGTH) return -1; STREAM_GET(msg->vrf_name, s, VRF_NAMSIZ); @@ -124,6 +139,7 @@ int mlag_lib_decode_mroute_del(struct stream *s, struct mlag_mroute_del *msg) STREAM_GETL(s, msg->owner_id); STREAM_GETL(s, msg->vrf_id); STREAM_GET(msg->intf_name, s, INTERFACE_NAMSIZ); + return 0; stream_failure: return -1; diff --git a/lib/mlag.h b/lib/mlag.h index c531fb5b68..37bb3aa6db 100644 --- a/lib/mlag.h +++ b/lib/mlag.h @@ -125,11 +125,14 @@ struct mlag_msg { extern char *mlag_role2str(enum mlag_role role, char *buf, size_t size); extern char *mlag_lib_msgid_to_str(enum mlag_msg_type msg_type, char *buf, size_t size); -extern int mlag_lib_decode_mlag_hdr(struct stream *s, struct mlag_msg *msg); +extern int mlag_lib_decode_mlag_hdr(struct stream *s, struct mlag_msg *msg, + size_t *length); extern int mlag_lib_decode_mroute_add(struct stream *s, - struct mlag_mroute_add *msg); + struct mlag_mroute_add *msg, + size_t *length); extern int mlag_lib_decode_mroute_del(struct stream *s, - struct mlag_mroute_del *msg); + struct mlag_mroute_del *msg, + size_t *length); extern int mlag_lib_decode_mlag_status(struct stream *s, struct mlag_status *msg); extern int mlag_lib_decode_vxlan_update(struct stream *s, diff --git a/lib/routemap_northbound.c b/lib/routemap_northbound.c index 2d04a3d65c..69cebbd2a1 100644 --- a/lib/routemap_northbound.c +++ b/lib/routemap_northbound.c @@ -221,8 +221,7 @@ static int lib_route_map_entry_description_modify(enum nb_event event, break; case NB_EV_APPLY: rmi = nb_running_get_entry(dnode, NULL, true); - if (rmi->description != NULL) - XFREE(MTYPE_TMP, rmi->description); + XFREE(MTYPE_TMP, rmi->description); rmi->description = resource->ptr; break; } diff --git a/lib/seqlock.c b/lib/seqlock.c index 588a1175bc..77673146ea 100644 --- a/lib/seqlock.c +++ b/lib/seqlock.c @@ -165,7 +165,7 @@ bool seqlock_timedwait(struct seqlock *sqlo, seqlock_val_t val, /* * ABS_REALTIME - used on NetBSD, Solaris and OSX */ -#if TIME_ABS_REALTIME +#ifdef TIME_ABS_REALTIME #define time_arg1 &abs_rt #define time_arg2 NULL #define time_prep @@ -187,7 +187,7 @@ bool seqlock_timedwait(struct seqlock *sqlo, seqlock_val_t val, /* * RELATIVE - used on OpenBSD (might get a patch to get absolute monotime) */ -#elif TIME_RELATIVE +#elif defined(TIME_RELATIVE) struct timespec reltime; #define time_arg1 abs_monotime_limit diff --git a/lib/skiplist.c b/lib/skiplist.c index 67cc1ab378..d955c6eb9e 100644 --- a/lib/skiplist.c +++ b/lib/skiplist.c @@ -211,12 +211,12 @@ int skiplist_insert(register struct skiplist *l, register void *key, q = newNodeOfLevel(k); q->key = key; q->value = value; -#if SKIPLIST_0TIMER_DEBUG +#ifdef SKIPLIST_0TIMER_DEBUG q->flags = SKIPLIST_NODE_FLAG_INSERTED; /* debug */ #endif ++(l->stats->forward[k]); -#if SKIPLIST_DEBUG +#ifdef SKIPLIST_DEBUG zlog_debug("%s: incremented stats @%p:%d, now %ld", __func__, l, k, l->stats->forward[k] - (struct skiplistnode *)NULL); #endif @@ -281,7 +281,7 @@ int skiplist_delete(register struct skiplist *l, register void *key, /* * found node to delete */ -#if SKIPLIST_0TIMER_DEBUG +#ifdef SKIPLIST_0TIMER_DEBUG q->flags &= ~SKIPLIST_NODE_FLAG_INSERTED; #endif /* @@ -300,7 +300,7 @@ int skiplist_delete(register struct skiplist *l, register void *key, p->forward[k] = q->forward[k]; } --(l->stats->forward[k - 1]); -#if SKIPLIST_DEBUG +#ifdef SKIPLIST_DEBUG zlog_debug("%s: decremented stats @%p:%d, now %ld", __func__, l, k - 1, l->stats->forward[k - 1] @@ -549,7 +549,7 @@ int skiplist_delete_first(register struct skiplist *l) } } -#if SKIPLIST_0TIMER_DEBUG +#ifdef SKIPLIST_0TIMER_DEBUG q->flags &= ~SKIPLIST_NODE_FLAG_INSERTED; #endif /* @@ -561,7 +561,7 @@ int skiplist_delete_first(register struct skiplist *l) } --(l->stats->forward[nodelevel]); -#if SKIPLIST_DEBUG +#ifdef SKIPLIST_DEBUG zlog_debug("%s: decremented stats @%p:%d, now %ld", __func__, l, nodelevel, l->stats->forward[nodelevel] - (struct skiplistnode *)NULL); diff --git a/lib/stream.h b/lib/stream.h index c0d25e0579..36c65afa3c 100644 --- a/lib/stream.h +++ b/lib/stream.h @@ -110,7 +110,7 @@ struct stream { size_t getp; /* next get position */ size_t endp; /* last valid data position */ size_t size; /* size of data segment */ - unsigned char data[0]; /* data pointer */ + unsigned char data[]; /* data pointer */ }; /* First in first out queue structure. */ diff --git a/lib/systemd.c b/lib/systemd.c index 81b0400ab9..c5cc3aa447 100644 --- a/lib/systemd.c +++ b/lib/systemd.c @@ -114,8 +114,10 @@ void systemd_send_started(struct thread_master *m, int the_process) systemd_master = m; systemd_send_information("READY=1"); - if (wsecs != 0) + if (wsecs != 0) { + systemd_send_information("WATCHDOG=1"); thread_add_timer(m, systemd_send_watchdog, m, wsecs, NULL); + } } void systemd_send_status(const char *status) diff --git a/m4/ax_python.m4 b/m4/ax_python.m4 index 69809184ee..d293da5257 100644 --- a/m4/ax_python.m4 +++ b/m4/ax_python.m4 @@ -3,7 +3,7 @@ dnl 2019 David Lamparter for NetDEF, Inc. dnl SPDX-License-Identifier: GPL-2.0-or-later dnl the _ at the beginning will be cut off (to support the empty version string) -m4_define_default([_FRR_PY_VERS], [_3 _ _2 _3.7 _3.6 _3.5 _3.4 _3.3 _3.2 _2.7]) +m4_define_default([_FRR_PY_VERS], [_3 _ _2 _3.8 _3.7 _3.6 _3.5 _3.4 _3.3 _3.2 _2.7]) dnl check basic interpreter properties (py2/py3) dnl doubles as simple check whether the interpreter actually works diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c index 1717f1e650..f8df37094f 100644 --- a/ospf6d/ospf6_zebra.c +++ b/ospf6d/ospf6_zebra.c @@ -256,7 +256,7 @@ static void ospf6_zebra_route_update(int type, struct ospf6_route *request) && ospf6_route_is_same(request, request->next)) { if (IS_OSPF6_DEBUG_ZEBRA(SEND)) zlog_debug( - " Best-path removal resulted Sencondary addition"); + " Best-path removal resulted Secondary addition"); type = ADD; request = request->next; } diff --git a/ospfd/ospf_nsm.c b/ospfd/ospf_nsm.c index 58f087ca4f..9cd83c245c 100644 --- a/ospfd/ospf_nsm.c +++ b/ospfd/ospf_nsm.c @@ -731,7 +731,7 @@ static void nsm_change_state(struct ospf_neighbor *nbr, int state) OSPF_DD_FLAG_I | OSPF_DD_FLAG_M | OSPF_DD_FLAG_MS; if (CHECK_FLAG(oi->ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) zlog_info( - "%s: Intializing [DD]: %s with seqnum:%x , flags:%x", + "%s: Initializing [DD]: %s with seqnum:%x , flags:%x", (oi->ospf->name) ? oi->ospf->name : VRF_DEFAULT_NAME, inet_ntoa(nbr->router_id), nbr->dd_seqnum, diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index fd2ab07261..75f556e39f 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -93,7 +93,7 @@ static int str2metric(const char *str, int *metric) return 0; *metric = strtol(str, NULL, 10); - if (*metric < 0 && *metric > 16777214) { + if (*metric < 0 || *metric > 16777214) { /* vty_out (vty, "OSPF metric value is invalid\n"); */ return 0; } diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index a3e5151a78..7e24d924a4 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -909,7 +909,7 @@ static void igmp_show_interface_join(struct pim_instance *pim, struct vty *vty) static void pim_show_interfaces_single(struct pim_instance *pim, struct vty *vty, const char *ifname, - bool uj) + bool mlag, bool uj) { struct in_addr ifaddr; struct interface *ifp; @@ -952,6 +952,9 @@ static void pim_show_interfaces_single(struct pim_instance *pim, if (!pim_ifp) continue; + if (mlag == true && pim_ifp->activeactive == false) + continue; + if (strcmp(ifname, "detail") && strcmp(ifname, ifp->name)) continue; @@ -1380,7 +1383,7 @@ static void igmp_show_statistics(struct pim_instance *pim, struct vty *vty, } static void pim_show_interfaces(struct pim_instance *pim, struct vty *vty, - bool uj) + bool mlag, bool uj) { struct interface *ifp; struct pim_interface *pim_ifp; @@ -1400,6 +1403,9 @@ static void pim_show_interfaces(struct pim_instance *pim, struct vty *vty, if (!pim_ifp) continue; + if (mlag == true && pim_ifp->activeactive == false) + continue; + pim_nbrs = pim_ifp->pim_neighbor_list->count; pim_ifchannels = pim_if_ifchannel_count(pim_ifp); fhr = 0; @@ -3726,8 +3732,6 @@ static void pim_show_bsr(struct pim_instance *pim, char bsr_str[PREFIX_STRLEN]; json_object *json = NULL; - vty_out(vty, "PIMv2 Bootstrap information\n"); - if (pim->global_scope.current_bsr.s_addr == INADDR_ANY) { strlcpy(bsr_str, "0.0.0.0", sizeof(bsr_str)); pim_time_uptime(uptime, sizeof(uptime), @@ -3773,6 +3777,7 @@ static void pim_show_bsr(struct pim_instance *pim, } else { + vty_out(vty, "PIMv2 Bootstrap information\n"); vty_out(vty, "Current preferred BSR address: %s\n", bsr_str); vty_out(vty, "Priority Fragment-Tag State UpTime\n"); @@ -4295,6 +4300,113 @@ DEFUN (show_ip_igmp_statistics, return CMD_SUCCESS; } +DEFUN (show_ip_pim_mlag_summary, + show_ip_pim_mlag_summary_cmd, + "show ip pim mlag summary [json]", + SHOW_STR + IP_STR + PIM_STR + "MLAG\n" + "status and stats\n" + JSON_STR) +{ + bool uj = use_json(argc, argv); + char role_buf[MLAG_ROLE_STRSIZE]; + char addr_buf[INET_ADDRSTRLEN]; + + if (uj) { + json_object *json = NULL; + json_object *json_stat = NULL; + + json = json_object_new_object(); + if (router->mlag_flags & PIM_MLAGF_LOCAL_CONN_UP) + json_object_boolean_true_add(json, "mlagConnUp"); + if (router->mlag_flags & PIM_MLAGF_PEER_CONN_UP) + json_object_boolean_true_add(json, "mlagPeerConnUp"); + if (router->mlag_flags & PIM_MLAGF_PEER_ZEBRA_UP) + json_object_boolean_true_add(json, "mlagPeerZebraUp"); + json_object_string_add(json, "mlagRole", + mlag_role2str(router->mlag_role, + role_buf, sizeof(role_buf))); + inet_ntop(AF_INET, &router->local_vtep_ip, + addr_buf, INET_ADDRSTRLEN); + json_object_string_add(json, "localVtepIp", addr_buf); + inet_ntop(AF_INET, &router->anycast_vtep_ip, + addr_buf, INET_ADDRSTRLEN); + json_object_string_add(json, "anycastVtepIp", addr_buf); + json_object_string_add(json, "peerlinkRif", + router->peerlink_rif); + + json_stat = json_object_new_object(); + json_object_int_add(json_stat, "mlagConnFlaps", + router->mlag_stats.mlagd_session_downs); + json_object_int_add(json_stat, "mlagPeerConnFlaps", + router->mlag_stats.peer_session_downs); + json_object_int_add(json_stat, "mlagPeerZebraFlaps", + router->mlag_stats.peer_zebra_downs); + json_object_int_add(json_stat, "mrouteAddRx", + router->mlag_stats.msg.mroute_add_rx); + json_object_int_add(json_stat, "mrouteAddTx", + router->mlag_stats.msg.mroute_add_tx); + json_object_int_add(json_stat, "mrouteDelRx", + router->mlag_stats.msg.mroute_del_rx); + json_object_int_add(json_stat, "mrouteDelTx", + router->mlag_stats.msg.mroute_del_tx); + json_object_int_add(json_stat, "mlagStatusUpdates", + router->mlag_stats.msg.mlag_status_updates); + json_object_int_add(json_stat, "peerZebraStatusUpdates", + router->mlag_stats.msg.peer_zebra_status_updates); + json_object_int_add(json_stat, "pimStatusUpdates", + router->mlag_stats.msg.pim_status_updates); + json_object_int_add(json_stat, "vxlanUpdates", + router->mlag_stats.msg.vxlan_updates); + json_object_object_add(json, "connStats", json_stat); + + vty_out(vty, "%s\n", json_object_to_json_string_ext( + json, JSON_C_TO_STRING_PRETTY)); + json_object_free(json); + return CMD_SUCCESS; + } + + vty_out(vty, "MLAG daemon connection: %s\n", + (router->mlag_flags & PIM_MLAGF_LOCAL_CONN_UP) + ? "up" : "down"); + vty_out(vty, "MLAG peer state: %s\n", + (router->mlag_flags & PIM_MLAGF_PEER_CONN_UP) + ? "up" : "down"); + vty_out(vty, "Zebra peer state: %s\n", + (router->mlag_flags & PIM_MLAGF_PEER_ZEBRA_UP) + ? "up" : "down"); + vty_out(vty, "MLAG role: %s\n", + mlag_role2str(router->mlag_role, role_buf, sizeof(role_buf))); + inet_ntop(AF_INET, &router->local_vtep_ip, + addr_buf, INET_ADDRSTRLEN); + vty_out(vty, "Local VTEP IP: %s\n", addr_buf); + inet_ntop(AF_INET, &router->anycast_vtep_ip, + addr_buf, INET_ADDRSTRLEN); + vty_out(vty, "Anycast VTEP IP: %s\n", addr_buf); + vty_out(vty, "Peerlink: %s\n", router->peerlink_rif); + vty_out(vty, "Session flaps: mlagd: %d mlag-peer: %d zebra-peer: %d\n", + router->mlag_stats.mlagd_session_downs, + router->mlag_stats.peer_session_downs, + router->mlag_stats.peer_zebra_downs); + vty_out(vty, "Message Statistics:\n"); + vty_out(vty, " mroute adds: rx: %d, tx: %d\n", + router->mlag_stats.msg.mroute_add_rx, + router->mlag_stats.msg.mroute_add_tx); + vty_out(vty, " mroute dels: rx: %d, tx: %d\n", + router->mlag_stats.msg.mroute_del_rx, + router->mlag_stats.msg.mroute_del_tx); + vty_out(vty, " peer zebra status updates: %d\n", + router->mlag_stats.msg.peer_zebra_status_updates); + vty_out(vty, " PIM status updates: %d\n", + router->mlag_stats.msg.pim_status_updates); + vty_out(vty, " VxLAN updates: %d\n", + router->mlag_stats.msg.vxlan_updates); + + return CMD_SUCCESS; +} + DEFUN (show_ip_pim_assert, show_ip_pim_assert_cmd, "show ip pim [vrf NAME] assert", @@ -4377,10 +4489,11 @@ DEFUN (show_ip_pim_assert_winner_metric, DEFUN (show_ip_pim_interface, show_ip_pim_interface_cmd, - "show ip pim [vrf NAME] interface [detail|WORD] [json]", + "show ip pim [mlag] [vrf NAME] interface [detail|WORD] [json]", SHOW_STR IP_STR PIM_STR + "MLAG\n" VRF_CMD_HELP_STR "PIM interface information\n" "Detailed output\n" @@ -4390,36 +4503,47 @@ DEFUN (show_ip_pim_interface, int idx = 2; struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx); bool uj = use_json(argc, argv); + bool mlag = false; if (!vrf) return CMD_WARNING; + if (argv_find(argv, argc, "mlag", &idx)) + mlag = true; + if (argv_find(argv, argc, "WORD", &idx) || argv_find(argv, argc, "detail", &idx)) - pim_show_interfaces_single(vrf->info, vty, argv[idx]->arg, uj); + pim_show_interfaces_single(vrf->info, vty, argv[idx]->arg, mlag, + uj); else - pim_show_interfaces(vrf->info, vty, uj); + pim_show_interfaces(vrf->info, vty, mlag, uj); return CMD_SUCCESS; } DEFUN (show_ip_pim_interface_vrf_all, show_ip_pim_interface_vrf_all_cmd, - "show ip pim vrf all interface [detail|WORD] [json]", + "show ip pim [mlag] vrf all interface [detail|WORD] [json]", SHOW_STR IP_STR PIM_STR + "MLAG\n" VRF_CMD_HELP_STR "PIM interface information\n" "Detailed output\n" "interface name\n" JSON_STR) { - int idx = 6; + int idx = 2; bool uj = use_json(argc, argv); struct vrf *vrf; bool first = true; + bool mlag = false; + + if (argv_find(argv, argc, "mlag", &idx)) + mlag = true; + idx = 6; if (uj) vty_out(vty, "{ "); RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { @@ -4433,9 +4557,9 @@ DEFUN (show_ip_pim_interface_vrf_all, if (argv_find(argv, argc, "WORD", &idx) || argv_find(argv, argc, "detail", &idx)) pim_show_interfaces_single(vrf->info, vty, - argv[idx]->arg, uj); + argv[idx]->arg, mlag, uj); else - pim_show_interfaces(vrf->info, vty, uj); + pim_show_interfaces(vrf->info, vty, mlag, uj); } if (uj) vty_out(vty, "}\n"); @@ -4625,113 +4749,6 @@ DEFUN (show_ip_pim_local_membership, return CMD_SUCCESS; } -DEFUN (show_ip_pim_mlag_summary, - show_ip_pim_mlag_summary_cmd, - "show ip pim mlag summary [json]", - SHOW_STR - IP_STR - PIM_STR - "MLAG\n" - "status and stats\n" - JSON_STR) -{ - bool uj = use_json(argc, argv); - char role_buf[MLAG_ROLE_STRSIZE]; - char addr_buf[INET_ADDRSTRLEN]; - - if (uj) { - json_object *json = NULL; - json_object *json_stat = NULL; - - json = json_object_new_object(); - if (router->mlag_flags & PIM_MLAGF_LOCAL_CONN_UP) - json_object_boolean_true_add(json, "mlagConnUp"); - if (router->mlag_flags & PIM_MLAGF_PEER_CONN_UP) - json_object_boolean_true_add(json, "mlagPeerConnUp"); - if (router->mlag_flags & PIM_MLAGF_PEER_ZEBRA_UP) - json_object_boolean_true_add(json, "mlagPeerZebraUp"); - json_object_string_add(json, "mlagRole", - mlag_role2str(router->mlag_role, - role_buf, sizeof(role_buf))); - inet_ntop(AF_INET, &router->local_vtep_ip, - addr_buf, INET_ADDRSTRLEN); - json_object_string_add(json, "localVtepIp", addr_buf); - inet_ntop(AF_INET, &router->anycast_vtep_ip, - addr_buf, INET_ADDRSTRLEN); - json_object_string_add(json, "anycastVtepIp", addr_buf); - json_object_string_add(json, "peerlinkRif", - router->peerlink_rif); - - json_stat = json_object_new_object(); - json_object_int_add(json_stat, "mlagConnFlaps", - router->mlag_stats.mlagd_session_downs); - json_object_int_add(json_stat, "mlagPeerConnFlaps", - router->mlag_stats.peer_session_downs); - json_object_int_add(json_stat, "mlagPeerZebraFlaps", - router->mlag_stats.peer_zebra_downs); - json_object_int_add(json_stat, "mrouteAddRx", - router->mlag_stats.msg.mroute_add_rx); - json_object_int_add(json_stat, "mrouteAddTx", - router->mlag_stats.msg.mroute_add_tx); - json_object_int_add(json_stat, "mrouteDelRx", - router->mlag_stats.msg.mroute_del_rx); - json_object_int_add(json_stat, "mrouteDelTx", - router->mlag_stats.msg.mroute_del_tx); - json_object_int_add(json_stat, "mlagStatusUpdates", - router->mlag_stats.msg.mlag_status_updates); - json_object_int_add(json_stat, "peerZebraStatusUpdates", - router->mlag_stats.msg.peer_zebra_status_updates); - json_object_int_add(json_stat, "pimStatusUpdates", - router->mlag_stats.msg.pim_status_updates); - json_object_int_add(json_stat, "vxlanUpdates", - router->mlag_stats.msg.vxlan_updates); - json_object_object_add(json, "connStats", json_stat); - - vty_out(vty, "%s\n", json_object_to_json_string_ext( - json, JSON_C_TO_STRING_PRETTY)); - json_object_free(json); - return CMD_SUCCESS; - } - - vty_out(vty, "MLAG daemon connection: %s\n", - (router->mlag_flags & PIM_MLAGF_LOCAL_CONN_UP) - ? "up" : "down"); - vty_out(vty, "MLAG peer state: %s\n", - (router->mlag_flags & PIM_MLAGF_PEER_CONN_UP) - ? "up" : "down"); - vty_out(vty, "Zebra peer state: %s\n", - (router->mlag_flags & PIM_MLAGF_PEER_ZEBRA_UP) - ? "up" : "down"); - vty_out(vty, "MLAG role: %s\n", - mlag_role2str(router->mlag_role, role_buf, sizeof(role_buf))); - inet_ntop(AF_INET, &router->local_vtep_ip, - addr_buf, INET_ADDRSTRLEN); - vty_out(vty, "Local VTEP IP: %s\n", addr_buf); - inet_ntop(AF_INET, &router->anycast_vtep_ip, - addr_buf, INET_ADDRSTRLEN); - vty_out(vty, "Anycast VTEP IP: %s\n", addr_buf); - vty_out(vty, "Peerlink: %s\n", router->peerlink_rif); - vty_out(vty, "Session flaps: mlagd: %d mlag-peer: %d zebra-peer: %d\n", - router->mlag_stats.mlagd_session_downs, - router->mlag_stats.peer_session_downs, - router->mlag_stats.peer_zebra_downs); - vty_out(vty, "Message Statistics:\n"); - vty_out(vty, " mroute adds: rx: %d, tx: %d\n", - router->mlag_stats.msg.mroute_add_rx, - router->mlag_stats.msg.mroute_add_tx); - vty_out(vty, " mroute dels: rx: %d, tx: %d\n", - router->mlag_stats.msg.mroute_del_rx, - router->mlag_stats.msg.mroute_del_tx); - vty_out(vty, " peer zebra status updates: %d\n", - router->mlag_stats.msg.peer_zebra_status_updates); - vty_out(vty, " PIM status updates: %d\n", - router->mlag_stats.msg.pim_status_updates); - vty_out(vty, " VxLAN updates: %d\n", - router->mlag_stats.msg.vxlan_updates); - - return CMD_SUCCESS; -} - static void pim_show_mlag_up_entry_detail(struct vrf *vrf, struct vty *vty, struct pim_upstream *up, char *src_str, char *grp_str, json_object *json) @@ -5772,12 +5789,18 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty, int oif_vif_index; struct interface *ifp_in; char proto[100]; + char state_str[PIM_REG_STATE_STR_LEN]; + char mroute_uptime[10]; if (uj) { json = json_object_new_object(); } else { + vty_out(vty, "IP Multicast Routing Table\n"); + vty_out(vty, "Flags: S- Sparse, C - Connected, P - Pruned\n"); + vty_out(vty, + " R - RP-bit set, F - Register flag, T - SPT-bit set\n"); vty_out(vty, - "Source Group Proto Input Output TTL Uptime\n"); + "\nSource Group Flags Proto Input Output TTL Uptime\n"); } now = pim_time_monotonic_sec(); @@ -5800,6 +5823,23 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty, sizeof(grp_str)); pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, src_str, sizeof(src_str)); + + strlcpy(state_str, "S", sizeof(state_str)); + /* When a non DR receives a igmp join, it creates a (*,G) + * channel_oil without any upstream creation */ + if (c_oil->up) { + if (PIM_UPSTREAM_FLAG_TEST_SRC_IGMP(c_oil->up->flags)) + strlcat(state_str, "C", sizeof(state_str)); + if (pim_upstream_is_sg_rpt(c_oil->up)) + strlcat(state_str, "R", sizeof(state_str)); + if (PIM_UPSTREAM_FLAG_TEST_FHR(c_oil->up->flags)) + strlcat(state_str, "F", sizeof(state_str)); + if (c_oil->up->sptbit == PIM_UPSTREAM_SPTBIT_TRUE) + strlcat(state_str, "T", sizeof(state_str)); + } + if (pim_channel_oil_empty(c_oil)) + strlcat(state_str, "P", sizeof(state_str)); + ifp_in = pim_if_find_by_vif_index(pim, c_oil->oil.mfcc_parent); if (ifp_in) @@ -5807,6 +5847,10 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty, else strlcpy(in_ifname, "<iif?>", sizeof(in_ifname)); + + pim_time_uptime(mroute_uptime, sizeof(mroute_uptime), + now - c_oil->mroute_creation); + if (uj) { /* Find the group, create it if it doesn't exist */ @@ -5819,7 +5863,8 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty, } /* Find the source nested under the group, create it if - * it doesn't exist */ + * it doesn't exist + */ json_object_object_get_ex(json_group, src_str, &json_source); @@ -5840,13 +5885,14 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty, json_object_int_add(json_source, "OilInheritedRescan", c_oil->oil_inherited_rescan); json_object_string_add(json_source, "iif", in_ifname); + json_object_string_add(json_source, "upTime", + mroute_uptime); json_oil = NULL; } for (oif_vif_index = 0; oif_vif_index < MAXVIFS; ++oif_vif_index) { struct interface *ifp_out; - char mroute_uptime[10]; int ttl; ttl = c_oil->oil.mfcc_ttls[oif_vif_index]; @@ -5864,9 +5910,6 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty, continue; ifp_out = pim_if_find_by_vif_index(pim, oif_vif_index); - pim_time_uptime( - mroute_uptime, sizeof(mroute_uptime), - now - c_oil->mroute_creation); found_oif = 1; if (ifp_out) @@ -5944,23 +5987,27 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty, } vty_out(vty, - "%-15s %-15s %-6s %-16s %-16s %-3d %8s\n", - src_str, grp_str, proto, in_ifname, - out_ifname, ttl, mroute_uptime); + "%-15s %-15s %-15s %-6s %-16s %-16s %-3d %8s\n", + src_str, grp_str, state_str, proto, + in_ifname, out_ifname, ttl, + mroute_uptime); if (first) { src_str[0] = '\0'; grp_str[0] = '\0'; in_ifname[0] = '\0'; + state_str[0] = '\0'; + mroute_uptime[0] = '\0'; first = 0; } } } if (!uj && !found_oif) { - vty_out(vty, "%-15s %-15s %-6s %-16s %-16s %-3d %8s\n", - src_str, grp_str, "none", in_ifname, "none", 0, - "--:--:--"); + vty_out(vty, + "%-15s %-15s %-15s %-6s %-16s %-16s %-3d %8s\n", + src_str, grp_str, state_str, "none", in_ifname, + "none", 0, "--:--:--"); } } @@ -8035,13 +8082,13 @@ DEFPY_HIDDEN (pim_test_sg_keepalive, return CMD_SUCCESS; } -DEFPY_HIDDEN (interface_ip_pim_activeactive, - interface_ip_pim_activeactive_cmd, - "[no$no] ip pim active-active", - NO_STR - IP_STR - PIM_STR - "Mark interface as Active-Active for MLAG operations, Hidden because not finished yet\n") +DEFPY (interface_ip_pim_activeactive, + interface_ip_pim_activeactive_cmd, + "[no$no] ip pim active-active", + NO_STR + IP_STR + PIM_STR + "Mark interface as Active-Active for MLAG operations, Hidden because not finished yet\n") { VTY_DECLVAR_CONTEXT(interface, ifp); struct pim_interface *pim_ifp; @@ -8051,6 +8098,11 @@ DEFPY_HIDDEN (interface_ip_pim_activeactive, return CMD_WARNING_CONFIG_FAILED; } + + if (PIM_DEBUG_MLAG) + zlog_debug("%sConfiguring PIM active-active on Interface: %s", + no ? "Un-":" ", ifp->name); + pim_ifp = ifp->info; if (no) pim_if_unconfigure_mlag_dualactive(pim_ifp); diff --git a/pimd/pim_iface.h b/pimd/pim_iface.h index 1b76b52305..570bf5eac3 100644 --- a/pimd/pim_iface.h +++ b/pimd/pim_iface.h @@ -55,6 +55,7 @@ #define PIM_IF_DONT_PIM_CAN_DISABLE_JOIN_SUPRESSION(options) ((options) &= ~PIM_IF_MASK_PIM_CAN_DISABLE_JOIN_SUPRESSION) #define PIM_I_am_DR(pim_ifp) (pim_ifp)->pim_dr_addr.s_addr == (pim_ifp)->primary_address.s_addr +#define PIM_I_am_DualActive(pim_ifp) (pim_ifp)->activeactive == true struct pim_iface_upstream_switch { struct in_addr address; diff --git a/pimd/pim_ifchannel.c b/pimd/pim_ifchannel.c index ead9d6dbcc..44d4ee7192 100644 --- a/pimd/pim_ifchannel.c +++ b/pimd/pim_ifchannel.c @@ -43,6 +43,7 @@ #include "pim_upstream.h" #include "pim_ssm.h" #include "pim_rp.h" +#include "pim_mlag.h" RB_GENERATE(pim_ifchannel_rb, pim_ifchannel, pim_ifp_rb, pim_ifchannel_compare); @@ -127,9 +128,29 @@ static void pim_ifchannel_find_new_children(struct pim_ifchannel *ch) void pim_ifchannel_delete(struct pim_ifchannel *ch) { struct pim_interface *pim_ifp; + struct pim_upstream *up; pim_ifp = ch->interface->info; + if (PIM_DEBUG_PIM_TRACE) + zlog_debug("%s: ifchannel entry %s(%s) del start", __func__, + ch->sg_str, ch->interface->name); + + if (PIM_I_am_DualActive(pim_ifp)) { + if (PIM_DEBUG_MLAG) + zlog_debug( + "%s: if-chnanel-%s is deleted from a Dual " + "active Interface", + __func__, ch->sg_str); + /* Post Delete only if it is the last Dual-active Interface */ + if (ch->upstream->dualactive_ifchannel_count == 1) { + pim_mlag_up_local_del(pim_ifp->pim, ch->upstream); + PIM_UPSTREAM_FLAG_UNSET_MLAG_INTERFACE( + ch->upstream->flags); + } + ch->upstream->dualactive_ifchannel_count--; + } + if (ch->upstream->channel_oil) { uint32_t mask = PIM_OIF_FLAG_PROTO_PIM; if (ch->upstream->flags & PIM_UPSTREAM_FLAG_MASK_SRC_IGMP) @@ -181,14 +202,14 @@ void pim_ifchannel_delete(struct pim_ifchannel *ch) listnode_delete(ch->upstream->ifchannels, ch); - pim_upstream_update_join_desired(pim_ifp->pim, ch->upstream); + up = ch->upstream; /* upstream is common across ifchannels, check if upstream's ifchannel list is empty before deleting upstream_del ref count will take care of it. */ if (ch->upstream->ref_count > 0) - pim_upstream_del(pim_ifp->pim, ch->upstream, __func__); + up = pim_upstream_del(pim_ifp->pim, ch->upstream, __func__); else { if (PIM_DEBUG_PIM_TRACE) @@ -213,10 +234,13 @@ void pim_ifchannel_delete(struct pim_ifchannel *ch) RB_REMOVE(pim_ifchannel_rb, &pim_ifp->ifchannel_rb, ch); if (PIM_DEBUG_PIM_TRACE) - zlog_debug("%s: ifchannel entry %s is deleted ", __func__, - ch->sg_str); + zlog_debug("%s: ifchannel entry %s(%s) is deleted ", __func__, + ch->sg_str, ch->interface->name); XFREE(MTYPE_PIM_IFCHANNEL, ch); + + if (up) + pim_upstream_update_join_desired(pim_ifp->pim, up); } void pim_ifchannel_delete_all(struct interface *ifp) @@ -586,9 +610,27 @@ struct pim_ifchannel *pim_ifchannel_add(struct interface *ifp, else PIM_IF_FLAG_UNSET_ASSERT_TRACKING_DESIRED(ch->flags); + /* + * advertise MLAG Data to MLAG peer + */ + if (PIM_I_am_DualActive(pim_ifp)) { + up->dualactive_ifchannel_count++; + /* Sync once for upstream */ + if (up->dualactive_ifchannel_count == 1) { + PIM_UPSTREAM_FLAG_SET_MLAG_INTERFACE(up->flags); + pim_mlag_up_local_add(pim_ifp->pim, up); + } + if (PIM_DEBUG_MLAG) + zlog_debug( + "%s: New Dual active if-chnanel is added to upstream:%s " + "count:%d, flags:0x%x", + __func__, up->sg_str, + up->dualactive_ifchannel_count, up->flags); + } + if (PIM_DEBUG_PIM_TRACE) - zlog_debug("%s: ifchannel %s is created ", __func__, - ch->sg_str); + zlog_debug("%s: ifchannel %s(%s) is created ", __func__, + ch->sg_str, ch->interface->name); return ch; } @@ -1073,6 +1115,9 @@ int pim_ifchannel_local_membership_add(struct interface *ifp, } } + /* vxlan term mroutes use ipmr-lo as local member to + * pull down multicast vxlan tunnel traffic + */ up_flags = is_vxlan ? PIM_UPSTREAM_FLAG_MASK_SRC_VXLAN_TERM : PIM_UPSTREAM_FLAG_MASK_SRC_IGMP; ch = pim_ifchannel_add(ifp, sg, 0, up_flags); diff --git a/pimd/pim_macro.c b/pimd/pim_macro.c index ea3e1a244f..c6961d30c2 100644 --- a/pimd/pim_macro.c +++ b/pimd/pim_macro.c @@ -157,6 +157,7 @@ int pim_macro_ch_lost_assert(const struct pim_ifchannel *ch) int pim_macro_chisin_pim_include(const struct pim_ifchannel *ch) { struct pim_interface *pim_ifp = ch->interface->info; + bool mlag_active = false; if (!pim_ifp) { zlog_warn("%s: (S,G)=%s: multicast not enabled on interface %s", @@ -172,9 +173,21 @@ int pim_macro_chisin_pim_include(const struct pim_ifchannel *ch) if (ch->ifassert_winner.s_addr == pim_ifp->primary_address.s_addr) return 1; /* true */ + /* + * When we have a activeactive interface we need to signal + * that this interface is interesting to the upstream + * decision to JOIN *if* we are syncing over the interface + */ + if (pim_ifp->activeactive) { + struct pim_upstream *up = ch->upstream; + + if (PIM_UPSTREAM_FLAG_TEST_MLAG_INTERFACE(up->flags)) + mlag_active = true; + } + return ( /* I_am_DR( I ) ? */ - PIM_I_am_DR(pim_ifp) && + (PIM_I_am_DR(pim_ifp) || mlag_active) && /* lost_assert(S,G,I) == false ? */ (!pim_macro_ch_lost_assert(ch))); } diff --git a/pimd/pim_mlag.c b/pimd/pim_mlag.c index f476cb5981..304e6ac6bc 100644 --- a/pimd/pim_mlag.c +++ b/pimd/pim_mlag.c @@ -32,6 +32,76 @@ extern struct zclient *zclient; #define PIM_MLAG_METADATA_LEN 4 +/*********************ACtual Data processing *****************************/ +/* TBD: There can be duplicate updates to FIB***/ +#define PIM_MLAG_ADD_OIF_TO_OIL(ch, ch_oil) \ + do { \ + if (PIM_DEBUG_MLAG) \ + zlog_debug( \ + "%s: add Dual-active Interface to %s " \ + "to oil:%s", \ + __func__, ch->interface->name, ch->sg_str); \ + pim_channel_add_oif(ch_oil, ch->interface, \ + PIM_OIF_FLAG_PROTO_IGMP, __func__); \ + } while (0) + +#define PIM_MLAG_DEL_OIF_TO_OIL(ch, ch_oil) \ + do { \ + if (PIM_DEBUG_MLAG) \ + zlog_debug( \ + "%s: del Dual-active Interface to %s " \ + "to oil:%s", \ + __func__, ch->interface->name, ch->sg_str); \ + pim_channel_del_oif(ch_oil, ch->interface, \ + PIM_OIF_FLAG_PROTO_IGMP, __func__); \ + } while (0) + + +static void pim_mlag_calculate_df_for_ifchannels(struct pim_upstream *up, + bool is_df) +{ + struct listnode *chnode; + struct listnode *chnextnode; + struct pim_ifchannel *ch; + struct pim_interface *pim_ifp = NULL; + struct channel_oil *ch_oil = NULL; + + ch_oil = (up) ? up->channel_oil : NULL; + + if (!ch_oil) + return; + + if (PIM_DEBUG_MLAG) + zlog_debug("%s: Calculating DF for Dual active if-channel%s", + __func__, up->sg_str); + + for (ALL_LIST_ELEMENTS(up->ifchannels, chnode, chnextnode, ch)) { + pim_ifp = (ch->interface) ? ch->interface->info : NULL; + if (!pim_ifp || !PIM_I_am_DualActive(pim_ifp)) + continue; + + if (is_df) + PIM_MLAG_ADD_OIF_TO_OIL(ch, ch_oil); + else + PIM_MLAG_DEL_OIF_TO_OIL(ch, ch_oil); + } +} + +static void pim_mlag_inherit_mlag_flags(struct pim_upstream *up, bool is_df) +{ + struct listnode *listnode; + struct pim_upstream *child; + + for (ALL_LIST_ELEMENTS_RO(up->sources, listnode, child)) { + PIM_UPSTREAM_FLAG_SET_MLAG_PEER(child->flags); + if (is_df) + PIM_UPSTREAM_FLAG_UNSET_MLAG_NON_DF(child->flags); + else + PIM_UPSTREAM_FLAG_SET_MLAG_NON_DF(child->flags); + pim_mlag_calculate_df_for_ifchannels(child, is_df); + } +} + /******************************* pim upstream sync **************************/ /* Update DF role for the upstream entry and return true on role change */ bool pim_mlag_up_df_role_update(struct pim_instance *pim, @@ -59,6 +129,15 @@ bool pim_mlag_up_df_role_update(struct pim_instance *pim, PIM_UPSTREAM_FLAG_SET_MLAG_NON_DF(up->flags); + /* + * This Upstream entry synced to peer Because of Dual-active + * Interface configuration + */ + if (PIM_UPSTREAM_FLAG_TEST_MLAG_INTERFACE(up->flags)) { + pim_mlag_calculate_df_for_ifchannels(up, is_df); + pim_mlag_inherit_mlag_flags(up, is_df); + } + /* If the DF role has changed check if ipmr-lo needs to be * muted/un-muted. Active-Active devices and vxlan termination * devices (ipmr-lo) are suppressed on the non-DF. @@ -91,7 +170,8 @@ static bool pim_mlag_up_df_role_elect(struct pim_instance *pim, uint32_t local_cost; bool rv; - if (!pim_up_mlag_is_local(up)) + if (!pim_up_mlag_is_local(up) + && !PIM_UPSTREAM_FLAG_TEST_MLAG_INTERFACE(up->flags)) return false; /* We are yet to rx a status update from the local MLAG daemon so @@ -316,14 +396,6 @@ static void pim_mlag_up_peer_del_all(void) list_delete(&temp); } -static int pim_mlag_signal_zpthread(void) -{ - /* XXX - This is a temporary stub; the MLAG thread code is planned for - * a separate commit - */ - return (0); -} - /* Send upstream entry to the local MLAG daemon (which will subsequently * send it to the peer MLAG switch). */ @@ -429,7 +501,8 @@ static void pim_mlag_up_local_replay(void) RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name) { pim = vrf->info; frr_each (rb_pim_upstream, &pim->upstream_head, up) { - if (pim_up_mlag_is_local(up)) + if (pim_up_mlag_is_local(up) + || PIM_UPSTREAM_FLAG_TEST_MLAG_INTERFACE(up->flags)) pim_mlag_up_local_add_send(pim, up); } } @@ -450,7 +523,9 @@ static void pim_mlag_up_local_reeval(bool mlagd_send, const char *reason_code) RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name) { pim = vrf->info; frr_each (rb_pim_upstream, &pim->upstream_head, up) { - if (!pim_up_mlag_is_local(up)) + if (!pim_up_mlag_is_local(up) + && !PIM_UPSTREAM_FLAG_TEST_MLAG_INTERFACE( + up->flags)) continue; /* if role changes re-send to peer */ if (pim_mlag_up_df_role_elect(pim, up) && @@ -694,8 +769,9 @@ int pim_zebra_mlag_handle_msg(struct stream *s, int len) struct mlag_msg mlag_msg; char buf[ZLOG_FILTER_LENGTH_MAX]; int rc = 0; + size_t length; - rc = mlag_lib_decode_mlag_hdr(s, &mlag_msg); + rc = mlag_lib_decode_mlag_hdr(s, &mlag_msg, &length); if (rc) return (rc); @@ -734,7 +810,7 @@ int pim_zebra_mlag_handle_msg(struct stream *s, int len) case MLAG_MROUTE_ADD: { struct mlag_mroute_add msg; - rc = mlag_lib_decode_mroute_add(s, &msg); + rc = mlag_lib_decode_mroute_add(s, &msg, &length); if (rc) return (rc); pim_mlag_process_mroute_add(msg); @@ -742,7 +818,7 @@ int pim_zebra_mlag_handle_msg(struct stream *s, int len) case MLAG_MROUTE_DEL: { struct mlag_mroute_del msg; - rc = mlag_lib_decode_mroute_del(s, &msg); + rc = mlag_lib_decode_mroute_del(s, &msg, &length); if (rc) return (rc); pim_mlag_process_mroute_del(msg); @@ -752,8 +828,7 @@ int pim_zebra_mlag_handle_msg(struct stream *s, int len) int i; for (i = 0; i < mlag_msg.msg_cnt; i++) { - - rc = mlag_lib_decode_mroute_add(s, &msg); + rc = mlag_lib_decode_mroute_add(s, &msg, &length); if (rc) return (rc); pim_mlag_process_mroute_add(msg); @@ -764,8 +839,7 @@ int pim_zebra_mlag_handle_msg(struct stream *s, int len) int i; for (i = 0; i < mlag_msg.msg_cnt; i++) { - - rc = mlag_lib_decode_mroute_del(s, &msg); + rc = mlag_lib_decode_mroute_del(s, &msg, &length); if (rc) return (rc); pim_mlag_process_mroute_del(msg); @@ -784,6 +858,12 @@ int pim_zebra_mlag_process_up(void) if (PIM_DEBUG_MLAG) zlog_debug("%s: Received Process-Up from Mlag", __func__); + /* + * Incase of local MLAG restart, PIM needs to replay all the data + * since MLAG is empty. + */ + router->connected_to_mlag = true; + router->mlag_flags |= PIM_MLAGF_LOCAL_CONN_UP; return 0; } @@ -876,7 +956,7 @@ static int pim_mlag_deregister_handler(struct thread *thread) void pim_mlag_deregister(void) { /* if somebody still interested in the MLAG channel skip de-reg */ - if (router->pim_mlag_intf_cnt) + if (router->pim_mlag_intf_cnt || pim_vxlan_do_mlag_reg()) return; /* not registered; nothing do */ @@ -894,10 +974,6 @@ void pim_if_configure_mlag_dualactive(struct pim_interface *pim_ifp) if (!pim_ifp || !pim_ifp->pim || pim_ifp->activeactive == true) return; - if (PIM_DEBUG_MLAG) - zlog_debug("%s: Configuring active-active on Interface: %s", - __func__, "NULL"); - pim_ifp->activeactive = true; if (pim_ifp->pim) pim_ifp->pim->inst_mlag_intf_cnt++; @@ -923,10 +999,6 @@ void pim_if_unconfigure_mlag_dualactive(struct pim_interface *pim_ifp) if (!pim_ifp || !pim_ifp->pim || pim_ifp->activeactive == false) return; - if (PIM_DEBUG_MLAG) - zlog_debug("%s: UnConfiguring active-active on Interface: %s", - __func__, "NULL"); - pim_ifp->activeactive = false; pim_ifp->pim->inst_mlag_intf_cnt--; @@ -943,6 +1015,7 @@ void pim_if_unconfigure_mlag_dualactive(struct pim_interface *pim_ifp) * De-register to Zebra */ pim_mlag_deregister(); + pim_mlag_param_reset(); } } diff --git a/pimd/pim_mlag.h b/pimd/pim_mlag.h index dab29cc9a2..eb316695f7 100644 --- a/pimd/pim_mlag.h +++ b/pimd/pim_mlag.h @@ -32,15 +32,22 @@ extern void pim_instance_mlag_init(struct pim_instance *pim); extern void pim_instance_mlag_terminate(struct pim_instance *pim); extern void pim_if_configure_mlag_dualactive(struct pim_interface *pim_ifp); extern void pim_if_unconfigure_mlag_dualactive(struct pim_interface *pim_ifp); -extern void pim_mlag_register(void); -extern void pim_mlag_deregister(void); extern int pim_zebra_mlag_process_up(void); extern int pim_zebra_mlag_process_down(void); extern int pim_zebra_mlag_handle_msg(struct stream *msg, int len); + +/* pm_zpthread.c */ +extern int pim_mlag_signal_zpthread(void); +extern void pim_zpthread_init(void); +extern void pim_zpthread_terminate(void); + +extern void pim_mlag_register(void); +extern void pim_mlag_deregister(void); extern void pim_mlag_up_local_add(struct pim_instance *pim, - struct pim_upstream *upstream); + struct pim_upstream *upstream); extern void pim_mlag_up_local_del(struct pim_instance *pim, - struct pim_upstream *upstream); + struct pim_upstream *upstream); extern bool pim_mlag_up_df_role_update(struct pim_instance *pim, - struct pim_upstream *up, bool is_df, const char *reason); + struct pim_upstream *up, bool is_df, + const char *reason); #endif diff --git a/pimd/pim_mroute.c b/pimd/pim_mroute.c index 14f8a8312b..5ce7863611 100644 --- a/pimd/pim_mroute.c +++ b/pimd/pim_mroute.c @@ -443,6 +443,7 @@ static int pim_mroute_msg_wrvifwhole(int fd, struct interface *ifp, { const struct ip *ip_hdr = (const struct ip *)buf; struct pim_interface *pim_ifp; + struct pim_instance *pim; struct pim_ifchannel *ch; struct pim_upstream *up; struct prefix_sg star_g; @@ -465,16 +466,18 @@ static int pim_mroute_msg_wrvifwhole(int fd, struct interface *ifp, star_g = sg; star_g.src.s_addr = INADDR_ANY; -#if 0 - ch = pim_ifchannel_find(ifp, &star_g); - if (ch) - { - if (PIM_DEBUG_MROUTE) - zlog_debug ("WRVIFWHOLE (*,G)=%s found ifchannel on interface %s", - pim_str_sg_dump (&star_g), ifp->name); - return -1; - } -#endif + + pim = pim_ifp->pim; + /* + * If the incoming interface is the pimreg, then + * we know the callback is associated with a pim register + * packet and there is nothing to do here as that + * normal pim processing will see the packet and allow + * us to do the right thing. + */ + if (ifp == pim->regiface) { + return 0; + } up = pim_upstream_find(pim_ifp->pim, &sg); if (up) { @@ -502,8 +505,17 @@ static int pim_mroute_msg_wrvifwhole(int fd, struct interface *ifp, * the pimreg period, so I believe we can ignore this packet */ if (!PIM_UPSTREAM_FLAG_TEST_FHR(up->flags)) { - // No if channel, but upstream we are at the RP. - if (pim_nexthop_lookup(pim_ifp->pim, &source, + /* + * No if channel, but upstream we are at the RP. + * + * This could be a anycast RP too and we may + * not have received a register packet from + * the source here at all. So gracefully + * bow out of doing a nexthop lookup and + * setting the SPTBIT to true + */ + if (up->upstream_register.s_addr != INADDR_ANY && + pim_nexthop_lookup(pim_ifp->pim, &source, up->upstream_register, 0)) { pim_register_stop_send(source.interface, &sg, pim_ifp->primary_address, @@ -1005,8 +1017,10 @@ static int pim_mroute_add(struct channel_oil *c_oil, const char *name) pim_channel_oil_dump(c_oil, buf, sizeof(buf))); } - c_oil->installed = 1; - c_oil->mroute_creation = pim_time_monotonic_sec(); + if (!c_oil->installed) { + c_oil->installed = 1; + c_oil->mroute_creation = pim_time_monotonic_sec(); + } return 0; } diff --git a/pimd/pim_oil.c b/pimd/pim_oil.c index 0618308ba8..21febcc969 100644 --- a/pimd/pim_oil.c +++ b/pimd/pim_oil.c @@ -33,9 +33,6 @@ #include "pim_time.h" #include "pim_vxlan.h" -// struct list *pim_channel_oil_list = NULL; -// struct hash *pim_channel_oil_hash = NULL; - static void pim_channel_update_mute(struct channel_oil *c_oil); char *pim_channel_oil_dump(struct channel_oil *c_oil, char *buf, size_t size) @@ -174,7 +171,7 @@ struct channel_oil *pim_channel_oil_add(struct pim_instance *pim, } struct channel_oil *pim_channel_oil_del(struct channel_oil *c_oil, - const char *name) + const char *name) { if (PIM_DEBUG_MROUTE) { struct prefix_sg sg = {.src = c_oil->oil.mfcc_mcastgrp, @@ -496,6 +493,23 @@ int pim_channel_add_oif(struct channel_oil *channel_oil, struct interface *oif, } } + if (PIM_DEBUG_MROUTE) { + char group_str[INET_ADDRSTRLEN]; + char source_str[INET_ADDRSTRLEN]; + pim_inet4_dump("<group?>", + channel_oil->oil.mfcc_mcastgrp, + group_str, sizeof(group_str)); + pim_inet4_dump("<source?>", + channel_oil->oil.mfcc_origin, source_str, + sizeof(source_str)); + zlog_debug( + "%s(%s): (S,G)=(%s,%s): proto_mask=%u OIF=%s vif_index=%d added to 0x%x", + __func__, caller, source_str, group_str, + proto_mask, oif->name, + pim_ifp->mroute_vif_index, + channel_oil + ->oif_flags[pim_ifp->mroute_vif_index]); + } return 0; } diff --git a/pimd/pim_oil.h b/pimd/pim_oil.h index 788ddaa16c..8a808afa73 100644 --- a/pimd/pim_oil.h +++ b/pimd/pim_oil.h @@ -130,7 +130,7 @@ void pim_channel_oil_change_iif(struct pim_instance *pim, struct channel_oil *c_oil, int input_vif_index, const char *name); struct channel_oil *pim_channel_oil_del(struct channel_oil *c_oil, - const char *name); + const char *name); int pim_channel_add_oif(struct channel_oil *c_oil, struct interface *oif, uint32_t proto_mask, const char *caller); @@ -146,6 +146,6 @@ void pim_channel_update_oif_mute(struct channel_oil *c_oil, void pim_channel_oil_upstream_deref(struct channel_oil *c_oil); void pim_channel_del_inherited_oif(struct channel_oil *c_oil, - struct interface *oif, const char *caller); + struct interface *oif, const char *caller); #endif /* PIM_OIL_H */ diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c index 8799134edd..355aa07048 100644 --- a/pimd/pim_rp.c +++ b/pimd/pim_rp.c @@ -248,13 +248,14 @@ struct rp_info *pim_rp_find_match_group(struct pim_instance *pim, if (PIM_DEBUG_PIM_TRACE) { char buf[PREFIX_STRLEN]; - route_unlock_node(rn); zlog_debug("Lookedup: %p for rp_info: %p(%s) Lock: %d", rn, rp_info, prefix2str(&rp_info->group, buf, sizeof(buf)), rn->lock); } + route_unlock_node(rn); + if (!best) return rp_info; diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c index cf333ffccf..efa58c1b1f 100644 --- a/pimd/pim_upstream.c +++ b/pimd/pim_upstream.c @@ -57,6 +57,7 @@ static void join_timer_stop(struct pim_upstream *up); static void pim_upstream_update_assert_tracking_desired(struct pim_upstream *up); +static bool pim_upstream_sg_running_proc(struct pim_upstream *up); /* * A (*,G) or a (*,*) is going away @@ -141,6 +142,18 @@ static struct pim_upstream *pim_upstream_find_parent(struct pim_instance *pim, if (up) listnode_add(up->sources, child); + /* + * In case parent is MLAG entry copy the data to child + */ + if (up && PIM_UPSTREAM_FLAG_TEST_MLAG_INTERFACE(up->flags)) { + PIM_UPSTREAM_FLAG_SET_MLAG_INTERFACE(child->flags); + if (PIM_UPSTREAM_FLAG_TEST_MLAG_NON_DF(up->flags)) + PIM_UPSTREAM_FLAG_SET_MLAG_NON_DF(child->flags); + else + PIM_UPSTREAM_FLAG_UNSET_MLAG_NON_DF( + child->flags); + } + return up; } @@ -853,9 +866,23 @@ static struct pim_upstream *pim_upstream_new(struct pim_instance *pim, up->ifchannels = list_new(); up->ifchannels->cmp = (int (*)(void *, void *))pim_ifchannel_compare; - if (up->sg.src.s_addr != INADDR_ANY) + if (up->sg.src.s_addr != INADDR_ANY) { wheel_add_item(pim->upstream_sg_wheel, up); + /* Inherit the DF role from the parent (*, G) entry for + * VxLAN BUM groups + */ + if (up->parent + && PIM_UPSTREAM_FLAG_TEST_MLAG_VXLAN(up->parent->flags) + && PIM_UPSTREAM_FLAG_TEST_MLAG_NON_DF(up->parent->flags)) { + PIM_UPSTREAM_FLAG_SET_MLAG_NON_DF(up->flags); + if (PIM_DEBUG_VXLAN) + zlog_debug( + "upstream %s inherited mlag non-df flag from parent", + up->sg_str); + } + } + if (PIM_UPSTREAM_FLAG_TEST_STATIC_IIF(up->flags) || PIM_UPSTREAM_FLAG_TEST_SRC_NOCACHE(up->flags)) { pim_upstream_fill_static_iif(up, incoming); @@ -885,24 +912,12 @@ static struct pim_upstream *pim_upstream_new(struct pim_instance *pim, } } - /* If (S, G) inherit the MLAG_VXLAN from the parent - * (*, G) entry. - */ - if ((up->sg.src.s_addr != INADDR_ANY) && - up->parent && - PIM_UPSTREAM_FLAG_TEST_MLAG_VXLAN(up->parent->flags) && - !PIM_UPSTREAM_FLAG_TEST_SRC_VXLAN_ORIG(up->flags)) { - PIM_UPSTREAM_FLAG_SET_MLAG_VXLAN(up->flags); - if (PIM_DEBUG_VXLAN) - zlog_debug("upstream %s inherited mlag vxlan flag from parent", - up->sg_str); - } - /* send the entry to the MLAG peer */ /* XXX - duplicate send is possible here if pim_rpf_update * successfully resolved the nexthop */ - if (pim_up_mlag_is_local(up)) + if (pim_up_mlag_is_local(up) + || PIM_UPSTREAM_FLAG_TEST_MLAG_INTERFACE(up->flags)) pim_mlag_up_local_add(pim, up); if (PIM_DEBUG_PIM_TRACE) { @@ -917,7 +932,8 @@ static struct pim_upstream *pim_upstream_new(struct pim_instance *pim, uint32_t pim_up_mlag_local_cost(struct pim_upstream *up) { - if (!(pim_up_mlag_is_local(up))) + if (!(pim_up_mlag_is_local(up)) + && !(up->flags & PIM_UPSTREAM_FLAG_MASK_MLAG_INTERFACE)) return router->infinite_assert_metric.route_metric; if ((up->rpf.source_nexthop.interface == @@ -1438,6 +1454,11 @@ static int pim_upstream_keep_alive_timer(struct thread *t) up = THREAD_ARG(t); + /* pull the stats and re-check */ + if (pim_upstream_sg_running_proc(up)) + /* kat was restarted because of new activity */ + return 0; + pim_upstream_keep_alive_timer_proc(up); return 0; } @@ -1751,6 +1772,7 @@ int pim_upstream_inherited_olist_decide(struct pim_instance *pim, up->sg_str); FOR_ALL_INTERFACES (pim->vrf, ifp) { + struct pim_interface *pim_ifp; if (!ifp->info) continue; @@ -1764,6 +1786,12 @@ int pim_upstream_inherited_olist_decide(struct pim_instance *pim, if (!ch && !starch) continue; + pim_ifp = ifp->info; + if (PIM_I_am_DualActive(pim_ifp) + && PIM_UPSTREAM_FLAG_TEST_MLAG_INTERFACE(up->flags) + && (PIM_UPSTREAM_FLAG_TEST_MLAG_NON_DF(up->flags) + || !PIM_UPSTREAM_FLAG_TEST_MLAG_PEER(up->flags))) + continue; if (pim_upstream_evaluate_join_desired_interface(up, ch, starch)) { int flag = PIM_OIF_FLAG_PROTO_PIM; @@ -1943,39 +1971,14 @@ static bool pim_upstream_kat_start_ok(struct pim_upstream *up) return false; } -/* - * Code to check and see if we've received packets on a S,G mroute - * and if so to set the SPT bit appropriately - */ -static void pim_upstream_sg_running(void *arg) +static bool pim_upstream_sg_running_proc(struct pim_upstream *up) { - struct pim_upstream *up = (struct pim_upstream *)arg; - struct pim_instance *pim = up->channel_oil->pim; + bool rv = false; + struct pim_instance *pim = up->pim; - // No packet can have arrived here if this is the case - if (!up->channel_oil->installed) { - if (PIM_DEBUG_PIM_TRACE) - zlog_debug("%s: %s%s is not installed in mroute", - __func__, up->sg_str, pim->vrf->name); - return; - } + if (!up->channel_oil->installed) + return rv; - /* - * This is a bit of a hack - * We've noted that we should rescan but - * we've missed the window for doing so in - * pim_zebra.c for some reason. I am - * only doing this at this point in time - * to get us up and working for the moment - */ - if (up->channel_oil->oil_inherited_rescan) { - if (PIM_DEBUG_PIM_TRACE) - zlog_debug( - "%s: Handling unscanned inherited_olist for %s[%s]", - __func__, up->sg_str, pim->vrf->name); - pim_upstream_inherited_olist_decide(pim, up); - up->channel_oil->oil_inherited_rescan = 0; - } pim_mroute_update_counters(up->channel_oil); // Have we seen packets? @@ -1989,7 +1992,7 @@ static void pim_upstream_sg_running(void *arg) up->channel_oil->cc.pktcnt, up->channel_oil->cc.lastused / 100); } - return; + return rv; } if (pim_upstream_kat_start_ok(up)) { @@ -2007,14 +2010,55 @@ static void pim_upstream_sg_running(void *arg) pim_upstream_fhr_kat_start(up); } pim_upstream_keep_alive_timer_start(up, pim->keep_alive_time); - } else if (PIM_UPSTREAM_FLAG_TEST_SRC_LHR(up->flags)) + rv = true; + } else if (PIM_UPSTREAM_FLAG_TEST_SRC_LHR(up->flags)) { pim_upstream_keep_alive_timer_start(up, pim->keep_alive_time); + rv = true; + } if ((up->sptbit != PIM_UPSTREAM_SPTBIT_TRUE) && (up->rpf.source_nexthop.interface)) { pim_upstream_set_sptbit(up, up->rpf.source_nexthop.interface); } - return; + + return rv; +} + +/* + * Code to check and see if we've received packets on a S,G mroute + * and if so to set the SPT bit appropriately + */ +static void pim_upstream_sg_running(void *arg) +{ + struct pim_upstream *up = (struct pim_upstream *)arg; + struct pim_instance *pim = up->channel_oil->pim; + + // No packet can have arrived here if this is the case + if (!up->channel_oil->installed) { + if (PIM_DEBUG_TRACE) + zlog_debug("%s: %s%s is not installed in mroute", + __func__, up->sg_str, pim->vrf->name); + return; + } + + /* + * This is a bit of a hack + * We've noted that we should rescan but + * we've missed the window for doing so in + * pim_zebra.c for some reason. I am + * only doing this at this point in time + * to get us up and working for the moment + */ + if (up->channel_oil->oil_inherited_rescan) { + if (PIM_DEBUG_TRACE) + zlog_debug( + "%s: Handling unscanned inherited_olist for %s[%s]", + __func__, up->sg_str, pim->vrf->name); + pim_upstream_inherited_olist_decide(pim, up); + up->channel_oil->oil_inherited_rescan = 0; + } + + pim_upstream_sg_running_proc(up); } void pim_upstream_add_lhr_star_pimreg(struct pim_instance *pim) diff --git a/pimd/pim_upstream.h b/pimd/pim_upstream.h index 4d693b8b64..ca693ee73f 100644 --- a/pimd/pim_upstream.h +++ b/pimd/pim_upstream.h @@ -237,6 +237,8 @@ struct pim_upstream { struct channel_oil *channel_oil; struct list *sources; struct list *ifchannels; + /* Counter for Dual active ifchannels*/ + uint32_t dualactive_ifchannel_count; enum pim_upstream_state join_state; enum pim_reg_state reg_state; diff --git a/pimd/pim_vty.c b/pimd/pim_vty.c index b5a5089ae7..8a87dfbb55 100644 --- a/pimd/pim_vty.c +++ b/pimd/pim_vty.c @@ -117,6 +117,11 @@ int pim_debug_config_write(struct vty *vty) ++writes; } + if (PIM_DEBUG_MLAG) { + vty_out(vty, "debug pim mlag\n"); + ++writes; + } + if (PIM_DEBUG_BSM) { vty_out(vty, "debug pim bsm\n"); ++writes; diff --git a/pimd/pim_vxlan.c b/pimd/pim_vxlan.c index 93e2f00f90..569b04d278 100644 --- a/pimd/pim_vxlan.c +++ b/pimd/pim_vxlan.c @@ -85,8 +85,16 @@ static void pim_vxlan_do_reg_work(void) if (PIM_DEBUG_VXLAN) zlog_debug("vxlan SG %s periodic NULL register", vxlan_sg->sg_str); - pim_null_register_send(vxlan_sg->up); - ++work_cnt; + + /* + * If we are on the work queue *and* the rpf + * has been lost on the vxlan_sg->up let's + * make sure that we don't send it. + */ + if (vxlan_sg->up->rpf.source_nexthop.interface) { + pim_null_register_send(vxlan_sg->up); + ++work_cnt; + } } if (work_cnt > vxlan_info.max_work_cnt) { @@ -217,6 +225,7 @@ static void pim_vxlan_orig_mr_up_del(struct pim_vxlan_sg *vxlan_sg) vxlan_sg->sg_str); vxlan_sg->up = NULL; + if (up->flags & PIM_UPSTREAM_FLAG_MASK_SRC_VXLAN_ORIG) { /* clear out all the vxlan properties */ up->flags &= ~(PIM_UPSTREAM_FLAG_MASK_SRC_VXLAN_ORIG | @@ -284,6 +293,7 @@ static void pim_vxlan_orig_mr_up_iif_update(struct pim_vxlan_sg *vxlan_sg) static void pim_vxlan_orig_mr_up_add(struct pim_vxlan_sg *vxlan_sg) { struct pim_upstream *up; + struct pim_interface *term_ifp; int flags = 0; struct prefix nht_p; struct pim_instance *pim = vxlan_sg->pim; @@ -345,6 +355,11 @@ static void pim_vxlan_orig_mr_up_add(struct pim_vxlan_sg *vxlan_sg) pim_upstream_update_use_rpt(up, false /*update_mroute*/); pim_upstream_ref(up, flags, __func__); vxlan_sg->up = up; + term_ifp = pim_vxlan_get_term_ifp(pim); + /* mute termination device on origination mroutes */ + if (term_ifp) + pim_channel_update_oif_mute(up->channel_oil, + term_ifp); pim_vxlan_orig_mr_up_iif_update(vxlan_sg); /* mute pimreg on origination mroutes */ if (pim->regiface) @@ -748,14 +763,8 @@ struct pim_vxlan_sg *pim_vxlan_sg_add(struct pim_instance *pim, return vxlan_sg; } -void pim_vxlan_sg_del(struct pim_instance *pim, struct prefix_sg *sg) +static void pim_vxlan_sg_del_item(struct pim_vxlan_sg *vxlan_sg) { - struct pim_vxlan_sg *vxlan_sg; - - vxlan_sg = pim_vxlan_sg_find(pim, sg); - if (!vxlan_sg) - return; - vxlan_sg->flags |= PIM_VXLAN_SGF_DEL_IN_PROG; pim_vxlan_del_work(vxlan_sg); @@ -765,14 +774,24 @@ void pim_vxlan_sg_del(struct pim_instance *pim, struct prefix_sg *sg) else pim_vxlan_term_mr_del(vxlan_sg); - hash_release(vxlan_sg->pim->vxlan.sg_hash, vxlan_sg); - if (PIM_DEBUG_VXLAN) zlog_debug("vxlan SG %s free", vxlan_sg->sg_str); XFREE(MTYPE_PIM_VXLAN_SG, vxlan_sg); } +void pim_vxlan_sg_del(struct pim_instance *pim, struct prefix_sg *sg) +{ + struct pim_vxlan_sg *vxlan_sg; + + vxlan_sg = pim_vxlan_sg_find(pim, sg); + if (!vxlan_sg) + return; + + pim_vxlan_sg_del_item(vxlan_sg); + hash_release(pim->vxlan.sg_hash, vxlan_sg); +} + /******************************* MLAG handling *******************************/ bool pim_vxlan_do_mlag_reg(void) { @@ -1147,8 +1166,14 @@ void pim_vxlan_init(struct pim_instance *pim) void pim_vxlan_exit(struct pim_instance *pim) { if (pim->vxlan.sg_hash) { - hash_clean(pim->vxlan.sg_hash, NULL); + hash_clean(pim->vxlan.sg_hash, + (void (*)(void *))pim_vxlan_sg_del_item); hash_free(pim->vxlan.sg_hash); pim->vxlan.sg_hash = NULL; } } + +void pim_vxlan_terminate(void) +{ + pim_vxlan_work_timer_setup(false); +} diff --git a/pimd/pim_vxlan.h b/pimd/pim_vxlan.h index 198d1c3281..18f1b74175 100644 --- a/pimd/pim_vxlan.h +++ b/pimd/pim_vxlan.h @@ -148,4 +148,6 @@ extern bool pim_vxlan_do_mlag_reg(void); extern void pim_vxlan_inherit_mlag_flags(struct pim_instance *pim, struct pim_upstream *up, bool inherit); +/* Shutdown of PIM stop the thread */ +extern void pim_vxlan_terminate(void); #endif /* PIM_VXLAN_H */ diff --git a/pimd/pim_zpthread.c b/pimd/pim_zpthread.c new file mode 100644 index 0000000000..518b024749 --- /dev/null +++ b/pimd/pim_zpthread.c @@ -0,0 +1,225 @@ +/* + * PIM for Quagga + * Copyright (C) 2008 Everton da Silva Marques + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; see the file COPYING; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <zebra.h> +#include <lib/log.h> +#include <lib/lib_errors.h> + +#include "pimd.h" +#include "pim_mlag.h" +#include "pim_zebra.h" + +extern struct zclient *zclient; + +#define PIM_MLAG_POST_LIMIT 100 + +int32_t mlag_bulk_cnt; + +static void pim_mlag_zebra_fill_header(enum mlag_msg_type msg_type) +{ + uint32_t fill_msg_type = msg_type; + uint16_t data_len; + uint16_t msg_cnt = 1; + + if (msg_type == MLAG_MSG_NONE) + return; + + switch (msg_type) { + case MLAG_REGISTER: + case MLAG_DEREGISTER: + data_len = sizeof(struct mlag_msg); + break; + case MLAG_MROUTE_ADD: + data_len = sizeof(struct mlag_mroute_add); + fill_msg_type = MLAG_MROUTE_ADD_BULK; + break; + case MLAG_MROUTE_DEL: + data_len = sizeof(struct mlag_mroute_del); + fill_msg_type = MLAG_MROUTE_DEL_BULK; + break; + default: + data_len = 0; + break; + } + + stream_reset(router->mlag_stream); + /* ADD Hedaer */ + stream_putl(router->mlag_stream, fill_msg_type); + /* + * In case of Bulk actual size & msg_cnt will be updated + * just before writing onto zebra + */ + stream_putw(router->mlag_stream, data_len); + stream_putw(router->mlag_stream, msg_cnt); + + if (PIM_DEBUG_MLAG) + zlog_debug(":%s: msg_type: %d/%d len %d", + __func__, msg_type, fill_msg_type, data_len); +} + +static void pim_mlag_zebra_flush_buffer(void) +{ + uint32_t msg_type; + + /* Stream had bulk messages update the Hedaer */ + if (mlag_bulk_cnt > 1) { + /* + * No need to reset the pointer, below api reads from data[0] + */ + STREAM_GETL(router->mlag_stream, msg_type); + if (msg_type == MLAG_MROUTE_ADD_BULK) { + stream_putw_at( + router->mlag_stream, 4, + (mlag_bulk_cnt * sizeof(struct mlag_mroute_add))); + stream_putw_at(router->mlag_stream, 6, mlag_bulk_cnt); + } else if (msg_type == MLAG_MROUTE_DEL_BULK) { + stream_putw_at( + router->mlag_stream, 4, + (mlag_bulk_cnt * sizeof(struct mlag_mroute_del))); + stream_putw_at(router->mlag_stream, 6, mlag_bulk_cnt); + } else { + flog_err(EC_LIB_ZAPI_ENCODE, + "unknown bulk message type %d bulk_count %d", + msg_type, mlag_bulk_cnt); + stream_reset(router->mlag_stream); + mlag_bulk_cnt = 0; + return; + } + } + + zclient_send_mlag_data(zclient, router->mlag_stream); +stream_failure: + stream_reset(router->mlag_stream); + mlag_bulk_cnt = 0; +} + +/* + * Only ROUTE add & Delete will be bulked. + * Buffer will be flushed, when + * 1) there were no messages in the queue + * 2) Curr_msg_type != prev_msg_type + */ + +static void pim_mlag_zebra_check_for_buffer_flush(uint32_t curr_msg_type, + uint32_t prev_msg_type) +{ + /* First Message, keep bulking */ + if (prev_msg_type == MLAG_MSG_NONE) { + mlag_bulk_cnt = 1; + return; + } + + /*msg type is route add & delete, keep bulking */ + if (curr_msg_type == prev_msg_type + && (curr_msg_type == MLAG_MROUTE_ADD + || curr_msg_type == MLAG_MROUTE_DEL)) { + mlag_bulk_cnt++; + return; + } + + pim_mlag_zebra_flush_buffer(); +} + +/* + * Thsi thread reads the clients data from the Gloabl queue and encodes with + * protobuf and pass on to the MLAG socket. + */ +static int pim_mlag_zthread_handler(struct thread *event) +{ + struct stream *read_s; + uint32_t wr_count = 0; + uint32_t prev_msg_type = MLAG_MSG_NONE; + uint32_t curr_msg_type = MLAG_MSG_NONE; + + router->zpthread_mlag_write = NULL; + wr_count = stream_fifo_count_safe(router->mlag_fifo); + + if (PIM_DEBUG_MLAG) + zlog_debug(":%s: Processing MLAG write, %d messages in queue", + __func__, wr_count); + + if (wr_count == 0) + return 0; + + for (wr_count = 0; wr_count < PIM_MLAG_POST_LIMIT; wr_count++) { + /* FIFO is empty,wait for teh message to be add */ + if (stream_fifo_count_safe(router->mlag_fifo) == 0) + break; + + read_s = stream_fifo_pop_safe(router->mlag_fifo); + if (!read_s) { + zlog_debug(":%s: Got a NULL Messages, some thing wrong", + __func__); + break; + } + STREAM_GETL(read_s, curr_msg_type); + /* + * Check for Buffer Overflow, + * MLAG Can't process more than 'PIM_MLAG_BUF_LIMIT' bytes + */ + if (router->mlag_stream->endp + read_s->endp + ZEBRA_HEADER_SIZE + > MLAG_BUF_LIMIT) + pim_mlag_zebra_flush_buffer(); + + pim_mlag_zebra_check_for_buffer_flush(curr_msg_type, + prev_msg_type); + + /* + * First message to Buffer, fill the Header + */ + if (router->mlag_stream->endp == 0) + pim_mlag_zebra_fill_header(curr_msg_type); + + /* + * add the data now + */ + stream_put(router->mlag_stream, read_s->data + read_s->getp, + read_s->endp - read_s->getp); + + stream_free(read_s); + prev_msg_type = curr_msg_type; + } + +stream_failure: + /* + * we are here , because + * 1. Queue might be empty + * 2. we crossed the max Q Read limit + * In any acse flush the buffer towards zebra + */ + pim_mlag_zebra_flush_buffer(); + + if (wr_count >= PIM_MLAG_POST_LIMIT) + pim_mlag_signal_zpthread(); + + return 0; +} + + +int pim_mlag_signal_zpthread(void) +{ + if (router->master) { + if (PIM_DEBUG_MLAG) + zlog_debug(":%s: Scheduling PIM MLAG write Thread", + __func__); + thread_add_event(router->master, pim_mlag_zthread_handler, NULL, + 0, &router->zpthread_mlag_write); + } + return (0); +} diff --git a/pimd/pimd.c b/pimd/pimd.c index a2af66fdc7..5ccbac32f2 100644 --- a/pimd/pimd.c +++ b/pimd/pimd.c @@ -39,6 +39,7 @@ #include "pim_static.h" #include "pim_rp.h" #include "pim_ssm.h" +#include "pim_vxlan.h" #include "pim_zlookup.h" #include "pim_zebra.h" @@ -102,6 +103,8 @@ void pim_router_init(void) router->packet_process = PIM_DEFAULT_PACKET_PROCESS; router->register_probe_time = PIM_REGISTER_PROBE_TIME_DEFAULT; router->vrf_id = VRF_DEFAULT; + router->pim_mlag_intf_cnt = 0; + router->connected_to_mlag = false; } void pim_router_terminate(void) @@ -133,6 +136,7 @@ void pim_terminate(void) prefix_list_delete_hook(NULL); prefix_list_reset(); + pim_vxlan_terminate(); pim_vrf_terminate(); zclient = pim_zebra_zclient_get(); diff --git a/pimd/subdir.am b/pimd/subdir.am index b5d135d032..0e30590079 100644 --- a/pimd/subdir.am +++ b/pimd/subdir.am @@ -34,6 +34,7 @@ pimd_libpim_a_SOURCES = \ pimd/pim_jp_agg.c \ pimd/pim_macro.c \ pimd/pim_memory.c \ + pimd/pim_mlag.c \ pimd/pim_mroute.c \ pimd/pim_msdp.c \ pimd/pim_msdp_packet.c \ @@ -62,7 +63,7 @@ pimd_libpim_a_SOURCES = \ pimd/pim_zebra.c \ pimd/pim_zlookup.c \ pimd/pim_vxlan.c \ - pimd/pim_mlag.c \ + pimd/pim_zpthread.c \ pimd/pimd.c \ # end @@ -88,6 +89,7 @@ noinst_HEADERS += \ pimd/pim_jp_agg.h \ pimd/pim_macro.h \ pimd/pim_memory.h \ + pimd/pim_mlag.h \ pimd/pim_mroute.h \ pimd/pim_msdp.h \ pimd/pim_msdp_packet.h \ @@ -115,7 +117,6 @@ noinst_HEADERS += \ pimd/pim_zebra.h \ pimd/pim_zlookup.h \ pimd/pim_vxlan.h \ - pimd/pim_mlag.h \ pimd/pim_vxlan_instance.h \ pimd/pimd.h \ pimd/mtracebis_netlink.h \ diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c index 7fbe64e8e3..bb33abdb2c 100644 --- a/ripngd/ripngd.c +++ b/ripngd/ripngd.c @@ -1455,7 +1455,7 @@ static int ripng_update(struct thread *t) if (ri->passive) continue; -#if RIPNG_ADVANCED +#ifdef RIPNG_ADVANCED if (ri->ri_send == RIPNG_SEND_OFF) { if (IS_RIPNG_DEBUG_EVENT) zlog_debug( diff --git a/tests/isisd/test_fuzz_isis_tlv_tests.h.gz b/tests/isisd/test_fuzz_isis_tlv_tests.h.gz Binary files differindex 46e45e5ee0..4f59d1d7c0 100644 --- a/tests/isisd/test_fuzz_isis_tlv_tests.h.gz +++ b/tests/isisd/test_fuzz_isis_tlv_tests.h.gz diff --git a/tests/topotests/bgp-basic-functionality-topo1/test_bgp_basic_functionality.py b/tests/topotests/bgp-basic-functionality-topo1/test_bgp_basic_functionality.py index e99111d90b..43639a81d1 100755 --- a/tests/topotests/bgp-basic-functionality-topo1/test_bgp_basic_functionality.py +++ b/tests/topotests/bgp-basic-functionality-topo1/test_bgp_basic_functionality.py @@ -79,6 +79,9 @@ try: except IOError: assert False, "Could not read file {}".format(jsonFile) +#Global Variable +KEEPALIVETIMER = 2 +HOLDDOWNTIMER = 6 class CreateTopo(Topo): """ @@ -292,8 +295,8 @@ def test_bgp_timers_functionality(request): "r2": { "dest_link":{ "r1": { - "keepalivetimer": 60, - "holddowntimer": 180, + "keepalivetimer": KEEPALIVETIMER, + "holddowntimer": HOLDDOWNTIMER } } } @@ -319,8 +322,6 @@ def test_bgp_timers_functionality(request): write_test_footer(tc_name) - - def test_static_routes(request): """ Test to create and verify static routes. """ diff --git a/tests/topotests/lib/bgp.py b/tests/topotests/lib/bgp.py index f3c17be684..997b72d691 100644 --- a/tests/topotests/lib/bgp.py +++ b/tests/topotests/lib/bgp.py @@ -382,8 +382,8 @@ def __create_bgp_neighbor(topo, input_dict, router, addr_type, add_neigh=True): disable_connected = peer.setdefault("disable_connected_check", False) - keep_alive = peer.setdefault("keep_alive", 60) - hold_down = peer.setdefault("hold_down", 180) + keep_alive = peer.setdefault("keepalivetimer", 60) + hold_down = peer.setdefault("holddowntimer", 180) password = peer.setdefault("password", None) max_hop_limit = peer.setdefault("ebgp_multihop", 1) diff --git a/scripts/coccinelle/__func__.cocci b/tools/coccinelle/__func__.cocci index fb68494d43..fb68494d43 100644 --- a/scripts/coccinelle/__func__.cocci +++ b/tools/coccinelle/__func__.cocci diff --git a/scripts/coccinelle/bool_assignment.cocci b/tools/coccinelle/bool_assignment.cocci index e6146ea310..e6146ea310 100644 --- a/scripts/coccinelle/bool_assignment.cocci +++ b/tools/coccinelle/bool_assignment.cocci diff --git a/scripts/coccinelle/bool_expression.cocci b/tools/coccinelle/bool_expression.cocci index c0c329cb59..c0c329cb59 100644 --- a/scripts/coccinelle/bool_expression.cocci +++ b/tools/coccinelle/bool_expression.cocci diff --git a/scripts/coccinelle/bool_function.cocci b/tools/coccinelle/bool_function.cocci index 0328ecfbbe..0328ecfbbe 100644 --- a/scripts/coccinelle/bool_function.cocci +++ b/tools/coccinelle/bool_function.cocci diff --git a/scripts/coccinelle/bool_function_type.cocci b/tools/coccinelle/bool_function_type.cocci index 71bf4f53b8..71bf4f53b8 100644 --- a/scripts/coccinelle/bool_function_type.cocci +++ b/tools/coccinelle/bool_function_type.cocci diff --git a/scripts/coccinelle/replace_bgp_flag_functions.cocci b/tools/coccinelle/replace_bgp_flag_functions.cocci index 3064fc0267..3064fc0267 100644 --- a/scripts/coccinelle/replace_bgp_flag_functions.cocci +++ b/tools/coccinelle/replace_bgp_flag_functions.cocci diff --git a/scripts/coccinelle/return_without_parenthesis.cocci b/tools/coccinelle/return_without_parenthesis.cocci index 7097e87ddc..7097e87ddc 100644 --- a/scripts/coccinelle/return_without_parenthesis.cocci +++ b/tools/coccinelle/return_without_parenthesis.cocci diff --git a/scripts/coccinelle/s_addr_0_to_INADDR_ANY.cocci b/tools/coccinelle/s_addr_0_to_INADDR_ANY.cocci index bd7f4af4f2..bd7f4af4f2 100644 --- a/scripts/coccinelle/s_addr_0_to_INADDR_ANY.cocci +++ b/tools/coccinelle/s_addr_0_to_INADDR_ANY.cocci diff --git a/scripts/coccinelle/shorthand_operator.cocci b/tools/coccinelle/shorthand_operator.cocci index f7019d4040..f7019d4040 100644 --- a/scripts/coccinelle/shorthand_operator.cocci +++ b/tools/coccinelle/shorthand_operator.cocci diff --git a/scripts/coccinelle/test_after_assert.cocci b/tools/coccinelle/test_after_assert.cocci index 30596a89c2..30596a89c2 100644 --- a/scripts/coccinelle/test_after_assert.cocci +++ b/tools/coccinelle/test_after_assert.cocci diff --git a/scripts/coccinelle/void_no_return.cocci b/tools/coccinelle/void_no_return.cocci index 7da9e73933..7da9e73933 100644 --- a/scripts/coccinelle/void_no_return.cocci +++ b/tools/coccinelle/void_no_return.cocci diff --git a/zebra/redistribute.c b/zebra/redistribute.c index 32051a62b7..d1148061b9 100644 --- a/zebra/redistribute.c +++ b/zebra/redistribute.c @@ -75,6 +75,10 @@ static void zebra_redistribute_default(struct zserv *client, vrf_id_t vrf_id) struct route_entry *newre; for (afi = AFI_IP; afi <= AFI_IP6; afi++) { + + if (!vrf_bitmap_check(client->redist_default[afi], vrf_id)) + continue; + /* Lookup table. */ table = zebra_vrf_table(afi, SAFI_UNICAST, vrf_id); if (!table) diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 7011342ab4..e40bf45f59 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -142,7 +142,7 @@ static uint16_t neigh_state_to_netlink(uint16_t dplane_state) } -static inline int is_selfroute(int proto) +static inline bool is_selfroute(int proto) { if ((proto == RTPROT_BGP) || (proto == RTPROT_OSPF) || (proto == RTPROT_ZSTATIC) || (proto == RTPROT_ZEBRA) @@ -151,10 +151,10 @@ static inline int is_selfroute(int proto) || (proto == RTPROT_LDP) || (proto == RTPROT_BABEL) || (proto == RTPROT_RIP) || (proto == RTPROT_SHARP) || (proto == RTPROT_PBR) || (proto == RTPROT_OPENFABRIC)) { - return 1; + return true; } - return 0; + return false; } static inline int zebra2proto(int proto) @@ -513,6 +513,7 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id, struct prefix p; struct prefix_ipv6 src_p = {}; vrf_id_t vrf_id; + bool selfroute; char anyaddr[16] = {0}; @@ -574,8 +575,9 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id, if (rtm->rtm_protocol == RTPROT_KERNEL) return 0; - if (!startup && is_selfroute(rtm->rtm_protocol) - && h->nlmsg_type == RTM_NEWROUTE) { + selfroute = is_selfroute(rtm->rtm_protocol); + + if (!startup && selfroute && h->nlmsg_type == RTM_NEWROUTE) { if (IS_ZEBRA_DEBUG_KERNEL) zlog_debug("Route type: %d Received that we think we have originated, ignoring", rtm->rtm_protocol); @@ -602,7 +604,7 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id, } /* Route which inserted by Zebra. */ - if (is_selfroute(rtm->rtm_protocol)) { + if (selfroute) { flags |= ZEBRA_FLAG_SELFROUTE; proto = proto2zebra(rtm->rtm_protocol, rtm->rtm_family, false); } @@ -2588,7 +2590,7 @@ static int netlink_macfdb_change(struct nlmsghdr *h, int len, ns_id_t ns_id) struct interface *br_if; struct ethaddr mac; vlanid_t vid = 0; - struct prefix vtep_ip; + struct in_addr vtep_ip; int vid_present = 0, dst_present = 0; char buf[ETHER_ADDR_STRLEN]; char vid_buf[20]; @@ -2601,66 +2603,25 @@ static int netlink_macfdb_change(struct nlmsghdr *h, int len, ns_id_t ns_id) if (!is_evpn_enabled()) return 0; - /* The interface should exist. */ - ifp = if_lookup_by_index_per_ns(zebra_ns_lookup(ns_id), - ndm->ndm_ifindex); - if (!ifp || !ifp->info) { - if (IS_ZEBRA_DEBUG_KERNEL) - zlog_debug("\t%s without associated interface: %u", - __func__, ndm->ndm_ifindex); - return 0; - } - - /* The interface should be something we're interested in. */ - if (!IS_ZEBRA_IF_BRIDGE_SLAVE(ifp)) { - if (IS_ZEBRA_DEBUG_KERNEL) - zlog_debug("\t%s Not interested in %s, not a slave", - __func__, ifp->name); - return 0; - } - - /* Drop "permanent" entries. */ - if (ndm->ndm_state & NUD_PERMANENT) { - if (IS_ZEBRA_DEBUG_KERNEL) - zlog_debug("\t%s Entry is PERMANENT, dropping", - __func__); - return 0; - } - - zif = (struct zebra_if *)ifp->info; - if ((br_if = zif->brslave_info.br_if) == NULL) { - if (IS_ZEBRA_DEBUG_KERNEL) - zlog_debug( - "%s family %s IF %s(%u) brIF %u - no bridge master", - nl_msg_type_to_str(h->nlmsg_type), - nl_family_to_str(ndm->ndm_family), ifp->name, - ndm->ndm_ifindex, - zif->brslave_info.bridge_ifindex); - return 0; - } - - /* Parse attributes and extract fields of interest. */ - memset(tb, 0, sizeof(tb)); + /* Parse attributes and extract fields of interest. Do basic + * validation of the fields. + */ + memset(tb, 0, sizeof tb); netlink_parse_rtattr(tb, NDA_MAX, NDA_RTA(ndm), len); if (!tb[NDA_LLADDR]) { if (IS_ZEBRA_DEBUG_KERNEL) - zlog_debug("%s family %s IF %s(%u) brIF %u - no LLADDR", + zlog_debug("%s AF_BRIDGE IF %u - no LLADDR", nl_msg_type_to_str(h->nlmsg_type), - nl_family_to_str(ndm->ndm_family), ifp->name, - ndm->ndm_ifindex, - zif->brslave_info.bridge_ifindex); + ndm->ndm_ifindex); return 0; } if (RTA_PAYLOAD(tb[NDA_LLADDR]) != ETH_ALEN) { if (IS_ZEBRA_DEBUG_KERNEL) zlog_debug( - "%s family %s IF %s(%u) brIF %u - LLADDR is not MAC, len %lu", - nl_msg_type_to_str(h->nlmsg_type), - nl_family_to_str(ndm->ndm_family), ifp->name, - ndm->ndm_ifindex, - zif->brslave_info.bridge_ifindex, + "%s AF_BRIDGE IF %u - LLADDR is not MAC, len %lu", + nl_msg_type_to_str(h->nlmsg_type), ndm->ndm_ifindex, (unsigned long)RTA_PAYLOAD(tb[NDA_LLADDR])); return 0; } @@ -2676,24 +2637,42 @@ static int netlink_macfdb_change(struct nlmsghdr *h, int len, ns_id_t ns_id) if (tb[NDA_DST]) { /* TODO: Only IPv4 supported now. */ dst_present = 1; - vtep_ip.family = AF_INET; - vtep_ip.prefixlen = IPV4_MAX_BITLEN; - memcpy(&(vtep_ip.u.prefix4.s_addr), RTA_DATA(tb[NDA_DST]), + memcpy(&vtep_ip.s_addr, RTA_DATA(tb[NDA_DST]), IPV4_MAX_BYTELEN); - sprintf(dst_buf, " dst %s", inet_ntoa(vtep_ip.u.prefix4)); + sprintf(dst_buf, " dst %s", inet_ntoa(vtep_ip)); } - sticky = !!(ndm->ndm_state & NUD_NOARP); - if (IS_ZEBRA_DEBUG_KERNEL) - zlog_debug("Rx %s family %s IF %s(%u)%s %sMAC %s%s", + zlog_debug("Rx %s AF_BRIDGE IF %u%s st 0x%x fl 0x%x MAC %s%s", nl_msg_type_to_str(h->nlmsg_type), - nl_family_to_str(ndm->ndm_family), ifp->name, ndm->ndm_ifindex, vid_present ? vid_buf : "", - sticky ? "sticky " : "", + ndm->ndm_state, ndm->ndm_flags, prefix_mac2str(&mac, buf, sizeof(buf)), dst_present ? dst_buf : ""); + /* The interface should exist. */ + ifp = if_lookup_by_index_per_ns(zebra_ns_lookup(ns_id), + ndm->ndm_ifindex); + if (!ifp || !ifp->info) + return 0; + + /* The interface should be something we're interested in. */ + if (!IS_ZEBRA_IF_BRIDGE_SLAVE(ifp)) + return 0; + + zif = (struct zebra_if *)ifp->info; + if ((br_if = zif->brslave_info.br_if) == NULL) { + if (IS_ZEBRA_DEBUG_KERNEL) + zlog_debug( + "%s AF_BRIDGE IF %s(%u) brIF %u - no bridge master", + nl_msg_type_to_str(h->nlmsg_type), ifp->name, + ndm->ndm_ifindex, + zif->brslave_info.bridge_ifindex); + return 0; + } + + sticky = !!(ndm->ndm_state & NUD_NOARP); + if (filter_vlan && vid != filter_vlan) { if (IS_ZEBRA_DEBUG_KERNEL) zlog_debug("\tFiltered due to filter vlan: %d", @@ -2707,6 +2686,13 @@ static int netlink_macfdb_change(struct nlmsghdr *h, int len, ns_id_t ns_id) * so perform an implicit delete of any local entry (if it exists). */ if (h->nlmsg_type == RTM_NEWNEIGH) { + /* Drop "permanent" entries. */ + if (ndm->ndm_state & NUD_PERMANENT) { + if (IS_ZEBRA_DEBUG_KERNEL) + zlog_debug("\tDropping entry because of NUD_PERMANENT"); + return 0; + } + if (IS_ZEBRA_IF_VXLAN(ifp)) return zebra_vxlan_check_del_local_mac(ifp, br_if, &mac, vid); @@ -2716,16 +2702,20 @@ static int netlink_macfdb_change(struct nlmsghdr *h, int len, ns_id_t ns_id) } /* This is a delete notification. + * Ignore the notification with IP dest as it may just signify that the + * MAC has moved from remote to local. The exception is the special + * all-zeros MAC that represents the BUM flooding entry; we may have + * to readd it. Otherwise, * 1. For a MAC over VxLan, check if it needs to be refreshed(readded) * 2. For a MAC over "local" interface, delete the mac * Note: We will get notifications from both bridge driver and VxLAN * driver. - * Ignore the notification from VxLan driver as it is also generated - * when mac moves from remote to local. */ if (dst_present) { - if (IS_ZEBRA_DEBUG_KERNEL) - zlog_debug("\tNo Destination Present"); + u_char zero_mac[6] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; + + if (!memcmp(zero_mac, mac.octet, ETH_ALEN)) + return zebra_vxlan_check_readd_vtep(ifp, vtep_ip); return 0; } @@ -3285,6 +3275,15 @@ static int netlink_request_specific_neigh_in_vlan(struct zebra_ns *zns, addattr_l(&req.n, sizeof(req), NDA_DST, &ip->ip.addr, ipa_len); + if (IS_ZEBRA_DEBUG_KERNEL) { + char buf[INET6_ADDRSTRLEN]; + + zlog_debug("%s: Tx %s family %s IF %u IP %s flags 0x%x", + __func__, nl_msg_type_to_str(type), + nl_family_to_str(req.ndm.ndm_family), ifindex, + ipaddr2str(ip, buf, sizeof(buf)), req.n.nlmsg_flags); + } + return netlink_request(&zns->netlink_cmd, &req.n); } diff --git a/zebra/rtadv.c b/zebra/rtadv.c index 4b7fd5060a..60ac471b5a 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -1118,18 +1118,31 @@ void rtadv_stop_ra(struct interface *ifp) } /* - * send router lifetime value of zero in RAs on all interfaces since we're + * Send router lifetime value of zero in RAs on all interfaces since we're * ceasing to advertise globally and want to let all of our neighbors know * RFC 4861 secion 6.2.5 + * + * Delete all ipv6 global prefixes added to the router advertisement prefix + * lists prior to ceasing. */ void rtadv_stop_ra_all(void) { struct vrf *vrf; struct interface *ifp; + struct listnode *node, *nnode; + struct zebra_if *zif; + struct rtadv_prefix *rprefix; RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) - FOR_ALL_INTERFACES (vrf, ifp) + FOR_ALL_INTERFACES (vrf, ifp) { + zif = ifp->info; + + for (ALL_LIST_ELEMENTS(zif->rtadv.AdvPrefixList, + node, nnode, rprefix)) + rtadv_prefix_reset(zif, rprefix); + rtadv_stop_ra(ifp); + } } void zebra_interface_radv_disable(ZAPI_HANDLER_ARGS) diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index f372b548fc..f1c181438e 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -2418,9 +2418,11 @@ static inline void zread_rule(ZAPI_HANDLER_ARGS) } if (!(zpr.rule.filter.dst_ip.family == AF_INET || zpr.rule.filter.dst_ip.family == AF_INET6)) { - zlog_warn("Unsupported PBR IP family: %s (%" PRIu8 ")", - family2str(zpr.rule.filter.dst_ip.family), - zpr.rule.filter.dst_ip.family); + zlog_warn( + "Unsupported PBR destination IP family: %s (%" PRIu8 + ")", + family2str(zpr.rule.filter.dst_ip.family), + zpr.rule.filter.dst_ip.family); return; } @@ -2510,6 +2512,23 @@ static inline void zread_ipset_entry(ZAPI_HANDLER_ARGS) if (zpi.proto != 0) zpi.filter_bm |= PBR_FILTER_PROTO; + if (!(zpi.dst.family == AF_INET + || zpi.dst.family == AF_INET6)) { + zlog_warn( + "Unsupported PBR destination IP family: %s (%" PRIu8 + ")", + family2str(zpi.dst.family), zpi.dst.family); + goto stream_failure; + } + if (!(zpi.src.family == AF_INET + || zpi.src.family == AF_INET6)) { + zlog_warn( + "Unsupported PBR source IP family: %s (%" PRIu8 + ")", + family2str(zpi.src.family), zpi.src.family); + goto stream_failure; + } + /* calculate backpointer */ zpi.backpointer = zebra_pbr_lookup_ipset_pername(ipset.ipset_name); diff --git a/zebra/zebra_dplane.c b/zebra/zebra_dplane.c index 5d0d0a48c3..459d2bc620 100644 --- a/zebra/zebra_dplane.c +++ b/zebra/zebra_dplane.c @@ -3331,7 +3331,7 @@ skip_one: return 0; } -#if DPLANE_TEST_PROVIDER +#ifdef DPLANE_TEST_PROVIDER /* * Test dataplane provider plugin @@ -3415,7 +3415,7 @@ static void dplane_provider_init(void) zlog_err("Unable to register kernel dplane provider: %d", ret); -#if DPLANE_TEST_PROVIDER +#ifdef DPLANE_TEST_PROVIDER /* Optional test provider ... */ ret = dplane_provider_register("Test", DPLANE_PRIO_PRE_KERNEL, diff --git a/zebra/zebra_gr.c b/zebra/zebra_gr.c index bda1ad6b35..19a280c0ca 100644 --- a/zebra/zebra_gr.c +++ b/zebra/zebra_gr.c @@ -127,8 +127,7 @@ static void zebra_gr_client_info_delte(struct zserv *client, THREAD_OFF(info->t_stale_removal); - if (info->current_prefix) - XFREE(MTYPE_TMP, info->current_prefix); + XFREE(MTYPE_TMP, info->current_prefix); LOG_GR("%s: Instance info is being deleted for client %s", __func__, zebra_route_string(client->proto)); diff --git a/zebra/zebra_mlag.c b/zebra/zebra_mlag.c index 5b721a8eac..8ba7998f50 100644 --- a/zebra/zebra_mlag.c +++ b/zebra/zebra_mlag.c @@ -322,7 +322,7 @@ static int zebra_mlag_post_data_from_main_thread(struct thread *thread) STREAM_GETL(s, msg_type); if (IS_ZEBRA_DEBUG_MLAG) zlog_debug( - "%s: Posting MLAG data for msg_type:0x%x to interested cleints", + "%s: Posting MLAG data for msg_type:0x%x to interested clients", __func__, msg_type); msg_len = s->endp - ZEBRA_MLAG_METADATA_LEN; @@ -364,7 +364,7 @@ stream_failure: /* * Start the MLAG Thread, this will be used to write client data on to - * MLAG Process and to read the data from MLAG and post to cleints. + * MLAG Process and to read the data from MLAG and post to clients. * when all clients are un-registered, this Thread will be * suspended. */ @@ -667,14 +667,17 @@ int zebra_mlag_protobuf_encode_client_data(struct stream *s, uint32_t *msg_type) int n_len = 0; int rc = 0; char buf[ZLOG_FILTER_LENGTH_MAX]; + size_t length; if (IS_ZEBRA_DEBUG_MLAG) zlog_debug("%s: Entering..", __func__); - rc = mlag_lib_decode_mlag_hdr(s, &mlag_msg); + rc = mlag_lib_decode_mlag_hdr(s, &mlag_msg, &length); if (rc) return rc; + memset(tmp_buf, 0, ZEBRA_MLAG_BUF_LIMIT); + if (IS_ZEBRA_DEBUG_MLAG) zlog_debug("%s: Mlag ProtoBuf encoding of message:%s, len:%d", __func__, @@ -688,9 +691,10 @@ int zebra_mlag_protobuf_encode_client_data(struct stream *s, uint32_t *msg_type) ZebraMlagMrouteAdd pay_load = ZEBRA_MLAG_MROUTE_ADD__INIT; uint32_t vrf_name_len = 0; - rc = mlag_lib_decode_mroute_add(s, &msg); + rc = mlag_lib_decode_mroute_add(s, &msg, &length); if (rc) return rc; + vrf_name_len = strlen(msg.vrf_name) + 1; pay_load.vrf_name = XMALLOC(MTYPE_MLAG_PBUF, vrf_name_len); strlcpy(pay_load.vrf_name, msg.vrf_name, vrf_name_len); @@ -720,7 +724,7 @@ int zebra_mlag_protobuf_encode_client_data(struct stream *s, uint32_t *msg_type) ZebraMlagMrouteDel pay_load = ZEBRA_MLAG_MROUTE_DEL__INIT; uint32_t vrf_name_len = 0; - rc = mlag_lib_decode_mroute_del(s, &msg); + rc = mlag_lib_decode_mroute_del(s, &msg, &length); if (rc) return rc; vrf_name_len = strlen(msg.vrf_name) + 1; @@ -749,18 +753,18 @@ int zebra_mlag_protobuf_encode_client_data(struct stream *s, uint32_t *msg_type) ZebraMlagMrouteAddBulk Bulk_msg = ZEBRA_MLAG_MROUTE_ADD_BULK__INIT; ZebraMlagMrouteAdd **pay_load = NULL; - int i; bool cleanup = false; + uint32_t i, actual; Bulk_msg.n_mroute_add = mlag_msg.msg_cnt; pay_load = XMALLOC(MTYPE_MLAG_PBUF, sizeof(ZebraMlagMrouteAdd *) * mlag_msg.msg_cnt); - for (i = 0; i < mlag_msg.msg_cnt; i++) { + for (i = 0, actual = 0; i < mlag_msg.msg_cnt; i++, actual++) { uint32_t vrf_name_len = 0; - rc = mlag_lib_decode_mroute_add(s, &msg); + rc = mlag_lib_decode_mroute_add(s, &msg, &length); if (rc) { cleanup = true; break; @@ -796,7 +800,15 @@ int zebra_mlag_protobuf_encode_client_data(struct stream *s, uint32_t *msg_type) tmp_buf); } - for (i = 0; i < mlag_msg.msg_cnt; i++) { + for (i = 0; i < actual; i++) { + /* + * The mlag_lib_decode_mroute_add can + * fail to properly decode and cause nothing + * to be allocated. Prevent a crash + */ + if (!pay_load[i]) + continue; + XFREE(MTYPE_MLAG_PBUF, pay_load[i]->vrf_name); if (pay_load[i]->owner_id == MLAG_OWNER_INTERFACE && pay_load[i]->intf_name) @@ -812,18 +824,18 @@ int zebra_mlag_protobuf_encode_client_data(struct stream *s, uint32_t *msg_type) ZebraMlagMrouteDelBulk Bulk_msg = ZEBRA_MLAG_MROUTE_DEL_BULK__INIT; ZebraMlagMrouteDel **pay_load = NULL; - int i; bool cleanup = false; + uint32_t i, actual; Bulk_msg.n_mroute_del = mlag_msg.msg_cnt; pay_load = XMALLOC(MTYPE_MLAG_PBUF, sizeof(ZebraMlagMrouteDel *) * mlag_msg.msg_cnt); - for (i = 0; i < mlag_msg.msg_cnt; i++) { + for (i = 0, actual = 0; i < mlag_msg.msg_cnt; i++, actual++) { uint32_t vrf_name_len = 0; - rc = mlag_lib_decode_mroute_del(s, &msg); + rc = mlag_lib_decode_mroute_del(s, &msg, &length); if (rc) { cleanup = true; break; @@ -858,7 +870,15 @@ int zebra_mlag_protobuf_encode_client_data(struct stream *s, uint32_t *msg_type) tmp_buf); } - for (i = 0; i < mlag_msg.msg_cnt; i++) { + for (i = 0; i < actual; i++) { + /* + * The mlag_lib_decode_mroute_add can + * fail to properly decode and cause nothing + * to be allocated. Prevent a crash + */ + if (!pay_load[i]) + continue; + XFREE(MTYPE_MLAG_PBUF, pay_load[i]->vrf_name); if (pay_load[i]->owner_id == MLAG_OWNER_INTERFACE && pay_load[i]->intf_name) @@ -915,6 +935,15 @@ int zebra_mlag_protobuf_encode_client_data(struct stream *s, uint32_t *msg_type) return len; } +static void zebra_fill_protobuf_msg(struct stream *s, char *name, int len) +{ + int str_len = strlen(name) + 1; + + stream_put(s, name, str_len); + /* Fill the rest with Null Character for aligning */ + stream_put(s, NULL, len - str_len); +} + int zebra_mlag_protobuf_decode_message(struct stream *s, uint8_t *data, uint32_t len) { @@ -966,7 +995,8 @@ int zebra_mlag_protobuf_decode_message(struct stream *s, uint8_t *data, /* No Batching */ stream_putw(s, MLAG_MSG_NO_BATCH); /* Actual Data */ - stream_put(s, msg->peerlink, INTERFACE_NAMSIZ); + zebra_fill_protobuf_msg(s, msg->peerlink, + INTERFACE_NAMSIZ); stream_putl(s, msg->my_role); stream_putl(s, msg->peer_state); zebra_mlag_status_update__free_unpacked(msg, NULL); @@ -1003,7 +1033,7 @@ int zebra_mlag_protobuf_decode_message(struct stream *s, uint8_t *data, /* No Batching */ stream_putw(s, MLAG_MSG_NO_BATCH); /* Actual Data */ - stream_put(s, msg->vrf_name, VRF_NAMSIZ); + zebra_fill_protobuf_msg(s, msg->vrf_name, VRF_NAMSIZ); stream_putl(s, msg->source_ip); stream_putl(s, msg->group_ip); @@ -1013,7 +1043,8 @@ int zebra_mlag_protobuf_decode_message(struct stream *s, uint8_t *data, stream_putc(s, msg->am_i_dual_active); stream_putl(s, msg->vrf_id); if (msg->owner_id == MLAG_OWNER_INTERFACE) - stream_put(s, msg->intf_name, INTERFACE_NAMSIZ); + zebra_fill_protobuf_msg(s, msg->intf_name, + INTERFACE_NAMSIZ); else stream_put(s, NULL, INTERFACE_NAMSIZ); zebra_mlag_mroute_add__free_unpacked(msg, NULL); @@ -1032,15 +1063,15 @@ int zebra_mlag_protobuf_decode_message(struct stream *s, uint8_t *data, /* No Batching */ stream_putw(s, MLAG_MSG_NO_BATCH); /* Actual Data */ - stream_put(s, msg->vrf_name, VRF_NAMSIZ); + zebra_fill_protobuf_msg(s, msg->vrf_name, VRF_NAMSIZ); stream_putl(s, msg->source_ip); stream_putl(s, msg->group_ip); - stream_putl(s, msg->group_ip); stream_putl(s, msg->owner_id); stream_putl(s, msg->vrf_id); if (msg->owner_id == MLAG_OWNER_INTERFACE) - stream_put(s, msg->intf_name, INTERFACE_NAMSIZ); + zebra_fill_protobuf_msg(s, msg->intf_name, + INTERFACE_NAMSIZ); else stream_put(s, NULL, INTERFACE_NAMSIZ); zebra_mlag_mroute_del__free_unpacked(msg, NULL); @@ -1067,7 +1098,8 @@ int zebra_mlag_protobuf_decode_message(struct stream *s, uint8_t *data, msg = Bulk_msg->mroute_add[i]; - stream_put(s, msg->vrf_name, VRF_NAMSIZ); + zebra_fill_protobuf_msg(s, msg->vrf_name, + VRF_NAMSIZ); stream_putl(s, msg->source_ip); stream_putl(s, msg->group_ip); stream_putl(s, msg->cost_to_rp); @@ -1076,8 +1108,9 @@ int zebra_mlag_protobuf_decode_message(struct stream *s, uint8_t *data, stream_putc(s, msg->am_i_dual_active); stream_putl(s, msg->vrf_id); if (msg->owner_id == MLAG_OWNER_INTERFACE) - stream_put(s, msg->intf_name, - INTERFACE_NAMSIZ); + zebra_fill_protobuf_msg( + s, msg->intf_name, + INTERFACE_NAMSIZ); else stream_put(s, NULL, INTERFACE_NAMSIZ); } @@ -1106,14 +1139,16 @@ int zebra_mlag_protobuf_decode_message(struct stream *s, uint8_t *data, msg = Bulk_msg->mroute_del[i]; - stream_put(s, msg->vrf_name, VRF_NAMSIZ); + zebra_fill_protobuf_msg(s, msg->vrf_name, + VRF_NAMSIZ); stream_putl(s, msg->source_ip); stream_putl(s, msg->group_ip); stream_putl(s, msg->owner_id); stream_putl(s, msg->vrf_id); if (msg->owner_id == MLAG_OWNER_INTERFACE) - stream_put(s, msg->intf_name, - INTERFACE_NAMSIZ); + zebra_fill_protobuf_msg( + s, msg->intf_name, + INTERFACE_NAMSIZ); else stream_put(s, NULL, INTERFACE_NAMSIZ); } diff --git a/zebra/zebra_mlag.h b/zebra/zebra_mlag.h index c35fa15561..d44a400666 100644 --- a/zebra/zebra_mlag.h +++ b/zebra/zebra_mlag.h @@ -46,6 +46,7 @@ extern uint32_t mlag_rd_buf_offset; static inline void zebra_mlag_reset_read_buffer(void) { + memset(mlag_wr_buffer, 0, ZEBRA_MLAG_BUF_LIMIT); mlag_rd_buf_offset = 0; } diff --git a/zebra/zebra_mlag_private.c b/zebra/zebra_mlag_private.c index 3024407ada..0f0285ed31 100644 --- a/zebra/zebra_mlag_private.c +++ b/zebra/zebra_mlag_private.c @@ -78,6 +78,8 @@ static int zebra_mlag_read(struct thread *thread) uint32_t h_msglen; uint32_t tot_len, curr_len = mlag_rd_buf_offset; + zrouter.mlag_info.t_read = NULL; + /* * Received message in sock_stream looks like below * | len-1 (4 Bytes) | payload-1 (len-1) | @@ -157,8 +159,6 @@ static int zebra_mlag_read(struct thread *thread) static int zebra_mlag_connect(struct thread *thread) { struct sockaddr_un svr = {0}; - struct ucred ucred; - socklen_t len = 0; /* Reset the Timer-running flag */ zrouter.mlag_info.timer_running = false; @@ -182,11 +182,8 @@ static int zebra_mlag_connect(struct thread *thread) &zrouter.mlag_info.t_read); return 0; } - len = sizeof(struct ucred); - ucred.pid = getpid(); set_nonblocking(mlag_socket); - setsockopt(mlag_socket, SOL_SOCKET, SO_PEERCRED, &ucred, len); if (IS_ZEBRA_DEBUG_MLAG) zlog_debug("%s: Connection with MLAG is established ", diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index fcd90c23e8..f0d43756b5 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -687,9 +687,9 @@ static struct nh_grp *nhg_ctx_get_grp(struct nhg_ctx *ctx) return ctx->u.grp; } -static struct nhg_ctx *nhg_ctx_new() +static struct nhg_ctx *nhg_ctx_new(void) { - struct nhg_ctx *new = NULL; + struct nhg_ctx *new; new = XCALLOC(MTYPE_NHG_CTX, sizeof(struct nhg_ctx)); diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index dce48d39bd..61865e5baf 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -7788,6 +7788,52 @@ stream_failure: } /* + * Handle remote vtep delete by kernel; re-add the vtep if we have it + */ +int zebra_vxlan_check_readd_vtep(struct interface *ifp, + struct in_addr vtep_ip) +{ + struct zebra_if *zif; + struct zebra_vrf *zvrf = NULL; + struct zebra_l2info_vxlan *vxl; + vni_t vni; + zebra_vni_t *zvni = NULL; + zebra_vtep_t *zvtep = NULL; + + zif = ifp->info; + assert(zif); + vxl = &zif->l2info.vxl; + vni = vxl->vni; + + /* If EVPN is not enabled, nothing to do. */ + if (!is_evpn_enabled()) + return 0; + + /* Locate VRF corresponding to interface. */ + zvrf = vrf_info_lookup(ifp->vrf_id); + if (!zvrf) + return -1; + + /* Locate hash entry; it is expected to exist. */ + zvni = zvni_lookup(vni); + if (!zvni) + return 0; + + /* If the remote vtep entry doesn't exists nothing to do */ + zvtep = zvni_vtep_find(zvni, &vtep_ip); + if (!zvtep) + return 0; + + if (IS_ZEBRA_DEBUG_VXLAN) + zlog_debug( + "Del MAC for remote VTEP %s intf %s(%u) VNI %u - readd", + inet_ntoa(vtep_ip), ifp->name, ifp->ifindex, vni); + + zvni_vtep_install(zvni, zvtep); + return 0; +} + +/* * Handle notification of MAC add/update over VxLAN. If the kernel is notifying * us, this must involve a multihoming scenario. Treat this as implicit delete * of any prior local MAC. diff --git a/zebra/zebra_vxlan.h b/zebra/zebra_vxlan.h index b551ba8dff..6ca93f6cb6 100644 --- a/zebra/zebra_vxlan.h +++ b/zebra/zebra_vxlan.h @@ -183,6 +183,8 @@ extern int zebra_vxlan_check_readd_remote_mac(struct interface *ifp, extern int zebra_vxlan_check_del_local_mac(struct interface *ifp, struct interface *br_if, struct ethaddr *mac, vlanid_t vid); +extern int zebra_vxlan_check_readd_vtep(struct interface *ifp, + struct in_addr vtep_ip); extern int zebra_vxlan_if_up(struct interface *ifp); extern int zebra_vxlan_if_down(struct interface *ifp); extern int zebra_vxlan_if_add(struct interface *ifp); |
