diff options
249 files changed, 4121 insertions, 3343 deletions
diff --git a/.gitignore b/.gitignore index 226dca09d0..ca61140d00 100644 --- a/.gitignore +++ b/.gitignore @@ -56,6 +56,12 @@  *.pb.cc  *_clippy.c +### gcov outputs + +*.gcno +*.gcov +*.gcda +  ### dist  *.tar.?z diff --git a/babeld/babeld.c b/babeld/babeld.c index 83a2a3137c..a7a3481998 100644 --- a/babeld/babeld.c +++ b/babeld/babeld.c @@ -138,7 +138,7 @@ babel_create_routing_process (void)      assert (babel_routing_process == NULL);      /* Allocaste Babel instance. */ -    babel_routing_process = XCALLOC (MTYPE_BABEL, sizeof (struct babel)); +    babel_routing_process = XCALLOC(MTYPE_BABEL, sizeof(struct babel));      /* Initialize timeouts */      gettime(&babel_now); diff --git a/babeld/util.h b/babeld/util.h index 00a025ff93..9310040571 100644 --- a/babeld/util.h +++ b/babeld/util.h @@ -122,7 +122,7 @@ void uchar_to_inaddr(struct in_addr *dest, const unsigned char *src);  void in6addr_to_uchar(unsigned char *dest, const struct in6_addr *src);  void uchar_to_in6addr(struct in6_addr *dest, const unsigned char *src);  int daemonise(void); -const unsigned char v4prefix[16]; +extern const unsigned char v4prefix[16];  /* If debugging is disabled, we want to avoid calling format_address     for every omitted debugging message.  So debug is a macro.  But diff --git a/bfdd/bfdd_nb_config.c b/bfdd/bfdd_nb_config.c index 50f953115c..48dcce3ddf 100644 --- a/bfdd/bfdd_nb_config.c +++ b/bfdd/bfdd_nb_config.c @@ -383,7 +383,7 @@ int bfdd_bfd_sessions_single_hop_administrative_down_modify(  	bs = nb_running_get_entry(dnode, NULL, true); -	if (shutdown == false) { +	if (!shutdown) {  		if (!BFD_CHECK_FLAG(bs->flags, BFD_SESS_FLAG_SHUTDOWN))  			return NB_OK; @@ -447,7 +447,7 @@ int bfdd_bfd_sessions_single_hop_echo_mode_modify(enum nb_event event,  	bs = nb_running_get_entry(dnode, NULL, true); -	if (echo == false) { +	if (!echo) {  		if (!BFD_CHECK_FLAG(bs->flags, BFD_SESS_FLAG_ECHO))  			return NB_OK; diff --git a/bfdd/bfdd_vty.c b/bfdd/bfdd_vty.c index e6307f78a4..2a98b0fb02 100644 --- a/bfdd/bfdd_vty.c +++ b/bfdd/bfdd_vty.c @@ -474,7 +474,7 @@ static void _display_peer_brief(struct vty *vty, struct bfd_session *bs)  	}  } -static void _display_peer_brief_iter(struct hash_backet *hb, void *arg) +static void _display_peer_brief_iter(struct hash_bucket *hb, void *arg)  {  	struct bfd_vrf_tuple *bvt = arg;  	struct vty *vty; @@ -500,7 +500,7 @@ static void _display_peers_brief(struct vty *vty, const char *vrfname, bool use_  	bvt.vrfname = vrfname; -	if (use_json == false) { +	if (!use_json) {  		bvt.vty = vty;  		vty_out(vty, "Session count: %lu\n", bfd_get_session_count()); diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c index a781e70d2f..f73d6e3009 100644 --- a/bgpd/bgp_aspath.c +++ b/bgpd/bgp_aspath.c @@ -41,9 +41,9 @@  #define AS_HEADER_SIZE 2  /* Now FOUR octets are used for AS value. */ -#define AS_VALUE_SIZE         sizeof (as_t) +#define AS_VALUE_SIZE         sizeof(as_t)  /* This is the old one */ -#define AS16_VALUE_SIZE	      sizeof (as16_t) +#define AS16_VALUE_SIZE	      sizeof(as16_t)  /* Maximum protocol segment length value */  #define AS_SEGMENT_MAX		255 @@ -768,7 +768,7 @@ static int assegments_parse(struct stream *s, size_t length,  		     * on more, than 8 bits (otherwise it's a warning, bug  		     * #564).  		     */ -		    || ((sizeof segh.length > 1) +		    || ((sizeof(segh.length) > 1)  			&& (0x10 + segh.length > 0x10 + AS_SEGMENT_MAX))) {  			if (head)  				assegment_free_all(head); @@ -793,7 +793,7 @@ static int assegments_parse(struct stream *s, size_t length,  		if (head)  			prev->next = seg;  		else /* it's the first segment */ -			head = prev = seg; +			head = seg;  		for (i = 0; i < segh.length; i++)  			seg->as[i] = @@ -2127,7 +2127,7 @@ static void *bgp_aggr_aspath_hash_alloc(void *p)  	return aspath;  } -static void bgp_aggr_aspath_prepare(struct hash_backet *hb, void *arg) +static void bgp_aggr_aspath_prepare(struct hash_bucket *hb, void *arg)  {  	struct aspath *hb_aspath = hb->data;  	struct aspath **aggr_aspath = arg; diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index f00bb2b3cd..33466957b0 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -2506,9 +2506,14 @@ static bgp_attr_parse_ret_t bgp_attr_psid_sub(uint8_t type, uint16_t length,  		}  		/* Configure from Info */ -		attr->srv6_vpn = XMALLOC(MTYPE_BGP_SRV6_VPN, +		if (attr->srv6_vpn) { +			flog_err(EC_BGP_ATTRIBUTE_REPEATED, +				 "Prefix SID SRv6 VPN field repeated"); +			return bgp_attr_malformed( +				args, BGP_NOTIFY_UPDATE_MAL_ATTR, args->total); +		} +		attr->srv6_vpn = XCALLOC(MTYPE_BGP_SRV6_VPN,  					 sizeof(struct bgp_attr_srv6_vpn)); -		attr->srv6_vpn->refcnt = 0;  		attr->srv6_vpn->sid_flags = sid_flags;  		sid_copy(&attr->srv6_vpn->sid, &ipv6_sid);  	} @@ -2543,7 +2548,13 @@ static bgp_attr_parse_ret_t bgp_attr_psid_sub(uint8_t type, uint16_t length,  		}  		/* Configure from Info */ -		attr->srv6_l3vpn = XMALLOC(MTYPE_BGP_SRV6_L3VPN, +		if (attr->srv6_l3vpn) { +			flog_err(EC_BGP_ATTRIBUTE_REPEATED, +				 "Prefix SID SRv6 L3VPN field repeated"); +			return bgp_attr_malformed( +				args, BGP_NOTIFY_UPDATE_MAL_ATTR, args->total); +		} +		attr->srv6_l3vpn = XCALLOC(MTYPE_BGP_SRV6_L3VPN,  					   sizeof(struct bgp_attr_srv6_l3vpn));  		attr->srv6_l3vpn->sid_flags = sid_flags;  		attr->srv6_l3vpn->endpoint_behavior = endpoint_behavior; diff --git a/bgpd/bgp_attr_evpn.h b/bgpd/bgp_attr_evpn.h index a8a35e8174..25654ba709 100644 --- a/bgpd/bgp_attr_evpn.h +++ b/bgpd/bgp_attr_evpn.h @@ -34,7 +34,6 @@  #define MAX_ET 0xffffffff -unsigned long eth_tag_id;  struct attr;  /* EVPN ESI */ diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c index 7ca48a5bea..5c461dbe77 100644 --- a/bgpd/bgp_clist.c +++ b/bgpd/bgp_clist.c @@ -44,7 +44,7 @@ static int64_t bgp_clist_new_seq_get(struct community_list *list)  	int64_t newseq;  	struct community_entry *entry; -	maxseq = newseq = 0; +	maxseq = 0;  	for (entry = list->head; entry; entry = entry->next) {  		if (maxseq < entry->seq) @@ -654,7 +654,7 @@ community_regexp_delete (struct community *com, regex_t * reg)  	i = 0;  	while (i < com->size)  	{ -		memcpy (&comval, com_nthval (com, i), sizeof (uint32_t)); +		memcpy (&comval, com_nthval (com, i), sizeof(uint32_t));  		comval = ntohl (comval);  		switch (comval) { diff --git a/bgpd/bgp_community.c b/bgpd/bgp_community.c index 496d7ed2b1..c145c47d02 100644 --- a/bgpd/bgp_community.c +++ b/bgpd/bgp_community.c @@ -907,7 +907,7 @@ static void *bgp_aggr_communty_hash_alloc(void *p)  	return community;  } -static void bgp_aggr_community_prepare(struct hash_backet *hb, void *arg) +static void bgp_aggr_community_prepare(struct hash_bucket *hb, void *arg)  {  	struct community *hb_community = hb->data;  	struct community **aggr_community = arg; diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c index b0fee079d1..792f3cea70 100644 --- a/bgpd/bgp_damp.c +++ b/bgpd/bgp_damp.c @@ -501,7 +501,7 @@ static const char *bgp_get_reuse_time(unsigned int penalty, char *buf,  				      bool use_json, json_object *json)  {  	time_t reuse_time = 0; -	struct tm *tm = NULL; +	struct tm tm;  	int time_store = 0;  	if (penalty > damp[afi][safi].reuse_limit) { @@ -513,7 +513,7 @@ static const char *bgp_get_reuse_time(unsigned int penalty, char *buf,  		if (reuse_time > damp[afi][safi].max_suppress_time)  			reuse_time = damp[afi][safi].max_suppress_time; -		tm = gmtime(&reuse_time); +		gmtime_r(&reuse_time, &tm);  	} else  		reuse_time = 0; @@ -525,39 +525,39 @@ static const char *bgp_get_reuse_time(unsigned int penalty, char *buf,  			snprintf(buf, len, "00:00:00");  	} else if (reuse_time < ONE_DAY_SECOND) {  		if (use_json) { -			time_store = (3600000 * tm->tm_hour) -				     + (60000 * tm->tm_min) -				     + (1000 * tm->tm_sec); +			time_store = (3600000 * tm.tm_hour) +				     + (60000 * tm.tm_min) +				     + (1000 * tm.tm_sec);  			json_object_int_add(json, "reuseTimerMsecs",  					    time_store);  		} else -			snprintf(buf, len, "%02d:%02d:%02d", tm->tm_hour, -				 tm->tm_min, tm->tm_sec); +			snprintf(buf, len, "%02d:%02d:%02d", tm.tm_hour, +				 tm.tm_min, tm.tm_sec);  	} else if (reuse_time < ONE_WEEK_SECOND) {  		if (use_json) { -			time_store = (86400000 * tm->tm_yday) -				     + (3600000 * tm->tm_hour) -				     + (60000 * tm->tm_min) -				     + (1000 * tm->tm_sec); +			time_store = (86400000 * tm.tm_yday) +				     + (3600000 * tm.tm_hour) +				     + (60000 * tm.tm_min) +				     + (1000 * tm.tm_sec);  			json_object_int_add(json, "reuseTimerMsecs",  					    time_store);  		} else -			snprintf(buf, len, "%dd%02dh%02dm", tm->tm_yday, -				 tm->tm_hour, tm->tm_min); +			snprintf(buf, len, "%dd%02dh%02dm", tm.tm_yday, +				 tm.tm_hour, tm.tm_min);  	} else {  		if (use_json) {  			time_store = -				(604800000 * tm->tm_yday / 7) +				(604800000 * tm.tm_yday / 7)  				+ (86400000 -				   * (tm->tm_yday - ((tm->tm_yday / 7) * 7))) -				+ (3600000 * tm->tm_hour) + (60000 * tm->tm_min) -				+ (1000 * tm->tm_sec); +				   * (tm.tm_yday - ((tm.tm_yday / 7) * 7))) +				+ (3600000 * tm.tm_hour) + (60000 * tm.tm_min) +				+ (1000 * tm.tm_sec);  			json_object_int_add(json, "reuseTimerMsecs",  					    time_store);  		} else -			snprintf(buf, len, "%02dw%dd%02dh", tm->tm_yday / 7, -				 tm->tm_yday - ((tm->tm_yday / 7) * 7), -				 tm->tm_hour); +			snprintf(buf, len, "%02dw%dd%02dh", tm.tm_yday / 7, +				 tm.tm_yday - ((tm.tm_yday / 7) * 7), +				 tm.tm_hour);  	}  	return buf; diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c index 298f9d0212..c448b9894a 100644 --- a/bgpd/bgp_dump.c +++ b/bgpd/bgp_dump.c @@ -106,19 +106,19 @@ static FILE *bgp_dump_open_file(struct bgp_dump *bgp_dump)  {  	int ret;  	time_t clock; -	struct tm *tm; +	struct tm tm;  	char fullpath[MAXPATHLEN];  	char realpath[MAXPATHLEN];  	mode_t oldumask;  	time(&clock); -	tm = localtime(&clock); +	localtime_r(&clock, &tm);  	if (bgp_dump->filename[0] != DIRECTORY_SEP) {  		sprintf(fullpath, "%s/%s", vty_get_cwd(), bgp_dump->filename); -		ret = strftime(realpath, MAXPATHLEN, fullpath, tm); +		ret = strftime(realpath, MAXPATHLEN, fullpath, &tm);  	} else -		ret = strftime(realpath, MAXPATHLEN, bgp_dump->filename, tm); +		ret = strftime(realpath, MAXPATHLEN, bgp_dump->filename, &tm);  	if (ret == 0) {  		flog_warn(EC_BGP_DUMP, "bgp_dump_open_file: strftime error"); @@ -147,7 +147,7 @@ static int bgp_dump_interval_add(struct bgp_dump *bgp_dump, int interval)  {  	int secs_into_day;  	time_t t; -	struct tm *tm; +	struct tm tm;  	if (interval > 0) {  		/* Periodic dump every interval seconds */ @@ -158,9 +158,9 @@ static int bgp_dump_interval_add(struct bgp_dump *bgp_dump, int interval)  			 * midnight  			 */  			(void)time(&t); -			tm = localtime(&t); -			secs_into_day = tm->tm_sec + 60 * tm->tm_min -					+ 60 * 60 * tm->tm_hour; +			localtime_r(&t, &tm); +			secs_into_day = tm.tm_sec + 60 * tm.tm_min +					+ 60 * 60 * tm.tm_hour;  			interval = interval  				   - secs_into_day % interval; /* always > 0 */  		} diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c index 4c55a0764d..2711cf7a69 100644 --- a/bgpd/bgp_ecommunity.c +++ b/bgpd/bgp_ecommunity.c @@ -1026,7 +1026,7 @@ static void *bgp_aggr_ecommunty_hash_alloc(void *p)  	return ecommunity;  } -static void bgp_aggr_ecommunity_prepare(struct hash_backet *hb, void *arg) +static void bgp_aggr_ecommunity_prepare(struct hash_bucket *hb, void *arg)  {  	struct ecommunity *hb_ecommunity = hb->data;  	struct ecommunity **aggr_ecommunity = arg; diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index 206680c403..664d62fd11 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -600,8 +600,9 @@ static int bgp_zebra_send_remote_macip(struct bgp *bgp, struct bgpevpn *vpn,  	/* Don't try to register if Zebra doesn't know of this instance. */  	if (!IS_BGP_INST_KNOWN_TO_ZEBRA(bgp)) {  		if (BGP_DEBUG(zebra, ZEBRA)) -			zlog_debug("%s: No zebra instance to talk to, not installing remote macip", -				   __PRETTY_FUNCTION__); +			zlog_debug( +				"%s: No zebra instance to talk to, not installing remote macip", +				__func__);  		return 0;  	}  	s = zclient->obuf; @@ -662,8 +663,9 @@ static int bgp_zebra_send_remote_vtep(struct bgp *bgp, struct bgpevpn *vpn,  	/* Don't try to register if Zebra doesn't know of this instance. */  	if (!IS_BGP_INST_KNOWN_TO_ZEBRA(bgp)) {  		if (BGP_DEBUG(zebra, ZEBRA)) -			zlog_debug("%s: No zebra instance to talk to, not installing remote vtep", -				   __PRETTY_FUNCTION__); +			zlog_debug( +				"%s: No zebra instance to talk to, not installing remote vtep", +				__func__);  		return 0;  	} diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index b483d39bba..a44effaac5 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -1450,7 +1450,7 @@ static int bgp_connect_success(struct peer *peer)  	if (bgp_getsockname(peer) < 0) {  		flog_err_sys(EC_LIB_SOCKET,  			     "%s: bgp_getsockname(): failed for peer %s, fd %d", -			     __FUNCTION__, peer->host, peer->fd); +			     __func__, peer->host, peer->fd);  		bgp_notify_send(  			peer, BGP_NOTIFY_FSM_ERR,  			BGP_NOTIFY_SUBCODE_UNSPECIFIC); /* internal error */ diff --git a/bgpd/bgp_lcommunity.c b/bgpd/bgp_lcommunity.c index f889693001..7a4435f6f2 100644 --- a/bgpd/bgp_lcommunity.c +++ b/bgpd/bgp_lcommunity.c @@ -550,7 +550,7 @@ static void *bgp_aggr_lcommunty_hash_alloc(void *p)  	return lcommunity;  } -static void bgp_aggr_lcommunity_prepare(struct hash_backet *hb, void *arg) +static void bgp_aggr_lcommunity_prepare(struct hash_bucket *hb, void *arg)  {  	struct lcommunity *hb_lcommunity = hb->data;  	struct lcommunity **aggr_lcommunity = arg; diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c index 55b44de6fb..dfa9ac9398 100644 --- a/bgpd/bgp_nht.c +++ b/bgpd/bgp_nht.c @@ -153,7 +153,7 @@ int bgp_find_or_add_nexthop(struct bgp *bgp_route, struct bgp *bgp_nexthop,  			if (BGP_DEBUG(nht, NHT)) {  				zlog_debug(  					"%s: Attempting to register with unknown AFI %d (not %d or %d)", -					__FUNCTION__, afi, AFI_IP, AFI_IP6); +					__func__, afi, AFI_IP, AFI_IP6);  			}  			return 0;  		} @@ -338,7 +338,7 @@ void bgp_parse_nexthop_update(int command, vrf_id_t vrf_id)  	if (!zapi_nexthop_update_decode(zclient->ibuf, &nhr)) {  		if (BGP_DEBUG(nht, NHT))  			zlog_debug("%s[%s]: Failure to decode nexthop update", -				   __PRETTY_FUNCTION__, bgp->name_pretty); +				   __func__, bgp->name_pretty);  		return;  	} @@ -563,7 +563,7 @@ static int make_prefix(int afi, struct bgp_path_info *pi, struct prefix *p)  		if (BGP_DEBUG(nht, NHT)) {  			zlog_debug(  				"%s: Attempting to make prefix with unknown AFI %d (not %d or %d)", -				__FUNCTION__, afi, AFI_IP, AFI_IP6); +				__func__, afi, AFI_IP, AFI_IP6);  		}  		break;  	} @@ -591,15 +591,17 @@ static void sendmsg_zebra_rnh(struct bgp_nexthop_cache *bnc, int command)  	/* Don't try to register if Zebra doesn't know of this instance. */  	if (!IS_BGP_INST_KNOWN_TO_ZEBRA(bnc->bgp)) {  		if (BGP_DEBUG(zebra, ZEBRA)) -			zlog_debug("%s: No zebra instance to talk to, not installing NHT entry", -				   __PRETTY_FUNCTION__); +			zlog_debug( +				"%s: No zebra instance to talk to, not installing NHT entry", +				__func__);  		return;  	}  	if (!bgp_zebra_num_connects()) {  		if (BGP_DEBUG(zebra, ZEBRA)) -			zlog_debug("%s: We have not connected yet, cannot send nexthops", -				   __PRETTY_FUNCTION__); +			zlog_debug( +				"%s: We have not connected yet, cannot send nexthops", +				__func__);  	}  	p = &(bnc->node->p);  	if ((command == ZEBRA_NEXTHOP_REGISTER @@ -801,9 +803,10 @@ static void evaluate_paths(struct bgp_nexthop_cache *bnc)  		if (!CHECK_FLAG(bnc->flags, BGP_NEXTHOP_PEER_NOTIFIED)) {  			if (BGP_DEBUG(nht, NHT)) -				zlog_debug("%s: Updating peer (%s(%s)) status with NHT", -					   __FUNCTION__, peer->host, -					   peer->bgp->name_pretty); +				zlog_debug( +					"%s: Updating peer (%s(%s)) status with NHT", +					__func__, peer->host, +					peer->bgp->name_pretty);  			bgp_fsm_event_update(peer, valid_nexthops);  			SET_FLAG(bnc->flags, BGP_NEXTHOP_PEER_NOTIFIED);  		} @@ -882,7 +885,7 @@ void bgp_nht_register_enhe_capability_interfaces(struct peer *peer)  	if (!sockunion2hostprefix(&peer->su, &p)) {  		if (BGP_DEBUG(nht, NHT))  			zlog_debug("%s: Unable to convert prefix to sockunion", -				   __PRETTY_FUNCTION__); +				   __func__);  		return;  	} diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c index 906083f755..81bb45aa76 100644 --- a/bgpd/bgp_open.c +++ b/bgpd/bgp_open.c @@ -696,7 +696,7 @@ static int bgp_capability_hostname(struct peer *peer,  		flog_warn(  			EC_BGP_CAPABILITY_INVALID_DATA,  			"%s: Received malformed hostname capability from peer %s", -			__FUNCTION__, peer->host); +			__func__, peer->host);  		return -1;  	} @@ -720,7 +720,7 @@ static int bgp_capability_hostname(struct peer *peer,  		flog_warn(  			EC_BGP_CAPABILITY_INVALID_DATA,  			"%s: Received invalid domain name len (hostname capability) from peer %s", -			__FUNCTION__, peer->host); +			__func__, peer->host);  		return -1;  	} @@ -729,7 +729,7 @@ static int bgp_capability_hostname(struct peer *peer,  		flog_warn(  			EC_BGP_CAPABILITY_INVALID_DATA,  			"%s: Received runt domain name (hostname capability) from peer %s", -			__FUNCTION__, peer->host); +			__func__, peer->host);  		return -1;  	} diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index 9d030378c7..0e251dced8 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -1303,8 +1303,7 @@ static int bgp_open_receive(struct peer *peer, bgp_size_t size)  	/* Open option part parse. */  	if (optlen != 0) { -		if ((ret = bgp_open_option_parse(peer, optlen, &mp_capability)) -		    < 0) +		if (bgp_open_option_parse(peer, optlen, &mp_capability) < 0)  			return BGP_Stop;  	} else {  		if (bgp_debug_neighbor_events(peer)) @@ -1346,10 +1345,10 @@ static int bgp_open_receive(struct peer *peer, bgp_size_t size)  		return BGP_Stop;  	/* Get sockname. */ -	if ((ret = bgp_getsockname(peer)) < 0) { +	if (bgp_getsockname(peer) < 0) {  		flog_err_sys(EC_LIB_SOCKET,  			     "%s: bgp_getsockname() failed for peer: %s", -			     __FUNCTION__, peer->host); +			     __func__, peer->host);  		return BGP_Stop;  	} @@ -1972,38 +1971,29 @@ static int bgp_route_refresh_receive(struct peer *peer, bgp_size_t size)  					} else  						p_pnt = p_end; -					if ((ok = (p_pnt < p_end))) -						orfp.ge = -							*p_pnt++; /* value -								     checked in -								     prefix_bgp_orf_set() -								     */ -					if ((ok = (p_pnt < p_end))) -						orfp.le = -							*p_pnt++; /* value -								     checked in -								     prefix_bgp_orf_set() -								     */ +					/* val checked in prefix_bgp_orf_set */ +					if (p_pnt < p_end) +						orfp.ge = *p_pnt++; + +					/* val checked in prefix_bgp_orf_set */ +					if (p_pnt < p_end) +						orfp.le = *p_pnt++; +  					if ((ok = (p_pnt < p_end)))  						orfp.p.prefixlen = *p_pnt++; -					orfp.p.family = afi2family( -						afi); /* afi checked already  */ - -					psize = PSIZE( -						orfp.p.prefixlen); /* 0 if not -								      ok */ -					if (psize -					    > prefix_blen( -						      &orfp.p)) /* valid for -								   family ?   */ -					{ + +					/* afi checked already */ +					orfp.p.family = afi2family(afi); + +					/* 0 if not ok */ +					psize = PSIZE(orfp.p.prefixlen); +					/* valid for family ? */ +					if (psize > prefix_blen(&orfp.p)) {  						ok = 0;  						psize = prefix_blen(&orfp.p);  					} -					if (psize -					    > (p_end - p_pnt)) /* valid for -								  packet ?   */ -					{ +					/* valid for packet ? */ +					if (psize > (p_end - p_pnt)) {  						ok = 0;  						psize = p_end - p_pnt;  					} diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 1cd0bbe578..bcd87eb01b 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -122,8 +122,6 @@ struct bgp_node *bgp_afi_node_get(struct bgp_table *table, afi_t afi,  	struct bgp_node *prn = NULL;  	assert(table); -	if (!table) -		return NULL;  	if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)  	    || (safi == SAFI_EVPN)) { @@ -299,7 +297,7 @@ static int bgp_node_set_defer_flag(struct bgp_node *rn, bool delete)  {  	struct peer *peer;  	struct bgp_path_info *old_pi, *nextpi; -	bool set_flag = 0; +	bool set_flag = false;  	struct bgp *bgp = NULL;  	struct bgp_table *table = NULL;  	afi_t afi = 0; @@ -339,7 +337,7 @@ static int bgp_node_set_defer_flag(struct bgp_node *rn, bool delete)  		 */  		if (CHECK_FLAG(old_pi->flags, BGP_PATH_STALE)  		    && (old_pi->sub_type == BGP_ROUTE_NORMAL)) { -			set_flag = 1; +			set_flag = true;  		} else {  			/* If the peer is graceful restart capable and peer is  			 * restarting mode, set the flag BGP_NODE_SELECT_DEFER @@ -349,7 +347,7 @@ static int bgp_node_set_defer_flag(struct bgp_node *rn, bool delete)  			    && BGP_PEER_RESTARTING_MODE(peer)  			    && (old_pi  				&& old_pi->sub_type == BGP_ROUTE_NORMAL)) { -				set_flag = 1; +				set_flag = true;  			}  		}  		if (set_flag) @@ -2926,8 +2924,7 @@ static int bgp_maximum_prefix_restart_timer(struct thread *thread)  			peer->host);  	if ((peer_clear(peer, NULL) < 0) && bgp_debug_neighbor_events(peer)) -		zlog_debug("%s: %s peer_clear failed", -			   __PRETTY_FUNCTION__, peer->host); +		zlog_debug("%s: %s peer_clear failed", __func__, peer->host);  	return 0;  } @@ -3732,7 +3729,7 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id,  							  ->nexthop,  						  buf1, INET6_ADDRSTRLEN);  					zlog_debug("%s(%s): NH unresolved", -						   __FUNCTION__, buf1); +						   __func__, buf1);  				}  				bgp_path_info_unset_flag(rn, pi,  							 BGP_PATH_VALID); @@ -3880,8 +3877,8 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id,  				inet_ntop(AF_INET,  					  (const void *)&attr_new->nexthop,  					  buf1, INET6_ADDRSTRLEN); -				zlog_debug("%s(%s): NH unresolved", -					   __FUNCTION__, buf1); +				zlog_debug("%s(%s): NH unresolved", __func__, +					   buf1);  			}  			bgp_path_info_unset_flag(rn, new, BGP_PATH_VALID);  		} @@ -4909,8 +4906,6 @@ void bgp_static_update(struct bgp *bgp, struct prefix *p,  #endif  	assert(bgp_static); -	if (!bgp_static) -		return;  	rn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, p, NULL); @@ -5040,7 +5035,7 @@ void bgp_static_update(struct bgp *bgp, struct prefix *p,  							  INET6_ADDRSTRLEN);  						zlog_debug(  							"%s(%s): Route not in table, not advertising", -							__FUNCTION__, buf1); +							__func__, buf1);  					}  					bgp_path_info_unset_flag(  						rn, pi, BGP_PATH_VALID); @@ -5089,7 +5084,7 @@ void bgp_static_update(struct bgp *bgp, struct prefix *p,  					  INET6_ADDRSTRLEN);  				zlog_debug(  					"%s(%s): Route not in table, not advertising", -					__FUNCTION__, buf1); +					__func__, buf1);  			}  			bgp_path_info_unset_flag(rn, new, BGP_PATH_VALID);  		} diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index 5e6c782400..52b5402737 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -4400,10 +4400,10 @@ DEFUN (no_set_distance,  DEFUN (set_local_pref,         set_local_pref_cmd, -       "set local-preference (0-4294967295)", +       "set local-preference WORD",         SET_STR         "BGP local preference path attribute\n" -       "Preference value\n") +       "Preference value (0-4294967295)\n")  {  	int idx_number = 2;  	return generic_set_add(vty, VTY_GET_CONTEXT(route_map_index), @@ -4413,11 +4413,11 @@ DEFUN (set_local_pref,  DEFUN (no_set_local_pref,         no_set_local_pref_cmd, -       "no set local-preference [(0-4294967295)]", +       "no set local-preference [WORD]",         NO_STR         SET_STR         "BGP local preference path attribute\n" -       "Preference value\n") +       "Preference value (0-4294967295)\n")  {  	int idx_localpref = 3;  	if (argc <= idx_localpref) diff --git a/bgpd/bgp_snmp.c b/bgpd/bgp_snmp.c index 70e4a3fa00..d507161052 100644 --- a/bgpd/bgp_snmp.c +++ b/bgpd/bgp_snmp.c @@ -869,7 +869,7 @@ static int bgpTrapEstablished(struct peer *peer)  	smux_trap(bgp_variables, array_size(bgp_variables), bgp_trap_oid,  		  array_size(bgp_trap_oid), bgp_oid, -		  sizeof bgp_oid / sizeof(oid), index, IN_ADDR_SIZE, +		  sizeof(bgp_oid) / sizeof(oid), index, IN_ADDR_SIZE,  		  bgpTrapList, array_size(bgpTrapList), BGPESTABLISHED);  	return 0;  } @@ -888,7 +888,7 @@ static int bgpTrapBackwardTransition(struct peer *peer)  	smux_trap(bgp_variables, array_size(bgp_variables), bgp_trap_oid,  		  array_size(bgp_trap_oid), bgp_oid, -		  sizeof bgp_oid / sizeof(oid), index, IN_ADDR_SIZE, +		  sizeof(bgp_oid) / sizeof(oid), index, IN_ADDR_SIZE,  		  bgpTrapList, array_size(bgpTrapList), BGPBACKWARDTRANSITION);  	return 0;  } diff --git a/bgpd/bgp_updgrp_packet.c b/bgpd/bgp_updgrp_packet.c index 89199d05cb..4dc9dfa39a 100644 --- a/bgpd/bgp_updgrp_packet.c +++ b/bgpd/bgp_updgrp_packet.c @@ -330,8 +330,6 @@ void bpacket_queue_remove_peer(struct peer_af *paf)  	q = PAF_PKTQ(paf);  	assert(q); -	if (!q) -		return;  	LIST_REMOVE(paf, pkt_train);  	paf->next_pkt_to_send = NULL; diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 62767a603c..fc89881cae 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -753,7 +753,7 @@ static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi,  }  static int bgp_peer_clear(struct peer *peer, afi_t afi, safi_t safi, -			  struct listnode *nnode, enum bgp_clear_type stype) +			  struct listnode **nnode, enum bgp_clear_type stype)  {  	int ret = 0; @@ -767,7 +767,7 @@ static int bgp_peer_clear(struct peer *peer, afi_t afi, safi_t safi,  				continue;  			if (stype == BGP_CLEAR_SOFT_NONE) -				ret = peer_clear(peer, &nnode); +				ret = peer_clear(peer, nnode);  			else  				ret = peer_clear_soft(peer, tmp_afi, tmp_safi,  						      stype); @@ -782,7 +782,7 @@ static int bgp_peer_clear(struct peer *peer, afi_t afi, safi_t safi,  				continue;  			if (stype == BGP_CLEAR_SOFT_NONE) -				ret = peer_clear(peer, &nnode); +				ret = peer_clear(peer, nnode);  			else  				ret = peer_clear_soft(peer, afi,  						      tmp_safi, stype); @@ -793,7 +793,7 @@ static int bgp_peer_clear(struct peer *peer, afi_t afi, safi_t safi,  			return 1;  		if (stype == BGP_CLEAR_SOFT_NONE) -			ret = peer_clear(peer, &nnode); +			ret = peer_clear(peer, nnode);  		else  			ret = peer_clear_soft(peer, afi, safi, stype);  	} @@ -826,7 +826,7 @@ static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,  			if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART))  				gr_router_detected = true; -			ret = bgp_peer_clear(peer, afi, safi, nnode, +			ret = bgp_peer_clear(peer, afi, safi, &nnode,  							  stype);  			if (ret < 0) @@ -901,7 +901,7 @@ static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,  		}  		for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { -			ret = bgp_peer_clear(peer, afi, safi, nnode, stype); +			ret = bgp_peer_clear(peer, afi, safi, &nnode, stype);  			if (ret < 0)  				bgp_clear_vty_error(vty, peer, afi, safi, ret); @@ -928,7 +928,7 @@ static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,  			if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART))  				gr_router_detected = true; -			ret = bgp_peer_clear(peer, afi, safi, nnode, stype); +			ret = bgp_peer_clear(peer, afi, safi, &nnode, stype);  			if (ret < 0)  				bgp_clear_vty_error(vty, peer, afi, safi, ret); @@ -965,7 +965,7 @@ static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,  			if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART))  				gr_router_detected = true; -			ret = bgp_peer_clear(peer, afi, safi, nnode, stype); +			ret = bgp_peer_clear(peer, afi, safi, &nnode, stype);  			if (ret < 0)  				bgp_clear_vty_error(vty, peer, afi, safi, ret); @@ -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")) { @@ -9440,7 +9432,7 @@ static void bgp_show_neighnor_graceful_restart_rbit(struct vty *vty,  						    bool use_json,  						    json_object *json)  { -	bool rbit_status = 0; +	bool rbit_status = false;  	if (!use_json)  		vty_out(vty, "\n    R bit: "); @@ -9450,9 +9442,9 @@ static void bgp_show_neighnor_graceful_restart_rbit(struct vty *vty,  	    && (p->status == Established)) {  		if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_BIT_RCV)) -			rbit_status = 1; +			rbit_status = true;  		else -			rbit_status = 0; +			rbit_status = false;  	}  	if (rbit_status) { @@ -10657,28 +10649,31 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  		/* read timer */  		time_t uptime; -		struct tm *tm; +		struct tm tm;  		uptime = bgp_clock();  		uptime -= p->readtime; -		tm = gmtime(&uptime); +		gmtime_r(&uptime, &tm); +  		json_object_int_add(json_neigh, "bgpTimerLastRead", -				    (tm->tm_sec * 1000) + (tm->tm_min * 60000) -					    + (tm->tm_hour * 3600000)); +				    (tm.tm_sec * 1000) + (tm.tm_min * 60000) +					    + (tm.tm_hour * 3600000));  		uptime = bgp_clock();  		uptime -= p->last_write; -		tm = gmtime(&uptime); +		gmtime_r(&uptime, &tm); +  		json_object_int_add(json_neigh, "bgpTimerLastWrite", -				    (tm->tm_sec * 1000) + (tm->tm_min * 60000) -					    + (tm->tm_hour * 3600000)); +				    (tm.tm_sec * 1000) + (tm.tm_min * 60000) +					    + (tm.tm_hour * 3600000));  		uptime = bgp_clock();  		uptime -= p->update_time; -		tm = gmtime(&uptime); +		gmtime_r(&uptime, &tm); +  		json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", -				    (tm->tm_sec * 1000) + (tm->tm_min * 60000) -					    + (tm->tm_hour * 3600000)); +				    (tm.tm_sec * 1000) + (tm.tm_min * 60000) +					    + (tm.tm_hour * 3600000));  		/* Configured timer values. */  		json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", @@ -11506,12 +11501,12 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  				vty_out(vty, "\n"); -				/* Gracefull Restart */ +				/* Graceful Restart */  				if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)  				    || CHECK_FLAG(p->cap,  						  PEER_CAP_RESTART_ADV)) {  					vty_out(vty, -						"    Graceful Restart Capabilty:"); +						"    Graceful Restart Capability:");  					if (CHECK_FLAG(p->cap,  						       PEER_CAP_RESTART_ADV))  						vty_out(vty, " advertised"); @@ -11841,15 +11836,16 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,  	} else {  		if (use_json) {  			time_t uptime; -			struct tm *tm; +			struct tm tm;  			uptime = bgp_clock();  			uptime -= p->resettime; -			tm = gmtime(&uptime); +			gmtime_r(&uptime, &tm); +  			json_object_int_add(json_neigh, "lastResetTimerMsecs", -					    (tm->tm_sec * 1000) -						    + (tm->tm_min * 60000) -						    + (tm->tm_hour * 3600000)); +					    (tm.tm_sec * 1000) +						    + (tm.tm_min * 60000) +						    + (tm.tm_hour * 3600000));  			bgp_show_peer_reset(NULL, p, json_neigh, true);  		} else {  			vty_out(vty, "  Last reset %s, ", @@ -16609,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/bgp_zebra.c b/bgpd/bgp_zebra.c index bb718c355f..f3ab608492 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -72,8 +72,9 @@ static inline int bgp_install_info_to_zebra(struct bgp *bgp)  		return 0;  	if (!IS_BGP_INST_KNOWN_TO_ZEBRA(bgp)) { -		zlog_debug("%s: No zebra instance to talk to, not installing information", -			   __PRETTY_FUNCTION__); +		zlog_debug( +			"%s: No zebra instance to talk to, not installing information", +			__func__);  		return 0;  	} @@ -1918,8 +1919,9 @@ int bgp_zebra_advertise_subnet(struct bgp *bgp, int advertise, vni_t vni)  	/* Don't try to register if Zebra doesn't know of this instance. */  	if (!IS_BGP_INST_KNOWN_TO_ZEBRA(bgp)) {  		if (BGP_DEBUG(zebra, ZEBRA)) -			zlog_debug("%s: No zebra instance to talk to, cannot advertise subnet", -				   __PRETTY_FUNCTION__); +			zlog_debug( +				"%s: No zebra instance to talk to, cannot advertise subnet", +				__func__);  		return 0;  	} @@ -1968,8 +1970,9 @@ int bgp_zebra_advertise_gw_macip(struct bgp *bgp, int advertise, vni_t vni)  	/* Don't try to register if Zebra doesn't know of this instance. */  	if (!IS_BGP_INST_KNOWN_TO_ZEBRA(bgp)) {  		if (BGP_DEBUG(zebra, ZEBRA)) -			zlog_debug("%s: No zebra instance to talk to, not installing gw_macip", -				   __PRETTY_FUNCTION__); +			zlog_debug( +				"%s: No zebra instance to talk to, not installing gw_macip", +				__func__);  		return 0;  	} @@ -1996,8 +1999,9 @@ int bgp_zebra_vxlan_flood_control(struct bgp *bgp,  	/* Don't try to register if Zebra doesn't know of this instance. */  	if (!IS_BGP_INST_KNOWN_TO_ZEBRA(bgp)) {  		if (BGP_DEBUG(zebra, ZEBRA)) -			zlog_debug("%s: No zebra instance to talk to, not installing all vni", -				   __PRETTY_FUNCTION__); +			zlog_debug( +				"%s: No zebra instance to talk to, not installing all vni", +				__func__);  		return 0;  	} @@ -2092,7 +2096,7 @@ static int rule_notify_owner(ZAPI_CALLBACK_ARGS)  		if (!bgp_pbr && note != ZAPI_RULE_REMOVED) {  			if (BGP_DEBUG(zebra, ZEBRA))  				zlog_debug("%s: Fail to look BGP rule (%u)", -					   __PRETTY_FUNCTION__, unique); +					   __func__, unique);  			return 0;  		}  	} @@ -2100,8 +2104,7 @@ static int rule_notify_owner(ZAPI_CALLBACK_ARGS)  	switch (note) {  	case ZAPI_RULE_FAIL_INSTALL:  		if (BGP_DEBUG(zebra, ZEBRA)) -			zlog_debug("%s: Received RULE_FAIL_INSTALL", -				   __PRETTY_FUNCTION__); +			zlog_debug("%s: Received RULE_FAIL_INSTALL", __func__);  		if (bgp_pbra) {  			bgp_pbra->installed = false;  			bgp_pbra->install_in_progress = false; @@ -2128,14 +2131,12 @@ static int rule_notify_owner(ZAPI_CALLBACK_ARGS)  					   bgp_pbr);  		}  		if (BGP_DEBUG(zebra, ZEBRA)) -			zlog_debug("%s: Received RULE_INSTALLED", -				   __PRETTY_FUNCTION__); +			zlog_debug("%s: Received RULE_INSTALLED", __func__);  		break;  	case ZAPI_RULE_FAIL_REMOVE:  	case ZAPI_RULE_REMOVED:  		if (BGP_DEBUG(zebra, ZEBRA)) -			zlog_debug("%s: Received RULE REMOVED", -				   __PRETTY_FUNCTION__); +			zlog_debug("%s: Received RULE REMOVED", __func__);  		break;  	} @@ -2157,15 +2158,14 @@ static int ipset_notify_owner(ZAPI_CALLBACK_ARGS)  	if (!bgp_pbim) {  		if (BGP_DEBUG(zebra, ZEBRA))  			zlog_debug("%s: Fail to look BGP match ( %u, ID %u)", -				   __PRETTY_FUNCTION__, note, unique); +				   __func__, note, unique);  		return 0;  	}  	switch (note) {  	case ZAPI_IPSET_FAIL_INSTALL:  		if (BGP_DEBUG(zebra, ZEBRA)) -			zlog_debug("%s: Received IPSET_FAIL_INSTALL", -				   __PRETTY_FUNCTION__); +			zlog_debug("%s: Received IPSET_FAIL_INSTALL", __func__);  		bgp_pbim->installed = false;  		bgp_pbim->install_in_progress = false;  		break; @@ -2173,14 +2173,12 @@ static int ipset_notify_owner(ZAPI_CALLBACK_ARGS)  		bgp_pbim->installed = true;  		bgp_pbim->install_in_progress = false;  		if (BGP_DEBUG(zebra, ZEBRA)) -			zlog_debug("%s: Received IPSET_INSTALLED", -				   __PRETTY_FUNCTION__); +			zlog_debug("%s: Received IPSET_INSTALLED", __func__);  		break;  	case ZAPI_IPSET_FAIL_REMOVE:  	case ZAPI_IPSET_REMOVED:  		if (BGP_DEBUG(zebra, ZEBRA)) -			zlog_debug("%s: Received IPSET REMOVED", -				   __PRETTY_FUNCTION__); +			zlog_debug("%s: Received IPSET REMOVED", __func__);  		break;  	} @@ -2205,8 +2203,9 @@ static int ipset_entry_notify_owner(ZAPI_CALLBACK_ARGS)  						     unique);  	if (!bgp_pbime) {  		if (BGP_DEBUG(zebra, ZEBRA)) -			zlog_debug("%s: Fail to look BGP match entry (%u, ID %u)", -				   __PRETTY_FUNCTION__, note, unique); +			zlog_debug( +				"%s: Fail to look BGP match entry (%u, ID %u)", +				__func__, note, unique);  		return 0;  	} @@ -2214,7 +2213,7 @@ static int ipset_entry_notify_owner(ZAPI_CALLBACK_ARGS)  	case ZAPI_IPSET_ENTRY_FAIL_INSTALL:  		if (BGP_DEBUG(zebra, ZEBRA))  			zlog_debug("%s: Received IPSET_ENTRY_FAIL_INSTALL", -				   __PRETTY_FUNCTION__); +				   __func__);  		bgp_pbime->installed = false;  		bgp_pbime->install_in_progress = false;  		break; @@ -2227,7 +2226,7 @@ static int ipset_entry_notify_owner(ZAPI_CALLBACK_ARGS)  		bgp_pbime->install_in_progress = false;  		if (BGP_DEBUG(zebra, ZEBRA))  			zlog_debug("%s: Received IPSET_ENTRY_INSTALLED", -				   __PRETTY_FUNCTION__); +				   __func__);  		/* link bgp_path_info to bpme */  		path = (struct bgp_path_info *)bgp_pbime->path;  		extra = bgp_path_info_extra_get(path); @@ -2238,7 +2237,7 @@ static int ipset_entry_notify_owner(ZAPI_CALLBACK_ARGS)  	case ZAPI_IPSET_ENTRY_REMOVED:  		if (BGP_DEBUG(zebra, ZEBRA))  			zlog_debug("%s: Received IPSET_ENTRY_REMOVED", -				   __PRETTY_FUNCTION__); +				   __func__);  		break;  	}  	return 0; @@ -2259,14 +2258,14 @@ static int iptable_notify_owner(ZAPI_CALLBACK_ARGS)  	if (!bgpm) {  		if (BGP_DEBUG(zebra, ZEBRA))  			zlog_debug("%s: Fail to look BGP iptable (%u %u)", -				   __PRETTY_FUNCTION__, note, unique); +				   __func__, note, unique);  		return 0;  	}  	switch (note) {  	case ZAPI_IPTABLE_FAIL_INSTALL:  		if (BGP_DEBUG(zebra, ZEBRA))  			zlog_debug("%s: Received IPTABLE_FAIL_INSTALL", -				   __PRETTY_FUNCTION__); +				   __func__);  		bgpm->installed_in_iptable = false;  		bgpm->install_iptable_in_progress = false;  		break; @@ -2274,15 +2273,13 @@ static int iptable_notify_owner(ZAPI_CALLBACK_ARGS)  		bgpm->installed_in_iptable = true;  		bgpm->install_iptable_in_progress = false;  		if (BGP_DEBUG(zebra, ZEBRA)) -			zlog_debug("%s: Received IPTABLE_INSTALLED", -				   __PRETTY_FUNCTION__); +			zlog_debug("%s: Received IPTABLE_INSTALLED", __func__);  		bgpm->action->refcnt++;  		break;  	case ZAPI_IPTABLE_FAIL_REMOVE:  	case ZAPI_IPTABLE_REMOVED:  		if (BGP_DEBUG(zebra, ZEBRA)) -			zlog_debug("%s: Received IPTABLE REMOVED", -				   __PRETTY_FUNCTION__); +			zlog_debug("%s: Received IPTABLE REMOVED", __func__);  		break;  	}  	return 0; @@ -2786,12 +2783,10 @@ void bgp_send_pbr_rule_action(struct bgp_pbr_action *pbra,  		return;  	if (BGP_DEBUG(zebra, ZEBRA)) {  		if (pbr) -			zlog_debug("%s: table %d (ip rule) %d", -				   __PRETTY_FUNCTION__, +			zlog_debug("%s: table %d (ip rule) %d", __func__,  				   pbra->table_id, install);  		else -			zlog_debug("%s: table %d fwmark %d %d", -				   __PRETTY_FUNCTION__, +			zlog_debug("%s: table %d fwmark %d %d", __func__,  				   pbra->table_id, pbra->fwmark, install);  	}  	s = zclient->obuf; @@ -2820,10 +2815,9 @@ void bgp_send_pbr_ipset_match(struct bgp_pbr_match *pbrim, bool install)  	if (pbrim->install_in_progress)  		return;  	if (BGP_DEBUG(zebra, ZEBRA)) -		zlog_debug("%s: name %s type %d %d, ID %u", -			   __PRETTY_FUNCTION__, -			   pbrim->ipset_name, pbrim->type, -			   install, pbrim->unique); +		zlog_debug("%s: name %s type %d %d, ID %u", __func__, +			   pbrim->ipset_name, pbrim->type, install, +			   pbrim->unique);  	s = zclient->obuf;  	stream_reset(s); @@ -2849,9 +2843,9 @@ void bgp_send_pbr_ipset_entry_match(struct bgp_pbr_match_entry *pbrime,  	if (pbrime->install_in_progress)  		return;  	if (BGP_DEBUG(zebra, ZEBRA)) -		zlog_debug("%s: name %s %d %d, ID %u", __PRETTY_FUNCTION__, -			   pbrime->backpointer->ipset_name, -			   pbrime->unique, install, pbrime->unique); +		zlog_debug("%s: name %s %d %d, ID %u", __func__, +			   pbrime->backpointer->ipset_name, pbrime->unique, +			   install, pbrime->unique);  	s = zclient->obuf;  	stream_reset(s); @@ -2916,9 +2910,8 @@ void bgp_send_pbr_iptable(struct bgp_pbr_action *pba,  	if (pbm->install_iptable_in_progress)  		return;  	if (BGP_DEBUG(zebra, ZEBRA)) -		zlog_debug("%s: name %s type %d mark %d %d, ID %u", -			   __PRETTY_FUNCTION__, pbm->ipset_name, -			   pbm->type, pba->fwmark, install, +		zlog_debug("%s: name %s type %d mark %d %d, ID %u", __func__, +			   pbm->ipset_name, pbm->type, pba->fwmark, install,  			   pbm->unique2);  	s = zclient->obuf;  	stream_reset(s); diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 96b307ee21..8cc4096076 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -1200,8 +1200,6 @@ struct peer *peer_new(struct bgp *bgp)  	/* bgp argument is absolutely required */  	assert(bgp); -	if (!bgp) -		return NULL;  	/* Allocate new peer. */  	peer = XCALLOC(MTYPE_BGP_PEER, sizeof(struct peer)); @@ -3148,7 +3146,7 @@ int bgp_handle_socket(struct bgp *bgp, struct vrf *vrf, vrf_id_t old_vrf_id,  		/*  		 * suppress vrf socket  		 */ -		if (create == false) { +		if (!create) {  			bgp_close_vrf_socket(bgp);  			return 0;  		} @@ -3228,7 +3226,7 @@ int bgp_get(struct bgp **bgp_val, as_t *as, const char *name,  	if (IS_BGP_INST_KNOWN_TO_ZEBRA(bgp)) {  		if (BGP_DEBUG(zebra, ZEBRA))  			zlog_debug("%s: Registering BGP instance %s to zebra", -				   __PRETTY_FUNCTION__, name); +				   __func__, name);  		bgp_zebra_instance_register(bgp);  	} @@ -3400,8 +3398,9 @@ int bgp_delete(struct bgp *bgp)  	/* Deregister from Zebra, if needed */  	if (IS_BGP_INST_KNOWN_TO_ZEBRA(bgp)) {  		if (BGP_DEBUG(zebra, ZEBRA)) -			zlog_debug("%s: deregistering this bgp %s instance from zebra", -				   __PRETTY_FUNCTION__, bgp->name); +			zlog_debug( +				"%s: deregistering this bgp %s instance from zebra", +				__func__, bgp->name);  		bgp_zebra_instance_deregister(bgp);  	} @@ -4032,7 +4031,7 @@ static int peer_flag_modify(struct peer *peer, uint32_t flag, int set)  	struct peer_flag_action action;  	memset(&action, 0, sizeof(struct peer_flag_action)); -	size = sizeof peer_flag_action_list / sizeof(struct peer_flag_action); +	size = sizeof(peer_flag_action_list) / sizeof(struct peer_flag_action);  	invert = CHECK_FLAG(peer->flags_invert, flag);  	found = peer_flag_action_set(peer_flag_action_list, size, &action, @@ -4138,7 +4137,7 @@ static int peer_af_flag_modify(struct peer *peer, afi_t afi, safi_t safi,  	bgp_peer_sort_t ptype;  	memset(&action, 0, sizeof(struct peer_flag_action)); -	size = sizeof peer_af_flag_action_list +	size = sizeof(peer_af_flag_action_list)  	       / sizeof(struct peer_flag_action);  	invert = CHECK_FLAG(peer->af_flags_invert[afi][safi], flag); @@ -6848,7 +6847,7 @@ char *peer_uptime(time_t uptime2, char *buf, size_t len, bool use_json,  		  json_object *json)  {  	time_t uptime1, epoch_tbuf; -	struct tm *tm; +	struct tm tm;  	/* If there is no connection has been done before print `never'. */  	if (uptime2 == 0) { @@ -6863,21 +6862,21 @@ char *peer_uptime(time_t uptime2, char *buf, size_t len, bool use_json,  	/* Get current time. */  	uptime1 = bgp_clock();  	uptime1 -= uptime2; -	tm = gmtime(&uptime1); +	gmtime_r(&uptime1, &tm);  	if (uptime1 < ONE_DAY_SECOND) -		snprintf(buf, len, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, -			 tm->tm_sec); +		snprintf(buf, len, "%02d:%02d:%02d", tm.tm_hour, tm.tm_min, +			 tm.tm_sec);  	else if (uptime1 < ONE_WEEK_SECOND) -		snprintf(buf, len, "%dd%02dh%02dm", tm->tm_yday, tm->tm_hour, -			 tm->tm_min); +		snprintf(buf, len, "%dd%02dh%02dm", tm.tm_yday, tm.tm_hour, +			 tm.tm_min);  	else if (uptime1 < ONE_YEAR_SECOND) -		snprintf(buf, len, "%02dw%dd%02dh", tm->tm_yday / 7, -			 tm->tm_yday - ((tm->tm_yday / 7) * 7), tm->tm_hour); +		snprintf(buf, len, "%02dw%dd%02dh", tm.tm_yday / 7, +			 tm.tm_yday - ((tm.tm_yday / 7) * 7), tm.tm_hour);  	else -		snprintf(buf, len, "%02dy%02dw%dd", tm->tm_year - 70, -			 tm->tm_yday / 7, -			 tm->tm_yday - ((tm->tm_yday / 7) * 7)); +		snprintf(buf, len, "%02dy%02dw%dd", tm.tm_year - 70, +			 tm.tm_yday / 7, +			 tm.tm_yday - ((tm.tm_yday / 7) * 7));  	if (use_json) {  		epoch_tbuf = time(NULL) - uptime1; diff --git a/bgpd/rfapi/rfapi_rib.c b/bgpd/rfapi/rfapi_rib.c index 39d4b3ee29..b7ec35c661 100644 --- a/bgpd/rfapi/rfapi_rib.c +++ b/bgpd/rfapi/rfapi_rib.c @@ -2184,6 +2184,7 @@ void rfapiRibPendingDeleteRoute(struct bgp *bgp, struct rfapi_import_table *it,  				rfapiRibUpdatePendingNode(  					bgp, m->rfd, it, it_node,  					m->rfd->response_lifetime); +				agg_unlock_node(rn);  			}  		} 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 38ed78eb86..de690adb34 100644 --- a/doc/user/bgp.rst +++ b/doc/user/bgp.rst @@ -1215,6 +1215,14 @@ Configuring Peers     keyword `all` is specified the modification is done also for routes learned     via iBGP. +.. index:: neighbor PEER attribute-unchanged [{as-path|next-hop|med}] +.. clicmd:: neighbor PEER attribute-unchanged [{as-path|next-hop|med}] + +   This command specifies attributes to be left unchanged for advertisements +   sent to a peer. Use this to leave the next-hop unchanged in ipv6 +   configurations, as the route-map directive to leave the next-hop unchanged +   is only available for ipv4. +  .. index:: [no] neighbor PEER update-source <IFNAME|ADDRESS>  .. clicmd:: [no] neighbor PEER update-source <IFNAME|ADDRESS> diff --git a/doc/user/overview.rst b/doc/user/overview.rst index 262c0117df..b72ceb8d38 100644 --- a/doc/user/overview.rst +++ b/doc/user/overview.rst @@ -292,6 +292,8 @@ BGP    :t:`BGP/MPLS IP Virtual Private Networks (VPNs). Y. Rekhter. Feb 2006.`  - :rfc:`4659`    :t:`BGP-MPLS IP Virtual Private Network (VPN) Extension for IPv6 VPN. J. De Clercq, D. Ooms, M. Carugi, F. Le Faucheur. September 2006.` +- :rfc:`4893` +  :t:`BGP Support for Four-octet AS Number Space. Q. Vohra, E. Chen May 2007.`  - :rfc:`5004`    :t:`Avoid BGP Best Path Transitions from One External to Another. E. Chen & S. Sangli. September 2007 (Partial support).`  - :rfc:`5082` @@ -445,4 +447,4 @@ For information on reporting bugs, please see :ref:`bug-reports`.  .. _frr: |package-url|  .. _github: https://github.com/frrouting/frr/  .. _github issues: https://github.com/frrouting/frr/issues -.. _slack: https://frrouting.slack.com/ +.. _slack: https://frrouting.org/#participate 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/doc/user/routemap.rst b/doc/user/routemap.rst index 8526b0f984..472e2c53ff 100644 --- a/doc/user/routemap.rst +++ b/doc/user/routemap.rst @@ -273,6 +273,16 @@ Route Map Set Command     Set the BGP local preference to `local_pref`. +.. index:: set local-preference +LOCAL_PREF +.. clicmd:: set local-preference +LOCAL_PREF + +   Add the BGP local preference to an existing `local_pref`. + +.. index:: set local-preference -LOCAL_PREF +.. clicmd:: set local-preference -LOCAL_PREF + +   Subtract the BGP local preference from an existing `local_pref`. +  .. index:: [no] set distance DISTANCE  .. clicmd:: [no] set distance DISTANCE diff --git a/doc/user/rpki.rst b/doc/user/rpki.rst index dfac10b4f2..f8ec98c964 100644 --- a/doc/user/rpki.rst +++ b/doc/user/rpki.rst @@ -200,6 +200,18 @@ Debugging  Displaying RPKI  --------------- +.. index:: show rpki prefix <A.B.C.D/M|X:X::X:X/M> [(1-4294967295)] +.. clicmd:: show rpki prefix <A.B.C.D/M|X:X::X:X/M> [(1-4294967295)] + +   Display validated prefixes received from the cache servers filtered +   by the specified prefix. + +.. index:: show rpki as-number ASN +.. clicmd:: show rpki as-number ASN + +   Display validated prefixes received from the cache servers filtered +   by ASN. +  .. index:: show rpki prefix-table  .. clicmd:: show rpki prefix-table diff --git a/doc/user/vrrp.rst b/doc/user/vrrp.rst index 435580131b..33582ee446 100644 --- a/doc/user/vrrp.rst +++ b/doc/user/vrrp.rst @@ -140,7 +140,7 @@ macvlan device. If you are using ``iproute2``, the equivalent configuration is:     ip link set dev vrrp4-2-1 up     ip link add vrrp6-2-1 link eth0 addrgenmode random type macvlan mode bridge -   ip link set dev vrrp4-2-1 address 00:00:5e:00:02:05 +   ip link set dev vrrp6-2-1 address 00:00:5e:00:02:05     ip addr add 2001:db8::370:7334/64 dev vrrp6-2-1     ip link set dev vrrp6-2-1 up diff --git a/eigrpd/eigrp_packet.c b/eigrpd/eigrp_packet.c index 6367ef58ab..48e9a18e5a 100644 --- a/eigrpd/eigrp_packet.c +++ b/eigrpd/eigrp_packet.c @@ -351,13 +351,13 @@ int eigrp_write(struct thread *thread)  	ep = eigrp_fifo_next(ei->obuf);  	if (!ep) {  		flog_err(EC_LIB_DEVELOPMENT, -			 "%s: Interface %s no packet on queue?", -			 __PRETTY_FUNCTION__, ei->ifp->name); +			 "%s: Interface %s no packet on queue?", __func__, +			 ei->ifp->name);  		goto out;  	}  	if (ep->length < EIGRP_HEADER_LEN) {  		flog_err(EC_EIGRP_PACKET, "%s: Packet just has a header?", -			 __PRETTY_FUNCTION__); +			 __func__);  		eigrp_header_dump((struct eigrp_header *)ep->s->data);  		eigrp_packet_delete(ei);  		goto out; @@ -1205,7 +1205,7 @@ uint16_t eigrp_add_internalTLV_to_stream(struct stream *s,  		break;  	default:  		flog_err(EC_LIB_DEVELOPMENT, "%s: Unexpected prefix length: %d", -			 __PRETTY_FUNCTION__, pe->destination->prefixlen); +			 __func__, pe->destination->prefixlen);  		return 0;  	}  	stream_putl(s, 0x00000000); diff --git a/eigrpd/eigrp_reply.c b/eigrpd/eigrp_reply.c index ccf0496736..79405efbbf 100644 --- a/eigrpd/eigrp_reply.c +++ b/eigrpd/eigrp_reply.c @@ -173,7 +173,7 @@ void eigrp_reply_receive(struct eigrp *eigrp, struct ip *iph,  			flog_err(  				EC_EIGRP_PACKET,  				"%s: Received prefix %s which we do not know about", -				__PRETTY_FUNCTION__, +				__func__,  				prefix2str(&dest_addr, buf, sizeof(buf)));  			eigrp_IPv4_InternalTLV_free(tlv);  			continue; diff --git a/eigrpd/eigrp_routemap.c b/eigrpd/eigrp_routemap.c index 99cc34d3d0..e15f777954 100644 --- a/eigrpd/eigrp_routemap.c +++ b/eigrpd/eigrp_routemap.c @@ -295,7 +295,7 @@ static void *route_match_metric_compile(const char *arg)  {  	//  uint32_t *metric;  	// -	//  metric = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (uint32_t)); +	//  metric = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof(uint32_t));  	//  *metric = atoi (arg);  	//  	//  if(*metric > 0) @@ -574,7 +574,7 @@ static void *route_match_tag_compile(const char *arg)  {  	//  unsigned short *tag;  	// -	//  tag = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (unsigned short)); +	//  tag = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof(unsigned short));  	//  *tag = atoi (arg);  	//  	//  return tag; @@ -667,7 +667,7 @@ static void *route_set_metric_compile(const char *arg)  	//    return NULL;*/  	//  	//  mod = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, -	//    sizeof (struct rip_metric_modifier)); +	//    sizeof(struct rip_metric_modifier));  	//  mod->type = type;  	//  mod->metric = metric; @@ -718,7 +718,7 @@ static void *route_set_ip_nexthop_compile(const char *arg)  	//  int ret;  	//  struct in_addr *address;  	// -	//  address = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct +	//  address = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof(struct  	//  in_addr));  	//  	//  ret = inet_aton (arg, address); @@ -775,7 +775,7 @@ static void *route_set_tag_compile(const char *arg)  {  	//  unsigned short *tag;  	// -	//  tag = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (unsigned short)); +	//  tag = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof(unsigned short));  	//  *tag = atoi (arg);  	//  	//  return tag; diff --git a/eigrpd/eigrp_topology.c b/eigrpd/eigrp_topology.c index 56dbe3d85e..7676af15f2 100644 --- a/eigrpd/eigrp_topology.c +++ b/eigrpd/eigrp_topology.c @@ -138,7 +138,7 @@ void eigrp_prefix_entry_add(struct route_table *topology,  			zlog_debug(  				"%s: %s Should we have found this entry in the topo table?", -				__PRETTY_FUNCTION__, +				__func__,  				prefix2str(pe->destination, buf, sizeof(buf)));  		}  		route_unlock_node(rn); @@ -402,7 +402,7 @@ eigrp_topology_update_distance(struct eigrp_fsm_action_message *msg)  		break;  	default:  		flog_err(EC_LIB_DEVELOPMENT, "%s: Please implement handler", -			 __PRETTY_FUNCTION__); +			 __func__);  		break;  	}  distance_done: @@ -175,7 +175,7 @@ static inline size_t fpm_msg_align(size_t len)   * The (rounded up) size of the FPM message header. This ensures that   * the message payload always starts at an aligned address.   */ -#define FPM_MSG_HDR_LEN (sizeof (fpm_msg_hdr_t)) +#define FPM_MSG_HDR_LEN (sizeof(fpm_msg_hdr_t))  #ifndef COMPILE_ASSERT  #define COMPILE_ASSERT(x) extern int __dummy[2 * !!(x) - 1] diff --git a/isisd/isis_misc.c b/isisd/isis_misc.c index a7f491e87d..5fa33f5500 100644 --- a/isisd/isis_misc.c +++ b/isisd/isis_misc.c @@ -562,19 +562,20 @@ void vty_multiline(struct vty *vty, const char *prefix, const char *format, ...)  void vty_out_timestr(struct vty *vty, time_t uptime)  { -	struct tm *tm; +	struct tm tm;  	time_t difftime = time(NULL);  	difftime -= uptime; -	tm = gmtime(&difftime); + +	gmtime_r(&difftime, &tm);  	if (difftime < ONE_DAY_SECOND) -		vty_out(vty, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, -			tm->tm_sec); +		vty_out(vty, "%02d:%02d:%02d", tm.tm_hour, tm.tm_min, +			tm.tm_sec);  	else if (difftime < ONE_WEEK_SECOND) -		vty_out(vty, "%dd%02dh%02dm", tm->tm_yday, tm->tm_hour, -			tm->tm_min); +		vty_out(vty, "%dd%02dh%02dm", tm.tm_yday, tm.tm_hour, +			tm.tm_min);  	else -		vty_out(vty, "%02dw%dd%02dh", tm->tm_yday / 7, -			tm->tm_yday - ((tm->tm_yday / 7) * 7), tm->tm_hour); +		vty_out(vty, "%02dw%dd%02dh", tm.tm_yday / 7, +			tm.tm_yday - ((tm.tm_yday / 7) * 7), tm.tm_hour);  	vty_out(vty, " ago");  } diff --git a/isisd/isis_vty_fabricd.c b/isisd/isis_vty_fabricd.c index 24e5c51947..88f7337a91 100644 --- a/isisd/isis_vty_fabricd.c +++ b/isisd/isis_vty_fabricd.c @@ -129,18 +129,20 @@ static void lsp_print_flooding(struct vty *vty, struct isis_lsp *lsp)  		lsp->flooding_interface : "(null)");  	time_t uptime = time(NULL) - lsp->flooding_time; -	struct tm *tm = gmtime(&uptime); +	struct tm tm; + +	gmtime_r(&uptime, &tm);  	if (uptime < ONE_DAY_SECOND) -		vty_out(vty, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, -			tm->tm_sec); +		vty_out(vty, "%02d:%02d:%02d", tm.tm_hour, tm.tm_min, +			tm.tm_sec);  	else if (uptime < ONE_WEEK_SECOND) -		vty_out(vty, "%dd%02dh%02dm", tm->tm_yday, tm->tm_hour, -			tm->tm_min); +		vty_out(vty, "%dd%02dh%02dm", tm.tm_yday, tm.tm_hour, +			tm.tm_min);  	else -		vty_out(vty, "%02dw%dd%02dh", tm->tm_yday / 7, -			tm->tm_yday - ((tm->tm_yday / 7) * 7), -			tm->tm_hour); +		vty_out(vty, "%02dw%dd%02dh", tm.tm_yday / 7, +			tm.tm_yday - ((tm.tm_yday / 7) * 7), +			tm.tm_hour);  	vty_out(vty, " ago)\n");  	if (lsp->flooding_circuit_scoped) { diff --git a/ldpd/address.c b/ldpd/address.c index 9c1564a31f..74a3f5a309 100644 --- a/ldpd/address.c +++ b/ldpd/address.c @@ -67,7 +67,7 @@ send_address(struct nbr *nbr, int af, struct if_addr_head *addr_list,  		fatalx("send_address: unknown af");  	} -	while ((if_addr = LIST_FIRST(addr_list)) != NULL) { +	while (LIST_FIRST(addr_list) != NULL) {  		/*  		 * Send as many addresses as possible - respect the session's  		 * negotiated maximum pdu length. diff --git a/ldpd/lde.c b/ldpd/lde.c index 006d27f6ab..5f94031320 100644 --- a/ldpd/lde.c +++ b/ldpd/lde.c @@ -71,9 +71,6 @@ struct nbr_tree		 lde_nbrs = RB_INITIALIZER(&lde_nbrs);  static struct imsgev	*iev_ldpe;  static struct imsgev	*iev_main, *iev_main_sync; -/* Master of threads. */ -struct thread_master *master; -  /* lde privileges */  static zebra_capabilities_t _caps_p [] =  { diff --git a/ldpd/ldpd.c b/ldpd/ldpd.c index dcbcf8ce50..78b1c3e544 100644 --- a/ldpd/ldpd.c +++ b/ldpd/ldpd.c @@ -86,6 +86,8 @@ static struct imsgev	*iev_lde, *iev_lde_sync;  static pid_t		 ldpe_pid;  static pid_t		 lde_pid; +enum ldpd_process ldpd_process; +  #define LDP_DEFAULT_CONFIG	"ldpd.conf"  #define LDP_VTY_PORT		2612 @@ -858,7 +860,6 @@ ldp_acl_request(struct imsgev *iev, char *acl_name, int af,      union ldpd_addr *addr, uint8_t prefixlen)  {  	struct imsg	 imsg; -	ssize_t		 n;  	struct acl_check acl_check;  	if (acl_name[0] == '\0') @@ -876,9 +877,9 @@ ldp_acl_request(struct imsgev *iev, char *acl_name, int af,  	imsg_flush(&iev->ibuf);  	/* receive (blocking) and parse result */ -	if ((n = imsg_read(&iev->ibuf)) == -1) +	if (imsg_read(&iev->ibuf) == -1)  		fatal("imsg_read error"); -	if ((n = imsg_get(&iev->ibuf, &imsg)) == -1) +	if (imsg_get(&iev->ibuf, &imsg) == -1)  		fatal("imsg_get");  	if (imsg.hdr.type != IMSG_ACL_CHECK ||  	    imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(int)) @@ -1408,7 +1409,7 @@ merge_ifaces(struct ldpd_conf *conf, struct ldpd_conf *xconf)  	RB_FOREACH_SAFE(iface, iface_head, &conf->iface_tree, itmp) {  		/* find deleted interfaces */ -		if ((xi = if_lookup_name(xconf, iface->name)) == NULL) { +		if (if_lookup_name(xconf, iface->name) == NULL) {  			switch (ldpd_process) {  			case PROC_LDP_ENGINE:  				ldpe_if_exit(iface); @@ -1469,7 +1470,7 @@ merge_tnbrs(struct ldpd_conf *conf, struct ldpd_conf *xconf)  			continue;  		/* find deleted tnbrs */ -		if ((xt = tnbr_find(xconf, tnbr->af, &tnbr->addr)) == NULL) { +		if (tnbr_find(xconf, tnbr->af, &tnbr->addr) == NULL) {  			switch (ldpd_process) {  			case PROC_LDP_ENGINE:  				tnbr->flags &= ~F_TNBR_CONFIGURED; @@ -1515,33 +1516,35 @@ merge_nbrps(struct ldpd_conf *conf, struct ldpd_conf *xconf)  	RB_FOREACH_SAFE(nbrp, nbrp_head, &conf->nbrp_tree, ntmp) {  		/* find deleted nbrps */ -		if ((xn = nbr_params_find(xconf, nbrp->lsr_id)) == NULL) { -			switch (ldpd_process) { -			case PROC_LDP_ENGINE: -				nbr = nbr_find_ldpid(nbrp->lsr_id.s_addr); -				if (nbr) { -					session_shutdown(nbr, S_SHUTDOWN, 0, 0); +		if (nbr_params_find(xconf, nbrp->lsr_id) != NULL) +			continue; + +		switch (ldpd_process) { +		case PROC_LDP_ENGINE: +			nbr = nbr_find_ldpid(nbrp->lsr_id.s_addr); +			if (nbr) { +				session_shutdown(nbr, S_SHUTDOWN, 0, 0);  #ifdef __OpenBSD__ -					pfkey_remove(nbr); +				pfkey_remove(nbr);  #else -					sock_set_md5sig( -					    (ldp_af_global_get(&global, -					    nbr->af))->ldp_session_socket, -					    nbr->af, &nbr->raddr, NULL); +				sock_set_md5sig( +					(ldp_af_global_get(&global, nbr->af)) +						->ldp_session_socket, +					nbr->af, &nbr->raddr, NULL);  #endif -					nbr->auth.method = AUTH_NONE; -					if (nbr_session_active_role(nbr)) -						nbr_establish_connection(nbr); -				} -				break; -			case PROC_LDE_ENGINE: -			case PROC_MAIN: -				break; +				nbr->auth.method = AUTH_NONE; +				if (nbr_session_active_role(nbr)) +					nbr_establish_connection(nbr);  			} -			RB_REMOVE(nbrp_head, &conf->nbrp_tree, nbrp); -			free(nbrp); +			break; +		case PROC_LDE_ENGINE: +		case PROC_MAIN: +			break;  		} +		RB_REMOVE(nbrp_head, &conf->nbrp_tree, nbrp); +		free(nbrp);  	} +  	RB_FOREACH_SAFE(xn, nbrp_head, &xconf->nbrp_tree, ntmp) {  		/* find new nbrps */  		if ((nbrp = nbr_params_find(conf, xn->lsr_id)) == NULL) { @@ -1624,7 +1627,7 @@ merge_l2vpns(struct ldpd_conf *conf, struct ldpd_conf *xconf)  	RB_FOREACH_SAFE(l2vpn, l2vpn_head, &conf->l2vpn_tree, ltmp) {  		/* find deleted l2vpns */ -		if ((xl = l2vpn_find(xconf, l2vpn->name)) == NULL) { +		if (l2vpn_find(xconf, l2vpn->name) == NULL) {  			switch (ldpd_process) {  			case PROC_LDE_ENGINE:  				l2vpn_exit(l2vpn); @@ -1680,14 +1683,14 @@ merge_l2vpn(struct ldpd_conf *xconf, struct l2vpn *l2vpn, struct l2vpn *xl)  	/* merge intefaces */  	RB_FOREACH_SAFE(lif, l2vpn_if_head, &l2vpn->if_tree, ftmp) {  		/* find deleted interfaces */ -		if ((xf = l2vpn_if_find(xl, lif->ifname)) == NULL) { +		if (l2vpn_if_find(xl, lif->ifname) == NULL) {  			RB_REMOVE(l2vpn_if_head, &l2vpn->if_tree, lif);  			free(lif);  		}  	}  	RB_FOREACH_SAFE(xf, l2vpn_if_head, &xl->if_tree, ftmp) {  		/* find new interfaces */ -		if ((lif = l2vpn_if_find(l2vpn, xf->ifname)) == NULL) { +		if (l2vpn_if_find(l2vpn, xf->ifname) == NULL) {  			COPY(lif, xf);  			RB_INSERT(l2vpn_if_head, &l2vpn->if_tree, lif);  			lif->l2vpn = l2vpn; @@ -1706,7 +1709,7 @@ merge_l2vpn(struct ldpd_conf *xconf, struct l2vpn *l2vpn, struct l2vpn *xl)  	/* merge active pseudowires */  	RB_FOREACH_SAFE(pw, l2vpn_pw_head, &l2vpn->pw_tree, ptmp) {  		/* find deleted active pseudowires */ -		if ((xp = l2vpn_pw_find_active(xl, pw->ifname)) == NULL) { +		if (l2vpn_pw_find_active(xl, pw->ifname) == NULL) {  			switch (ldpd_process) {  			case PROC_LDE_ENGINE:  				l2vpn_pw_exit(pw); @@ -1807,7 +1810,7 @@ merge_l2vpn(struct ldpd_conf *xconf, struct l2vpn *l2vpn, struct l2vpn *xl)  	/* merge inactive pseudowires */  	RB_FOREACH_SAFE(pw, l2vpn_pw_head, &l2vpn->pw_inactive_tree, ptmp) {  		/* find deleted inactive pseudowires */ -		if ((xp = l2vpn_pw_find_inactive(xl, pw->ifname)) == NULL) { +		if (l2vpn_pw_find_inactive(xl, pw->ifname) == NULL) {  			RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_inactive_tree, pw);  			free(pw);  		} diff --git a/ldpd/ldpd.h b/ldpd/ldpd.h index bd7562e5ad..a5d1bb7177 100644 --- a/ldpd/ldpd.h +++ b/ldpd/ldpd.h @@ -446,7 +446,7 @@ DECLARE_QOBJ_TYPE(l2vpn)  #define L2VPN_TYPE_VPLS		2  /* ldp_conf */ -enum ldpd_process { +extern enum ldpd_process {  	PROC_MAIN,  	PROC_LDP_ENGINE,  	PROC_LDE_ENGINE diff --git a/ldpd/ldpe.c b/ldpd/ldpe.c index c16d92f28b..82e52f5fe3 100644 --- a/ldpd/ldpe.c +++ b/ldpd/ldpe.c @@ -54,9 +54,6 @@ static struct imsgev	*iev_lde;  static struct thread	*pfkey_ev;  #endif -/* Master of threads. */ -struct thread_master *master; -  /* ldpe privileges */  static zebra_capabilities_t _caps_p [] =  { @@ -97,6 +94,8 @@ static struct quagga_signal_t ldpe_signals[] =  	},  }; +char *pkt_ptr; /* packet buffer */ +  /* label distribution protocol engine */  void  ldpe(void) diff --git a/ldpd/ldpe.h b/ldpd/ldpe.h index ccff1e803d..5b40383db2 100644 --- a/ldpd/ldpe.h +++ b/ldpd/ldpe.h @@ -291,7 +291,7 @@ struct tcp_conn		*tcp_new(int, struct nbr *);  void			 pending_conn_del(struct pending_conn *);  struct pending_conn	*pending_conn_find(int, union ldpd_addr *); -char	*pkt_ptr;	/* packet buffer */ +extern char *pkt_ptr; /* packet buffer */  /* pfkey.c */  #ifdef __OpenBSD__ diff --git a/ldpd/socket.c b/ldpd/socket.c index 8706d03c6f..997434620a 100644 --- a/ldpd/socket.c +++ b/ldpd/socket.c @@ -209,7 +209,7 @@ sock_set_nonblock(int fd)  	flags |= O_NONBLOCK; -	if ((flags = fcntl(fd, F_SETFL, flags)) == -1) +	if (fcntl(fd, F_SETFL, flags) == -1)  		fatal("fcntl F_SETFL");  } @@ -223,7 +223,7 @@ sock_set_cloexec(int fd)  	flags |= FD_CLOEXEC; -	if ((flags = fcntl(fd, F_SETFD, flags)) == -1) +	if (fcntl(fd, F_SETFD, flags) == -1)  		fatal("fcntl F_SETFD");  } diff --git a/lib/agentx.c b/lib/agentx.c index b479b5ea4c..d1b801fe8c 100644 --- a/lib/agentx.c +++ b/lib/agentx.c @@ -264,7 +264,7 @@ int smux_trap(struct variable *vp, size_t vp_len, const oid *ename,  	      uint8_t sptrap)  {  	oid objid_snmptrap[] = {1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0}; -	size_t objid_snmptrap_len = sizeof objid_snmptrap / sizeof(oid); +	size_t objid_snmptrap_len = sizeof(objid_snmptrap) / sizeof(oid);  	oid notification_oid[MAX_OID_LEN];  	size_t notification_oid_len;  	unsigned int i; @@ -136,7 +136,7 @@ void bfd_peer_sendmsg(struct zclient *zclient, struct bfd_info *bfd_info,  		if (bfd_debug)  			zlog_debug(  				"%s: Suppressing BFD peer reg/dereg messages", -				__FUNCTION__); +				__func__);  		return;  	} @@ -146,7 +146,7 @@ void bfd_peer_sendmsg(struct zclient *zclient, struct bfd_info *bfd_info,  			zlog_debug(  				"%s: Can't send BFD peer register, Zebra client not "  				"established", -				__FUNCTION__); +				__func__);  		return;  	} @@ -328,7 +328,7 @@ static void bfd_last_update(time_t last_update, char *buf, size_t len)  {  	time_t curr;  	time_t diff; -	struct tm *tm; +	struct tm tm;  	struct timeval tv;  	/* If no BFD satatus update has ever been received, print `never'. */ @@ -341,10 +341,10 @@ static void bfd_last_update(time_t last_update, char *buf, size_t len)  	monotime(&tv);  	curr = tv.tv_sec;  	diff = curr - last_update; -	tm = gmtime(&diff); +	gmtime_r(&diff, &tm); -	snprintf(buf, len, "%d:%02d:%02d:%02d", tm->tm_yday, tm->tm_hour, -		 tm->tm_min, tm->tm_sec); +	snprintf(buf, len, "%d:%02d:%02d:%02d", tm.tm_yday, tm.tm_hour, +		 tm.tm_min, tm.tm_sec);  }  /* @@ -454,7 +454,7 @@ void bfd_client_sendmsg(struct zclient *zclient, int command,  			zlog_debug(  				"%s: Can't send BFD client register, Zebra client not "  				"established", -				__FUNCTION__); +				__func__);  		return;  	} diff --git a/lib/buffer.c b/lib/buffer.c index 766b9791a5..ff49bc83df 100644 --- a/lib/buffer.c +++ b/lib/buffer.c @@ -288,7 +288,7 @@ buffer_status_t buffer_flush_window(struct buffer *b, int fd, int width,  	/* Previously print out is performed. */  	if (erase_flag) {  		iov[iov_index].iov_base = erase; -		iov[iov_index].iov_len = sizeof erase; +		iov[iov_index].iov_len = sizeof(erase);  		iov_index++;  	} @@ -341,7 +341,7 @@ buffer_status_t buffer_flush_window(struct buffer *b, int fd, int width,  	/* In case of `more' display need. */  	if (b->tail && (b->tail->sp < b->tail->cp) && !no_more_flag) {  		iov[iov_index].iov_base = more; -		iov[iov_index].iov_len = sizeof more; +		iov[iov_index].iov_len = sizeof(more);  		iov_index++;  	} diff --git a/lib/filter.c b/lib/filter.c index 80f8cf0bd0..3226fb2f5e 100644 --- a/lib/filter.c +++ b/lib/filter.c @@ -412,7 +412,7 @@ static int64_t filter_new_seq_get(struct access_list *access)  	int64_t newseq;  	struct filter *filter; -	maxseq = newseq = 0; +	maxseq = 0;  	for (filter = access->head; filter; filter = filter->next) {  		if (maxseq < filter->seq) diff --git a/lib/frr_zmq.c b/lib/frr_zmq.c index 7781beae5e..565936a410 100644 --- a/lib/frr_zmq.c +++ b/lib/frr_zmq.c @@ -177,7 +177,7 @@ int funcname_frrzmq_thread_add_read(struct thread_master *master,  	else {  		cb = XCALLOC(MTYPE_ZEROMQ_CB, sizeof(struct frrzmq_cb)); -		cb->write.cancelled = 1; +		cb->write.cancelled = true;  		*cbp = cb;  	} @@ -187,7 +187,7 @@ int funcname_frrzmq_thread_add_read(struct thread_master *master,  	cb->read.cb_msg = msgfunc;  	cb->read.cb_part = partfunc;  	cb->read.cb_error = errfunc; -	cb->read.cancelled = 0; +	cb->read.cancelled = false;  	if (events & ZMQ_POLLIN) {  		if (cb->read.thread) { @@ -285,7 +285,7 @@ int funcname_frrzmq_thread_add_write(struct thread_master *master,  	else {  		cb = XCALLOC(MTYPE_ZEROMQ_CB, sizeof(struct frrzmq_cb)); -		cb->read.cancelled = 1; +		cb->read.cancelled = true;  		*cbp = cb;  	} @@ -295,7 +295,7 @@ int funcname_frrzmq_thread_add_write(struct thread_master *master,  	cb->write.cb_msg = msgfunc;  	cb->write.cb_part = NULL;  	cb->write.cb_error = errfunc; -	cb->write.cancelled = 0; +	cb->write.cancelled = false;  	if (events & ZMQ_POLLOUT) {  		if (cb->write.thread) { @@ -316,7 +316,7 @@ void frrzmq_thread_cancel(struct frrzmq_cb **cb, struct cb_core *core)  {  	if (!cb || !*cb)  		return; -	core->cancelled = 1; +	core->cancelled = true;  	if (core->thread) {  		thread_cancel(core->thread);  		core->thread = NULL; diff --git a/lib/hash.h b/lib/hash.h index 7b3372d433..e7ba3187f5 100644 --- a/lib/hash.h +++ b/lib/hash.h @@ -36,11 +36,6 @@ extern "C" {  #define HASHWALK_CONTINUE 0  #define HASHWALK_ABORT -1 -#if CONFDATE > 20200225 -CPP_NOTICE("hash.h: time to remove hash_backet #define") -#endif -#define hash_backet hash_bucket -  struct hash_bucket {  	/*  	 * if this bucket is the head of the linked listed, len denotes the diff --git a/lib/ipaddr.h b/lib/ipaddr.h index 6bd614044c..c6372f1abb 100644 --- a/lib/ipaddr.h +++ b/lib/ipaddr.h @@ -119,10 +119,13 @@ static inline void ipv4_mapped_ipv6_to_ipv4(struct in6_addr *in6,  	memcpy(in, (char *)in6 + 12, sizeof(struct in_addr));  } +/* + * Check if a struct ipaddr has nonzero value + */  static inline bool ipaddr_isset(struct ipaddr *ip)  {  	static struct ipaddr a = {}; -	return (0 == memcmp(&a, ip, sizeof(struct ipaddr))); +	return (0 != memcmp(&a, ip, sizeof(struct ipaddr)));  }  #ifdef __cplusplus diff --git a/lib/keychain.c b/lib/keychain.c index fc9f0f9cfa..ea512a2699 100644 --- a/lib/keychain.c +++ b/lib/keychain.c @@ -967,12 +967,12 @@ static struct cmd_node keychain_key_node = {KEYCHAIN_KEY_NODE,  static int keychain_strftime(char *buf, int bufsiz, time_t *time)  { -	struct tm *tm; +	struct tm tm;  	size_t len; -	tm = localtime(time); +	localtime_r(time, &tm); -	len = strftime(buf, bufsiz, "%T %b %d %Y", tm); +	len = strftime(buf, bufsiz, "%T %b %d %Y", &tm);  	return len;  } diff --git a/lib/libfrr.c b/lib/libfrr.c index 4fb43edff2..3622890e46 100644 --- a/lib/libfrr.c +++ b/lib/libfrr.c @@ -383,7 +383,7 @@ static int frr_opt(int opt)  		exit(0);  		break;  	case 'd': -		di->daemon_mode = 1; +		di->daemon_mode = true;  		break;  	case 'M':  		oc = XMALLOC(MTYPE_TMP, sizeof(*oc)); @@ -467,12 +467,12 @@ static int frr_opt(int opt)  	case 'C':  		if (di->flags & FRR_NO_CFG_PID_DRY)  			return 1; -		di->dryrun = 1; +		di->dryrun = true;  		break;  	case 't':  		if (di->flags & FRR_NO_CFG_PID_DRY)  			return 1; -		di->terminal = 1; +		di->terminal = true;  		break;  	case 'z':  		di->zpathspace = true; @@ -220,11 +220,11 @@ size_t quagga_timestamp(int timestamp_precision, char *buf, size_t buflen)  	/* first, we update the cache if the time has changed */  	if (cache.last != clock.tv_sec) { -		struct tm *tm; +		struct tm tm;  		cache.last = clock.tv_sec; -		tm = localtime(&cache.last); +		localtime_r(&cache.last, &tm);  		cache.len = strftime(cache.buf, sizeof(cache.buf), -				     "%Y/%m/%d %H:%M:%S", tm); +				     "%Y/%m/%d %H:%M:%S", &tm);  	}  	/* note: it's not worth caching the subsecond part, because  	   chances are that back-to-back calls are not sufficiently close @@ -412,8 +412,8 @@ void hmac_md5(unsigned char *text, int text_len, unsigned char *key,  	 */  	/* start out by storing key in pads */ -	bzero(k_ipad, sizeof k_ipad); -	bzero(k_opad, sizeof k_opad); +	bzero(k_ipad, sizeof(k_ipad)); +	bzero(k_opad, sizeof(k_opad));  	bcopy(key, k_ipad, key_len);  	bcopy(key, k_opad, key_len); 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/module.c b/lib/module.c index 098c550684..14d5cfd44f 100644 --- a/lib/module.c +++ b/lib/module.c @@ -58,7 +58,7 @@ static const char *execname = NULL;  void frrmod_init(struct frrmod_runtime *modinfo)  { -	modinfo->finished_loading = 1; +	modinfo->finished_loading = true;  	*frrmod_last = modinfo;  	frrmod_last = &modinfo->next; @@ -134,7 +134,7 @@ struct frrmod_runtime *frrmod_load(const char *spec, const char *dir, char *err,  		goto out_fail;  	} -	rtinfo->finished_loading = 1; +	rtinfo->finished_loading = true;  	*frrmod_last = rtinfo;  	frrmod_last = &rtinfo->next; diff --git a/lib/nexthop_group.c b/lib/nexthop_group.c index 3005a51c71..d660428bcd 100644 --- a/lib/nexthop_group.c +++ b/lib/nexthop_group.c @@ -216,7 +216,8 @@ struct nexthop_group *nexthop_group_new(void)  	return XCALLOC(MTYPE_NEXTHOP_GROUP, sizeof(struct nexthop_group));  } -void nexthop_group_copy(struct nexthop_group *to, struct nexthop_group *from) +void nexthop_group_copy(struct nexthop_group *to, +			const struct nexthop_group *from)  {  	/* Copy everything, including recursive info */  	copy_nexthops(&to->nexthop, from->nexthop, NULL); diff --git a/lib/nexthop_group.h b/lib/nexthop_group.h index 73b020283a..f99a53f694 100644 --- a/lib/nexthop_group.h +++ b/lib/nexthop_group.h @@ -43,7 +43,7 @@ struct nexthop_group *nexthop_group_new(void);  void nexthop_group_delete(struct nexthop_group **nhg);  void nexthop_group_copy(struct nexthop_group *to, -			struct nexthop_group *from); +			const struct nexthop_group *from);  /*   * Copy a list of nexthops in 'nh' to an nhg, enforcing canonical sort order diff --git a/lib/northbound.c b/lib/northbound.c index 206a88d980..cebedcff09 100644 --- a/lib/northbound.c +++ b/lib/northbound.c @@ -996,7 +996,7 @@ static int nb_transaction_process(enum nb_event event,  		 * Only try to release resources that were allocated  		 * successfully.  		 */ -		if (event == NB_EV_ABORT && change->prepare_ok == false) +		if (event == NB_EV_ABORT && !change->prepare_ok)  			break;  		/* Call the appropriate callback. */ diff --git a/lib/plist.c b/lib/plist.c index 2a3a087cf0..40131aebed 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -387,7 +387,7 @@ static int64_t prefix_new_seq_get(struct prefix_list *plist)  	int64_t newseq;  	struct prefix_list_entry *pentry; -	maxseq = newseq = 0; +	maxseq = 0;  	for (pentry = plist->head; pentry; pentry = pentry->next) {  		if (maxseq < pentry->seq) @@ -2039,7 +2039,7 @@ static void prefix_list_reset_afi(afi_t afi, int orf)  	assert(master->str.head == NULL);  	assert(master->str.tail == NULL); -	master->seqnum = 1; +	master->seqnum = true;  	master->recent = NULL;  } diff --git a/lib/prefix.c b/lib/prefix.c index 2b7727fd0a..80fe0f54a9 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -1082,7 +1082,7 @@ struct prefix *prefix_new(void)  {  	struct prefix *p; -	p = XCALLOC(MTYPE_PREFIX, sizeof *p); +	p = XCALLOC(MTYPE_PREFIX, sizeof(*p));  	return p;  } diff --git a/lib/printf/printf-pos.c b/lib/printf/printf-pos.c index 20a58eacdc..cc03f7ef9a 100644 --- a/lib/printf/printf-pos.c +++ b/lib/printf/printf-pos.c @@ -686,7 +686,7 @@ build_arg_table(struct typetable *types, va_list ap, union arg **argtable)  	if (types->tablemax >= STATIC_ARG_TBL_SIZE) {  		*argtable = (union arg *) -		    malloc (sizeof (union arg) * (types->tablemax + 1)); +		    malloc (sizeof(union arg) * (types->tablemax + 1));  		if (*argtable == NULL)  			return;  	} diff --git a/lib/ptm_lib.c b/lib/ptm_lib.c index 54f027deeb..b66ae221cf 100644 --- a/lib/ptm_lib.c +++ b/lib/ptm_lib.c @@ -143,7 +143,7 @@ int ptm_lib_append_msg(ptm_lib_handle_t *hdl, void *ctxt, const char *key,  	csv_record_t *mh_rec, *rec;  	if (!p_ctxt) { -		ERRLOG("%s: no context \n", __FUNCTION__); +		ERRLOG("%s: no context \n", __func__);  		return -1;  	} @@ -154,7 +154,7 @@ int ptm_lib_append_msg(ptm_lib_handle_t *hdl, void *ctxt, const char *key,  	/* append to the hdr record */  	rec = csv_append_record(csv, rec, 1, key);  	if (!rec) { -		ERRLOG("%s: Could not append key \n", __FUNCTION__); +		ERRLOG("%s: Could not append key \n", __func__);  		return -1;  	} @@ -162,7 +162,7 @@ int ptm_lib_append_msg(ptm_lib_handle_t *hdl, void *ctxt, const char *key,  	/* append to the data record */  	rec = csv_append_record(csv, rec, 1, val);  	if (!rec) { -		ERRLOG("%s: Could not append val \n", __FUNCTION__); +		ERRLOG("%s: Could not append val \n", __func__);  		return -1;  	} @@ -186,7 +186,7 @@ int ptm_lib_init_msg(ptm_lib_handle_t *hdl, int cmd_id, int type, void *in_ctxt,  	csv = csv_init(NULL, NULL, PTMLIB_MSG_SZ);  	if (!csv) { -		ERRLOG("%s: Could not allocate csv \n", __FUNCTION__); +		ERRLOG("%s: Could not allocate csv \n", __func__);  		return -1;  	} @@ -194,7 +194,7 @@ int ptm_lib_init_msg(ptm_lib_handle_t *hdl, int cmd_id, int type, void *in_ctxt,  				     cmd_id, hdl->client_name);  	if (!rec) { -		ERRLOG("%s: Could not allocate record \n", __FUNCTION__); +		ERRLOG("%s: Could not allocate record \n", __func__);  		csv_clean(csv);  		csv_free(csv);  		return -1; @@ -202,7 +202,7 @@ int ptm_lib_init_msg(ptm_lib_handle_t *hdl, int cmd_id, int type, void *in_ctxt,  	p_ctxt = calloc(1, sizeof(*p_ctxt));  	if (!p_ctxt) { -		ERRLOG("%s: Could not allocate context \n", __FUNCTION__); +		ERRLOG("%s: Could not allocate context \n", __func__);  		csv_clean(csv);  		csv_free(csv);  		return -1; @@ -234,7 +234,7 @@ int ptm_lib_cleanup_msg(ptm_lib_handle_t *hdl, void *ctxt)  	csv_t *csv;  	if (!p_ctxt) { -		ERRLOG("%s: no context \n", __FUNCTION__); +		ERRLOG("%s: no context \n", __func__);  		return -1;  	} @@ -254,7 +254,7 @@ int ptm_lib_complete_msg(ptm_lib_handle_t *hdl, void *ctxt, char *buf, int *len)  	csv_record_t *rec;  	if (!p_ctxt) { -		ERRLOG("%s: no context \n", __FUNCTION__); +		ERRLOG("%s: no context \n", __func__);  		return -1;  	} @@ -268,7 +268,7 @@ int ptm_lib_complete_msg(ptm_lib_handle_t *hdl, void *ctxt, char *buf, int *len)  	/* parse csv contents into string */  	if (buf && len) {  		if (csv_serialize(csv, buf, *len)) { -			ERRLOG("%s: cannot serialize\n", __FUNCTION__); +			ERRLOG("%s: cannot serialize\n", __func__);  			return -1;  		}  		*len = csvlen(csv); @@ -425,8 +425,7 @@ int ptm_lib_process_msg(ptm_lib_handle_t *hdl, int fd, char *inbuf, int inlen,  		csv_decode(csv, inbuf);  		p_ctxt = calloc(1, sizeof(*p_ctxt));  		if (!p_ctxt) { -			ERRLOG("%s: Could not allocate context \n", -			       __FUNCTION__); +			ERRLOG("%s: Could not allocate context \n", __func__);  			csv_clean(csv);  			csv_free(csv);  			return -1; diff --git a/lib/routemap.c b/lib/routemap.c index 54b5383173..e2baa36f24 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -2257,7 +2257,7 @@ static void route_map_pentry_update(route_map_event_t event,  	}  } -static void route_map_pentry_process_dependency(struct hash_backet *backet, +static void route_map_pentry_process_dependency(struct hash_bucket *backet,  						void *data)  {  	char *rmap_name = NULL; @@ -2447,7 +2447,7 @@ route_map_result_t route_map_apply(struct route_map *map,  	}  	for (; index; index = index->next) { -		if (skip_match_clause == false) { +		if (!skip_match_clause) {  			/* Apply this index. */  			match_ret = route_map_apply_match(&index->match_list,  							  prefix, type, object); @@ -2684,8 +2684,7 @@ static void route_map_print_dependency(struct hash_bucket *bucket, void *data)  	char *rmap_name = dep_data->rname;  	char *dep_name = data; -	zlog_debug("%s: Dependency for %s: %s", __FUNCTION__, dep_name, -		   rmap_name); +	zlog_debug("%s: Dependency for %s: %s", __func__, dep_name, rmap_name);  }  static int route_map_dep_update(struct hash *dephash, const char *dep_name, 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 c05ec19db4..588a1175bc 100644 --- a/lib/seqlock.c +++ b/lib/seqlock.c @@ -254,7 +254,7 @@ bool seqlock_check(struct seqlock *sqlo, seqlock_val_t val)  	cur = atomic_load_explicit(&sqlo->pos, memory_order_relaxed);  	if (!(cur & SEQLOCK_HELD)) -		return 1; +		return true;  	cur = SEQLOCK_VAL(cur) - val - 1;  	assert(cur < 0x40000000 || cur > 0xc0000000);  	return cur < 0x80000000; diff --git a/lib/skiplist.c b/lib/skiplist.c index 6efa2c362d..67cc1ab378 100644 --- a/lib/skiplist.c +++ b/lib/skiplist.c @@ -378,7 +378,7 @@ int skiplist_next_value(register struct skiplist *l, /* in */  			void **valuePointer,	 /* in/out */  			void **cursor)		     /* in/out */  { -	register int k, m; +	register int k;  	register struct skiplistnode *p, *q;  	CHECKLAST(l); @@ -389,7 +389,7 @@ int skiplist_next_value(register struct skiplist *l, /* in */  	if (!cursor || !*cursor) {  		p = l->header; -		k = m = l->level; +		k = l->level;  		/*  		 * Find matching key diff --git a/lib/sockopt.c b/lib/sockopt.c index d6c88c0aff..45d9008796 100644 --- a/lib/sockopt.c +++ b/lib/sockopt.c @@ -90,12 +90,11 @@ int getsockopt_so_recvbuf(const int sock)  static void *getsockopt_cmsg_data(struct msghdr *msgh, int level, int type)  {  	struct cmsghdr *cmsg; -	void *ptr = NULL;  	for (cmsg = CMSG_FIRSTHDR(msgh); cmsg != NULL;  	     cmsg = CMSG_NXTHDR(msgh, cmsg))  		if (cmsg->cmsg_level == level && cmsg->cmsg_type == type) -			return (ptr = CMSG_DATA(cmsg)); +			return CMSG_DATA(cmsg);  	return NULL;  } @@ -684,7 +683,7 @@ int sockopt_tcp_signature_ext(int sock, union sockunion *su, uint16_t prefixlen,  #endif /* GNU_LINUX */  	if ((ret = setsockopt(sock, IPPROTO_TCP, optname, &md5sig, -			      sizeof md5sig)) +			      sizeof(md5sig)))  	    < 0) {  		/* ENOENT is harmless.  It is returned when we clear a password  		   for which diff --git a/lib/sockopt.h b/lib/sockopt.h index 59d8a65964..4081e6a45b 100644 --- a/lib/sockopt.h +++ b/lib/sockopt.h @@ -39,7 +39,7 @@ extern int setsockopt_ipv6_hoplimit(int, int);  extern int setsockopt_ipv6_multicast_loop(int, int);  extern int setsockopt_ipv6_tclass(int, int); -#define SOPT_SIZE_CMSG_PKTINFO_IPV6() (sizeof (struct in6_pktinfo)); +#define SOPT_SIZE_CMSG_PKTINFO_IPV6() (sizeof(struct in6_pktinfo));  /*   * Size defines for control messages used to get ifindex.  We define @@ -49,7 +49,7 @@ extern int setsockopt_ipv6_tclass(int, int);   */  #if defined(IP_PKTINFO)  /* Linux in_pktinfo. */ -#define SOPT_SIZE_CMSG_PKTINFO_IPV4()  (CMSG_SPACE(sizeof (struct in_pktinfo))) +#define SOPT_SIZE_CMSG_PKTINFO_IPV4()  (CMSG_SPACE(sizeof(struct in_pktinfo)))  /* XXX This should perhaps be defined even if IP_PKTINFO is not. */  #define SOPT_SIZE_CMSG_PKTINFO(af)                                             \    ((af == AF_INET) ? SOPT_SIZE_CMSG_PKTINFO_IPV4() \ @@ -60,9 +60,9 @@ extern int setsockopt_ipv6_tclass(int, int);  /* BSD/Solaris */  #if defined(SUNOS_5) -#define SOPT_SIZE_CMSG_RECVIF_IPV4()  (sizeof (uint_t)) +#define SOPT_SIZE_CMSG_RECVIF_IPV4()  (sizeof(uint_t))  #else -#define SOPT_SIZE_CMSG_RECVIF_IPV4()	(sizeof (struct sockaddr_dl)) +#define SOPT_SIZE_CMSG_RECVIF_IPV4()	(sizeof(struct sockaddr_dl))  #endif /* SUNOS_5 */  #endif /* IP_RECVIF */ @@ -72,7 +72,7 @@ extern int setsockopt_ipv6_tclass(int, int);  #elif defined(SOPT_SIZE_CMSG_RECVIF_IPV4)  #define SOPT_SIZE_CMSG_IFINDEX_IPV4() SOPT_SIZE_CMSG_RECVIF_IPV4()  #else  /* Nothing available */ -#define SOPT_SIZE_CMSG_IFINDEX_IPV4() (sizeof (char *)) +#define SOPT_SIZE_CMSG_IFINDEX_IPV4() (sizeof(char *))  #endif /* SOPT_SIZE_CMSG_IFINDEX_IPV4 */  #define SOPT_SIZE_CMSG_IFINDEX(af)                                             \ diff --git a/lib/sockunion.c b/lib/sockunion.c index e9c418fdf2..63d8a8c69b 100644 --- a/lib/sockunion.c +++ b/lib/sockunion.c @@ -214,7 +214,7 @@ enum connect_result sockunion_connect(int fd, const union sockunion *peersu,  		if (errno != EINPROGRESS) {  			char str[SU_ADDRSTRLEN];  			zlog_info("can't connect to %s fd %d : %s", -				  sockunion_log(&su, str, sizeof str), fd, +				  sockunion_log(&su, str, sizeof(str)), fd,  				  safe_strerror(errno));  			return connect_error;  		} @@ -518,8 +518,8 @@ union sockunion *sockunion_getsockname(int fd)  	} name;  	union sockunion *su; -	memset(&name, 0, sizeof name); -	len = sizeof name; +	memset(&name, 0, sizeof(name)); +	len = sizeof(name);  	ret = getsockname(fd, (struct sockaddr *)&name, &len);  	if (ret < 0) { @@ -556,8 +556,8 @@ union sockunion *sockunion_getpeername(int fd)  	} name;  	union sockunion *su; -	memset(&name, 0, sizeof name); -	len = sizeof name; +	memset(&name, 0, sizeof(name)); +	len = sizeof(name);  	ret = getpeername(fd, (struct sockaddr *)&name, &len);  	if (ret < 0) {  		flog_err(EC_LIB_SOCKET, "Can't get remote address and port: %s", diff --git a/lib/thread.c b/lib/thread.c index 651d26dfb2..2217a60f0a 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -171,7 +171,7 @@ static void cpu_record_print(struct vty *vty, uint8_t filter)  	struct thread_master *m;  	struct listnode *ln; -	memset(&tmp, 0, sizeof tmp); +	memset(&tmp, 0, sizeof(tmp));  	tmp.funcname = "TOTAL";  	tmp.types = filter; @@ -493,8 +493,7 @@ void vrf_init(int (*create)(struct vrf *), int (*enable)(struct vrf *),  	/* initialise NS, in case VRF backend if NETNS */  	ns_init();  	if (debug_vrf) -		zlog_debug("%s: Initializing VRF subsystem", -			   __PRETTY_FUNCTION__); +		zlog_debug("%s: Initializing VRF subsystem", __func__);  	vrf_master.vrf_new_hook = create;  	vrf_master.vrf_enable_hook = enable; @@ -535,8 +534,7 @@ void vrf_terminate(void)  	struct vrf *vrf;  	if (debug_vrf) -		zlog_debug("%s: Shutting down vrf subsystem", -			   __PRETTY_FUNCTION__); +		zlog_debug("%s: Shutting down vrf subsystem", __func__);  	while (!RB_EMPTY(vrf_id_head, &vrfs_by_id)) {  		vrf = RB_ROOT(vrf_id_head, &vrfs_by_id); diff --git a/lib/wheel.c b/lib/wheel.c index 8e479c931b..f5e5cc52c3 100644 --- a/lib/wheel.c +++ b/lib/wheel.c @@ -47,8 +47,8 @@ static int wheel_timer_thread_helper(struct thread *t)  	curr_slot = wheel->curr_slot % wheel->slots;  	if (debug_timer_wheel) -		zlog_debug("%s: Wheel Slot: %lld(%lld) count: %d", -			   __PRETTY_FUNCTION__, wheel->curr_slot, curr_slot, +		zlog_debug("%s: Wheel Slot: %lld(%lld) count: %d", __func__, +			   wheel->curr_slot, curr_slot,  			   listcount(wheel->wheel_slot_lists[curr_slot]));  	for (ALL_LIST_ELEMENTS(wheel->wheel_slot_lists[curr_slot], node, @@ -146,8 +146,8 @@ int wheel_add_item(struct timer_wheel *wheel, void *item)  	slot = (*wheel->slot_key)(item);  	if (debug_timer_wheel) -		zlog_debug("%s: Inserting %p: %lld %lld", __PRETTY_FUNCTION__, -			   item, slot, slot % wheel->slots); +		zlog_debug("%s: Inserting %p: %lld %lld", __func__, item, slot, +			   slot % wheel->slots);  	listnode_add(wheel->wheel_slot_lists[slot % wheel->slots], item);  	return 0; @@ -160,8 +160,8 @@ int wheel_remove_item(struct timer_wheel *wheel, void *item)  	slot = (*wheel->slot_key)(item);  	if (debug_timer_wheel) -		zlog_debug("%s: Removing %p: %lld %lld", __PRETTY_FUNCTION__, -			   item, slot, slot % wheel->slots); +		zlog_debug("%s: Removing %p: %lld %lld", __func__, item, slot, +			   slot % wheel->slots);  	listnode_delete(wheel->wheel_slot_lists[slot % wheel->slots], item);  	return 0; diff --git a/lib/zclient.c b/lib/zclient.c index b0d2ea43a2..eac6c7081d 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -236,9 +236,8 @@ int zclient_socket_connect(struct zclient *zclient)  	ret = connect(sock, (struct sockaddr *)&zclient_addr, zclient_addr_len);  	if (ret < 0) {  		if (zclient_debug) -			zlog_debug("%s connect failure: %d(%s)", -				   __PRETTY_FUNCTION__, errno, -				   safe_strerror(errno)); +			zlog_debug("%s connect failure: %d(%s)", __func__, +				   errno, safe_strerror(errno));  		close(sock);  		return -1;  	} @@ -958,7 +957,7 @@ int zapi_route_encode(uint8_t cmd, struct stream *s, struct zapi_route *api)  	if (api->type >= ZEBRA_ROUTE_MAX) {  		flog_err(EC_LIB_ZAPI_ENCODE,  			 "%s: Specified route type (%u) is not a legal value\n", -			 __PRETTY_FUNCTION__, api->type); +			 __func__, api->type);  		return -1;  	}  	stream_putc(s, api->type); @@ -970,7 +969,7 @@ int zapi_route_encode(uint8_t cmd, struct stream *s, struct zapi_route *api)  	if (api->safi < SAFI_UNICAST || api->safi >= SAFI_MAX) {  		flog_err(EC_LIB_ZAPI_ENCODE,  			 "%s: Specified route SAFI (%u) is not a legal value\n", -			 __PRETTY_FUNCTION__, api->safi); +			 __func__, api->safi);  		return -1;  	}  	stream_putc(s, api->safi); @@ -1122,7 +1121,7 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)  	if (api->type >= ZEBRA_ROUTE_MAX) {  		flog_err(EC_LIB_ZAPI_ENCODE,  			 "%s: Specified route type: %d is not a legal value\n", -			 __PRETTY_FUNCTION__, api->type); +			 __func__, api->type);  		return -1;  	} @@ -1133,7 +1132,7 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)  	if (api->safi < SAFI_UNICAST || api->safi >= SAFI_MAX) {  		flog_err(EC_LIB_ZAPI_ENCODE,  			 "%s: Specified route SAFI (%u) is not a legal value\n", -			 __PRETTY_FUNCTION__, api->safi); +			 __func__, api->safi);  		return -1;  	} @@ -1146,7 +1145,7 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)  			flog_err(  				EC_LIB_ZAPI_ENCODE,  				"%s: V4 prefixlen is %d which should not be more than 32", -				__PRETTY_FUNCTION__, api->prefix.prefixlen); +				__func__, api->prefix.prefixlen);  			return -1;  		}  		break; @@ -1155,14 +1154,14 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)  			flog_err(  				EC_LIB_ZAPI_ENCODE,  				"%s: v6 prefixlen is %d which should not be more than 128", -				__PRETTY_FUNCTION__, api->prefix.prefixlen); +				__func__, api->prefix.prefixlen);  			return -1;  		}  		break;  	default:  		flog_err(EC_LIB_ZAPI_ENCODE, -			 "%s: Specified family %d is not v4 or v6", -			 __PRETTY_FUNCTION__, api->prefix.family); +			 "%s: Specified family %d is not v4 or v6", __func__, +			 api->prefix.family);  		return -1;  	}  	STREAM_GET(&api->prefix.u.prefix, s, PSIZE(api->prefix.prefixlen)); @@ -1174,7 +1173,7 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)  			flog_err(  				EC_LIB_ZAPI_ENCODE,  				"%s: SRC Prefix prefixlen received: %d is too large", -				__PRETTY_FUNCTION__, api->src_prefix.prefixlen); +				__func__, api->src_prefix.prefixlen);  			return -1;  		}  		STREAM_GET(&api->src_prefix.prefix, s, @@ -1185,7 +1184,7 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)  			flog_err(  				EC_LIB_ZAPI_ENCODE,  				"%s: SRC prefix specified in some manner that makes no sense", -				__PRETTY_FUNCTION__); +				__func__);  			return -1;  		}  	} @@ -1309,8 +1308,7 @@ bool zapi_rule_notify_decode(struct stream *s, uint32_t *seqno,  	STREAM_GETL(s, ifi);  	if (zclient_debug) -		zlog_debug("%s: %u %u %u %u", __PRETTY_FUNCTION__, seq, prio, -			   uni, ifi); +		zlog_debug("%s: %u %u %u %u", __func__, seq, prio, uni, ifi);  	*seqno = seq;  	*priority = prio;  	*unique = uni; @@ -1332,7 +1330,7 @@ bool zapi_ipset_notify_decode(struct stream *s, uint32_t *unique,  	STREAM_GETL(s, uni);  	if (zclient_debug) -		zlog_debug("%s: %u", __PRETTY_FUNCTION__, uni); +		zlog_debug("%s: %u", __func__, uni);  	*unique = uni;  	return true; @@ -1354,7 +1352,7 @@ bool zapi_ipset_entry_notify_decode(struct stream *s, uint32_t *unique,  	STREAM_GET(ipset_name, s, ZEBRA_IPSET_NAME_SIZE);  	if (zclient_debug) -		zlog_debug("%s: %u", __PRETTY_FUNCTION__, uni); +		zlog_debug("%s: %u", __func__, uni);  	*unique = uni;  	return true; @@ -1374,7 +1372,7 @@ bool zapi_iptable_notify_decode(struct stream *s,  	STREAM_GETL(s, uni);  	if (zclient_debug) -		zlog_debug("%s: %u", __PRETTY_FUNCTION__, uni); +		zlog_debug("%s: %u", __func__, uni);  	*unique = uni;  	return true; @@ -1978,7 +1976,7 @@ struct connected *zebra_interface_address_read(int type, struct stream *s,  					"warning: interface %s address %s with peer flag set, but no peer address!",  					ifp->name,  					prefix2str(ifc->address, buf, -						   sizeof buf)); +						   sizeof(buf)));  				UNSET_FLAG(ifc->flags, ZEBRA_IFA_PEER);  			}  		} @@ -2664,8 +2662,7 @@ int zapi_labels_decode(struct stream *s, struct zapi_labels *zl)  			if (zl->route.prefix.prefixlen > IPV4_MAX_BITLEN) {  				zlog_debug(  					"%s: Specified prefix length %d is greater than a v4 address can support", -					__PRETTY_FUNCTION__, -					zl->route.prefix.prefixlen); +					__func__, zl->route.prefix.prefixlen);  				return -1;  			}  			STREAM_GET(&zl->route.prefix.u.prefix4.s_addr, s, @@ -2675,8 +2672,7 @@ int zapi_labels_decode(struct stream *s, struct zapi_labels *zl)  			if (zl->route.prefix.prefixlen > IPV6_MAX_BITLEN) {  				zlog_debug(  					"%s: Specified prefix length %d is greater than a v6 address can support", -					__PRETTY_FUNCTION__, -					zl->route.prefix.prefixlen); +					__func__, zl->route.prefix.prefixlen);  				return -1;  			}  			STREAM_GET(&zl->route.prefix.u.prefix6, s, psize); @@ -2684,7 +2680,7 @@ int zapi_labels_decode(struct stream *s, struct zapi_labels *zl)  		default:  			flog_err(EC_LIB_ZAPI_ENCODE,  				 "%s: Specified family %u is not v4 or v6", -				 __PRETTY_FUNCTION__, zl->route.prefix.family); +				 __func__, zl->route.prefix.family);  			return -1;  		} diff --git a/nhrpd/nhrp_cache.c b/nhrpd/nhrp_cache.c index ad478bab97..d7ab897d23 100644 --- a/nhrpd/nhrp_cache.c +++ b/nhrpd/nhrp_cache.c @@ -257,7 +257,7 @@ static void nhrp_cache_authorize_binding(struct nhrp_reqid *r, void *arg)  	char buf[3][SU_ADDRSTRLEN];  	debugf(NHRP_DEBUG_COMMON, "cache: %s %s: %s", c->ifp->name, -	       sockunion2str(&c->remote_addr, buf[0], sizeof buf[0]), +	       sockunion2str(&c->remote_addr, buf[0], sizeof(buf[0])),  	       (const char *)arg);  	nhrp_reqid_free(&nhrp_event_reqid, r); @@ -377,7 +377,7 @@ int nhrp_cache_update_binding(struct nhrp_cache *c, enum nhrp_cache_type type,  			c->cur.remote_nbma_natoa = *nbma_oa;  		else  			memset(&c->cur.remote_nbma_natoa, 0, -			       sizeof c->cur.remote_nbma_natoa); +			       sizeof(c->cur.remote_nbma_natoa));  		nhrp_peer_unref(p);  	} else {  		debugf(NHRP_DEBUG_COMMON, diff --git a/nhrpd/nhrp_event.c b/nhrpd/nhrp_event.c index 9301c2d515..40efeb5795 100644 --- a/nhrpd/nhrp_event.c +++ b/nhrpd/nhrp_event.c @@ -200,7 +200,7 @@ static int evmgr_reconnect(struct thread *t)  	fd = sock_open_unix(nhrp_event_socket_path);  	if (fd < 0) {  		zlog_warn("%s: failure connecting nhrp-event socket: %s", -			  __PRETTY_FUNCTION__, strerror(errno)); +			  __func__, strerror(errno));  		zbufq_reset(&evmgr->obuf);  		thread_add_timer(master, evmgr_reconnect, evmgr, 10,  				 &evmgr->t_reconnect); diff --git a/nhrpd/nhrp_interface.c b/nhrpd/nhrp_interface.c index 7cf8dfbde4..1e576fc5ac 100644 --- a/nhrpd/nhrp_interface.c +++ b/nhrpd/nhrp_interface.c @@ -112,7 +112,7 @@ static void nhrp_interface_interface_notifier(struct notifier_block *n,  			      NOTIFY_INTERFACE_NBMA_CHANGED);  		debugf(NHRP_DEBUG_IF, "%s: NBMA change: address %s",  		       nifp->ifp->name, -		       sockunion2str(&nifp->nbma, buf, sizeof buf)); +		       sockunion2str(&nifp->nbma, buf, sizeof(buf)));  		break;  	}  } @@ -221,7 +221,7 @@ static void nhrp_interface_update_address(struct interface *ifp, afi_t afi,  	if (best && if_ad->configured  	    && best->address->prefixlen != 8 * prefix_blen(best->address)) {  		zlog_notice("%s: %s is not a host prefix", ifp->name, -			    prefix2str(best->address, buf, sizeof buf)); +			    prefix2str(best->address, buf, sizeof(buf)));  		best = NULL;  	} @@ -243,7 +243,7 @@ static void nhrp_interface_update_address(struct interface *ifp, afi_t afi,  	debugf(NHRP_DEBUG_KERNEL, "%s: IPv%d address changed to %s", ifp->name,  	       afi == AFI_IP ? 4 : 6, -	       best ? prefix2str(best->address, buf, sizeof buf) : "(none)"); +	       best ? prefix2str(best->address, buf, sizeof(buf)) : "(none)");  	if_ad->addr = addr;  	if (if_ad->configured && sockunion_family(&if_ad->addr) != AF_UNSPEC) { @@ -342,7 +342,7 @@ int nhrp_interface_address_add(ZAPI_CALLBACK_ARGS)  		return 0;  	debugf(NHRP_DEBUG_IF, "if-addr-add: %s: %s", ifc->ifp->name, -	       prefix2str(ifc->address, buf, sizeof buf)); +	       prefix2str(ifc->address, buf, sizeof(buf)));  	nhrp_interface_update_address(  		ifc->ifp, family2afi(PREFIX_FAMILY(ifc->address)), 0); @@ -360,7 +360,7 @@ int nhrp_interface_address_delete(ZAPI_CALLBACK_ARGS)  		return 0;  	debugf(NHRP_DEBUG_IF, "if-addr-del: %s: %s", ifc->ifp->name, -	       prefix2str(ifc->address, buf, sizeof buf)); +	       prefix2str(ifc->address, buf, sizeof(buf)));  	nhrp_interface_update_address(  		ifc->ifp, family2afi(PREFIX_FAMILY(ifc->address)), 0); diff --git a/nhrpd/nhrp_nhs.c b/nhrpd/nhrp_nhs.c index bec6c014a0..8509cedcee 100644 --- a/nhrpd/nhrp_nhs.c +++ b/nhrpd/nhrp_nhs.c @@ -136,7 +136,7 @@ static void nhrp_reg_peer_notify(struct notifier_block *n, unsigned long cmd)  	case NOTIFY_PEER_MTU_CHANGED:  		debugf(NHRP_DEBUG_COMMON, "NHS: Flush timer for %s",  		       sockunion2str(&r->peer->vc->remote.nbma, buf, -				     sizeof buf)); +				     sizeof(buf)));  		THREAD_TIMER_OFF(r->t_register);  		thread_add_timer_msec(master, nhrp_reg_send_req, r, 10,  				      &r->t_register); @@ -162,7 +162,7 @@ static int nhrp_reg_send_req(struct thread *t)  	if (!nhrp_peer_check(r->peer, 2)) {  		debugf(NHRP_DEBUG_COMMON, "NHS: Waiting link for %s",  		       sockunion2str(&r->peer->vc->remote.nbma, buf1, -				     sizeof buf1)); +				     sizeof(buf1)));  		thread_add_timer(master, nhrp_reg_send_req, r, 120,  				 &r->t_register);  		return 0; diff --git a/nhrpd/nhrp_peer.c b/nhrpd/nhrp_peer.c index 90f0986eba..471a138f98 100644 --- a/nhrpd/nhrp_peer.c +++ b/nhrpd/nhrp_peer.c @@ -305,8 +305,8 @@ void nhrp_peer_send(struct nhrp_peer *p, struct zbuf *zb)  		return;  	debugf(NHRP_DEBUG_KERNEL, "PACKET: Send %s -> %s", -	       sockunion2str(&p->vc->local.nbma, buf[0], sizeof buf[0]), -	       sockunion2str(&p->vc->remote.nbma, buf[1], sizeof buf[1])); +	       sockunion2str(&p->vc->local.nbma, buf[0], sizeof(buf[0])), +	       sockunion2str(&p->vc->remote.nbma, buf[1], sizeof(buf[1])));  	os_sendmsg(zb->head, zbuf_used(zb), p->ifp->ifindex,  		   sockunion_get_addr(&p->vc->remote.nbma), @@ -650,15 +650,15 @@ void nhrp_peer_send_indication(struct interface *ifp, uint16_t protocol_type,  		debugf(NHRP_DEBUG_COMMON,  		       "Send Traffic Indication to %s about packet to %s ignored",  		       sockunion2str(&p->vc->remote.nbma, buf[0], -				     sizeof buf[0]), -		       sockunion2str(&dst, buf[1], sizeof buf[1])); +				     sizeof(buf[0])), +		       sockunion2str(&dst, buf[1], sizeof(buf[1])));  		return;  	}  	debugf(NHRP_DEBUG_COMMON,  	       "Send Traffic Indication to %s (online=%d) about packet to %s", -	       sockunion2str(&p->vc->remote.nbma, buf[0], sizeof buf[0]), -	       p->online, sockunion2str(&dst, buf[1], sizeof buf[1])); +	       sockunion2str(&p->vc->remote.nbma, buf[0], sizeof(buf[0])), +	       p->online, sockunion2str(&dst, buf[1], sizeof(buf[1])));  	/* Create reply */  	zb = zbuf_alloc(1500); @@ -688,8 +688,8 @@ static void nhrp_handle_error_ind(struct nhrp_packet_parser *pp)  	debugf(NHRP_DEBUG_COMMON,  	       "Error Indication from %s about packet to %s ignored", -	       sockunion2str(&pp->src_proto, buf[0], sizeof buf[0]), -	       sockunion2str(&dst_proto, buf[1], sizeof buf[1])); +	       sockunion2str(&pp->src_proto, buf[0], sizeof(buf[0])), +	       sockunion2str(&dst_proto, buf[1], sizeof(buf[1])));  	reqid = nhrp_reqid_lookup(&nhrp_packet_reqid, htonl(hdr->u.request_id));  	if (reqid) @@ -707,8 +707,8 @@ static void nhrp_handle_traffic_ind(struct nhrp_packet_parser *p)  	debugf(NHRP_DEBUG_COMMON,  	       "Traffic Indication from %s about packet to %s: %s", -	       sockunion2str(&p->src_proto, buf[0], sizeof buf[0]), -	       sockunion2str(&dst, buf[1], sizeof buf[1]), +	       sockunion2str(&p->src_proto, buf[0], sizeof(buf[0])), +	       sockunion2str(&dst, buf[1], sizeof(buf[1])),  	       (p->if_ad->flags & NHRP_IFF_SHORTCUT) ? "trying shortcut"  						     : "ignored"); @@ -821,10 +821,9 @@ static void nhrp_peer_forward(struct nhrp_peer *p,  			if ((type == NHRP_EXTENSION_REVERSE_TRANSIT_NHS)  			    == (packet_types[hdr->type].type == PACKET_REPLY)) {  				/* Check NHS list for forwarding loop */ -				while ((cie = nhrp_cie_pull(&extpl, pp->hdr, -							    &cie_nbma, -							    &cie_protocol)) -				       != NULL) { +				while (nhrp_cie_pull(&extpl, pp->hdr, +						     &cie_nbma, +						     &cie_protocol) != NULL) {  					if (sockunion_same(&p->vc->remote.nbma,  							   &cie_nbma))  						goto err; @@ -876,8 +875,8 @@ static void nhrp_packet_debug(struct zbuf *zb, const char *dir)  	zbuf_init(&zhdr, zb->buf, zb->tail - zb->buf, zb->tail - zb->buf);  	hdr = nhrp_packet_pull(&zhdr, &src_nbma, &src_proto, &dst_proto); -	sockunion2str(&src_proto, buf[0], sizeof buf[0]); -	sockunion2str(&dst_proto, buf[1], sizeof buf[1]); +	sockunion2str(&src_proto, buf[0], sizeof(buf[0])); +	sockunion2str(&dst_proto, buf[1], sizeof(buf[1]));  	reply = packet_types[hdr->type].type == PACKET_REPLY;  	debugf(NHRP_DEBUG_COMMON, "%s %s(%d) %s -> %s", dir, @@ -919,8 +918,8 @@ void nhrp_peer_recv(struct nhrp_peer *p, struct zbuf *zb)  	afi_t nbma_afi, proto_afi;  	debugf(NHRP_DEBUG_KERNEL, "PACKET: Recv %s -> %s", -	       sockunion2str(&vc->remote.nbma, buf[0], sizeof buf[0]), -	       sockunion2str(&vc->local.nbma, buf[1], sizeof buf[1])); +	       sockunion2str(&vc->remote.nbma, buf[0], sizeof(buf[0])), +	       sockunion2str(&vc->local.nbma, buf[1], sizeof(buf[1])));  	if (!p->online) {  		info = "peer not online"; @@ -952,7 +951,7 @@ void nhrp_peer_recv(struct nhrp_peer *p, struct zbuf *zb)  	    || htons(hdr->packet_size) > realsize) {  		zlog_info(  			"From %s: error: packet type %d, version %d, AFI %d, proto %x, size %d (real size %d)", -			sockunion2str(&vc->remote.nbma, buf[0], sizeof buf[0]), +			sockunion2str(&vc->remote.nbma, buf[0], sizeof(buf[0])),  			(int)hdr->type, (int)hdr->version, (int)nbma_afi,  			(int)htons(hdr->protocol_type),  			(int)htons(hdr->packet_size), (int)realsize); @@ -1033,7 +1032,7 @@ drop:  	if (info) {  		zlog_info(  			"From %s: error: %s", -			sockunion2str(&vc->remote.nbma, buf[0], sizeof buf[0]), +			sockunion2str(&vc->remote.nbma, buf[0], sizeof(buf[0])),  			info);  	}  	if (peer) diff --git a/nhrpd/nhrp_route.c b/nhrpd/nhrp_route.c index a23ac34745..f242c2e367 100644 --- a/nhrpd/nhrp_route.c +++ b/nhrpd/nhrp_route.c @@ -220,8 +220,8 @@ int nhrp_route_read(ZAPI_CALLBACK_ARGS)  	added = (cmd == ZEBRA_REDISTRIBUTE_ROUTE_ADD);  	debugf(NHRP_DEBUG_ROUTE, "if-route-%s: %s via %s dev %s",  	       added ? "add" : "del", -	       prefix2str(&api.prefix, buf[0], sizeof buf[0]), -	       sockunion2str(&nexthop_addr, buf[1], sizeof buf[1]), +	       prefix2str(&api.prefix, buf[0], sizeof(buf[0])), +	       sockunion2str(&nexthop_addr, buf[1], sizeof(buf[1])),  	       ifp ? ifp->name : "(none)");  	nhrp_route_update_zebra(&api.prefix, &nexthop_addr, ifp); @@ -248,7 +248,7 @@ int nhrp_route_get_nexthop(const union sockunion *addr, struct prefix *p,  	ri = rn->info;  	if (ri->nhrp_ifp) {  		debugf(NHRP_DEBUG_ROUTE, "lookup %s: nhrp_if=%s", -		       prefix2str(&lookup, buf, sizeof buf), +		       prefix2str(&lookup, buf, sizeof(buf)),  		       ri->nhrp_ifp->name);  		if (via) @@ -257,7 +257,7 @@ int nhrp_route_get_nexthop(const union sockunion *addr, struct prefix *p,  			*ifp = ri->nhrp_ifp;  	} else {  		debugf(NHRP_DEBUG_ROUTE, "lookup %s: zebra route dev %s", -		       prefix2str(&lookup, buf, sizeof buf), +		       prefix2str(&lookup, buf, sizeof(buf)),  		       ri->ifp ? ri->ifp->name : "(none)");  		if (via) diff --git a/nhrpd/nhrp_shortcut.c b/nhrpd/nhrp_shortcut.c index cd53a391c1..561645e2bd 100644 --- a/nhrpd/nhrp_shortcut.c +++ b/nhrpd/nhrp_shortcut.c @@ -32,7 +32,7 @@ static void nhrp_shortcut_check_use(struct nhrp_shortcut *s)  	if (s->expiring && s->cache && s->cache->used) {  		debugf(NHRP_DEBUG_ROUTE, "Shortcut %s used and expiring", -		       prefix2str(s->p, buf, sizeof buf)); +		       prefix2str(s->p, buf, sizeof(buf)));  		nhrp_shortcut_send_resolution_req(s);  	}  } @@ -162,7 +162,7 @@ static void nhrp_shortcut_delete(struct nhrp_shortcut *s)  	nhrp_reqid_free(&nhrp_packet_reqid, &s->reqid);  	debugf(NHRP_DEBUG_ROUTE, "Shortcut %s purged", -	       prefix2str(s->p, buf, sizeof buf)); +	       prefix2str(s->p, buf, sizeof(buf)));  	nhrp_shortcut_update_binding(s, NHRP_CACHE_INVALID, NULL, 0); @@ -202,7 +202,7 @@ static struct nhrp_shortcut *nhrp_shortcut_get(struct prefix *p)  		s->p = &rn->p;  		debugf(NHRP_DEBUG_ROUTE, "Shortcut %s created", -		       prefix2str(s->p, buf, sizeof buf)); +		       prefix2str(s->p, buf, sizeof(buf)));  	} else {  		s = rn->info;  		route_unlock_node(rn); @@ -246,7 +246,7 @@ static void nhrp_shortcut_recv_resolution_rep(struct nhrp_reqid *reqid,  	}  	/* Parse extensions */ -	memset(&nat_nbma, 0, sizeof nat_nbma); +	memset(&nat_nbma, 0, sizeof(nat_nbma));  	while ((ext = nhrp_ext_pull(&pp->extensions, &extpl)) != NULL) {  		switch (htons(ext->type) & ~NHRP_EXTENSION_FLAG_COMPULSORY) {  		case NHRP_EXTENSION_NAT_ADDRESS: @@ -260,8 +260,8 @@ static void nhrp_shortcut_recv_resolution_rep(struct nhrp_reqid *reqid,  	if (!sockunion_same(&cie_proto, &pp->dst_proto)) {  		debugf(NHRP_DEBUG_COMMON,  		       "Shortcut: Warning dst_proto altered from %s to %s", -		       sockunion2str(&cie_proto, buf[0], sizeof buf[0]), -		       sockunion2str(&pp->dst_proto, buf[1], sizeof buf[1])); +		       sockunion2str(&cie_proto, buf[0], sizeof(buf[0])), +		       sockunion2str(&pp->dst_proto, buf[1], sizeof(buf[1])));  	}  	/* One or more CIEs should be given as reply, we support only one */ @@ -291,9 +291,8 @@ static void nhrp_shortcut_recv_resolution_rep(struct nhrp_reqid *reqid,  	}  	debugf(NHRP_DEBUG_COMMON, -	       "Shortcut: %s is at proto %s dst_proto %s cie-nbma %s nat-nbma " -	       "%s cie-holdtime %d", -	       prefix2str(&prefix, bufp, sizeof bufp), +	       "Shortcut: %s is at proto %s dst_proto %s cie-nbma %s nat-nbma %s cie-holdtime %d", +	       prefix2str(&prefix, bufp, sizeof(bufp)),  	       sockunion2str(proto, buf[0], sizeof(buf[0])),  	       sockunion2str(&pp->dst_proto, buf[1], sizeof(buf[1])),  	       sockunion2str(&cie_nbma, buf[2], sizeof(buf[2])), diff --git a/nhrpd/nhrp_vc.c b/nhrpd/nhrp_vc.c index 605aa34ff9..6567b231a9 100644 --- a/nhrpd/nhrp_vc.c +++ b/nhrpd/nhrp_vc.c @@ -142,8 +142,8 @@ int nhrp_vc_ipsec_updown(uint32_t child_id, struct nhrp_vc *vc)  		sa->vc->abort_migration = 0;  		debugf(NHRP_DEBUG_COMMON, "IPsec NBMA change of %s to %s",  		       sockunion2str(&sa->vc->remote.nbma, buf[0], -				     sizeof buf[0]), -		       sockunion2str(&vc->remote.nbma, buf[1], sizeof buf[1])); +				     sizeof(buf[0])), +		       sockunion2str(&vc->remote.nbma, buf[1], sizeof(buf[1])));  		nhrp_vc_update(sa->vc, NOTIFY_VC_IPSEC_UPDATE_NBMA);  		abort_migration = sa->vc->abort_migration;  	} diff --git a/nhrpd/nhrp_vty.c b/nhrpd/nhrp_vty.c index 8438f3cb4a..f6d18fb77f 100644 --- a/nhrpd/nhrp_vty.c +++ b/nhrpd/nhrp_vty.c @@ -613,9 +613,9 @@ static void show_ip_nhrp_cache(struct nhrp_cache *c, void *pctx)  	vty_out(ctx->vty, "%-8s %-8s %-24s %-24s %c%c%c    %s\n", c->ifp->name,  		nhrp_cache_type_str[c->cur.type], -		sockunion2str(&c->remote_addr, buf[0], sizeof buf[0]), +		sockunion2str(&c->remote_addr, buf[0], sizeof(buf[0])),  		c->cur.peer ? sockunion2str(&c->cur.peer->vc->remote.nbma, -					    buf[1], sizeof buf[1]) +					    buf[1], sizeof(buf[1]))  			    : "-",  		c->used ? 'U' : ' ', c->t_timeout ? 'T' : ' ',  		c->t_auth ? 'A' : ' ', @@ -637,10 +637,10 @@ static void show_ip_nhrp_nhs(struct nhrp_nhs *n, struct nhrp_registration *reg,  	vty_out(vty, "%-8s %-24s %-16s %-16s\n", n->ifp->name, n->nbma_fqdn,  		(reg && reg->peer) ? sockunion2str(®->peer->vc->remote.nbma, -						   buf[0], sizeof buf[0]) +						   buf[0], sizeof(buf[0]))  				   : "-",  		sockunion2str(reg ? ®->proto_addr : &n->proto_addr, buf[1], -			      sizeof buf[1])); +			      sizeof(buf[1])));  }  static void show_ip_nhrp_shortcut(struct nhrp_shortcut *s, void *pctx) @@ -658,8 +658,8 @@ static void show_ip_nhrp_shortcut(struct nhrp_shortcut *s, void *pctx)  	c = s->cache;  	vty_out(ctx->vty, "%-8s %-24s %-24s %s\n", nhrp_cache_type_str[s->type], -		prefix2str(s->p, buf1, sizeof buf1), -		c ? sockunion2str(&c->remote_addr, buf2, sizeof buf2) : "", +		prefix2str(s->p, buf1, sizeof(buf1)), +		c ? sockunion2str(&c->remote_addr, buf2, sizeof(buf2)) : "",  		(c && c->cur.peer) ? c->cur.peer->vc->remote.id : "");  } @@ -678,19 +678,19 @@ static void show_ip_opennhrp_cache(struct nhrp_cache *c, void *pctx)  		nhrp_cache_type_str[c->cur.type],  		(c->cur.peer && c->cur.peer->online) ? " up" : "",  		c->used ? " used" : "", -		sockunion2str(&c->remote_addr, buf, sizeof buf), +		sockunion2str(&c->remote_addr, buf, sizeof(buf)),  		8 * family2addrsize(sockunion_family(&c->remote_addr)));  	if (c->cur.peer) {  		vty_out(ctx->vty, "NBMA-Address: %s\n",  			sockunion2str(&c->cur.peer->vc->remote.nbma, buf, -				      sizeof buf)); +				      sizeof(buf)));  	}  	if (sockunion_family(&c->cur.remote_nbma_natoa) != AF_UNSPEC) {  		vty_out(ctx->vty, "NBMA-NAT-OA-Address: %s\n",  			sockunion2str(&c->cur.remote_nbma_natoa, buf, -				      sizeof buf)); +				      sizeof(buf)));  	}  	vty_out(ctx->vty, "\n\n"); @@ -741,8 +741,8 @@ static void show_dmvpn_entry(struct nhrp_vc *vc, void *ctx)  	char buf[2][SU_ADDRSTRLEN];  	vty_out(vty, "%-24s %-24s %c      %-4d %-24s\n", -		sockunion2str(&vc->local.nbma, buf[0], sizeof buf[0]), -		sockunion2str(&vc->remote.nbma, buf[1], sizeof buf[1]), +		sockunion2str(&vc->local.nbma, buf[0], sizeof(buf[0])), +		sockunion2str(&vc->remote.nbma, buf[1], sizeof(buf[1])),  		notifier_active(&vc->notifier_list) ? 'n' : ' ', vc->ipsec,  		vc->remote.id);  } @@ -824,11 +824,11 @@ static void interface_config_write_nhrp_map(struct nhrp_cache *c, void *data)  		return;  	vty_out(vty, " %s nhrp map %s %s\n", ctx->aficmd, -		sockunion2str(&c->remote_addr, buf[0], sizeof buf[0]), +		sockunion2str(&c->remote_addr, buf[0], sizeof(buf[0])),  		c->cur.type == NHRP_CACHE_LOCAL  			? "local"  			: sockunion2str(&c->cur.peer->vc->remote.nbma, buf[1], -					sizeof buf[1])); +					sizeof(buf[1])));  }  static int interface_config_write(struct vty *vty) @@ -904,7 +904,7 @@ static int interface_config_write(struct vty *vty)  						? "dynamic"  						: sockunion2str(  							  &nhs->proto_addr, buf, -							  sizeof buf), +							  sizeof(buf)),  					nhs->nbma_fqdn);  			}  		} diff --git a/nhrpd/vici.c b/nhrpd/vici.c index d6105b71d4..2dc05a4aa7 100644 --- a/nhrpd/vici.c +++ b/nhrpd/vici.c @@ -303,7 +303,7 @@ static void vici_recv_sa(struct vici_conn *vici, struct zbuf *msg, int event)  	if (ctx.kill_ikesa && ctx.ike_uniqueid) {  		debugf(NHRP_DEBUG_COMMON, "VICI: Deleting IKE_SA %u",  		       ctx.ike_uniqueid); -		snprintf(buf, sizeof buf, "%u", ctx.ike_uniqueid); +		snprintf(buf, sizeof(buf), "%u", ctx.ike_uniqueid);  		vici_submit_request(vici, "terminate", VICI_KEY_VALUE, "ike-id",  				    strlen(buf), buf, VICI_END);  	} @@ -481,8 +481,8 @@ static int vici_reconnect(struct thread *t)  	fd = sock_open_unix("/var/run/charon.vici");  	if (fd < 0) {  		debugf(NHRP_DEBUG_VICI, -		       "%s: failure connecting VICI socket: %s", -		       __PRETTY_FUNCTION__, strerror(errno)); +		       "%s: failure connecting VICI socket: %s", __func__, +		       strerror(errno));  		thread_add_timer(master, vici_reconnect, vici, 2,  				 &vici->t_reconnect);  		return 0; @@ -527,8 +527,8 @@ void vici_request_vc(const char *profile, union sockunion *src,  	struct vici_conn *vici = &vici_connection;  	char buf[2][SU_ADDRSTRLEN]; -	sockunion2str(src, buf[0], sizeof buf[0]); -	sockunion2str(dst, buf[1], sizeof buf[1]); +	sockunion2str(src, buf[0], sizeof(buf[0])); +	sockunion2str(dst, buf[1], sizeof(buf[1]));  	vici_submit_request(vici, "initiate", VICI_KEY_VALUE, "child",  			    strlen(profile), profile, VICI_KEY_VALUE, "timeout", diff --git a/ospf6d/ospf6_abr.c b/ospf6d/ospf6_abr.c index ff82bb1798..ead186b6fc 100644 --- a/ospf6d/ospf6_abr.c +++ b/ospf6d/ospf6_abr.c @@ -232,8 +232,8 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,  							&route->prefix)), buf,  						  sizeof(buf));  					zlog_debug( -						"%s: route %s with cost %u is not best, ignore." -						, __PRETTY_FUNCTION__, buf, +						"%s: route %s with cost %u is not best, ignore.", +						__func__, buf,  						route->path.cost);  				}  				return 0; @@ -246,9 +246,10 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,  				if (is_debug) {  					prefix2str(&route->prefix, buf,  						   sizeof(buf)); -					zlog_debug("%s: intra-prefix route %s with cost %u is not best, ignore." -					   , __PRETTY_FUNCTION__, buf, -					   route->path.cost); +					zlog_debug( +						"%s: intra-prefix route %s with cost %u is not best, ignore.", +						__func__, buf, +						route->path.cost);  				}  				return 0;  			} @@ -762,11 +763,13 @@ void ospf6_abr_old_path_update(struct ospf6_route *old_route,  		}  		if (IS_OSPF6_DEBUG_ABR || IS_OSPF6_DEBUG_EXAMIN(INTER_PREFIX)) -			zlog_debug("%s: paths %u nh %u", __PRETTY_FUNCTION__, -				   old_route->paths ? -				   listcount(old_route->paths) : 0, -				   old_route->nh_list ? -				   listcount(old_route->nh_list) : 0); +			zlog_debug("%s: paths %u nh %u", __func__, +				   old_route->paths +					   ? listcount(old_route->paths) +					   : 0, +				   old_route->nh_list +					   ? listcount(old_route->nh_list) +					   : 0);  		if (table->hook_add)  			(*table->hook_add)(old_route); @@ -822,9 +825,10 @@ void ospf6_abr_old_route_remove(struct ospf6_lsa *lsa,  					prefix2str(&old->prefix, buf,  						   sizeof(buf));  					zlog_debug("%s: old %s updated nh %u", -						   __PRETTY_FUNCTION__, buf, -						   old->nh_list ? -						   listcount(old->nh_list) : 0); +						   __func__, buf, +						   old->nh_list ? listcount( +							   old->nh_list) +								: 0);  				}  				if (table->hook_add) @@ -878,8 +882,8 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)  	if (lsa->header->type == htons(OSPF6_LSTYPE_INTER_PREFIX)) {  		if (IS_OSPF6_DEBUG_EXAMIN(INTER_PREFIX)) {  			is_debug++; -			zlog_debug("%s: Examin %s in area %s", -				   __PRETTY_FUNCTION__, lsa->name, oa->name); +			zlog_debug("%s: Examin %s in area %s", __func__, +				   lsa->name, oa->name);  		}  		prefix_lsa = @@ -898,8 +902,8 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)  	} else if (lsa->header->type == htons(OSPF6_LSTYPE_INTER_ROUTER)) {  		if (IS_OSPF6_DEBUG_EXAMIN(INTER_ROUTER)) {  			is_debug++; -			zlog_debug("%s: Examin %s in area %s", -				   __PRETTY_FUNCTION__, lsa->name, oa->name); +			zlog_debug("%s: Examin %s in area %s", __func__, +				   lsa->name, oa->name);  		}  		router_lsa = @@ -946,9 +950,10 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)  						old = route;  						if (is_debug) -							zlog_debug("%s: old entry found in paths, adv_router %s", -							__PRETTY_FUNCTION__, -							adv_router); +							zlog_debug( +								"%s: old entry found in paths, adv_router %s", +								__func__, +								adv_router);  						break;  					} @@ -973,8 +978,8 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)  	}  	if (OSPF6_LSA_IS_MAXAGE(lsa)) {  		if (is_debug) -			zlog_debug("%s: LSA %s is MaxAge, ignore", -				   __PRETTY_FUNCTION__, lsa->name); +			zlog_debug("%s: LSA %s is MaxAge, ignore", __func__, +				   lsa->name);  		if (old)  			ospf6_abr_old_route_remove(lsa, old, table);  		return; @@ -1053,21 +1058,21 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)  	    || CHECK_FLAG(abr_entry->flag, OSPF6_ROUTE_REMOVE)  	    || !CHECK_FLAG(abr_entry->path.router_bits, OSPF6_ROUTER_BIT_B)) {  		if (is_debug) -			zlog_debug("%s: ABR router entry does not exist, ignore", -				   __PRETTY_FUNCTION__); +			zlog_debug( +				"%s: ABR router entry does not exist, ignore", +				__func__);  		if (old) {  			if (old->type == OSPF6_DEST_TYPE_ROUTER &&  			    oa->intra_brouter_calc) {  				if (is_debug)  					zlog_debug( -						   "%s: intra_brouter_calc is on, skip brouter remove: %s (%p)", -						   __PRETTY_FUNCTION__, buf, -						   (void *)old); +						"%s: intra_brouter_calc is on, skip brouter remove: %s (%p)", +						__func__, buf, (void *)old);  			} else {  				if (is_debug) -					zlog_debug("%s: remove old entry: %s %p ", -						   __PRETTY_FUNCTION__, buf, -						   (void *)old); +					zlog_debug( +						"%s: remove old entry: %s %p ", +						__func__, buf, (void *)old);  				ospf6_route_remove(old, table);  			}  		} @@ -1142,11 +1147,10 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)  		if ((ospf6_route_cmp(route, old_route) != 0)) {  			if (is_debug) {  				prefix2str(&prefix, buf, sizeof(buf)); -				zlog_debug("%s: old %p %s cost %u new route cost %u are not same", -					   __PRETTY_FUNCTION__, -					   (void *)old_route, buf, -					   old_route->path.cost, -					   route->path.cost); +				zlog_debug( +					"%s: old %p %s cost %u new route cost %u are not same", +					__func__, (void *)old_route, buf, +					old_route->path.cost, route->path.cost);  			}  			/* Check new route's adv. router is same in one of @@ -1185,14 +1189,15 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)  				inet_ntop(AF_INET,  					  &ecmp_path->origin.adv_router,  					  adv_router, sizeof(adv_router)); -				zlog_debug("%s: route %s cost %u another path %s added with nh %u, effective paths %u nh %u", -						__PRETTY_FUNCTION__, buf, -						old_route->path.cost, -						adv_router, -						listcount(ecmp_path->nh_list), -						old_route->paths ? -						listcount(old_route->paths) : 0, -						listcount(old_route->nh_list)); +				zlog_debug( +					"%s: route %s cost %u another path %s added with nh %u, effective paths %u nh %u", +					__func__, buf, old_route->path.cost, +					adv_router, +					listcount(ecmp_path->nh_list), +					old_route->paths +						? listcount(old_route->paths) +						: 0, +					listcount(old_route->nh_list));  			}  		} else {  			/* adv. router exists in the list, update the nhs */ @@ -1201,10 +1206,11 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)  		}  		if (is_debug) -			zlog_debug("%s: Update route: %s %p old cost %u new cost %u nh %u", -				   __PRETTY_FUNCTION__, buf, (void *)old_route, -				   old_route->path.cost, route->path.cost, -				   listcount(route->nh_list)); +			zlog_debug( +				"%s: Update route: %s %p old cost %u new cost %u nh %u", +				__func__, buf, (void *)old_route, +				old_route->path.cost, route->path.cost, +				listcount(route->nh_list));  		/* For Inter-Prefix route: Update RIB/FIB,  		 * For Inter-Router trigger summary update @@ -1221,9 +1227,10 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)  		if (is_debug) {  			inet_ntop(AF_INET, &route->path.origin.adv_router,  				  adv_router, sizeof(adv_router)); -			zlog_debug("%s: Install route: %s cost %u nh %u adv_router %s ", -				   __PRETTY_FUNCTION__, buf, route->path.cost, -				   listcount(route->nh_list), adv_router); +			zlog_debug( +				"%s: Install route: %s cost %u nh %u adv_router %s ", +				__func__, buf, route->path.cost, +				listcount(route->nh_list), adv_router);  		}  		path = ospf6_path_dup(&route->path); diff --git a/ospf6d/ospf6_area.c b/ospf6d/ospf6_area.c index e4c4d4ad9c..9fe077b544 100644 --- a/ospf6d/ospf6_area.c +++ b/ospf6d/ospf6_area.c @@ -61,8 +61,7 @@ static void ospf6_area_lsdb_hook_add(struct ospf6_lsa *lsa)  	case OSPF6_LSTYPE_ROUTER:  	case OSPF6_LSTYPE_NETWORK:  		if (IS_OSPF6_DEBUG_EXAMIN_TYPE(lsa->header->type)) { -			zlog_debug("%s Examin LSA %s", __PRETTY_FUNCTION__, -				   lsa->name); +			zlog_debug("%s Examin LSA %s", __func__, lsa->name);  			zlog_debug(" Schedule SPF Calculation for %s",  				   OSPF6_AREA(lsa->lsdb->data)->name);  		} diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c index 0f9a20df87..805e411c7b 100644 --- a/ospf6d/ospf6_asbr.c +++ b/ospf6d/ospf6_asbr.c @@ -166,7 +166,7 @@ int ospf6_orig_as_external_lsa(struct thread *thread)  		if (IS_OSPF6_DEBUG_ASBR)  			zlog_debug(  				"%s: Send update of AS-External LSA %s seq 0x%x", -				__PRETTY_FUNCTION__, lsa->name, +				__func__, lsa->name,  				ntohl(lsa->header->seqnum));  		ospf6_flood_interface(NULL, lsa, oi); @@ -245,7 +245,7 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old,  					   sizeof(buf));  				zlog_debug(  					"%s: route %s cost old %u new %u is not same, replace route", -					__PRETTY_FUNCTION__, buf, o_path->cost, +					__func__, buf, o_path->cost,  					route->path.cost);  			} @@ -309,7 +309,7 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old,  						   sizeof(buf));  					zlog_debug(  						"%s: route %s old cost %u new cost %u, delete old entry.", -						__PRETTY_FUNCTION__, buf, +						__func__, buf,  						old_route->path.cost,  						route->path.cost);  				} @@ -340,8 +340,7 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old,  					   sizeof(buf));  				zlog_debug(  					"%s: old route %s path  cost %u e2 %u", -					__PRETTY_FUNCTION__, buf, -					old_route->path.cost, +					__func__, buf, old_route->path.cost,  					old_route->path.u.cost_e2);  			}  			route_found = true; @@ -378,13 +377,11 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old,  						   sizeof(buf));  					zlog_debug(  						"%s: route %s another path added with nh %u, effective paths %u nh %u", -						__PRETTY_FUNCTION__, buf, +						__func__, buf,  						listcount(ecmp_path->nh_list), -						old_route->paths -							? listcount( -								  old_route -									  ->paths) -							: 0, +						old_route->paths ? listcount( +							old_route->paths) +								 : 0,  						listcount(old_route->nh_list));  				}  			} else { @@ -410,9 +407,9 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old,  							AS_EXTERNAL)) {  						prefix2str(&old_route->prefix,  							   buf, sizeof(buf)); -						zlog_debug("%s: ls_prfix %s asbr_entry not found.", -							   __PRETTY_FUNCTION__, -							   buf); +						zlog_debug( +							"%s: ls_prfix %s asbr_entry not found.", +							__func__, buf);  					}  					continue;  				} @@ -422,12 +419,15 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old,  			if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) {  				prefix2str(&route->prefix, buf, sizeof(buf)); -				zlog_debug("%s: route %s with effective paths %u nh %u", -					   __PRETTY_FUNCTION__, buf, -					   old_route->paths ? -					   listcount(old_route->paths) : 0, -					   old_route->nh_list ? -					   listcount(old_route->nh_list) : 0); +				zlog_debug( +					"%s: route %s with effective paths %u nh %u", +					__func__, buf, +					old_route->paths +						? listcount(old_route->paths) +						: 0, +					old_route->nh_list +						? listcount(old_route->nh_list) +						: 0);  			}  			/* Update RIB/FIB */ @@ -532,7 +532,7 @@ void ospf6_asbr_lsa_add(struct ospf6_lsa *lsa)  	if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) {  		prefix2str(&route->prefix, buf, sizeof(buf));  		zlog_debug("%s: AS-External %u route add %s cost %u(%u) nh %u", -			   __PRETTY_FUNCTION__, +			   __func__,  			   (route->path.type == OSPF6_PATH_TYPE_EXTERNAL1) ? 1  									   : 2,  			   buf, route->path.cost, route->path.u.cost_e2, @@ -621,9 +621,8 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa,  		prefix2str(&prefix, buf, sizeof(buf));  		zlog_debug(  			"%s: Current route %s cost %u e2 %u, route to del cost %u e2 %u", -			__PRETTY_FUNCTION__, buf, route->path.cost, -			route->path.u.cost_e2, route_to_del->path.cost, -			route_to_del->path.u.cost_e2); +			__func__, buf, route->path.cost, route->path.u.cost_e2, +			route_to_del->path.cost, route_to_del->path.u.cost_e2);  	}  	for (ospf6_route_lock(route); @@ -670,8 +669,8 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa,  							   sizeof(buf));  						zlog_debug(  							"%s: route %s to delete is not same, cost %u del cost %u. skip", -							__PRETTY_FUNCTION__, -							buf, route->path.cost, +							__func__, buf, +							route->path.cost,  							route_to_del->path  								.cost);  					} @@ -682,8 +681,7 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa,  					prefix2str(&prefix, buf, sizeof(buf));  					zlog_debug(  						"%s: route %s path found with cost %u nh %u to remove.", -						__PRETTY_FUNCTION__, buf, -						route->path.cost, +						__func__, buf, route->path.cost,  						listcount(o_path->nh_list));  				} @@ -726,14 +724,15 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa,  						   sizeof(buf));  					zlog_debug(  						"%s: AS-External %u route %s update paths %u nh %u", -						__PRETTY_FUNCTION__, +						__func__,  						(route->path.type  						 == OSPF6_PATH_TYPE_EXTERNAL1)  							? 1  							: 2,  						buf, listcount(route->paths), -						route->nh_list ? -						listcount(route->nh_list) : 0); +						route->nh_list ? listcount( +							route->nh_list) +							       : 0);  				}  				if (listcount(route->paths)) { @@ -785,8 +784,7 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa,  					prefix2str(&prefix, buf, sizeof(buf));  					zlog_debug(  						"%s: route %s to delete is not same, cost %u del cost %u. skip", -						__PRETTY_FUNCTION__, buf, -						route->path.cost, +						__func__, buf, route->path.cost,  						route_to_del->path.cost);  				}  				continue; @@ -802,7 +800,7 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa,  			prefix2str(&route->prefix, buf, sizeof(buf));  			zlog_debug(  				"%s: AS-External %u route remove %s cost %u(%u) nh %u", -				__PRETTY_FUNCTION__, +				__func__,  				route->path.type == OSPF6_PATH_TYPE_EXTERNAL1  					? 1  					: 2, @@ -892,8 +890,7 @@ static int ospf6_asbr_routemap_update_timer(struct thread *thread)  	if (ospf6->rmap[arg_type].map) {  		if (IS_OSPF6_DEBUG_ASBR)  			zlog_debug("%s: route-map %s update, reset redist %s", -				   __PRETTY_FUNCTION__, -				   ospf6->rmap[arg_type].name, +				   __func__, ospf6->rmap[arg_type].name,  				   ZROUTE_NAME(arg_type));  		ospf6_zebra_no_redistribute(arg_type); @@ -917,8 +914,8 @@ void ospf6_asbr_distribute_list_update(int type)  	args[1] = (void *)((ptrdiff_t)type);  	if (IS_OSPF6_DEBUG_ASBR) -		zlog_debug("%s: trigger redistribute %s reset thread", -			   __PRETTY_FUNCTION__, ZROUTE_NAME(type)); +		zlog_debug("%s: trigger redistribute %s reset thread", __func__, +			   ZROUTE_NAME(type));  	ospf6->t_distribute_update = NULL;  	thread_add_timer_msec(master, ospf6_asbr_routemap_update_timer, @@ -943,7 +940,7 @@ static void ospf6_asbr_routemap_update(const char *mapname)  				if (IS_OSPF6_DEBUG_ASBR)  					zlog_debug(  						"%s: route-map %s update, reset redist %s", -						__PRETTY_FUNCTION__, mapname, +						__func__, mapname,  						ZROUTE_NAME(type));  				route_map_counter_increment( diff --git a/ospf6d/ospf6_flood.c b/ospf6d/ospf6_flood.c index 15dbd0716a..85d02c186b 100644 --- a/ospf6d/ospf6_flood.c +++ b/ospf6d/ospf6_flood.c @@ -258,8 +258,8 @@ void ospf6_install_lsa(struct ospf6_lsa *lsa)  	if (IS_OSPF6_DEBUG_LSA_TYPE(lsa->header->type)  	    || IS_OSPF6_DEBUG_EXAMIN_TYPE(lsa->header->type))  		zlog_debug("%s Install LSA: %s age %d seqnum %x in LSDB.", -			   __PRETTY_FUNCTION__, lsa->name, -			   ntohs(lsa->header->age), ntohl(lsa->header->seqnum)); +			   __func__, lsa->name, ntohs(lsa->header->age), +			   ntohl(lsa->header->seqnum));  	/* actually install */  	lsa->installed = now; @@ -373,7 +373,7 @@ void ospf6_flood_interface(struct ospf6_neighbor *from, struct ospf6_lsa *lsa,  			if (is_debug)  				zlog_debug(  					"%s: Send LSA %s (age %d) update now", -					__PRETTY_FUNCTION__, lsa->name, +					__func__, lsa->name,  					ntohs(lsa->header->age));  			ospf6_lsupdate_send_neighbor_now(on, lsa);  			continue; @@ -1004,7 +1004,7 @@ void ospf6_receive_lsa(struct ospf6_neighbor *from,  				if (is_debug)  					zlog_debug(  						"%s: Current copy of LSA %s is MAXAGE, but new has recent Age.", -						old->name, __PRETTY_FUNCTION__); +						old->name, __func__);  				ospf6_lsa_purge(old);  				if (new->header->adv_router diff --git a/ospf6d/ospf6_intra.c b/ospf6d/ospf6_intra.c index 61879b2cbb..9c239b75ff 100644 --- a/ospf6d/ospf6_intra.c +++ b/ospf6d/ospf6_intra.c @@ -1022,8 +1022,9 @@ int ospf6_intra_prefix_lsa_originate_stub(struct thread *thread)  	 */  	if (oa->intra_prefix_originate) {  		if (IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX)) -			zlog_debug("%s: Re-originate intra prefix LSA, Current full nbrs %u", -				   __PRETTY_FUNCTION__, oa->full_nbrs); +			zlog_debug( +				"%s: Re-originate intra prefix LSA, Current full nbrs %u", +				__func__, oa->full_nbrs);  		if (old)  			ospf6_lsa_purge_multi_ls_id(oa, old);  		oa->intra_prefix_originate = 0; @@ -1401,9 +1402,10 @@ void ospf6_intra_prefix_route_ecmp_path(struct ospf6_area *oa,  			if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) {  				prefix2str(&old_route->prefix, buf,  					   sizeof(buf)); -				zlog_debug("%s: route %s cost old %u new %u is not same, replace route", -					   __PRETTY_FUNCTION__, buf, -					   o_path->cost, route->path.cost); +				zlog_debug( +					"%s: route %s cost old %u new %u is not same, replace route", +					__func__, buf, o_path->cost, +					route->path.cost);  			}  			/* Remove selected current path's nh from @@ -1458,10 +1460,11 @@ void ospf6_intra_prefix_route_ecmp_path(struct ospf6_area *oa,  				if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) {  					prefix2str(&old_route->prefix, buf,  						   sizeof(buf)); -					zlog_debug("%s: route %s old cost %u new cost %u, delete old entry.", -						   __PRETTY_FUNCTION__, buf, -						   old_route->path.cost, -						   route->path.cost); +					zlog_debug( +						"%s: route %s old cost %u new cost %u, delete old entry.", +						__func__, buf, +						old_route->path.cost, +						route->path.cost);  				}  				if (oa->route_table->hook_remove)  					ospf6_route_remove(old_route, @@ -1516,13 +1519,13 @@ void ospf6_intra_prefix_route_ecmp_path(struct ospf6_area *oa,  						   sizeof(buf));  					zlog_debug(  						"%s: route %s %p another path added with nh %u, effective paths %u nh %u", -						__PRETTY_FUNCTION__, buf, +						__func__, buf,  						(void *)old_route,  						listcount(ecmp_path->nh_list), -						old_route->paths ? -						listcount(old_route->paths) : 0, +						old_route->paths ? listcount( +							old_route->paths) +								 : 0,  						listcount(old_route->nh_list)); -  				}  			} else {  				list_delete_all_node(o_path->nh_list); @@ -1540,9 +1543,9 @@ void ospf6_intra_prefix_route_ecmp_path(struct ospf6_area *oa,  							oa->spf_table);  				if (ls_entry == NULL) {  					if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) -						zlog_debug("%s: ls_prfix %s ls_entry not found.", -							   __PRETTY_FUNCTION__, -							   buf); +						zlog_debug( +							"%s: ls_prfix %s ls_entry not found.", +							__func__, buf);  					continue;  				}  				lsa = ospf6_lsdb_lookup(o_path->origin.type, @@ -1559,9 +1562,9 @@ void ospf6_intra_prefix_route_ecmp_path(struct ospf6_area *oa,  						o_path->origin.id, &adv_prefix);  						prefix2str(&adv_prefix, buf,  							   sizeof(buf)); -						zlog_debug("%s: adv_router %s lsa not found", -							   __PRETTY_FUNCTION__, -							   buf); +						zlog_debug( +							"%s: adv_router %s lsa not found", +							__func__, buf);  					}  					continue;  				} @@ -1587,12 +1590,13 @@ void ospf6_intra_prefix_route_ecmp_path(struct ospf6_area *oa,  			if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) {  				prefix2str(&route->prefix, buf, sizeof(buf)); -				zlog_debug("%s: route %s %p with final effective paths %u nh%u", -					   __PRETTY_FUNCTION__, buf, -					   (void *)old_route, -					   old_route->paths ? -					   listcount(old_route->paths) : 0, -					   listcount(old_route->nh_list)); +				zlog_debug( +					"%s: route %s %p with final effective paths %u nh%u", +					__func__, buf, (void *)old_route, +					old_route->paths +						? listcount(old_route->paths) +						: 0, +					listcount(old_route->nh_list));  			}  			/* used in intra_route_calculation() to add to @@ -1636,7 +1640,7 @@ void ospf6_intra_prefix_lsa_add(struct ospf6_lsa *lsa)  		return;  	if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) -		zlog_debug("%s: LSA %s found", __PRETTY_FUNCTION__, lsa->name); +		zlog_debug("%s: LSA %s found", __func__, lsa->name);  	oa = OSPF6_AREA(lsa->lsdb->data); @@ -1732,21 +1736,22 @@ void ospf6_intra_prefix_lsa_add(struct ospf6_lsa *lsa)  		if (old) {  			if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) {  				prefix2str(&route->prefix, buf, sizeof(buf)); -				zlog_debug("%s Update route: %s old cost %u new cost %u paths %u nh %u", -					   __PRETTY_FUNCTION__, buf, -					   old->path.cost, route->path.cost, -					   listcount(route->paths), -					   listcount(route->nh_list)); +				zlog_debug( +					"%s Update route: %s old cost %u new cost %u paths %u nh %u", +					__func__, buf, old->path.cost, +					route->path.cost, +					listcount(route->paths), +					listcount(route->nh_list));  			}  			ospf6_intra_prefix_route_ecmp_path(oa, old, route);  		} else {  			if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) {  				prefix2str(&route->prefix, buf, sizeof(buf)); -				zlog_debug("%s route %s add with cost %u paths %u nh %u", -					   __PRETTY_FUNCTION__, buf, -					   route->path.cost, -					   listcount(route->paths), -					   listcount(route->nh_list)); +				zlog_debug( +					"%s route %s add with cost %u paths %u nh %u", +					__func__, buf, route->path.cost, +					listcount(route->paths), +					listcount(route->nh_list));  			}  			ospf6_route_add(route, oa->route_table);  		} @@ -1783,7 +1788,7 @@ static void ospf6_intra_prefix_lsa_remove_update_route(struct ospf6_lsa *lsa,  			prefix2str(&route->prefix, buf, sizeof(buf));  			zlog_debug(  				"%s: route %s path found with cost %u nh %u to remove.", -				__PRETTY_FUNCTION__, buf, o_path->cost, +				__func__, buf, o_path->cost,  				listcount(o_path->nh_list));  		} @@ -1819,11 +1824,10 @@ static void ospf6_intra_prefix_lsa_remove_update_route(struct ospf6_lsa *lsa,  		if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) {  			prefix2str(&route->prefix, buf, sizeof(buf)); -			zlog_debug("%s: route %s update paths %u nh %u", -				   __PRETTY_FUNCTION__, buf, -				   route->paths ? listcount(route->paths) : 0, -				   route->nh_list ? listcount(route->nh_list) -				   : 0); +			zlog_debug( +				"%s: route %s update paths %u nh %u", __func__, +				buf, route->paths ? listcount(route->paths) : 0, +				route->nh_list ? listcount(route->nh_list) : 0);  		}  		/* Update Global Route table and @@ -1859,8 +1863,7 @@ void ospf6_intra_prefix_lsa_remove(struct ospf6_lsa *lsa)  	char buf[PREFIX2STR_BUFFER];  	if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) -		zlog_debug("%s: %s disappearing", __PRETTY_FUNCTION__, -			   lsa->name); +		zlog_debug("%s: %s disappearing", __func__, lsa->name);  	oa = OSPF6_AREA(lsa->lsdb->data); @@ -1917,12 +1920,12 @@ void ospf6_intra_prefix_lsa_remove(struct ospf6_lsa *lsa)  				if (IS_OSPF6_DEBUG_EXAMIN(INTRA_PREFIX)) {  					prefix2str(&route->prefix, buf,  						   sizeof(buf)); -					zlog_debug("%s: route remove %s with path type %u cost %u paths %u nh %u", -						   __PRETTY_FUNCTION__, buf, -						   route->path.type, -						   route->path.cost, -						   listcount(route->paths), -						   listcount(route->nh_list)); +					zlog_debug( +						"%s: route remove %s with path type %u cost %u paths %u nh %u", +						__func__, buf, route->path.type, +						route->path.cost, +						listcount(route->paths), +						listcount(route->nh_list));  				}  				ospf6_route_remove(route, oa->route_table);  			} @@ -2054,8 +2057,8 @@ void ospf6_intra_brouter_calculation(struct ospf6_area *oa)  	if (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ID(oa->area_id) ||  	    IS_OSPF6_DEBUG_ROUTE(MEMORY)) -		zlog_info("%s: border-router calculation for area %s", -			  __PRETTY_FUNCTION__, oa->name); +		zlog_info("%s: border-router calculation for area %s", __func__, +			  oa->name);  	hook_add = oa->ospf6->brouter_table->hook_add;  	hook_remove = oa->ospf6->brouter_table->hook_remove; @@ -2161,10 +2164,11 @@ void ospf6_intra_brouter_calculation(struct ospf6_area *oa)  			if (ospf6_route_lookup(&adv_prefix, oa->spf_table)) {  				if (IS_OSPF6_DEBUG_BROUTER) { -					zlog_debug("%s: keep inter brouter %s as adv router 0x%x found in spf", -						   __PRETTY_FUNCTION__, -						   brouter_name, -					brouter->path.origin.adv_router); +					zlog_debug( +						"%s: keep inter brouter %s as adv router 0x%x found in spf", +						__func__, brouter_name, +						brouter->path.origin +							.adv_router);  					ospf6_brouter_debug_print(brouter);  				}  				UNSET_FLAG(brouter->flag, OSPF6_ROUTE_REMOVE); @@ -2183,9 +2187,9 @@ void ospf6_intra_brouter_calculation(struct ospf6_area *oa)  				       brouter_id)  			    || IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ID(  				       oa->area_id)) -				zlog_info("%s: brouter %s disappears via area %s", -					  __PRETTY_FUNCTION__, brouter_name, -					  oa->name); +				zlog_info( +					"%s: brouter %s disappears via area %s", +					__func__, brouter_name, oa->name);  			/* This is used to protect nbrouter from removed from  			 * the table. For an example, ospf6_abr_examin_summary,  			 * removes brouters which are marked for remove. @@ -2201,8 +2205,7 @@ void ospf6_intra_brouter_calculation(struct ospf6_area *oa)  			    || IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ID(  				       oa->area_id))  				zlog_info("%s: brouter %s appears via area %s", -					  __PRETTY_FUNCTION__, brouter_name, -					  oa->name); +					  __func__, brouter_name, oa->name);  			/* newly added */  			if (hook_add) @@ -2229,7 +2232,7 @@ void ospf6_intra_brouter_calculation(struct ospf6_area *oa)  	if (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ID(oa->area_id) ||  	    IS_OSPF6_DEBUG_ROUTE(MEMORY))  		zlog_info("%s: border-router calculation for area %s: done", -			  __PRETTY_FUNCTION__, oa->name); +			  __func__, oa->name);  }  static const struct ospf6_lsa_handler router_handler = { diff --git a/ospf6d/ospf6_message.c b/ospf6d/ospf6_message.c index d75fc39bbb..21f9b0722c 100644 --- a/ospf6d/ospf6_message.c +++ b/ospf6d/ospf6_message.c @@ -2186,9 +2186,8 @@ int ospf6_lsupdate_send_neighbor_now(struct ospf6_neighbor *on,  	if (IS_OSPF6_DEBUG_FLOODING  	    || IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_LSUPDATE, SEND)) -		zlog_debug("%s: Send lsupdate with lsa %s (age %u)", -			   __PRETTY_FUNCTION__, lsa->name, -			   ntohs(lsa->header->age)); +		zlog_debug("%s: Send lsupdate with lsa %s (age %u)", __func__, +			   lsa->name, ntohs(lsa->header->age));  	ospf6_send_lsupdate(on, NULL, oh); @@ -2244,8 +2243,7 @@ int ospf6_lsupdate_send_interface(struct thread *thread)  				if (IS_OSPF6_DEBUG_MESSAGE(  					    OSPF6_MESSAGE_TYPE_LSUPDATE, SEND))  					zlog_debug("%s: LSUpdate length %d", -						   __PRETTY_FUNCTION__, -						   ntohs(oh->length)); +						   __func__, ntohs(oh->length));  				memset(sendbuf, 0, iobuflen);  				oh = (struct ospf6_header *)sendbuf; diff --git a/ospf6d/ospf6_proto.h b/ospf6d/ospf6_proto.h index c9e7b549db..3876a98c50 100644 --- a/ospf6d/ospf6_proto.h +++ b/ospf6d/ospf6_proto.h @@ -71,7 +71,7 @@ struct ospf6_prefix {  #define OSPF6_PREFIX_OPTION_P  (1 << 3)  /* Propagate (NSSA) */  /* caddr_t OSPF6_PREFIX_BODY (struct ospf6_prefix *); */ -#define OSPF6_PREFIX_BODY(x) ((caddr_t)(x) + sizeof (struct ospf6_prefix)) +#define OSPF6_PREFIX_BODY(x) ((caddr_t)(x) + sizeof(struct ospf6_prefix))  /* size_t OSPF6_PREFIX_SPACE (int prefixlength); */  #define OSPF6_PREFIX_SPACE(x) ((((x) + 31) / 32) * 4) diff --git a/ospf6d/ospf6_snmp.c b/ospf6d/ospf6_snmp.c index 27f5ef8edd..9a1141f631 100644 --- a/ospf6d/ospf6_snmp.c +++ b/ospf6d/ospf6_snmp.c @@ -1356,7 +1356,7 @@ static int ospf6TrapNbrStateChange(struct ospf6_neighbor *on, int next_state,  	smux_trap(ospfv3_variables, array_size(ospfv3_variables),  		  ospfv3_trap_oid, array_size(ospfv3_trap_oid), ospfv3_oid, -		  sizeof ospfv3_oid / sizeof(oid), index, 3, ospf6NbrTrapList, +		  sizeof(ospfv3_oid) / sizeof(oid), index, 3, ospf6NbrTrapList,  		  array_size(ospf6NbrTrapList), NBRSTATECHANGE);  	return 0;  } @@ -1378,7 +1378,7 @@ static int ospf6TrapIfStateChange(struct ospf6_interface *oi, int next_state,  	smux_trap(ospfv3_variables, array_size(ospfv3_variables),  		  ospfv3_trap_oid, array_size(ospfv3_trap_oid), ospfv3_oid, -		  sizeof ospfv3_oid / sizeof(oid), index, 2, ospf6IfTrapList, +		  sizeof(ospfv3_oid) / sizeof(oid), index, 2, ospf6IfTrapList,  		  array_size(ospf6IfTrapList), IFSTATECHANGE);  	return 0;  } diff --git a/ospf6d/ospf6_spf.c b/ospf6d/ospf6_spf.c index 966ef44825..b0fe890d33 100644 --- a/ospf6d/ospf6_spf.c +++ b/ospf6d/ospf6_spf.c @@ -351,7 +351,7 @@ static int ospf6_spf_install(struct ospf6_vertex *v,  			if (IS_OSPF6_DEBUG_SPF(PROCESS)) {  				zlog_debug(  					"%s: V lsa %s id %u, route id %u are different", -					__PRETTY_FUNCTION__, v->lsa->name, +					__func__, v->lsa->name,  					ntohl(v->lsa->header->id),  					ntohl(route->path.origin.id));  			} @@ -995,15 +995,15 @@ struct ospf6_lsa *ospf6_create_single_router_lsa(struct ospf6_area *area,  		rtr_lsa = ospf6_lsdb_next(end, rtr_lsa);  	}  	if (IS_OSPF6_DEBUG_SPF(PROCESS)) -		zlog_debug("%s: adv_router %s num_lsa %u to convert.", -			   __PRETTY_FUNCTION__, ifbuf, num_lsa); +		zlog_debug("%s: adv_router %s num_lsa %u to convert.", __func__, +			   ifbuf, num_lsa);  	if (num_lsa == 1)  		return lsa;  	if (num_lsa == 0) {  		if (IS_OSPF6_DEBUG_SPF(PROCESS))  			zlog_debug("%s: adv_router %s not found in LSDB.", -				   __PRETTY_FUNCTION__, ifbuf); +				   __func__, ifbuf);  		return NULL;  	} @@ -1052,7 +1052,7 @@ struct ospf6_lsa *ospf6_create_single_router_lsa(struct ospf6_area *area,  			inet_ntop(AF_INET, &interface_id, ifbuf, sizeof(ifbuf));  			zlog_debug(  				"%s: Next Router LSA %s to aggreat with len %u interface_id %s", -				__PRETTY_FUNCTION__, rtr_lsa->name, +				__func__, rtr_lsa->name,  				ntohs(lsa_header->length), ifbuf);  		} @@ -1074,9 +1074,9 @@ struct ospf6_lsa *ospf6_create_single_router_lsa(struct ospf6_area *area,  	if (IS_OSPF6_DEBUG_SPF(PROCESS))  		zlog_debug("%s: LSA %s id %u type 0%x len %u num_lsa %u", -			   __PRETTY_FUNCTION__, lsa->name, -			   ntohl(lsa->header->id), ntohs(lsa->header->type), -			   ntohs(lsa->header->length), num_lsa); +			   __func__, lsa->name, ntohl(lsa->header->id), +			   ntohs(lsa->header->type), ntohs(lsa->header->length), +			   num_lsa);  	return lsa;  } @@ -1089,7 +1089,7 @@ void ospf6_remove_temp_router_lsa(struct ospf6_area *area)  		if (IS_OSPF6_DEBUG_SPF(PROCESS))  			zlog_debug(  				"%s Remove LSA %s lsa->lock %u lsdb count %u", -				__PRETTY_FUNCTION__, lsa->name, lsa->lock, +				__func__, lsa->name, lsa->lock,  				area->temp_router_lsa_lsdb->count);  		ospf6_lsdb_remove(lsa, area->temp_router_lsa_lsdb);  	} diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c index 95537eb86e..96eee51929 100644 --- a/ospf6d/ospf6_top.c +++ b/ospf6d/ospf6_top.c @@ -111,7 +111,7 @@ static void ospf6_top_brouter_hook_add(struct ospf6_route *route)  		inet_ntop(AF_INET, &brouter_id, brouter_name,  			  sizeof(brouter_name));  		zlog_debug("%s: brouter %s add with adv router %x nh count %u", -			   __PRETTY_FUNCTION__, brouter_name, +			   __func__, brouter_name,  			   route->path.origin.adv_router,  			   listcount(route->nh_list));  	} @@ -131,7 +131,7 @@ static void ospf6_top_brouter_hook_remove(struct ospf6_route *route)  		inet_ntop(AF_INET, &brouter_id, brouter_name,  			  sizeof(brouter_name));  		zlog_debug("%s: brouter %p %s del with adv router %x nh %u", -			   __PRETTY_FUNCTION__, (void *)route, brouter_name, +			   __func__, (void *)route, brouter_name,  			   route->path.origin.adv_router,  			   listcount(route->nh_list));  	} diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c index 6832737ada..1717f1e650 100644 --- a/ospf6d/ospf6_zebra.c +++ b/ospf6d/ospf6_zebra.c @@ -64,10 +64,9 @@ static int ospf6_router_id_update_zebra(ZAPI_CALLBACK_ARGS)  	if (IS_OSPF6_DEBUG_ZEBRA(RECV)) {  		char buf[INET_ADDRSTRLEN]; -		zlog_debug("%s: zebra router-id %s update", -			   __PRETTY_FUNCTION__, -			   inet_ntop(AF_INET, &router_id.u.prefix4, -				     buf, INET_ADDRSTRLEN)); +		zlog_debug("%s: zebra router-id %s update", __func__, +			   inet_ntop(AF_INET, &router_id.u.prefix4, buf, +				     INET_ADDRSTRLEN));  	}  	ospf6_router_id_update(); diff --git a/ospfd/ospf_abr.c b/ospfd/ospf_abr.c index b4690cfa42..a8dfcbb36b 100644 --- a/ospfd/ospf_abr.c +++ b/ospfd/ospf_abr.c @@ -670,8 +670,7 @@ static int ospf_abr_translate_nssa(struct ospf_area *area, struct ospf_lsa *lsa)  		 * originate translated LSA  		 */ -		if ((new = ospf_translated_nssa_originate(area->ospf, lsa)) -		    == NULL) { +		if (ospf_translated_nssa_originate(area->ospf, lsa) == NULL) {  			if (IS_DEBUG_OSPF_NSSA)  				zlog_debug(  					"ospf_abr_translate_nssa(): Could not translate " diff --git a/ospfd/ospf_dump.c b/ospfd/ospf_dump.c index dffcb930e4..a712ecde95 100644 --- a/ospfd/ospf_dump.c +++ b/ospfd/ospf_dump.c @@ -158,12 +158,12 @@ const char *ospf_timeval_dump(struct timeval *t, char *buf, size_t size)  #define HOUR_IN_SECONDS		(60*MINUTE_IN_SECONDS)  #define DAY_IN_SECONDS		(24*HOUR_IN_SECONDS)  #define WEEK_IN_SECONDS		(7*DAY_IN_SECONDS) -	unsigned long w, d, h, m, s, ms, us; +	unsigned long w, d, h, m, ms, us;  	if (!t)  		return "inactive"; -	w = d = h = m = s = ms = us = 0; +	w = d = h = m = ms = 0;  	memset(buf, 0, size);  	us = t->tv_usec; @@ -386,7 +386,7 @@ static void ospf_packet_db_desc_dump(struct stream *s, uint16_t length)  	zlog_debug("  Options %d (%s)", dd->options,  		   ospf_options_dump(dd->options));  	zlog_debug("  Flags %d (%s)", dd->flags, -		   ospf_dd_flags_dump(dd->flags, dd_flags, sizeof dd_flags)); +		   ospf_dd_flags_dump(dd->flags, dd_flags, sizeof(dd_flags)));  	zlog_debug("  Sequence Number 0x%08lx",  		   (unsigned long)ntohl(dd->dd_seqnum)); diff --git a/ospfd/ospf_flood.c b/ospfd/ospf_flood.c index c29b464cab..818e7e72bc 100644 --- a/ospfd/ospf_flood.c +++ b/ospfd/ospf_flood.c @@ -948,7 +948,7 @@ void ospf_lsa_flush_area(struct ospf_lsa *lsa, struct ospf_area *area)  	   retransmissions */  	lsa->data->ls_age = htons(OSPF_LSA_MAXAGE);  	if (IS_DEBUG_OSPF_EVENT) -		zlog_debug("%s: MAXAGE set to LSA %s", __PRETTY_FUNCTION__, +		zlog_debug("%s: MAXAGE set to LSA %s", __func__,  			   inet_ntoa(lsa->data->id));  	monotime(&lsa->tv_recv);  	lsa->tv_orig = lsa->tv_recv; diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c index f2efaf322f..1622b2fd25 100644 --- a/ospfd/ospf_interface.c +++ b/ospfd/ospf_interface.c @@ -272,8 +272,8 @@ struct ospf_interface *ospf_if_new(struct ospf *ospf, struct interface *ifp,  	if (IS_DEBUG_OSPF_EVENT)  		zlog_debug("%s: ospf interface %s vrf %s id %u created", -			   __PRETTY_FUNCTION__, ifp->name, -			   ospf_get_name(ospf), ospf->vrf_id); +			   __func__, ifp->name, ospf_get_name(ospf), +			   ospf->vrf_id);  	return oi;  } @@ -349,7 +349,7 @@ void ospf_if_free(struct ospf_interface *oi)  	if (IS_DEBUG_OSPF_EVENT)  		zlog_debug("%s: ospf interface %s vrf %s id %u deleted", -			   __PRETTY_FUNCTION__, oi->ifp->name, +			   __func__, oi->ifp->name,  			   ospf_vrf_id_to_name(oi->ifp->vrf_id),  			   oi->ifp->vrf_id); diff --git a/ospfd/ospf_ism.c b/ospfd/ospf_ism.c index f4e89da45d..86712c6198 100644 --- a/ospfd/ospf_ism.c +++ b/ospfd/ospf_ism.c @@ -183,17 +183,22 @@ static void ospf_dr_change(struct ospf *ospf, struct route_table *nbrs)  	struct route_node *rn;  	struct ospf_neighbor *nbr; -	for (rn = route_top(nbrs); rn; rn = route_next(rn)) -		if ((nbr = rn->info) != NULL) -			/* Ignore 0.0.0.0 node*/ -			if (nbr->router_id.s_addr != INADDR_ANY) -				/* Is neighbor upper 2-Way? */ -				if (nbr->state >= NSM_TwoWay) -					/* Ignore myself. */ -					if (!IPV4_ADDR_SAME(&nbr->router_id, -							    &ospf->router_id)) -						OSPF_NSM_EVENT_SCHEDULE( -							nbr, NSM_AdjOK); +	for (rn = route_top(nbrs); rn; rn = route_next(rn)) { +		nbr = rn->info; + +		if (!nbr) +			continue; + +		/* +		 * Ignore 0.0.0.0 node +		 * Is neighbor 2-Way? +		 * Ignore myself +		 */ +		if (nbr->router_id.s_addr != INADDR_ANY +		    && nbr->state >= NSM_TwoWay +		    && !IPV4_ADDR_SAME(&nbr->router_id, &ospf->router_id)) +			OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_AdjOK); +	}  }  static int ospf_dr_election(struct ospf_interface *oi) diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c index 35bbe06cd1..55ec638522 100644 --- a/ospfd/ospf_lsa.c +++ b/ospfd/ospf_lsa.c @@ -434,7 +434,7 @@ static char link_info_set(struct stream **s, struct in_addr id,  			/* we futz the size here for simplicity, really we need  			 * to account  			 * for just: -			 * IP Header - (sizeof (struct ip)) +			 * IP Header - (sizeof(struct ip))  			 * OSPF Header - OSPF_HEADER_SIZE  			 * LSA Header - OSPF_LSA_HEADER_SIZE  			 * MD5 auth data, if MD5 is configured - @@ -2858,7 +2858,7 @@ void ospf_lsa_maxage_delete(struct ospf *ospf, struct ospf_lsa *lsa)  	} else {  		if (IS_DEBUG_OSPF_EVENT)  			zlog_debug("%s: lsa %s is not found in maxage db.", -				   __PRETTY_FUNCTION__, dump_lsa_key(lsa)); +				   __func__, dump_lsa_key(lsa));  	}  } diff --git a/ospfd/ospf_nsm.c b/ospfd/ospf_nsm.c index 0fc2cd60f9..58f087ca4f 100644 --- a/ospfd/ospf_nsm.c +++ b/ospfd/ospf_nsm.c @@ -684,7 +684,7 @@ static void nsm_change_state(struct ospf_neighbor *nbr, int state)  			zlog_info(  				"%s:[%s:%s], %s -> %s): "  				"scheduling new router-LSA origination", -				__PRETTY_FUNCTION__, inet_ntoa(nbr->router_id), +				__func__, inet_ntoa(nbr->router_id),  				ospf_get_name(oi->ospf),  				lookup_msg(ospf_nsm_state_msg, old_state, NULL),  				lookup_msg(ospf_nsm_state_msg, state, NULL)); diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c index a989b8468c..b042a06372 100644 --- a/ospfd/ospf_opaque.c +++ b/ospfd/ospf_opaque.c @@ -1557,8 +1557,8 @@ struct ospf_lsa *ospf_opaque_lsa_install(struct ospf_lsa *lsa, int rt_recalc)  		ospf_lsa_unlock(&oipi->lsa);  		oipi->lsa = ospf_lsa_lock(lsa);  	} -	/* Register the new lsa entry and get its control info. */ -	else if ((oipi = register_opaque_lsa(lsa)) == NULL) { +	/* Register the new lsa entry */ +	else if (register_opaque_lsa(lsa) == NULL) {  		flog_warn(EC_OSPF_LSA,  			  "ospf_opaque_lsa_install: register_opaque_lsa() ?");  		goto out; diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index 213db15fa5..d87f02627b 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -725,7 +725,7 @@ static int ospf_write(struct thread *thread)  		 * but.. */  		if (sizeof(struct ip)  		    > (unsigned int)(iph.ip_hl << OSPF_WRITE_IPHL_SHIFT)) -			iph.ip_hl++; /* we presume sizeof struct ip cant +			iph.ip_hl++; /* we presume sizeof(struct ip) cant  					overflow ip_hl.. */  		iph.ip_v = IPVERSION; @@ -2376,9 +2376,9 @@ static struct stream *ospf_recv_packet(struct ospf *ospf, int fd,  	}  	if (IS_DEBUG_OSPF_PACKET(0, RECV)) -		zlog_debug("%s: fd %d(%s) on interface %d(%s)", -			   __PRETTY_FUNCTION__, fd, ospf_get_name(ospf), -			   ifindex, *ifp ? (*ifp)->name : "Unknown"); +		zlog_debug("%s: fd %d(%s) on interface %d(%s)", __func__, fd, +			   ospf_get_name(ospf), ifindex, +			   *ifp ? (*ifp)->name : "Unknown");  	return ibuf;  } @@ -2984,8 +2984,7 @@ static enum ospf_read_return_enum ospf_read_helper(struct ospf *ospf)  			if (IS_DEBUG_OSPF_PACKET(0, RECV))  				zlog_debug(  					"%s: Unable to determine incoming interface from: %s(%s)", -					__PRETTY_FUNCTION__, -					inet_ntoa(iph->ip_src), +					__func__, inet_ntoa(iph->ip_src),  					ospf_get_name(ospf));  			return OSPF_READ_CONTINUE;  		} @@ -3251,7 +3250,7 @@ static int ospf_make_auth(struct ospf_interface *oi, struct ospf_header *ospfh)  	switch (ospf_auth_type(oi)) {  	case OSPF_AUTH_NULL: -		/* memset (ospfh->u.auth_data, 0, sizeof (ospfh->u.auth_data)); +		/* memset (ospfh->u.auth_data, 0, sizeof(ospfh->u.auth_data));  		 */  		break;  	case OSPF_AUTH_SIMPLE: @@ -3274,7 +3273,7 @@ static int ospf_make_auth(struct ospf_interface *oi, struct ospf_header *ospfh)  		/* note: the seq is done in ospf_make_md5_digest() */  		break;  	default: -		/* memset (ospfh->u.auth_data, 0, sizeof (ospfh->u.auth_data)); +		/* memset (ospfh->u.auth_data, 0, sizeof(ospfh->u.auth_data));  		 */  		break;  	} @@ -3689,7 +3688,7 @@ static void ospf_hello_send_sub(struct ospf_interface *oi, in_addr_t addr)  		if (oi->ospf->vrf_id)  			zlog_debug(  				"%s: Hello Tx interface %s ospf vrf %s id %u", -				__PRETTY_FUNCTION__, oi->ifp->name, +				__func__, oi->ifp->name,  				ospf_vrf_id_to_name(oi->ospf->vrf_id),  				oi->ospf->vrf_id);  	} diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c index 7bd586fd31..550e5ee9ee 100644 --- a/ospfd/ospf_snmp.c +++ b/ospfd/ospf_snmp.c @@ -2455,7 +2455,7 @@ static void ospfTrapNbrStateChange(struct ospf_neighbor *on)  	ospf_nbr_state_message(on, msgbuf, sizeof(msgbuf));  	if (IS_DEBUG_OSPF_EVENT) -		zlog_info("%s: trap sent: %s now %s", __PRETTY_FUNCTION__, +		zlog_info("%s: trap sent: %s now %s", __func__,  			  inet_ntoa(on->address.u.prefix4), msgbuf);  	oid_copy_addr(index, &(on->address.u.prefix4), IN_ADDR_SIZE); @@ -2463,7 +2463,7 @@ static void ospfTrapNbrStateChange(struct ospf_neighbor *on)  	smux_trap(ospf_variables, array_size(ospf_variables), ospf_trap_oid,  		  array_size(ospf_trap_oid), ospf_oid, -		  sizeof ospf_oid / sizeof(oid), index, IN_ADDR_SIZE + 1, +		  sizeof(ospf_oid) / sizeof(oid), index, IN_ADDR_SIZE + 1,  		  ospfNbrTrapList, array_size(ospfNbrTrapList), NBRSTATECHANGE);  } @@ -2478,7 +2478,7 @@ static void ospfTrapVirtNbrStateChange(struct ospf_neighbor *on)  	smux_trap(ospf_variables, array_size(ospf_variables), ospf_trap_oid,  		  array_size(ospf_trap_oid), ospf_oid, -		  sizeof ospf_oid / sizeof(oid), index, IN_ADDR_SIZE + 1, +		  sizeof(ospf_oid) / sizeof(oid), index, IN_ADDR_SIZE + 1,  		  ospfVirtNbrTrapList, array_size(ospfVirtNbrTrapList),  		  VIRTNBRSTATECHANGE);  } @@ -2508,7 +2508,7 @@ static void ospfTrapIfStateChange(struct ospf_interface *oi)  	oid index[sizeof(oid) * (IN_ADDR_SIZE + 1)];  	if (IS_DEBUG_OSPF_EVENT) -		zlog_info("%s: trap sent: %s now %s", __PRETTY_FUNCTION__, +		zlog_info("%s: trap sent: %s now %s", __func__,  			  inet_ntoa(oi->address->u.prefix4),  			  lookup_msg(ospf_ism_state_msg, oi->state, NULL)); @@ -2517,7 +2517,7 @@ static void ospfTrapIfStateChange(struct ospf_interface *oi)  	smux_trap(ospf_variables, array_size(ospf_variables), ospf_trap_oid,  		  array_size(ospf_trap_oid), ospf_oid, -		  sizeof ospf_oid / sizeof(oid), index, IN_ADDR_SIZE + 1, +		  sizeof(ospf_oid) / sizeof(oid), index, IN_ADDR_SIZE + 1,  		  ospfIfTrapList, array_size(ospfIfTrapList), IFSTATECHANGE);  } @@ -2532,7 +2532,7 @@ static void ospfTrapVirtIfStateChange(struct ospf_interface *oi)  	smux_trap(ospf_variables, array_size(ospf_variables), ospf_trap_oid,  		  array_size(ospf_trap_oid), ospf_oid, -		  sizeof ospf_oid / sizeof(oid), index, IN_ADDR_SIZE + 1, +		  sizeof(ospf_oid) / sizeof(oid), index, IN_ADDR_SIZE + 1,  		  ospfVirtIfTrapList, array_size(ospfVirtIfTrapList),  		  VIRTIFSTATECHANGE);  } diff --git a/ospfd/ospf_spf.c b/ospfd/ospf_spf.c index 620691a98d..8b605b3bac 100644 --- a/ospfd/ospf_spf.c +++ b/ospfd/ospf_spf.c @@ -1345,7 +1345,7 @@ static int ospf_spf_calculate_timer(struct thread *thread)  	if (IS_DEBUG_OSPF_EVENT)  		zlog_debug(  			"%s: ospf install new route, vrf %s id %u new_table count %lu", -			__PRETTY_FUNCTION__, ospf_vrf_id_to_name(ospf->vrf_id), +			__func__, ospf_vrf_id_to_name(ospf->vrf_id),  			ospf->vrf_id, new_table->count);  	/* Update routing table. */  	monotime(&start_time); diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index fb4082e509..fd2ab07261 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -619,8 +619,7 @@ DEFUN (ospf_network_area,  		if (IS_DEBUG_OSPF_EVENT)  			zlog_debug(  				"%s ospf vrf %s num of %u ip osp area x config", -				__PRETTY_FUNCTION__, -				ospf->name ? ospf->name : "NIL", +				__func__, ospf->name ? ospf->name : "NIL",  				ospf->if_ospf_cli_count);  		return CMD_WARNING_CONFIG_FAILED;  	} diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index 64013435f6..385a7ece7b 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -87,8 +87,8 @@ static int ospf_router_id_update_zebra(ZAPI_CALLBACK_ARGS)  			prefix2str(&router_id, buf, sizeof(buf));  			zlog_debug(  				"%s: ospf instance not found for vrf %s id %u router_id %s", -				__PRETTY_FUNCTION__, -				ospf_vrf_id_to_name(vrf_id), vrf_id, buf); +				__func__, ospf_vrf_id_to_name(vrf_id), vrf_id, +				buf);  		}  	}  	return 0; @@ -197,7 +197,7 @@ static int ospf_interface_vrf_update(ZAPI_CALLBACK_ARGS)  	if (IS_DEBUG_OSPF_EVENT)  		zlog_debug(  			"%s: Rx Interface %s VRF change vrf_id %u New vrf %s id %u", -			__PRETTY_FUNCTION__, ifp->name, vrf_id, +			__func__, ifp->name, vrf_id,  			ospf_vrf_id_to_name(new_vrf_id), new_vrf_id);  	/*if_update(ifp, ifp->name, strlen(ifp->name), new_vrf_id);*/ @@ -957,8 +957,8 @@ static int ospf_distribute_list_update_timer(struct thread *thread)  	if (IS_DEBUG_OSPF_EVENT) {  		zlog_debug(  			"%s: ospf distribute-list update arg_type %d vrf %s id %d", -			__PRETTY_FUNCTION__, arg_type, -			ospf_vrf_id_to_name(ospf->vrf_id), ospf->vrf_id); +			__func__, arg_type, ospf_vrf_id_to_name(ospf->vrf_id), +			ospf->vrf_id);  	}  	/* foreach all external info. */ @@ -1002,7 +1002,6 @@ static int ospf_distribute_list_update_timer(struct thread *thread)  void ospf_distribute_list_update(struct ospf *ospf, int type,  				 unsigned short instance)  { -	struct route_table *rt;  	struct ospf_external *ext;  	void **args = XCALLOC(MTYPE_OSPF_DIST_ARGS, sizeof(void *) * 2); @@ -1011,7 +1010,7 @@ void ospf_distribute_list_update(struct ospf *ospf, int type,  	/* External info does not exist. */  	ext = ospf_external_lookup(ospf, type, instance); -	if (!ext || !(rt = EXTERNAL_INFO(ext))) { +	if (!ext || !EXTERNAL_INFO(ext)) {  		XFREE(MTYPE_OSPF_DIST_ARGS, args);  		return;  	} @@ -1321,8 +1320,7 @@ void ospf_zebra_vrf_register(struct ospf *ospf)  	if (ospf->vrf_id != VRF_UNKNOWN) {  		if (IS_DEBUG_OSPF_EVENT) -			zlog_debug("%s: Register VRF %s id %u", -				   __PRETTY_FUNCTION__, +			zlog_debug("%s: Register VRF %s id %u", __func__,  				   ospf_vrf_id_to_name(ospf->vrf_id),  				   ospf->vrf_id);  		zclient_send_reg_requests(zclient, ospf->vrf_id); @@ -1337,8 +1335,7 @@ void ospf_zebra_vrf_deregister(struct ospf *ospf)  	if (ospf->vrf_id != VRF_DEFAULT && ospf->vrf_id != VRF_UNKNOWN) {  		if (IS_DEBUG_OSPF_EVENT)  			zlog_debug("%s: De-Register VRF %s id %u to Zebra.", -				   __PRETTY_FUNCTION__, -				   ospf_vrf_id_to_name(ospf->vrf_id), +				   __func__, ospf_vrf_id_to_name(ospf->vrf_id),  				   ospf->vrf_id);  		/* Deregister for router-id, interfaces,  		 * redistributed routes. */ diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c index 2a3f1329a0..f3fe9e17b2 100644 --- a/ospfd/ospfd.c +++ b/ospfd/ospfd.c @@ -220,7 +220,7 @@ static struct ospf *ospf_new(unsigned short instance, const char *name)  		if (IS_DEBUG_OSPF_EVENT)  			zlog_debug(  				"%s: Create new ospf instance with vrf_name %s vrf_id %u", -				__PRETTY_FUNCTION__, name, new->vrf_id); +				__func__, name, new->vrf_id);  	} else {  		new->vrf_id = VRF_DEFAULT;  		vrf = vrf_lookup_by_id(VRF_DEFAULT); @@ -1308,7 +1308,7 @@ void ospf_if_update(struct ospf *ospf, struct interface *ifp)  	if (IS_DEBUG_OSPF_EVENT)  		zlog_debug(  			"%s: interface %s ifp->vrf_id %u ospf vrf %s vrf_id %u router_id %s", -			__PRETTY_FUNCTION__, ifp->name, ifp->vrf_id, +			__func__, ifp->name, ifp->vrf_id,  			ospf_vrf_id_to_name(ospf->vrf_id), ospf->vrf_id,  			inet_ntoa(ospf->router_id)); @@ -2019,8 +2019,8 @@ void ospf_vrf_unlink(struct ospf *ospf, struct vrf *vrf)  static int ospf_vrf_new(struct vrf *vrf)  {  	if (IS_DEBUG_OSPF_EVENT) -		zlog_debug("%s: VRF Created: %s(%u)", __PRETTY_FUNCTION__, -			   vrf->name, vrf->vrf_id); +		zlog_debug("%s: VRF Created: %s(%u)", __func__, vrf->name, +			   vrf->vrf_id);  	return 0;  } @@ -2029,8 +2029,8 @@ static int ospf_vrf_new(struct vrf *vrf)  static int ospf_vrf_delete(struct vrf *vrf)  {  	if (IS_DEBUG_OSPF_EVENT) -		zlog_debug("%s: VRF Deletion: %s(%u)", __PRETTY_FUNCTION__, -			   vrf->name, vrf->vrf_id); +		zlog_debug("%s: VRF Deletion: %s(%u)", __func__, vrf->name, +			   vrf->vrf_id);  	return 0;  } @@ -2060,8 +2060,8 @@ static int ospf_vrf_enable(struct vrf *vrf)  	int ret = 0;  	if (IS_DEBUG_OSPF_EVENT) -		zlog_debug("%s: VRF %s id %u enabled", __PRETTY_FUNCTION__, -			   vrf->name, vrf->vrf_id); +		zlog_debug("%s: VRF %s id %u enabled", __func__, vrf->name, +			   vrf->vrf_id);  	ospf = ospf_lookup_by_name(vrf->name);  	if (ospf) { @@ -2075,8 +2075,7 @@ static int ospf_vrf_enable(struct vrf *vrf)  		if (IS_DEBUG_OSPF_EVENT)  			zlog_debug(  				"%s: ospf linked to vrf %s vrf_id %u (old id %u)", -				__PRETTY_FUNCTION__, vrf->name, ospf->vrf_id, -				old_vrf_id); +				__func__, vrf->name, ospf->vrf_id, old_vrf_id);  		if (old_vrf_id != ospf->vrf_id) {  			frr_with_privs(&ospfd_privs) { @@ -2113,8 +2112,8 @@ static int ospf_vrf_disable(struct vrf *vrf)  		return 0;  	if (IS_DEBUG_OSPF_EVENT) -		zlog_debug("%s: VRF %s id %d disabled.", __PRETTY_FUNCTION__, -			   vrf->name, vrf->vrf_id); +		zlog_debug("%s: VRF %s id %d disabled.", __func__, vrf->name, +			   vrf->vrf_id);  	ospf = ospf_lookup_by_name(vrf->name);  	if (ospf) { @@ -2126,8 +2125,8 @@ static int ospf_vrf_disable(struct vrf *vrf)  		ospf_vrf_unlink(ospf, vrf);  		ospf->oi_running = 0;  		if (IS_DEBUG_OSPF_EVENT) -			zlog_debug("%s: ospf old_vrf_id %d unlinked", -				   __PRETTY_FUNCTION__, old_vrf_id); +			zlog_debug("%s: ospf old_vrf_id %d unlinked", __func__, +				   old_vrf_id);  		thread_cancel(ospf->t_read);  		close(ospf->fd);  		ospf->fd = -1; diff --git a/pbrd/pbr_map.c b/pbrd/pbr_map.c index 37b6be6949..e45e629649 100644 --- a/pbrd/pbr_map.c +++ b/pbrd/pbr_map.c @@ -202,7 +202,7 @@ void pbr_map_reason_string(unsigned int reason, char *buf, int size)  void pbr_map_final_interface_deletion(struct pbr_map *pbrm,  				      struct pbr_map_interface *pmi)  { -	if (pmi->delete == true && !pbr_map_interface_is_installed(pbrm, pmi)) { +	if (pmi->delete && !pbr_map_interface_is_installed(pbrm, pmi)) {  		listnode_delete(pbrm->incoming, pmi);  		pmi->pbrm = NULL; @@ -327,8 +327,7 @@ void pbr_map_vrf_update(const struct pbr_vrf *pbr_vrf)  	       enabled ? "enabled" : "disabled");  	RB_FOREACH (pbrm, pbr_map_entry_head, &pbr_maps) { -		DEBUGD(&pbr_dbg_map, "%s: Looking at %s", __PRETTY_FUNCTION__, -		       pbrm->name); +		DEBUGD(&pbr_dbg_map, "%s: Looking at %s", __func__, pbrm->name);  		for (ALL_LIST_ELEMENTS_RO(pbrm->seqnumbers, node, pbrms))  			pbrms_vrf_update(pbrms, pbr_vrf);  	} @@ -417,8 +416,7 @@ struct pbr_map_sequence *pbrms_lookup_unique(uint32_t unique, ifindex_t ifindex,  			for (ALL_LIST_ELEMENTS_RO(pbrm->seqnumbers, snode,  						  pbrms)) {  				DEBUGD(&pbr_dbg_map, "%s: Comparing %u to %u", -				       __PRETTY_FUNCTION__, pbrms->unique, -				       unique); +				       __func__, pbrms->unique, unique);  				if (pbrms->unique == unique)  					return pbrms;  			} @@ -595,8 +593,8 @@ bool pbr_map_check_valid(const char *name)  	pbrm = pbrm_find(name);  	if (!pbrm) {  		DEBUGD(&pbr_dbg_map, -		       "%s: Specified PBR-MAP(%s) does not exist?", -		       __PRETTY_FUNCTION__, name); +		       "%s: Specified PBR-MAP(%s) does not exist?", __func__, +		       name);  		return false;  	} @@ -611,8 +609,7 @@ void pbr_map_schedule_policy_from_nhg(const char *nh_group)  	struct listnode *node;  	RB_FOREACH (pbrm, pbr_map_entry_head, &pbr_maps) { -		DEBUGD(&pbr_dbg_map, "%s: Looking at %s", __PRETTY_FUNCTION__, -		       pbrm->name); +		DEBUGD(&pbr_dbg_map, "%s: Looking at %s", __func__, pbrm->name);  		for (ALL_LIST_ELEMENTS_RO(pbrm->seqnumbers, node, pbrms)) {  			DEBUGD(&pbr_dbg_map, "\tNH Grp name: %s",  			       pbrms->nhgrp_name ? @@ -643,16 +640,15 @@ void pbr_map_policy_install(const char *name)  	struct listnode *node, *inode;  	struct pbr_map_interface *pmi; -	DEBUGD(&pbr_dbg_map, "%s: for %s", __PRETTY_FUNCTION__, name); +	DEBUGD(&pbr_dbg_map, "%s: for %s", __func__, name);  	pbrm = pbrm_find(name);  	if (!pbrm)  		return;  	for (ALL_LIST_ELEMENTS_RO(pbrm->seqnumbers, node, pbrms)) {  		DEBUGD(&pbr_dbg_map, -		       "%s: Looking at what to install %s(%u) %d %d", -		       __PRETTY_FUNCTION__, name, pbrms->seqno, pbrm->valid, -		       pbrms->nhs_installed); +		       "%s: Looking at what to install %s(%u) %d %d", __func__, +		       name, pbrms->seqno, pbrm->valid, pbrms->nhs_installed);  		if (pbrm->valid && pbrms->nhs_installed  		    && pbrm->incoming->count) { @@ -726,8 +722,8 @@ void pbr_map_check(struct pbr_map_sequence *pbrms)  	bool install;  	pbrm = pbrms->parent; -	DEBUGD(&pbr_dbg_map, "%s: for %s(%u)", __PRETTY_FUNCTION__, -	       pbrm->name, pbrms->seqno); +	DEBUGD(&pbr_dbg_map, "%s: for %s(%u)", __func__, pbrm->name, +	       pbrms->seqno);  	if (pbr_map_check_valid(pbrm->name))  		DEBUGD(&pbr_dbg_map, "We are totally valid %s",  		       pbrm->name); @@ -735,16 +731,13 @@ void pbr_map_check(struct pbr_map_sequence *pbrms)  	if (pbrms->reason == PBR_MAP_VALID_SEQUENCE_NUMBER) {  		install = true;  		DEBUGD(&pbr_dbg_map, "%s: Installing %s(%u) reason: %" PRIu64, -		       __PRETTY_FUNCTION__, pbrm->name, pbrms->seqno, -		       pbrms->reason); +		       __func__, pbrm->name, pbrms->seqno, pbrms->reason);  		DEBUGD(&pbr_dbg_map,  		       "\tSending PBR_MAP_POLICY_INSTALL event");  	} else {  		install = false; -		DEBUGD(&pbr_dbg_map, -		       "%s: Removing %s(%u) reason: %" PRIu64, -		       __PRETTY_FUNCTION__, pbrm->name, -		       pbrms->seqno, pbrms->reason); +		DEBUGD(&pbr_dbg_map, "%s: Removing %s(%u) reason: %" PRIu64, +		       __func__, pbrm->name, pbrms->seqno, pbrms->reason);  	}  	if (install) diff --git a/pbrd/pbr_nht.c b/pbrd/pbr_nht.c index 5ab714e617..ecd375333c 100644 --- a/pbrd/pbr_nht.c +++ b/pbrd/pbr_nht.c @@ -97,8 +97,7 @@ static void *pbr_nh_alloc(void *p)  	/* Decremented again in pbr_nh_delete */  	++nhrc->refcount; -	DEBUGD(&pbr_dbg_nht, "%s: Sending nexthop to Zebra", -	       __PRETTY_FUNCTION__); +	DEBUGD(&pbr_dbg_nht, "%s: Sending nexthop to Zebra", __func__);  	pbr_send_rnh(new->nexthop, true); @@ -116,7 +115,7 @@ static void pbr_nh_delete(struct pbr_nexthop_cache **pnhc)  		--nhrc->refcount;  	if (!nhrc || nhrc->refcount == 0) {  		DEBUGD(&pbr_dbg_nht, "%s: Removing nexthop from Zebra", -		       __PRETTY_FUNCTION__); +		       __func__);  		pbr_send_rnh((*pnhc)->nexthop, false);  	}  	if (nhrc && nhrc->refcount == 0) { @@ -197,8 +196,8 @@ static void *pbr_nhgc_alloc(void *p)  	strlcpy(new->name, pnhgc->name, sizeof(pnhgc->name));  	new->table_id = pbr_nht_get_next_tableid(false); -	DEBUGD(&pbr_dbg_nht, "%s: NHT: %s assigned Table ID: %u", -	       __PRETTY_FUNCTION__, new->name, new->table_id); +	DEBUGD(&pbr_dbg_nht, "%s: NHT: %s assigned Table ID: %u", __func__, +	       new->name, new->table_id);  	new->nhh = hash_create_size(8, pbr_nh_hash_key, pbr_nh_hash_equal,  				    "PBR NH Cache Hash"); @@ -215,7 +214,7 @@ void pbr_nhgroup_add_cb(const char *name)  	if (!nhgc) {  		DEBUGD(&pbr_dbg_nht, "%s: Could not find nhgc with name: %s\n", -		       __PRETTY_FUNCTION__, name); +		       __func__, name);  		return;  	} @@ -224,8 +223,7 @@ void pbr_nhgroup_add_cb(const char *name)  	if (!pnhgc)  		return; -	DEBUGD(&pbr_dbg_nht, "%s: Added nexthop-group %s", __PRETTY_FUNCTION__, -	       name); +	DEBUGD(&pbr_dbg_nht, "%s: Added nexthop-group %s", __func__, name);  	pbr_map_check_nh_group_change(name);  } @@ -242,7 +240,7 @@ void pbr_nhgroup_add_nexthop_cb(const struct nexthop_group_cmd *nhgc,  	if (!pbr_nht_get_next_tableid(true)) {  		zlog_warn(  			"%s: Exhausted all table identifiers; cannot create nexthop-group cache for nexthop-group '%s'", -			__PRETTY_FUNCTION__, nhgc->name); +			__func__, nhgc->name);  		return;  	} @@ -261,7 +259,7 @@ void pbr_nhgroup_add_nexthop_cb(const struct nexthop_group_cmd *nhgc,  	if (DEBUG_MODE_CHECK(&pbr_dbg_nht, DEBUG_MODE_ALL)) {  		nexthop2str(nhop, debugstr, sizeof(debugstr));  		DEBUGD(&pbr_dbg_nht, "%s: Added %s to nexthop-group %s", -		       __PRETTY_FUNCTION__, debugstr, nhgc->name); +		       __func__, debugstr, nhgc->name);  	}  	pbr_nht_install_nexthop_group(pnhgc, nhgc->nhg); @@ -302,7 +300,7 @@ void pbr_nhgroup_del_nexthop_cb(const struct nexthop_group_cmd *nhgc,  	if (DEBUG_MODE_CHECK(&pbr_dbg_nht, DEBUG_MODE_ALL)) {  		nexthop2str(nhop, debugstr, sizeof(debugstr));  		DEBUGD(&pbr_dbg_nht, "%s: Removed %s from nexthop-group %s", -		       __PRETTY_FUNCTION__, debugstr, nhgc->name); +		       __func__, debugstr, nhgc->name);  	}  	if (pnhgc->nhh->count) @@ -315,8 +313,7 @@ void pbr_nhgroup_del_nexthop_cb(const struct nexthop_group_cmd *nhgc,  void pbr_nhgroup_delete_cb(const char *name)  { -	DEBUGD(&pbr_dbg_nht, "%s: Removed nexthop-group %s", -	       __PRETTY_FUNCTION__, name); +	DEBUGD(&pbr_dbg_nht, "%s: Removed nexthop-group %s", __func__, name);  	/* delete group from all pbrms's */  	pbr_nht_delete_group(name); @@ -339,8 +336,8 @@ static void pbr_nht_find_nhg_from_table_install(struct hash_bucket *b,  	uint32_t *table_id = (uint32_t *)data;  	if (pnhgc->table_id == *table_id) { -		DEBUGD(&pbr_dbg_nht, "%s: Table ID (%u) matches %s", -		       __PRETTY_FUNCTION__, *table_id, pnhgc->name); +		DEBUGD(&pbr_dbg_nht, "%s: Table ID (%u) matches %s", __func__, +		       *table_id, pnhgc->name);  		/*  		 * If the table has been re-handled by zebra @@ -434,13 +431,13 @@ static afi_t pbr_nht_which_afi(struct nexthop_group nhg,  	if (!bh && v6 && v4)  		DEBUGD(&pbr_dbg_nht, -		       "%s: Saw both V6 and V4 nexthops...using %s", -		       __PRETTY_FUNCTION__, afi2str(install_afi)); +		       "%s: Saw both V6 and V4 nexthops...using %s", __func__, +		       afi2str(install_afi));  	if (bh && (v6 || v4))  		DEBUGD(&pbr_dbg_nht,  		       "%s: Saw blackhole nexthop(s) with %s%s%s nexthop(s), using AFI_MAX.", -		       __PRETTY_FUNCTION__, v4 ? "v4" : "", -		       (v4 && v6) ? " and " : "", v6 ? "v6" : ""); +		       __func__, v4 ? "v4" : "", (v4 && v6) ? " and " : "", +		       v6 ? "v6" : "");  	return install_afi;  } @@ -488,7 +485,7 @@ void pbr_nht_change_group(const char *name)  	if (!pnhgc) {  		DEBUGD(&pbr_dbg_nht,  		       "%s: Could not find nexthop-group cache w/ name '%s'", -		       __PRETTY_FUNCTION__, name); +		       __func__, name);  		return;  	} @@ -527,7 +524,7 @@ void pbr_nht_add_individual_nexthop(struct pbr_map_sequence *pbrms)  	if (!pbr_nht_get_next_tableid(true)) {  		zlog_warn(  			"%s: Exhausted all table identifiers; cannot create nexthop-group cache for nexthop-group '%s'", -			__PRETTY_FUNCTION__, find.name); +			__func__, find.name);  		return;  	} @@ -582,7 +579,7 @@ struct pbr_nexthop_group_cache *pbr_nht_add_group(const char *name)  	if (!pbr_nht_get_next_tableid(true)) {  		zlog_warn(  			"%s: Exhausted all table identifiers; cannot create nexthop-group cache for nexthop-group '%s'", -			__PRETTY_FUNCTION__, name); +			__func__, name);  		return NULL;  	} @@ -590,14 +587,13 @@ struct pbr_nexthop_group_cache *pbr_nht_add_group(const char *name)  	if (!nhgc) {  		DEBUGD(&pbr_dbg_nht, "%s: Could not find nhgc with name: %s\n", -		       __PRETTY_FUNCTION__, name); +		       __func__, name);  		return NULL;  	}  	snprintf(lookup.name, sizeof(lookup.name), "%s", name);  	pnhgc = hash_get(pbr_nhg_hash, &lookup, pbr_nhgc_alloc); -	DEBUGD(&pbr_dbg_nht, "%s: Retrieved NHGC @ %p", __PRETTY_FUNCTION__, -	       pnhgc); +	DEBUGD(&pbr_dbg_nht, "%s: Retrieved NHGC @ %p", __func__, pnhgc);  	for (ALL_NEXTHOPS(nhgc->nhg, nhop)) {  		struct pbr_nexthop_cache lookupc; @@ -641,7 +637,7 @@ void pbr_nht_delete_group(const char *name)  bool pbr_nht_nexthop_valid(struct nexthop_group *nhg)  { -	DEBUGD(&pbr_dbg_nht, "%s: %p", __PRETTY_FUNCTION__, nhg); +	DEBUGD(&pbr_dbg_nht, "%s: %p", __func__, nhg);  	return true;  } @@ -650,13 +646,13 @@ bool pbr_nht_nexthop_group_valid(const char *name)  	struct pbr_nexthop_group_cache *pnhgc;  	struct pbr_nexthop_group_cache lookup; -	DEBUGD(&pbr_dbg_nht, "%s: %s", __PRETTY_FUNCTION__, name); +	DEBUGD(&pbr_dbg_nht, "%s: %s", __func__, name);  	snprintf(lookup.name, sizeof(lookup.name), "%s", name);  	pnhgc = hash_get(pbr_nhg_hash, &lookup, NULL);  	if (!pnhgc)  		return false; -	DEBUGD(&pbr_dbg_nht, "%s: \t%d %d", __PRETTY_FUNCTION__, pnhgc->valid, +	DEBUGD(&pbr_dbg_nht, "%s: \t%d %d", __func__, pnhgc->valid,  	       pnhgc->installed);  	if (pnhgc->valid && pnhgc->installed)  		return true; @@ -853,7 +849,7 @@ void pbr_nht_nexthop_update(struct zapi_route *nhr)  }  static void -pbr_nht_individual_nexthop_interface_update_lookup(struct hash_backet *b, +pbr_nht_individual_nexthop_interface_update_lookup(struct hash_bucket *b,  						   void *data)  {  	struct pbr_nexthop_cache *pnhc = b->data; @@ -871,7 +867,7 @@ pbr_nht_individual_nexthop_interface_update_lookup(struct hash_backet *b,  		pnhi->valid += 1;  } -static void pbr_nht_nexthop_interface_update_lookup(struct hash_backet *b, +static void pbr_nht_nexthop_interface_update_lookup(struct hash_bucket *b,  						    void *data)  {  	struct pbr_nexthop_group_cache *pnhgc = b->data; @@ -982,7 +978,7 @@ uint32_t pbr_nht_get_table(const char *name)  	if (!pnhgc) {  		DEBUGD(&pbr_dbg_nht,  		       "%s: Could not find nexthop-group cache w/ name '%s'", -		       __PRETTY_FUNCTION__, name); +		       __func__, name);  		return 5000;  	} diff --git a/pbrd/pbr_vty.c b/pbrd/pbr_vty.c index c1922d8728..e395b7831d 100644 --- a/pbrd/pbr_vty.c +++ b/pbrd/pbr_vty.c @@ -88,8 +88,7 @@ DEFUN_NOSH(no_pbr_map, no_pbr_map_cmd, "no pbr-map PBRMAP [seq (1-700)]",  DEFPY(pbr_set_table_range,        pbr_set_table_range_cmd, -      "[no] pbr table range (10000-4294966272)$lb (10000-4294966272)$ub", -      NO_STR +      "pbr table range (10000-4294966272)$lb (10000-4294966272)$ub",        PBR_STR        "Set table ID range\n"        "Set table ID range\n" @@ -113,6 +112,19 @@ DEFPY(pbr_set_table_range,  	return ret;  } +DEFPY(no_pbr_set_table_range, no_pbr_set_table_range_cmd, +      "no pbr table range [(10000-4294966272)$lb (10000-4294966272)$ub]", +      NO_STR +      PBR_STR +      "Set table ID range\n" +      "Set table ID range\n" +      "Lower bound for table ID range\n" +      "Upper bound for table ID range\n") +{ +	pbr_nht_set_tableid_range(PBR_NHT_DEFAULT_LOW_TABLEID, +				  PBR_NHT_DEFAULT_HIGH_TABLEID); +	return CMD_SUCCESS; +}  DEFPY(pbr_map_match_src, pbr_map_match_src_cmd,  	"[no] match src-ip <A.B.C.D/M|X:X::X:X/M>$prefix", @@ -854,6 +866,7 @@ void pbr_vty_init(void)  	install_element(CONFIG_NODE, &pbr_map_cmd);  	install_element(CONFIG_NODE, &no_pbr_map_cmd);  	install_element(CONFIG_NODE, &pbr_set_table_range_cmd); +	install_element(CONFIG_NODE, &no_pbr_set_table_range_cmd);  	install_element(INTERFACE_NODE, &pbr_policy_cmd);  	install_element(PBRMAP_NODE, &pbr_map_match_src_cmd);  	install_element(PBRMAP_NODE, &pbr_map_match_dst_cmd); diff --git a/pbrd/pbr_zebra.c b/pbrd/pbr_zebra.c index ec0327d74f..c2d93a405e 100644 --- a/pbrd/pbr_zebra.c +++ b/pbrd/pbr_zebra.c @@ -62,8 +62,7 @@ struct pbr_interface *pbr_if_new(struct interface *ifp)  /* Inteface addition message from zebra. */  int pbr_ifp_create(struct interface *ifp)  { -	DEBUGD(&pbr_dbg_zebra, -	       "%s: %s", __PRETTY_FUNCTION__, ifp->name); +	DEBUGD(&pbr_dbg_zebra, "%s: %s", __func__, ifp->name);  	if (!ifp->info)  		pbr_if_new(ifp); @@ -78,8 +77,7 @@ int pbr_ifp_create(struct interface *ifp)  int pbr_ifp_destroy(struct interface *ifp)  { -	DEBUGD(&pbr_dbg_zebra, -	       "%s: %s", __PRETTY_FUNCTION__, ifp->name); +	DEBUGD(&pbr_dbg_zebra, "%s: %s", __func__, ifp->name);  	pbr_map_policy_interface_update(ifp, false); @@ -93,8 +91,7 @@ static int interface_address_add(ZAPI_CALLBACK_ARGS)  	c = zebra_interface_address_read(cmd, zclient->ibuf, vrf_id); -	DEBUGD(&pbr_dbg_zebra, -	       "%s: %s added %s", __PRETTY_FUNCTION__, +	DEBUGD(&pbr_dbg_zebra, "%s: %s added %s", __func__,  	       c ? c->ifp->name : "Unknown",  	       c ? prefix2str(c->address, buf, sizeof(buf)) : "Unknown"); @@ -111,8 +108,7 @@ static int interface_address_delete(ZAPI_CALLBACK_ARGS)  	if (!c)  		return 0; -	DEBUGD(&pbr_dbg_zebra, -	       "%s: %s deleted %s", __PRETTY_FUNCTION__, c->ifp->name, +	DEBUGD(&pbr_dbg_zebra, "%s: %s deleted %s", __func__, c->ifp->name,  	       prefix2str(c->address, buf, sizeof(buf)));  	connected_free(&c); @@ -121,8 +117,7 @@ static int interface_address_delete(ZAPI_CALLBACK_ARGS)  int pbr_ifp_up(struct interface *ifp)  { -	DEBUGD(&pbr_dbg_zebra, -	       "%s: %s is up", __PRETTY_FUNCTION__, ifp->name); +	DEBUGD(&pbr_dbg_zebra, "%s: %s is up", __func__, ifp->name);  	pbr_nht_nexthop_interface_update(ifp); @@ -131,8 +126,7 @@ int pbr_ifp_up(struct interface *ifp)  int pbr_ifp_down(struct interface *ifp)  { -	DEBUGD(&pbr_dbg_zebra, -	       "%s: %s is down", __PRETTY_FUNCTION__, ifp->name); +	DEBUGD(&pbr_dbg_zebra, "%s: %s is down", __func__, ifp->name);  	pbr_nht_nexthop_interface_update(ifp); @@ -177,30 +171,30 @@ static int route_notify_owner(ZAPI_CALLBACK_ARGS)  	switch (note) {  	case ZAPI_ROUTE_FAIL_INSTALL:  		DEBUGD(&pbr_dbg_zebra, -		       "%s: [%s] Route install failure for table: %u", -		       __PRETTY_FUNCTION__, buf, table_id); +		       "%s: [%s] Route install failure for table: %u", __func__, +		       buf, table_id);  		break;  	case ZAPI_ROUTE_BETTER_ADMIN_WON:  		DEBUGD(&pbr_dbg_zebra,  		       "%s: [%s] Route better admin distance won for table: %u", -		       __PRETTY_FUNCTION__, buf, table_id); +		       __func__, buf, table_id);  		break;  	case ZAPI_ROUTE_INSTALLED:  		DEBUGD(&pbr_dbg_zebra,  		       "%s: [%s] Route installed succeeded for table: %u", -		       __PRETTY_FUNCTION__, buf, table_id); +		       __func__, buf, table_id);  		pbr_nht_route_installed_for_table(table_id);  		break;  	case ZAPI_ROUTE_REMOVED:  		DEBUGD(&pbr_dbg_zebra,  		       "%s: [%s] Route Removed succeeded for table: %u", -		       __PRETTY_FUNCTION__, buf, table_id); +		       __func__, buf, table_id);  		pbr_nht_route_removed_for_table(table_id);  		break;  	case ZAPI_ROUTE_REMOVE_FAIL:  		DEBUGD(&pbr_dbg_zebra, -		       "%s: [%s] Route remove fail for table: %u", -		       __PRETTY_FUNCTION__, buf, table_id); +		       "%s: [%s] Route remove fail for table: %u", __func__, +		       buf, table_id);  		break;  	} @@ -224,8 +218,8 @@ static int rule_notify_owner(ZAPI_CALLBACK_ARGS)  	pbrms = pbrms_lookup_unique(unique, ifi, &pmi);  	if (!pbrms) {  		DEBUGD(&pbr_dbg_zebra, -		       "%s: Failure to lookup pbrms based upon %u", -		       __PRETTY_FUNCTION__, unique); +		       "%s: Failure to lookup pbrms based upon %u", __func__, +		       unique);  		return 0;  	} @@ -256,8 +250,7 @@ static int rule_notify_owner(ZAPI_CALLBACK_ARGS)  static void zebra_connected(struct zclient *zclient)  { -	DEBUGD(&pbr_dbg_zebra, "%s: Registering for fun and profit", -	       __PRETTY_FUNCTION__); +	DEBUGD(&pbr_dbg_zebra, "%s: Registering for fun and profit", __func__);  	zclient_send_reg_requests(zclient, VRF_DEFAULT);  } @@ -318,8 +311,7 @@ void route_add(struct pbr_nexthop_group_cache *pnhgc, struct nexthop_group nhg,  {  	struct zapi_route api; -	DEBUGD(&pbr_dbg_zebra, "%s for Table: %d", __PRETTY_FUNCTION__, -	       pnhgc->table_id); +	DEBUGD(&pbr_dbg_zebra, "%s for Table: %d", __func__, pnhgc->table_id);  	memset(&api, 0, sizeof(api)); @@ -347,12 +339,11 @@ void route_add(struct pbr_nexthop_group_cache *pnhgc, struct nexthop_group nhg,  	case AFI_L2VPN:  		DEBUGD(&pbr_dbg_zebra,  		       "%s: Asked to install unsupported route type: L2VPN", -		       __PRETTY_FUNCTION__); +		       __func__);  		break;  	case AFI_UNSPEC:  		DEBUGD(&pbr_dbg_zebra, -		       "%s: Asked to install unspecified route type", -		       __PRETTY_FUNCTION__); +		       "%s: Asked to install unspecified route type", __func__);  		break;  	}  } @@ -365,8 +356,7 @@ void route_delete(struct pbr_nexthop_group_cache *pnhgc, afi_t afi)  {  	struct zapi_route api; -	DEBUGD(&pbr_dbg_zebra, "%s for Table: %d", __PRETTY_FUNCTION__, -	       pnhgc->table_id); +	DEBUGD(&pbr_dbg_zebra, "%s for Table: %d", __func__, pnhgc->table_id);  	memset(&api, 0, sizeof(api));  	api.vrf_id = VRF_DEFAULT; @@ -394,12 +384,11 @@ void route_delete(struct pbr_nexthop_group_cache *pnhgc, afi_t afi)  	case AFI_L2VPN:  		DEBUGD(&pbr_dbg_zebra,  		       "%s: Asked to delete unsupported route type: L2VPN", -		       __PRETTY_FUNCTION__); +		       __func__);  		break;  	case AFI_UNSPEC:  		DEBUGD(&pbr_dbg_zebra, -		       "%s: Asked to delete unspecified route type", -		       __PRETTY_FUNCTION__); +		       "%s: Asked to delete unspecified route type", __func__);  		break;  	}  } @@ -418,16 +407,15 @@ static int pbr_zebra_nexthop_update(ZAPI_CALLBACK_ARGS)  	if (DEBUG_MODE_CHECK(&pbr_dbg_zebra, DEBUG_MODE_ALL)) {  		DEBUGD(&pbr_dbg_zebra, "%s: Received Nexthop update: %s", -		       __PRETTY_FUNCTION__, -		       prefix2str(&nhr.prefix, buf, sizeof(buf))); +		       __func__, prefix2str(&nhr.prefix, buf, sizeof(buf))); -		DEBUGD(&pbr_dbg_zebra, "%s: (\tNexthops(%u)", -		       __PRETTY_FUNCTION__, nhr.nexthop_num); +		DEBUGD(&pbr_dbg_zebra, "%s: (\tNexthops(%u)", __func__, +		       nhr.nexthop_num);  		for (i = 0; i < nhr.nexthop_num; i++) {  			DEBUGD(&pbr_dbg_zebra,  			       "%s: \tType: %d: vrf: %d, ifindex: %d gate: %s", -			       __PRETTY_FUNCTION__, nhr.nexthops[i].type, +			       __func__, nhr.nexthops[i].type,  			       nhr.nexthops[i].vrf_id, nhr.nexthops[i].ifindex,  			       inet_ntoa(nhr.nexthops[i].gate.ipv4));  		} @@ -490,8 +478,7 @@ void pbr_send_rnh(struct nexthop *nhop, bool reg)  	if (zclient_send_rnh(zclient, command, &p,  			     false, nhop->vrf_id) < 0) { -		zlog_warn("%s: Failure to send nexthop to zebra", -			  __PRETTY_FUNCTION__); +		zlog_warn("%s: Failure to send nexthop to zebra", __func__);  	}  } @@ -569,8 +556,8 @@ void pbr_send_pbr_map(struct pbr_map_sequence *pbrms,  	is_installed &= pbrms->installed; -	DEBUGD(&pbr_dbg_zebra, "%s: for %s %d(%" PRIu64 ")", -	       __PRETTY_FUNCTION__, pbrm->name, install, is_installed); +	DEBUGD(&pbr_dbg_zebra, "%s: for %s %d(%" PRIu64 ")", __func__, +	       pbrm->name, install, is_installed);  	/*  	 * If we are installed and asked to do so again @@ -595,9 +582,9 @@ void pbr_send_pbr_map(struct pbr_map_sequence *pbrms,  	 */  	stream_putl(s, 1); -	DEBUGD(&pbr_dbg_zebra, "%s: \t%s %s %d %s %u", -	       __PRETTY_FUNCTION__, install ? "Installing" : "Deleting", -	       pbrm->name, install, pmi->ifp->name, pmi->delete); +	DEBUGD(&pbr_dbg_zebra, "%s: \t%s %s %d %s %u", __func__, +	       install ? "Installing" : "Deleting", pbrm->name, install, +	       pmi->ifp->name, pmi->delete);  	pbr_encode_pbr_map_sequence(s, pbrms, pmi->ifp); diff --git a/pimd/pim_assert.c b/pimd/pim_assert.c index 53ab22754c..957f904714 100644 --- a/pimd/pim_assert.c +++ b/pimd/pim_assert.c @@ -56,7 +56,7 @@ void pim_ifassert_winner_set(struct pim_ifchannel *ch,  		if (ch->ifassert_state != new_state) {  			zlog_debug(  				"%s: (S,G)=%s assert state changed from %s to %s on interface %s", -				__PRETTY_FUNCTION__, ch->sg_str, +				__func__, ch->sg_str,  				pim_ifchannel_ifassert_name(ch->ifassert_state),  				pim_ifchannel_ifassert_name(new_state),  				ch->interface->name); @@ -71,8 +71,8 @@ void pim_ifassert_winner_set(struct pim_ifchannel *ch,  				       sizeof(winner_str));  			zlog_debug(  				"%s: (S,G)=%s assert winner changed from %s to %s on interface %s", -				__PRETTY_FUNCTION__, ch->sg_str, was_str, -				winner_str, ch->interface->name); +				__func__, ch->sg_str, was_str, winner_str, +				ch->interface->name);  		}  	} /* PIM_DEBUG_PIM_EVENTS */ @@ -130,7 +130,7 @@ static void if_could_assert_do_a1(const char *caller, struct pim_ifchannel *ch)  		if (assert_action_a1(ch)) {  			zlog_warn(  				"%s: %s: (S,G)=%s assert_action_a1 failure on interface %s", -				__PRETTY_FUNCTION__, caller, ch->sg_str, +				__func__, caller, ch->sg_str,  				ch->interface->name);  			/* log warning only */  		} @@ -153,12 +153,12 @@ static int dispatch_assert(struct interface *ifp, struct in_addr source_addr,  	case PIM_IFASSERT_NOINFO:  		if (recv_metric.rpt_bit_flag) {  			/* RPT bit set */ -			if_could_assert_do_a1(__PRETTY_FUNCTION__, ch); +			if_could_assert_do_a1(__func__, ch);  		} else {  			/* RPT bit clear */  			if (inferior_assert(&ch->ifassert_my_metric,  					    &recv_metric)) { -				if_could_assert_do_a1(__PRETTY_FUNCTION__, ch); +				if_could_assert_do_a1(__func__, ch);  			} else if (acceptable_assert(&ch->ifassert_my_metric,  						     &recv_metric)) {  				if (PIM_IF_FLAG_TEST_ASSERT_TRACKING_DESIRED( @@ -205,8 +205,7 @@ static int dispatch_assert(struct interface *ifp, struct in_addr source_addr,  	default: {  		zlog_warn(  			"%s: (S,G)=%s invalid assert state %d on interface %s", -			__PRETTY_FUNCTION__, ch->sg_str, ch->ifassert_state, -			ifp->name); +			__func__, ch->sg_str, ch->ifassert_state, ifp->name);  	}  		return -2;  	} @@ -225,7 +224,7 @@ int pim_assert_recv(struct interface *ifp, struct pim_neighbor *neigh,  	int curr_size;  	struct pim_interface *pim_ifp = NULL; -	on_trace(__PRETTY_FUNCTION__, ifp, src_addr); +	on_trace(__func__, ifp, src_addr);  	curr = buf;  	curr_size = buf_size; @@ -239,7 +238,7 @@ int pim_assert_recv(struct interface *ifp, struct pim_neighbor *neigh,  		char src_str[INET_ADDRSTRLEN];  		pim_inet4_dump("<src?>", src_addr, src_str, sizeof(src_str));  		zlog_warn("%s: pim_parse_addr_group() failure: from %s on %s", -			  __PRETTY_FUNCTION__, src_str, ifp->name); +			  __func__, src_str, ifp->name);  		return -1;  	}  	curr += offset; @@ -253,7 +252,7 @@ int pim_assert_recv(struct interface *ifp, struct pim_neighbor *neigh,  		char src_str[INET_ADDRSTRLEN];  		pim_inet4_dump("<src?>", src_addr, src_str, sizeof(src_str));  		zlog_warn("%s: pim_parse_addr_ucast() failure: from %s on %s", -			  __PRETTY_FUNCTION__, src_str, ifp->name); +			  __func__, src_str, ifp->name);  		return -2;  	}  	curr += offset; @@ -264,7 +263,7 @@ int pim_assert_recv(struct interface *ifp, struct pim_neighbor *neigh,  		pim_inet4_dump("<src?>", src_addr, src_str, sizeof(src_str));  		zlog_warn(  			"%s: preference/metric size is less than 8 bytes: size=%d from %s on interface %s", -			__PRETTY_FUNCTION__, curr_size, src_str, ifp->name); +			__func__, curr_size, src_str, ifp->name);  		return -3;  	} @@ -297,9 +296,8 @@ int pim_assert_recv(struct interface *ifp, struct pim_neighbor *neigh,  		pim_inet4_dump("<grp?>", sg.grp, group_str, sizeof(group_str));  		zlog_debug(  			"%s: from %s on %s: (S,G)=(%s,%s) pref=%u metric=%u rpt_bit=%u", -			__PRETTY_FUNCTION__, neigh_str, ifp->name, source_str, -			group_str, msg_metric.metric_preference, -			msg_metric.route_metric, +			__func__, neigh_str, ifp->name, source_str, group_str, +			msg_metric.metric_preference, msg_metric.route_metric,  			PIM_FORCE_BOOLEAN(msg_metric.rpt_bit_flag));  	} @@ -380,7 +378,7 @@ int pim_assert_build_msg(uint8_t *pim_msg, int buf_size, struct interface *ifp,  			       sizeof(group_str));  		zlog_warn(  			"%s: failure encoding group address %s: space left=%d", -			__PRETTY_FUNCTION__, group_str, remain); +			__func__, group_str, remain);  		return -1;  	} @@ -394,7 +392,7 @@ int pim_assert_build_msg(uint8_t *pim_msg, int buf_size, struct interface *ifp,  			       sizeof(source_str));  		zlog_warn(  			"%s: failure encoding source address %s: space left=%d", -			__PRETTY_FUNCTION__, source_str, remain); +			__func__, source_str, remain);  		return -2;  	} @@ -429,7 +427,7 @@ static int pim_assert_do(struct pim_ifchannel *ch,  	if (!ifp) {  		if (PIM_DEBUG_PIM_TRACE)  			zlog_debug("%s: channel%s has no associated interface!", -				   __PRETTY_FUNCTION__, ch->sg_str); +				   __func__, ch->sg_str);  		return -1;  	}  	pim_ifp = ifp->info; @@ -437,7 +435,7 @@ static int pim_assert_do(struct pim_ifchannel *ch,  		if (PIM_DEBUG_PIM_TRACE)  			zlog_debug(  				"%s: channel %s pim not enabled on interface: %s", -				__PRETTY_FUNCTION__, ch->sg_str, ifp->name); +				__func__, ch->sg_str, ifp->name);  		return -1;  	} @@ -448,7 +446,7 @@ static int pim_assert_do(struct pim_ifchannel *ch,  	if (pim_msg_size < 1) {  		zlog_warn(  			"%s: failure building PIM assert message: msg_size=%d", -			__PRETTY_FUNCTION__, pim_msg_size); +			__func__, pim_msg_size);  		return -2;  	} @@ -465,7 +463,7 @@ static int pim_assert_do(struct pim_ifchannel *ch,  	if (PIM_DEBUG_PIM_TRACE) {  		zlog_debug("%s: to %s: (S,G)=%s pref=%u metric=%u rpt_bit=%u", -			   __PRETTY_FUNCTION__, ifp->name, ch->sg_str, +			   __func__, ifp->name, ch->sg_str,  			   metric.metric_preference, metric.route_metric,  			   PIM_FORCE_BOOLEAN(metric.rpt_bit_flag));  	} @@ -475,7 +473,7 @@ static int pim_assert_do(struct pim_ifchannel *ch,  			 qpim_all_pim_routers_addr, pim_msg, pim_msg_size,  			 ifp->name)) {  		zlog_warn("%s: could not send PIM message on interface %s", -			  __PRETTY_FUNCTION__, ifp->name); +			  __func__, ifp->name);  		return -3;  	} @@ -516,7 +514,7 @@ static int on_assert_timer(struct thread *t)  	if (PIM_DEBUG_PIM_TRACE) {  		zlog_debug("%s: (S,G)=%s timer expired on interface %s", -			   __PRETTY_FUNCTION__, ch->sg_str, ifp->name); +			   __func__, ch->sg_str, ifp->name);  	}  	ch->t_ifassert_timer = NULL; @@ -532,8 +530,8 @@ static int on_assert_timer(struct thread *t)  		if (PIM_DEBUG_PIM_EVENTS)  			zlog_warn(  				"%s: (S,G)=%s invalid assert state %d on interface %s", -				__PRETTY_FUNCTION__, ch->sg_str, -				ch->ifassert_state, ifp->name); +				__func__, ch->sg_str, ch->ifassert_state, +				ifp->name);  	}  	} @@ -546,8 +544,7 @@ static void assert_timer_off(struct pim_ifchannel *ch)  		if (ch->t_ifassert_timer) {  			zlog_debug(  				"%s: (S,G)=%s cancelling timer on interface %s", -				__PRETTY_FUNCTION__, ch->sg_str, -				ch->interface->name); +				__func__, ch->sg_str, ch->interface->name);  		}  	}  	THREAD_OFF(ch->t_ifassert_timer); @@ -559,8 +556,7 @@ static void pim_assert_timer_set(struct pim_ifchannel *ch, int interval)  	if (PIM_DEBUG_PIM_TRACE) {  		zlog_debug("%s: (S,G)=%s starting %u sec timer on interface %s", -			   __PRETTY_FUNCTION__, ch->sg_str, interval, -			   ch->interface->name); +			   __func__, ch->sg_str, interval, ch->interface->name);  	}  	thread_add_timer(router->master, on_assert_timer, ch, interval, @@ -591,7 +587,7 @@ int assert_action_a1(struct pim_ifchannel *ch)  	pim_ifp = ifp->info;  	if (!pim_ifp) {  		zlog_warn("%s: (S,G)=%s multicast not enabled on interface %s", -			  __PRETTY_FUNCTION__, ch->sg_str, ifp->name); +			  __func__, ch->sg_str, ifp->name);  		return -1; /* must return since pim_ifp is used below */  	} @@ -604,7 +600,7 @@ int assert_action_a1(struct pim_ifchannel *ch)  	if (assert_action_a3(ch)) {  		zlog_warn(  			"%s: (S,G)=%s assert_action_a3 failure on interface %s", -			__PRETTY_FUNCTION__, ch->sg_str, ifp->name); +			__func__, ch->sg_str, ifp->name);  		/* warning only */  	} @@ -612,7 +608,7 @@ int assert_action_a1(struct pim_ifchannel *ch)  		if (PIM_DEBUG_PIM_EVENTS)  			zlog_warn(  				"%s: channel%s not in expected PIM_IFASSERT_I_AM_WINNER state", -				__PRETTY_FUNCTION__, ch->sg_str); +				__func__, ch->sg_str);  	}  	return 0; @@ -639,7 +635,7 @@ static void assert_action_a2(struct pim_ifchannel *ch,  		if (PIM_DEBUG_PIM_EVENTS)  			zlog_warn(  				"%s: channel%s not in expected PIM_IFASSERT_I_AM_LOSER state", -				__PRETTY_FUNCTION__, ch->sg_str); +				__func__, ch->sg_str);  	}  } @@ -657,7 +653,7 @@ static int assert_action_a3(struct pim_ifchannel *ch)  		if (PIM_DEBUG_PIM_EVENTS)  			zlog_warn(  				"%s: channel%s expected to be in PIM_IFASSERT_I_AM_WINNER state", -				__PRETTY_FUNCTION__, ch->sg_str); +				__func__, ch->sg_str);  		return -1;  	} @@ -665,7 +661,7 @@ static int assert_action_a3(struct pim_ifchannel *ch)  	if (pim_assert_send(ch)) {  		zlog_warn("%s: (S,G)=%s failure sending assert on interface %s", -			  __PRETTY_FUNCTION__, ch->sg_str, ch->interface->name); +			  __func__, ch->sg_str, ch->interface->name);  		return -1;  	} @@ -686,7 +682,7 @@ void assert_action_a4(struct pim_ifchannel *ch)  {  	if (pim_assert_cancel(ch)) {  		zlog_warn("%s: failure sending AssertCancel%s on interface %s", -			  __PRETTY_FUNCTION__, ch->sg_str, ch->interface->name); +			  __func__, ch->sg_str, ch->interface->name);  		/* log warning only */  	} @@ -696,7 +692,7 @@ void assert_action_a4(struct pim_ifchannel *ch)  		if (PIM_DEBUG_PIM_EVENTS)  			zlog_warn(  				"%s: channel%s not in PIM_IFASSERT_NOINFO state as expected", -				__PRETTY_FUNCTION__, ch->sg_str); +				__func__, ch->sg_str);  	}  } @@ -715,7 +711,7 @@ void assert_action_a5(struct pim_ifchannel *ch)  		if (PIM_DEBUG_PIM_EVENTS)  			zlog_warn(  				"%s: channel%s not in PIM_IFSSERT_NOINFO state as expected", -				__PRETTY_FUNCTION__, ch->sg_str); +				__func__, ch->sg_str);  	}  } @@ -747,6 +743,6 @@ static void assert_action_a6(struct pim_ifchannel *ch,  		if (PIM_DEBUG_PIM_EVENTS)  			zlog_warn(  				"%s: channel%s not in PIM_IFASSERT_I_AM_LOSER state as expected", -				__PRETTY_FUNCTION__, ch->sg_str); +				__func__, ch->sg_str);  	}  } diff --git a/pimd/pim_bfd.c b/pimd/pim_bfd.c index 01a7980858..84f6733eaf 100644 --- a/pimd/pim_bfd.c +++ b/pimd/pim_bfd.c @@ -125,7 +125,7 @@ static void pim_bfd_reg_dereg_nbr(struct pim_neighbor *nbr, int command)  		char str[INET_ADDRSTRLEN];  		pim_inet4_dump("<bfd_nbr?>", nbr->source_addr, str,  			       sizeof(str)); -		zlog_debug("%s Nbr %s %s with BFD", __PRETTY_FUNCTION__, str, +		zlog_debug("%s Nbr %s %s with BFD", __func__, str,  			   bfd_get_command_dbg_str(command));  	} @@ -199,8 +199,8 @@ void pim_bfd_if_param_set(struct interface *ifp, uint32_t min_rx,  	if (pim_ifp->bfd_info) {  		if (PIM_DEBUG_PIM_TRACE) -			zlog_debug("%s: interface %s has bfd_info", -				   __PRETTY_FUNCTION__, ifp->name); +			zlog_debug("%s: interface %s has bfd_info", __func__, +				   ifp->name);  	}  	if (command)  		pim_bfd_reg_dereg_all_nbr(ifp, command); @@ -240,16 +240,15 @@ static int pim_bfd_interface_dest_update(ZAPI_CALLBACK_ARGS)  	if (!pim_ifp->bfd_info) {  		if (PIM_DEBUG_PIM_TRACE)  			zlog_debug("%s: pim interface %s BFD is disabled ", -				   __PRETTY_FUNCTION__, ifp->name); +				   __func__, ifp->name);  		return 0;  	}  	if (PIM_DEBUG_PIM_TRACE) {  		char buf[PREFIX2STR_BUFFER];  		prefix2str(&p, buf, sizeof(buf)); -		zlog_debug("%s: interface %s bfd destination %s %s", -			   __PRETTY_FUNCTION__, ifp->name, buf, -			   bfd_get_status_str(status)); +		zlog_debug("%s: interface %s bfd destination %s %s", __func__, +			   ifp->name, buf, bfd_get_status_str(status));  	}  	for (ALL_LIST_ELEMENTS(pim_ifp->pim_neighbor_list, neigh_node, @@ -265,7 +264,7 @@ static int pim_bfd_interface_dest_update(ZAPI_CALLBACK_ARGS)  				pim_inet4_dump("<nht_nbr?>", neigh->source_addr,  					       str, sizeof(str));  				zlog_debug("%s: bfd status is same for nbr %s", -					   __PRETTY_FUNCTION__, str); +					   __func__, str);  			}  			continue;  		} @@ -275,8 +274,7 @@ static int pim_bfd_interface_dest_update(ZAPI_CALLBACK_ARGS)  		bfd_info->last_update = tv.tv_sec;  		if (PIM_DEBUG_PIM_TRACE) { -			zlog_debug("%s: status %s old_status %s", -				   __PRETTY_FUNCTION__, +			zlog_debug("%s: status %s old_status %s", __func__,  				   bfd_get_status_str(status),  				   bfd_get_status_str(old_status));  		} @@ -328,8 +326,7 @@ static int pim_bfd_nbr_replay(ZAPI_CALLBACK_ARGS)  						       sizeof(str));  					zlog_debug(  						"%s: Replaying Pim Neigh %s to BFD vrf_id %u", -						__PRETTY_FUNCTION__, str, -						vrf->vrf_id); +						__func__, str, vrf->vrf_id);  				}  				pim_bfd_reg_dereg_nbr(neigh,  						      ZEBRA_BFD_DEST_UPDATE); diff --git a/pimd/pim_bsm.c b/pimd/pim_bsm.c index e14b7e058d..bcf11aedbd 100644 --- a/pimd/pim_bsm.c +++ b/pimd/pim_bsm.c @@ -145,8 +145,7 @@ static struct bsgrp_node *pim_bsm_new_bsgrp_node(struct route_table *rt,  	rn = route_node_get(rt, grp);  	if (!rn) { -		zlog_warn("%s: route node creation failed", -			  __PRETTY_FUNCTION__); +		zlog_warn("%s: route node creation failed", __func__);  		return NULL;  	}  	bsgrp = XCALLOC(MTYPE_PIM_BSGRP_NODE, sizeof(struct bsgrp_node)); @@ -180,7 +179,7 @@ static int pim_on_bs_timer(struct thread *t)  	if (PIM_DEBUG_BSM)  		zlog_debug("%s: Bootstrap Timer expired for scope: %d", -			   __PRETTY_FUNCTION__, scope->sz_id); +			   __func__, scope->sz_id);  	/* Remove next hop tracking for the bsr */  	nht_p.family = AF_INET; @@ -189,7 +188,7 @@ static int pim_on_bs_timer(struct thread *t)  	if (PIM_DEBUG_BSM) {  		prefix2str(&nht_p, buf, sizeof(buf));  		zlog_debug("%s: Deregister BSR addr %s with Zebra NHT", -			   __PRETTY_FUNCTION__, buf); +			   __func__, buf);  	}  	pim_delete_tracked_nexthop(scope->pim, &nht_p, NULL, NULL,  				   is_bsr_tracking); @@ -209,8 +208,7 @@ static int pim_on_bs_timer(struct thread *t)  		bsgrp_node = (struct bsgrp_node *)rn->info;  		if (!bsgrp_node) {  			if (PIM_DEBUG_BSM) -				zlog_debug("%s: bsgrp_node is null", -					   __PRETTY_FUNCTION__); +				zlog_debug("%s: bsgrp_node is null", __func__);  			continue;  		}  		/* Give grace time for rp to continue for another hold time */ @@ -231,8 +229,8 @@ static int pim_on_bs_timer(struct thread *t)  static void pim_bs_timer_stop(struct bsm_scope *scope)  {  	if (PIM_DEBUG_BSM) -		zlog_debug("%s : BS timer being stopped of sz: %d", -			   __PRETTY_FUNCTION__, scope->sz_id); +		zlog_debug("%s : BS timer being stopped of sz: %d", __func__, +			   scope->sz_id);  	THREAD_OFF(scope->bs_timer);  } @@ -240,14 +238,14 @@ static void pim_bs_timer_start(struct bsm_scope *scope, int bs_timeout)  {  	if (!scope) {  		if (PIM_DEBUG_BSM) -			zlog_debug("%s : Invalid scope(NULL).", -				   __PRETTY_FUNCTION__); +			zlog_debug("%s : Invalid scope(NULL).", __func__);  		return;  	}  	THREAD_OFF(scope->bs_timer);  	if (PIM_DEBUG_BSM) -		zlog_debug("%s : starting bs timer for scope %d with timeout %d secs", -			   __PRETTY_FUNCTION__, scope->sz_id, bs_timeout); +		zlog_debug( +			"%s : starting bs timer for scope %d with timeout %d secs", +			__func__, scope->sz_id, bs_timeout);  	thread_add_timer(router->master, pim_on_bs_timer, scope, bs_timeout,  			 &scope->bs_timer);  } @@ -337,7 +335,7 @@ static int pim_on_g2rp_timer(struct thread *t)  	rn = route_node_lookup(pim->rp_table, &bsgrp_node->group);  	if (!rn) { -		zlog_warn("%s: Route node doesn't exist", __PRETTY_FUNCTION__); +		zlog_warn("%s: Route node doesn't exist", __func__);  		return 0;  	} @@ -376,8 +374,7 @@ static void pim_g2rp_timer_start(struct bsm_rpinfo *bsrp, int hold_time)  {  	if (!bsrp) {  		if (PIM_DEBUG_BSM) -			zlog_debug("%s : Invalid brsp(NULL).", -				   __PRETTY_FUNCTION__); +			zlog_debug("%s : Invalid brsp(NULL).", __func__);  		return;  	}  	THREAD_OFF(bsrp->g2rp_timer); @@ -386,8 +383,7 @@ static void pim_g2rp_timer_start(struct bsm_rpinfo *bsrp, int hold_time)  		zlog_debug(  			"%s : starting g2rp timer for grp: %s - rp: %s with timeout  %d secs(Actual Hold time : %d secs)", -			__PRETTY_FUNCTION__, -			prefix2str(&bsrp->bsgrp_node->group, buf, 48), +			__func__, prefix2str(&bsrp->bsgrp_node->group, buf, 48),  			inet_ntoa(bsrp->rp_address), hold_time,  			bsrp->rp_holdtime);  	} @@ -411,7 +407,7 @@ static void pim_g2rp_timer_stop(struct bsm_rpinfo *bsrp)  		char buf[48];  		zlog_debug("%s : stopping g2rp timer for grp: %s - rp: %s", -			   __PRETTY_FUNCTION__, +			   __func__,  			   prefix2str(&bsrp->bsgrp_node->group, buf, 48),  			   inet_ntoa(bsrp->rp_address));  	} @@ -466,8 +462,7 @@ static void pim_instate_pend_list(struct bsgrp_node *bsgrp_node)  	if (!rn || (prefix_same(&rp_all->group, &bsgrp_node->group)  		    && pim_rpf_addr_is_inaddr_none(&rp_all->rp))) {  		if (PIM_DEBUG_BSM) -			zlog_debug("%s: Route node doesn't exist", -				   __PRETTY_FUNCTION__); +			zlog_debug("%s: Route node doesn't exist", __func__);  		if (pend)  			pim_rp_new(pim, pend->rp_address, bsgrp_node->group,  				   NULL, RP_SRC_BSR); @@ -507,7 +502,7 @@ static void pim_instate_pend_list(struct bsgrp_node *bsgrp_node)  			if (PIM_DEBUG_BSM) {  				zlog_debug(  					"%s: Both bsrp and partial list are empty", -					__PRETTY_FUNCTION__); +					__func__);  			}  			pim_free_bsgrp_node(bsgrp_node->scope->bsrp_table,  					    &bsgrp_node->group); @@ -523,7 +518,7 @@ static void pim_instate_pend_list(struct bsgrp_node *bsgrp_node)  					    &bsgrp_node->group);  			if (PIM_DEBUG_BSM) {  				zlog_debug("%s:Pend List is null,del grp node", -					   __PRETTY_FUNCTION__); +					   __func__);  			}  			pim_free_bsgrp_data(bsgrp_node);  			return; @@ -540,7 +535,7 @@ static void pim_instate_pend_list(struct bsgrp_node *bsgrp_node)  			if (PIM_DEBUG_BSM)  				zlog_debug(  					"%s: Partial list is empty, static rp exists", -					__PRETTY_FUNCTION__); +					__func__);  			pim_free_bsgrp_node(bsgrp_node->scope->bsrp_table,  					    &bsgrp_node->group);  			pim_free_bsgrp_data(bsgrp_node); @@ -587,8 +582,8 @@ static bool pim_bsr_rpf_check(struct pim_instance *pim, struct in_addr bsr,  			char bsr_str[INET_ADDRSTRLEN];  			pim_inet4_dump("<bsr?>", bsr, bsr_str, sizeof(bsr_str)); -			zlog_debug("%s : No route to BSR address %s", -				   __PRETTY_FUNCTION__, bsr_str); +			zlog_debug("%s : No route to BSR address %s", __func__, +				   bsr_str);  		}  		return false;  	} @@ -634,7 +629,7 @@ static void pim_bsm_update(struct pim_instance *pim, struct in_addr bsr,  				prefix2str(&nht_p, buf, sizeof(buf));  				zlog_debug(  					"%s: Deregister BSR addr %s with Zebra NHT", -					__PRETTY_FUNCTION__, buf); +					__func__, buf);  			}  			pim_delete_tracked_nexthop(pim, &nht_p, NULL, NULL,  						   is_bsr_tracking); @@ -645,7 +640,7 @@ static void pim_bsm_update(struct pim_instance *pim, struct in_addr bsr,  			prefix2str(&nht_p, buf, sizeof(buf));  			zlog_debug(  				"%s: NHT Register BSR addr %s with Zebra NHT", -				__PRETTY_FUNCTION__, buf); +				__func__, buf);  		}  		memset(&pnc, 0, sizeof(struct pim_nexthop_cache)); @@ -670,21 +665,21 @@ static bool pim_bsm_send_intf(uint8_t *buf, int len, struct interface *ifp,  	if (!pim_ifp) {  		if (PIM_DEBUG_BSM)  			zlog_debug("%s: Pim interface not available for %s", -				   __PRETTY_FUNCTION__, ifp->name); +				   __func__, ifp->name);  		return false;  	}  	if (pim_ifp->pim_sock_fd == -1) {  		if (PIM_DEBUG_BSM)  			zlog_debug("%s: Pim sock not available for %s", -				   __PRETTY_FUNCTION__, ifp->name); +				   __func__, ifp->name);  		return false;  	}  	if (pim_msg_send(pim_ifp->pim_sock_fd, pim_ifp->primary_address,  			 dst_addr, buf, len, ifp->name)) {  		zlog_warn("%s: Could not send BSM message on interface: %s", -			  __PRETTY_FUNCTION__, ifp->name); +			  __func__, ifp->name);  		return false;  	} @@ -715,11 +710,11 @@ static bool pim_bsm_frag_send(uint8_t *buf, uint32_t len, struct interface *ifp,  	if (pim_mtu < (PIM_MIN_BSM_LEN)) {  		zlog_warn(  			"%s: mtu(pim mtu: %d) size less than minimum bootstrap len", -			__PRETTY_FUNCTION__, pim_mtu); +			__func__, pim_mtu);  		if (PIM_DEBUG_BSM)  			zlog_debug(  				"%s: mtu (pim mtu:%d) less than minimum bootstrap len", -				__PRETTY_FUNCTION__, pim_mtu); +				__func__, pim_mtu);  		return false;  	} @@ -886,8 +881,7 @@ static void pim_bsm_fwd_whole_sz(struct pim_instance *pim, uint8_t *buf,  						dst_addr, no_fwd);  			if (PIM_DEBUG_BSM)  				zlog_debug("%s: pim_bsm_frag_send returned %s", -					   __PRETTY_FUNCTION__, -					   ret ? "TRUE" : "FALSE"); +					   __func__, ret ? "TRUE" : "FALSE");  		} else {  			pim_msg_build_header(buf, len, PIM_MSG_TYPE_BOOTSTRAP,  					     no_fwd); @@ -895,7 +889,7 @@ static void pim_bsm_fwd_whole_sz(struct pim_instance *pim, uint8_t *buf,  				if (PIM_DEBUG_BSM)  					zlog_debug(  						"%s: pim_bsm_send_intf returned false", -						__PRETTY_FUNCTION__); +						__func__);  			}  		}  	} @@ -916,8 +910,8 @@ bool pim_bsm_new_nbr_fwd(struct pim_neighbor *neigh, struct interface *ifp)  	if (PIM_DEBUG_BSM) {  		pim_inet4_dump("<src?>", neigh->source_addr, neigh_src_str,  			       sizeof(neigh_src_str)); -		zlog_debug("%s: New neighbor %s seen on %s", -			   __PRETTY_FUNCTION__, neigh_src_str, ifp->name); +		zlog_debug("%s: New neighbor %s seen on %s", __func__, +			   neigh_src_str, ifp->name);  	}  	pim_ifp = ifp->info; @@ -927,13 +921,13 @@ bool pim_bsm_new_nbr_fwd(struct pim_neighbor *neigh, struct interface *ifp)  		if (PIM_DEBUG_BSM)  			zlog_debug(  				"%s: It is not DR, so don't forward BSM packet", -				__PRETTY_FUNCTION__); +				__func__);  	}  	if (!pim_ifp->bsm_enable) {  		if (PIM_DEBUG_BSM) -			zlog_debug("%s: BSM proc not enabled on %s", -				   __PRETTY_FUNCTION__, ifp->name); +			zlog_debug("%s: BSM proc not enabled on %s", __func__, +				   ifp->name);  		return ret;  	} @@ -942,20 +936,20 @@ bool pim_bsm_new_nbr_fwd(struct pim_neighbor *neigh, struct interface *ifp)  	if (!scope->bsm_list->count) {  		if (PIM_DEBUG_BSM)  			zlog_debug("%s: BSM list for the scope is empty", -				   __PRETTY_FUNCTION__); +				   __func__);  		return ret;  	}  	if (!pim_ifp->ucast_bsm_accept) {  		dst_addr = qpim_all_pim_routers_addr;  		if (PIM_DEBUG_BSM) -			zlog_debug("%s: Sending BSM mcast to %s", -				   __PRETTY_FUNCTION__, neigh_src_str); +			zlog_debug("%s: Sending BSM mcast to %s", __func__, +				   neigh_src_str);  	} else {  		dst_addr = neigh->source_addr;  		if (PIM_DEBUG_BSM) -			zlog_debug("%s: Sending BSM ucast to %s", -				   __PRETTY_FUNCTION__, neigh_src_str); +			zlog_debug("%s: Sending BSM ucast to %s", __func__, +				   neigh_src_str);  	}  	pim_mtu = ifp->mtu - MAX_IP_HDR_LEN;  	pim_hello_require(ifp); @@ -968,7 +962,7 @@ bool pim_bsm_new_nbr_fwd(struct pim_neighbor *neigh, struct interface *ifp)  				if (PIM_DEBUG_BSM)  					zlog_debug(  						"%s: pim_bsm_frag_send failed", -						__PRETTY_FUNCTION__); +						__func__);  			}  		} else {  			/* Pim header needs to be constructed */ @@ -980,7 +974,7 @@ bool pim_bsm_new_nbr_fwd(struct pim_neighbor *neigh, struct interface *ifp)  				if (PIM_DEBUG_BSM)  					zlog_debug(  						"%s: pim_bsm_frag_send failed", -						__PRETTY_FUNCTION__); +						__func__);  			}  		}  	} @@ -997,7 +991,7 @@ struct bsgrp_node *pim_bsm_get_bsgrp_node(struct bsm_scope *scope,  	if (!rn) {  		if (PIM_DEBUG_BSM)  			zlog_debug("%s: Route node doesn't exist for the group", -				   __PRETTY_FUNCTION__); +				   __func__);  		return NULL;  	}  	bsgrp = rn->info; @@ -1063,12 +1057,12 @@ static bool pim_install_bsm_grp_rp(struct pim_instance *pim,  		if (PIM_DEBUG_BSM)  			zlog_debug(  				"%s, bs_rpinfo node added to the partial bs_rplist.\r\n", -				__PRETTY_FUNCTION__); +				__func__);  		return true;  	}  	if (PIM_DEBUG_BSM) -		zlog_debug("%s: list node not added\n", __PRETTY_FUNCTION__); +		zlog_debug("%s: list node not added\n", __func__);  	XFREE(MTYPE_PIM_BSRP_NODE, bsm_rpinfo);  	return false; @@ -1087,7 +1081,7 @@ static void pim_update_pending_rp_cnt(struct bsm_scope *sz,  			if (PIM_DEBUG_BSM)  				zlog_debug(  					"%s,Received a new BSM ,so clear the pending bs_rpinfo list.\r\n", -					__PRETTY_FUNCTION__); +					__func__);  			list_delete_all_node(bsgrp->partial_bsrp_list);  			bsgrp->pend_rp_cnt = total_rp_count;  		} @@ -1114,7 +1108,7 @@ static bool pim_bsm_parse_install_g2rp(struct bsm_scope *scope, uint8_t *buf,  			if (PIM_DEBUG_BSM)  				zlog_debug(  					"%s: buflen received %d is less than the internal data structure of the packet would suggest", -					__PRETTY_FUNCTION__, buflen); +					__func__, buflen);  			return false;  		}  		/* Extract Group tlv from BSM */ @@ -1127,7 +1121,7 @@ static bool pim_bsm_parse_install_g2rp(struct bsm_scope *scope, uint8_t *buf,  				       sizeof(grp_str));  			zlog_debug(  				"%s, Group %s  Rpcount:%d Fragment-Rp-count:%d\r\n", -				__PRETTY_FUNCTION__, grp_str, grpinfo.rp_count, +				__func__, grp_str, grpinfo.rp_count,  				grpinfo.frag_rp_count);  		} @@ -1142,7 +1136,7 @@ static bool pim_bsm_parse_install_g2rp(struct bsm_scope *scope, uint8_t *buf,  					       grp_str, sizeof(grp_str));  				zlog_debug(  					"%s, Rp count is zero for group: %s\r\n", -					__PRETTY_FUNCTION__, grp_str); +					__func__, grp_str);  			}  			return false;  		} @@ -1150,8 +1144,9 @@ static bool pim_bsm_parse_install_g2rp(struct bsm_scope *scope, uint8_t *buf,  		group.family = AF_INET;  		if (grpinfo.group.mask > IPV4_MAX_BITLEN) {  			if (PIM_DEBUG_BSM) -				zlog_debug("%s, v4 prefix length specified: %d is too long", -					   __PRETTY_FUNCTION__, grpinfo.group.mask); +				zlog_debug( +					"%s, v4 prefix length specified: %d is too long", +					__func__, grpinfo.group.mask);  			return false;  		}  		group.prefixlen = grpinfo.group.mask; @@ -1164,7 +1159,7 @@ static bool pim_bsm_parse_install_g2rp(struct bsm_scope *scope, uint8_t *buf,  			if (PIM_DEBUG_BSM)  				zlog_debug(  					"%s, Create new  BSM Group node.\r\n", -					__PRETTY_FUNCTION__); +					__func__);  			/* create a new node to be added to the tree. */  			bsgrp = pim_bsm_new_bsgrp_node(scope->bsrp_table, @@ -1173,7 +1168,7 @@ static bool pim_bsm_parse_install_g2rp(struct bsm_scope *scope, uint8_t *buf,  			if (!bsgrp) {  				zlog_debug(  					"%s, Failed to get the BSM group node.\r\n", -					__PRETTY_FUNCTION__); +					__func__);  				continue;  			} @@ -1191,7 +1186,7 @@ static bool pim_bsm_parse_install_g2rp(struct bsm_scope *scope, uint8_t *buf,  				if (PIM_DEBUG_BSM)  					zlog_debug(  						"%s, buflen received: %u is less than the internal data structure of the packet would suggest", -						__PRETTY_FUNCTION__, buflen); +						__func__, buflen);  				return false;  			} @@ -1208,8 +1203,8 @@ static bool pim_bsm_parse_install_g2rp(struct bsm_scope *scope, uint8_t *buf,  					       rp_str, sizeof(rp_str));  				zlog_debug(  					"%s, Rp address - %s; pri:%d hold:%d\r\n", -					__PRETTY_FUNCTION__, rp_str, -					rpinfo.rp_pri, rpinfo.rp_holdtime); +					__func__, rp_str, rpinfo.rp_pri, +					rpinfo.rp_holdtime);  			}  			/* Call Install api to update grp-rp mappings */ @@ -1223,7 +1218,7 @@ static bool pim_bsm_parse_install_g2rp(struct bsm_scope *scope, uint8_t *buf,  			if (PIM_DEBUG_BSM)  				zlog_debug(  					"%s, Recvd all the rps for this group, so bsrp list with penidng rp list.", -					__PRETTY_FUNCTION__); +					__func__);  			/* replace the bsrp_list with pending list */  			pim_instate_pend_list(bsgrp);  		} @@ -1249,7 +1244,7 @@ int pim_bsm_process(struct interface *ifp, struct ip *ip_hdr, uint8_t *buf,  	if (!pim_ifp) {  		if (PIM_DEBUG_BSM)  			zlog_debug("%s: multicast not enabled on interface %s", -				   __PRETTY_FUNCTION__, ifp->name); +				   __func__, ifp->name);  		return -1;  	} @@ -1259,8 +1254,8 @@ int pim_bsm_process(struct interface *ifp, struct ip *ip_hdr, uint8_t *buf,  	/* Drop if bsm processing is disabled on interface */  	if (!pim_ifp->bsm_enable) { -		zlog_warn("%s: BSM not enabled on interface %s", -			  __PRETTY_FUNCTION__, ifp->name); +		zlog_warn("%s: BSM not enabled on interface %s", __func__, +			  ifp->name);  		pim_ifp->pim_ifstat_bsm_cfg_miss++;  		pim->bsm_dropped++;  		return -1; @@ -1268,8 +1263,9 @@ int pim_bsm_process(struct interface *ifp, struct ip *ip_hdr, uint8_t *buf,  	if (buf_size < (PIM_MSG_HEADER_LEN + sizeof(struct bsm_hdr))) {  		if (PIM_DEBUG_BSM) -			zlog_debug("%s: received buffer length of %d which is too small to properly decode", -				   __PRETTY_FUNCTION__, buf_size); +			zlog_debug( +				"%s: received buffer length of %d which is too small to properly decode", +				__func__, buf_size);  		return -1;  	} @@ -1291,7 +1287,7 @@ int pim_bsm_process(struct interface *ifp, struct ip *ip_hdr, uint8_t *buf,  			if (PIM_DEBUG_BSM)  				zlog_debug(  					"%s : Administratively scoped range BSM received", -					__PRETTY_FUNCTION__); +					__func__);  			pim_ifp->pim_ifstat_bsm_invalid_sz++;  			pim->bsm_dropped++;  			return -1; @@ -1302,7 +1298,7 @@ int pim_bsm_process(struct interface *ifp, struct ip *ip_hdr, uint8_t *buf,  	if (!is_preferred_bsr(pim, bshdr->bsr_addr.addr, bshdr->bsr_prio)) {  		if (PIM_DEBUG_BSM)  			zlog_debug("%s : Received a non-preferred BSM", -				   __PRETTY_FUNCTION__); +				   __func__);  		pim->bsm_dropped++;  		return -1;  	} @@ -1316,7 +1312,7 @@ int pim_bsm_process(struct interface *ifp, struct ip *ip_hdr, uint8_t *buf,  			if (PIM_DEBUG_BSM)  				zlog_debug(  					"%s : nofwd_bsm received on %s when accpt_nofwd_bsm false", -					__PRETTY_FUNCTION__, bsr_str); +					__func__, bsr_str);  			pim->bsm_dropped++;  			pim_ifp->pim_ifstat_ucast_bsm_cfg_miss++;  			return -1; @@ -1331,7 +1327,7 @@ int pim_bsm_process(struct interface *ifp, struct ip *ip_hdr, uint8_t *buf,  				if (PIM_DEBUG_BSM)  					zlog_debug(  						"%s : RPF check fail for BSR address %s", -						__PRETTY_FUNCTION__, bsr_str); +						__func__, bsr_str);  				pim->bsm_dropped++;  				return -1;  			} @@ -1345,7 +1341,7 @@ int pim_bsm_process(struct interface *ifp, struct ip *ip_hdr, uint8_t *buf,  			if (PIM_DEBUG_BSM)  				zlog_debug(  					"%s : Unicast BSM not enabled on interface %s", -					__PRETTY_FUNCTION__, ifp->name); +					__func__, ifp->name);  			pim_ifp->pim_ifstat_ucast_bsm_cfg_miss++;  			pim->bsm_dropped++;  			return -1; @@ -1354,15 +1350,14 @@ int pim_bsm_process(struct interface *ifp, struct ip *ip_hdr, uint8_t *buf,  	} else {  		if (PIM_DEBUG_BSM)  			zlog_debug("%s : Invalid destination address", -				   __PRETTY_FUNCTION__); +				   __func__);  		pim->bsm_dropped++;  		return -1;  	}  	if (empty_bsm) {  		if (PIM_DEBUG_BSM) -			zlog_debug("%s : Empty Pref BSM received", -				   __PRETTY_FUNCTION__); +			zlog_debug("%s : Empty Pref BSM received", __func__);  	}  	/* Parse Update bsm rp table and install/uninstall rp if required */  	if (!pim_bsm_parse_install_g2rp( @@ -1371,8 +1366,7 @@ int pim_bsm_process(struct interface *ifp, struct ip *ip_hdr, uint8_t *buf,  		    (buf_size - PIM_BSM_HDR_LEN - PIM_MSG_HEADER_LEN),  		    frag_tag)) {  		if (PIM_DEBUG_BSM) { -			zlog_debug("%s, Parsing BSM failed.\r\n", -				   __PRETTY_FUNCTION__); +			zlog_debug("%s, Parsing BSM failed.\r\n", __func__);  		}  		pim->bsm_dropped++;  		return -1; @@ -1385,7 +1379,7 @@ int pim_bsm_process(struct interface *ifp, struct ip *ip_hdr, uint8_t *buf,  	if (pim_ifp->pim->global_scope.bsm_frag_tag != frag_tag) {  		if (PIM_DEBUG_BSM) {  			zlog_debug("%s: Current frag tag: %d Frag teg rcvd: %d", -				   __PRETTY_FUNCTION__, +				   __func__,  				   pim_ifp->pim->global_scope.bsm_frag_tag,  				   frag_tag);  		} diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 0caf8e4f78..abc1548967 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; @@ -3927,7 +3933,7 @@ static void clear_mroute(struct pim_instance *pim)  	/* clean up all upstreams*/  	while ((up = rb_pim_upstream_first(&pim->upstream_head))) { -		pim_upstream_del(pim, up, __PRETTY_FUNCTION__); +		pim_upstream_del(pim, up, __func__);  	}  } @@ -4295,6 +4301,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 +4490,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 +4504,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 +4558,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 +4750,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,6 +5790,7 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty,  	int oif_vif_index;  	struct interface *ifp_in;  	char proto[100]; +	char mroute_uptime[10];  	if (uj) {  		json = json_object_new_object(); @@ -5807,6 +5826,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 */ @@ -5840,13 +5863,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 +5888,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) @@ -5952,6 +5973,7 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty,  					src_str[0] = '\0';  					grp_str[0] = '\0';  					in_ifname[0] = '\0'; +					mroute_uptime[0] = '\0';  					first = 0;  				}  			} @@ -7415,7 +7437,7 @@ static void igmp_sock_query_interval_reconfig(struct igmp_sock *igmp)  		pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str,  			       sizeof(ifaddr_str));  		zlog_debug("%s: Querier %s on %s reconfig query_interval=%d", -			   __PRETTY_FUNCTION__, ifaddr_str, ifp->name, +			   __func__, ifaddr_str, ifp->name,  			   pim_ifp->igmp_default_query_interval);  	} @@ -7429,6 +7451,9 @@ static void igmp_sock_query_interval_reconfig(struct igmp_sock *igmp)  static void igmp_sock_query_reschedule(struct igmp_sock *igmp)  { +	if (igmp->mtrace_only) +		return; +  	if (igmp->t_igmp_query_timer) {  		/* other querier present */  		zassert(igmp->t_igmp_query_timer); @@ -8032,13 +8057,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; @@ -8048,6 +8073,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); @@ -10397,7 +10427,7 @@ static void pim_show_vxlan_sg_entry(struct pim_vxlan_sg *vxlan_sg,  	}  } -static void pim_show_vxlan_sg_hash_entry(struct hash_backet *backet, void *arg) +static void pim_show_vxlan_sg_hash_entry(struct hash_bucket *backet, void *arg)  {  	pim_show_vxlan_sg_entry((struct pim_vxlan_sg *)backet->data,  		 (struct pim_sg_cache_walk_data *)arg); diff --git a/pimd/pim_hello.c b/pimd/pim_hello.c index 34c5eb43bc..ecdb3a34a7 100644 --- a/pimd/pim_hello.c +++ b/pimd/pim_hello.c @@ -154,7 +154,7 @@ int pim_hello_recv(struct interface *ifp, struct in_addr src_addr,  	struct list *hello_option_addr_list = 0;  	if (PIM_DEBUG_PIM_HELLO) -		on_trace(__PRETTY_FUNCTION__, ifp, src_addr); +		on_trace(__func__, ifp, src_addr);  	pim_ifp = ifp->info;  	zassert(pim_ifp); @@ -180,8 +180,8 @@ int pim_hello_recv(struct interface *ifp, struct in_addr src_addr,  					       sizeof(src_str));  				zlog_debug(  					"%s: short PIM hello TLV size=%d < min=%d from %s on interface %s", -					__PRETTY_FUNCTION__, remain, -					PIM_TLV_MIN_SIZE, src_str, ifp->name); +					__func__, remain, PIM_TLV_MIN_SIZE, +					src_str, ifp->name);  			}  			FREE_ADDR_LIST_THEN_RETURN(-1);  		} @@ -198,9 +198,9 @@ int pim_hello_recv(struct interface *ifp, struct in_addr src_addr,  					       sizeof(src_str));  				zlog_debug(  					"%s: long PIM hello TLV type=%d length=%d > left=%td from %s on interface %s", -					__PRETTY_FUNCTION__, option_type, -					option_len, tlv_pastend - tlv_curr, -					src_str, ifp->name); +					__func__, option_type, option_len, +					tlv_pastend - tlv_curr, src_str, +					ifp->name);  			}  			FREE_ADDR_LIST_THEN_RETURN(-2);  		} @@ -211,8 +211,8 @@ int pim_hello_recv(struct interface *ifp, struct in_addr src_addr,  				       sizeof(src_str));  			zlog_debug(  				"%s: parse left_size=%d: PIM hello TLV type=%d length=%d from %s on %s", -				__PRETTY_FUNCTION__, remain, option_type, -				option_len, src_str, ifp->name); +				__func__, remain, option_type, option_len, +				src_str, ifp->name);  		}  		switch (option_type) { @@ -264,8 +264,8 @@ int pim_hello_recv(struct interface *ifp, struct in_addr src_addr,  					       sizeof(src_str));  				zlog_debug(  					"%s: ignoring PIM hello dense-mode state refresh TLV option type=%d length=%d from %s on interface %s", -					__PRETTY_FUNCTION__, option_type, -					option_len, src_str, ifp->name); +					__func__, option_type, option_len, +					src_str, ifp->name);  			}  			break;  		default: @@ -275,8 +275,8 @@ int pim_hello_recv(struct interface *ifp, struct in_addr src_addr,  					       sizeof(src_str));  				zlog_debug(  					"%s: ignoring unknown PIM hello TLV type=%d length=%d from %s on interface %s", -					__PRETTY_FUNCTION__, option_type, -					option_len, src_str, ifp->name); +					__func__, option_type, option_len, +					src_str, ifp->name);  			}  		} @@ -288,44 +288,38 @@ int pim_hello_recv(struct interface *ifp, struct in_addr src_addr,  	*/  	if (PIM_DEBUG_PIM_HELLO) { -		tlv_trace_uint16(__PRETTY_FUNCTION__, "holdtime", ifp->name, -				 src_addr, +		tlv_trace_uint16(__func__, "holdtime", ifp->name, src_addr,  				 PIM_OPTION_IS_SET(hello_options,  						   PIM_OPTION_MASK_HOLDTIME),  				 hello_option_holdtime);  		tlv_trace_uint16( -			__PRETTY_FUNCTION__, "propagation_delay", ifp->name, -			src_addr, +			__func__, "propagation_delay", ifp->name, src_addr,  			PIM_OPTION_IS_SET(hello_options,  					  PIM_OPTION_MASK_LAN_PRUNE_DELAY),  			hello_option_propagation_delay);  		tlv_trace_uint16( -			__PRETTY_FUNCTION__, "override_interval", ifp->name, -			src_addr, +			__func__, "override_interval", ifp->name, src_addr,  			PIM_OPTION_IS_SET(hello_options,  					  PIM_OPTION_MASK_LAN_PRUNE_DELAY),  			hello_option_override_interval);  		tlv_trace_bool( -			__PRETTY_FUNCTION__, "can_disable_join_suppression", -			ifp->name, src_addr, +			__func__, "can_disable_join_suppression", ifp->name, +			src_addr,  			PIM_OPTION_IS_SET(hello_options,  					  PIM_OPTION_MASK_LAN_PRUNE_DELAY),  			PIM_OPTION_IS_SET(  				hello_options,  				PIM_OPTION_MASK_CAN_DISABLE_JOIN_SUPPRESSION)); -		tlv_trace_uint32(__PRETTY_FUNCTION__, "dr_priority", ifp->name, -				 src_addr, +		tlv_trace_uint32(__func__, "dr_priority", ifp->name, src_addr,  				 PIM_OPTION_IS_SET(hello_options,  						   PIM_OPTION_MASK_DR_PRIORITY),  				 hello_option_dr_priority);  		tlv_trace_uint32_hex( -			__PRETTY_FUNCTION__, "generation_id", ifp->name, -			src_addr, +			__func__, "generation_id", ifp->name, src_addr,  			PIM_OPTION_IS_SET(hello_options,  					  PIM_OPTION_MASK_GENERATION_ID),  			hello_option_generation_id); -		tlv_trace_list(__PRETTY_FUNCTION__, "address_list", ifp->name, -			       src_addr, +		tlv_trace_list(__func__, "address_list", ifp->name, src_addr,  			       PIM_OPTION_IS_SET(hello_options,  						 PIM_OPTION_MASK_ADDRESS_LIST),  			       hello_option_addr_list); @@ -338,7 +332,7 @@ int pim_hello_recv(struct interface *ifp, struct in_addr src_addr,  				       sizeof(src_str));  			zlog_debug(  				"%s: PIM hello missing holdtime from %s on interface %s", -				__PRETTY_FUNCTION__, src_str, ifp->name); +				__func__, src_str, ifp->name);  		}  	} @@ -363,16 +357,16 @@ int pim_hello_recv(struct interface *ifp, struct in_addr src_addr,  					       sizeof(src_str));  				zlog_warn(  					"%s: failure creating PIM neighbor %s on interface %s", -					__PRETTY_FUNCTION__, src_str, -					ifp->name); +					__func__, src_str, ifp->name);  			}  			FREE_ADDR_LIST_THEN_RETURN(-8);  		}  		/* Forward BSM if required */  		if (!pim_bsm_new_nbr_fwd(neigh, ifp)) {  			if (PIM_DEBUG_PIM_HELLO) -				zlog_debug("%s: forwarding bsm to new nbr failed", -					   __PRETTY_FUNCTION__); +				zlog_debug( +					"%s: forwarding bsm to new nbr failed", +					__func__);  		}  		/* actual addr list has been saved under neighbor */ @@ -396,8 +390,7 @@ int pim_hello_recv(struct interface *ifp, struct in_addr src_addr,  					       sizeof(src_str));  				zlog_debug(  					"%s: GenId mismatch new=%08x old=%08x: replacing neighbor %s on %s", -					__PRETTY_FUNCTION__, -					hello_option_generation_id, +					__func__, hello_option_generation_id,  					neigh->generation_id, src_str,  					ifp->name);  			} @@ -422,16 +415,16 @@ int pim_hello_recv(struct interface *ifp, struct in_addr src_addr,  						       sizeof(src_str));  					zlog_debug(  						"%s: failure re-creating PIM neighbor %s on interface %s", -						__PRETTY_FUNCTION__, src_str, -						ifp->name); +						__func__, src_str, ifp->name);  				}  				FREE_ADDR_LIST_THEN_RETURN(-9);  			}  			/* Forward BSM if required */  			if (!pim_bsm_new_nbr_fwd(neigh, ifp)) {  				if (PIM_DEBUG_PIM_HELLO) -					zlog_debug("%s: forwarding bsm to new nbr failed", -						   __PRETTY_FUNCTION__); +					zlog_debug( +						"%s: forwarding bsm to new nbr failed", +						__func__);  			}  			/* actual addr list is saved under neighbor */  			return 0; @@ -473,7 +466,7 @@ int pim_hello_build_tlv(struct interface *ifp, uint8_t *tlv_buf,  		if (PIM_DEBUG_PIM_HELLO) {  			zlog_debug(  				"%s: could not set PIM hello Holdtime option for interface %s", -				__PRETTY_FUNCTION__, ifp->name); +				__func__, ifp->name);  		}  		return -1;  	} @@ -486,7 +479,7 @@ int pim_hello_build_tlv(struct interface *ifp, uint8_t *tlv_buf,  		if (PIM_DEBUG_PIM_HELLO) {  			zlog_debug(  				"%s: could not set PIM LAN Prune Delay option for interface %s", -				__PRETTY_FUNCTION__, ifp->name); +				__func__, ifp->name);  		}  		return -1;  	} @@ -502,7 +495,7 @@ int pim_hello_build_tlv(struct interface *ifp, uint8_t *tlv_buf,  		if (PIM_DEBUG_PIM_HELLO) {  			zlog_debug(  				"%s: could not set PIM hello DR Priority option for interface %s", -				__PRETTY_FUNCTION__, ifp->name); +				__func__, ifp->name);  		}  		return -2;  	} @@ -515,7 +508,7 @@ int pim_hello_build_tlv(struct interface *ifp, uint8_t *tlv_buf,  		if (PIM_DEBUG_PIM_HELLO) {  			zlog_debug(  				"%s: could not set PIM hello Generation ID option for interface %s", -				__PRETTY_FUNCTION__, ifp->name); +				__func__, ifp->name);  		}  		return -3;  	} @@ -528,7 +521,7 @@ int pim_hello_build_tlv(struct interface *ifp, uint8_t *tlv_buf,  			if (PIM_DEBUG_PIM_HELLO) {  				zlog_debug(  					"%s: could not set PIM hello v4 Secondary Address List option for interface %s", -					__PRETTY_FUNCTION__, ifp->name); +					__func__, ifp->name);  			}  			return -4;  		} @@ -539,7 +532,7 @@ int pim_hello_build_tlv(struct interface *ifp, uint8_t *tlv_buf,  				if (PIM_DEBUG_PIM_HELLO) {  					zlog_debug(  						"%s: could not sent PIM hello v6 secondary Address List option for interface %s", -						__PRETTY_FUNCTION__, ifp->name); +						__func__, ifp->name);  				}  				return -4;  			} diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c index 8cc720c535..cb31878e01 100644 --- a/pimd/pim_iface.c +++ b/pimd/pim_iface.c @@ -314,9 +314,9 @@ static int detect_primary_address_change(struct interface *ifp,  			       sizeof(new_prim_str));  		pim_inet4_dump("<old?>", pim_ifp->primary_address, old_prim_str,  			       sizeof(old_prim_str)); -		zlog_debug("%s: old=%s new=%s on interface %s: %s", -			   __PRETTY_FUNCTION__, old_prim_str, new_prim_str, -			   ifp->name, changed ? "changed" : "unchanged"); +		zlog_debug("%s: old=%s new=%s on interface %s: %s", __func__, +			   old_prim_str, new_prim_str, ifp->name, +			   changed ? "changed" : "unchanged");  	}  	if (changed) { @@ -487,8 +487,7 @@ int pim_update_source_set(struct interface *ifp, struct in_addr source)  	}  	pim_ifp->update_source = source; -	detect_address_change(ifp, 0 /* force_prim_as_any */, -			      __PRETTY_FUNCTION__); +	detect_address_change(ifp, 0 /* force_prim_as_any */, __func__);  	return PIM_SUCCESS;  } @@ -515,7 +514,7 @@ void pim_if_addr_add(struct connected *ifc)  		char buf[BUFSIZ];  		prefix2str(ifc->address, buf, BUFSIZ);  		zlog_debug("%s: %s ifindex=%d connected IP address %s %s", -			   __PRETTY_FUNCTION__, ifp->name, ifp->ifindex, buf, +			   __func__, ifp->name, ifp->ifindex, buf,  			   CHECK_FLAG(ifc->flags, ZEBRA_IFA_SECONDARY)  				   ? "secondary"  				   : "primary"); @@ -523,7 +522,7 @@ void pim_if_addr_add(struct connected *ifc)  	ifaddr = ifc->address->u.prefix4; -	detect_address_change(ifp, 0, __PRETTY_FUNCTION__); +	detect_address_change(ifp, 0, __func__);  	// if (ifc->address->family != AF_INET)  	//  return; @@ -571,8 +570,8 @@ void pim_if_addr_add(struct connected *ifc)  						source_str, sizeof(source_str));  					zlog_warn(  						"%s: igmp_join_sock() failure for IGMP group %s source %s on interface %s", -						__PRETTY_FUNCTION__, group_str, -						source_str, ifp->name); +						__func__, group_str, source_str, +						ifp->name);  					/* warning only */  				} else  					ij->sock_fd = join_fd; @@ -712,13 +711,13 @@ void pim_if_addr_del(struct connected *ifc, int force_prim_as_any)  		char buf[BUFSIZ];  		prefix2str(ifc->address, buf, BUFSIZ);  		zlog_debug("%s: %s ifindex=%d disconnected IP address %s %s", -			   __PRETTY_FUNCTION__, ifp->name, ifp->ifindex, buf, +			   __func__, ifp->name, ifp->ifindex, buf,  			   CHECK_FLAG(ifc->flags, ZEBRA_IFA_SECONDARY)  				   ? "secondary"  				   : "primary");  	} -	detect_address_change(ifp, force_prim_as_any, __PRETTY_FUNCTION__); +	detect_address_change(ifp, force_prim_as_any, __func__);  	pim_if_addr_del_igmp(ifc);  	pim_if_addr_del_pim(ifc); @@ -877,7 +876,7 @@ struct in_addr pim_find_primary_addr(struct interface *ifp)  		if (PIM_INADDR_IS_ANY(p->u.prefix4)) {  			zlog_warn(  				"%s: null IPv4 address connected to interface %s", -				__PRETTY_FUNCTION__, ifp->name); +				__func__, ifp->name);  			continue;  		} @@ -947,14 +946,14 @@ int pim_if_add_vif(struct interface *ifp, bool ispimreg, bool is_vxlan_term)  	if (pim_ifp->mroute_vif_index > 0) {  		zlog_warn("%s: vif_index=%d > 0 on interface %s ifindex=%d", -			  __PRETTY_FUNCTION__, pim_ifp->mroute_vif_index, -			  ifp->name, ifp->ifindex); +			  __func__, pim_ifp->mroute_vif_index, ifp->name, +			  ifp->ifindex);  		return -1;  	}  	if (ifp->ifindex < 0) { -		zlog_warn("%s: ifindex=%d < 1 on interface %s", -			  __PRETTY_FUNCTION__, ifp->ifindex, ifp->name); +		zlog_warn("%s: ifindex=%d < 1 on interface %s", __func__, +			  ifp->ifindex, ifp->name);  		return -2;  	} @@ -962,7 +961,7 @@ int pim_if_add_vif(struct interface *ifp, bool ispimreg, bool is_vxlan_term)  	if (!ispimreg && !is_vxlan_term && PIM_INADDR_IS_ANY(ifaddr)) {  		zlog_warn(  			"%s: could not get address for interface %s ifindex=%d", -			__PRETTY_FUNCTION__, ifp->name, ifp->ifindex); +			__func__, ifp->name, ifp->ifindex);  		return -4;  	} @@ -971,7 +970,7 @@ int pim_if_add_vif(struct interface *ifp, bool ispimreg, bool is_vxlan_term)  	if (pim_ifp->mroute_vif_index >= MAXVIFS) {  		zlog_warn(  			"%s: Attempting to configure more than MAXVIFS=%d on pim enabled interface %s", -			__PRETTY_FUNCTION__, MAXVIFS, ifp->name); +			__func__, MAXVIFS, ifp->name);  		return -3;  	} @@ -1001,8 +1000,8 @@ int pim_if_del_vif(struct interface *ifp)  	if (pim_ifp->mroute_vif_index < 1) {  		zlog_warn("%s: vif_index=%d < 1 on interface %s ifindex=%d", -			  __PRETTY_FUNCTION__, pim_ifp->mroute_vif_index, -			  ifp->name, ifp->ifindex); +			  __func__, pim_ifp->mroute_vif_index, ifp->name, +			  ifp->ifindex);  		return -1;  	} @@ -1129,8 +1128,8 @@ struct pim_neighbor *pim_if_find_neighbor(struct interface *ifp,  	pim_ifp = ifp->info;  	if (!pim_ifp) { -		zlog_warn("%s: multicast not enabled on interface %s", -			  __PRETTY_FUNCTION__, ifp->name); +		zlog_warn("%s: multicast not enabled on interface %s", __func__, +			  ifp->name);  		return 0;  	} @@ -1155,7 +1154,7 @@ struct pim_neighbor *pim_if_find_neighbor(struct interface *ifp,  		pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str));  		zlog_debug(  			"%s: neighbor not found for address %s on interface %s", -			__PRETTY_FUNCTION__, addr_str, ifp->name); +			__func__, addr_str, ifp->name);  	}  	return NULL; @@ -1223,8 +1222,8 @@ static int igmp_join_sock(const char *ifname, ifindex_t ifindex,  			       sizeof(source_str));  		zlog_warn(  			"%s: setsockopt(fd=%d) failure for IGMP group %s source %s ifindex %d on interface %s: errno=%d: %s", -			__PRETTY_FUNCTION__, join_fd, group_str, source_str, -			ifindex, ifname, errno, safe_strerror(errno)); +			__func__, join_fd, group_str, source_str, ifindex, +			ifname, errno, safe_strerror(errno));  		close(join_fd);  		return -2; @@ -1256,7 +1255,7 @@ static struct igmp_join *igmp_join_new(struct interface *ifp,  			       sizeof(source_str));  		zlog_warn(  			"%s: igmp_join_sock() failure for IGMP group %s source %s on interface %s", -			__PRETTY_FUNCTION__, group_str, source_str, ifp->name); +			__func__, group_str, source_str, ifp->name);  		return 0;  	} @@ -1308,7 +1307,7 @@ ferr_r pim_if_igmp_join_add(struct interface *ifp, struct in_addr group_addr,  			       sizeof(source_str));  		zlog_debug(  			"%s: issued static igmp join for channel (S,G)=(%s,%s) on interface %s", -			__PRETTY_FUNCTION__, source_str, group_str, ifp->name); +			__func__, source_str, group_str, ifp->name);  	}  	return ferr_ok(); @@ -1323,14 +1322,14 @@ int pim_if_igmp_join_del(struct interface *ifp, struct in_addr group_addr,  	pim_ifp = ifp->info;  	if (!pim_ifp) { -		zlog_warn("%s: multicast not enabled on interface %s", -			  __PRETTY_FUNCTION__, ifp->name); +		zlog_warn("%s: multicast not enabled on interface %s", __func__, +			  ifp->name);  		return -1;  	}  	if (!pim_ifp->igmp_join_list) { -		zlog_warn("%s: no IGMP join on interface %s", -			  __PRETTY_FUNCTION__, ifp->name); +		zlog_warn("%s: no IGMP join on interface %s", __func__, +			  ifp->name);  		return -2;  	} @@ -1344,7 +1343,7 @@ int pim_if_igmp_join_del(struct interface *ifp, struct in_addr group_addr,  			       sizeof(source_str));  		zlog_warn(  			"%s: could not find IGMP group %s source %s on interface %s", -			__PRETTY_FUNCTION__, group_str, source_str, ifp->name); +			__func__, group_str, source_str, ifp->name);  		return -3;  	} @@ -1357,8 +1356,8 @@ int pim_if_igmp_join_del(struct interface *ifp, struct in_addr group_addr,  			       sizeof(source_str));  		zlog_warn(  			"%s: failure closing sock_fd=%d for IGMP group %s source %s on interface %s: errno=%d: %s", -			__PRETTY_FUNCTION__, ij->sock_fd, group_str, source_str, -			ifp->name, errno, safe_strerror(errno)); +			__func__, ij->sock_fd, group_str, source_str, ifp->name, +			errno, safe_strerror(errno));  		/* warning only */  	}  	listnode_delete(pim_ifp->igmp_join_list, ij); @@ -1380,8 +1379,8 @@ static void pim_if_igmp_join_del_all(struct interface *ifp)  	pim_ifp = ifp->info;  	if (!pim_ifp) { -		zlog_warn("%s: multicast not enabled on interface %s", -			  __PRETTY_FUNCTION__, ifp->name); +		zlog_warn("%s: multicast not enabled on interface %s", __func__, +			  ifp->name);  		return;  	} @@ -1546,8 +1545,8 @@ int pim_ifp_create(struct interface *ifp)  	if (PIM_DEBUG_ZEBRA) {  		zlog_debug(  			"%s: %s index %d(%u) flags %ld metric %d mtu %d operative %d", -			__PRETTY_FUNCTION__, ifp->name, ifp->ifindex, -			ifp->vrf_id, (long)ifp->flags, ifp->metric, ifp->mtu, +			__func__, ifp->name, ifp->ifindex, ifp->vrf_id, +			(long)ifp->flags, ifp->metric, ifp->mtu,  			if_is_operative(ifp));  	} @@ -1599,8 +1598,8 @@ int pim_ifp_up(struct interface *ifp)  	if (PIM_DEBUG_ZEBRA) {  		zlog_debug(  			"%s: %s index %d(%u) flags %ld metric %d mtu %d operative %d", -			__PRETTY_FUNCTION__, ifp->name, ifp->ifindex, -			ifp->vrf_id, (long)ifp->flags, ifp->metric, ifp->mtu, +			__func__, ifp->name, ifp->ifindex, ifp->vrf_id, +			(long)ifp->flags, ifp->metric, ifp->mtu,  			if_is_operative(ifp));  	} @@ -1636,7 +1635,7 @@ int pim_ifp_up(struct interface *ifp)  				if (!master) {  					zlog_debug(  						"%s: Unable to find Master interface for %s", -						__PRETTY_FUNCTION__, vrf->name); +						__func__, vrf->name);  					return 0;  				}  				pim_zebra_interface_set_master(master, ifp); @@ -1651,8 +1650,8 @@ int pim_ifp_down(struct interface *ifp)  	if (PIM_DEBUG_ZEBRA) {  		zlog_debug(  			"%s: %s index %d(%u) flags %ld metric %d mtu %d operative %d", -			__PRETTY_FUNCTION__, ifp->name, ifp->ifindex, -			ifp->vrf_id, (long)ifp->flags, ifp->metric, ifp->mtu, +			__func__, ifp->name, ifp->ifindex, ifp->vrf_id, +			(long)ifp->flags, ifp->metric, ifp->mtu,  			if_is_operative(ifp));  	} @@ -1687,8 +1686,8 @@ int pim_ifp_destroy(struct interface *ifp)  	if (PIM_DEBUG_ZEBRA) {  		zlog_debug(  			"%s: %s index %d(%u) flags %ld metric %d mtu %d operative %d", -			__PRETTY_FUNCTION__, ifp->name, ifp->ifindex, -			ifp->vrf_id, (long)ifp->flags, ifp->metric, ifp->mtu, +			__func__, ifp->name, ifp->ifindex, ifp->vrf_id, +			(long)ifp->flags, ifp->metric, ifp->mtu,  			if_is_operative(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 2ea1f4e9a4..8d8534a794 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,22 +202,22 @@ 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, -			__PRETTY_FUNCTION__); +		up = pim_upstream_del(pim_ifp->pim, ch->upstream, __func__);  	else {  		if (PIM_DEBUG_PIM_TRACE) -			zlog_debug("%s: Avoiding deletion of upstream with ref_count %d " -				   "from ifchannel(%s): %s", __PRETTY_FUNCTION__, -				   ch->upstream->ref_count, ch->interface->name, -				   ch->sg_str); +			zlog_debug( +				"%s: Avoiding deletion of upstream with ref_count %d " +				"from ifchannel(%s): %s", +				__func__, ch->upstream->ref_count, +				ch->interface->name, ch->sg_str);  	}  	ch->upstream = NULL; @@ -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 ", -			   __PRETTY_FUNCTION__, ch->sg_str); +		zlog_debug("%s: ifchannel entry %s is deleted ", __func__, +			   ch->sg_str);  	XFREE(MTYPE_PIM_IFCHANNEL, ch); + +	if (up) +		pim_upstream_update_join_desired(pim_ifp->pim, up);  }  void pim_ifchannel_delete_all(struct interface *ifp) @@ -231,8 +255,7 @@ void pim_ifchannel_delete_all(struct interface *ifp)  	while (!RB_EMPTY(pim_ifchannel_rb, &pim_ifp->ifchannel_rb)) {  		ch = RB_ROOT(pim_ifchannel_rb, &pim_ifp->ifchannel_rb); -		pim_ifchannel_ifjoin_switch(__PRETTY_FUNCTION__, -				ch, PIM_IFJOIN_NOINFO); +		pim_ifchannel_ifjoin_switch(__func__, ch, PIM_IFJOIN_NOINFO);  		pim_ifchannel_delete(ch);  	}  } @@ -264,7 +287,7 @@ void pim_ifchannel_ifjoin_switch(const char *caller, struct pim_ifchannel *ch,  		if (PIM_DEBUG_PIM_EVENTS) {  			zlog_debug(  				"%s calledby %s: non-transition on state %d (%s)", -				__PRETTY_FUNCTION__, caller, new_state, +				__func__, caller, new_state,  				pim_ifchannel_ifjoin_name(new_state, 0));  		}  		return; @@ -287,8 +310,7 @@ void pim_ifchannel_ifjoin_switch(const char *caller, struct pim_ifchannel *ch,  					if (PIM_DEBUG_PIM_TRACE)  						zlog_debug(  							"%s %s: Prune(S,G)=%s from %s", -							__FILE__, -							__PRETTY_FUNCTION__, +							__FILE__, __func__,  							child->sg_str,  							up->sg_str);  					if (!c_oil) @@ -314,8 +336,7 @@ void pim_ifchannel_ifjoin_switch(const char *caller, struct pim_ifchannel *ch,  					if (PIM_DEBUG_PIM_TRACE)  						zlog_debug(  							"%s %s: Join(S,G)=%s from %s", -							__FILE__, -							__PRETTY_FUNCTION__, +							__FILE__, __func__,  							child->sg_str,  							up->sg_str); @@ -438,7 +459,7 @@ struct pim_ifchannel *pim_ifchannel_find(struct interface *ifp,  	if (!pim_ifp) {  		zlog_warn("%s: (S,G)=%s: multicast not enabled on interface %s", -			  __PRETTY_FUNCTION__, pim_str_sg_dump(sg), ifp->name); +			  __func__, pim_str_sg_dump(sg), ifp->name);  		return NULL;  	} @@ -459,7 +480,7 @@ static void ifmembership_set(struct pim_ifchannel *ch,  	if (PIM_DEBUG_PIM_EVENTS) {  		zlog_debug("%s: (S,G)=%s membership now is %s on interface %s", -			   __PRETTY_FUNCTION__, ch->sg_str, +			   __func__, ch->sg_str,  			   membership == PIM_IFMEMBERSHIP_INCLUDE ? "INCLUDE"  								  : "NOINFO",  			   ch->interface->name); @@ -564,8 +585,7 @@ struct pim_ifchannel *pim_ifchannel_add(struct interface *ifp,  	RB_INSERT(pim_ifchannel_rb, &pim_ifp->ifchannel_rb, ch); -	up = pim_upstream_add(pim_ifp->pim, sg, NULL, up_flags, -			      __PRETTY_FUNCTION__, ch); +	up = pim_upstream_add(pim_ifp->pim, sg, NULL, up_flags, __func__, ch);  	ch->upstream = up; @@ -590,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 ", __PRETTY_FUNCTION__, -			   ch->sg_str); +		zlog_debug("%s: ifchannel %s(%s) is created ", __func__, +			   ch->sg_str, ch->interface->name);  	return ch;  } @@ -600,7 +638,7 @@ struct pim_ifchannel *pim_ifchannel_add(struct interface *ifp,  static void ifjoin_to_noinfo(struct pim_ifchannel *ch, bool ch_del)  {  	pim_forward_stop(ch, !ch_del); -	pim_ifchannel_ifjoin_switch(__PRETTY_FUNCTION__, ch, PIM_IFJOIN_NOINFO); +	pim_ifchannel_ifjoin_switch(__func__, ch, PIM_IFJOIN_NOINFO);  	if (ch_del)  		delete_on_noinfo(ch);  } @@ -612,7 +650,7 @@ static int on_ifjoin_expiry_timer(struct thread *t)  	ch = THREAD_ARG(t);  	if (PIM_DEBUG_PIM_TRACE) -		zlog_debug("%s: ifchannel %s expiry timer", __PRETTY_FUNCTION__, +		zlog_debug("%s: ifchannel %s expiry timer", __func__,  			   ch->sg_str);  	ifjoin_to_noinfo(ch, true); @@ -633,7 +671,7 @@ static int on_ifjoin_prune_pending_timer(struct thread *t)  	if (PIM_DEBUG_PIM_TRACE)  		zlog_debug(  			"%s: IFCHANNEL%s %s Prune Pending Timer Popped", -			__PRETTY_FUNCTION__, pim_str_sg_dump(&ch->sg), +			__func__, pim_str_sg_dump(&ch->sg),  			pim_ifchannel_ifjoin_name(ch->ifjoin_state, ch->flags));  	if (ch->ifjoin_state == PIM_IFJOIN_PRUNE_PENDING) { @@ -695,8 +733,8 @@ static void check_recv_upstream(int is_join, struct interface *recv_ifp,  	if (pim_rpf_addr_is_inaddr_any(&up->rpf)) {  		/* RPF'(S,G) not found */ -		zlog_warn("%s %s: RPF'%s not found", __FILE__, -			  __PRETTY_FUNCTION__, up->sg_str); +		zlog_warn("%s %s: RPF'%s not found", __FILE__, __func__, +			  up->sg_str);  		return;  	} @@ -709,8 +747,8 @@ static void check_recv_upstream(int is_join, struct interface *recv_ifp,  			      sizeof(rpf_str));  		zlog_warn(  			"%s %s: (S,G)=%s upstream=%s not directed to RPF'(S,G)=%s on interface %s", -			__FILE__, __PRETTY_FUNCTION__, up->sg_str, up_str, -			rpf_str, recv_ifp->name); +			__FILE__, __func__, up->sg_str, up_str, rpf_str, +			recv_ifp->name);  		return;  	}  	/* upstream directed to RPF'(S,G) */ @@ -761,7 +799,7 @@ static int nonlocal_upstream(int is_join, struct interface *recv_ifp,  		char up_str[INET_ADDRSTRLEN];  		pim_inet4_dump("<upstream?>", upstream, up_str, sizeof(up_str));  		zlog_warn("%s: recv %s (S,G)=%s to non-local upstream=%s on %s", -			  __PRETTY_FUNCTION__, is_join ? "join" : "prune", +			  __func__, is_join ? "join" : "prune",  			  pim_str_sg_dump(sg), up_str, recv_ifp->name);  	} @@ -778,8 +816,7 @@ static int nonlocal_upstream(int is_join, struct interface *recv_ifp,  static void pim_ifchannel_ifjoin_handler(struct pim_ifchannel *ch,  		struct pim_interface *pim_ifp)  { -	pim_ifchannel_ifjoin_switch(__PRETTY_FUNCTION__, ch, -			PIM_IFJOIN_JOIN); +	pim_ifchannel_ifjoin_switch(__func__, ch, PIM_IFJOIN_JOIN);  	PIM_IF_FLAG_UNSET_S_G_RPT(ch->flags);  	/* check if the interface qualifies as an immediate  	 * OIF @@ -833,8 +870,7 @@ void pim_ifchannel_join_add(struct interface *ifp, struct in_addr neigh_addr,  		pim_inet4_dump("<neigh?>", neigh_addr, neigh_str,  			       sizeof(neigh_str));  		zlog_warn("%s: Assert Loser recv Join%s from %s on %s", -			  __PRETTY_FUNCTION__, ch->sg_str, neigh_str, -			  ifp->name); +			  __func__, ch->sg_str, neigh_str, ifp->name);  		assert_action_a5(ch);  	} @@ -844,8 +880,7 @@ void pim_ifchannel_join_add(struct interface *ifp, struct in_addr neigh_addr,  	switch (ch->ifjoin_state) {  	case PIM_IFJOIN_NOINFO: -		pim_ifchannel_ifjoin_switch(__PRETTY_FUNCTION__, ch, -					    PIM_IFJOIN_JOIN); +		pim_ifchannel_ifjoin_switch(__func__, ch, PIM_IFJOIN_JOIN);  		if (pim_macro_chisin_oiflist(ch)) {  			pim_upstream_inherited_olist(pim_ifp->pim,  						     ch->upstream); @@ -861,7 +896,7 @@ void pim_ifchannel_join_add(struct interface *ifp, struct in_addr neigh_addr,  			 & PIM_UPSTREAM_FLAG_MASK_SRC_LHR)) {  			pim_upstream_ref(ch->upstream,  					 PIM_UPSTREAM_FLAG_MASK_SRC_LHR, -					 __PRETTY_FUNCTION__); +					 __func__);  			pim_upstream_keep_alive_timer_start(  				ch->upstream, pim_ifp->pim->keep_alive_time);  		} @@ -903,7 +938,7 @@ void pim_ifchannel_join_add(struct interface *ifp, struct in_addr neigh_addr,  		break;  	case PIM_IFJOIN_PRUNE:  		if (source_flags & PIM_ENCODE_RPT_BIT) -			pim_ifchannel_ifjoin_switch(__PRETTY_FUNCTION__, ch, +			pim_ifchannel_ifjoin_switch(__func__, ch,  						    PIM_IFJOIN_NOINFO);  		else  			pim_ifchannel_ifjoin_handler(ch, pim_ifp); @@ -912,7 +947,7 @@ void pim_ifchannel_join_add(struct interface *ifp, struct in_addr neigh_addr,  		THREAD_OFF(ch->t_ifjoin_prune_pending_timer);  		if (source_flags & PIM_ENCODE_RPT_BIT) {  			THREAD_OFF(ch->t_ifjoin_expiry_timer); -			pim_ifchannel_ifjoin_switch(__PRETTY_FUNCTION__, ch, +			pim_ifchannel_ifjoin_switch(__func__, ch,  						    PIM_IFJOIN_NOINFO);  		} else {  			pim_ifchannel_ifjoin_handler(ch, pim_ifp); @@ -948,8 +983,8 @@ void pim_ifchannel_prune(struct interface *ifp, struct in_addr upstream,  		if (PIM_DEBUG_PIM_TRACE)  			zlog_debug(  				"%s: Received prune with no relevant ifchannel %s%s state: %d", -				__PRETTY_FUNCTION__, ifp->name, -				pim_str_sg_dump(sg), source_flags); +				__func__, ifp->name, pim_str_sg_dump(sg), +				source_flags);  		return;  	} @@ -995,7 +1030,7 @@ void pim_ifchannel_prune(struct interface *ifp, struct in_addr upstream,  	case PIM_IFJOIN_JOIN:  		THREAD_OFF(ch->t_ifjoin_expiry_timer); -		pim_ifchannel_ifjoin_switch(__PRETTY_FUNCTION__, ch, +		pim_ifchannel_ifjoin_switch(__func__, ch,  					    PIM_IFJOIN_PRUNE_PENDING);  		if (listcount(pim_ifp->pim_neighbor_list) > 1) @@ -1055,16 +1090,15 @@ int pim_ifchannel_local_membership_add(struct interface *ifp,  	if (!pim_ifp) {  		if (PIM_DEBUG_EVENTS)  			zlog_debug("%s:%s Expected pim interface setup for %s", -				   __PRETTY_FUNCTION__, -				   pim_str_sg_dump(sg), ifp->name); +				   __func__, pim_str_sg_dump(sg), ifp->name);  		return 0;  	}  	if (!PIM_IF_TEST_PIM(pim_ifp->options)) {  		if (PIM_DEBUG_EVENTS) -			zlog_debug("%s:%s PIM is not configured on this interface %s", -				   __PRETTY_FUNCTION__, -				   pim_str_sg_dump(sg), ifp->name); +			zlog_debug( +				"%s:%s PIM is not configured on this interface %s", +				__func__, pim_str_sg_dump(sg), ifp->name);  		return 0;  	} @@ -1076,12 +1110,14 @@ int pim_ifchannel_local_membership_add(struct interface *ifp,  			if (PIM_DEBUG_PIM_EVENTS)  				zlog_debug(  					"%s: local membership (S,G)=%s ignored as group is SSM", -					__PRETTY_FUNCTION__, -					pim_str_sg_dump(sg)); +					__func__, pim_str_sg_dump(sg));  			return 1;  		}  	} +	/* 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); @@ -1098,9 +1134,8 @@ int pim_ifchannel_local_membership_add(struct interface *ifp,  		for (ALL_LIST_ELEMENTS_RO(up->sources, up_node, child)) {  			if (PIM_DEBUG_EVENTS)  				zlog_debug("%s %s: IGMP (S,G)=%s(%s) from %s", -					   __FILE__, __PRETTY_FUNCTION__, -					   child->sg_str, ifp->name, -					   up->sg_str); +					   __FILE__, __func__, child->sg_str, +					   ifp->name, up->sg_str);  			ch = pim_ifchannel_find(ifp, &child->sg);  			if (pim_upstream_evaluate_join_desired_interface( @@ -1172,9 +1207,8 @@ void pim_ifchannel_local_membership_del(struct interface *ifp,  			if (PIM_DEBUG_EVENTS)  				zlog_debug("%s %s: Prune(S,G)=%s(%s) from %s", -					   __FILE__, __PRETTY_FUNCTION__, -					   up->sg_str, ifp->name, -					   child->sg_str); +					   __FILE__, __func__, up->sg_str, +					   ifp->name, child->sg_str);  			ch = pim_ifchannel_find(ifp, &child->sg);  			/* @@ -1214,9 +1248,8 @@ void pim_ifchannel_update_could_assert(struct pim_ifchannel *ch)  		pim_inet4_dump("<src?>", ch->sg.src, src_str, sizeof(src_str));  		pim_inet4_dump("<grp?>", ch->sg.grp, grp_str, sizeof(grp_str));  		zlog_debug("%s: CouldAssert(%s,%s,%s) changed from %d to %d", -			   __PRETTY_FUNCTION__, src_str, grp_str, -			   ch->interface->name, old_couldassert, -			   new_couldassert); +			   __func__, src_str, grp_str, ch->interface->name, +			   old_couldassert, new_couldassert);  	}  	if (new_couldassert) { @@ -1263,8 +1296,7 @@ void pim_ifchannel_update_my_assert_metric(struct pim_ifchannel *ch)  			       new_addr_str, sizeof(new_addr_str));  		zlog_debug(  			"%s: my_assert_metric(%s,%s,%s) changed from %u,%u,%u,%s to %u,%u,%u,%s", -			__PRETTY_FUNCTION__, src_str, grp_str, -			ch->interface->name, +			__func__, src_str, grp_str, ch->interface->name,  			ch->ifassert_my_metric.rpt_bit_flag,  			ch->ifassert_my_metric.metric_preference,  			ch->ifassert_my_metric.route_metric, old_addr_str, @@ -1298,8 +1330,8 @@ void pim_ifchannel_update_assert_tracking_desired(struct pim_ifchannel *ch)  		pim_inet4_dump("<grp?>", ch->sg.grp, grp_str, sizeof(grp_str));  		zlog_debug(  			"%s: AssertTrackingDesired(%s,%s,%s) changed from %d to %d", -			__PRETTY_FUNCTION__, src_str, grp_str, -			ch->interface->name, old_atd, new_atd); +			__func__, src_str, grp_str, ch->interface->name, +			old_atd, new_atd);  	}  	if (new_atd) { @@ -1368,7 +1400,7 @@ void pim_ifchannel_set_star_g_join_state(struct pim_ifchannel *ch, int eom,  	if (PIM_DEBUG_PIM_TRACE)  		zlog_debug( -			"%s: %s %s eom: %d join %u", __PRETTY_FUNCTION__, +			"%s: %s %s eom: %d join %u", __func__,  			pim_ifchannel_ifjoin_name(ch->ifjoin_state, ch->flags),  			ch->sg_str, eom, join);  	if (!ch->sources) diff --git a/pimd/pim_igmp.c b/pimd/pim_igmp.c index 39ef706f79..8d39d7e800 100644 --- a/pimd/pim_igmp.c +++ b/pimd/pim_igmp.c @@ -64,9 +64,8 @@ static int igmp_sock_open(struct in_addr ifaddr, struct interface *ifp,  		} else {  			zlog_warn(  				"%s %s: IGMP socket fd=%d interface %s: could not solve %s to group address: errno=%d: %s", -				__FILE__, __PRETTY_FUNCTION__, fd, -				inet_ntoa(ifaddr), PIM_ALL_ROUTERS, errno, -				safe_strerror(errno)); +				__FILE__, __func__, fd, inet_ntoa(ifaddr), +				PIM_ALL_ROUTERS, errno, safe_strerror(errno));  		}  	} @@ -81,7 +80,7 @@ static int igmp_sock_open(struct in_addr ifaddr, struct interface *ifp,  	} else {  		zlog_warn(  			"%s %s: IGMP socket fd=%d interface %s: could not solve %s to group address: errno=%d: %s", -			__FILE__, __PRETTY_FUNCTION__, fd, inet_ntoa(ifaddr), +			__FILE__, __func__, fd, inet_ntoa(ifaddr),  			PIM_ALL_SYSTEMS, errno, safe_strerror(errno));  	} @@ -92,7 +91,7 @@ static int igmp_sock_open(struct in_addr ifaddr, struct interface *ifp,  	} else {  		zlog_warn(  			"%s %s: IGMP socket fd=%d interface %s: could not solve %s to group address: errno=%d: %s", -			__FILE__, __PRETTY_FUNCTION__, fd, inet_ntoa(ifaddr), +			__FILE__, __func__, fd, inet_ntoa(ifaddr),  			PIM_ALL_IGMP_ROUTERS, errno, safe_strerror(errno));  	} @@ -119,8 +118,8 @@ static void igmp_sock_dump(array_t *igmp_sock_array)  		struct igmp_sock *igmp = array_get(igmp_sock_array, i);  		zlog_debug("%s %s: [%d/%d] igmp_addr=%s fd=%d", __FILE__, -			   __PRETTY_FUNCTION__, i, size, -			   inet_ntoa(igmp->ifaddr), igmp->fd); +			   __func__, i, size, inet_ntoa(igmp->ifaddr), +			   igmp->fd);  	}  }  #endif @@ -166,8 +165,7 @@ static int pim_igmp_other_querier_expire(struct thread *t)  		char ifaddr_str[INET_ADDRSTRLEN];  		pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str,  			       sizeof(ifaddr_str)); -		zlog_debug("%s: Querier %s resuming", __PRETTY_FUNCTION__, -			   ifaddr_str); +		zlog_debug("%s: Querier %s resuming", __func__, ifaddr_str);  	}  	/* @@ -419,7 +417,7 @@ static int igmp_v1_recv_report(struct igmp_sock *igmp, struct in_addr from,  	struct igmp_group *group;  	struct in_addr group_addr; -	on_trace(__PRETTY_FUNCTION__, igmp->interface, from); +	on_trace(__func__, igmp->interface, from);  	if (igmp->mtrace_only)  		return 0; @@ -435,8 +433,7 @@ static int igmp_v1_recv_report(struct igmp_sock *igmp, struct in_addr from,  	igmp->rx_stats.report_v1++;  	if (PIM_DEBUG_IGMP_TRACE) { -		zlog_warn("%s %s: FIXME WRITEME", __FILE__, -			  __PRETTY_FUNCTION__); +		zlog_warn("%s %s: FIXME WRITEME", __FILE__, __func__);  	}  	memcpy(&group_addr, igmp_msg + 4, sizeof(struct in_addr)); @@ -1014,9 +1011,8 @@ static int igmp_group_timer(struct thread *t)  		char group_str[INET_ADDRSTRLEN];  		pim_inet4_dump("<group?>", group->group_addr, group_str,  			       sizeof(group_str)); -		zlog_debug("%s: Timer for group %s on interface %s", -			   __PRETTY_FUNCTION__, group_str, -			   group->group_igmp_sock->interface->name); +		zlog_debug("%s: Timer for group %s on interface %s", __func__, +			   group_str, group->group_igmp_sock->interface->name);  	}  	zassert(group->group_filtermode_isexcl); @@ -1108,7 +1104,7 @@ struct igmp_group *igmp_add_group_by_addr(struct igmp_sock *igmp,  	if (!pim_is_group_224_4(group_addr)) {  		zlog_warn("%s: Group Specified is not part of 224.0.0.0/4", -			  __PRETTY_FUNCTION__); +			  __func__);  		return NULL;  	} @@ -1116,7 +1112,7 @@ struct igmp_group *igmp_add_group_by_addr(struct igmp_sock *igmp,  		if (PIM_DEBUG_IGMP_TRACE)  			zlog_debug(  				"%s: Group specified %s is part of 224.0.0.0/24", -				__PRETTY_FUNCTION__, inet_ntoa(group_addr)); +				__func__, inet_ntoa(group_addr));  		return NULL;  	}  	/* diff --git a/pimd/pim_igmp_mtrace.c b/pimd/pim_igmp_mtrace.c index 309b8c1495..1cecd976cd 100644 --- a/pimd/pim_igmp_mtrace.c +++ b/pimd/pim_igmp_mtrace.c @@ -132,8 +132,8 @@ static bool mtrace_fwd_info(struct pim_instance *pim,  	if (!up->rpf.source_nexthop.interface) {  		if (PIM_DEBUG_TRACE) -			zlog_debug("%s: up %s RPF is not present", -			__PRETTY_FUNCTION__, up->sg_str); +			zlog_debug("%s: up %s RPF is not present", __func__, +				   up->sg_str);  		return false;  	} diff --git a/pimd/pim_igmpv2.c b/pimd/pim_igmpv2.c index 19c3768813..af598d040d 100644 --- a/pimd/pim_igmpv2.c +++ b/pimd/pim_igmpv2.c @@ -109,7 +109,7 @@ int igmp_v2_recv_report(struct igmp_sock *igmp, struct in_addr from,  	struct in_addr group_addr;  	char group_str[INET_ADDRSTRLEN]; -	on_trace(__PRETTY_FUNCTION__, igmp->interface, from); +	on_trace(__func__, igmp->interface, from);  	if (igmp->mtrace_only)  		return 0; @@ -158,7 +158,7 @@ int igmp_v2_recv_leave(struct igmp_sock *igmp, struct in_addr from,  	struct in_addr group_addr;  	char group_str[INET_ADDRSTRLEN]; -	on_trace(__PRETTY_FUNCTION__, igmp->interface, from); +	on_trace(__func__, igmp->interface, from);  	if (igmp->mtrace_only)  		return 0; diff --git a/pimd/pim_igmpv3.c b/pimd/pim_igmpv3.c index 2d58340c8c..ffd872ce03 100644 --- a/pimd/pim_igmpv3.c +++ b/pimd/pim_igmpv3.c @@ -126,7 +126,7 @@ static int igmp_source_timer(struct thread *t)  			       sizeof(source_str));  		zlog_debug(  			"%s: Source timer expired for group %s source %s on %s", -			__PRETTY_FUNCTION__, group_str, source_str, +			__func__, group_str, source_str,  			group->group_igmp_sock->interface->name);  	} @@ -332,8 +332,7 @@ void igmp_source_free(struct igmp_source *source)  static void source_channel_oil_detach(struct igmp_source *source)  {  	if (source->source_channel_oil) { -		pim_channel_oil_del(source->source_channel_oil, -				    __PRETTY_FUNCTION__); +		pim_channel_oil_del(source->source_channel_oil, __func__);  		source->source_channel_oil = NULL;  	}  } @@ -378,7 +377,7 @@ void igmp_source_delete(struct igmp_source *source)  			       sizeof(source_str));  		zlog_warn(  			"%s: forwarding=ON(!) IGMP source %s for group %s from socket %d interface %s", -			__PRETTY_FUNCTION__, source_str, group_str, +			__func__, source_str, group_str,  			group->group_igmp_sock->fd,  			group->group_igmp_sock->interface->name);  		/* warning only */ @@ -545,8 +544,8 @@ void igmpv3_report_isin(struct igmp_sock *igmp, struct in_addr from,  			struct in_addr group_addr, int num_sources,  			struct in_addr *sources)  { -	on_trace(__PRETTY_FUNCTION__, igmp->interface, from, group_addr, -		 num_sources, sources); +	on_trace(__func__, igmp->interface, from, group_addr, num_sources, +		 sources);  	allow(igmp, from, group_addr, num_sources, sources);  } @@ -654,8 +653,7 @@ void igmpv3_report_isex(struct igmp_sock *igmp, struct in_addr from,  	struct interface *ifp = igmp->interface;  	struct igmp_group *group; -	on_trace(__PRETTY_FUNCTION__, ifp, from, group_addr, num_sources, -		 sources); +	on_trace(__func__, ifp, from, group_addr, num_sources, sources);  	if (pim_is_group_filtered(ifp->info, &group_addr))  		return; @@ -774,8 +772,7 @@ void igmpv3_report_toin(struct igmp_sock *igmp, struct in_addr from,  	struct interface *ifp = igmp->interface;  	struct igmp_group *group; -	on_trace(__PRETTY_FUNCTION__, ifp, from, group_addr, num_sources, -		 sources); +	on_trace(__func__, ifp, from, group_addr, num_sources, sources);  	/*  	 * If the requested filter mode is INCLUDE *and* the requested source @@ -937,8 +934,7 @@ void igmpv3_report_toex(struct igmp_sock *igmp, struct in_addr from,  	struct interface *ifp = igmp->interface;  	struct igmp_group *group; -	on_trace(__PRETTY_FUNCTION__, ifp, from, group_addr, num_sources, -		 sources); +	on_trace(__func__, ifp, from, group_addr, num_sources, sources);  	/* non-existant group is created as INCLUDE {empty} */  	group = igmp_add_group_by_addr(igmp, group_addr); @@ -964,8 +960,8 @@ void igmpv3_report_allow(struct igmp_sock *igmp, struct in_addr from,  			 struct in_addr group_addr, int num_sources,  			 struct in_addr *sources)  { -	on_trace(__PRETTY_FUNCTION__, igmp->interface, from, group_addr, -		 num_sources, sources); +	on_trace(__func__, igmp->interface, from, group_addr, num_sources, +		 sources);  	allow(igmp, from, group_addr, num_sources, sources);  } @@ -1137,7 +1133,7 @@ static int group_retransmit_sources(struct igmp_group *group,  					       group_str, sizeof(group_str));  				zlog_warn(  					"%s: group %s on %s: s_flag=1 unable to fit %d sources into buf_size=%zu (max_sources=%d)", -					__PRETTY_FUNCTION__, group_str, +					__func__, group_str,  					igmp->interface->name,  					num_sources_tosend1, sizeof(query_buf1),  					query_buf1_max_sources); @@ -1181,9 +1177,9 @@ static int group_retransmit_sources(struct igmp_group *group,  				       sizeof(group_str));  			zlog_warn(  				"%s: group %s on %s: s_flag=0 unable to fit %d sources into buf_size=%zu (max_sources=%d)", -				__PRETTY_FUNCTION__, group_str, -				igmp->interface->name, num_sources_tosend2, -				sizeof(query_buf2), query_buf2_max_sources); +				__func__, group_str, igmp->interface->name, +				num_sources_tosend2, sizeof(query_buf2), +				query_buf2_max_sources);  		} else {  			/*  			  RFC3376: 4.1.12. IP Destination Addresses for Queries @@ -1469,8 +1465,7 @@ void igmpv3_report_block(struct igmp_sock *igmp, struct in_addr from,  	struct interface *ifp = igmp->interface;  	struct igmp_group *group; -	on_trace(__PRETTY_FUNCTION__, ifp, from, group_addr, num_sources, -		 sources); +	on_trace(__func__, ifp, from, group_addr, num_sources, sources);  	/* non-existant group is created as INCLUDE {empty} */  	group = igmp_add_group_by_addr(igmp, group_addr); @@ -1524,7 +1519,7 @@ void igmp_group_timer_lower_to_lmqt(struct igmp_group *group)  			       sizeof(group_str));  		zlog_debug(  			"%s: group %s on %s: LMQC=%d LMQI=%d dsec LMQT=%d msec", -			__PRETTY_FUNCTION__, group_str, ifname, lmqc, lmqi_dsec, +			__func__, group_str, ifname, lmqc, lmqi_dsec,  			lmqt_msec);  	} @@ -1564,8 +1559,8 @@ void igmp_source_timer_lower_to_lmqt(struct igmp_source *source)  			       sizeof(source_str));  		zlog_debug(  			"%s: group %s source %s on %s: LMQC=%d LMQI=%d dsec LMQT=%d msec", -			__PRETTY_FUNCTION__, group_str, source_str, ifname, -			lmqc, lmqi_dsec, lmqt_msec); +			__func__, group_str, source_str, ifname, lmqc, +			lmqi_dsec, lmqt_msec);  	}  	igmp_source_timer_on(group, source, lmqt_msec); @@ -1593,8 +1588,7 @@ void igmp_v3_send_query(struct igmp_group *group, int fd, const char *ifname,  		flog_err(  			EC_LIB_DEVELOPMENT,  			"%s %s: unable to send: msg_size=%zd larger than query_buf_size=%d", -			__FILE__, __PRETTY_FUNCTION__, msg_size, -			query_buf_size); +			__FILE__, __func__, msg_size, query_buf_size);  		return;  	} @@ -1691,7 +1685,7 @@ void igmp_v3_send_query(struct igmp_group *group, int fd, const char *ifname,  				       sizeof(group_str));  			zlog_warn(  				"%s: to %s on %s: group=%s sources=%d: s_flag is clear for general query!", -				__PRETTY_FUNCTION__, dst_str, ifname, group_str, +				__func__, dst_str, ifname, group_str,  				num_sources);  		}  	} diff --git a/pimd/pim_instance.c b/pimd/pim_instance.c index 955ad14b01..347b0fc284 100644 --- a/pimd/pim_instance.c +++ b/pimd/pim_instance.c @@ -101,7 +101,7 @@ static struct pim_instance *pim_instance_init(struct vrf *vrf)  					 hash_name);  	if (PIM_DEBUG_ZEBRA) -		zlog_debug("%s: NHT rpf hash init ", __PRETTY_FUNCTION__); +		zlog_debug("%s: NHT rpf hash init ", __func__);  	pim->ssm_info = pim_ssm_init(); @@ -165,7 +165,7 @@ static int pim_vrf_enable(struct vrf *vrf)  {  	struct pim_instance *pim = (struct pim_instance *)vrf->info; -	zlog_debug("%s: for %s", __PRETTY_FUNCTION__, vrf->name); +	zlog_debug("%s: for %s", __func__, vrf->name);  	pim_mroute_socket_enable(pim); diff --git a/pimd/pim_join.c b/pimd/pim_join.c index fbb547c80e..62bd2360c3 100644 --- a/pimd/pim_join.c +++ b/pimd/pim_join.c @@ -64,7 +64,7 @@ static void recv_join(struct interface *ifp, struct pim_neighbor *neigh,  			       sizeof(neigh_str));  		zlog_debug(  			"%s: join (S,G)=%s rpt=%d wc=%d upstream=%s holdtime=%d from %s on %s", -			__PRETTY_FUNCTION__, pim_str_sg_dump(sg), +			__func__, pim_str_sg_dump(sg),  			!!(source_flags & PIM_RPT_BIT_MASK),  			!!(source_flags & PIM_WILDCARD_BIT_MASK), up_str,  			holdtime, neigh_str, ifp->name); @@ -84,8 +84,8 @@ static void recv_join(struct interface *ifp, struct pim_neighbor *neigh,  		struct pim_rpf *rp = RP(pim_ifp->pim, sg->grp);  		if (!rp) { -			zlog_warn("%s: Lookup of RP failed for %pSG4", -				  __PRETTY_FUNCTION__, sg); +			zlog_warn("%s: Lookup of RP failed for %pSG4", __func__, +				  sg);  			return;  		}  		/* @@ -99,8 +99,9 @@ static void recv_join(struct interface *ifp, struct pim_neighbor *neigh,  				       sizeof(received_rp));  			pim_inet4_dump("<local?>", rp->rpf_addr.u.prefix4,  				       local_rp, sizeof(local_rp)); -			zlog_warn("%s: Specified RP(%s) in join is different than our configured RP(%s)", -				  __PRETTY_FUNCTION__, received_rp, local_rp); +			zlog_warn( +				"%s: Specified RP(%s) in join is different than our configured RP(%s)", +				__func__, received_rp, local_rp);  			return;  		} @@ -126,7 +127,7 @@ static void recv_prune(struct interface *ifp, struct pim_neighbor *neigh,  			       sizeof(neigh_str));  		zlog_debug(  			"%s: prune (S,G)=%s rpt=%d wc=%d upstream=%s holdtime=%d from %s on %s", -			__PRETTY_FUNCTION__, pim_str_sg_dump(sg), +			__func__, pim_str_sg_dump(sg),  			source_flags & PIM_RPT_BIT_MASK,  			source_flags & PIM_WILDCARD_BIT_MASK, up_str, holdtime,  			neigh_str, ifp->name); @@ -143,8 +144,9 @@ static void recv_prune(struct interface *ifp, struct pim_neighbor *neigh,  		if (!rp) {  			if (PIM_DEBUG_PIM_TRACE) -				zlog_debug("%s: RP for %pSG4 completely failed lookup", -					   __PRETTY_FUNCTION__, sg); +				zlog_debug( +					"%s: RP for %pSG4 completely failed lookup", +					__func__, sg);  			return;  		}  		// Ignoring Prune *,G's at the moment. @@ -184,7 +186,7 @@ int pim_joinprune_recv(struct interface *ifp, struct pim_neighbor *neigh,  		char src_str[INET_ADDRSTRLEN];  		pim_inet4_dump("<src?>", src_addr, src_str, sizeof(src_str));  		zlog_warn("%s: pim_parse_addr_ucast() failure: from %s on %s", -			  __PRETTY_FUNCTION__, src_str, ifp->name); +			  __func__, src_str, ifp->name);  		return -1;  	}  	buf += addr_offset; @@ -195,9 +197,9 @@ int pim_joinprune_recv(struct interface *ifp, struct pim_neighbor *neigh,  	if (msg_upstream_addr.family != AF_INET) {  		char src_str[INET_ADDRSTRLEN];  		pim_inet4_dump("<src?>", src_addr, src_str, sizeof(src_str)); -		zlog_warn("%s: ignoring join/prune directed to unexpected addr family=%d from %s on %s", -			  __PRETTY_FUNCTION__, msg_upstream_addr.family, -			  src_str, ifp->name); +		zlog_warn( +			"%s: ignoring join/prune directed to unexpected addr family=%d from %s on %s", +			__func__, msg_upstream_addr.family, src_str, ifp->name);  		return -2;  	} @@ -207,7 +209,7 @@ int pim_joinprune_recv(struct interface *ifp, struct pim_neighbor *neigh,  		pim_inet4_dump("<src?>", src_addr, src_str, sizeof(src_str));  		zlog_warn(  			"%s: short join/prune message buffer for group list: size=%d minimum=%d from %s on %s", -			__PRETTY_FUNCTION__, remain, 4, src_str, ifp->name); +			__func__, remain, 4, src_str, ifp->name);  		return -4;  	} @@ -226,8 +228,8 @@ int pim_joinprune_recv(struct interface *ifp, struct pim_neighbor *neigh,  			       upstream_str, sizeof(upstream_str));  		zlog_debug(  			"%s: join/prune upstream=%s groups=%d holdtime=%d from %s on %s", -			__PRETTY_FUNCTION__, upstream_str, msg_num_groups, -			msg_holdtime, src_str, ifp->name); +			__func__, upstream_str, msg_num_groups, msg_holdtime, +			src_str, ifp->name);  	}  	/* Scan groups */ @@ -254,8 +256,7 @@ int pim_joinprune_recv(struct interface *ifp, struct pim_neighbor *neigh,  				       sizeof(src_str));  			zlog_warn(  				"%s: short join/prune buffer for source list: size=%d minimum=%d from %s on %s", -				__PRETTY_FUNCTION__, remain, 4, src_str, -				ifp->name); +				__func__, remain, 4, src_str, ifp->name);  			return -6;  		} @@ -276,7 +277,7 @@ int pim_joinprune_recv(struct interface *ifp, struct pim_neighbor *neigh,  				       sizeof(group_str));  			zlog_debug(  				"%s: join/prune upstream=%s group=%s/32 join_src=%d prune_src=%d from %s on %s", -				__PRETTY_FUNCTION__, upstream_str, group_str, +				__func__, upstream_str, group_str,  				msg_num_joined_sources, msg_num_pruned_sources,  				src_str, ifp->name);  		} @@ -345,8 +346,7 @@ int pim_joinprune_recv(struct interface *ifp, struct pim_neighbor *neigh,  					if (PIM_DEBUG_PIM_TRACE)  						zlog_debug(  							"%s: SGRpt flag is set, del inherit oif from up %s", -							__PRETTY_FUNCTION__, -							up->sg_str); +							__func__, up->sg_str);  					pim_channel_del_inherited_oif(  						up->channel_oil,  						starg_ch->interface, @@ -445,17 +445,15 @@ int pim_joinprune_send(struct pim_rpf *rpf, struct list *groups)  	if (rpf->source_nexthop.interface)  		pim_ifp = rpf->source_nexthop.interface->info;  	else { -		zlog_warn("%s: RPF interface is not present", -			  __PRETTY_FUNCTION__); +		zlog_warn("%s: RPF interface is not present", __func__);  		return -1;  	} -	on_trace(__PRETTY_FUNCTION__, rpf->source_nexthop.interface, -		rpf->rpf_addr.u.prefix4); +	on_trace(__func__, rpf->source_nexthop.interface, +		 rpf->rpf_addr.u.prefix4);  	if (!pim_ifp) { -		zlog_warn("%s: multicast not enabled on interface %s", -			  __PRETTY_FUNCTION__, +		zlog_warn("%s: multicast not enabled on interface %s", __func__,  			  rpf->source_nexthop.interface->name);  		return -1;  	} @@ -466,7 +464,7 @@ int pim_joinprune_send(struct pim_rpf *rpf, struct list *groups)  			pim_inet4_dump("<dst?>", rpf->rpf_addr.u.prefix4,  				       dst_str, sizeof(dst_str));  			zlog_debug("%s: upstream=%s is myself on interface %s", -				   __PRETTY_FUNCTION__, dst_str, +				   __func__, dst_str,  				   rpf->source_nexthop.interface->name);  		}  		return 0; @@ -515,7 +513,7 @@ int pim_joinprune_send(struct pim_rpf *rpf, struct list *groups)  				       sizeof(grp_str));  			zlog_debug(  				"%s: sending (G)=%s to upstream=%s on interface %s", -				__PRETTY_FUNCTION__, grp_str, dst_str, +				__func__, grp_str, dst_str,  				rpf->source_nexthop.interface->name);  		} @@ -530,7 +528,7 @@ int pim_joinprune_send(struct pim_rpf *rpf, struct list *groups)  					 rpf->source_nexthop.interface->name)) {  				zlog_warn(  					"%s: could not send PIM message on interface %s", -					__PRETTY_FUNCTION__, +					__func__,  					rpf->source_nexthop.interface->name);  			} @@ -571,8 +569,7 @@ int pim_joinprune_send(struct pim_rpf *rpf, struct list *groups)  		if (PIM_DEBUG_PIM_TRACE)  			zlog_debug(  				"%s: interface %s num_joins %u num_prunes %u", -				__PRETTY_FUNCTION__, -				rpf->source_nexthop.interface->name, +				__func__, rpf->source_nexthop.interface->name,  				ntohs(grp->joins), ntohs(grp->prunes));  		grp = (struct pim_jp_groups *)curr_ptr; @@ -587,7 +584,7 @@ int pim_joinprune_send(struct pim_rpf *rpf, struct list *groups)  					 rpf->source_nexthop.interface->name)) {  				zlog_warn(  					"%s: could not send PIM message on interface %s", -					__PRETTY_FUNCTION__, +					__func__,  					rpf->source_nexthop.interface->name);  			} @@ -606,8 +603,7 @@ int pim_joinprune_send(struct pim_rpf *rpf, struct list *groups)  				 rpf->source_nexthop.interface->name)) {  			zlog_warn(  				"%s: could not send PIM message on interface %s", -				__PRETTY_FUNCTION__, -				rpf->source_nexthop.interface->name); +				__func__, rpf->source_nexthop.interface->name);  		}  	}  	return 0; diff --git a/pimd/pim_jp_agg.c b/pimd/pim_jp_agg.c index 2662c9eae6..5279a00855 100644 --- a/pimd/pim_jp_agg.c +++ b/pimd/pim_jp_agg.c @@ -239,8 +239,8 @@ void pim_jp_agg_upstream_verification(struct pim_upstream *up, bool ignore)  	if (!up->rpf.source_nexthop.interface) {  		if (PIM_DEBUG_PIM_TRACE) -			zlog_debug("%s: up %s RPF is not present", -				__PRETTY_FUNCTION__, up->sg_str); +			zlog_debug("%s: up %s RPF is not present", __func__, +				   up->sg_str);  		return;  	} diff --git a/pimd/pim_macro.c b/pimd/pim_macro.c index 6691cc00d6..c6961d30c2 100644 --- a/pimd/pim_macro.c +++ b/pimd/pim_macro.c @@ -113,8 +113,7 @@ int pim_macro_ch_lost_assert(const struct pim_ifchannel *ch)  	ifp = ch->interface;  	if (!ifp) { -		zlog_warn("%s: (S,G)=%s: null interface", __PRETTY_FUNCTION__, -			  ch->sg_str); +		zlog_warn("%s: (S,G)=%s: null interface", __func__, ch->sg_str);  		return 0; /* false */  	} @@ -125,7 +124,7 @@ int pim_macro_ch_lost_assert(const struct pim_ifchannel *ch)  	pim_ifp = ifp->info;  	if (!pim_ifp) {  		zlog_warn("%s: (S,G)=%s: multicast not enabled on interface %s", -			  __PRETTY_FUNCTION__, ch->sg_str, ifp->name); +			  __func__, ch->sg_str, ifp->name);  		return 0; /* false */  	} @@ -158,10 +157,11 @@ 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", -			  __PRETTY_FUNCTION__, ch->sg_str, ch->interface->name); +			  __func__, ch->sg_str, ch->interface->name);  		return 0; /* false */  	} @@ -173,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)));  } @@ -221,8 +233,7 @@ int pim_macro_ch_could_assert_eval(const struct pim_ifchannel *ch)  	ifp = ch->interface;  	if (!ifp) { -		zlog_warn("%s: (S,G)=%s: null interface", __PRETTY_FUNCTION__, -			  ch->sg_str); +		zlog_warn("%s: (S,G)=%s: null interface", __func__, ch->sg_str);  		return 0; /* false */  	} @@ -379,15 +390,14 @@ int pim_macro_assert_tracking_desired_eval(const struct pim_ifchannel *ch)  	ifp = ch->interface;  	if (!ifp) { -		zlog_warn("%s: (S,G)=%s: null interface", __PRETTY_FUNCTION__, -			  ch->sg_str); +		zlog_warn("%s: (S,G)=%s: null interface", __func__, ch->sg_str);  		return 0; /* false */  	}  	pim_ifp = ifp->info;  	if (!pim_ifp) {  		zlog_warn("%s: (S,G)=%s: multicast not enabled on interface %s", -			  __PRETTY_FUNCTION__, ch->sg_str, ch->interface->name); +			  __func__, ch->sg_str, ch->interface->name);  		return 0; /* false */  	} diff --git a/pimd/pim_mlag.c b/pimd/pim_mlag.c index 1c2f7c563d..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 @@ -186,13 +266,12 @@ static void pim_mlag_up_peer_add(struct mlag_mroute_add *msg)  		 * doesn't already exist.  		 */  		if (!PIM_UPSTREAM_FLAG_TEST_MLAG_PEER(up->flags)) -			pim_upstream_ref(up, -					PIM_UPSTREAM_FLAG_MASK_MLAG_PEER, -					__PRETTY_FUNCTION__); +			pim_upstream_ref(up, PIM_UPSTREAM_FLAG_MASK_MLAG_PEER, +					 __func__);  	} else {  		PIM_UPSTREAM_FLAG_SET_MLAG_PEER(flags); -		up = pim_upstream_add(pim, &sg, NULL /*iif*/, flags, -				__PRETTY_FUNCTION__, NULL /*if_ch*/); +		up = pim_upstream_add(pim, &sg, NULL /*iif*/, flags, __func__, +				      NULL /*if_ch*/);  		if (!up) {  			if (PIM_DEBUG_MLAG) @@ -211,17 +290,20 @@ static void pim_mlag_up_peer_add(struct mlag_mroute_add *msg)   * - if a local entry continues to exisy and has a MLAG OIF DF election   *   is re-run (at the end of which the local entry will be the DF).   */ -static void pim_mlag_up_peer_deref(struct pim_instance *pim, -		struct pim_upstream *up) +static struct pim_upstream *pim_mlag_up_peer_deref(struct pim_instance *pim, +						   struct pim_upstream *up)  {  	if (!PIM_UPSTREAM_FLAG_TEST_MLAG_PEER(up->flags)) -		return; +		return up;  	PIM_UPSTREAM_FLAG_UNSET_MLAG_PEER(up->flags); -	up = pim_upstream_del(pim, up, __PRETTY_FUNCTION__); +	up = pim_upstream_del(pim, up, __func__);  	if (up)  		pim_mlag_up_df_role_elect(pim, up); + +	return up;  } +  static void pim_mlag_up_peer_del(struct mlag_mroute_del *msg)  {  	struct pim_upstream *up; @@ -257,7 +339,7 @@ static void pim_mlag_up_peer_del(struct mlag_mroute_del *msg)  		return;  	} -	pim_mlag_up_peer_deref(pim, up); +	(void)pim_mlag_up_peer_deref(pim, up);  }  /* When we lose connection to the local MLAG daemon we can drop all peer @@ -301,26 +383,19 @@ static void pim_mlag_up_peer_del_all(void)  			up = listnode_head(temp);  			listnode_delete(temp, up); -			pim_mlag_up_peer_deref(pim, up); +			up = pim_mlag_up_peer_deref(pim, up);  			/*  			 * This is the deletion of the reference added  			 * above  			 */ -			pim_upstream_del(pim, up, __PRETTY_FUNCTION__); +			if (up) +				pim_upstream_del(pim, up, __func__);  		}  	}  	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).   */ @@ -426,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);  		}  	} @@ -447,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) && @@ -691,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); @@ -731,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); @@ -739,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); @@ -749,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); @@ -761,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); @@ -781,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;  } @@ -873,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 */ @@ -891,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++; @@ -920,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--; @@ -940,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 4afd05ab76..f366fdbe79 100644 --- a/pimd/pim_mroute.c +++ b/pimd/pim_mroute.c @@ -65,10 +65,9 @@ static int pim_mroute_set(struct pim_instance *pim, int enable)  					 &data, data_len);  			if (err) {  				zlog_warn( -					  "%s %s: failure: setsockopt(fd=%d,IPPROTO_IP, MRT_TABLE=%d): errno=%d: %s", -					  __FILE__, __PRETTY_FUNCTION__, -					  pim->mroute_socket, data, errno, -					  safe_strerror(errno)); +					"%s %s: failure: setsockopt(fd=%d,IPPROTO_IP, MRT_TABLE=%d): errno=%d: %s", +					__FILE__, __func__, pim->mroute_socket, +					data, errno, safe_strerror(errno));  				return -1;  			} @@ -86,11 +85,10 @@ static int pim_mroute_set(struct pim_instance *pim, int enable)  				 opt, &data, data_len);  		if (err) {  			zlog_warn( -				  "%s %s: failure: setsockopt(fd=%d,IPPROTO_IP,%s=%d): errno=%d: %s", -				  __FILE__, __PRETTY_FUNCTION__, -				  pim->mroute_socket, -				  enable ? "MRT_INIT" : "MRT_DONE", data, errno, -				  safe_strerror(errno)); +				"%s %s: failure: setsockopt(fd=%d,IPPROTO_IP,%s=%d): errno=%d: %s", +				__FILE__, __func__, pim->mroute_socket, +				enable ? "MRT_INIT" : "MRT_DONE", data, errno, +				safe_strerror(errno));  			return -1;  		}  	} @@ -168,7 +166,7 @@ static int pim_mroute_msg_nocache(int fd, struct interface *ifp,  		if (PIM_DEBUG_MROUTE_DETAIL)  			zlog_debug(  				"%s: Interface is not configured correctly to handle incoming packet: Could be !pim_ifp, !SM, !RP", -				__PRETTY_FUNCTION__); +				__func__);  		return 0;  	} @@ -181,7 +179,7 @@ static int pim_mroute_msg_nocache(int fd, struct interface *ifp,  		if (PIM_DEBUG_MROUTE_DETAIL)  			zlog_debug(  				"%s: Received incoming packet that doesn't originate on our seg", -				__PRETTY_FUNCTION__); +				__func__);  		return 0;  	} @@ -191,8 +189,9 @@ static int pim_mroute_msg_nocache(int fd, struct interface *ifp,  	if (!(PIM_I_am_DR(pim_ifp))) {  		if (PIM_DEBUG_MROUTE_DETAIL) -			zlog_debug("%s: Interface is not the DR blackholing incoming traffic for %s", -				   __PRETTY_FUNCTION__, pim_str_sg_dump(&sg)); +			zlog_debug( +				"%s: Interface is not the DR blackholing incoming traffic for %s", +				__func__, pim_str_sg_dump(&sg));  		/*  		 * We are not the DR, but we are still receiving packets @@ -205,15 +204,14 @@ static int pim_mroute_msg_nocache(int fd, struct interface *ifp,  		 * this for future reference.  		 */  		up = pim_upstream_find_or_add( -			&sg, ifp, PIM_UPSTREAM_FLAG_MASK_SRC_NOCACHE, -			__PRETTY_FUNCTION__); -		pim_upstream_mroute_add(up->channel_oil, __PRETTY_FUNCTION__); +			&sg, ifp, PIM_UPSTREAM_FLAG_MASK_SRC_NOCACHE, __func__); +		pim_upstream_mroute_add(up->channel_oil, __func__);  		return 0;  	}  	up = pim_upstream_find_or_add(&sg, ifp, PIM_UPSTREAM_FLAG_MASK_FHR, -				      __PRETTY_FUNCTION__); +				      __func__);  	/*  	 * I moved this debug till after the actual add because @@ -221,7 +219,7 @@ static int pim_mroute_msg_nocache(int fd, struct interface *ifp,  	 */  	if (PIM_DEBUG_MROUTE) {  		zlog_debug("%s: Adding a Route %s for WHOLEPKT consumption", -			   __PRETTY_FUNCTION__, up->sg_str); +			   __func__, up->sg_str);  	}  	PIM_UPSTREAM_FLAG_SET_SRC_STREAM(up->flags); @@ -265,13 +263,12 @@ static int pim_mroute_msg_wholepkt(int fd, struct interface *ifp,  		if (up && PIM_UPSTREAM_FLAG_TEST_CAN_BE_LHR(up->flags)) {  			up = pim_upstream_add(pim_ifp->pim, &sg, ifp,  					      PIM_UPSTREAM_FLAG_MASK_SRC_LHR, -					      __PRETTY_FUNCTION__, NULL); +					      __func__, NULL);  			if (!up) {  				if (PIM_DEBUG_MROUTE)  					zlog_debug(  						"%s: Unable to create upstream information for %s", -						__PRETTY_FUNCTION__, -						pim_str_sg_dump(&sg)); +						__func__, pim_str_sg_dump(&sg));  				return 0;  			}  			pim_upstream_keep_alive_timer_start( @@ -281,21 +278,21 @@ static int pim_mroute_msg_wholepkt(int fd, struct interface *ifp,  			if (PIM_DEBUG_MROUTE)  				zlog_debug("%s: Creating %s upstream on LHR", -					   __PRETTY_FUNCTION__, up->sg_str); +					   __func__, up->sg_str);  			return 0;  		}  		if (PIM_DEBUG_MROUTE_DETAIL) {  			zlog_debug(  				"%s: Unable to find upstream channel WHOLEPKT%s", -				__PRETTY_FUNCTION__, pim_str_sg_dump(&sg)); +				__func__, pim_str_sg_dump(&sg));  		}  		return 0;  	}  	if (!up->rpf.source_nexthop.interface) {  		if (PIM_DEBUG_PIM_TRACE) -			zlog_debug("%s: up %s RPF is not present", -				__PRETTY_FUNCTION__, up->sg_str); +			zlog_debug("%s: up %s RPF is not present", __func__, +				   up->sg_str);  		return 0;  	} @@ -306,8 +303,7 @@ static int pim_mroute_msg_wholepkt(int fd, struct interface *ifp,  	if ((pim_rpf_addr_is_inaddr_none(rpg)) || (!pim_ifp)  	    || (!(PIM_I_am_DR(pim_ifp)))) {  		if (PIM_DEBUG_MROUTE) { -			zlog_debug("%s: Failed Check send packet", -				   __PRETTY_FUNCTION__); +			zlog_debug("%s: Failed Check send packet", __func__);  		}  		return 0;  	} @@ -365,8 +361,7 @@ static int pim_mroute_msg_wrongvif(int fd, struct interface *ifp,  		if (PIM_DEBUG_MROUTE)  			zlog_debug(  				"%s: WRONGVIF (S,G)=%s could not find input interface for input_vif_index=%d", -				__PRETTY_FUNCTION__, pim_str_sg_dump(&sg), -				msg->im_vif); +				__func__, pim_str_sg_dump(&sg), msg->im_vif);  		return -1;  	} @@ -375,8 +370,7 @@ static int pim_mroute_msg_wrongvif(int fd, struct interface *ifp,  		if (PIM_DEBUG_MROUTE)  			zlog_debug(  				"%s: WRONGVIF (S,G)=%s multicast not enabled on interface %s", -				__PRETTY_FUNCTION__, pim_str_sg_dump(&sg), -				ifp->name); +				__func__, pim_str_sg_dump(&sg), ifp->name);  		return -2;  	} @@ -386,8 +380,7 @@ static int pim_mroute_msg_wrongvif(int fd, struct interface *ifp,  		if (PIM_DEBUG_MROUTE)  			zlog_debug(  				"%s: WRONGVIF (S,G)=%s could not find channel on interface %s", -				__PRETTY_FUNCTION__, pim_str_sg_dump(&sg), -				ifp->name); +				__func__, pim_str_sg_dump(&sg), ifp->name);  		star_g.src.s_addr = INADDR_ANY;  		ch = pim_ifchannel_find(ifp, &star_g); @@ -395,8 +388,8 @@ static int pim_mroute_msg_wrongvif(int fd, struct interface *ifp,  			if (PIM_DEBUG_MROUTE)  				zlog_debug(  					"%s: WRONGVIF (*,G)=%s could not find channel on interface %s", -					__PRETTY_FUNCTION__, -					pim_str_sg_dump(&star_g), ifp->name); +					__func__, pim_str_sg_dump(&star_g), +					ifp->name);  			return -3;  		}  	} @@ -419,7 +412,7 @@ static int pim_mroute_msg_wrongvif(int fd, struct interface *ifp,  		if (PIM_DEBUG_MROUTE) {  			zlog_debug(  				"%s: WRONGVIF (S,G)=%s channel is not on Assert NoInfo state for interface %s", -				__PRETTY_FUNCTION__, ch->sg_str, ifp->name); +				__func__, ch->sg_str, ifp->name);  		}  		return -4;  	} @@ -428,7 +421,7 @@ static int pim_mroute_msg_wrongvif(int fd, struct interface *ifp,  		if (PIM_DEBUG_MROUTE) {  			zlog_debug(  				"%s: WRONGVIF (S,G)=%s interface %s is not downstream for channel", -				__PRETTY_FUNCTION__, ch->sg_str, ifp->name); +				__func__, ch->sg_str, ifp->name);  		}  		return -5;  	} @@ -437,7 +430,7 @@ static int pim_mroute_msg_wrongvif(int fd, struct interface *ifp,  		if (PIM_DEBUG_MROUTE) {  			zlog_debug(  				"%s: WRONGVIF (S,G)=%s assert_action_a1 failure on interface %s", -				__PRETTY_FUNCTION__, ch->sg_str, ifp->name); +				__func__, ch->sg_str, ifp->name);  		}  		return -6;  	} @@ -450,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; @@ -472,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) { @@ -509,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, @@ -521,7 +526,7 @@ static int pim_mroute_msg_wrvifwhole(int fd, struct interface *ifp,  			pim_upstream_inherited_olist(pim_ifp->pim, up);  			if (!up->channel_oil->installed)  				pim_upstream_mroute_add(up->channel_oil, -					       __PRETTY_FUNCTION__); +							__func__);  		} else {  			if (I_am_RP(pim_ifp->pim, up->sg.grp)) {  				if (pim_nexthop_lookup(pim_ifp->pim, &source, @@ -544,8 +549,8 @@ static int pim_mroute_msg_wrvifwhole(int fd, struct interface *ifp,  	pim_ifp = ifp->info;  	if (pim_if_connected_to_source(ifp, sg.src)) {  		up = pim_upstream_add(pim_ifp->pim, &sg, ifp, -				      PIM_UPSTREAM_FLAG_MASK_FHR, -				      __PRETTY_FUNCTION__, NULL); +				      PIM_UPSTREAM_FLAG_MASK_FHR, __func__, +				      NULL);  		if (!up) {  			if (PIM_DEBUG_MROUTE)  				zlog_debug( @@ -567,10 +572,9 @@ static int pim_mroute_msg_wrvifwhole(int fd, struct interface *ifp,  	} else {  		up = pim_upstream_add(pim_ifp->pim, &sg, ifp,  				      PIM_UPSTREAM_FLAG_MASK_SRC_NOCACHE, -				      __PRETTY_FUNCTION__, NULL); +				      __func__, NULL);  		if (!up->channel_oil->installed) -			pim_upstream_mroute_add(up->channel_oil, -					__PRETTY_FUNCTION__); +			pim_upstream_mroute_add(up->channel_oil, __func__);  	}  	return 0; @@ -621,8 +625,8 @@ static int pim_mroute_msg(struct pim_instance *pim, const char *buf,  			zlog_debug(  				"%s(%s): igmp kernel upcall on %s(%p) for %s -> %s", -				__PRETTY_FUNCTION__, pim->vrf->name, ifp->name, -				igmp, ip_src_str, ip_dst_str); +				__func__, pim->vrf->name, ifp->name, igmp, +				ip_src_str, ip_dst_str);  		}  		if (igmp)  			pim_igmp_packet(igmp, (char *)buf, buf_size); @@ -635,8 +639,8 @@ static int pim_mroute_msg(struct pim_instance *pim, const char *buf,  				       sizeof(grp_str));  			zlog_debug(  				"%s: no kernel upcall proto=%d src: %s dst: %s msg_size=%d", -				__PRETTY_FUNCTION__, ip_hdr->ip_p, src_str, -				grp_str, buf_size); +				__func__, ip_hdr->ip_p, src_str, grp_str, +				buf_size);  		}  	} else { @@ -653,8 +657,7 @@ static int pim_mroute_msg(struct pim_instance *pim, const char *buf,  				       sizeof(grp_str));  			zlog_debug(  				"%s: pim kernel upcall %s type=%d ip_p=%d from fd=%d for (S,G)=(%s,%s) on %s vifi=%d  size=%d", -				__PRETTY_FUNCTION__, -				igmpmsgtype2str[msg->im_msgtype], +				__func__, igmpmsgtype2str[msg->im_msgtype],  				msg->im_msgtype, ip_hdr->ip_p,  				pim->mroute_socket, src_str, grp_str, ifp->name,  				msg->im_vif, buf_size); @@ -706,9 +709,10 @@ static int mroute_read(struct thread *t)  			if (errno == EWOULDBLOCK || errno == EAGAIN)  				break; -			zlog_warn("%s: failure reading rd=%d: fd=%d: errno=%d: %s", -				  __PRETTY_FUNCTION__, rd, pim->mroute_socket, -				  errno, safe_strerror(errno)); +			zlog_warn( +				"%s: failure reading rd=%d: fd=%d: errno=%d: %s", +				__func__, rd, pim->mroute_socket, errno, +				safe_strerror(errno));  			goto done;  		} @@ -815,7 +819,7 @@ int pim_mroute_add_vif(struct interface *ifp, struct in_addr ifaddr,  	int err;  	if (PIM_DEBUG_MROUTE) -		zlog_debug("%s: Add Vif %d (%s[%s])", __PRETTY_FUNCTION__, +		zlog_debug("%s: Add Vif %d (%s[%s])", __func__,  			   pim_ifp->mroute_vif_index, ifp->name,  			   pim_ifp->pim->vrf->name); @@ -827,7 +831,7 @@ int pim_mroute_add_vif(struct interface *ifp, struct in_addr ifaddr,  	if (ifaddr.s_addr == INADDR_ANY) {  		zlog_warn(  			"%s: unnumbered interfaces are not supported on this platform", -			__PRETTY_FUNCTION__); +			__func__);  		return -1;  	}  	memcpy(&vc.vifc_lcl_addr, &ifaddr, sizeof(vc.vifc_lcl_addr)); @@ -853,9 +857,8 @@ int pim_mroute_add_vif(struct interface *ifp, struct in_addr ifaddr,  		zlog_warn(  			"%s: failure: setsockopt(fd=%d,IPPROTO_IP,MRT_ADD_VIF,vif_index=%d,ifaddr=%s,flag=%d): errno=%d: %s", -			__PRETTY_FUNCTION__, pim_ifp->pim->mroute_socket, -			ifp->ifindex, ifaddr_str, flags, errno, -			safe_strerror(errno)); +			__func__, pim_ifp->pim->mroute_socket, ifp->ifindex, +			ifaddr_str, flags, errno, safe_strerror(errno));  		return -2;  	} @@ -869,7 +872,7 @@ int pim_mroute_del_vif(struct interface *ifp)  	int err;  	if (PIM_DEBUG_MROUTE) -		zlog_debug("%s: Del Vif %d (%s[%s])", __PRETTY_FUNCTION__, +		zlog_debug("%s: Del Vif %d (%s[%s])", __func__,  			   pim_ifp->mroute_vif_index, ifp->name,  			   pim_ifp->pim->vrf->name); @@ -881,9 +884,8 @@ int pim_mroute_del_vif(struct interface *ifp)  	if (err) {  		zlog_warn(  			"%s %s: failure: setsockopt(fd=%d,IPPROTO_IP,MRT_DEL_VIF,vif_index=%d): errno=%d: %s", -			__FILE__, __PRETTY_FUNCTION__, -			pim_ifp->pim->mroute_socket, pim_ifp->mroute_vif_index, -			errno, safe_strerror(errno)); +			__FILE__, __func__, pim_ifp->pim->mroute_socket, +			pim_ifp->mroute_vif_index, errno, safe_strerror(errno));  		return -2;  	} @@ -1003,15 +1005,15 @@ static int pim_mroute_add(struct channel_oil *c_oil, const char *name)  	if (err) {  		zlog_warn(  			"%s %s: failure: setsockopt(fd=%d,IPPROTO_IP,MRT_ADD_MFC): errno=%d: %s", -			__FILE__, __PRETTY_FUNCTION__, pim->mroute_socket, -			errno, safe_strerror(errno)); +			__FILE__, __func__, pim->mroute_socket, errno, +			safe_strerror(errno));  		return -2;  	}  	if (PIM_DEBUG_MROUTE) {  		char buf[1000]; -		zlog_debug("%s(%s), vrf %s Added Route: %s", -			   __PRETTY_FUNCTION__, name, pim->vrf->name, +		zlog_debug("%s(%s), vrf %s Added Route: %s", __func__, name, +			   pim->vrf->name,  			   pim_channel_oil_dump(c_oil, buf, sizeof(buf)));  	} @@ -1170,8 +1172,7 @@ int pim_mroute_del(struct channel_oil *c_oil, const char *name)  			char buf[1000];  			zlog_debug(  				"%s %s: vifi %d for route is %s not installed, do not need to send del req. ", -				__FILE__, __PRETTY_FUNCTION__, -				c_oil->oil.mfcc_parent, +				__FILE__, __func__, c_oil->oil.mfcc_parent,  				pim_channel_oil_dump(c_oil, buf, sizeof(buf)));  		}  		return -2; @@ -1183,16 +1184,15 @@ int pim_mroute_del(struct channel_oil *c_oil, const char *name)  		if (PIM_DEBUG_MROUTE)  			zlog_warn(  				"%s %s: failure: setsockopt(fd=%d,IPPROTO_IP,MRT_DEL_MFC): errno=%d: %s", -				__FILE__, __PRETTY_FUNCTION__, -				pim->mroute_socket, errno, +				__FILE__, __func__, pim->mroute_socket, errno,  				safe_strerror(errno));  		return -2;  	}  	if (PIM_DEBUG_MROUTE) {  		char buf[1000]; -		zlog_debug("%s(%s), vrf %s Deleted Route: %s", -			   __PRETTY_FUNCTION__, name, pim->vrf->name, +		zlog_debug("%s(%s), vrf %s Deleted Route: %s", __func__, name, +			   pim->vrf->name,  			   pim_channel_oil_dump(c_oil, buf, sizeof(buf)));  	} diff --git a/pimd/pim_msdp.c b/pimd/pim_msdp.c index 27af9473bb..63d34e859c 100644 --- a/pimd/pim_msdp.c +++ b/pimd/pim_msdp.c @@ -126,7 +126,7 @@ static void pim_msdp_sa_upstream_del(struct pim_msdp_sa *sa)  	if (PIM_UPSTREAM_FLAG_TEST_SRC_MSDP(up->flags)) {  		PIM_UPSTREAM_FLAG_UNSET_SRC_MSDP(up->flags);  		sa->flags |= PIM_MSDP_SAF_UP_DEL_IN_PROG; -		up = pim_upstream_del(sa->pim, up, __PRETTY_FUNCTION__); +		up = pim_upstream_del(sa->pim, up, __func__);  		/* re-eval joinDesired; clearing peer-msdp-sa flag can  		 * cause JD to change  		 */ @@ -210,8 +210,7 @@ static void pim_msdp_sa_upstream_update(struct pim_msdp_sa *sa,  	/* RFC3618: "RP triggers a (S, G) join event towards the data source  	 * as if a JP message was rxed addressed to the RP itself." */  	up = pim_upstream_add(sa->pim, &sa->sg, NULL /* iif */, -			      PIM_UPSTREAM_FLAG_MASK_SRC_MSDP, -			      __PRETTY_FUNCTION__, NULL); +			      PIM_UPSTREAM_FLAG_MASK_SRC_MSDP, __func__, NULL);  	sa->up = up;  	if (up) { diff --git a/pimd/pim_msdp_socket.c b/pimd/pim_msdp_socket.c index 22eb8bc7b4..7620cd5792 100644 --- a/pimd/pim_msdp_socket.c +++ b/pimd/pim_msdp_socket.c @@ -162,14 +162,14 @@ int pim_msdp_sock_listen(struct pim_instance *pim)  		if (!ifp) {  			flog_err(EC_LIB_INTERFACE,  				 "%s: Unable to lookup vrf interface: %s", -				 __PRETTY_FUNCTION__, pim->vrf->name); +				 __func__, pim->vrf->name);  			close(sock);  			return -1;  		}  		if (pim_socket_bind(sock, ifp)) {  			flog_err_sys(EC_LIB_SOCKET,  				     "%s: Unable to bind to socket: %s", -				     __PRETTY_FUNCTION__, safe_strerror(errno)); +				     __func__, safe_strerror(errno));  			close(sock);  			return -1;  		} @@ -243,13 +243,13 @@ int pim_msdp_sock_connect(struct pim_msdp_peer *mp)  		if (!ifp) {  			flog_err(EC_LIB_INTERFACE,  				 "%s: Unable to lookup vrf interface: %s", -				 __PRETTY_FUNCTION__, mp->pim->vrf->name); +				 __func__, mp->pim->vrf->name);  			return -1;  		}  		if (pim_socket_bind(mp->fd, ifp)) {  			flog_err_sys(EC_LIB_SOCKET,  				     "%s: Unable to bind to socket: %s", -				     __PRETTY_FUNCTION__, safe_strerror(errno)); +				     __func__, safe_strerror(errno));  			close(mp->fd);  			mp->fd = -1;  			return -1; diff --git a/pimd/pim_msg.c b/pimd/pim_msg.c index fba76d84dd..65b6405c81 100644 --- a/pimd/pim_msg.c +++ b/pimd/pim_msg.c @@ -123,7 +123,7 @@ size_t pim_msg_get_jp_group_size(struct list *sources)  		if (PIM_DEBUG_PIM_PACKETS)  			zlog_debug(  				"%s: Considering (%s) children for (S,G,rpt) prune", -				__PRETTY_FUNCTION__, up->sg_str); +				__func__, up->sg_str);  		for (ALL_LIST_ELEMENTS_RO(up->sources, up_node, child)) {  			if (!PIM_UPSTREAM_FLAG_TEST_USE_RPT(child->flags)) { @@ -144,13 +144,12 @@ size_t pim_msg_get_jp_group_size(struct list *sources)  					if (PIM_DEBUG_PIM_PACKETS)  						zlog_debug(  							"%s: SPT Bit and RPF'(%s) != RPF'(S,G): Add Prune (%s,rpt) to compound message", -							__PRETTY_FUNCTION__, -							up->sg_str, +							__func__, up->sg_str,  							child->sg_str);  				} else if (PIM_DEBUG_PIM_PACKETS)  					zlog_debug(  						"%s: SPT Bit and RPF'(%s) == RPF'(S,G): Not adding Prune for (%s,rpt)", -						__PRETTY_FUNCTION__, up->sg_str, +						__func__, up->sg_str,  						child->sg_str);  			} else if (pim_upstream_empty_inherited_olist(child)) {  				/* S is supposed to be forwarded along the RPT @@ -163,14 +162,12 @@ size_t pim_msg_get_jp_group_size(struct list *sources)  						child->flags);  				if (PIM_DEBUG_PIM_PACKETS)  					zlog_debug( -							"%s: inherited_olist(%s,rpt) is NULL, Add Prune to compound message", -							__PRETTY_FUNCTION__, -							child->sg_str); +						"%s: inherited_olist(%s,rpt) is NULL, Add Prune to compound message", +						__func__, child->sg_str);  			} else if (PIM_DEBUG_PIM_PACKETS)  				zlog_debug( -						"%s: Do not add Prune %s to compound message %s", -						__PRETTY_FUNCTION__, child->sg_str, -						up->sg_str); +					"%s: Do not add Prune %s to compound message %s", +					__func__, child->sg_str, up->sg_str);  		}  	}  	return size; diff --git a/pimd/pim_neighbor.c b/pimd/pim_neighbor.c index 3f2aaf2bbe..ca7ca11402 100644 --- a/pimd/pim_neighbor.c +++ b/pimd/pim_neighbor.c @@ -53,8 +53,7 @@ static void dr_election_by_addr(struct interface *ifp)  	pim_ifp->pim_dr_addr = pim_ifp->primary_address;  	if (PIM_DEBUG_PIM_TRACE) { -		zlog_debug("%s: on interface %s", __PRETTY_FUNCTION__, -			   ifp->name); +		zlog_debug("%s: on interface %s", __func__, ifp->name);  	}  	for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, node, neigh)) { @@ -79,14 +78,14 @@ static void dr_election_by_pri(struct interface *ifp)  	dr_pri = pim_ifp->pim_dr_priority;  	if (PIM_DEBUG_PIM_TRACE) { -		zlog_debug("%s: dr pri %u on interface %s", __PRETTY_FUNCTION__, -			   dr_pri, ifp->name); +		zlog_debug("%s: dr pri %u on interface %s", __func__, dr_pri, +			   ifp->name);  	}  	for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, node, neigh)) {  		if (PIM_DEBUG_PIM_TRACE) {  			zlog_info("%s: neigh pri %u addr %x if dr addr %x", -				  __PRETTY_FUNCTION__, neigh->dr_priority, +				  __func__, neigh->dr_priority,  				  ntohl(neigh->source_addr.s_addr),  				  ntohl(pim_ifp->pim_dr_addr.s_addr));  		} @@ -133,8 +132,7 @@ int pim_if_dr_election(struct interface *ifp)  			pim_inet4_dump("<new_dr?>", pim_ifp->pim_dr_addr,  				       dr_new_str, sizeof(dr_new_str));  			zlog_debug("%s: DR was %s now is %s on interface %s", -				   __PRETTY_FUNCTION__, dr_old_str, dr_new_str, -				   ifp->name); +				   __func__, dr_old_str, dr_new_str, ifp->name);  		}  		pim_ifp->pim_dr_election_last = @@ -251,7 +249,7 @@ void pim_neighbor_timer_reset(struct pim_neighbor *neigh, uint16_t holdtime)  		pim_inet4_dump("<src?>", neigh->source_addr, src_str,  			       sizeof(src_str));  		zlog_debug("%s: starting %u sec timer for neighbor %s on %s", -			   __PRETTY_FUNCTION__, neigh->holdtime, src_str, +			   __func__, neigh->holdtime, src_str,  			   neigh->interface->name);  	} @@ -269,7 +267,7 @@ static int on_neighbor_jp_timer(struct thread *t)  		pim_inet4_dump("<src?>", neigh->source_addr, src_str,  			       sizeof(src_str));  		zlog_debug("%s:Sending JP Agg to %s on %s with %d groups", -			   __PRETTY_FUNCTION__, src_str, neigh->interface->name, +			   __func__, src_str, neigh->interface->name,  			   neigh->upstream_jp_agg->count);  	} @@ -338,7 +336,7 @@ pim_neighbor_new(struct interface *ifp, struct in_addr source_addr,  	if (PIM_DEBUG_PIM_EVENTS) {  		zlog_debug("%s: creating PIM neighbor %s on interface %s", -			   __PRETTY_FUNCTION__, src_str, ifp->name); +			   __func__, src_str, ifp->name);  	}  	zlog_info("PIM NEIGHBOR UP: neighbor %s on interface %s", src_str, @@ -390,7 +388,7 @@ static void delete_prefix_list(struct pim_neighbor *neigh)  				       sizeof(addr_str));  			zlog_debug(  				"%s: DUMP_PREFIX_LIST neigh=%x prefix_list=%x prefix=%x addr=%s [%d/%d]", -				__PRETTY_FUNCTION__, (unsigned)neigh, +				__func__, (unsigned)neigh,  				(unsigned)neigh->prefix_list, (unsigned)p,  				addr_str, i, list_size);  			++i; @@ -502,7 +500,7 @@ pim_neighbor_add(struct interface *ifp, struct in_addr source_addr,  	if (PIM_DEBUG_PIM_TRACE_DETAIL) {  		char str[INET_ADDRSTRLEN];  		pim_inet4_dump("<nht_nbr?>", source_addr, str, sizeof(str)); -		zlog_debug("%s: neighbor %s added ", __PRETTY_FUNCTION__, str); +		zlog_debug("%s: neighbor %s added ", __func__, str);  	}  	/*  	  RFC 4601: 4.3.2.  DR Election @@ -657,7 +655,7 @@ void pim_neighbor_delete(struct interface *ifp, struct pim_neighbor *neigh,  	if (PIM_DEBUG_PIM_TRACE) {  		zlog_debug("%s: deleting PIM neighbor %s on interface %s", -			   __PRETTY_FUNCTION__, src_str, ifp->name); +			   __func__, src_str, ifp->name);  	}  	// De-Register PIM Neighbor with BFD @@ -793,7 +791,7 @@ void pim_neighbor_update(struct pim_neighbor *neigh,  #ifdef DUMP_PREFIX_LIST  	zlog_debug(  		"%s: DUMP_PREFIX_LIST old_prefix_list=%x old_size=%d new_prefix_list=%x new_size=%d", -		__PRETTY_FUNCTION__, (unsigned)neigh->prefix_list, +		__func__, (unsigned)neigh->prefix_list,  		neigh->prefix_list ? (int)listcount(neigh->prefix_list) : -1,  		(unsigned)addr_list,  		addr_list ? (int)listcount(addr_list) : -1); @@ -804,7 +802,7 @@ void pim_neighbor_update(struct pim_neighbor *neigh,  			flog_err(  				EC_LIB_DEVELOPMENT,  				"%s: internal error: trying to replace same prefix list=%p", -				__PRETTY_FUNCTION__, (void *)addr_list); +				__func__, (void *)addr_list);  		}  	} else {  		/* Delete existing secondary address list */ diff --git a/pimd/pim_nht.c b/pimd/pim_nht.c index 9efeeaee27..60b7c73d43 100644 --- a/pimd/pim_nht.c +++ b/pimd/pim_nht.c @@ -61,7 +61,7 @@ void pim_sendmsg_zebra_rnh(struct pim_instance *pim, struct zclient *zclient,  		prefix2str(p, buf, sizeof(buf));  		zlog_debug(  			"%s: NHT %sregistered addr %s(%s) with Zebra ret:%d ", -			__PRETTY_FUNCTION__, +			__func__,  			(command == ZEBRA_NEXTHOP_REGISTER) ? " " : "de", buf,  			pim->vrf->name, ret);  	} @@ -145,7 +145,7 @@ int pim_find_or_track_nexthop(struct pim_instance *pim, struct prefix *addr,  			prefix2str(addr, buf, sizeof(buf));  			zlog_debug(  				"%s: NHT cache and zebra notification added for %s(%s)", -				__PRETTY_FUNCTION__, buf, pim->vrf->name); +				__func__, buf, pim->vrf->name);  		}  	} @@ -217,10 +217,10 @@ void pim_delete_tracked_nexthop(struct pim_instance *pim, struct prefix *addr,  		if (PIM_DEBUG_PIM_NHT) {  			char buf[PREFIX_STRLEN]; -			prefix2str(addr, buf, sizeof buf); +			prefix2str(addr, buf, sizeof(buf));  			zlog_debug(  				"%s: NHT %s(%s) rp_list count:%d upstream count:%ld", -				__PRETTY_FUNCTION__, buf, pim->vrf->name, +				__func__, buf, pim->vrf->name,  				pnc->rp_list->count, pnc->upstream_hash->count);  		} @@ -255,7 +255,7 @@ bool pim_nexthop_match(struct pim_instance *pim, struct in_addr addr,  	int num_ifindex;  	if (addr.s_addr == INADDR_NONE) -		return 0; +		return false;  	memset(nexthop_tab, 0,  	       sizeof(struct pim_zlookup_nexthop) * MULTIPATH_NUM); @@ -267,8 +267,8 @@ bool pim_nexthop_match(struct pim_instance *pim, struct in_addr addr,  		pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str));  		zlog_warn(  			"%s %s: could not find nexthop ifindex for address %s", -			__FILE__, __PRETTY_FUNCTION__, addr_str); -		return 0; +			__FILE__, __func__, addr_str); +		return false;  	}  	while (i < num_ifindex) { @@ -283,8 +283,8 @@ bool pim_nexthop_match(struct pim_instance *pim, struct in_addr addr,  					       sizeof(addr_str));  				zlog_debug(  					"%s %s: could not find interface for ifindex %d (address %s)", -					__FILE__, __PRETTY_FUNCTION__, -					first_ifindex, addr_str); +					__FILE__, __func__, first_ifindex, +					addr_str);  			}  			i++;  			continue; @@ -298,8 +298,8 @@ bool pim_nexthop_match(struct pim_instance *pim, struct in_addr addr,  					       sizeof(addr_str));  				zlog_debug(  					"%s: multicast not enabled on input interface %s (ifindex=%d, RPF for source %s)", -					__PRETTY_FUNCTION__, ifp->name, -					first_ifindex, addr_str); +					__func__, ifp->name, first_ifindex, +					addr_str);  			}  			i++;  			continue; @@ -319,12 +319,12 @@ bool pim_nexthop_match(struct pim_instance *pim, struct in_addr addr,  		if (nexthop_tab[i].nexthop_addr.u.prefix4.s_addr  		    == ip_src.s_addr) -			return 1; +			return true;  		i++;  	} -	return 0; +	return false;  }  /* Given a source address and a neighbor address, check if the neighbor is one @@ -348,7 +348,7 @@ bool pim_nexthop_match_nht_cache(struct pim_instance *pim, struct in_addr addr,  	pnc = pim_nexthop_cache_find(pim, &rpf);  	if (!pnc || !pnc->nexthop_num) -		return 0; +		return false;  	for (nh_node = pnc->nexthop; nh_node; nh_node = nh_node->next) {  		first_ifindex = nh_node->ifindex; @@ -361,9 +361,8 @@ bool pim_nexthop_match_nht_cache(struct pim_instance *pim, struct in_addr addr,  					       sizeof(addr_str));  				zlog_debug(  					"%s %s: could not find interface for ifindex %d (address %s(%s))", -					__FILE__, __PRETTY_FUNCTION__, -					first_ifindex, addr_str, -					pim->vrf->name); +					__FILE__, __func__, first_ifindex, +					addr_str, pim->vrf->name);  			}  			nh_iter++;  			continue; @@ -376,9 +375,8 @@ bool pim_nexthop_match_nht_cache(struct pim_instance *pim, struct in_addr addr,  					       sizeof(addr_str));  				zlog_debug(  					"%s: multicast not enabled on input interface %s(%s) (ifindex=%d, RPF for source %s)", -					__PRETTY_FUNCTION__, ifp->name, -					pim->vrf->name, first_ifindex, -					addr_str); +					__func__, ifp->name, pim->vrf->name, +					first_ifindex, addr_str);  			}  			nh_iter++;  			continue; @@ -390,7 +388,7 @@ bool pim_nexthop_match_nht_cache(struct pim_instance *pim, struct in_addr addr,  				if (PIM_DEBUG_PIM_NHT)  					zlog_debug(  						"%s: pim nbr not found on input interface %s(%s)", -						__PRETTY_FUNCTION__, ifp->name, +						__func__, ifp->name,  						pim->vrf->name);  				nh_iter++;  				continue; @@ -398,10 +396,10 @@ bool pim_nexthop_match_nht_cache(struct pim_instance *pim, struct in_addr addr,  		}  		if (nh_node->gate.ipv4.s_addr == ip_src.s_addr) -			return 1; +			return true;  	} -	return 0; +	return false;  }  void pim_rp_nexthop_del(struct rp_info *rp_info) @@ -460,12 +458,15 @@ static int pim_update_upstream_nh_helper(struct hash_bucket *bucket, void *arg)  	if (PIM_DEBUG_PIM_NHT) { -		zlog_debug("%s: NHT upstream %s(%s) old ifp %s new ifp %s", -			__PRETTY_FUNCTION__, up->sg_str, pim->vrf->name, -			old.source_nexthop.interface -			? old.source_nexthop.interface->name : "Unknown", -			up->rpf.source_nexthop.interface -			? up->rpf.source_nexthop.interface->name : "Unknown"); +		zlog_debug( +			"%s: NHT upstream %s(%s) old ifp %s new ifp %s", +			__func__, up->sg_str, pim->vrf->name, +			old.source_nexthop.interface ? old.source_nexthop +							       .interface->name +						     : "Unknown", +			up->rpf.source_nexthop.interface ? up->rpf.source_nexthop +								   .interface->name +							 : "Unknown");  	}  	return HASHWALK_CONTINUE; @@ -559,7 +560,7 @@ static int pim_ecmp_nexthop_search(struct pim_instance *pim,  					if (PIM_DEBUG_PIM_NHT)  						zlog_debug(  							"%s: current nexthop does not have nbr ", -							__PRETTY_FUNCTION__); +							__func__);  				} else {  					/* update metric even if the upstream  					 * neighbor stays unchanged @@ -581,9 +582,8 @@ static int pim_ecmp_nexthop_search(struct pim_instance *pim,  							       sizeof(grp_str));  						zlog_debug(  							"%s: (%s,%s)(%s) current nexthop %s is valid, skipping new path selection", -							__PRETTY_FUNCTION__, -							src_str, grp_str, -							pim->vrf->name, +							__func__, src_str, +							grp_str, pim->vrf->name,  							nexthop->interface->name);  					}  					return 1; @@ -633,9 +633,8 @@ static int pim_ecmp_nexthop_search(struct pim_instance *pim,  					       addr_str, sizeof(addr_str));  				zlog_debug(  					"%s %s: could not find interface for ifindex %d (address %s(%s))", -					__FILE__, __PRETTY_FUNCTION__, -					first_ifindex, addr_str, -					pim->vrf->name); +					__FILE__, __func__, first_ifindex, +					addr_str, pim->vrf->name);  			}  			if (nh_iter == mod_val)  				mod_val++; // Select nexthpath @@ -649,9 +648,8 @@ static int pim_ecmp_nexthop_search(struct pim_instance *pim,  					       addr_str, sizeof(addr_str));  				zlog_debug(  					"%s: multicast not enabled on input interface %s(%s) (ifindex=%d, RPF for source %s)", -					__PRETTY_FUNCTION__, ifp->name, -					pim->vrf->name, first_ifindex, -					addr_str); +					__func__, ifp->name, pim->vrf->name, +					first_ifindex, addr_str);  			}  			if (nh_iter == mod_val)  				mod_val++; // Select nexthpath @@ -666,7 +664,7 @@ static int pim_ecmp_nexthop_search(struct pim_instance *pim,  				if (PIM_DEBUG_PIM_NHT)  					zlog_debug(  						"%s: pim nbr not found on input interface %s(%s)", -						__PRETTY_FUNCTION__, ifp->name, +						__func__, ifp->name,  						pim->vrf->name);  				if (nh_iter == mod_val)  					mod_val++; // Select nexthpath @@ -701,9 +699,9 @@ static int pim_ecmp_nexthop_search(struct pim_instance *pim,  					buf, sizeof(buf));  				zlog_debug(  					"%s: (%s,%s)(%s) selected nhop interface %s addr %s mod_val %u iter %d ecmp %d", -					__PRETTY_FUNCTION__, buf2, buf3, -					pim->vrf->name, ifp->name, buf, mod_val, -					nh_iter, pim->ecmp_enable); +					__func__, buf2, buf3, pim->vrf->name, +					ifp->name, buf, mod_val, nh_iter, +					pim->ecmp_enable);  			}  		}  		nh_iter++; @@ -740,7 +738,7 @@ int pim_parse_nexthop_update(ZAPI_CALLBACK_ARGS)  		if (PIM_DEBUG_PIM_NHT)  			zlog_debug(  				"%s: Decode of nexthop update from zebra failed", -				__PRETTY_FUNCTION__); +				__func__);  		return 0;  	} @@ -753,7 +751,7 @@ int pim_parse_nexthop_update(ZAPI_CALLBACK_ARGS)  				prefix2str(&rpf.rpf_addr, buf, sizeof(buf));  				zlog_debug(  					"%s: Skipping NHT update, addr %s is not in local cached DB.", -					__PRETTY_FUNCTION__, buf); +					__func__, buf);  			}  			return 0;  		} @@ -810,8 +808,7 @@ int pim_parse_nexthop_update(ZAPI_CALLBACK_ARGS)  					char buf[NEXTHOP_STRLEN];  					zlog_debug(  						"%s: could not find interface for ifindex %d(%s) (addr %s)", -						__PRETTY_FUNCTION__, -						nexthop->ifindex, +						__func__, nexthop->ifindex,  						pim->vrf->name,  						nexthop2str(nexthop, buf,  							    sizeof(buf))); @@ -826,8 +823,7 @@ int pim_parse_nexthop_update(ZAPI_CALLBACK_ARGS)  				prefix2str(&nhr.prefix, p_str, sizeof(p_str));  				zlog_debug(  					"%s: NHT addr %s(%s) %d-nhop via %s(%s) type %d distance:%u metric:%u ", -					__PRETTY_FUNCTION__, p_str, -					pim->vrf->name, i + 1, +					__func__, p_str, pim->vrf->name, i + 1,  					inet_ntoa(nexthop->gate.ipv4),  					ifp->name, nexthop->type, nhr.distance,  					nhr.metric); @@ -847,7 +843,7 @@ int pim_parse_nexthop_update(ZAPI_CALLBACK_ARGS)  					zlog_debug(  						"%s: multicast not enabled on input interface %s(%s) (ifindex=%d, addr %s)", -						__PRETTY_FUNCTION__, ifp->name, +						__func__, ifp->name,  						pim->vrf->name,  						nexthop->ifindex,  						nexthop2str(nexthop, buf, @@ -886,9 +882,9 @@ int pim_parse_nexthop_update(ZAPI_CALLBACK_ARGS)  		prefix2str(&nhr.prefix, buf, sizeof(buf));  		zlog_debug(  			"%s: NHT Update for %s(%s) num_nh %d num_pim_nh %d vrf:%u up %ld rp %d", -			__PRETTY_FUNCTION__, buf, pim->vrf->name, -			nhr.nexthop_num, pnc->nexthop_num, vrf_id, -			pnc->upstream_hash->count, listcount(pnc->rp_list)); +			__func__, buf, pim->vrf->name, nhr.nexthop_num, +			pnc->nexthop_num, vrf_id, pnc->upstream_hash->count, +			listcount(pnc->rp_list));  	}  	pim_rpf_set_refresh_time(pim); @@ -922,7 +918,7 @@ int pim_ecmp_nexthop_lookup(struct pim_instance *pim,  		pim_inet4_dump("<addr?>", src->u.prefix4, addr_str,  			       sizeof(addr_str));  		zlog_debug("%s: Looking up: %s(%s), last lookup time: %lld", -			   __PRETTY_FUNCTION__, addr_str, pim->vrf->name, +			   __func__, addr_str, pim->vrf->name,  			   nexthop->last_lookup_time);  	} @@ -947,7 +943,7 @@ int pim_ecmp_nexthop_lookup(struct pim_instance *pim,  		if (PIM_DEBUG_PIM_NHT)  			zlog_warn(  				"%s: could not find nexthop ifindex for address %s(%s)", -				__PRETTY_FUNCTION__, addr_str, pim->vrf->name); +				__func__, addr_str, pim->vrf->name);  		return 0;  	} @@ -984,8 +980,8 @@ int pim_ecmp_nexthop_lookup(struct pim_instance *pim,  		hash_val = pim_compute_ecmp_hash(src, grp);  		mod_val = hash_val % consider;  		if (PIM_DEBUG_PIM_NHT_DETAIL) -			zlog_debug("%s: hash_val %u mod_val %u", -				   __PRETTY_FUNCTION__, hash_val, mod_val); +			zlog_debug("%s: hash_val %u mod_val %u", __func__, +				   hash_val, mod_val);  	}  	i = 0; @@ -997,9 +993,8 @@ int pim_ecmp_nexthop_lookup(struct pim_instance *pim,  			if (PIM_DEBUG_PIM_NHT)  				zlog_debug(  					"%s %s: could not find interface for ifindex %d (address %s(%s))", -					__FILE__, __PRETTY_FUNCTION__, -					first_ifindex, addr_str, -					pim->vrf->name); +					__FILE__, __func__, first_ifindex, +					addr_str, pim->vrf->name);  			if (i == mod_val)  				mod_val++;  			i++; @@ -1010,9 +1005,8 @@ int pim_ecmp_nexthop_lookup(struct pim_instance *pim,  			if (PIM_DEBUG_PIM_NHT)  				zlog_debug(  					"%s: multicast not enabled on input interface %s(%s) (ifindex=%d, RPF for source %s)", -					__PRETTY_FUNCTION__, ifp->name, -					pim->vrf->name, first_ifindex, -					addr_str); +					__func__, ifp->name, pim->vrf->name, +					first_ifindex, addr_str);  			if (i == mod_val)  				mod_val++;  			i++; @@ -1031,7 +1025,7 @@ int pim_ecmp_nexthop_lookup(struct pim_instance *pim,  				if (PIM_DEBUG_PIM_NHT)  					zlog_debug(  						"%s: NBR not found on input interface %s(%s) (RPF for source %s)", -						__PRETTY_FUNCTION__, ifp->name, +						__func__, ifp->name,  						pim->vrf->name, addr_str);  				continue;  			} @@ -1046,8 +1040,8 @@ int pim_ecmp_nexthop_lookup(struct pim_instance *pim,  					      nexthop_str, sizeof(nexthop_str));  				zlog_debug(  					"%s: found nhop %s for addr %s interface %s(%s) metric %d dist %d", -					__PRETTY_FUNCTION__, nexthop_str, -					addr_str, ifp->name, pim->vrf->name, +					__func__, nexthop_str, addr_str, +					ifp->name, pim->vrf->name,  					nexthop_tab[i].route_metric,  					nexthop_tab[i].protocol_distance);  			} @@ -1086,11 +1080,11 @@ int pim_ecmp_fib_lookup_if_vif_index(struct pim_instance *pim,  			       sizeof(addr_str));  	memset(&nhop, 0, sizeof(nhop)); -	if (!pim_ecmp_nexthop_lookup(pim, &nhop, src, grp, 0)) { +	if (!pim_ecmp_nexthop_lookup(pim, &nhop, src, grp, 1)) {  		if (PIM_DEBUG_PIM_NHT)  			zlog_debug(  				"%s: could not find nexthop ifindex for address %s(%s)", -				__PRETTY_FUNCTION__, addr_str, pim->vrf->name); +				__func__, addr_str, pim->vrf->name);  		return -1;  	} @@ -1098,8 +1092,7 @@ int pim_ecmp_fib_lookup_if_vif_index(struct pim_instance *pim,  	if (PIM_DEBUG_PIM_NHT)  		zlog_debug(  			"%s: found nexthop ifindex=%d (interface %s(%s)) for address %s", -			__PRETTY_FUNCTION__, ifindex, -			ifindex2ifname(ifindex, pim->vrf_id), +			__func__, ifindex, ifindex2ifname(ifindex, pim->vrf_id),  			pim->vrf->name, addr_str);  	vif_index = pim_if_find_vifindex_by_ifindex(pim, ifindex); @@ -1108,8 +1101,7 @@ int pim_ecmp_fib_lookup_if_vif_index(struct pim_instance *pim,  		if (PIM_DEBUG_PIM_NHT) {  			zlog_debug(  				"%s: low vif_index=%d(%s) < 1 nexthop for address %s", -				__PRETTY_FUNCTION__, vif_index, pim->vrf->name, -				addr_str); +				__func__, vif_index, pim->vrf->name, addr_str);  		}  		return -2;  	} diff --git a/pimd/pim_oil.c b/pimd/pim_oil.c index 598988f88f..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) @@ -149,8 +146,7 @@ struct channel_oil *pim_channel_oil_add(struct pim_instance *pim,  		if (PIM_DEBUG_MROUTE)  			zlog_debug(  				"%s(%s): Existing oil for %pSG4 Ref Count: %d (Post Increment)", -				__PRETTY_FUNCTION__, name, sg, -				c_oil->oil_ref_count); +				__func__, name, sg, c_oil->oil_ref_count);  		return c_oil;  	} @@ -175,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, @@ -183,7 +179,7 @@ struct channel_oil *pim_channel_oil_del(struct channel_oil *c_oil,  		zlog_debug(  			"%s(%s): Del oil for %pSG4, Ref Count: %d (Predecrement)", -			__PRETTY_FUNCTION__, name, &sg, c_oil->oil_ref_count); +			__func__, name, &sg, c_oil->oil_ref_count);  	}  	--c_oil->oil_ref_count; @@ -244,7 +240,7 @@ int pim_channel_del_oif(struct channel_oil *channel_oil, struct interface *oif,  				       sizeof(source_str));  			zlog_debug(  				"%s %s: no existing protocol mask %u(%u) for requested OIF %s (vif_index=%d, min_ttl=%d) for channel (S,G)=(%s,%s)", -				__FILE__, __PRETTY_FUNCTION__, proto_mask, +				__FILE__, __func__, proto_mask,  				channel_oil  					->oif_flags[pim_ifp->mroute_vif_index],  				oif->name, pim_ifp->mroute_vif_index, @@ -270,7 +266,7 @@ int pim_channel_del_oif(struct channel_oil *channel_oil, struct interface *oif,  				       sizeof(source_str));  			zlog_debug(  				"%s %s: other protocol masks remain for requested OIF %s (vif_index=%d, min_ttl=%d) for channel (S,G)=(%s,%s)", -				__FILE__, __PRETTY_FUNCTION__, oif->name, +				__FILE__, __func__, oif->name,  				pim_ifp->mroute_vif_index,  				channel_oil->oil  					.mfcc_ttls[pim_ifp->mroute_vif_index], @@ -283,7 +279,7 @@ int pim_channel_del_oif(struct channel_oil *channel_oil, struct interface *oif,  	/* clear mute; will be re-evaluated when the OIF becomes valid again */  	channel_oil->oif_flags[pim_ifp->mroute_vif_index] &= ~PIM_OIF_FLAG_MUTE; -	if (pim_upstream_mroute_add(channel_oil, __PRETTY_FUNCTION__)) { +	if (pim_upstream_mroute_add(channel_oil, __func__)) {  		if (PIM_DEBUG_MROUTE) {  			char group_str[INET_ADDRSTRLEN];  			char source_str[INET_ADDRSTRLEN]; @@ -295,7 +291,7 @@ int pim_channel_del_oif(struct channel_oil *channel_oil, struct interface *oif,  				       sizeof(source_str));  			zlog_debug(  				"%s %s: could not remove output interface %s (vif_index=%d) for channel (S,G)=(%s,%s)", -				__FILE__, __PRETTY_FUNCTION__, oif->name, +				__FILE__, __func__, oif->name,  				pim_ifp->mroute_vif_index, source_str,  				group_str);  		} @@ -313,8 +309,8 @@ int pim_channel_del_oif(struct channel_oil *channel_oil, struct interface *oif,  			       source_str, sizeof(source_str));  		zlog_debug(  			"%s(%s): (S,G)=(%s,%s): proto_mask=%u IIF:%d OIF=%s vif_index=%d", -			__PRETTY_FUNCTION__, caller, source_str, group_str, -			proto_mask, channel_oil->oil.mfcc_parent, oif->name, +			__func__, caller, source_str, group_str, proto_mask, +			channel_oil->oil.mfcc_parent, oif->name,  			pim_ifp->mroute_vif_index);  	} @@ -405,7 +401,7 @@ void pim_channel_update_oif_mute(struct channel_oil *c_oil,  		c_oil->oif_flags[pim_ifp->mroute_vif_index] &=  			~PIM_OIF_FLAG_MUTE; -	pim_upstream_mroute_add(c_oil, __PRETTY_FUNCTION__); +	pim_upstream_mroute_add(c_oil, __func__);  }  /* pim_upstream has been set or cleared on the c_oil. re-eval mute state @@ -455,8 +451,8 @@ int pim_channel_add_oif(struct channel_oil *channel_oil, struct interface *oif,  				       sizeof(source_str));  			zlog_debug(  				"%s %s: existing protocol mask %u requested OIF %s (vif_index=%d, min_ttl=%d) for channel (S,G)=(%s,%s)", -				__FILE__, __PRETTY_FUNCTION__, proto_mask, -				oif->name, pim_ifp->mroute_vif_index, +				__FILE__, __func__, proto_mask, oif->name, +				pim_ifp->mroute_vif_index,  				channel_oil->oil  					.mfcc_ttls[pim_ifp->mroute_vif_index],  				source_str, group_str); @@ -489,15 +485,31 @@ int pim_channel_add_oif(struct channel_oil *channel_oil, struct interface *oif,  					       source_str, sizeof(source_str));  				zlog_warn(  					"%s %s: new protocol mask %u requested nonexistent OIF %s (vif_index=%d, min_ttl=%d) for channel (S,G)=(%s,%s)", -					__FILE__, __PRETTY_FUNCTION__, -					proto_mask, oif->name, -					pim_ifp->mroute_vif_index, +					__FILE__, __func__, proto_mask, +					oif->name, pim_ifp->mroute_vif_index,  					channel_oil->oil.mfcc_ttls  						[pim_ifp->mroute_vif_index],  					source_str, group_str);  			}  		} +		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;  	} @@ -515,7 +527,7 @@ int pim_channel_add_oif(struct channel_oil *channel_oil, struct interface *oif,  				       sizeof(source_str));  			zlog_debug(  				"%s %s: interface %s (vif_index=%d) is existing output for channel (S,G)=(%s,%s)", -				__FILE__, __PRETTY_FUNCTION__, oif->name, +				__FILE__, __func__, oif->name,  				pim_ifp->mroute_vif_index, source_str,  				group_str);  		} @@ -541,7 +553,7 @@ int pim_channel_add_oif(struct channel_oil *channel_oil, struct interface *oif,  	 * valid to get installed in kernel.  	 */  	if (channel_oil->oil.mfcc_parent != MAXVIFS) { -		if (pim_upstream_mroute_add(channel_oil, __PRETTY_FUNCTION__)) { +		if (pim_upstream_mroute_add(channel_oil, __func__)) {  			if (PIM_DEBUG_MROUTE) {  				char group_str[INET_ADDRSTRLEN];  				char source_str[INET_ADDRSTRLEN]; @@ -552,10 +564,10 @@ int pim_channel_add_oif(struct channel_oil *channel_oil, struct interface *oif,  				      channel_oil->oil.mfcc_origin, source_str,  				      sizeof(source_str));  				zlog_debug( -				    "%s %s: could not add output interface %s (vif_index=%d) for channel (S,G)=(%s,%s)", -				    __FILE__, __PRETTY_FUNCTION__, oif->name, -				    pim_ifp->mroute_vif_index, source_str, -				    group_str); +					"%s %s: could not add output interface %s (vif_index=%d) for channel (S,G)=(%s,%s)", +					__FILE__, __func__, oif->name, +					pim_ifp->mroute_vif_index, source_str, +					group_str);  			}  			channel_oil->oil.mfcc_ttls[pim_ifp->mroute_vif_index] @@ -578,8 +590,8 @@ int pim_channel_add_oif(struct channel_oil *channel_oil, struct interface *oif,  			       source_str, sizeof(source_str));  		zlog_debug(  			"%s(%s): (S,G)=(%s,%s): proto_mask=%u OIF=%s vif_index=%d: DONE", -			__PRETTY_FUNCTION__, caller, source_str, group_str, -			proto_mask, oif->name, pim_ifp->mroute_vif_index); +			__func__, caller, source_str, group_str, proto_mask, +			oif->name, 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_pim.c b/pimd/pim_pim.c index b367aa21f4..8d7a921cf4 100644 --- a/pimd/pim_pim.c +++ b/pimd/pim_pim.c @@ -119,7 +119,7 @@ void pim_sock_delete(struct interface *ifp, const char *delete_message)  	if (!ifp->info) {  		flog_err(EC_PIM_CONFIG,  			 "%s: %s: but PIM not enabled on interface %s (!)", -			 __PRETTY_FUNCTION__, delete_message, ifp->name); +			 __func__, delete_message, ifp->name);  		return;  	} @@ -233,7 +233,7 @@ int pim_pim_packet(struct interface *ifp, uint8_t *buf, size_t len)  			ifp->name, ip_hdr->ip_ttl, header->ver, pim_msg_len,  			checksum);  		if (PIM_DEBUG_PIM_PACKETDUMP_RECV) { -			pim_pkt_dump(__PRETTY_FUNCTION__, pim_msg, pim_msg_len); +			pim_pkt_dump(__func__, pim_msg, pim_msg_len);  		}  	} @@ -258,8 +258,8 @@ int pim_pim_packet(struct interface *ifp, uint8_t *buf, size_t len)  			if (PIM_DEBUG_PIM_PACKETS)  				zlog_debug(  					"%s %s: non-hello PIM message type=%d from non-neighbor %s on %s", -					__FILE__, __PRETTY_FUNCTION__, -					header->type, src_str, ifp->name); +					__FILE__, __func__, header->type, +					src_str, ifp->name);  			return -1;  		}  		pim_neighbor_timer_reset(neigh, neigh->holdtime); @@ -273,8 +273,8 @@ int pim_pim_packet(struct interface *ifp, uint8_t *buf, size_t len)  			if (PIM_DEBUG_PIM_PACKETS)  				zlog_debug(  					"%s %s: non-hello PIM message type=%d from non-neighbor %s on %s", -					__FILE__, __PRETTY_FUNCTION__, -					header->type, src_str, ifp->name); +					__FILE__, __func__, header->type, +					src_str, ifp->name);  			return -1;  		}  		pim_neighbor_timer_reset(neigh, neigh->holdtime); @@ -347,15 +347,15 @@ static int pim_sock_read(struct thread *t)  			if (PIM_DEBUG_PIM_PACKETS)  				zlog_debug(  					"%s: Received incoming pim packet on interface(%s:%d) not yet configured for pim", -					__PRETTY_FUNCTION__, -					ifp ? ifp->name : "Unknown", ifindex); +					__func__, ifp ? ifp->name : "Unknown", +					ifindex);  			goto done;  		}  		int fail = pim_pim_packet(ifp, buf, len);  		if (fail) {  			if (PIM_DEBUG_PIM_PACKETS)  				zlog_debug("%s: pim_pim_packet() return=%d", -					   __PRETTY_FUNCTION__, fail); +					   __func__, fail);  			goto done;  		} @@ -519,8 +519,8 @@ static int pim_msg_send_frame(int fd, char *buf, size_t len,  					       sizeof(dst_str));  				zlog_warn(  					"%s: sendto() failure to %s: fd=%d msg_size=%zd: errno=%d: %s", -					__PRETTY_FUNCTION__, dst_str, fd, len, -					errno, safe_strerror(errno)); +					__func__, dst_str, fd, len, errno, +					safe_strerror(errno));  			}  			return -1;  		} @@ -588,9 +588,8 @@ int pim_msg_send(int fd, struct in_addr src, struct in_addr dst,  	if (PIM_DEBUG_PIM_PACKETS) {  		char dst_str[INET_ADDRSTRLEN];  		pim_inet4_dump("<dst?>", dst, dst_str, sizeof(dst_str)); -		zlog_debug("%s: to %s on %s: msg_size=%d checksum=%x", -			   __PRETTY_FUNCTION__, dst_str, ifname, pim_msg_size, -			   header->checksum); +		zlog_debug("%s: to %s on %s: msg_size=%d checksum=%x", __func__, +			   dst_str, ifname, pim_msg_size, header->checksum);  	}  	memset(&to, 0, sizeof(to)); @@ -599,7 +598,7 @@ int pim_msg_send(int fd, struct in_addr src, struct in_addr dst,  	tolen = sizeof(to);  	if (PIM_DEBUG_PIM_PACKETDUMP_SEND) { -		pim_pkt_dump(__PRETTY_FUNCTION__, pim_msg, pim_msg_size); +		pim_pkt_dump(__func__, pim_msg, pim_msg_size);  	}  	pim_msg_send_frame(fd, (char *)buffer, sendlen, (struct sockaddr *)&to, @@ -622,7 +621,7 @@ static int hello_send(struct interface *ifp, uint16_t holdtime)  			       sizeof(dst_str));  		zlog_debug(  			"%s: to %s on %s: holdt=%u prop_d=%u overr_i=%u dis_join_supp=%d dr_prio=%u gen_id=%08x addrs=%d", -			__PRETTY_FUNCTION__, dst_str, ifp->name, holdtime, +			__func__, dst_str, ifp->name, holdtime,  			pim_ifp->pim_propagation_delay_msec,  			pim_ifp->pim_override_interval_msec,  			PIM_IF_TEST_PIM_CAN_DISABLE_JOIN_SUPRESSION( @@ -655,7 +654,7 @@ static int hello_send(struct interface *ifp, uint16_t holdtime)  		if (PIM_DEBUG_PIM_HELLO) {  			zlog_debug(  				"%s: could not send PIM message on interface %s", -				__PRETTY_FUNCTION__, ifp->name); +				__func__, ifp->name);  		}  		return -2;  	} diff --git a/pimd/pim_register.c b/pimd/pim_register.c index aa9faf6923..19baecb9c2 100644 --- a/pimd/pim_register.c +++ b/pimd/pim_register.c @@ -99,7 +99,7 @@ void pim_register_stop_send(struct interface *ifp, struct prefix_sg *sg,  	pinfo = (struct pim_interface *)ifp->info;  	if (!pinfo) {  		if (PIM_DEBUG_PIM_TRACE) -			zlog_debug("%s: No pinfo!", __PRETTY_FUNCTION__); +			zlog_debug("%s: No pinfo!", __func__);  		return;  	}  	if (pim_msg_send(pinfo->pim_sock_fd, src, originator, buffer, @@ -107,7 +107,7 @@ void pim_register_stop_send(struct interface *ifp, struct prefix_sg *sg,  		if (PIM_DEBUG_PIM_TRACE) {  			zlog_debug(  				"%s: could not send PIM register stop message on interface %s", -				__PRETTY_FUNCTION__, ifp->name); +				__func__, ifp->name);  		}  	}  	++pinfo->pim_ifstat_reg_stop_send; @@ -122,6 +122,8 @@ int pim_register_stop_recv(struct interface *ifp, uint8_t *buf, int buf_size)  	struct prefix_sg sg;  	int l; +	++pim_ifp->pim_ifstat_reg_stop_recv; +  	memset(&sg, 0, sizeof(struct prefix_sg));  	l = pim_parse_addr_group(&sg, buf, buf_size);  	buf += l; @@ -177,7 +179,7 @@ void pim_register_send(const uint8_t *buf, int buf_size, struct in_addr src,  	if (!ifp) {  		if (PIM_DEBUG_PIM_REG)  			zlog_debug("%s: No interface to transmit register on", -				   __PRETTY_FUNCTION__); +				   __func__);  		return;  	}  	pinfo = (struct pim_interface *)ifp->info; @@ -185,7 +187,7 @@ void pim_register_send(const uint8_t *buf, int buf_size, struct in_addr src,  		if (PIM_DEBUG_PIM_REG)  			zlog_debug(  				"%s: Interface: %s not configured for pim to trasmit on!\n", -				__PRETTY_FUNCTION__, ifp->name); +				__func__, ifp->name);  		return;  	} @@ -194,8 +196,8 @@ void pim_register_send(const uint8_t *buf, int buf_size, struct in_addr src,  		strlcpy(rp_str, inet_ntoa(rpg->rpf_addr.u.prefix4),  			sizeof(rp_str));  		zlog_debug("%s: Sending %s %sRegister Packet to %s on %s", -			   __PRETTY_FUNCTION__, up->sg_str, -			   null_register ? "NULL " : "", rp_str, ifp->name); +			   __func__, up->sg_str, null_register ? "NULL " : "", +			   rp_str, ifp->name);  	}  	memset(buffer, 0, 10000); @@ -215,7 +217,7 @@ void pim_register_send(const uint8_t *buf, int buf_size, struct in_addr src,  		if (PIM_DEBUG_PIM_TRACE) {  			zlog_debug(  				"%s: could not send PIM register message on interface %s", -				__PRETTY_FUNCTION__, ifp->name); +				__func__, ifp->name);  		}  		return;  	} @@ -233,7 +235,7 @@ void pim_null_register_send(struct pim_upstream *up)  		if (PIM_DEBUG_PIM_TRACE)  			zlog_debug(  				"%s: Cannot send null-register for %s no valid iif", -				__PRETTY_FUNCTION__, up->sg_str); +				__func__, up->sg_str);  		return;  	} @@ -242,7 +244,7 @@ void pim_null_register_send(struct pim_upstream *up)  		if (PIM_DEBUG_PIM_TRACE)  			zlog_debug(  				"%s: Cannot send null-register for %s no RPF to the RP", -				__PRETTY_FUNCTION__, up->sg_str); +				__func__, up->sg_str);  		return;  	} @@ -261,7 +263,7 @@ void pim_null_register_send(struct pim_upstream *up)  			if (PIM_DEBUG_PIM_TRACE)  				zlog_debug(  					"%s: Cannot send null-register for %s vxlan-aa PIP unavailable", -					__PRETTY_FUNCTION__, up->sg_str); +					__func__, up->sg_str);  			return;  		}  	} @@ -417,8 +419,8 @@ int pim_register_recv(struct interface *ifp, struct in_addr dest_addr,  		if (!upstream) {  			upstream = pim_upstream_add(  				pim_ifp->pim, &sg, ifp, -				PIM_UPSTREAM_FLAG_MASK_SRC_STREAM, -				__PRETTY_FUNCTION__, NULL); +				PIM_UPSTREAM_FLAG_MASK_SRC_STREAM, __func__, +				NULL);  			if (!upstream) {  				zlog_warn("Failure to create upstream state");  				return 1; diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c index 2db39bac4b..8799134edd 100644 --- a/pimd/pim_rp.c +++ b/pimd/pim_rp.c @@ -240,7 +240,7 @@ struct rp_info *pim_rp_find_match_group(struct pim_instance *pim,  		flog_err(  			EC_LIB_DEVELOPMENT,  			"%s: BUG We should have found default group information\n", -			__PRETTY_FUNCTION__); +			__func__);  		return best;  	} @@ -351,8 +351,7 @@ void pim_upstream_update(struct pim_instance *pim, struct pim_upstream *up)  	if (PIM_DEBUG_PIM_TRACE)  		zlog_debug("%s: pim upstream update for  old upstream %s", -			   __PRETTY_FUNCTION__, -			   inet_ntoa(old_upstream_addr)); +			   __func__, inet_ntoa(old_upstream_addr));  	if (old_upstream_addr.s_addr == new_upstream_addr.s_addr)  		return; @@ -371,8 +370,9 @@ void pim_upstream_update(struct pim_instance *pim, struct pim_upstream *up)  			char buf[PREFIX2STR_BUFFER];  			prefix2str(&nht_p, buf, sizeof(buf)); -			zlog_debug("%s: Deregister upstream %s addr %s with Zebra NHT", -				   __PRETTY_FUNCTION__, up->sg_str, buf); +			zlog_debug( +				"%s: Deregister upstream %s addr %s with Zebra NHT", +				__func__, up->sg_str, buf);  		}  		pim_delete_tracked_nexthop(pim, &nht_p, up, NULL, false);  	} @@ -384,7 +384,7 @@ void pim_upstream_update(struct pim_instance *pim, struct pim_upstream *up)  	rpf_result = pim_rpf_update(pim, up, &old_rpf, __func__);  	if (rpf_result == PIM_RPF_FAILURE) -		pim_mroute_del(up->channel_oil, __PRETTY_FUNCTION__); +		pim_mroute_del(up->channel_oil, __func__);  	/* update kernel multicast forwarding cache (MFC) */  	if (up->rpf.source_nexthop.interface && up->channel_oil) @@ -550,7 +550,7 @@ int pim_rp_new(struct pim_instance *pim, struct in_addr rp_addr,  				prefix2str(&rp_all->group, buf1, sizeof(buf1));  				zlog_debug(  					"%s: NHT Register rp_all addr %s grp %s ", -					__PRETTY_FUNCTION__, buf, buf1); +					__func__, buf, buf1);  			}  			frr_each (rb_pim_upstream, &pim->upstream_head, up) { @@ -676,7 +676,7 @@ int pim_rp_new(struct pim_instance *pim, struct in_addr rp_addr,  		prefix2str(&nht_p, buf, sizeof(buf));  		prefix2str(&rp_info->group, buf1, sizeof(buf1));  		zlog_debug("%s: NHT Register RP addr %s grp %s with Zebra ", -			   __PRETTY_FUNCTION__, buf, buf1); +			   __func__, buf, buf1);  	}  	pim_find_or_track_nexthop(pim, &nht_p, NULL, rp_info, false, NULL);  	if (!pim_ecmp_nexthop_lookup(pim, &rp_info->rp.source_nexthop, &nht_p, @@ -744,8 +744,8 @@ int pim_rp_del(struct pim_instance *pim, struct in_addr rp_addr,  	}  	if (PIM_DEBUG_PIM_TRACE) -		zlog_debug("%s: Delete RP %s for the group %s", -			   __PRETTY_FUNCTION__, rp_str, grp_str); +		zlog_debug("%s: Delete RP %s for the group %s", __func__, +			   rp_str, grp_str);  	/* While static RP is getting deleted, we need to check if dynamic RP  	 * present for the same group in BSM RP table, then install the dynamic @@ -764,9 +764,9 @@ int pim_rp_del(struct pim_instance *pim, struct in_addr rp_addr,  						       sizeof(bsrp_str)))  						sprintf(bsrp_str, "<bsrp?>"); -					zlog_debug("%s: BSM RP %s found for the group %s", -						   __PRETTY_FUNCTION__, -						   bsrp_str, grp_str); +					zlog_debug( +						"%s: BSM RP %s found for the group %s", +						__func__, bsrp_str, grp_str);  				}  				return pim_rp_change(pim, bsrp->rp_address,  						     group, RP_SRC_BSR); @@ -775,7 +775,7 @@ int pim_rp_del(struct pim_instance *pim, struct in_addr rp_addr,  			if (PIM_DEBUG_PIM_TRACE)  				zlog_debug(  					"%s: BSM RP not found for the group %s", -					__PRETTY_FUNCTION__, grp_str); +					__func__, grp_str);  		}  	} @@ -786,8 +786,8 @@ int pim_rp_del(struct pim_instance *pim, struct in_addr rp_addr,  	if (PIM_DEBUG_PIM_NHT_RP) {  		char buf[PREFIX2STR_BUFFER];  		prefix2str(&nht_p, buf, sizeof(buf)); -		zlog_debug("%s: Deregister RP addr %s with Zebra ", -			   __PRETTY_FUNCTION__, buf); +		zlog_debug("%s: Deregister RP addr %s with Zebra ", __func__, +			   buf);  	}  	pim_delete_tracked_nexthop(pim, &nht_p, NULL, rp_info, false); @@ -836,7 +836,7 @@ int pim_rp_del(struct pim_instance *pim, struct in_addr rp_addr,  				zlog_debug(  					"%s:Found for Freeing: %p for rp_info: %p(%s) Lock: %d", -					__PRETTY_FUNCTION__, rn, rp_info, +					__func__, rn, rp_info,  					prefix2str(&rp_info->group, buf,  						   sizeof(buf)),  					rn->lock); @@ -924,7 +924,7 @@ int pim_rp_change(struct pim_instance *pim, struct in_addr new_rp_addr,  			prefix2str(&nht_p, buf, sizeof(buf));  			zlog_debug("%s: Deregister RP addr %s with Zebra ", -				   __PRETTY_FUNCTION__, buf); +				   __func__, buf);  		}  		pim_delete_tracked_nexthop(pim, &nht_p, NULL, rp_info, false);  	} @@ -962,7 +962,7 @@ int pim_rp_change(struct pim_instance *pim, struct in_addr new_rp_addr,  		prefix2str(&nht_p, buf, sizeof(buf));  		prefix2str(&rp_info->group, buf1, sizeof(buf1));  		zlog_debug("%s: NHT Register RP addr %s grp %s with Zebra ", -			   __PRETTY_FUNCTION__, buf, buf1); +			   __func__, buf, buf1);  	}  	pim_find_or_track_nexthop(pim, &nht_p, NULL, rp_info, false, NULL); @@ -1146,7 +1146,7 @@ struct pim_rpf *pim_rp_g(struct pim_instance *pim, struct in_addr group)  			prefix2str(&rp_info->group, buf1, sizeof(buf1));  			zlog_debug(  				"%s: NHT Register RP addr %s grp %s with Zebra", -				__PRETTY_FUNCTION__, buf, buf1); +				__func__, buf, buf1);  		}  		pim_find_or_track_nexthop(pim, &nht_p, NULL, rp_info, false,  					  NULL); @@ -1185,7 +1185,7 @@ int pim_rp_set_upstream_addr(struct pim_instance *pim, struct in_addr *up,  			 && (source.s_addr == INADDR_ANY))) {  		if (PIM_DEBUG_PIM_NHT_RP)  			zlog_debug("%s: Received a (*,G) with no RP configured", -				   __PRETTY_FUNCTION__); +				   __func__);  		up->s_addr = INADDR_ANY;  		return 0;  	} @@ -1394,8 +1394,7 @@ void pim_resolve_rp_nh(struct pim_instance *pim, struct pim_neighbor *nbr)  					      sizeof(str));  				zlog_debug(  					"%s: addr %s new nexthop addr %s interface %s", -					__PRETTY_FUNCTION__, str, str1, -					ifp1->name); +					__func__, str, str1, ifp1->name);  			}  		}  	} diff --git a/pimd/pim_rpf.c b/pimd/pim_rpf.c index b27374e302..010ec7d745 100644 --- a/pimd/pim_rpf.c +++ b/pimd/pim_rpf.c @@ -45,7 +45,7 @@ void pim_rpf_set_refresh_time(struct pim_instance *pim)  	pim->last_route_change_time = pim_time_monotonic_usec();  	if (PIM_DEBUG_PIM_TRACE)  		zlog_debug("%s: vrf(%s) New last route change time: %" PRId64, -			   __PRETTY_FUNCTION__, pim->vrf->name, +			   __func__, pim->vrf->name,  			   pim->last_route_change_time);  } @@ -78,9 +78,9 @@ bool pim_nexthop_lookup(struct pim_instance *pim, struct pim_nexthop *nexthop,  			pim_addr_dump("<nexthop?>", &nexthop->mrib_nexthop_addr,  				      nexthop_str, sizeof(nexthop_str));  			zlog_debug( -				"%s: Using last lookup for %s at %lld, %" PRId64 " addr %s", -				__PRETTY_FUNCTION__, addr_str, -				nexthop->last_lookup_time, +				"%s: Using last lookup for %s at %lld, %" PRId64 +				" addr %s", +				__func__, addr_str, nexthop->last_lookup_time,  				pim->last_route_change_time, nexthop_str);  		}  		pim->nexthop_lookups_avoided++; @@ -92,8 +92,7 @@ bool pim_nexthop_lookup(struct pim_instance *pim, struct pim_nexthop *nexthop,  				       sizeof(addr_str));  			zlog_debug(  				"%s: Looking up: %s, last lookup time: %lld, %" PRId64, -				__PRETTY_FUNCTION__, addr_str, -				nexthop->last_lookup_time, +				__func__, addr_str, nexthop->last_lookup_time,  				pim->last_route_change_time);  		}  	} @@ -107,7 +106,7 @@ bool pim_nexthop_lookup(struct pim_instance *pim, struct pim_nexthop *nexthop,  		pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str));  		zlog_warn(  			"%s %s: could not find nexthop ifindex for address %s", -			__FILE__, __PRETTY_FUNCTION__, addr_str); +			__FILE__, __func__, addr_str);  		return false;  	} @@ -122,8 +121,8 @@ bool pim_nexthop_lookup(struct pim_instance *pim, struct pim_nexthop *nexthop,  					       sizeof(addr_str));  				zlog_debug(  					"%s %s: could not find interface for ifindex %d (address %s)", -					__FILE__, __PRETTY_FUNCTION__, -					first_ifindex, addr_str); +					__FILE__, __func__, first_ifindex, +					addr_str);  			}  			i++;  			continue; @@ -136,8 +135,8 @@ bool pim_nexthop_lookup(struct pim_instance *pim, struct pim_nexthop *nexthop,  					       sizeof(addr_str));  				zlog_debug(  					"%s: multicast not enabled on input interface %s (ifindex=%d, RPF for source %s)", -					__PRETTY_FUNCTION__, ifp->name, -					first_ifindex, addr_str); +					__func__, ifp->name, first_ifindex, +					addr_str);  			}  			i++;  		} else if (neighbor_needed @@ -166,8 +165,8 @@ bool pim_nexthop_lookup(struct pim_instance *pim, struct pim_nexthop *nexthop,  				       sizeof(addr_str));  			zlog_debug(  				"%s %s: found nexthop %s for address %s: interface %s ifindex=%d metric=%d pref=%d", -				__FILE__, __PRETTY_FUNCTION__, nexthop_str, -				addr_str, ifp->name, first_ifindex, +				__FILE__, __func__, nexthop_str, addr_str, +				ifp->name, first_ifindex,  				nexthop_tab[i].route_metric,  				nexthop_tab[i].protocol_distance);  		} @@ -383,7 +382,7 @@ static struct in_addr pim_rpf_find_rpf_addr(struct pim_upstream *up)  	if (!up->rpf.source_nexthop.interface) {  		zlog_warn("%s: missing RPF interface for upstream (S,G)=%s", -			  __PRETTY_FUNCTION__, up->sg_str); +			  __func__, up->sg_str);  		rpf_addr.s_addr = PIM_NET_INADDR_ANY;  		return rpf_addr; @@ -415,7 +414,7 @@ int pim_rpf_addr_is_inaddr_none(struct pim_rpf *rpf)  	case AF_INET:  		return rpf->rpf_addr.u.prefix4.s_addr == INADDR_NONE;  	case AF_INET6: -		zlog_warn("%s: v6 Unimplmeneted", __PRETTY_FUNCTION__); +		zlog_warn("%s: v6 Unimplmeneted", __func__);  		return 1;  	default:  		return 0; @@ -430,7 +429,7 @@ int pim_rpf_addr_is_inaddr_any(struct pim_rpf *rpf)  	case AF_INET:  		return rpf->rpf_addr.u.prefix4.s_addr == INADDR_ANY;  	case AF_INET6: -		zlog_warn("%s: v6 Unimplmented", __PRETTY_FUNCTION__); +		zlog_warn("%s: v6 Unimplmented", __func__);  		return 1;  	default:  		return 0; diff --git a/pimd/pim_sock.c b/pimd/pim_sock.c index 7f03e18389..ae5781f0cc 100644 --- a/pimd/pim_sock.c +++ b/pimd/pim_sock.c @@ -69,8 +69,7 @@ void pim_socket_ip_hdr(int fd)  		if (setsockopt(fd, IPPROTO_IP, IP_HDRINCL, &on, sizeof(on)))  			zlog_err("%s: Could not turn on IP_HDRINCL option: %s", -				 __PRETTY_FUNCTION__, safe_strerror(errno)); - +				 __func__, safe_strerror(errno));  	}  } @@ -153,7 +152,7 @@ int pim_socket_mcast(int protocol, struct in_addr ifaddr, struct interface *ifp,  		flog_err(  			EC_LIB_DEVELOPMENT,  			"%s %s: Missing IP_PKTINFO and IP_RECVDSTADDR: unable to get dst addr from recvmsg()", -			__FILE__, __PRETTY_FUNCTION__); +			__FILE__, __func__);  		close(fd);  		return PIM_SOCK_ERR_DSTADDR;  #endif @@ -231,8 +230,8 @@ int pim_socket_mcast(int protocol, struct in_addr ifaddr, struct interface *ifp,  	}  	if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &rcvbuf, sizeof(rcvbuf))) -		zlog_warn("%s: Failure to set buffer size to %d", -			  __PRETTY_FUNCTION__, rcvbuf); +		zlog_warn("%s: Failure to set buffer size to %d", __func__, +			  rcvbuf);  	{  		long flags; diff --git a/pimd/pim_ssm.c b/pimd/pim_ssm.c index 6a70a73b45..8d3e04f5da 100644 --- a/pimd/pim_ssm.c +++ b/pimd/pim_ssm.c @@ -75,7 +75,7 @@ static int pim_is_grp_standard_ssm(struct prefix *group)  		if (!str2prefix(PIM_SSM_STANDARD_RANGE, &group_ssm))  			flog_err(EC_LIB_DEVELOPMENT,  				 "%s: Failure to Read Group Address: %s", -				 __PRETTY_FUNCTION__, PIM_SSM_STANDARD_RANGE); +				 __func__, PIM_SSM_STANDARD_RANGE);  		first = 0;  	} diff --git a/pimd/pim_ssmpingd.c b/pimd/pim_ssmpingd.c index 17bc375c12..f4d3547b3f 100644 --- a/pimd/pim_ssmpingd.c +++ b/pimd/pim_ssmpingd.c @@ -85,7 +85,7 @@ static int ssmpingd_socket(struct in_addr addr, int port, int mttl)  	if (fd < 0) {  		flog_err_sys(EC_LIB_SOCKET,  			     "%s: could not create socket: errno=%d: %s", -			     __PRETTY_FUNCTION__, errno, safe_strerror(errno)); +			     __func__, errno, safe_strerror(errno));  		return -1;  	} @@ -98,8 +98,8 @@ static int ssmpingd_socket(struct in_addr addr, int port, int mttl)  		pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str));  		zlog_warn(  			"%s: bind(fd=%d,addr=%s,port=%d,len=%zu) failure: errno=%d: %s", -			__PRETTY_FUNCTION__, fd, addr_str, port, -			sizeof(sockaddr), errno, safe_strerror(errno)); +			__func__, fd, addr_str, port, sizeof(sockaddr), errno, +			safe_strerror(errno));  		close(fd);  		return -1;  	} @@ -112,8 +112,7 @@ static int ssmpingd_socket(struct in_addr addr, int port, int mttl)  		if (setsockopt(fd, IPPROTO_IP, IP_PKTINFO, &opt, sizeof(opt))) {  			zlog_warn(  				"%s: could not set IP_PKTINFO on socket fd=%d: errno=%d: %s", -				__PRETTY_FUNCTION__, fd, errno, -				safe_strerror(errno)); +				__func__, fd, errno, safe_strerror(errno));  		}  #elif defined(HAVE_IP_RECVDSTADDR)  		/* BSD IP_RECVDSTADDR */ @@ -122,14 +121,13 @@ static int ssmpingd_socket(struct in_addr addr, int port, int mttl)  			       sizeof(opt))) {  			zlog_warn(  				"%s: could not set IP_RECVDSTADDR on socket fd=%d: errno=%d: %s", -				__PRETTY_FUNCTION__, fd, errno, -				safe_strerror(errno)); +				__func__, fd, errno, safe_strerror(errno));  		}  #else  		flog_err(  			EC_LIB_DEVELOPMENT,  			"%s %s: missing IP_PKTINFO and IP_RECVDSTADDR: unable to get dst addr from recvmsg()", -			__FILE__, __PRETTY_FUNCTION__); +			__FILE__, __func__);  		close(fd);  		return -1;  #endif @@ -141,8 +139,7 @@ static int ssmpingd_socket(struct in_addr addr, int port, int mttl)  			       sizeof(reuse))) {  			zlog_warn(  				"%s: could not set Reuse Address Option on socket fd=%d: errno=%d: %s", -				__PRETTY_FUNCTION__, fd, errno, -				safe_strerror(errno)); +				__func__, fd, errno, safe_strerror(errno));  			close(fd);  			return -1;  		} @@ -152,8 +149,7 @@ static int ssmpingd_socket(struct in_addr addr, int port, int mttl)  		       sizeof(mttl))) {  		zlog_warn(  			"%s: could not set multicast TTL=%d on socket fd=%d: errno=%d: %s", -			__PRETTY_FUNCTION__, mttl, fd, errno, -			safe_strerror(errno)); +			__func__, mttl, fd, errno, safe_strerror(errno));  		close(fd);  		return -1;  	} @@ -161,7 +157,7 @@ static int ssmpingd_socket(struct in_addr addr, int port, int mttl)  	if (setsockopt_ipv4_multicast_loop(fd, 0)) {  		zlog_warn(  			"%s: could not disable Multicast Loopback Option on socket fd=%d: errno=%d: %s", -			__PRETTY_FUNCTION__, fd, errno, safe_strerror(errno)); +			__func__, fd, errno, safe_strerror(errno));  		close(fd);  		return PIM_SOCK_ERR_LOOP;  	} @@ -170,7 +166,7 @@ static int ssmpingd_socket(struct in_addr addr, int port, int mttl)  		       sizeof(addr))) {  		zlog_warn(  			"%s: could not set Outgoing Interface Option on socket fd=%d: errno=%d: %s", -			__PRETTY_FUNCTION__, fd, errno, safe_strerror(errno)); +			__func__, fd, errno, safe_strerror(errno));  		close(fd);  		return -1;  	} @@ -182,8 +178,7 @@ static int ssmpingd_socket(struct in_addr addr, int port, int mttl)  		if (flags < 0) {  			zlog_warn(  				"%s: could not get fcntl(F_GETFL,O_NONBLOCK) on socket fd=%d: errno=%d: %s", -				__PRETTY_FUNCTION__, fd, errno, -				safe_strerror(errno)); +				__func__, fd, errno, safe_strerror(errno));  			close(fd);  			return -1;  		} @@ -191,8 +186,7 @@ static int ssmpingd_socket(struct in_addr addr, int port, int mttl)  		if (fcntl(fd, F_SETFL, flags | O_NONBLOCK)) {  			zlog_warn(  				"%s: could not set fcntl(F_SETFL,O_NONBLOCK) on socket fd=%d: errno=%d: %s", -				__PRETTY_FUNCTION__, fd, errno, -				safe_strerror(errno)); +				__func__, fd, errno, safe_strerror(errno));  			close(fd);  			return -1;  		} @@ -213,7 +207,7 @@ static void ssmpingd_delete(struct ssmpingd_sock *ss)  			       sizeof(source_str));  		zlog_warn(  			"%s: failure closing ssmpingd sock_fd=%d for source %s: errno=%d: %s", -			__PRETTY_FUNCTION__, ss->sock_fd, source_str, errno, +			__func__, ss->sock_fd, source_str, errno,  			safe_strerror(errno));  		/* warning only */  	} @@ -236,12 +230,12 @@ static void ssmpingd_sendto(struct ssmpingd_sock *ss, const uint8_t *buf,  		if (sent < 0) {  			zlog_warn(  				"%s: sendto() failure to %s,%d: fd=%d len=%d: errno=%d: %s", -				__PRETTY_FUNCTION__, to_str, ntohs(to.sin_port), +				__func__, to_str, ntohs(to.sin_port),  				ss->sock_fd, len, errno, safe_strerror(errno));  		} else {  			zlog_warn(  				"%s: sendto() partial to %s,%d: fd=%d len=%d: sent=%d", -				__PRETTY_FUNCTION__, to_str, ntohs(to.sin_port), +				__func__, to_str, ntohs(to.sin_port),  				ss->sock_fd, len, sent);  		}  	} @@ -268,7 +262,7 @@ static int ssmpingd_read_msg(struct ssmpingd_sock *ss)  			       sizeof(source_str));  		zlog_warn(  			"%s: failure receiving ssmping for source %s on fd=%d: errno=%d: %s", -			__PRETTY_FUNCTION__, source_str, ss->sock_fd, errno, +			__func__, source_str, ss->sock_fd, errno,  			safe_strerror(errno));  		return -1;  	} @@ -286,8 +280,8 @@ static int ssmpingd_read_msg(struct ssmpingd_sock *ss)  		pim_inet4_dump("<to?>", to.sin_addr, to_str, sizeof(to_str));  		zlog_warn(  			"%s: bad ssmping type=%d from %s,%d to %s,%d on interface %s ifindex=%d fd=%d src=%s", -			__PRETTY_FUNCTION__, buf[0], from_str, -			ntohs(from.sin_port), to_str, ntohs(to.sin_port), +			__func__, buf[0], from_str, ntohs(from.sin_port), +			to_str, ntohs(to.sin_port),  			ifp ? ifp->name : "<iface?>", ifindex, ss->sock_fd,  			source_str);  		return 0; @@ -304,10 +298,9 @@ static int ssmpingd_read_msg(struct ssmpingd_sock *ss)  		pim_inet4_dump("<to?>", to.sin_addr, to_str, sizeof(to_str));  		zlog_debug(  			"%s: recv ssmping from %s,%d to %s,%d on interface %s ifindex=%d fd=%d src=%s", -			__PRETTY_FUNCTION__, from_str, ntohs(from.sin_port), -			to_str, ntohs(to.sin_port), -			ifp ? ifp->name : "<iface?>", ifindex, ss->sock_fd, -			source_str); +			__func__, from_str, ntohs(from.sin_port), to_str, +			ntohs(to.sin_port), ifp ? ifp->name : "<iface?>", +			ifindex, ss->sock_fd, source_str);  	}  	buf[0] = PIM_SSMPINGD_REPLY; @@ -361,7 +354,7 @@ static struct ssmpingd_sock *ssmpingd_new(struct pim_instance *pim,  		pim_inet4_dump("<src?>", source_addr, source_str,  			       sizeof(source_str));  		zlog_warn("%s: ssmpingd_socket() failure for source %s", -			  __PRETTY_FUNCTION__, source_str); +			  __func__, source_str);  		return 0;  	} @@ -395,8 +388,8 @@ int pim_ssmpingd_start(struct pim_instance *pim, struct in_addr source_addr)  		char source_str[INET_ADDRSTRLEN];  		pim_inet4_dump("<src?>", source_addr, source_str,  			       sizeof(source_str)); -		zlog_info("%s: starting ssmpingd for source %s", -			  __PRETTY_FUNCTION__, source_str); +		zlog_info("%s: starting ssmpingd for source %s", __func__, +			  source_str);  	}  	ss = ssmpingd_new(pim, source_addr); @@ -404,8 +397,8 @@ int pim_ssmpingd_start(struct pim_instance *pim, struct in_addr source_addr)  		char source_str[INET_ADDRSTRLEN];  		pim_inet4_dump("<src?>", source_addr, source_str,  			       sizeof(source_str)); -		zlog_warn("%s: ssmpingd_new() failure for source %s", -			  __PRETTY_FUNCTION__, source_str); +		zlog_warn("%s: ssmpingd_new() failure for source %s", __func__, +			  source_str);  		return -1;  	} @@ -421,8 +414,8 @@ int pim_ssmpingd_stop(struct pim_instance *pim, struct in_addr source_addr)  		char source_str[INET_ADDRSTRLEN];  		pim_inet4_dump("<src?>", source_addr, source_str,  			       sizeof(source_str)); -		zlog_warn("%s: could not find ssmpingd for source %s", -			  __PRETTY_FUNCTION__, source_str); +		zlog_warn("%s: could not find ssmpingd for source %s", __func__, +			  source_str);  		return -1;  	} @@ -430,8 +423,8 @@ int pim_ssmpingd_stop(struct pim_instance *pim, struct in_addr source_addr)  		char source_str[INET_ADDRSTRLEN];  		pim_inet4_dump("<src?>", source_addr, source_str,  			       sizeof(source_str)); -		zlog_info("%s: stopping ssmpingd for source %s", -			  __PRETTY_FUNCTION__, source_str); +		zlog_info("%s: stopping ssmpingd for source %s", __func__, +			  source_str);  	}  	ssmpingd_delete(ss); diff --git a/pimd/pim_static.c b/pimd/pim_static.c index 7b121c9136..91c9b5b933 100644 --- a/pimd/pim_static.c +++ b/pimd/pim_static.c @@ -79,7 +79,7 @@ int pim_static_add(struct pim_instance *pim, struct interface *iif,  	if (!iif_index || !oif_index || iif_index == -1 || oif_index == -1) {  		zlog_warn(  			"%s %s: Unable to add static route: Invalid interface index(iif=%d,oif=%d)", -			__FILE__, __PRETTY_FUNCTION__, iif_index, oif_index); +			__FILE__, __func__, iif_index, oif_index);  		return -2;  	} @@ -88,7 +88,7 @@ int pim_static_add(struct pim_instance *pim, struct interface *iif,  		/* looped MFC entry */  		zlog_warn(  			"%s %s: Unable to add static route: Looped MFC entry(iif=%d,oif=%d)", -			__FILE__, __PRETTY_FUNCTION__, iif_index, oif_index); +			__FILE__, __func__, iif_index, oif_index);  		return -4;  	}  #endif @@ -109,9 +109,8 @@ int pim_static_add(struct pim_instance *pim, struct interface *iif,  					       sizeof(sifaddr_str));  				zlog_warn(  					"%s %s: Unable to add static route: Route already exists (iif=%d,oif=%d,group=%s,source=%s)", -					__FILE__, __PRETTY_FUNCTION__, -					iif_index, oif_index, gifaddr_str, -					sifaddr_str); +					__FILE__, __func__, iif_index, +					oif_index, gifaddr_str, sifaddr_str);  				return -3;  			} @@ -138,9 +137,8 @@ int pim_static_add(struct pim_instance *pim, struct interface *iif,  			} else {  				/* input interface changed */  				s_route->iif = iif_index; -				pim_static_mroute_iif_update(&s_route->c_oil, -							   iif_index, -							   __PRETTY_FUNCTION__); +				pim_static_mroute_iif_update( +					&s_route->c_oil, iif_index, __func__);  #ifdef PIM_ENFORCE_LOOPFREE_MFC  				/* check to make sure the new input was not an @@ -179,7 +177,7 @@ int pim_static_add(struct pim_instance *pim, struct interface *iif,  	s_route->c_oil.pim = pim; -	if (pim_static_mroute_add(&s_route->c_oil, __PRETTY_FUNCTION__)) { +	if (pim_static_mroute_add(&s_route->c_oil, __func__)) {  		char gifaddr_str[INET_ADDRSTRLEN];  		char sifaddr_str[INET_ADDRSTRLEN];  		pim_inet4_dump("<ifaddr?>", group, gifaddr_str, @@ -188,8 +186,8 @@ int pim_static_add(struct pim_instance *pim, struct interface *iif,  			       sizeof(sifaddr_str));  		zlog_warn(  			"%s %s: Unable to add static route(iif=%d,oif=%d,group=%s,source=%s)", -			__FILE__, __PRETTY_FUNCTION__, iif_index, oif_index, -			gifaddr_str, sifaddr_str); +			__FILE__, __func__, iif_index, oif_index, gifaddr_str, +			sifaddr_str);  		/* Need to put s_route back to the way it was */  		if (original_s_route) { @@ -223,7 +221,7 @@ int pim_static_add(struct pim_instance *pim, struct interface *iif,  			       sizeof(sifaddr_str));  		zlog_debug(  			"%s: Static route added(iif=%d,oif=%d,group=%s,source=%s)", -			__PRETTY_FUNCTION__, iif_index, oif_index, gifaddr_str, +			__func__, iif_index, oif_index, gifaddr_str,  			sifaddr_str);  	} @@ -245,7 +243,7 @@ int pim_static_del(struct pim_instance *pim, struct interface *iif,  	if (!iif_index || !oif_index) {  		zlog_warn(  			"%s %s: Unable to remove static route: Invalid interface index(iif=%d,oif=%d)", -			__FILE__, __PRETTY_FUNCTION__, iif_index, oif_index); +			__FILE__, __func__, iif_index, oif_index);  		return -2;  	} @@ -262,10 +260,9 @@ int pim_static_del(struct pim_instance *pim, struct interface *iif,  			 * route, otherwise set the route with the new outputs  			 */  			if (s_route->c_oil.oil_ref_count <= 0 -				    ? pim_mroute_del(&s_route->c_oil, -						     __PRETTY_FUNCTION__) +				    ? pim_mroute_del(&s_route->c_oil, __func__)  				    : pim_static_mroute_add(&s_route->c_oil, -						     __PRETTY_FUNCTION__)) { +							    __func__)) {  				char gifaddr_str[INET_ADDRSTRLEN];  				char sifaddr_str[INET_ADDRSTRLEN];  				pim_inet4_dump("<ifaddr?>", group, gifaddr_str, @@ -274,9 +271,8 @@ int pim_static_del(struct pim_instance *pim, struct interface *iif,  					       sizeof(sifaddr_str));  				zlog_warn(  					"%s %s: Unable to remove static route(iif=%d,oif=%d,group=%s,source=%s)", -					__FILE__, __PRETTY_FUNCTION__, -					iif_index, oif_index, gifaddr_str, -					sifaddr_str); +					__FILE__, __func__, iif_index, +					oif_index, gifaddr_str, sifaddr_str);  				s_route->oif_ttls[oif_index] = 1;  				s_route->c_oil.oil.mfcc_ttls[oif_index] = 1; @@ -301,8 +297,8 @@ int pim_static_del(struct pim_instance *pim, struct interface *iif,  					       sizeof(sifaddr_str));  				zlog_debug(  					"%s: Static route removed(iif=%d,oif=%d,group=%s,source=%s)", -					__PRETTY_FUNCTION__, iif_index, -					oif_index, gifaddr_str, sifaddr_str); +					__func__, iif_index, oif_index, +					gifaddr_str, sifaddr_str);  			}  			break; @@ -318,8 +314,8 @@ int pim_static_del(struct pim_instance *pim, struct interface *iif,  			       sizeof(sifaddr_str));  		zlog_warn(  			"%s %s: Unable to remove static route: Route does not exist(iif=%d,oif=%d,group=%s,source=%s)", -			__FILE__, __PRETTY_FUNCTION__, iif_index, oif_index, -			gifaddr_str, sifaddr_str); +			__FILE__, __func__, iif_index, oif_index, gifaddr_str, +			sifaddr_str);  		return -3;  	} diff --git a/pimd/pim_time.c b/pimd/pim_time.c index f12f767537..9878fcf6b4 100644 --- a/pimd/pim_time.c +++ b/pimd/pim_time.c @@ -37,7 +37,7 @@ static int gettime_monotonic(struct timeval *tv)  	if (result) {  		flog_err_sys(EC_LIB_SYSTEM_CALL,  			     "%s: gettimeofday() failure: errno=%d: %s", -			     __PRETTY_FUNCTION__, errno, safe_strerror(errno)); +			     __func__, errno, safe_strerror(errno));  	}  	return result; @@ -54,7 +54,7 @@ int64_t pim_time_monotonic_sec(void)  	if (gettime_monotonic(&now_tv)) {  		flog_err_sys(EC_LIB_SYSTEM_CALL,  			     "%s: gettime_monotonic() failure: errno=%d: %s", -			     __PRETTY_FUNCTION__, errno, safe_strerror(errno)); +			     __func__, errno, safe_strerror(errno));  		return -1;  	} @@ -73,7 +73,7 @@ int64_t pim_time_monotonic_dsec(void)  	if (gettime_monotonic(&now_tv)) {  		flog_err_sys(EC_LIB_SYSTEM_CALL,  			     "%s: gettime_monotonic() failure: errno=%d: %s", -			     __PRETTY_FUNCTION__, errno, safe_strerror(errno)); +			     __func__, errno, safe_strerror(errno));  		return -1;  	} @@ -91,7 +91,7 @@ int64_t pim_time_monotonic_usec(void)  	if (gettime_monotonic(&now_tv)) {  		flog_err_sys(EC_LIB_SYSTEM_CALL,  			     "%s: gettime_monotonic() failure: errno=%d: %s", -			     __PRETTY_FUNCTION__, errno, safe_strerror(errno)); +			     __func__, errno, safe_strerror(errno));  		return -1;  	} diff --git a/pimd/pim_tlv.c b/pimd/pim_tlv.c index 5faa499276..5a751ac929 100644 --- a/pimd/pim_tlv.c +++ b/pimd/pim_tlv.c @@ -143,7 +143,7 @@ int pim_encode_addr_ucast(uint8_t *buf, struct prefix *p)  	}  } -#define group_ipv4_encoding_len (4 + sizeof (struct in_addr)) +#define group_ipv4_encoding_len (4 + sizeof(struct in_addr))  /*   * Encoded-Group addresses take the following format: @@ -257,7 +257,7 @@ uint8_t *pim_tlv_append_addrlist_ucast(uint8_t *buf, const uint8_t *buf_pastend,  	if (PIM_DEBUG_PIM_TRACE_DETAIL) {  		zlog_debug(  			"%s: number of encoded secondary unicast IPv4 addresses: %zu", -			__PRETTY_FUNCTION__, option_len / uel); +			__func__, option_len / uel);  	}  	if (option_len < 1) { @@ -340,15 +340,15 @@ int pim_tlv_parse_holdtime(const char *ifname, struct in_addr src_addr,  {  	const char *label = "holdtime"; -	if (check_tlv_length(__PRETTY_FUNCTION__, label, ifname, src_addr, +	if (check_tlv_length(__func__, label, ifname, src_addr,  			     sizeof(uint16_t), option_len)) {  		return -1;  	} -	check_tlv_redefinition_uint16( -		__PRETTY_FUNCTION__, label, ifname, src_addr, *hello_options, -		PIM_OPTION_MASK_HOLDTIME, PIM_TLV_GET_HOLDTIME(tlv_curr), -		*hello_option_holdtime); +	check_tlv_redefinition_uint16(__func__, label, ifname, src_addr, +				      *hello_options, PIM_OPTION_MASK_HOLDTIME, +				      PIM_TLV_GET_HOLDTIME(tlv_curr), +				      *hello_option_holdtime);  	PIM_OPTION_SET(*hello_options, PIM_OPTION_MASK_HOLDTIME); @@ -363,13 +363,13 @@ int pim_tlv_parse_lan_prune_delay(const char *ifname, struct in_addr src_addr,  				  uint16_t *hello_option_override_interval,  				  uint16_t option_len, const uint8_t *tlv_curr)  { -	if (check_tlv_length(__PRETTY_FUNCTION__, "lan_prune_delay", ifname, -			     src_addr, sizeof(uint32_t), option_len)) { +	if (check_tlv_length(__func__, "lan_prune_delay", ifname, src_addr, +			     sizeof(uint32_t), option_len)) {  		return -1;  	} -	check_tlv_redefinition_uint16(__PRETTY_FUNCTION__, "propagation_delay", -				      ifname, src_addr, *hello_options, +	check_tlv_redefinition_uint16(__func__, "propagation_delay", ifname, +				      src_addr, *hello_options,  				      PIM_OPTION_MASK_LAN_PRUNE_DELAY,  				      PIM_TLV_GET_PROPAGATION_DELAY(tlv_curr),  				      *hello_option_propagation_delay); @@ -400,13 +400,13 @@ int pim_tlv_parse_dr_priority(const char *ifname, struct in_addr src_addr,  {  	const char *label = "dr_priority"; -	if (check_tlv_length(__PRETTY_FUNCTION__, label, ifname, src_addr, +	if (check_tlv_length(__func__, label, ifname, src_addr,  			     sizeof(uint32_t), option_len)) {  		return -1;  	}  	check_tlv_redefinition_uint32( -		__PRETTY_FUNCTION__, label, ifname, src_addr, *hello_options, +		__func__, label, ifname, src_addr, *hello_options,  		PIM_OPTION_MASK_DR_PRIORITY, PIM_TLV_GET_DR_PRIORITY(tlv_curr),  		*hello_option_dr_priority); @@ -424,13 +424,13 @@ int pim_tlv_parse_generation_id(const char *ifname, struct in_addr src_addr,  {  	const char *label = "generation_id"; -	if (check_tlv_length(__PRETTY_FUNCTION__, label, ifname, src_addr, +	if (check_tlv_length(__func__, label, ifname, src_addr,  			     sizeof(uint32_t), option_len)) {  		return -1;  	} -	check_tlv_redefinition_uint32_hex(__PRETTY_FUNCTION__, label, ifname, -					  src_addr, *hello_options, +	check_tlv_redefinition_uint32_hex(__func__, label, ifname, src_addr, +					  *hello_options,  					  PIM_OPTION_MASK_GENERATION_ID,  					  PIM_TLV_GET_GENERATION_ID(tlv_curr),  					  *hello_option_generation_id); @@ -453,7 +453,7 @@ int pim_parse_addr_ucast(struct prefix *p, const uint8_t *buf, int buf_size)  	if (buf_size < ucast_encoding_min_len) {  		zlog_warn(  			"%s: unicast address encoding overflow: left=%d needed=%d", -			__PRETTY_FUNCTION__, buf_size, ucast_encoding_min_len); +			__func__, buf_size, ucast_encoding_min_len);  		return -1;  	} @@ -465,7 +465,7 @@ int pim_parse_addr_ucast(struct prefix *p, const uint8_t *buf, int buf_size)  	if (type) {  		zlog_warn("%s: unknown unicast address encoding type=%d", -			  __PRETTY_FUNCTION__, type); +			  __func__, type);  		return -2;  	} @@ -474,7 +474,7 @@ int pim_parse_addr_ucast(struct prefix *p, const uint8_t *buf, int buf_size)  		if ((addr + sizeof(struct in_addr)) > pastend) {  			zlog_warn(  				"%s: IPv4 unicast address overflow: left=%zd needed=%zu", -				__PRETTY_FUNCTION__, pastend - addr, +				__func__, pastend - addr,  				sizeof(struct in_addr));  			return -3;  		} @@ -490,7 +490,7 @@ int pim_parse_addr_ucast(struct prefix *p, const uint8_t *buf, int buf_size)  		if ((addr + sizeof(struct in6_addr)) > pastend) {  			zlog_warn(  				"%s: IPv6 unicast address overflow: left=%zd needed %zu", -				__PRETTY_FUNCTION__, pastend - addr, +				__func__, pastend - addr,  				sizeof(struct in6_addr));  			return -3;  		} @@ -503,7 +503,7 @@ int pim_parse_addr_ucast(struct prefix *p, const uint8_t *buf, int buf_size)  		break;  	default: {  		zlog_warn("%s: unknown unicast address encoding family=%d from", -			  __PRETTY_FUNCTION__, family); +			  __func__, family);  		return -4;  	}  	} @@ -524,7 +524,7 @@ int pim_parse_addr_group(struct prefix_sg *sg, const uint8_t *buf, int buf_size)  	if (buf_size < grp_encoding_min_len) {  		zlog_warn(  			"%s: group address encoding overflow: left=%d needed=%d", -			__PRETTY_FUNCTION__, buf_size, grp_encoding_min_len); +			__func__, buf_size, grp_encoding_min_len);  		return -1;  	} @@ -542,14 +542,14 @@ int pim_parse_addr_group(struct prefix_sg *sg, const uint8_t *buf, int buf_size)  		if (type) {  			zlog_warn(  				"%s: unknown group address encoding type=%d from", -				__PRETTY_FUNCTION__, type); +				__func__, type);  			return -2;  		}  		if ((addr + sizeof(struct in_addr)) > pastend) {  			zlog_warn(  				"%s: IPv4 group address overflow: left=%zd needed=%zu from", -				__PRETTY_FUNCTION__, pastend - addr, +				__func__, pastend - addr,  				sizeof(struct in_addr));  			return -3;  		} @@ -562,7 +562,7 @@ int pim_parse_addr_group(struct prefix_sg *sg, const uint8_t *buf, int buf_size)  	default: {  		zlog_warn(  			"%s: unknown group address encoding family=%d mask_len=%d from", -			__PRETTY_FUNCTION__, family, mask_len); +			__func__, family, mask_len);  		return -4;  	}  	} @@ -584,7 +584,7 @@ int pim_parse_addr_source(struct prefix_sg *sg, uint8_t *flags,  	if (buf_size < src_encoding_min_len) {  		zlog_warn(  			"%s: source address encoding overflow: left=%d needed=%d", -			__PRETTY_FUNCTION__, buf_size, src_encoding_min_len); +			__func__, buf_size, src_encoding_min_len);  		return -1;  	} @@ -599,8 +599,7 @@ int pim_parse_addr_source(struct prefix_sg *sg, uint8_t *flags,  	if (type) {  		zlog_warn(  			"%s: unknown source address encoding type=%d: %02x%02x%02x%02x", -			__PRETTY_FUNCTION__, type, buf[0], buf[1], buf[2], -			buf[3]); +			__func__, type, buf[0], buf[1], buf[2], buf[3]);  		return -2;  	} @@ -609,7 +608,7 @@ int pim_parse_addr_source(struct prefix_sg *sg, uint8_t *flags,  		if ((addr + sizeof(struct in_addr)) > pastend) {  			zlog_warn(  				"%s: IPv4 source address overflow: left=%zd needed=%zu", -				__PRETTY_FUNCTION__, pastend - addr, +				__func__, pastend - addr,  				sizeof(struct in_addr));  			return -3;  		} @@ -630,7 +629,7 @@ int pim_parse_addr_source(struct prefix_sg *sg, uint8_t *flags,  		*/  		if (mask_len != 32) {  			zlog_warn("%s: IPv4 bad source address mask: %d", -				  __PRETTY_FUNCTION__, mask_len); +				  __func__, mask_len);  			return -4;  		} @@ -640,8 +639,7 @@ int pim_parse_addr_source(struct prefix_sg *sg, uint8_t *flags,  	default: {  		zlog_warn(  			"%s: unknown source address encoding family=%d: %02x%02x%02x%02x", -			__PRETTY_FUNCTION__, family, buf[0], buf[1], buf[2], -			buf[3]); +			__func__, family, buf[0], buf[1], buf[2], buf[3]);  		return -5;  	}  	} @@ -686,7 +684,7 @@ int pim_tlv_parse_addr_list(const char *ifname, struct in_addr src_addr,  				       sizeof(src_str));  			zlog_warn(  				"%s: pim_parse_addr_ucast() failure: from %s on %s", -				__PRETTY_FUNCTION__, src_str, ifname); +				__func__, src_str, ifname);  			FREE_ADDR_LIST(*hello_option_addr_list);  			return -1;  		} @@ -706,10 +704,10 @@ int pim_tlv_parse_addr_list(const char *ifname, struct in_addr src_addr,  					       sizeof(src_str));  				zlog_debug(  					"%s: PIM hello TLV option: list_old_size=%d IPv4 address %s from %s on %s", -					__PRETTY_FUNCTION__, +					__func__,  					*hello_option_addr_list  						? ((int)listcount( -							  *hello_option_addr_list)) +							*hello_option_addr_list))  						: -1,  					addr_str, src_str, ifname);  			} break; @@ -721,10 +719,10 @@ int pim_tlv_parse_addr_list(const char *ifname, struct in_addr src_addr,  					       sizeof(src_str));  				zlog_debug(  					"%s: PIM hello TLV option: list_old_size=%d UNKNOWN address family from %s on %s", -					__PRETTY_FUNCTION__, +					__func__,  					*hello_option_addr_list  						? ((int)listcount( -							  *hello_option_addr_list)) +							*hello_option_addr_list))  						: -1,  					src_str, ifname);  			} @@ -742,7 +740,7 @@ int pim_tlv_parse_addr_list(const char *ifname, struct in_addr src_addr,  					       sizeof(src_str));  				zlog_warn(  					"%s: ignoring primary address in secondary list from %s on %s", -					__PRETTY_FUNCTION__, src_str, ifname); +					__func__, src_str, ifname);  				continue;  			}  		} diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c index 444ab938f2..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 @@ -76,8 +77,7 @@ static void pim_upstream_remove_children(struct pim_instance *pim,  		listnode_delete(up->sources, child);  		if (PIM_UPSTREAM_FLAG_TEST_SRC_LHR(child->flags)) {  			PIM_UPSTREAM_FLAG_UNSET_SRC_LHR(child->flags); -			child = pim_upstream_del(pim, child, -						 __PRETTY_FUNCTION__); +			child = pim_upstream_del(pim, child, __func__);  		}  		if (child) {  			child->parent = NULL; @@ -142,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;  	} @@ -179,7 +191,7 @@ struct pim_upstream *pim_upstream_del(struct pim_instance *pim,  	if (PIM_DEBUG_PIM_TRACE)  		zlog_debug(  			"%s(%s): Delete %s[%s] ref count: %d , flags: %d c_oil ref count %d (Pre decrement)", -			__PRETTY_FUNCTION__, name, up->sg_str, pim->vrf->name, +			__func__, name, up->sg_str, pim->vrf->name,  			up->ref_count, up->flags,  			up->channel_oil->oil_ref_count); @@ -222,7 +234,7 @@ struct pim_upstream *pim_upstream_del(struct pim_instance *pim,  		notify_msdp = true;  	} -	pim_mroute_del(up->channel_oil, __PRETTY_FUNCTION__); +	pim_mroute_del(up->channel_oil, __func__);  	upstream_channel_oil_detach(up);  	for (ALL_LIST_ELEMENTS(up->ifchannels, node, nnode, ch)) @@ -257,8 +269,9 @@ struct pim_upstream *pim_upstream_del(struct pim_instance *pim,  		if (PIM_DEBUG_PIM_TRACE) {  			char buf[PREFIX2STR_BUFFER];  			prefix2str(&nht_p, buf, sizeof(buf)); -			zlog_debug("%s: Deregister upstream %s addr %s with Zebra NHT", -				   __PRETTY_FUNCTION__, up->sg_str, buf); +			zlog_debug( +				"%s: Deregister upstream %s addr %s with Zebra NHT", +				__func__, up->sg_str, buf);  		}  		pim_delete_tracked_nexthop(pim, &nht_p, up, NULL, false);  	} @@ -272,8 +285,8 @@ void pim_upstream_send_join(struct pim_upstream *up)  {  	if (!up->rpf.source_nexthop.interface) {  		if (PIM_DEBUG_PIM_TRACE) -			zlog_debug("%s: up %s RPF is not present", -				__PRETTY_FUNCTION__, up->sg_str); +			zlog_debug("%s: up %s RPF is not present", __func__, +				   up->sg_str);  		return;  	} @@ -281,13 +294,13 @@ void pim_upstream_send_join(struct pim_upstream *up)  		char rpf_str[PREFIX_STRLEN];  		pim_addr_dump("<rpf?>", &up->rpf.rpf_addr, rpf_str,  			      sizeof(rpf_str)); -		zlog_debug("%s: RPF'%s=%s(%s) for Interface %s", -			   __PRETTY_FUNCTION__, up->sg_str, rpf_str, +		zlog_debug("%s: RPF'%s=%s(%s) for Interface %s", __func__, +			   up->sg_str, rpf_str,  			   pim_upstream_state2str(up->join_state),  			   up->rpf.source_nexthop.interface->name);  		if (pim_rpf_addr_is_inaddr_any(&up->rpf)) {  			zlog_debug("%s: can't send join upstream: RPF'%s=%s", -				   __PRETTY_FUNCTION__, up->sg_str, rpf_str); +				   __func__, up->sg_str, rpf_str);  			/* warning only */  		}  	} @@ -304,8 +317,8 @@ static int on_join_timer(struct thread *t)  	if (!up->rpf.source_nexthop.interface) {  		if (PIM_DEBUG_PIM_TRACE) -			zlog_debug("%s: up %s RPF is not present", -			__PRETTY_FUNCTION__, up->sg_str); +			zlog_debug("%s: up %s RPF is not present", __func__, +				   up->sg_str);  		return 0;  	} @@ -355,8 +368,7 @@ void join_timer_start(struct pim_upstream *up)  		if (PIM_DEBUG_PIM_EVENTS) {  			zlog_debug(  				"%s: starting %d sec timer for upstream (S,G)=%s", -				__PRETTY_FUNCTION__, router->t_periodic, -				up->sg_str); +				__func__, router->t_periodic, up->sg_str);  		}  	} @@ -389,7 +401,7 @@ static void pim_upstream_join_timer_restart_msec(struct pim_upstream *up,  {  	if (PIM_DEBUG_PIM_EVENTS) {  		zlog_debug("%s: restarting %d msec timer for upstream (S,G)=%s", -			   __PRETTY_FUNCTION__, interval_msec, up->sg_str); +			   __func__, interval_msec, up->sg_str);  	}  	THREAD_OFF(up->t_join_timer); @@ -405,8 +417,8 @@ void pim_upstream_join_suppress(struct pim_upstream *up,  	if (!up->rpf.source_nexthop.interface) {  		if (PIM_DEBUG_PIM_TRACE) -			zlog_debug("%s: up %s RPF is not present", -				__PRETTY_FUNCTION__, up->sg_str); +			zlog_debug("%s: up %s RPF is not present", __func__, +				   up->sg_str);  		return;  	} @@ -421,7 +433,7 @@ void pim_upstream_join_suppress(struct pim_upstream *up,  		pim_inet4_dump("<rpf?>", rpf_addr, rpf_str, sizeof(rpf_str));  		zlog_debug(  			"%s %s: detected Join%s to RPF'(S,G)=%s: join_timer=%ld msec t_joinsuppress=%ld msec", -			__FILE__, __PRETTY_FUNCTION__, up->sg_str, rpf_str, +			__FILE__, __func__, up->sg_str, rpf_str,  			join_timer_remain_msec, t_joinsuppress_msec);  	} @@ -429,7 +441,7 @@ void pim_upstream_join_suppress(struct pim_upstream *up,  		if (PIM_DEBUG_PIM_TRACE) {  			zlog_debug(  				"%s %s: suppressing Join(S,G)=%s for %ld msec", -				__FILE__, __PRETTY_FUNCTION__, up->sg_str, +				__FILE__, __func__, up->sg_str,  				t_joinsuppress_msec);  		} @@ -445,8 +457,8 @@ void pim_upstream_join_timer_decrease_to_t_override(const char *debug_label,  	if (!up->rpf.source_nexthop.interface) {  		if (PIM_DEBUG_PIM_TRACE) -			zlog_debug("%s: up %s RPF is not present", -				__PRETTY_FUNCTION__, up->sg_str); +			zlog_debug("%s: up %s RPF is not present", __func__, +				   up->sg_str);  		return;  	} @@ -518,8 +530,8 @@ static int pim_upstream_could_register(struct pim_upstream *up)  		pim_ifp = up->rpf.source_nexthop.interface->info;  	else {  		if (PIM_DEBUG_PIM_TRACE) -			zlog_debug("%s: up %s RPF is not present", -				   __PRETTY_FUNCTION__, up->sg_str); +			zlog_debug("%s: up %s RPF is not present", __func__, +				   up->sg_str);  	}  	if (pim_ifp && PIM_I_am_DR(pim_ifp) @@ -655,21 +667,21 @@ void pim_upstream_switch(struct pim_instance *pim, struct pim_upstream *up,  	if (up->upstream_addr.s_addr == INADDR_ANY) {  		if (PIM_DEBUG_PIM_EVENTS) -			zlog_debug("%s: RPF not configured for %s", -				__PRETTY_FUNCTION__, up->sg_str); +			zlog_debug("%s: RPF not configured for %s", __func__, +				   up->sg_str);  		return;  	}  	if (!up->rpf.source_nexthop.interface)  {  		if (PIM_DEBUG_PIM_EVENTS) -			zlog_debug("%s: RP not reachable for %s", -				__PRETTY_FUNCTION__, up->sg_str); +			zlog_debug("%s: RP not reachable for %s", __func__, +				   up->sg_str);  		return;  	}  	if (PIM_DEBUG_PIM_EVENTS) {  		zlog_debug("%s: PIM_UPSTREAM_%s: (S,G) old: %s new: %s", -			   __PRETTY_FUNCTION__, up->sg_str, +			   __func__, up->sg_str,  			   pim_upstream_state2str(up->join_state),  			   pim_upstream_state2str(new_state));  	} @@ -816,7 +828,7 @@ static struct pim_upstream *pim_upstream_new(struct pim_instance *pim,  				      sg->grp)) {  		if (PIM_DEBUG_PIM_TRACE)  			zlog_debug("%s: Received a (*,G) with no RP configured", -				   __PRETTY_FUNCTION__); +				   __func__);  	}  	up->parent = pim_upstream_find_parent(pim, up); @@ -837,8 +849,7 @@ static struct pim_upstream *pim_upstream_new(struct pim_instance *pim,  	up->join_state = PIM_UPSTREAM_NOTJOINED;  	up->reg_state = PIM_REG_NOINFO;  	up->state_transition = pim_time_monotonic_sec(); -	up->channel_oil = -		pim_channel_oil_add(pim, &up->sg, __PRETTY_FUNCTION__); +	up->channel_oil = pim_channel_oil_add(pim, &up->sg, __func__);  	up->sptbit = PIM_UPSTREAM_SPTBIT_FALSE;  	up->rpf.source_nexthop.interface = NULL; @@ -855,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); @@ -878,7 +903,7 @@ static struct pim_upstream *pim_upstream_new(struct pim_instance *pim,  			if (PIM_DEBUG_PIM_TRACE)  				zlog_debug(  					"%s: Attempting to create upstream(%s), Unable to RPF for source", -					__PRETTY_FUNCTION__, up->sg_str); +					__func__, up->sg_str);  		}  		if (up->rpf.source_nexthop.interface) { @@ -887,31 +912,19 @@ 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) {  		zlog_debug(  			"%s: Created Upstream %s upstream_addr %s ref count %d increment", -			__PRETTY_FUNCTION__, up->sg_str, -			inet_ntoa(up->upstream_addr), up->ref_count); +			__func__, up->sg_str, inet_ntoa(up->upstream_addr), +			up->ref_count);  	}  	return up; @@ -919,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 == @@ -995,8 +1009,7 @@ void pim_upstream_ref(struct pim_upstream *up, int flags, const char *name)  	++up->ref_count;  	if (PIM_DEBUG_PIM_TRACE)  		zlog_debug("%s(%s): upstream %s ref count %d increment", -			   __PRETTY_FUNCTION__, name, up->sg_str, -			   up->ref_count); +			   __func__, name, up->sg_str, up->ref_count);  }  struct pim_upstream *pim_upstream_add(struct pim_instance *pim, @@ -1021,14 +1034,13 @@ struct pim_upstream *pim_upstream_add(struct pim_instance *pim,  			char buf[PREFIX2STR_BUFFER];  			prefix2str(&up->rpf.rpf_addr, buf, sizeof(buf));  			zlog_debug("%s(%s): %s, iif %s (%s) found: %d: ref_count: %d", -		   __PRETTY_FUNCTION__, name, +		   __func__, name,  		   up->sg_str, buf, up->rpf.source_nexthop.interface ?                     up->rpf.source_nexthop.interface->name : "Unknown" ,  		   found, up->ref_count);  		} else -			zlog_debug("%s(%s): (%s) failure to create", -				   __PRETTY_FUNCTION__, name, -				   pim_str_sg_dump(sg)); +			zlog_debug("%s(%s): (%s) failure to create", __func__, +				   name, pim_str_sg_dump(sg));  	}  	return up; @@ -1151,7 +1163,7 @@ static inline bool pim_upstream_is_msdp_peer_sa(struct pim_upstream *up)   *           AND inherited_olist(S,G) != NULL ) )   *   }   */ -int pim_upstream_evaluate_join_desired(struct pim_instance *pim, +bool pim_upstream_evaluate_join_desired(struct pim_instance *pim,  				       struct pim_upstream *up)  {  	bool empty_imm_oil; @@ -1232,8 +1244,7 @@ void pim_upstream_rpf_genid_changed(struct pim_instance *pim,  				      sizeof(rpf_addr_str));  			zlog_debug(  				"%s: matching neigh=%s against upstream (S,G)=%s[%s] joined=%d rpf_addr=%s", -				__PRETTY_FUNCTION__, neigh_str, up->sg_str, -				pim->vrf->name, +				__func__, neigh_str, up->sg_str, pim->vrf->name,  				up->join_state == PIM_UPSTREAM_JOINED,  				rpf_addr_str);  		} @@ -1409,13 +1420,13 @@ struct pim_upstream *pim_upstream_keep_alive_timer_proc(  		PIM_UPSTREAM_FLAG_UNSET_SRC_STREAM(up->flags);  		/* Return if upstream entry got deleted.*/ -		if (!pim_upstream_del(pim, up, __PRETTY_FUNCTION__)) +		if (!pim_upstream_del(pim, up, __func__))  			return NULL;  	}  	if (PIM_UPSTREAM_FLAG_TEST_SRC_NOCACHE(up->flags)) {  		PIM_UPSTREAM_FLAG_UNSET_SRC_NOCACHE(up->flags); -		if (!pim_upstream_del(pim, up, __PRETTY_FUNCTION__)) +		if (!pim_upstream_del(pim, up, __func__))  			return NULL;  	} @@ -1427,7 +1438,7 @@ struct pim_upstream *pim_upstream_keep_alive_timer_proc(  		struct pim_upstream *parent = up->parent;  		PIM_UPSTREAM_FLAG_UNSET_SRC_LHR(up->flags); -		up = pim_upstream_del(pim, up, __PRETTY_FUNCTION__); +		up = pim_upstream_del(pim, up, __func__);  		if (parent) {  			pim_jp_agg_single_upstream_send(&parent->rpf, parent, @@ -1443,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;  } @@ -1559,7 +1575,7 @@ void pim_upstream_set_sptbit(struct pim_upstream *up,  		if (PIM_DEBUG_PIM_TRACE)  			zlog_debug(  				"%s: Incoming Interface: %s is different than RPF_interface(S) %s", -				__PRETTY_FUNCTION__, incoming->name, +				__func__, incoming->name,  				up->rpf.source_nexthop.interface->name);  		return;  	} @@ -1567,8 +1583,8 @@ void pim_upstream_set_sptbit(struct pim_upstream *up,  	// AND JoinDesired(S,G) == true  	if (!pim_upstream_evaluate_join_desired(up->channel_oil->pim, up)) {  		if (PIM_DEBUG_PIM_TRACE) -			zlog_debug("%s: %s Join is not Desired", -				   __PRETTY_FUNCTION__, up->sg_str); +			zlog_debug("%s: %s Join is not Desired", __func__, +				   up->sg_str);  		return;  	} @@ -1577,7 +1593,7 @@ void pim_upstream_set_sptbit(struct pim_upstream *up,  				       up->sg.src)) {  		if (PIM_DEBUG_PIM_TRACE)  			zlog_debug("%s: %s is directly connected to the source", -				   __PRETTY_FUNCTION__, up->sg_str); +				   __func__, up->sg_str);  		up->sptbit = PIM_UPSTREAM_SPTBIT_TRUE;  		return;  	} @@ -1591,7 +1607,7 @@ void pim_upstream_set_sptbit(struct pim_upstream *up,  		if (PIM_DEBUG_PIM_TRACE)  			zlog_debug(  				"%s: %s RPF_interface(S) != RPF_interface(RP(G))", -				__PRETTY_FUNCTION__, up->sg_str); +				__func__, up->sg_str);  		up->sptbit = PIM_UPSTREAM_SPTBIT_TRUE;  		pim_jp_agg_single_upstream_send(&starup->rpf, starup, true); @@ -1603,7 +1619,7 @@ void pim_upstream_set_sptbit(struct pim_upstream *up,  	    && pim_upstream_empty_inherited_olist(up)) {  		if (PIM_DEBUG_PIM_TRACE)  			zlog_debug("%s: %s OR inherited_olist(S,G,rpt) == NULL", -				   __PRETTY_FUNCTION__, up->sg_str); +				   __func__, up->sg_str);  		up->sptbit = PIM_UPSTREAM_SPTBIT_TRUE;  		return;  	} @@ -1613,7 +1629,7 @@ void pim_upstream_set_sptbit(struct pim_upstream *up,  	if (up->parent && pim_rpf_is_same(&up->rpf, &up->parent->rpf)) {  		if (PIM_DEBUG_PIM_TRACE)  			zlog_debug("%s: %s RPF'(S,G) is the same as RPF'(*,G)", -				   __PRETTY_FUNCTION__, up->sg_str); +				   __func__, up->sg_str);  		up->sptbit = PIM_UPSTREAM_SPTBIT_TRUE;  		return;  	} @@ -1665,8 +1681,9 @@ static int pim_upstream_register_stop_timer(struct thread *t)  	if (PIM_DEBUG_PIM_TRACE) {  		char state_str[PIM_REG_STATE_STR_LEN];  		zlog_debug("%s: (S,G)=%s[%s] upstream register stop timer %s", -			   __PRETTY_FUNCTION__, up->sg_str, pim->vrf->name, -			   pim_reg_state2str(up->reg_state, state_str, sizeof(state_str))); +			   __func__, up->sg_str, pim->vrf->name, +			   pim_reg_state2str(up->reg_state, state_str, +					     sizeof(state_str)));  	}  	switch (up->reg_state) { @@ -1683,7 +1700,7 @@ static int pim_upstream_register_stop_timer(struct thread *t)  		if (!up->rpf.source_nexthop.interface) {  			if (PIM_DEBUG_PIM_TRACE)  				zlog_debug("%s: up %s RPF is not present", -					__PRETTY_FUNCTION__, up->sg_str); +					   __func__, up->sg_str);  			return 0;  		} @@ -1692,7 +1709,7 @@ static int pim_upstream_register_stop_timer(struct thread *t)  			if (PIM_DEBUG_PIM_TRACE)  				zlog_debug(  					"%s: Interface: %s is not configured for pim", -					__PRETTY_FUNCTION__, +					__func__,  					up->rpf.source_nexthop.interface->name);  			return 0;  		} @@ -1705,7 +1722,7 @@ static int pim_upstream_register_stop_timer(struct thread *t)  			if (PIM_DEBUG_PIM_TRACE)  				zlog_debug(  					"%s: Stop sending the register, because I am the RP and we haven't seen a packet in a while", -					__PRETTY_FUNCTION__); +					__func__);  			return 0;  		}  		pim_null_register_send(up); @@ -1735,7 +1752,7 @@ void pim_upstream_start_register_stop_timer(struct pim_upstream *up,  	if (PIM_DEBUG_PIM_TRACE) {  		zlog_debug(  			"%s: (S,G)=%s Starting upstream register stop timer %d", -			__PRETTY_FUNCTION__, up->sg_str, time); +			__func__, up->sg_str, time);  	}  	thread_add_timer(router->master, pim_upstream_register_stop_timer, up,  			 time, &up->t_rs_timer); @@ -1751,10 +1768,11 @@ int pim_upstream_inherited_olist_decide(struct pim_instance *pim,  	if (!up->rpf.source_nexthop.interface)  		if (PIM_DEBUG_PIM_TRACE) -			zlog_debug("%s: up %s RPF is not present", -				   __PRETTY_FUNCTION__, up->sg_str); +			zlog_debug("%s: up %s RPF is not present", __func__, +				   up->sg_str);  	FOR_ALL_INTERFACES (pim->vrf, ifp) { +		struct pim_interface *pim_ifp;  		if (!ifp->info)  			continue; @@ -1768,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; @@ -1843,8 +1867,8 @@ void pim_upstream_find_new_rpf(struct pim_instance *pim)  		if (up->upstream_addr.s_addr == INADDR_ANY) {  			if (PIM_DEBUG_PIM_TRACE)  				zlog_debug( -				    "%s: RP not configured for Upstream %s", -				    __PRETTY_FUNCTION__, up->sg_str); +					"%s: RP not configured for Upstream %s", +					__func__, up->sg_str);  			continue;  		} @@ -1852,7 +1876,7 @@ void pim_upstream_find_new_rpf(struct pim_instance *pim)  			if (PIM_DEBUG_PIM_TRACE)  				zlog_debug(  					"%s: Upstream %s without a path to send join, checking", -					__PRETTY_FUNCTION__, up->sg_str); +					__func__, up->sg_str);  			old.source_nexthop.interface =  				up->rpf.source_nexthop.interface;  			rpf_result = pim_rpf_update(pim, up, &old, __func__); @@ -1880,7 +1904,7 @@ void pim_upstream_terminate(struct pim_instance *pim)  	struct pim_upstream *up;  	while ((up = rb_pim_upstream_first(&pim->upstream_head))) { -		pim_upstream_del(pim, up, __PRETTY_FUNCTION__); +		pim_upstream_del(pim, up, __func__);  	}  	rb_pim_upstream_fini(&pim->upstream_head); @@ -1947,41 +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", -				   __PRETTY_FUNCTION__, 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]", -				__PRETTY_FUNCTION__, 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? @@ -1990,12 +1987,12 @@ static void pim_upstream_sg_running(void *arg)  		if (PIM_DEBUG_PIM_TRACE) {  			zlog_debug(  				"%s[%s]: %s old packet count is equal or lastused is greater than 30, (%ld,%ld,%lld)", -				__PRETTY_FUNCTION__, up->sg_str, pim->vrf->name, +				__func__, up->sg_str, pim->vrf->name,  				up->channel_oil->cc.oldpktcnt,  				up->channel_oil->cc.pktcnt,  				up->channel_oil->cc.lastused / 100);  		} -		return; +		return rv;  	}  	if (pim_upstream_kat_start_ok(up)) { @@ -2007,21 +2004,61 @@ static void pim_upstream_sg_running(void *arg)  					"source reference created on kat restart %s[%s]",  					up->sg_str, pim->vrf->name); -			pim_upstream_ref(up, -					PIM_UPSTREAM_FLAG_MASK_SRC_STREAM, -					__PRETTY_FUNCTION__); +			pim_upstream_ref(up, PIM_UPSTREAM_FLAG_MASK_SRC_STREAM, +					 __func__);  			PIM_UPSTREAM_FLAG_SET_SRC_STREAM(up->flags);  			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 c717c467dc..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; @@ -303,8 +305,8 @@ struct pim_upstream *pim_upstream_del(struct pim_instance *pim,  				      struct pim_upstream *up,  				      const char *name); -int pim_upstream_evaluate_join_desired(struct pim_instance *pim, -				       struct pim_upstream *up); +bool pim_upstream_evaluate_join_desired(struct pim_instance *pim, +					struct pim_upstream *up);  int pim_upstream_evaluate_join_desired_interface(struct pim_upstream *up,  						 struct pim_ifchannel *ch,  						 struct pim_ifchannel *starch); 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 57b922a531..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 | @@ -239,8 +248,7 @@ static void pim_vxlan_orig_mr_up_del(struct pim_vxlan_sg *vxlan_sg)  			 * origination mroutes active sources but just in  			 * case  			 */ -			up = pim_upstream_del(vxlan_sg->pim, up, -				__PRETTY_FUNCTION__); +			up = pim_upstream_del(vxlan_sg->pim, up, __func__);  		}  		/* if there are other references register the source  		 * for nht @@ -285,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; @@ -344,8 +353,13 @@ static void pim_vxlan_orig_mr_up_add(struct pim_vxlan_sg *vxlan_sg)  		}  		/* We are acting FHR; clear out use_rpt setting if any */  		pim_upstream_update_use_rpt(up, false /*update_mroute*/); -		pim_upstream_ref(up, flags, __PRETTY_FUNCTION__); +		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) @@ -353,8 +367,7 @@ static void pim_vxlan_orig_mr_up_add(struct pim_vxlan_sg *vxlan_sg)  					pim->regiface->info);  	} else {  		up = pim_upstream_add(vxlan_sg->pim, &vxlan_sg->sg, -				vxlan_sg->iif, flags, -				__PRETTY_FUNCTION__, NULL); +				      vxlan_sg->iif, flags, __func__, NULL);  		vxlan_sg->up = up;  	} @@ -475,7 +488,7 @@ static void pim_vxlan_orig_mr_del(struct pim_vxlan_sg *vxlan_sg)  	pim_vxlan_orig_mr_up_del(vxlan_sg);  } -static void pim_vxlan_orig_mr_iif_update(struct hash_backet *backet, void *arg) +static void pim_vxlan_orig_mr_iif_update(struct hash_bucket *backet, void *arg)  {  	struct interface *ifp;  	struct pim_vxlan_sg *vxlan_sg = (struct pim_vxlan_sg *)backet->data; @@ -614,9 +627,8 @@ static void pim_vxlan_term_mr_up_add(struct pim_vxlan_sg *vxlan_sg)  	/* enable MLAG designated-forwarder election on termination mroutes */  	PIM_UPSTREAM_FLAG_SET_MLAG_VXLAN(flags); -	up = pim_upstream_add(vxlan_sg->pim, &vxlan_sg->sg, -			NULL /* iif */, flags, -			__PRETTY_FUNCTION__, NULL); +	up = pim_upstream_add(vxlan_sg->pim, &vxlan_sg->sg, NULL /* iif */, +			      flags, __func__, NULL);  	vxlan_sg->up = up;  	if (!up) { @@ -648,8 +660,7 @@ static void pim_vxlan_term_mr_up_del(struct pim_vxlan_sg *vxlan_sg)  		up->flags &= ~(PIM_UPSTREAM_FLAG_MASK_SRC_VXLAN_TERM |  			PIM_UPSTREAM_FLAG_MASK_MLAG_VXLAN);  		pim_mlag_up_local_del(vxlan_sg->pim, up); -		pim_upstream_del(vxlan_sg->pim, up, -				__PRETTY_FUNCTION__); +		pim_upstream_del(vxlan_sg->pim, up, __func__);  	}  } @@ -752,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); @@ -769,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)  { @@ -788,8 +803,8 @@ bool pim_vxlan_do_mlag_reg(void)   * to the MLAG peer which may mroute it over the underlay if there are any   * interested receivers.   */ -static void pim_vxlan_sg_peerlink_oif_update(struct hash_backet *backet, -		void *arg) +static void pim_vxlan_sg_peerlink_oif_update(struct hash_bucket *backet, +					     void *arg)  {  	struct interface *new_oif = (struct interface *)arg;  	struct pim_vxlan_sg *vxlan_sg = (struct pim_vxlan_sg *)backet->data; @@ -881,9 +896,8 @@ static void pim_vxlan_set_default_iif(struct pim_instance *pim,  	old_iif = pim->vxlan.default_iif;  	if (PIM_DEBUG_VXLAN)  		zlog_debug("%s: vxlan default iif changed from %s to %s", -			__PRETTY_FUNCTION__, -			old_iif ? old_iif->name : "-", -			ifp ? ifp->name : "-"); +			   __func__, old_iif ? old_iif->name : "-", +			   ifp ? ifp->name : "-");  	old_iif = pim_vxlan_orig_mr_iif_get(pim);  	pim->vxlan.default_iif = ifp; @@ -892,9 +906,9 @@ static void pim_vxlan_set_default_iif(struct pim_instance *pim,  		return;  	if (PIM_DEBUG_VXLAN) -		zlog_debug("%s: vxlan orig iif changed from %s to %s", -			__PRETTY_FUNCTION__, old_iif ? old_iif->name : "-", -			ifp ? ifp->name : "-"); +		zlog_debug("%s: vxlan orig iif changed from %s to %s", __func__, +			   old_iif ? old_iif->name : "-", +			   ifp ? ifp->name : "-");  	/* add/del upstream entries for the existing vxlan SG when the  	 * interface becomes available @@ -927,8 +941,7 @@ static void pim_vxlan_up_cost_update(struct pim_instance *pim,  	}  } -static void pim_vxlan_term_mr_cost_update(struct hash_backet *backet, -		void *arg) +static void pim_vxlan_term_mr_cost_update(struct hash_bucket *backet, void *arg)  {  	struct interface *old_peerlink_rif = (struct interface *)arg;  	struct pim_vxlan_sg *vxlan_sg = (struct pim_vxlan_sg *)backet->data; @@ -953,8 +966,8 @@ static void pim_vxlan_term_mr_cost_update(struct hash_backet *backet,  				old_peerlink_rif);  } -static void pim_vxlan_sg_peerlink_rif_update(struct hash_backet *backet, -		void *arg) +static void pim_vxlan_sg_peerlink_rif_update(struct hash_bucket *backet, +					     void *arg)  {  	pim_vxlan_orig_mr_iif_update(backet, NULL);  	pim_vxlan_term_mr_cost_update(backet, arg); @@ -974,8 +987,8 @@ static void pim_vxlan_set_peerlink_rif(struct pim_instance *pim,  	old_iif = pim->vxlan.peerlink_rif;  	if (PIM_DEBUG_VXLAN)  		zlog_debug("%s: vxlan peerlink_rif changed from %s to %s", -			__PRETTY_FUNCTION__, old_iif ? old_iif->name : "-", -			ifp ? ifp->name : "-"); +			   __func__, old_iif ? old_iif->name : "-", +			   ifp ? ifp->name : "-");  	old_iif = pim_vxlan_orig_mr_iif_get(pim);  	old_oif = pim_vxlan_orig_mr_oif_get(pim); @@ -985,9 +998,8 @@ static void pim_vxlan_set_peerlink_rif(struct pim_instance *pim,  	if (old_iif != new_iif) {  		if (PIM_DEBUG_VXLAN)  			zlog_debug("%s: vxlan orig iif changed from %s to %s", -				__PRETTY_FUNCTION__, -				old_iif ? old_iif->name : "-", -				new_iif ? new_iif->name : "-"); +				   __func__, old_iif ? old_iif->name : "-", +				   new_iif ? new_iif->name : "-");  		/* add/del upstream entries for the existing vxlan SG when the  		 * interface becomes available @@ -1002,9 +1014,8 @@ static void pim_vxlan_set_peerlink_rif(struct pim_instance *pim,  	if (old_oif != new_oif) {  		if (PIM_DEBUG_VXLAN)  			zlog_debug("%s: vxlan orig oif changed from %s to %s", -				__PRETTY_FUNCTION__, -				old_oif ? old_oif->name : "-", -				new_oif ? new_oif->name : "-"); +				   __func__, old_oif ? old_oif->name : "-", +				   new_oif ? new_oif->name : "-");  		if (pim->vxlan.sg_hash)  			hash_iterate(pim->vxlan.sg_hash,  					pim_vxlan_sg_peerlink_oif_update, @@ -1012,7 +1023,7 @@ static void pim_vxlan_set_peerlink_rif(struct pim_instance *pim,  	}  } -static void pim_vxlan_term_mr_oif_update(struct hash_backet *backet, void *arg) +static void pim_vxlan_term_mr_oif_update(struct hash_bucket *backet, void *arg)  {  	struct interface *ifp = (struct interface *)arg;  	struct pim_vxlan_sg *vxlan_sg = (struct pim_vxlan_sg *)backet->data; @@ -1155,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_zebra.c b/pimd/pim_zebra.c index baa6216df2..e791500ede 100644 --- a/pimd/pim_zebra.c +++ b/pimd/pim_zebra.c @@ -75,9 +75,8 @@ static int pim_zebra_interface_vrf_update(ZAPI_CALLBACK_ARGS)  		return 0;  	if (PIM_DEBUG_ZEBRA) -		zlog_debug("%s: %s updating from %u to %u", -			   __PRETTY_FUNCTION__, -			   ifp->name, vrf_id, new_vrf_id); +		zlog_debug("%s: %s updating from %u to %u", __func__, ifp->name, +			   vrf_id, new_vrf_id);  	if_update_to_new_vrf(ifp, new_vrf_id); @@ -90,8 +89,8 @@ static void dump_if_address(struct interface *ifp)  	struct connected *ifc;  	struct listnode *node; -	zlog_debug("%s %s: interface %s addresses:", __FILE__, -		   __PRETTY_FUNCTION__, ifp->name); +	zlog_debug("%s %s: interface %s addresses:", __FILE__, __func__, +		   ifp->name);  	for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, ifc)) {  		struct prefix *p = ifc->address; @@ -100,8 +99,7 @@ static void dump_if_address(struct interface *ifp)  			continue;  		zlog_debug("%s %s: interface %s address %s %s", __FILE__, -			   __PRETTY_FUNCTION__, ifp->name, -			   inet_ntoa(p->u.prefix4), +			   __func__, ifp->name, inet_ntoa(p->u.prefix4),  			   CHECK_FLAG(ifc->flags, ZEBRA_IFA_SECONDARY)  				   ? "secondary"  				   : "primary"); @@ -135,8 +133,7 @@ static int pim_zebra_if_address_add(ZAPI_CALLBACK_ARGS)  		char buf[BUFSIZ];  		prefix2str(p, buf, BUFSIZ);  		zlog_debug("%s: %s(%u) connected IP address %s flags %u %s", -			   __PRETTY_FUNCTION__, c->ifp->name, vrf_id, buf, -			   c->flags, +			   __func__, c->ifp->name, vrf_id, buf, c->flags,  			   CHECK_FLAG(c->flags, ZEBRA_IFA_SECONDARY)  				   ? "secondary"  				   : "primary"); @@ -161,7 +158,7 @@ static int pim_zebra_if_address_add(ZAPI_CALLBACK_ARGS)  				zlog_warn(  					"%s: %s : forcing secondary flag on %s", -					__PRETTY_FUNCTION__, c->ifp->name, buf); +					__func__, c->ifp->name, buf);  			}  			SET_FLAG(c->flags, ZEBRA_IFA_SECONDARY);  		} @@ -218,8 +215,7 @@ static int pim_zebra_if_address_del(ZAPI_CALLBACK_ARGS)  			prefix2str(p, buf, BUFSIZ);  			zlog_debug(  				"%s: %s(%u) disconnected IP address %s flags %u %s", -				__PRETTY_FUNCTION__, c->ifp->name, vrf_id, buf, -				c->flags, +				__func__, c->ifp->name, vrf_id, buf, c->flags,  				CHECK_FLAG(c->flags, ZEBRA_IFA_SECONDARY)  					? "secondary"  					: "primary"); @@ -291,7 +287,7 @@ void pim_zebra_upstream_rpf_changed(struct pim_instance *pim,  			 */  			if (!up->channel_oil->installed)  				pim_upstream_mroute_add(up->channel_oil, -					__PRETTY_FUNCTION__); +							__func__);  			/*  			 * RFC 4601: 4.5.7.  Sending (S,G) @@ -329,8 +325,7 @@ void pim_zebra_upstream_rpf_changed(struct pim_instance *pim,  			pim_jp_agg_switch_interface(old, &up->rpf, up);  		if (!up->channel_oil->installed) -			pim_upstream_mroute_add(up->channel_oil, -					__PRETTY_FUNCTION__); +			pim_upstream_mroute_add(up->channel_oil, __func__);  	}  	/* FIXME can join_desired actually be changed by pim_rpf_update() @@ -430,7 +425,7 @@ void sched_rpf_cache_refresh(struct pim_instance *pim)  	/* Start refresh timer */  	if (PIM_DEBUG_ZEBRA) { -		zlog_debug("%s: triggering %ld msec timer", __PRETTY_FUNCTION__, +		zlog_debug("%s: triggering %ld msec timer", __func__,  			   router->rpf_cache_refresh_delay_msec);  	} @@ -475,8 +470,7 @@ void pim_zebra_init(void)  	zclient_init(zclient, ZEBRA_ROUTE_PIM, 0, &pimd_privs);  	if (PIM_DEBUG_PIM_TRACE) { -		zlog_notice("%s: zclient socket initialized", -			    __PRETTY_FUNCTION__); +		zlog_notice("%s: zclient socket initialized", __func__);  	}  	zclient_lookup_new(); @@ -493,8 +487,7 @@ void igmp_anysource_forward_start(struct pim_instance *pim,  	source = source_new(group, src_addr);  	if (!source) { -		zlog_warn("%s: Failure to create * source", -			  __PRETTY_FUNCTION__); +		zlog_warn("%s: Failure to create * source", __func__);  		return;  	} @@ -604,8 +597,8 @@ void igmp_source_forward_start(struct pim_instance *pim,  	if (PIM_DEBUG_IGMP_TRACE) {  		zlog_debug( -			"%s: (S,G)=%s igmp_sock=%d oif=%s fwd=%d", -			__PRETTY_FUNCTION__, pim_str_sg_dump(&sg), +			"%s: (S,G)=%s igmp_sock=%d oif=%s fwd=%d", __func__, +			pim_str_sg_dump(&sg),  			source->source_group->group_igmp_sock->fd,  			source->source_group->group_igmp_sock->interface->name,  			IGMP_SOURCE_TEST_FORWARDING(source->source_flags)); @@ -621,11 +614,10 @@ void igmp_source_forward_start(struct pim_instance *pim,  	pim_oif = group->group_igmp_sock->interface->info;  	if (!pim_oif) {  		if (PIM_DEBUG_IGMP_TRACE) { -			zlog_debug( -				   "%s: multicast not enabled on oif=%s ?", -				   __PRETTY_FUNCTION__, +			zlog_debug("%s: multicast not enabled on oif=%s ?", +				   __func__,  				   source->source_group->group_igmp_sock -				   ->interface->name); +					   ->interface->name);  		}  		return;  	} @@ -639,8 +631,8 @@ void igmp_source_forward_start(struct pim_instance *pim,  		if (!pim_rp_set_upstream_addr(pim, &vif_source,  					      source->source_addr, sg.grp)) {  			/*Create a dummy channel oil */ -			source->source_channel_oil = pim_channel_oil_add( -				pim, &sg, __PRETTY_FUNCTION__); +			source->source_channel_oil = +				pim_channel_oil_add(pim, &sg, __func__);  		}  		else { @@ -672,10 +664,10 @@ void igmp_source_forward_start(struct pim_instance *pim,  				pim_inet4_dump("<source?>", vif_source, buf2,  					       sizeof(buf2)); -				zlog_debug("%s: NHT %s vif_source %s vif_index:%d ", -					__PRETTY_FUNCTION__, -					pim_str_sg_dump(&sg), -					buf2, input_iface_vif_index); +				zlog_debug( +					"%s: NHT %s vif_source %s vif_index:%d ", +					__func__, pim_str_sg_dump(&sg), buf2, +					input_iface_vif_index);  			}  			if (input_iface_vif_index < 1) { @@ -685,14 +677,11 @@ void igmp_source_forward_start(struct pim_instance *pim,  						source->source_addr,  						source_str, sizeof(source_str));  					zlog_debug( -					    "%s %s: could not find input interface for source %s", -					    __FILE__, __PRETTY_FUNCTION__, -					    source_str); +						"%s %s: could not find input interface for source %s", +						__FILE__, __func__, source_str);  				}  				source->source_channel_oil = -					pim_channel_oil_add( -						pim, &sg, -						__PRETTY_FUNCTION__); +					pim_channel_oil_add(pim, &sg, __func__);  			}  			else { @@ -710,30 +699,28 @@ void igmp_source_forward_start(struct pim_instance *pim,  					 */  					if (PIM_DEBUG_IGMP_TRACE) {  						zlog_debug( -						    "%s: ignoring request for looped MFC entry (S,G)=%s: igmp_sock=%d oif=%s vif_index=%d", -						    __PRETTY_FUNCTION__, -						    pim_str_sg_dump(&sg), -						    source->source_group -						    ->group_igmp_sock->fd, -						    source->source_group -						    ->group_igmp_sock -						    ->interface->name, -						    input_iface_vif_index); +							"%s: ignoring request for looped MFC entry (S,G)=%s: igmp_sock=%d oif=%s vif_index=%d", +							__func__, +							pim_str_sg_dump(&sg), +							source->source_group +								->group_igmp_sock +								->fd, +							source->source_group +								->group_igmp_sock +								->interface->name, +							input_iface_vif_index);  					}  					return;  				}  				source->source_channel_oil = -					pim_channel_oil_add( -						pim, &sg, -						__PRETTY_FUNCTION__); +					pim_channel_oil_add(pim, &sg, __func__);  				if (!source->source_channel_oil) {  					if (PIM_DEBUG_IGMP_TRACE) {  						zlog_debug( -						    "%s %s: could not create OIL for channel (S,G)=%s", -						    __FILE__, -						    __PRETTY_FUNCTION__, -						    pim_str_sg_dump(&sg)); +							"%s %s: could not create OIL for channel (S,G)=%s", +							__FILE__, __func__, +							pim_str_sg_dump(&sg));  					}  					return;  				} @@ -754,10 +741,10 @@ void igmp_source_forward_start(struct pim_instance *pim,  		}  	} else {  		if (PIM_DEBUG_IGMP_TRACE) -			zlog_debug("%s: %s was received on %s interface but we are not DR for that interface", -				   __PRETTY_FUNCTION__, -				   pim_str_sg_dump(&sg), -				   group->group_igmp_sock->interface->name); +			zlog_debug( +				"%s: %s was received on %s interface but we are not DR for that interface", +				__func__, pim_str_sg_dump(&sg), +				group->group_igmp_sock->interface->name);  		return;  	} @@ -770,7 +757,7 @@ void igmp_source_forward_start(struct pim_instance *pim,  						false /*is_vxlan*/)) {  		if (PIM_DEBUG_MROUTE)  			zlog_warn("%s: Failure to add local membership for %s", -				  __PRETTY_FUNCTION__, pim_str_sg_dump(&sg)); +				  __func__, pim_str_sg_dump(&sg));  		pim_channel_del_oif(source->source_channel_oil,  				    group->group_igmp_sock->interface, @@ -797,8 +784,8 @@ void igmp_source_forward_stop(struct igmp_source *source)  	if (PIM_DEBUG_IGMP_TRACE) {  		zlog_debug( -			"%s: (S,G)=%s igmp_sock=%d oif=%s fwd=%d", -			__PRETTY_FUNCTION__, pim_str_sg_dump(&sg), +			"%s: (S,G)=%s igmp_sock=%d oif=%s fwd=%d", __func__, +			pim_str_sg_dump(&sg),  			source->source_group->group_igmp_sock->fd,  			source->source_group->group_igmp_sock->interface->name,  			IGMP_SOURCE_TEST_FORWARDING(source->source_flags)); @@ -861,7 +848,7 @@ void pim_forward_start(struct pim_ifchannel *ch)  			       sizeof(group_str));  		pim_inet4_dump("<upstream?>", up->upstream_addr, upstream_str,  			       sizeof(upstream_str)); -		zlog_debug("%s: (S,G)=(%s,%s) oif=%s (%s)", __PRETTY_FUNCTION__, +		zlog_debug("%s: (S,G)=(%s,%s) oif=%s (%s)", __func__,  			   source_str, group_str, ch->interface->name,  			   inet_ntoa(up->upstream_addr));  	} @@ -879,7 +866,7 @@ void pim_forward_stop(struct pim_ifchannel *ch, bool install_it)  	if (PIM_DEBUG_PIM_TRACE) {  		zlog_debug("%s: (S,G)=%s oif=%s install_it: %d installed: %d", -			   __PRETTY_FUNCTION__, ch->sg_str, ch->interface->name, +			   __func__, ch->sg_str, ch->interface->name,  			   install_it, up->channel_oil->installed);  	} @@ -895,7 +882,7 @@ void pim_forward_stop(struct pim_ifchannel *ch, bool install_it)  				    PIM_OIF_FLAG_PROTO_PIM, __func__);  	if (install_it && !up->channel_oil->installed) -		pim_upstream_mroute_add(up->channel_oil, __PRETTY_FUNCTION__); +		pim_upstream_mroute_add(up->channel_oil, __func__);  }  void pim_zebra_zclient_update(struct vty *vty) diff --git a/pimd/pim_zlookup.c b/pimd/pim_zlookup.c index 0454c0d69e..fc486f4998 100644 --- a/pimd/pim_zlookup.c +++ b/pimd/pim_zlookup.c @@ -56,7 +56,7 @@ static int zclient_lookup_connect(struct thread *t)  	if (zclient_socket_connect(zlookup) < 0) {  		++zlookup->fail;  		zlog_warn("%s: failure connecting zclient socket: failures=%d", -			  __PRETTY_FUNCTION__, zlookup->fail); +			  __func__, zlookup->fail);  	} else {  		zlookup->fail = 0; /* reset counter on connection */  	} @@ -79,7 +79,7 @@ static void zclient_lookup_sched(struct zclient *zlookup, int delay)  			 &zlookup->t_connect);  	zlog_notice("%s: zclient lookup connection scheduled for %d seconds", -		    __PRETTY_FUNCTION__, delay); +		    __func__, delay);  }  /* Schedule connection for now. */ @@ -89,7 +89,7 @@ static void zclient_lookup_sched_now(struct zclient *zlookup)  			 &zlookup->t_connect);  	zlog_notice("%s: zclient lookup immediate connection scheduled", -		    __PRETTY_FUNCTION__); +		    __func__);  }  /* Schedule reconnection, if needed. */ @@ -128,7 +128,7 @@ void zclient_lookup_new(void)  	zlookup = zclient_new(router->master, &zclient_options_default);  	if (!zlookup) {  		flog_err(EC_LIB_ZAPI_SOCKET, "%s: zclient_new() failure", -			 __PRETTY_FUNCTION__); +			 __func__);  		return;  	} @@ -138,8 +138,7 @@ void zclient_lookup_new(void)  	zclient_lookup_sched_now(zlookup); -	zlog_notice("%s: zclient lookup socket initialized", -		    __PRETTY_FUNCTION__); +	zlog_notice("%s: zclient lookup socket initialized", __func__);  }  static int zclient_read_nexthop(struct pim_instance *pim, @@ -163,7 +162,7 @@ static int zclient_read_nexthop(struct pim_instance *pim,  	if (PIM_DEBUG_PIM_NHT_DETAIL) {  		char addr_str[INET_ADDRSTRLEN];  		pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str)); -		zlog_debug("%s: addr=%s(%s)", __PRETTY_FUNCTION__, addr_str, +		zlog_debug("%s: addr=%s(%s)", __func__, addr_str,  			   pim->vrf->name);  	} @@ -175,8 +174,7 @@ static int zclient_read_nexthop(struct pim_instance *pim,  					  &version, &vrf_id, &command);  		if (err < 0) {  			flog_err(EC_LIB_ZAPI_MISSMATCH, -				 "%s: zclient_read_header() failed", -				 __PRETTY_FUNCTION__); +				 "%s: zclient_read_header() failed", __func__);  			zclient_lookup_failed(zlookup);  			return -1;  		} @@ -198,8 +196,7 @@ static int zclient_read_nexthop(struct pim_instance *pim,  		pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str));  		pim_inet4_dump("<raddr?>", raddr, raddr_str, sizeof(raddr_str));  		zlog_warn("%s: address mismatch: addr=%s(%s) raddr=%s", -			  __PRETTY_FUNCTION__, addr_str, pim->vrf->name, -			  raddr_str); +			  __func__, addr_str, pim->vrf->name, raddr_str);  		/* warning only */  	} @@ -228,8 +225,8 @@ static int zclient_read_nexthop(struct pim_instance *pim,  				       sizeof(addr_str));  			zlog_warn(  				"%s: found too many nexthop ifindexes (%d > %d) for address %s(%s)", -				__PRETTY_FUNCTION__, (num_ifindex + 1), -				tab_size, addr_str, pim->vrf->name); +				__func__, (num_ifindex + 1), tab_size, addr_str, +				pim->vrf->name);  			return num_ifindex;  		}  		nexthop_tab[num_ifindex].protocol_distance = distance; @@ -304,8 +301,8 @@ static int zclient_read_nexthop(struct pim_instance *pim,  					       sizeof(addr_str));  				zlog_warn(  					"%s: found non-ifindex nexthop type=%d for address %s(%s)", -					__PRETTY_FUNCTION__, nexthop_type, -					addr_str, pim->vrf->name); +					__func__, nexthop_type, addr_str, +					pim->vrf->name);  			}  			break;  		} @@ -324,7 +321,7 @@ static int zclient_lookup_nexthop_once(struct pim_instance *pim,  	if (PIM_DEBUG_PIM_NHT_DETAIL) {  		char addr_str[INET_ADDRSTRLEN];  		pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str)); -		zlog_debug("%s: addr=%s(%s)", __PRETTY_FUNCTION__, addr_str, +		zlog_debug("%s: addr=%s(%s)", __func__, addr_str,  			   pim->vrf->name);  	} @@ -332,7 +329,7 @@ static int zclient_lookup_nexthop_once(struct pim_instance *pim,  	if (zlookup->sock < 0) {  		flog_err(EC_LIB_ZAPI_SOCKET,  			 "%s: zclient lookup socket is not connected", -			 __PRETTY_FUNCTION__); +			 __func__);  		zclient_lookup_failed(zlookup);  		return -1;  	} @@ -340,7 +337,7 @@ static int zclient_lookup_nexthop_once(struct pim_instance *pim,  	if (pim->vrf->vrf_id == VRF_UNKNOWN) {  		zlog_notice(  			"%s: VRF: %s does not fully exist yet, delaying lookup", -			__PRETTY_FUNCTION__, pim->vrf->name); +			__func__, pim->vrf->name);  		return -1;  	} @@ -356,14 +353,14 @@ static int zclient_lookup_nexthop_once(struct pim_instance *pim,  		flog_err(  			EC_LIB_SOCKET,  			"%s: writen() failure: %d writing to zclient lookup socket", -			__PRETTY_FUNCTION__, errno); +			__func__, errno);  		zclient_lookup_failed(zlookup);  		return -2;  	}  	if (ret == 0) {  		flog_err_sys(EC_LIB_SOCKET,  			     "%s: connection closed on zclient lookup socket", -			     __PRETTY_FUNCTION__); +			     __func__);  		zclient_lookup_failed(zlookup);  		return -3;  	} @@ -410,8 +407,8 @@ int zclient_lookup_nexthop(struct pim_instance *pim,  					       sizeof(addr_str));  				zlog_debug(  					"%s: lookup=%d/%d: could not find nexthop ifindex for address %s(%s)", -					__PRETTY_FUNCTION__, lookup, max_lookup, -					addr_str, pim->vrf->name); +					__func__, lookup, max_lookup, addr_str, +					pim->vrf->name);  			}  			return -1;  		} @@ -448,9 +445,9 @@ int zclient_lookup_nexthop(struct pim_instance *pim,  						       sizeof(addr_str));  					zlog_debug(  						"%s: lookup=%d/%d: found non-recursive ifindex=%d for address %s(%s) dist=%d met=%d", -						__PRETTY_FUNCTION__, lookup, -						max_lookup, first_ifindex, -						addr_str, pim->vrf->name, +						__func__, lookup, max_lookup, +						first_ifindex, addr_str, +						pim->vrf->name,  						nexthop_tab[0]  							.protocol_distance,  						nexthop_tab[0].route_metric); @@ -477,8 +474,8 @@ int zclient_lookup_nexthop(struct pim_instance *pim,  				      sizeof(nexthop_str));  			zlog_debug(  				"%s: lookup=%d/%d: zebra returned recursive nexthop %s for address %s(%s) dist=%d met=%d", -				__PRETTY_FUNCTION__, lookup, max_lookup, -				nexthop_str, addr_str, pim->vrf->name, +				__func__, lookup, max_lookup, nexthop_str, +				addr_str, pim->vrf->name,  				nexthop_tab[0].protocol_distance,  				nexthop_tab[0].route_metric);  		} @@ -493,8 +490,7 @@ int zclient_lookup_nexthop(struct pim_instance *pim,  		pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str));  		zlog_warn(  			"%s: lookup=%d/%d: failure searching recursive nexthop ifindex for address %s(%s)", -			__PRETTY_FUNCTION__, lookup, max_lookup, addr_str, -			pim->vrf->name); +			__func__, lookup, max_lookup, addr_str, pim->vrf->name);  	}  	return -2; @@ -548,7 +544,7 @@ int pim_zlookup_sg_statistics(struct channel_oil *c_oil)  		flog_err(  			EC_LIB_SOCKET,  			"%s: writen() failure: %d writing to zclient lookup socket", -			__PRETTY_FUNCTION__, errno); +			__func__, errno);  		return -1;  	} @@ -566,8 +562,7 @@ int pim_zlookup_sg_statistics(struct channel_oil *c_oil)  					  &version, &vrf_id, &command);  		if (err < 0) {  			flog_err(EC_LIB_ZAPI_MISSMATCH, -				 "%s: zclient_read_header() failed", -				 __PRETTY_FUNCTION__); +				 "%s: zclient_read_header() failed", __func__);  			zclient_lookup_failed(zlookup);  			return -1;  		} @@ -585,7 +580,7 @@ int pim_zlookup_sg_statistics(struct channel_oil *c_oil)  			flog_err(  				EC_LIB_ZAPI_MISSMATCH,  				"%s: Received wrong %s(%s) information requested", -				__PRETTY_FUNCTION__, pim_str_sg_dump(&more), +				__func__, pim_str_sg_dump(&more),  				c_oil->pim->vrf->name);  		}  		zclient_lookup_failed(zlookup); 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 0a7ac3b31f..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) @@ -115,8 +118,8 @@ void pim_init(void)  		flog_err(  			EC_LIB_SOCKET,  			"%s %s: could not solve %s to group address: errno=%d: %s", -			__FILE__, __PRETTY_FUNCTION__, PIM_ALL_PIM_ROUTERS, -			errno, safe_strerror(errno)); +			__FILE__, __func__, PIM_ALL_PIM_ROUTERS, errno, +			safe_strerror(errno));  		zassert(0);  		return;  	} @@ -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/ripd/rip_interface.c b/ripd/rip_interface.c index 2ed8d5394d..c05d776eb1 100644 --- a/ripd/rip_interface.c +++ b/ripd/rip_interface.c @@ -216,7 +216,7 @@ rip_request_neighbor (struct in_addr addr)  {    struct sockaddr_in to; -  memset (&to, 0, sizeof (struct sockaddr_in)); +  memset (&to, 0, sizeof(struct sockaddr_in));    to.sin_port = htons (RIP_PORT_DEFAULT);    to.sin_addr = addr; diff --git a/ripd/rip_peer.c b/ripd/rip_peer.c index 4ad7309c41..55dafd7c1f 100644 --- a/ripd/rip_peer.c +++ b/ripd/rip_peer.c @@ -131,7 +131,7 @@ void rip_peer_bad_packet(struct rip *rip, struct sockaddr_in *from)  static char *rip_peer_uptime(struct rip_peer *peer, char *buf, size_t len)  {  	time_t uptime; -	struct tm *tm; +	struct tm tm;  	/* If there is no connection has been done before print `never'. */  	if (peer->uptime == 0) { @@ -142,17 +142,17 @@ static char *rip_peer_uptime(struct rip_peer *peer, char *buf, size_t len)  	/* Get current time. */  	uptime = time(NULL);  	uptime -= peer->uptime; -	tm = gmtime(&uptime); +	gmtime_r(&uptime, &tm);  	if (uptime < ONE_DAY_SECOND) -		snprintf(buf, len, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, -			 tm->tm_sec); +		snprintf(buf, len, "%02d:%02d:%02d", tm.tm_hour, tm.tm_min, +			 tm.tm_sec);  	else if (uptime < ONE_WEEK_SECOND) -		snprintf(buf, len, "%dd%02dh%02dm", tm->tm_yday, tm->tm_hour, -			 tm->tm_min); +		snprintf(buf, len, "%dd%02dh%02dm", tm.tm_yday, tm.tm_hour, +			 tm.tm_min);  	else -		snprintf(buf, len, "%02dw%dd%02dh", tm->tm_yday / 7, -			 tm->tm_yday - ((tm->tm_yday / 7) * 7), tm->tm_hour); +		snprintf(buf, len, "%02dw%dd%02dh", tm.tm_yday / 7, +			 tm.tm_yday - ((tm.tm_yday / 7) * 7), tm.tm_hour);  	return buf;  } diff --git a/ripd/rip_routemap.c b/ripd/rip_routemap.c index 102b64df6b..77c2db8ceb 100644 --- a/ripd/rip_routemap.c +++ b/ripd/rip_routemap.c @@ -468,7 +468,7 @@ static void *route_set_metric_compile(const char *arg)  	if (metric > RIP_METRIC_INFINITY) {  		zlog_info(  			"%s: Metric specified: %ld is greater than RIP_METRIC_INFINITY, using INFINITY instead", -			__PRETTY_FUNCTION__, metric); +			__func__, metric);  		mod->metric = RIP_METRIC_INFINITY;  	} else  		mod->metric = metric; diff --git a/ripd/rip_snmp.c b/ripd/rip_snmp.c index 39e07f3c2e..be222c7a5f 100644 --- a/ripd/rip_snmp.c +++ b/ripd/rip_snmp.c @@ -553,7 +553,7 @@ static uint8_t *rip2PeerTable(struct variable *v, oid name[], size_t *length,         * - don't support this variable, at all         * Currently, we do the latter...         */ -      *val_len = sizeof (time_t); +      *val_len = sizeof(time_t);        uptime = peer->uptime; /* now - snmp_agent_startup - peer->uptime */        return (uint8_t *) &uptime;  #else diff --git a/ripd/ripd.c b/ripd/ripd.c index 5ccefac178..f092da847d 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -104,7 +104,7 @@ static int sockopt_broadcast(int sock)  	int on = 1;  	ret = setsockopt(sock, SOL_SOCKET, SO_BROADCAST, (char *)&on, -			 sizeof on); +			 sizeof(on));  	if (ret < 0) {  		zlog_warn("can't set sockopt SO_BROADCAST to socket %d", sock);  		return -1; @@ -3020,20 +3020,20 @@ void rip_ecmp_disable(struct rip *rip)  static void rip_vty_out_uptime(struct vty *vty, struct rip_info *rinfo)  {  	time_t clock; -	struct tm *tm; +	struct tm tm;  #define TIME_BUF 25  	char timebuf[TIME_BUF];  	struct thread *thread;  	if ((thread = rinfo->t_timeout) != NULL) {  		clock = thread_timer_remain_second(thread); -		tm = gmtime(&clock); -		strftime(timebuf, TIME_BUF, "%M:%S", tm); +		gmtime_r(&clock, &tm); +		strftime(timebuf, TIME_BUF, "%M:%S", &tm);  		vty_out(vty, "%5s", timebuf);  	} else if ((thread = rinfo->t_garbage_collect) != NULL) {  		clock = thread_timer_remain_second(thread); -		tm = gmtime(&clock); -		strftime(timebuf, TIME_BUF, "%M:%S", tm); +		gmtime_r(&clock, &tm); +		strftime(timebuf, TIME_BUF, "%M:%S", &tm);  		vty_out(vty, "%5s", timebuf);  	}  } diff --git a/ripngd/ripng_peer.c b/ripngd/ripng_peer.c index 109524e212..c038bfccf0 100644 --- a/ripngd/ripng_peer.c +++ b/ripngd/ripng_peer.c @@ -141,7 +141,7 @@ void ripng_peer_bad_packet(struct ripng *ripng, struct sockaddr_in6 *from)  static char *ripng_peer_uptime(struct ripng_peer *peer, char *buf, size_t len)  {  	time_t uptime; -	struct tm *tm; +	struct tm tm;  	/* If there is no connection has been done before print `never'. */  	if (peer->uptime == 0) { @@ -152,17 +152,17 @@ static char *ripng_peer_uptime(struct ripng_peer *peer, char *buf, size_t len)  	/* Get current time. */  	uptime = time(NULL);  	uptime -= peer->uptime; -	tm = gmtime(&uptime); +	gmtime_r(&uptime, &tm);  	if (uptime < ONE_DAY_SECOND) -		snprintf(buf, len, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, -			 tm->tm_sec); +		snprintf(buf, len, "%02d:%02d:%02d", tm.tm_hour, tm.tm_min, +			 tm.tm_sec);  	else if (uptime < ONE_WEEK_SECOND) -		snprintf(buf, len, "%dd%02dh%02dm", tm->tm_yday, tm->tm_hour, -			 tm->tm_min); +		snprintf(buf, len, "%dd%02dh%02dm", tm.tm_yday, tm.tm_hour, +			 tm.tm_min);  	else -		snprintf(buf, len, "%02dw%dd%02dh", tm->tm_yday / 7, -			 tm->tm_yday - ((tm->tm_yday / 7) * 7), tm->tm_hour); +		snprintf(buf, len, "%02dw%dd%02dh", tm.tm_yday / 7, +			 tm.tm_yday - ((tm.tm_yday / 7) * 7), tm.tm_hour);  	return buf;  } diff --git a/ripngd/ripng_routemap.c b/ripngd/ripng_routemap.c index 6123591429..b5f80d2ab0 100644 --- a/ripngd/ripng_routemap.c +++ b/ripngd/ripng_routemap.c @@ -237,9 +237,9 @@ static void *route_set_metric_compile(const char *arg)  		return mod;  	if (metric > RIPNG_METRIC_INFINITY) { -		zlog_info("%s: Metric specified: %ld is being converted into METRIC_INFINITY", -			  __PRETTY_FUNCTION__, -			  metric); +		zlog_info( +			"%s: Metric specified: %ld is being converted into METRIC_INFINITY", +			__func__, metric);  		mod->metric = RIPNG_METRIC_INFINITY;  	} else  		mod->metric = metric; diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c index f8d7dc968b..7fbe64e8e3 100644 --- a/ripngd/ripngd.c +++ b/ripngd/ripngd.c @@ -271,7 +271,7 @@ static int ripng_recv_packet(int sock, uint8_t *buf, int bufsize,  	msg.msg_iov = &iov;  	msg.msg_iovlen = 1;  	msg.msg_control = (void *)adata; -	msg.msg_controllen = sizeof adata; +	msg.msg_controllen = sizeof(adata);  	iov.iov_base = buf;  	iov.iov_len = bufsize; @@ -1991,20 +1991,20 @@ void ripng_event(struct ripng *ripng, enum ripng_event event, int sock)  static void ripng_vty_out_uptime(struct vty *vty, struct ripng_info *rinfo)  {  	time_t clock; -	struct tm *tm; +	struct tm tm;  #define TIME_BUF 25  	char timebuf[TIME_BUF];  	struct thread *thread;  	if ((thread = rinfo->t_timeout) != NULL) {  		clock = thread_timer_remain_second(thread); -		tm = gmtime(&clock); -		strftime(timebuf, TIME_BUF, "%M:%S", tm); +		gmtime_r(&clock, &tm); +		strftime(timebuf, TIME_BUF, "%M:%S", &tm);  		vty_out(vty, "%5s", timebuf);  	} else if ((thread = rinfo->t_garbage_collect) != NULL) {  		clock = thread_timer_remain_second(thread); -		tm = gmtime(&clock); -		strftime(timebuf, TIME_BUF, "%M:%S", tm); +		gmtime_r(&clock, &tm); +		strftime(timebuf, TIME_BUF, "%M:%S", &tm);  		vty_out(vty, "%5s", timebuf);  	}  } diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c index 4fc8f40ae1..5baa74fe96 100644 --- a/sharpd/sharp_zebra.c +++ b/sharpd/sharp_zebra.c @@ -318,8 +318,7 @@ void sharp_zebra_nexthop_watch(struct prefix *p, vrf_id_t vrf_id, bool import,  	}  	if (zclient_send_rnh(zclient, command, p, connected, vrf_id) < 0) -		zlog_warn("%s: Failure to send nexthop to zebra", -			  __PRETTY_FUNCTION__); +		zlog_warn("%s: Failure to send nexthop to zebra", __func__);  }  static int sharp_debug_nexthops(struct zapi_route *api) @@ -367,7 +366,7 @@ static int sharp_nexthop_update(ZAPI_CALLBACK_ARGS)  	struct zapi_route nhr;  	if (!zapi_nexthop_update_decode(zclient->ibuf, &nhr)) { -		zlog_warn("%s: Decode of update failed", __PRETTY_FUNCTION__); +		zlog_warn("%s: Decode of update failed", __func__);  		return 0;  	} @@ -388,8 +387,7 @@ static int sharp_redistribute_route(ZAPI_CALLBACK_ARGS)  	struct zapi_route api;  	if (zapi_route_decode(zclient->ibuf, &api) < 0) -		zlog_warn("%s: Decode of redistribute failed: %d", -			  __PRETTY_FUNCTION__, +		zlog_warn("%s: Decode of redistribute failed: %d", __func__,  			  ZEBRA_REDISTRIBUTE_ROUTE_ADD);  	zlog_debug("%s: %pFX (%s)", zserv_command_string(cmd), diff --git a/staticd/static_debug.h b/staticd/static_debug.h index 6e58118ed0..8932e2d429 100644 --- a/staticd/static_debug.h +++ b/staticd/static_debug.h @@ -29,7 +29,7 @@  #include "lib/debug.h"  /* staticd debugging records */ -struct debug static_dbg_events; +extern struct debug static_dbg_events;  /*   * Initialize staticd debugging. diff --git a/staticd/static_main.c b/staticd/static_main.c index 43cb7db51d..3aa8a8db3e 100644 --- a/staticd/static_main.c +++ b/staticd/static_main.c @@ -73,6 +73,8 @@ static void sigint(void)  {  	zlog_notice("Terminating on signal"); +	static_vrf_terminate(); +  	exit(0);  } diff --git a/staticd/static_vrf.c b/staticd/static_vrf.c index abb64aad3f..6c065932a1 100644 --- a/staticd/static_vrf.c +++ b/staticd/static_vrf.c @@ -111,6 +111,7 @@ static int static_vrf_delete(struct vrf *vrf)  			svrf->stable[afi][safi] = NULL;  		}  	} +	XFREE(MTYPE_TMP, svrf);  	return 0;  } @@ -204,3 +205,8 @@ void static_vrf_init(void)  	vrf_cmd_init(static_vrf_config_write, &static_privs);  } + +void static_vrf_terminate(void) +{ +	vrf_terminate(); +} diff --git a/staticd/static_vrf.h b/staticd/static_vrf.h index 28fcdd0d36..6951e56712 100644 --- a/staticd/static_vrf.h +++ b/staticd/static_vrf.h @@ -35,4 +35,5 @@ void static_vrf_init(void);  struct route_table *static_vrf_static_table(afi_t afi, safi_t safi,  					    struct static_vrf *svrf); +extern void static_vrf_terminate(void);  #endif diff --git a/staticd/static_vty.c b/staticd/static_vty.c index 6390fd811f..40bcf2b5d3 100644 --- a/staticd/static_vty.c +++ b/staticd/static_vty.c @@ -287,8 +287,8 @@ static int static_route_leak(  		if (vty)  			vty_out(vty, "%% Malformed address\n");  		else -			zlog_warn("%s: Malformed address: %s", -				  __PRETTY_FUNCTION__, dest_str); +			zlog_warn("%s: Malformed address: %s", __func__, +				  dest_str);  		return CMD_WARNING_CONFIG_FAILED;  	} @@ -302,8 +302,7 @@ static int static_route_leak(  					vty_out(vty, "%% Malformed address\n");  				else  					zlog_warn("%s: Malformed address: %s", -						  __PRETTY_FUNCTION__, -						  mask_str); +						  __func__, mask_str);  				return CMD_WARNING_CONFIG_FAILED;  			}  			p.prefixlen = ip_masklen(mask); @@ -320,7 +319,7 @@ static int static_route_leak(  				else  					zlog_warn(  						"%s: Malformed source address: %s", -						__PRETTY_FUNCTION__, src_str); +						__func__, src_str);  				return CMD_WARNING_CONFIG_FAILED;  			}  			src_p = (struct prefix_ipv6 *)&src; @@ -351,10 +350,9 @@ static int static_route_leak(  				    "%% Table %s overlaps vrf table %u\n",  				    table_str, svrf->vrf->data.l.table_id);  			else -				zlog_warn( -				    "%s: Table %s overlaps vrf table %u", -				    __PRETTY_FUNCTION__, -				    table_str, svrf->vrf->data.l.table_id); +				zlog_warn("%s: Table %s overlaps vrf table %u", +					  __func__, table_str, +					  svrf->vrf->data.l.table_id);  			return CMD_WARNING_CONFIG_FAILED;  		}  	} @@ -379,7 +377,7 @@ static int static_route_leak(  			else  				zlog_warn(  					"%s: MPLS not turned on in kernel ignoring static route to %s", -					__PRETTY_FUNCTION__, dest_str); +					__func__, dest_str);  			return CMD_WARNING_CONFIG_FAILED;  		}  		int rc = mpls_str2label(label_str, &snh_label.num_labels, @@ -392,7 +390,7 @@ static int static_route_leak(  				else  					zlog_warn(  						"%s: Malformed labels specified for route %s", -						__PRETTY_FUNCTION__, dest_str); +						__func__, dest_str);  				break;  			case -2:  				if (vty) @@ -403,7 +401,7 @@ static int static_route_leak(  				else  					zlog_warn(  						"%s: Cannot use reserved labels (%d-%d) for %s", -						__PRETTY_FUNCTION__, +						__func__,  						MPLS_LABEL_RESERVED_MIN,  						MPLS_LABEL_RESERVED_MAX,  						dest_str); @@ -416,8 +414,8 @@ static int static_route_leak(  				else  					zlog_warn(  						"%s: Too many labels, Enter %d or fewer for %s", -						__PRETTY_FUNCTION__, -						MPLS_MAX_LABELS, dest_str); +						__func__, MPLS_MAX_LABELS, +						dest_str);  				break;  			}  			return CMD_WARNING_CONFIG_FAILED; @@ -439,7 +437,7 @@ static int static_route_leak(  			else  				zlog_warn(  					"%s: %s: Nexthop interface name can not be from reserved keywords (Null0, reject, blackhole)", -					__PRETTY_FUNCTION__, dest_str); +					__func__, dest_str);  			return CMD_WARNING_CONFIG_FAILED;  		}  	} @@ -462,8 +460,7 @@ static int static_route_leak(  					flag_str);  			else  				zlog_warn("%s: Malformed flag %s for %s", -					  __PRETTY_FUNCTION__, flag_str, -					  dest_str); +					  __func__, flag_str, dest_str);  			return CMD_WARNING_CONFIG_FAILED;  		}  	} @@ -477,8 +474,7 @@ static int static_route_leak(  			else  				zlog_warn(  					"%s: Malformed nexthop address %s for %s", -					__PRETTY_FUNCTION__, gate_str, -					dest_str); +					__func__, gate_str, dest_str);  			return CMD_WARNING_CONFIG_FAILED;  		}  		gatep = &gate; @@ -595,7 +591,7 @@ void static_config_install_delayed_routes(struct static_vrf *svrf)  		if (installed != CMD_SUCCESS)  			zlog_debug(  				"%s: Attempt to install %s as a route and it was rejected", -				__PRETTY_FUNCTION__, shr->dest_str); +				__func__, shr->dest_str);  		listnode_delete(static_list, shr);  		static_list_delete(shr);  	} diff --git a/staticd/static_zebra.c b/staticd/static_zebra.c index 42646d15bc..5cadf34365 100644 --- a/staticd/static_zebra.c +++ b/staticd/static_zebra.c @@ -122,12 +122,13 @@ static int route_notify_owner(ZAPI_CALLBACK_ARGS)  	case ZAPI_ROUTE_FAIL_INSTALL:  		static_nht_mark_state(&p, vrf_id, STATIC_NOT_INSTALLED);  		zlog_warn("%s: Route %s failed to install for table: %u", -			  __PRETTY_FUNCTION__, buf, table_id); +			  __func__, buf, table_id);  		break;  	case ZAPI_ROUTE_BETTER_ADMIN_WON:  		static_nht_mark_state(&p, vrf_id, STATIC_NOT_INSTALLED); -		zlog_warn("%s: Route %s over-ridden by better route for table: %u", -			  __PRETTY_FUNCTION__, buf, table_id); +		zlog_warn( +			"%s: Route %s over-ridden by better route for table: %u", +			__func__, buf, table_id);  		break;  	case ZAPI_ROUTE_INSTALLED:  		static_nht_mark_state(&p, vrf_id, STATIC_INSTALLED); @@ -138,7 +139,7 @@ static int route_notify_owner(ZAPI_CALLBACK_ARGS)  	case ZAPI_ROUTE_REMOVE_FAIL:  		static_nht_mark_state(&p, vrf_id, STATIC_INSTALLED);  		zlog_warn("%s: Route %s failure to remove for table: %u", -			  __PRETTY_FUNCTION__, buf, table_id); +			  __func__, buf, table_id);  		break;  	} @@ -335,8 +336,7 @@ void static_zebra_nht_register(struct route_node *rn,  	}  	if (zclient_send_rnh(zclient, cmd, &p, false, si->nh_vrf_id) < 0) -		zlog_warn("%s: Failure to send nexthop to zebra", -			  __PRETTY_FUNCTION__); +		zlog_warn("%s: Failure to send nexthop to zebra", __func__);  }  extern void static_zebra_route_add(struct route_node *rn, diff --git a/tests/bgpd/test_mpath.c b/tests/bgpd/test_mpath.c index 3f63c0499a..2258df9491 100644 --- a/tests/bgpd/test_mpath.c +++ b/tests/bgpd/test_mpath.c @@ -52,8 +52,8 @@  #define EXPECT_TRUE(expr, res)                                                 \  	if (!(expr)) {                                                         \ -		printf("Test failure in %s line %u: %s\n", __FUNCTION__,       \ -		       __LINE__, #expr);                                       \ +		printf("Test failure in %s line %u: %s\n", __func__, __LINE__, \ +		       #expr);                                                 \  		(res) = TEST_FAILED;                                           \  	} @@ -75,7 +75,7 @@ struct testcase_t__ {  /* need these to link in libbgp */  struct thread_master *master = NULL; -struct zclient *zclient; +extern struct zclient *zclient;  struct zebra_privs_t bgpd_privs = {  	.user = NULL,  	.group = NULL, diff --git a/tests/topotests/bgp-route-map/test_route_map_topo1.py b/tests/topotests/bgp-route-map/test_route_map_topo1.py index 86ec6c82d2..22dd3a6380 100755 --- a/tests/topotests/bgp-route-map/test_route_map_topo1.py +++ b/tests/topotests/bgp-route-map/test_route_map_topo1.py @@ -71,7 +71,7 @@ from time import sleep  # Save the Current Working Directory to find configuration files.  CWD = os.path.dirname(os.path.realpath(__file__)) -sys.path.append(os.path.join(CWD, '../')) +sys.path.append(os.path.join(CWD, "../"))  # pylint: disable=C0413  # Import topogen and topotest helpers @@ -102,7 +102,7 @@ ADDR_TYPES = check_address_types()  # Reading the data from JSON File for topology and configuration creation  jsonFile = "{}/bgp_route_map_topo1.json".format(CWD)  try: -    with open(jsonFile, 'r') as topoJson: +    with open(jsonFile, "r") as topoJson:          topo = json.load(topoJson)  except IOError:      assert False, "Could not read file {}".format(jsonFile) @@ -442,11 +442,12 @@ def test_route_map_inbound_outbound_same_neighbor_p0(request):              }          } -        result = verify_rib(tgen, adt, dut, input_dict_2, protocol=protocol) +        result = verify_rib(tgen, adt, dut, input_dict_2, protocol=protocol, +                            expected=False)          assert result is not True, "Testcase {} : Failed \n" -        "Expected behavior: routes are not present in rib \n" -        "Error: {}".format( +        "routes are not present in rib \n Error: {}".format(              tc_name, result) +        logger.info("Expected behaviour: {}".format(result))          # Verifying RIB routes          dut = "r4" @@ -461,11 +462,12 @@ def test_route_map_inbound_outbound_same_neighbor_p0(request):                  ]              }          } -        result = verify_rib(tgen, adt, dut, input_dict, protocol=protocol) +        result = verify_rib(tgen, adt, dut, input_dict, protocol=protocol, +                            expected=False)          assert result is not True, "Testcase {} : Failed \n " -        "Expected behavior: routes are not present in rib \n " -        "Error: {}".format( +        "routes are not present in rib \n Error: {}".format(              tc_name, result) +        logger.info("Expected behaviour: {}".format(result))      write_test_footer(tc_name) @@ -649,10 +651,14 @@ def test_route_map_with_action_values_combination_of_prefix_action_p0(              }          } -        result = verify_rib(tgen, adt, dut, input_dict_2, protocol=protocol) +        #tgen.mininet_cli() +        result = verify_rib(tgen, adt, dut, input_dict_2, protocol=protocol, +                            expected=False)          if "deny" in [prefix_action, rmap_action]: -            assert result is not True, "Testcase {} : Failed \n Error: {}".\ +            assert result is not True, "Testcase {} : Failed \n " +            "Routes are still present \n Error: {}".\                  format(tc_name, result) +            logger.info("Expected behaviour: {}".format(result))          else:              assert result is True, "Testcase {} : Failed \n Error: {}".format(                  tc_name, result) diff --git a/tests/topotests/bgp-route-map/test_route_map_topo2.py b/tests/topotests/bgp-route-map/test_route_map_topo2.py index 7009fc97ce..f2398c33ff 100755 --- a/tests/topotests/bgp-route-map/test_route_map_topo2.py +++ b/tests/topotests/bgp-route-map/test_route_map_topo2.py @@ -32,17 +32,17 @@ TC_61:  TC_50_1:      Test modify/remove prefix-lists referenced by a      route-map for match statement. -TC_50_1: +TC_50_2:      Remove prefix-list referencec by route-map match cluase      and verifying it reflecting as intended  TC_51:      Add and remove community-list referencec by route-map match cluase      and verifying it reflecting as intended  TC_45: -    Test multiple match statements as part of a route-map's single +    Test multiple match statements as part of a route-map"s single      sequence number. (Logical OR-ed of multiple match statements)  TC_44: -    Test multiple match statements as part of a route-map's single +    Test multiple match statements as part of a route-map"s single      sequence number. (Logical AND of multiple match statements)  TC_41:      Test add/remove route-maps to specific neighbor and see if @@ -57,7 +57,7 @@ TC_48:      Create route map setting local preference and weight to eBGP peeer      and metric to ibgp peer and verifying it should not get advertised  TC_43: -    Test multiple set statements as part of a route-map's +    Test multiple set statements as part of a route-map"s      single sequence number.  TC_54:      Verify route-maps continue clause functionality. @@ -112,7 +112,7 @@ from time import sleep  # Save the Current Working Directory to find configuration files.  CWD = os.path.dirname(os.path.realpath(__file__)) -sys.path.append(os.path.join(CWD, '../')) +sys.path.append(os.path.join(CWD, "../"))  # pylint: disable=C0413  # Import topogen and topotest helpers @@ -127,7 +127,8 @@ from lib.common_config import (      verify_rib, delete_route_maps, create_bgp_community_lists,      interface_status, create_route_maps, create_prefix_lists,      verify_route_maps, check_address_types, verify_bgp_community, -    shutdown_bringup_interface, verify_prefix_lists, reset_config_on_routers) +    shutdown_bringup_interface, verify_prefix_lists, reset_config_on_routers, +    verify_create_community_list)  from lib.topolog import logger  from lib.bgp import (      verify_bgp_convergence, create_router_bgp, @@ -138,7 +139,7 @@ from lib.topojson import build_topo_from_json, build_config_from_json  jsonFile = "{}/bgp_route_map_topo2.json".format(CWD)  try: -    with open(jsonFile, 'r') as topoJson: +    with open(jsonFile, "r") as topoJson:          topo = json.load(topoJson)  except IOError:      assert False, "Could not read file {}".format(jsonFile) @@ -198,14 +199,14 @@ def setup_module(mod):      global bgp_convergence      global ADDR_TYPES -    # Don't run this test if we have any failure. +    # Don"t run this test if we have any failure.      if tgen.routers_have_failure():          pytest.skip(tgen.errors)      # Api call verify whether BGP is converged      bgp_convergence = verify_bgp_convergence(tgen, topo) -    assert bgp_convergence is True, ('setup_module :Failed \n Error:' -                                     ' {}'.format(bgp_convergence)) +    assert bgp_convergence is True, ("setup_module :Failed \n Error:" +                                     " {}".format(bgp_convergence))      logger.info("Running setup_module() done") @@ -241,7 +242,7 @@ def test_rmap_match_prefix_list_permit_in_and_outbound_prefixes_p0():      global bgp_convergence      if bgp_convergence is not True: -        pytest.skip('skipped because of BGP Convergence failure') +        pytest.skip("skipped because of BGP Convergence failure")      # test case name      tc_name = inspect.stack()[0][3] @@ -250,20 +251,20 @@ def test_rmap_match_prefix_list_permit_in_and_outbound_prefixes_p0():      # Create ip prefix list      input_dict_2 = { -        'r3': { -            'prefix_lists': { -                'ipv4': { -                    'pf_list_1_ipv4': [{ -                        'seqid': 10, -                        'network': 'any', -                        'action': 'permit', +        "r3": { +            "prefix_lists": { +                "ipv4": { +                    "pf_list_1_ipv4": [{ +                        "seqid": 10, +                        "network": "any", +                        "action": "permit",                      }]                  }, -                'ipv6': { -                    'pf_list_1_ipv6': [{ -                        'seqid': 10, -                        'network': 'any', -                        'action': 'permit', +                "ipv6": { +                    "pf_list_1_ipv6": [{ +                        "seqid": 10, +                        "network": "any", +                        "action": "permit",                      }]                  }              } @@ -271,7 +272,7 @@ def test_rmap_match_prefix_list_permit_in_and_outbound_prefixes_p0():      }      result = create_prefix_lists(tgen, input_dict_2) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      for addr_type in ADDR_TYPES:      # Create route map @@ -280,7 +281,7 @@ def test_rmap_match_prefix_list_permit_in_and_outbound_prefixes_p0():                  "route_maps": {                      "rmap_match_pf_1_{}".format(addr_type): [{                          "action": "permit", -                        'seq_id': '5', +                        "seq_id": "5",                          "match": {                              addr_type: {                                  "prefix_lists": "pf_list_1_" + addr_type @@ -294,7 +295,7 @@ def test_rmap_match_prefix_list_permit_in_and_outbound_prefixes_p0():                      ],                      "rmap_match_pf_2_{}".format(addr_type): [{                          "action": "permit", -                        'seq_id': '5', +                        "seq_id": "5",                          "match": {                              addr_type: {                                  "prefix_lists": "pf_list_1_" + addr_type @@ -309,12 +310,12 @@ def test_rmap_match_prefix_list_permit_in_and_outbound_prefixes_p0():              }          }          result = create_route_maps(tgen, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Configure neighbor for route map      input_dict_4 = { -       'r3': { +       "r3": {             "bgp": {                 "address_family": {                     "ipv4": { @@ -326,7 +327,7 @@ def test_rmap_match_prefix_list_permit_in_and_outbound_prefixes_p0():                                             "route_maps": [{                                                     "name":                                                     "rmap_match_pf_1_ipv4", -                                                   "direction": 'in' +                                                   "direction": "in"                                             }]                                         }                                     } @@ -337,7 +338,7 @@ def test_rmap_match_prefix_list_permit_in_and_outbound_prefixes_p0():                                             "route_maps": [{                                                     "name":                                                     "rmap_match_pf_2_ipv4", -                                                   "direction": 'out' +                                                   "direction": "out"                                             }]                                         }                                     } @@ -354,7 +355,7 @@ def test_rmap_match_prefix_list_permit_in_and_outbound_prefixes_p0():                                             "route_maps": [{                                                     "name":                                                     "rmap_match_pf_1_ipv6", -                                                   "direction": 'in' +                                                   "direction": "in"                                             }]                                         }                                     } @@ -365,7 +366,7 @@ def test_rmap_match_prefix_list_permit_in_and_outbound_prefixes_p0():                                             "route_maps": [{                                                     "name":                                                     "rmap_match_pf_2_ipv6", -                                                   "direction": 'out' +                                                   "direction": "out"                                             }]                                         }                                     } @@ -379,23 +380,23 @@ def test_rmap_match_prefix_list_permit_in_and_outbound_prefixes_p0():      }      result = create_router_bgp(tgen, topo, input_dict_4) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Verifying RIB routes -    dut = 'r3' -    protocol = 'bgp' +    dut = "r3" +    protocol = "bgp"      input_dict = topo["routers"]      # dual stack changes      for addr_type in ADDR_TYPES:          result4 = verify_rib(tgen, addr_type, dut, input_dict,              protocol=protocol) -        assert result4 is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result4 is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result4)      # Verifying BGP set attributes -    dut = 'r3' +    dut = "r3"      routes = {            "ipv4": ["10.0.20.1/32", "10.0.20.2/32"],            "ipv6": ["1::1/128", "1::2/128"] @@ -405,21 +406,21 @@ def test_rmap_match_prefix_list_permit_in_and_outbound_prefixes_p0():          rmap_name = "rmap_match_pf_1_{}".format(addr_type)          result4 = verify_bgp_attributes(tgen, addr_type, dut, routes[              addr_type],rmap_name, input_dict_3) -        assert result4 is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result4 is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result4)      # Verifying RIB routes -    dut = 'r4' -    protocol = 'bgp' +    dut = "r4" +    protocol = "bgp"      # dual stack changes      for addr_type in ADDR_TYPES:          result4 = verify_rib(tgen, addr_type, dut, input_dict,              protocol=protocol) -        assert result4 is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result4 is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result4)      # Verifying BGP set attributes -    dut = 'r4' +    dut = "r4"      routes = {            "ipv4": ["10.0.20.1/32", "10.0.20.2/32"],            "ipv6": ["1::1/128", "1::2/128"] @@ -429,7 +430,7 @@ def test_rmap_match_prefix_list_permit_in_and_outbound_prefixes_p0():          rmap_name = "rmap_match_pf_2_{}".format(addr_type)          result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type],                                     rmap_name, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      write_test_footer(tc_name) @@ -448,7 +449,7 @@ def test_modify_set_match_clauses_in_rmap_p0():      global bgp_convergence      if bgp_convergence is not True: -        pytest.skip('skipped because of BGP Convergence failure') +        pytest.skip("skipped because of BGP Convergence failure")      # test case name      tc_name = inspect.stack()[0][3] @@ -458,37 +459,37 @@ def test_modify_set_match_clauses_in_rmap_p0():      # Create ip prefix list      input_dict_2 = { -        'r3': { -            'prefix_lists': { -                'ipv4': { -                    'pf_list_1_ipv4': [{ -                        'seqid': 10, -                        'network': 'any', -                        'action': 'permit', +        "r3": { +            "prefix_lists": { +                "ipv4": { +                    "pf_list_1_ipv4": [{ +                        "seqid": 10, +                        "network": "any", +                        "action": "permit",                      }], -                    'pf_list_2_ipv4': [{ -                        'seqid': 10, -                        'network': 'any', -                        'action': 'permit' +                    "pf_list_2_ipv4": [{ +                        "seqid": 10, +                        "network": "any", +                        "action": "permit"                      }]                  }, -                'ipv6': { -                    'pf_list_1_ipv6': [{ -                        'seqid': 10, -                        'network': 'any', -                        'action': 'permit', +                "ipv6": { +                    "pf_list_1_ipv6": [{ +                        "seqid": 10, +                        "network": "any", +                        "action": "permit",                      }], -                    'pf_list_2_ipv6': [{ -                        'seqid': 10, -                        'network': 'any', -                        'action': 'permit' +                    "pf_list_2_ipv6": [{ +                        "seqid": 10, +                        "network": "any", +                        "action": "permit"                      }]                  }              }          }          }      result = create_prefix_lists(tgen, input_dict_2) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Create route map @@ -498,7 +499,7 @@ def test_modify_set_match_clauses_in_rmap_p0():              "route_maps": {                  "rmap_match_pf_1_{}".format(addr_type): [{                      "action": "permit", -                    'seq_id': '5', +                    "seq_id": "5",                      "match": {                          addr_type: {                              "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -510,7 +511,7 @@ def test_modify_set_match_clauses_in_rmap_p0():                  }],                  "rmap_match_pf_2_{}".format(addr_type): [{                      "action": "permit", -                    'seq_id': '5', +                    "seq_id": "5",                      "match": {                          addr_type: {                              "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -524,12 +525,12 @@ def test_modify_set_match_clauses_in_rmap_p0():          }          }          result = create_route_maps(tgen, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Configure neighbor for route map      input_dict_4 = { -       'r3': { +       "r3": {             "bgp": {                 "address_family": {                     "ipv4": { @@ -541,7 +542,7 @@ def test_modify_set_match_clauses_in_rmap_p0():                                             "route_maps": [{                                                     "name":                                                     "rmap_match_pf_1_ipv4", -                                                   "direction": 'in' +                                                   "direction": "in"                                             }]                                         }                                     } @@ -552,7 +553,7 @@ def test_modify_set_match_clauses_in_rmap_p0():                                             "route_maps": [{                                                     "name":                                                     "rmap_match_pf_2_ipv4", -                                                   "direction": 'out' +                                                   "direction": "out"                                             }]                                         }                                     } @@ -569,7 +570,7 @@ def test_modify_set_match_clauses_in_rmap_p0():                                             "route_maps": [{                                                     "name":                                                     "rmap_match_pf_1_ipv6", -                                                   "direction": 'in' +                                                   "direction": "in"                                             }]                                         }                                     } @@ -580,7 +581,7 @@ def test_modify_set_match_clauses_in_rmap_p0():                                             "route_maps": [{                                                     "name":                                                     "rmap_match_pf_2_ipv6", -                                                   "direction": 'out' +                                                   "direction": "out"                                             }]                                         }                                     } @@ -593,21 +594,21 @@ def test_modify_set_match_clauses_in_rmap_p0():         }     }      result = create_router_bgp(tgen, topo, input_dict_4) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Verifying RIB routes -    dut = 'r3' -    protocol = 'bgp' +    dut = "r3" +    protocol = "bgp"      input_dict = topo["routers"]      for addr_type in ADDR_TYPES:          result = verify_rib(tgen, addr_type, dut, input_dict,              protocol=protocol) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Verifying BGP set attributes -    dut = 'r3' +    dut = "r3"      routes = {            "ipv4": ["10.0.20.1/32", "10.0.20.2/32"],            "ipv6": ["1::1/128", "1::2/128"] @@ -617,21 +618,21 @@ def test_modify_set_match_clauses_in_rmap_p0():          rmap_name = "rmap_match_pf_1_{}".format(addr_type)          result4 = verify_bgp_attributes(tgen, addr_type, dut, routes[              addr_type],rmap_name, input_dict_3) -        assert result4 is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result4 is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result4)      # Verifying RIB routes -    dut = 'r4' -    protocol = 'bgp' +    dut = "r4" +    protocol = "bgp"      # dual stack changes      for addr_type in ADDR_TYPES:          result4 = verify_rib(tgen, addr_type, dut, input_dict,              protocol=protocol) -        assert result4 is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result4 is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result4)      # Verifying BGP set attributes -    dut = 'r4' +    dut = "r4"      routes = {            "ipv4": ["10.0.20.1/32", "10.0.20.2/32"],            "ipv6": ["1::1/128", "1::2/128"] @@ -640,7 +641,7 @@ def test_modify_set_match_clauses_in_rmap_p0():          rmap_name = "rmap_match_pf_2_{}".format(addr_type)          result = verify_bgp_attributes(tgen, addr_type, dut, routes[              addr_type],rmap_name, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Modify set/match clause of in-used route map @@ -650,7 +651,7 @@ def test_modify_set_match_clauses_in_rmap_p0():          "route_maps": {              "rmap_match_pf_1_{}".format(addr_type): [{                  "action": "permit", -                'seq_id': '5', +                "seq_id": "5",                  "match": {                      addr_type: {                          "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -662,7 +663,7 @@ def test_modify_set_match_clauses_in_rmap_p0():              }],              "rmap_match_pf_2_{}".format(addr_type): [{                  "action": "permit", -                'seq_id': '5', +                "seq_id": "5",                  "match": {                      addr_type: {                          "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -676,20 +677,20 @@ def test_modify_set_match_clauses_in_rmap_p0():          }          }          result = create_route_maps(tgen, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Verifying RIB routes -    dut = 'r3' -    protocol = 'bgp' +    dut = "r3" +    protocol = "bgp"      for addr_type in ADDR_TYPES:          result = verify_rib(tgen, addr_type, dut, input_dict,              protocol=protocol) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Verifying BGP set attributes -    dut = 'r3' +    dut = "r3"      routes = {            "ipv4": ["10.0.20.1/32", "10.0.20.2/32"],            "ipv6": ["1::1/128", "1::2/128"] @@ -698,20 +699,20 @@ def test_modify_set_match_clauses_in_rmap_p0():          rmap_name = "rmap_match_pf_1_{}".format(addr_type)          result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type],                                     rmap_name, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Verifying RIB routes -    dut = 'r4' -    protocol = 'bgp' +    dut = "r4" +    protocol = "bgp"      for addr_type in ADDR_TYPES:          result = verify_rib(tgen, addr_type, dut, input_dict,              protocol=protocol) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Verifying BGP set attributes -    dut = 'r4' +    dut = "r4"      routes = {            "ipv4": ["10.0.20.1/32", "10.0.20.2/32"],            "ipv6": ["1::1/128", "1::2/128"] @@ -720,7 +721,7 @@ def test_modify_set_match_clauses_in_rmap_p0():          rmap_name = "rmap_match_pf_2_{}".format(addr_type)          result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type],                                     rmap_name, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      write_test_footer(tc_name) @@ -739,7 +740,7 @@ def test_delete_route_maps_p1():      global bgp_convergence      if bgp_convergence is not True: -        pytest.skip('skipped because of BGP Convergence failure') +        pytest.skip("skipped because of BGP Convergence failure")      # test case name      tc_name = inspect.stack()[0][3] @@ -763,22 +764,22 @@ def test_delete_route_maps_p1():          }          }          result = create_route_maps(tgen, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Delete route maps      for addr_type in ADDR_TYPES:          input_dict = { -        'r3': { -            'route_maps': ['rmap_match_tag_1_{}'.format(addr_type)] +        "r3": { +            "route_maps": ["rmap_match_tag_1_{}".format(addr_type)]          }          }          result = delete_route_maps(tgen, input_dict) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      result = verify_route_maps(tgen, input_dict) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      write_test_footer(tc_name) @@ -797,7 +798,7 @@ def test_modify_prefix_list_referenced_by_rmap_p0():      global bgp_convergence      if bgp_convergence is not True: -        pytest.skip('skipped because of BGP Convergence failure') +        pytest.skip("skipped because of BGP Convergence failure")      # test case name      tc_name = inspect.stack()[0][3] @@ -806,27 +807,27 @@ def test_modify_prefix_list_referenced_by_rmap_p0():      # Create ip prefix list      input_dict_2 = { -        'r3': { -            'prefix_lists': { -                'ipv4': { -                    'pf_list_1_ipv4': [{ -                        'seqid': 10, -                        'network': 'any', -                        'action': 'permit', +        "r3": { +            "prefix_lists": { +                "ipv4": { +                    "pf_list_1_ipv4": [{ +                        "seqid": 10, +                        "network": "any", +                        "action": "permit",                      }]                  }, -                'ipv6': { -                    'pf_list_1_ipv6': [{ -                        'seqid': 100, -                        'network': 'any', -                        'action': 'permit', +                "ipv6": { +                    "pf_list_1_ipv6": [{ +                        "seqid": 100, +                        "network": "any", +                        "action": "permit",                      }]                  }              }          }          }      result = create_prefix_lists(tgen, input_dict_2) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Create route map @@ -836,7 +837,7 @@ def test_modify_prefix_list_referenced_by_rmap_p0():              "route_maps": {                  "rmap_match_pf_1_{}".format(addr_type): [{                      "action": "permit", -                    'seq_id': '5', +                    "seq_id": "5",                      "match": {                          addr_type: {                              "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -849,7 +850,7 @@ def test_modify_prefix_list_referenced_by_rmap_p0():                  }],                  "rmap_match_pf_2_{}".format(addr_type): [{                      "action": "permit", -                    'seq_id': '5', +                    "seq_id": "5",                      "match": {                          addr_type: {                              "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -863,12 +864,12 @@ def test_modify_prefix_list_referenced_by_rmap_p0():          }          }          result = create_route_maps(tgen, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Configure neighbor for route map      input_dict_4 = { -       'r3': { +       "r3": {             "bgp": {                 "address_family": {                     "ipv4": { @@ -880,7 +881,7 @@ def test_modify_prefix_list_referenced_by_rmap_p0():                                             "route_maps": [{                                                     "name":                                                     "rmap_match_pf_1_ipv4", -                                                   "direction": 'in' +                                                   "direction": "in"                                             }]                                         }                                     } @@ -891,7 +892,7 @@ def test_modify_prefix_list_referenced_by_rmap_p0():                                             "route_maps": [{                                                     "name":                                                     "rmap_match_pf_2_ipv4", -                                                   "direction": 'out' +                                                   "direction": "out"                                             }]                                         }                                     } @@ -908,7 +909,7 @@ def test_modify_prefix_list_referenced_by_rmap_p0():                                             "route_maps": [{                                                     "name":                                                     "rmap_match_pf_1_ipv6", -                                                   "direction": 'in' +                                                   "direction": "in"                                             }]                                         }                                     } @@ -919,7 +920,7 @@ def test_modify_prefix_list_referenced_by_rmap_p0():                                             "route_maps": [{                                                     "name":                                                     "rmap_match_pf_2_ipv6", -                                                   "direction": 'out' +                                                   "direction": "out"                                             }]                                         }                                     } @@ -933,21 +934,21 @@ def test_modify_prefix_list_referenced_by_rmap_p0():     }      result = create_router_bgp(tgen, topo, input_dict_4) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Verifying RIB routes -    dut = 'r3' -    protocol = 'bgp' +    dut = "r3" +    protocol = "bgp"      input_dict = topo["routers"]      for addr_type in ADDR_TYPES:          result = verify_rib(tgen, addr_type, dut, input_dict,              protocol=protocol) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Verifying BGP set attributes -    dut = 'r3' +    dut = "r3"      routes = {            "ipv4": ["10.0.20.1/32", "10.0.20.2/32"],            "ipv6": ["1::1/128", "1::2/128"] @@ -956,20 +957,20 @@ def test_modify_prefix_list_referenced_by_rmap_p0():          rmap_name = "rmap_match_pf_1_{}".format(addr_type)          result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type],                                     rmap_name, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Verifying RIB routes -    dut = 'r4' -    protocol = 'bgp' +    dut = "r4" +    protocol = "bgp"      for addr_type in ADDR_TYPES:          result = verify_rib(tgen, addr_type, dut, input_dict,              protocol=protocol) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Verifying BGP set attributes -    dut = 'r4' +    dut = "r4"      routes = {            "ipv4": ["10.0.20.1/32", "10.0.20.2/32"],            "ipv6": ["1::1/128", "1::2/128"] @@ -979,55 +980,55 @@ def test_modify_prefix_list_referenced_by_rmap_p0():          rmap_name = "rmap_match_pf_2_{}".format(addr_type)          result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type],                                     rmap_name, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Modify ip prefix list      input_dict_2 = { -        'r3': { -            'prefix_lists': { -                'ipv4': { -                'pf_list_1_ipv4': [{ -                    'seqid': 10, -                    'network': 'any', -                    'action': 'deny' +        "r3": { +            "prefix_lists": { +                "ipv4": { +                "pf_list_1_ipv4": [{ +                    "seqid": 10, +                    "network": "any", +                    "action": "deny"                  }]              }, -            'ipv6': { -                'pf_list_1_ipv6': [{ -                    'seqid': 100, -                    'network': 'any', -                    'action': 'deny' +            "ipv6": { +                "pf_list_1_ipv6": [{ +                    "seqid": 100, +                    "network": "any", +                    "action": "deny"                  }]              }              }          }      }      result = create_prefix_lists(tgen, input_dict_2) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      sleep(5)      # Verifying RIB routes -    dut = 'r3' -    protocol = 'bgp' +    dut = "r3" +    protocol = "bgp"      for addr_type in ADDR_TYPES:          result = verify_rib(tgen, addr_type, dut, input_dict, -                protocol=protocol) -        assert result is not True, 'Testcase {} : Failed \n' -        'Expected behaviour: routes are not present \n ' -        'Error: {}'.format( +                protocol=protocol, expected=False) +        assert result is not True, "Testcase {} : Failed \n" +        "routes are not present \n Error: {}".format(              tc_name, result) +        logger.info("Expected behaviour: {}".format(result))      # Verifying RIB routes -    dut = 'r4' -    protocol = 'bgp' +    dut = "r4" +    protocol = "bgp"      for addr_type in ADDR_TYPES:          result = verify_rib(tgen, addr_type, dut, input_dict, -                protocol=protocol) -        assert result is not True, 'Testcase {} : Failed \n' -        'Expected behaviour: routes are not present \n ' -        'Error: {}'.format( +                            protocol=protocol, expected=False) +        assert result is not True, "Testcase {} : Failed \n" +        "Expected behaviour: routes are not present \n " +        "Error: {}".format(              tc_name, result)      write_test_footer(tc_name) @@ -1038,7 +1039,7 @@ def test_modify_prefix_list_referenced_by_rmap_p0():  def test_remove_prefix_list_referenced_by_rmap_p0():      """ -    TC_50_1: +    TC_50_2:      Remove prefix-list referencec by route-map match cluase      and verifying it reflecting as intended      """ @@ -1046,7 +1047,7 @@ def test_remove_prefix_list_referenced_by_rmap_p0():      global bgp_convergence      if bgp_convergence is not True: -        pytest.skip('skipped because of BGP Convergence failure') +        pytest.skip("skipped because of BGP Convergence failure")      # test case name      tc_name = inspect.stack()[0][3] @@ -1055,27 +1056,27 @@ def test_remove_prefix_list_referenced_by_rmap_p0():      # Create ip prefix list      input_dict_2 = { -        'r3': { -            'prefix_lists': { -                'ipv4': { -                'pf_list_1_ipv4': [{ -                    'seqid': 10, -                    'network': 'any', -                    'action': 'permit' +        "r3": { +            "prefix_lists": { +                "ipv4": { +                "pf_list_1_ipv4": [{ +                    "seqid": 10, +                    "network": "any", +                    "action": "permit"                  }]              }, -                'ipv6': { -                'pf_list_1_ipv6': [{ -                    'seqid': 100, -                    'network': 'any', -                    'action': 'permit' +                "ipv6": { +                "pf_list_1_ipv6": [{ +                    "seqid": 100, +                    "network": "any", +                    "action": "permit"                  }]              }          }          }      }      result = create_prefix_lists(tgen, input_dict_2) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Create route map @@ -1085,7 +1086,7 @@ def test_remove_prefix_list_referenced_by_rmap_p0():              "route_maps": {                  "rmap_match_pf_1_{}".format(addr_type): [{                      "action": "permit", -                    'seq_id': '5', +                    "seq_id": "5",                      "match": {                          addr_type: {                              "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -1097,7 +1098,7 @@ def test_remove_prefix_list_referenced_by_rmap_p0():                  }],                  "rmap_match_pf_2_{}".format(addr_type): [{                      "action": "permit", -                    'seq_id': '5', +                    "seq_id": "5",                      "match": {                          addr_type: {                          "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -1111,13 +1112,13 @@ def test_remove_prefix_list_referenced_by_rmap_p0():          }          }          result = create_route_maps(tgen, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Configure neighbor for route map      for addr_type in ADDR_TYPES:          input_dict_4 = { -       'r3': { +       "r3": {               "bgp": {                   "address_family": {                       "ipv4": { @@ -1129,7 +1130,7 @@ def test_remove_prefix_list_referenced_by_rmap_p0():                                               "route_maps": [{                                                       "name":                                                       "rmap_match_pf_1_ipv4", -                                                     "direction": 'in' +                                                     "direction": "in"                                               }]                                           }                                       } @@ -1140,7 +1141,7 @@ def test_remove_prefix_list_referenced_by_rmap_p0():                                               "route_maps": [{                                                       "name":                                                       "rmap_match_pf_2_ipv4", -                                                     "direction": 'out' +                                                     "direction": "out"                                               }]                                           }                                       } @@ -1157,7 +1158,7 @@ def test_remove_prefix_list_referenced_by_rmap_p0():                                               "route_maps": [{                                                       "name":                                                       "rmap_match_pf_1_ipv6", -                                                     "direction": 'in' +                                                     "direction": "in"                                               }]                                           }                                       } @@ -1168,7 +1169,7 @@ def test_remove_prefix_list_referenced_by_rmap_p0():                                               "route_maps": [{                                                       "name":                                                       "rmap_match_pf_2_ipv6", -                                                     "direction": 'out' +                                                     "direction": "out"                                               }]                                           }                                       } @@ -1181,21 +1182,21 @@ def test_remove_prefix_list_referenced_by_rmap_p0():           }       }          result = create_router_bgp(tgen, topo, input_dict_4) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Verifying RIB routes -    dut = 'r3' -    protocol = 'bgp' +    dut = "r3" +    protocol = "bgp"      input_dict = topo["routers"]      for addr_type in ADDR_TYPES:          result = verify_rib(tgen, addr_type, dut, input_dict,              protocol=protocol) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Verifying BGP set attributes -    dut = 'r3' +    dut = "r3"      routes = {            "ipv4": ["10.0.20.1/32", "10.0.20.2/32"],            "ipv6": ["1::1/128", "1::2/128"] @@ -1204,20 +1205,20 @@ def test_remove_prefix_list_referenced_by_rmap_p0():          rmap_name = "rmap_match_pf_1_{}".format(addr_type)          result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type],                                     rmap_name, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Verifying RIB routes -    dut = 'r4' -    protocol = 'bgp' +    dut = "r4" +    protocol = "bgp"      for addr_type in ADDR_TYPES:          result = verify_rib(tgen, addr_type, dut, input_dict,              protocol=protocol) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Verifying BGP set attributes -    dut = 'r4' +    dut = "r4"      routes = {            "ipv4": ["10.0.20.1/32", "10.0.20.2/32"],            "ipv6": ["1::1/128", "1::2/128"] @@ -1226,67 +1227,67 @@ def test_remove_prefix_list_referenced_by_rmap_p0():          rmap_name = "rmap_match_pf_2_{}".format(addr_type)          result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type],                          rmap_name, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Remove/Delete prefix list      input_dict_3 = { -        'r3': { -            'prefix_lists': { -                'ipv4': { -                'pf_list_1_ipv4': [{ -                    'seqid': 10, -                    'network': 'any', -                    'action': 'permit', -                    'delete': True +        "r3": { +            "prefix_lists": { +                "ipv4": { +                "pf_list_1_ipv4": [{ +                    "seqid": 10, +                    "network": "any", +                    "action": "permit", +                    "delete": True                  }]              }, -                'ipv6': { -                'pf_list_1_ipv6': [{ -                    'seqid': 100, -                    'network': 'any', -                    'action': 'permit', -                    'delete': True +                "ipv6": { +                "pf_list_1_ipv6": [{ +                    "seqid": 100, +                    "network": "any", +                    "action": "permit", +                    "delete": True                  }]              }          }          }      }      result = create_prefix_lists(tgen, input_dict_3) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      result = verify_prefix_lists(tgen, input_dict_3) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Api call to clear bgp, so config changes would be reflected -    dut = 'r3' +    dut = "r3"      result = clear_bgp_and_verify(tgen, topo, dut) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Verifying RIB routes -    dut = 'r3' -    protocol = 'bgp' +    dut = "r3" +    protocol = "bgp"      for addr_type in ADDR_TYPES:          result = verify_rib(tgen, addr_type, dut, input_dict, -            protocol=protocol) -        assert result is not True, 'Testcase {} : Failed \n' -        'Expected behaviour: routes are not present \n ' -        'Error: {}'.format( +            protocol=protocol, expected=False) +        assert result is not True, "Testcase {} : Failed \n" +        "routes are not present \n Error: {}".format(              tc_name, result) +        logger.info("Expected behaviour: {}".format(result))      # Verifying RIB routes -    dut = 'r4' -    protocol = 'bgp' +    dut = "r4" +    protocol = "bgp"      for addr_type in ADDR_TYPES:          result = verify_rib(tgen, addr_type, dut, input_dict, -            protocol=protocol) -        assert result is not True, 'Testcase {} : Failed \n' -        'Expected behaviour: routes are not present \n ' -        'Error: {}'.format( -            tc_name, result) +            protocol=protocol, expected=False) +        assert result is not True, "Testcase {} : Failed \n" +        "routes are not present \n Error: {}".\ +            format(tc_name, result) +        logger.info("Expected behaviour: {}".format(result))      write_test_footer(tc_name) @@ -1304,7 +1305,7 @@ def test_add_and_remove_community_list_referenced_by_rmap_p0():      global bgp_convergence      if bgp_convergence is not True: -        pytest.skip('skipped because of BGP Convergence failure') +        pytest.skip("skipped because of BGP Convergence failure")      # test case name      tc_name = inspect.stack()[0][3] @@ -1329,12 +1330,12 @@ def test_add_and_remove_community_list_referenced_by_rmap_p0():          }          }          result = create_route_maps(tgen, input_dict_5) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Configure neighbor for route map      input_dict_6 = { -       'r1': { +       "r1": {             "bgp": {                 "address_family": {                     "ipv4": { @@ -1345,7 +1346,7 @@ def test_add_and_remove_community_list_referenced_by_rmap_p0():                                         "r1": {                                             "route_maps": [{                                                     "name": "rm_r1_out_ipv4", -                                                   "direction": 'out' +                                                   "direction": "out"                                             }]                                         }                                     } @@ -1361,7 +1362,7 @@ def test_add_and_remove_community_list_referenced_by_rmap_p0():                                         "r1": {                                             "route_maps": [{                                                     "name": "rm_r1_out_ipv6", -                                                   "direction": 'out' +                                                   "direction": "out"                                             }]                                         }                                     } @@ -1375,7 +1376,7 @@ def test_add_and_remove_community_list_referenced_by_rmap_p0():     }      result = create_router_bgp(tgen, topo, input_dict_6) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      for addr_type in ADDR_TYPES: @@ -1394,9 +1395,14 @@ def test_add_and_remove_community_list_referenced_by_rmap_p0():                  }              }              result = create_bgp_community_lists(tgen, input_dict_1) -            assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +            assert result is True, "Testcase {} : Failed \n Error: {}".format(                  tc_name, result) +    # Verify BGP large community is created +    result = verify_create_community_list(tgen, input_dict_1) +    assert result is True, "Testcase {} : Failed \n Error: {}".format( +        tc_name, result) +      for addr_type in ADDR_TYPES:      # Create route map          input_dict_2 = { @@ -1415,12 +1421,12 @@ def test_add_and_remove_community_list_referenced_by_rmap_p0():          }          }          result = create_route_maps(tgen, input_dict_2) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Configure neighbor for route map      input_dict_3 = { -       'r3': { +       "r3": {             "bgp": {                 "address_family": {                     "ipv4": { @@ -1431,7 +1437,7 @@ def test_add_and_remove_community_list_referenced_by_rmap_p0():                                         "r3": {                                             "route_maps": [{                                                     "name": "rm_r3_in_ipv4", -                                                   "direction": 'in' +                                                   "direction": "in"                                             }]                                         }                                     } @@ -1447,7 +1453,7 @@ def test_add_and_remove_community_list_referenced_by_rmap_p0():                                         "r3": {                                             "route_maps": [{                                                     "name": "rm_r3_in_ipv6", -                                                   "direction": 'in' +                                                   "direction": "in"                                             }]                                         }                                     } @@ -1461,33 +1467,33 @@ def test_add_and_remove_community_list_referenced_by_rmap_p0():     }      result = create_router_bgp(tgen, topo, input_dict_3) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      sleep(5)      # Verifying RIB routes -    dut = 'r3' -    protocol = 'bgp' +    dut = "r3" +    protocol = "bgp"      input_dict = topo["routers"]      for addr_type in ADDR_TYPES:          result = verify_rib(tgen, addr_type, dut, input_dict,              protocol=protocol) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Verify large-community-list -    dut = 'r3' +    dut = "r3"      networks = {            "ipv4": ["10.0.20.1/32", "10.0.20.2/32"],            "ipv6": ["1::1/128", "1::2/128"]      }      input_dict_4 = { -        'largeCommunity': '1:1:1 1:2:3 2:1:1 2:2:2' +        "largeCommunity": "1:1:1 1:2:3 2:1:1 2:2:2"      }      for addr_type in ADDR_TYPES:          result = verify_bgp_community(tgen, addr_type, dut, networks[              addr_type],input_dict_4) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      write_test_footer(tc_name) @@ -1498,14 +1504,14 @@ def test_add_and_remove_community_list_referenced_by_rmap_p0():  def test_multiple_match_statement_in_route_map_logical_ORed_p0():      """      TC_45: -    Test multiple match statements as part of a route-map's single +    Test multiple match statements as part of a route-map"s single      sequence number. (Logical OR-ed of multiple match statements)      """      tgen = get_topogen()      global bgp_convergence      if bgp_convergence is not True: -        pytest.skip('skipped because of BGP Convergence failure') +        pytest.skip("skipped because of BGP Convergence failure")      # test case name      tc_name = inspect.stack()[0][3] @@ -1514,20 +1520,20 @@ def test_multiple_match_statement_in_route_map_logical_ORed_p0():      # Api call to advertise networks      input_dict_nw1 = { -            'r1': { +            "r1": {                  "bgp": {                      "address_family": {                          "ipv4": {                              "unicast": {                                  "advertise_networks": [ -                                    {"network": '10.0.30.1/32'} +                                    {"network": "10.0.30.1/32"}                                  ]                              }                          },                          "ipv6": {                              "unicast": {                                  "advertise_networks": [ -                                    {"network": '1::1/128'} +                                    {"network": "1::1/128"}                                  ]                              }                          } @@ -1537,25 +1543,25 @@ def test_multiple_match_statement_in_route_map_logical_ORed_p0():          }      result = create_router_bgp(tgen, topo, input_dict_nw1) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Api call to advertise networks      input_dict_nw2 = { -            'r1': { +            "r1": {                  "bgp": {                      "address_family": {                          "ipv4": {                              "unicast": {                                  "advertise_networks": [ -                                    {"network": '20.0.30.1/32'} +                                    {"network": "20.0.30.1/32"}                                  ]                              }                          },                          "ipv6": {                              "unicast": {                                  "advertise_networks": [ -                                    {"network": '2::1/128'} +                                    {"network": "2::1/128"}                                  ]                              }                          } @@ -1565,57 +1571,57 @@ def test_multiple_match_statement_in_route_map_logical_ORed_p0():          }      result = create_router_bgp(tgen, topo, input_dict_nw2) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Create ip prefix list      input_dict_2 = { -        'r3': { -            'prefix_lists': { -                'ipv4': { -                'pf_list_1_ipv4': [{ -                    'seqid': 10, -                    'network': 'any', -                    'action': 'permit' +        "r3": { +            "prefix_lists": { +                "ipv4": { +                "pf_list_1_ipv4": [{ +                    "seqid": 10, +                    "network": "any", +                    "action": "permit"                  }]              }, -                'ipv6': { -                'pf_list_1_ipv6': [{ -                    'seqid': 100, -                    'network': 'any', -                    'action': 'permit' +                "ipv6": { +                "pf_list_1_ipv6": [{ +                    "seqid": 100, +                    "network": "any", +                    "action": "permit"                  }]              }              }          }      }      result = create_prefix_lists(tgen, input_dict_2) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Create ip prefix list      input_dict_2 = { -        'r3': { -            'prefix_lists': { -                'ipv4': { -                'pf_list_2_ipv4': [{ -                    'seqid': 10, -                    'network': 'any', -                    'action': 'permit' +        "r3": { +            "prefix_lists": { +                "ipv4": { +                "pf_list_2_ipv4": [{ +                    "seqid": 10, +                    "network": "any", +                    "action": "permit"                  }]              }, -                'ipv6': { -                'pf_list_2_ipv6': [{ -                    'seqid': 100, -                    'network': 'any', -                    'action': 'permit' +                "ipv6": { +                "pf_list_2_ipv6": [{ +                    "seqid": 100, +                    "network": "any", +                    "action": "permit"                  }]              }              }          }      }      result = create_prefix_lists(tgen, input_dict_2) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      input_dict_3_addr_type ={} @@ -1626,7 +1632,7 @@ def test_multiple_match_statement_in_route_map_logical_ORed_p0():              "route_maps": {                  "rmap_match_pf_1_{}".format(addr_type): [{                      "action": "permit", -                    'seq_id': '5', +                    "seq_id": "5",                      "match": {                          addr_type: {                          "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -1641,7 +1647,7 @@ def test_multiple_match_statement_in_route_map_logical_ORed_p0():          }          input_dict_3_addr_type[addr_type] = input_dict_3          result = create_route_maps(tgen, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Create route map @@ -1651,7 +1657,7 @@ def test_multiple_match_statement_in_route_map_logical_ORed_p0():              "route_maps": {                  "rmap_match_pf_1_{}".format(addr_type): [{                      "action": "permit", -                    'seq_id': '5', +                    "seq_id": "5",                      "match": {                          addr_type: {                          "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -1666,12 +1672,12 @@ def test_multiple_match_statement_in_route_map_logical_ORed_p0():          }          input_dict_3_addr_type[addr_type] = input_dict_3          result = create_route_maps(tgen, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Configure neighbor for route map      input_dict_6 = { -       'r3': { +       "r3": {             "bgp": {                 "address_family": {                     "ipv4": { @@ -1683,7 +1689,7 @@ def test_multiple_match_statement_in_route_map_logical_ORed_p0():                                             "route_maps": [{                                                     "name":                                                     "rmap_match_pf_1_ipv4", -                                                   "direction": 'in' +                                                   "direction": "in"                                             }]                                         }                                     } @@ -1700,7 +1706,7 @@ def test_multiple_match_statement_in_route_map_logical_ORed_p0():                                             "route_maps": [{                                                     "name":                                                     "rmap_match_pf_1_ipv6", -                                                   "direction": 'in' +                                                   "direction": "in"                                             }]                                         }                                     } @@ -1714,21 +1720,21 @@ def test_multiple_match_statement_in_route_map_logical_ORed_p0():     }      result = create_router_bgp(tgen, topo, input_dict_6) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Verifying RIB routes -    dut = 'r3' -    protocol = 'bgp' +    dut = "r3" +    protocol = "bgp"      input_dict = topo["routers"]      for addr_type in ADDR_TYPES:          result = verify_rib(tgen, addr_type, dut, input_dict,              protocol=protocol) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Verifying BGP set attributes -    dut = 'r3' +    dut = "r3"      routes = {            "ipv4": ["10.0.30.1/32"],            "ipv6": ["1::1/128"] @@ -1737,7 +1743,7 @@ def test_multiple_match_statement_in_route_map_logical_ORed_p0():          rmap_name = "rmap_match_pf_1_{}".format(addr_type)          result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type],                                  rmap_name, input_dict_3_addr_type[addr_type]) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Verifying BGP set attributes @@ -1748,7 +1754,7 @@ def test_multiple_match_statement_in_route_map_logical_ORed_p0():      for addr_type in ADDR_TYPES:          result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type],                                     rmap_name, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      write_test_footer(tc_name) @@ -1757,17 +1763,17 @@ def test_multiple_match_statement_in_route_map_logical_ORed_p0():      # tgen.mininet_cli() -def test_multiple_match_statement_in_route_map_logical_ANDed(): +def test_multiple_match_statement_in_route_map_logical_ANDed_p1():      """      TC_44: -    Test multiple match statements as part of a route-map's single +    Test multiple match statements as part of a route-map"s single      sequence number. (Logical AND of multiple match statements)      """      tgen = get_topogen()      global bgp_convergence      if bgp_convergence is not True: -        pytest.skip('skipped because of BGP Convergence failure') +        pytest.skip("skipped because of BGP Convergence failure")      # test case name      tc_name = inspect.stack()[0][3] @@ -1790,13 +1796,13 @@ def test_multiple_match_statement_in_route_map_logical_ANDed():              }          }          result = create_route_maps(tgen, input_dict_5) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Configure neighbor for route map      for addr_type in ADDR_TYPES:          input_dict_6 = { -        'r1': { +        "r1": {             "bgp": {                 "address_family": {                  addr_type: { @@ -1808,7 +1814,7 @@ def test_multiple_match_statement_in_route_map_logical_ANDed():                                             "route_maps": [{                                                     "name":                                              "rm_r1_out_{}".format(addr_type), -                                                   "direction": 'out' +                                                   "direction": "out"                                             }]                                         }                                     } @@ -1821,25 +1827,25 @@ def test_multiple_match_statement_in_route_map_logical_ANDed():          }          }          result = create_router_bgp(tgen, topo, input_dict_6) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Create ip prefix list      input_dict_2 = { -        'r3': { -            'prefix_lists': { -                'ipv4': { -                'pf_list_1_ipv4': [{ -                    'seqid': 10, -                    'network': 'any', -                    'action': 'permit' +        "r3": { +            "prefix_lists": { +                "ipv4": { +                "pf_list_1_ipv4": [{ +                    "seqid": 10, +                    "network": "any", +                    "action": "permit"                  }]                  }, -                'ipv6': { -                'pf_list_1_ipv6': [{ -                    'seqid': 100, -                    'network': 'any', -                    'action': 'permit' +                "ipv6": { +                "pf_list_1_ipv6": [{ +                    "seqid": 100, +                    "network": "any", +                    "action": "permit"                  }]                  }              } @@ -1847,7 +1853,7 @@ def test_multiple_match_statement_in_route_map_logical_ANDed():      }      result = create_prefix_lists(tgen, input_dict_2) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      for addr_type in ADDR_TYPES: @@ -1866,9 +1872,14 @@ def test_multiple_match_statement_in_route_map_logical_ANDed():              }          }          result = create_bgp_community_lists(tgen, input_dict_1) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result) +    # Verify BGP large community is created +    result = verify_create_community_list(tgen, input_dict_1) +    assert result is True, "Testcase {} : Failed \n Error: {}".format( +        tc_name, result) +      # Create route map      for addr_type in ADDR_TYPES:          input_dict_3 = { @@ -1876,7 +1887,7 @@ def test_multiple_match_statement_in_route_map_logical_ANDed():                  "route_maps": {                      "rmap_match_pf_1_{}".format(addr_type): [{                          "action": "permit", -                        'seq_id': '5', +                        "seq_id": "5",                          "match": {                              addr_type: {                              "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -1890,7 +1901,7 @@ def test_multiple_match_statement_in_route_map_logical_ANDed():              }          }          result = create_route_maps(tgen, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      for addr_type in ADDR_TYPES: @@ -1900,7 +1911,7 @@ def test_multiple_match_statement_in_route_map_logical_ANDed():                  "route_maps": {                      "rmap_match_pf_1_{}".format(addr_type): [{                          "action": "permit", -                        'seq_id': '5', +                        "seq_id": "5",                          "match": {                              addr_type : {                              "large_community_list": {"id": "rmap_lcomm_"+ @@ -1915,12 +1926,12 @@ def test_multiple_match_statement_in_route_map_logical_ANDed():              }          }          result = create_route_maps(tgen, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Configure neighbor for route map      for addr_type in ADDR_TYPES:          input_dict_4 = { -       'r3': { +       "r3": {             "bgp": {                 "address_family": {                  addr_type: { @@ -1932,7 +1943,7 @@ def test_multiple_match_statement_in_route_map_logical_ANDed():                                             "route_maps": [{                                                     "name":                                          "rmap_match_pf_1_{}".format(addr_type), -                                                   "direction": 'in' +                                                   "direction": "in"                                             }]                                         }                                     } @@ -1945,20 +1956,20 @@ def test_multiple_match_statement_in_route_map_logical_ANDed():          }          }          result = create_router_bgp(tgen, topo, input_dict_4) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # sleep(10)      # Verifying RIB routes -    dut = 'r3' -    protocol = 'bgp' +    dut = "r3" +    protocol = "bgp"      input_dict = topo["routers"]      for addr_type in ADDR_TYPES:          result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Verifying BGP set attributes -    dut = 'r3' +    dut = "r3"      routes = {            "ipv4": ["10.0.20.1/32", "10.0.20.2/32"],            "ipv6": ["1::1/128", "1::2/128"] @@ -1967,7 +1978,7 @@ def test_multiple_match_statement_in_route_map_logical_ANDed():          rmap_name = "rmap_match_pf_1_{}".format(addr_type)          result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type],                                     rmap_name, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      write_test_footer(tc_name) @@ -1986,7 +1997,7 @@ def test_add_remove_rmap_to_specific_neighbor_p0():      global bgp_convergence      if bgp_convergence is not True: -        pytest.skip('skipped because of BGP Convergence failure') +        pytest.skip("skipped because of BGP Convergence failure")      # test case name      tc_name = inspect.stack()[0][3] @@ -1995,27 +2006,27 @@ def test_add_remove_rmap_to_specific_neighbor_p0():      # Create ip prefix list      input_dict_2 = { -        'r3': { -            'prefix_lists': { -            'ipv4': { -                'pf_list_1_ipv4': [{ -                    'seqid': 10, -                    'network': 'any', -                    'action': 'deny' +        "r3": { +            "prefix_lists": { +            "ipv4": { +                "pf_list_1_ipv4": [{ +                    "seqid": 10, +                    "network": "any", +                    "action": "deny"                  }]              }, -            'ipv6': { -                'pf_list_1_ipv6': [{ -                    'seqid': 100, -                    'network': 'any', -                    'action': 'deny' +            "ipv6": { +                "pf_list_1_ipv6": [{ +                    "seqid": 100, +                    "network": "any", +                    "action": "deny"                  }]              }              }          }      }      result = create_prefix_lists(tgen, input_dict_2) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Create route map @@ -2025,7 +2036,7 @@ def test_add_remove_rmap_to_specific_neighbor_p0():              "route_maps": {                  "rmap_match_pf_1_{}".format(addr_type): [{                      "action": "permit", -                    'seq_id': '5', +                    "seq_id": "5",                      "match": {                          addr_type: {                          "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -2039,12 +2050,12 @@ def test_add_remove_rmap_to_specific_neighbor_p0():          }          }          result = create_route_maps(tgen, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Configure neighbor for route map      input_dict_4 = { -        'r3': { +        "r3": {              "bgp": {                  "address_family": {                      "ipv4": { @@ -2056,7 +2067,7 @@ def test_add_remove_rmap_to_specific_neighbor_p0():                                              "route_maps": [{                                                      "name":                                                      "rmap_match_pf_1_ipv4", -                                                    "direction": 'in' +                                                    "direction": "in"                                              }]                                          }                                      } @@ -2073,7 +2084,7 @@ def test_add_remove_rmap_to_specific_neighbor_p0():                                              "route_maps": [{                                                      "name":                                                      "rmap_match_pf_1_ipv6", -                                                    "direction": 'in' +                                                    "direction": "in"                                              }]                                          }                                      } @@ -2087,24 +2098,24 @@ def test_add_remove_rmap_to_specific_neighbor_p0():      }      result = create_router_bgp(tgen, topo, input_dict_4) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(           tc_name, result)      # Verifying RIB routes -    dut = 'r3' -    protocol = 'bgp' +    dut = "r3" +    protocol = "bgp"      input_dict = topo["routers"]      for addr_type in ADDR_TYPES:          result = verify_rib(tgen, addr_type, dut, input_dict, -                            protocol=protocol) -        assert result is not True, 'Testcase {} : \n' -        'Expected Behavior: Routes are not present in RIB \n' -        ' Error: {}'.format( +                            protocol=protocol, expected=False) +        assert result is not True, "Testcase {} : Failed \n Error" +        "Routes are still present: {}".format(              tc_name, result) +        logger.info("Expected behaviour: {}".format(result))      # Remove applied rmap from neighbor      input_dict_4 = { -        'r3': { +        "r3": {              "bgp": {                  "address_family": {                      "ipv4": { @@ -2116,7 +2127,7 @@ def test_add_remove_rmap_to_specific_neighbor_p0():                                              "route_maps": [{                                                      "name":                                                      "rmap_match_pf_1_ipv4", -                                                    "direction": 'in', +                                                    "direction": "in",                                                      "delete": True                                              }]                                          } @@ -2134,7 +2145,7 @@ def test_add_remove_rmap_to_specific_neighbor_p0():                                              "route_maps": [{                                                      "name":                                                      "rmap_match_pf_1_ipv6", -                                                    "direction": 'in', +                                                    "direction": "in",                                                      "delete": True                                              }]                                          } @@ -2149,16 +2160,16 @@ def test_add_remove_rmap_to_specific_neighbor_p0():      }      result = create_router_bgp(tgen, topo, input_dict_4) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(           tc_name, result)      # Verifying RIB routes -    dut = 'r3' -    protocol = 'bgp' +    dut = "r3" +    protocol = "bgp"      input_dict = topo["routers"]      for addr_type in ADDR_TYPES:          result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(               tc_name, result)      write_test_footer(tc_name) @@ -2177,7 +2188,7 @@ def test_clear_bgp_and_flap_interface_to_verify_rmap_properties_p0():      global bgp_convergence      if bgp_convergence is not True: -        pytest.skip('skipped because of BGP Convergence failure') +        pytest.skip("skipped because of BGP Convergence failure")      # test case name      tc_name = inspect.stack()[0][3] @@ -2186,27 +2197,27 @@ def test_clear_bgp_and_flap_interface_to_verify_rmap_properties_p0():      # Create ip prefix list      input_dict_2 = { -        'r3': { -            'prefix_lists': { -                'ipv4': { -                'pf_list_1_ipv4': [{ -                    'seqid': 10, -                    'network': 'any', -                    'action': 'permit' +        "r3": { +            "prefix_lists": { +                "ipv4": { +                "pf_list_1_ipv4": [{ +                    "seqid": 10, +                    "network": "any", +                    "action": "permit"                  }]              }, -                'ipv6': { -                'pf_list_1_ipv6': [{ -                    'seqid': 100, -                    'network': 'any', -                    'action': 'permit' +                "ipv6": { +                "pf_list_1_ipv6": [{ +                    "seqid": 100, +                    "network": "any", +                    "action": "permit"                  }]              }              }          }      }      result = create_prefix_lists(tgen, input_dict_2) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Create route map @@ -2216,7 +2227,7 @@ def test_clear_bgp_and_flap_interface_to_verify_rmap_properties_p0():              "route_maps": {                  "rmap_match_pf_1_{}".format(addr_type): [{                      "action": "permit", -                    'seq_id': '5', +                    "seq_id": "5",                      "match": {                          addr_type: {                          "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -2231,12 +2242,12 @@ def test_clear_bgp_and_flap_interface_to_verify_rmap_properties_p0():          }          }          result = create_route_maps(tgen, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Configure neighbor for route map      input_dict_4 = { -        'r3': { +        "r3": {              "bgp": {                  "address_family": {                      "ipv4": { @@ -2248,7 +2259,7 @@ def test_clear_bgp_and_flap_interface_to_verify_rmap_properties_p0():                                              "route_maps": [{                                                      "name":                                                      "rmap_match_pf_1_ipv4", -                                                    "direction": 'in' +                                                    "direction": "in"                                              }]                                          }                                      } @@ -2265,7 +2276,7 @@ def test_clear_bgp_and_flap_interface_to_verify_rmap_properties_p0():                                              "route_maps": [{                                                      "name":                                                      "rmap_match_pf_1_ipv6", -                                                    "direction": 'in' +                                                    "direction": "in"                                              }]                                          }                                      } @@ -2279,20 +2290,20 @@ def test_clear_bgp_and_flap_interface_to_verify_rmap_properties_p0():      }      result = create_router_bgp(tgen, topo, input_dict_4) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(           tc_name, result)      # Verifying RIB routes -    dut = 'r3' -    protocol = 'bgp' +    dut = "r3" +    protocol = "bgp"      input_dict = topo["routers"]      for addr_type in ADDR_TYPES:          result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Verifying BGP set attributes -    dut = 'r3' +    dut = "r3"      routes = {            "ipv4": ["10.0.20.1/32", "10.0.20.2/32"],            "ipv6": ["1::1/128", "1::2/128"] @@ -2301,26 +2312,26 @@ def test_clear_bgp_and_flap_interface_to_verify_rmap_properties_p0():          rmap_name = "rmap_match_pf_1_{}".format(addr_type)          result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type],                                     rmap_name, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # clear bgp, so config changes would be reflected -    dut = 'r3' +    dut = "r3"      result = clear_bgp_and_verify(tgen, topo, dut) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Verifying RIB routes -    dut = 'r3' -    protocol = 'bgp' +    dut = "r3" +    protocol = "bgp"      input_dict = topo["routers"]      for addr_type in ADDR_TYPES:          result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Verifying BGP set attributes -    dut = 'r3' +    dut = "r3"      routes = {            "ipv4": ["10.0.20.1/32", "10.0.20.2/32"],            "ipv6": ["1::1/128", "1::2/128"] @@ -2329,7 +2340,7 @@ def test_clear_bgp_and_flap_interface_to_verify_rmap_properties_p0():          rmap_name = "rmap_match_pf_1_{}".format(addr_type)          result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type],                                         rmap_name, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Flap interface to see if route-map properties are intact @@ -2348,19 +2359,19 @@ def test_clear_bgp_and_flap_interface_to_verify_rmap_properties_p0():      # Verify BGP convergence once interface is up      result = verify_bgp_convergence(tgen, topo)      assert result is True, ( -        'setup_module :Failed \n Error:' ' {}'.format(result)) +        "setup_module :Failed \n Error:" " {}".format(result))      # Verifying RIB routes -    dut = 'r3' -    protocol = 'bgp' +    dut = "r3" +    protocol = "bgp"      input_dict = topo["routers"]      for addr_type in ADDR_TYPES:          result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Verifying BGP set attributes -    dut = 'r3' +    dut = "r3"      routes = {            "ipv4": ["10.0.20.1/32", "10.0.20.2/32"],            "ipv6": ["1::1/128", "1::2/128"] @@ -2369,7 +2380,7 @@ def test_clear_bgp_and_flap_interface_to_verify_rmap_properties_p0():          rmap_name = "rmap_match_pf_1_{}".format(addr_type)          result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type],                                     rmap_name, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      write_test_footer(tc_name) @@ -2388,7 +2399,7 @@ def test_rmap_without_match_and_set_clause_p0():      global bgp_convergence      if bgp_convergence is not True: -        pytest.skip('skipped because of BGP Convergence failure') +        pytest.skip("skipped because of BGP Convergence failure")      # test case name      tc_name = inspect.stack()[0][3] @@ -2402,22 +2413,22 @@ def test_rmap_without_match_and_set_clause_p0():              "route_maps": {                  "rmap_no_match_set_1_{}".format(addr_type): [{                      "action": "permit", -                    'seq_id': '5' +                    "seq_id": "5"                  }],                  "rmap_no_match_set_2_{}".format(addr_type): [{                      "action": "deny", -                    'seq_id': '5' +                    "seq_id": "5"                  }]              }          }          }          result = create_route_maps(tgen, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Configure neighbor for route map      input_dict_4 = { -        'r3': { +        "r3": {              "bgp": {                  "address_family": {                      "ipv4": { @@ -2429,7 +2440,7 @@ def test_rmap_without_match_and_set_clause_p0():                                              "route_maps": [{                                                      "name":                                                      "rmap_no_match_set_1_ipv4", -                                                    "direction": 'in' +                                                    "direction": "in"                                              }]                                          }                                      } @@ -2440,7 +2451,7 @@ def test_rmap_without_match_and_set_clause_p0():                                              "route_maps": [{                                                      "name":                                                      "rmap_no_match_set_2_ipv4", -                                                    "direction": 'out' +                                                    "direction": "out"                                              }]                                          }                                      } @@ -2457,7 +2468,7 @@ def test_rmap_without_match_and_set_clause_p0():                                              "route_maps": [{                                                      "name":                                                      "rmap_no_match_set_1_ipv6", -                                                    "direction": 'in' +                                                    "direction": "in"                                              }]                                          }                                      } @@ -2468,7 +2479,7 @@ def test_rmap_without_match_and_set_clause_p0():                                              "route_maps": [{                                                      "name":                                                      "rmap_no_match_set_2_ipv6", -                                                    "direction": 'out' +                                                    "direction": "out"                                              }]                                          }                                      } @@ -2482,30 +2493,30 @@ def test_rmap_without_match_and_set_clause_p0():      }      result = create_router_bgp(tgen, topo, input_dict_4) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(           tc_name, result)      # Verifying RIB routes -    dut = 'r3' -    protocol = 'bgp' +    dut = "r3" +    protocol = "bgp"      input_dict = topo["routers"]      for addr_type in ADDR_TYPES:          result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Verifying RIB routes -    dut = 'r4' -    protocol = 'bgp' +    dut = "r4" +    protocol = "bgp"      for addr_type in ADDR_TYPES: -        result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) -        assert result is not True, 'Testcase {} : Failed \n' -        'Expected behaviour: routes are not present \n ' -        'Error: {}'.format( +        result = verify_rib(tgen, addr_type, dut, input_dict, +                            protocol=protocol, expected=False) +        assert result is not True, "Testcase {} : Failed \n" +        "routes are not present \n Error: {}".format(              tc_name, result) +        logger.info("Expected behaviour: {}".format(result))      write_test_footer(tc_name) -      # Uncomment next line for debugging      # tgen.mininet_cli() @@ -2520,7 +2531,7 @@ def test_set_localpref_weight_to_ebgp_and_med_to_ibgp_peers_p0():      global bgp_convergence      if bgp_convergence is not True: -        pytest.skip('skipped because of BGP Convergence failure') +        pytest.skip("skipped because of BGP Convergence failure")      # test case name      tc_name = inspect.stack()[0][3] @@ -2529,27 +2540,27 @@ def test_set_localpref_weight_to_ebgp_and_med_to_ibgp_peers_p0():      # Create ip prefix list      input_dict_2 = { -        'r3': { -            'prefix_lists': { -                  'ipv4': { -                'pf_list_1_ipv4': [{ -                    'seqid': 10, -                    'network': 'any', -                    'action': 'permit' +        "r3": { +            "prefix_lists": { +                  "ipv4": { +                "pf_list_1_ipv4": [{ +                    "seqid": 10, +                    "network": "any", +                    "action": "permit"                  }]              }, -                  'ipv6': { -                'pf_list_1_ipv6': [{ -                    'seqid': 100, -                    'network': 'any', -                    'action': 'permit' +                  "ipv6": { +                "pf_list_1_ipv6": [{ +                    "seqid": 100, +                    "network": "any", +                    "action": "permit"                  }]              }              }          }      }      result = create_prefix_lists(tgen, input_dict_2) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Create route map @@ -2597,12 +2608,12 @@ def test_set_localpref_weight_to_ebgp_and_med_to_ibgp_peers_p0():                      }          input_dict_3_addr_type[addr_type] = input_dict_3          result = create_route_maps(tgen, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Configure neighbor for route map      input_dict_4 = { -        'r3': { +        "r3": {              "bgp": {                  "address_family": {                      "ipv4": { @@ -2614,7 +2625,7 @@ def test_set_localpref_weight_to_ebgp_and_med_to_ibgp_peers_p0():                                              "route_maps": [{                                                      "name":                                                      "rmap_match_pf_1_ipv4", -                                                    "direction": 'in' +                                                    "direction": "in"                                              }]                                          }                                      } @@ -2625,7 +2636,7 @@ def test_set_localpref_weight_to_ebgp_and_med_to_ibgp_peers_p0():                                              "route_maps": [{                                                      "name":                                                      "rmap_match_pf_2_ipv4", -                                                    "direction": 'out' +                                                    "direction": "out"                                              }]                                          }                                      } @@ -2636,7 +2647,7 @@ def test_set_localpref_weight_to_ebgp_and_med_to_ibgp_peers_p0():                                              "route_maps": [{                                                      "name":                                                      "rmap_match_pf_3_ipv4", -                                                    "direction": 'out' +                                                    "direction": "out"                                              }]                                          }                                      } @@ -2653,7 +2664,7 @@ def test_set_localpref_weight_to_ebgp_and_med_to_ibgp_peers_p0():                                              "route_maps": [{                                                      "name":                                                      "rmap_match_pf_1_ipv6", -                                                    "direction": 'in' +                                                    "direction": "in"                                              }]                                          }                                      } @@ -2664,7 +2675,7 @@ def test_set_localpref_weight_to_ebgp_and_med_to_ibgp_peers_p0():                                              "route_maps": [{                                                      "name":                                                      "rmap_match_pf_2_ipv6", -                                                    "direction": 'out' +                                                    "direction": "out"                                              }]                                          }                                      } @@ -2675,7 +2686,7 @@ def test_set_localpref_weight_to_ebgp_and_med_to_ibgp_peers_p0():                                              "route_maps": [{                                                      "name":                                                      "rmap_match_pf_3_ipv6", -                                                    "direction": 'out' +                                                    "direction": "out"                                              }]                                          }                                      } @@ -2689,21 +2700,21 @@ def test_set_localpref_weight_to_ebgp_and_med_to_ibgp_peers_p0():      }      result = create_router_bgp(tgen, topo, input_dict_4) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Verifying RIB routes -    dut = 'r3' -    protocol = 'bgp' +    dut = "r3" +    protocol = "bgp"      input_dict = topo["routers"]      for addr_type in ADDR_TYPES:          result = verify_rib(tgen, addr_type, dut, input_dict,              protocol=protocol) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Verifying BGP set attributes -    dut = 'r3' +    dut = "r3"      routes = {            "ipv4": ["10.0.20.1/32", "10.0.20.2/32"],            "ipv6": ["1::1/128", "1::2/128"] @@ -2713,20 +2724,20 @@ def test_set_localpref_weight_to_ebgp_and_med_to_ibgp_peers_p0():          rmap_name = "rmap_match_pf_1_{}".format(addr_type)          result = verify_bgp_attributes(tgen, addr_type, dut, routes[              addr_type],rmap_name, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Verifying RIB routes -    dut = 'r4' -    protocol = 'bgp' +    dut = "r4" +    protocol = "bgp"      for addr_type in ADDR_TYPES:          result = verify_rib(tgen, addr_type, dut, input_dict,              protocol=protocol) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Verifying BGP set attributes -    dut = 'r4' +    dut = "r4"      routes = {            "ipv4": ["10.0.20.1/32", "10.0.20.2/32"],            "ipv6": ["1::1/128", "1::2/128"] @@ -2736,22 +2747,23 @@ def test_set_localpref_weight_to_ebgp_and_med_to_ibgp_peers_p0():          rmap_name = "rmap_match_pf_2_{}".format(addr_type)          result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type], -                                rmap_name, input_dict_3_addr_type[addr_type]) -        assert result is not True, 'Testcase {} : Failed \n' -        'Expected behaviour: Attributes are not set \n' -        'Error: {}'.format( +                                rmap_name, input_dict_3_addr_type[addr_type], +                                expected=False) +        assert result is not True, "Testcase {} : Failed \n" +        "Attributes are not set \n Error: {}".format(              tc_name, result) +        logger.info("Expected behaviour: {}".format(result))      # Verifying RIB routes -    dut = 'r5' -    protocol = 'bgp' +    dut = "r5" +    protocol = "bgp"      for addr_type in ADDR_TYPES:          result = verify_rib(tgen, addr_type, dut, input_dict,              protocol=protocol) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Verifying BGP set attributes -    dut = 'r5' +    dut = "r5"      routes = {            "ipv4": ["10.0.20.1/32", "10.0.20.2/32"],            "ipv6": ["1::1/128", "1::2/128"] @@ -2761,12 +2773,11 @@ def test_set_localpref_weight_to_ebgp_and_med_to_ibgp_peers_p0():      for addr_type in ADDR_TYPES:          rmap_name = "rmap_match_pf_3_{}".format(addr_type)          result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type], -                                rmap_name, input_dict_3_addr_type[addr_type]) -        assert result is not True, 'Testcase {} : Failed \n' -        'Expected behaviour: Attributes are not set \n' -        'Error: {}'.format( +                                rmap_name, input_dict_3_addr_type[addr_type], +                                expected=False) +        assert result is not True, "Testcase {} : Failed \n" +        "Attributes are not set \n Error: {}".format(              tc_name, result) -          logger.info("Expected behaviour: {}".format(result))      write_test_footer(tc_name) @@ -2778,14 +2789,14 @@ def test_set_localpref_weight_to_ebgp_and_med_to_ibgp_peers_p0():  def test_multiple_set_on_single_sequence_in_rmap_p0():      """      TC_43: -    Test multiple set statements as part of a route-map's +    Test multiple set statements as part of a route-map"s      single sequence number.      """      tgen = get_topogen()      global bgp_convergence      if bgp_convergence is not True: -        pytest.skip('skipped because of BGP Convergence failure') +        pytest.skip("skipped because of BGP Convergence failure")      # test case name      tc_name = inspect.stack()[0][3] @@ -2794,27 +2805,27 @@ def test_multiple_set_on_single_sequence_in_rmap_p0():      # Create ip prefix list      input_dict_2 = { -        'r3': { -            'prefix_lists': { -                'ipv4': { -                'pf_list_1_ipv4': [{ -                    'seqid': 10, -                    'network': 'any', -                    'action': 'permit' +        "r3": { +            "prefix_lists": { +                "ipv4": { +                "pf_list_1_ipv4": [{ +                    "seqid": 10, +                    "network": "any", +                    "action": "permit"                  }]                  }, -                'ipv6': { -                'pf_list_1_ipv6': [{ -                    'seqid': 100, -                    'network': 'any', -                    'action': 'permit' +                "ipv6": { +                "pf_list_1_ipv6": [{ +                    "seqid": 100, +                    "network": "any", +                    "action": "permit"                  }]                  }              }          }      }      result = create_prefix_lists(tgen, input_dict_2) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Create route map @@ -2839,12 +2850,12 @@ def test_multiple_set_on_single_sequence_in_rmap_p0():          }          }          result = create_route_maps(tgen, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Configure neighbor for route map      input_dict_4 = { -       'r3': { +       "r3": {               "bgp": {                   "address_family": {                       "ipv4": { @@ -2856,7 +2867,7 @@ def test_multiple_set_on_single_sequence_in_rmap_p0():                                               "route_maps": [{                                                       "name":                                                       "rmap_match_pf_1_ipv4", -                                                     "direction": 'in' +                                                     "direction": "in"                                               }]                                           }                                       } @@ -2873,7 +2884,7 @@ def test_multiple_set_on_single_sequence_in_rmap_p0():                                               "route_maps": [{                                                       "name":                                                       "rmap_match_pf_1_ipv6", -                                                     "direction": 'in' +                                                     "direction": "in"                                               }]                                           }                                       } @@ -2886,20 +2897,20 @@ def test_multiple_set_on_single_sequence_in_rmap_p0():           }       }      result = create_router_bgp(tgen, topo, input_dict_4) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Verifying RIB routes -    dut = 'r3' -    protocol = 'bgp' +    dut = "r3" +    protocol = "bgp"      input_dict = topo["routers"]      for addr_type in ADDR_TYPES:          result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Verifying BGP set attributes -    dut = 'r3' +    dut = "r3"      routes = {            "ipv4": ["10.0.20.1/32", "10.0.20.2/32"],            "ipv6": ["1::1/128", "1::2/128"] @@ -2910,7 +2921,7 @@ def test_multiple_set_on_single_sequence_in_rmap_p0():          rmap_name = "rmap_match_pf_1_{}".format(addr_type)          result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type],                                     rmap_name, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      write_test_footer(tc_name) @@ -2928,7 +2939,7 @@ def test_route_maps_with_continue_clause_p0():      global bgp_convergence      if bgp_convergence is not True: -        pytest.skip('skipped because of BGP Convergence failure') +        pytest.skip("skipped because of BGP Convergence failure")      # test case name      tc_name = inspect.stack()[0][3] @@ -2937,27 +2948,27 @@ def test_route_maps_with_continue_clause_p0():      # Create ip prefix list      input_dict_2 = { -        'r3': { -            'prefix_lists': { -                'ipv4': { -                'pf_list_1_ipv4': [{ -                    'seqid': 10, -                    'network': 'any', -                    'action': 'permit' +        "r3": { +            "prefix_lists": { +                "ipv4": { +                "pf_list_1_ipv4": [{ +                    "seqid": 10, +                    "network": "any", +                    "action": "permit"                  }]              }, -                'ipv6': { -                'pf_list_1_ipv6': [{ -                    'seqid': 100, -                    'network': 'any', -                    'action': 'permit' +                "ipv6": { +                "pf_list_1_ipv6": [{ +                    "seqid": 100, +                    "network": "any", +                    "action": "permit"                  }]              }              }          }      }      result = create_prefix_lists(tgen, input_dict_2) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Create route map @@ -2967,7 +2978,7 @@ def test_route_maps_with_continue_clause_p0():              "route_maps": {                  "rmap_match_pf_1_{}".format(addr_type): [{                          "action": "permit", -                        'seq_id': '10', +                        "seq_id": "10",                          "match": {                              addr_type: {                              "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -2980,7 +2991,7 @@ def test_route_maps_with_continue_clause_p0():                      },                      {                          "action": "permit", -                        'seq_id': '20', +                        "seq_id": "20",                          "match": {                              addr_type: {                              "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -2992,7 +3003,7 @@ def test_route_maps_with_continue_clause_p0():                      },                      {                          "action": "permit", -                        'seq_id': '30', +                        "seq_id": "30",                          "match": {                              addr_type: {                              "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -3007,12 +3018,12 @@ def test_route_maps_with_continue_clause_p0():          }          }          result = create_route_maps(tgen, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Configure neighbor for route map      input_dict_4 = { -       'r3': { +       "r3": {               "bgp": {                   "address_family": {                       "ipv4": { @@ -3024,7 +3035,7 @@ def test_route_maps_with_continue_clause_p0():                                               "route_maps": [{                                                       "name":                                                       "rmap_match_pf_1_ipv4", -                                                     "direction": 'in' +                                                     "direction": "in"                                               }]                                           }                                       } @@ -3041,7 +3052,7 @@ def test_route_maps_with_continue_clause_p0():                                               "route_maps": [{                                                       "name":                                                       "rmap_match_pf_1_ipv6", -                                                     "direction": 'in' +                                                     "direction": "in"                                               }]                                           }                                       } @@ -3054,21 +3065,21 @@ def test_route_maps_with_continue_clause_p0():           }       }      result = create_router_bgp(tgen, topo, input_dict_4) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Verifying RIB routes -    dut = 'r3' -    protocol = 'bgp' +    dut = "r3" +    protocol = "bgp"      input_dict = topo["routers"]      for addr_type in ADDR_TYPES:          result = verify_rib(tgen, addr_type, dut, input_dict,              protocol=protocol) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Verifying BGP set attributes -    dut = 'r3' +    dut = "r3"      rmap_name = "rmap_match_pf_1"      routes = {            "ipv4": ["10.0.20.1/32", "10.0.20.2/32"], @@ -3082,7 +3093,7 @@ def test_route_maps_with_continue_clause_p0():          rmap_name = "rmap_match_pf_1_{}".format(addr_type)          result = verify_bgp_attributes(tgen, addr_type, dut, routes[              addr_type],rmap_name, input_dict_3, seq_id[addr_type]) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      write_test_footer(tc_name) @@ -3100,7 +3111,7 @@ def test_route_maps_with_goto_clause_p0():      global bgp_convergence      if bgp_convergence is not True: -        pytest.skip('skipped because of BGP Convergence failure') +        pytest.skip("skipped because of BGP Convergence failure")      # test case name      tc_name = inspect.stack()[0][3] @@ -3109,27 +3120,27 @@ def test_route_maps_with_goto_clause_p0():      # Create ip prefix list      input_dict_2 = { -        'r3': { -            'prefix_lists': { -                'ipv4': { -                'pf_list_1_ipv4': [{ -                    'seqid': 10, -                    'network': 'any', -                    'action': 'permit' +        "r3": { +            "prefix_lists": { +                "ipv4": { +                "pf_list_1_ipv4": [{ +                    "seqid": 10, +                    "network": "any", +                    "action": "permit"                  }]              }, -                'ipv6': { -                'pf_list_1_ipv6': [{ -                    'seqid': 100, -                    'network': 'any', -                    'action': 'permit' +                "ipv6": { +                "pf_list_1_ipv6": [{ +                    "seqid": 100, +                    "network": "any", +                    "action": "permit"                  }]              }              }          }      }      result = create_prefix_lists(tgen, input_dict_2) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Create route map @@ -3139,7 +3150,7 @@ def test_route_maps_with_goto_clause_p0():              "route_maps": {                  "rmap_match_pf_1_{}".format(addr_type): [{                          "action": "permit", -                        'seq_id': '10', +                        "seq_id": "10",                          "match": {                          addr_type: {                              "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -3149,7 +3160,7 @@ def test_route_maps_with_goto_clause_p0():                      },                      {                          "action": "permit", -                        'seq_id': '20', +                        "seq_id": "20",                          "match": {                          addr_type: {                              "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -3161,7 +3172,7 @@ def test_route_maps_with_goto_clause_p0():                      },                      {                          "action": "permit", -                        'seq_id': '30', +                        "seq_id": "30",                          "match": {                          addr_type: {                              "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -3176,12 +3187,13 @@ def test_route_maps_with_goto_clause_p0():          }          }          result = create_route_maps(tgen, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        # tgen.mininet_cli() +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Configure neighbor for route map      input_dict_4 = { -       'r3': { +       "r3": {               "bgp": {                   "address_family": {                       "ipv4": { @@ -3193,7 +3205,7 @@ def test_route_maps_with_goto_clause_p0():                                               "route_maps": [{                                                       "name":                                                       "rmap_match_pf_1_ipv4", -                                                     "direction": 'in' +                                                     "direction": "in"                                               }]                                           }                                       } @@ -3210,7 +3222,7 @@ def test_route_maps_with_goto_clause_p0():                                               "route_maps": [{                                                       "name":                                                       "rmap_match_pf_1_ipv6", -                                                     "direction": 'in' +                                                     "direction": "in"                                               }]                                           }                                       } @@ -3223,20 +3235,20 @@ def test_route_maps_with_goto_clause_p0():           }       }      result = create_router_bgp(tgen, topo, input_dict_4) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Verifying RIB routes -    dut = 'r3' -    protocol = 'bgp' +    dut = "r3" +    protocol = "bgp"      input_dict = topo["routers"]      for addr_type in ADDR_TYPES:          result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Verifying BGP set attributes -    dut = 'r3' +    dut = "r3"      rmap_name = "rmap_match_pf_1"      routes = {            "ipv4": ["10.0.20.1/32", "10.0.20.2/32"], @@ -3250,7 +3262,7 @@ def test_route_maps_with_goto_clause_p0():          rmap_name = "rmap_match_pf_1_{}".format(addr_type)          result = verify_bgp_attributes(tgen, addr_type, dut, routes[              addr_type],rmap_name, input_dict_3, seq_id[addr_type]) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      write_test_footer(tc_name) @@ -3268,7 +3280,7 @@ def test_route_maps_with_call_clause_p0():      global bgp_convergence      if bgp_convergence is not True: -        pytest.skip('skipped because of BGP Convergence failure') +        pytest.skip("skipped because of BGP Convergence failure")      # test case name      tc_name = inspect.stack()[0][3] @@ -3277,27 +3289,27 @@ def test_route_maps_with_call_clause_p0():      # Create ip prefix list      input_dict_2 = { -        'r3': { -            'prefix_lists': { -                'ipv4': { -                'pf_list_1_ipv4': [{ -                    'seqid': 10, -                    'network': 'any', -                    'action': 'permit' +        "r3": { +            "prefix_lists": { +                "ipv4": { +                "pf_list_1_ipv4": [{ +                    "seqid": 10, +                    "network": "any", +                    "action": "permit"                  }]              }, -                'ipv6': { -                'pf_list_1_ipv6': [{ -                    'seqid': 100, -                    'network': 'any', -                    'action': 'permit' +                "ipv6": { +                "pf_list_1_ipv6": [{ +                    "seqid": 100, +                    "network": "any", +                    "action": "permit"                  }]              }              }          }      }      result = create_prefix_lists(tgen, input_dict_2) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Create route map @@ -3332,12 +3344,12 @@ def test_route_maps_with_call_clause_p0():          }          }          result = create_route_maps(tgen, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Configure neighbor for route map      input_dict_4 = { -       'r3': { +       "r3": {               "bgp": {                   "address_family": {                       "ipv4": { @@ -3349,7 +3361,7 @@ def test_route_maps_with_call_clause_p0():                                               "route_maps": [{                                                       "name":                                                       "rmap_match_pf_1_ipv4", -                                                     "direction": 'in' +                                                     "direction": "in"                                               }]                                           }                                       } @@ -3366,7 +3378,7 @@ def test_route_maps_with_call_clause_p0():                                               "route_maps": [{                                                       "name":                                                       "rmap_match_pf_1_ipv6", -                                                     "direction": 'in' +                                                     "direction": "in"                                               }]                                           }                                       } @@ -3379,20 +3391,20 @@ def test_route_maps_with_call_clause_p0():           }       }      result = create_router_bgp(tgen, topo, input_dict_4) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Verifying RIB routes -    dut = 'r3' -    protocol = 'bgp' +    dut = "r3" +    protocol = "bgp"      input_dict = topo["routers"]      for addr_type in ADDR_TYPES:          result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Verifying BGP set attributes -    dut = 'r3' +    dut = "r3"      routes = {            "ipv4": ["10.0.20.1/32", "10.0.20.2/32"],            "ipv6": ["1::1/128", "1::2/128"] @@ -3402,7 +3414,7 @@ def test_route_maps_with_call_clause_p0():          rmap_name = "rmap_match_pf_1_{}".format(addr_type)          result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type],                                     rmap_name, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      rmap_name = "rmap_match_pf_2" @@ -3410,7 +3422,7 @@ def test_route_maps_with_call_clause_p0():          rmap_name = "rmap_match_pf_2_{}".format(addr_type)          result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type],                                      rmap_name, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      write_test_footer(tc_name) @@ -3429,7 +3441,7 @@ def test_create_rmap_match_prefix_list_to_deny_in_and_outbound_prefixes_p0():      global bgp_convergence      if bgp_convergence is not True: -        pytest.skip('skipped because of BGP Convergence failure') +        pytest.skip("skipped because of BGP Convergence failure")      # test case name      tc_name = inspect.stack()[0][3] @@ -3438,27 +3450,27 @@ def test_create_rmap_match_prefix_list_to_deny_in_and_outbound_prefixes_p0():      # Create ip prefix list      input_dict_2 = { -        'r3': { -            'prefix_lists': { -                'ipv4': { -                'pf_list_1_ipv4': [{ -                    'seqid': 10, -                    'network': 'any', -                    'action': 'permit' +        "r3": { +            "prefix_lists": { +                "ipv4": { +                "pf_list_1_ipv4": [{ +                    "seqid": 10, +                    "network": "any", +                    "action": "permit"                  }]              }, -                'ipv6': { -                'pf_list_1_ipv6': [{ -                    'seqid': 100, -                    'network': 'any', -                    'action': 'permit' +                "ipv6": { +                "pf_list_1_ipv6": [{ +                    "seqid": 100, +                    "network": "any", +                    "action": "permit"                  }]              }              }          }      }      result = create_prefix_lists(tgen, input_dict_2) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Create route map @@ -3492,12 +3504,12 @@ def test_create_rmap_match_prefix_list_to_deny_in_and_outbound_prefixes_p0():          }          }          result = create_route_maps(tgen, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Configure neighbor for route map      input_dict_4 = { -       'r3': { +       "r3": {               "bgp": {                   "address_family": {                       "ipv4": { @@ -3509,7 +3521,7 @@ def test_create_rmap_match_prefix_list_to_deny_in_and_outbound_prefixes_p0():                                               "route_maps": [{                                                       "name":                                                       "rmap_match_pf_1_ipv4", -                                                     "direction": 'in' +                                                     "direction": "in"                                               }]                                           }                                       } @@ -3520,7 +3532,7 @@ def test_create_rmap_match_prefix_list_to_deny_in_and_outbound_prefixes_p0():                                               "route_maps": [{                                                       "name":                                                       "rmap_match_pf_2_ipv6", -                                                     "direction": 'out' +                                                     "direction": "out"                                               }]                                           }                                       } @@ -3537,7 +3549,7 @@ def test_create_rmap_match_prefix_list_to_deny_in_and_outbound_prefixes_p0():                                               "route_maps": [{                                                       "name":                                                       "rmap_match_pf_1_ipv4", -                                                     "direction": 'in' +                                                     "direction": "in"                                               }]                                           }                                       } @@ -3548,7 +3560,7 @@ def test_create_rmap_match_prefix_list_to_deny_in_and_outbound_prefixes_p0():                                               "route_maps": [{                                                       "name":                                                       "rmap_match_pf_2_ipv6", -                                                     "direction": 'out' +                                                     "direction": "out"                                               }]                                           }                                       } @@ -3561,31 +3573,31 @@ def test_create_rmap_match_prefix_list_to_deny_in_and_outbound_prefixes_p0():           }       }      result = create_router_bgp(tgen, topo, input_dict_4) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Verifying RIB routes -    dut = 'r3' -    protocol = 'bgp' +    dut = "r3" +    protocol = "bgp"      input_dict = topo["routers"]      for addr_type in ADDR_TYPES:          result = verify_rib(tgen, addr_type, dut, input_dict, -        protocol=protocol) -        assert result is not True, 'Testcase {} : Failed \n' -        'Expected behaviour: routes are not present \n ' -        'Error: {}'.format( -            tc_name, result) +                            protocol=protocol, expected=False) +        assert result is not True, "Testcase {} : Failed \n" +        "routes are not present \n Error: {}".\ +            format(tc_name, result) +        logger.info("Expected behaviour: {}".format(result))      # Verifying RIB routes -    dut = 'r4' -    protocol = 'bgp' +    dut = "r4" +    protocol = "bgp"      for addr_type in ADDR_TYPES:          result = verify_rib(tgen, addr_type, dut, input_dict, -        protocol=protocol) -        assert result is not True, 'Testcase {} : Failed \n' -        'Expected behaviour: routes are not present \n ' -        'Error: {}'.format( -            tc_name, result) +                            protocol=protocol, expected=False) +        assert result is not True, "Testcase {} : Failed \n" +        "routes are not present \n Error: {}".\ +            format(tc_name, result) +        logger.info("Expected behaviour: {}".format(result))      write_test_footer(tc_name) @@ -3603,7 +3615,7 @@ def test_create_rmap_to_match_tag_permit_inbound_prefixes_p0():      global bgp_convergence      if bgp_convergence is not True: -        pytest.skip('skipped because of BGP Convergence failure') +        pytest.skip("skipped because of BGP Convergence failure")      # test case name      tc_name = inspect.stack()[0][3] @@ -3675,12 +3687,12 @@ def test_create_rmap_to_match_tag_permit_inbound_prefixes_p0():          }          }          result = create_route_maps(tgen, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Configure neighbor for route map      input_dict_4 = { -       'r1': { +       "r1": {               "bgp": {                   "address_family": {                       "ipv4": { @@ -3692,7 +3704,7 @@ def test_create_rmap_to_match_tag_permit_inbound_prefixes_p0():                                               "route_maps": [{                                                       "name":                                                       "rmap_match_tag_1_ipv4", -                                                     "direction": 'out' +                                                     "direction": "out"                                               }]                                           }                                       } @@ -3709,7 +3721,7 @@ def test_create_rmap_to_match_tag_permit_inbound_prefixes_p0():                                               "route_maps": [{                                                       "name":                                                       "rmap_match_tag_1_ipv6", -                                                     "direction": 'out' +                                                     "direction": "out"                                               }]                                           }                                       } @@ -3722,12 +3734,12 @@ def test_create_rmap_to_match_tag_permit_inbound_prefixes_p0():           }       }      result = create_router_bgp(tgen, topo, input_dict_4) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Verifying RIB routes -    dut = 'r3' -    protocol = 'bgp' +    dut = "r3" +    protocol = "bgp"      for addr_type in ADDR_TYPES:          input_dict = { @@ -3743,7 +3755,7 @@ def test_create_rmap_to_match_tag_permit_inbound_prefixes_p0():          }          result = verify_rib(tgen, addr_type, dut, input_dict,          protocol=protocol) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      write_test_footer(tc_name) @@ -3762,7 +3774,7 @@ def test_create_rmap_to_match_tag_deny_outbound_prefixes_p0():      global bgp_convergence      if bgp_convergence is not True: -        pytest.skip('skipped because of BGP Convergence failure') +        pytest.skip("skipped because of BGP Convergence failure")      # test case name      tc_name = inspect.stack()[0][3] @@ -3834,12 +3846,12 @@ def test_create_rmap_to_match_tag_deny_outbound_prefixes_p0():          }          }          result = create_route_maps(tgen, input_dict_3) -        assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +        assert result is True, "Testcase {} : Failed \n Error: {}".format(              tc_name, result)      # Configure neighbor for route map      input_dict_4 = { -       'r1': { +       "r1": {               "bgp": {                   "address_family": {                       "ipv4": { @@ -3851,7 +3863,7 @@ def test_create_rmap_to_match_tag_deny_outbound_prefixes_p0():                                               "route_maps": [{                                                      "name":                                                      "rmap_match_tag_1_ipv4", -                                                    "direction": 'out' +                                                    "direction": "out"                                               }]                                           }                                       } @@ -3868,7 +3880,7 @@ def test_create_rmap_to_match_tag_deny_outbound_prefixes_p0():                                               "route_maps": [{                                                      "name":                                                      "rmap_match_tag_1_ipv6", -                                                    "direction": 'out' +                                                    "direction": "out"                                               }]                                           }                                       } @@ -3881,12 +3893,12 @@ def test_create_rmap_to_match_tag_deny_outbound_prefixes_p0():           }      }      result = create_router_bgp(tgen, topo, input_dict_4) -    assert result is True, 'Testcase {} : Failed \n Error: {}'.format( +    assert result is True, "Testcase {} : Failed \n Error: {}".format(          tc_name, result)      # Verifying RIB routes -    dut = 'r3' -    protocol = 'bgp' +    dut = "r3" +    protocol = "bgp"      for addr_type in ADDR_TYPES:          input_dict = { @@ -3901,16 +3913,17 @@ def test_create_rmap_to_match_tag_deny_outbound_prefixes_p0():              }          }          result = verify_rib(tgen, addr_type, dut, input_dict, -                            protocol=protocol) -        assert result is not True, 'Testcase {} : Failed \n' -        'Expected behavior: routes are denied \n Error: {}'.format( +                            protocol=protocol, expected=False) +        assert result is not True, "Testcase {} : Failed \n" +        "routes are denied \n Error: {}".format(              tc_name, result) +        logger.info("Expected behaviour: {}".format(result))      write_test_footer(tc_name)      # Uncomment next line for debugging      # tgen.mininet_cli() -if __name__ == '__main__': +if __name__ == "__main__":      args = ["-s"] + sys.argv[1:]      sys.exit(pytest.main(args)) diff --git a/tests/topotests/bgp_set_local-preference_add_subtract/__init__.py b/tests/topotests/bgp_set_local-preference_add_subtract/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/topotests/bgp_set_local-preference_add_subtract/__init__.py diff --git a/tests/topotests/bgp_set_local-preference_add_subtract/r1/bgpd.conf b/tests/topotests/bgp_set_local-preference_add_subtract/r1/bgpd.conf new file mode 100644 index 0000000000..1a9c5325ad --- /dev/null +++ b/tests/topotests/bgp_set_local-preference_add_subtract/r1/bgpd.conf @@ -0,0 +1,5 @@ +router bgp 65000 +  neighbor 192.168.255.2 remote-as 65000 +  neighbor 192.168.255.3 remote-as 65000 +  exit-address-family +! diff --git a/tests/topotests/bgp_set_local-preference_add_subtract/r1/zebra.conf b/tests/topotests/bgp_set_local-preference_add_subtract/r1/zebra.conf new file mode 100644 index 0000000000..6e9b0b4a7e --- /dev/null +++ b/tests/topotests/bgp_set_local-preference_add_subtract/r1/zebra.conf @@ -0,0 +1,6 @@ +! +interface r1-eth0 +  ip address 192.168.255.1/24 +! +ip forwarding +! diff --git a/tests/topotests/bgp_set_local-preference_add_subtract/r2/bgpd.conf b/tests/topotests/bgp_set_local-preference_add_subtract/r2/bgpd.conf new file mode 100644 index 0000000000..89e1256667 --- /dev/null +++ b/tests/topotests/bgp_set_local-preference_add_subtract/r2/bgpd.conf @@ -0,0 +1,9 @@ +router bgp 65000 +  neighbor 192.168.255.1 remote-as 65000 +  address-family ipv4 +    redistribute connected +    neighbor 192.168.255.1 route-map r1-out out +  exit-address-family +! +route-map r1-out permit 10 +  set local-preference +50 diff --git a/tests/topotests/bgp_set_local-preference_add_subtract/r2/zebra.conf b/tests/topotests/bgp_set_local-preference_add_subtract/r2/zebra.conf new file mode 100644 index 0000000000..93e3590448 --- /dev/null +++ b/tests/topotests/bgp_set_local-preference_add_subtract/r2/zebra.conf @@ -0,0 +1,9 @@ +! +interface lo +  ip address 172.16.255.254/32 +! +interface r2-eth0 +  ip address 192.168.255.2/24 +! +ip forwarding +! diff --git a/tests/topotests/bgp_set_local-preference_add_subtract/r3/bgpd.conf b/tests/topotests/bgp_set_local-preference_add_subtract/r3/bgpd.conf new file mode 100644 index 0000000000..fabd4605f3 --- /dev/null +++ b/tests/topotests/bgp_set_local-preference_add_subtract/r3/bgpd.conf @@ -0,0 +1,9 @@ +router bgp 65000 +  neighbor 192.168.255.1 remote-as 65000 +  address-family ipv4 +    redistribute connected +    neighbor 192.168.255.1 route-map r1-out out +  exit-address-family +! +route-map r1-out permit 10 +  set local-preference -50 diff --git a/tests/topotests/bgp_set_local-preference_add_subtract/r3/zebra.conf b/tests/topotests/bgp_set_local-preference_add_subtract/r3/zebra.conf new file mode 100644 index 0000000000..b5e060c3d6 --- /dev/null +++ b/tests/topotests/bgp_set_local-preference_add_subtract/r3/zebra.conf @@ -0,0 +1,9 @@ +! +interface lo +  ip address 172.16.255.254/32 +! +interface r3-eth0 +  ip address 192.168.255.3/24 +! +ip forwarding +! diff --git a/tests/topotests/bgp_set_local-preference_add_subtract/test_bgp_set_local-preference_add_subtract.py b/tests/topotests/bgp_set_local-preference_add_subtract/test_bgp_set_local-preference_add_subtract.py new file mode 100644 index 0000000000..09e195e22d --- /dev/null +++ b/tests/topotests/bgp_set_local-preference_add_subtract/test_bgp_set_local-preference_add_subtract.py @@ -0,0 +1,147 @@ +#!/usr/bin/env python + +# +# bgp_set_local-preference_add_subtract.py +# Part of NetDEF Topology Tests +# +# Copyright (c) 2020 by +# Donatas Abraitis <donatas.abraitis@gmail.com> +# +# Permission to use, copy, modify, and/or distribute this software +# for any purpose with or without fee is hereby granted, provided +# that the above copyright notice and this permission notice appear +# in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY +# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS +# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. +# + +""" +bgp_set_local-preference_add_subtract.py: +Test if we can add/subtract the value to/from an existing +LOCAL_PREF in route-maps. +""" + +import os +import sys +import json +import time +import pytest +import functools + +CWD = os.path.dirname(os.path.realpath(__file__)) +sys.path.append(os.path.join(CWD, '../')) + +# pylint: disable=C0413 +from lib import topotest +from lib.topogen import Topogen, TopoRouter, get_topogen +from lib.topolog import logger +from mininet.topo import Topo + +class TemplateTopo(Topo): +    def build(self, *_args, **_opts): +        tgen = get_topogen(self) + +        for routern in range(1, 4): +            tgen.add_router('r{}'.format(routern)) + +        switch = tgen.add_switch('s1') +        switch.add_link(tgen.gears['r1']) +        switch.add_link(tgen.gears['r2']) +        switch.add_link(tgen.gears['r3']) + +def setup_module(mod): +    tgen = Topogen(TemplateTopo, mod.__name__) +    tgen.start_topology() + +    router_list = tgen.routers() + +    for i, (rname, router) in enumerate(router_list.iteritems(), 1): +        router.load_config( +            TopoRouter.RD_ZEBRA, +            os.path.join(CWD, '{}/zebra.conf'.format(rname)) +        ) +        router.load_config( +            TopoRouter.RD_BGP, +            os.path.join(CWD, '{}/bgpd.conf'.format(rname)) +        ) + +    tgen.start_router() + +def teardown_module(mod): +    tgen = get_topogen() +    tgen.stop_topology() + +def test_bgp_set_local_preference(): +    tgen = get_topogen() + +    if tgen.routers_have_failure(): +        pytest.skip(tgen.errors) + +    router = tgen.gears['r1'] + +    def _bgp_converge(router): +        output = json.loads(router.vtysh_cmd("show ip bgp neighbor json")) +        expected = { +            '192.168.255.2': { +                'bgpState': 'Established', +                'addressFamilyInfo': { +                    'ipv4Unicast': { +                        'acceptedPrefixCounter': 2 +                    } +                } +            }, +            '192.168.255.3': { +                'bgpState': 'Established', +                'addressFamilyInfo': { +                    'ipv4Unicast': { +                        'acceptedPrefixCounter': 2 +                    } +                } +            } +        } +        return topotest.json_cmp(output, expected) + +    def _bgp_check_local_preference(router): +        output = json.loads(router.vtysh_cmd("show ip bgp 172.16.255.254/32 json")) +        expected = { +            'paths': [ +                { +                    'localpref': 50, +                    'nexthops': [ +                        { +                            'ip': '192.168.255.3' +                        } +                    ] +                }, +                { +                    'localpref': 150, +                    'nexthops': [ +                        { +                            'ip': '192.168.255.2' +                        } +                    ] +                } +            ] +        } +        return topotest.json_cmp(output, expected) + +    test_func = functools.partial(_bgp_converge, router) +    success, result = topotest.run_and_expect(test_func, None, count=15, wait=0.5) + +    assert result is None, 'Failed to see BGP convergence in "{}"'.format(router) + +    test_func = functools.partial(_bgp_check_local_preference, router) +    success, result = topotest.run_and_expect(test_func, None, count=15, wait=0.5) + +    assert result is None, 'Failed to see applied BGP local-preference in "{}"'.format(router) + +if __name__ == '__main__': +    args = ["-s"] + sys.argv[1:] +    sys.exit(pytest.main(args)) diff --git a/tests/topotests/lib/bgp.py b/tests/topotests/lib/bgp.py index a8354f4c77..f3c17be684 100644 --- a/tests/topotests/lib/bgp.py +++ b/tests/topotests/lib/bgp.py @@ -1293,16 +1293,13 @@ def verify_bgp_attributes(tgen, addr_type, dut, static_routes, rmap_name,          for static_route in static_routes:              cmd = "show bgp {} {} json".format(addr_type, static_route)              show_bgp_json = run_frr_cmd(rnode, cmd, isjson=True) -            print("show_bgp_json $$$$$", show_bgp_json)              dict_to_test = []              tmp_list = []              for rmap_router in input_dict.keys():                  for rmap, values in input_dict[rmap_router][                          "route_maps"].items(): -                    print("rmap == rmap_name $$$$1", rmap, rmap_name)                      if rmap == rmap_name: -                        print("rmap == rmap_name $$$$", rmap, rmap_name)                          dict_to_test = values                          for rmap_dict in values:                              if seq_id is not None: @@ -1318,7 +1315,6 @@ def verify_bgp_attributes(tgen, addr_type, dut, static_routes, rmap_name,                          if tmp_list:                              dict_to_test = tmp_list -                        print("dict_to_test $$$$", dict_to_test)                          for rmap_dict in dict_to_test:                              if "set" in rmap_dict:                                  for criteria in rmap_dict["set"].keys(): diff --git a/tools/coccinelle/__func__.cocci b/tools/coccinelle/__func__.cocci new file mode 100644 index 0000000000..fb68494d43 --- /dev/null +++ b/tools/coccinelle/__func__.cocci @@ -0,0 +1,10 @@ +@@ +@@ + +( +- __PRETTY_FUNCTION__ ++ __func__ +| +- __FUNCTION__ ++ __func__ +) diff --git a/tools/coccinelle/bool_assignment.cocci b/tools/coccinelle/bool_assignment.cocci new file mode 100644 index 0000000000..e6146ea310 --- /dev/null +++ b/tools/coccinelle/bool_assignment.cocci @@ -0,0 +1,13 @@ +@@ +bool b; +@@ + +( + b = +- 0 ++ false +| + b = +- 1 ++ true +) diff --git a/tools/coccinelle/bool_expression.cocci b/tools/coccinelle/bool_expression.cocci new file mode 100644 index 0000000000..c0c329cb59 --- /dev/null +++ b/tools/coccinelle/bool_expression.cocci @@ -0,0 +1,29 @@ +@@ +bool t; +@@ + +( +- t == true ++ t +| +- true == t ++ t +| +- t != true ++ !t +| +- true != t ++ !t +| +- t == false ++ !t +| +- false == t ++ !t +| +- t != false ++ t +| +- false != t ++ t +) diff --git a/tools/coccinelle/bool_function.cocci b/tools/coccinelle/bool_function.cocci new file mode 100644 index 0000000000..0328ecfbbe --- /dev/null +++ b/tools/coccinelle/bool_function.cocci @@ -0,0 +1,21 @@ +@@ +identifier fn; +typedef bool; +symbol false; +symbol true; +@@ + +bool fn ( ... ) +{ +<... +return +( +- 0 ++ false +| +- 1 ++ true +) +  ; +...> +} diff --git a/tools/coccinelle/bool_function_type.cocci b/tools/coccinelle/bool_function_type.cocci new file mode 100644 index 0000000000..71bf4f53b8 --- /dev/null +++ b/tools/coccinelle/bool_function_type.cocci @@ -0,0 +1,19 @@ +@@ +identifier fn; +typedef bool; +symbol false; +symbol true; +@@ + +- int ++ bool +fn (...) +{ +?... +return +( +  true +| +  false +); +} 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/tools/coccinelle/test_after_assert.cocci b/tools/coccinelle/test_after_assert.cocci new file mode 100644 index 0000000000..30596a89c2 --- /dev/null +++ b/tools/coccinelle/test_after_assert.cocci @@ -0,0 +1,7 @@ +@@ +identifier i; +@@ + +assert(i); +- if (!i) +-   return ...; 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/vrrpd/vrrp.c b/vrrpd/vrrp.c index 03a08dd86b..3ef9fd90aa 100644 --- a/vrrpd/vrrp.c +++ b/vrrpd/vrrp.c @@ -185,6 +185,11 @@ static bool vrrp_ifp_has_vrrp_mac(struct interface *ifp)   * is used to look up any existing instances that match the interface. It does   * not matter whether the instance is already bound to the interface or not.   * + * Note that the interface linkages must be correct for this to work. In other + * words, the macvlan must have a valid VRRP MAC, and its link_ifindex must be + * be equal to the ifindex of another interface in the interface RB trees (its + * parent). If these conditions aren't satisfied we won't find the VR. + *   * mvl_ifp   *    Interface pointer to use to lookup. Should be a macvlan device.   * @@ -953,7 +958,7 @@ static int vrrp_recv_advertisement(struct vrrp_router *r, struct ipaddr *src,  			thread_add_timer_msec(  				master, vrrp_master_down_timer_expire, r,  				r->skew_time * CS2MS, &r->t_master_down_timer); -		} else if (r->vr->preempt_mode == false +		} else if (!r->vr->preempt_mode  			   || pkt->hdr.priority >= r->priority) {  			if (r->vr->version == 3) {  				r->master_adver_interval = @@ -965,7 +970,7 @@ static int vrrp_recv_advertisement(struct vrrp_router *r, struct ipaddr *src,  					      vrrp_master_down_timer_expire, r,  					      r->master_down_interval * CS2MS,  					      &r->t_master_down_timer); -		} else if (r->vr->preempt_mode == true +		} else if (r->vr->preempt_mode  			   && pkt->hdr.priority < r->priority) {  			/* Discard advertisement */  			DEBUGD(&vrrp_dbg_proto, @@ -1646,7 +1651,7 @@ static int vrrp_shutdown(struct vrrp_router *r)  		       r->vr->vrid, family2str(r->family),  		       vrrp_event_names[VRRP_EVENT_SHUTDOWN],  		       vrrp_state_names[VRRP_STATE_INITIALIZE]); -		break; +		return 0;  	}  	/* Cancel all timers */ @@ -1834,7 +1839,7 @@ static int vrrp_autoconfig_if_add(struct interface *ifp)  		created = true;  	} -	if (!vr || vr->autoconf == false) +	if (!vr || !vr->autoconf)  		return 0;  	if (!created) { @@ -2214,18 +2219,57 @@ void vrrp_if_del(struct interface *ifp)  {  	struct listnode *ln;  	struct vrrp_vrouter *vr; -	struct list *vrs = vrrp_lookup_by_if_any(ifp);  	vrrp_if_down(ifp); +	/* +	 * You think we'd be able use vrrp_lookup_by_if_any to find interfaces? +	 * Nah. FRR's interface management is insane. There are no ordering +	 * guarantees about what interfaces are deleted when. Maybe this is a +	 * macvlan and its parent was already deleted, in which case its +	 * ifindex is now IFINDEX_INTERNAL, so ifp->link_ifindex - while still +	 * valid - doesn't match any interface on the system, meaning we can't +	 * use any of the vrrp_lookup* functions since they rely on finding the +	 * base interface of what they're given by following link_ifindex. +	 * +	 * Since we need to actually NULL out pointers in this function to +	 * avoid a UAF - since the caller will (might) free ifp after we return +	 * - we need to look up based on pointers. +	 */ +	struct list *vrs = hash_to_list(vrrp_vrouters_hash); +  	for (ALL_LIST_ELEMENTS_RO(vrs, ln, vr)) { -		if ((vr->v4->mvl_ifp == ifp || vr->ifp == ifp) -		    && vr->v4->fsm.state != VRRP_STATE_INITIALIZE) { +		if (ifp == vr->ifp) {  			vrrp_event(vr->v4, VRRP_EVENT_SHUTDOWN); +			vrrp_event(vr->v6, VRRP_EVENT_SHUTDOWN); +			/* +			 * Stands to reason if the base was deleted, so were +			 * (or will be) its children +			 */  			vr->v4->mvl_ifp = NULL; -		} else if ((vr->v6->mvl_ifp == ifp || vr->ifp == ifp) -			   && vr->v6->fsm.state != VRRP_STATE_INITIALIZE) { +			vr->v6->mvl_ifp = NULL; +			/* +			 * We shouldn't need to lose the reference if it's the +			 * primary interface, because that was configured +			 * explicitly in our config, and thus will be kept as a +			 * stub; to avoid stupid bugs, double check that +			 */ +			assert(ifp->configured); +		} else if (ifp == vr->v4->mvl_ifp) { +			vrrp_event(vr->v4, VRRP_EVENT_SHUTDOWN); +			/* +			 * If this is a macvlan, then it wasn't explicitly +			 * configured and will be deleted when we return from +			 * this function, so we need to lose the reference +			 */ +			vr->v4->mvl_ifp = NULL; +		} else if (ifp == vr->v6->mvl_ifp) {  			vrrp_event(vr->v6, VRRP_EVENT_SHUTDOWN); +			/* +			 * If this is a macvlan, then it wasn't explicitly +			 * configured and will be deleted when we return from +			 * this function, so we need to lose the reference +			 */  			vr->v6->mvl_ifp = NULL;  		}  	} @@ -2347,11 +2391,11 @@ static bool vrrp_hash_cmp(const void *arg1, const void *arg2)  	const struct vrrp_vrouter *vr2 = arg2;  	if (vr1->ifp != vr2->ifp) -		return 0; +		return false;  	if (vr1->vrid != vr2->vrid) -		return 0; +		return false; -	return 1; +	return true;  }  void vrrp_init(void) diff --git a/vrrpd/vrrp_debug.h b/vrrpd/vrrp_debug.h index 20f9930955..459d4d01aa 100644 --- a/vrrpd/vrrp_debug.h +++ b/vrrpd/vrrp_debug.h @@ -25,13 +25,13 @@  #include "lib/debug.h"  /* VRRP debugging records */ -struct debug vrrp_dbg_arp; -struct debug vrrp_dbg_auto; -struct debug vrrp_dbg_ndisc; -struct debug vrrp_dbg_pkt; -struct debug vrrp_dbg_proto; -struct debug vrrp_dbg_sock; -struct debug vrrp_dbg_zebra; +extern struct debug vrrp_dbg_arp; +extern struct debug vrrp_dbg_auto; +extern struct debug vrrp_dbg_ndisc; +extern struct debug vrrp_dbg_pkt; +extern struct debug vrrp_dbg_proto; +extern struct debug vrrp_dbg_sock; +extern struct debug vrrp_dbg_zebra;  /*   * Initialize VRRP debugging. diff --git a/vrrpd/vrrp_zebra.c b/vrrpd/vrrp_zebra.c index 000672a080..a578921df6 100644 --- a/vrrpd/vrrp_zebra.c +++ b/vrrpd/vrrp_zebra.c @@ -204,5 +204,5 @@ void vrrp_zebra_init(void)  	zclient_init(zclient, ZEBRA_ROUTE_VRRP, 0, &vrrp_privs); -	zlog_notice("%s: zclient socket initialized", __PRETTY_FUNCTION__); +	zlog_notice("%s: zclient socket initialized", __func__);  } diff --git a/vtysh/extract.pl.in b/vtysh/extract.pl.in index b7ac0abe02..c4f293fd3b 100755 --- a/vtysh/extract.pl.in +++ b/vtysh/extract.pl.in @@ -43,7 +43,9 @@ sub scan_file {      open (FH, "@CPP@ -DHAVE_CONFIG_H -DVTYSH_EXTRACT_PL -Ivtysh/@top_builddir@ -Ivtysh/@top_srcdir@ -Ivtysh/@top_srcdir@/lib -Ivtysh/@top_builddir@/lib -Ivtysh/@top_srcdir@/bgpd -Ivtysh/@top_srcdir@/bgpd/rfapi @LUA_INCLUDE@ @CPPFLAGS@ $cppadd $file |");      local $/; undef $/;      $line = <FH>; -    close (FH); +    if (!close (FH)) { +	printf "File: $file failed to compile, when extracting cli from it please inspect\n" +    }      # ?: makes a group non-capturing      @defun = ($line =~ /((?:DEFUN|DEFUN_HIDDEN|ALIAS|ALIAS_HIDDEN)\s*\(.+?\));?\s?\s?\n/sg); diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 92d52ff650..310acdf37f 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -3670,7 +3670,7 @@ char *vtysh_prompt(void)  {  	static char buf[512]; -	snprintf(buf, sizeof buf, cmd_prompt(vty->node), cmd_hostname_get()); +	snprintf(buf, sizeof(buf), cmd_prompt(vty->node), cmd_hostname_get());  	return buf;  } diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c index 5951274257..25d1bf7db0 100644 --- a/vtysh/vtysh_main.c +++ b/vtysh/vtysh_main.c @@ -229,14 +229,15 @@ static char *vtysh_rl_gets(void)  static void log_it(const char *line)  {  	time_t t = time(NULL); -	struct tm *tmp = localtime(&t); +	struct tm tmp;  	const char *user = getenv("USER");  	char tod[64]; +	localtime_r(&t, &tmp);  	if (!user)  		user = "boot"; -	strftime(tod, sizeof tod, "%Y%m%d-%H:%M.%S", tmp); +	strftime(tod, sizeof(tod), "%Y%m%d-%H:%M.%S", &tmp);  	fprintf(logfile, "%s:%s %s\n", tod, user, line);  } diff --git a/zebra/connected.c b/zebra/connected.c index 0ee41afa8f..5c713aa970 100644 --- a/zebra/connected.c +++ b/zebra/connected.c @@ -210,9 +210,10 @@ void connected_up(struct interface *ifp, struct connected *ifc)  	zvrf = zebra_vrf_lookup_by_id(ifp->vrf_id);  	if (!zvrf) { -		flog_err(EC_ZEBRA_VRF_NOT_FOUND, -			 "%s: Received Up for interface but no associated zvrf: %d", -			 __PRETTY_FUNCTION__, ifp->vrf_id); +		flog_err( +			EC_ZEBRA_VRF_NOT_FOUND, +			"%s: Received Up for interface but no associated zvrf: %d", +			__func__, ifp->vrf_id);  		return;  	}  	if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_REAL)) @@ -355,9 +356,10 @@ void connected_down(struct interface *ifp, struct connected *ifc)  	zvrf = zebra_vrf_lookup_by_id(ifp->vrf_id);  	if (!zvrf) { -		flog_err(EC_ZEBRA_VRF_NOT_FOUND, -			 "%s: Received Up for interface but no associated zvrf: %d", -			 __PRETTY_FUNCTION__, ifp->vrf_id); +		flog_err( +			EC_ZEBRA_VRF_NOT_FOUND, +			"%s: Received Up for interface but no associated zvrf: %d", +			__func__, ifp->vrf_id);  		return;  	} diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c index 4731d1ed15..65a0add57e 100644 --- a/zebra/if_netlink.c +++ b/zebra/if_netlink.c @@ -286,7 +286,7 @@ static void netlink_vrf_change(struct nlmsghdr *h, struct rtattr *tb,  	ifi = NLMSG_DATA(h); -	memset(linkinfo, 0, sizeof linkinfo); +	memset(linkinfo, 0, sizeof(linkinfo));  	parse_rtattr_nested(linkinfo, IFLA_INFO_MAX, tb);  	if (!linkinfo[IFLA_INFO_DATA]) { @@ -297,7 +297,7 @@ static void netlink_vrf_change(struct nlmsghdr *h, struct rtattr *tb,  		return;  	} -	memset(attr, 0, sizeof attr); +	memset(attr, 0, sizeof(attr));  	parse_rtattr_nested(attr, IFLA_VRF_MAX, linkinfo[IFLA_INFO_DATA]);  	if (!attr[IFLA_VRF_TABLE]) {  		if (IS_ZEBRA_DEBUG_KERNEL) @@ -433,7 +433,7 @@ static int netlink_extract_bridge_info(struct rtattr *link_data,  	struct rtattr *attr[IFLA_BR_MAX + 1];  	memset(bridge_info, 0, sizeof(*bridge_info)); -	memset(attr, 0, sizeof attr); +	memset(attr, 0, sizeof(attr));  	parse_rtattr_nested(attr, IFLA_BR_MAX, link_data);  	if (attr[IFLA_BR_VLAN_FILTERING])  		bridge_info->vlan_aware = @@ -448,7 +448,7 @@ static int netlink_extract_vlan_info(struct rtattr *link_data,  	vlanid_t vid_in_msg;  	memset(vlan_info, 0, sizeof(*vlan_info)); -	memset(attr, 0, sizeof attr); +	memset(attr, 0, sizeof(attr));  	parse_rtattr_nested(attr, IFLA_VLAN_MAX, link_data);  	if (!attr[IFLA_VLAN_ID]) {  		if (IS_ZEBRA_DEBUG_KERNEL) @@ -469,7 +469,7 @@ static int netlink_extract_vxlan_info(struct rtattr *link_data,  	struct in_addr vtep_ip_in_msg;  	memset(vxl_info, 0, sizeof(*vxl_info)); -	memset(attr, 0, sizeof attr); +	memset(attr, 0, sizeof(attr));  	parse_rtattr_nested(attr, IFLA_VXLAN_MAX, link_data);  	if (!attr[IFLA_VXLAN_ID]) {  		if (IS_ZEBRA_DEBUG_KERNEL) @@ -543,7 +543,7 @@ static int netlink_bridge_interface(struct nlmsghdr *h, int len, ns_id_t ns_id,  	/* Fetch name and ifindex */  	ifi = NLMSG_DATA(h); -	memset(tb, 0, sizeof tb); +	memset(tb, 0, sizeof(tb));  	netlink_parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), len);  	if (tb[IFLA_IFNAME] == NULL) @@ -567,7 +567,7 @@ static int netlink_bridge_interface(struct nlmsghdr *h, int len, ns_id_t ns_id,  	/* There is a 1-to-1 mapping of VLAN to VxLAN - hence  	 * only 1 access VLAN is accepted.  	 */ -	memset(aftb, 0, sizeof aftb); +	memset(aftb, 0, sizeof(aftb));  	parse_rtattr_nested(aftb, IFLA_BRIDGE_MAX, tb[IFLA_AF_SPEC]);  	if (!aftb[IFLA_BRIDGE_VLAN_INFO])  		return 0; @@ -616,10 +616,10 @@ static int netlink_interface(struct nlmsghdr *h, ns_id_t ns_id, int startup)  	len = h->nlmsg_len - NLMSG_LENGTH(sizeof(struct ifinfomsg));  	if (len < 0) { -		zlog_err("%s: Message received from netlink is of a broken size: %d %zu", -			 __PRETTY_FUNCTION__, -			 h->nlmsg_len, -			 (size_t)NLMSG_LENGTH(sizeof(struct ifinfomsg))); +		zlog_err( +			"%s: Message received from netlink is of a broken size: %d %zu", +			__func__, h->nlmsg_len, +			(size_t)NLMSG_LENGTH(sizeof(struct ifinfomsg)));  		return -1;  	} @@ -628,8 +628,8 @@ static int netlink_interface(struct nlmsghdr *h, ns_id_t ns_id, int startup)  		return netlink_bridge_interface(h, len, ns_id, startup);  	/* Looking up interface name. */ -	memset(tb, 0, sizeof tb); -	memset(linkinfo, 0, sizeof linkinfo); +	memset(tb, 0, sizeof(tb)); +	memset(linkinfo, 0, sizeof(linkinfo));  	netlink_parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), len);  	/* check for wireless messages to ignore */ @@ -858,7 +858,7 @@ int kernel_interface_set_master(struct interface *master,  		char buf[NL_PKT_BUF_SIZE];  	} req; -	memset(&req, 0, sizeof req); +	memset(&req, 0, sizeof(req));  	req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg));  	req.n.nlmsg_flags = NLM_F_REQUEST; @@ -867,8 +867,8 @@ int kernel_interface_set_master(struct interface *master,  	req.ifa.ifi_index = slave->ifindex; -	addattr_l(&req.n, sizeof req, IFLA_MASTER, &master->ifindex, 4); -	addattr_l(&req.n, sizeof req, IFLA_LINK, &slave->ifindex, 4); +	addattr_l(&req.n, sizeof(req), IFLA_MASTER, &master->ifindex, 4); +	addattr_l(&req.n, sizeof(req), IFLA_LINK, &slave->ifindex, 4);  	return netlink_talk(netlink_talk_filter, &req.n, &zns->netlink_cmd, zns,  			    0); @@ -975,14 +975,14 @@ int netlink_interface_addr(struct nlmsghdr *h, ns_id_t ns_id, int startup)  	len = h->nlmsg_len - NLMSG_LENGTH(sizeof(struct ifaddrmsg));  	if (len < 0) { -		zlog_err("%s: Message received from netlink is of a broken size: %d %zu", -			 __PRETTY_FUNCTION__, -			 h->nlmsg_len, -			 (size_t)NLMSG_LENGTH(sizeof(struct ifaddrmsg))); +		zlog_err( +			"%s: Message received from netlink is of a broken size: %d %zu", +			__func__, h->nlmsg_len, +			(size_t)NLMSG_LENGTH(sizeof(struct ifaddrmsg)));  		return -1;  	} -	memset(tb, 0, sizeof tb); +	memset(tb, 0, sizeof(tb));  	netlink_parse_rtattr(tb, IFA_MAX, IFA_RTA(ifa), len);  	ifp = if_lookup_by_index_per_ns(zns, ifa->ifa_index); @@ -1176,9 +1176,10 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)  	len = h->nlmsg_len - NLMSG_LENGTH(sizeof(struct ifinfomsg));  	if (len < 0) { -		zlog_err("%s: Message received from netlink is of a broken size %d %zu", -			 __PRETTY_FUNCTION__, h->nlmsg_len, -			 (size_t)NLMSG_LENGTH(sizeof(struct ifinfomsg))); +		zlog_err( +			"%s: Message received from netlink is of a broken size %d %zu", +			__func__, h->nlmsg_len, +			(size_t)NLMSG_LENGTH(sizeof(struct ifinfomsg)));  		return -1;  	} @@ -1187,8 +1188,8 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)  		return netlink_bridge_interface(h, len, ns_id, startup);  	/* Looking up interface name. */ -	memset(tb, 0, sizeof tb); -	memset(linkinfo, 0, sizeof linkinfo); +	memset(tb, 0, sizeof(tb)); +	memset(linkinfo, 0, sizeof(linkinfo));  	netlink_parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), len);  	/* check for wireless messages to ignore */ diff --git a/zebra/interface.c b/zebra/interface.c index a434ba0d38..59cbfc6854 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -84,9 +84,8 @@ static int if_zebra_speed_update(struct thread *thread)  		return 1;  	if (new_speed != ifp->speed) { -		zlog_info("%s: %s old speed: %u new speed: %u", -			  __PRETTY_FUNCTION__, ifp->name, ifp->speed, -			  new_speed); +		zlog_info("%s: %s old speed: %u new speed: %u", __func__, +			  ifp->name, ifp->speed, new_speed);  		ifp->speed = new_speed;  		if_add_update(ifp);  		changed = true; diff --git a/zebra/ipforward_proc.c b/zebra/ipforward_proc.c index 226f722937..4bd160ddbc 100644 --- a/zebra/ipforward_proc.c +++ b/zebra/ipforward_proc.c @@ -34,9 +34,7 @@ static const char proc_net_snmp[] = "/proc/net/snmp";  static void dropline(FILE *fp)  { -	int c; - -	while ((c = getc(fp)) != '\n') +	while (getc(fp) != '\n')  		;  } diff --git a/zebra/ipforward_sysctl.c b/zebra/ipforward_sysctl.c index ac8f537075..48ab95d1ba 100644 --- a/zebra/ipforward_sysctl.c +++ b/zebra/ipforward_sysctl.c @@ -41,7 +41,7 @@ int ipforward(void)  	size_t len;  	int ipforwarding = 0; -	len = sizeof ipforwarding; +	len = sizeof(ipforwarding);  	if (sysctl(mib, MIB_SIZ, &ipforwarding, &len, 0, 0) < 0) {  		flog_err_sys(EC_LIB_SYSTEM_CALL,  			     "Can't get ipforwarding value"); @@ -55,7 +55,7 @@ int ipforward_on(void)  	size_t len;  	int ipforwarding = 1; -	len = sizeof ipforwarding; +	len = sizeof(ipforwarding);  	frr_with_privs(&zserv_privs) {  		if (sysctl(mib, MIB_SIZ, NULL, NULL, &ipforwarding, len) < 0) {  			flog_err_sys(EC_LIB_SYSTEM_CALL, @@ -71,7 +71,7 @@ int ipforward_off(void)  	size_t len;  	int ipforwarding = 0; -	len = sizeof ipforwarding; +	len = sizeof(ipforwarding);  	frr_with_privs(&zserv_privs) {  		if (sysctl(mib, MIB_SIZ, NULL, NULL, &ipforwarding, len) < 0) {  			flog_err_sys(EC_LIB_SYSTEM_CALL, @@ -96,7 +96,7 @@ int ipforward_ipv6(void)  	size_t len;  	int ip6forwarding = 0; -	len = sizeof ip6forwarding; +	len = sizeof(ip6forwarding);  	frr_with_privs(&zserv_privs) {  		if (sysctl(mib_ipv6, MIB_SIZ, &ip6forwarding, &len, 0, 0) < 0) {  			flog_err_sys(EC_LIB_SYSTEM_CALL, @@ -112,7 +112,7 @@ int ipforward_ipv6_on(void)  	size_t len;  	int ip6forwarding = 1; -	len = sizeof ip6forwarding; +	len = sizeof(ip6forwarding);  	frr_with_privs(&zserv_privs) {  		if (sysctl(mib_ipv6, MIB_SIZ, NULL, NULL, &ip6forwarding, len)  		    < 0) { @@ -129,7 +129,7 @@ int ipforward_ipv6_off(void)  	size_t len;  	int ip6forwarding = 0; -	len = sizeof ip6forwarding; +	len = sizeof(ip6forwarding);  	frr_with_privs(&zserv_privs) {  		if (sysctl(mib_ipv6, MIB_SIZ, NULL, NULL, &ip6forwarding, len)  		    < 0) { diff --git a/zebra/irdp_main.c b/zebra/irdp_main.c index 0de618625d..a1e6e8248e 100644 --- a/zebra/irdp_main.c +++ b/zebra/irdp_main.c @@ -190,7 +190,7 @@ static void irdp_send(struct interface *ifp, struct prefix *p, struct stream *s)  	if (irdp->flags & IF_DEBUG_MESSAGES)  		zlog_debug("IRDP: TX Advert on %s %s Holdtime=%d Preference=%d", -			   ifp->name, prefix2str(p, buf, sizeof buf), +			   ifp->name, prefix2str(p, buf, sizeof(buf)),  			   irdp->flags & IF_SHUTDOWN ? 0 : irdp->Lifetime,  			   get_pref(irdp, p)); diff --git a/zebra/irdp_packet.c b/zebra/irdp_packet.c index 13dcab9294..502a2f277c 100644 --- a/zebra/irdp_packet.c +++ b/zebra/irdp_packet.c @@ -196,7 +196,7 @@ static int irdp_recvmsg(int sock, uint8_t *buf, int size, int *ifindex)  	msg.msg_iov = &iov;  	msg.msg_iovlen = 1;  	msg.msg_control = (void *)adata; -	msg.msg_controllen = sizeof adata; +	msg.msg_controllen = sizeof(adata);  	iov.iov_base = buf;  	iov.iov_len = size; diff --git a/zebra/kernel_netlink.c b/zebra/kernel_netlink.c index 90d3aeb482..97b0238362 100644 --- a/zebra/kernel_netlink.c +++ b/zebra/kernel_netlink.c @@ -231,12 +231,12 @@ static int netlink_socket(struct nlsock *nl, unsigned long groups,  			return -1;  		} -		memset(&snl, 0, sizeof snl); +		memset(&snl, 0, sizeof(snl));  		snl.nl_family = AF_NETLINK;  		snl.nl_groups = groups;  		/* Bind the socket to the netlink structure for anything. */ -		ret = bind(sock, (struct sockaddr *)&snl, sizeof snl); +		ret = bind(sock, (struct sockaddr *)&snl, sizeof(snl));  	}  	if (ret < 0) { @@ -247,9 +247,9 @@ static int netlink_socket(struct nlsock *nl, unsigned long groups,  	}  	/* multiple netlink sockets will have different nl_pid */ -	namelen = sizeof snl; +	namelen = sizeof(snl);  	ret = getsockname(sock, (struct sockaddr *)&snl, (socklen_t *)&namelen); -	if (ret < 0 || namelen != sizeof snl) { +	if (ret < 0 || namelen != sizeof(snl)) {  		flog_err_sys(EC_LIB_SOCKET, "Can't get %s socket name: %s",  			     nl->name, safe_strerror(errno));  		close(sock); @@ -697,8 +697,7 @@ static void netlink_parse_extended_ack(struct nlmsghdr *h)  			 * but noticing it for later.  			 */  			err_nlh = &err->msg; -			zlog_debug("%s: Received %s extended Ack", -				   __PRETTY_FUNCTION__, +			zlog_debug("%s: Received %s extended Ack", __func__,  				   nl_msg_type_to_str(err_nlh->nlmsg_type));  		}  	} @@ -739,10 +738,10 @@ int netlink_parse_info(int (*filter)(struct nlmsghdr *, ns_id_t, int),  	while (1) {  		char buf[NL_RCV_PKT_BUF_SIZE]; -		struct iovec iov = {.iov_base = buf, .iov_len = sizeof buf}; +		struct iovec iov = {.iov_base = buf, .iov_len = sizeof(buf)};  		struct sockaddr_nl snl;  		struct msghdr msg = {.msg_name = (void *)&snl, -				     .msg_namelen = sizeof snl, +				     .msg_namelen = sizeof(snl),  				     .msg_iov = &iov,  				     .msg_iovlen = 1};  		struct nlmsghdr *h; @@ -784,7 +783,7 @@ int netlink_parse_info(int (*filter)(struct nlmsghdr *, ns_id_t, int),  			return -1;  		} -		if (msg.msg_namelen != sizeof snl) { +		if (msg.msg_namelen != sizeof(snl)) {  			flog_err(EC_ZEBRA_NETLINK_LENGTH_ERROR,  				 "%s sender address length error: length %d",  				 nl->name, msg.msg_namelen); @@ -844,7 +843,7 @@ int netlink_parse_info(int (*filter)(struct nlmsghdr *, ns_id_t, int),  					if (IS_ZEBRA_DEBUG_KERNEL) {  						zlog_debug(  							"%s: %s ACK: type=%s(%u), seq=%u, pid=%u", -							__FUNCTION__, nl->name, +							__func__, nl->name,  							nl_msg_type_to_str(  								err->msg.nlmsg_type),  							err->msg.nlmsg_type, @@ -990,14 +989,14 @@ int netlink_talk_info(int (*filter)(struct nlmsghdr *, ns_id_t, int startup),  	int save_errno = 0;  	const struct nlsock *nl; -	memset(&snl, 0, sizeof snl); -	memset(&iov, 0, sizeof iov); -	memset(&msg, 0, sizeof msg); +	memset(&snl, 0, sizeof(snl)); +	memset(&iov, 0, sizeof(iov)); +	memset(&msg, 0, sizeof(msg));  	iov.iov_base = n;  	iov.iov_len = n->nlmsg_len;  	msg.msg_name = (void *)&snl; -	msg.msg_namelen = sizeof snl; +	msg.msg_namelen = sizeof(snl);  	msg.msg_iov = &iov;  	msg.msg_iovlen = 1; @@ -1078,13 +1077,13 @@ int netlink_request(struct nlsock *nl, struct nlmsghdr *n)  	n->nlmsg_pid = nl->snl.nl_pid;  	n->nlmsg_seq = ++nl->seq; -	memset(&snl, 0, sizeof snl); +	memset(&snl, 0, sizeof(snl));  	snl.nl_family = AF_NETLINK;  	/* Raise capabilities and send message, then lower capabilities. */  	frr_with_privs(&zserv_privs) {  		ret = sendto(nl->sock, (void *)n, n->nlmsg_len, 0, -			     (struct sockaddr *)&snl, sizeof snl); +			     (struct sockaddr *)&snl, sizeof(snl));  	}  	if (ret < 0) { diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c index 7cdd6ef84e..5ab5210664 100644 --- a/zebra/kernel_socket.c +++ b/zebra/kernel_socket.c @@ -1371,7 +1371,7 @@ static int kernel_read(struct thread *thread)  	/* Fetch routing socket. */  	sock = THREAD_FD(thread); -	nbytes = read(sock, &buf, sizeof buf); +	nbytes = read(sock, &buf, sizeof(buf));  	if (nbytes <= 0) {  		if (nbytes < 0 && errno != EWOULDBLOCK && errno != EAGAIN) diff --git a/zebra/redistribute.c b/zebra/redistribute.c index 03bb19923f..32051a62b7 100644 --- a/zebra/redistribute.c +++ b/zebra/redistribute.c @@ -346,14 +346,13 @@ void zebra_redistribute_add(ZAPI_HANDLER_ARGS)  	if (afi == 0 || afi >= AFI_MAX) {  		flog_warn(EC_ZEBRA_REDISTRIBUTE_UNKNOWN_AF, -			  "%s: Specified afi %d does not exist", -			  __PRETTY_FUNCTION__, afi); +			  "%s: Specified afi %d does not exist", __func__, afi);  		return;  	}  	if (type == 0 || type >= ZEBRA_ROUTE_MAX) {  		zlog_debug("%s: Specified Route Type %d does not exist", -			   __PRETTY_FUNCTION__, type); +			   __func__, type);  		return;  	} @@ -395,14 +394,13 @@ void zebra_redistribute_delete(ZAPI_HANDLER_ARGS)  	if (afi == 0 || afi >= AFI_MAX) {  		flog_warn(EC_ZEBRA_REDISTRIBUTE_UNKNOWN_AF, -			  "%s: Specified afi %d does not exist", -			  __PRETTY_FUNCTION__, afi); +			  "%s: Specified afi %d does not exist", __func__, afi);  		return;  	}  	if (type == 0 || type >= ZEBRA_ROUTE_MAX) {  		zlog_debug("%s: Specified Route Type %d does not exist", -			   __PRETTY_FUNCTION__, type); +			   __func__, type);  		return;  	} @@ -429,8 +427,7 @@ void zebra_redistribute_default_add(ZAPI_HANDLER_ARGS)  	if (afi == 0 || afi >= AFI_MAX) {  		flog_warn(EC_ZEBRA_REDISTRIBUTE_UNKNOWN_AF, -			  "%s: Specified afi %u does not exist", -			  __PRETTY_FUNCTION__, afi); +			  "%s: Specified afi %u does not exist", __func__, afi);  		return;  	} @@ -449,8 +446,7 @@ void zebra_redistribute_default_delete(ZAPI_HANDLER_ARGS)  	if (afi == 0 || afi >= AFI_MAX) {  		flog_warn(EC_ZEBRA_REDISTRIBUTE_UNKNOWN_AF, -			  "%s: Specified afi %u does not exist", -			  __PRETTY_FUNCTION__, afi); +			  "%s: Specified afi %u does not exist", __func__, afi);  		return;  	} @@ -648,7 +644,7 @@ int zebra_add_import_table_entry(struct zebra_vrf *zvrf, struct route_node *rn,  	if (rmap_name)  		ret = zebra_import_table_route_map_check(  			afi, re->type, re->instance, &rn->p, -			re->nhe->nhg->nexthop, +			re->nhe->nhg.nexthop,  			zvrf->vrf->vrf_id, re->tag, rmap_name);  	if (ret != RMAP_PERMITMATCH) { @@ -685,7 +681,7 @@ int zebra_add_import_table_entry(struct zebra_vrf *zvrf, struct route_node *rn,  	newre->instance = re->table;  	ng = nexthop_group_new(); -	copy_nexthops(&ng->nexthop, re->nhe->nhg->nexthop, NULL); +	copy_nexthops(&ng->nexthop, re->nhe->nhg.nexthop, NULL);  	rib_add_multipath(afi, SAFI_UNICAST, &p, NULL, newre, ng); @@ -702,7 +698,7 @@ int zebra_del_import_table_entry(struct zebra_vrf *zvrf, struct route_node *rn,  	prefix_copy(&p, &rn->p);  	rib_delete(afi, SAFI_UNICAST, zvrf->vrf->vrf_id, ZEBRA_ROUTE_TABLE, -		   re->table, re->flags, &p, NULL, re->nhe->nhg->nexthop, +		   re->table, re->flags, &p, NULL, re->nhe->nhg.nexthop,  		   re->nhe_id, zvrf->table_id, re->metric, re->distance,  		   false); diff --git a/zebra/rib.h b/zebra/rib.h index 927675e3d9..931c97638e 100644 --- a/zebra/rib.h +++ b/zebra/rib.h @@ -515,7 +515,7 @@ static inline struct nexthop_group *rib_active_nhg(struct route_entry *re)  	if (re->fib_ng.nexthop)  		return &(re->fib_ng);  	else -		return re->nhe->nhg; +		return &(re->nhe->nhg);  }  extern void zebra_vty_init(void); diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 1d63db32e8..7011342ab4 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -213,7 +213,7 @@ static inline int zebra2proto(int proto)  		 */  		zlog_debug(  			"%s: Please add this protocol(%d) to proper rt_netlink.c handling", -			__PRETTY_FUNCTION__, proto); +			__func__, proto);  		proto = RTPROT_ZEBRA;  		break;  	} @@ -280,7 +280,7 @@ static inline int proto2zebra(int proto, int family, bool is_nexthop)  		 */  		zlog_debug(  			"%s: Please add this protocol(%d) to proper rt_netlink.c handling", -			__PRETTY_FUNCTION__, proto); +			__func__, proto);  		proto = ZEBRA_ROUTE_KERNEL;  		break;  	} @@ -439,7 +439,7 @@ static uint8_t parse_multipath_nexthops_unicast(ns_id_t ns_id,  				flog_warn(  					EC_ZEBRA_UNKNOWN_INTERFACE,  					"%s: Unknown interface %u specified, defaulting to VRF_DEFAULT", -					__PRETTY_FUNCTION__, index); +					__func__, index);  				nh_vrf_id = VRF_DEFAULT;  			}  		} else @@ -557,13 +557,14 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,  	len = h->nlmsg_len - NLMSG_LENGTH(sizeof(struct rtmsg));  	if (len < 0) { -		zlog_err("%s: Message received from netlink is of a broken size %d %zu", -			 __PRETTY_FUNCTION__, h->nlmsg_len, -			 (size_t)NLMSG_LENGTH(sizeof(struct rtmsg))); +		zlog_err( +			"%s: Message received from netlink is of a broken size %d %zu", +			__func__, h->nlmsg_len, +			(size_t)NLMSG_LENGTH(sizeof(struct rtmsg)));  		return -1;  	} -	memset(tb, 0, sizeof tb); +	memset(tb, 0, sizeof(tb));  	netlink_parse_rtattr(tb, RTA_MAX, RTM_RTA(rtm), len);  	if (rtm->rtm_flags & RTM_F_CLONED) @@ -638,7 +639,7 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,  	if (tb[RTA_METRICS]) {  		struct rtattr *mxrta[RTAX_MAX + 1]; -		memset(mxrta, 0, sizeof mxrta); +		memset(mxrta, 0, sizeof(mxrta));  		netlink_parse_rtattr(mxrta, RTAX_MAX, RTA_DATA(tb[RTA_METRICS]),  				     RTA_PAYLOAD(tb[RTA_METRICS])); @@ -848,7 +849,7 @@ static int netlink_route_change_read_multicast(struct nlmsghdr *h,  	len = h->nlmsg_len - NLMSG_LENGTH(sizeof(struct rtmsg)); -	memset(tb, 0, sizeof tb); +	memset(tb, 0, sizeof(tb));  	netlink_parse_rtattr(tb, RTA_MAX, RTM_RTA(rtm), len);  	if (tb[RTA_TABLE]) @@ -951,10 +952,10 @@ int netlink_route_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)  	len = h->nlmsg_len - NLMSG_LENGTH(sizeof(struct rtmsg));  	if (len < 0) { -		zlog_err("%s: Message received from netlink is of a broken size: %d %zu", -			 __PRETTY_FUNCTION__, -			 h->nlmsg_len, -			 (size_t)NLMSG_LENGTH(sizeof(struct rtmsg))); +		zlog_err( +			"%s: Message received from netlink is of a broken size: %d %zu", +			__func__, h->nlmsg_len, +			(size_t)NLMSG_LENGTH(sizeof(struct rtmsg)));  		return -1;  	} @@ -2296,7 +2297,7 @@ static struct nexthop netlink_nexthop_process_nh(struct rtattr **tb,  		flog_warn(  			EC_ZEBRA_UNKNOWN_INTERFACE,  			"%s: Unknown nexthop interface %u received, defaulting to VRF_DEFAULT", -			__PRETTY_FUNCTION__, nh.ifindex); +			__func__, nh.ifindex);  		nh.vrf_id = VRF_DEFAULT;  	} @@ -2386,7 +2387,7 @@ int netlink_nexthop_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)  	if (len < 0) {  		zlog_warn(  			"%s: Message received from netlink is of a broken size %d %zu", -			__PRETTY_FUNCTION__, h->nlmsg_len, +			__func__, h->nlmsg_len,  			(size_t)NLMSG_LENGTH(sizeof(struct nhmsg)));  		return -1;  	} @@ -2606,7 +2607,7 @@ static int netlink_macfdb_change(struct nlmsghdr *h, int len, ns_id_t ns_id)  	if (!ifp || !ifp->info) {  		if (IS_ZEBRA_DEBUG_KERNEL)  			zlog_debug("\t%s without associated interface: %u", -				   __PRETTY_FUNCTION__, ndm->ndm_ifindex); +				   __func__, ndm->ndm_ifindex);  		return 0;  	} @@ -2614,7 +2615,7 @@ static int netlink_macfdb_change(struct nlmsghdr *h, int len, ns_id_t ns_id)  	if (!IS_ZEBRA_IF_BRIDGE_SLAVE(ifp)) {  		if (IS_ZEBRA_DEBUG_KERNEL)  			zlog_debug("\t%s Not interested in %s, not a slave", -				   __PRETTY_FUNCTION__, ifp->name); +				   __func__, ifp->name);  		return 0;  	} @@ -2622,7 +2623,7 @@ static int netlink_macfdb_change(struct nlmsghdr *h, int len, ns_id_t ns_id)  	if (ndm->ndm_state & NUD_PERMANENT) {  		if (IS_ZEBRA_DEBUG_KERNEL)  			zlog_debug("\t%s Entry is PERMANENT, dropping", -				   __PRETTY_FUNCTION__); +				   __func__);  		return 0;  	} @@ -2639,7 +2640,7 @@ static int netlink_macfdb_change(struct nlmsghdr *h, int len, ns_id_t ns_id)  	}  	/* Parse attributes and extract fields of interest. */ -	memset(tb, 0, sizeof tb); +	memset(tb, 0, sizeof(tb));  	netlink_parse_rtattr(tb, NDA_MAX, NDA_RTA(ndm), len);  	if (!tb[NDA_LLADDR]) { @@ -2871,8 +2872,7 @@ static int netlink_request_specific_mac_in_bridge(struct zebra_ns *zns,  	addattr32(&req.n, sizeof(req), NDA_MASTER, br_if->ifindex);  	if (IS_ZEBRA_DEBUG_KERNEL) -		zlog_debug("%s: Tx family %s IF %s(%u) MAC %s vid %u", -			   __PRETTY_FUNCTION__, +		zlog_debug("%s: Tx family %s IF %s(%u) MAC %s vid %u", __func__,  			   nl_family_to_str(req.ndm.ndm_family), br_if->name,  			   br_if->ifindex,  			   prefix_mac2str(mac, buf, sizeof(buf)), vid); @@ -3050,7 +3050,7 @@ static int netlink_ipneigh_change(struct nlmsghdr *h, int len, ns_id_t ns_id)  	zif = (struct zebra_if *)ifp->info;  	/* Parse attributes and extract fields of interest. */ -	memset(tb, 0, sizeof tb); +	memset(tb, 0, sizeof(tb));  	netlink_parse_rtattr(tb, NDA_MAX, NDA_RTA(ndm), len);  	if (!tb[NDA_DST]) { @@ -3303,10 +3303,8 @@ int netlink_neigh_read_specific_ip(struct ipaddr *ip,  	if (IS_ZEBRA_DEBUG_KERNEL)  		zlog_debug("%s: neigh request IF %s(%u) IP %s vrf_id %u", -			   __PRETTY_FUNCTION__, vlan_if->name, -			   vlan_if->ifindex, -			   ipaddr2str(ip, buf, sizeof(buf)), -			   vlan_if->vrf_id); +			   __func__, vlan_if->name, vlan_if->ifindex, +			   ipaddr2str(ip, buf, sizeof(buf)), vlan_if->vrf_id);  	ret = netlink_request_specific_neigh_in_vlan(zns, RTM_GETNEIGH, ip,  					    vlan_if->ifindex); @@ -3330,9 +3328,10 @@ int netlink_neigh_change(struct nlmsghdr *h, ns_id_t ns_id)  	/* Length validity. */  	len = h->nlmsg_len - NLMSG_LENGTH(sizeof(struct ndmsg));  	if (len < 0) { -		zlog_err("%s: Message received from netlink is of a broken size %d %zu", -			 __PRETTY_FUNCTION__, h->nlmsg_len, -			 (size_t)NLMSG_LENGTH(sizeof(struct ndmsg))); +		zlog_err( +			"%s: Message received from netlink is of a broken size %d %zu", +			__func__, h->nlmsg_len, +			(size_t)NLMSG_LENGTH(sizeof(struct ndmsg)));  		return -1;  	} diff --git a/zebra/rtadv.c b/zebra/rtadv.c index 829dcfcfd2..60ac471b5a 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -130,7 +130,7 @@ static int rtadv_recv_packet(struct zebra_vrf *zvrf, int sock, uint8_t *buf,  	msg.msg_iov = &iov;  	msg.msg_iovlen = 1;  	msg.msg_control = (void *)adata; -	msg.msg_controllen = sizeof adata; +	msg.msg_controllen = sizeof(adata);  	iov.iov_base = buf;  	iov.iov_len = buflen; @@ -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) @@ -2425,7 +2438,7 @@ static int if_join_all_router(int sock, struct interface *ifp)  	mreq.ipv6mr_interface = ifp->ifindex;  	ret = setsockopt(sock, IPPROTO_IPV6, IPV6_JOIN_GROUP, (char *)&mreq, -			 sizeof mreq); +			 sizeof(mreq));  	if (ret < 0)  		flog_err_sys(EC_LIB_SOCKET,  			     "%s(%u): Failed to join group, socket %u error %s", @@ -2451,7 +2464,7 @@ static int if_leave_all_router(int sock, struct interface *ifp)  	mreq.ipv6mr_interface = ifp->ifindex;  	ret = setsockopt(sock, IPPROTO_IPV6, IPV6_LEAVE_GROUP, (char *)&mreq, -			 sizeof mreq); +			 sizeof(mreq));  	if (ret < 0)  		flog_err_sys(  			EC_LIB_SOCKET, diff --git a/zebra/rtread_getmsg.c b/zebra/rtread_getmsg.c index 3ba5d6ee73..28529cc138 100644 --- a/zebra/rtread_getmsg.c +++ b/zebra/rtread_getmsg.c @@ -231,7 +231,7 @@ void route_read(struct zebra_ns *zns)  				    != 0) {  					zlog_debug(  						"getmsg(data) returned " -						"msgdata.len = %d (%% sizeof (mib2_ipRouteEntry_t) != 0)", +						"msgdata.len = %d (%% sizeof(mib2_ipRouteEntry_t) != 0)",  						msgdata.len);  					goto exit;  				} diff --git a/zebra/rule_netlink.c b/zebra/rule_netlink.c index 2fdb215128..c9699c7d95 100644 --- a/zebra/rule_netlink.c +++ b/zebra/rule_netlink.c @@ -201,9 +201,10 @@ int netlink_rule_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)  	len = h->nlmsg_len - NLMSG_LENGTH(sizeof(struct fib_rule_hdr));  	if (len < 0) { -		zlog_err("%s: Message received from netlink is of a broken size: %d %zu", -			 __PRETTY_FUNCTION__, h->nlmsg_len, -			 (size_t)NLMSG_LENGTH(sizeof(struct fib_rule_hdr))); +		zlog_err( +			"%s: Message received from netlink is of a broken size: %d %zu", +			__func__, h->nlmsg_len, +			(size_t)NLMSG_LENGTH(sizeof(struct fib_rule_hdr)));  		return -1;  	} diff --git a/zebra/rule_socket.c b/zebra/rule_socket.c index c5660abf3a..e2c650b4ad 100644 --- a/zebra/rule_socket.c +++ b/zebra/rule_socket.c @@ -46,14 +46,14 @@  enum zebra_dplane_result kernel_add_pbr_rule(struct zebra_pbr_rule *rule)  {  	flog_err(EC_LIB_UNAVAILABLE, "%s not Implemented for this platform", -		 __PRETTY_FUNCTION__); +		 __func__);  	return ZEBRA_DPLANE_REQUEST_FAILURE;  }  enum zebra_dplane_result kernel_del_pbr_rule(struct zebra_pbr_rule *rule)  {  	flog_err(EC_LIB_UNAVAILABLE, "%s not Implemented for this platform", -		 __PRETTY_FUNCTION__); +		 __func__);  	return ZEBRA_DPLANE_REQUEST_FAILURE;  } diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index 6012962b1c..f372b548fc 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -580,7 +580,7 @@ int zsend_redistribute_route(int cmd, struct zserv *client,  		memcpy(&api.src_prefix, src_p, sizeof(api.src_prefix));  	} -	for (nexthop = re->nhe->nhg->nexthop; +	for (nexthop = re->nhe->nhg.nexthop;  	     nexthop; nexthop = nexthop->next) {  		if (!CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE))  			continue; @@ -689,7 +689,7 @@ static int zsend_ipv4_nexthop_lookup_mrib(struct zserv *client,  		 * nexthop we are looking up. Therefore, we will just iterate  		 * over the top chain of nexthops.  		 */ -		for (nexthop = re->nhe->nhg->nexthop; nexthop; +		for (nexthop = re->nhe->nhg.nexthop; nexthop;  		     nexthop = nexthop->next)  			if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE))  				num += zserv_encode_nexthop(s, nexthop); @@ -790,8 +790,7 @@ void zsend_rule_notify_owner(struct zebra_pbr_rule *rule,  	struct stream *s;  	if (IS_ZEBRA_DEBUG_PACKET) -		zlog_debug("%s: Notifying %u", __PRETTY_FUNCTION__, -			   rule->rule.unique); +		zlog_debug("%s: Notifying %u", __func__, rule->rule.unique);  	for (ALL_LIST_ELEMENTS_RO(zrouter.client_list, node, client)) {  		if (rule->sock == client->sock) @@ -823,8 +822,7 @@ void zsend_ipset_notify_owner(struct zebra_pbr_ipset *ipset,  	struct stream *s;  	if (IS_ZEBRA_DEBUG_PACKET) -		zlog_debug("%s: Notifying %u", __PRETTY_FUNCTION__, -			   ipset->unique); +		zlog_debug("%s: Notifying %u", __func__, ipset->unique);  	for (ALL_LIST_ELEMENTS_RO(zrouter.client_list, node, client)) {  		if (ipset->sock == client->sock) @@ -853,8 +851,7 @@ void zsend_ipset_entry_notify_owner(struct zebra_pbr_ipset_entry *ipset,  	struct stream *s;  	if (IS_ZEBRA_DEBUG_PACKET) -		zlog_debug("%s: Notifying %u", __PRETTY_FUNCTION__, -			   ipset->unique); +		zlog_debug("%s: Notifying %u", __func__, ipset->unique);  	for (ALL_LIST_ELEMENTS_RO(zrouter.client_list, node, client)) {  		if (ipset->sock == client->sock) @@ -883,8 +880,7 @@ void zsend_iptable_notify_owner(struct zebra_pbr_iptable *iptable,  	struct stream *s;  	if (IS_ZEBRA_DEBUG_PACKET) -		zlog_debug("%s: Notifying %u", __PRETTY_FUNCTION__, -			   iptable->unique); +		zlog_debug("%s: Notifying %u", __func__, iptable->unique);  	for (ALL_LIST_ELEMENTS_RO(zrouter.client_list, node, client)) {  		if (iptable->sock == client->sock) @@ -1086,7 +1082,7 @@ static void zread_rnh_register(ZAPI_HANDLER_ARGS)  			if (p.prefixlen > IPV4_MAX_BITLEN) {  				zlog_debug(  					"%s: Specified prefix hdr->length %d is too large for a v4 address", -					__PRETTY_FUNCTION__, p.prefixlen); +					__func__, p.prefixlen);  				return;  			}  			STREAM_GET(&p.u.prefix4.s_addr, s, IPV4_MAX_BYTELEN); @@ -1096,7 +1092,7 @@ static void zread_rnh_register(ZAPI_HANDLER_ARGS)  			if (p.prefixlen > IPV6_MAX_BITLEN) {  				zlog_debug(  					"%s: Specified prefix hdr->length %d is to large for a v6 address", -					__PRETTY_FUNCTION__, p.prefixlen); +					__func__, p.prefixlen);  				return;  			}  			STREAM_GET(&p.u.prefix6, s, IPV6_MAX_BYTELEN); @@ -1177,7 +1173,7 @@ static void zread_rnh_unregister(ZAPI_HANDLER_ARGS)  			if (p.prefixlen > IPV4_MAX_BITLEN) {  				zlog_debug(  					"%s: Specified prefix hdr->length %d is to large for a v4 address", -					__PRETTY_FUNCTION__, p.prefixlen); +					__func__, p.prefixlen);  				return;  			}  			STREAM_GET(&p.u.prefix4.s_addr, s, IPV4_MAX_BYTELEN); @@ -1187,7 +1183,7 @@ static void zread_rnh_unregister(ZAPI_HANDLER_ARGS)  			if (p.prefixlen > IPV6_MAX_BITLEN) {  				zlog_debug(  					"%s: Specified prefix hdr->length %d is to large for a v6 address", -					__PRETTY_FUNCTION__, p.prefixlen); +					__func__, p.prefixlen);  				return;  			}  			STREAM_GET(&p.u.prefix6, s, IPV6_MAX_BYTELEN); @@ -1255,7 +1251,7 @@ static void zread_fec_register(ZAPI_HANDLER_ARGS)  			&& p.prefixlen > IPV6_MAX_BITLEN)) {  			zlog_debug(  				"%s: Specified prefix hdr->length: %d is to long for %d", -				__PRETTY_FUNCTION__, p.prefixlen, p.family); +				__func__, p.prefixlen, p.family);  			return;  		}  		l += 5; @@ -1321,7 +1317,7 @@ static void zread_fec_unregister(ZAPI_HANDLER_ARGS)  			&& p.prefixlen > IPV6_MAX_BITLEN)) {  			zlog_debug(  				"%s: Received prefix hdr->length %d which is greater than %d can support", -				__PRETTY_FUNCTION__, p.prefixlen, p.family); +				__func__, p.prefixlen, p.family);  			return;  		}  		l += 5; @@ -1426,7 +1422,7 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)  	if (zapi_route_decode(s, &api) < 0) {  		if (IS_ZEBRA_DEBUG_RECV)  			zlog_debug("%s: Unable to decode zapi_route sent", -				   __PRETTY_FUNCTION__); +				   __func__);  		return;  	} @@ -1563,7 +1559,7 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)  			flog_warn(  				EC_ZEBRA_NEXTHOP_CREATION_FAILED,  				"%s: Nexthops Specified: %d but we failed to properly create one", -				__PRETTY_FUNCTION__, api.nexthop_num); +				__func__, api.nexthop_num);  			nexthop_group_delete(&ng);  			XFREE(MTYPE_RE, re);  			return; @@ -1612,7 +1608,7 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)  	if (afi != AFI_IP6 && CHECK_FLAG(api.message, ZAPI_MESSAGE_SRCPFX)) {  		flog_warn(EC_ZEBRA_RX_SRCDEST_WRONG_AFI,  			  "%s: Received SRC Prefix but afi is not v6", -			  __PRETTY_FUNCTION__); +			  __func__);  		nexthop_group_delete(&ng);  		XFREE(MTYPE_RE, re);  		return; @@ -1663,7 +1659,7 @@ static void zread_route_del(ZAPI_HANDLER_ARGS)  	if (afi != AFI_IP6 && CHECK_FLAG(api.message, ZAPI_MESSAGE_SRCPFX)) {  		flog_warn(EC_ZEBRA_RX_SRCDEST_WRONG_AFI,  			  "%s: Received a src prefix while afi is not v6", -			  __PRETTY_FUNCTION__); +			  __func__);  		return;  	}  	if (CHECK_FLAG(api.message, ZAPI_MESSAGE_SRCPFX)) @@ -1773,10 +1769,11 @@ static void zread_hello(ZAPI_HANDLER_ARGS)  		client->proto = proto;  		client->instance = instance; + +		/* Graceful restart processing for client connect */ +		zebra_gr_client_reconnect(client);  	} -	/* Graceful restart processing for client connect */ -	zebra_gr_client_reconnect(client);  	zsend_capabilities(client, zvrf);  	zebra_vrf_update_all(client);  stream_failure: @@ -1815,7 +1812,7 @@ static void zread_mpls_labels_add(ZAPI_HANDLER_ARGS)  	if (zapi_labels_decode(s, &zl) < 0) {  		if (IS_ZEBRA_DEBUG_RECV)  			zlog_debug("%s: Unable to decode zapi_labels sent", -				   __PRETTY_FUNCTION__); +				   __func__);  		return;  	} @@ -1826,7 +1823,9 @@ static void zread_mpls_labels_add(ZAPI_HANDLER_ARGS)  		struct zapi_nexthop *znh;  		znh = &zl.nexthops[i]; -		mpls_lsp_install(zvrf, zl.type, zl.local_label, 1, znh->labels, + +		mpls_lsp_install(zvrf, zl.type, zl.local_label, +				 znh->label_num, znh->labels,  				 znh->type, &znh->gate, znh->ifindex);  		if (CHECK_FLAG(zl.message, ZAPI_LABELS_FTN)) @@ -1857,7 +1856,7 @@ static void zread_mpls_labels_delete(ZAPI_HANDLER_ARGS)  	if (zapi_labels_decode(s, &zl) < 0) {  		if (IS_ZEBRA_DEBUG_RECV)  			zlog_debug("%s: Unable to decode zapi_labels sent", -				   __PRETTY_FUNCTION__); +				   __func__);  		return;  	} @@ -1912,7 +1911,7 @@ static void zread_mpls_labels_replace(ZAPI_HANDLER_ARGS)  	if (zapi_labels_decode(s, &zl) < 0) {  		if (IS_ZEBRA_DEBUG_RECV)  			zlog_debug("%s: Unable to decode zapi_labels sent", -				   __PRETTY_FUNCTION__); +				   __func__);  		return;  	} @@ -1929,7 +1928,7 @@ static void zread_mpls_labels_replace(ZAPI_HANDLER_ARGS)  		znh = &zl.nexthops[i];  		mpls_lsp_install(zvrf, zl.type, zl.local_label, -				 1, znh->labels, znh->type, +				 znh->label_num, znh->labels, znh->type,  				 &znh->gate, znh->ifindex);  		if (CHECK_FLAG(zl.message, ZAPI_LABELS_FTN)) { diff --git a/zebra/zebra_dplane.c b/zebra/zebra_dplane.c index 17b148178f..5d0d0a48c3 100644 --- a/zebra/zebra_dplane.c +++ b/zebra/zebra_dplane.c @@ -1513,9 +1513,9 @@ static int dplane_ctx_route_init(struct zebra_dplane_ctx *ctx,  	/* Copy nexthops; recursive info is included too */  	copy_nexthops(&(ctx->u.rinfo.zd_ng.nexthop), -		      re->nhe->nhg->nexthop, NULL); +		      re->nhe->nhg.nexthop, NULL); -	/* Ensure that the dplane's nexthops flags are clear. */ +	/* Ensure that the dplane nexthops' flags are clear. */  	for (ALL_NEXTHOPS(ctx->u.rinfo.zd_ng, nexthop))  		UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB); @@ -1596,9 +1596,9 @@ static int dplane_ctx_nexthop_init(struct zebra_dplane_ctx *ctx,  	ctx->u.rinfo.nhe.vrf_id = nhe->vrf_id;  	ctx->u.rinfo.nhe.type = nhe->type; -	nexthop_group_copy(&(ctx->u.rinfo.nhe.ng), nhe->nhg); +	nexthop_group_copy(&(ctx->u.rinfo.nhe.ng), &(nhe->nhg)); -	/* If its a group, convert it to a grp array of ids */ +	/* If this is a group, convert it to a grp array of ids */  	if (!zebra_nhg_depends_is_empty(nhe)  	    && !CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_RECURSIVE))  		ctx->u.rinfo.nhe.nh_grp_count = zebra_nhg_nhe2grp( @@ -1753,7 +1753,7 @@ static int dplane_ctx_pw_init(struct zebra_dplane_ctx *ctx,  			if (re)  				copy_nexthops(&(ctx->u.pw.nhg.nexthop), -					      re->nhe->nhg->nexthop, NULL); +					      re->nhe->nhg.nexthop, NULL);  			route_unlock_node(rn);  		} @@ -1849,7 +1849,7 @@ dplane_route_update_internal(struct route_node *rn,  			 * We'll need these to do per-nexthop deletes.  			 */  			copy_nexthops(&(ctx->u.rinfo.zd_old_ng.nexthop), -				      old_re->nhe->nhg->nexthop, NULL); +				      old_re->nhe->nhg.nexthop, NULL);  #endif	/* !HAVE_NETLINK */  		} diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c index fa48c03c71..0190ee2b8d 100644 --- a/zebra/zebra_fpm.c +++ b/zebra/zebra_fpm.c @@ -70,7 +70,7 @@ DEFINE_MTYPE_STATIC(ZEBRA, FPM_MAC_INFO, "FPM_MAC_INFO");  #define ZFPM_STATS_IVL_SECS        10  #define FPM_MAX_MAC_MSG_LEN 512 -static void zfpm_iterate_rmac_table(struct hash_backet *backet, void *args); +static void zfpm_iterate_rmac_table(struct hash_bucket *backet, void *args);  /*   * Structure that holds state for iterating over all route_node @@ -1647,7 +1647,7 @@ static int zfpm_trigger_rmac_update(zebra_mac_t *rmac, zebra_l3vni_t *zl3vni,   * Iterate over all the RMAC entries for the given L3VNI   * and enqueue the RMAC for FPM processing.   */ -static void zfpm_trigger_rmac_update_wrapper(struct hash_backet *backet, +static void zfpm_trigger_rmac_update_wrapper(struct hash_bucket *backet,  					     void *args)  {  	zebra_mac_t *zrmac = (zebra_mac_t *)backet->data; @@ -1661,7 +1661,7 @@ static void zfpm_trigger_rmac_update_wrapper(struct hash_backet *backet,   * This function iterates over all the L3VNIs to trigger   * FPM updates for RMACs currently available.   */ -static void zfpm_iterate_rmac_table(struct hash_backet *backet, void *args) +static void zfpm_iterate_rmac_table(struct hash_bucket *backet, void *args)  {  	zebra_l3vni_t *zl3vni = (zebra_l3vni_t *)backet->data; diff --git a/zebra/zebra_fpm_dt.c b/zebra/zebra_fpm_dt.c index 389781d4f7..81437e72f5 100644 --- a/zebra/zebra_fpm_dt.c +++ b/zebra/zebra_fpm_dt.c @@ -90,7 +90,7 @@ static int zfpm_dt_find_route(rib_dest_t **dest_p, struct route_entry **re_p)  		if (!re)  			continue; -		if (nexthop_group_active_nexthop_num(re->nhe->nhg) == 0) +		if (nexthop_group_active_nexthop_num(&(re->nhe->nhg)) == 0)  			continue;  		*dest_p = dest; diff --git a/zebra/zebra_fpm_netlink.c b/zebra/zebra_fpm_netlink.c index be29b75aea..0d6428026a 100644 --- a/zebra/zebra_fpm_netlink.c +++ b/zebra/zebra_fpm_netlink.c @@ -300,8 +300,7 @@ static int netlink_route_info_fill(netlink_route_info_t *ri, int cmd,  		return 1;  	if (!re) { -		zfpm_debug("%s: Expected non-NULL re pointer", -			   __PRETTY_FUNCTION__); +		zfpm_debug("%s: Expected non-NULL re pointer", __func__);  		return 0;  	} @@ -309,7 +308,7 @@ static int netlink_route_info_fill(netlink_route_info_t *ri, int cmd,  	ri->rtm_type = RTN_UNICAST;  	ri->metric = &re->metric; -	for (ALL_NEXTHOPS_PTR(re->nhe->nhg, nexthop)) { +	for (ALL_NEXTHOPS(re->nhe->nhg, nexthop)) {  		if (ri->num_nhs >= zrouter.multipath_num)  			break; @@ -570,7 +569,7 @@ int zfpm_netlink_encode_route(int cmd, rib_dest_t *dest, struct route_entry *re,  	if (!netlink_route_info_fill(ri, cmd, dest, re))  		return 0; -	zfpm_log_route_info(ri, __FUNCTION__); +	zfpm_log_route_info(ri, __func__);  	return netlink_route_info_encode(ri, in_buf, in_buf_len);  } diff --git a/zebra/zebra_fpm_protobuf.c b/zebra/zebra_fpm_protobuf.c index d50981debf..ade4b636d6 100644 --- a/zebra/zebra_fpm_protobuf.c +++ b/zebra/zebra_fpm_protobuf.c @@ -173,7 +173,7 @@ static Fpm__AddRoute *create_add_route_message(qpb_allocator_t *allocator,  	 * Figure out the set of nexthops to be added to the message.  	 */  	num_nhs = 0; -	for (ALL_NEXTHOPS_PTR(re->nhe->nhg, nexthop)) { +	for (ALL_NEXTHOPS(re->nhe->nhg, nexthop)) {  		if (num_nhs >= zrouter.multipath_num)  			break; diff --git a/zebra/zebra_gr.c b/zebra/zebra_gr.c index 956fe9c2c8..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)); @@ -265,30 +264,31 @@ void zebra_gr_client_reconnect(struct zserv *client)  	}  	/* Copy the timers */ -	if (old_client) { -		client->gr_instance_count = old_client->gr_instance_count; -		client->restart_time = old_client->restart_time; - -		LOG_GR("%s : old client %s, gr_instance_count %d", __func__, -		       zebra_route_string(old_client->proto), -		       old_client->gr_instance_count); - -		if (TAILQ_FIRST(&old_client->gr_info_queue)) { -			TAILQ_CONCAT(&client->gr_info_queue, -				     &old_client->gr_info_queue, gr_info); -			TAILQ_INIT(&old_client->gr_info_queue); -		} +	if (!old_client) +		return; -		TAILQ_FOREACH (info, &client->gr_info_queue, gr_info) { -			info->stale_client_ptr = client; -			info->stale_client = false; -		} +	client->gr_instance_count = old_client->gr_instance_count; +	client->restart_time = old_client->restart_time; + +	LOG_GR("%s : old client %s, gr_instance_count %d", __func__, +	       zebra_route_string(old_client->proto), +	       old_client->gr_instance_count); -		/* Delete the stale client */ -		listnode_delete(zrouter.stale_client_list, old_client); -		/* Delete old client */ -		XFREE(MTYPE_TMP, old_client); +	if (TAILQ_FIRST(&old_client->gr_info_queue)) { +		TAILQ_CONCAT(&client->gr_info_queue, &old_client->gr_info_queue, +			     gr_info); +		TAILQ_INIT(&old_client->gr_info_queue);  	} + +	TAILQ_FOREACH (info, &client->gr_info_queue, gr_info) { +		info->stale_client_ptr = client; +		info->stale_client = false; +	} + +	/* Delete the stale client */ +	listnode_delete(zrouter.stale_client_list, old_client); +	/* Delete old client */ +	XFREE(MTYPE_TMP, old_client);  }  /* @@ -425,6 +425,12 @@ void zread_client_capabilities(ZAPI_HANDLER_ARGS)  		return;  	} +	/* GR only for dynamic clients */ +	if (client->proto <= ZEBRA_ROUTE_CONNECT) { +		LOG_GR("%s: GR capabilities for client %s not supported", +		       __func__, zebra_route_string(client->proto)); +		return; +	}  	/* Call the capabilities handler */  	zebra_client_capabilities_handler(client, &api);  } diff --git a/zebra/zebra_mlag.c b/zebra/zebra_mlag.c index fc7804a409..cf2fe26489 100644 --- a/zebra/zebra_mlag.c +++ b/zebra/zebra_mlag.c @@ -605,7 +605,7 @@ int32_t zebra_mlag_test_mlag_internal(const char *none, const char *primary,  		zsend_capabilities_all_clients();  		if (zrouter.mlag_info.role != MLAG_ROLE_NONE) {  			if (zrouter.mlag_info.clients_interested_cnt == 0 -			    && test_mlag_in_progress == false) { +			    && !test_mlag_in_progress) {  				if (zrouter.mlag_info.zebra_pth_mlag == NULL)  					zebra_mlag_spawn_pthread();  				zrouter.mlag_info.clients_interested_cnt++; @@ -613,7 +613,7 @@ int32_t zebra_mlag_test_mlag_internal(const char *none, const char *primary,  				hook_call(zebra_mlag_private_open_channel);  			}  		} else { -			if (test_mlag_in_progress == true) { +			if (test_mlag_in_progress) {  				test_mlag_in_progress = false;  				zrouter.mlag_info.clients_interested_cnt--;  				hook_call(zebra_mlag_private_close_channel); @@ -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; @@ -790,13 +794,21 @@ int zebra_mlag_protobuf_encode_client_data(struct stream *s, uint32_t *msg_type)  					vrf_name_len);  			}  		} -		if (cleanup == false) { +		if (!cleanup) {  			Bulk_msg.mroute_add = pay_load;  			len = zebra_mlag_mroute_add_bulk__pack(&Bulk_msg,  							       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) @@ -804,7 +816,7 @@ int zebra_mlag_protobuf_encode_client_data(struct stream *s, uint32_t *msg_type)  			XFREE(MTYPE_MLAG_PBUF, pay_load[i]);  		}  		XFREE(MTYPE_MLAG_PBUF, pay_load); -		if (cleanup == true) +		if (cleanup)  			return -1;  	} break;  	case MLAG_MROUTE_DEL_BULK: { @@ -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_mpls.c b/zebra/zebra_mpls.c index c167e6a8ad..d373fdf370 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -93,6 +93,8 @@ static void lsp_processq_del(struct work_queue *wq, void *data);  static void lsp_processq_complete(struct work_queue *wq);  static int lsp_processq_add(zebra_lsp_t *lsp);  static void *lsp_alloc(void *p); +/* Free lsp; sets caller's pointer to NULL */ +static void lsp_free(struct hash *lsp_table, zebra_lsp_t **plsp);  static char *nhlfe2str(zebra_nhlfe_t *nhlfe, char *buf, int size);  static int nhlfe_nhop_match(zebra_nhlfe_t *nhlfe, enum nexthop_types_t gtype, @@ -186,7 +188,7 @@ static int lsp_install(struct zebra_vrf *zvrf, mpls_label_t label,  	 * the label advertised by the recursive nexthop (plus we don't have the  	 * logic yet to push multiple labels).  	 */ -	for (nexthop = re->nhe->nhg->nexthop; +	for (nexthop = re->nhe->nhg.nexthop;  	     nexthop; nexthop = nexthop->next) {  		/* Skip inactive and recursive entries. */  		if (!CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE)) @@ -250,14 +252,8 @@ static int lsp_install(struct zebra_vrf *zvrf, mpls_label_t label,  		if (lsp_processq_add(lsp))  			return -1;  	} else if (!lsp->nhlfe_list -		   && !CHECK_FLAG(lsp->flags, LSP_FLAG_SCHEDULED)) { -		if (IS_ZEBRA_DEBUG_MPLS) -			zlog_debug("Free LSP in-label %u flags 0x%x", -				   lsp->ile.in_label, lsp->flags); - -		lsp = hash_release(lsp_table, &lsp->ile); -		XFREE(MTYPE_LSP, lsp); -	} +		   && !CHECK_FLAG(lsp->flags, LSP_FLAG_SCHEDULED)) +		lsp_free(lsp_table, &lsp);  	return 0;  } @@ -313,14 +309,8 @@ static int lsp_uninstall(struct zebra_vrf *zvrf, mpls_label_t label)  		if (lsp_processq_add(lsp))  			return -1;  	} else if (!lsp->nhlfe_list -		   && !CHECK_FLAG(lsp->flags, LSP_FLAG_SCHEDULED)) { -		if (IS_ZEBRA_DEBUG_MPLS) -			zlog_debug("Del LSP in-label %u flags 0x%x", -				   lsp->ile.in_label, lsp->flags); - -		lsp = hash_release(lsp_table, &lsp->ile); -		XFREE(MTYPE_LSP, lsp); -	} +		   && !CHECK_FLAG(lsp->flags, LSP_FLAG_SCHEDULED)) +		lsp_free(lsp_table, &lsp);  	return 0;  } @@ -638,7 +628,7 @@ static int nhlfe_nexthop_active_ipv4(zebra_nhlfe_t *nhlfe,  		    || !CHECK_FLAG(match->flags, ZEBRA_FLAG_SELECTED))  			continue; -		for (match_nh = match->nhe->nhg->nexthop; match_nh; +		for (match_nh = match->nhe->nhg.nexthop; match_nh;  		     match_nh = match_nh->next) {  			if (match->type == ZEBRA_ROUTE_CONNECT  			    || nexthop->ifindex == match_nh->ifindex) { @@ -689,10 +679,10 @@ static int nhlfe_nexthop_active_ipv6(zebra_nhlfe_t *nhlfe,  			break;  	} -	if (!match || !match->nhe->nhg->nexthop) +	if (!match || !match->nhe->nhg.nexthop)  		return 0; -	nexthop->ifindex = match->nhe->nhg->nexthop->ifindex; +	nexthop->ifindex = match->nhe->nhg.nexthop->ifindex;  	return 1;  } @@ -1047,14 +1037,8 @@ static void lsp_processq_del(struct work_queue *wq, void *data)  			nhlfe_del(nhlfe);  	} -	if (!lsp->nhlfe_list) { -		if (IS_ZEBRA_DEBUG_MPLS) -			zlog_debug("Free LSP in-label %u flags 0x%x", -				   lsp->ile.in_label, lsp->flags); - -		lsp = hash_release(lsp_table, &lsp->ile); -		XFREE(MTYPE_LSP, lsp); -	} +	if (!lsp->nhlfe_list) +		lsp_free(lsp_table, &lsp);  }  /* @@ -1104,6 +1088,37 @@ static void *lsp_alloc(void *p)  }  /* + * Dtor for an LSP: remove from ile hash, release any internal allocations, + * free LSP object. + */ +static void lsp_free(struct hash *lsp_table, zebra_lsp_t **plsp) +{ +	zebra_lsp_t *lsp; +	zebra_nhlfe_t *nhlfe, *nhlfe_next; + +	if (plsp == NULL || *plsp == NULL) +		return; + +	lsp = *plsp; + +	if (IS_ZEBRA_DEBUG_MPLS) +		zlog_debug("Free LSP in-label %u flags 0x%x", +			   lsp->ile.in_label, lsp->flags); + +	/* Free nhlfes, if any. */ +	for (nhlfe = lsp->nhlfe_list; nhlfe; nhlfe = nhlfe_next) { +		nhlfe_next = nhlfe->next; + +		nhlfe_del(nhlfe); +	} + +	hash_release(lsp_table, &lsp->ile); +	XFREE(MTYPE_LSP, lsp); + +	*plsp = NULL; +} + +/*   * Create printable string for NHLFE entry.   */  static char *nhlfe2str(zebra_nhlfe_t *nhlfe, char *buf, int size) @@ -1334,14 +1349,8 @@ static int mpls_lsp_uninstall_all(struct hash *lsp_table, zebra_lsp_t *lsp,  		if (lsp_processq_add(lsp))  			return -1;  	} else if (!lsp->nhlfe_list -		   && !CHECK_FLAG(lsp->flags, LSP_FLAG_SCHEDULED)) { -		if (IS_ZEBRA_DEBUG_MPLS) -			zlog_debug("Free LSP in-label %u flags 0x%x", -				   lsp->ile.in_label, lsp->flags); - -		lsp = hash_release(lsp_table, &lsp->ile); -		XFREE(MTYPE_LSP, lsp); -	} +		   && !CHECK_FLAG(lsp->flags, LSP_FLAG_SCHEDULED)) +		lsp_free(lsp_table, &lsp);  	return 0;  } @@ -2631,7 +2640,7 @@ int mpls_ftn_update(int add, struct zebra_vrf *zvrf, enum lsp_types_t type,  	 * We can't just change the values here since we are hashing  	 * on labels. We need to create a whole new group  	 */ -	nexthop_group_copy(&new_grp, re->nhe->nhg); +	nexthop_group_copy(&new_grp, &(re->nhe->nhg));  	found = false;  	for (nexthop = new_grp.nexthop; nexthop; nexthop = nexthop->next) { @@ -2712,7 +2721,7 @@ int mpls_ftn_uninstall(struct zebra_vrf *zvrf, enum lsp_types_t type,  	if (re == NULL)  		return -1; -	nexthop_group_copy(&new_grp, re->nhe->nhg); +	nexthop_group_copy(&new_grp, &(re->nhe->nhg));  	for (nexthop = new_grp.nexthop; nexthop; nexthop = nexthop->next)  		nexthop_del_labels(nexthop); @@ -2872,14 +2881,9 @@ int mpls_lsp_uninstall(struct zebra_vrf *zvrf, enum lsp_types_t type,  		/* Free LSP entry if no other NHLFEs and not scheduled. */  		if (!lsp->nhlfe_list -		    && !CHECK_FLAG(lsp->flags, LSP_FLAG_SCHEDULED)) { -			if (IS_ZEBRA_DEBUG_MPLS) -				zlog_debug("Free LSP in-label %u flags 0x%x", -					   lsp->ile.in_label, lsp->flags); +		    && !CHECK_FLAG(lsp->flags, LSP_FLAG_SCHEDULED)) +			lsp_free(lsp_table, &lsp); -			lsp = hash_release(lsp_table, &lsp->ile); -			XFREE(MTYPE_LSP, lsp); -		}  	}  	return 0;  } @@ -2949,7 +2953,7 @@ static void mpls_ftn_uninstall_all(struct zebra_vrf *zvrf,  		RNODE_FOREACH_RE (rn, re) {  			struct nexthop_group new_grp = {}; -			nexthop_group_copy(&new_grp, re->nhe->nhg); +			nexthop_group_copy(&new_grp, &(re->nhe->nhg));  			for (nexthop = new_grp.nexthop; nexthop;  			     nexthop = nexthop->next) { diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index bb95e72382..fcd90c23e8 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -315,20 +315,20 @@ zebra_nhg_connect_depends(struct nhg_hash_entry *nhe,  	}  	/* Add the ifp now if its not a group or recursive and has ifindex */ -	if (zebra_nhg_depends_is_empty(nhe) && nhe->nhg->nexthop -	    && nhe->nhg->nexthop->ifindex) { +	if (zebra_nhg_depends_is_empty(nhe) && nhe->nhg.nexthop +	    && nhe->nhg.nexthop->ifindex) {  		struct interface *ifp = NULL; -		ifp = if_lookup_by_index(nhe->nhg->nexthop->ifindex, -					 nhe->nhg->nexthop->vrf_id); +		ifp = if_lookup_by_index(nhe->nhg.nexthop->ifindex, +					 nhe->nhg.nexthop->vrf_id);  		if (ifp)  			zebra_nhg_set_if(nhe, ifp);  		else  			flog_err(  				EC_ZEBRA_IF_LOOKUP_FAILED,  				"Zebra failed to lookup an interface with ifindex=%d in vrf=%u for NHE id=%u", -				nhe->nhg->nexthop->ifindex, -				nhe->nhg->nexthop->vrf_id, nhe->id); +				nhe->nhg.nexthop->ifindex, +				nhe->nhg.nexthop->vrf_id, nhe->id);  	}  } @@ -350,8 +350,7 @@ static struct nhg_hash_entry *zebra_nhg_copy(const struct nhg_hash_entry *copy,  	nhe->id = id; -	nhe->nhg = nexthop_group_new(); -	nexthop_group_copy(nhe->nhg, copy->nhg); +	nexthop_group_copy(&(nhe->nhg), &(copy->nhg));  	nhe->vrf_id = copy->vrf_id;  	nhe->afi = copy->afi; @@ -371,7 +370,7 @@ static void *zebra_nhg_hash_alloc(void *arg)  	nhe = zebra_nhg_copy(copy, copy->id);  	/* Mark duplicate nexthops in a group at creation time. */ -	nexthop_group_mark_duplicates(nhe->nhg); +	nexthop_group_mark_duplicates(&(nhe->nhg));  	zebra_nhg_connect_depends(nhe, copy->nhg_depends);  	zebra_nhg_insert_id(nhe); @@ -385,7 +384,8 @@ uint32_t zebra_nhg_hash_key(const void *arg)  	uint32_t key = 0x5a351234; -	key = jhash_3words(nhe->vrf_id, nhe->afi, nexthop_group_hash(nhe->nhg), +	key = jhash_3words(nhe->vrf_id, nhe->afi, +			   nexthop_group_hash(&(nhe->nhg)),  			   key);  	return key; @@ -416,7 +416,7 @@ bool zebra_nhg_hash_equal(const void *arg1, const void *arg2)  		return false;  	/* Nexthops should be sorted */ -	for (nexthop1 = nhe1->nhg->nexthop, nexthop2 = nhe2->nhg->nexthop; +	for (nexthop1 = nhe1->nhg.nexthop, nexthop2 = nhe2->nhg.nexthop;  	     nexthop1 || nexthop2;  	     nexthop1 = nexthop1->next, nexthop2 = nexthop2->next) {  		if (nexthop1 && !nexthop2) @@ -498,7 +498,7 @@ static int zebra_nhg_process_grp(struct nexthop_group *nhg,  		 * in the kernel.  		 */ -		copy_nexthops(&nhg->nexthop, depend->nhg->nexthop, NULL); +		copy_nexthops(&nhg->nexthop, depend->nhg.nexthop, NULL);  	}  	return 0; @@ -536,14 +536,14 @@ static bool zebra_nhg_find(struct nhg_hash_entry **nhe, uint32_t id,  	lookup.id = id ? id : ++id_counter;  	lookup.type = type ? type : ZEBRA_ROUTE_NHG; -	lookup.nhg = nhg; +	lookup.nhg = *nhg;  	lookup.vrf_id = vrf_id; -	if (lookup.nhg->nexthop->next) { +	if (lookup.nhg.nexthop->next) {  		/* Groups can have all vrfs and AF's in them */  		lookup.afi = AFI_UNSPEC;  	} else { -		switch (lookup.nhg->nexthop->type) { +		switch (lookup.nhg.nexthop->type) {  		case (NEXTHOP_TYPE_IFINDEX):  		case (NEXTHOP_TYPE_BLACKHOLE):  			/* @@ -1193,12 +1193,6 @@ zebra_nhg_rib_find(uint32_t id, struct nexthop_group *nhg, afi_t rt_afi)  	assert(nhg->nexthop);  	vrf_id = !vrf_is_backend_netns() ? VRF_DEFAULT : nhg->nexthop->vrf_id; -	if (!(nhg && nhg->nexthop)) { -		flog_err(EC_ZEBRA_TABLE_LOOKUP_FAILED, -			 "No nexthop passed to %s", __func__); -		return NULL; -	} -  	zebra_nhg_find(&nhe, id, nhg, NULL, vrf_id, rt_afi, 0);  	return nhe; @@ -1206,7 +1200,8 @@ zebra_nhg_rib_find(uint32_t id, struct nexthop_group *nhg, afi_t rt_afi)  static void zebra_nhg_free_members(struct nhg_hash_entry *nhe)  { -	nexthop_group_delete(&nhe->nhg); +	nexthops_free(nhe->nhg.nexthop); +  	/* Decrement to remove connection ref */  	nhg_connected_tree_decrement_ref(&nhe->nhg_depends);  	nhg_connected_tree_free(&nhe->nhg_depends); @@ -1417,7 +1412,7 @@ static int nexthop_active(afi_t afi, struct route_entry *re,  			if (IS_ZEBRA_DEBUG_RIB_DETAILED)  				zlog_debug(  					"\t%s: Onlink and interface: %u[%u] does not exist", -					__PRETTY_FUNCTION__, nexthop->ifindex, +					__func__, nexthop->ifindex,  					nexthop->vrf_id);  			return 0;  		} @@ -1428,14 +1423,14 @@ static int nexthop_active(afi_t afi, struct route_entry *re,  			if (IS_ZEBRA_DEBUG_RIB_DETAILED)  				zlog_debug(  					"\t%s: Onlink and interface %s is not operative", -					__PRETTY_FUNCTION__, ifp->name); +					__func__, ifp->name);  			return 0;  		}  		if (!if_is_operative(ifp)) {  			if (IS_ZEBRA_DEBUG_RIB_DETAILED)  				zlog_debug(  					"\t%s: Interface %s is not unnumbered", -					__PRETTY_FUNCTION__, ifp->name); +					__func__, ifp->name);  			return 0;  		}  	} @@ -1447,7 +1442,7 @@ static int nexthop_active(afi_t afi, struct route_entry *re,  		if (IS_ZEBRA_DEBUG_RIB_DETAILED)  			zlog_debug(  				"\t:%s: Attempting to install a max prefixlength route through itself", -				__PRETTY_FUNCTION__); +				__func__);  		return 0;  	} @@ -1474,8 +1469,7 @@ static int nexthop_active(afi_t afi, struct route_entry *re,  	zvrf = zebra_vrf_lookup_by_id(nexthop->vrf_id);  	if (!table || !zvrf) {  		if (IS_ZEBRA_DEBUG_RIB_DETAILED) -			zlog_debug("\t%s: Table not found", -				   __PRETTY_FUNCTION__); +			zlog_debug("\t%s: Table not found", __func__);  		return 0;  	} @@ -1494,7 +1488,7 @@ static int nexthop_active(afi_t afi, struct route_entry *re,  				if (IS_ZEBRA_DEBUG_RIB_DETAILED)  					zlog_debug(  						"\t%s: Matched against ourself and prefix length is not max bit length", -						__PRETTY_FUNCTION__); +						__func__);  				return 0;  			} @@ -1507,7 +1501,7 @@ static int nexthop_active(afi_t afi, struct route_entry *re,  			if (IS_ZEBRA_DEBUG_RIB_DETAILED)  				zlog_debug(  					"\t:%s: Resolved against default route", -					__PRETTY_FUNCTION__); +					__func__);  			return 0;  		} @@ -1533,7 +1527,7 @@ static int nexthop_active(afi_t afi, struct route_entry *re,  		if (match->type == ZEBRA_ROUTE_CONNECT) {  			/* Directly point connected route. */ -			newhop = match->nhe->nhg->nexthop; +			newhop = match->nhe->nhg.nexthop;  			if (newhop) {  				if (nexthop->type == NEXTHOP_TYPE_IPV4  				    || nexthop->type == NEXTHOP_TYPE_IPV6) @@ -1542,7 +1536,7 @@ static int nexthop_active(afi_t afi, struct route_entry *re,  			return 1;  		} else if (CHECK_FLAG(re->flags, ZEBRA_FLAG_ALLOW_RECURSION)) {  			resolved = 0; -			for (ALL_NEXTHOPS_PTR(match->nhe->nhg, newhop)) { +			for (ALL_NEXTHOPS(match->nhe->nhg, newhop)) {  				if (!CHECK_FLAG(match->status,  						ROUTE_ENTRY_INSTALLED))  					continue; @@ -1559,11 +1553,11 @@ static int nexthop_active(afi_t afi, struct route_entry *re,  			if (!resolved && IS_ZEBRA_DEBUG_RIB_DETAILED)  				zlog_debug("\t%s: Recursion failed to find", -					   __PRETTY_FUNCTION__); +					   __func__);  			return resolved;  		} else if (re->type == ZEBRA_ROUTE_STATIC) {  			resolved = 0; -			for (ALL_NEXTHOPS_PTR(match->nhe->nhg, newhop)) { +			for (ALL_NEXTHOPS(match->nhe->nhg, newhop)) {  				if (!CHECK_FLAG(match->status,  						ROUTE_ENTRY_INSTALLED))  					continue; @@ -1581,14 +1575,13 @@ static int nexthop_active(afi_t afi, struct route_entry *re,  			if (!resolved && IS_ZEBRA_DEBUG_RIB_DETAILED)  				zlog_debug(  					"\t%s: Static route unable to resolve", -					__PRETTY_FUNCTION__); +					__func__);  			return resolved;  		} else {  			if (IS_ZEBRA_DEBUG_RIB_DETAILED) {  				zlog_debug(  					"\t%s: Route Type %s has not turned on recursion", -					__PRETTY_FUNCTION__, -					zebra_route_string(re->type)); +					__func__, zebra_route_string(re->type));  				if (re->type == ZEBRA_ROUTE_BGP  				    && !CHECK_FLAG(re->flags, ZEBRA_FLAG_IBGP))  					zlog_debug( @@ -1598,8 +1591,7 @@ static int nexthop_active(afi_t afi, struct route_entry *re,  		}  	}  	if (IS_ZEBRA_DEBUG_RIB_DETAILED) -		zlog_debug("\t%s: Nexthop did not lookup in table", -			   __PRETTY_FUNCTION__); +		zlog_debug("\t%s: Nexthop did not lookup in table", __func__);  	return 0;  } @@ -1636,7 +1628,16 @@ static unsigned nexthop_active_check(struct route_node *rn,  	switch (nexthop->type) {  	case NEXTHOP_TYPE_IFINDEX:  		ifp = if_lookup_by_index(nexthop->ifindex, nexthop->vrf_id); -		if (ifp && if_is_operative(ifp)) +		/* +		 * If the interface exists and its operative or its a kernel +		 * route and interface is up, its active. We trust kernel routes +		 * to be good. +		 */ +		if (ifp +		    && (if_is_operative(ifp) +			|| (if_is_up(ifp) +			    && (re->type == ZEBRA_ROUTE_KERNEL +				|| re->type == ZEBRA_ROUTE_SYSTEM))))  			SET_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE);  		else  			UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE); @@ -1683,7 +1684,7 @@ static unsigned nexthop_active_check(struct route_node *rn,  	if (!CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE)) {  		if (IS_ZEBRA_DEBUG_RIB_DETAILED)  			zlog_debug("\t%s: Unable to find a active nexthop", -				   __PRETTY_FUNCTION__); +				   __func__);  		return 0;  	} @@ -1712,7 +1713,7 @@ static unsigned nexthop_active_check(struct route_node *rn,  	zvrf = zebra_vrf_lookup_by_id(nexthop->vrf_id);  	if (!zvrf) {  		if (IS_ZEBRA_DEBUG_RIB_DETAILED) -			zlog_debug("\t%s: zvrf is NULL", __PRETTY_FUNCTION__); +			zlog_debug("\t%s: zvrf is NULL", __func__);  		return CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE);  	} @@ -1754,7 +1755,7 @@ int nexthop_active_update(struct route_node *rn, struct route_entry *re)  	UNSET_FLAG(re->status, ROUTE_ENTRY_CHANGED);  	/* Copy over the nexthops in current state */ -	nexthop_group_copy(&new_grp, re->nhe->nhg); +	nexthop_group_copy(&new_grp, &(re->nhe->nhg));  	for (nexthop = new_grp.nexthop; nexthop; nexthop = nexthop->next) { @@ -1866,7 +1867,7 @@ uint8_t zebra_nhg_nhe2grp(struct nh_grp *grp, struct nhg_hash_entry *nhe,  		if (!duplicate) {  			grp[i].id = depend->id;  			/* We aren't using weights for anything right now */ -			grp[i].weight = depend->nhg->nexthop->weight; +			grp[i].weight = depend->nhg.nexthop->weight;  			i++;  		} diff --git a/zebra/zebra_nhg.h b/zebra/zebra_nhg.h index 4d001944b7..dc3a47c020 100644 --- a/zebra/zebra_nhg.h +++ b/zebra/zebra_nhg.h @@ -40,16 +40,15 @@ struct nh_grp {  PREDECL_RBTREE_UNIQ(nhg_connected_tree);  /* - * Hashtables contiaining entries found in `zebra_router`. + * Hashtables containing nhg entries is in `zebra_router`.   */ -  struct nhg_hash_entry {  	uint32_t id;  	afi_t afi;  	vrf_id_t vrf_id;  	int type; -	struct nexthop_group *nhg; +	struct nexthop_group nhg;  	/* If this is not a group, it  	 * will be a single nexthop diff --git a/zebra/zebra_pbr.c b/zebra/zebra_pbr.c index ff3907451b..6728567e6e 100644 --- a/zebra/zebra_pbr.c +++ b/zebra/zebra_pbr.c @@ -458,7 +458,7 @@ void zebra_pbr_del_rule(struct zebra_pbr_rule *rule)  		XFREE(MTYPE_TMP, lookup);  	} else  		zlog_debug("%s: Rule being deleted we know nothing about", -			   __PRETTY_FUNCTION__); +			   __func__);  }  static void zebra_pbr_cleanup_rules(struct hash_bucket *b, void *data) @@ -572,7 +572,7 @@ void zebra_pbr_destroy_ipset(struct zebra_pbr_ipset *ipset)  	} else  		zlog_debug(  			"%s: IPSet Entry being deleted we know nothing about", -			__PRETTY_FUNCTION__); +			__func__);  }  struct pbr_ipset_name_lookup { @@ -651,7 +651,7 @@ void zebra_pbr_del_ipset_entry(struct zebra_pbr_ipset_entry *ipset)  		XFREE(MTYPE_TMP, lookup);  	} else  		zlog_debug("%s: IPSet being deleted we know nothing about", -			   __PRETTY_FUNCTION__); +			   __func__);  }  static void *pbr_iptable_alloc_intern(void *arg) @@ -710,7 +710,7 @@ void zebra_pbr_del_iptable(struct zebra_pbr_iptable *iptable)  		XFREE(MTYPE_TMP, lookup);  	} else  		zlog_debug("%s: IPTable being deleted we know nothing about", -			   __PRETTY_FUNCTION__); +			   __func__);  }  /* diff --git a/zebra/zebra_ptm.c b/zebra/zebra_ptm.c index b80c9026a7..669cb2466f 100644 --- a/zebra/zebra_ptm.c +++ b/zebra/zebra_ptm.c @@ -390,7 +390,7 @@ static int zebra_ptm_socket_init(void)  	if (set_nonblocking(sock) < 0) {  		if (IS_ZEBRA_DEBUG_EVENT)  			zlog_debug("%s: Unable to set socket non blocking[%s]", -				   __PRETTY_FUNCTION__, safe_strerror(errno)); +				   __func__, safe_strerror(errno));  		close(sock);  		return -1;  	} diff --git a/zebra/zebra_pw.c b/zebra/zebra_pw.c index 618a232408..610a052c31 100644 --- a/zebra/zebra_pw.c +++ b/zebra/zebra_pw.c @@ -259,7 +259,7 @@ static int zebra_pw_check_reachability(struct zebra_pw *pw)  	 * Need to ensure that there's a label binding for all nexthops.  	 * Otherwise, ECMP for this route could render the pseudowire unusable.  	 */ -	for (ALL_NEXTHOPS_PTR(re->nhe->nhg, nexthop)) { +	for (ALL_NEXTHOPS(re->nhe->nhg, nexthop)) {  		if (!nexthop->nh_label) {  			if (IS_ZEBRA_DEBUG_PW)  				zlog_debug("%s: unlabeled route for %s", diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 7f919e47e1..29d59b515f 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -198,8 +198,8 @@ int zebra_check_addr(const struct prefix *p)   */  void route_entry_copy_nexthops(struct route_entry *re, struct nexthop *nh)  { -	assert(!re->nhe->nhg->nexthop); -	copy_nexthops(&re->nhe->nhg->nexthop, nh, NULL); +	assert(!re->nhe->nhg.nexthop); +	copy_nexthops(&re->nhe->nhg.nexthop, nh, NULL);  }  static void route_entry_attach_ref(struct route_entry *re, @@ -217,12 +217,14 @@ int route_entry_update_nhe(struct route_entry *re, struct nhg_hash_entry *new)  	int ret = 0;  	if (new == NULL) { -		re->nhe->nhg = NULL; +		if (re->nhe) +			zebra_nhg_decrement_ref(re->nhe); +		re->nhe = NULL;  		goto done;  	}  	if (re->nhe_id != new->id) { -		old = zebra_nhg_lookup_id(re->nhe_id); +		old = re->nhe;  		route_entry_attach_ref(re, new); @@ -404,7 +406,7 @@ int zebra_rib_labeled_unicast(struct route_entry *re)  	if (re->type != ZEBRA_ROUTE_BGP)  		return 0; -	for (ALL_NEXTHOPS_PTR(re->nhe->nhg, nexthop)) +	for (ALL_NEXTHOPS(re->nhe->nhg, nexthop))  		if (!nexthop->nh_label || !nexthop->nh_label->num_labels)  			return 0; @@ -428,7 +430,7 @@ void rib_install_kernel(struct route_node *rn, struct route_entry *re,  	srcdest_rnode_prefixes(rn, &p, &src_p);  	if (info->safi != SAFI_UNICAST) { -		for (ALL_NEXTHOPS_PTR(re->nhe->nhg, nexthop)) +		for (ALL_NEXTHOPS(re->nhe->nhg, nexthop))  			SET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB);  		return;  	} @@ -437,7 +439,7 @@ void rib_install_kernel(struct route_node *rn, struct route_entry *re,  	/*  	 * Install the resolved nexthop object first.  	 */ -	zebra_nhg_install_kernel(zebra_nhg_lookup_id(re->nhe_id)); +	zebra_nhg_install_kernel(re->nhe);  	/*  	 * If this is a replace to a new RE let the originator of the RE @@ -506,7 +508,7 @@ void rib_uninstall_kernel(struct route_node *rn, struct route_entry *re)  	if (info->safi != SAFI_UNICAST) {  		UNSET_FLAG(re->status, ROUTE_ENTRY_INSTALLED); -		for (ALL_NEXTHOPS_PTR(re->nhe->nhg, nexthop)) +		for (ALL_NEXTHOPS(re->nhe->nhg, nexthop))  			UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB);  		return;  	} @@ -566,7 +568,7 @@ static void rib_uninstall(struct route_node *rn, struct route_entry *re)  			re->fib_ng.nexthop = NULL;  		} -		for (ALL_NEXTHOPS_PTR(re->nhe->nhg, nexthop)) +		for (ALL_NEXTHOPS(re->nhe->nhg, nexthop))  			UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB);  	} @@ -630,10 +632,11 @@ void zebra_rib_evaluate_rn_nexthops(struct route_node *rn, uint32_t seq)  		if (IS_ZEBRA_DEBUG_NHT_DETAILED) {  			char buf[PREFIX_STRLEN]; -			zlog_debug("%s: %s Being examined for Nexthop Tracking Count: %zd", -				   __PRETTY_FUNCTION__, -				   srcdest_rnode2str(rn, buf, sizeof(buf)), -				   dest ? rnh_list_count(&dest->nht) : 0); +			zlog_debug( +				"%s: %s Being examined for Nexthop Tracking Count: %zd", +				__func__, +				srcdest_rnode2str(rn, buf, sizeof(buf)), +				dest ? rnh_list_count(&dest->nht) : 0);  		}  		if (!dest) {  			rn = rn->parent; @@ -742,7 +745,7 @@ static void rib_process_add_fib(struct zebra_vrf *zvrf, struct route_node *rn,  	/* Update real nexthop. This may actually determine if nexthop is active  	 * or not. */ -	if (!nexthop_group_active_nexthop_num(new->nhe->nhg)) { +	if (!nexthop_group_active_nexthop_num(&(new->nhe->nhg))) {  		UNSET_FLAG(new->status, ROUTE_ENTRY_CHANGED);  		return;  	} @@ -811,7 +814,7 @@ static void rib_process_update_fib(struct zebra_vrf *zvrf,  		/* Update the nexthop; we could determine here that nexthop is  		 * inactive. */ -		if (nexthop_group_active_nexthop_num(new->nhe->nhg)) +		if (nexthop_group_active_nexthop_num(&(new->nhe->nhg)))  			nh_active = 1;  		/* If nexthop is active, install the selected route, if @@ -929,7 +932,7 @@ static struct route_entry *rib_choose_best(struct route_entry *current,  		/* both are connected.  are either loop or vrf? */  		struct nexthop *nexthop = NULL; -		for (ALL_NEXTHOPS_PTR(alternate->nhe->nhg, nexthop)) { +		for (ALL_NEXTHOPS(alternate->nhe->nhg, nexthop)) {  			struct interface *ifp = if_lookup_by_index(  				nexthop->ifindex, alternate->vrf_id); @@ -937,7 +940,7 @@ static struct route_entry *rib_choose_best(struct route_entry *current,  				return alternate;  		} -		for (ALL_NEXTHOPS_PTR(current->nhe->nhg, nexthop)) { +		for (ALL_NEXTHOPS(current->nhe->nhg, nexthop)) {  			struct interface *ifp = if_lookup_by_index(  				nexthop->ifindex, current->vrf_id); @@ -1269,7 +1272,7 @@ static void zebra_rib_fixup_system(struct route_node *rn)  		SET_FLAG(re->status, ROUTE_ENTRY_INSTALLED);  		UNSET_FLAG(re->status, ROUTE_ENTRY_QUEUED); -		for (ALL_NEXTHOPS_PTR(re->nhe->nhg, nhop)) { +		for (ALL_NEXTHOPS(re->nhe->nhg, nhop)) {  			if (CHECK_FLAG(nhop->flags, NEXTHOP_FLAG_RECURSIVE))  				continue; @@ -1386,7 +1389,7 @@ static bool rib_update_re_from_ctx(struct route_entry *re,  	    || !CHECK_FLAG(ctx_nexthop->flags, NEXTHOP_FLAG_ACTIVE))  		ctx_nexthop = nexthop_next_active_resolved(ctx_nexthop); -	for (ALL_NEXTHOPS_PTR(re->nhe->nhg, nexthop)) { +	for (ALL_NEXTHOPS(re->nhe->nhg, nexthop)) {  		if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_RECURSIVE))  			continue; @@ -2354,8 +2357,8 @@ void rib_unlink(struct route_node *rn, struct route_entry *re)  		nhe = zebra_nhg_lookup_id(re->nhe_id);  		if (nhe)  			zebra_nhg_decrement_ref(nhe); -	} else if (re->nhe->nhg) -		nexthop_group_delete(&re->nhe->nhg); +	} else if (re->nhe->nhg.nexthop) +		nexthops_free(re->nhe->nhg.nexthop);  	nexthops_free(re->fib_ng.nexthop); @@ -2423,10 +2426,10 @@ void _route_entry_dump(const char *func, union prefixconstptr pp,  		"%s: metric == %u, mtu == %u, distance == %u, flags == %u, status == %u",  		straddr, re->metric, re->mtu, re->distance, re->flags, re->status);  	zlog_debug("%s: nexthop_num == %u, nexthop_active_num == %u", straddr, -		   nexthop_group_nexthop_num(re->nhe->nhg), -		   nexthop_group_active_nexthop_num(re->nhe->nhg)); +		   nexthop_group_nexthop_num(&(re->nhe->nhg)), +		   nexthop_group_active_nexthop_num(&(re->nhe->nhg))); -	for (ALL_NEXTHOPS_PTR(re->nhe->nhg, nexthop)) { +	for (ALL_NEXTHOPS(re->nhe->nhg, nexthop)) {  		struct interface *ifp;  		struct vrf *vrf = vrf_lookup_by_id(nexthop->vrf_id); @@ -2784,7 +2787,7 @@ void rib_delete(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type,  		if (re->type == ZEBRA_ROUTE_KERNEL && re->metric != metric)  			continue;  		if (re->type == ZEBRA_ROUTE_CONNECT && -		    (rtnh = re->nhe->nhg->nexthop) +		    (rtnh = re->nhe->nhg.nexthop)  		    && rtnh->type == NEXTHOP_TYPE_IFINDEX && nh) {  			if (rtnh->ifindex != nh->ifindex)  				continue; @@ -2802,7 +2805,7 @@ void rib_delete(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type,  			same = re;  			break;  		} -		for (ALL_NEXTHOPS_PTR(re->nhe->nhg, rtnh)) { +		for (ALL_NEXTHOPS(re->nhe->nhg, rtnh)) {  			/*  			 * No guarantee all kernel send nh with labels  			 * on delete. @@ -2844,7 +2847,7 @@ void rib_delete(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type,  			if (allow_delete) {  				UNSET_FLAG(fib->status, ROUTE_ENTRY_INSTALLED);  				/* Unset flags. */ -				for (rtnh = fib->nhe->nhg->nexthop; rtnh; +				for (rtnh = fib->nhe->nhg.nexthop; rtnh;  				     rtnh = rtnh->next)  					UNSET_FLAG(rtnh->flags,  						   NEXTHOP_FLAG_FIB); @@ -2900,7 +2903,7 @@ void rib_delete(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type,  		if (CHECK_FLAG(flags, ZEBRA_FLAG_EVPN_ROUTE)) {  			struct nexthop *tmp_nh; -			for (ALL_NEXTHOPS_PTR(re->nhe->nhg, tmp_nh)) { +			for (ALL_NEXTHOPS(re->nhe->nhg, tmp_nh)) {  				struct ipaddr vtep_ip;  				memset(&vtep_ip, 0, sizeof(struct ipaddr)); @@ -3170,7 +3173,7 @@ void rib_update(rib_update_event_t event)  			      &t_rib_update_threads[event]))  		rib_update_ctx_fini(&ctx); /* Already scheduled */  	else if (IS_ZEBRA_DEBUG_EVENT) -		zlog_debug("%s: Schedued VRF (ALL), event %s", __func__, +		zlog_debug("%s: Scheduled VRF (ALL), event %s", __func__,  			   rib_update_event2str(event));  } @@ -3224,7 +3227,7 @@ void rib_sweep_table(struct route_table *table)  			 * this decision needs to be revisited  			 */  			SET_FLAG(re->status, ROUTE_ENTRY_INSTALLED); -			for (ALL_NEXTHOPS_PTR(re->nhe->nhg, nexthop)) +			for (ALL_NEXTHOPS(re->nhe->nhg, nexthop))  				SET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB);  			rib_uninstall_kernel(rn, re); diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c index 2d9c83becb..6cfc68eb74 100644 --- a/zebra/zebra_rnh.c +++ b/zebra/zebra_rnh.c @@ -54,7 +54,7 @@ DEFINE_MTYPE_STATIC(ZEBRA, RNH, "Nexthop tracking object")  static void free_state(vrf_id_t vrf_id, struct route_entry *re,  		       struct route_node *rn); -static void copy_state(struct rnh *rnh, struct route_entry *re, +static void copy_state(struct rnh *rnh, const struct route_entry *re,  		       struct route_node *rn);  static int compare_state(struct route_entry *r1, struct route_entry *r2);  static int send_client(struct rnh *rnh, struct zserv *client, rnh_type_t type, @@ -111,8 +111,8 @@ static void zebra_rnh_remove_from_routing_table(struct rnh *rnh)  		char buf[PREFIX_STRLEN];  		char buf1[PREFIX_STRLEN]; -		zlog_debug("%s: %u:%s removed from tracking on %s", -			   __PRETTY_FUNCTION__, rnh->vrf_id, +		zlog_debug("%s: %u:%s removed from tracking on %s", __func__, +			   rnh->vrf_id,  			   prefix2str(&rnh->node->p, buf, sizeof(buf)),  			   srcdest_rnode2str(rn, buf1, sizeof(buf)));  	} @@ -137,8 +137,8 @@ static void zebra_rnh_store_in_routing_table(struct rnh *rnh)  		char buf[PREFIX_STRLEN];  		char buf1[PREFIX_STRLEN]; -		zlog_debug("%s: %u:%s added for tracking on %s", -			   __PRETTY_FUNCTION__, rnh->vrf_id, +		zlog_debug("%s: %u:%s added for tracking on %s", __func__, +			   rnh->vrf_id,  			   prefix2str(&rnh->node->p, buf, sizeof(buf)),  			   srcdest_rnode2str(rn, buf1, sizeof(buf)));  	} @@ -384,7 +384,7 @@ static void zebra_rnh_clear_nexthop_rnh_filters(struct route_entry *re)  	struct nexthop *nexthop;  	if (re) { -		for (nexthop = re->nhe->nhg->nexthop; nexthop; +		for (nexthop = re->nhe->nhg.nexthop; nexthop;  		     nexthop = nexthop->next) {  			UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_RNH_FILTERED);  		} @@ -403,7 +403,7 @@ static int zebra_rnh_apply_nht_rmap(afi_t afi, struct zebra_vrf *zvrf,  	route_map_result_t ret;  	if (prn && re) { -		for (nexthop = re->nhe->nhg->nexthop; nexthop; +		for (nexthop = re->nhe->nhg.nexthop; nexthop;  		     nexthop = nexthop->next) {  			ret = zebra_nht_route_map_check(  				afi, proto, &prn->p, zvrf, re, nexthop); @@ -452,8 +452,8 @@ zebra_rnh_resolve_import_entry(struct zebra_vrf *zvrf, afi_t afi,  		char buf[PREFIX_STRLEN];  		char buf1[PREFIX_STRLEN]; -		zlog_debug("%s: %u:%s Resolved Import Entry to %s", -			   __PRETTY_FUNCTION__, rnh->vrf_id, +		zlog_debug("%s: %u:%s Resolved Import Entry to %s", __func__, +			   rnh->vrf_id,  			   prefix2str(&rnh->node->p, buf, sizeof(buf)),  			   srcdest_rnode2str(rn, buf1, sizeof(buf)));  	} @@ -643,8 +643,8 @@ zebra_rnh_resolve_nexthop_entry(struct zebra_vrf *zvrf, afi_t afi,  			char buf[PREFIX_STRLEN];  			char buf1[PREFIX_STRLEN]; -			zlog_debug("%s: %u:%s Possible Match to %s", -				   __PRETTY_FUNCTION__, rnh->vrf_id, +			zlog_debug("%s: %u:%s Possible Match to %s", __func__, +				   rnh->vrf_id,  				   prefix2str(&rnh->node->p, buf, sizeof(buf)),  				   srcdest_rnode2str(rn, buf1, sizeof(buf)));  		} @@ -669,7 +669,8 @@ zebra_rnh_resolve_nexthop_entry(struct zebra_vrf *zvrf, afi_t afi,  						zebra_route_string(re->type));  				continue;  			} -			if (!CHECK_FLAG(re->flags, ZEBRA_FLAG_SELECTED)) { +			if (!CHECK_FLAG(re->flags, ZEBRA_FLAG_SELECTED) && +			    !CHECK_FLAG(re->flags, ZEBRA_FLAG_FIB_OVERRIDE)) {  				if (IS_ZEBRA_DEBUG_NHT_DETAILED)  					zlog_debug(  						"\tRoute Entry %s !selected", @@ -688,7 +689,7 @@ zebra_rnh_resolve_nexthop_entry(struct zebra_vrf *zvrf, afi_t afi,  			/* Just being SELECTED isn't quite enough - must  			 * have an installed nexthop to be useful.  			 */ -			for (ALL_NEXTHOPS_PTR(re->nhe->nhg, nexthop)) { +			for (ALL_NEXTHOPS(re->nhe->nhg, nexthop)) {  				if (rnh_nexthop_valid(re, nexthop))  					break;  			} @@ -707,7 +708,7 @@ zebra_rnh_resolve_nexthop_entry(struct zebra_vrf *zvrf, afi_t afi,  					break;  				if (re->type == ZEBRA_ROUTE_NHRP) { -					for (nexthop = re->nhe->nhg->nexthop; +					for (nexthop = re->nhe->nhg.nexthop;  					     nexthop;  					     nexthop = nexthop->next)  						if (nexthop->type @@ -945,7 +946,7 @@ static void free_state(vrf_id_t vrf_id, struct route_entry *re,  	XFREE(MTYPE_RE, re);  } -static void copy_state(struct rnh *rnh, struct route_entry *re, +static void copy_state(struct rnh *rnh, const struct route_entry *re,  		       struct route_node *rn)  {  	struct route_entry *state; @@ -966,9 +967,8 @@ static void copy_state(struct rnh *rnh, struct route_entry *re,  	state->status = re->status;  	state->nhe = zebra_nhg_alloc(); -	state->nhe->nhg = nexthop_group_new(); -	nexthop_group_copy(state->nhe->nhg, re->nhe->nhg); +	nexthop_group_copy(&(state->nhe->nhg), &(re->nhe->nhg));  	rnh->state = state;  } @@ -986,12 +986,12 @@ static int compare_state(struct route_entry *r1, struct route_entry *r2)  	if (r1->metric != r2->metric)  		return 1; -	if (nexthop_group_nexthop_num(r1->nhe->nhg) -	    != nexthop_group_nexthop_num(r2->nhe->nhg)) +	if (nexthop_group_nexthop_num(&(r1->nhe->nhg)) +	    != nexthop_group_nexthop_num(&(r2->nhe->nhg)))  		return 1; -	if (nexthop_group_hash(r1->nhe->nhg) != -	    nexthop_group_hash(r2->nhe->nhg)) +	if (nexthop_group_hash(&(r1->nhe->nhg)) != +	    nexthop_group_hash(&(r2->nhe->nhg)))  		return 1;  	return 0; @@ -1043,7 +1043,7 @@ static int send_client(struct rnh *rnh, struct zserv *client, rnh_type_t type,  		num = 0;  		nump = stream_get_endp(s);  		stream_putc(s, 0); -		for (ALL_NEXTHOPS_PTR(re->nhe->nhg, nh)) +		for (ALL_NEXTHOPS(re->nhe->nhg, nh))  			if (rnh_nexthop_valid(re, nh)) {  				zapi_nexthop_from_nexthop(&znh, nh);  				zapi_nexthop_encode(s, &znh, 0 /* flags */); @@ -1114,7 +1114,7 @@ static void print_rnh(struct route_node *rn, struct vty *vty)  	if (rnh->state) {  		vty_out(vty, " resolved via %s\n",  			zebra_route_string(rnh->state->type)); -		for (nexthop = rnh->state->nhe->nhg->nexthop; nexthop; +		for (nexthop = rnh->state->nhe->nhg.nexthop; nexthop;  		     nexthop = nexthop->next)  			print_nh(nexthop, vty);  	} else diff --git a/zebra/zebra_snmp.c b/zebra/zebra_snmp.c index 70bb6a14ca..5de45c0294 100644 --- a/zebra/zebra_snmp.c +++ b/zebra/zebra_snmp.c @@ -285,8 +285,8 @@ static void check_replace(struct route_node *np2, struct route_entry *re2,  		return;  	} -	if (in_addr_cmp((uint8_t *)&(*re)->nhe->nhg->nexthop->gate.ipv4, -			(uint8_t *)&re2->nhe->nhg->nexthop->gate.ipv4) +	if (in_addr_cmp((uint8_t *)&(*re)->nhe->nhg.nexthop->gate.ipv4, +			(uint8_t *)&re2->nhe->nhg.nexthop->gate.ipv4)  	    <= 0)  		return; @@ -372,7 +372,7 @@ static void get_fwtable_route_node(struct variable *v, oid objid[],  					 (uint8_t *)&dest)) {  				RNODE_FOREACH_RE (*np, *re) {  					if (!in_addr_cmp((uint8_t *)&(*re)->nhe -							 ->nhg->nexthop +							 ->nhg.nexthop  							 ->gate.ipv4,  							 (uint8_t *)&nexthop))  						if (proto @@ -407,7 +407,7 @@ static void get_fwtable_route_node(struct variable *v, oid objid[],  				    || ((policy == policy2) && (proto == proto2)  					&& (in_addr_cmp(  						    (uint8_t *)&re2->nhe -						    ->nhg->nexthop->gate.ipv4, +						    ->nhg.nexthop->gate.ipv4,  						    (uint8_t *)&nexthop)  					    >= 0)))  					check_replace(np2, re2, np, re); @@ -432,7 +432,7 @@ static void get_fwtable_route_node(struct variable *v, oid objid[],  	{  		struct nexthop *nexthop; -		nexthop = (*re)->nhe->nhg->nexthop; +		nexthop = (*re)->nhe->nhg.nexthop;  		if (nexthop) {  			pnt = (uint8_t *)&nexthop->gate.ipv4;  			for (i = 0; i < 4; i++) @@ -462,7 +462,7 @@ static uint8_t *ipFwTable(struct variable *v, oid objid[], size_t *objid_len,  	if (!np)  		return NULL; -	nexthop = re->nhe->nhg->nexthop; +	nexthop = re->nhe->nhg.nexthop;  	if (!nexthop)  		return NULL; diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index ce6b0d1bee..79ce43be93 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -241,30 +241,30 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,  		vty_out(vty, "\n");  		time_t uptime; -		struct tm *tm; +		struct tm tm;  		uptime = monotime(NULL);  		uptime -= re->uptime; -		tm = gmtime(&uptime); +		gmtime_r(&uptime, &tm);  		vty_out(vty, "  Last update ");  		if (uptime < ONE_DAY_SECOND) -			vty_out(vty, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, -				tm->tm_sec); +			vty_out(vty, "%02d:%02d:%02d", tm.tm_hour, tm.tm_min, +				tm.tm_sec);  		else if (uptime < ONE_WEEK_SECOND) -			vty_out(vty, "%dd%02dh%02dm", tm->tm_yday, tm->tm_hour, -				tm->tm_min); +			vty_out(vty, "%dd%02dh%02dm", tm.tm_yday, tm.tm_hour, +				tm.tm_min);  		else -			vty_out(vty, "%02dw%dd%02dh", tm->tm_yday / 7, -				tm->tm_yday - ((tm->tm_yday / 7) * 7), -				tm->tm_hour); +			vty_out(vty, "%02dw%dd%02dh", tm.tm_yday / 7, +				tm.tm_yday - ((tm.tm_yday / 7) * 7), +				tm.tm_hour);  		vty_out(vty, " ago\n");  		if (show_ng)  			vty_out(vty, "  Nexthop Group ID: %u\n", re->nhe_id); -		for (ALL_NEXTHOPS_PTR(re->nhe->nhg, nexthop)) { +		for (ALL_NEXTHOPS(re->nhe->nhg, nexthop)) {  			char addrstr[32];  			vty_out(vty, "  %c%s", @@ -286,7 +286,7 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,  			case NEXTHOP_TYPE_IPV6_IFINDEX:  				vty_out(vty, " %s",  					inet_ntop(AF_INET6, &nexthop->gate.ipv6, -						  buf, sizeof buf)); +						  buf, sizeof(buf)));  				if (nexthop->ifindex)  					vty_out(vty, ", via %s",  						ifindex2ifname( @@ -348,7 +348,7 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,  				if (nexthop->src.ipv4.s_addr) {  					if (inet_ntop(AF_INET,  						      &nexthop->src.ipv4, -						      addrstr, sizeof addrstr)) +						      addrstr, sizeof(addrstr)))  						vty_out(vty, ", src %s",  							addrstr);  				} @@ -359,7 +359,7 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,  						    &in6addr_any)) {  					if (inet_ntop(AF_INET6,  						      &nexthop->src.ipv6, -						      addrstr, sizeof addrstr)) +						      addrstr, sizeof(addrstr)))  						vty_out(vty, ", src %s",  							addrstr);  				} @@ -378,7 +378,7 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,  					mpls_label2str(  						nexthop->nh_label->num_labels,  						nexthop->nh_label->label, buf, -						sizeof buf, 1)); +						sizeof(buf), 1));  			}  			if (nexthop->weight) @@ -402,14 +402,14 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,  	json_object *json_route = NULL;  	json_object *json_labels = NULL;  	time_t uptime; -	struct tm *tm; +	struct tm tm;  	struct vrf *vrf = NULL;  	rib_dest_t *dest = rib_dest_from_rnode(rn);  	struct nexthop_group *nhg;  	uptime = monotime(NULL);  	uptime -= re->uptime; -	tm = gmtime(&uptime); +	gmtime_r(&uptime, &tm);  	/* If showing fib information, use the fib view of the  	 * nexthops. @@ -417,14 +417,14 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,  	if (is_fib)  		nhg = rib_active_nhg(re);  	else -		nhg = re->nhe->nhg; +		nhg = &(re->nhe->nhg);  	if (json) {  		json_route = json_object_new_object();  		json_nexthops = json_object_new_array();  		json_object_string_add(json_route, "prefix", -				       srcdest_rnode2str(rn, buf, sizeof buf)); +				       srcdest_rnode2str(rn, buf, sizeof(buf)));  		json_object_string_add(json_route, "protocol",  				       zebra_route_string(re->type)); @@ -470,20 +470,20 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,  		json_object_int_add(json_route, "internalFlags",  				    re->flags);  		json_object_int_add(json_route, "internalNextHopNum", -				    nexthop_group_nexthop_num(re->nhe->nhg)); +				    nexthop_group_nexthop_num(&(re->nhe->nhg)));  		json_object_int_add(json_route, "internalNextHopActiveNum",  				    nexthop_group_active_nexthop_num( -					    re->nhe->nhg)); +					    &(re->nhe->nhg)));  		if (uptime < ONE_DAY_SECOND) -			sprintf(buf, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, -				tm->tm_sec); +			sprintf(buf, "%02d:%02d:%02d", tm.tm_hour, tm.tm_min, +				tm.tm_sec);  		else if (uptime < ONE_WEEK_SECOND) -			sprintf(buf, "%dd%02dh%02dm", tm->tm_yday, tm->tm_hour, -				tm->tm_min); +			sprintf(buf, "%dd%02dh%02dm", tm.tm_yday, tm.tm_hour, +				tm.tm_min);  		else -			sprintf(buf, "%02dw%dd%02dh", tm->tm_yday / 7, -				tm->tm_yday - ((tm->tm_yday / 7) * 7), -				tm->tm_hour); +			sprintf(buf, "%02dw%dd%02dh", tm.tm_yday / 7, +				tm.tm_yday - ((tm.tm_yday / 7) * 7), +				tm.tm_hour);  		json_object_string_add(json_route, "uptime", buf); @@ -526,7 +526,7 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,  				json_object_string_add(  					json_nexthop, "ip",  					inet_ntop(AF_INET6, &nexthop->gate.ipv6, -						  buf, sizeof buf)); +						  buf, sizeof(buf)));  				json_object_string_add(json_nexthop, "afi",  						       "ipv6"); @@ -606,7 +606,7 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,  				if (nexthop->src.ipv4.s_addr) {  					if (inet_ntop(AF_INET,  						      &nexthop->src.ipv4, buf, -						      sizeof buf)) +						      sizeof(buf)))  						json_object_string_add(  							json_nexthop, "source",  							buf); @@ -618,7 +618,7 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,  						    &in6addr_any)) {  					if (inet_ntop(AF_INET6,  						      &nexthop->src.ipv6, buf, -						      sizeof buf)) +						      sizeof(buf)))  						json_object_string_add(  							json_nexthop, "source",  							buf); @@ -667,7 +667,7 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,  					? '>'  					: ' ',  				re_status_output_char(re, nexthop), -				srcdest_rnode2str(rn, buf, sizeof buf)); +				srcdest_rnode2str(rn, buf, sizeof(buf)));  			/* Distance and metric display. */  			if (((re->type == ZEBRA_ROUTE_CONNECT) && @@ -694,7 +694,7 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,  		case NEXTHOP_TYPE_IPV6_IFINDEX:  			vty_out(vty, " via %s",  				inet_ntop(AF_INET6, &nexthop->gate.ipv6, buf, -					  sizeof buf)); +					  sizeof(buf)));  			if (nexthop->ifindex)  				vty_out(vty, ", %s",  					ifindex2ifname(nexthop->ifindex, @@ -750,7 +750,7 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,  		case NEXTHOP_TYPE_IPV4_IFINDEX:  			if (nexthop->src.ipv4.s_addr) {  				if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, -					      sizeof buf)) +					      sizeof(buf)))  					vty_out(vty, ", src %s", buf);  			}  			break; @@ -758,7 +758,7 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,  		case NEXTHOP_TYPE_IPV6_IFINDEX:  			if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any)) {  				if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, -					      sizeof buf)) +					      sizeof(buf)))  					vty_out(vty, ", src %s", buf);  			}  			break; @@ -771,19 +771,19 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,  			vty_out(vty, ", label %s",  				mpls_label2str(nexthop->nh_label->num_labels,  					       nexthop->nh_label->label, buf, -					       sizeof buf, 1)); +					       sizeof(buf), 1));  		}  		if (uptime < ONE_DAY_SECOND) -			vty_out(vty, ", %02d:%02d:%02d", tm->tm_hour, -				tm->tm_min, tm->tm_sec); +			vty_out(vty, ", %02d:%02d:%02d", tm.tm_hour, +				tm.tm_min, tm.tm_sec);  		else if (uptime < ONE_WEEK_SECOND) -			vty_out(vty, ", %dd%02dh%02dm", tm->tm_yday, -				tm->tm_hour, tm->tm_min); +			vty_out(vty, ", %dd%02dh%02dm", tm.tm_yday, +				tm.tm_hour, tm.tm_min);  		else -			vty_out(vty, ", %02dw%dd%02dh", tm->tm_yday / 7, -				tm->tm_yday - ((tm->tm_yday / 7) * 7), -				tm->tm_hour); +			vty_out(vty, ", %02dw%dd%02dh", tm.tm_yday / 7, +				tm.tm_yday - ((tm.tm_yday / 7) * 7), +				tm.tm_hour);  		vty_out(vty, "\n");  	}  } @@ -915,8 +915,8 @@ static void do_show_route_helper(struct vty *vty, struct zebra_vrf *zvrf,  	}  } -static void do_show_ip_route_all(struct vty *vty, struct zebra_vrf *zvrf, afi_t afi, -				 bool use_fib, bool use_json, +static void do_show_ip_route_all(struct vty *vty, struct zebra_vrf *zvrf, +				 afi_t afi, bool use_fib, bool use_json,  				 route_tag_t tag,  				 const struct prefix *longer_prefix_p,  				 bool supernets_only, int type, @@ -934,12 +934,12 @@ static void do_show_ip_route_all(struct vty *vty, struct zebra_vrf *zvrf, afi_t  		if (zrt->afi != afi ||  		    zrt->safi != SAFI_UNICAST)  			continue; -		if (zrt->table) -			do_show_ip_route(vty, zvrf_name(zvrf), afi, -					 SAFI_UNICAST, use_fib, use_json, -					 tag, longer_prefix_p, -					 supernets_only, type, -					 ospf_instance_id, zrt->tableid); + +		do_show_ip_route(vty, zvrf_name(zvrf), afi, +				 SAFI_UNICAST, use_fib, use_json, +				 tag, longer_prefix_p, +				 supernets_only, type, +				 ospf_instance_id, zrt->tableid);  	}  } @@ -1093,7 +1093,7 @@ static void show_nexthop_group_out(struct vty *vty, struct nhg_hash_entry *nhe)  		vty_out(vty, "\n");  	} -	for (ALL_NEXTHOPS_PTR(nhe->nhg, nexthop)) { +	for (ALL_NEXTHOPS(nhe->nhg, nexthop)) {  		if (!CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_RECURSIVE))  			vty_out(vty, "          ");  		else @@ -1532,10 +1532,8 @@ DEFPY (show_route,  	if (vrf_all) {  		RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { -			struct route_table *route_table; -  			if ((zvrf = vrf->info) == NULL -			    || (route_table = zvrf->table[afi][SAFI_UNICAST]) == NULL) +			    || (zvrf->table[afi][SAFI_UNICAST] == NULL))  				continue;  			if (table_all) @@ -1953,7 +1951,7 @@ static void vty_show_ip_route_summary_prefix(struct vty *vty,  				fib_cnt[ZEBRA_ROUTE_TOTAL]++;  				fib_cnt[re->type]++;  			} -			for (nexthop = re->nhe->nhg->nexthop; (!cnt && nexthop); +			for (nexthop = re->nhe->nhg.nexthop; (!cnt && nexthop);  			     nexthop = nexthop->next) {  				cnt++;  				rib_cnt[ZEBRA_ROUTE_TOTAL]++; diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index 4b56581ca9..dce48d39bd 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -101,8 +101,6 @@ static void *zvni_neigh_alloc(void *p);  static zebra_neigh_t *zvni_neigh_add(zebra_vni_t *zvni, struct ipaddr *ip,  				     struct ethaddr *mac);  static int zvni_neigh_del(zebra_vni_t *zvni, zebra_neigh_t *n); -static void zvni_neigh_del_from_vtep(zebra_vni_t *zvni, int uninstall, -				     struct in_addr *r_vtep_ip);  static void zvni_neigh_del_all(zebra_vni_t *zvni, int uninstall, int upd_client,  			       uint32_t flags);  static zebra_neigh_t *zvni_neigh_lookup(zebra_vni_t *zvni, struct ipaddr *ip); @@ -156,8 +154,6 @@ static bool mac_cmp(const void *p1, const void *p2);  static void *zvni_mac_alloc(void *p);  static zebra_mac_t *zvni_mac_add(zebra_vni_t *zvni, struct ethaddr *macaddr);  static int zvni_mac_del(zebra_vni_t *zvni, zebra_mac_t *mac); -static void zvni_mac_del_from_vtep(zebra_vni_t *zvni, int uninstall, -				   struct in_addr *r_vtep_ip);  static void zvni_mac_del_all(zebra_vni_t *zvni, int uninstall, int upd_client,  			     uint32_t flags);  static zebra_mac_t *zvni_mac_lookup(zebra_vni_t *zvni, struct ethaddr *macaddr); @@ -225,7 +221,7 @@ static void zebra_vxlan_sg_deref(struct in_addr local_vtep_ip,  				struct in_addr mcast_grp);  static void zebra_vxlan_sg_ref(struct in_addr local_vtep_ip,  				struct in_addr mcast_grp); -static void zebra_vxlan_sg_cleanup(struct hash_backet *backet, void *arg); +static void zebra_vxlan_sg_cleanup(struct hash_bucket *bucket, void *arg);  static void zvni_send_mac_to_client(zebra_vni_t *zvn);  static void zvni_send_neigh_to_client(zebra_vni_t *zvni); @@ -258,8 +254,8 @@ static int host_rb_entry_compare(const struct host_rb_entry *hle1,  		return memcmp(&hle1->p.u.prefix6, &hle2->p.u.prefix6,  			      IPV6_MAX_BYTELEN);  	} else { -		zlog_debug("%s: Unexpected family type: %d", -			   __PRETTY_FUNCTION__, hle1->p.family); +		zlog_debug("%s: Unexpected family type: %d", __func__, +			   hle1->p.family);  		return 0;  	}  } @@ -447,12 +443,11 @@ static void zebra_vxlan_dup_addr_detect_for_mac(struct zebra_vrf *zvrf,  	if (CHECK_FLAG(mac->flags, ZEBRA_MAC_DUPLICATE)) {  		if (IS_ZEBRA_DEBUG_VXLAN)  			zlog_debug( -				   "%s: duplicate addr MAC %s flags 0x%x skip update to client, learn count %u recover time %u", -				   __PRETTY_FUNCTION__, -				   prefix_mac2str(&mac->macaddr, buf, -						  sizeof(buf)), -				   mac->flags, mac->dad_count, -				   zvrf->dad_freeze_time); +				"%s: duplicate addr MAC %s flags 0x%x skip update to client, learn count %u recover time %u", +				__func__, +				prefix_mac2str(&mac->macaddr, buf, sizeof(buf)), +				mac->flags, mac->dad_count, +				zvrf->dad_freeze_time);  		/* For duplicate MAC do not update  		 * client but update neigh due to @@ -483,11 +478,10 @@ static void zebra_vxlan_dup_addr_detect_for_mac(struct zebra_vrf *zvrf,  	if (reset_params) {  		if (IS_ZEBRA_DEBUG_VXLAN)  			zlog_debug( -				   "%s: duplicate addr MAC %s flags 0x%x detection time passed, reset learn count %u" -				   , __PRETTY_FUNCTION__, -				   prefix_mac2str(&mac->macaddr, buf, -						  sizeof(buf)), -				   mac->flags, mac->dad_count); +				"%s: duplicate addr MAC %s flags 0x%x detection time passed, reset learn count %u", +				__func__, +				prefix_mac2str(&mac->macaddr, buf, sizeof(buf)), +				mac->flags, mac->dad_count);  		mac->dad_count = 0;  		/* Start dup. addr detection (DAD) start time, @@ -551,8 +545,8 @@ static void zebra_vxlan_dup_addr_detect_for_mac(struct zebra_vrf *zvrf,  		if (zvrf->dad_freeze && zvrf->dad_freeze_time) {  			if (IS_ZEBRA_DEBUG_VXLAN)  				zlog_debug( -					"%s: duplicate addr MAC %s flags 0x%x auto recovery time %u start" -					, __PRETTY_FUNCTION__, +					"%s: duplicate addr MAC %s flags 0x%x auto recovery time %u start", +					__func__,  					prefix_mac2str(&mac->macaddr, buf,  						       sizeof(buf)),  					mac->flags, zvrf->dad_freeze_time); @@ -594,8 +588,8 @@ static void zebra_vxlan_dup_addr_detect_for_neigh(struct zebra_vrf *zvrf,  	if (CHECK_FLAG(nbr->flags, ZEBRA_NEIGH_DUPLICATE)) {  		if (IS_ZEBRA_DEBUG_VXLAN)  			zlog_debug( -				   "%s: duplicate addr MAC %s IP %s flags 0x%x skip installing, learn count %u recover time %u", -					   __PRETTY_FUNCTION__, +				"%s: duplicate addr MAC %s IP %s flags 0x%x skip installing, learn count %u recover time %u", +				__func__,  				prefix_mac2str(&nbr->emac, buf, sizeof(buf)),  				ipaddr2str(&nbr->ip, buf1, sizeof(buf1)),  				nbr->flags, nbr->dad_count, @@ -635,7 +629,7 @@ static void zebra_vxlan_dup_addr_detect_for_neigh(struct zebra_vrf *zvrf,  		if (IS_ZEBRA_DEBUG_VXLAN)  			zlog_debug(  				"%s: duplicate addr MAC %s IP %s flags 0x%x detection time passed, reset learn count %u", -				__PRETTY_FUNCTION__, +				__func__,  				prefix_mac2str(&nbr->emac, buf, sizeof(buf)),  				ipaddr2str(&nbr->ip, buf1, sizeof(buf1)),  				nbr->flags, nbr->dad_count); @@ -685,10 +679,12 @@ static void zebra_vxlan_dup_addr_detect_for_neigh(struct zebra_vrf *zvrf,  			if (IS_ZEBRA_DEBUG_VXLAN)  				zlog_debug(  					"%s: duplicate addr MAC %s IP %s flags 0x%x auto recovery time %u start", -				   __PRETTY_FUNCTION__, -				   prefix_mac2str(&nbr->emac, buf, sizeof(buf)), -				   ipaddr2str(&nbr->ip, buf1, sizeof(buf1)), -				   nbr->flags, zvrf->dad_freeze_time); +					__func__, +					prefix_mac2str(&nbr->emac, buf, +						       sizeof(buf)), +					ipaddr2str(&nbr->ip, buf1, +						   sizeof(buf1)), +					nbr->flags, zvrf->dad_freeze_time);  			thread_add_timer(zrouter.master,  				zebra_vxlan_dad_ip_auto_recovery_exp, @@ -2302,26 +2298,6 @@ static void zvni_neigh_del_hash_entry(struct hash_bucket *bucket, void *arg)  }  /* - * Delete all neighbor entries from specific VTEP for a particular VNI. - */ -static void zvni_neigh_del_from_vtep(zebra_vni_t *zvni, int uninstall, -				     struct in_addr *r_vtep_ip) -{ -	struct neigh_walk_ctx wctx; - -	if (!zvni->neigh_table) -		return; - -	memset(&wctx, 0, sizeof(struct neigh_walk_ctx)); -	wctx.zvni = zvni; -	wctx.uninstall = uninstall; -	wctx.flags = DEL_REMOTE_NEIGH_FROM_VTEP; -	wctx.r_vtep_ip = *r_vtep_ip; - -	hash_iterate(zvni->neigh_table, zvni_neigh_del_hash_entry, &wctx); -} - -/*   * Delete all neighbor entries for this VNI.   */  static void zvni_neigh_del_all(zebra_vni_t *zvni, int uninstall, int upd_client, @@ -3450,11 +3426,10 @@ static bool zvni_check_mac_del_from_db(struct mac_walk_ctx *wctx,  		if (IS_ZEBRA_DEBUG_VXLAN) {  			char buf[ETHER_ADDR_STRLEN]; -			zlog_debug("%s: Del MAC %s flags 0x%x", -				   __PRETTY_FUNCTION__, -				   prefix_mac2str(&mac->macaddr, -						  buf, sizeof(buf)), -				   mac->flags); +			zlog_debug( +				"%s: Del MAC %s flags 0x%x", __func__, +				prefix_mac2str(&mac->macaddr, buf, sizeof(buf)), +				mac->flags);  		}  		wctx->uninstall = 0; @@ -3487,26 +3462,6 @@ static void zvni_mac_del_hash_entry(struct hash_bucket *bucket, void *arg)  }  /* - * Delete all MAC entries from specific VTEP for a particular VNI. - */ -static void zvni_mac_del_from_vtep(zebra_vni_t *zvni, int uninstall, -				   struct in_addr *r_vtep_ip) -{ -	struct mac_walk_ctx wctx; - -	if (!zvni->mac_table) -		return; - -	memset(&wctx, 0, sizeof(struct mac_walk_ctx)); -	wctx.zvni = zvni; -	wctx.uninstall = uninstall; -	wctx.flags = DEL_REMOTE_MAC_FROM_VTEP; -	wctx.r_vtep_ip = *r_vtep_ip; - -	hash_iterate(zvni->mac_table, zvni_mac_del_hash_entry, &wctx); -} - -/*   * Delete all MAC entries for this VNI.   */  static void zvni_mac_del_all(zebra_vni_t *zvni, int uninstall, int upd_client, @@ -5875,14 +5830,11 @@ static void process_remote_macip_del(vni_t vni,  	zns = zebra_ns_lookup(NS_DEFAULT);  	vxl = &zif->l2info.vxl; -	/* The remote VTEP specified is normally expected to exist, but -	 * it is possible that the peer may delete the VTEP before deleting -	 * any MACs referring to the VTEP, in which case the handler (see -	 * remote_vtep_del) would have already deleted the MACs. +	/* It is possible remote vtep del request is processed prior to +	 * remote macip route delete. remote_vtep_del does not clean up +	 * the macip route delete. Explicite withdraw of the macip route +	 * is expected to recieve. This handler removes the remote route.  	 */ -	if (!zvni_vtep_find(zvni, &vtep_ip)) -		return; -  	mac = zvni_mac_lookup(zvni, macaddr);  	if (ipa_len)  		n = zvni_neigh_lookup(zvni, ipaddr); @@ -5928,7 +5880,7 @@ static void process_remote_macip_del(vni_t vni,  			if (IS_ZEBRA_DEBUG_VXLAN)  				zlog_debug(  					"%s: IP %s (flags 0x%x intf %s) is remote and duplicate, read kernel for local entry", -					__PRETTY_FUNCTION__, +					__func__,  					ipaddr2str(ipaddr, buf1, sizeof(buf1)),  					n->flags,  					vlan_if ? vlan_if->name : "Unknown"); @@ -5958,11 +5910,12 @@ static void process_remote_macip_del(vni_t vni,  		    CHECK_FLAG(mac->flags, ZEBRA_MAC_DUPLICATE) &&  		    CHECK_FLAG(mac->flags, ZEBRA_MAC_REMOTE)) {  			if (IS_ZEBRA_DEBUG_VXLAN) -				zlog_debug("%s: MAC %s (flags 0x%x) is remote and duplicate, read kernel for local entry", -					   __PRETTY_FUNCTION__, -					   prefix_mac2str(macaddr, buf, -							  sizeof(buf)), -					   mac->flags); +				zlog_debug( +					"%s: MAC %s (flags 0x%x) is remote and duplicate, read kernel for local entry", +					__func__, +					prefix_mac2str(macaddr, buf, +						       sizeof(buf)), +					mac->flags);  			macfdb_read_specific_mac(zns, zif->brslave_info.br_if,  						 macaddr, vxl->access_vlan);  		} @@ -7028,8 +6981,7 @@ int zebra_vxlan_clear_dup_detect_vni_ip(struct vty *vty,  	if (IS_ZEBRA_DEBUG_VXLAN)  		zlog_debug("%s: clear neigh %s in dup state, flags 0x%x seq %u", -			   __PRETTY_FUNCTION__, buf, nbr->flags, -			   nbr->loc_seq); +			   __func__, buf, nbr->flags, nbr->loc_seq);  	UNSET_FLAG(nbr->flags, ZEBRA_NEIGH_DUPLICATE);  	nbr->dad_count = 0; @@ -7122,10 +7074,8 @@ static void zvni_clear_dup_neigh_hash(struct hash_bucket *bucket, void *ctxt)  	if (IS_ZEBRA_DEBUG_VXLAN) {  		ipaddr2str(&nbr->ip, buf, sizeof(buf)); -		zlog_debug( -		"%s: clear neigh %s dup state, flags 0x%x seq %u", -			   __PRETTY_FUNCTION__, buf, -			   nbr->flags, nbr->loc_seq); +		zlog_debug("%s: clear neigh %s dup state, flags 0x%x seq %u", +			   __func__, buf, nbr->flags, nbr->loc_seq);  	}  	UNSET_FLAG(nbr->flags, ZEBRA_NEIGH_DUPLICATE); @@ -7560,9 +7510,10 @@ int zebra_vxlan_handle_kernel_neigh_del(struct interface *ifp,  	zvni = zvni_from_svi(ifp, link_if);  	if (!zvni) {  		if (IS_ZEBRA_DEBUG_VXLAN) -			zlog_debug("%s: Del neighbor %s VNI is not present for interface %s", -				   __PRETTY_FUNCTION__, -				   ipaddr2str(ip, buf, sizeof(buf)), ifp->name); +			zlog_debug( +				"%s: Del neighbor %s VNI is not present for interface %s", +				__func__, ipaddr2str(ip, buf, sizeof(buf)), +				ifp->name);  		return 0;  	} @@ -7605,8 +7556,8 @@ int zebra_vxlan_handle_kernel_neigh_del(struct interface *ifp,  	zvrf = vrf_info_lookup(zvni->vxlan_if->vrf_id);  	if (!zvrf) { -		zlog_debug("%s: VNI %u vrf lookup failed.", -				   __PRETTY_FUNCTION__, zvni->vni); +		zlog_debug("%s: VNI %u vrf lookup failed.", __func__, +			   zvni->vni);  		return -1;  	} @@ -8220,7 +8171,7 @@ void zebra_vxlan_remote_vtep_del(ZAPI_HANDLER_ARGS)  	if (!is_evpn_enabled()) {  		zlog_debug(  			"%s: EVPN is not enabled yet we have received a vtep del command", -			__PRETTY_FUNCTION__); +			__func__);  		return;  	} @@ -8284,8 +8235,6 @@ void zebra_vxlan_remote_vtep_del(ZAPI_HANDLER_ARGS)  		if (!zvtep)  			continue; -		zvni_neigh_del_from_vtep(zvni, 1, &vtep_ip); -		zvni_mac_del_from_vtep(zvni, 1, &vtep_ip);  		zvni_vtep_uninstall(zvni, &vtep_ip);  		zvni_vtep_del(zvni, zvtep);  	} @@ -8312,7 +8261,7 @@ void zebra_vxlan_remote_vtep_add(ZAPI_HANDLER_ARGS)  	if (!is_evpn_enabled()) {  		zlog_debug(  			"%s: EVPN not enabled yet we received a vtep_add zapi call", -			__PRETTY_FUNCTION__); +			__func__);  		return;  	} @@ -9227,12 +9176,12 @@ int zebra_vxlan_process_vrf_vni_cmd(struct zebra_vrf *zvrf, vni_t vni,  		zl3vni->mac_vlan_if = zl3vni_map_to_mac_vlan_if(zl3vni);  		if (IS_ZEBRA_DEBUG_VXLAN) -			zlog_debug("%s: l3vni %u svi_if %s mac_vlan_if %s", -				   __PRETTY_FUNCTION__, vni, -				   zl3vni->svi_if ? -				   zl3vni->svi_if->name : "NIL", -				   zl3vni->mac_vlan_if ? -				   zl3vni->mac_vlan_if->name : "NIL"); +			zlog_debug( +				"%s: l3vni %u svi_if %s mac_vlan_if %s", +				__func__, vni, +				zl3vni->svi_if ? zl3vni->svi_if->name : "NIL", +				zl3vni->mac_vlan_if ? zl3vni->mac_vlan_if->name +						    : "NIL");  		/* formulate l2vni list */  		hash_iterate(zvrf_evpn->vni_table, zvni_add_to_l3vni_list, @@ -9785,12 +9734,12 @@ static int zebra_vxlan_dad_ip_auto_recovery_exp(struct thread *t)  		return 0;  	if (IS_ZEBRA_DEBUG_VXLAN) -		zlog_debug("%s: duplicate addr MAC %s IP %s flags 0x%x learn count %u vni %u auto recovery expired", -			  __PRETTY_FUNCTION__, -			  prefix_mac2str(&nbr->emac, buf2, sizeof(buf2)), -			  ipaddr2str(&nbr->ip, buf1, sizeof(buf1)), -			  nbr->flags, -			  nbr->dad_count, zvni->vni); +		zlog_debug( +			"%s: duplicate addr MAC %s IP %s flags 0x%x learn count %u vni %u auto recovery expired", +			__func__, +			prefix_mac2str(&nbr->emac, buf2, sizeof(buf2)), +			ipaddr2str(&nbr->ip, buf1, sizeof(buf1)), nbr->flags, +			nbr->dad_count, zvni->vni);  	UNSET_FLAG(nbr->flags, ZEBRA_NEIGH_DUPLICATE);  	nbr->dad_count = 0; @@ -9836,12 +9785,11 @@ static int zebra_vxlan_dad_mac_auto_recovery_exp(struct thread *t)  		return 0;  	if (IS_ZEBRA_DEBUG_VXLAN) -		zlog_debug("%s: duplicate addr mac %s flags 0x%x learn count %u host count %u auto recovery expired", -			    __PRETTY_FUNCTION__, -			    prefix_mac2str(&mac->macaddr, buf, sizeof(buf)), -			    mac->flags, -			    mac->dad_count, -			    listcount(mac->neigh_list)); +		zlog_debug( +			"%s: duplicate addr mac %s flags 0x%x learn count %u host count %u auto recovery expired", +			__func__, +			prefix_mac2str(&mac->macaddr, buf, sizeof(buf)), +			mac->flags, mac->dad_count, listcount(mac->neigh_list));  	/* Remove all IPs as duplicate associcated with this MAC */  	for (ALL_LIST_ELEMENTS_RO(mac->neigh_list, node, nbr)) { @@ -10102,14 +10050,14 @@ static void zebra_vxlan_sg_ref(struct in_addr local_vtep_ip,  	zebra_vxlan_sg_do_ref(zvrf, local_vtep_ip, mcast_grp);  } -static void zebra_vxlan_sg_cleanup(struct hash_backet *backet, void *arg) +static void zebra_vxlan_sg_cleanup(struct hash_bucket *backet, void *arg)  {  	zebra_vxlan_sg_t *vxlan_sg = (zebra_vxlan_sg_t *)backet->data;  	zebra_vxlan_sg_del(vxlan_sg);  } -static void zebra_vxlan_sg_replay_send(struct hash_backet *backet, void *arg) +static void zebra_vxlan_sg_replay_send(struct hash_bucket *backet, void *arg)  {  	zebra_vxlan_sg_t *vxlan_sg = (zebra_vxlan_sg_t *)backet->data; diff --git a/zebra/zserv.c b/zebra/zserv.c index 2a5352a1da..40aa9010c5 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -568,7 +568,7 @@ static void zserv_client_free(struct zserv *client)  		close(client->sock); -		if (!client->gr_instance_count) { +		if (DYNAMIC_CLIENT_GR_DISABLED(client)) {  			nroutes = rib_score_proto(client->proto,  						  client->instance);  			zlog_notice( @@ -610,7 +610,7 @@ static void zserv_client_free(struct zserv *client)  	 * If any instance are graceful restart enabled,  	 * client is not deleted  	 */ -	if (!client->gr_instance_count) { +	if (DYNAMIC_CLIENT_GR_DISABLED(client)) {  		if (IS_ZEBRA_DEBUG_EVENT)  			zlog_debug("%s: Deleting client %s", __func__,  				   zebra_route_string(client->proto)); @@ -858,7 +858,7 @@ void zserv_event(struct zserv *client, enum zserv_event event)  #define ZEBRA_TIME_BUF 32  static char *zserv_time_buf(time_t *time1, char *buf, int buflen)  { -	struct tm *tm; +	struct tm tm;  	time_t now;  	assert(buf != NULL); @@ -872,17 +872,17 @@ static char *zserv_time_buf(time_t *time1, char *buf, int buflen)  	now = monotime(NULL);  	now -= *time1; -	tm = gmtime(&now); +	gmtime_r(&now, &tm);  	if (now < ONE_DAY_SECOND) -		snprintf(buf, buflen, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, -			 tm->tm_sec); +		snprintf(buf, buflen, "%02d:%02d:%02d", tm.tm_hour, tm.tm_min, +			 tm.tm_sec);  	else if (now < ONE_WEEK_SECOND) -		snprintf(buf, buflen, "%dd%02dh%02dm", tm->tm_yday, tm->tm_hour, -			 tm->tm_min); +		snprintf(buf, buflen, "%dd%02dh%02dm", tm.tm_yday, tm.tm_hour, +			 tm.tm_min);  	else -		snprintf(buf, buflen, "%02dw%dd%02dh", tm->tm_yday / 7, -			 tm->tm_yday - ((tm->tm_yday / 7) * 7), tm->tm_hour); +		snprintf(buf, buflen, "%02dw%dd%02dh", tm.tm_yday / 7, +			 tm.tm_yday - ((tm.tm_yday / 7) * 7), tm.tm_hour);  	return buf;  } @@ -1001,7 +1001,7 @@ static void zebra_show_stale_client_detail(struct vty *vty,  					   struct zserv *client)  {  	char buf[PREFIX2STR_BUFFER]; -	struct tm *tm; +	struct tm tm;  	struct timeval tv;  	time_t uptime;  	struct client_gr_info *info = NULL; @@ -1030,22 +1030,23 @@ static void zebra_show_stale_client_detail(struct vty *vty,  				s = (struct zserv *)(info->stale_client_ptr);  				uptime = monotime(&tv);  				uptime -= s->restart_time; -				tm = gmtime(&uptime); +				gmtime_r(&uptime, &tm); +  				vty_out(vty, "Last restart time : ");  				if (uptime < ONE_DAY_SECOND)  					vty_out(vty, "%02d:%02d:%02d", -						tm->tm_hour, tm->tm_min, -						tm->tm_sec); +						tm.tm_hour, tm.tm_min, +						tm.tm_sec);  				else if (uptime < ONE_WEEK_SECOND)  					vty_out(vty, "%dd%02dh%02dm", -						tm->tm_yday, tm->tm_hour, -						tm->tm_min); +						tm.tm_yday, tm.tm_hour, +						tm.tm_min);  				else  					vty_out(vty, "%02dw%dd%02dh", -						tm->tm_yday / 7, -						tm->tm_yday - ((tm->tm_yday / 7) +						tm.tm_yday / 7, +						tm.tm_yday - ((tm.tm_yday / 7)  							       * 7), -						tm->tm_hour); +						tm.tm_hour);  				vty_out(vty, "  ago\n");  				vty_out(vty, "Stalepath removal time: %d sec\n", diff --git a/zebra/zserv.h b/zebra/zserv.h index 77ea19202f..6a075cc9a7 100644 --- a/zebra/zserv.h +++ b/zebra/zserv.h @@ -229,6 +229,10 @@ struct zserv {  DECLARE_HOOK(zserv_client_connect, (struct zserv *client), (client));  DECLARE_KOOH(zserv_client_close, (struct zserv *client), (client)); +#define DYNAMIC_CLIENT_GR_DISABLED(_client)                                    \ +	((_client->proto <= ZEBRA_ROUTE_CONNECT)                               \ +	 || !(_client->gr_instance_count)) +  /*   * Initialize Zebra API server.   *  | 
