diff options
283 files changed, 6790 insertions, 6809 deletions
diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c index caac385fb5..c3bbb71687 100644 --- a/bgpd/bgp_aspath.c +++ b/bgpd/bgp_aspath.c @@ -498,7 +498,8 @@ static void aspath_make_str_count(struct aspath *as, bool make_json)  	if (!as->segments) {  		if (make_json) {  			json_object_string_add(as->json, "string", "Local"); -			json_object_object_add(as->json, "segments", jaspath_segments); +			json_object_object_add(as->json, "segments", +					       jaspath_segments);  			json_object_int_add(as->json, "length", 0);  		}  		as->str = XMALLOC(MTYPE_AS_STR, 1); @@ -575,8 +576,9 @@ static void aspath_make_str_count(struct aspath *as, bool make_json)  		/* write out the ASNs, with their seperators, bar the last one*/  		for (i = 0; i < seg->length; i++) {  			if (make_json) -				json_object_array_add(jseg_list, -						      json_object_new_int(seg->as[i])); +				json_object_array_add( +					jseg_list, +					json_object_new_int(seg->as[i]));  			len += snprintf(str_buf + len, str_size - len, "%u",  					seg->as[i]); @@ -588,8 +590,9 @@ static void aspath_make_str_count(struct aspath *as, bool make_json)  		if (make_json) {  			jseg = json_object_new_object(); -			json_object_string_add(jseg, "type", -					       aspath_segment_type_str[seg->type]); +			json_object_string_add( +				jseg, "type", +				aspath_segment_type_str[seg->type]);  			json_object_object_add(jseg, "list", jseg_list);  			json_object_array_add(jaspath_segments, jseg);  		} @@ -904,7 +907,8 @@ size_t aspath_put(struct stream *s, struct aspath *as, int use32bit)  				assegment_data_put(s, seg->as, AS_SEGMENT_MAX,  						   use32bit);  				written += AS_SEGMENT_MAX; -				bytes += ASSEGMENT_SIZE(AS_SEGMENT_MAX, use32bit); +				bytes += ASSEGMENT_SIZE(AS_SEGMENT_MAX, +							use32bit);  			}  			/* write the final segment, probably is also the first @@ -2032,9 +2036,7 @@ int aspath_cmp(const void *arg1, const void *arg2)  /* AS path hash initialize. */  void aspath_init(void)  { -	ashash = hash_create_size(32768, -				  aspath_key_make, -				  aspath_cmp, +	ashash = hash_create_size(32768, aspath_key_make, aspath_cmp,  				  "BGP AS Path");  } diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index 3f3acbe0e2..84b5de91fd 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -83,15 +83,14 @@ static const struct message attr_str[] = {  	{BGP_ATTR_PREFIX_SID, "PREFIX_SID"},  	{0}}; -static const struct message attr_flag_str[] = -	{ -		{BGP_ATTR_FLAG_OPTIONAL, "Optional"}, -		{BGP_ATTR_FLAG_TRANS, "Transitive"}, -		{BGP_ATTR_FLAG_PARTIAL, "Partial"}, -		/* bgp_attr_flags_diagnose() relies on this bit being last in -		   this list */ -		{BGP_ATTR_FLAG_EXTLEN, "Extended Length"}, -		{0}}; +static const struct message attr_flag_str[] = { +	{BGP_ATTR_FLAG_OPTIONAL, "Optional"}, +	{BGP_ATTR_FLAG_TRANS, "Transitive"}, +	{BGP_ATTR_FLAG_PARTIAL, "Partial"}, +	/* bgp_attr_flags_diagnose() relies on this bit being last in +	   this list */ +	{BGP_ATTR_FLAG_EXTLEN, "Extended Length"}, +	{0}};  static struct hash *cluster_hash; @@ -185,8 +184,7 @@ void cluster_unintern(struct cluster_list *cluster)  static void cluster_init(void)  { -	cluster_hash = hash_create(cluster_hash_key_make, -				   cluster_hash_cmp, +	cluster_hash = hash_create(cluster_hash_key_make, cluster_hash_cmp,  				   "BGP Cluster");  } @@ -363,12 +361,10 @@ static int encap_hash_cmp(const void *p1, const void *p2)  static void encap_init(void)  { -	encap_hash = hash_create(encap_hash_key_make, -				 encap_hash_cmp, +	encap_hash = hash_create(encap_hash_key_make, encap_hash_cmp,  				 "BGP Encap Hash");  #if ENABLE_BGP_VNC -	vnc_hash = hash_create(encap_hash_key_make, -			       encap_hash_cmp, +	vnc_hash = hash_create(encap_hash_key_make, encap_hash_cmp,  			       "BGP VNC Hash");  #endif  } @@ -454,8 +450,7 @@ static int transit_hash_cmp(const void *p1, const void *p2)  static void transit_init(void)  { -	transit_hash = hash_create(transit_hash_key_make, -				   transit_hash_cmp, +	transit_hash = hash_create(transit_hash_key_make, transit_hash_cmp,  				   "BGP Transit Hash");  } @@ -496,7 +491,8 @@ unsigned int attrhash_key_make(void *p)  #define MIX3(a, b, c)	key = jhash_3words((a), (b), (c), key)  	MIX3(attr->origin, attr->nexthop.s_addr, attr->med); -	MIX3(attr->local_pref, attr->aggregator_as, attr->aggregator_addr.s_addr); +	MIX3(attr->local_pref, attr->aggregator_as, +	     attr->aggregator_addr.s_addr);  	MIX3(attr->weight, attr->mp_nexthop_global_in.s_addr,  	     attr->originator_id.s_addr);  	MIX3(attr->tag, attr->label, attr->label_index); @@ -571,9 +567,8 @@ int attrhash_cmp(const void *p1, const void *p2)  static void attrhash_init(void)  { -	attrhash = hash_create(attrhash_key_make, -			       attrhash_cmp, -			       "BGP Attributes"); +	attrhash = +		hash_create(attrhash_key_make, attrhash_cmp, "BGP Attributes");  }  /* @@ -747,8 +742,8 @@ struct attr *bgp_attr_aggregate_intern(struct bgp *bgp, u_char origin,  		/* If we are not shutting down ourselves and we are  		 * aggregating a route that contains the GSHUT community we  		 * need to remove that community when creating the aggregate */ -		if (!bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN) && -		    community_include(community, gshut)) { +		if (!bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN) +		    && community_include(community, gshut)) {  			community_del_val(community, &gshut);  		} @@ -840,7 +835,6 @@ void bgp_attr_undup(struct attr *new, struct attr *old)  	if (new->lcommunity != old->lcommunity)  		lcommunity_free(&new->lcommunity); -  }  /* Free bgp attribute and aspath. */ @@ -1661,14 +1655,14 @@ int bgp_mp_reach_parse(struct bgp_attr_parser_args *args,  	case BGP_ATTR_NHLEN_VPNV4:  		stream_getl(s); /* RD high */  		stream_getl(s); /* RD low */ -		/* -		 * NOTE: intentional fall through -		 * - for consistency in rx processing -		 * -		 * The following comment is to signal GCC this intention -		 * and supress the warning -		 */ -		/* FALLTHRU */ +				/* +				 * NOTE: intentional fall through +				 * - for consistency in rx processing +				 * +				 * The following comment is to signal GCC this intention +				 * and supress the warning +				 */ +	/* FALLTHRU */  	case BGP_ATTR_NHLEN_IPV4:  		stream_get(&attr->mp_nexthop_global_in, s, IPV4_MAX_BYTELEN);  		/* Probably needed for RFC 2283 */ @@ -1960,8 +1954,7 @@ static int bgp_attr_encap(uint8_t type, struct peer *peer, /* IN */  		/* alloc and copy sub-tlv */  		/* TBD make sure these are freed when attributes are released */  		tlv = XCALLOC(MTYPE_ENCAP_TLV, -			      sizeof(struct bgp_attr_encap_subtlv) -				      + sublength); +			      sizeof(struct bgp_attr_encap_subtlv) + sublength);  		tlv->type = subtype;  		tlv->length = sublength;  		stream_get(tlv->value, peer->curr, sublength); @@ -2715,8 +2708,8 @@ void bgp_packet_mpattr_prefix(struct stream *s, afi_t afi, safi_t safi,  		stream_put(s, &p->u.prefix, PSIZE(p->prefixlen));  	} else if (afi == AFI_L2VPN && safi == SAFI_EVPN) {  		/* EVPN prefix - contents depend on type */ -		bgp_evpn_encode_prefix(s, p, prd, label, num_labels, -				       attr, addpath_encode, addpath_tx_id); +		bgp_evpn_encode_prefix(s, p, prd, label, num_labels, attr, +				       addpath_encode, addpath_tx_id);  	} else if (safi == SAFI_LABELED_UNICAST) {  		/* Prefix write with label. */  		stream_put_labeled_prefix(s, p, label); @@ -2799,8 +2792,9 @@ static void bgp_packet_mpattr_tea(struct bgp *bgp, struct peer *peer,  	if (attrlenfield > 0xff) {  		/* 2-octet length field */ -		stream_putc(s, BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL -				       | BGP_ATTR_FLAG_EXTLEN); +		stream_putc(s, +			    BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL +				    | BGP_ATTR_FLAG_EXTLEN);  		stream_putc(s, attrtype);  		stream_putw(s, attrlenfield & 0xffff);  	} else { @@ -2867,9 +2861,9 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,  		mpattrlen_pos = bgp_packet_mpattr_start(s, peer, afi, safi,  							vecarr, attr); -		bgp_packet_mpattr_prefix(s, afi, safi, p, prd, -					 label, num_labels, -					 addpath_encode, addpath_tx_id, attr); +		bgp_packet_mpattr_prefix(s, afi, safi, p, prd, label, +					 num_labels, addpath_encode, +					 addpath_tx_id, attr);  		bgp_packet_mpattr_end(s, mpattrlen_pos);  	} @@ -3039,14 +3033,15 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,  	if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)  	    && (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES))) {  		if (attr->community->size * 4 > 255) { -			stream_putc(s, BGP_ATTR_FLAG_OPTIONAL -					       | BGP_ATTR_FLAG_TRANS -					       | BGP_ATTR_FLAG_EXTLEN); +			stream_putc(s, +				    BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS +					    | BGP_ATTR_FLAG_EXTLEN);  			stream_putc(s, BGP_ATTR_COMMUNITIES);  			stream_putw(s, attr->community->size * 4);  		} else { -			stream_putc(s, BGP_ATTR_FLAG_OPTIONAL -					       | BGP_ATTR_FLAG_TRANS); +			stream_putc(s, +				    BGP_ATTR_FLAG_OPTIONAL +					    | BGP_ATTR_FLAG_TRANS);  			stream_putc(s, BGP_ATTR_COMMUNITIES);  			stream_putc(s, attr->community->size * 4);  		} @@ -3060,14 +3055,15 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,  		       PEER_FLAG_SEND_LARGE_COMMUNITY)  	    && (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES))) {  		if (lcom_length(attr->lcommunity) > 255) { -			stream_putc(s, BGP_ATTR_FLAG_OPTIONAL -					       | BGP_ATTR_FLAG_TRANS -					       | BGP_ATTR_FLAG_EXTLEN); +			stream_putc(s, +				    BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS +					    | BGP_ATTR_FLAG_EXTLEN);  			stream_putc(s, BGP_ATTR_LARGE_COMMUNITIES);  			stream_putw(s, lcom_length(attr->lcommunity));  		} else { -			stream_putc(s, BGP_ATTR_FLAG_OPTIONAL -					       | BGP_ATTR_FLAG_TRANS); +			stream_putc(s, +				    BGP_ATTR_FLAG_OPTIONAL +					    | BGP_ATTR_FLAG_TRANS);  			stream_putc(s, BGP_ATTR_LARGE_COMMUNITIES);  			stream_putc(s, lcom_length(attr->lcommunity));  		} @@ -3119,14 +3115,16 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,  		if (peer->sort == BGP_PEER_IBGP  		    || peer->sort == BGP_PEER_CONFED) {  			if (attr->ecommunity->size * 8 > 255) { -				stream_putc(s, BGP_ATTR_FLAG_OPTIONAL -						       | BGP_ATTR_FLAG_TRANS -						       | BGP_ATTR_FLAG_EXTLEN); +				stream_putc(s, +					    BGP_ATTR_FLAG_OPTIONAL +						    | BGP_ATTR_FLAG_TRANS +						    | BGP_ATTR_FLAG_EXTLEN);  				stream_putc(s, BGP_ATTR_EXT_COMMUNITIES);  				stream_putw(s, attr->ecommunity->size * 8);  			} else { -				stream_putc(s, BGP_ATTR_FLAG_OPTIONAL -						       | BGP_ATTR_FLAG_TRANS); +				stream_putc(s, +					    BGP_ATTR_FLAG_OPTIONAL +						    | BGP_ATTR_FLAG_TRANS);  				stream_putc(s, BGP_ATTR_EXT_COMMUNITIES);  				stream_putc(s, attr->ecommunity->size * 8);  			} @@ -3192,8 +3190,9 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,  			label_index = attr->label_index;  			if (label_index != BGP_INVALID_LABEL_INDEX) { -				stream_putc(s, BGP_ATTR_FLAG_OPTIONAL -						       | BGP_ATTR_FLAG_TRANS); +				stream_putc(s, +					    BGP_ATTR_FLAG_OPTIONAL +						    | BGP_ATTR_FLAG_TRANS);  				stream_putc(s, BGP_ATTR_PREFIX_SID);  				stream_putc(s, 10);  				stream_putc(s, BGP_PREFIX_SID_LABEL_INDEX); @@ -3221,8 +3220,9 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,  		 */  		aspath = aspath_delete_confed_seq(aspath); -		stream_putc(s, BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL -				       | BGP_ATTR_FLAG_EXTLEN); +		stream_putc(s, +			    BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL +				    | BGP_ATTR_FLAG_EXTLEN);  		stream_putc(s, BGP_ATTR_AS4_PATH);  		aspath_sizep = stream_get_endp(s);  		stream_putw(s, 0); @@ -3264,8 +3264,10 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,  		stream_putc(s, 9); // Length  		stream_putc(s, 0); // Flags  		stream_putc(s, 6); // Tunnel type: Ingress Replication (6) -		stream_put(s, &(attr->label), BGP_LABEL_BYTES); // MPLS Label / VXLAN VNI -		stream_put_ipv4(s, attr->nexthop.s_addr); // Unicast tunnel endpoint IP address +		stream_put(s, &(attr->label), +			   BGP_LABEL_BYTES); // MPLS Label / VXLAN VNI +		stream_put_ipv4(s, attr->nexthop.s_addr); // Unicast tunnel +							  // endpoint IP address  	}  	/* Unknown transit attribute. */ @@ -3311,8 +3313,7 @@ void bgp_packet_mpunreach_prefix(struct stream *s, struct prefix *p, afi_t afi,  		num_labels = 1;  	} -	return bgp_packet_mpattr_prefix(s, afi, safi, p, prd, -					label, num_labels, +	return bgp_packet_mpattr_prefix(s, afi, safi, p, prd, label, num_labels,  					addpath_encode, addpath_tx_id, attr);  } @@ -3422,14 +3423,15 @@ void bgp_dump_routes_attr(struct stream *s, struct attr *attr,  	/* Community attribute. */  	if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES)) {  		if (attr->community->size * 4 > 255) { -			stream_putc(s, BGP_ATTR_FLAG_OPTIONAL -					       | BGP_ATTR_FLAG_TRANS -					       | BGP_ATTR_FLAG_EXTLEN); +			stream_putc(s, +				    BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS +					    | BGP_ATTR_FLAG_EXTLEN);  			stream_putc(s, BGP_ATTR_COMMUNITIES);  			stream_putw(s, attr->community->size * 4);  		} else { -			stream_putc(s, BGP_ATTR_FLAG_OPTIONAL -					       | BGP_ATTR_FLAG_TRANS); +			stream_putc(s, +				    BGP_ATTR_FLAG_OPTIONAL +					    | BGP_ATTR_FLAG_TRANS);  			stream_putc(s, BGP_ATTR_COMMUNITIES);  			stream_putc(s, attr->community->size * 4);  		} @@ -3439,19 +3441,21 @@ void bgp_dump_routes_attr(struct stream *s, struct attr *attr,  	/* Large Community attribute. */  	if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES)) {  		if (lcom_length(attr->lcommunity) > 255) { -			stream_putc(s, BGP_ATTR_FLAG_OPTIONAL -					       | BGP_ATTR_FLAG_TRANS -					       | BGP_ATTR_FLAG_EXTLEN); +			stream_putc(s, +				    BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS +					    | BGP_ATTR_FLAG_EXTLEN);  			stream_putc(s, BGP_ATTR_LARGE_COMMUNITIES);  			stream_putw(s, lcom_length(attr->lcommunity));  		} else { -			stream_putc(s, BGP_ATTR_FLAG_OPTIONAL -					       | BGP_ATTR_FLAG_TRANS); +			stream_putc(s, +				    BGP_ATTR_FLAG_OPTIONAL +					    | BGP_ATTR_FLAG_TRANS);  			stream_putc(s, BGP_ATTR_LARGE_COMMUNITIES);  			stream_putc(s, lcom_length(attr->lcommunity));  		} -		stream_put(s, attr->lcommunity->val, lcom_length(attr->lcommunity)); +		stream_put(s, attr->lcommunity->val, +			   lcom_length(attr->lcommunity));  	}  	/* Add a MP_NLRI attribute to dump the IPv6 next hop */ @@ -3490,8 +3494,9 @@ void bgp_dump_routes_attr(struct stream *s, struct attr *attr,  	/* Prefix SID */  	if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_PREFIX_SID)) {  		if (attr->label_index != BGP_INVALID_LABEL_INDEX) { -			stream_putc(s, BGP_ATTR_FLAG_OPTIONAL -					       | BGP_ATTR_FLAG_TRANS); +			stream_putc(s, +				    BGP_ATTR_FLAG_OPTIONAL +					    | BGP_ATTR_FLAG_TRANS);  			stream_putc(s, BGP_ATTR_PREFIX_SID);  			stream_putc(s, 10);  			stream_putc(s, BGP_PREFIX_SID_LABEL_INDEX); diff --git a/bgpd/bgp_attr.h b/bgpd/bgp_attr.h index 1b1471a198..1a49e4ecf2 100644 --- a/bgpd/bgp_attr.h +++ b/bgpd/bgp_attr.h @@ -215,10 +215,8 @@ struct transit {  /* "(void) 0" will generate a compiler error.  this is a safety check to   * ensure we're not using a value that exceeds the bit size of attr->flag. */ -#define ATTR_FLAG_BIT(X) \ -	__builtin_choose_expr((X) >= 1 && (X) <= 64, \ -			      1ULL << ((X) - 1), \ -			      (void) 0) +#define ATTR_FLAG_BIT(X)                                                       \ +	__builtin_choose_expr((X) >= 1 && (X) <= 64, 1ULL << ((X)-1), (void)0)  #define BGP_CLUSTER_LIST_LENGTH(attr)                                          \  	(((attr)->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))                 \ @@ -260,8 +258,8 @@ extern bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *,  				       struct bpacket_attr_vec_arr *vecarr,  				       struct prefix *, afi_t, safi_t,  				       struct peer *, struct prefix_rd *, -				       mpls_label_t *, u_int32_t, -				       int, u_int32_t); +				       mpls_label_t *, u_int32_t, int, +				       u_int32_t);  extern void bgp_dump_routes_attr(struct stream *, struct attr *,  				 struct prefix *);  extern int attrhash_cmp(const void *, const void *); @@ -320,9 +318,9 @@ extern size_t bgp_packet_mpunreach_start(struct stream *s, afi_t afi,  					 safi_t safi);  extern void bgp_packet_mpunreach_prefix(struct stream *s, struct prefix *p,  					afi_t afi, safi_t safi, -					struct prefix_rd *prd, -					mpls_label_t *, u_int32_t, -					int, u_int32_t, struct attr *); +					struct prefix_rd *prd, mpls_label_t *, +					u_int32_t, int, u_int32_t, +					struct attr *);  extern void bgp_packet_mpunreach_end(struct stream *s, size_t attrlen_pnt);  static inline int bgp_rmap_nhop_changed(u_int32_t out_rmap_flags, diff --git a/bgpd/bgp_attr_evpn.c b/bgpd/bgp_attr_evpn.c index e74fa5a2be..8d5eff9a6f 100644 --- a/bgpd/bgp_attr_evpn.c +++ b/bgpd/bgp_attr_evpn.c @@ -106,8 +106,7 @@ char *ecom_mac2str(char *ecom_mac)  }  /* Fetch router-mac from extended community */ -void bgp_attr_rmac(struct attr *attr, -		   struct ethaddr *rmac) +void bgp_attr_rmac(struct attr *attr, struct ethaddr *rmac)  {  	int i = 0;  	struct ecommunity *ecom; @@ -126,8 +125,8 @@ void bgp_attr_rmac(struct attr *attr,  		type = *pnt++;  		sub_type = *pnt++; -		if (!(type == ECOMMUNITY_ENCODE_EVPN && -		     sub_type == ECOMMUNITY_EVPN_SUBTYPE_ROUTERMAC)) +		if (!(type == ECOMMUNITY_ENCODE_EVPN +		      && sub_type == ECOMMUNITY_EVPN_SUBTYPE_ROUTERMAC))  			continue;  		memcpy(rmac, pnt, ETH_ALEN); @@ -139,8 +138,8 @@ void bgp_attr_rmac(struct attr *attr,   */  uint8_t bgp_attr_default_gw(struct attr *attr)  { -	struct ecommunity	*ecom; -	int			i; +	struct ecommunity *ecom; +	int i;  	ecom = attr->ecommunity;  	if (!ecom || !ecom->size) @@ -149,15 +148,15 @@ uint8_t bgp_attr_default_gw(struct attr *attr)  	/* If there is a default gw extendd community return true otherwise  	 * return 0 */  	for (i = 0; i < ecom->size; i++) { -		u_char		*pnt; -		u_char		type, sub_type; +		u_char *pnt; +		u_char type, sub_type;  		pnt = (ecom->val + (i * ECOMMUNITY_SIZE));  		type = *pnt++;  		sub_type = *pnt++;  		if ((type == ECOMMUNITY_ENCODE_OPAQUE -		      && sub_type == ECOMMUNITY_EVPN_SUBTYPE_DEF_GW)) +		     && sub_type == ECOMMUNITY_EVPN_SUBTYPE_DEF_GW))  			return 1;  	} diff --git a/bgpd/bgp_community.c b/bgpd/bgp_community.c index 7c83eaa091..b78edcb2ff 100644 --- a/bgpd/bgp_community.c +++ b/bgpd/bgp_community.c @@ -222,7 +222,8 @@ static void set_community_string(struct community *com, bool make_json)  		if (make_json) {  			json_object_string_add(com->json, "string", ""); -			json_object_object_add(com->json, "list", json_community_list); +			json_object_object_add(com->json, "list", +					       json_community_list);  		}  		com->str = str;  		return; @@ -277,24 +278,30 @@ static void set_community_string(struct community *com, bool make_json)  			strcpy(pnt, "internet");  			pnt += strlen("internet");  			if (make_json) { -				json_string = json_object_new_string("internet"); -				json_object_array_add(json_community_list, json_string); +				json_string = +					json_object_new_string("internet"); +				json_object_array_add(json_community_list, +						      json_string);  			}  			break;  		case COMMUNITY_NO_EXPORT:  			strcpy(pnt, "no-export");  			pnt += strlen("no-export");  			if (make_json) { -				json_string = json_object_new_string("noExport"); -				json_object_array_add(json_community_list, json_string); +				json_string = +					json_object_new_string("noExport"); +				json_object_array_add(json_community_list, +						      json_string);  			}  			break;  		case COMMUNITY_NO_ADVERTISE:  			strcpy(pnt, "no-advertise");  			pnt += strlen("no-advertise");  			if (make_json) { -				json_string = json_object_new_string("noAdvertise"); -				json_object_array_add(json_community_list, json_string); +				json_string = +					json_object_new_string("noAdvertise"); +				json_object_array_add(json_community_list, +						      json_string);  			}  			break;  		case COMMUNITY_LOCAL_AS: @@ -302,15 +309,18 @@ static void set_community_string(struct community *com, bool make_json)  			pnt += strlen("local-AS");  			if (make_json) {  				json_string = json_object_new_string("localAs"); -				json_object_array_add(json_community_list, json_string); +				json_object_array_add(json_community_list, +						      json_string);  			}  			break;  		case COMMUNITY_GSHUT:  			strcpy(pnt, "graceful-shutdown");  			pnt += strlen("graceful-shutdown");  			if (make_json) { -				json_string = json_object_new_string("gracefulShutdown"); -				json_object_array_add(json_community_list, json_string); +				json_string = json_object_new_string( +					"gracefulShutdown"); +				json_object_array_add(json_community_list, +						      json_string);  			}  			break;  		default: @@ -319,7 +329,8 @@ static void set_community_string(struct community *com, bool make_json)  			sprintf(pnt, "%u:%d", as, val);  			if (make_json) {  				json_string = json_object_new_string(pnt); -				json_object_array_add(json_community_list, json_string); +				json_object_array_add(json_community_list, +						      json_string);  			}  			pnt += strlen(pnt);  			break; @@ -545,7 +556,8 @@ community_gettoken(const char *buf, enum community_token *token, u_int32_t *val)  			p += strlen("local-AS");  			return p;  		} -		if (strncmp(p, "graceful-shutdown", strlen("graceful-shutdown")) == 0) { +		if (strncmp(p, "graceful-shutdown", strlen("graceful-shutdown")) +		    == 0) {  			*val = COMMUNITY_GSHUT;  			*token = community_token_gshut;  			p += strlen("graceful-shutdown"); @@ -662,10 +674,10 @@ struct hash *community_hash(void)  /* Initialize comminity related hash. */  void community_init(void)  { -	comhash = hash_create( -		(unsigned int (*)(void *))community_hash_make, -		(int (*)(const void *, const void *))community_cmp, -		"BGP Community Hash"); +	comhash = +		hash_create((unsigned int (*)(void *))community_hash_make, +			    (int (*)(const void *, const void *))community_cmp, +			    "BGP Community Hash");  }  void community_finish(void) diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c index 36ffb0e9c5..e2f97bf4fe 100644 --- a/bgpd/bgp_damp.c +++ b/bgpd/bgp_damp.c @@ -542,7 +542,7 @@ static const char *bgp_get_reuse_time(unsigned int penalty, char *buf,  	} else  		reuse_time = 0; -/* Making formatted timer strings. */ +	/* Making formatted timer strings. */  	if (reuse_time == 0) {  		if (use_json)  			json_object_int_add(json, "reuseTimerMsecs", 0); diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c index 7dafde51a1..cea1c6baa2 100644 --- a/bgpd/bgp_ecommunity.c +++ b/bgpd/bgp_ecommunity.c @@ -260,8 +260,7 @@ int ecommunity_cmp(const void *arg1, const void *arg2)  /* Initialize Extended Comminities related hash. */  void ecommunity_init(void)  { -	ecomhash = hash_create(ecommunity_hash_make, -			       ecommunity_cmp, +	ecomhash = hash_create(ecommunity_hash_make, ecommunity_cmp,  			       "BGP ecommunity hash");  } @@ -690,7 +689,7 @@ char *ecommunity_ecom2str(struct ecommunity *ecom, int format, int filter)  				tunneltype = ntohs(tunneltype);  				len = sprintf(str_buf + str_pnt, "ET:%d",  					      tunneltype); -			}  else if (*pnt == ECOMMUNITY_EVPN_SUBTYPE_DEF_GW) { +			} else if (*pnt == ECOMMUNITY_EVPN_SUBTYPE_DEF_GW) {  				len = sprintf(str_buf + str_pnt,  					      "Default Gateway");  			} else diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index e5863e4980..fc7549671e 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -193,8 +193,7 @@ static struct vrf_irt_node *lookup_vrf_import_rt(struct ecommunity_val *rt)  /*   * Is specified VRF present on the RT's list of "importing" VRFs?   */ -static int is_vrf_present_in_irt_vrfs(struct list *vrfs, -				      struct bgp *bgp_vrf) +static int is_vrf_present_in_irt_vrfs(struct list *vrfs, struct bgp *bgp_vrf)  {  	struct listnode *node = NULL, *nnode = NULL;  	struct bgp *tmp_bgp_vrf = NULL; @@ -353,8 +352,7 @@ static inline void mask_ecom_global_admin(struct ecommunity_val *dst,   * Map one RT to specified VRF.   * bgp_vrf = BGP vrf instance   */ -static void map_vrf_to_rt(struct bgp *bgp_vrf, -			  struct ecommunity_val *eval) +static void map_vrf_to_rt(struct bgp *bgp_vrf, struct ecommunity_val *eval)  {  	struct vrf_irt_node *irt = NULL;  	struct ecommunity_val eval_tmp; @@ -365,8 +363,7 @@ static void map_vrf_to_rt(struct bgp *bgp_vrf,  	 * as the RT for EBGP peering too.  	 */  	memcpy(&eval_tmp, eval, ECOMMUNITY_SIZE); -	if (!CHECK_FLAG(bgp_vrf->vrf_flags, -			BGP_VRF_IMPORT_RT_CFGD)) +	if (!CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_IMPORT_RT_CFGD))  		mask_ecom_global_admin(&eval_tmp, eval);  	irt = lookup_vrf_import_rt(&eval_tmp); @@ -389,8 +386,7 @@ static void map_vrf_to_rt(struct bgp *bgp_vrf,   * VRFs for this RT, then the RT hash is deleted.   * bgp_vrf: BGP VRF specific instance   */ -static void unmap_vrf_from_rt(struct bgp *bgp_vrf, -			      struct vrf_irt_node *irt) +static void unmap_vrf_from_rt(struct bgp *bgp_vrf, struct vrf_irt_node *irt)  {  	/* Delete VRF from list for this RT. */  	listnode_delete(irt->vrfs, bgp_vrf); @@ -503,9 +499,9 @@ static int bgp_zebra_send_remote_macip(struct bgp *bgp, struct bgpevpn *vpn,  	s = zclient->obuf;  	stream_reset(s); -	zclient_create_header(s, add ? ZEBRA_REMOTE_MACIP_ADD -				     : ZEBRA_REMOTE_MACIP_DEL, -			      bgp->vrf_id); +	zclient_create_header( +		s, add ? ZEBRA_REMOTE_MACIP_ADD : ZEBRA_REMOTE_MACIP_DEL, +		bgp->vrf_id);  	stream_putl(s, vpn->vni);  	stream_put(s, &p->prefix.mac.octet, ETH_ALEN); /* Mac Addr */  	/* IP address length and IP address, if any. */ @@ -526,13 +522,13 @@ static int bgp_zebra_send_remote_macip(struct bgp *bgp, struct bgpevpn *vpn,  	stream_putw_at(s, 0, stream_get_endp(s));  	if (bgp_debug_zebra(NULL)) -		zlog_debug("Tx %s MACIP, VNI %u MAC %s IP %s (flags: 0x%x) remote VTEP %s", -			   add ? "ADD" : "DEL", vpn->vni, -			   prefix_mac2str(&p->prefix.mac, buf1, sizeof(buf1)), -			   ipaddr2str(&p->prefix.ip, buf3, sizeof(buf3)), -			   flags, -			   inet_ntop(AF_INET, &remote_vtep_ip, buf2, -				     sizeof(buf2))); +		zlog_debug( +			"Tx %s MACIP, VNI %u MAC %s IP %s (flags: 0x%x) remote VTEP %s", +			add ? "ADD" : "DEL", vpn->vni, +			prefix_mac2str(&p->prefix.mac, buf1, sizeof(buf1)), +			ipaddr2str(&p->prefix.ip, buf3, sizeof(buf3)), flags, +			inet_ntop(AF_INET, &remote_vtep_ip, buf2, +				  sizeof(buf2)));  	return zclient_send_message(zclient);  } @@ -556,9 +552,9 @@ static int bgp_zebra_send_remote_vtep(struct bgp *bgp, struct bgpevpn *vpn,  	s = zclient->obuf;  	stream_reset(s); -	zclient_create_header(s, add ? ZEBRA_REMOTE_VTEP_ADD -				     : ZEBRA_REMOTE_VTEP_DEL, -			      bgp->vrf_id); +	zclient_create_header( +		s, add ? ZEBRA_REMOTE_VTEP_ADD : ZEBRA_REMOTE_VTEP_DEL, +		bgp->vrf_id);  	stream_putl(s, vpn->vni);  	if (IS_EVPN_PREFIX_IPADDR_V4(p))  		stream_put_in_addr(s, &p->prefix.ip.ipaddr_v4); @@ -608,8 +604,8 @@ static void build_evpn_type5_route_extcomm(struct bgp *bgp_vrf,  	vrf_export_rtl = bgp_vrf->vrf_export_rtl;  	if (vrf_export_rtl && !list_isempty(vrf_export_rtl)) {  		for (ALL_LIST_ELEMENTS(vrf_export_rtl, node, nnode, ecom)) -			attr->ecommunity = ecommunity_merge(attr->ecommunity, -							    ecom); +			attr->ecommunity = +				ecommunity_merge(attr->ecommunity, ecom);  	}  	/* add the router mac extended community */ @@ -618,8 +614,8 @@ static void build_evpn_type5_route_extcomm(struct bgp *bgp_vrf,  		encode_rmac_extcomm(&eval_rmac, &attr->rmac);  		ecom_rmac.size = 1;  		ecom_rmac.val = (uint8_t *)eval_rmac.val; -		attr->ecommunity = ecommunity_merge(attr->ecommunity, -						    &ecom_rmac); +		attr->ecommunity = +			ecommunity_merge(attr->ecommunity, &ecom_rmac);  	}  	attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES); @@ -675,9 +671,8 @@ static void build_evpn_route_extcomm(struct bgpevpn *vpn, struct attr *attr,  		if (vrf_export_rtl && !list_isempty(vrf_export_rtl)) {  			for (ALL_LIST_ELEMENTS(vrf_export_rtl, node, nnode,  					       ecom)) -				attr->ecommunity = -					ecommunity_merge(attr->ecommunity, -							 ecom); +				attr->ecommunity = ecommunity_merge( +					attr->ecommunity, ecom);  		}  	} @@ -695,14 +690,14 @@ static void build_evpn_route_extcomm(struct bgpevpn *vpn, struct attr *attr,  	 * only attach l3-vni rmac for ipv4 address family and if we are  	 * advertising both the labels in type-2 routes  	 */ -	if (afi == AFI_IP && !is_zero_mac(&attr->rmac) && -	    CHECK_FLAG(vpn->flags, VNI_FLAG_USE_TWO_LABELS)) { +	if (afi == AFI_IP && !is_zero_mac(&attr->rmac) +	    && CHECK_FLAG(vpn->flags, VNI_FLAG_USE_TWO_LABELS)) {  		memset(&ecom_rmac, 0, sizeof(ecom_rmac));  		encode_rmac_extcomm(&eval_rmac, &attr->rmac);  		ecom_rmac.size = 1;  		ecom_rmac.val = (uint8_t *)eval_rmac.val; -		attr->ecommunity = ecommunity_merge(attr->ecommunity, -						    &ecom_rmac); +		attr->ecommunity = +			ecommunity_merge(attr->ecommunity, &ecom_rmac);  	}  	if (attr->default_gw) { @@ -710,8 +705,8 @@ static void build_evpn_route_extcomm(struct bgpevpn *vpn, struct attr *attr,  		encode_default_gw_extcomm(&eval_default_gw);  		ecom_default_gw.size = 1;  		ecom_default_gw.val = (uint8_t *)eval_default_gw.val; -		attr->ecommunity = ecommunity_merge(attr->ecommunity, -						    &ecom_default_gw); +		attr->ecommunity = +			ecommunity_merge(attr->ecommunity, &ecom_default_gw);  	}  	attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES); @@ -848,7 +843,7 @@ static int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn,  	afi_t afi = AFI_L2VPN;  	safi_t safi = SAFI_EVPN;  	int ret = 0; -	u_char			flags = 0; +	u_char flags = 0;  	/* Compute the best path. */  	bgp_best_selection(bgp, rn, &bgp->maxpaths[afi][safi], &old_and_new, @@ -871,10 +866,9 @@ static int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn,  				SET_FLAG(flags, ZEBRA_MACIP_TYPE_STICKY);  			if (old_select->attr->default_gw)  				SET_FLAG(flags, ZEBRA_MACIP_TYPE_GW); -			ret = evpn_zebra_install(bgp, vpn, -						 (struct prefix_evpn *)&rn->p, -						 old_select->attr->nexthop, -						 flags); +			ret = evpn_zebra_install( +				bgp, vpn, (struct prefix_evpn *)&rn->p, +				old_select->attr->nexthop, flags);  		}  		UNSET_FLAG(old_select->flags, BGP_INFO_MULTIPATH_CHG);  		bgp_zebra_clear_route_change_flags(rn); @@ -906,8 +900,7 @@ static int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn,  		if (new_select->attr->default_gw)  			SET_FLAG(flags, ZEBRA_MACIP_TYPE_GW);  		ret = evpn_zebra_install(bgp, vpn, (struct prefix_evpn *)&rn->p, -					 new_select->attr->nexthop, -					 flags); +					 new_select->attr->nexthop, flags);  		/* If an old best existed and it was a "local" route, the only  		 * reason  		 * it would be supplanted is due to MAC mobility procedures. So, @@ -942,8 +935,8 @@ static int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn,   */  static int evpn_route_is_def_gw(struct bgp *bgp, struct bgp_node *rn)  { -	struct bgp_info		*tmp_ri = NULL; -	struct bgp_info		*local_ri = NULL; +	struct bgp_info *tmp_ri = NULL; +	struct bgp_info *local_ri = NULL;  	local_ri = NULL;  	for (tmp_ri = rn->info; tmp_ri; tmp_ri = tmp_ri->next) { @@ -1053,9 +1046,8 @@ static int update_evpn_type5_route_entry(struct bgp *bgp_def,  }  /* update evpn type-5 route entry */ -static int update_evpn_type5_route(struct bgp *bgp_vrf, -				   struct prefix_evpn *evp, -				   struct attr* src_attr) +static int update_evpn_type5_route(struct bgp *bgp_vrf, struct prefix_evpn *evp, +				   struct attr *src_attr)  {  	afi_t afi = AFI_L2VPN;  	safi_t safi = SAFI_EVPN; @@ -1088,14 +1080,12 @@ static int update_evpn_type5_route(struct bgp *bgp_vrf,  	/* get the route node in global table */  	rn = bgp_afi_node_get(bgp_def->rib[afi][safi], afi, safi, -			      (struct prefix *)evp, -			      &bgp_vrf->vrf_prd); +			      (struct prefix *)evp, &bgp_vrf->vrf_prd);  	assert(rn);  	/* create or update the route entry within the route node */ -	update_evpn_type5_route_entry(bgp_def, bgp_vrf, -				      afi, safi, -				      rn, &attr, &route_changed); +	update_evpn_type5_route_entry(bgp_def, bgp_vrf, afi, safi, rn, &attr, +				      &route_changed);  	/* schedule for processing and unlock node */  	if (route_changed) { @@ -1200,8 +1190,8 @@ static int update_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn,  		 * Only attach second label if we are advertising two labels for  		 * type-2 routes.  		 */ -		if (evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE && -		    CHECK_FLAG(vpn->flags, VNI_FLAG_USE_TWO_LABELS)) { +		if (evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE +		    && CHECK_FLAG(vpn->flags, VNI_FLAG_USE_TWO_LABELS)) {  			vni_t l3vni;  			l3vni = bgpevpn_get_l3vni(vpn); @@ -1225,8 +1215,9 @@ static int update_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn,  			 * be advertised with right labels.  			 */  			vni2label(vpn->vni, &label[0]); -			if (evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE && -			    CHECK_FLAG(vpn->flags, VNI_FLAG_USE_TWO_LABELS)) { +			if (evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE +			    && CHECK_FLAG(vpn->flags, +					  VNI_FLAG_USE_TWO_LABELS)) {  				vni_t l3vni;  				l3vni = bgpevpn_get_l3vni(vpn); @@ -1294,9 +1285,8 @@ static int update_evpn_route(struct bgp *bgp, struct bgpevpn *vpn,  	vni2label(vpn->vni, &(attr.label));  	/* Set up RT and ENCAP extended community. */ -	build_evpn_route_extcomm(vpn, &attr, -				 IS_EVPN_PREFIX_IPADDR_V4(p) ? -					AFI_IP : AFI_IP6); +	build_evpn_route_extcomm( +		vpn, &attr, IS_EVPN_PREFIX_IPADDR_V4(p) ? AFI_IP : AFI_IP6);  	/* First, create (or fetch) route node within the VNI. */  	/* NOTE: There is no RD here. */ @@ -1340,9 +1330,8 @@ static int update_evpn_route(struct bgp *bgp, struct bgpevpn *vpn,  /* Delete EVPN type5 route entry from global table */  static void delete_evpn_type5_route_entry(struct bgp *bgp_def, -					  struct bgp *bgp_vrf, -					  afi_t afi, safi_t safi, -					  struct bgp_node *rn, +					  struct bgp *bgp_vrf, afi_t afi, +					  safi_t safi, struct bgp_node *rn,  					  struct bgp_info **ri)  {  	struct bgp_info *tmp_ri = NULL; @@ -1364,8 +1353,7 @@ static void delete_evpn_type5_route_entry(struct bgp *bgp_def,  }  /* Delete EVPN type5 route */ -static int delete_evpn_type5_route(struct bgp *bgp_vrf, -				   struct prefix_evpn *evp) +static int delete_evpn_type5_route(struct bgp *bgp_vrf, struct prefix_evpn *evp)  {  	afi_t afi = AFI_L2VPN;  	safi_t safi = SAFI_EVPN; @@ -1553,12 +1541,12 @@ static int update_all_type2_routes(struct bgp *bgp, struct bgpevpn *vpn)  		if (IS_EVPN_PREFIX_IPADDR_V4(evp)) {  			if (evpn_route_is_sticky(bgp, rn))  				update_evpn_route_entry(bgp, vpn, afi, safi, rn, -							&attr_sticky, 0, 1, -							&ri, 0); +							&attr_sticky, 0, 1, &ri, +							0);  			else if (evpn_route_is_def_gw(bgp, rn))  				update_evpn_route_entry(bgp, vpn, afi, safi, rn, -							&attr_def_gw, 0, 1, -							&ri, 0); +							&attr_def_gw, 0, 1, &ri, +							0);  			else  				update_evpn_route_entry(bgp, vpn, afi, safi, rn,  							&attr, 0, 1, &ri, 0); @@ -1573,8 +1561,8 @@ static int update_all_type2_routes(struct bgp *bgp, struct bgpevpn *vpn)  							&ri, 0);  			else  				update_evpn_route_entry(bgp, vpn, afi, safi, rn, -							&attr_ip6, 0, 1, -							&ri, 0); +							&attr_ip6, 0, 1, &ri, +							0);  		}  		/* If a local route exists for this prefix, we need to update @@ -1819,10 +1807,11 @@ static int install_evpn_route_entry_in_vrf(struct bgp *bgp_vrf,  		ip_prefix_from_type5_prefix(evp, pp);  	if (bgp_debug_zebra(NULL)) { -		zlog_debug("installing evpn prefix %s as ip prefix %s in vrf %s", -			   prefix2str(evp, buf, sizeof(buf)), -			   prefix2str(pp, buf1, sizeof(buf)), -			   vrf_id_to_name(bgp_vrf->vrf_id)); +		zlog_debug( +			"installing evpn prefix %s as ip prefix %s in vrf %s", +			prefix2str(evp, buf, sizeof(buf)), +			prefix2str(pp, buf1, sizeof(buf)), +			vrf_id_to_name(bgp_vrf->vrf_id));  	}  	/* Create (or fetch) route within the VRF. */ @@ -1983,10 +1972,11 @@ static int uninstall_evpn_route_entry_in_vrf(struct bgp *bgp_vrf,  		ip_prefix_from_type5_prefix(evp, pp);  	if (bgp_debug_zebra(NULL)) { -		zlog_debug("uninstalling evpn prefix %s as ip prefix %s in vrf %s", -			   prefix2str(evp, buf, sizeof(buf)), -			   prefix2str(pp, buf1, sizeof(buf)), -			   vrf_id_to_name(bgp_vrf->vrf_id)); +		zlog_debug( +			"uninstalling evpn prefix %s as ip prefix %s in vrf %s", +			prefix2str(evp, buf, sizeof(buf)), +			prefix2str(pp, buf1, sizeof(buf)), +			vrf_id_to_name(bgp_vrf->vrf_id));  	}  	/* Locate route within the VRF. */ @@ -2068,8 +2058,7 @@ static int uninstall_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn,   * Given a route entry and a VRF, see if this route entry should be   * imported into the VRF i.e., RTs match.   */ -static int is_route_matching_for_vrf(struct bgp *bgp_vrf, -				     struct bgp_info *ri) +static int is_route_matching_for_vrf(struct bgp *bgp_vrf, struct bgp_info *ri)  {  	struct attr *attr = ri->attr;  	struct ecommunity *ecom; @@ -2202,8 +2191,7 @@ static int is_route_matching_for_vni(struct bgp *bgp, struct bgpevpn *vpn,   * Install or uninstall mac-ip routes are appropriate for this   * particular VRF.   */ -static int install_uninstall_routes_for_vrf(struct bgp *bgp_vrf, -					    int install) +static int install_uninstall_routes_for_vrf(struct bgp *bgp_vrf, int install)  {  	afi_t afi;  	safi_t safi; @@ -2234,13 +2222,14 @@ static int install_uninstall_routes_for_vrf(struct bgp *bgp_vrf,  			struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p;  			/* if not mac-ip route skip this route */ -			if (!(evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE || -			      evp->prefix.route_type == BGP_EVPN_IP_PREFIX_ROUTE)) +			if (!(evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE +			      || evp->prefix.route_type +					 == BGP_EVPN_IP_PREFIX_ROUTE))  				continue;  			/* if not a mac+ip route skip this route */ -			if (!(IS_EVPN_PREFIX_IPADDR_V4(evp) || -			      IS_EVPN_PREFIX_IPADDR_V6(evp))) +			if (!(IS_EVPN_PREFIX_IPADDR_V4(evp) +			      || IS_EVPN_PREFIX_IPADDR_V6(evp)))  				continue;  			for (ri = rn->info; ri; ri = ri->next) { @@ -2254,12 +2243,10 @@ static int install_uninstall_routes_for_vrf(struct bgp *bgp_vrf,  				if (is_route_matching_for_vrf(bgp_vrf, ri)) {  					if (install) -						ret = -						install_evpn_route_entry_in_vrf( +						ret = install_evpn_route_entry_in_vrf(  							bgp_vrf, evp, ri);  					else -						ret = -						uninstall_evpn_route_entry_in_vrf( +						ret = uninstall_evpn_route_entry_in_vrf(  							bgp_vrf, evp, ri);  					if (ret) { @@ -2269,7 +2256,8 @@ static int install_uninstall_routes_for_vrf(struct bgp *bgp_vrf,  								: "uninstall",  							prefix2str(evp, buf,  								   sizeof(buf)), -							vrf_id_to_name(bgp_vrf->vrf_id)); +							vrf_id_to_name( +								bgp_vrf->vrf_id));  						return ret;  					}  				} @@ -2425,24 +2413,24 @@ static int install_uninstall_route_in_vrfs(struct bgp *bgp_def, afi_t afi,  	struct listnode *node, *nnode;  	/* Only type-2/type-5 routes go into a VRF */ -	if (!(evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE || -	      evp->prefix.route_type == BGP_EVPN_IP_PREFIX_ROUTE)) +	if (!(evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE +	      || evp->prefix.route_type == BGP_EVPN_IP_PREFIX_ROUTE))  		return 0;  	/* if it is type-2 route and not a mac+ip route skip this route */ -	if ((evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE) && -	    !(IS_EVPN_PREFIX_IPADDR_V4(evp) || IS_EVPN_PREFIX_IPADDR_V6(evp))) +	if ((evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE) +	    && !(IS_EVPN_PREFIX_IPADDR_V4(evp) +		 || IS_EVPN_PREFIX_IPADDR_V6(evp)))  		return 0;  	for (ALL_LIST_ELEMENTS(vrfs, node, nnode, bgp_vrf)) {  		int ret;  		if (install) -			ret = install_evpn_route_entry_in_vrf(bgp_vrf, -							      evp, ri); +			ret = install_evpn_route_entry_in_vrf(bgp_vrf, evp, ri);  		else -			ret = uninstall_evpn_route_entry_in_vrf(bgp_vrf, -								evp, ri); +			ret = uninstall_evpn_route_entry_in_vrf(bgp_vrf, evp, +								ri);  		if (ret) {  			zlog_err("%u: Failed to %s prefix %s in VRF %s", @@ -2529,7 +2517,7 @@ static int install_uninstall_evpn_route(struct bgp *bgp, afi_t afi, safi_t safi,  		u_char type, sub_type;  		struct ecommunity_val *eval;  		struct ecommunity_val eval_tmp; -		struct irt_node *irt; /* import rt for l2vni */ +		struct irt_node *irt;	 /* import rt for l2vni */  		struct vrf_irt_node *vrf_irt; /* import rt for l3vni */  		/* Only deal with RTs */ @@ -2577,9 +2565,8 @@ static int install_uninstall_evpn_route(struct bgp *bgp, afi_t afi, safi_t safi,  			install_uninstall_route_in_vnis(bgp, afi, safi, evp, ri,  							irt->vnis, import);  		if (vrf_irt && vrf_irt->vrfs) -			install_uninstall_route_in_vrfs(bgp, afi, safi, evp, -							ri, vrf_irt->vrfs, -							import); +			install_uninstall_route_in_vrfs(bgp, afi, safi, evp, ri, +							vrf_irt->vrfs, import);  	}  	return 0; @@ -2897,7 +2884,8 @@ static int process_type2_route(struct peer *peer, afi_t afi, safi_t safi,  		memcpy(&label[1], pfx, BGP_LABEL_BYTES);  		/*  		 * If in future, we are required to access additional fields, -		 * we MUST increment pfx by BGP_LABEL_BYTES in before reading the next field +		 * we MUST increment pfx by BGP_LABEL_BYTES in before reading +		 * the next field  		 */  	} @@ -3057,7 +3045,8 @@ static int process_type5_route(struct peer *peer, afi_t afi, safi_t safi,  	/*  	 * If in future, we are required to access additional fields, -	 * we MUST increment pfx by BGP_LABEL_BYTES in before reading the next field +	 * we MUST increment pfx by BGP_LABEL_BYTES in before reading the next +	 * field  	 */  	/* Process the route. */ @@ -3074,9 +3063,8 @@ static int process_type5_route(struct peer *peer, afi_t afi, safi_t safi,  }  static void evpn_mpattr_encode_type5(struct stream *s, struct prefix *p, -				     struct prefix_rd *prd, -				     mpls_label_t *label, u_int32_t num_labels, -				     struct attr *attr) +				     struct prefix_rd *prd, mpls_label_t *label, +				     u_int32_t num_labels, struct attr *attr)  {  	int len;  	char temp[16]; @@ -3234,16 +3222,14 @@ void bgp_evpn_withdraw_type5_route(struct bgp *bgp_vrf, struct prefix *p,  	ret = delete_evpn_type5_route(bgp_vrf, &evp);  	if (ret) {  		zlog_err( -			 "%u failed to delete type-5 route for prefix %s in vrf %s", -			 bgp_vrf->vrf_id, -			 prefix2str(p, buf, sizeof(buf)), -			 vrf_id_to_name(bgp_vrf->vrf_id)); +			"%u failed to delete type-5 route for prefix %s in vrf %s", +			bgp_vrf->vrf_id, prefix2str(p, buf, sizeof(buf)), +			vrf_id_to_name(bgp_vrf->vrf_id));  	}  }  /* withdraw all type-5 routes for an address family */ -void bgp_evpn_withdraw_type5_routes(struct bgp *bgp_vrf, -				    afi_t afi, safi_t safi) +void bgp_evpn_withdraw_type5_routes(struct bgp *bgp_vrf, afi_t afi, safi_t safi)  {  	struct bgp_table *table = NULL;  	struct bgp_node *rn = NULL; @@ -3258,8 +3244,8 @@ void bgp_evpn_withdraw_type5_routes(struct bgp *bgp_vrf,  		/* Only care about "selected" routes - non-imported. */  		/* TODO: Support for AddPath for EVPN. */  		for (ri = rn->info; ri; ri = ri->next) { -			if (CHECK_FLAG(ri->flags, BGP_INFO_SELECTED) && -			    (!ri->extra || !ri->extra->parent)) { +			if (CHECK_FLAG(ri->flags, BGP_INFO_SELECTED) +			    && (!ri->extra || !ri->extra->parent)) {  				bgp_evpn_withdraw_type5_route(bgp_vrf, &rn->p,  							      afi, safi);  				break; @@ -3275,8 +3261,8 @@ void bgp_evpn_withdraw_type5_routes(struct bgp *bgp_vrf,   * are advertising local subnets), the src_attr will be NULL.   */  void bgp_evpn_advertise_type5_route(struct bgp *bgp_vrf, struct prefix *p, -				    struct attr *src_attr, -				    afi_t afi, safi_t safi) +				    struct attr *src_attr, afi_t afi, +				    safi_t safi)  {  	int ret = 0;  	struct prefix_evpn evp; @@ -3289,18 +3275,16 @@ void bgp_evpn_advertise_type5_route(struct bgp *bgp_vrf, struct prefix *p,  	build_type5_prefix_from_ip_prefix(&evp, p);  	ret = update_evpn_type5_route(bgp_vrf, &evp, src_attr);  	if (ret) -		zlog_err( -			 "%u: Failed to create type-5 route for prefix %s", -			 bgp_vrf->vrf_id, -			 prefix2str(p, buf, sizeof(buf))); +		zlog_err("%u: Failed to create type-5 route for prefix %s", +			 bgp_vrf->vrf_id, prefix2str(p, buf, sizeof(buf)));  }  /* Inject all prefixes of a particular address-family (currently, IPv4 or   * IPv6 unicast) into EVPN as type-5 routes. This is invoked when the   * advertisement is enabled.   */ -void bgp_evpn_advertise_type5_routes(struct bgp *bgp_vrf, -				     afi_t afi, safi_t safi) +void bgp_evpn_advertise_type5_routes(struct bgp *bgp_vrf, afi_t afi, +				     safi_t safi)  {  	struct bgp_table *table = NULL;  	struct bgp_node *rn = NULL; @@ -3317,31 +3301,29 @@ void bgp_evpn_advertise_type5_routes(struct bgp *bgp_vrf,  		 * TODO: Support for AddPath for EVPN.  		 */  		for (ri = rn->info; ri; ri = ri->next) { -			if (CHECK_FLAG(ri->flags, BGP_INFO_SELECTED) && -			    (!ri->extra || !ri->extra->parent)) { +			if (CHECK_FLAG(ri->flags, BGP_INFO_SELECTED) +			    && (!ri->extra || !ri->extra->parent)) {  				/* apply the route-map */  				if (bgp_vrf->adv_cmd_rmap[afi][safi].map) {  					int ret = 0; -					ret = -						route_map_apply( -							bgp_vrf->adv_cmd_rmap[afi][safi].map, -							&rn->p, RMAP_BGP, ri); +					ret = route_map_apply( +						bgp_vrf->adv_cmd_rmap[afi][safi] +							.map, +						&rn->p, RMAP_BGP, ri);  					if (ret == RMAP_DENYMATCH)  						continue;  				} -				bgp_evpn_advertise_type5_route(bgp_vrf, &rn->p, -							       ri->attr, -							       afi, safi); +				bgp_evpn_advertise_type5_route( +					bgp_vrf, &rn->p, ri->attr, afi, safi);  				break;  			}  		}  	}  } -void evpn_rt_delete_auto(struct bgp *bgp, vni_t vni, -				struct list *rtl) +void evpn_rt_delete_auto(struct bgp *bgp, vni_t vni, struct list *rtl)  {  	struct listnode *node, *nnode, *node_to_del;  	struct ecommunity *ecom, *ecom_auto; @@ -3437,7 +3419,6 @@ void bgp_evpn_configure_export_rt_for_vrf(struct bgp *bgp_vrf,  	SET_FLAG(bgp_vrf->vrf_flags, BGP_VRF_EXPORT_RT_CFGD);  	bgp_evpn_handle_export_rt_change_for_vrf(bgp_vrf); -  }  void bgp_evpn_unconfigure_export_rt_for_vrf(struct bgp *bgp_vrf, @@ -3515,8 +3496,7 @@ int bgp_evpn_handle_export_rt_change(struct bgp *bgp, struct bgpevpn *vpn)  	return update_routes_for_vni(bgp, vpn);  } -void bgp_evpn_handle_vrf_rd_change(struct bgp *bgp_vrf, -				   int withdraw) +void bgp_evpn_handle_vrf_rd_change(struct bgp *bgp_vrf, int withdraw)  {  	if (withdraw)  		delete_withdraw_vrf_routes(bgp_vrf); @@ -3560,14 +3540,14 @@ int bgp_evpn_uninstall_routes(struct bgp *bgp, struct bgpevpn *vpn)  /*   * TODO: Hardcoded for a maximum of 2 VNIs right now   */ -char *bgp_evpn_label2str(mpls_label_t *label, u_int32_t num_labels, -			 char *buf, int len) +char *bgp_evpn_label2str(mpls_label_t *label, u_int32_t num_labels, char *buf, +			 int len)  {  	vni_t vni1, vni2;  	vni1 = label2vni(label);  	if (num_labels == 2) { -		vni2 = label2vni(label+1); +		vni2 = label2vni(label + 1);  		snprintf(buf, len, "%u/%u", vni1, vni2);  	} else  		snprintf(buf, len, "%u", vni1); @@ -3675,11 +3655,10 @@ char *bgp_evpn_route2str(struct prefix_evpn *p, char *buf, int len)  		}  	} else if (p->prefix.route_type == BGP_EVPN_IP_PREFIX_ROUTE) {  		snprintf(buf, len, "[%d]:[0]:[0]:[%d]:[%s]", -			 p->prefix.route_type, -			 p->prefix.ip_prefix_length, -			 IS_EVPN_PREFIX_IPADDR_V4(p) ? -				inet_ntoa(p->prefix.ip.ipaddr_v4) : -				inet6_ntoa(p->prefix.ip.ipaddr_v6)); +			 p->prefix.route_type, p->prefix.ip_prefix_length, +			 IS_EVPN_PREFIX_IPADDR_V4(p) +				 ? inet_ntoa(p->prefix.ip.ipaddr_v4) +				 : inet6_ntoa(p->prefix.ip.ipaddr_v6));  	} else {  		/* For EVPN route types not supported yet. */  		snprintf(buf, len, "(unsupported route type %d)", @@ -3693,10 +3672,9 @@ char *bgp_evpn_route2str(struct prefix_evpn *p, char *buf, int len)   * Encode EVPN prefix in Update (MP_REACH)   */  void bgp_evpn_encode_prefix(struct stream *s, struct prefix *p, -			    struct prefix_rd *prd, -			    mpls_label_t *label, u_int32_t num_labels, -			    struct attr *attr, int addpath_encode, -			    u_int32_t addpath_tx_id) +			    struct prefix_rd *prd, mpls_label_t *label, +			    u_int32_t num_labels, struct attr *attr, +			    int addpath_encode, u_int32_t addpath_tx_id)  {  	struct prefix_evpn *evp = (struct prefix_evpn *)p;  	int len, ipa_len = 0; @@ -3718,19 +3696,19 @@ void bgp_evpn_encode_prefix(struct stream *s, struct prefix *p,  		if (ipa_len && num_labels > 1) /* There are 2 VNIs */  			len += 3;  		stream_putc(s, len); -		stream_put(s, prd->val, 8);	 /* RD */ -		stream_put(s, 0, 10);		    /* ESI */ -		stream_putl(s, 0);		    /* Ethernet Tag ID */ +		stream_put(s, prd->val, 8);   /* RD */ +		stream_put(s, 0, 10);	 /* ESI */ +		stream_putl(s, 0);	    /* Ethernet Tag ID */  		stream_putc(s, 8 * ETH_ALEN); /* Mac Addr Len - bits */  		stream_put(s, evp->prefix.mac.octet, 6); /* Mac Addr */  		stream_putc(s, 8 * ipa_len);		 /* IP address Length */ -		if (ipa_len) /* IP */ +		if (ipa_len)				 /* IP */  			stream_put(s, &evp->prefix.ip.ip.addr, ipa_len);  		/* 1st label is the L2 VNI */  		stream_put(s, label, BGP_LABEL_BYTES);  		/* Include 2nd label (L3 VNI) if advertising MAC+IP */  		if (ipa_len && num_labels > 1) -			stream_put(s, label+1, BGP_LABEL_BYTES); +			stream_put(s, label + 1, BGP_LABEL_BYTES);  		break;  	case BGP_EVPN_IMET_ROUTE: @@ -3914,7 +3892,6 @@ void bgp_evpn_unmap_vrf_from_its_rts(struct bgp *bgp_vrf)  } -  /*   * Map the RTs (configured or automatically derived) of a VNI to the VNI.   * The mapping will be used during route processing. @@ -4242,11 +4219,11 @@ int bgp_evpn_local_macip_add(struct bgp *bgp, vni_t vni, struct ethaddr *mac,  		zlog_err(  			"%u:Failed to create Type-2 route, VNI %u %s MAC %s IP %s (flags: 0x%x)",  			bgp->vrf_id, vpn->vni, -			CHECK_FLAG(flags, ZEBRA_MACIP_TYPE_STICKY) ? "sticky gateway" -								 : "", +			CHECK_FLAG(flags, ZEBRA_MACIP_TYPE_STICKY) +				? "sticky gateway" +				: "",  			prefix_mac2str(mac, buf, sizeof(buf)), -			ipaddr2str(ip, buf2, sizeof(buf2)), -			flags); +			ipaddr2str(ip, buf2, sizeof(buf2)), flags);  		return -1;  	} @@ -4267,11 +4244,8 @@ static void link_l2vni_hash_to_l3vni(struct hash_backet *backet,  		bgpevpn_link_to_l3vni(vpn);  } -int bgp_evpn_local_l3vni_add(vni_t l3vni, -			     vrf_id_t vrf_id, -			     struct ethaddr *rmac, -			     struct in_addr originator_ip, -			     int filter) +int bgp_evpn_local_l3vni_add(vni_t l3vni, vrf_id_t vrf_id, struct ethaddr *rmac, +			     struct in_addr originator_ip, int filter)  {  	struct bgp *bgp_vrf = NULL; /* bgp VRF instance */  	struct bgp *bgp_def = NULL; /* default bgp instance */ @@ -4284,8 +4258,9 @@ int bgp_evpn_local_l3vni_add(vni_t l3vni,  	 */  	bgp_def = bgp_get_default();  	if (!bgp_def) { -		zlog_err("Cannot process L3VNI  %u ADD - default BGP instance not yet created", -			 l3vni); +		zlog_err( +			"Cannot process L3VNI  %u ADD - default BGP instance not yet created", +			l3vni);  		return -1;  	}  	as = bgp_def->as; @@ -4336,8 +4311,8 @@ int bgp_evpn_local_l3vni_add(vni_t l3vni,  	/* link all corresponding l2vnis */  	hash_iterate(bgp_def->vnihash, -		     (void (*)(struct hash_backet *, void *)) -			link_l2vni_hash_to_l3vni, +		     (void (*)(struct hash_backet *, +			       void *))link_l2vni_hash_to_l3vni,  		     bgp_vrf);  	/* Only update all corresponding type-2 routes if we are advertising two @@ -4357,8 +4332,7 @@ int bgp_evpn_local_l3vni_add(vni_t l3vni,  	return 0;  } -int bgp_evpn_local_l3vni_del(vni_t l3vni, -			     vrf_id_t vrf_id) +int bgp_evpn_local_l3vni_del(vni_t l3vni, vrf_id_t vrf_id)  {  	struct bgp *bgp_vrf = NULL; /* bgp vrf instance */  	struct bgp *bgp_def = NULL; /* default bgp instance */ @@ -4367,15 +4341,17 @@ int bgp_evpn_local_l3vni_del(vni_t l3vni,  	bgp_vrf = bgp_lookup_by_vrf_id(vrf_id);  	if (!bgp_vrf) { -		zlog_err("Cannot process L3VNI %u Del - Could not find BGP instance", -			 l3vni); +		zlog_err( +			"Cannot process L3VNI %u Del - Could not find BGP instance", +			l3vni);  		return -1;  	}  	bgp_def = bgp_get_default();  	if (!bgp_def) { -		zlog_err("Cannot process L3VNI %u Del - Could not find default BGP instance", -			 l3vni); +		zlog_err( +			"Cannot process L3VNI %u Del - Could not find default BGP instance", +			l3vni);  		return -1;  	} @@ -4461,8 +4437,7 @@ int bgp_evpn_local_vni_del(struct bgp *bgp, vni_t vni)   * about are for the local-tunnel-ip and the (tenant) VRF.   */  int bgp_evpn_local_vni_add(struct bgp *bgp, vni_t vni, -			   struct in_addr originator_ip, -			   vrf_id_t tenant_vrf_id) +			   struct in_addr originator_ip, vrf_id_t tenant_vrf_id)  {  	struct bgpevpn *vpn;  	struct prefix_evpn p; @@ -4612,10 +4587,8 @@ void bgp_evpn_init(struct bgp *bgp)  	bgp->vrf_export_rtl->cmp =  		(int (*)(void *, void *))evpn_route_target_cmp;  	bgp->l2vnis = list_new(); -	bgp->l2vnis->cmp = -		(int (*)(void *, void *))vni_hash_cmp; +	bgp->l2vnis->cmp = (int (*)(void *, void *))vni_hash_cmp;  	bf_assign_index(bm->rd_idspace, bgp->vrf_rd_id); -  }  void bgp_evpn_vrf_delete(struct bgp *bgp_vrf) diff --git a/bgpd/bgp_evpn.h b/bgpd/bgp_evpn.h index d8d92618f6..bf6150e648 100644 --- a/bgpd/bgp_evpn.h +++ b/bgpd/bgp_evpn.h @@ -57,10 +57,9 @@ static inline vni_t label2vni(mpls_label_t *label)  extern void bgp_evpn_advertise_type5_route(struct bgp *bgp_vrf,  					   struct prefix *p, -					   struct attr *src_attr, -					   afi_t afi, safi_t safi); -extern void bgp_evpn_withdraw_type5_route(struct bgp *bgp_vrf, -					  struct prefix *p, +					   struct attr *src_attr, afi_t afi, +					   safi_t safi); +extern void bgp_evpn_withdraw_type5_route(struct bgp *bgp_vrf, struct prefix *p,  					  afi_t afi, safi_t safi);  extern void bgp_evpn_withdraw_type5_routes(struct bgp *bgp_vrf, afi_t afi,  					   safi_t safi); @@ -73,10 +72,9 @@ extern char *bgp_evpn_label2str(mpls_label_t *label, u_int32_t num_labels,  extern char *bgp_evpn_route2str(struct prefix_evpn *p, char *buf, int len);  extern void bgp_evpn_route2json(struct prefix_evpn *p, json_object *json);  extern void bgp_evpn_encode_prefix(struct stream *s, struct prefix *p, -				   struct prefix_rd *prd, -				   mpls_label_t *label, u_int32_t num_labels, -				   struct attr *attr, int addpath_encode, -				   u_int32_t addpath_tx_id); +				   struct prefix_rd *prd, mpls_label_t *label, +				   u_int32_t num_labels, struct attr *attr, +				   int addpath_encode, u_int32_t addpath_tx_id);  extern int bgp_nlri_parse_evpn(struct peer *peer, struct attr *attr,  			       struct bgp_nlri *packet, int withdraw);  extern int bgp_evpn_import_route(struct bgp *bgp, afi_t afi, safi_t safi, @@ -91,8 +89,7 @@ extern int bgp_evpn_local_macip_add(struct bgp *bgp, vni_t vni,  				    u_char flags);  extern int bgp_evpn_local_l3vni_add(vni_t vni, vrf_id_t vrf_id,  				    struct ethaddr *rmac, -				    struct in_addr originator_ip, -				    int filter); +				    struct in_addr originator_ip, int filter);  extern int bgp_evpn_local_l3vni_del(vni_t vni, vrf_id_t vrf_id);  extern int bgp_evpn_local_vni_del(struct bgp *bgp, vni_t vni);  extern int bgp_evpn_local_vni_add(struct bgp *bgp, vni_t vni, diff --git a/bgpd/bgp_evpn_private.h b/bgpd/bgp_evpn_private.h index 5d59ed5ae6..63dd581845 100644 --- a/bgpd/bgp_evpn_private.h +++ b/bgpd/bgp_evpn_private.h @@ -66,29 +66,34 @@ struct bgpevpn {  	struct bgp *bgp_vrf; /* back pointer to the vrf instance */ -	/* Flag to indicate if we are advertising the g/w mac ip for this VNI*/ -	u_int8_t advertise_gw_macip; +					   /* Flag to indicate if we are +					    * advertising the g/w mac ip for +					    * this VNI*/ +					   u_int8_t advertise_gw_macip; -	/* Flag to indicate if we are advertising subnet for this VNI */ -	u_int8_t advertise_subnet; +					   /* Flag to indicate if we are +					    * advertising subnet for this VNI */ +					   u_int8_t advertise_subnet; -	/* Id for deriving the RD automatically for this VNI */ -	u_int16_t rd_id; +					   /* Id for deriving the RD +					    * automatically for this VNI */ +					   u_int16_t rd_id; -	/* RD for this VNI. */ -	struct prefix_rd prd; +					   /* RD for this VNI. */ +					   struct prefix_rd prd; -	/* Route type 3 field */ -	struct in_addr originator_ip; +					   /* Route type 3 field */ +					   struct in_addr originator_ip; -	/* Import and Export RTs. */ -	struct list *import_rtl; -	struct list *export_rtl; +					   /* Import and Export RTs. */ +					   struct list *import_rtl; +					   struct list *export_rtl; -	/* Route table for EVPN routes for this VNI. */ -	struct bgp_table *route_table; +					   /* Route table for EVPN routes for +					    * this VNI. */ +					   struct bgp_table *route_table; -	QOBJ_FIELDS +					   QOBJ_FIELDS  };  DECLARE_QOBJ_TYPE(bgpevpn) @@ -124,8 +129,7 @@ struct vrf_irt_node {  static inline int is_vrf_rd_configured(struct bgp *bgp_vrf)  { -	return (CHECK_FLAG(bgp_vrf->vrf_flags, -			   BGP_VRF_RD_CFGD)); +	return (CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_RD_CFGD));  }  static inline int bgp_evpn_vrf_rd_matches_existing(struct bgp *bgp_vrf, @@ -168,10 +172,10 @@ static inline void bgpevpn_unlink_from_l3vni(struct bgpevpn *vpn)  	/* bail if vpn is not associated to bgp_vrf */  	if (!vpn->bgp_vrf)  		return; -   +  	UNSET_FLAG(vpn->flags, VNI_FLAG_USE_TWO_LABELS);  	listnode_delete(vpn->bgp_vrf->l2vnis, vpn); -   +  	/* remove the backpointer to the vrf instance */  	vpn->bgp_vrf = NULL;  } @@ -193,8 +197,7 @@ static inline void bgpevpn_link_to_l3vni(struct bgpevpn *vpn)  	listnode_add_sort(bgp_vrf->l2vnis, vpn);  	/* check if we are advertising two labels for this vpn */ -	if (!CHECK_FLAG(bgp_vrf->vrf_flags, -		       BGP_VRF_L3VNI_PREFIX_ROUTES_ONLY)) +	if (!CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_L3VNI_PREFIX_ROUTES_ONLY))  		SET_FLAG(vpn->flags, VNI_FLAG_USE_TWO_LABELS);  } @@ -272,14 +275,12 @@ static inline void ip_prefix_from_type5_prefix(struct prefix_evpn *evp,  	if (IS_EVPN_PREFIX_IPADDR_V4(evp)) {  		ip->family = AF_INET;  		ip->prefixlen = evp->prefix.ip_prefix_length; -		memcpy(&(ip->u.prefix4), -		       &(evp->prefix.ip.ip), +		memcpy(&(ip->u.prefix4), &(evp->prefix.ip.ip),  		       IPV4_MAX_BYTELEN);  	} else if (IS_EVPN_PREFIX_IPADDR_V6(evp)) {  		ip->family = AF_INET6;  		ip->prefixlen = evp->prefix.ip_prefix_length; -		memcpy(&(ip->u.prefix6), -		       &(evp->prefix.ip.ip), +		memcpy(&(ip->u.prefix6), &(evp->prefix.ip.ip),  		       IPV6_MAX_BYTELEN);  	}  } @@ -291,14 +292,12 @@ static inline void ip_prefix_from_type2_prefix(struct prefix_evpn *evp,  	if (IS_EVPN_PREFIX_IPADDR_V4(evp)) {  		ip->family = AF_INET;  		ip->prefixlen = IPV4_MAX_BITLEN; -		memcpy(&(ip->u.prefix4), -		       &(evp->prefix.ip.ip), +		memcpy(&(ip->u.prefix4), &(evp->prefix.ip.ip),  		       IPV4_MAX_BYTELEN);  	} else if (IS_EVPN_PREFIX_IPADDR_V6(evp)) {  		ip->family = AF_INET6;  		ip->prefixlen = IPV6_MAX_BITLEN; -		memcpy(&(ip->u.prefix6), -		       &(evp->prefix.ip.ip), +		memcpy(&(ip->u.prefix6), &(evp->prefix.ip.ip),  		       IPV6_MAX_BYTELEN);  	}  } @@ -353,24 +352,23 @@ static inline void build_evpn_type3_prefix(struct prefix_evpn *p,  	p->prefix.ip.ipaddr_v4 = originator_ip;  } -static inline int advertise_type5_routes(struct bgp *bgp_vrf, -					 afi_t afi) +static inline int advertise_type5_routes(struct bgp *bgp_vrf, afi_t afi)  {  	if (!bgp_vrf->l3vni)  		return 0; -	if (afi == AFI_IP && -	    CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_ADVERTISE_IPV4_IN_EVPN)) +	if (afi == AFI_IP +	    && CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_ADVERTISE_IPV4_IN_EVPN))  		return 1; -	if (afi == AFI_IP6 && -	    CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_ADVERTISE_IPV6_IN_EVPN)) +	if (afi == AFI_IP6 +	    && CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_ADVERTISE_IPV6_IN_EVPN))  		return 1;  	return 0;  } -extern void evpn_rt_delete_auto(struct bgp*, vni_t, struct list*); +extern void evpn_rt_delete_auto(struct bgp *, vni_t, struct list *);  extern void bgp_evpn_configure_export_rt_for_vrf(struct bgp *bgp_vrf,  						 struct ecommunity *ecomadd);  extern void bgp_evpn_unconfigure_export_rt_for_vrf(struct bgp *bgp_vrf, diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index f519bb463b..d42da23f52 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -53,8 +53,7 @@ struct vni_walk_ctx {  };  #if defined(HAVE_CUMULUS) -static void display_vrf_import_rt(struct vty *vty, -				  struct vrf_irt_node *irt, +static void display_vrf_import_rt(struct vty *vty, struct vrf_irt_node *irt,  				  json_object *json)  {  	u_char *pnt; @@ -138,8 +137,7 @@ static void display_vrf_import_rt(struct vty *vty,  			json_object_array_add(  				json_vrfs,  				json_object_new_string( -						vrf_id_to_name( -							tmp_bgp_vrf->vrf_id))); +					vrf_id_to_name(tmp_bgp_vrf->vrf_id)));  		else  			vty_out(vty, "  %s\n",  				vrf_id_to_name(tmp_bgp_vrf->vrf_id)); @@ -151,8 +149,7 @@ static void display_vrf_import_rt(struct vty *vty,  	}  } -static void show_vrf_import_rt_entry(struct hash_backet *backet, -				     void *args[]) +static void show_vrf_import_rt_entry(struct hash_backet *backet, void *args[])  {  	json_object *json = NULL;  	struct vty *vty = NULL; @@ -604,7 +601,7 @@ static void show_vni_routes_hash(struct hash_backet *backet, void *arg)  }  static void show_l3vni_entry(struct vty *vty, struct bgp *bgp, -			   json_object *json) +			     json_object *json)  {  	json_object *json_vni;  	json_object *json_import_rtl; @@ -639,8 +636,7 @@ static void show_l3vni_entry(struct vty *vty, struct bgp *bgp,  			json_vni, "rd",  			prefix_rd2str(&bgp->vrf_prd, buf2, RD_ADDRSTRLEN));  	} else { -		vty_out(vty, "%-1s %-10u %-4s %-21s", -			buf1, bgp->l3vni, "L3", +		vty_out(vty, "%-1s %-10u %-4s %-21s", buf1, bgp->l3vni, "L3",  			prefix_rd2str(&bgp->vrf_prd, buf2, RD_ADDRSTRLEN));  	} @@ -748,8 +744,7 @@ static void show_vni_entry(struct hash_backet *backet, void *args[])  			json_vni, "rd",  			prefix_rd2str(&vpn->prd, buf2, sizeof(buf2)));  	} else { -		vty_out(vty, "%-1s %-10u %-4s %-21s", -			buf1, vpn->vni, "L2", +		vty_out(vty, "%-1s %-10u %-4s %-21s", buf1, vpn->vni, "L2",  			prefix_rd2str(&vpn->prd, buf2, RD_ADDRSTRLEN));  	} @@ -1430,8 +1425,7 @@ DEFUN(evpnrt5_network,  	return bgp_static_set_safi(  		AFI_L2VPN, SAFI_EVPN, vty, argv[idx_ipv4_prefixlen]->arg, -		argv[idx_route_distinguisher]->arg, argv[idx_label]->arg, -		NULL, +		argv[idx_route_distinguisher]->arg, argv[idx_label]->arg, NULL,  		BGP_EVPN_IP_PREFIX_ROUTE, argv[idx_esi]->arg,  		argv[idx_gwip]->arg, argv[idx_ethtag]->arg,  		argv[idx_routermac]->arg); @@ -1632,8 +1626,7 @@ static void evpn_unconfigure_export_rt(struct bgp *bgp, struct bgpevpn *vpn,  /*   * Configure RD for VRF   */ -static void evpn_configure_vrf_rd(struct bgp *bgp_vrf, -				  struct prefix_rd *rd) +static void evpn_configure_vrf_rd(struct bgp *bgp_vrf, struct prefix_rd *rd)  {  	/* If we have already advertise type-5 routes with a diffrent RD, we  	 * have to delete and withdraw them firs @@ -1777,8 +1770,7 @@ static int evpn_delete_vni(struct bgp *bgp, struct bgpevpn *vpn)   * Display import RT mapping to VRFs (vty handler)   * bgp_def: default bgp instance   */ -static void evpn_show_vrf_import_rts(struct vty *vty, -				     struct bgp *bgp_def, +static void evpn_show_vrf_import_rts(struct vty *vty, struct bgp *bgp_def,  				     json_object *json)  {  	void *args[2]; @@ -1787,8 +1779,8 @@ static void evpn_show_vrf_import_rts(struct vty *vty,  	args[1] = json;  	hash_iterate(bgp_def->vrf_import_rt_hash, -		     (void (*)(struct hash_backet *, void *)) -		     show_vrf_import_rt_entry, +		     (void (*)(struct hash_backet *, +			       void *))show_vrf_import_rt_entry,  		     args);  } @@ -2364,8 +2356,7 @@ static void evpn_show_all_vnis(struct vty *vty, struct bgp *bgp,  	if (!json) {  		vty_out(vty, "Flags: * - Kernel\n");  		vty_out(vty, "  %-10s %-4s %-21s %-25s %-25s %-37s\n", "VNI", -			"Type", "RD", "Import RT", -			"Export RT", "Tenant VRF"); +			"Type", "RD", "Import RT", "Export RT", "Tenant VRF");  	}  	/* print all L2 VNIS */ @@ -2378,7 +2369,6 @@ static void evpn_show_all_vnis(struct vty *vty, struct bgp *bgp,  	/* print all L3 VNIs */  	for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp_temp))  		show_l3vni_entry(vty, bgp_temp, json); -  }  /* @@ -2429,8 +2419,7 @@ static void evpn_unset_advertise_default_gw(struct bgp *bgp,  /*   * evpn - enable advertisement of default g/w   */ -static void evpn_set_advertise_subnet(struct bgp *bgp, -				      struct bgpevpn *vpn) +static void evpn_set_advertise_subnet(struct bgp *bgp, struct bgpevpn *vpn)  {  	if (vpn->advertise_subnet)  		return; @@ -2442,8 +2431,7 @@ static void evpn_set_advertise_subnet(struct bgp *bgp,  /*   * evpn - disable advertisement of default g/w   */ -static void evpn_unset_advertise_subnet(struct bgp *bgp, -					struct bgpevpn *vpn) +static void evpn_unset_advertise_subnet(struct bgp *bgp, struct bgpevpn *vpn)  {  	if (!vpn->advertise_subnet)  		return; @@ -2643,8 +2631,8 @@ DEFUN (bgp_evpn_advertise_vni_subnet,  	if (!bgp_vrf)  		return CMD_WARNING; -	if (!(advertise_type5_routes(bgp_vrf, AFI_IP) || -	      advertise_type5_routes(bgp_vrf, AFI_IP6))) { +	if (!(advertise_type5_routes(bgp_vrf, AFI_IP) +	      || advertise_type5_routes(bgp_vrf, AFI_IP6))) {  		vty_out(vty,  			"%%Please enable ip prefix advertisement under l2vpn evpn in %s",  			vrf_id_to_name(bgp_vrf->vrf_id)); @@ -2699,7 +2687,8 @@ DEFUN (bgp_evpn_advertise_type5,  		if (!bgp_vrf->adv_cmd_rmap[afi][safi].name)  			rmap_changed = 1;  		else if (strcmp(argv[idx_rmap + 1]->arg, -				bgp_vrf->adv_cmd_rmap[afi][safi].name) != 0) +				bgp_vrf->adv_cmd_rmap[afi][safi].name) +			 != 0)  			rmap_changed = 1;  	} else if (bgp_vrf->adv_cmd_rmap[afi][safi].name) {  		rmap_changed = 1; @@ -2725,8 +2714,7 @@ DEFUN (bgp_evpn_advertise_type5,  		if (!rmap_changed && CHECK_FLAG(bgp_vrf->vrf_flags,  						BGP_VRF_ADVERTISE_IPV4_IN_EVPN))  			return CMD_WARNING; -		SET_FLAG(bgp_vrf->vrf_flags, -			 BGP_VRF_ADVERTISE_IPV4_IN_EVPN); +		SET_FLAG(bgp_vrf->vrf_flags, BGP_VRF_ADVERTISE_IPV4_IN_EVPN);  	} else {  		/* if we are already advertising ipv6 prefix as type-5 @@ -2735,8 +2723,7 @@ DEFUN (bgp_evpn_advertise_type5,  		if (!rmap_changed && CHECK_FLAG(bgp_vrf->vrf_flags,  						BGP_VRF_ADVERTISE_IPV6_IN_EVPN))  			return CMD_WARNING; -		SET_FLAG(bgp_vrf->vrf_flags, -			 BGP_VRF_ADVERTISE_IPV6_IN_EVPN); +		SET_FLAG(bgp_vrf->vrf_flags, BGP_VRF_ADVERTISE_IPV6_IN_EVPN);  	}  	if (rmap_changed) { @@ -2752,8 +2739,7 @@ DEFUN (bgp_evpn_advertise_type5,  	/* set the route-map for advertise command */  	if (ret && argv[idx_rmap + 1]->arg) {  		bgp_vrf->adv_cmd_rmap[afi][safi].name = -			XSTRDUP(MTYPE_ROUTE_MAP_NAME, -				argv[idx_rmap + 1]->arg); +			XSTRDUP(MTYPE_ROUTE_MAP_NAME, argv[idx_rmap + 1]->arg);  		bgp_vrf->adv_cmd_rmap[afi][safi].map =  			route_map_lookup_by_name(argv[idx_rmap + 1]->arg);  	} @@ -2879,16 +2865,15 @@ DEFUN(show_bgp_l2vpn_evpn_vni,  						       ? "Enabled"  						       : "Disabled");  			json_object_string_add(json, "advertiseAllVnis", -					       is_evpn_enabled() -						       ? "Enabled" -						       : "Disabled"); +					       is_evpn_enabled() ? "Enabled" +								 : "Disabled");  			json_object_int_add(json, "numVnis", num_vnis);  			json_object_int_add(json, "numL2Vnis", num_l2vnis);  			json_object_int_add(json, "numL3Vnis", num_l3vnis);  		} else {  			vty_out(vty, "Advertise Gateway Macip: %s\n",  				bgp_def->advertise_gw_macip ? "Enabled" -							: "Disabled"); +							    : "Disabled");  			vty_out(vty, "Advertise All VNI flag: %s\n",  				is_evpn_enabled() ? "Enabled" : "Disabled");  			vty_out(vty, "Number of L2 VNIs: %u\n", num_l2vnis); @@ -3478,8 +3463,7 @@ ALIAS_HIDDEN(show_bgp_l2vpn_evpn_vni, show_bgp_evpn_vni_cmd,  ALIAS_HIDDEN(show_bgp_l2vpn_evpn_summary, show_bgp_evpn_summary_cmd,  	     "show bgp evpn summary [json]", SHOW_STR BGP_STR EVPN_HELP_STR -	     "Summary of BGP neighbor status\n" -	     JSON_STR) +	     "Summary of BGP neighbor status\n" JSON_STR)  ALIAS_HIDDEN(show_bgp_l2vpn_evpn_route, show_bgp_evpn_route_cmd,  	     "show bgp evpn route [type <macip|multicast>]", @@ -3855,13 +3839,11 @@ DEFUN (show_bgp_vrf_l3vni_info,  	bgp = bgp_lookup_by_name(name);  	if (!bgp) {  		if (!uj) -			vty_out(vty, "BGP instance for VRF %s not found", -				name); +			vty_out(vty, "BGP instance for VRF %s not found", name);  		else {  			json_object_string_add(json, "warning",  					       "BGP instance not found"); -			vty_out(vty, "%s\n", -				json_object_to_json_string(json)); +			vty_out(vty, "%s\n", json_object_to_json_string(json));  			json_object_free(json);  		}  		return CMD_WARNING; @@ -3869,15 +3851,15 @@ DEFUN (show_bgp_vrf_l3vni_info,  	if (!json) {  		vty_out(vty, "BGP VRF: %s\n", name); -		vty_out(vty, "  Local-Ip: %s\n", -			inet_ntoa(bgp->originator_ip)); +		vty_out(vty, "  Local-Ip: %s\n", inet_ntoa(bgp->originator_ip));  		vty_out(vty, "  L3-VNI: %u\n", bgp->l3vni);  		vty_out(vty, "  Rmac: %s\n",  			prefix_mac2str(&bgp->rmac, buf, sizeof(buf)));  		vty_out(vty, "  VNI Filter: %s\n",  			CHECK_FLAG(bgp->vrf_flags, -				   BGP_VRF_L3VNI_PREFIX_ROUTES_ONLY) ? -				"prefix-routes-only" : "none"); +				   BGP_VRF_L3VNI_PREFIX_ROUTES_ONLY) +				? "prefix-routes-only" +				: "none");  		vty_out(vty, "  L2-VNI List:\n");  		vty_out(vty, "    ");  		for (ALL_LIST_ELEMENTS_RO(bgp->l2vnis, node, vpn)) @@ -3900,13 +3882,15 @@ DEFUN (show_bgp_vrf_l3vni_info,  		json_object_string_add(json, "local-ip",  				       inet_ntoa(bgp->originator_ip));  		json_object_int_add(json, "l3vni", bgp->l3vni); -		json_object_string_add(json, "rmac", -				       prefix_mac2str(&bgp->rmac, buf, -						      sizeof(buf))); -		json_object_string_add(json, "vniFilter", -				       CHECK_FLAG(bgp->vrf_flags, -						  BGP_VRF_L3VNI_PREFIX_ROUTES_ONLY) -				       ? "prefix-routes-only" : "none"); +		json_object_string_add( +			json, "rmac", +			prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); +		json_object_string_add( +			json, "vniFilter", +			CHECK_FLAG(bgp->vrf_flags, +				   BGP_VRF_L3VNI_PREFIX_ROUTES_ONLY) +				? "prefix-routes-only" +				: "none");  		/* list of l2vnis */  		for (ALL_LIST_ELEMENTS_RO(bgp->l2vnis, node, vpn))  			json_object_array_add(json_vnis, @@ -3915,21 +3899,20 @@ DEFUN (show_bgp_vrf_l3vni_info,  		/* export rts */  		for (ALL_LIST_ELEMENTS_RO(bgp->vrf_export_rtl, node, ecom)) -			json_object_array_add(json_export_rts, -					      json_object_new_string( -							ecommunity_str(ecom))); +			json_object_array_add( +				json_export_rts, +				json_object_new_string(ecommunity_str(ecom)));  		json_object_object_add(json, "export-rts", json_export_rts);  		/* import rts */  		for (ALL_LIST_ELEMENTS_RO(bgp->vrf_import_rtl, node, ecom)) -			json_object_array_add(json_import_rts, -					      json_object_new_string( -							ecommunity_str(ecom))); +			json_object_array_add( +				json_import_rts, +				json_object_new_string(ecommunity_str(ecom)));  		json_object_object_add(json, "import-rts", json_import_rts);  		json_object_string_add(  			json, "rd",  			prefix_rd2str(&bgp->vrf_prd, buf1, RD_ADDRSTRLEN)); -  	}  	if (uj) { @@ -3979,8 +3962,7 @@ DEFUN (bgp_evpn_vrf_rt,  		ecommunity_str(ecomadd);  		/* Do nothing if we already have this import route-target */ -		if (!bgp_evpn_rt_matches_existing(bgp->vrf_import_rtl, -						  ecomadd)) +		if (!bgp_evpn_rt_matches_existing(bgp->vrf_import_rtl, ecomadd))  			bgp_evpn_configure_import_rt_for_vrf(bgp, ecomadd);  	} @@ -3995,8 +3977,7 @@ DEFUN (bgp_evpn_vrf_rt,  		ecommunity_str(ecomadd);  		/* Do nothing if we already have this export route-target */ -		if (!bgp_evpn_rt_matches_existing(bgp->vrf_export_rtl, -						  ecomadd)) +		if (!bgp_evpn_rt_matches_existing(bgp->vrf_export_rtl, ecomadd))  			bgp_evpn_configure_export_rt_for_vrf(bgp, ecomadd);  	} @@ -4344,8 +4325,7 @@ void bgp_config_write_evpn_info(struct vty *vty, struct bgp *bgp, afi_t afi,  				       ecom)) {  			ecom_str = ecommunity_ecom2str(  				ecom, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); -			vty_out(vty, "   route-target import %s\n", -				ecom_str); +			vty_out(vty, "   route-target import %s\n", ecom_str);  			XFREE(MTYPE_ECOMMUNITY_STR, ecom_str);  		}  	} @@ -4360,8 +4340,7 @@ void bgp_config_write_evpn_info(struct vty *vty, struct bgp *bgp, afi_t afi,  				       ecom)) {  			ecom_str = ecommunity_ecom2str(  				ecom, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); -			vty_out(vty, "   route-target export %s\n", -				ecom_str); +			vty_out(vty, "   route-target export %s\n", ecom_str);  			XFREE(MTYPE_ECOMMUNITY_STR, ecom_str);  		}  	} diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index de11a98a20..3255aff2a8 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -1056,8 +1056,8 @@ int bgp_stop(struct peer *peer)  			UNSET_FLAG(peer->sflags, PEER_STATUS_NSF_MODE);  			for (afi = AFI_IP; afi < AFI_MAX; afi++) -				for (safi = SAFI_UNICAST; -				     safi <= SAFI_MPLS_VPN; safi++) +				for (safi = SAFI_UNICAST; safi <= SAFI_MPLS_VPN; +				     safi++)  					peer->nsf[afi][safi] = 0;  		} @@ -1377,12 +1377,11 @@ int bgp_start(struct peer *peer)  		return 0;  	} -	if (peer->bgp && -	    peer->bgp->vrf_id == VRF_UNKNOWN) { +	if (peer->bgp && peer->bgp->vrf_id == VRF_UNKNOWN) {  		if (bgp_debug_neighbor_events(peer))  			zlog_err( -				 "%s [FSM] In a VRF that is not initialised yet", -				 peer->host); +				"%s [FSM] In a VRF that is not initialised yet", +				peer->host);  		return -1;  	} @@ -1518,9 +1517,8 @@ static int bgp_establish(struct peer *peer)  	}  	if (other == peer) -		ret = -			1; /* bgp_establish specific code when xfer_conn -			      happens. */ +		ret = 1; /* bgp_establish specific code when xfer_conn +			    happens. */  	/* Reset capability open status flag. */  	if (!CHECK_FLAG(peer->sflags, PEER_STATUS_CAPABILITY_OPEN)) diff --git a/bgpd/bgp_io.c b/bgpd/bgp_io.c index 59b2d1cdaa..8621997419 100644 --- a/bgpd/bgp_io.c +++ b/bgpd/bgp_io.c @@ -290,8 +290,8 @@ static uint16_t bgp_write(struct peer *peer)  	uint16_t status = 0;  	uint32_t wpkt_quanta_old; -	wpkt_quanta_old = -	    atomic_load_explicit(&peer->bgp->wpkt_quanta, memory_order_relaxed); +	wpkt_quanta_old = atomic_load_explicit(&peer->bgp->wpkt_quanta, +					       memory_order_relaxed);  	while (count < wpkt_quanta_old && (s = stream_fifo_head(peer->obuf))) {  		int writenum; @@ -402,7 +402,7 @@ static uint16_t bgp_read(struct peer *peer)  	/* EAGAIN or EWOULDBLOCK; come back later */  	if (nbytes < 0 && ERRNO_IO_RETRY(errno)) {  		SET_FLAG(status, BGP_IO_TRANS_ERR); -	/* Fatal error; tear down session */ +		/* Fatal error; tear down session */  	} else if (nbytes < 0) {  		zlog_err("%s [Error] bgp_read_packet error: %s", peer->host,  			 safe_strerror(errno)); @@ -417,7 +417,7 @@ static uint16_t bgp_read(struct peer *peer)  		BGP_EVENT_ADD(peer, TCP_fatal_error);  		SET_FLAG(status, BGP_IO_FATAL_ERR); -	/* Received EOF / TCP session closed */ +		/* Received EOF / TCP session closed */  	} else if (nbytes == 0) {  		if (bgp_debug_neighbor_events(peer))  			zlog_debug("%s [Event] BGP connection closed fd %d", @@ -485,8 +485,8 @@ static bool validate_header(struct peer *peer)  				   type);  		bgp_notify_send_with_data(peer, BGP_NOTIFY_HEADER_ERR, -					  BGP_NOTIFY_HEADER_BAD_MESTYPE, -					  &type, 1); +					  BGP_NOTIFY_HEADER_BAD_MESTYPE, &type, +					  1);  		return false;  	} @@ -506,14 +506,14 @@ static bool validate_header(struct peer *peer)  			zlog_debug("%s bad message length - %d for %s",  				   peer->host, size,  				   type == 128 ? "ROUTE-REFRESH" -					       : bgp_type_str[(int) type]); +					       : bgp_type_str[(int)type]);  		}  		uint16_t nsize = htons(size);  		bgp_notify_send_with_data(peer, BGP_NOTIFY_HEADER_ERR,  					  BGP_NOTIFY_HEADER_BAD_MESLEN, -					  (unsigned char *) &nsize, 2); +					  (unsigned char *)&nsize, 2);  		return false;  	} diff --git a/bgpd/bgp_lcommunity.c b/bgpd/bgp_lcommunity.c index 54e9fd8894..36980b7c24 100644 --- a/bgpd/bgp_lcommunity.c +++ b/bgpd/bgp_lcommunity.c @@ -174,13 +174,11 @@ struct lcommunity *lcommunity_merge(struct lcommunity *lcom1,  				    struct lcommunity *lcom2)  {  	if (lcom1->val) -		lcom1->val = -			XREALLOC(MTYPE_LCOMMUNITY_VAL, lcom1->val, -				 lcom_length(lcom1) + lcom_length(lcom2)); +		lcom1->val = XREALLOC(MTYPE_LCOMMUNITY_VAL, lcom1->val, +				      lcom_length(lcom1) + lcom_length(lcom2));  	else -		lcom1->val = -			XMALLOC(MTYPE_LCOMMUNITY_VAL, -				lcom_length(lcom1) + lcom_length(lcom2)); +		lcom1->val = XMALLOC(MTYPE_LCOMMUNITY_VAL, +				     lcom_length(lcom1) + lcom_length(lcom2));  	memcpy(lcom1->val + lcom_length(lcom1), lcom2->val, lcom_length(lcom2));  	lcom1->size += lcom2->size; @@ -243,8 +241,7 @@ int lcommunity_cmp(const void *arg1, const void *arg2)  	const struct lcommunity *lcom2 = arg2;  	return (lcom1->size == lcom2->size -		&& memcmp(lcom1->val, lcom2->val, lcom_length(lcom1)) -			   == 0); +		&& memcmp(lcom1->val, lcom2->val, lcom_length(lcom1)) == 0);  }  /* Return communities hash.  */ @@ -256,8 +253,7 @@ struct hash *lcommunity_hash(void)  /* Initialize Large Comminities related hash. */  void lcommunity_init(void)  { -	lcomhash = hash_create(lcommunity_hash_make, -			       lcommunity_cmp, +	lcomhash = hash_create(lcommunity_hash_make, lcommunity_cmp,  			       "BGP lcommunity hash");  } @@ -462,8 +458,8 @@ int lcommunity_match(const struct lcommunity *lcom1,  	/* Every community on com2 needs to be on com1 for this to match */  	while (i < lcom1->size && j < lcom2->size) { -		if (memcmp(lcom1->val + (i * LCOMMUNITY_SIZE), lcom2->val + (j * LCOMMUNITY_SIZE), -			   LCOMMUNITY_SIZE) +		if (memcmp(lcom1->val + (i * LCOMMUNITY_SIZE), +			   lcom2->val + (j * LCOMMUNITY_SIZE), LCOMMUNITY_SIZE)  		    == 0)  			j++;  		i++; @@ -499,8 +495,8 @@ void lcommunity_del_val(struct lcommunity *lcom, u_char *ptr)  			if (lcom->size > 0)  				lcom->val = -					XREALLOC(MTYPE_LCOMMUNITY_VAL, lcom->val, -						 lcom_length(lcom)); +					XREALLOC(MTYPE_LCOMMUNITY_VAL, +						 lcom->val, lcom_length(lcom));  			else {  				XFREE(MTYPE_LCOMMUNITY_VAL, lcom->val);  				lcom->val = NULL; diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c index 30b7afff92..7039786014 100644 --- a/bgpd/bgp_main.c +++ b/bgpd/bgp_main.c @@ -105,9 +105,8 @@ static struct quagga_signal_t bgp_signals[] = {  static int retain_mode = 0;  /* privileges */ -static zebra_capabilities_t _caps_p[] = { -	ZCAP_BIND, ZCAP_NET_RAW, ZCAP_NET_ADMIN, ZCAP_SYS_ADMIN -}; +static zebra_capabilities_t _caps_p[] = {ZCAP_BIND, ZCAP_NET_RAW, +					 ZCAP_NET_ADMIN, ZCAP_SYS_ADMIN};  struct zebra_privs_t bgpd_privs = {  #if defined(FRR_USER) && defined(FRR_GROUP) diff --git a/bgpd/bgp_mpath.c b/bgpd/bgp_mpath.c index 5d83192a30..667be50842 100644 --- a/bgpd/bgp_mpath.c +++ b/bgpd/bgp_mpath.c @@ -141,16 +141,17 @@ int bgp_info_nexthop_cmp(struct bgp_info *bi1, struct bgp_info *bi2)  					&bi2->attr->mp_nexthop_global);  				break;  			case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL: -				addr1 = (bi1->attr->mp_nexthop_prefer_global) ? -					bi1->attr->mp_nexthop_global -					: bi1->attr->mp_nexthop_local; -				addr2 = (bi2->attr->mp_nexthop_prefer_global) ? -					bi2->attr->mp_nexthop_global -					: bi2->attr->mp_nexthop_local; - -				if (!bi1->attr->mp_nexthop_prefer_global && -				    !bi2->attr->mp_nexthop_prefer_global) -					compare = !bgp_interface_same(bi1->peer->ifp, bi2->peer->ifp); +				addr1 = (bi1->attr->mp_nexthop_prefer_global) +						? bi1->attr->mp_nexthop_global +						: bi1->attr->mp_nexthop_local; +				addr2 = (bi2->attr->mp_nexthop_prefer_global) +						? bi2->attr->mp_nexthop_global +						: bi2->attr->mp_nexthop_local; + +				if (!bi1->attr->mp_nexthop_prefer_global +				    && !bi2->attr->mp_nexthop_prefer_global) +					compare = !bgp_interface_same( +						bi1->peer->ifp, bi2->peer->ifp);  				if (!compare)  					compare = IPV6_ADDR_CMP(&addr1, &addr2); diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c index 0ab583f444..71454dfe03 100644 --- a/bgpd/bgp_network.c +++ b/bgpd/bgp_network.c @@ -447,8 +447,8 @@ static char *bgp_get_bound_name(struct peer *peer)  {  	char *name = NULL; -	if ((peer->bgp->vrf_id == VRF_DEFAULT) && -	    !peer->ifname && !peer->conf_if) +	if ((peer->bgp->vrf_id == VRF_DEFAULT) && !peer->ifname +	    && !peer->conf_if)  		return NULL;  	if (peer->su.sa.sa_family != AF_INET @@ -673,8 +673,7 @@ static int bgp_listener(int sock, struct sockaddr *sa, socklen_t salen,  	listener->fd = sock;  	/* this socket needs a change of ns. record bgp back pointer */ -	if (bgp->vrf_id != VRF_DEFAULT && -	    vrf_is_mapped_on_netns(bgp->vrf_id)) +	if (bgp->vrf_id != VRF_DEFAULT && vrf_is_mapped_on_netns(bgp->vrf_id))  		listener->bgp = bgp;  	memcpy(&listener->su, sa, salen); @@ -704,8 +703,8 @@ int bgp_socket(struct bgp *bgp, unsigned short port, const char *address)  	if (bgpd_privs.change(ZPRIVS_RAISE))  		zlog_err("Can't raise privileges"); -	ret = vrf_getaddrinfo(address, port_str, &req, -			      &ainfo_save, bgp->vrf_id); +	ret = vrf_getaddrinfo(address, port_str, &req, &ainfo_save, +			      bgp->vrf_id);  	if (bgpd_privs.change(ZPRIVS_LOWER))  		zlog_err("Can't lower privileges");  	if (ret != 0) { @@ -723,8 +722,7 @@ int bgp_socket(struct bgp *bgp, unsigned short port, const char *address)  		if (bgpd_privs.change(ZPRIVS_RAISE))  			zlog_err("Can't raise privileges");  		sock = vrf_socket(ainfo->ai_family, ainfo->ai_socktype, -				  ainfo->ai_protocol, bgp->vrf_id, -				  NULL); +				  ainfo->ai_protocol, bgp->vrf_id, NULL);  		if (bgpd_privs.change(ZPRIVS_LOWER))  			zlog_err("Can't lower privileges");  		if (sock < 0) { @@ -736,8 +734,8 @@ int bgp_socket(struct bgp *bgp, unsigned short port, const char *address)  		 * ttl=255 */  		sockopt_ttl(ainfo->ai_family, sock, MAXTTL); -		ret = bgp_listener(sock, ainfo->ai_addr, -				   ainfo->ai_addrlen, bgp); +		ret = bgp_listener(sock, ainfo->ai_addr, ainfo->ai_addrlen, +				   bgp);  		if (ret == 0)  			++count;  		else @@ -745,8 +743,9 @@ int bgp_socket(struct bgp *bgp, unsigned short port, const char *address)  	}  	freeaddrinfo(ainfo_save);  	if (count == 0) { -		zlog_err("%s: no usable addresses please check other programs usage of specified port %d", -			 __func__, port); +		zlog_err( +			"%s: no usable addresses please check other programs usage of specified port %d", +			__func__, port);  		zlog_err("%s: Program cannot continue", __func__);  		exit(-1);  	} diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c index 870da22d20..79463ee142 100644 --- a/bgpd/bgp_nexthop.c +++ b/bgpd/bgp_nexthop.c @@ -122,8 +122,7 @@ static int bgp_tip_hash_cmp(const void *p1, const void *p2)  void bgp_tip_hash_init(struct bgp *bgp)  { -	bgp->tip_hash = hash_create(bgp_tip_hash_key_make, -				    bgp_tip_hash_cmp, +	bgp->tip_hash = hash_create(bgp_tip_hash_key_make, bgp_tip_hash_cmp,  				    "BGP TIP hash");  } @@ -204,9 +203,9 @@ static int bgp_address_hash_cmp(const void *p1, const void *p2)  void bgp_address_init(struct bgp *bgp)  { -	bgp->address_hash = hash_create(bgp_address_hash_key_make, -					bgp_address_hash_cmp, -					"BGP Address Hash"); +	bgp->address_hash = +		hash_create(bgp_address_hash_key_make, bgp_address_hash_cmp, +			    "BGP Address Hash");  }  void bgp_address_destroy(struct bgp *bgp) @@ -448,16 +447,14 @@ int bgp_subgrp_multiaccess_check_v4(struct in_addr nexthop,  	rn1 = rn2 = NULL;  	bgp = SUBGRP_INST(subgrp); -	rn1 = bgp_node_match(bgp->connected_table[AFI_IP], -			     &np); +	rn1 = bgp_node_match(bgp->connected_table[AFI_IP], &np);  	if (!rn1)  		return 0; -	SUBGRP_FOREACH_PEER(subgrp, paf) { +	SUBGRP_FOREACH_PEER (subgrp, paf) {  		p.u.prefix4 = paf->peer->su.sin.sin_addr; -		rn2 = bgp_node_match(bgp->connected_table[AFI_IP], -				     &p); +		rn2 = bgp_node_match(bgp->connected_table[AFI_IP], &p);  		if (rn1 == rn2) {  			bgp_unlock_node(rn1);  			bgp_unlock_node(rn2); @@ -472,8 +469,7 @@ int bgp_subgrp_multiaccess_check_v4(struct in_addr nexthop,  	return 0;  } -static void bgp_show_nexthops_detail(struct vty *vty, -				     struct bgp *bgp, +static void bgp_show_nexthops_detail(struct vty *vty, struct bgp *bgp,  				     struct bgp_nexthop_cache *bnc)  {  	char buf[PREFIX2STR_BUFFER]; @@ -483,39 +479,35 @@ static void bgp_show_nexthops_detail(struct vty *vty,  		switch (nexthop->type) {  		case NEXTHOP_TYPE_IPV6:  			vty_out(vty, "  gate %s\n", -				inet_ntop(AF_INET6, &nexthop->gate.ipv6, -					  buf, sizeof(buf))); +				inet_ntop(AF_INET6, &nexthop->gate.ipv6, buf, +					  sizeof(buf)));  			break;  		case NEXTHOP_TYPE_IPV6_IFINDEX:  			vty_out(vty, "  gate %s, if %s\n", -				inet_ntop(AF_INET6, &nexthop->gate.ipv6, -					  buf, sizeof(buf)), -				ifindex2ifname(nexthop->ifindex, -					       bgp->vrf_id)); +				inet_ntop(AF_INET6, &nexthop->gate.ipv6, buf, +					  sizeof(buf)), +				ifindex2ifname(nexthop->ifindex, bgp->vrf_id));  			break;  		case NEXTHOP_TYPE_IPV4:  			vty_out(vty, "  gate %s\n", -				inet_ntop(AF_INET, &nexthop->gate.ipv4, -					  buf, sizeof(buf))); +				inet_ntop(AF_INET, &nexthop->gate.ipv4, buf, +					  sizeof(buf)));  			break;  		case NEXTHOP_TYPE_IFINDEX:  			vty_out(vty, "  if %s\n", -				ifindex2ifname(nexthop->ifindex, -					       bgp->vrf_id)); +				ifindex2ifname(nexthop->ifindex, bgp->vrf_id));  			break;  		case NEXTHOP_TYPE_IPV4_IFINDEX:  			vty_out(vty, "  gate %s, if %s\n", -				inet_ntop(AF_INET, &nexthop->gate.ipv4, -					  buf, sizeof(buf)), -				ifindex2ifname(nexthop->ifindex, -					       bgp->vrf_id)); +				inet_ntop(AF_INET, &nexthop->gate.ipv4, buf, +					  sizeof(buf)), +				ifindex2ifname(nexthop->ifindex, bgp->vrf_id));  			break;  		case NEXTHOP_TYPE_BLACKHOLE:  			vty_out(vty, "  blackhole\n");  			break;  		default: -			vty_out(vty, -				"  invalid nexthop type %u\n", +			vty_out(vty, "  invalid nexthop type %u\n",  				nexthop->type);  		}  } @@ -549,7 +541,7 @@ static void bgp_show_nexthops(struct vty *vty, struct bgp *bgp, int detail)  					bgp_show_nexthops_detail(vty, bgp, bnc); -				} else{ +				} else {  					vty_out(vty, " %s invalid\n",  						inet_ntop(rn->p.family,  							  &rn->p.u.prefix, buf, diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c index d39fbec86d..54c0f85cb3 100644 --- a/bgpd/bgp_nht.c +++ b/bgpd/bgp_nht.c @@ -546,14 +546,14 @@ static void sendmsg_zebra_rnh(struct bgp_nexthop_cache *bnc, int command)  		return;  	p = &(bnc->node->p); -	if ((command == ZEBRA_NEXTHOP_REGISTER || -	     command == ZEBRA_IMPORT_ROUTE_REGISTER) && -	    (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_CONNECTED) -	     || CHECK_FLAG(bnc->flags, BGP_STATIC_ROUTE_EXACT_MATCH))) +	if ((command == ZEBRA_NEXTHOP_REGISTER +	     || command == ZEBRA_IMPORT_ROUTE_REGISTER) +	    && (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_CONNECTED) +		|| CHECK_FLAG(bnc->flags, BGP_STATIC_ROUTE_EXACT_MATCH)))  		exact_match = true; -	ret = zclient_send_rnh(zclient, command, p, -			       exact_match, bnc->bgp->vrf_id); +	ret = zclient_send_rnh(zclient, command, p, exact_match, +			       bnc->bgp->vrf_id);  	/* TBD: handle the failure */  	if (ret < 0)  		zlog_warn("sendmsg_nexthop: zclient_send_message() failed"); diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index 0ce2466f52..cb702d80d1 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -1573,9 +1573,8 @@ static int bgp_update_receive(struct peer *peer, bgp_size_t size)  	 * Non-MP IPv4/Unicast EoR is a completely empty UPDATE  	 * and MP EoR should have only an empty MP_UNREACH  	 */ -	if ((!update_len && !withdraw_len && -	     nlris[NLRI_MP_UPDATE].length == 0) || -	    (attr_parse_ret == BGP_ATTR_PARSE_EOR)) { +	if ((!update_len && !withdraw_len && nlris[NLRI_MP_UPDATE].length == 0) +	    || (attr_parse_ret == BGP_ATTR_PARSE_EOR)) {  		afi_t afi = 0;  		safi_t safi; diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 3dfc446b2c..2dab3ce6a9 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -1967,9 +1967,8 @@ int subgroup_process_announce_selected(struct update_subgroup *subgrp,  						 : NULL);  	/* First update is deferred until ORF or ROUTE-REFRESH is received */ -	if (onlypeer -	    && CHECK_FLAG(onlypeer->af_sflags[afi][safi], -			  PEER_STATUS_ORF_WAIT_REFRESH)) +	if (onlypeer && CHECK_FLAG(onlypeer->af_sflags[afi][safi], +				   PEER_STATUS_ORF_WAIT_REFRESH))  		return 0;  	memset(&attr, 0, sizeof(struct attr)); @@ -2228,13 +2227,12 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn,  	/* advertise/withdraw type-5 routes */  	if ((afi == AFI_IP || afi == AFI_IP6) && (safi == SAFI_UNICAST)) { -		if (new_select && -		    (!new_select->extra || !new_select->extra->parent)) -			bgp_evpn_advertise_type5_route(bgp, &rn->p, -						       new_select->attr, -						       afi, safi); -		else if (old_select && -		         (!old_select->extra || !old_select->extra->parent)) +		if (new_select +		    && (!new_select->extra || !new_select->extra->parent)) +			bgp_evpn_advertise_type5_route( +				bgp, &rn->p, new_select->attr, afi, safi); +		else if (old_select +			 && (!old_select->extra || !old_select->extra->parent))  			bgp_evpn_withdraw_type5_route(bgp, &rn->p, afi, safi);  	} @@ -6842,10 +6840,9 @@ static void damp_route_vty_out(struct vty *vty, struct prefix *p,  		bgp_damp_reuse_time_vty(vty, binfo, timebuf, BGP_UPTIME_LEN,  					use_json, json);  	else -		vty_out(vty, "%s ", -			bgp_damp_reuse_time_vty(vty, binfo, timebuf, -						BGP_UPTIME_LEN, use_json, -						json)); +		vty_out(vty, "%s ", bgp_damp_reuse_time_vty(vty, binfo, timebuf, +							    BGP_UPTIME_LEN, +							    use_json, json));  	/* Print attribute */  	attr = binfo->attr; @@ -6924,9 +6921,8 @@ static void flap_route_vty_out(struct vty *vty, struct prefix *p,  		peer_uptime(bdi->start_time, timebuf, BGP_UPTIME_LEN, use_json,  			    json);  	else -		vty_out(vty, "%s ", -			peer_uptime(bdi->start_time, timebuf, BGP_UPTIME_LEN, 0, -				    NULL)); +		vty_out(vty, "%s ", peer_uptime(bdi->start_time, timebuf, +						BGP_UPTIME_LEN, 0, NULL));  	if (CHECK_FLAG(binfo->flags, BGP_INFO_DAMPED)  	    && !CHECK_FLAG(binfo->flags, BGP_INFO_HISTORY)) { @@ -8032,9 +8028,8 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,  			}  			if (!use_json && header) { -				vty_out(vty, -					"BGP table version is %" PRIu64 -					", local router ID is %s\n", +				vty_out(vty, "BGP table version is %" PRIu64 +					     ", local router ID is %s\n",  					table->version,  					inet_ntoa(bgp->router_id));  				vty_out(vty, BGP_SHOW_SCODE_HEADER); @@ -8516,9 +8511,8 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp,  		if (display)  			json_object_object_add(json, "paths", json_paths); -		vty_out(vty, "%s\n", -			json_object_to_json_string_ext( -				json, JSON_C_TO_STRING_PRETTY)); +		vty_out(vty, "%s\n", json_object_to_json_string_ext( +					     json, JSON_C_TO_STRING_PRETTY));  		json_object_free(json);  	} else {  		if (!display) { @@ -9593,9 +9587,8 @@ static int bgp_peer_counts(struct vty *vty, struct peer *peer, afi_t afi,  				json, "recommended",  				"Please report this bug, with the above command output");  		} -		vty_out(vty, "%s\n", -			json_object_to_json_string_ext( -				json, JSON_C_TO_STRING_PRETTY)); +		vty_out(vty, "%s\n", json_object_to_json_string_ext( +					     json, JSON_C_TO_STRING_PRETTY));  		json_object_free(json);  	} else { @@ -9829,9 +9822,8 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,  					       "bgpOriginatingDefaultNetwork",  					       "0.0.0.0");  		} else { -			vty_out(vty, -				"BGP table version is %" PRIu64 -				", local router ID is %s\n", +			vty_out(vty, "BGP table version is %" PRIu64 +				     ", local router ID is %s\n",  				table->version, inet_ntoa(bgp->router_id));  			vty_out(vty, BGP_SHOW_SCODE_HEADER);  			vty_out(vty, BGP_SHOW_OCODE_HEADER); @@ -9974,9 +9966,8 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,  				output_count);  	}  	if (use_json) { -		vty_out(vty, "%s\n", -			json_object_to_json_string_ext( -				json, JSON_C_TO_STRING_PRETTY)); +		vty_out(vty, "%s\n", json_object_to_json_string_ext( +					     json, JSON_C_TO_STRING_PRETTY));  		json_object_free(json);  	}  } diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h index 2d4034d77d..dffe2b8ddc 100644 --- a/bgpd/bgp_route.h +++ b/bgpd/bgp_route.h @@ -104,10 +104,8 @@ struct bgp_info_extra {  				struct in6_addr addr6;  			} un; /* cached un address */  			time_t create_time; -			struct -				prefix -					aux_prefix; /* AFI_L2VPN: the IP addr, -						       if family set */ +			struct prefix aux_prefix; /* AFI_L2VPN: the IP addr, +						     if family set */  		} import;  	} vnc; diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index 4d5624d3b0..5371b37239 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -742,8 +742,7 @@ static void route_match_evpn_route_type_free(void *rule)  /* Route map commands for evpn route-type  matching. */  struct route_map_rule_cmd route_match_evpn_route_type_cmd = {  	"evpn route-type", route_match_evpn_route_type, -	route_match_evpn_route_type_compile, -	route_match_evpn_route_type_free}; +	route_match_evpn_route_type_compile, route_match_evpn_route_type_free};  /* `match local-preference LOCAL-PREF' */ @@ -3079,12 +3078,13 @@ static void bgp_route_map_process_update(struct bgp *bgp, const char *rmap_name,  	/* for type5 command route-maps */  	FOREACH_AFI_SAFI (afi, safi) { -		if (bgp->adv_cmd_rmap[afi][safi].name && -		    strcmp(rmap_name, bgp->adv_cmd_rmap[afi][safi].name) == 0) { +		if (bgp->adv_cmd_rmap[afi][safi].name +		    && strcmp(rmap_name, bgp->adv_cmd_rmap[afi][safi].name) +			       == 0) {  			if (BGP_DEBUG(zebra, ZEBRA))  				zlog_debug( -					   "Processing route_map %s update on advertise type5 route command", -					   rmap_name); +					"Processing route_map %s update on advertise type5 route command", +					rmap_name);  			bgp_evpn_withdraw_type5_routes(bgp, afi, safi);  			bgp_evpn_advertise_type5_routes(bgp, afi, safi);  		} diff --git a/bgpd/bgp_rpki.c b/bgpd/bgp_rpki.c index 19d4769cd3..1fb5bf19f1 100644 --- a/bgpd/bgp_rpki.c +++ b/bgpd/bgp_rpki.c @@ -1,9 +1,12 @@  /*   * BGP RPKI   * Copyright (C) 2013 Michael Mester (m.mester@fu-berlin.de), for FU Berlin - * Copyright (C) 2014-2017 Andreas Reuter (andreas.reuter@fu-berlin.de), for FU Berlin - * Copyright (C) 2016-2017 Colin Sames (colin.sames@haw-hamburg.de), for HAW Hamburg - * Copyright (C) 2017 Marcel Röthke (marcel.roethke@haw-hamburg.de), for HAW Hamburg + * Copyright (C) 2014-2017 Andreas Reuter (andreas.reuter@fu-berlin.de), for FU + * Berlin + * Copyright (C) 2016-2017 Colin Sames (colin.sames@haw-hamburg.de), for HAW + * Hamburg + * Copyright (C) 2017 Marcel Röthke (marcel.roethke@haw-hamburg.de), for HAW + * Hamburg   *   * This file is part of FRRouting.   * @@ -77,14 +80,14 @@ DEFINE_MTYPE_STATIC(BGPD, BGP_RPKI_CACHE_GROUP, "BGP RPKI Cache server group")  #define RPKI_OUTPUT_STRING "Control rpki specific settings\n"  struct cache { -       enum { TCP, SSH } type; -       struct tr_socket *tr_socket; -       union { +	enum { TCP, SSH } type; +	struct tr_socket *tr_socket; +	union {  		struct tr_tcp_config *tcp_config;  		struct tr_ssh_config *ssh_config; -       } tr_config; -       struct rtr_socket *rtr_socket; -       uint8_t preference; +	} tr_config; +	struct rtr_socket *rtr_socket; +	uint8_t preference;  };  enum return_values { SUCCESS = 0, ERROR = -1 }; @@ -105,27 +108,22 @@ static void overwrite_exit_commands(void);  static void free_cache(struct cache *cache);  static struct rtr_mgr_group *get_groups(void);  #if defined(FOUND_SSH) -static int add_ssh_cache(const char *host, -			 const unsigned int port, -			 const char *username, -			 const char *client_privkey_path, +static int add_ssh_cache(const char *host, const unsigned int port, +			 const char *username, const char *client_privkey_path,  			 const char *client_pubkey_path,  			 const char *server_pubkey_path,  			 const uint8_t preference);  #endif  static struct rtr_socket *create_rtr_socket(struct tr_socket *tr_socket);  static struct cache *find_cache(const uint8_t preference); -static int add_tcp_cache(const char *host, -			 const char *port, +static int add_tcp_cache(const char *host, const char *port,  			 const uint8_t preference);  static void print_record(const struct pfx_record *record, void *data);  static int is_synchronized(void);  static int is_running(void);  static void route_match_free(void *rule); -static route_map_result_t route_match(void *rule, -				      struct prefix *prefix, -				      route_map_object_t type, -				      void *object); +static route_map_result_t route_match(void *rule, struct prefix *prefix, +				      route_map_object_t type, void *object);  static void *route_match_compile(const char *arg);  static struct rtr_mgr_config *rtr_config; @@ -139,9 +137,8 @@ static unsigned int timeout;  static unsigned int initial_synchronisation_timeout;  static struct cmd_node rpki_node = {RPKI_NODE, "%s(config-rpki)# ", 1}; -static struct route_map_rule_cmd route_match_rpki_cmd = {"rpki", route_match, -						  route_match_compile, -						  route_match_free}; +static struct route_map_rule_cmd route_match_rpki_cmd = { +	"rpki", route_match, route_match_compile, route_match_free};  static void *malloc_wrapper(size_t size)  { @@ -162,8 +159,7 @@ static int rpki_validate_prefix(struct peer *peer, struct attr *attr,  				struct prefix *prefix);  static route_map_result_t route_match(void *rule, struct prefix *prefix, -				      route_map_object_t type, -				      void *object) +				      route_map_object_t type, void *object)  {  	int *rpki_status = rule;  	struct bgp_info *bgp_info; @@ -285,7 +281,7 @@ static int bgp_rpki_init(struct thread_master *master)  	rtr_is_running = 0;  	cache_list = list_new(); -	cache_list->del = (void (*)(void *)) &free_cache; +	cache_list->del = (void (*)(void *)) & free_cache;  	polling_period = POLLING_PERIOD_DEFAULT;  	expire_interval = EXPIRE_INTERVAL_DEFAULT; @@ -307,9 +303,7 @@ static int bgp_rpki_fini(void)  static int bgp_rpki_module_init(void)  { -	lrtr_set_alloc_functions(malloc_wrapper, -				 realloc_wrapper, -				 free_wrapper); +	lrtr_set_alloc_functions(malloc_wrapper, realloc_wrapper, free_wrapper);  	hook_register(frr_late_init, bgp_rpki_init);  	hook_register(frr_early_fini, &bgp_rpki_fini); @@ -332,8 +326,8 @@ static int start(void)  	struct rtr_mgr_group *groups = get_groups();  	ret = rtr_mgr_init(&rtr_config, groups, groups_len, polling_period, -			   expire_interval, retry_interval, -			   NULL, NULL, NULL, NULL); +			   expire_interval, retry_interval, NULL, NULL, NULL, +			   NULL);  	if (ret == RTR_ERROR) {  		RPKI_DEBUG("Init rtr_mgr failed.");  		return ERROR; @@ -447,8 +441,8 @@ static int rpki_validate_prefix(struct peer *peer, struct attr *attr,  		if (as_segment->type == AS_SEQUENCE) {  			// Get rightmost asn  			as_number = as_segment->as[as_segment->length - 1]; -		} else if (as_segment->type == AS_CONFED_SEQUENCE || -			   as_segment->type == AS_CONFED_SET) { +		} else if (as_segment->type == AS_CONFED_SEQUENCE +			   || as_segment->type == AS_CONFED_SET) {  			// Set own as number  			as_number = peer->bgp->as;  		} else { @@ -520,16 +514,15 @@ static int add_cache(struct cache *cache)  	listnode_add(cache_list, cache); -	if (rtr_is_running && -	    rtr_mgr_add_group(rtr_config, &group) != RTR_SUCCESS) { +	if (rtr_is_running +	    && rtr_mgr_add_group(rtr_config, &group) != RTR_SUCCESS) {  		return ERROR;  	}  	return SUCCESS;  } -static int add_tcp_cache(const char *host, -			 const char *port, +static int add_tcp_cache(const char *host, const char *port,  			 const uint8_t preference)  {  	struct rtr_socket *rtr_socket; @@ -556,10 +549,8 @@ static int add_tcp_cache(const char *host,  }  #if defined(FOUND_SSH) -static int add_ssh_cache(const char *host, -			 const unsigned int port, -			 const char *username, -			 const char *client_privkey_path, +static int add_ssh_cache(const char *host, const unsigned int port, +			 const char *username, const char *client_privkey_path,  			 const char *client_pubkey_path,  			 const char *server_pubkey_path,  			 const uint8_t preference) @@ -577,8 +568,8 @@ static int add_ssh_cache(const char *host,  	ssh_config->bindaddr = NULL;  	ssh_config->username = XSTRDUP(MTYPE_BGP_RPKI_CACHE, username); -	ssh_config->client_privkey_path = XSTRDUP( -			MTYPE_BGP_RPKI_CACHE, client_privkey_path); +	ssh_config->client_privkey_path = +		XSTRDUP(MTYPE_BGP_RPKI_CACHE, client_privkey_path);  	ssh_config->server_hostkey_path =  		XSTRDUP(MTYPE_BGP_RPKI_CACHE, server_pubkey_path); @@ -597,16 +588,13 @@ static int add_ssh_cache(const char *host,  static void free_cache(struct cache *cache)  {  	if (cache->type == TCP) { -		XFREE(MTYPE_BGP_RPKI_CACHE, -		      cache->tr_config.tcp_config->host); -		XFREE(MTYPE_BGP_RPKI_CACHE, -		      cache->tr_config.tcp_config->port); +		XFREE(MTYPE_BGP_RPKI_CACHE, cache->tr_config.tcp_config->host); +		XFREE(MTYPE_BGP_RPKI_CACHE, cache->tr_config.tcp_config->port);  		XFREE(MTYPE_BGP_RPKI_CACHE, cache->tr_config.tcp_config);  	}  #if defined(FOUND_SSH)  	else { -		XFREE(MTYPE_BGP_RPKI_CACHE, -		      cache->tr_config.ssh_config->host); +		XFREE(MTYPE_BGP_RPKI_CACHE, cache->tr_config.ssh_config->host);  		XFREE(MTYPE_BGP_RPKI_CACHE,  		      cache->tr_config.ssh_config->username);  		XFREE(MTYPE_BGP_RPKI_CACHE, @@ -644,22 +632,17 @@ static int config_write(struct vty *vty)  #endif  			case TCP:  				tcp_config = cache->tr_config.tcp_config; -				vty_out(vty, -					"  rpki cache %s %s ", -					tcp_config->host, -					tcp_config->port); +				vty_out(vty, "  rpki cache %s %s ", +					tcp_config->host, tcp_config->port);  				break;  #if defined(FOUND_SSH)  			case SSH:  				ssh_config = cache->tr_config.ssh_config; -				vty_out(vty, -					"  rpki cache %s %u %s %s %s ", -					ssh_config->host, -					ssh_config->port, +				vty_out(vty, "  rpki cache %s %u %s %s %s ", +					ssh_config->host, ssh_config->port,  					ssh_config->username,  					ssh_config->client_privkey_path, -					ssh_config->server_hostkey_path -							!= NULL +					ssh_config->server_hostkey_path != NULL  						? ssh_config  							  ->server_hostkey_path  						: " "); @@ -694,7 +677,8 @@ DEFUN (bgp_rpki_start,         "start rpki support\n")  {  	if (listcount(cache_list) == 0) -		vty_out(vty, "Could not start rpki because no caches are configured\n"); +		vty_out(vty, +			"Could not start rpki because no caches are configured\n");  	if (!is_running()) {  		if (start() == ERROR) { @@ -855,9 +839,9 @@ DEFPY (rpki_cache,  	// use ssh connection  	if (ssh_uname) {  #if defined(FOUND_SSH) -		return_value = add_ssh_cache( -			cache, sshport, ssh_uname, ssh_privkey, ssh_pubkey, -			server_pubkey, preference); +		return_value = +			add_ssh_cache(cache, sshport, ssh_uname, ssh_privkey, +				      ssh_pubkey, server_pubkey, preference);  #else  		vty_out(vty,  			"ssh sockets are not supported. " @@ -923,8 +907,7 @@ DEFUN (show_rpki_prefix_table,  	struct cache *cache;  	for (ALL_LIST_ELEMENTS_RO(cache_list, cache_node, cache)) { -		vty_out(vty, -			"host: %s port: %s\n", +		vty_out(vty, "host: %s port: %s\n",  			cache->tr_config.tcp_config->host,  			cache->tr_config.tcp_config->port);  	} @@ -947,8 +930,7 @@ DEFUN (show_rpki_cache_server,  	struct cache *cache;  	for (ALL_LIST_ELEMENTS_RO(cache_list, cache_node, cache)) { -		vty_out(vty, -			"host: %s port: %s\n", +		vty_out(vty, "host: %s port: %s\n",  			cache->tr_config.tcp_config->host,  			cache->tr_config.tcp_config->port);  	} @@ -973,8 +955,7 @@ DEFUN (show_rpki_cache_connection,  			return CMD_SUCCESS;  		}  		vty_out(vty, "Connected to group %d\n", group->preference); -		for (ALL_LIST_ELEMENTS_RO(cache_list, cache_node, -					  cache)) { +		for (ALL_LIST_ELEMENTS_RO(cache_list, cache_node, cache)) {  			if (cache->preference == group->preference) {  				struct tr_tcp_config *tcp_config;  #if defined(FOUND_SSH) @@ -984,8 +965,7 @@ DEFUN (show_rpki_cache_connection,  				switch (cache->type) {  				case TCP:  					tcp_config = -						cache->tr_config -							.tcp_config; +						cache->tr_config.tcp_config;  					vty_out(vty,  						"rpki tcp cache %s %s pref %hhu\n",  						tcp_config->host, @@ -996,8 +976,7 @@ DEFUN (show_rpki_cache_connection,  #if defined(FOUND_SSH)  				case SSH:  					ssh_config = -						cache->tr_config -							.ssh_config; +						cache->tr_config.ssh_config;  					vty_out(vty,  						"rpki ssh cache %s %u pref %hhu\n",  						ssh_config->host, @@ -1142,9 +1121,9 @@ static void overwrite_exit_commands(void)  	for (i = 0; i < cmd_vector->active; ++i) {  		struct cmd_element *cmd = vector_lookup(cmd_vector, i); -		if (strcmp(cmd->string, "exit") == 0 || -		    strcmp(cmd->string, "quit") == 0 || -		    strcmp(cmd->string, "end") == 0) { +		if (strcmp(cmd->string, "exit") == 0 +		    || strcmp(cmd->string, "quit") == 0 +		    || strcmp(cmd->string, "end") == 0) {  			uninstall_element(RPKI_NODE, cmd);  		}  	} @@ -1156,7 +1135,7 @@ static void overwrite_exit_commands(void)  static void install_cli_commands(void)  { -	//TODO: make config write work +	// TODO: make config write work  	install_node(&rpki_node, &config_write);  	install_default(RPKI_NODE);  	overwrite_exit_commands(); @@ -1212,4 +1191,4 @@ static void install_cli_commands(void)  FRR_MODULE_SETUP(.name = "bgpd_rpki", .version = "0.3.6",  		 .description = "Enable RPKI support for FRR.", -	 .init = bgp_rpki_module_init) +		 .init = bgp_rpki_module_init) diff --git a/bgpd/bgp_snmp.c b/bgpd/bgp_snmp.c index 8317a252e1..90ffa9da34 100644 --- a/bgpd/bgp_snmp.c +++ b/bgpd/bgp_snmp.c @@ -864,8 +864,6 @@ static u_char *bgp4PathAttrTable(struct variable *v, oid name[], size_t *length,  		return SNMP_INTEGER(-1);  		break;  	case BGP4PATHATTRBEST: /* 13 */ -			       /* $FRR indent$ */ -			       /* clang-format off */  #define BGP4_PathAttrBest_false 1  #define BGP4_PathAttrBest_true  2  		if (CHECK_FLAG(binfo->flags, BGP_INFO_SELECTED)) diff --git a/bgpd/bgp_updgrp.c b/bgpd/bgp_updgrp.c index 1c589f7960..d2e89a6785 100644 --- a/bgpd/bgp_updgrp.c +++ b/bgpd/bgp_updgrp.c @@ -85,9 +85,8 @@ static void sync_init(struct update_subgroup *subgrp)  	BGP_ADV_FIFO_INIT(&subgrp->sync->update);  	BGP_ADV_FIFO_INIT(&subgrp->sync->withdraw);  	BGP_ADV_FIFO_INIT(&subgrp->sync->withdraw_low); -	subgrp->hash = hash_create(baa_hash_key, -				   baa_hash_cmp, -				   "BGP SubGroup Hash"); +	subgrp->hash = +		hash_create(baa_hash_key, baa_hash_cmp, "BGP SubGroup Hash");  	/* We use a larger buffer for subgrp->work in the event that:  	 * - We RX a BGP_UPDATE where the attributes alone are just @@ -1545,8 +1544,7 @@ void update_bgp_group_init(struct bgp *bgp)  	AF_FOREACH (afid)  		bgp->update_groups[afid] = -			hash_create(updgrp_hash_key_make, -				    updgrp_hash_cmp, +			hash_create(updgrp_hash_key_make, updgrp_hash_cmp,  				    "BGP Update Group Hash");  } @@ -1877,11 +1875,12 @@ void subgroup_trigger_write(struct update_subgroup *subgrp)  	 * the subgroup output queue into their own output queue. This action  	 * will trigger a write job on the I/O thread.  	 */ -	SUBGRP_FOREACH_PEER(subgrp, paf) -	if (paf->peer->status == Established) -		thread_add_timer_msec(bm->master, bgp_generate_updgrp_packets, -				      paf->peer, 0, -				      &paf->peer->t_generate_updgrp_packets); +	SUBGRP_FOREACH_PEER (subgrp, paf) +		if (paf->peer->status == Established) +			thread_add_timer_msec( +				bm->master, bgp_generate_updgrp_packets, +				paf->peer, 0, +				&paf->peer->t_generate_updgrp_packets);  }  int update_group_clear_update_dbg(struct update_group *updgrp, void *arg) diff --git a/bgpd/bgp_updgrp.h b/bgpd/bgp_updgrp.h index e941fecb61..233fe5d14e 100644 --- a/bgpd/bgp_updgrp.h +++ b/bgpd/bgp_updgrp.h @@ -287,7 +287,6 @@ struct update_subgroup {   */  #define SUBGRP_DECR_STAT(subgrp, stat) SUBGRP_INCR_STAT_BY(subgrp, stat, -1) -  typedef int (*updgrp_walkcb)(struct update_group *updgrp, void *ctx);  /* really a private structure */ @@ -341,23 +340,23 @@ struct updwalk_context {   * Walk all subgroups in an update group.   */  #define UPDGRP_FOREACH_SUBGRP(updgrp, subgrp)                                  \ -	LIST_FOREACH(subgrp, &((updgrp)->subgrps), updgrp_train) +	LIST_FOREACH (subgrp, &((updgrp)->subgrps), updgrp_train)  #define UPDGRP_FOREACH_SUBGRP_SAFE(updgrp, subgrp, tmp_subgrp)                 \ -	LIST_FOREACH_SAFE(subgrp, &((updgrp)->subgrps), updgrp_train,          \ -			  tmp_subgrp) +	LIST_FOREACH_SAFE (subgrp, &((updgrp)->subgrps), updgrp_train,         \ +			   tmp_subgrp)  #define SUBGRP_FOREACH_PEER(subgrp, paf)                                       \ -	LIST_FOREACH(paf, &(subgrp->peers), subgrp_train) +	LIST_FOREACH (paf, &(subgrp->peers), subgrp_train)  #define SUBGRP_FOREACH_PEER_SAFE(subgrp, paf, temp_paf)                        \ -	LIST_FOREACH_SAFE(paf, &(subgrp->peers), subgrp_train, temp_paf) +	LIST_FOREACH_SAFE (paf, &(subgrp->peers), subgrp_train, temp_paf)  #define SUBGRP_FOREACH_ADJ(subgrp, adj)                                        \ -	TAILQ_FOREACH(adj, &(subgrp->adjq), subgrp_adj_train) +	TAILQ_FOREACH (adj, &(subgrp->adjq), subgrp_adj_train)  #define SUBGRP_FOREACH_ADJ_SAFE(subgrp, adj, adj_temp)                         \ -	TAILQ_FOREACH_SAFE(adj, &(subgrp->adjq), subgrp_adj_train, adj_temp) +	TAILQ_FOREACH_SAFE (adj, &(subgrp->adjq), subgrp_adj_train, adj_temp)  /* Prototypes.  */  /* bgp_updgrp.c */ diff --git a/bgpd/bgp_updgrp_packet.c b/bgpd/bgp_updgrp_packet.c index 9fa733a720..1d50cb1ca1 100644 --- a/bgpd/bgp_updgrp_packet.c +++ b/bgpd/bgp_updgrp_packet.c @@ -733,8 +733,9 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)  		space_remaining = STREAM_CONCAT_REMAIN(s, snlri, STREAM_SIZE(s))  				  - BGP_MAX_PACKET_SIZE_OVERFLOW; -		space_needed = BGP_NLRI_LENGTH + addpath_overhead + -			       bgp_packet_mpattr_prefix_size(afi, safi, &rn->p); +		space_needed = +			BGP_NLRI_LENGTH + addpath_overhead +			+ bgp_packet_mpattr_prefix_size(afi, safi, &rn->p);  		/* When remaining space can't include NLRI and it's length.  */  		if (space_remaining < space_needed) @@ -778,9 +779,9 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)  			space_remaining =  				STREAM_CONCAT_REMAIN(s, snlri, STREAM_SIZE(s))  				- BGP_MAX_PACKET_SIZE_OVERFLOW; -			space_needed = BGP_NLRI_LENGTH + addpath_overhead + -				bgp_packet_mpattr_prefix_size(afi, safi, -							      &rn->p); +			space_needed = BGP_NLRI_LENGTH + addpath_overhead +				       + bgp_packet_mpattr_prefix_size( +						 afi, safi, &rn->p);  			/* If the attributes alone do not leave any room for  			 * NLRI then diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 8fa5dc9c6f..3bdd09c3c1 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -832,8 +832,7 @@ DEFUN_NOSH (router_bgp,  		}  		if (listcount(bm->bgp) > 1) { -			vty_out(vty, -				"%% Please specify ASN and VRF\n"); +			vty_out(vty, "%% Please specify ASN and VRF\n");  			return CMD_WARNING_CONFIG_FAILED;  		}  	} @@ -908,8 +907,7 @@ DEFUN (no_router_bgp,  		}  		if (listcount(bm->bgp) > 1) { -			vty_out(vty, -				"%% Please specify ASN and VRF\n"); +			vty_out(vty, "%% Please specify ASN and VRF\n");  			return CMD_WARNING_CONFIG_FAILED;  		} @@ -1540,8 +1538,7 @@ DEFUN (no_bgp_maxpaths,  }  ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, -	     "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", -	     NO_STR +	     "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR  	     "Forward packets over multiple paths\n"  	     "Number of paths\n") @@ -6571,9 +6568,8 @@ DEFUN (show_bgp_vrfs,  		json_object_int_add(json, "totalVrfs", count); -		vty_out(vty, "%s\n", -			json_object_to_json_string_ext( -				json, JSON_C_TO_STRING_PRETTY)); +		vty_out(vty, "%s\n", json_object_to_json_string_ext( +					     json, JSON_C_TO_STRING_PRETTY));  		json_object_free(json);  	} else {  		if (count) @@ -6722,20 +6718,17 @@ DEFUN (show_bgp_memory,  	/* Other attributes */  	if ((count = community_count()))  		vty_out(vty, "%ld BGP community entries, using %s of memory\n", -			count, -			mtype_memstr(memstrbuf, sizeof(memstrbuf), -				     count * sizeof(struct community))); +			count, mtype_memstr(memstrbuf, sizeof(memstrbuf), +					    count * sizeof(struct community)));  	if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY)))  		vty_out(vty, "%ld BGP community entries, using %s of memory\n", -			count, -			mtype_memstr(memstrbuf, sizeof(memstrbuf), -				     count * sizeof(struct ecommunity))); +			count, mtype_memstr(memstrbuf, sizeof(memstrbuf), +					    count * sizeof(struct ecommunity)));  	if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY)))  		vty_out(vty,  			"%ld BGP large-community entries, using %s of memory\n", -			count, -			mtype_memstr(memstrbuf, sizeof(memstrbuf), -				     count * sizeof(struct lcommunity))); +			count, mtype_memstr(memstrbuf, sizeof(memstrbuf), +					    count * sizeof(struct lcommunity)));  	if ((count = mtype_stats_alloc(MTYPE_CLUSTER)))  		vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, @@ -6764,9 +6757,8 @@ DEFUN (show_bgp_memory,  				     count * sizeof(struct hash_backet)));  	if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP)))  		vty_out(vty, "%ld compiled regexes, using %s of memory\n", -			count, -			mtype_memstr(memstrbuf, sizeof(memstrbuf), -				     count * sizeof(regex_t))); +			count, mtype_memstr(memstrbuf, sizeof(memstrbuf), +					    count * sizeof(regex_t)));  	return CMD_SUCCESS;  } @@ -7018,9 +7010,8 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,  						json, "peerGroupCount", ents);  					json_object_int_add(  						json, "peerGroupMemory", -						ents -							* sizeof(struct -								 peer_group)); +						ents * sizeof(struct +							      peer_group));  				}  				if (CHECK_FLAG(bgp->af_flags[afi][safi], @@ -7043,11 +7034,10 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,  				vty_out(vty,  					"RIB entries %ld, using %s of memory\n",  					ents, -					mtype_memstr( -						memstrbuf, sizeof(memstrbuf), -						ents -							* sizeof(struct -								 bgp_node))); +					mtype_memstr(memstrbuf, +						     sizeof(memstrbuf), +						     ents * sizeof(struct +								   bgp_node)));  				/* Peer related usage */  				ents = listcount(bgp->peer); @@ -7064,9 +7054,8 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,  						mtype_memstr(  							memstrbuf,  							sizeof(memstrbuf), -							ents -								* sizeof(struct -									 peer_group))); +							ents * sizeof(struct +								      peer_group)));  				if (CHECK_FLAG(bgp->af_flags[afi][safi],  					       BGP_CONFIG_DAMPENING)) @@ -7199,9 +7188,8 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,  		bgp_show_bestpath_json(bgp, json); -		vty_out(vty, "%s\n", -			json_object_to_json_string_ext( -				json, JSON_C_TO_STRING_PRETTY)); +		vty_out(vty, "%s\n", json_object_to_json_string_ext( +					     json, JSON_C_TO_STRING_PRETTY));  		json_object_free(json);  	} else {  		if (count) @@ -7836,9 +7824,8 @@ static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi,  		paf = peer_af_find(p, afi, safi);  		if (paf && PAF_SUBGRP(paf)) { -			vty_out(vty, -				"  Update group %" PRIu64 ", subgroup %" PRIu64 -				"\n", +			vty_out(vty, "  Update group %" PRIu64 +				     ", subgroup %" PRIu64 "\n",  				PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id);  			vty_out(vty, "  Packet Queue length %d\n",  				bpacket_queue_virtual_length(paf)); @@ -9638,9 +9625,8 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, u_char use_json,  			} else  				vty_out(vty,  					"  Reduce the no. of prefix from %s, will restart in %ld seconds\n", -					p->host, -					thread_timer_remain_second( -						p->t_pmax_restart)); +					p->host, thread_timer_remain_second( +							 p->t_pmax_restart));  		} else {  			if (use_json)  				json_object_boolean_true_add( @@ -9884,9 +9870,8 @@ static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp,  	}  	if (use_json) { -		vty_out(vty, "%s\n", -			json_object_to_json_string_ext( -				json, JSON_C_TO_STRING_PRETTY)); +		vty_out(vty, "%s\n", json_object_to_json_string_ext( +					     json, JSON_C_TO_STRING_PRETTY));  		json_object_free(json);  	} else {  		vty_out(vty, "\n"); diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 029b3d4d36..23f626e960 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -1746,8 +1746,7 @@ static int bgp_zebra_process_local_l3vni(int cmd, struct zclient *zclient,  	if (BGP_DEBUG(zebra, ZEBRA))  		zlog_debug("Rx L3-VNI %s VRF %s VNI %u RMAC %s filter %s",  			   (cmd == ZEBRA_L3VNI_ADD) ? "add" : "del", -			   vrf_id_to_name(vrf_id), -			   l3vni, +			   vrf_id_to_name(vrf_id), l3vni,  			   prefix_mac2str(&rmac, buf, sizeof(buf)),  			   filter ? "prefix-routes-only" : "none"); diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index c06339aad9..c2fd125b71 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -3019,17 +3019,15 @@ struct bgp *bgp_lookup_by_vrf_id(vrf_id_t vrf_id)  /* handle socket creation or deletion, if necessary   * this is called for all new BGP instances   */ -int bgp_handle_socket(struct bgp *bgp, struct vrf *vrf, -			  vrf_id_t old_vrf_id, bool create) +int bgp_handle_socket(struct bgp *bgp, struct vrf *vrf, vrf_id_t old_vrf_id, +		      bool create)  {  	int ret = 0;  	/* Create BGP server socket, if listen mode not disabled */  	if (!bgp || bgp_option_check(BGP_OPT_NO_LISTEN))  		return 0; -	if (bgp->name -	    && bgp->inst_type == BGP_INSTANCE_TYPE_VRF -	    && vrf) { +	if (bgp->name && bgp->inst_type == BGP_INSTANCE_TYPE_VRF && vrf) {  		/*  		 * suppress vrf socket  		 */ @@ -3425,8 +3423,8 @@ struct peer *peer_lookup(struct bgp *bgp, union sockunion *su)  			 * invoked without an instance  			 * when examining VRFs.  			 */ -			if ((bgp->inst_type == BGP_INSTANCE_TYPE_VRF) && -			    !vrf_is_mapped_on_netns(bgp->vrf_id)) +			if ((bgp->inst_type == BGP_INSTANCE_TYPE_VRF) +			    && !vrf_is_mapped_on_netns(bgp->vrf_id))  				continue;  			peer = hash_lookup(bgp->peerhash, &tmp_peer); @@ -4070,9 +4068,8 @@ static int peer_af_flag_modify(struct peer *peer, afi_t afi, safi_t safi,  	}  	/* Track if addpath TX is in use */ -	if (flag -	    & (PEER_FLAG_ADDPATH_TX_ALL_PATHS -	       | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) { +	if (flag & (PEER_FLAG_ADDPATH_TX_ALL_PATHS +		    | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) {  		bgp = peer->bgp;  		addpath_tx_used = 0; @@ -6885,9 +6882,8 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,  	} else {  		if (!peer_af_flag_check(peer, afi, safi,  					PEER_FLAG_SEND_COMMUNITY) -		    && (!g_peer -			|| peer_af_flag_check(g_peer, afi, safi, -					      PEER_FLAG_SEND_COMMUNITY)) +		    && (!g_peer || peer_af_flag_check(g_peer, afi, safi, +						      PEER_FLAG_SEND_COMMUNITY))  		    && !peer_af_flag_check(peer, afi, safi,  					   PEER_FLAG_SEND_EXT_COMMUNITY)  		    && (!g_peer @@ -6895,10 +6891,9 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,  					      PEER_FLAG_SEND_EXT_COMMUNITY))  		    && !peer_af_flag_check(peer, afi, safi,  					   PEER_FLAG_SEND_LARGE_COMMUNITY) -		    && (!g_peer -			|| peer_af_flag_check( -				   g_peer, afi, safi, -				   PEER_FLAG_SEND_LARGE_COMMUNITY))) { +		    && (!g_peer || peer_af_flag_check( +					   g_peer, afi, safi, +					   PEER_FLAG_SEND_LARGE_COMMUNITY))) {  			vty_out(vty, "  no neighbor %s send-community all\n",  				addr);  		} else { @@ -6926,10 +6921,9 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,  			if (!peer_af_flag_check(peer, afi, safi,  						PEER_FLAG_SEND_COMMUNITY) -			    && (!g_peer -				|| peer_af_flag_check( -					   g_peer, afi, safi, -					   PEER_FLAG_SEND_COMMUNITY))) { +			    && (!g_peer || peer_af_flag_check( +						   g_peer, afi, safi, +						   PEER_FLAG_SEND_COMMUNITY))) {  				vty_out(vty,  					"  no neighbor %s send-community\n",  					addr); diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index b3c7418602..e265da803f 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -133,8 +133,6 @@ struct bgp_master {  	/* timer to dampen route map changes */  	struct thread *t_rmap_update; /* Handle route map updates */  	u_int32_t rmap_update_timer;  /* Route map update timer */ -				      /* $FRR indent$ */ -				      /* clang-format off */  #define RMAP_DEFAULT_UPDATE_TIMER 5 /* disabled by default */  	/* Id space for automatic RD derivation for an EVI/VRF */ @@ -249,8 +247,6 @@ struct bgp {  		*t_startup; /* start-up timer on only once at the beginning */  	u_int32_t v_maxmed_onstartup;     /* Duration of max-med on start-up */ -					  /* $FRR indent$ */ -					  /* clang-format off */  #define BGP_MAXMED_ONSTARTUP_UNCONFIGURED  0 /* 0 means off, its the default */  	u_int32_t maxmed_onstartup_value; /* Max-med value when active on  					     start-up */ @@ -259,17 +255,13 @@ struct bgp {  	u_char maxmed_onstartup_over; /* Flag to make it effective only once */  	u_char v_maxmed_admin; /* 1/0 if max-med administrative is on/off */ -			       /* $FRR indent$ */ -			       /* clang-format off */  #define BGP_MAXMED_ADMIN_UNCONFIGURED  0 /* Off by default */  	u_int32_t maxmed_admin_value; /* Max-med value when administrative in on  				       */ -				      /* $FRR indent$ */ -				      /* clang-format off */  #define BGP_MAXMED_VALUE_DEFAULT  4294967294 /* Maximum by default */ -	u_char maxmed_active;	 /* 1/0 if max-med is active or not */ -	u_int32_t maxmed_value;       /* Max-med value when its active */ +	u_char maxmed_active;   /* 1/0 if max-med is active or not */ +	u_int32_t maxmed_value; /* Max-med value when its active */  	/* BGP update delay on startup */  	struct thread *t_update_delay; @@ -680,8 +672,6 @@ struct peer {  	unsigned short port; /* Destination port for peer */  	char *host;	  /* Printable address of the peer. */  	union sockunion su;  /* Sockunion address of the peer. */ -			     /* $FRR indent$ */ -			     /* clang-format off */  #define BGP_PEER_SU_UNSPEC(peer) (peer->su.sa.sa_family == AF_UNSPEC)  	time_t uptime;       /* Last Up/Down time */  	time_t readtime;     /* Last read time */ @@ -898,8 +888,8 @@ struct peer {  				       memory_order_relaxed)  	/* Statistics field */ -	_Atomic uint32_t open_in;         /* Open message input count */ -	_Atomic uint32_t open_out;        /* Open message output count */ +	_Atomic uint32_t open_in;	 /* Open message input count */ +	_Atomic uint32_t open_out;	/* Open message output count */  	_Atomic uint32_t update_in;       /* Update message input count */  	_Atomic uint32_t update_out;      /* Update message ouput count */  	_Atomic time_t update_time;       /* Update message received time. */ diff --git a/bgpd/rfapi/bgp_rfapi_cfg.c b/bgpd/rfapi/bgp_rfapi_cfg.c index f28b8a2ced..4c7c392ab8 100644 --- a/bgpd/rfapi/bgp_rfapi_cfg.c +++ b/bgpd/rfapi/bgp_rfapi_cfg.c @@ -1636,9 +1636,8 @@ DEFUN (vnc_nve_group_export_no_prefixlist,  	idx += 2; /* skip afi and keyword */  	if (is_bgp) { -		if (idx == argc -		    || strmatch(argv[idx]->arg, -				rfg->plist_export_bgp_name[afi])) { +		if (idx == argc || strmatch(argv[idx]->arg, +					    rfg->plist_export_bgp_name[afi])) {  			if (rfg->plist_export_bgp_name[afi])  				free(rfg->plist_export_bgp_name[afi]);  			rfg->plist_export_bgp_name[afi] = NULL; @@ -1768,9 +1767,8 @@ DEFUN (vnc_nve_group_export_no_routemap,  	}  	if (is_bgp) { -		if (idx == argc -		    || strmatch(argv[idx]->arg, -				rfg->routemap_export_bgp_name)) { +		if (idx == argc || strmatch(argv[idx]->arg, +					    rfg->routemap_export_bgp_name)) {  			if (rfg->routemap_export_bgp_name)  				free(rfg->routemap_export_bgp_name);  			rfg->routemap_export_bgp_name = NULL; @@ -1780,9 +1778,8 @@ DEFUN (vnc_nve_group_export_no_routemap,  			vnc_direct_bgp_reexport_group_afi(bgp, rfg, AFI_IP6);  		}  	} else { -		if (idx == argc -		    || strmatch(argv[idx]->arg, -				rfg->routemap_export_zebra_name)) { +		if (idx == argc || strmatch(argv[idx]->arg, +					    rfg->routemap_export_zebra_name)) {  			if (rfg->routemap_export_zebra_name)  				free(rfg->routemap_export_zebra_name);  			rfg->routemap_export_zebra_name = NULL; @@ -2978,7 +2975,8 @@ DEFUN_NOSH (vnc_vrf_policy,  	VTY_DECLVAR_CONTEXT(bgp, bgp);  	if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) { -		vty_out(vty, "Can't configure vrf-policy within a BGP VRF instance\n"); +		vty_out(vty, +			"Can't configure vrf-policy within a BGP VRF instance\n");  		return CMD_WARNING_CONFIG_FAILED;  	} diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c index 9d169eed32..8d782864c8 100644 --- a/bgpd/rfapi/rfapi.c +++ b/bgpd/rfapi/rfapi.c @@ -383,9 +383,8 @@ void del_vnc_route(struct rfapi_descriptor *rfd,  	vnc_zlog_debug_verbose(  		"%s: peer=%p, prefix=%s, prd=%s afi=%d, safi=%d bn=%p, bn->info=%p", -		__func__, peer, buf, -		prefix_rd2str(prd, buf2, sizeof(buf2)), afi, safi, bn, -		(bn ? bn->info : NULL)); +		__func__, peer, buf, prefix_rd2str(prd, buf2, sizeof(buf2)), +		afi, safi, bn, (bn ? bn->info : NULL));  	for (bi = (bn ? bn->info : NULL); bi; bi = bi->next) { @@ -749,9 +748,8 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */  	if (lifetime && *lifetime != RFAPI_INFINITE_LIFETIME) {  		uint32_t lt; -		encaptlv = -			XCALLOC(MTYPE_ENCAP_TLV, -				sizeof(struct bgp_attr_encap_subtlv) + 4); +		encaptlv = XCALLOC(MTYPE_ENCAP_TLV, +				   sizeof(struct bgp_attr_encap_subtlv) + 4);  		assert(encaptlv);  		encaptlv->type =  			BGP_VNC_SUBTLV_TYPE_LIFETIME; /* prefix lifetime */ @@ -795,8 +793,8 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */  				 */  				encaptlv = XCALLOC(  					MTYPE_ENCAP_TLV, -					sizeof(struct bgp_attr_encap_subtlv) -					+ 2 + hop->length); +					sizeof(struct bgp_attr_encap_subtlv) + 2 +						+ hop->length);  				assert(encaptlv);  				encaptlv->type =  					BGP_VNC_SUBTLV_TYPE_RFPOPTION; /* RFP diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c index e1508dbd83..c7d64bf1ed 100644 --- a/bgpd/rfapi/rfapi_import.c +++ b/bgpd/rfapi/rfapi_import.c @@ -1083,9 +1083,8 @@ int rfapiEcommunityGetEthernetTag(struct ecommunity *ecom, uint16_t *tag_id)  				} else if (encode == ECOMMUNITY_ENCODE_AS) {  					as = (*p++ << 8);  					as |= (*p++); -					p += -						2; /* skip next two, tag/vid -						      always in lowest bytes */ +					p += 2; /* skip next two, tag/vid +						   always in lowest bytes */  				}  				if (as == bgp->as) {  					*tag_id = *p++ << 8; @@ -1221,8 +1220,7 @@ static int rfapiVpnBiSamePtUn(struct bgp_info *bi1, struct bgp_info *bi2)  	switch (pfx_un1.family) {  	case AF_INET: -		if (!IPV4_ADDR_SAME(&pfx_un1.u.prefix4, -				    &pfx_un2.u.prefix4)) +		if (!IPV4_ADDR_SAME(&pfx_un1.u.prefix4, &pfx_un2.u.prefix4))  			return 0;  		break;  	case AF_INET6: @@ -2235,9 +2233,9 @@ static struct bgp_info *rfapiItBiIndexSearch(  				vnc_zlog_debug_verbose(  					"%s: bi has prd=%s, peer=%p", __func__, -					prefix_rd2str(&bi_result->extra->vnc.import.rd, -						      buf, -						      sizeof(buf)), +					prefix_rd2str(&bi_result->extra->vnc +							       .import.rd, +						      buf, sizeof(buf)),  					bi_result->peer);  			}  #endif diff --git a/bgpd/rfapi/rfapi_monitor.c b/bgpd/rfapi/rfapi_monitor.c index 5c222b6dda..30182ba7a6 100644 --- a/bgpd/rfapi/rfapi_monitor.c +++ b/bgpd/rfapi/rfapi_monitor.c @@ -929,17 +929,14 @@ void rfapiMonitorItNodeChanged(  					char buf_attach_pfx[PREFIX_STRLEN];  					char buf_target_pfx[PREFIX_STRLEN]; -					prefix2str(&m->node->p, -						   buf_attach_pfx, +					prefix2str(&m->node->p, buf_attach_pfx,  						   sizeof(buf_attach_pfx)); -					prefix2str(&m->p, -						   buf_target_pfx, +					prefix2str(&m->p, buf_target_pfx,  						   sizeof(buf_target_pfx));  					vnc_zlog_debug_verbose(  						"%s: update rfd %p attached to pfx %s (targ=%s)",  						__func__, m->rfd, -						buf_attach_pfx, -						buf_target_pfx); +						buf_attach_pfx, buf_target_pfx);  					/*  					 * update its RIB diff --git a/bgpd/rfapi/rfapi_private.h b/bgpd/rfapi/rfapi_private.h index c82a0d6c6f..9c759fc47e 100644 --- a/bgpd/rfapi/rfapi_private.h +++ b/bgpd/rfapi/rfapi_private.h @@ -345,7 +345,8 @@ extern void rfapi_un_options_free(struct rfapi_un_option *goner);  extern void rfapi_vn_options_free(struct rfapi_vn_option *goner); -extern void vnc_add_vrf_opener(struct bgp *bgp, struct rfapi_nve_group_cfg *rfg); +extern void vnc_add_vrf_opener(struct bgp *bgp, +			       struct rfapi_nve_group_cfg *rfg);  extern void clear_vnc_vrf_closer(struct rfapi_nve_group_cfg *rfg);  /*------------------------------------------   * rfapi_extract_l2o diff --git a/bgpd/rfapi/rfapi_rib.c b/bgpd/rfapi/rfapi_rib.c index 271c748510..2a8a465b70 100644 --- a/bgpd/rfapi/rfapi_rib.c +++ b/bgpd/rfapi/rfapi_rib.c @@ -511,7 +511,8 @@ void rfapiRibClear(struct rfapi_descriptor *rfd)  				if (pn->info) {  					if (pn->info != (void *)1) {  						list_delete_and_null( -							(struct list **)(&pn->info)); +							(struct list * +								 *)(&pn->info));  					}  					pn->info = NULL;  					/* linklist or 1 deleted */ @@ -1407,9 +1408,10 @@ callback:  						vnc_zlog_debug_verbose(  							"%s: move route to recently deleted list, rd=%s",  							__func__, -							prefix_rd2str(&ri->rk.rd, -								      buf_rd, -								      sizeof(buf_rd))); +							prefix_rd2str( +								&ri->rk.rd, +								buf_rd, +								sizeof(buf_rd)));  					}  #endif diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c index 28d068cc57..c5b3094b1e 100644 --- a/bgpd/rfapi/rfapi_vty.c +++ b/bgpd/rfapi/rfapi_vty.c @@ -1163,8 +1163,7 @@ static int rfapiPrintRemoteRegBi(struct bgp *bgp, void *stream,  		 * print that on the next line  		 */ -		if (bi->extra -		    && bi->extra->vnc.import.aux_prefix.family) { +		if (bi->extra && bi->extra->vnc.import.aux_prefix.family) {  			const char *sp;  			sp = rfapi_ntop( @@ -4630,7 +4629,7 @@ notcfg:   ************************************************************************/  void vnc_add_vrf_opener(struct bgp *bgp, struct rfapi_nve_group_cfg *rfg)  { -	if (rfg->rfd == NULL) {	/* need new rfapi_handle */ +	if (rfg->rfd == NULL) { /* need new rfapi_handle */  		/* based on rfapi_open */  		struct rfapi_descriptor *rfd; diff --git a/bgpd/rfapi/vnc_export_bgp.c b/bgpd/rfapi/vnc_export_bgp.c index e294cae074..c4d66bbc65 100644 --- a/bgpd/rfapi/vnc_export_bgp.c +++ b/bgpd/rfapi/vnc_export_bgp.c @@ -53,8 +53,7 @@  static void vnc_direct_add_rn_group_rd(struct bgp *bgp,  				       struct rfapi_nve_group_cfg *rfg, -				       struct route_node *rn, -				       struct attr *attr, +				       struct route_node *rn, struct attr *attr,  				       afi_t afi,  				       struct rfapi_descriptor *irfd); @@ -879,8 +878,9 @@ void vnc_direct_bgp_del_prefix(struct bgp *bgp,  				     NULL,		 /* attr, ignored */  				     afi, SAFI_UNICAST, ZEBRA_ROUTE_VNC_DIRECT,  				     BGP_ROUTE_REDISTRIBUTE, -				     NULL,	/* RD not used for unicast */ -				     NULL, 0, NULL); /* tag not used for unicast */ +				     NULL, /* RD not used for unicast */ +				     NULL, 0, +				     NULL); /* tag not used for unicast */  			/*  			 * yuck!  			 *  - but consistent with rest of function @@ -908,8 +908,9 @@ void vnc_direct_bgp_del_prefix(struct bgp *bgp,  				     NULL,		 /* attr, ignored */  				     afi, SAFI_UNICAST, ZEBRA_ROUTE_VNC_DIRECT,  				     BGP_ROUTE_REDISTRIBUTE, -				     NULL,	/* RD not used for unicast */ -				     NULL, 0, NULL); /* tag not used for unicast */ +				     NULL, /* RD not used for unicast */ +				     NULL, 0, +				     NULL); /* tag not used for unicast */  		}  	}  } @@ -1151,10 +1152,8 @@ void vnc_direct_bgp_del_nve(struct bgp *bgp, struct rfapi_descriptor *rfd)  static void vnc_direct_add_rn_group_rd(struct bgp *bgp,  				       struct rfapi_nve_group_cfg *rfg, -				       struct route_node *rn, -				       struct attr *attr, -				       afi_t afi, -				       struct rfapi_descriptor *irfd) +				       struct route_node *rn, struct attr *attr, +				       afi_t afi, struct rfapi_descriptor *irfd)  {  	struct prefix nhp;  	struct bgp_info info; @@ -1167,23 +1166,26 @@ static void vnc_direct_add_rn_group_rd(struct bgp *bgp,  		assert(rfg->rfd == NULL);  		if (!rfg->rt_export_list || !rfg->rfapi_import_table) { -			vnc_zlog_debug_verbose("%s: VRF \"%s\" is missing RT import/export configuration.\n", -					       __func__, rfg->name); +			vnc_zlog_debug_verbose( +				"%s: VRF \"%s\" is missing RT import/export configuration.\n", +				__func__, rfg->name);  			return;  		}  		if (!rfg->rd.prefixlen) { -			vnc_zlog_debug_verbose("%s: VRF \"%s\" is missing RD configuration.\n", -					       __func__, rfg->name); +			vnc_zlog_debug_verbose( +				"%s: VRF \"%s\" is missing RD configuration.\n", +				__func__, rfg->name);  			return;  		}  		if (rfg->label > MPLS_LABEL_MAX) { -			vnc_zlog_debug_verbose("%s: VRF \"%s\" is missing defaul label configuration.\n", -					       __func__, rfg->name); +			vnc_zlog_debug_verbose( +				"%s: VRF \"%s\" is missing defaul label configuration.\n", +				__func__, rfg->name);  			return;  		}  		irfd = XCALLOC(MTYPE_RFAPI_DESC, -			      sizeof(struct rfapi_descriptor)); +			       sizeof(struct rfapi_descriptor));  		irfd->bgp = bgp;  		rfg->rfd = irfd;  		/* @@ -1219,11 +1221,9 @@ static void vnc_direct_add_rn_group_rd(struct bgp *bgp,  		return;  	if (VNC_DEBUG(EXPORT_BGP_DIRECT_ADD)) { -		vnc_zlog_debug_any("%s: attr follows", -				   __func__); +		vnc_zlog_debug_any("%s: attr follows", __func__);  		rfapiPrintAttrPtrs(NULL, attr); -		vnc_zlog_debug_any("%s: hattr follows", -				   __func__); +		vnc_zlog_debug_any("%s: hattr follows", __func__);  		rfapiPrintAttrPtrs(NULL, &hattr);  	} @@ -1232,12 +1232,13 @@ static void vnc_direct_add_rn_group_rd(struct bgp *bgp,  		info.peer = irfd->peer;  		info.attr = &hattr; -		ret = route_map_apply(rfg->routemap_export_bgp, -				      &rn->p, RMAP_BGP, &info); +		ret = route_map_apply(rfg->routemap_export_bgp, &rn->p, +				      RMAP_BGP, &info);  		if (ret == RMAP_DENYMATCH) {  			bgp_attr_flush(&hattr); -			vnc_zlog_debug_verbose("%s: route map says DENY, so not calling bgp_update", -					       __func__); +			vnc_zlog_debug_verbose( +				"%s: route map says DENY, so not calling bgp_update", +				__func__);  			return;  		}  	} @@ -1252,13 +1253,11 @@ static void vnc_direct_add_rn_group_rd(struct bgp *bgp,  	bgp_update(irfd->peer, &rn->p, /* prefix */  		   0,		       /* addpath_id */ -		   iattr, /* bgp_update copies it */ -		   afi, SAFI_UNICAST, -		   ZEBRA_ROUTE_VNC_DIRECT, -		   BGP_ROUTE_REDISTRIBUTE, -		   NULL, /* RD not used for unicast */ -		   NULL, /* tag not used for unicast */ -		   0, 0, NULL); /* EVPN not used */ +		   iattr,	      /* bgp_update copies it */ +		   afi, SAFI_UNICAST, ZEBRA_ROUTE_VNC_DIRECT, +		   BGP_ROUTE_REDISTRIBUTE, NULL, /* RD not used for unicast */ +		   NULL,			 /* tag not used for unicast */ +		   0, 0, NULL);			 /* EVPN not used */  	bgp_attr_unintern(&iattr); @@ -1338,7 +1337,8 @@ static void vnc_direct_bgp_add_group_afi(struct bgp *bgp,  			for (ln = listhead(rfg->nves); ln;  			     ln = listnextnode(ln)) {  				vnc_direct_add_rn_group_rd(bgp, rfg, rn, &attr, -						   afi, listgetdata(ln)); +							   afi, +							   listgetdata(ln));  			}  		}  	} @@ -1359,21 +1359,17 @@ void vnc_direct_bgp_add_group(struct bgp *bgp, struct rfapi_nve_group_cfg *rfg)  static void vnc_direct_del_rn_group_rd(struct bgp *bgp,  				       struct rfapi_nve_group_cfg *rfg, -				       struct route_node *rn, -				       afi_t afi, +				       struct route_node *rn, afi_t afi,  				       struct rfapi_descriptor *irfd)  {  	if (irfd == NULL)  		return;  	bgp_withdraw(irfd->peer, &rn->p, /* prefix */ -		     0,		    /* addpath_id */ -		     NULL,		    /* attr, ignored */ -		     afi, SAFI_UNICAST, -		     ZEBRA_ROUTE_VNC_DIRECT, -		     BGP_ROUTE_REDISTRIBUTE, -		     NULL, /* RD not used for unicast */ -		     NULL, 0, -		     NULL); /* tag not used for unicast */ +		     0,			 /* addpath_id */ +		     NULL,		 /* attr, ignored */ +		     afi, SAFI_UNICAST, ZEBRA_ROUTE_VNC_DIRECT, +		     BGP_ROUTE_REDISTRIBUTE, NULL, /* RD not used for unicast */ +		     NULL, 0, NULL); /* tag not used for unicast */  	return;  } @@ -1412,20 +1408,22 @@ static void vnc_direct_bgp_del_group_afi(struct bgp *bgp,  	for (rn = route_top(rt); rn; rn = route_next(rn))  		if (rn->info) {  			if (rfg->type == RFAPI_GROUP_CFG_VRF) -				vnc_direct_del_rn_group_rd(bgp, rfg, rn, -							   afi, rfg->rfd); +				vnc_direct_del_rn_group_rd(bgp, rfg, rn, afi, +							   rfg->rfd);  			else {  				struct listnode *ln;  				/* -				 * For each NVE that is assigned to the export nve +				 * For each NVE that is assigned to the export +				 * nve  				 * group, generate  				 * a route with that NVE as its next hop  				 */  				for (ln = listhead(rfg->nves); ln;  				     ln = listnextnode(ln)) -					vnc_direct_del_rn_group_rd(bgp, rfg, rn, -						afi, listgetdata(ln)); +					vnc_direct_del_rn_group_rd( +						bgp, rfg, rn, afi, +						listgetdata(ln));  			}  		}  } @@ -1529,8 +1527,8 @@ static void import_table_to_nve_list_direct_bgp(struct bgp *bgp,  		if (rfgn->rfg && rfgn->rfg->rfapi_import_table == it) {  			if (rfgn->rfg->nves)  				nve_group_to_nve_list(rfgn->rfg, nves, family); -			else if (rfgn->rfg->rfd && -				 rfgn->rfg->type == RFAPI_GROUP_CFG_VRF) { +			else if (rfgn->rfg->rfd +				 && rfgn->rfg->type == RFAPI_GROUP_CFG_VRF) {  				if (!*nves)  					*nves = list_new();  				listnode_add(*nves, rfgn->rfg->rfd); @@ -1716,7 +1714,7 @@ void vnc_direct_bgp_rh_add_route(struct bgp *bgp, afi_t afi,  		   iattr,	/* bgp_update copies this attr */  		   afi, SAFI_UNICAST, ZEBRA_ROUTE_VNC_DIRECT_RH,  		   BGP_ROUTE_REDISTRIBUTE, NULL, /* RD not used for unicast */ -		   NULL,     /* tag not used for unicast, EVPN neither */ +		   NULL,	/* tag not used for unicast, EVPN neither */  		   0, 0, NULL); /* EVPN not used */  	bgp_attr_unintern(&iattr);  } @@ -1732,7 +1730,8 @@ static int vncExportWithdrawTimer(struct thread *t)  		     NULL,			  /* attr, ignored */  		     family2afi(eti->node->p.family), SAFI_UNICAST, eti->type,  		     eti->subtype, NULL, /* RD not used for unicast */ -		     NULL, 0, NULL); /* tag not used for unicast, EVPN neither */ +		     NULL, 0, +		     NULL); /* tag not used for unicast, EVPN neither */  	/*  	 * Free the eti @@ -1855,9 +1854,8 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)  				prefix2str(&rn->p, prefixstr,  					   sizeof(prefixstr)); -				vnc_zlog_debug_verbose( -					"%s: checking prefix %s", __func__, -					prefixstr); +				vnc_zlog_debug_verbose("%s: checking prefix %s", +						       __func__, prefixstr);  			}  			/* diff --git a/bgpd/rfapi/vnc_import_bgp.c b/bgpd/rfapi/vnc_import_bgp.c index cfa4c599f2..4f54166434 100644 --- a/bgpd/rfapi/vnc_import_bgp.c +++ b/bgpd/rfapi/vnc_import_bgp.c @@ -2557,7 +2557,7 @@ void vnc_import_bgp_exterior_del_route_interior(  				if (bi->extra) {  					prd = &bi->extra->vnc.import.rd;  					label = decode_label( -							&bi->extra->label[0]); +						&bi->extra->label[0]);  				} else  					prd = NULL; diff --git a/eigrpd/eigrp_const.h b/eigrpd/eigrp_const.h index 94f6aa70d4..3d84c82179 100644 --- a/eigrpd/eigrp_const.h +++ b/eigrpd/eigrp_const.h @@ -94,11 +94,7 @@  #define EIGRP_MULTICAST_ADDRESS            0xe000000A /*224.0.0.10*/  #define EIGRP_MAX_METRIC                   0xffffffffU    /*4294967295*/ -enum metric_change { -	METRIC_DECREASE, -	METRIC_SAME, -	METRIC_INCREASE -}; +enum metric_change { METRIC_DECREASE, METRIC_SAME, METRIC_INCREASE };  #define DEFAULT_ROUTE               ZEBRA_ROUTE_MAX  #define DEFAULT_ROUTE_TYPE(T) ((T) == DEFAULT_ROUTE) @@ -182,7 +178,7 @@ enum eigrp_fsm_events {  	 * state not changed  	 * usually by receiving not last reply  	 */ -	 EIGRP_FSM_KEEP_STATE, +	EIGRP_FSM_KEEP_STATE,  };  /** diff --git a/eigrpd/eigrp_dump.c b/eigrpd/eigrp_dump.c index 20656ec4eb..8857be78e8 100644 --- a/eigrpd/eigrp_dump.c +++ b/eigrpd/eigrp_dump.c @@ -216,8 +216,7 @@ void show_ip_eigrp_interface_sub(struct vty *vty, struct eigrp *eigrp,  	vty_out(vty, "%u %c %-10u", 0, '/',  		eigrp_neighbor_packet_queue_sum(ei));  	vty_out(vty, "%-7u %-14u %-12u %-8u", 0, 0, 0, 0); -	vty_out(vty, "%-8u %-8u \n", ei->params.v_hello, -		ei->params.v_wait); +	vty_out(vty, "%-8u %-8u \n", ei->params.v_hello, ei->params.v_wait);  }  void show_ip_eigrp_interface_detail(struct vty *vty, struct eigrp *eigrp, @@ -253,7 +252,8 @@ void show_ip_eigrp_neighbor_sub(struct vty *vty, struct eigrp_neighbor *nbr,  	vty_out(vty, "%-3u %-17s %-21s", 0, eigrp_neigh_ip_string(nbr),  		eigrp_if_name_string(nbr->ei));  	if (nbr->t_holddown) -		vty_out(vty, "%-7lu", thread_timer_remain_second(nbr->t_holddown)); +		vty_out(vty, "%-7lu", +			thread_timer_remain_second(nbr->t_holddown));  	else  		vty_out(vty, "-      ");  	vty_out(vty, "%-8u %-6u %-5u", 0, 0, EIGRP_PACKET_RETRANS_TIME); @@ -295,8 +295,7 @@ void show_ip_eigrp_prefix_entry(struct vty *vty, struct eigrp_prefix_entry *tn)  	vty_out(vty, "%s, ",  		prefix2str(tn->destination, buffer, PREFIX_STRLEN)); -	vty_out(vty, "%u successors, ", -		(successors) ? successors->count : 0); +	vty_out(vty, "%u successors, ", (successors) ? successors->count : 0);  	vty_out(vty, "FD is %u, serno: %" PRIu64 " \n", tn->fdistance,  		tn->serno); @@ -305,7 +304,7 @@ void show_ip_eigrp_prefix_entry(struct vty *vty, struct eigrp_prefix_entry *tn)  }  void show_ip_eigrp_nexthop_entry(struct vty *vty, struct eigrp *eigrp, -				  struct eigrp_nexthop_entry *te, int *first) +				 struct eigrp_nexthop_entry *te, int *first)  {  	if (te->reported_distance == EIGRP_MAX_METRIC)  		return; diff --git a/eigrpd/eigrp_dump.h b/eigrpd/eigrp_dump.h index cda304ba6d..389ac1b5fd 100644 --- a/eigrpd/eigrp_dump.h +++ b/eigrpd/eigrp_dump.h @@ -157,7 +157,7 @@ extern void show_ip_eigrp_neighbor_sub(struct vty *, struct eigrp_neighbor *,  extern void show_ip_eigrp_prefix_entry(struct vty *,  				       struct eigrp_prefix_entry *);  extern void show_ip_eigrp_nexthop_entry(struct vty *, struct eigrp *, -					 struct eigrp_nexthop_entry *, int *); +					struct eigrp_nexthop_entry *, int *);  extern void eigrp_debug_init(void); diff --git a/eigrpd/eigrp_fsm.c b/eigrpd/eigrp_fsm.c index b4978bc06f..a4ee5b11dc 100644 --- a/eigrpd/eigrp_fsm.c +++ b/eigrpd/eigrp_fsm.c @@ -257,8 +257,8 @@ static const char *change2str(enum metric_change change)   * Return number of occurred event (arrow in diagram).   *   */ -static enum eigrp_fsm_events eigrp_get_fsm_event( -	struct eigrp_fsm_action_message *msg) +static enum eigrp_fsm_events +eigrp_get_fsm_event(struct eigrp_fsm_action_message *msg)  {  	// Loading base information from message  	// struct eigrp *eigrp = msg->eigrp; @@ -315,8 +315,7 @@ static enum eigrp_fsm_events eigrp_get_fsm_event(  				return EIGRP_FSM_KEEP_STATE;  			zlog_info("All reply received\n"); -			if (head->reported_distance -			    < prefix->fdistance) { +			if (head->reported_distance < prefix->fdistance) {  				return EIGRP_FSM_EVENT_LR_FCS;  			} @@ -417,13 +416,12 @@ int eigrp_fsm_event(struct eigrp_fsm_action_message *msg)  {  	enum eigrp_fsm_events event = eigrp_get_fsm_event(msg); -	zlog_info("EIGRP AS: %d State: %s Event: %s Network: %s Packet Type: %s Reply RIJ Count: %d change: %s", -		  msg->eigrp->AS, prefix_state2str(msg->prefix->state), -		  fsm_state2str(event), -		  eigrp_topology_ip_string(msg->prefix), -		  packet_type2str(msg->packet_type), -		  msg->prefix->rij->count, -		  change2str(msg->change)); +	zlog_info( +		"EIGRP AS: %d State: %s Event: %s Network: %s Packet Type: %s Reply RIJ Count: %d change: %s", +		msg->eigrp->AS, prefix_state2str(msg->prefix->state), +		fsm_state2str(event), eigrp_topology_ip_string(msg->prefix), +		packet_type2str(msg->packet_type), msg->prefix->rij->count, +		change2str(msg->change));  	(*(NSM[msg->prefix->state][event].func))(msg);  	return 1; @@ -444,8 +442,7 @@ int eigrp_fsm_event_nq_fcn(struct eigrp_fsm_action_message *msg)  	ne = listnode_head(successors);  	prefix->state = EIGRP_FSM_STATE_ACTIVE_1; -	prefix->rdistance = prefix->distance = prefix->fdistance = -		ne->distance; +	prefix->rdistance = prefix->distance = prefix->fdistance = ne->distance;  	prefix->reported_metric = ne->total_metric;  	if (eigrp_nbr_count_get()) { @@ -472,8 +469,7 @@ int eigrp_fsm_event_q_fcn(struct eigrp_fsm_action_message *msg)  	ne = listnode_head(successors);  	prefix->state = EIGRP_FSM_STATE_ACTIVE_3; -	prefix->rdistance = prefix->distance = prefix->fdistance = -		ne->distance; +	prefix->rdistance = prefix->distance = prefix->fdistance = ne->distance;  	prefix->reported_metric = ne->total_metric;  	if (eigrp_nbr_count_get()) {  		prefix->req_action |= EIGRP_FSM_NEED_QUERY; @@ -498,8 +494,7 @@ int eigrp_fsm_event_keep_state(struct eigrp_fsm_action_message *msg)  					   ne->total_metric)) {  			prefix->rdistance = prefix->fdistance =  				prefix->distance = ne->distance; -			prefix->reported_metric = -				ne->total_metric; +			prefix->reported_metric = ne->total_metric;  			if (msg->packet_type == EIGRP_OPC_QUERY)  				eigrp_send_reply(msg->adv_router, prefix);  			prefix->req_action |= EIGRP_FSM_NEED_UPDATE; @@ -523,8 +518,7 @@ int eigrp_fsm_event_lr(struct eigrp_fsm_action_message *msg)  	struct eigrp_prefix_entry *prefix = msg->prefix;  	struct eigrp_nexthop_entry *ne = listnode_head(prefix->entries); -	prefix->fdistance = prefix->distance = prefix->rdistance = -		ne->distance; +	prefix->fdistance = prefix->distance = prefix->rdistance = ne->distance;  	prefix->reported_metric = ne->total_metric;  	if (prefix->state == EIGRP_FSM_STATE_ACTIVE_3) { @@ -533,8 +527,7 @@ int eigrp_fsm_event_lr(struct eigrp_fsm_action_message *msg)  		assert(successors); // It's like Napolean and Waterloo  		ne = listnode_head(successors); -		eigrp_send_reply(ne->adv_router, -				 prefix); +		eigrp_send_reply(ne->adv_router, prefix);  		list_delete_and_null(&successors);  	} @@ -587,8 +580,7 @@ int eigrp_fsm_event_lr_fcs(struct eigrp_fsm_action_message *msg)  		assert(successors); // Having a spoon and all you need is a  				    // knife  		ne = listnode_head(successors); -		eigrp_send_reply(ne->adv_router, -				 prefix); +		eigrp_send_reply(ne->adv_router, prefix);  		list_delete_and_null(&successors);  	} diff --git a/eigrpd/eigrp_hello.c b/eigrpd/eigrp_hello.c index 1cb265cf12..bba028f1e8 100644 --- a/eigrpd/eigrp_hello.c +++ b/eigrpd/eigrp_hello.c @@ -96,8 +96,8 @@ int eigrp_hello_timer(struct thread *thread)  	/* Hello timer set. */  	ei->t_hello = NULL; -	thread_add_timer(master, eigrp_hello_timer, ei, -			 ei->params.v_hello, &ei->t_hello); +	thread_add_timer(master, eigrp_hello_timer, ei, ei->params.v_hello, +			 &ei->t_hello);  	return 0;  } @@ -443,7 +443,7 @@ static u_int16_t eigrp_sw_version_encode(struct stream *s)  	stream_putw(s, EIGRP_TLV_SW_VERSION);  	stream_putw(s, length); -	stream_putc(s, FRR_MAJOR);  //!< major os version +	stream_putc(s, FRR_MAJOR); //!< major os version  	stream_putc(s, FRR_MINOR); //!< minor os version  	/* and the core eigrp version */ @@ -634,14 +634,14 @@ static struct eigrp_packet *eigrp_hello_encode(struct eigrp_interface *ei,  	if (ep) {  		// encode common header feilds -		eigrp_packet_header_init(EIGRP_OPC_HELLO, ei->eigrp, ep->s, 0, 0, ack); +		eigrp_packet_header_init(EIGRP_OPC_HELLO, ei->eigrp, ep->s, 0, +					 0, ack);  		// encode Authentication TLV  		if ((ei->params.auth_type == EIGRP_AUTH_TYPE_MD5)  		    && (ei->params.auth_keychain != NULL)) {  			length += eigrp_add_authTLV_MD5_to_stream(ep->s, ei); -		} else if ((ei->params.auth_type -			    == EIGRP_AUTH_TYPE_SHA256) +		} else if ((ei->params.auth_type == EIGRP_AUTH_TYPE_SHA256)  			   && (ei->params.auth_keychain != NULL)) {  			length += eigrp_add_authTLV_SHA256_to_stream(ep->s, ei);  		} @@ -680,8 +680,7 @@ static struct eigrp_packet *eigrp_hello_encode(struct eigrp_interface *ei,  		    && (ei->params.auth_keychain != NULL)) {  			eigrp_make_md5_digest(ei, ep->s,  					      EIGRP_AUTH_BASIC_HELLO_FLAG); -		} else if ((ei->params.auth_type -			    == EIGRP_AUTH_TYPE_SHA256) +		} else if ((ei->params.auth_type == EIGRP_AUTH_TYPE_SHA256)  			   && (ei->params.auth_keychain != NULL)) {  			eigrp_make_sha256_digest(ei, ep->s,  						 EIGRP_AUTH_BASIC_HELLO_FLAG); diff --git a/eigrpd/eigrp_interface.c b/eigrpd/eigrp_interface.c index ec29d86fd2..2897e262c9 100644 --- a/eigrpd/eigrp_interface.c +++ b/eigrpd/eigrp_interface.c @@ -125,12 +125,11 @@ struct list *eigrp_iflist;  void eigrp_if_init()  {  	/* Initialize Zebra interface data structure. */ -	//hook_register_prio(if_add, 0, eigrp_if_new); +	// hook_register_prio(if_add, 0, eigrp_if_new);  	hook_register_prio(if_del, 0, eigrp_if_delete_hook);  } -  void eigrp_del_if_params(struct eigrp_if_params *eip)  {  	if (eip->auth_keychain) @@ -160,8 +159,7 @@ int eigrp_if_up(struct eigrp_interface *ei)  	thread_add_event(master, eigrp_hello_timer, ei, (1), NULL);  	/*Prepare metrics*/ -	metric.bandwidth = -		eigrp_bandwidth_to_scaled(ei->params.bandwidth); +	metric.bandwidth = eigrp_bandwidth_to_scaled(ei->params.bandwidth);  	metric.delay = eigrp_delay_to_scaled(ei->params.delay);  	metric.load = ei->params.load;  	metric.reliability = ei->params.reliability; @@ -310,8 +308,7 @@ void eigrp_if_set_multicast(struct eigrp_interface *ei)  		 * group. */  		if (ei->member_allrouters) {  			/* Only actually drop if this is the last reference */ -			eigrp_if_drop_allspfrouters(ei->eigrp, -						    ei->address, +			eigrp_if_drop_allspfrouters(ei->eigrp, ei->address,  						    ei->ifp->ifindex);  			/* Unset the flag regardless of whether the system call  			   to leave @@ -333,8 +330,7 @@ u_char eigrp_default_iftype(struct interface *ifp)  		return EIGRP_IFTYPE_BROADCAST;  } -void eigrp_if_free(struct eigrp_interface *ei, -		   int source) +void eigrp_if_free(struct eigrp_interface *ei, int source)  {  	struct prefix dest_addr;  	struct eigrp_prefix_entry *pe; diff --git a/eigrpd/eigrp_macros.h b/eigrpd/eigrp_macros.h index 14a8892bac..eea7a26425 100644 --- a/eigrpd/eigrp_macros.h +++ b/eigrpd/eigrp_macros.h @@ -28,7 +28,6 @@  #ifndef _ZEBRA_EIGRP_MACROS_H_  #define _ZEBRA_EIGRP_MACROS_H_ -  //--------------------------------------------------------------------------  #define EIGRP_IF_STRING_MAXLEN  40 diff --git a/eigrpd/eigrp_neighbor.c b/eigrpd/eigrp_neighbor.c index b7b336949e..77bd93f6be 100644 --- a/eigrpd/eigrp_neighbor.c +++ b/eigrpd/eigrp_neighbor.c @@ -358,7 +358,8 @@ void eigrp_nbr_hard_restart(struct eigrp_neighbor *nbr, struct vty *vty)  	eigrp_nbr_delete(nbr);  } -int eigrp_nbr_split_horizon_check(struct eigrp_nexthop_entry *ne, struct eigrp_interface *ei) +int eigrp_nbr_split_horizon_check(struct eigrp_nexthop_entry *ne, +				  struct eigrp_interface *ei)  {  	if (ne->distance == EIGRP_MAX_METRIC)  		return 0; diff --git a/eigrpd/eigrp_network.c b/eigrpd/eigrp_network.c index 21413bf446..a70a7fc765 100644 --- a/eigrpd/eigrp_network.c +++ b/eigrpd/eigrp_network.c @@ -280,8 +280,7 @@ static void eigrp_network_run_interface(struct eigrp *eigrp, struct prefix *p,  		if (CHECK_FLAG(co->flags, ZEBRA_IFA_SECONDARY))  			continue; -		if (p->family == co->address->family -		    && !ifp->info +		if (p->family == co->address->family && !ifp->info  		    && eigrp_network_match_iface(co, p)) {  			ei = eigrp_if_new(eigrp, ifp, co->address); @@ -408,17 +407,17 @@ u_int32_t eigrp_calculate_total_metrics(struct eigrp *eigrp,  	struct eigrp_interface *ei = entry->ei;  	entry->total_metric = entry->reported_metric; -	uint64_t temp_delay = (uint64_t)entry->total_metric.delay -			      + (uint64_t)eigrp_delay_to_scaled(ei->params.delay); +	uint64_t temp_delay = +		(uint64_t)entry->total_metric.delay +		+ (uint64_t)eigrp_delay_to_scaled(ei->params.delay);  	entry->total_metric.delay = temp_delay > EIGRP_MAX_METRIC  					    ? EIGRP_MAX_METRIC  					    : (u_int32_t)temp_delay; -	u_int32_t bw = -		eigrp_bandwidth_to_scaled(ei->params.bandwidth); +	u_int32_t bw = eigrp_bandwidth_to_scaled(ei->params.bandwidth);  	entry->total_metric.bandwidth = entry->total_metric.bandwidth > bw -					       ? bw -					       : entry->total_metric.bandwidth; +						? bw +						: entry->total_metric.bandwidth;  	return eigrp_calculate_metrics(eigrp, entry->total_metric);  } diff --git a/eigrpd/eigrp_packet.c b/eigrpd/eigrp_packet.c index ea6f1f3f62..e2cd44429e 100644 --- a/eigrpd/eigrp_packet.c +++ b/eigrpd/eigrp_packet.c @@ -194,8 +194,9 @@ int eigrp_check_md5_digest(struct stream *s,  		key = key_lookup_for_send(keychain);  	if (!key) { -		zlog_warn("Interface %s: Expected key value not found in config", -			  nbr->ei->ifp->name); +		zlog_warn( +			"Interface %s: Expected key value not found in config", +			nbr->ei->ifp->name);  		return 0;  	} @@ -270,8 +271,9 @@ int eigrp_make_sha256_digest(struct eigrp_interface *ei, struct stream *s,  		key = key_lookup_for_send(keychain);  	if (!key) { -		zlog_warn("Interface %s: Expected key value not found in config", -			  ei->ifp->name); +		zlog_warn( +			"Interface %s: Expected key value not found in config", +			ei->ifp->name);  		eigrp_authTLV_SHA256_free(auth_TLV);  		return 0;  	} @@ -325,8 +327,6 @@ int eigrp_write(struct thread *thread)  #ifdef WANT_EIGRP_WRITE_FRAGMENT  	static u_int16_t ipid = 0;  #endif /* WANT_EIGRP_WRITE_FRAGMENT */ -       /* $FRR indent$ */ -/* clang-format off */  #define EIGRP_WRITE_IPHL_SHIFT 2  	eigrp->t_write = NULL; @@ -350,8 +350,7 @@ int eigrp_write(struct thread *thread)  		goto out;  	}  	if (ep->length < EIGRP_HEADER_LEN) { -		zlog_err("%s: Packet just has a header?", -			 __PRETTY_FUNCTION__); +		zlog_err("%s: Packet just has a header?", __PRETTY_FUNCTION__);  		eigrp_header_dump((struct eigrp_header *)ep->s->data);  		eigrp_packet_delete(ei);  		goto out; @@ -435,10 +434,10 @@ int eigrp_write(struct thread *thread)  	if (IS_DEBUG_EIGRP_TRANSMIT(0, SEND)) {  		eigrph = (struct eigrp_header *)STREAM_DATA(ep->s); -		zlog_debug("Sending [%s][%d/%d] to [%s] via [%s] ret [%d].", -			   lookup_msg(eigrp_packet_type_str, eigrph->opcode, NULL), -			   seqno, ack, -			   inet_ntoa(ep->dst), IF_NAME(ei), ret); +		zlog_debug( +			"Sending [%s][%d/%d] to [%s] via [%s] ret [%d].", +			lookup_msg(eigrp_packet_type_str, eigrph->opcode, NULL), +			seqno, ack, inet_ntoa(ep->dst), IF_NAME(ei), ret);  	}  	if (ret < 0) @@ -615,10 +614,11 @@ int eigrp_read(struct thread *thread)  		strlcpy(src, inet_ntoa(iph->ip_src), sizeof(src));  		strlcpy(dst, inet_ntoa(iph->ip_dst), sizeof(dst)); -		zlog_debug("Received [%s][%d/%d] length [%u] via [%s] src [%s] dst [%s]", -			   lookup_msg(eigrp_packet_type_str, opcode, NULL), -			   ntohl(eigrph->sequence), ntohl(eigrph->ack), length, -			   IF_NAME(ei), src, dst); +		zlog_debug( +			"Received [%s][%d/%d] length [%u] via [%s] src [%s] dst [%s]", +			lookup_msg(eigrp_packet_type_str, opcode, NULL), +			ntohl(eigrph->sequence), ntohl(eigrph->ack), length, +			IF_NAME(ei), src, dst);  	}  	/* Read rest of the packet and call each sort of packet routine. */ @@ -639,7 +639,8 @@ int eigrp_read(struct thread *thread)  			eigrp_packet_free(ep);  			if ((nbr->state == EIGRP_NEIGHBOR_PENDING) -			    && (ntohl(eigrph->ack) == nbr->init_sequence_number)) { +			    && (ntohl(eigrph->ack) +				== nbr->init_sequence_number)) {  				eigrp_nbr_state_set(nbr, EIGRP_NEIGHBOR_UP);  				zlog_info("Neighbor(%s) adjacency became full",  					  inet_ntoa(nbr->src)); @@ -647,8 +648,7 @@ int eigrp_read(struct thread *thread)  				nbr->recv_sequence_number =  					ntohl(eigrph->sequence);  				eigrp_update_send_EOT(nbr); -			} -			else +			} else  				eigrp_send_packet_reliably(nbr);  		}  		ep = eigrp_fifo_next(nbr->multicast_queue); @@ -875,9 +875,9 @@ void eigrp_packet_checksum(struct eigrp_interface *ei, struct stream *s,  }  /* Make EIGRP header. */ -void eigrp_packet_header_init(int type, struct eigrp *eigrp, -			      struct stream *s, u_int32_t flags, -			      u_int32_t sequence, u_int32_t ack) +void eigrp_packet_header_init(int type, struct eigrp *eigrp, struct stream *s, +			      u_int32_t flags, u_int32_t sequence, +			      u_int32_t ack)  {  	struct eigrp_header *eigrph; @@ -1234,8 +1234,7 @@ u_int16_t eigrp_add_internalTLV_to_stream(struct stream *s,  	stream_putc(s, pe->destination->u.prefix4.s_addr & 0xFF);  	if (pe->destination->prefixlen > 8) -		stream_putc(s, -			    (pe->destination->u.prefix4.s_addr >> 8) & 0xFF); +		stream_putc(s, (pe->destination->u.prefix4.s_addr >> 8) & 0xFF);  	if (pe->destination->prefixlen > 16)  		stream_putc(s,  			    (pe->destination->u.prefix4.s_addr >> 16) & 0xFF); diff --git a/eigrpd/eigrp_packet.h b/eigrpd/eigrp_packet.h index a7d510218f..00e1c7eac7 100644 --- a/eigrpd/eigrp_packet.h +++ b/eigrpd/eigrp_packet.h @@ -41,9 +41,8 @@ extern struct eigrp_packet *eigrp_packet_duplicate(struct eigrp_packet *,  						   struct eigrp_neighbor *);  extern void eigrp_packet_free(struct eigrp_packet *);  extern void eigrp_packet_delete(struct eigrp_interface *); -extern void eigrp_packet_header_init(int, struct eigrp *, -				     struct stream *, u_int32_t, u_int32_t, -				     u_int32_t); +extern void eigrp_packet_header_init(int, struct eigrp *, struct stream *, +				     u_int32_t, u_int32_t, u_int32_t);  extern void eigrp_packet_checksum(struct eigrp_interface *, struct stream *,  				  u_int16_t); @@ -84,8 +83,7 @@ extern int eigrp_hello_timer(struct thread *);   * These externs are found in eigrp_update.c   */  extern bool eigrp_update_prefix_apply(struct eigrp *eigrp, -				      struct eigrp_interface *ei, -				      int in, +				      struct eigrp_interface *ei, int in,  				      struct prefix *prefix);  extern void eigrp_update_send(struct eigrp_interface *);  extern void eigrp_update_receive(struct eigrp *, struct ip *, diff --git a/eigrpd/eigrp_query.c b/eigrpd/eigrp_query.c index 1fe70b60e8..72780f7a03 100644 --- a/eigrpd/eigrp_query.c +++ b/eigrpd/eigrp_query.c @@ -142,13 +142,13 @@ void eigrp_query_receive(struct eigrp *eigrp, struct ip *iph,  			break;  		case EIGRP_TLV_IPv4_EXT: -			/* DVS: processing of external routes needs packet and fsm work. -			 *      for now, lets just not creash the box -			 */ +		/* DVS: processing of external routes needs packet and fsm work. +		 *      for now, lets just not creash the box +		 */  		default:  			length = stream_getw(s);  			// -2 for type, -2 for len -			for (length-=4; length ; length--) { +			for (length -= 4; length; length--) {  				(void)stream_getc(s);  			}  		} @@ -177,16 +177,15 @@ void eigrp_send_query(struct eigrp_interface *ei)  			ep = eigrp_packet_new(ei->ifp->mtu, NULL);  			/* Prepare EIGRP INIT UPDATE header */ -			eigrp_packet_header_init(EIGRP_OPC_QUERY, -						 ei->eigrp, ep->s, 0, +			eigrp_packet_header_init(EIGRP_OPC_QUERY, ei->eigrp, +						 ep->s, 0,  						 ei->eigrp->sequence_number, 0);  			// encode Authentication TLV, if needed  			if ((ei->params.auth_type == EIGRP_AUTH_TYPE_MD5)  			    && (ei->params.auth_keychain != NULL)) { -				length += -					eigrp_add_authTLV_MD5_to_stream(ep->s, -									ei); +				length += eigrp_add_authTLV_MD5_to_stream(ep->s, +									  ei);  			}  			new_packet = false;  		} diff --git a/eigrpd/eigrp_reply.c b/eigrpd/eigrp_reply.c index 84396f0878..ae2d0c0904 100644 --- a/eigrpd/eigrp_reply.c +++ b/eigrpd/eigrp_reply.c @@ -75,12 +75,10 @@ void eigrp_send_reply(struct eigrp_neighbor *nbr, struct eigrp_prefix_entry *pe)  		      sizeof(struct eigrp_prefix_entry));  	memcpy(pe2, pe, sizeof(struct eigrp_prefix_entry)); -	if (eigrp_update_prefix_apply(eigrp, ei, -				      EIGRP_FILTER_OUT, +	if (eigrp_update_prefix_apply(eigrp, ei, EIGRP_FILTER_OUT,  				      pe2->destination)) {  		zlog_info("REPLY SEND: Setting Metric to max");  		pe2->reported_metric.delay = EIGRP_MAX_METRIC; -  	}  	/* @@ -163,17 +161,18 @@ void eigrp_reply_receive(struct eigrp *eigrp, struct ip *iph,  		dest_addr.u.prefix4 = tlv->destination;  		dest_addr.prefixlen = tlv->prefix_length;  		struct eigrp_prefix_entry *dest = -			eigrp_topology_table_lookup_ipv4( -				eigrp->topology_table, &dest_addr); +			eigrp_topology_table_lookup_ipv4(eigrp->topology_table, +							 &dest_addr);  		/*  		 * Destination must exists  		 */  		if (!dest) {  			char buf[PREFIX_STRLEN]; -			zlog_err("%s: Received prefix %s which we do not know about", -				 __PRETTY_FUNCTION__, -				 prefix2str(&dest_addr, buf, sizeof(buf))); +			zlog_err( +				"%s: Received prefix %s which we do not know about", +				__PRETTY_FUNCTION__, +				prefix2str(&dest_addr, buf, sizeof(buf)));  			eigrp_IPv4_InternalTLV_free(tlv);  			continue;  		} @@ -182,8 +181,7 @@ void eigrp_reply_receive(struct eigrp *eigrp, struct ip *iph,  		struct eigrp_nexthop_entry *entry =  			eigrp_prefix_entry_lookup(dest->entries, nbr); -		if (eigrp_update_prefix_apply(eigrp, ei, -					      EIGRP_FILTER_IN, +		if (eigrp_update_prefix_apply(eigrp, ei, EIGRP_FILTER_IN,  					      &dest_addr)) {  			tlv->metric.delay = EIGRP_MAX_METRIC;  		} diff --git a/eigrpd/eigrp_routemap.h b/eigrpd/eigrp_routemap.h index 1d37b25efc..c471679619 100644 --- a/eigrpd/eigrp_routemap.h +++ b/eigrpd/eigrp_routemap.h @@ -11,8 +11,7 @@  #include "if_rmap.h"  extern bool eigrp_routemap_prefix_apply(struct eigrp *eigrp, -					struct eigrp_interface *ei, -					int in, +					struct eigrp_interface *ei, int in,  					struct prefix *prefix);  extern void eigrp_route_map_update(const char *);  extern void eigrp_route_map_init(); diff --git a/eigrpd/eigrp_structs.h b/eigrpd/eigrp_structs.h index aae56c8ffe..ea281fc974 100644 --- a/eigrpd/eigrp_structs.h +++ b/eigrpd/eigrp_structs.h @@ -104,9 +104,8 @@ struct eigrp {  	uint64_t serno; /* Global serial number counter for topology entry  			   changes*/ -	uint64_t -		serno_last_update; /* Highest serial number of information send -				      by last update*/ +	uint64_t serno_last_update; /* Highest serial number of information send +				       by last update*/  	struct list *topology_changes_internalIPV4;  	struct list *topology_changes_externalIPV4; @@ -140,14 +139,14 @@ struct eigrp_if_params {  	u_char passive_interface;  	u_int32_t v_hello;  	u_int16_t v_wait; -	u_char type;      /* type of interface */ +	u_char type; /* type of interface */  	u_int32_t bandwidth;  	u_int32_t delay;  	u_char reliability;  	u_char load;  	char *auth_keychain; /* Associated keychain with interface*/ -	int auth_type; /* EIGRP authentication type */ +	int auth_type;       /* EIGRP authentication type */  };  enum { MEMBER_ALLROUTERS = 0, @@ -160,7 +159,7 @@ struct eigrp_interface {  	/*multicast group refcnts */  	bool member_allrouters; -	 +  	/* This interface's parent eigrp instance. */  	struct eigrp *eigrp; diff --git a/eigrpd/eigrp_topology.c b/eigrpd/eigrp_topology.c index 7d352b8bed..bab47ea133 100644 --- a/eigrpd/eigrp_topology.c +++ b/eigrpd/eigrp_topology.c @@ -52,7 +52,7 @@  #include "eigrpd/eigrp_memory.h"  static int eigrp_nexthop_entry_cmp(struct eigrp_nexthop_entry *, -				    struct eigrp_nexthop_entry *); +				   struct eigrp_nexthop_entry *);  /*   * Returns linkedlist used as topology table @@ -87,7 +87,7 @@ struct eigrp_prefix_entry *eigrp_prefix_entry_new()   * Topology entry comparison   */  static int eigrp_nexthop_entry_cmp(struct eigrp_nexthop_entry *entry1, -				    struct eigrp_nexthop_entry *entry2) +				   struct eigrp_nexthop_entry *entry2)  {  	if (entry1->distance < entry2->distance)  		return -1; @@ -142,10 +142,10 @@ void eigrp_prefix_entry_add(struct route_table *topology,  		if (IS_DEBUG_EIGRP_EVENT) {  			char buf[PREFIX_STRLEN]; -			zlog_debug("%s: %s Should we have found this entry in the topo table?", -				   __PRETTY_FUNCTION__, -				   prefix2str(pe->destination, buf, -					      sizeof(buf))); +			zlog_debug( +				"%s: %s Should we have found this entry in the topo table?", +				__PRETTY_FUNCTION__, +				prefix2str(pe->destination, buf, sizeof(buf)));  		}  	} @@ -157,7 +157,7 @@ void eigrp_prefix_entry_add(struct route_table *topology,   * Adding topology entry to topology node   */  void eigrp_nexthop_entry_add(struct eigrp_prefix_entry *node, -			      struct eigrp_nexthop_entry *entry) +			     struct eigrp_nexthop_entry *entry)  {  	struct list *l = list_new(); @@ -197,8 +197,8 @@ void eigrp_prefix_entry_delete(struct route_table *table,  	eigrp_zebra_route_delete(pe->destination);  	rn->info = NULL; -	route_unlock_node(rn);  //Lookup above -	route_unlock_node(rn);  //Initial creation +	route_unlock_node(rn); // Lookup above +	route_unlock_node(rn); // Initial creation  	XFREE(MTYPE_EIGRP_PREFIX_ENTRY, pe);  } @@ -206,7 +206,7 @@ void eigrp_prefix_entry_delete(struct route_table *table,   * Deleting topology entry from topology node   */  void eigrp_nexthop_entry_delete(struct eigrp_prefix_entry *node, -				 struct eigrp_nexthop_entry *entry) +				struct eigrp_nexthop_entry *entry)  {  	if (listnode_lookup(node->entries, entry) != NULL) {  		listnode_delete(node->entries, entry); @@ -355,7 +355,8 @@ struct list *eigrp_neighbor_prefixes_lookup(struct eigrp *eigrp,  	return prefixes;  } -enum metric_change eigrp_topology_update_distance(struct eigrp_fsm_action_message *msg) +enum metric_change +eigrp_topology_update_distance(struct eigrp_fsm_action_message *msg)  {  	struct eigrp *eigrp = msg->eigrp;  	struct eigrp_prefix_entry *prefix = msg->prefix; @@ -365,7 +366,7 @@ enum metric_change eigrp_topology_update_distance(struct eigrp_fsm_action_messag  	assert(entry); -	switch(msg->data_type) { +	switch (msg->data_type) {  	case EIGRP_CONNECTED:  		if (prefix->nt == EIGRP_TOPOLOGY_TYPE_CONNECTED)  			return change; @@ -382,8 +383,8 @@ enum metric_change eigrp_topology_update_distance(struct eigrp_fsm_action_messag  			return change; // No change  		} -		new_reported_distance = eigrp_calculate_metrics(eigrp, -								msg->metrics); +		new_reported_distance = +			eigrp_calculate_metrics(eigrp, msg->metrics);  		if (entry->reported_distance < new_reported_distance) {  			change = METRIC_INCREASE; @@ -410,7 +411,7 @@ enum metric_change eigrp_topology_update_distance(struct eigrp_fsm_action_messag  		zlog_err("%s: Please implement handler", __PRETTY_FUNCTION__);  		break;  	} - distance_done: +distance_done:  	/*  	 * Move to correct position in list according to new distance  	 */ @@ -469,8 +470,7 @@ void eigrp_update_routing_table(struct eigrp_prefix_entry *prefix)  	struct eigrp_nexthop_entry *entry;  	if (successors) { -		eigrp_zebra_route_add(prefix->destination, -				      successors); +		eigrp_zebra_route_add(prefix->destination, successors);  		for (ALL_LIST_ELEMENTS_RO(successors, node, entry))  			entry->flags |= EIGRP_NEXTHOP_ENTRY_INTABLE_FLAG; diff --git a/eigrpd/eigrp_topology.h b/eigrpd/eigrp_topology.h index c8772c8c3a..af39f7f1aa 100644 --- a/eigrpd/eigrp_topology.h +++ b/eigrpd/eigrp_topology.h @@ -42,16 +42,15 @@ extern void eigrp_topology_cleanup(struct route_table *table);  extern void eigrp_prefix_entry_add(struct route_table *table,  				   struct eigrp_prefix_entry *pe);  extern void eigrp_nexthop_entry_add(struct eigrp_prefix_entry *, -				     struct eigrp_nexthop_entry *); +				    struct eigrp_nexthop_entry *);  extern void eigrp_prefix_entry_delete(struct route_table *table,  				      struct eigrp_prefix_entry *pe);  extern void eigrp_nexthop_entry_delete(struct eigrp_prefix_entry *, -					struct eigrp_nexthop_entry *); +				       struct eigrp_nexthop_entry *);  extern void eigrp_topology_delete_all(struct route_table *table);  extern unsigned int eigrp_topology_table_isempty(struct list *);  extern struct eigrp_prefix_entry * -eigrp_topology_table_lookup_ipv4(struct route_table *table, -				 struct prefix *p); +eigrp_topology_table_lookup_ipv4(struct route_table *table, struct prefix *p);  extern struct list *eigrp_topology_get_successor(struct eigrp_prefix_entry *);  extern struct list *  eigrp_topology_get_successor_max(struct eigrp_prefix_entry *pe, @@ -62,7 +61,8 @@ extern struct list *eigrp_neighbor_prefixes_lookup(struct eigrp *,  						   struct eigrp_neighbor *);  extern void eigrp_topology_update_all_node_flags(struct eigrp *);  extern void eigrp_topology_update_node_flags(struct eigrp_prefix_entry *); -extern enum metric_change eigrp_topology_update_distance(struct eigrp_fsm_action_message *); +extern enum metric_change +eigrp_topology_update_distance(struct eigrp_fsm_action_message *);  extern void eigrp_update_routing_table(struct eigrp_prefix_entry *);  extern void eigrp_topology_neighbor_down(struct eigrp *,  					 struct eigrp_neighbor *); diff --git a/eigrpd/eigrp_update.c b/eigrpd/eigrp_update.c index c3eb62886a..baaf7f6891 100644 --- a/eigrpd/eigrp_update.c +++ b/eigrpd/eigrp_update.c @@ -63,8 +63,7 @@  #include "eigrpd/eigrp_network.h"  #include "eigrpd/eigrp_memory.h" -bool eigrp_update_prefix_apply(struct eigrp *eigrp, -			       struct eigrp_interface *ei, +bool eigrp_update_prefix_apply(struct eigrp *eigrp, struct eigrp_interface *ei,  			       int in, struct prefix *prefix)  {  	struct access_list *alist; @@ -143,9 +142,9 @@ static void eigrp_update_receive_GR_ask(struct eigrp *eigrp,  	/* iterate over all prefixes which weren't advertised by neighbor */  	for (ALL_LIST_ELEMENTS_RO(nbr_prefixes, node1, prefix)) {  		char buffer[PREFIX_STRLEN]; -		zlog_debug("GR receive: Neighbor not advertised %s", -			   prefix2str(prefix->destination, -				      buffer, PREFIX_STRLEN)); +		zlog_debug( +			"GR receive: Neighbor not advertised %s", +			prefix2str(prefix->destination, buffer, PREFIX_STRLEN));  		fsm_msg.metrics = prefix->reported_metric;  		/* set delay to MAX */ @@ -335,9 +334,9 @@ void eigrp_update_receive(struct eigrp *eigrp, struct ip *iph,  				/*Here comes topology information save*/  				pe = eigrp_prefix_entry_new();  				pe->serno = eigrp->serno; -				pe->destination = (struct prefix *)prefix_ipv4_new(); -				prefix_copy(pe->destination, -					    &dest_addr); +				pe->destination = +					(struct prefix *)prefix_ipv4_new(); +				prefix_copy(pe->destination, &dest_addr);  				pe->af = AF_INET;  				pe->state = EIGRP_FSM_STATE_PASSIVE;  				pe->nt = EIGRP_TOPOLOGY_TYPE_REMOTE; @@ -354,7 +353,8 @@ void eigrp_update_receive(struct eigrp *eigrp, struct ip *iph,  				if (eigrp_update_prefix_apply(eigrp, ei,  							      EIGRP_FILTER_IN,  							      &dest_addr)) -					ne->reported_metric.delay = EIGRP_MAX_METRIC; +					ne->reported_metric.delay = +						EIGRP_MAX_METRIC;  				ne->distance = eigrp_calculate_total_metrics(  					eigrp, ne); @@ -381,13 +381,13 @@ void eigrp_update_receive(struct eigrp *eigrp, struct ip *iph,  			break;  		case EIGRP_TLV_IPv4_EXT: -			/* DVS: processing of external routes needs packet and fsm work. -			 *      for now, lets just not creash the box -			 */ +		/* DVS: processing of external routes needs packet and fsm work. +		 *      for now, lets just not creash the box +		 */  		default:  			length = stream_getw(s);  			// -2 for type, -2 for len -			for (length-=4; length ; length--) { +			for (length -= 4; length; length--) {  				(void)stream_getc(s);  			}  		} @@ -428,10 +428,9 @@ void eigrp_update_send_init(struct eigrp_neighbor *nbr)  			   nbr->ei->eigrp->sequence_number,  			   nbr->recv_sequence_number); -	eigrp_packet_header_init(EIGRP_OPC_UPDATE, nbr->ei->eigrp, -				 ep->s, EIGRP_INIT_FLAG, -				 nbr->ei->eigrp->sequence_number, -				 nbr->recv_sequence_number); +	eigrp_packet_header_init( +		EIGRP_OPC_UPDATE, nbr->ei->eigrp, ep->s, EIGRP_INIT_FLAG, +		nbr->ei->eigrp->sequence_number, nbr->recv_sequence_number);  	// encode Authentication TLV, if needed  	if ((nbr->ei->params.auth_type == EIGRP_AUTH_TYPE_MD5) @@ -464,12 +463,11 @@ void eigrp_update_send_init(struct eigrp_neighbor *nbr)  static void eigrp_update_place_on_nbr_queue(struct eigrp_neighbor *nbr,  					    struct eigrp_packet *ep, -					    u_int32_t seq_no, -					    int length) +					    u_int32_t seq_no, int length)  { -	if((nbr->ei->params.auth_type == EIGRP_AUTH_TYPE_MD5) && -	   (nbr->ei->params.auth_keychain != NULL)) { -		eigrp_make_md5_digest(nbr->ei,ep->s, EIGRP_AUTH_UPDATE_FLAG); +	if ((nbr->ei->params.auth_type == EIGRP_AUTH_TYPE_MD5) +	    && (nbr->ei->params.auth_keychain != NULL)) { +		eigrp_make_md5_digest(nbr->ei, ep->s, EIGRP_AUTH_UPDATE_FLAG);  	}  	/* EIGRP Checksum */ @@ -541,14 +539,13 @@ void eigrp_update_send_EOT(struct eigrp_neighbor *nbr)  	ep = eigrp_packet_new(mtu, nbr);  	/* Prepare EIGRP EOT UPDATE header */ -	eigrp_packet_header_init(EIGRP_OPC_UPDATE, eigrp, -				 ep->s, EIGRP_EOT_FLAG, +	eigrp_packet_header_init(EIGRP_OPC_UPDATE, eigrp, ep->s, EIGRP_EOT_FLAG,  				 seq_no, nbr->recv_sequence_number);  	// encode Authentication TLV, if needed -	if((ei->params.auth_type == EIGRP_AUTH_TYPE_MD5) && -	   (ei->params.auth_keychain != NULL)) { -		length += eigrp_add_authTLV_MD5_to_stream(ep->s,ei); +	if ((ei->params.auth_type == EIGRP_AUTH_TYPE_MD5) +	    && (ei->params.auth_keychain != NULL)) { +		length += eigrp_add_authTLV_MD5_to_stream(ep->s, ei);  	}  	for (rn = route_top(eigrp->topology_table); rn; rn = route_next(rn)) { @@ -561,38 +558,40 @@ void eigrp_update_send_EOT(struct eigrp_neighbor *nbr)  				continue;  			if ((length + EIGRP_TLV_MAX_IPV4_BYTE) > mtu) { -				eigrp_update_place_on_nbr_queue (nbr, ep, seq_no, length); +				eigrp_update_place_on_nbr_queue(nbr, ep, seq_no, +								length);  				seq_no++;  				length = EIGRP_HEADER_LEN;  				ep = eigrp_packet_new(mtu, nbr); -				eigrp_packet_header_init(EIGRP_OPC_UPDATE, -							 nbr->ei->eigrp, -							 ep->s, EIGRP_EOT_FLAG, -							 seq_no, -							 nbr->recv_sequence_number); - -				if((ei->params.auth_type == EIGRP_AUTH_TYPE_MD5) && -				   (ei->params.auth_keychain != NULL)) -				{ -					length += eigrp_add_authTLV_MD5_to_stream(ep->s,ei); +				eigrp_packet_header_init( +					EIGRP_OPC_UPDATE, nbr->ei->eigrp, ep->s, +					EIGRP_EOT_FLAG, seq_no, +					nbr->recv_sequence_number); + +				if ((ei->params.auth_type +				     == EIGRP_AUTH_TYPE_MD5) +				    && (ei->params.auth_keychain != NULL)) { +					length += +						eigrp_add_authTLV_MD5_to_stream( +							ep->s, ei);  				}  			}  			/* Get destination address from prefix */  			dest_addr = pe->destination;  			/* Check if any list fits */ -			if (eigrp_update_prefix_apply(eigrp, ei, -						      EIGRP_FILTER_OUT, -						      dest_addr)) +			if (eigrp_update_prefix_apply( +				    eigrp, ei, EIGRP_FILTER_OUT, dest_addr))  				continue;  			else { -				length += eigrp_add_internalTLV_to_stream(ep->s, pe); +				length += eigrp_add_internalTLV_to_stream(ep->s, +									  pe);  			}  		}  	} -	eigrp_update_place_on_nbr_queue (nbr, ep, seq_no, length); +	eigrp_update_place_on_nbr_queue(nbr, ep, seq_no, length);  	eigrp->sequence_number = seq_no++;  } @@ -614,8 +613,7 @@ void eigrp_update_send(struct eigrp_interface *ei)  	ep = eigrp_packet_new(ei->ifp->mtu, NULL);  	/* Prepare EIGRP INIT UPDATE header */ -	eigrp_packet_header_init(EIGRP_OPC_UPDATE, eigrp, -				 ep->s, 0, seq_no, 0); +	eigrp_packet_header_init(EIGRP_OPC_UPDATE, eigrp, ep->s, 0, seq_no, 0);  	// encode Authentication TLV, if needed  	if ((ei->params.auth_type == EIGRP_AUTH_TYPE_MD5) @@ -635,11 +633,12 @@ void eigrp_update_send(struct eigrp_interface *ei)  		if (eigrp_nbr_split_horizon_check(ne, ei))  			continue; -		if ((length + EIGRP_TLV_MAX_IPV4_BYTE) > -		    (u_int16_t)ei->ifp->mtu) { +		if ((length + EIGRP_TLV_MAX_IPV4_BYTE) +		    > (u_int16_t)ei->ifp->mtu) {  			if ((ei->params.auth_type == EIGRP_AUTH_TYPE_MD5)  			    && (ei->params.auth_keychain != NULL)) { -				eigrp_make_md5_digest(ei, ep->s, EIGRP_AUTH_UPDATE_FLAG); +				eigrp_make_md5_digest(ei, ep->s, +						      EIGRP_AUTH_UPDATE_FLAG);  			}  			eigrp_packet_checksum(ei, ep->s, length); @@ -653,25 +652,24 @@ void eigrp_update_send(struct eigrp_interface *ei)  			length = EIGRP_HEADER_LEN;  			ep = eigrp_packet_new(ei->ifp->mtu, NULL); -			eigrp_packet_header_init(EIGRP_OPC_UPDATE, eigrp, -						 ep->s, 0, seq_no, 0); +			eigrp_packet_header_init(EIGRP_OPC_UPDATE, eigrp, ep->s, +						 0, seq_no, 0);  			if ((ei->params.auth_type == EIGRP_AUTH_TYPE_MD5)  			    && (ei->params.auth_keychain != NULL)) { -				length += eigrp_add_authTLV_MD5_to_stream(ep->s, ei); +				length += eigrp_add_authTLV_MD5_to_stream(ep->s, +									  ei);  			}  			has_tlv = 0;  		}  		/* Get destination address from prefix */  		dest_addr = pe->destination; -		if (eigrp_update_prefix_apply(eigrp, ei, -					      EIGRP_FILTER_OUT, +		if (eigrp_update_prefix_apply(eigrp, ei, EIGRP_FILTER_OUT,  					      dest_addr)) {  			// pe->reported_metric.delay = EIGRP_MAX_METRIC;  			continue;  		} else { -			length += eigrp_add_internalTLV_to_stream(ep->s, -								  pe); +			length += eigrp_add_internalTLV_to_stream(ep->s, pe);  			has_tlv = 1;  		}  	} @@ -729,7 +727,8 @@ void eigrp_update_send_all(struct eigrp *eigrp,  /**   * @fn eigrp_update_send_GR_part   * - * @param[in]		nbr		contains neighbor who would receive Graceful + * @param[in]		nbr		contains neighbor who would receive + * Graceful   * restart   *   * @return void @@ -814,8 +813,7 @@ static void eigrp_update_send_GR_part(struct eigrp_neighbor *nbr)  		 */  		dest_addr = pe->destination; -		if (eigrp_update_prefix_apply(eigrp, ei, -					      EIGRP_FILTER_OUT, +		if (eigrp_update_prefix_apply(eigrp, ei, EIGRP_FILTER_OUT,  					      dest_addr)) {  			/* do not send filtered route */  			zlog_info("Filtered prefix %s won't be sent out.", @@ -830,8 +828,7 @@ static void eigrp_update_send_GR_part(struct eigrp_neighbor *nbr)  		 * This makes no sense, Filter out then filter in???  		 * Look into this more - DBS  		 */ -		if (eigrp_update_prefix_apply(eigrp, ei, -					      EIGRP_FILTER_IN, +		if (eigrp_update_prefix_apply(eigrp, ei, EIGRP_FILTER_IN,  					      dest_addr)) {  			/* do not send filtered route */  			zlog_info("Filtered prefix %s will be removed.", @@ -942,7 +939,8 @@ int eigrp_update_send_GR_thread(struct thread *thread)  /**   * @fn eigrp_update_send_GR   * - * @param[in]		nbr			Neighbor who would receive Graceful + * @param[in]		nbr			Neighbor who would receive + * Graceful   * restart   * @param[in]		gr_type 	Who executed Graceful restart   * @param[in]		vty 		Virtual terminal for log output @@ -980,8 +978,7 @@ void eigrp_update_send_GR(struct eigrp_neighbor *nbr, enum GR_type gr_type,  			vty_out(vty,  				"Neighbor %s (%s) is resync: manually cleared\n",  				inet_ntoa(nbr->src), -				ifindex2ifname(ei->ifp->ifindex, -					       VRF_DEFAULT)); +				ifindex2ifname(ei->ifp->ifindex, VRF_DEFAULT));  		}  	} @@ -1007,7 +1004,9 @@ void eigrp_update_send_GR(struct eigrp_neighbor *nbr, enum GR_type gr_type,  /**   * @fn eigrp_update_send_interface_GR   * - * @param[in]		ei			Interface to neighbors of which the GR + * @param[in]		ei			Interface to neighbors of which + * the + * GR   * is sent   * @param[in]		gr_type 	Who executed Graceful restart   * @param[in]		vty 		Virtual terminal for log output diff --git a/eigrpd/eigrp_vty.c b/eigrpd/eigrp_vty.c index 4e76428535..96c96411f5 100644 --- a/eigrpd/eigrp_vty.c +++ b/eigrpd/eigrp_vty.c @@ -109,8 +109,7 @@ static int config_write_interfaces(struct vty *vty, struct eigrp *eigrp)  		if (ei->params.auth_keychain) {  			vty_out(vty,  				" ip authentication key-chain eigrp %d %s\n", -				eigrp->AS, -				ei->params.auth_keychain); +				eigrp->AS, ei->params.auth_keychain);  		}  		if (ei->params.v_hello != EIGRP_HELLO_INTERVAL_DEFAULT) { @@ -147,8 +146,7 @@ static int eigrp_write_interface(struct vty *vty)  			vty_out(vty, " description %s\n", ifp->desc);  		if (ei->params.bandwidth != EIGRP_BANDWIDTH_DEFAULT) -			vty_out(vty, " bandwidth %u\n", -				ei->params.bandwidth); +			vty_out(vty, " bandwidth %u\n", ei->params.bandwidth);  		if (ei->params.delay != EIGRP_DELAY_DEFAULT)  			vty_out(vty, " delay %u\n", ei->params.delay);  		if (ei->params.v_hello != EIGRP_HELLO_INTERVAL_DEFAULT) @@ -495,7 +493,7 @@ DEFUN (show_ip_eigrp_topology,  				     & EIGRP_NEXTHOP_ENTRY_FSUCCESSOR_FLAG)  				    == EIGRP_NEXTHOP_ENTRY_FSUCCESSOR_FLAG))) {  				show_ip_eigrp_nexthop_entry(vty, eigrp, te, -							     &first); +							    &first);  				first = 0;  			}  		} @@ -777,8 +775,7 @@ DEFUN (no_eigrp_if_ip_hellointerval,  	ei->params.v_hello = EIGRP_HELLO_INTERVAL_DEFAULT;  	THREAD_TIMER_OFF(ei->t_hello); -	thread_add_timer(master, eigrp_hello_timer, ei, 1, -			 &ei->t_hello); +	thread_add_timer(master, eigrp_hello_timer, ei, 1, &ei->t_hello);  	return CMD_SUCCESS;  } @@ -1008,11 +1005,9 @@ DEFUN (eigrp_authentication_keychain,  	if (keychain != NULL) {  		if (ei->params.auth_keychain) {  			free(ei->params.auth_keychain); -			ei->params.auth_keychain = -				strdup(keychain->name); +			ei->params.auth_keychain = strdup(keychain->name);  		} else -			ei->params.auth_keychain = -				strdup(keychain->name); +			ei->params.auth_keychain = strdup(keychain->name);  	} else  		vty_out(vty, "Key chain with specified name not found\n"); @@ -1339,8 +1334,7 @@ DEFUN (clear_ip_eigrp_neighbors_IP,  	struct in_addr nbr_addr;  	if (!inet_aton(argv[4]->arg, &nbr_addr)) { -		vty_out(vty, "Unable to parse %s", -			argv[4]->arg); +		vty_out(vty, "Unable to parse %s", argv[4]->arg);  		return CMD_WARNING;  	} @@ -1446,8 +1440,7 @@ DEFUN (clear_ip_eigrp_neighbors_IP_soft,  	struct in_addr nbr_addr;  	if (!inet_aton(argv[4]->arg, &nbr_addr)) { -		vty_out(vty, "Unable to parse: %s", -			argv[4]->arg); +		vty_out(vty, "Unable to parse: %s", argv[4]->arg);  		return CMD_WARNING;  	} diff --git a/eigrpd/eigrp_zebra.c b/eigrpd/eigrp_zebra.c index e8392f50b4..3a3d6aae12 100644 --- a/eigrpd/eigrp_zebra.c +++ b/eigrpd/eigrp_zebra.c @@ -114,7 +114,7 @@ static void eigrp_zebra_connected(struct zclient *zclient)  void eigrp_zebra_init(void)  { -	struct zclient_options opt = { .receive_notify = false }; +	struct zclient_options opt = {.receive_notify = false};  	zclient = zclient_new_notify(master, &opt); @@ -205,8 +205,7 @@ static int eigrp_interface_delete(int command, struct zclient *zclient,  			ifp->metric, ifp->mtu);  	if (ifp->info) -		eigrp_if_free(ifp->info, -			      INTERFACE_DOWN_BY_ZEBRA); +		eigrp_if_free(ifp->info, INTERFACE_DOWN_BY_ZEBRA);  	if_set_index(ifp, IFINDEX_INTERNAL);  	return 0; diff --git a/isisd/isis_adjacency.c b/isisd/isis_adjacency.c index c8b9a66e29..72e6d4bdb9 100644 --- a/isisd/isis_adjacency.c +++ b/isisd/isis_adjacency.c @@ -437,10 +437,10 @@ void isis_adj_print_vty(struct isis_adjacency *adj, struct vty *vty,  			for (unsigned int i = 0; i < adj->area_address_count;  			     i++) {  				vty_out(vty, "      %s\n", -					  isonet_print(adj->area_addresses[i] -							       .area_addr, -						       adj->area_addresses[i] -							       .addr_len)); +					isonet_print(adj->area_addresses[i] +							     .area_addr, +						     adj->area_addresses[i] +							     .addr_len));  			}  		}  		if (adj->ipv4_address_count) { @@ -448,7 +448,7 @@ void isis_adj_print_vty(struct isis_adjacency *adj, struct vty *vty,  			for (unsigned int i = 0; i < adj->ipv4_address_count;  			     i++)  				vty_out(vty, "      %s\n", -					  inet_ntoa(adj->ipv4_addresses[i])); +					inet_ntoa(adj->ipv4_addresses[i]));  		}  		if (adj->ipv6_address_count) {  			vty_out(vty, "    IPv6 Address(es):\n"); diff --git a/isisd/isis_bpf.c b/isisd/isis_bpf.c index a4c6b4c75d..0493c125bd 100644 --- a/isisd/isis_bpf.c +++ b/isisd/isis_bpf.c @@ -248,8 +248,7 @@ int isis_recv_pdu_bcast(struct isis_circuit *circuit, u_char *ssnpa)  		     bpf_hdr->bh_caplen - LLC_LEN - ETHER_HDR_LEN);  	stream_set_getp(circuit->rcv_stream, 0); -	memcpy(ssnpa, readbuff + bpf_hdr->bh_hdrlen + ETH_ALEN, -	       ETH_ALEN); +	memcpy(ssnpa, readbuff + bpf_hdr->bh_hdrlen + ETH_ALEN, ETH_ALEN);  	if (ioctl(circuit->fd, BIOCFLUSH, &one) < 0)  		zlog_warn("Flushing failed: %s", safe_strerror(errno)); diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c index 20ce0f1fad..75d4397637 100644 --- a/isisd/isis_circuit.c +++ b/isisd/isis_circuit.c @@ -382,10 +382,12 @@ static uint8_t isis_circuit_id_gen(struct interface *ifp)  	/* Circuit ids MUST be unique for any broadcast circuits. Otherwise,  	 * Pseudo-Node LSPs cannot be generated correctly.  	 * -	 * Currently, allocate one circuit ID for any circuit, limiting the total +	 * Currently, allocate one circuit ID for any circuit, limiting the +	 * total  	 * numer of circuits IS-IS can run on to 255.  	 * -	 * We should revisit this when implementing 3-way adjacencies for p2p, since +	 * We should revisit this when implementing 3-way adjacencies for p2p, +	 * since  	 * we then have extended interface IDs available.  	 */  	uint8_t id = ifp->ifindex; @@ -398,7 +400,8 @@ static uint8_t isis_circuit_id_gen(struct interface *ifp)  	}  	if (i == 256) { -		zlog_warn("Could not allocate a circuit id for '%s'", ifp->name); +		zlog_warn("Could not allocate a circuit id for '%s'", +			  ifp->name);  		return 0;  	} @@ -1349,7 +1352,8 @@ void isis_circuit_schedule_lsp_send(struct isis_circuit *circuit)  {  	if (circuit->t_send_lsp)  		return; -	circuit->t_send_lsp = thread_add_event(master, send_lsp, circuit, 0, NULL); +	circuit->t_send_lsp = +		thread_add_event(master, send_lsp, circuit, 0, NULL);  }  void isis_circuit_queue_lsp(struct isis_circuit *circuit, struct isis_lsp *lsp) diff --git a/isisd/isis_circuit.h b/isisd/isis_circuit.h index ab181189a9..0d392036e9 100644 --- a/isisd/isis_circuit.h +++ b/isisd/isis_circuit.h @@ -82,8 +82,9 @@ struct isis_circuit {  	struct thread *t_send_csnp[2];  	struct thread *t_send_psnp[2];  	struct thread *t_send_lsp; -	struct list *lsp_queue;	/* LSPs to be txed (both levels) */ -	struct isis_lsp_hash *lsp_hash; /* Hashtable synchronized with lsp_queue */ +	struct list *lsp_queue; /* LSPs to be txed (both levels) */ +	struct isis_lsp_hash +		*lsp_hash; /* Hashtable synchronized with lsp_queue */  	time_t lsp_queue_last_push[2]; /* timestamp used to enforce transmit  					* interval;  					* for scalability, use one timestamp per @@ -96,8 +97,6 @@ struct isis_circuit {  	int (*tx)(struct isis_circuit *circuit, int level);  	struct stream *snd_stream; /* Stream for sending */  	int idx;		   /* idx in S[RM|SN] flags */ -				   /* $FRR indent$ */ -				   /* clang-format off */  #define CIRCUIT_T_UNKNOWN    0  #define CIRCUIT_T_BROADCAST  1  #define CIRCUIT_T_P2P        2 @@ -185,7 +184,7 @@ void isis_circuit_af_set(struct isis_circuit *circuit, bool ip_router,  			 bool ipv6_router);  ferr_r isis_circuit_passive_set(struct isis_circuit *circuit, bool passive);  void isis_circuit_is_type_set(struct isis_circuit *circuit, int is_type); -ferr_r isis_circuit_circ_type_set (struct isis_circuit *circuit, int circ_type); +ferr_r isis_circuit_circ_type_set(struct isis_circuit *circuit, int circ_type);  ferr_r isis_circuit_metric_set(struct isis_circuit *circuit, int level,  			       int metric); diff --git a/isisd/isis_flags.h b/isisd/isis_flags.h index 229b7ab337..7d9572a2c2 100644 --- a/isisd/isis_flags.h +++ b/isisd/isis_flags.h @@ -41,20 +41,18 @@ long int flags_get_index(struct flags *flags);  void flags_free_index(struct flags *flags, long int index);  int flags_any_set(u_int32_t *flags); -#define _ISIS_SET_FLAG(F, C)                          \ -	{                                             \ -		F[(C) >> 5] |= (1 << ((C) & 0x1F));   \ +#define _ISIS_SET_FLAG(F, C)                                                   \ +	{                                                                      \ +		F[(C) >> 5] |= (1 << ((C)&0x1F));                              \  	}  #define ISIS_SET_FLAG(F, C) _ISIS_SET_FLAG(F, C->idx) - -#define _ISIS_CLEAR_FLAG(F, C)                        \ -	{                                             \ -		F[(C) >> 5] &= ~(1 << ((C) & 0x1F));  \ +#define _ISIS_CLEAR_FLAG(F, C)                                                 \ +	{                                                                      \ +		F[(C) >> 5] &= ~(1 << ((C)&0x1F));                             \  	}  #define ISIS_CLEAR_FLAG(F, C) _ISIS_CLEAR_FLAG(F, C->idx) -  #define _ISIS_CHECK_FLAG(F, C)  (F[(C)>>5] & (1<<((C) & 0x1F)))  #define ISIS_CHECK_FLAG(F, C) _ISIS_CHECK_FLAG(F, C->idx) diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c index e1e9ccee48..55888bd389 100644 --- a/isisd/isis_lsp.c +++ b/isisd/isis_lsp.c @@ -1106,7 +1106,8 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area)  	struct list *fragments = isis_fragment_tlvs(tlvs, tlv_space);  	if (!fragments) {  		zlog_warn("BUG: could not fragment own LSP:"); -		log_multiline(LOG_WARNING, "    ", "%s", isis_format_tlvs(tlvs)); +		log_multiline(LOG_WARNING, "    ", "%s", +			      isis_format_tlvs(tlvs));  		isis_free_tlvs(tlvs);  		return;  	} @@ -1119,8 +1120,9 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area)  			if (LSP_FRAGMENT(frag->hdr.lsp_id) == 255) {  				if (!fragment_overflow) {  					fragment_overflow = true; -					zlog_warn("ISIS (%s): Too much information for 256 fragments", -						  area->area_tag); +					zlog_warn( +						"ISIS (%s): Too much information for 256 fragments", +						area->area_tag);  				}  				isis_free_tlvs(tlvs);  				continue; @@ -1794,7 +1796,7 @@ int lsp_tick(struct thread *thread)  	dnode_t *dnode, *dnode_next;  	int level;  	u_int16_t rem_lifetime; -        time_t now = monotime(NULL); +	time_t now = monotime(NULL);  	lsp_list = list_new(); @@ -1873,12 +1875,15 @@ int lsp_tick(struct thread *thread)  					if (!circuit->lsp_queue)  						continue; -					if (now - circuit->lsp_queue_last_push[level] +					if (now +						    - circuit->lsp_queue_last_push +							      [level]  					    < MIN_LSP_RETRANS_INTERVAL) {  						continue;  					} -					circuit->lsp_queue_last_push[level] = now; +					circuit->lsp_queue_last_push[level] = +						now;  					for (ALL_LIST_ELEMENTS_RO(  						     lsp_list, lspnode, lsp)) { @@ -1887,7 +1892,8 @@ int lsp_tick(struct thread *thread)  						    && ISIS_CHECK_FLAG(  							       lsp->SRMflags,  							       circuit)) { -							isis_circuit_queue_lsp(circuit, lsp); +							isis_circuit_queue_lsp( +								circuit, lsp);  						}  					}  				} diff --git a/isisd/isis_lsp_hash.c b/isisd/isis_lsp_hash.c index 9196128828..c521f42b3c 100644 --- a/isisd/isis_lsp_hash.c +++ b/isisd/isis_lsp_hash.c @@ -71,7 +71,7 @@ void isis_lsp_hash_free(struct isis_lsp_hash *ih)  }  struct isis_lsp *isis_lsp_hash_lookup(struct isis_lsp_hash *ih, -			    struct isis_lsp *lsp) +				      struct isis_lsp *lsp)  {  	return hash_lookup(ih->h, lsp);  } diff --git a/isisd/isis_pdu.c b/isisd/isis_pdu.c index 2ea1fe0a5f..20c39a624f 100644 --- a/isisd/isis_pdu.c +++ b/isisd/isis_pdu.c @@ -887,11 +887,10 @@ dontcheckadj:  					lsp_set_all_srmflags(lsp);  					/* v */  					ISIS_FLAGS_CLEAR_ALL( -						lsp -							->SSNflags); /* FIXME: -									OTHER -									than c -									*/ +						lsp->SSNflags); /* FIXME: +								   OTHER +								   than c +								   */  					/* For the case of lsp confusion, flood  					 * the purge back to its @@ -1185,7 +1184,8 @@ static int process_snp(uint8_t pdu_type, struct isis_circuit *circuit,  		     entry = entry->next) {  			zlog_debug(  				"ISIS-Snp (%s):         %cSNP entry %s, seq 0x%08" PRIx32 -				", cksum 0x%04" PRIx16 ", lifetime %" PRIu16 "s", +				", cksum 0x%04" PRIx16 ", lifetime %" PRIu16 +				"s",  				circuit->area->area_tag, typechar,  				rawlspid_print(entry->id), entry->seqno,  				entry->checksum, entry->rem_lifetime); @@ -1244,10 +1244,12 @@ static int process_snp(uint8_t pdu_type, struct isis_circuit *circuit,  					       ISIS_SYS_ID_LEN + 1);  					LSP_FRAGMENT(lspid) = 0;  					lsp0 = lsp_search( -						  lspid, -						  circuit->area->lspdb[level - 1]); +						lspid, +						circuit->area +							->lspdb[level - 1]);  					if (!lsp0) { -						zlog_debug("Got lsp frag in snp, while zero not in database"); +						zlog_debug( +							"Got lsp frag in snp, while zero not in database");  						continue;  					}  				} diff --git a/isisd/isis_pfpacket.c b/isisd/isis_pfpacket.c index 974d2b78cf..852ad49c8a 100644 --- a/isisd/isis_pfpacket.c +++ b/isisd/isis_pfpacket.c @@ -45,17 +45,16 @@  #include "privs.h"  /* tcpdump -i eth0 'isis' -dd */ -static struct sock_filter isisfilter[] = -	{ -		/* NB: we're in SOCK_DGRAM, so src/dst mac + length are stripped -		 * off! -		 * (OTOH it's a bit more lower-layer agnostic and might work -		 * over GRE?) */ -		/*	{ 0x28, 0, 0, 0x0000000c - 14 }, */ -		/*	{ 0x25, 5, 0, 0x000005dc }, */ -		{0x28, 0, 0, 0x0000000e - 14}, {0x15, 0, 3, 0x0000fefe}, -		{0x30, 0, 0, 0x00000011 - 14}, {0x15, 0, 1, 0x00000083}, -		{0x6, 0, 0, 0x00040000},       {0x6, 0, 0, 0x00000000}, +static struct sock_filter isisfilter[] = { +	/* NB: we're in SOCK_DGRAM, so src/dst mac + length are stripped +	 * off! +	 * (OTOH it's a bit more lower-layer agnostic and might work +	 * over GRE?) */ +	/*	{ 0x28, 0, 0, 0x0000000c - 14 }, */ +	/*	{ 0x25, 5, 0, 0x000005dc }, */ +	{0x28, 0, 0, 0x0000000e - 14}, {0x15, 0, 3, 0x0000fefe}, +	{0x30, 0, 0, 0x00000011 - 14}, {0x15, 0, 1, 0x00000083}, +	{0x6, 0, 0, 0x00040000},       {0x6, 0, 0, 0x00000000},  };  static struct sock_fprog bpf = { diff --git a/isisd/isis_spf.c b/isisd/isis_spf.c index a076bb555c..0eabcb7e47 100644 --- a/isisd/isis_spf.c +++ b/isisd/isis_spf.c @@ -85,10 +85,10 @@ struct isis_vertex {  		struct prefix prefix;  	} N; -	u_int32_t d_N;	       /* d(N) Distance from this IS      */ -	u_int16_t depth;       /* The depth in the imaginary tree */ -	struct list *Adj_N;    /* {Adj(N)} next hop or neighbor list */ -	struct list *parents;  /* list of parents for ECMP */ +	u_int32_t d_N;	/* d(N) Distance from this IS      */ +	u_int16_t depth;      /* The depth in the imaginary tree */ +	struct list *Adj_N;   /* {Adj(N)} next hop or neighbor list */ +	struct list *parents; /* list of parents for ECMP */  	uint64_t insert_counter;  }; @@ -161,7 +161,8 @@ static struct skiplist *isis_vertex_queue_skiplist(void)  	return skiplist_new(0, isis_vertex_queue_tent_cmp, NULL);  } -static void isis_vertex_queue_init(struct isis_vertex_queue *queue, const char *name, bool ordered) +static void isis_vertex_queue_init(struct isis_vertex_queue *queue, +				   const char *name, bool ordered)  {  	if (ordered) {  		queue->insert_counter = 1; @@ -171,8 +172,7 @@ static void isis_vertex_queue_init(struct isis_vertex_queue *queue, const char *  		queue->l.list = list_new();  	}  	queue->hash = hash_create(isis_vertex_queue_hash_key, -				  isis_vertex_queue_hash_cmp, -				  name); +				  isis_vertex_queue_hash_cmp, name);  }  static void isis_vertex_del(struct isis_vertex *vertex); @@ -183,7 +183,8 @@ static void isis_vertex_queue_clear(struct isis_vertex_queue *queue)  	if (queue->insert_counter) {  		struct isis_vertex *vertex; -		while (0 == skiplist_first(queue->l.slist, NULL, (void**)&vertex)) { +		while (0 == skiplist_first(queue->l.slist, NULL, +					   (void **)&vertex)) {  			isis_vertex_del(vertex);  			skiplist_delete_first(queue->l.slist);  		} @@ -241,13 +242,14 @@ static void isis_vertex_queue_insert(struct isis_vertex_queue *queue,  	assert(inserted == vertex);  } -static struct isis_vertex *isis_vertex_queue_pop(struct isis_vertex_queue *queue) +static struct isis_vertex * +isis_vertex_queue_pop(struct isis_vertex_queue *queue)  {  	assert(queue->insert_counter);  	struct isis_vertex *rv; -	if (skiplist_first(queue->l.slist, NULL, (void**)&rv)) +	if (skiplist_first(queue->l.slist, NULL, (void **)&rv))  		return NULL;  	skiplist_delete_first(queue->l.slist); @@ -265,8 +267,8 @@ static void isis_vertex_queue_delete(struct isis_vertex_queue *queue,  	hash_release(queue->hash, vertex);  } -#define ALL_QUEUE_ELEMENTS_RO(queue, node, data) \ -		ALL_LIST_ELEMENTS_RO((queue)->l.list, node, data) +#define ALL_QUEUE_ELEMENTS_RO(queue, node, data)                               \ +	ALL_LIST_ELEMENTS_RO((queue)->l.list, node, data)  /* End of vertex queue definitions */ @@ -274,11 +276,12 @@ static void isis_vertex_queue_delete(struct isis_vertex_queue *queue,  struct isis_spftree {  	struct isis_vertex_queue paths; /* the SPT */  	struct isis_vertex_queue tents; /* TENT */ -	struct isis_area *area;    /* back pointer to area */ -	unsigned int runcount;     /* number of runs since uptime */ -	time_t last_run_timestamp; /* last run timestamp as wall time for display */ -	time_t last_run_monotime;  /* last run as monotime for scheduling */ -	time_t last_run_duration;  /* last run duration in msec */ +	struct isis_area *area;		/* back pointer to area */ +	unsigned int runcount;		/* number of runs since uptime */ +	time_t last_run_timestamp;      /* last run timestamp as wall time for +					   display */ +	time_t last_run_monotime; /* last run as monotime for scheduling */ +	time_t last_run_duration; /* last run duration in msec */  	uint16_t mtid;  	int family; @@ -405,7 +408,8 @@ static const char *vid2string(struct isis_vertex *vertex, char *buff, int size)  	return "UNKNOWN";  } -static void isis_vertex_id_init(struct isis_vertex *vertex, void *id, enum vertextype vtype) +static void isis_vertex_id_init(struct isis_vertex *vertex, void *id, +				enum vertextype vtype)  {  	vertex->type = vtype; @@ -621,8 +625,8 @@ static struct isis_vertex *isis_spf_add_root(struct isis_spftree *spftree,  	return vertex;  } -static struct isis_vertex *isis_find_vertex(struct isis_vertex_queue *queue, void *id, -					    enum vertextype vtype) +static struct isis_vertex *isis_find_vertex(struct isis_vertex_queue *queue, +					    void *id, enum vertextype vtype)  {  	struct isis_vertex querier; @@ -827,10 +831,10 @@ static int isis_spf_process_lsp(struct isis_spftree *spftree,  		return ISIS_OK;  	/* RFC3787 section 4 SHOULD ignore overload bit in pseudo LSPs */ -	bool no_overload = (pseudo_lsp -			    || (spftree->mtid == ISIS_MT_IPV4_UNICAST +	bool no_overload = +		(pseudo_lsp || (spftree->mtid == ISIS_MT_IPV4_UNICAST  				&& !ISIS_MASK_LSP_OL_BIT(lsp->hdr.lsp_bits)) -			    || (mt_router_info && !mt_router_info->overload)); +		 || (mt_router_info && !mt_router_info->overload));  lspfragloop:  	if (lsp->hdr.seqno == 0) { @@ -1372,10 +1376,10 @@ static int isis_run_spf_cb(struct thread *thread)  	if (area->ip_circuits)  		retval = isis_run_spf(area, level, AF_INET, isis->sysid, -			&thread->real); +				      &thread->real);  	if (area->ipv6_circuits)  		retval = isis_run_spf(area, level, AF_INET6, isis->sysid, -			&thread->real); +				      &thread->real);  	return retval;  } @@ -1426,7 +1430,8 @@ int isis_spf_schedule(struct isis_area *area, int level)  	/* wait configured min_spf_interval before doing the SPF */  	long timer;  	if (diff >= area->min_spf_interval[level - 1]) { -		/* Last run is more than min interval ago, schedule immediate run */ +		/* Last run is more than min interval ago, schedule immediate +		 * run */  		timer = 0;  	} else {  		timer = area->min_spf_interval[level - 1] - diff; @@ -1469,9 +1474,9 @@ static void isis_print_paths(struct vty *vty, struct isis_vertex_queue *queue,  		vty_out(vty, "%-20s %-12s %-6u ",  			vid2string(vertex, buff, sizeof(buff)),  			vtype2string(vertex->type), vertex->d_N); -		for (unsigned int i = 0; -		     i < MAX(listcount(vertex->Adj_N), -			     listcount(vertex->parents)); i++) { +		for (unsigned int i = 0; i < MAX(listcount(vertex->Adj_N), +						 listcount(vertex->parents)); +		     i++) {  			if (anode) {  				adj = listgetdata(anode);  				anode = anode->next; @@ -1502,8 +1507,7 @@ static void isis_print_paths(struct vty *vty, struct isis_vertex_queue *queue,  					vty_out(vty, "%-20s %-9s ", "", "");  				vty_out(vty, "%s(%d)", -					vid2string(pvertex, buff, -						   sizeof(buff)), +					vid2string(pvertex, buff, sizeof(buff)),  					pvertex->type);  			} @@ -1545,7 +1549,9 @@ DEFUN (show_isis_topology,  				continue;  			if (area->ip_circuits > 0 && area->spftree[level - 1] -			    && isis_vertex_queue_count(&area->spftree[level - 1]->paths) > 0) { +			    && isis_vertex_queue_count( +				       &area->spftree[level - 1]->paths) +				       > 0) {  				vty_out(vty,  					"IS-IS paths to level-%d routers that speak IP\n",  					level); @@ -1555,7 +1561,9 @@ DEFUN (show_isis_topology,  				vty_out(vty, "\n");  			}  			if (area->ipv6_circuits > 0 && area->spftree6[level - 1] -			    && isis_vertex_queue_count(&area->spftree6[level - 1]->paths) > 0) { +			    && isis_vertex_queue_count( +				       &area->spftree6[level - 1]->paths) +				       > 0) {  				vty_out(vty,  					"IS-IS paths to level-%d routers that speak IPv6\n",  					level); @@ -1586,6 +1594,5 @@ void isis_spf_print(struct isis_spftree *spftree, struct vty *vty)  	vty_out(vty, "      last run duration : %u usec\n",  		(u_int32_t)spftree->last_run_duration); -	vty_out(vty, "      run count         : %u\n", -		spftree->runcount); +	vty_out(vty, "      run count         : %u\n", spftree->runcount);  } diff --git a/isisd/isis_te.c b/isisd/isis_te.c index 104a0fd4bf..df0b8b62d6 100644 --- a/isisd/isis_te.c +++ b/isisd/isis_te.c @@ -725,7 +725,8 @@ static u_char print_subtlv_max_rsv_bw(struct sbuf *buf, int indent,  	fval = ntohf(tlv->value); -	sbuf_push(buf, indent, "Maximum Reservable Bandwidth: %g (Bytes/sec)\n", fval); +	sbuf_push(buf, indent, "Maximum Reservable Bandwidth: %g (Bytes/sec)\n", +		  fval);  	return (SUBTLV_HDR_SIZE + SUBTLV_DEF_SIZE);  } @@ -741,8 +742,9 @@ static u_char print_subtlv_unrsv_bw(struct sbuf *buf, int indent,  	for (i = 0; i < MAX_CLASS_TYPE; i += 2) {  		fval1 = ntohf(tlv->value[i]);  		fval2 = ntohf(tlv->value[i + 1]); -		sbuf_push(buf, indent + 2, "[%d]: %g (Bytes/sec),\t[%d]: %g (Bytes/sec)\n", -			  i, fval1, i + 1, fval2); +		sbuf_push(buf, indent + 2, +			  "[%d]: %g (Bytes/sec),\t[%d]: %g (Bytes/sec)\n", i, +			  fval1, i + 1, fval2);  	}  	return (SUBTLV_HDR_SIZE + TE_SUBTLV_UNRSV_SIZE); @@ -786,7 +788,8 @@ static u_char print_subtlv_av_delay(struct sbuf *buf, int indent,  	delay = (u_int32_t)ntohl(tlv->value) & TE_EXT_MASK;  	A = (u_int32_t)ntohl(tlv->value) & TE_EXT_ANORMAL; -	sbuf_push(buf, indent, "%s Average Link Delay: %" PRIu32 " (micro-sec)\n", +	sbuf_push(buf, indent, +		  "%s Average Link Delay: %" PRIu32 " (micro-sec)\n",  		  A ? "Anomalous" : "Normal", delay);  	return (SUBTLV_HDR_SIZE + SUBTLV_DEF_SIZE); @@ -802,7 +805,8 @@ static u_char print_subtlv_mm_delay(struct sbuf *buf, int indent,  	A = (u_int32_t)ntohl(tlv->low) & TE_EXT_ANORMAL;  	high = (u_int32_t)ntohl(tlv->high) & TE_EXT_MASK; -	sbuf_push(buf, indent, "%s Min/Max Link Delay: %" PRIu32 " / %" PRIu32 " (micro-sec)\n", +	sbuf_push(buf, indent, "%s Min/Max Link Delay: %" PRIu32 " / %" PRIu32 +			       " (micro-sec)\n",  		  A ? "Anomalous" : "Normal", low, high);  	return (SUBTLV_HDR_SIZE + SUBTLV_DEF_SIZE); @@ -815,7 +819,8 @@ static u_char print_subtlv_delay_var(struct sbuf *buf, int indent,  	jitter = (u_int32_t)ntohl(tlv->value) & TE_EXT_MASK; -	sbuf_push(buf, indent, "Delay Variation: %" PRIu32 " (micro-sec)\n", jitter); +	sbuf_push(buf, indent, "Delay Variation: %" PRIu32 " (micro-sec)\n", +		  jitter);  	return (SUBTLV_HDR_SIZE + SUBTLV_DEF_SIZE);  } @@ -844,8 +849,8 @@ static u_char print_subtlv_res_bw(struct sbuf *buf, int indent,  	fval = ntohf(tlv->value); -	sbuf_push(buf, indent, "Unidirectional Residual Bandwidth: %g (Bytes/sec)\n", -		  fval); +	sbuf_push(buf, indent, +		  "Unidirectional Residual Bandwidth: %g (Bytes/sec)\n", fval);  	return (SUBTLV_HDR_SIZE + SUBTLV_DEF_SIZE);  } @@ -857,8 +862,8 @@ static u_char print_subtlv_ava_bw(struct sbuf *buf, int indent,  	fval = ntohf(tlv->value); -	sbuf_push(buf, indent, "Unidirectional Available Bandwidth: %g (Bytes/sec)\n", -		  fval); +	sbuf_push(buf, indent, +		  "Unidirectional Available Bandwidth: %g (Bytes/sec)\n", fval);  	return (SUBTLV_HDR_SIZE + SUBTLV_DEF_SIZE);  } @@ -870,8 +875,8 @@ static u_char print_subtlv_use_bw(struct sbuf *buf, int indent,  	fval = ntohf(tlv->value); -	sbuf_push(buf, indent, "Unidirectional Utilized Bandwidth: %g (Bytes/sec)\n", -		  fval); +	sbuf_push(buf, indent, +		  "Unidirectional Utilized Bandwidth: %g (Bytes/sec)\n", fval);  	return (SUBTLV_HDR_SIZE + SUBTLV_DEF_SIZE);  } @@ -892,8 +897,7 @@ static u_char print_unknown_tlv(struct sbuf *buf, int indent,  			sbuf_push(buf, 0, " %#.2x", v[i]);  			if (rtn == 8) {  				sbuf_push(buf, 0, "\n"); -				sbuf_push(buf, indent + 8, -					  "[%.2x]", i + 1); +				sbuf_push(buf, indent + 8, "[%.2x]", i + 1);  				rtn = 1;  			} else  				rtn++; @@ -909,8 +913,8 @@ static u_char print_unknown_tlv(struct sbuf *buf, int indent,  }  /* Main Show function */ -void mpls_te_print_detail(struct sbuf *buf, int indent, -			  uint8_t *subtlvs, uint8_t subtlv_len) +void mpls_te_print_detail(struct sbuf *buf, int indent, uint8_t *subtlvs, +			  uint8_t subtlv_len)  {  	struct subtlv_header *tlvh = (struct subtlv_header *)subtlvs;  	uint16_t sum = 0; @@ -918,72 +922,78 @@ void mpls_te_print_detail(struct sbuf *buf, int indent,  	for (; sum < subtlv_len; tlvh = SUBTLV_HDR_NEXT(tlvh)) {  		switch (tlvh->type) {  		case TE_SUBTLV_ADMIN_GRP: -			sum += print_subtlv_admin_grp(buf, indent, +			sum += print_subtlv_admin_grp( +				buf, indent,  				(struct te_subtlv_admin_grp *)tlvh);  			break;  		case TE_SUBTLV_LLRI:  			sum += print_subtlv_llri(buf, indent, -				(struct te_subtlv_llri *)tlvh); +						 (struct te_subtlv_llri *)tlvh);  			break;  		case TE_SUBTLV_LOCAL_IPADDR: -			sum += print_subtlv_local_ipaddr(buf, indent, +			sum += print_subtlv_local_ipaddr( +				buf, indent,  				(struct te_subtlv_local_ipaddr *)tlvh);  			break;  		case TE_SUBTLV_RMT_IPADDR: -			sum += print_subtlv_rmt_ipaddr(buf, indent, +			sum += print_subtlv_rmt_ipaddr( +				buf, indent,  				(struct te_subtlv_rmt_ipaddr *)tlvh);  			break;  		case TE_SUBTLV_MAX_BW: -			sum += print_subtlv_max_bw(buf, indent, -				(struct te_subtlv_max_bw *)tlvh); +			sum += print_subtlv_max_bw( +				buf, indent, (struct te_subtlv_max_bw *)tlvh);  			break;  		case TE_SUBTLV_MAX_RSV_BW: -			sum += print_subtlv_max_rsv_bw(buf, indent, +			sum += print_subtlv_max_rsv_bw( +				buf, indent,  				(struct te_subtlv_max_rsv_bw *)tlvh);  			break;  		case TE_SUBTLV_UNRSV_BW: -			sum += print_subtlv_unrsv_bw(buf, indent, -				(struct te_subtlv_unrsv_bw *)tlvh); +			sum += print_subtlv_unrsv_bw( +				buf, indent, (struct te_subtlv_unrsv_bw *)tlvh);  			break;  		case TE_SUBTLV_TE_METRIC: -			sum += print_subtlv_te_metric(buf, indent, +			sum += print_subtlv_te_metric( +				buf, indent,  				(struct te_subtlv_te_metric *)tlvh);  			break;  		case TE_SUBTLV_RAS:  			sum += print_subtlv_ras(buf, indent, -				(struct te_subtlv_ras *)tlvh); +						(struct te_subtlv_ras *)tlvh);  			break;  		case TE_SUBTLV_RIP:  			sum += print_subtlv_rip(buf, indent, -				(struct te_subtlv_rip *)tlvh); +						(struct te_subtlv_rip *)tlvh);  			break;  		case TE_SUBTLV_AV_DELAY: -			sum += print_subtlv_av_delay(buf, indent, -				(struct te_subtlv_av_delay *)tlvh); +			sum += print_subtlv_av_delay( +				buf, indent, (struct te_subtlv_av_delay *)tlvh);  			break;  		case TE_SUBTLV_MM_DELAY: -			sum += print_subtlv_mm_delay(buf, indent, -				(struct te_subtlv_mm_delay *)tlvh); +			sum += print_subtlv_mm_delay( +				buf, indent, (struct te_subtlv_mm_delay *)tlvh);  			break;  		case TE_SUBTLV_DELAY_VAR: -			sum += print_subtlv_delay_var(buf, indent, +			sum += print_subtlv_delay_var( +				buf, indent,  				(struct te_subtlv_delay_var *)tlvh);  			break;  		case TE_SUBTLV_PKT_LOSS: -			sum += print_subtlv_pkt_loss(buf, indent, -				(struct te_subtlv_pkt_loss *)tlvh); +			sum += print_subtlv_pkt_loss( +				buf, indent, (struct te_subtlv_pkt_loss *)tlvh);  			break;  		case TE_SUBTLV_RES_BW: -			sum += print_subtlv_res_bw(buf, indent, -				(struct te_subtlv_res_bw *)tlvh); +			sum += print_subtlv_res_bw( +				buf, indent, (struct te_subtlv_res_bw *)tlvh);  			break;  		case TE_SUBTLV_AVA_BW: -			sum += print_subtlv_ava_bw(buf, indent, -				(struct te_subtlv_ava_bw *)tlvh); +			sum += print_subtlv_ava_bw( +				buf, indent, (struct te_subtlv_ava_bw *)tlvh);  			break;  		case TE_SUBTLV_USE_BW: -			sum += print_subtlv_use_bw(buf, indent, -				(struct te_subtlv_use_bw *)tlvh); +			sum += print_subtlv_use_bw( +				buf, indent, (struct te_subtlv_use_bw *)tlvh);  			break;  		default:  			sum += print_unknown_tlv(buf, indent, tlvh); diff --git a/isisd/isis_te.h b/isisd/isis_te.h index 9b29792e2b..91bcb72698 100644 --- a/isisd/isis_te.h +++ b/isisd/isis_te.h @@ -309,7 +309,8 @@ struct mpls_te_circuit {  void isis_mpls_te_init(void);  struct mpls_te_circuit *mpls_te_circuit_new(void);  struct sbuf; -void mpls_te_print_detail(struct sbuf *buf, int indent, uint8_t *subtlvs, uint8_t subtlv_len); +void mpls_te_print_detail(struct sbuf *buf, int indent, uint8_t *subtlvs, +			  uint8_t subtlv_len);  void set_circuitparams_local_ipaddr(struct mpls_te_circuit *, struct in_addr);  void set_circuitparams_rmt_ipaddr(struct mpls_te_circuit *, struct in_addr);  uint8_t subtlvs_len(struct mpls_te_circuit *); diff --git a/isisd/isis_tlvs.c b/isisd/isis_tlvs.c index 55b0a362f6..8e0fd74b73 100644 --- a/isisd/isis_tlvs.c +++ b/isisd/isis_tlvs.c @@ -161,9 +161,11 @@ static int unpack_subtlv_ipv6_source_prefix(enum isis_tlv_context context,  	sbuf_push(log, indent, "Unpacking IPv6 Source Prefix Sub-TLV...\n");  	if (tlv_len < 1) { -		sbuf_push(log, indent, -			  "Not enough data left. (expected 1 or more bytes, got %" PRIu8 ")\n", -			  tlv_len); +		sbuf_push( +			log, indent, +			"Not enough data left. (expected 1 or more bytes, got %" PRIu8 +			")\n", +			tlv_len);  		return 1;  	} @@ -496,8 +498,9 @@ static void format_item_lsp_entry(uint16_t mtid, struct isis_item *i,  {  	struct isis_lsp_entry *e = (struct isis_lsp_entry *)i; -	sbuf_push(buf, indent, "LSP Entry: %s, seq 0x%08" PRIx32 -		  ", cksum 0x%04" PRIx16 ", lifetime %" PRIu16 "s\n", +	sbuf_push(buf, indent, +		  "LSP Entry: %s, seq 0x%08" PRIx32 ", cksum 0x%04" PRIx16 +		  ", lifetime %" PRIu16 "s\n",  		  isis_format_id(e->id, 8), e->seqno, e->checksum,  		  e->rem_lifetime);  } @@ -579,7 +582,8 @@ static void format_item_extended_reach(uint16_t mtid, struct isis_item *i,  	sbuf_push(buf, 0, "\n");  	if (r->subtlv_len && r->subtlvs) -		mpls_te_print_detail(buf, indent + 2, r->subtlvs, r->subtlv_len); +		mpls_te_print_detail(buf, indent + 2, r->subtlvs, +				     r->subtlv_len);  }  static void free_item_extended_reach(struct isis_item *i) @@ -621,10 +625,11 @@ static int unpack_item_extended_reach(uint16_t mtid, uint8_t len,  		  (mtid == ISIS_MT_IPV4_UNICAST) ? "extended" : "mt");  	if (len < 11) { -		sbuf_push(log, indent, -			  "Not enough data left. (expected 11 or more bytes, got %" -			  PRIu8 ")\n", -			  len); +		sbuf_push( +			log, indent, +			"Not enough data left. (expected 11 or more bytes, got %" PRIu8 +			")\n", +			len);  		goto out;  	} @@ -690,7 +695,8 @@ static void format_item_oldstyle_ip_reach(uint16_t mtid, struct isis_item *i,  	char prefixbuf[PREFIX2STR_BUFFER];  	sbuf_push(buf, indent, "IP Reachability: %s (Metric: %" PRIu8 ")\n", -		  prefix2str(&r->prefix, prefixbuf, sizeof(prefixbuf)), r->metric); +		  prefix2str(&r->prefix, prefixbuf, sizeof(prefixbuf)), +		  r->metric);  }  static void free_item_oldstyle_ip_reach(struct isis_item *i) @@ -971,8 +977,7 @@ static void format_item_mt_router_info(uint16_t mtid, struct isis_item *i,  	struct isis_mt_router_info *info = (struct isis_mt_router_info *)i;  	sbuf_push(buf, indent, "MT Router Info: %s%s%s\n", -		  isis_mtid2str(info->mtid), -		  info->overload ? " Overload" : "", +		  isis_mtid2str(info->mtid), info->overload ? " Overload" : "",  		  info->attached ? " Attached" : "");  } @@ -1121,8 +1126,8 @@ static void format_item_extended_ip_reach(uint16_t mtid, struct isis_item *i,  	sbuf_push(buf, indent, "%s IP Reachability: %s (Metric: %u)%s",  		  (mtid == ISIS_MT_IPV4_UNICAST) ? "Extended" : "MT", -		  prefix2str(&r->prefix, prefixbuf, sizeof(prefixbuf)), r->metric, -		  r->down ? " Down" : ""); +		  prefix2str(&r->prefix, prefixbuf, sizeof(prefixbuf)), +		  r->metric, r->down ? " Down" : "");  	if (mtid != ISIS_MT_IPV4_UNICAST)  		sbuf_push(buf, 0, " %s", isis_mtid2str(mtid));  	sbuf_push(buf, 0, "\n"); @@ -1175,9 +1180,11 @@ static int unpack_item_extended_ip_reach(uint16_t mtid, uint8_t len,  	consume = 5;  	if (len < consume) { -		sbuf_push(log, indent, -			  "Not enough data left. (expected 5 or more bytes, got %" PRIu8 ")\n", -			  len); +		sbuf_push( +			log, indent, +			"Not enough data left. (expected 5 or more bytes, got %" PRIu8 +			")\n", +			len);  		goto out;  	} @@ -1196,9 +1203,10 @@ static int unpack_item_extended_ip_reach(uint16_t mtid, uint8_t len,  	consume += PSIZE(rv->prefix.prefixlen);  	if (len < consume) { -		sbuf_push(log, indent, -			  "Expected %u bytes of prefix, but only %u bytes available.\n", -			  PSIZE(rv->prefix.prefixlen), len - 5); +		sbuf_push( +			log, indent, +			"Expected %u bytes of prefix, but only %u bytes available.\n", +			PSIZE(rv->prefix.prefixlen), len - 5);  		goto out;  	}  	stream_get(&rv->prefix.prefix.s_addr, s, PSIZE(rv->prefix.prefixlen)); @@ -1213,23 +1221,26 @@ static int unpack_item_extended_ip_reach(uint16_t mtid, uint8_t len,  	if (control & ISIS_EXTENDED_IP_REACH_SUBTLV) {  		consume += 1;  		if (len < consume) { -			sbuf_push(log, indent, -				  "Expected 1 byte of subtlv len, but no more data present.\n"); +			sbuf_push( +				log, indent, +				"Expected 1 byte of subtlv len, but no more data present.\n");  			goto out;  		}  		subtlv_len = stream_getc(s);  		if (!subtlv_len) { -			sbuf_push(log, indent + 2, -				  "  WARNING: subtlv bit is set, but there are no subtlvs.\n"); +			sbuf_push( +				log, indent + 2, +				"  WARNING: subtlv bit is set, but there are no subtlvs.\n");  		}  		consume += subtlv_len;  		if (len < consume) { -			sbuf_push(log, indent, -				  "Expected %" PRIu8 -				  " bytes of subtlvs, but only %u bytes available.\n", -				  subtlv_len, -				  len - 6 - PSIZE(rv->prefix.prefixlen)); +			sbuf_push( +				log, indent, +				"Expected %" PRIu8 +				" bytes of subtlvs, but only %u bytes available.\n", +				subtlv_len, +				len - 6 - PSIZE(rv->prefix.prefixlen));  			goto out;  		}  		sbuf_push(log, indent, "Skipping %" PRIu8 " bytes of subvls", @@ -1350,8 +1361,7 @@ static void format_item_ipv6_reach(uint16_t mtid, struct isis_item *i,  	sbuf_push(buf, indent, "%sIPv6 Reachability: %s (Metric: %u)%s%s",  		  (mtid == ISIS_MT_IPV4_UNICAST) ? "" : "MT ",  		  prefix2str(&r->prefix, prefixbuf, sizeof(prefixbuf)), -		  r->metric, -		  r->down ? " Down" : "", +		  r->metric, r->down ? " Down" : "",  		  r->external ? " External" : "");  	if (mtid != ISIS_MT_IPV4_UNICAST)  		sbuf_push(buf, 0, " %s", isis_mtid2str(mtid)); @@ -1416,10 +1426,11 @@ static int unpack_item_ipv6_reach(uint16_t mtid, uint8_t len, struct stream *s,  		  (mtid == ISIS_MT_IPV4_UNICAST) ? "" : "mt ");  	consume = 6;  	if (len < consume) { -		sbuf_push(log, indent, -			  "Not enough data left. (expected 6 or more bytes, got %" -			  PRIu8 ")\n", -			  len); +		sbuf_push( +			log, indent, +			"Not enough data left. (expected 6 or more bytes, got %" PRIu8 +			")\n", +			len);  		goto out;  	} @@ -1440,9 +1451,10 @@ static int unpack_item_ipv6_reach(uint16_t mtid, uint8_t len, struct stream *s,  	consume += PSIZE(rv->prefix.prefixlen);  	if (len < consume) { -		sbuf_push(log, indent, -			  "Expected %u bytes of prefix, but only %u bytes available.\n", -			  PSIZE(rv->prefix.prefixlen), len - 6); +		sbuf_push( +			log, indent, +			"Expected %u bytes of prefix, but only %u bytes available.\n", +			PSIZE(rv->prefix.prefixlen), len - 6);  		goto out;  	}  	stream_get(&rv->prefix.prefix.s6_addr, s, PSIZE(rv->prefix.prefixlen)); @@ -1456,23 +1468,26 @@ static int unpack_item_ipv6_reach(uint16_t mtid, uint8_t len, struct stream *s,  	if (control & ISIS_IPV6_REACH_SUBTLV) {  		consume += 1;  		if (len < consume) { -			sbuf_push(log, indent, -				  "Expected 1 byte of subtlv len, but no more data persent.\n"); +			sbuf_push( +				log, indent, +				"Expected 1 byte of subtlv len, but no more data persent.\n");  			goto out;  		}  		subtlv_len = stream_getc(s);  		if (!subtlv_len) { -			sbuf_push(log, indent + 2, -				  "  WARNING: subtlv bit set, but there are no subtlvs.\n"); +			sbuf_push( +				log, indent + 2, +				"  WARNING: subtlv bit set, but there are no subtlvs.\n");  		}  		consume += subtlv_len;  		if (len < consume) { -			sbuf_push(log, indent, -				  "Expected %" PRIu8 -				  " bytes of subtlvs, but only %u bytes available.\n", -				  subtlv_len, -				  len - 6 - PSIZE(rv->prefix.prefixlen)); +			sbuf_push( +				log, indent, +				"Expected %" PRIu8 +				" bytes of subtlvs, but only %u bytes available.\n", +				subtlv_len, +				len - 6 - PSIZE(rv->prefix.prefixlen));  			goto out;  		} @@ -1695,16 +1710,19 @@ static int pack_item(enum isis_tlv_context context, enum isis_tlv_type type,  	return 1;  } -static void add_item_to_fragment(struct isis_item *i, struct pack_order_entry *pe, +static void add_item_to_fragment(struct isis_item *i, +				 struct pack_order_entry *pe,  				 struct isis_tlvs *fragment_tlvs, uint16_t mtid)  {  	struct isis_item_list *l;  	if (pe->how_to_pack == ISIS_ITEMS) { -		l = (struct isis_item_list *)(((char *)fragment_tlvs) + pe->what_to_pack); +		l = (struct isis_item_list *)(((char *)fragment_tlvs) +					      + pe->what_to_pack);  	} else {  		struct isis_mt_item_list *m; -		m = (struct isis_mt_item_list *)(((char *)fragment_tlvs) + pe->what_to_pack); +		m = (struct isis_mt_item_list *)(((char *)fragment_tlvs) +						 + pe->what_to_pack);  		l = isis_get_mt_items(m, mtid);  	} @@ -2284,8 +2302,9 @@ static int pack_tlvs(struct isis_tlvs *tlvs, struct stream *stream,  	/* When fragmenting, don't add auth as it's already accounted for in the  	 * size we are given. */  	if (!fragment_tlvs) { -		rv = pack_items(ISIS_CONTEXT_LSP, ISIS_TLV_AUTH, &tlvs->isis_auth, -				stream, NULL, NULL, NULL, NULL); +		rv = pack_items(ISIS_CONTEXT_LSP, ISIS_TLV_AUTH, +				&tlvs->isis_auth, stream, NULL, NULL, NULL, +				NULL);  		if (rv)  			return rv;  	} @@ -2440,9 +2459,11 @@ static int unpack_tlv(enum isis_tlv_context context, size_t avail_len,  		  tlv_type, tlv_len);  	if (avail_len < ((size_t)tlv_len) + 2) { -		sbuf_push(log, indent + 2, -			  "Available data %zu too short for claimed TLV len %" PRIu8 ".\n", -			  avail_len - 2, tlv_len); +		sbuf_push( +			log, indent + 2, +			"Available data %zu too short for claimed TLV len %" PRIu8 +			".\n", +			avail_len - 2, tlv_len);  		return 1;  	} @@ -2520,7 +2541,7 @@ int isis_unpack_tlvs(size_t avail_len, struct stream *stream,  	static const struct tlv_ops tlv_##_name_##_ops = {                     \  		.name = _desc_,                                                \  		.unpack = unpack_tlv_with_items,                               \ -									       \ +                                                                               \  		.pack_item = pack_item_##_name_,                               \  		.free_item = free_item_##_name_,                               \  		.unpack_item = unpack_item_##_name_,                           \ @@ -2550,34 +2571,49 @@ ITEM_TLV_OPS(ipv6_reach, "TLV 236 IPv6 Reachability");  SUBTLV_OPS(ipv6_source_prefix, "Sub-TLV 22 IPv6 Source Prefix"); -static const struct tlv_ops *tlv_table[ISIS_CONTEXT_MAX][ISIS_TLV_MAX] = { -	[ISIS_CONTEXT_LSP] = { -		[ISIS_TLV_AREA_ADDRESSES] = &tlv_area_address_ops, -		[ISIS_TLV_OLDSTYLE_REACH] = &tlv_oldstyle_reach_ops, -		[ISIS_TLV_LAN_NEIGHBORS] = &tlv_lan_neighbor_ops, -		[ISIS_TLV_LSP_ENTRY] = &tlv_lsp_entry_ops, -		[ISIS_TLV_AUTH] = &tlv_auth_ops, -		[ISIS_TLV_EXTENDED_REACH] = &tlv_extended_reach_ops, -		[ISIS_TLV_MT_REACH] = &tlv_extended_reach_ops, -		[ISIS_TLV_OLDSTYLE_IP_REACH] = &tlv_oldstyle_ip_reach_ops, -		[ISIS_TLV_PROTOCOLS_SUPPORTED] = &tlv_protocols_supported_ops, -		[ISIS_TLV_OLDSTYLE_IP_REACH_EXT] = &tlv_oldstyle_ip_reach_ops, -		[ISIS_TLV_IPV4_ADDRESS] = &tlv_ipv4_address_ops, -		[ISIS_TLV_TE_ROUTER_ID] = &tlv_te_router_id_ops, -		[ISIS_TLV_EXTENDED_IP_REACH] = &tlv_extended_ip_reach_ops, -		[ISIS_TLV_MT_IP_REACH] = &tlv_extended_ip_reach_ops, -		[ISIS_TLV_DYNAMIC_HOSTNAME] = &tlv_dynamic_hostname_ops, -		[ISIS_TLV_MT_ROUTER_INFO] = &tlv_mt_router_info_ops, -		[ISIS_TLV_IPV6_ADDRESS] = &tlv_ipv6_address_ops, -		[ISIS_TLV_IPV6_REACH] = &tlv_ipv6_reach_ops, -		[ISIS_TLV_MT_IPV6_REACH] = &tlv_ipv6_reach_ops, -	}, -	[ISIS_CONTEXT_SUBTLV_NE_REACH] = {}, -	[ISIS_CONTEXT_SUBTLV_IP_REACH] = {}, -	[ISIS_CONTEXT_SUBTLV_IPV6_REACH] = { -		[ISIS_SUBTLV_IPV6_SOURCE_PREFIX] = &subtlv_ipv6_source_prefix_ops, -	} -}; +static const struct tlv_ops *tlv_table[ISIS_CONTEXT_MAX][ISIS_TLV_MAX] = +	{[ISIS_CONTEXT_LSP] = +		 { +				 [ISIS_TLV_AREA_ADDRESSES] = +					 &tlv_area_address_ops, +				 [ISIS_TLV_OLDSTYLE_REACH] = +					 &tlv_oldstyle_reach_ops, +				 [ISIS_TLV_LAN_NEIGHBORS] = +					 &tlv_lan_neighbor_ops, +				 [ISIS_TLV_LSP_ENTRY] = &tlv_lsp_entry_ops, +				 [ISIS_TLV_AUTH] = &tlv_auth_ops, +				 [ISIS_TLV_EXTENDED_REACH] = +					 &tlv_extended_reach_ops, +				 [ISIS_TLV_MT_REACH] = &tlv_extended_reach_ops, +				 [ISIS_TLV_OLDSTYLE_IP_REACH] = +					 &tlv_oldstyle_ip_reach_ops, +				 [ISIS_TLV_PROTOCOLS_SUPPORTED] = +					 &tlv_protocols_supported_ops, +				 [ISIS_TLV_OLDSTYLE_IP_REACH_EXT] = +					 &tlv_oldstyle_ip_reach_ops, +				 [ISIS_TLV_IPV4_ADDRESS] = +					 &tlv_ipv4_address_ops, +				 [ISIS_TLV_TE_ROUTER_ID] = +					 &tlv_te_router_id_ops, +				 [ISIS_TLV_EXTENDED_IP_REACH] = +					 &tlv_extended_ip_reach_ops, +				 [ISIS_TLV_MT_IP_REACH] = +					 &tlv_extended_ip_reach_ops, +				 [ISIS_TLV_DYNAMIC_HOSTNAME] = +					 &tlv_dynamic_hostname_ops, +				 [ISIS_TLV_MT_ROUTER_INFO] = +					 &tlv_mt_router_info_ops, +				 [ISIS_TLV_IPV6_ADDRESS] = +					 &tlv_ipv6_address_ops, +				 [ISIS_TLV_IPV6_REACH] = &tlv_ipv6_reach_ops, +				 [ISIS_TLV_MT_IPV6_REACH] = &tlv_ipv6_reach_ops, +		 }, +	 [ISIS_CONTEXT_SUBTLV_NE_REACH] = {}, +	 [ISIS_CONTEXT_SUBTLV_IP_REACH] = {}, +	 [ISIS_CONTEXT_SUBTLV_IPV6_REACH] = { +			 [ISIS_SUBTLV_IPV6_SOURCE_PREFIX] = +				 &subtlv_ipv6_source_prefix_ops, +	 }};  /* Accessor functions */ diff --git a/isisd/isisd.c b/isisd/isisd.c index a6a2202728..6d64e07705 100644 --- a/isisd/isisd.c +++ b/isisd/isisd.c @@ -764,7 +764,7 @@ DEFUN_NOSH (show_debugging,  	    "State of each debugging option\n"  	    ISIS_STR)  { -	vty_out (vty, "IS-IS debugging status:\n"); +	vty_out(vty, "IS-IS debugging status:\n");  	if (isis->debugs)  		print_debug(vty, isis->debugs, 1); diff --git a/isisd/isisd.h b/isisd/isisd.h index 427d314df6..a8dcc8adaf 100644 --- a/isisd/isisd.h +++ b/isisd/isisd.h @@ -52,8 +52,9 @@ struct isis {  	struct area_addr *man_area_addrs; /* manualAreaAddresses */  	u_int32_t debugs;		  /* bitmap for debug */  	time_t uptime;			  /* when did we start */ -	struct thread *t_dync_clean;      /* dynamic hostname cache cleanup thread */ -	uint32_t circuit_ids_used[8];     /* 256 bits to track circuit ids 0 through 255 */ +	struct thread *t_dync_clean; /* dynamic hostname cache cleanup thread */ +	uint32_t circuit_ids_used +		[8]; /* 256 bits to track circuit ids 0 through 255 */  	struct route_table *ext_info[REDIST_PROTOCOL_COUNT]; @@ -70,8 +71,6 @@ struct isis_area {  	struct route_table *route_table[ISIS_LEVELS];  /* IPv4 routes */  	struct isis_spftree *spftree6[ISIS_LEVELS];    /* The v6 SPTs */  	struct route_table *route_table6[ISIS_LEVELS]; /* IPv6 routes */ -						       /* $FRR indent$ */ -/* clang-format off */  #define DEFAULT_LSP_MTU 1497  	unsigned int lsp_mtu;      /* Size of LSPs to generate */  	struct list *circuit_list; /* IS-IS circuits */ diff --git a/lib/command.c b/lib/command.c index 3fa086bf62..6d04ad83c0 100644 --- a/lib/command.c +++ b/lib/command.c @@ -62,7 +62,7 @@ const char *node_names[] = {  	"aaa",			    // AAA_NODE,  	"keychain",		    // KEYCHAIN_NODE,  	"keychain key",		    // KEYCHAIN_KEY_NODE, -	"logical-router",	    // LOGICALROUTER_NODE, +	"logical-router",	   // LOGICALROUTER_NODE,  	"vrf",			    // VRF_NODE,  	"interface",		    // INTERFACE_NODE,  	"zebra",		    // ZEBRA_NODE, @@ -74,14 +74,14 @@ const char *node_names[] = {  	"bgp",			    // BGP_NODE,  	"bgp vpnv4",		    // BGP_VPNV4_NODE,  	"bgp vpnv6",		    // BGP_VPNV6_NODE, -	"bgp ipv4 unicast",         // BGP_IPV4_NODE, +	"bgp ipv4 unicast",	 // BGP_IPV4_NODE,  	"bgp ipv4 multicast",       // BGP_IPV4M_NODE,  	"bgp ipv4 labeled unicast", // BGP_IPV4L_NODE,  	"bgp ipv6",		    // BGP_IPV6_NODE,  	"bgp ipv6 multicast",       // BGP_IPV6M_NODE,  	"bgp ipv6 labeled unicast", // BGP_IPV6L_NODE, -	"bgp vrf policy",	    // BGP_VRF_POLICY_NODE, -	"bgp vnc defaults",         // BGP_VNC_DEFAULTS_NODE, +	"bgp vrf policy",	   // BGP_VRF_POLICY_NODE, +	"bgp vnc defaults",	 // BGP_VNC_DEFAULTS_NODE,  	"bgp vnc nve",		    // BGP_VNC_NVE_GROUP_NODE,  	"bgp vnc l2",		    // BGP_VNC_L2_GROUP_NODE,  	"rfp defaults",		    // RFP_DEFAULTS_NODE, @@ -99,13 +99,13 @@ const char *node_names[] = {  	"masc",			    // MASC_NODE,  	"irdp",			    // IRDP_NODE,  	"static ip",		    // IP_NODE, -	"ipv4 access list",         // ACCESS_NODE, -	"ipv4 prefix list",         // PREFIX_NODE, -	"ipv6 access list",         // ACCESS_IPV6_NODE, -	"MAC access list",          // ACCESS_MAC_NODE, -	"ipv6 prefix list",         // PREFIX_IPV6_NODE, +	"ipv4 access list",	 // ACCESS_NODE, +	"ipv4 prefix list",	 // PREFIX_NODE, +	"ipv6 access list",	 // ACCESS_IPV6_NODE, +	"MAC access list",	  // ACCESS_MAC_NODE, +	"ipv6 prefix list",	 // PREFIX_IPV6_NODE,  	"as list",		    // AS_LIST_NODE, -	"community list",	    // COMMUNITY_LIST_NODE, +	"community list",	   // COMMUNITY_LIST_NODE,  	"routemap",		    // RMAP_NODE,  	"smux",			    // SMUX_NODE,  	"dump",			    // DUMP_NODE, @@ -301,8 +301,7 @@ void install_node(struct cmd_node *node, int (*func)(struct vty *))  		cmd_token_new(START_TKN, CMD_ATTR_NORMAL, NULL, NULL);  	graph_new_node(node->cmdgraph, token,  		       (void (*)(void *)) & cmd_token_del); -	node->cmd_hash = hash_create_size(16, cmd_hash_key, -					  cmd_hash_cmp, +	node->cmd_hash = hash_create_size(16, cmd_hash_key, cmd_hash_cmp,  					  "Command Hash");  } @@ -1170,8 +1169,7 @@ int command_config_read_one_line(struct vty *vty,  	if (!(use_daemon && ret == CMD_SUCCESS_DAEMON)  	    && !(!use_daemon && ret == CMD_ERR_NOTHING_TODO)  	    && ret != CMD_SUCCESS && ret != CMD_WARNING -	    && ret != CMD_NOT_MY_INSTANCE -	    && ret != CMD_WARNING_CONFIG_FAILED +	    && ret != CMD_NOT_MY_INSTANCE && ret != CMD_WARNING_CONFIG_FAILED  	    && vty->node != CONFIG_NODE) {  		saved_node = vty->node; diff --git a/lib/command.h b/lib/command.h index 269318989f..56e70abf6f 100644 --- a/lib/command.h +++ b/lib/command.h @@ -85,7 +85,7 @@ enum node_type {  	AAA_NODE,		/* AAA node. */  	KEYCHAIN_NODE,		/* Key-chain node. */  	KEYCHAIN_KEY_NODE,      /* Key-chain key node. */ -	LOGICALROUTER_NODE,	/* Logical-Router node. */ +	LOGICALROUTER_NODE,     /* Logical-Router node. */  	VRF_NODE,		/* VRF mode node. */  	INTERFACE_NODE,		/* Interface mode node. */  	ZEBRA_NODE,		/* zebra connection node. */ @@ -139,8 +139,9 @@ enum node_type {  	VTY_NODE,		/* Vty node. */  	LINK_PARAMS_NODE,       /* Link-parameters node */  	BGP_EVPN_VNI_NODE,      /* BGP EVPN VNI */ -	RPKI_NODE,		/* RPKI node for configuration of RPKI cache server connections.*/ -	NODE_TYPE_MAX,		/* maximum */ +	RPKI_NODE,     /* RPKI node for configuration of RPKI cache server +			  connections.*/ +	NODE_TYPE_MAX, /* maximum */  };  extern vector cmdvec; diff --git a/lib/compiler.h b/lib/compiler.h index 49a2f2a422..773a52e742 100644 --- a/lib/compiler.h +++ b/lib/compiler.h @@ -21,25 +21,25 @@   *   void prototype(void) __attribute__((_CONSTRUCTOR(100)));   */  #if defined(__clang__) -# if __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 5) +#if __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 5)  #  define _RET_NONNULL    , returns_nonnull -# endif +#endif  # define _CONSTRUCTOR(x)  constructor(x)  #elif defined(__GNUC__) -# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9) +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)  #  define _RET_NONNULL    , returns_nonnull -# endif -# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +#endif +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)  #  define _CONSTRUCTOR(x) constructor(x)  #  define _DESTRUCTOR(x)  destructor(x)  #  define _ALLOC_SIZE(x)  alloc_size(x) -# endif +#endif  #endif  #ifdef __sun  /* Solaris doesn't do constructor priorities due to linker restrictions */ -# undef _CONSTRUCTOR -# undef _DESTRUCTOR +#undef _CONSTRUCTOR +#undef _DESTRUCTOR  #endif  /* fallback versions */ diff --git a/lib/ferr.c b/lib/ferr.c index 69aeb3db40..d315cf843c 100644 --- a/lib/ferr.c +++ b/lib/ferr.c @@ -63,8 +63,8 @@ ferr_r ferr_clear(void)  }  static ferr_r ferr_set_va(const char *file, int line, const char *func, -		enum ferr_kind kind, const char *pathname, int errno_val, -		const char *text, va_list va) +			  enum ferr_kind kind, const char *pathname, +			  int errno_val, const char *text, va_list va)  {  	struct ferr *error = pthread_getspecific(errkey); @@ -74,7 +74,8 @@ static ferr_r ferr_set_va(const char *file, int line, const char *func,  			/* we're screwed */  			zlog_err("out of memory while allocating error info");  			raise(SIGSEGV); -			abort(); /* raise() can return, but raise(SIGSEGV) shall not */ +			abort(); /* raise() can return, but raise(SIGSEGV) shall +				    not */  		}  		pthread_setspecific(errkey, error); @@ -86,12 +87,12 @@ static ferr_r ferr_set_va(const char *file, int line, const char *func,  	error->kind = kind;  	error->unique_id = jhash(text, strlen(text), -			jhash(file, strlen(file), 0xd4ed0298)); +				 jhash(file, strlen(file), 0xd4ed0298));  	error->errno_val = errno_val;  	if (pathname) -		snprintf(error->pathname, sizeof(error->pathname), -				"%s", pathname); +		snprintf(error->pathname, sizeof(error->pathname), "%s", +			 pathname);  	else  		error->pathname[0] = '\0'; @@ -100,7 +101,7 @@ static ferr_r ferr_set_va(const char *file, int line, const char *func,  }  ferr_r ferr_set_internal(const char *file, int line, const char *func, -		enum ferr_kind kind, const char *text, ...) +			 enum ferr_kind kind, const char *text, ...)  {  	ferr_r rv;  	va_list va; @@ -111,8 +112,8 @@ ferr_r ferr_set_internal(const char *file, int line, const char *func,  }  ferr_r ferr_set_internal_ext(const char *file, int line, const char *func, -		enum ferr_kind kind, const char *pathname, int errno_val, -		const char *text, ...) +			     enum ferr_kind kind, const char *pathname, +			     int errno_val, const char *text, ...)  {  	ferr_r rv;  	va_list va; @@ -139,10 +140,8 @@ void vty_print_error(struct vty *vty, ferr_r err, const char *msg, ...)  	else {  		replacepos[0] = '\0';  		replacepos += sizeof(REPLACE) - 1; -		vty_out(vty, "%s%s%s\n", -			tmpmsg, +		vty_out(vty, "%s%s%s\n", tmpmsg,  			last_error ? last_error->message : "(no error?)",  			replacepos);  	}  } - diff --git a/lib/ferr.h b/lib/ferr.h index 94a4de2f90..2f100c1b01 100644 --- a/lib/ferr.h +++ b/lib/ferr.h @@ -107,13 +107,12 @@ ferr_r ferr_clear(void);  /* do NOT call these functions directly.  only for macro use! */  ferr_r ferr_set_internal(const char *file, int line, const char *func, -		enum ferr_kind kind, const char *text, ...); +			 enum ferr_kind kind, const char *text, ...);  ferr_r ferr_set_internal_ext(const char *file, int line, const char *func, -		enum ferr_kind kind, const char *pathname, int errno_val, -		const char *text, ...); +			     enum ferr_kind kind, const char *pathname, +			     int errno_val, const char *text, ...); -#define ferr_ok() \ -	0 +#define ferr_ok() 0  /* Report an error.   * @@ -122,48 +121,49 @@ ferr_r ferr_set_internal_ext(const char *file, int line, const char *func,   *   * Don't put a \n at the end of the error message.   */ -#define ferr_code_bug(...) \ -	ferr_set_internal(__FILE__, __LINE__, __func__, FERR_CODE_BUG, \ -			__VA_ARGS__) -#define ferr_cfg_invalid(...) \ -	ferr_set_internal(__FILE__, __LINE__, __func__, FERR_CONFIG_INVALID, \ -			__VA_ARGS__) -#define ferr_cfg_reality(...) \ -	ferr_set_internal(__FILE__, __LINE__, __func__, FERR_CONFIG_REALITY, \ -			__VA_ARGS__) -#define ferr_cfg_resource(...) \ -	ferr_set_internal(__FILE__, __LINE__, __func__, FERR_RESOURCE, \ -			__VA_ARGS__) -#define ferr_system(...) \ -	ferr_set_internal(__FILE__, __LINE__, __func__, FERR_SYSTEM, \ -			__VA_ARGS__) -#define ferr_library(...) \ -	ferr_set_internal(__FILE__, __LINE__, __func__, FERR_LIBRARY, \ -			__VA_ARGS__) +#define ferr_code_bug(...)                                                     \ +	ferr_set_internal(__FILE__, __LINE__, __func__, FERR_CODE_BUG,         \ +			  __VA_ARGS__) +#define ferr_cfg_invalid(...)                                                  \ +	ferr_set_internal(__FILE__, __LINE__, __func__, FERR_CONFIG_INVALID,   \ +			  __VA_ARGS__) +#define ferr_cfg_reality(...)                                                  \ +	ferr_set_internal(__FILE__, __LINE__, __func__, FERR_CONFIG_REALITY,   \ +			  __VA_ARGS__) +#define ferr_cfg_resource(...)                                                 \ +	ferr_set_internal(__FILE__, __LINE__, __func__, FERR_RESOURCE,         \ +			  __VA_ARGS__) +#define ferr_system(...)                                                       \ +	ferr_set_internal(__FILE__, __LINE__, __func__, FERR_SYSTEM,           \ +			  __VA_ARGS__) +#define ferr_library(...)                                                      \ +	ferr_set_internal(__FILE__, __LINE__, __func__, FERR_LIBRARY,          \ +			  __VA_ARGS__)  /* extended information variants */ -#define ferr_system_errno(...) \ -	ferr_set_internal_ext(__FILE__, __LINE__, __func__, FERR_SYSTEM, \ -			NULL, errno, __VA_ARGS__) -#define ferr_system_path_errno(path, ...) \ -	ferr_set_internal_ext(__FILE__, __LINE__, __func__, FERR_SYSTEM, \ -			path, errno, __VA_ARGS__) +#define ferr_system_errno(...)                                                 \ +	ferr_set_internal_ext(__FILE__, __LINE__, __func__, FERR_SYSTEM, NULL, \ +			      errno, __VA_ARGS__) +#define ferr_system_path_errno(path, ...)                                      \ +	ferr_set_internal_ext(__FILE__, __LINE__, __func__, FERR_SYSTEM, path, \ +			      errno, __VA_ARGS__)  #include "vty.h"  /* print error message to vty;  $ERR is replaced by the error's message */  void vty_print_error(struct vty *vty, ferr_r err, const char *msg, ...); -#define CMD_FERR_DO(func, action, ...) \ -	do { ferr_r cmd_retval = func; \ -		if (cmd_retval) { \ -			vty_print_error(vty, cmd_retval, __VA_ARGS__); \ -			action; \ -		} \ +#define CMD_FERR_DO(func, action, ...)                                         \ +	do {                                                                   \ +		ferr_r cmd_retval = func;                                      \ +		if (cmd_retval) {                                              \ +			vty_print_error(vty, cmd_retval, __VA_ARGS__);         \ +			action;                                                \ +		}                                                              \  	} while (0) -#define CMD_FERR_RETURN(func, ...) \ +#define CMD_FERR_RETURN(func, ...)                                             \  	CMD_FERR_DO(func, return CMD_WARNING_CONFIG_FAILED, __VA_ARGS__) -#define CMD_FERR_GOTO(func, label, ...) \ +#define CMD_FERR_GOTO(func, label, ...)                                        \  	CMD_FERR_DO(func, goto label, __VA_ARGS__)  /* example: uses bogus #define to keep indent.py happy */ @@ -183,7 +183,7 @@ ferr_r foo_bar_set(struct object *obj, int bar)  DEFUN("bla")  {  	CMD_FERR_RETURN(foo_bar_set(obj, atoi(argv[1])), -		"command failed: $ERR\n"); +			"command failed: $ERR\n");  	return CMD_SUCCESS;  } diff --git a/lib/freebsd-queue.h b/lib/freebsd-queue.h index d198f5674f..4fcfe85a68 100644 --- a/lib/freebsd-queue.h +++ b/lib/freebsd-queue.h @@ -302,8 +302,7 @@ struct qm_trace {  	(STAILQ_EMPTY((head))                                                  \  		 ? NULL                                                        \  		 : ((struct type *)(void *)((char *)((head)->stqh_last)        \ -					    - offsetof(struct type,            \ -							 field)))) +					    - offsetof(struct type, field))))  #define	STAILQ_NEXT(elm, field)	((elm)->field.stqe_next) diff --git a/lib/grammar_sandbox.c b/lib/grammar_sandbox.c index 79c951dd69..41dd57b7f1 100644 --- a/lib/grammar_sandbox.c +++ b/lib/grammar_sandbox.c @@ -402,8 +402,8 @@ DEFUN (grammar_findambig,  			nodegraph = cnode->cmdgraph;  			if (!nodegraph)  				continue; -			vty_out(vty, "scanning node %d (%s)\n", -				scannode - 1, node_names[scannode - 1]); +			vty_out(vty, "scanning node %d (%s)\n", scannode - 1, +				node_names[scannode - 1]);  		}  		commands = cmd_graph_permutations(nodegraph); diff --git a/lib/hook.c b/lib/hook.c index 1468c4d329..935064f4d2 100644 --- a/lib/hook.c +++ b/lib/hook.c @@ -38,9 +38,8 @@ void _hook_register(struct hook *hook, void *funcptr, void *arg, bool has_arg,  	he->priority = priority;  	for (pos = &hook->entries; *pos; pos = &(*pos)->next) -		if (hook->reverse -		    ? (*pos)->priority < priority -		    : (*pos)->priority >= priority) +		if (hook->reverse ? (*pos)->priority < priority +				  : (*pos)->priority >= priority)  			break;  	he->next = *pos; diff --git a/lib/hook.h b/lib/hook.h index 5f45e113e7..ee496ab365 100644 --- a/lib/hook.h +++ b/lib/hook.h @@ -150,8 +150,8 @@ extern void _hook_register(struct hook *hook, void *funcptr, void *arg,  		       NULL, false, THIS_MODULE, #func, prio)  #define hook_register_arg_prio(hookname, prio, func, arg)                      \  	_hook_register(&_hook_##hookname,                                      \ -		       _hook_typecheck_arg_##hookname(func),                   \ -		       arg, true, THIS_MODULE, #func, prio) +		       _hook_typecheck_arg_##hookname(func), arg, true,        \ +		       THIS_MODULE, #func, prio)  extern void _hook_unregister(struct hook *hook, void *funcptr, void *arg,  			     bool has_arg); @@ -190,7 +190,7 @@ extern void _hook_unregister(struct hook *hook, void *funcptr, void *arg,  	{                                                                      \  		return (void *)funcptr;                                        \  	} -#define DECLARE_KOOH(hookname, arglist, passlist) \ +#define DECLARE_KOOH(hookname, arglist, passlist)                              \  	DECLARE_HOOK(hookname, arglist, passlist)  /* use in source file - contains hook-related definitions. @@ -220,9 +220,9 @@ extern void _hook_unregister(struct hook *hook, void *funcptr, void *arg,  		return hooksum;                                                \  	} -#define DEFINE_HOOK(hookname, arglist, passlist) \ +#define DEFINE_HOOK(hookname, arglist, passlist)                               \  	DEFINE_HOOK_INT(hookname, arglist, passlist, false) -#define DEFINE_KOOH(hookname, arglist, passlist) \ +#define DEFINE_KOOH(hookname, arglist, passlist)                               \  	DEFINE_HOOK_INT(hookname, arglist, passlist, true)  #endif /* _FRR_HOOK_H */ @@ -48,8 +48,8 @@ RB_GENERATE(if_index_head, interface, index_entry, if_cmp_index_func);  DEFINE_QOBJ_TYPE(interface) -DEFINE_HOOK(if_add, (struct interface *ifp), (ifp)) -DEFINE_KOOH(if_del, (struct interface *ifp), (ifp)) +DEFINE_HOOK(if_add, (struct interface * ifp), (ifp)) +DEFINE_KOOH(if_del, (struct interface * ifp), (ifp))  /* List of interfaces in only the default VRF */  int ptm_enable = 0; @@ -152,7 +152,7 @@ struct interface *if_create(const char *name, vrf_id_t vrf_id)  	SET_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION);  	QOBJ_REG(ifp, interface); -        hook_call(if_add, ifp); +	hook_call(if_add, ifp);  	return ifp;  } @@ -181,7 +181,7 @@ void if_update_to_new_vrf(struct interface *ifp, vrf_id_t vrf_id)  /* Delete interface structure. */  void if_delete_retain(struct interface *ifp)  { -        hook_call(if_del, ifp); +	hook_call(if_del, ifp);  	QOBJ_UNREG(ifp);  	/* Free connected address list */ @@ -225,7 +225,7 @@ struct interface *if_lookup_by_index(ifindex_t ifindex, vrf_id_t vrf_id)  	if (vrf_id == VRF_UNKNOWN) {  		struct interface *ifp; -		RB_FOREACH(vrf, vrf_id_head, &vrfs_by_id) { +		RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id) {  			ifp = if_lookup_by_index(ifindex, vrf->vrf_id);  			if (ifp)  				return ifp; @@ -404,8 +404,7 @@ struct interface *if_get_by_name(const char *name, vrf_id_t vrf_id, int vty)  	 * this should not be considered as an update  	 * then create the new interface  	 */ -	if (ifp->vrf_id != vrf_id && -	    vrf_is_mapped_on_netns(vrf_id)) +	if (ifp->vrf_id != vrf_id && vrf_is_mapped_on_netns(vrf_id))  		return if_create(name, vrf_id);  	/* If it came from the kernel  	 * or by way of zclient, believe it and update @@ -337,8 +337,8 @@ DECLARE_QOBJ_TYPE(interface)   * can use 1000+ so they run after the daemon has initialised daemon-specific   * interface data   */ -DECLARE_HOOK(if_add, (struct interface *ifp), (ifp)) -DECLARE_KOOH(if_del, (struct interface *ifp), (ifp)) +DECLARE_HOOK(if_add, (struct interface * ifp), (ifp)) +DECLARE_KOOH(if_del, (struct interface * ifp), (ifp))  /* Connected address structure. */  struct connected { @@ -460,7 +460,7 @@ extern int if_cmp_name_func(char *, char *);   * else think before you use VRF_UNKNOWN   */  extern void if_update_to_new_vrf(struct interface *, vrf_id_t vrf_id); -extern struct interface *if_create(const char *name,  vrf_id_t vrf_id); +extern struct interface *if_create(const char *name, vrf_id_t vrf_id);  extern struct interface *if_lookup_by_index(ifindex_t, vrf_id_t vrf_id);  extern struct interface *if_lookup_exact_address(void *matchaddr, int family,  						 vrf_id_t vrf_id); diff --git a/lib/if_rmap.c b/lib/if_rmap.c index 53c2824a99..2c686ecb85 100644 --- a/lib/if_rmap.c +++ b/lib/if_rmap.c @@ -294,9 +294,7 @@ void if_rmap_reset()  void if_rmap_init(int node)  { -	ifrmaphash = hash_create_size(4, -				      if_rmap_hash_make, -				      if_rmap_hash_cmp, +	ifrmaphash = hash_create_size(4, if_rmap_hash_make, if_rmap_hash_cmp,  				      "Interface Route-Map Hash");  	if (node == RIPNG_NODE) {  	} else if (node == RIP_NODE) { diff --git a/lib/imsg-buffer.c b/lib/imsg-buffer.c index ae660504e4..ba1e26820b 100644 --- a/lib/imsg-buffer.c +++ b/lib/imsg-buffer.c @@ -21,14 +21,13 @@  #include "queue.h"  #include "imsg.h" -int	ibuf_realloc(struct ibuf *, size_t); -void	ibuf_enqueue(struct msgbuf *, struct ibuf *); -void	ibuf_dequeue(struct msgbuf *, struct ibuf *); +int ibuf_realloc(struct ibuf *, size_t); +void ibuf_enqueue(struct msgbuf *, struct ibuf *); +void ibuf_dequeue(struct msgbuf *, struct ibuf *); -struct ibuf * -ibuf_open(size_t len) +struct ibuf *ibuf_open(size_t len)  { -	struct ibuf	*buf; +	struct ibuf *buf;  	if ((buf = calloc(1, sizeof(struct ibuf))) == NULL)  		return (NULL); @@ -42,10 +41,9 @@ ibuf_open(size_t len)  	return (buf);  } -struct ibuf * -ibuf_dynamic(size_t len, size_t max) +struct ibuf *ibuf_dynamic(size_t len, size_t max)  { -	struct ibuf	*buf; +	struct ibuf *buf;  	if (max < len)  		return (NULL); @@ -59,10 +57,9 @@ ibuf_dynamic(size_t len, size_t max)  	return (buf);  } -int -ibuf_realloc(struct ibuf *buf, size_t len) +int ibuf_realloc(struct ibuf *buf, size_t len)  { -	u_char	*b; +	u_char *b;  	/* on static buffers max is eq size and so the following fails */  	if (buf->wpos + len > buf->max) { @@ -79,8 +76,7 @@ ibuf_realloc(struct ibuf *buf, size_t len)  	return (0);  } -int -ibuf_add(struct ibuf *buf, const void *data, size_t len) +int ibuf_add(struct ibuf *buf, const void *data, size_t len)  {  	if (buf->wpos + len > buf->size)  		if (ibuf_realloc(buf, len) == -1) @@ -91,10 +87,9 @@ ibuf_add(struct ibuf *buf, const void *data, size_t len)  	return (0);  } -void * -ibuf_reserve(struct ibuf *buf, size_t len) +void *ibuf_reserve(struct ibuf *buf, size_t len)  { -	void	*b; +	void *b;  	if (buf->wpos + len > buf->size)  		if (ibuf_realloc(buf, len) == -1) @@ -105,8 +100,7 @@ ibuf_reserve(struct ibuf *buf, size_t len)  	return (b);  } -void * -ibuf_seek(struct ibuf *buf, size_t pos, size_t len) +void *ibuf_seek(struct ibuf *buf, size_t pos, size_t len)  {  	/* only allowed to seek in already written parts */  	if (pos + len > buf->wpos) @@ -115,34 +109,30 @@ ibuf_seek(struct ibuf *buf, size_t pos, size_t len)  	return (buf->buf + pos);  } -size_t -ibuf_size(struct ibuf *buf) +size_t ibuf_size(struct ibuf *buf)  {  	return (buf->wpos);  } -size_t -ibuf_left(struct ibuf *buf) +size_t ibuf_left(struct ibuf *buf)  {  	return (buf->max - buf->wpos);  } -void -ibuf_close(struct msgbuf *msgbuf, struct ibuf *buf) +void ibuf_close(struct msgbuf *msgbuf, struct ibuf *buf)  {  	ibuf_enqueue(msgbuf, buf);  } -int -ibuf_write(struct msgbuf *msgbuf) +int ibuf_write(struct msgbuf *msgbuf)  { -	struct iovec	 iov[IOV_MAX]; -	struct ibuf	*buf; -	unsigned int	 i = 0; -	ssize_t	n; +	struct iovec iov[IOV_MAX]; +	struct ibuf *buf; +	unsigned int i = 0; +	ssize_t n;  	memset(&iov, 0, sizeof(iov)); -	TAILQ_FOREACH(buf, &msgbuf->bufs, entry) { +	TAILQ_FOREACH (buf, &msgbuf->bufs, entry) {  		if (i >= IOV_MAX)  			break;  		iov[i].iov_base = buf->buf + buf->rpos; @@ -159,7 +149,7 @@ again:  		return (-1);  	} -	if (n == 0) {			/* connection closed */ +	if (n == 0) { /* connection closed */  		errno = 0;  		return (0);  	} @@ -169,8 +159,7 @@ again:  	return (1);  } -void -ibuf_free(struct ibuf *buf) +void ibuf_free(struct ibuf *buf)  {  	if (buf == NULL)  		return; @@ -178,21 +167,19 @@ ibuf_free(struct ibuf *buf)  	free(buf);  } -void -msgbuf_init(struct msgbuf *msgbuf) +void msgbuf_init(struct msgbuf *msgbuf)  {  	msgbuf->queued = 0;  	msgbuf->fd = -1;  	TAILQ_INIT(&msgbuf->bufs);  } -void -msgbuf_drain(struct msgbuf *msgbuf, size_t n) +void msgbuf_drain(struct msgbuf *msgbuf, size_t n)  { -	struct ibuf	*buf, *next; +	struct ibuf *buf, *next;  	for (buf = TAILQ_FIRST(&msgbuf->bufs); buf != NULL && n > 0; -	    buf = next) { +	     buf = next) {  		next = TAILQ_NEXT(buf, entry);  		if (buf->rpos + n >= buf->wpos) {  			n -= buf->wpos - buf->rpos; @@ -204,33 +191,31 @@ msgbuf_drain(struct msgbuf *msgbuf, size_t n)  	}  } -void -msgbuf_clear(struct msgbuf *msgbuf) +void msgbuf_clear(struct msgbuf *msgbuf)  { -	struct ibuf	*buf; +	struct ibuf *buf;  	while ((buf = TAILQ_FIRST(&msgbuf->bufs)) != NULL)  		ibuf_dequeue(msgbuf, buf);  } -int -msgbuf_write(struct msgbuf *msgbuf) +int msgbuf_write(struct msgbuf *msgbuf)  { -	struct iovec	 iov[IOV_MAX]; -	struct ibuf	*buf; -	unsigned int	 i = 0; -	ssize_t		 n; -	struct msghdr	 msg; -	struct cmsghdr	*cmsg; +	struct iovec iov[IOV_MAX]; +	struct ibuf *buf; +	unsigned int i = 0; +	ssize_t n; +	struct msghdr msg; +	struct cmsghdr *cmsg;  	union { -		struct cmsghdr	hdr; -		char		buf[CMSG_SPACE(sizeof(int))]; +		struct cmsghdr hdr; +		char buf[CMSG_SPACE(sizeof(int))];  	} cmsgbuf;  	memset(&iov, 0, sizeof(iov));  	memset(&msg, 0, sizeof(msg));  	memset(&cmsgbuf, 0, sizeof(cmsgbuf)); -	TAILQ_FOREACH(buf, &msgbuf->bufs, entry) { +	TAILQ_FOREACH (buf, &msgbuf->bufs, entry) {  		if (i >= IOV_MAX)  			break;  		iov[i].iov_base = buf->buf + buf->rpos; @@ -262,7 +247,7 @@ again:  		return (-1);  	} -	if (n == 0) {			/* connection closed */ +	if (n == 0) { /* connection closed */  		errno = 0;  		return (0);  	} @@ -281,15 +266,13 @@ again:  	return (1);  } -void -ibuf_enqueue(struct msgbuf *msgbuf, struct ibuf *buf) +void ibuf_enqueue(struct msgbuf *msgbuf, struct ibuf *buf)  {  	TAILQ_INSERT_TAIL(&msgbuf->bufs, buf, entry);  	msgbuf->queued++;  } -void -ibuf_dequeue(struct msgbuf *msgbuf, struct ibuf *buf) +void ibuf_dequeue(struct msgbuf *msgbuf, struct ibuf *buf)  {  	TAILQ_REMOVE(&msgbuf->bufs, buf, entry); diff --git a/lib/imsg.c b/lib/imsg.c index 999ab679b8..1c2f480aab 100644 --- a/lib/imsg.c +++ b/lib/imsg.c @@ -21,22 +21,21 @@  #include "queue.h"  #include "imsg.h" -int	 imsg_fd_overhead = 0; +int imsg_fd_overhead = 0; -int	 imsg_get_fd(struct imsgbuf *); +int imsg_get_fd(struct imsgbuf *);  #ifndef __OpenBSD__  /*   * The original code calls getdtablecount() which is OpenBSD specific. Use   * available_fds() from OpenSMTPD instead.   */ -static int -available_fds(unsigned int n) +static int available_fds(unsigned int n)  { -	unsigned int	i; -	int		ret, fds[256]; +	unsigned int i; +	int ret, fds[256]; -	if (n > (sizeof(fds)/sizeof(fds[0]))) +	if (n > (sizeof(fds) / sizeof(fds[0])))  		return (1);  	ret = 0; @@ -59,8 +58,7 @@ available_fds(unsigned int n)  }  #endif -void -imsg_init(struct imsgbuf *ibuf, int fd) +void imsg_init(struct imsgbuf *ibuf, int fd)  {  	msgbuf_init(&ibuf->w);  	memset(&ibuf->r, 0, sizeof(ibuf->r)); @@ -70,19 +68,18 @@ imsg_init(struct imsgbuf *ibuf, int fd)  	TAILQ_INIT(&ibuf->fds);  } -ssize_t -imsg_read(struct imsgbuf *ibuf) +ssize_t imsg_read(struct imsgbuf *ibuf)  { -	struct msghdr		 msg; -	struct cmsghdr		*cmsg; +	struct msghdr msg; +	struct cmsghdr *cmsg;  	union {  		struct cmsghdr hdr; -		char	buf[CMSG_SPACE(sizeof(int) * 1)]; +		char buf[CMSG_SPACE(sizeof(int) * 1)];  	} cmsgbuf; -	struct iovec		 iov; -	ssize_t			 n = -1; -	int			 fd; -	struct imsg_fd		*ifd; +	struct iovec iov; +	ssize_t n = -1; +	int fd; +	struct imsg_fd *ifd;  	memset(&msg, 0, sizeof(msg));  	memset(&cmsgbuf, 0, sizeof(cmsgbuf)); @@ -99,12 +96,14 @@ imsg_read(struct imsgbuf *ibuf)  again:  #ifdef __OpenBSD__ -	if (getdtablecount() + imsg_fd_overhead + -	    (int)((CMSG_SPACE(sizeof(int))-CMSG_SPACE(0))/sizeof(int)) +	if (getdtablecount() + imsg_fd_overhead +		    + (int)((CMSG_SPACE(sizeof(int)) - CMSG_SPACE(0)) +			    / sizeof(int))  	    >= getdtablesize()) {  #else -	if (available_fds(imsg_fd_overhead + -	    (CMSG_SPACE(sizeof(int))-CMSG_SPACE(0))/sizeof(int))) { +	if (available_fds(imsg_fd_overhead +			  + (CMSG_SPACE(sizeof(int)) - CMSG_SPACE(0)) +				    / sizeof(int))) {  #endif  		errno = EAGAIN;  		free(ifd); @@ -120,9 +119,9 @@ again:  	ibuf->r.wpos += n;  	for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; -	    cmsg = CMSG_NXTHDR(&msg, cmsg)) { -		if (cmsg->cmsg_level == SOL_SOCKET && -		    cmsg->cmsg_type == SCM_RIGHTS) { +	     cmsg = CMSG_NXTHDR(&msg, cmsg)) { +		if (cmsg->cmsg_level == SOL_SOCKET +		    && cmsg->cmsg_type == SCM_RIGHTS) {  			int i;  			int j; @@ -131,14 +130,15 @@ again:  			 * padding rules, our control buffer might contain  			 * more than one fd, and we must close them.  			 */ -			j = ((char *)cmsg + cmsg->cmsg_len - -			    (char *)CMSG_DATA(cmsg)) / sizeof(int); +			j = ((char *)cmsg + cmsg->cmsg_len +			     - (char *)CMSG_DATA(cmsg)) +			    / sizeof(int);  			for (i = 0; i < j; i++) {  				fd = ((int *)CMSG_DATA(cmsg))[i];  				if (ifd != NULL) {  					ifd->fd = fd;  					TAILQ_INSERT_TAIL(&ibuf->fds, ifd, -					    entry); +							  entry);  					ifd = NULL;  				} else  					close(fd); @@ -152,10 +152,9 @@ fail:  	return (n);  } -ssize_t -imsg_get(struct imsgbuf *ibuf, struct imsg *imsg) +ssize_t imsg_get(struct imsgbuf *ibuf, struct imsg *imsg)  { -	size_t			 av, left, datalen; +	size_t av, left, datalen;  	av = ibuf->r.wpos; @@ -163,8 +162,7 @@ imsg_get(struct imsgbuf *ibuf, struct imsg *imsg)  		return (0);  	memcpy(&imsg->hdr, ibuf->r.buf, sizeof(imsg->hdr)); -	if (imsg->hdr.len < IMSG_HEADER_SIZE || -	    imsg->hdr.len > MAX_IMSGSIZE) { +	if (imsg->hdr.len < IMSG_HEADER_SIZE || imsg->hdr.len > MAX_IMSGSIZE) {  		errno = ERANGE;  		return (-1);  	} @@ -183,7 +181,7 @@ imsg_get(struct imsgbuf *ibuf, struct imsg *imsg)  		imsg->fd = -1;  	if (imsg->data) -	  memcpy(imsg->data, ibuf->r.rptr, datalen); +		memcpy(imsg->data, ibuf->r.rptr, datalen);  	if (imsg->hdr.len < av) {  		left = av - imsg->hdr.len; @@ -195,11 +193,10 @@ imsg_get(struct imsgbuf *ibuf, struct imsg *imsg)  	return (datalen + IMSG_HEADER_SIZE);  } -int -imsg_compose(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid, -    pid_t pid, int fd, const void *data, u_int16_t datalen) +int imsg_compose(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid, +		 pid_t pid, int fd, const void *data, u_int16_t datalen)  { -	struct ibuf	*wbuf; +	struct ibuf *wbuf;  	if ((wbuf = imsg_create(ibuf, type, peerid, pid, datalen)) == NULL)  		return (-1); @@ -214,12 +211,11 @@ imsg_compose(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,  	return (1);  } -int -imsg_composev(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid, -    pid_t pid, int fd, const struct iovec *iov, int iovcnt) +int imsg_composev(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid, +		  pid_t pid, int fd, const struct iovec *iov, int iovcnt)  { -	struct ibuf	*wbuf; -	int		 i, datalen = 0; +	struct ibuf *wbuf; +	int i, datalen = 0;  	for (i = 0; i < iovcnt; i++)  		datalen += iov[i].iov_len; @@ -239,12 +235,11 @@ imsg_composev(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,  }  /* ARGSUSED */ -struct ibuf * -imsg_create(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid, -    pid_t pid, u_int16_t datalen) +struct ibuf *imsg_create(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid, +			 pid_t pid, u_int16_t datalen)  { -	struct ibuf	*wbuf; -	struct imsg_hdr	 hdr; +	struct ibuf *wbuf; +	struct imsg_hdr hdr;  	datalen += IMSG_HEADER_SIZE;  	if (datalen > MAX_IMSGSIZE) { @@ -266,8 +261,7 @@ imsg_create(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,  	return (wbuf);  } -int -imsg_add(struct ibuf *msg, const void *data, u_int16_t datalen) +int imsg_add(struct ibuf *msg, const void *data, u_int16_t datalen)  {  	if (datalen)  		if (ibuf_add(msg, data, datalen) == -1) { @@ -277,10 +271,9 @@ imsg_add(struct ibuf *msg, const void *data, u_int16_t datalen)  	return (datalen);  } -void -imsg_close(struct imsgbuf *ibuf, struct ibuf *msg) +void imsg_close(struct imsgbuf *ibuf, struct ibuf *msg)  { -	struct imsg_hdr	*hdr; +	struct imsg_hdr *hdr;  	hdr = (struct imsg_hdr *)msg->buf; @@ -293,17 +286,15 @@ imsg_close(struct imsgbuf *ibuf, struct ibuf *msg)  	ibuf_close(&ibuf->w, msg);  } -void -imsg_free(struct imsg *imsg) +void imsg_free(struct imsg *imsg)  {  	free(imsg->data);  } -int -imsg_get_fd(struct imsgbuf *ibuf) +int imsg_get_fd(struct imsgbuf *ibuf)  { -	int		 fd; -	struct imsg_fd	*ifd; +	int fd; +	struct imsg_fd *ifd;  	if ((ifd = TAILQ_FIRST(&ibuf->fds)) == NULL)  		return (-1); @@ -315,8 +306,7 @@ imsg_get_fd(struct imsgbuf *ibuf)  	return (fd);  } -int -imsg_flush(struct imsgbuf *ibuf) +int imsg_flush(struct imsgbuf *ibuf)  {  	while (ibuf->w.queued)  		if (msgbuf_write(&ibuf->w) <= 0) @@ -324,10 +314,9 @@ imsg_flush(struct imsgbuf *ibuf)  	return (0);  } -void -imsg_clear(struct imsgbuf *ibuf) +void imsg_clear(struct imsgbuf *ibuf)  { -	int	fd; +	int fd;  	msgbuf_clear(&ibuf->w);  	while ((fd = imsg_get_fd(ibuf)) != -1) diff --git a/lib/imsg.h b/lib/imsg.h index d053d01956..ddaf71344e 100644 --- a/lib/imsg.h +++ b/lib/imsg.h @@ -26,87 +26,87 @@  #define MAX_IMSGSIZE		16384  struct ibuf { -	TAILQ_ENTRY(ibuf)	 entry; -	u_char			*buf; -	size_t			 size; -	size_t			 max; -	size_t			 wpos; -	size_t			 rpos; -	int			 fd; +	TAILQ_ENTRY(ibuf) entry; +	u_char *buf; +	size_t size; +	size_t max; +	size_t wpos; +	size_t rpos; +	int fd;  };  struct msgbuf { -	TAILQ_HEAD(, ibuf)	 bufs; -	u_int32_t		 queued; -	int			 fd; +	TAILQ_HEAD(, ibuf) bufs; +	u_int32_t queued; +	int fd;  };  struct ibuf_read { -	u_char			 buf[IBUF_READ_SIZE]; -	u_char			*rptr; -	size_t			 wpos; +	u_char buf[IBUF_READ_SIZE]; +	u_char *rptr; +	size_t wpos;  };  struct imsg_fd { -	TAILQ_ENTRY(imsg_fd)	entry; -	int			fd; +	TAILQ_ENTRY(imsg_fd) entry; +	int fd;  };  struct imsgbuf { -	TAILQ_HEAD(, imsg_fd)	 fds; -	struct ibuf_read	 r; -	struct msgbuf		 w; -	int			 fd; -	pid_t			 pid; +	TAILQ_HEAD(, imsg_fd) fds; +	struct ibuf_read r; +	struct msgbuf w; +	int fd; +	pid_t pid;  };  #define IMSGF_HASFD	1  struct imsg_hdr { -	u_int32_t	 type; -	u_int16_t	 len; -	u_int16_t	 flags; -	u_int32_t	 peerid; -	u_int32_t	 pid; +	u_int32_t type; +	u_int16_t len; +	u_int16_t flags; +	u_int32_t peerid; +	u_int32_t pid;  };  struct imsg { -	struct imsg_hdr	 hdr; -	int		 fd; -	void		*data; +	struct imsg_hdr hdr; +	int fd; +	void *data;  };  /* buffer.c */ -struct ibuf	*ibuf_open(size_t); -struct ibuf	*ibuf_dynamic(size_t, size_t); -int		 ibuf_add(struct ibuf *, const void *, size_t); -void		*ibuf_reserve(struct ibuf *, size_t); -void		*ibuf_seek(struct ibuf *, size_t, size_t); -size_t		 ibuf_size(struct ibuf *); -size_t		 ibuf_left(struct ibuf *); -void		 ibuf_close(struct msgbuf *, struct ibuf *); -int		 ibuf_write(struct msgbuf *); -void		 ibuf_free(struct ibuf *); -void		 msgbuf_init(struct msgbuf *); -void		 msgbuf_clear(struct msgbuf *); -int		 msgbuf_write(struct msgbuf *); -void		 msgbuf_drain(struct msgbuf *, size_t); +struct ibuf *ibuf_open(size_t); +struct ibuf *ibuf_dynamic(size_t, size_t); +int ibuf_add(struct ibuf *, const void *, size_t); +void *ibuf_reserve(struct ibuf *, size_t); +void *ibuf_seek(struct ibuf *, size_t, size_t); +size_t ibuf_size(struct ibuf *); +size_t ibuf_left(struct ibuf *); +void ibuf_close(struct msgbuf *, struct ibuf *); +int ibuf_write(struct msgbuf *); +void ibuf_free(struct ibuf *); +void msgbuf_init(struct msgbuf *); +void msgbuf_clear(struct msgbuf *); +int msgbuf_write(struct msgbuf *); +void msgbuf_drain(struct msgbuf *, size_t);  /* imsg.c */ -void	 imsg_init(struct imsgbuf *, int); -ssize_t	 imsg_read(struct imsgbuf *); -ssize_t	 imsg_get(struct imsgbuf *, struct imsg *); -int	 imsg_compose(struct imsgbuf *, u_int32_t, u_int32_t, pid_t, -	    int, const void *, u_int16_t); -int	 imsg_composev(struct imsgbuf *, u_int32_t, u_int32_t,  pid_t, -	    int, const struct iovec *, int); +void imsg_init(struct imsgbuf *, int); +ssize_t imsg_read(struct imsgbuf *); +ssize_t imsg_get(struct imsgbuf *, struct imsg *); +int imsg_compose(struct imsgbuf *, u_int32_t, u_int32_t, pid_t, int, +		 const void *, u_int16_t); +int imsg_composev(struct imsgbuf *, u_int32_t, u_int32_t, pid_t, int, +		  const struct iovec *, int);  struct ibuf *imsg_create(struct imsgbuf *, u_int32_t, u_int32_t, pid_t, -	    u_int16_t); -int	 imsg_add(struct ibuf *, const void *, u_int16_t); -void	 imsg_close(struct imsgbuf *, struct ibuf *); -void	 imsg_free(struct imsg *); -int	 imsg_flush(struct imsgbuf *); -void	 imsg_clear(struct imsgbuf *); +			 u_int16_t); +int imsg_add(struct ibuf *, const void *, u_int16_t); +void imsg_close(struct imsgbuf *, struct ibuf *); +void imsg_free(struct imsg *); +int imsg_flush(struct imsgbuf *); +void imsg_clear(struct imsgbuf *);  #endif diff --git a/lib/keychain.c b/lib/keychain.c index d9a09a3e41..39807cc7ce 100644 --- a/lib/keychain.c +++ b/lib/keychain.c @@ -1083,8 +1083,7 @@ void keychain_init()  			&accept_lifetime_duration_day_month_cmd);  	install_element(KEYCHAIN_KEY_NODE,  			&accept_lifetime_duration_month_day_cmd); -	install_element(KEYCHAIN_KEY_NODE, -			&no_accept_lifetime_cmd); +	install_element(KEYCHAIN_KEY_NODE, &no_accept_lifetime_cmd);  	install_element(KEYCHAIN_KEY_NODE,  			&send_lifetime_day_month_day_month_cmd); @@ -1102,6 +1101,5 @@ void keychain_init()  			&send_lifetime_duration_day_month_cmd);  	install_element(KEYCHAIN_KEY_NODE,  			&send_lifetime_duration_month_day_cmd); -	install_element(KEYCHAIN_KEY_NODE, -			&no_send_lifetime_cmd); +	install_element(KEYCHAIN_KEY_NODE, &no_send_lifetime_cmd);  } diff --git a/lib/libfrr.c b/lib/libfrr.c index 6cb8711edf..8d4a3ff8df 100644 --- a/lib/libfrr.c +++ b/lib/libfrr.c @@ -168,7 +168,7 @@ bool frr_zclient_addr(struct sockaddr_storage *sa, socklen_t *sa_len,  			break;  		case '6':  			path++; -			/* fallthrough */ +		/* fallthrough */  		default:  			af = AF_INET6;  			break; @@ -629,7 +629,7 @@ static void frr_daemon_wait(int fd)  		rcvd_signal = 0; -#if   defined(HAVE_PPOLL) +#if defined(HAVE_PPOLL)  		ret = ppoll(pfd, 1, NULL, &prevsigs);  #elif defined(HAVE_POLLTS)  		ret = pollts(pfd, 1, NULL, &prevsigs); @@ -811,18 +811,18 @@ static int frr_daemon_ctl(struct thread *t)  		return 0;  	switch (buf[0]) { -	case 'S':	/* SIGTSTP */ +	case 'S': /* SIGTSTP */  		vty_stdio_suspend();  		send(daemon_ctl_sock, "s", 1, 0);  		break; -	case 'R':	/* SIGTCNT [implicit] */ +	case 'R': /* SIGTCNT [implicit] */  		vty_stdio_resume();  		break; -	case 'I':	/* SIGINT */ +	case 'I': /* SIGINT */  		di->daemon_mode = false;  		raise(SIGINT);  		break; -	case 'Q':	/* SIGQUIT */ +	case 'Q': /* SIGQUIT */  		di->daemon_mode = true;  		vty_stdio_close();  		break; @@ -914,10 +914,8 @@ void frr_fini(void)  	if (!have_leftovers)  		return; -	snprintf(filename, sizeof(filename), -		 "/tmp/frr-memstats-%s-%llu-%llu", -		 di->name, -		 (unsigned long long)getpid(), +	snprintf(filename, sizeof(filename), "/tmp/frr-memstats-%s-%llu-%llu", +		 di->name, (unsigned long long)getpid(),  		 (unsigned long long)time(NULL));  	fp = fopen(filename, "w"); diff --git a/lib/linklist.h b/lib/linklist.h index 8a43fbe64b..46617b5f65 100644 --- a/lib/linklist.h +++ b/lib/linklist.h @@ -89,10 +89,12 @@ CPP_NOTICE("list_delete without double pointer is deprecated, please fixup")  #endif  extern void list_delete_and_null(struct list **);  extern void list_delete_original(struct list *); -#define list_delete(X) list_delete_original((X))			\ -	CPP_WARN("Please transition to using list_delete_and_null") -#define list_free(X) list_delete_original((X))				\ -	CPP_WARN("Please transition tousing list_delete_and_null") +#define list_delete(X)                                                         \ +	list_delete_original((X))                                              \ +		CPP_WARN("Please transition to using list_delete_and_null") +#define list_free(X)                                                           \ +	list_delete_original((X))                                              \ +		CPP_WARN("Please transition tousing list_delete_and_null")  extern void list_delete_all_node(struct list *); @@ -177,9 +177,8 @@ static void time_print(FILE *fp, struct timestamp_control *ctl)  static void vzlog_file(struct zlog *zl, struct timestamp_control *tsctl, -		       const char *proto_str, int record_priority, -		       int priority, FILE *fp, const char *format, -		       va_list args) +		       const char *proto_str, int record_priority, int priority, +		       FILE *fp, const char *format, va_list args)  {  	va_list ac; @@ -237,8 +236,8 @@ void vzlog(int priority, const char *format, va_list args)  	/* File output. */  	if ((priority <= zl->maxlvl[ZLOG_DEST_FILE]) && zl->fp) -		vzlog_file(zl, &tsctl, proto_str, zl->record_priority, -				priority, zl->fp, format, args); +		vzlog_file(zl, &tsctl, proto_str, zl->record_priority, priority, +			   zl->fp, format, args);  	/* fixed-config logging to stderr while we're stating up & haven't  	 * daemonized / reached mainloop yet @@ -246,11 +245,11 @@ void vzlog(int priority, const char *format, va_list args)  	 * note the "else" on stdout output -- we don't want to print the same  	 * message to both stderr and stdout. */  	if (zlog_startup_stderr && priority <= LOG_WARNING) -		vzlog_file(zl, &tsctl, proto_str, 1, -				priority, stderr, format, args); +		vzlog_file(zl, &tsctl, proto_str, 1, priority, stderr, format, +			   args);  	else if (priority <= zl->maxlvl[ZLOG_DEST_STDOUT]) -		vzlog_file(zl, &tsctl, proto_str, zl->record_priority, -				priority, stdout, format, args); +		vzlog_file(zl, &tsctl, proto_str, zl->record_priority, priority, +			   stdout, format, args);  	/* Terminal monitor. */  	if (priority <= zl->maxlvl[ZLOG_DEST_MONITOR]) @@ -1114,10 +1113,9 @@ void zlog_hexdump(const void *mem, unsigned int len)  						 printing */  					s += sprintf(s, " "); -				else if ( -					isprint((int)((const char *)mem) -							[j])) /* printable char -								 */ +				else if (isprint((int)((const char *)mem) +							 [j])) /* printable char +								  */  					s += sprintf(  						s, "%c",  						0xFF & ((const char *)mem)[j]); diff --git a/lib/logicalrouter.c b/lib/logicalrouter.c index 4dc99d304f..da69ae5312 100644 --- a/lib/logicalrouter.c +++ b/lib/logicalrouter.c @@ -35,8 +35,7 @@  DEFINE_MTYPE_STATIC(LIB, LOGICALROUTER_NAME, "Logical Router Name")  /* Logical Router node has no interface. */ -static struct cmd_node logicalrouter_node = {LOGICALROUTER_NODE, "", -					     1}; +static struct cmd_node logicalrouter_node = {LOGICALROUTER_NODE, "", 1};  static int logicalrouter_backend; diff --git a/lib/memory.c b/lib/memory.c index c684c7605c..90d7d420a9 100644 --- a/lib/memory.c +++ b/lib/memory.c @@ -132,7 +132,7 @@ static int qmem_exit_walker(void *arg, struct memgroup *mg, struct memtype *mt)  int log_memstats(FILE *fp, const char *prefix)  { -	struct exit_dump_args eda = { .fp = fp, .prefix = prefix, .error = 0 }; +	struct exit_dump_args eda = {.fp = fp, .prefix = prefix, .error = 0};  	qmem_walk(qmem_exit_walker, &eda);  	return eda.error;  } diff --git a/lib/module.c b/lib/module.c index b3ab91c4ea..3f13307d82 100644 --- a/lib/module.c +++ b/lib/module.c @@ -42,10 +42,11 @@ static struct frrmod_info frrmod_default_info = {  	.description = "libfrr core module",  };  union _frrmod_runtime_u frrmod_default = { -	.r = { -		.info = &frrmod_default_info, -		.finished_loading = 1, -	}, +	.r = +		{ +			.info = &frrmod_default_info, +			.finished_loading = 1, +		},  };  // if defined(HAVE_SYS_WEAK_ALIAS_ATTRIBUTE) diff --git a/lib/netns_linux.c b/lib/netns_linux.c index 0e955bade9..eddd801127 100644 --- a/lib/netns_linux.c +++ b/lib/netns_linux.c @@ -173,7 +173,7 @@ static struct ns *ns_get_created_internal(struct ns *ns, char *name,  			zlog_info("NS %s is created.", ns->name);  	}  	if (ns_master.ns_new_hook) -		(*ns_master.ns_new_hook) (ns); +		(*ns_master.ns_new_hook)(ns);  	return ns;  } @@ -247,8 +247,7 @@ static void ns_disable_internal(struct ns *ns)  {  	if (ns_is_enabled(ns)) {  		if (ns_debug) -			zlog_info("NS %u is to be disabled.", -				  ns->ns_id); +			zlog_info("NS %u is to be disabled.", ns->ns_id);  		if (ns_master.ns_disable_hook)  			(*ns_master.ns_disable_hook)(ns); @@ -295,8 +294,7 @@ void ns_delete(struct ns *ns)  }  /* Look up the data pointer of the specified VRF. */ -void * -ns_info_lookup(ns_id_t ns_id) +void *ns_info_lookup(ns_id_t ns_id)  {  	struct ns *ns = ns_lookup_internal(ns_id); @@ -385,18 +383,17 @@ char *ns_netns_pathname(struct vty *vty, const char *name)  			vty_out(vty, "Invalid pathname: %s\n",  				safe_strerror(errno));  		else -			zlog_warn("Invalid pathname: %s", -				  safe_strerror(errno)); +			zlog_warn("Invalid pathname: %s", safe_strerror(errno));  		return NULL;  	}  	check_base = basename(pathname);  	if (check_base != NULL && strlen(check_base) + 1 > NS_NAMSIZ) {  		if (vty)  			vty_out(vty, "NS name (%s) invalid: too long (>%d)\n", -				check_base, NS_NAMSIZ-1); +				check_base, NS_NAMSIZ - 1);  		else  			zlog_warn("NS name (%s) invalid: too long (>%d)", -				  check_base, NS_NAMSIZ-1); +				  check_base, NS_NAMSIZ - 1);  		return NULL;  	}  	return pathname; @@ -435,8 +432,7 @@ void ns_init_management(ns_id_t default_ns_id)  	ns_init();  	default_ns = ns_get_created_internal(NULL, NULL, default_ns_id);  	if (!default_ns) { -		zlog_err("%s: failed to create the default NS!", -			 __func__); +		zlog_err("%s: failed to create the default NS!", __func__);  		exit(1);  	}  	if (have_netns()) { @@ -446,13 +442,12 @@ void ns_init_management(ns_id_t default_ns_id)  	/* Set the default NS name. */  	default_ns->name = XSTRDUP(MTYPE_NS_NAME, NS_DEFAULT_NAME);  	if (ns_debug) -		zlog_info("%s: default NSID is %u", -			  __func__, default_ns->ns_id); +		zlog_info("%s: default NSID is %u", __func__, +			  default_ns->ns_id);  	/* Enable the default NS. */  	if (!ns_enable(default_ns, NULL)) { -		zlog_err("%s: failed to enable the default NS!", -			 __func__); +		zlog_err("%s: failed to enable the default NS!", __func__);  		exit(1);  	}  } @@ -536,4 +531,3 @@ ns_id_t ns_get_default_id(void)  		return default_ns->ns_id;  	return NS_UNKNOWN;  } - diff --git a/lib/nexthop.c b/lib/nexthop.c index a094c0e38d..6809a01469 100644 --- a/lib/nexthop.c +++ b/lib/nexthop.c @@ -71,18 +71,16 @@ int nexthop_same_no_recurse(const struct nexthop *next1,  	return 1;  } -int -nexthop_same_firsthop (struct nexthop *next1, struct nexthop *next2) +int nexthop_same_firsthop(struct nexthop *next1, struct nexthop *next2)  {  	int type1 = NEXTHOP_FIRSTHOPTYPE(next1->type);  	int type2 = NEXTHOP_FIRSTHOPTYPE(next2->type);  	if (type1 != type2)  		return 0; -	switch (type1) -	{ +	switch (type1) {  	case NEXTHOP_TYPE_IPV4_IFINDEX: -		if (! IPV4_ADDR_SAME (&next1->gate.ipv4, &next2->gate.ipv4)) +		if (!IPV4_ADDR_SAME(&next1->gate.ipv4, &next2->gate.ipv4))  			return 0;  		if (next1->ifindex != next2->ifindex)  			return 0; @@ -92,7 +90,7 @@ nexthop_same_firsthop (struct nexthop *next1, struct nexthop *next2)  			return 0;  		break;  	case NEXTHOP_TYPE_IPV6_IFINDEX: -		if (! IPV6_ADDR_SAME (&next1->gate.ipv6, &next2->gate.ipv6)) +		if (!IPV6_ADDR_SAME(&next1->gate.ipv6, &next2->gate.ipv6))  			return 0;  		if (next1->ifindex != next2->ifindex)  			return 0; @@ -173,7 +171,8 @@ void copy_nexthops(struct nexthop **tnh, struct nexthop *nh,  		nexthop->flags = nh1->flags;  		memcpy(&nexthop->gate, &nh1->gate, sizeof(nh1->gate));  		memcpy(&nexthop->src, &nh1->src, sizeof(nh1->src)); -		memcpy(&nexthop->rmap_src, &nh1->rmap_src, sizeof(nh1->rmap_src)); +		memcpy(&nexthop->rmap_src, &nh1->rmap_src, +		       sizeof(nh1->rmap_src));  		nexthop->rparent = rparent;  		if (nh1->nh_label)  			nexthop_add_labels(nexthop, nh1->nh_label_type, diff --git a/lib/nexthop.h b/lib/nexthop.h index b502f293bc..0be949688f 100644 --- a/lib/nexthop.h +++ b/lib/nexthop.h @@ -51,9 +51,10 @@ enum blackhole_type {  };  /* IPV[46] -> IPV[46]_IFINDEX */ -#define NEXTHOP_FIRSTHOPTYPE(type) \ -	((type) == NEXTHOP_TYPE_IFINDEX || (type) == NEXTHOP_TYPE_BLACKHOLE) \ -		? (type) : ((type) | 1) +#define NEXTHOP_FIRSTHOPTYPE(type)                                             \ +	((type) == NEXTHOP_TYPE_IFINDEX || (type) == NEXTHOP_TYPE_BLACKHOLE)   \ +		? (type)                                                       \ +		: ((type) | 1)  /* Nexthop structure. */  struct nexthop { @@ -79,9 +80,9 @@ struct nexthop {  #define NEXTHOP_FLAG_FILTERED   (1 << 5) /* rmap filtered, used by static only */  #define NEXTHOP_FLAG_DUPLICATE  (1 << 6) /* nexthop duplicates another active one */  #define NEXTHOP_FLAG_EVPN_RVTEP (1 << 7) /* EVPN remote vtep nexthop */ -#define NEXTHOP_IS_ACTIVE(flags) \ -	(CHECK_FLAG(flags, NEXTHOP_FLAG_ACTIVE) \ -		&& !CHECK_FLAG(flags, NEXTHOP_FLAG_DUPLICATE)) +#define NEXTHOP_IS_ACTIVE(flags)                                               \ +	(CHECK_FLAG(flags, NEXTHOP_FLAG_ACTIVE)                                \ +	 && !CHECK_FLAG(flags, NEXTHOP_FLAG_DUPLICATE))  	/* Nexthop address */  	union { @@ -137,7 +138,7 @@ extern const char *nexthop_type_to_str(enum nexthop_types_t nh_type);  extern int nexthop_same_no_recurse(const struct nexthop *next1,  				   const struct nexthop *next2);  extern int nexthop_labels_match(struct nexthop *nh1, struct nexthop *nh2); -extern int nexthop_same_firsthop (struct nexthop *next1, struct nexthop *next2); +extern int nexthop_same_firsthop(struct nexthop *next1, struct nexthop *next2);  extern const char *nexthop2str(struct nexthop *nexthop, char *str, int size);  extern struct nexthop *nexthop_next(struct nexthop *nexthop); diff --git a/lib/openbsd-tree.c b/lib/openbsd-tree.c index d171e14d25..35bfce3a89 100644 --- a/lib/openbsd-tree.c +++ b/lib/openbsd-tree.c @@ -45,16 +45,14 @@  #include <lib/openbsd-tree.h> -static inline struct rb_entry * -rb_n2e(const struct rb_type *t, void *node) +static inline struct rb_entry *rb_n2e(const struct rb_type *t, void *node)  {  	unsigned long addr = (unsigned long)node;  	return ((struct rb_entry *)(addr + t->t_offset));  } -static inline void * -rb_e2n(const struct rb_type *t, struct rb_entry *rbe) +static inline void *rb_e2n(const struct rb_type *t, struct rb_entry *rbe)  {  	unsigned long addr = (unsigned long)rbe; @@ -68,37 +66,33 @@ rb_e2n(const struct rb_type *t, struct rb_entry *rbe)  #define RBH_ROOT(_rbt)		(_rbt)->rbt_root -static inline void -rbe_set(struct rb_entry *rbe, struct rb_entry *parent) +static inline void rbe_set(struct rb_entry *rbe, struct rb_entry *parent)  {  	RBE_PARENT(rbe) = parent;  	RBE_LEFT(rbe) = RBE_RIGHT(rbe) = NULL;  	RBE_COLOR(rbe) = RB_RED;  } -static inline void -rbe_set_blackred(struct rb_entry *black, struct rb_entry *red) +static inline void rbe_set_blackred(struct rb_entry *black, +				    struct rb_entry *red)  {  	RBE_COLOR(black) = RB_BLACK;  	RBE_COLOR(red) = RB_RED;  } -static inline void -rbe_augment(const struct rb_type *t, struct rb_entry *rbe) +static inline void rbe_augment(const struct rb_type *t, struct rb_entry *rbe)  {  	(*t->t_augment)(rb_e2n(t, rbe));  } -static inline void -rbe_if_augment(const struct rb_type *t, struct rb_entry *rbe) +static inline void rbe_if_augment(const struct rb_type *t, struct rb_entry *rbe)  {  	if (t->t_augment != NULL)  		rbe_augment(t, rbe);  } -static inline void -rbe_rotate_left(const struct rb_type *t, struct rbt_tree *rbt, -    struct rb_entry *rbe) +static inline void rbe_rotate_left(const struct rb_type *t, +				   struct rbt_tree *rbt, struct rb_entry *rbe)  {  	struct rb_entry *parent;  	struct rb_entry *tmp; @@ -130,9 +124,8 @@ rbe_rotate_left(const struct rb_type *t, struct rbt_tree *rbt,  	}  } -static inline void -rbe_rotate_right(const struct rb_type *t, struct rbt_tree *rbt, -    struct rb_entry *rbe) +static inline void rbe_rotate_right(const struct rb_type *t, +				    struct rbt_tree *rbt, struct rb_entry *rbe)  {  	struct rb_entry *parent;  	struct rb_entry *tmp; @@ -164,14 +157,13 @@ rbe_rotate_right(const struct rb_type *t, struct rbt_tree *rbt,  	}  } -static inline void -rbe_insert_color(const struct rb_type *t, struct rbt_tree *rbt, -    struct rb_entry *rbe) +static inline void rbe_insert_color(const struct rb_type *t, +				    struct rbt_tree *rbt, struct rb_entry *rbe)  {  	struct rb_entry *parent, *gparent, *tmp; -	while ((parent = RBE_PARENT(rbe)) != NULL && -	    RBE_COLOR(parent) == RB_RED) { +	while ((parent = RBE_PARENT(rbe)) != NULL +	       && RBE_COLOR(parent) == RB_RED) {  		gparent = RBE_PARENT(parent);  		if (parent == RBE_LEFT(gparent)) { @@ -216,14 +208,15 @@ rbe_insert_color(const struct rb_type *t, struct rbt_tree *rbt,  	RBE_COLOR(RBH_ROOT(rbt)) = RB_BLACK;  } -static inline void -rbe_remove_color(const struct rb_type *t, struct rbt_tree *rbt, -    struct rb_entry *parent, struct rb_entry *rbe) +static inline void rbe_remove_color(const struct rb_type *t, +				    struct rbt_tree *rbt, +				    struct rb_entry *parent, +				    struct rb_entry *rbe)  {  	struct rb_entry *tmp; -	while ((rbe == NULL || RBE_COLOR(rbe) == RB_BLACK) && -	    rbe != RBH_ROOT(rbt) && parent) { +	while ((rbe == NULL || RBE_COLOR(rbe) == RB_BLACK) +	       && rbe != RBH_ROOT(rbt) && parent) {  		if (RBE_LEFT(parent) == rbe) {  			tmp = RBE_RIGHT(parent);  			if (RBE_COLOR(tmp) == RB_RED) { @@ -231,16 +224,16 @@ rbe_remove_color(const struct rb_type *t, struct rbt_tree *rbt,  				rbe_rotate_left(t, rbt, parent);  				tmp = RBE_RIGHT(parent);  			} -			if ((RBE_LEFT(tmp) == NULL || -			     RBE_COLOR(RBE_LEFT(tmp)) == RB_BLACK) && -			    (RBE_RIGHT(tmp) == NULL || -			     RBE_COLOR(RBE_RIGHT(tmp)) == RB_BLACK)) { +			if ((RBE_LEFT(tmp) == NULL +			     || RBE_COLOR(RBE_LEFT(tmp)) == RB_BLACK) +			    && (RBE_RIGHT(tmp) == NULL +				|| RBE_COLOR(RBE_RIGHT(tmp)) == RB_BLACK)) {  				RBE_COLOR(tmp) = RB_RED;  				rbe = parent;  				parent = RBE_PARENT(rbe);  			} else { -				if (RBE_RIGHT(tmp) == NULL || -				    RBE_COLOR(RBE_RIGHT(tmp)) == RB_BLACK) { +				if (RBE_RIGHT(tmp) == NULL +				    || RBE_COLOR(RBE_RIGHT(tmp)) == RB_BLACK) {  					struct rb_entry *oleft;  					oleft = RBE_LEFT(tmp); @@ -269,16 +262,16 @@ rbe_remove_color(const struct rb_type *t, struct rbt_tree *rbt,  				tmp = RBE_LEFT(parent);  			} -			if ((RBE_LEFT(tmp) == NULL || -			     RBE_COLOR(RBE_LEFT(tmp)) == RB_BLACK) && -			    (RBE_RIGHT(tmp) == NULL || -			     RBE_COLOR(RBE_RIGHT(tmp)) == RB_BLACK)) { +			if ((RBE_LEFT(tmp) == NULL +			     || RBE_COLOR(RBE_LEFT(tmp)) == RB_BLACK) +			    && (RBE_RIGHT(tmp) == NULL +				|| RBE_COLOR(RBE_RIGHT(tmp)) == RB_BLACK)) {  				RBE_COLOR(tmp) = RB_RED;  				rbe = parent;  				parent = RBE_PARENT(rbe);  			} else { -				if (RBE_LEFT(tmp) == NULL || -				    RBE_COLOR(RBE_LEFT(tmp)) == RB_BLACK) { +				if (RBE_LEFT(tmp) == NULL +				    || RBE_COLOR(RBE_LEFT(tmp)) == RB_BLACK) {  					struct rb_entry *oright;  					oright = RBE_RIGHT(tmp); @@ -388,8 +381,7 @@ color:  	return (old);  } -void * -_rb_remove(const struct rb_type *t, struct rbt_tree *rbt, void *elm) +void *_rb_remove(const struct rb_type *t, struct rbt_tree *rbt, void *elm)  {  	struct rb_entry *rbe = rb_n2e(t, elm);  	struct rb_entry *old; @@ -399,8 +391,7 @@ _rb_remove(const struct rb_type *t, struct rbt_tree *rbt, void *elm)  	return (old == NULL ? NULL : rb_e2n(t, old));  } -void * -_rb_insert(const struct rb_type *t, struct rbt_tree *rbt, void *elm) +void *_rb_insert(const struct rb_type *t, struct rbt_tree *rbt, void *elm)  {  	struct rb_entry *rbe = rb_n2e(t, elm);  	struct rb_entry *tmp; @@ -440,8 +431,7 @@ _rb_insert(const struct rb_type *t, struct rbt_tree *rbt, void *elm)  }  /* Finds the node with the same key as elm */ -void * -_rb_find(const struct rb_type *t, struct rbt_tree *rbt, const void *key) +void *_rb_find(const struct rb_type *t, struct rbt_tree *rbt, const void *key)  {  	struct rb_entry *tmp = RBH_ROOT(rbt);  	void *node; @@ -462,8 +452,7 @@ _rb_find(const struct rb_type *t, struct rbt_tree *rbt, const void *key)  }  /* Finds the first node greater than or equal to the search key */ -void * -_rb_nfind(const struct rb_type *t, struct rbt_tree *rbt, const void *key) +void *_rb_nfind(const struct rb_type *t, struct rbt_tree *rbt, const void *key)  {  	struct rb_entry *tmp = RBH_ROOT(rbt);  	void *node; @@ -485,8 +474,7 @@ _rb_nfind(const struct rb_type *t, struct rbt_tree *rbt, const void *key)  	return (res);  } -void * -_rb_next(const struct rb_type *t, void *elm) +void *_rb_next(const struct rb_type *t, void *elm)  {  	struct rb_entry *rbe = rb_n2e(t, elm); @@ -495,12 +483,11 @@ _rb_next(const struct rb_type *t, void *elm)  		while (RBE_LEFT(rbe) != NULL)  			rbe = RBE_LEFT(rbe);  	} else { -		if (RBE_PARENT(rbe) && -		    (rbe == RBE_LEFT(RBE_PARENT(rbe)))) +		if (RBE_PARENT(rbe) && (rbe == RBE_LEFT(RBE_PARENT(rbe))))  			rbe = RBE_PARENT(rbe);  		else { -			while (RBE_PARENT(rbe) && -			    (rbe == RBE_RIGHT(RBE_PARENT(rbe)))) +			while (RBE_PARENT(rbe) +			       && (rbe == RBE_RIGHT(RBE_PARENT(rbe))))  				rbe = RBE_PARENT(rbe);  			rbe = RBE_PARENT(rbe);  		} @@ -509,8 +496,7 @@ _rb_next(const struct rb_type *t, void *elm)  	return (rbe == NULL ? NULL : rb_e2n(t, rbe));  } -void * -_rb_prev(const struct rb_type *t, void *elm) +void *_rb_prev(const struct rb_type *t, void *elm)  {  	struct rb_entry *rbe = rb_n2e(t, elm); @@ -519,12 +505,11 @@ _rb_prev(const struct rb_type *t, void *elm)  		while (RBE_RIGHT(rbe))  			rbe = RBE_RIGHT(rbe);  	} else { -		if (RBE_PARENT(rbe) && -		    (rbe == RBE_RIGHT(RBE_PARENT(rbe)))) +		if (RBE_PARENT(rbe) && (rbe == RBE_RIGHT(RBE_PARENT(rbe))))  			rbe = RBE_PARENT(rbe);  		else { -			while (RBE_PARENT(rbe) && -			    (rbe == RBE_LEFT(RBE_PARENT(rbe)))) +			while (RBE_PARENT(rbe) +			       && (rbe == RBE_LEFT(RBE_PARENT(rbe))))  				rbe = RBE_PARENT(rbe);  			rbe = RBE_PARENT(rbe);  		} @@ -533,16 +518,14 @@ _rb_prev(const struct rb_type *t, void *elm)  	return (rbe == NULL ? NULL : rb_e2n(t, rbe));  } -void * -_rb_root(const struct rb_type *t, struct rbt_tree *rbt) +void *_rb_root(const struct rb_type *t, struct rbt_tree *rbt)  {  	struct rb_entry *rbe = RBH_ROOT(rbt);  	return (rbe == NULL ? rbe : rb_e2n(t, rbe));  } -void * -_rb_min(const struct rb_type *t, struct rbt_tree *rbt) +void *_rb_min(const struct rb_type *t, struct rbt_tree *rbt)  {  	struct rb_entry *rbe = RBH_ROOT(rbt);  	struct rb_entry *parent = NULL; @@ -555,8 +538,7 @@ _rb_min(const struct rb_type *t, struct rbt_tree *rbt)  	return (parent == NULL ? NULL : rb_e2n(t, parent));  } -void * -_rb_max(const struct rb_type *t, struct rbt_tree *rbt) +void *_rb_max(const struct rb_type *t, struct rbt_tree *rbt)  {  	struct rb_entry *rbe = RBH_ROOT(rbt);  	struct rb_entry *parent = NULL; @@ -569,32 +551,28 @@ _rb_max(const struct rb_type *t, struct rbt_tree *rbt)  	return (parent == NULL ? NULL : rb_e2n(t, parent));  } -void * -_rb_left(const struct rb_type *t, void *node) +void *_rb_left(const struct rb_type *t, void *node)  {  	struct rb_entry *rbe = rb_n2e(t, node);  	rbe = RBE_LEFT(rbe);  	return (rbe == NULL ? NULL : rb_e2n(t, rbe));  } -void * -_rb_right(const struct rb_type *t, void *node) +void *_rb_right(const struct rb_type *t, void *node)  {  	struct rb_entry *rbe = rb_n2e(t, node);  	rbe = RBE_RIGHT(rbe);  	return (rbe == NULL ? NULL : rb_e2n(t, rbe));  } -void * -_rb_parent(const struct rb_type *t, void *node) +void *_rb_parent(const struct rb_type *t, void *node)  {  	struct rb_entry *rbe = rb_n2e(t, node);  	rbe = RBE_PARENT(rbe);  	return (rbe == NULL ? NULL : rb_e2n(t, rbe));  } -void -_rb_set_left(const struct rb_type *t, void *node, void *left) +void _rb_set_left(const struct rb_type *t, void *node, void *left)  {  	struct rb_entry *rbe = rb_n2e(t, node);  	struct rb_entry *rbl = (left == NULL) ? NULL : rb_n2e(t, left); @@ -602,8 +580,7 @@ _rb_set_left(const struct rb_type *t, void *node, void *left)  	RBE_LEFT(rbe) = rbl;  } -void -_rb_set_right(const struct rb_type *t, void *node, void *right) +void _rb_set_right(const struct rb_type *t, void *node, void *right)  {  	struct rb_entry *rbe = rb_n2e(t, node);  	struct rb_entry *rbr = (right == NULL) ? NULL : rb_n2e(t, right); @@ -611,8 +588,7 @@ _rb_set_right(const struct rb_type *t, void *node, void *right)  	RBE_RIGHT(rbe) = rbr;  } -void -_rb_set_parent(const struct rb_type *t, void *node, void *parent) +void _rb_set_parent(const struct rb_type *t, void *node, void *parent)  {  	struct rb_entry *rbe = rb_n2e(t, node);  	struct rb_entry *rbp = (parent == NULL) ? NULL : rb_n2e(t, parent); @@ -620,21 +596,19 @@ _rb_set_parent(const struct rb_type *t, void *node, void *parent)  	RBE_PARENT(rbe) = rbp;  } -void -_rb_poison(const struct rb_type *t, void *node, unsigned long poison) +void _rb_poison(const struct rb_type *t, void *node, unsigned long poison)  {  	struct rb_entry *rbe = rb_n2e(t, node);  	RBE_PARENT(rbe) = RBE_LEFT(rbe) = RBE_RIGHT(rbe) = -	    (struct rb_entry *)poison; +		(struct rb_entry *)poison;  } -int -_rb_check(const struct rb_type *t, void *node, unsigned long poison) +int _rb_check(const struct rb_type *t, void *node, unsigned long poison)  {  	struct rb_entry *rbe = rb_n2e(t, node); -	return ((unsigned long)RBE_PARENT(rbe) == poison && -	    (unsigned long)RBE_LEFT(rbe) == poison && -	    (unsigned long)RBE_RIGHT(rbe) == poison); +	return ((unsigned long)RBE_PARENT(rbe) == poison +		&& (unsigned long)RBE_LEFT(rbe) == poison +		&& (unsigned long)RBE_RIGHT(rbe) == poison);  } diff --git a/lib/openbsd-tree.h b/lib/openbsd-tree.h index 22cb9252f5..859f751678 100644 --- a/lib/openbsd-tree.h +++ b/lib/openbsd-tree.h @@ -24,7 +24,7 @@   * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.   */ -#ifndef	_SYS_TREE_H_ +#ifndef _SYS_TREE_H_  #define	_SYS_TREE_H_  /* @@ -54,23 +54,26 @@   * The maximum height of a red-black tree is 2lg (n+1).   */ -#define SPLAY_HEAD(name, type)						\ -struct name {								\ -	struct type *sph_root; /* root of the tree */			\ -} +#define SPLAY_HEAD(name, type)                                                 \ +	struct name {                                                          \ +		struct type *sph_root; /* root of the tree */                  \ +	} -#define SPLAY_INITIALIZER(root)						\ -	{ NULL } +#define SPLAY_INITIALIZER(root)                                                \ +	{                                                                      \ +		NULL                                                           \ +	} -#define SPLAY_INIT(root) do {						\ -	(root)->sph_root = NULL;					\ -} while (0) +#define SPLAY_INIT(root)                                                       \ +	do {                                                                   \ +		(root)->sph_root = NULL;                                       \ +	} while (0) -#define SPLAY_ENTRY(type)						\ -struct {								\ -	struct type *spe_left; /* left element */			\ -	struct type *spe_right; /* right element */			\ -} +#define SPLAY_ENTRY(type)                                                      \ +	struct {                                                               \ +		struct type *spe_left;  /* left element */                     \ +		struct type *spe_right; /* right element */                    \ +	}  #define SPLAY_LEFT(elm, field)		(elm)->field.spe_left  #define SPLAY_RIGHT(elm, field)		(elm)->field.spe_right @@ -78,197 +81,220 @@ struct {								\  #define SPLAY_EMPTY(head)		(SPLAY_ROOT(head) == NULL)  /* SPLAY_ROTATE_{LEFT,RIGHT} expect that tmp hold SPLAY_{RIGHT,LEFT} */ -#define SPLAY_ROTATE_RIGHT(head, tmp, field) do {			\ -	SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field);	\ -	SPLAY_RIGHT(tmp, field) = (head)->sph_root;			\ -	(head)->sph_root = tmp;						\ -} while (0) - -#define SPLAY_ROTATE_LEFT(head, tmp, field) do {			\ -	SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field);	\ -	SPLAY_LEFT(tmp, field) = (head)->sph_root;			\ -	(head)->sph_root = tmp;						\ -} while (0) - -#define SPLAY_LINKLEFT(head, tmp, field) do {				\ -	SPLAY_LEFT(tmp, field) = (head)->sph_root;			\ -	tmp = (head)->sph_root;						\ -	(head)->sph_root = SPLAY_LEFT((head)->sph_root, field);		\ -} while (0) - -#define SPLAY_LINKRIGHT(head, tmp, field) do {				\ -	SPLAY_RIGHT(tmp, field) = (head)->sph_root;			\ -	tmp = (head)->sph_root;						\ -	(head)->sph_root = SPLAY_RIGHT((head)->sph_root, field);	\ -} while (0) - -#define SPLAY_ASSEMBLE(head, node, left, right, field) do {		\ -	SPLAY_RIGHT(left, field) = SPLAY_LEFT((head)->sph_root, field);	\ -	SPLAY_LEFT(right, field) = SPLAY_RIGHT((head)->sph_root, field);\ -	SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(node, field);	\ -	SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(node, field);	\ -} while (0) +#define SPLAY_ROTATE_RIGHT(head, tmp, field)                                   \ +	do {                                                                   \ +		SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field); \ +		SPLAY_RIGHT(tmp, field) = (head)->sph_root;                    \ +		(head)->sph_root = tmp;                                        \ +	} while (0) + +#define SPLAY_ROTATE_LEFT(head, tmp, field)                                    \ +	do {                                                                   \ +		SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \ +		SPLAY_LEFT(tmp, field) = (head)->sph_root;                     \ +		(head)->sph_root = tmp;                                        \ +	} while (0) + +#define SPLAY_LINKLEFT(head, tmp, field)                                       \ +	do {                                                                   \ +		SPLAY_LEFT(tmp, field) = (head)->sph_root;                     \ +		tmp = (head)->sph_root;                                        \ +		(head)->sph_root = SPLAY_LEFT((head)->sph_root, field);        \ +	} while (0) + +#define SPLAY_LINKRIGHT(head, tmp, field)                                      \ +	do {                                                                   \ +		SPLAY_RIGHT(tmp, field) = (head)->sph_root;                    \ +		tmp = (head)->sph_root;                                        \ +		(head)->sph_root = SPLAY_RIGHT((head)->sph_root, field);       \ +	} while (0) + +#define SPLAY_ASSEMBLE(head, node, left, right, field)                         \ +	do {                                                                   \ +		SPLAY_RIGHT(left, field) =                                     \ +			SPLAY_LEFT((head)->sph_root, field);                   \ +		SPLAY_LEFT(right, field) =                                     \ +			SPLAY_RIGHT((head)->sph_root, field);                  \ +		SPLAY_LEFT((head)->sph_root, field) =                          \ +			SPLAY_RIGHT(node, field);                              \ +		SPLAY_RIGHT((head)->sph_root, field) =                         \ +			SPLAY_LEFT(node, field);                               \ +	} while (0)  /* Generates prototypes and inline functions */ -#define SPLAY_PROTOTYPE(name, type, field, cmp)				\ -void name##_SPLAY(struct name *, struct type *);			\ -void name##_SPLAY_MINMAX(struct name *, int);				\ -struct type *name##_SPLAY_INSERT(struct name *, struct type *);		\ -struct type *name##_SPLAY_REMOVE(struct name *, struct type *);		\ -									\ -/* Finds the node with the same key as elm */				\ -static __inline struct type *						\ -name##_SPLAY_FIND(struct name *head, struct type *elm)			\ -{									\ -	if (SPLAY_EMPTY(head))						\ -		return(NULL);						\ -	name##_SPLAY(head, elm);					\ -	if ((cmp)(elm, (head)->sph_root) == 0)				\ -		return (head->sph_root);				\ -	return (NULL);							\ -}									\ -									\ -static __inline struct type *						\ -name##_SPLAY_NEXT(struct name *head, struct type *elm)			\ -{									\ -	name##_SPLAY(head, elm);					\ -	if (SPLAY_RIGHT(elm, field) != NULL) {				\ -		elm = SPLAY_RIGHT(elm, field);				\ -		while (SPLAY_LEFT(elm, field) != NULL) {		\ -			elm = SPLAY_LEFT(elm, field);			\ -		}							\ -	} else								\ -		elm = NULL;						\ -	return (elm);							\ -}									\ -									\ -static __inline struct type *						\ -name##_SPLAY_MIN_MAX(struct name *head, int val)			\ -{									\ -	name##_SPLAY_MINMAX(head, val);					\ -        return (SPLAY_ROOT(head));					\ -} +#define SPLAY_PROTOTYPE(name, type, field, cmp)                                \ +	void name##_SPLAY(struct name *, struct type *);                       \ +	void name##_SPLAY_MINMAX(struct name *, int);                          \ +	struct type *name##_SPLAY_INSERT(struct name *, struct type *);        \ +	struct type *name##_SPLAY_REMOVE(struct name *, struct type *);        \ +                                                                               \ +	/* Finds the node with the same key as elm */                          \ +	static __inline struct type *name##_SPLAY_FIND(struct name *head,      \ +						       struct type *elm)       \ +	{                                                                      \ +		if (SPLAY_EMPTY(head))                                         \ +			return (NULL);                                         \ +		name##_SPLAY(head, elm);                                       \ +		if ((cmp)(elm, (head)->sph_root) == 0)                         \ +			return (head->sph_root);                               \ +		return (NULL);                                                 \ +	}                                                                      \ +                                                                               \ +	static __inline struct type *name##_SPLAY_NEXT(struct name *head,      \ +						       struct type *elm)       \ +	{                                                                      \ +		name##_SPLAY(head, elm);                                       \ +		if (SPLAY_RIGHT(elm, field) != NULL) {                         \ +			elm = SPLAY_RIGHT(elm, field);                         \ +			while (SPLAY_LEFT(elm, field) != NULL) {               \ +				elm = SPLAY_LEFT(elm, field);                  \ +			}                                                      \ +		} else                                                         \ +			elm = NULL;                                            \ +		return (elm);                                                  \ +	}                                                                      \ +                                                                               \ +	static __inline struct type *name##_SPLAY_MIN_MAX(struct name *head,   \ +							  int val)             \ +	{                                                                      \ +		name##_SPLAY_MINMAX(head, val);                                \ +		return (SPLAY_ROOT(head));                                     \ +	}  /* Main splay operation.   * Moves node close to the key of elm to top   */ -#define SPLAY_GENERATE(name, type, field, cmp)				\ -struct type *								\ -name##_SPLAY_INSERT(struct name *head, struct type *elm)		\ -{									\ -    if (SPLAY_EMPTY(head)) {						\ -	    SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL;	\ -    } else {								\ -	    int __comp;							\ -	    name##_SPLAY(head, elm);					\ -	    __comp = (cmp)(elm, (head)->sph_root);			\ -	    if(__comp < 0) {						\ -		    SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field);\ -		    SPLAY_RIGHT(elm, field) = (head)->sph_root;		\ -		    SPLAY_LEFT((head)->sph_root, field) = NULL;		\ -	    } else if (__comp > 0) {					\ -		    SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field);\ -		    SPLAY_LEFT(elm, field) = (head)->sph_root;		\ -		    SPLAY_RIGHT((head)->sph_root, field) = NULL;	\ -	    } else							\ -		    return ((head)->sph_root);				\ -    }									\ -    (head)->sph_root = (elm);						\ -    return (NULL);							\ -}									\ -									\ -struct type *								\ -name##_SPLAY_REMOVE(struct name *head, struct type *elm)		\ -{									\ -	struct type *__tmp;						\ -	if (SPLAY_EMPTY(head))						\ -		return (NULL);						\ -	name##_SPLAY(head, elm);					\ -	if ((cmp)(elm, (head)->sph_root) == 0) {			\ -		if (SPLAY_LEFT((head)->sph_root, field) == NULL) {	\ -			(head)->sph_root = SPLAY_RIGHT((head)->sph_root, field);\ -		} else {						\ -			__tmp = SPLAY_RIGHT((head)->sph_root, field);	\ -			(head)->sph_root = SPLAY_LEFT((head)->sph_root, field);\ -			name##_SPLAY(head, elm);			\ -			SPLAY_RIGHT((head)->sph_root, field) = __tmp;	\ -		}							\ -		return (elm);						\ -	}								\ -	return (NULL);							\ -}									\ -									\ -void									\ -name##_SPLAY(struct name *head, struct type *elm)			\ -{									\ -	struct type __node, *__left, *__right, *__tmp;			\ -	int __comp;							\ -\ -	SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\ -	__left = __right = &__node;					\ -\ -	while ((__comp = (cmp)(elm, (head)->sph_root))) {		\ -		if (__comp < 0) {					\ -			__tmp = SPLAY_LEFT((head)->sph_root, field);	\ -			if (__tmp == NULL)				\ -				break;					\ -			if ((cmp)(elm, __tmp) < 0){			\ -				SPLAY_ROTATE_RIGHT(head, __tmp, field);	\ -				if (SPLAY_LEFT((head)->sph_root, field) == NULL)\ -					break;				\ -			}						\ -			SPLAY_LINKLEFT(head, __right, field);		\ -		} else if (__comp > 0) {				\ -			__tmp = SPLAY_RIGHT((head)->sph_root, field);	\ -			if (__tmp == NULL)				\ -				break;					\ -			if ((cmp)(elm, __tmp) > 0){			\ -				SPLAY_ROTATE_LEFT(head, __tmp, field);	\ -				if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\ -					break;				\ -			}						\ -			SPLAY_LINKRIGHT(head, __left, field);		\ -		}							\ -	}								\ -	SPLAY_ASSEMBLE(head, &__node, __left, __right, field);		\ -}									\ -									\ -/* Splay with either the minimum or the maximum element			\ - * Used to find minimum or maximum element in tree.			\ - */									\ -void name##_SPLAY_MINMAX(struct name *head, int __comp) \ -{									\ -	struct type __node, *__left, *__right, *__tmp;			\ -\ -	SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\ -	__left = __right = &__node;					\ -\ -	while (1) {							\ -		if (__comp < 0) {					\ -			__tmp = SPLAY_LEFT((head)->sph_root, field);	\ -			if (__tmp == NULL)				\ -				break;					\ -			if (__comp < 0){				\ -				SPLAY_ROTATE_RIGHT(head, __tmp, field);	\ -				if (SPLAY_LEFT((head)->sph_root, field) == NULL)\ -					break;				\ -			}						\ -			SPLAY_LINKLEFT(head, __right, field);		\ -		} else if (__comp > 0) {				\ -			__tmp = SPLAY_RIGHT((head)->sph_root, field);	\ -			if (__tmp == NULL)				\ -				break;					\ -			if (__comp > 0) {				\ -				SPLAY_ROTATE_LEFT(head, __tmp, field);	\ -				if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\ -					break;				\ -			}						\ -			SPLAY_LINKRIGHT(head, __left, field);		\ -		}							\ -	}								\ -	SPLAY_ASSEMBLE(head, &__node, __left, __right, field);		\ -} +#define SPLAY_GENERATE(name, type, field, cmp)                                 \ +	struct type *name##_SPLAY_INSERT(struct name *head, struct type *elm)  \ +	{                                                                      \ +		if (SPLAY_EMPTY(head)) {                                       \ +			SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) =     \ +				NULL;                                          \ +		} else {                                                       \ +			int __comp;                                            \ +			name##_SPLAY(head, elm);                               \ +			__comp = (cmp)(elm, (head)->sph_root);                 \ +			if (__comp < 0) {                                      \ +				SPLAY_LEFT(elm, field) =                       \ +					SPLAY_LEFT((head)->sph_root, field);   \ +				SPLAY_RIGHT(elm, field) = (head)->sph_root;    \ +				SPLAY_LEFT((head)->sph_root, field) = NULL;    \ +			} else if (__comp > 0) {                               \ +				SPLAY_RIGHT(elm, field) =                      \ +					SPLAY_RIGHT((head)->sph_root, field);  \ +				SPLAY_LEFT(elm, field) = (head)->sph_root;     \ +				SPLAY_RIGHT((head)->sph_root, field) = NULL;   \ +			} else                                                 \ +				return ((head)->sph_root);                     \ +		}                                                              \ +		(head)->sph_root = (elm);                                      \ +		return (NULL);                                                 \ +	}                                                                      \ +                                                                               \ +	struct type *name##_SPLAY_REMOVE(struct name *head, struct type *elm)  \ +	{                                                                      \ +		struct type *__tmp;                                            \ +		if (SPLAY_EMPTY(head))                                         \ +			return (NULL);                                         \ +		name##_SPLAY(head, elm);                                       \ +		if ((cmp)(elm, (head)->sph_root) == 0) {                       \ +			if (SPLAY_LEFT((head)->sph_root, field) == NULL) {     \ +				(head)->sph_root =                             \ +					SPLAY_RIGHT((head)->sph_root, field);  \ +			} else {                                               \ +				__tmp = SPLAY_RIGHT((head)->sph_root, field);  \ +				(head)->sph_root =                             \ +					SPLAY_LEFT((head)->sph_root, field);   \ +				name##_SPLAY(head, elm);                       \ +				SPLAY_RIGHT((head)->sph_root, field) = __tmp;  \ +			}                                                      \ +			return (elm);                                          \ +		}                                                              \ +		return (NULL);                                                 \ +	}                                                                      \ +                                                                               \ +	void name##_SPLAY(struct name *head, struct type *elm)                 \ +	{                                                                      \ +		struct type __node, *__left, *__right, *__tmp;                 \ +		int __comp;                                                    \ +                                                                               \ +		SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) =     \ +			NULL;                                                  \ +		__left = __right = &__node;                                    \ +                                                                               \ +		while ((__comp = (cmp)(elm, (head)->sph_root))) {              \ +			if (__comp < 0) {                                      \ +				__tmp = SPLAY_LEFT((head)->sph_root, field);   \ +				if (__tmp == NULL)                             \ +					break;                                 \ +				if ((cmp)(elm, __tmp) < 0) {                   \ +					SPLAY_ROTATE_RIGHT(head, __tmp,        \ +							   field);             \ +					if (SPLAY_LEFT((head)->sph_root,       \ +						       field)                  \ +					    == NULL)                           \ +						break;                         \ +				}                                              \ +				SPLAY_LINKLEFT(head, __right, field);          \ +			} else if (__comp > 0) {                               \ +				__tmp = SPLAY_RIGHT((head)->sph_root, field);  \ +				if (__tmp == NULL)                             \ +					break;                                 \ +				if ((cmp)(elm, __tmp) > 0) {                   \ +					SPLAY_ROTATE_LEFT(head, __tmp, field); \ +					if (SPLAY_RIGHT((head)->sph_root,      \ +							field)                 \ +					    == NULL)                           \ +						break;                         \ +				}                                              \ +				SPLAY_LINKRIGHT(head, __left, field);          \ +			}                                                      \ +		}                                                              \ +		SPLAY_ASSEMBLE(head, &__node, __left, __right, field);         \ +	}                                                                      \ +                                                                               \ +	/* Splay with either the minimum or the maximum element                \ +	 * Used to find minimum or maximum element in tree.                    \ +	 */                                                                    \ +	void name##_SPLAY_MINMAX(struct name *head, int __comp)                \ +	{                                                                      \ +		struct type __node, *__left, *__right, *__tmp;                 \ +                                                                               \ +		SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) =     \ +			NULL;                                                  \ +		__left = __right = &__node;                                    \ +                                                                               \ +		while (1) {                                                    \ +			if (__comp < 0) {                                      \ +				__tmp = SPLAY_LEFT((head)->sph_root, field);   \ +				if (__tmp == NULL)                             \ +					break;                                 \ +				if (__comp < 0) {                              \ +					SPLAY_ROTATE_RIGHT(head, __tmp,        \ +							   field);             \ +					if (SPLAY_LEFT((head)->sph_root,       \ +						       field)                  \ +					    == NULL)                           \ +						break;                         \ +				}                                              \ +				SPLAY_LINKLEFT(head, __right, field);          \ +			} else if (__comp > 0) {                               \ +				__tmp = SPLAY_RIGHT((head)->sph_root, field);  \ +				if (__tmp == NULL)                             \ +					break;                                 \ +				if (__comp > 0) {                              \ +					SPLAY_ROTATE_LEFT(head, __tmp, field); \ +					if (SPLAY_RIGHT((head)->sph_root,      \ +							field)                 \ +					    == NULL)                           \ +						break;                         \ +				}                                              \ +				SPLAY_LINKRIGHT(head, __left, field);          \ +			}                                                      \ +		}                                                              \ +		SPLAY_ASSEMBLE(head, &__node, __left, __right, field);         \ +	}  #define SPLAY_NEGINF	-1  #define SPLAY_INF	1 @@ -277,14 +303,13 @@ void name##_SPLAY_MINMAX(struct name *head, int __comp) \  #define SPLAY_REMOVE(name, x, y)	name##_SPLAY_REMOVE(x, y)  #define SPLAY_FIND(name, x, y)		name##_SPLAY_FIND(x, y)  #define SPLAY_NEXT(name, x, y)		name##_SPLAY_NEXT(x, y) -#define SPLAY_MIN(name, x)		(SPLAY_EMPTY(x) ? NULL	\ -					: name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF)) -#define SPLAY_MAX(name, x)		(SPLAY_EMPTY(x) ? NULL	\ -					: name##_SPLAY_MIN_MAX(x, SPLAY_INF)) - -#define SPLAY_FOREACH(x, name, head)					\ -	for ((x) = SPLAY_MIN(name, head);				\ -	     (x) != NULL;						\ +#define SPLAY_MIN(name, x)                                                     \ +	(SPLAY_EMPTY(x) ? NULL : name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF)) +#define SPLAY_MAX(name, x)                                                     \ +	(SPLAY_EMPTY(x) ? NULL : name##_SPLAY_MIN_MAX(x, SPLAY_INF)) + +#define SPLAY_FOREACH(x, name, head)                                           \ +	for ((x) = SPLAY_MIN(name, head); (x) != NULL;                         \  	     (x) = SPLAY_NEXT(name, head, x))  /* @@ -307,203 +332,197 @@ void name##_SPLAY_MINMAX(struct name *head, int __comp) \  #define RB_RED		1  struct rb_type { -	int		(*t_compare)(const void *, const void *); -	void		(*t_augment)(void *); -	unsigned int	  t_offset;	/* offset of rb_entry in type */ +	int (*t_compare)(const void *, const void *); +	void (*t_augment)(void *); +	unsigned int t_offset; /* offset of rb_entry in type */  };  struct rbt_tree { -	struct rb_entry	*rbt_root; +	struct rb_entry *rbt_root;  };  struct rb_entry { -	struct rb_entry	 *rbt_parent; -	struct rb_entry	 *rbt_left; -	struct rb_entry	 *rbt_right; -	unsigned int	  rbt_color; +	struct rb_entry *rbt_parent; +	struct rb_entry *rbt_left; +	struct rb_entry *rbt_right; +	unsigned int rbt_color;  }; -#define RB_HEAD(_name, _type)						\ -struct _name {								\ -	struct rbt_tree rbh_root;					\ -} +#define RB_HEAD(_name, _type)                                                  \ +	struct _name {                                                         \ +		struct rbt_tree rbh_root;                                      \ +	}  #define RB_ENTRY(_type)	struct rb_entry -static inline void -_rb_init(struct rbt_tree *rbt) +static inline void _rb_init(struct rbt_tree *rbt)  {  	rbt->rbt_root = NULL;  } -static inline int -_rb_empty(struct rbt_tree *rbt) +static inline int _rb_empty(struct rbt_tree *rbt)  {  	return (rbt->rbt_root == NULL);  } -void	*_rb_insert(const struct rb_type *, struct rbt_tree *, void *); -void	*_rb_remove(const struct rb_type *, struct rbt_tree *, void *); -void	*_rb_find(const struct rb_type *, struct rbt_tree *, const void *); -void	*_rb_nfind(const struct rb_type *, struct rbt_tree *, const void *); -void	*_rb_root(const struct rb_type *, struct rbt_tree *); -void	*_rb_min(const struct rb_type *, struct rbt_tree *); -void	*_rb_max(const struct rb_type *, struct rbt_tree *); -void	*_rb_next(const struct rb_type *, void *); -void	*_rb_prev(const struct rb_type *, void *); -void	*_rb_left(const struct rb_type *, void *); -void	*_rb_right(const struct rb_type *, void *); -void	*_rb_parent(const struct rb_type *, void *); -void	 _rb_set_left(const struct rb_type *, void *, void *); -void	 _rb_set_right(const struct rb_type *, void *, void *); -void	 _rb_set_parent(const struct rb_type *, void *, void *); -void	 _rb_poison(const struct rb_type *, void *, unsigned long); -int	 _rb_check(const struct rb_type *, void *, unsigned long); +void *_rb_insert(const struct rb_type *, struct rbt_tree *, void *); +void *_rb_remove(const struct rb_type *, struct rbt_tree *, void *); +void *_rb_find(const struct rb_type *, struct rbt_tree *, const void *); +void *_rb_nfind(const struct rb_type *, struct rbt_tree *, const void *); +void *_rb_root(const struct rb_type *, struct rbt_tree *); +void *_rb_min(const struct rb_type *, struct rbt_tree *); +void *_rb_max(const struct rb_type *, struct rbt_tree *); +void *_rb_next(const struct rb_type *, void *); +void *_rb_prev(const struct rb_type *, void *); +void *_rb_left(const struct rb_type *, void *); +void *_rb_right(const struct rb_type *, void *); +void *_rb_parent(const struct rb_type *, void *); +void _rb_set_left(const struct rb_type *, void *, void *); +void _rb_set_right(const struct rb_type *, void *, void *); +void _rb_set_parent(const struct rb_type *, void *, void *); +void _rb_poison(const struct rb_type *, void *, unsigned long); +int _rb_check(const struct rb_type *, void *, unsigned long);  #define RB_INITIALIZER(_head)	{ { NULL } } -#define RB_PROTOTYPE(_name, _type, _field, _cmp)			\ -extern const struct rb_type *const _name##_RB_TYPE;			\ -									\ -__attribute__((__unused__)) static inline void				\ -_name##_RB_INIT(struct _name *head)					\ -{									\ -	_rb_init(&head->rbh_root);					\ -}									\ -									\ -__attribute__((__unused__)) static inline struct _type *		\ -_name##_RB_INSERT(struct _name *head, struct _type *elm)		\ -{									\ -	return _rb_insert(_name##_RB_TYPE, &head->rbh_root, elm);	\ -}									\ -									\ -__attribute__((__unused__)) static inline struct _type *		\ -_name##_RB_REMOVE(struct _name *head, struct _type *elm)		\ -{									\ -	return _rb_remove(_name##_RB_TYPE, &head->rbh_root, elm);	\ -}									\ -									\ -__attribute__((__unused__)) static inline struct _type *		\ -_name##_RB_FIND(struct _name *head, const struct _type *key)		\ -{									\ -	return _rb_find(_name##_RB_TYPE, &head->rbh_root, key);	\ -}									\ -									\ -__attribute__((__unused__)) static inline struct _type *		\ -_name##_RB_NFIND(struct _name *head, const struct _type *key)		\ -{									\ -	return _rb_nfind(_name##_RB_TYPE, &head->rbh_root, key);	\ -}									\ -									\ -__attribute__((__unused__)) static inline struct _type *		\ -_name##_RB_ROOT(struct _name *head)					\ -{									\ -	return _rb_root(_name##_RB_TYPE, &head->rbh_root);		\ -}									\ -									\ -__attribute__((__unused__)) static inline int				\ -_name##_RB_EMPTY(struct _name *head)					\ -{									\ -	return _rb_empty(&head->rbh_root);				\ -}									\ -									\ -__attribute__((__unused__)) static inline struct _type *		\ -_name##_RB_MIN(struct _name *head)					\ -{									\ -	return _rb_min(_name##_RB_TYPE, &head->rbh_root);		\ -}									\ -									\ -__attribute__((__unused__)) static inline struct _type *		\ -_name##_RB_MAX(struct _name *head)					\ -{									\ -	return _rb_max(_name##_RB_TYPE, &head->rbh_root);		\ -}									\ -									\ -__attribute__((__unused__)) static inline struct _type *		\ -_name##_RB_NEXT(struct _type *elm)					\ -{									\ -	return _rb_next(_name##_RB_TYPE, elm);				\ -}									\ -									\ -__attribute__((__unused__)) static inline struct _type *		\ -_name##_RB_PREV(struct _type *elm)					\ -{									\ -	return _rb_prev(_name##_RB_TYPE, elm);				\ -}									\ -									\ -__attribute__((__unused__)) static inline struct _type *		\ -_name##_RB_LEFT(struct _type *elm)					\ -{									\ -	return _rb_left(_name##_RB_TYPE, elm);				\ -}									\ -									\ -__attribute__((__unused__)) static inline struct _type *		\ -_name##_RB_RIGHT(struct _type *elm)					\ -{									\ -	return _rb_right(_name##_RB_TYPE, elm);			\ -}									\ -									\ -__attribute__((__unused__)) static inline struct _type *		\ -_name##_RB_PARENT(struct _type *elm)					\ -{									\ -	return _rb_parent(_name##_RB_TYPE, elm);			\ -}									\ -									\ -__attribute__((__unused__)) static inline void				\ -_name##_RB_SET_LEFT(struct _type *elm, struct _type *left)		\ -{									\ -	return _rb_set_left(_name##_RB_TYPE, elm, left);		\ -}									\ -									\ -__attribute__((__unused__)) static inline void				\ -_name##_RB_SET_RIGHT(struct _type *elm, struct _type *right)		\ -{									\ -	return _rb_set_right(_name##_RB_TYPE, elm, right);		\ -}									\ -									\ -__attribute__((__unused__)) static inline void				\ -_name##_RB_SET_PARENT(struct _type *elm, struct _type *parent)		\ -{									\ -	return _rb_set_parent(_name##_RB_TYPE, elm, parent);		\ -}									\ -									\ -__attribute__((__unused__)) static inline void				\ -_name##_RB_POISON(struct _type *elm, unsigned long poison)		\ -{									\ -	return _rb_poison(_name##_RB_TYPE, elm, poison);		\ -}									\ -									\ -__attribute__((__unused__)) static inline int				\ -_name##_RB_CHECK(struct _type *elm, unsigned long poison)		\ -{									\ -	return _rb_check(_name##_RB_TYPE, elm, poison);		\ -} - -#define RB_GENERATE_INTERNAL(_name, _type, _field, _cmp, _aug)		\ -static int								\ -_name##_RB_COMPARE(const void *lptr, const void *rptr)			\ -{									\ -	const struct _type *l = lptr, *r = rptr;			\ -	return _cmp(l, r);						\ -}									\ -static const struct rb_type _name##_RB_INFO = {			\ -	_name##_RB_COMPARE,						\ -	_aug,								\ -	offsetof(struct _type, _field),					\ -};									\ -const struct rb_type *const _name##_RB_TYPE = &_name##_RB_INFO; - -#define RB_GENERATE_AUGMENT(_name, _type, _field, _cmp, _aug)		\ -static void								\ -_name##_RB_AUGMENT(void *ptr)						\ -{									\ -	struct _type *p = ptr;						\ -	return _aug(p);							\ -}									\ -RB_GENERATE_INTERNAL(_name, _type, _field, _cmp, _name##_RB_AUGMENT) - -#define RB_GENERATE(_name, _type, _field, _cmp)			\ -    RB_GENERATE_INTERNAL(_name, _type, _field, _cmp, NULL) +#define RB_PROTOTYPE(_name, _type, _field, _cmp)                               \ +	extern const struct rb_type *const _name##_RB_TYPE;                    \ +                                                                               \ +	__attribute__((__unused__)) static inline void _name##_RB_INIT(        \ +		struct _name *head)                                            \ +	{                                                                      \ +		_rb_init(&head->rbh_root);                                     \ +	}                                                                      \ +                                                                               \ +	__attribute__((__unused__)) static inline struct _type                 \ +		*_name##_RB_INSERT(struct _name *head, struct _type *elm)      \ +	{                                                                      \ +		return _rb_insert(_name##_RB_TYPE, &head->rbh_root, elm);      \ +	}                                                                      \ +                                                                               \ +	__attribute__((__unused__)) static inline struct _type                 \ +		*_name##_RB_REMOVE(struct _name *head, struct _type *elm)      \ +	{                                                                      \ +		return _rb_remove(_name##_RB_TYPE, &head->rbh_root, elm);      \ +	}                                                                      \ +                                                                               \ +	__attribute__((__unused__)) static inline struct _type                 \ +		*_name##_RB_FIND(struct _name *head, const struct _type *key)  \ +	{                                                                      \ +		return _rb_find(_name##_RB_TYPE, &head->rbh_root, key);        \ +	}                                                                      \ +                                                                               \ +	__attribute__((__unused__)) static inline struct _type                 \ +		*_name##_RB_NFIND(struct _name *head, const struct _type *key) \ +	{                                                                      \ +		return _rb_nfind(_name##_RB_TYPE, &head->rbh_root, key);       \ +	}                                                                      \ +                                                                               \ +	__attribute__((__unused__)) static inline struct _type                 \ +		*_name##_RB_ROOT(struct _name *head)                           \ +	{                                                                      \ +		return _rb_root(_name##_RB_TYPE, &head->rbh_root);             \ +	}                                                                      \ +                                                                               \ +	__attribute__((__unused__)) static inline int _name##_RB_EMPTY(        \ +		struct _name *head)                                            \ +	{                                                                      \ +		return _rb_empty(&head->rbh_root);                             \ +	}                                                                      \ +                                                                               \ +	__attribute__((__unused__)) static inline struct _type                 \ +		*_name##_RB_MIN(struct _name *head)                            \ +	{                                                                      \ +		return _rb_min(_name##_RB_TYPE, &head->rbh_root);              \ +	}                                                                      \ +                                                                               \ +	__attribute__((__unused__)) static inline struct _type                 \ +		*_name##_RB_MAX(struct _name *head)                            \ +	{                                                                      \ +		return _rb_max(_name##_RB_TYPE, &head->rbh_root);              \ +	}                                                                      \ +                                                                               \ +	__attribute__((__unused__)) static inline struct _type                 \ +		*_name##_RB_NEXT(struct _type *elm)                            \ +	{                                                                      \ +		return _rb_next(_name##_RB_TYPE, elm);                         \ +	}                                                                      \ +                                                                               \ +	__attribute__((__unused__)) static inline struct _type                 \ +		*_name##_RB_PREV(struct _type *elm)                            \ +	{                                                                      \ +		return _rb_prev(_name##_RB_TYPE, elm);                         \ +	}                                                                      \ +                                                                               \ +	__attribute__((__unused__)) static inline struct _type                 \ +		*_name##_RB_LEFT(struct _type *elm)                            \ +	{                                                                      \ +		return _rb_left(_name##_RB_TYPE, elm);                         \ +	}                                                                      \ +                                                                               \ +	__attribute__((__unused__)) static inline struct _type                 \ +		*_name##_RB_RIGHT(struct _type *elm)                           \ +	{                                                                      \ +		return _rb_right(_name##_RB_TYPE, elm);                        \ +	}                                                                      \ +                                                                               \ +	__attribute__((__unused__)) static inline struct _type                 \ +		*_name##_RB_PARENT(struct _type *elm)                          \ +	{                                                                      \ +		return _rb_parent(_name##_RB_TYPE, elm);                       \ +	}                                                                      \ +                                                                               \ +	__attribute__((__unused__)) static inline void _name##_RB_SET_LEFT(    \ +		struct _type *elm, struct _type *left)                         \ +	{                                                                      \ +		return _rb_set_left(_name##_RB_TYPE, elm, left);               \ +	}                                                                      \ +                                                                               \ +	__attribute__((__unused__)) static inline void _name##_RB_SET_RIGHT(   \ +		struct _type *elm, struct _type *right)                        \ +	{                                                                      \ +		return _rb_set_right(_name##_RB_TYPE, elm, right);             \ +	}                                                                      \ +                                                                               \ +	__attribute__((__unused__)) static inline void _name##_RB_SET_PARENT(  \ +		struct _type *elm, struct _type *parent)                       \ +	{                                                                      \ +		return _rb_set_parent(_name##_RB_TYPE, elm, parent);           \ +	}                                                                      \ +                                                                               \ +	__attribute__((__unused__)) static inline void _name##_RB_POISON(      \ +		struct _type *elm, unsigned long poison)                       \ +	{                                                                      \ +		return _rb_poison(_name##_RB_TYPE, elm, poison);               \ +	}                                                                      \ +                                                                               \ +	__attribute__((__unused__)) static inline int _name##_RB_CHECK(        \ +		struct _type *elm, unsigned long poison)                       \ +	{                                                                      \ +		return _rb_check(_name##_RB_TYPE, elm, poison);                \ +	} + +#define RB_GENERATE_INTERNAL(_name, _type, _field, _cmp, _aug)                 \ +	static int _name##_RB_COMPARE(const void *lptr, const void *rptr)      \ +	{                                                                      \ +		const struct _type *l = lptr, *r = rptr;                       \ +		return _cmp(l, r);                                             \ +	}                                                                      \ +	static const struct rb_type _name##_RB_INFO = {                        \ +		_name##_RB_COMPARE, _aug, offsetof(struct _type, _field),      \ +	};                                                                     \ +	const struct rb_type *const _name##_RB_TYPE = &_name##_RB_INFO; + +#define RB_GENERATE_AUGMENT(_name, _type, _field, _cmp, _aug)                  \ +	static void _name##_RB_AUGMENT(void *ptr)                              \ +	{                                                                      \ +		struct _type *p = ptr;                                         \ +		return _aug(p);                                                \ +	}                                                                      \ +	RB_GENERATE_INTERNAL(_name, _type, _field, _cmp, _name##_RB_AUGMENT) + +#define RB_GENERATE(_name, _type, _field, _cmp)                                \ +	RB_GENERATE_INTERNAL(_name, _type, _field, _cmp, NULL)  #define RB_INIT(_name, _head)		_name##_RB_INIT(_head)  #define RB_INSERT(_name, _head, _elm)	_name##_RB_INSERT(_head, _elm) @@ -525,24 +544,20 @@ RB_GENERATE_INTERNAL(_name, _type, _field, _cmp, _name##_RB_AUGMENT)  #define RB_POISON(_name, _elm, _p)	_name##_RB_POISON(_elm, _p)  #define RB_CHECK(_name, _elm, _p)	_name##_RB_CHECK(_elm, _p) -#define RB_FOREACH(_e, _name, _head)					\ -	for ((_e) = RB_MIN(_name, (_head));				\ -	     (_e) != NULL;						\ +#define RB_FOREACH(_e, _name, _head)                                           \ +	for ((_e) = RB_MIN(_name, (_head)); (_e) != NULL;                      \  	     (_e) = RB_NEXT(_name, (_e))) -#define RB_FOREACH_SAFE(_e, _name, _head, _n)				\ -	for ((_e) = RB_MIN(_name, (_head));				\ -	     (_e) != NULL && ((_n) = RB_NEXT(_name, (_e)), 1);	\ -	     (_e) = (_n)) +#define RB_FOREACH_SAFE(_e, _name, _head, _n)                                  \ +	for ((_e) = RB_MIN(_name, (_head));                                    \ +	     (_e) != NULL && ((_n) = RB_NEXT(_name, (_e)), 1); (_e) = (_n)) -#define RB_FOREACH_REVERSE(_e, _name, _head)				\ -	for ((_e) = RB_MAX(_name, (_head));				\ -	     (_e) != NULL;						\ +#define RB_FOREACH_REVERSE(_e, _name, _head)                                   \ +	for ((_e) = RB_MAX(_name, (_head)); (_e) != NULL;                      \  	     (_e) = RB_PREV(_name, (_e))) -#define RB_FOREACH_REVERSE_SAFE(_e, _name, _head, _n)			\ -	for ((_e) = RB_MAX(_name, (_head));				\ -	     (_e) != NULL && ((_n) = RB_PREV(_name, (_e)), 1);	\ -	     (_e) = (_n)) +#define RB_FOREACH_REVERSE_SAFE(_e, _name, _head, _n)                          \ +	for ((_e) = RB_MAX(_name, (_head));                                    \ +	     (_e) != NULL && ((_n) = RB_PREV(_name, (_e)), 1); (_e) = (_n)) -#endif	/* _SYS_TREE_H_ */ +#endif /* _SYS_TREE_H_ */ diff --git a/lib/plist.c b/lib/plist.c index a95749cf0e..9dd5e561a7 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -1230,8 +1230,8 @@ static int vty_show_prefix_list_prefix(struct vty *vty, afi_t afi,  				match = 1;  		if (type == longer_display) { -			if ((p.family == pentry->prefix.family) && -			    (prefix_match(&p, &pentry->prefix))) +			if ((p.family == pentry->prefix.family) +			    && (prefix_match(&p, &pentry->prefix)))  				match = 1;  		} @@ -1310,8 +1310,8 @@ static int vty_clear_prefix_list(struct vty *vty, afi_t afi, const char *name,  		for (pentry = plist->head; pentry; pentry = pentry->next) {  			if (prefix) { -				if (pentry->prefix.family == p.family && -				    prefix_match(&pentry->prefix, &p)) +				if (pentry->prefix.family == p.family +				    && prefix_match(&pentry->prefix, &p))  					pentry->hitcnt = 0;  			} else  				pentry->hitcnt = 0; diff --git a/lib/plist.h b/lib/plist.h index bf06e74d36..9662f0311b 100644 --- a/lib/plist.h +++ b/lib/plist.h @@ -60,10 +60,9 @@ extern struct prefix_list *prefix_list_lookup(afi_t, const char *);   * If no pointer is sent in, do not return anything.   * If it is a empty plist return a NULL pointer.   */ -extern enum prefix_list_type prefix_list_apply_which_prefix( -	struct prefix_list *plist, -	struct prefix **which, -	void *object); +extern enum prefix_list_type +prefix_list_apply_which_prefix(struct prefix_list *plist, struct prefix **which, +			       void *object);  #define prefix_list_apply(A, B) prefix_list_apply_which_prefix((A), NULL, (B))  extern struct prefix_list *prefix_bgp_orf_lookup(afi_t, const char *); diff --git a/lib/prefix.c b/lib/prefix.c index 9f13cb8bb1..1344039498 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -37,262 +37,390 @@ static const u_char maskbit[] = {0x00, 0x80, 0xc0, 0xe0, 0xf0,  static const struct in6_addr maskbytes6[] = {  	/* /0   */ {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /1   */ {{{0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /2   */ {{{0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /3   */ {{{0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /4   */ {{{0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /5   */ {{{0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /6   */ {{{0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /7   */ {{{0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /8   */ {{{0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /9   */ {{{0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /10  */ {{{0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /11  */ {{{0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /12  */ {{{0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /13  */ {{{0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /14  */ {{{0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /15  */ {{{0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /16  */ {{{0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /17  */ {{{0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /18  */ {{{0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /19  */ {{{0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /20  */ {{{0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /21  */ {{{0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /22  */ {{{0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /23  */ {{{0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /24  */ {{{0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /25  */ {{{0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /26  */ {{{0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /27  */ {{{0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /28  */ {{{0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /29  */ {{{0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /30  */ {{{0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /31  */ {{{0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /32  */ {{{0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /33  */ {{{0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /34  */ {{{0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /35  */ {{{0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /36  */ {{{0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /37  */ {{{0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /38  */ {{{0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /39  */ {{{0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /40  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /41  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /42  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /43  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /44  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /45  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /46  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /47  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /48  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /49  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /50  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /51  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /52  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /53  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /54  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /55  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /56  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /57  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /58  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /59  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /60  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /61  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /62  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /63  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /64  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /65  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /66  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /67  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /68  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /69  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /70  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /71  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /72  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /73  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /74  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /75  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /76  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /77  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /78  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /79  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /80  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /81  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /82  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /83  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /84  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /85  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /86  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /87  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /88  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00}}}, -	/* /89  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00}}}, -	/* /90  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00}}}, -	/* /91  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00}}}, -	/* /92  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00}}}, -	/* /93  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00}}}, -	/* /94  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00}}}, -	/* /95  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00}}}, -	/* /96  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00}}}, -	/* /97  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00}}}, -	/* /98  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00}}}, -	/* /99  */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00}}}, -	/* /100 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00}}}, -	/* /101 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00}}}, -	/* /102 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00}}}, -	/* /103 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00}}}, -	/* /104 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00}}}, -	/* /105 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00}}}, -	/* /106 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00}}}, -	/* /107 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00}}}, -	/* /108 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00}}}, -	/* /109 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00}}}, -	/* /110 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00}}}, -	/* /111 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00}}}, -	/* /112 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00}}}, -	/* /113 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00}}}, -	/* /114 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00}}}, -	/* /115 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00}}}, -	/* /116 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00}}}, -	/* /117 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00}}}, -	/* /118 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00}}}, -	/* /119 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00}}}, -	/* /120 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00}}}, -	/* /121 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80}}}, -	/* /122 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0}}}, -	/* /123 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0}}}, -	/* /124 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0}}}, -	/* /125 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8}}}, -	/* /126 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc}}}, -	/* /127 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe}}}, -	/* /128 */ {{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -		      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}}}; +	/* /1   */ +	{{{0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /2   */ +	{{{0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /3   */ +	{{{0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /4   */ +	{{{0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /5   */ +	{{{0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /6   */ +	{{{0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /7   */ +	{{{0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /8   */ +	{{{0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /9   */ +	{{{0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /10  */ +	{{{0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /11  */ +	{{{0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /12  */ +	{{{0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /13  */ +	{{{0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /14  */ +	{{{0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /15  */ +	{{{0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /16  */ +	{{{0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /17  */ +	{{{0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /18  */ +	{{{0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /19  */ +	{{{0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /20  */ +	{{{0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /21  */ +	{{{0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /22  */ +	{{{0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /23  */ +	{{{0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /24  */ +	{{{0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /25  */ +	{{{0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /26  */ +	{{{0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /27  */ +	{{{0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /28  */ +	{{{0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /29  */ +	{{{0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /30  */ +	{{{0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /31  */ +	{{{0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /32  */ +	{{{0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /33  */ +	{{{0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /34  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /35  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /36  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /37  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /38  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /39  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /40  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /41  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /42  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /43  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /44  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /45  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /46  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /47  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /48  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /49  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /50  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /51  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /52  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /53  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /54  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /55  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /56  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /57  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /58  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /59  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /60  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /61  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /62  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /63  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /64  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /65  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /66  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /67  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /68  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /69  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /70  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /71  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /72  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /73  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /74  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /75  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /76  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /77  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /78  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /79  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /80  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /81  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /82  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /83  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /84  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /85  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /86  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /87  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /88  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0x00, 0x00, 0x00, 0x00, 0x00}}}, +	/* /89  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0x80, 0x00, 0x00, 0x00, 0x00}}}, +	/* /90  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xc0, 0x00, 0x00, 0x00, 0x00}}}, +	/* /91  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xe0, 0x00, 0x00, 0x00, 0x00}}}, +	/* /92  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xf0, 0x00, 0x00, 0x00, 0x00}}}, +	/* /93  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xf8, 0x00, 0x00, 0x00, 0x00}}}, +	/* /94  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xfc, 0x00, 0x00, 0x00, 0x00}}}, +	/* /95  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xfe, 0x00, 0x00, 0x00, 0x00}}}, +	/* /96  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0x00, 0x00, 0x00, 0x00}}}, +	/* /97  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0x80, 0x00, 0x00, 0x00}}}, +	/* /98  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0xc0, 0x00, 0x00, 0x00}}}, +	/* /99  */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0xe0, 0x00, 0x00, 0x00}}}, +	/* /100 */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0xf0, 0x00, 0x00, 0x00}}}, +	/* /101 */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0xf8, 0x00, 0x00, 0x00}}}, +	/* /102 */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0xfc, 0x00, 0x00, 0x00}}}, +	/* /103 */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0xfe, 0x00, 0x00, 0x00}}}, +	/* /104 */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0xff, 0x00, 0x00, 0x00}}}, +	/* /105 */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0xff, 0x80, 0x00, 0x00}}}, +	/* /106 */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0xff, 0xc0, 0x00, 0x00}}}, +	/* /107 */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0xff, 0xe0, 0x00, 0x00}}}, +	/* /108 */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0xff, 0xf0, 0x00, 0x00}}}, +	/* /109 */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0xff, 0xf8, 0x00, 0x00}}}, +	/* /110 */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0xff, 0xfc, 0x00, 0x00}}}, +	/* /111 */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0xff, 0xfe, 0x00, 0x00}}}, +	/* /112 */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0xff, 0xff, 0x00, 0x00}}}, +	/* /113 */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0xff, 0xff, 0x80, 0x00}}}, +	/* /114 */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0xff, 0xff, 0xc0, 0x00}}}, +	/* /115 */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0xff, 0xff, 0xe0, 0x00}}}, +	/* /116 */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0xff, 0xff, 0xf0, 0x00}}}, +	/* /117 */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0xff, 0xff, 0xf8, 0x00}}}, +	/* /118 */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0xff, 0xff, 0xfc, 0x00}}}, +	/* /119 */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0xff, 0xff, 0xfe, 0x00}}}, +	/* /120 */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0xff, 0xff, 0xff, 0x00}}}, +	/* /121 */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0xff, 0xff, 0xff, 0x80}}}, +	/* /122 */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0xff, 0xff, 0xff, 0xc0}}}, +	/* /123 */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0xff, 0xff, 0xff, 0xe0}}}, +	/* /124 */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0xff, 0xff, 0xff, 0xf0}}}, +	/* /125 */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0xff, 0xff, 0xff, 0xf8}}}, +	/* /126 */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0xff, 0xff, 0xff, 0xfc}}}, +	/* /127 */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0xff, 0xff, 0xff, 0xfe}}}, +	/* /128 */ +	{{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +	   0xff, 0xff, 0xff, 0xff, 0xff}}}};  /* Number of bits in prefix type. */  #ifndef PNBBY @@ -726,7 +854,7 @@ int str2prefix_eth(const char *str, struct prefix_eth *p)  	 * a comparison to zero, let's assume  	 */  	if (!slash && is_zero_mac(&(p->eth_addr))) -	    p->prefixlen = 0; +		p->prefixlen = 0;  	ret = 1; @@ -1047,11 +1175,10 @@ static const char *prefixevpn2str(const struct prefix *p, char *str, int size)  			 p->u.prefix_evpn.route_type, p->u.prefix_evpn.eth_tag,  			 inet_ntop(family, &p->u.prefix_evpn.ip.ip.addr, buf,  				   PREFIX2STR_BUFFER), -			 p->u.prefix_evpn.ip_prefix_length, -			 p->prefixlen); +			 p->u.prefix_evpn.ip_prefix_length, p->prefixlen);  	} else {  		sprintf(str, "Unsupported EVPN route type %d", -			 p->u.prefix_evpn.route_type); +			p->u.prefix_evpn.route_type);  	}  	return str; @@ -1264,6 +1391,7 @@ unsigned prefix_hash_key(void *pp)  	 * padding and unused prefix bytes. */  	memset(©, 0, sizeof(copy));  	prefix_copy(©, (struct prefix *)pp); -	return jhash(©, offsetof(struct prefix, u.prefix) -		     + PSIZE(copy.prefixlen), 0x55aa5a5a); +	return jhash(©, +		     offsetof(struct prefix, u.prefix) + PSIZE(copy.prefixlen), +		     0x55aa5a5a);  } diff --git a/lib/prefix.h b/lib/prefix.h index 5bf7d498c1..1724225817 100644 --- a/lib/prefix.h +++ b/lib/prefix.h @@ -310,9 +310,9 @@ extern void prefix_ipv4_free(struct prefix_ipv4 *);  extern int str2prefix_ipv4(const char *, struct prefix_ipv4 *);  extern void apply_mask_ipv4(struct prefix_ipv4 *); -#define PREFIX_COPY(DST, SRC)                                        \ +#define PREFIX_COPY(DST, SRC)                                                  \  	*((struct prefix *)(DST)) = *((const struct prefix *)(SRC)) -#define PREFIX_COPY_IPV4(DST, SRC)                                   \ +#define PREFIX_COPY_IPV4(DST, SRC)                                             \  	*((struct prefix_ipv4 *)(DST)) = *((const struct prefix_ipv4 *)(SRC));  extern int prefix_ipv4_any(const struct prefix_ipv4 *); @@ -380,15 +380,12 @@ static inline int is_default_prefix(const struct prefix *p)  	if (!p)  		return 0; -	if ((p->family == AF_INET) && -	    (p->u.prefix4.s_addr == INADDR_ANY) && -	    (p->prefixlen == 0)) +	if ((p->family == AF_INET) && (p->u.prefix4.s_addr == INADDR_ANY) +	    && (p->prefixlen == 0))  		return 1; -	if ((p->family == AF_INET6) && -	    (p->prefixlen == 0) && -	    (!memcmp(&p->u.prefix6, &in6addr_any, -		     sizeof(struct in6_addr)))) +	if ((p->family == AF_INET6) && (p->prefixlen == 0) +	    && (!memcmp(&p->u.prefix6, &in6addr_any, sizeof(struct in6_addr))))  		return 1;  	return 0; diff --git a/lib/qobj.c b/lib/qobj.c index c75002052e..c3f1a27c82 100644 --- a/lib/qobj.c +++ b/lib/qobj.c @@ -98,9 +98,7 @@ void qobj_init(void)  {  	if (!nodes) {  		pthread_rwlock_init(&nodes_lock, NULL); -		nodes = hash_create_size(16, qobj_key, -					 qobj_cmp, -					 "QOBJ Hash"); +		nodes = hash_create_size(16, qobj_key, qobj_cmp, "QOBJ Hash");  	}  } diff --git a/lib/queue.h b/lib/queue.h index 29b67a26e6..04fbeee700 100644 --- a/lib/queue.h +++ b/lib/queue.h @@ -40,8 +40,7 @@  	(SIMPLEQ_EMPTY((head))                                                 \  		 ? NULL                                                        \  		 : ((struct type *)(void *)((char *)((head)->sqh_last)         \ -					    - offsetof(struct type,            \ -							 field)))) +					    - offsetof(struct type, field))))  #define STAILQ_NEXT(elm, field)				SIMPLEQ_NEXT(elm, field)  #define STAILQ_REMOVE(head, elm, type, field)                                  \  	do {                                                                   \ diff --git a/lib/ringbuf.c b/lib/ringbuf.c index 11db502a94..1c3c3e9753 100644 --- a/lib/ringbuf.c +++ b/lib/ringbuf.c @@ -96,7 +96,7 @@ size_t ringbuf_peek(struct ringbuf *buf, size_t offset, void *data, size_t size)  	size_t remain = ringbuf_remain(buf);  	if (offset >= remain)  		return 0; -	size_t copysize = MAX(MIN(remain - offset, size), (size_t) 0); +	size_t copysize = MAX(MIN(remain - offset, size), (size_t)0);  	size_t tocopy = copysize;  	size_t cstart = (buf->start + offset) % buf->size;  	if (tocopy >= buf->size - cstart) { diff --git a/lib/routemap.c b/lib/routemap.c index 175e099994..ea61043a8d 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -423,8 +423,7 @@ int generic_match_add(struct vty *vty, struct route_map_index *index,  		}  		break;  	case RMAP_RULE_MISSING: -		vty_out(vty, "%% [%s] Can't find rule.\n", -			frr_protonameinst); +		vty_out(vty, "%% [%s] Can't find rule.\n", frr_protonameinst);  		return CMD_WARNING_CONFIG_FAILED;  		break;  	case RMAP_COMPILE_ERROR: @@ -464,8 +463,7 @@ int generic_match_delete(struct vty *vty, struct route_map_index *index,  	ret = route_map_delete_match(index, command, dep_name);  	switch (ret) {  	case RMAP_RULE_MISSING: -		vty_out(vty, "%% [%s] Can't find rule.\n", -			frr_protonameinst); +		vty_out(vty, "%% [%s] Can't find rule.\n", frr_protonameinst);  		retval = CMD_WARNING_CONFIG_FAILED;  		break;  	case RMAP_COMPILE_ERROR: @@ -496,8 +494,7 @@ int generic_set_add(struct vty *vty, struct route_map_index *index,  	ret = route_map_add_set(index, command, arg);  	switch (ret) {  	case RMAP_RULE_MISSING: -		vty_out(vty, "%% [%s] Can't find rule.\n", -			frr_protonameinst); +		vty_out(vty, "%% [%s] Can't find rule.\n", frr_protonameinst);  		return CMD_WARNING_CONFIG_FAILED;  		break;  	case RMAP_COMPILE_ERROR: @@ -521,8 +518,7 @@ int generic_set_delete(struct vty *vty, struct route_map_index *index,  	ret = route_map_delete_set(index, command, arg);  	switch (ret) {  	case RMAP_RULE_MISSING: -		vty_out(vty, "%% [%s] Can't find rule.\n", -			frr_protonameinst); +		vty_out(vty, "%% [%s] Can't find rule.\n", frr_protonameinst);  		return CMD_WARNING_CONFIG_FAILED;  		break;  	case RMAP_COMPILE_ERROR: @@ -1581,10 +1577,9 @@ static void *route_map_dep_hash_alloc(void *p)  	dep_entry = XCALLOC(MTYPE_ROUTE_MAP_DEP, sizeof(struct route_map_dep));  	dep_entry->dep_name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, dep_name); -	dep_entry->dep_rmap_hash = hash_create_size(8, -						    route_map_dep_hash_make_key, -						    route_map_rmap_hash_cmp, -						    "Route Map Dep Hash"); +	dep_entry->dep_rmap_hash = +		hash_create_size(8, route_map_dep_hash_make_key, +				 route_map_rmap_hash_cmp, "Route Map Dep Hash");  	dep_entry->this_hash = NULL;  	return ((void *)dep_entry); @@ -2786,15 +2781,13 @@ void route_map_init(void)  	route_match_vec = vector_init(1);  	route_set_vec = vector_init(1);  	route_map_master_hash = -		hash_create_size(8, route_map_hash_key_make, -				 route_map_hash_cmp, +		hash_create_size(8, route_map_hash_key_make, route_map_hash_cmp,  				 "Route Map Master Hash");  	for (i = 1; i < ROUTE_MAP_DEP_MAX; i++) -		route_map_dep_hash[i] = -			hash_create_size(8, route_map_dep_hash_make_key, -					 route_map_dep_hash_cmp, -					 "Route Map Dep Hash"); +		route_map_dep_hash[i] = hash_create_size( +			8, route_map_dep_hash_make_key, route_map_dep_hash_cmp, +			"Route Map Dep Hash");  	cmd_variable_handler_register(rmap_var_handlers); diff --git a/lib/routemap.h b/lib/routemap.h index 8c00e8104c..0046b77c46 100644 --- a/lib/routemap.h +++ b/lib/routemap.h @@ -98,15 +98,13 @@ struct route_map_rule_cmd {  };  /* Route map apply error. */ -enum { -	RMAP_COMPILE_SUCCESS, +enum { RMAP_COMPILE_SUCCESS, -	/* Route map rule is missing. */ -	RMAP_RULE_MISSING, +       /* Route map rule is missing. */ +       RMAP_RULE_MISSING, -	/* Route map rule can't compile */ -	RMAP_COMPILE_ERROR -}; +       /* Route map rule can't compile */ +       RMAP_COMPILE_ERROR };  /* Route map rule list. */  struct route_map_rule_list { diff --git a/lib/sbuf.h b/lib/sbuf.h index 3e49ada6c2..c38e96912f 100644 --- a/lib/sbuf.h +++ b/lib/sbuf.h @@ -53,8 +53,10 @@   *         return 1;   * }   * - * In this case, sbuf_example uses a string buffer with undefined size, which will - * be allocated on the heap by sbuf. The caller of sbuf_example is expected to free + * In this case, sbuf_example uses a string buffer with undefined size, which + * will + * be allocated on the heap by sbuf. The caller of sbuf_example is expected to + * free   * the string returned in parser_log.   */ diff --git a/lib/spf_backoff.c b/lib/spf_backoff.c index d7907fafdf..c420c25f04 100644 --- a/lib/spf_backoff.c +++ b/lib/spf_backoff.c @@ -227,7 +227,8 @@ void spf_backoff_show(struct spf_backoff *backoff, struct vty *vty,  		struct timeval remain =  			thread_timer_remain(backoff->t_holddown);  		vty_out(vty, "%s                   Still runs for %lld msec\n", -			prefix, (long long)remain.tv_sec * 1000 +			prefix, +			(long long)remain.tv_sec * 1000  				+ remain.tv_usec / 1000);  	} else {  		vty_out(vty, "%s                   Inactive\n", prefix); @@ -239,7 +240,8 @@ void spf_backoff_show(struct spf_backoff *backoff, struct vty *vty,  		struct timeval remain =  			thread_timer_remain(backoff->t_timetolearn);  		vty_out(vty, "%s                   Still runs for %lld msec\n", -			prefix, (long long)remain.tv_sec * 1000 +			prefix, +			(long long)remain.tv_sec * 1000  				+ remain.tv_usec / 1000);  	} else {  		vty_out(vty, "%s                   Inactive\n", prefix); diff --git a/lib/stream.c b/lib/stream.c index 0eb790b753..3c08d4454b 100644 --- a/lib/stream.c +++ b/lib/stream.c @@ -65,19 +65,19 @@ DEFINE_MTYPE_STATIC(LIB, STREAM_FIFO, "Stream FIFO")  		assert(ENDP_VALID(S, (S)->endp));                              \  	} while (0) -#define STREAM_BOUND_WARN(S, WHAT)					\ -	do {								\ -		zlog_warn("%s: Attempt to %s out of bounds", __func__,	\ -			  (WHAT));					\ -		STREAM_WARN_OFFSETS(S);					\ -		assert(0);						\ +#define STREAM_BOUND_WARN(S, WHAT)                                             \ +	do {                                                                   \ +		zlog_warn("%s: Attempt to %s out of bounds", __func__,         \ +			  (WHAT));                                             \ +		STREAM_WARN_OFFSETS(S);                                        \ +		assert(0);                                                     \  	} while (0) -#define STREAM_BOUND_WARN2(S, WHAT)					\ -	do {								\ -		zlog_warn("%s: Attempt to %s out of bounds", __func__,	\ -			  (WHAT));					\ -		STREAM_WARN_OFFSETS(S);					\ +#define STREAM_BOUND_WARN2(S, WHAT)                                            \ +	do {                                                                   \ +		zlog_warn("%s: Attempt to %s out of bounds", __func__,         \ +			  (WHAT));                                             \ +		STREAM_WARN_OFFSETS(S);                                        \  	} while (0)  /* XXX: Deprecated macro: do not use */ @@ -353,7 +353,7 @@ inline bool stream_getw2(struct stream *s, uint16_t *word)  		return false;  	} -	*word  = s->data[s->getp++] << 8; +	*word = s->data[s->getp++] << 8;  	*word |= s->data[s->getp++];  	return true; @@ -474,13 +474,12 @@ inline bool stream_getl2(struct stream *s, uint32_t *l)  		return false;  	} -	*l  = (unsigned int)(s->data[s->getp++]) << 24; +	*l = (unsigned int)(s->data[s->getp++]) << 24;  	*l |= s->data[s->getp++] << 16;  	*l |= s->data[s->getp++] << 8;  	*l |= s->data[s->getp++];  	return true; -  }  u_int32_t stream_getl(struct stream *s) diff --git a/lib/stream.h b/lib/stream.h index 4d387f9564..e738040d34 100644 --- a/lib/stream.h +++ b/lib/stream.h @@ -281,34 +281,34 @@ static inline uint8_t *ptr_get_be32(uint8_t *ptr, uint32_t *out)   * the stream functions but we need a transition   * plan.   */ -#define STREAM_GETC(S, P)			\ -	do {					\ -		uint8_t	_pval;			\ -		if (!stream_getc2((S), &_pval))	\ -			goto stream_failure;	\ -		(P) = _pval;			\ +#define STREAM_GETC(S, P)                                                      \ +	do {                                                                   \ +		uint8_t _pval;                                                 \ +		if (!stream_getc2((S), &_pval))                                \ +			goto stream_failure;                                   \ +		(P) = _pval;                                                   \  	} while (0) -#define STREAM_GETW(S, P)			\ -	do {					\ -		uint16_t _pval;			\ -		if (!stream_getw2((S), &_pval))	\ -			goto stream_failure;	\ -		(P) = _pval;			\ +#define STREAM_GETW(S, P)                                                      \ +	do {                                                                   \ +		uint16_t _pval;                                                \ +		if (!stream_getw2((S), &_pval))                                \ +			goto stream_failure;                                   \ +		(P) = _pval;                                                   \  	} while (0) -#define STREAM_GETL(S, P)				\ -	do {						\ -		uint32_t _pval;				\ -		if (!stream_getl2((S), &_pval))		\ -			goto stream_failure;		\ -		(P) = _pval;				\ +#define STREAM_GETL(S, P)                                                      \ +	do {                                                                   \ +		uint32_t _pval;                                                \ +		if (!stream_getl2((S), &_pval))                                \ +			goto stream_failure;                                   \ +		(P) = _pval;                                                   \  	} while (0) -#define STREAM_GET(P, STR, SIZE)			\ -	do {						\ -		if (!stream_get2((P), (STR), (SIZE)))	\ -			goto stream_failure;		\ +#define STREAM_GET(P, STR, SIZE)                                               \ +	do {                                                                   \ +		if (!stream_get2((P), (STR), (SIZE)))                          \ +			goto stream_failure;                                   \  	} while (0)  #endif /* _ZEBRA_STREAM_H */ diff --git a/lib/thread.c b/lib/thread.c index 9d64663d9c..a221c77628 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -59,7 +59,7 @@ static struct list *masters;  /* CLI start ---------------------------------------------------------------- */  static unsigned int cpu_record_hash_key(struct cpu_thread_history *a)  { -	int size = sizeof (&a->func); +	int size = sizeof(&a->func);  	return jhash(&a->func, size, 0);  } @@ -380,8 +380,7 @@ struct thread_master *thread_master_create(const char *name)  	}  	rv->cpu_record = hash_create_size( -		8, -		(unsigned int (*)(void *))cpu_record_hash_key, +		8, (unsigned int (*)(void *))cpu_record_hash_key,  		(int (*)(const void *, const void *))cpu_record_hash_cmp,  		"Thread Hash"); @@ -937,7 +936,7 @@ static void thread_cancel_rw(struct thread_master *master, int fd, short state)  		zlog_debug(  			"[!] Received cancellation request for nonexistent rw job");  		zlog_debug("[!] threadmaster: %s | fd: %d", -			 master->name ? master->name : "", fd); +			   master->name ? master->name : "", fd);  		return;  	} @@ -150,8 +150,8 @@ struct vrf *vrf_get(vrf_id_t vrf_id, const char *name)  	int new = 0;  	if (debug_vrf) -		zlog_debug("VRF_GET: %s(%u)", -			   name == NULL ? "(NULL)" : name, vrf_id); +		zlog_debug("VRF_GET: %s(%u)", name == NULL ? "(NULL)" : name, +			   vrf_id);  	/* Nothing to see, move along here */  	if (!name && vrf_id == VRF_UNKNOWN) @@ -500,14 +500,14 @@ int vrf_socket(int domain, int type, int protocol, vrf_id_t vrf_id,  	ret = vrf_switch_to_netns(vrf_id);  	if (ret < 0) -		zlog_err("%s: Can't switch to VRF %u (%s)", -			 __func__, vrf_id, safe_strerror(errno)); +		zlog_err("%s: Can't switch to VRF %u (%s)", __func__, vrf_id, +			 safe_strerror(errno));  	ret = socket(domain, type, protocol);  	save_errno = errno;  	ret2 = vrf_switchback_to_initial();  	if (ret2 < 0) -		zlog_err("%s: Can't switchback from VRF %u (%s)", -			 __func__, vrf_id, safe_strerror(errno)); +		zlog_err("%s: Can't switchback from VRF %u (%s)", __func__, +			 vrf_id, safe_strerror(errno));  	errno = save_errno;  	if (ret <= 0)  		return ret; @@ -541,12 +541,12 @@ int vrf_handler_create(struct vty *vty, const char *vrfname, struct vrf **vrf)  	if (strlen(vrfname) > VRF_NAMSIZ) {  		if (vty)  			vty_out(vty, -			   "%% VRF name %s invalid: length exceeds %d bytes\n", -			   vrfname, VRF_NAMSIZ); +				"%% VRF name %s invalid: length exceeds %d bytes\n", +				vrfname, VRF_NAMSIZ);  		else  			zlog_warn( -			   "%% VRF name %s invalid: length exceeds %d bytes\n", -			   vrfname, VRF_NAMSIZ); +				"%% VRF name %s invalid: length exceeds %d bytes\n", +				vrfname, VRF_NAMSIZ);  		return CMD_WARNING_CONFIG_FAILED;  	} @@ -560,8 +560,8 @@ int vrf_handler_create(struct vty *vty, const char *vrfname, struct vrf **vrf)  	return CMD_SUCCESS;  } -int vrf_netns_handler_create(struct vty *vty, struct vrf *vrf, -			     char *pathname, ns_id_t ns_id) +int vrf_netns_handler_create(struct vty *vty, struct vrf *vrf, char *pathname, +			     ns_id_t ns_id)  {  	struct ns *ns = NULL; @@ -578,16 +578,16 @@ int vrf_netns_handler_create(struct vty *vty, struct vrf *vrf,  		return CMD_WARNING_CONFIG_FAILED;  	}  	if (vrf->ns_ctxt != NULL) { -		ns = (struct ns *) vrf->ns_ctxt; +		ns = (struct ns *)vrf->ns_ctxt;  		if (ns && 0 != strcmp(ns->name, pathname)) {  			if (vty)  				vty_out(vty, -				   "VRF %u already configured with NETNS %s\n", -				   vrf->vrf_id, ns->name); +					"VRF %u already configured with NETNS %s\n", +					vrf->vrf_id, ns->name);  			else  				zlog_warn( -				  "VRF %u already configured with NETNS %s", -				  vrf->vrf_id, ns->name); +					"VRF %u already configured with NETNS %s", +					vrf->vrf_id, ns->name);  			return CMD_WARNING_CONFIG_FAILED;  		}  	} @@ -598,9 +598,10 @@ int vrf_netns_handler_create(struct vty *vty, struct vrf *vrf,  		if (vrf2 == vrf)  			return CMD_SUCCESS;  		if (vty) -			vty_out(vty, "NS %s is already configured" +			vty_out(vty, +				"NS %s is already configured"  				" with VRF %u(%s)\n", -			    ns->name, vrf2->vrf_id, vrf2->name); +				ns->name, vrf2->vrf_id, vrf2->name);  		else  			zlog_warn("NS %s is already configured with VRF %u(%s)",  				  ns->name, vrf2->vrf_id, vrf2->name); @@ -616,7 +617,7 @@ int vrf_netns_handler_create(struct vty *vty, struct vrf *vrf,  	if (!ns_enable(ns, vrf_update_vrf_id)) {  		if (vty)  			vty_out(vty, "Can not associate NS %u with NETNS %s\n", -			    ns->ns_id, ns->name); +				ns->ns_id, ns->name);  		else  			zlog_warn("Can not associate NS %u with NETNS %s",  				  ns->ns_id, ns->name); @@ -812,30 +813,29 @@ int vrf_bind(vrf_id_t vrf_id, int fd, char *name)  	if (vrf_is_mapped_on_netns(vrf_id))  		return fd;  #ifdef SO_BINDTODEVICE -	ret = setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, name, -			 strlen(name)); +	ret = setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, name, strlen(name));  	if (ret < 0) -		zlog_debug("bind to interface %s failed, errno=%d", -			   name, errno); +		zlog_debug("bind to interface %s failed, errno=%d", name, +			   errno);  #endif /* SO_BINDTODEVICE */  	return ret;  }  int vrf_getaddrinfo(const char *node, const char *service, -		    const struct addrinfo *hints, -		    struct addrinfo **res, vrf_id_t vrf_id) +		    const struct addrinfo *hints, struct addrinfo **res, +		    vrf_id_t vrf_id)  {  	int ret, ret2, save_errno;  	ret = vrf_switch_to_netns(vrf_id);  	if (ret < 0) -		zlog_err("%s: Can't switch to VRF %u (%s)", -			 __func__, vrf_id, safe_strerror(errno)); +		zlog_err("%s: Can't switch to VRF %u (%s)", __func__, vrf_id, +			 safe_strerror(errno));  	ret = getaddrinfo(node, service, hints, res);  	save_errno = errno;  	ret2 = vrf_switchback_to_initial();  	if (ret2 < 0) -		zlog_err("%s: Can't switchback from VRF %u (%s)", -			 __func__, vrf_id, safe_strerror(errno)); +		zlog_err("%s: Can't switchback from VRF %u (%s)", __func__, +			 vrf_id, safe_strerror(errno));  	errno = save_errno;  	return ret;  } @@ -846,16 +846,16 @@ int vrf_ioctl(vrf_id_t vrf_id, int d, unsigned long request, char *params)  	ret = vrf_switch_to_netns(vrf_id);  	if (ret < 0) { -		zlog_err("%s: Can't switch to VRF %u (%s)", -			 __func__, vrf_id, safe_strerror(errno)); +		zlog_err("%s: Can't switch to VRF %u (%s)", __func__, vrf_id, +			 safe_strerror(errno));  		return 0;  	}  	rc = ioctl(d, request, params);  	saved_errno = errno;  	ret = vrf_switchback_to_initial();  	if (ret < 0) -		zlog_err("%s: Can't switchback from VRF %u (%s)", -			 __func__, vrf_id, safe_strerror(errno)); +		zlog_err("%s: Can't switchback from VRF %u (%s)", __func__, +			 vrf_id, safe_strerror(errno));  	errno = saved_errno;  	return rc;  } @@ -867,14 +867,14 @@ int vrf_sockunion_socket(const union sockunion *su, vrf_id_t vrf_id,  	ret = vrf_switch_to_netns(vrf_id);  	if (ret < 0) -		zlog_err("%s: Can't switch to VRF %u (%s)", -			 __func__, vrf_id, safe_strerror(errno)); +		zlog_err("%s: Can't switch to VRF %u (%s)", __func__, vrf_id, +			 safe_strerror(errno));  	ret = sockunion_socket(su);  	save_errno = errno;  	ret2 = vrf_switchback_to_initial();  	if (ret2 < 0) -		zlog_err("%s: Can't switchback from VRF %u (%s)", -			 __func__, vrf_id, safe_strerror(errno)); +		zlog_err("%s: Can't switchback from VRF %u (%s)", __func__, +			 vrf_id, safe_strerror(errno));  	errno = save_errno;  	if (ret <= 0) @@ -206,19 +206,18 @@ extern void vrf_terminate(void);   */  /* Create a socket serving for the given VRF */ -extern int vrf_socket(int domain, int type, -		      int protocol, vrf_id_t vrf_id, +extern int vrf_socket(int domain, int type, int protocol, vrf_id_t vrf_id,  		      char *name); -extern int vrf_sockunion_socket(const union sockunion *su, -				vrf_id_t vrf_id, char *name); +extern int vrf_sockunion_socket(const union sockunion *su, vrf_id_t vrf_id, +				char *name);  extern int vrf_bind(vrf_id_t vrf_id, int fd, char *name);  /* VRF ioctl operations */  extern int vrf_getaddrinfo(const char *node, const char *service, -		    const struct addrinfo *hints, -		    struct addrinfo **res, vrf_id_t vrf_id); +			   const struct addrinfo *hints, struct addrinfo **res, +			   vrf_id_t vrf_id);  extern int vrf_ioctl(vrf_id_t vrf_id, int d, unsigned long request, char *args); @@ -264,8 +263,7 @@ extern int vrf_is_backend_netns(void);  /* API to create a VRF. either from vty   * or through discovery   */ -extern int vrf_handler_create(struct vty *vty, -			      const char *name, +extern int vrf_handler_create(struct vty *vty, const char *name,  			      struct vrf **vrf);  /* API to associate a VRF with a NETNS. @@ -273,7 +271,7 @@ extern int vrf_handler_create(struct vty *vty,   * should be called from zebra only   */  extern int vrf_netns_handler_create(struct vty *vty, struct vrf *vrf, -			     char *pathname, ns_id_t ns_id); +				    char *pathname, ns_id_t ns_id);  /* used internally to enable or disable VRF.   * Notify a change in the VRF ID of the VRF @@ -2287,7 +2287,8 @@ static void vty_read_file(FILE *confp)  			message = "Command returned Incomplete";  			break;  		case CMD_ERR_EXEED_ARGC_MAX: -			message = "Command exceeded maximum number of Arguments"; +			message = +				"Command exceeded maximum number of Arguments";  			break;  		default:  			message = "Command returned unhandled error message"; @@ -2297,8 +2298,8 @@ static void vty_read_file(FILE *confp)  		nl = strchr(vty->error_buf, '\n');  		if (nl)  			*nl = '\0'; -		zlog_err("ERROR: %s on config line %u: %s", -			 message, line_num, vty->error_buf); +		zlog_err("ERROR: %s on config line %u: %s", message, line_num, +			 vty->error_buf);  	}  	vty_close(vty); @@ -2370,7 +2371,8 @@ void vty_read_config(const char *config_file, char *config_default_dir)  	if (config_file != NULL) {  		if (!IS_DIRECTORY_SEP(config_file[0])) {  			if (getcwd(cwd, MAXPATHLEN) == NULL) { -				zlog_err("Failure to determine Current Working Directory %d!", +				zlog_err( +					"Failure to determine Current Working Directory %d!",  					errno);  				exit(1);  			} @@ -2385,14 +2387,15 @@ void vty_read_config(const char *config_file, char *config_default_dir)  		if (confp == NULL) {  			zlog_err("%s: failed to open configuration file %s: %s", -				__func__, fullpath, safe_strerror(errno)); +				 __func__, fullpath, safe_strerror(errno));  			confp = vty_use_backup_config(fullpath);  			if (confp) -				zlog_warn("WARNING: using backup configuration file!"); +				zlog_warn( +					"WARNING: using backup configuration file!");  			else {  				zlog_err("can't open configuration file [%s]", -					config_file); +					 config_file);  				exit(1);  			}  		} @@ -2427,16 +2430,17 @@ void vty_read_config(const char *config_file, char *config_default_dir)  		confp = fopen(config_default_dir, "r");  		if (confp == NULL) {  			zlog_err("%s: failed to open configuration file %s: %s", -				__func__, config_default_dir, -				safe_strerror(errno)); +				 __func__, config_default_dir, +				 safe_strerror(errno));  			confp = vty_use_backup_config(config_default_dir);  			if (confp) { -				zlog_warn("WARNING: using backup configuration file!"); +				zlog_warn( +					"WARNING: using backup configuration file!");  				fullpath = config_default_dir;  			} else {  				zlog_err("can't open configuration file [%s]", -					config_default_dir); +					 config_default_dir);  				goto tmp_free_and_out;  			}  		} else @@ -2946,12 +2950,11 @@ static void vty_save_cwd(void)  		 */  		if (!chdir(SYSCONFDIR)) {  			zlog_err("Failure to chdir to %s, errno: %d", -				SYSCONFDIR, errno); +				 SYSCONFDIR, errno);  			exit(-1);  		}  		if (getcwd(cwd, MAXPATHLEN) == NULL) { -			zlog_err("Failure to getcwd, errno: %d", -				errno); +			zlog_err("Failure to getcwd, errno: %d", errno);  			exit(-1);  		}  	} @@ -174,8 +174,8 @@ static inline void vty_push_context(struct vty *vty, int node, uint64_t id)  	struct structname *ptr = VTY_GET_CONTEXT_SUB(structname);              \  	VTY_CHECK_CONTEXT(ptr);  #define VTY_DECLVAR_INSTANCE_CONTEXT(structname, ptr)                          \ -	if (vty->qobj_index == 0)					       \ -		return CMD_NOT_MY_INSTANCE;				       \ +	if (vty->qobj_index == 0)                                              \ +		return CMD_NOT_MY_INSTANCE;                                    \  	struct structname *ptr = VTY_GET_CONTEXT(structname);                  \  	VTY_CHECK_CONTEXT(ptr); diff --git a/lib/workqueue.c b/lib/workqueue.c index 952012a006..d4ff3ee6ce 100644 --- a/lib/workqueue.c +++ b/lib/workqueue.c @@ -127,8 +127,8 @@ bool work_queue_is_scheduled(struct work_queue *wq)  static int work_queue_schedule(struct work_queue *wq, unsigned int delay)  {  	/* if appropriate, schedule work queue thread */ -	if (CHECK_FLAG(wq->flags, WQ_UNPLUGGED) && (wq->thread == NULL) && -	    !work_queue_empty(wq)) { +	if (CHECK_FLAG(wq->flags, WQ_UNPLUGGED) && (wq->thread == NULL) +	    && !work_queue_empty(wq)) {  		wq->thread = NULL;  		thread_add_timer_msec(wq->master, work_queue_run, wq, delay,  				      &wq->thread); @@ -159,7 +159,8 @@ void work_queue_add(struct work_queue *wq, void *data)  	return;  } -static void work_queue_item_requeue(struct work_queue *wq, struct work_queue_item *item) +static void work_queue_item_requeue(struct work_queue *wq, +				    struct work_queue_item *item)  {  	work_queue_item_dequeue(wq, item); diff --git a/lib/workqueue.h b/lib/workqueue.h index df35d44fbc..de49cb87fb 100644 --- a/lib/workqueue.h +++ b/lib/workqueue.h @@ -93,8 +93,9 @@ struct work_queue {  	} spec;  	/* remaining fields should be opaque to users */ -	STAILQ_HEAD(work_queue_items, work_queue_item) items; /* queue item list */ -	int item_count; /* queued items */ +	STAILQ_HEAD(work_queue_items, work_queue_item) +	items;		      /* queue item list */ +	int item_count;       /* queued items */  	unsigned long runs;   /* runs count */  	unsigned long yields; /* yields count */ @@ -120,7 +121,8 @@ static inline bool work_queue_empty(struct work_queue *wq)  	return (wq->item_count == 0) ? true : false;  } -static inline struct work_queue_item *work_queue_last_item(struct work_queue *wq) +static inline struct work_queue_item * +work_queue_last_item(struct work_queue *wq)  {  	return STAILQ_LAST(&wq->items, work_queue_item, wq);  } diff --git a/lib/zclient.c b/lib/zclient.c index 8535c3b5f5..f853824bbb 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -52,7 +52,7 @@ socklen_t zclient_addr_len;  /* This file local debug flag. */  int zclient_debug = 0; -struct zclient_options zclient_options_default = { .receive_notify = false }; +struct zclient_options zclient_options_default = {.receive_notify = false};  /* Allocate zclient structure. */  struct zclient *zclient_new_notify(struct thread_master *master, @@ -186,8 +186,8 @@ void zclient_reset(struct zclient *zclient)  			&zclient->mi_redist[afi][zclient->redist_default],  			zclient->instance); -	zclient_init(zclient, zclient->redist_default, -		     zclient->instance, zclient->privs); +	zclient_init(zclient, zclient->redist_default, zclient->instance, +		     zclient->privs);  }  /** @@ -214,8 +214,7 @@ int zclient_socket_connect(struct zclient *zclient)  	zclient->privs->change(ZPRIVS_LOWER);  	/* Connect to zebra. */ -	ret = connect(sock, (struct sockaddr *)&zclient_addr, -			zclient_addr_len); +	ret = connect(sock, (struct sockaddr *)&zclient_addr, zclient_addr_len);  	if (ret < 0) {  		if (zclient_debug)  			zlog_warn("%s connect failure: %d(%s)", @@ -416,13 +415,13 @@ void zclient_send_reg_requests(struct zclient *zclient, vrf_id_t vrf_id)  				for (ALL_LIST_ELEMENTS_RO(  					     zclient->mi_redist[afi][i] -					     .instances, node, id)) +						     .instances, +					     node, id))  					if (!(i == zclient->redist_default  					      && *id == zclient->instance))  						zebra_redistribute_send(  							ZEBRA_REDISTRIBUTE_ADD, -							zclient, afi, i, -							*id, +							zclient, afi, i, *id,  							VRF_DEFAULT);  			}  		} @@ -481,13 +480,13 @@ void zclient_send_dereg_requests(struct zclient *zclient, vrf_id_t vrf_id)  				for (ALL_LIST_ELEMENTS_RO(  					     zclient->mi_redist[afi][i] -					     .instances, node, id)) +						     .instances, +					     node, id))  					if (!(i == zclient->redist_default  					      && *id == zclient->instance))  						zebra_redistribute_send(  							ZEBRA_REDISTRIBUTE_DELETE, -							zclient, afi, i, -							*id, +							zclient, afi, i, *id,  							VRF_DEFAULT);  			}  		} @@ -583,8 +582,8 @@ int zclient_start(struct zclient *zclient)  /* Initialize zebra client.  Argument redist_default is unwanted     redistribute route type. */ -void zclient_init(struct zclient *zclient, int redist_default, -		  u_short instance, struct zebra_privs_t *privs) +void zclient_init(struct zclient *zclient, int redist_default, u_short instance, +		  struct zebra_privs_t *privs)  {  	int afi, i; @@ -1021,8 +1020,9 @@ int zapi_route_encode(u_char cmd, struct stream *s, struct zapi_route *api)  				stream_putl(s, api_nh->ifindex);  				break;  			default: -				zlog_warn("%s: Specified Nexthop type %d does not exist", -					  __PRETTY_FUNCTION__, api_nh->type); +				zlog_warn( +					"%s: Specified Nexthop type %d does not exist", +					__PRETTY_FUNCTION__, api_nh->type);  				return -1;  			} @@ -1076,7 +1076,7 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)  	STREAM_GETC(s, api->type);  	if (api->type > ZEBRA_ROUTE_MAX) {  		zlog_warn("%s: Specified route type: %d is not a legal value\n", -			   __PRETTY_FUNCTION__, api->type); +			  __PRETTY_FUNCTION__, api->type);  		return -1;  	} @@ -1093,15 +1093,17 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)  	switch (api->prefix.family) {  	case AF_INET:  		if (api->prefix.prefixlen > IPV4_MAX_PREFIXLEN) { -			zlog_warn("%s: V4 prefixlen is %d which should not be more than 32", -				  __PRETTY_FUNCTION__, api->prefix.prefixlen); +			zlog_warn( +				"%s: V4 prefixlen is %d which should not be more than 32", +				__PRETTY_FUNCTION__, api->prefix.prefixlen);  			return -1;  		}  		break;  	case AF_INET6:  		if (api->prefix.prefixlen > IPV6_MAX_PREFIXLEN) { -			zlog_warn("%s: v6 prefixlen is %d which should not be more than 128", -				  __PRETTY_FUNCTION__, api->prefix.prefixlen); +			zlog_warn( +				"%s: v6 prefixlen is %d which should not be more than 128", +				__PRETTY_FUNCTION__, api->prefix.prefixlen);  			return -1;  		}  		break; @@ -1116,9 +1118,9 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)  		api->src_prefix.family = AF_INET6;  		STREAM_GETC(s, api->src_prefix.prefixlen);  		if (api->src_prefix.prefixlen > IPV6_MAX_PREFIXLEN) { -			zlog_warn("%s: SRC Prefix prefixlen received: %d is too large", -				  __PRETTY_FUNCTION__, -				  api->src_prefix.prefixlen); +			zlog_warn( +				"%s: SRC Prefix prefixlen received: %d is too large", +				__PRETTY_FUNCTION__, api->src_prefix.prefixlen);  			return -1;  		}  		STREAM_GET(&api->src_prefix.prefix, s, @@ -1126,8 +1128,9 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)  		if (api->prefix.family != AF_INET6  		    || api->src_prefix.prefixlen == 0) { -			zlog_warn("%s: SRC prefix specified in some manner that makes no sense", -				  __PRETTY_FUNCTION__); +			zlog_warn( +				"%s: SRC prefix specified in some manner that makes no sense", +				__PRETTY_FUNCTION__);  			return -1;  		}  	} @@ -1170,9 +1173,9 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)  				STREAM_GETL(s, api_nh->ifindex);  				break;  			default: -				zlog_warn("%s: Specified nexthop type %d does not exist", -					  __PRETTY_FUNCTION__, -					  api_nh->type); +				zlog_warn( +					"%s: Specified nexthop type %d does not exist", +					__PRETTY_FUNCTION__, api_nh->type);  				return -1;  			} @@ -1219,8 +1222,7 @@ bool zapi_route_notify_decode(struct stream *s, struct prefix *p,  	STREAM_GETC(s, p->family);  	STREAM_GETC(s, p->prefixlen); -	STREAM_GET(&p->u.prefix, s, -		   prefix_blen(p)); +	STREAM_GET(&p->u.prefix, s, prefix_blen(p));  	STREAM_GETL(s, t);  	*tableid = t; @@ -1255,7 +1257,7 @@ bool zapi_nexthop_update_decode(struct stream *s, struct zapi_route *nhr)  	STREAM_GETW(s, nhr->prefix.family);  	STREAM_GETC(s, nhr->prefix.prefixlen); -	switch(nhr->prefix.family) { +	switch (nhr->prefix.family) {  	case AF_INET:  		STREAM_GET(&nhr->prefix.u.prefix4.s_addr, s, IPV4_MAX_BYTELEN);  		break; @@ -1272,13 +1274,13 @@ bool zapi_nexthop_update_decode(struct stream *s, struct zapi_route *nhr)  	STREAM_GETL(s, nhr->metric);  	STREAM_GETC(s, nhr->nexthop_num); -	for (i = 0; i < nhr->nexthop_num ; i++) { +	for (i = 0; i < nhr->nexthop_num; i++) {  		STREAM_GETC(s, nhr->nexthops[i].type);  		switch (nhr->nexthops[i].type) {  		case NEXTHOP_TYPE_IPV4:  		case NEXTHOP_TYPE_IPV4_IFINDEX: -			STREAM_GET(&nhr->nexthops[i].gate.ipv4.s_addr, -				   s, IPV4_MAX_BYTELEN); +			STREAM_GET(&nhr->nexthops[i].gate.ipv4.s_addr, s, +				   IPV4_MAX_BYTELEN);  			STREAM_GETL(s, nhr->nexthops[i].ifindex);  			break;  		case NEXTHOP_TYPE_IFINDEX: @@ -1286,8 +1288,8 @@ bool zapi_nexthop_update_decode(struct stream *s, struct zapi_route *nhr)  			break;  		case NEXTHOP_TYPE_IPV6:  		case NEXTHOP_TYPE_IPV6_IFINDEX: -			STREAM_GET(&nhr->nexthops[i].gate.ipv6, -				   s, IPV6_MAX_BYTELEN); +			STREAM_GET(&nhr->nexthops[i].gate.ipv6, s, +				   IPV6_MAX_BYTELEN);  			STREAM_GETL(s, nhr->nexthops[i].ifindex);  			break;  		case NEXTHOP_TYPE_BLACKHOLE: diff --git a/lib/zclient.h b/lib/zclient.h index 4c84af1f61..d91b084e74 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -368,10 +368,12 @@ extern struct zclient_options zclient_options_default;  extern struct zclient *zclient_new_notify(struct thread_master *m,  					  struct zclient_options *opt); -#define zclient_new(A) zclient_new_notify((A), &zclient_options_default); \ +#define zclient_new(A)                                                         \ +	zclient_new_notify((A), &zclient_options_default);                     \  	CPP_WARN("Please transition to using zclient_new_notify"); -extern void zclient_init(struct zclient *, int, u_short, struct zebra_privs_t *privs); +extern void zclient_init(struct zclient *, int, u_short, +			 struct zebra_privs_t *privs);  extern int zclient_start(struct zclient *);  extern void zclient_stop(struct zclient *);  extern void zclient_reset(struct zclient *); @@ -446,7 +448,8 @@ extern void zebra_interface_if_set_value(struct stream *, struct interface *);  extern void zebra_router_id_update_read(struct stream *s, struct prefix *rid);  #if CONFDATE > 20180823 -CPP_NOTICE("zapi_ipv4_route, zapi_ipv6_route, zapi_ipv4_route_ipv6_nexthop as well as the zapi_ipv4 and zapi_ipv6 data structures should be removed now"); +CPP_NOTICE( +	"zapi_ipv4_route, zapi_ipv6_route, zapi_ipv4_route_ipv6_nexthop as well as the zapi_ipv4 and zapi_ipv6 data structures should be removed now");  #endif  extern int zapi_ipv4_route(u_char, struct zclient *, struct prefix_ipv4 *, diff --git a/lib/zebra.h b/lib/zebra.h index 11bf764b63..df367bd27b 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -127,10 +127,10 @@ typedef unsigned char u_int8_t;  #endif  #ifndef HAVE_LIBCRYPT -#   ifdef HAVE_LIBCRYPTO -#      include <openssl/des.h> +#ifdef HAVE_LIBCRYPTO +#include <openssl/des.h>  #      define crypt DES_crypt -#   endif +#endif  #endif  #include "openbsd-tree.h" diff --git a/nhrpd/debug.h b/nhrpd/debug.h index b1f49aa8b7..db4bac7916 100644 --- a/nhrpd/debug.h +++ b/nhrpd/debug.h @@ -20,23 +20,24 @@ extern unsigned int debug_flags;  #if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L -#define debugf(level, ...) \ -	do {						\ -		if (unlikely(debug_flags & level))	\ -			zlog_debug(__VA_ARGS__);	\ -	} while(0) +#define debugf(level, ...)                                                     \ +	do {                                                                   \ +		if (unlikely(debug_flags & level))                             \ +			zlog_debug(__VA_ARGS__);                               \ +	} while (0)  #elif defined __GNUC__ -#define debugf(level, _args...)				\ -	do {						\ -		if (unlikely(debug_flags & level))	\ -			zlog_debug(_args);		\ -	} while(0) +#define debugf(level, _args...)                                                \ +	do {                                                                   \ +		if (unlikely(debug_flags & level))                             \ +			zlog_debug(_args);                                     \ +	} while (0)  #else -static inline void debugf(int level, const char *format, ...) { } +static inline void debugf(int level, const char *format, ...) +{ +}  #endif - diff --git a/nhrpd/linux.c b/nhrpd/linux.c index 88804a87d6..46a327b59f 100644 --- a/nhrpd/linux.c +++ b/nhrpd/linux.c @@ -31,16 +31,17 @@ static int nhrp_socket_fd = -1;  int os_socket(void)  {  	if (nhrp_socket_fd < 0) -		nhrp_socket_fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_NHRP)); +		nhrp_socket_fd = +			socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_NHRP));  	return nhrp_socket_fd;  } -int os_sendmsg(const uint8_t *buf, size_t len, int ifindex, const uint8_t *addr, size_t addrlen) +int os_sendmsg(const uint8_t *buf, size_t len, int ifindex, const uint8_t *addr, +	       size_t addrlen)  {  	struct sockaddr_ll lladdr;  	struct iovec iov = { -		.iov_base = (void*) buf, -		.iov_len = len, +		.iov_base = (void *)buf, .iov_len = len,  	};  	struct msghdr msg = {  		.msg_name = &lladdr, @@ -67,12 +68,12 @@ int os_sendmsg(const uint8_t *buf, size_t len, int ifindex, const uint8_t *addr,  	return 0;  } -int os_recvmsg(uint8_t *buf, size_t *len, int *ifindex, uint8_t *addr, size_t *addrlen) +int os_recvmsg(uint8_t *buf, size_t *len, int *ifindex, uint8_t *addr, +	       size_t *addrlen)  {  	struct sockaddr_ll lladdr;  	struct iovec iov = { -		.iov_base = buf, -		.iov_len = *len, +		.iov_base = buf, .iov_len = *len,  	};  	struct msghdr msg = {  		.msg_name = &lladdr, @@ -89,7 +90,7 @@ int os_recvmsg(uint8_t *buf, size_t *len, int *ifindex, uint8_t *addr, size_t *a  	*len = r;  	*ifindex = lladdr.sll_ifindex; -	if (*addrlen <= (size_t) lladdr.sll_addr) { +	if (*addrlen <= (size_t)lladdr.sll_addr) {  		if (memcmp(lladdr.sll_addr, "\x00\x00\x00\x00", 4) != 0) {  			memcpy(addr, lladdr.sll_addr, lladdr.sll_halen);  			*addrlen = lladdr.sll_halen; diff --git a/nhrpd/list.h b/nhrpd/list.h index 32f21ed5e5..ee7f1c4403 100644 --- a/nhrpd/list.h +++ b/nhrpd/list.h @@ -25,9 +25,11 @@  #endif  #ifndef container_of -#define container_of(ptr, type, member) ({                      \ -        const typeof( ((type *)0)->member ) *__mptr = (ptr);    \ -        (type *)( (char *)__mptr - offsetof(type,member) );}) +#define container_of(ptr, type, member)                                        \ +	({                                                                     \ +		const typeof(((type *)0)->member) *__mptr = (ptr);             \ +		(type *)((char *)__mptr - offsetof(type, member));             \ +	})  #endif  struct hlist_head { @@ -73,7 +75,8 @@ static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)  	h->first = n;  } -static inline void hlist_add_after(struct hlist_node *n, struct hlist_node *prev) +static inline void hlist_add_after(struct hlist_node *n, +				   struct hlist_node *prev)  {  	n->next = prev->next;  	n->pprev = &prev->next; @@ -92,21 +95,34 @@ static inline struct hlist_node **hlist_tail_ptr(struct hlist_head *h)  #define hlist_entry(ptr, type, member) container_of(ptr,type,member) -#define hlist_for_each(pos, head) \ +#define hlist_for_each(pos, head)                                              \  	for (pos = (head)->first; pos; pos = pos->next) -#define hlist_for_each_safe(pos, n, head) \ -	for (pos = (head)->first; pos && ({ n = pos->next; 1; }); pos = n) +#define hlist_for_each_safe(pos, n, head)                                      \ +	for (pos = (head)->first; pos && ({                                    \ +					  n = pos->next;                       \ +					  1;                                   \ +				  });                                          \ +	     pos = n) -#define hlist_for_each_entry(tpos, pos, head, member)			 \ -	for (pos = (head)->first; pos && 				 \ -		({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ +#define hlist_for_each_entry(tpos, pos, head, member)                          \ +	for (pos = (head)->first;                                              \ +	     pos && ({                                                         \ +		     tpos = hlist_entry(pos, typeof(*tpos), member);           \ +		     1;                                                        \ +	     });                                                               \  	     pos = pos->next) -#define hlist_for_each_entry_safe(tpos, pos, n, head, member) 		 \ -	for (pos = (head)->first;					 \ -	     pos && ({ n = pos->next; 1; }) &&				 \ -		({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ +#define hlist_for_each_entry_safe(tpos, pos, n, head, member)                  \ +	for (pos = (head)->first;                                              \ +	     pos && ({                                                         \ +		     n = pos->next;                                            \ +		     1;                                                        \ +	     })                                                                \ +	     && ({                                                             \ +			tpos = hlist_entry(pos, typeof(*tpos), member);        \ +			1;                                                     \ +		});                                                            \  	     pos = n) @@ -122,8 +138,7 @@ static inline void list_init(struct list_head *list)  	list->prev = list;  } -static inline void __list_add(struct list_head *new, -			      struct list_head *prev, +static inline void __list_add(struct list_head *new, struct list_head *prev,  			      struct list_head *next)  {  	next->prev = new; @@ -142,7 +157,7 @@ static inline void list_add_tail(struct list_head *new, struct list_head *head)  	__list_add(new, head->prev, head);  } -static inline void __list_del(struct list_head * prev, struct list_head * next) +static inline void __list_del(struct list_head *prev, struct list_head *next)  {  	next->prev = prev;  	prev->next = next; @@ -165,27 +180,27 @@ static inline int list_empty(const struct list_head *n)  	return !list_hashed(n);  } -#define list_next(ptr, type, member) \ -	(list_hashed(ptr) ? container_of((ptr)->next,type,member) : NULL) +#define list_next(ptr, type, member)                                           \ +	(list_hashed(ptr) ? container_of((ptr)->next, type, member) : NULL)  #define list_entry(ptr, type, member) container_of(ptr,type,member) -#define list_for_each(pos, head) \ +#define list_for_each(pos, head)                                               \  	for (pos = (head)->next; pos != (head); pos = pos->next) -#define list_for_each_safe(pos, n, head) \ -	for (pos = (head)->next, n = pos->next; pos != (head); \ -		pos = n, n = pos->next) +#define list_for_each_safe(pos, n, head)                                       \ +	for (pos = (head)->next, n = pos->next; pos != (head);                 \ +	     pos = n, n = pos->next) -#define list_for_each_entry(pos, head, member)				\ -	for (pos = list_entry((head)->next, typeof(*pos), member);	\ -	     &pos->member != (head); 					\ +#define list_for_each_entry(pos, head, member)                                 \ +	for (pos = list_entry((head)->next, typeof(*pos), member);             \ +	     &pos->member != (head);                                           \  	     pos = list_entry(pos->member.next, typeof(*pos), member)) -#define list_for_each_entry_safe(pos, n, head, member)			\ -	for (pos = list_entry((head)->next, typeof(*pos), member),	\ -		n = list_entry(pos->member.next, typeof(*pos), member);	\ -	     &pos->member != (head); 					\ +#define list_for_each_entry_safe(pos, n, head, member)                         \ +	for (pos = list_entry((head)->next, typeof(*pos), member),             \ +	    n = list_entry(pos->member.next, typeof(*pos), member);            \ +	     &pos->member != (head);                                           \  	     pos = n, n = list_entry(n->member.next, typeof(*n), member))  #endif diff --git a/nhrpd/netlink.h b/nhrpd/netlink.h index e8dc22adf0..74cb81daaa 100644 --- a/nhrpd/netlink.h +++ b/nhrpd/netlink.h @@ -17,8 +17,10 @@ extern int netlink_req_fd;  void netlink_init(void);  int netlink_configure_arp(unsigned int ifindex, int pf); -void netlink_update_binding(struct interface *ifp, union sockunion *proto, union sockunion *nbma); +void netlink_update_binding(struct interface *ifp, union sockunion *proto, +			    union sockunion *nbma);  void netlink_set_nflog_group(int nlgroup); -void netlink_gre_get_info(unsigned int ifindex, uint32_t *gre_key, unsigned int *link_index, struct in_addr *saddr); +void netlink_gre_get_info(unsigned int ifindex, uint32_t *gre_key, +			  unsigned int *link_index, struct in_addr *saddr);  void netlink_gre_set_link(unsigned int ifindex, unsigned int link_index); diff --git a/nhrpd/netlink_arp.c b/nhrpd/netlink_arp.c index 425526cede..af78b3d9ee 100644 --- a/nhrpd/netlink_arp.c +++ b/nhrpd/netlink_arp.c @@ -27,23 +27,27 @@ static int netlink_listen_fd = -1;  typedef void (*netlink_dispatch_f)(struct nlmsghdr *msg, struct zbuf *zb); -void netlink_update_binding(struct interface *ifp, union sockunion *proto, union sockunion *nbma) +void netlink_update_binding(struct interface *ifp, union sockunion *proto, +			    union sockunion *nbma)  {  	struct nlmsghdr *n;  	struct ndmsg *ndm;  	struct zbuf *zb = zbuf_alloc(512); -	n = znl_nlmsg_push(zb, nbma ? RTM_NEWNEIGH : RTM_DELNEIGH, NLM_F_REQUEST | NLM_F_REPLACE | NLM_F_CREATE); +	n = znl_nlmsg_push(zb, nbma ? RTM_NEWNEIGH : RTM_DELNEIGH, +			   NLM_F_REQUEST | NLM_F_REPLACE | NLM_F_CREATE);  	ndm = znl_push(zb, sizeof(*ndm)); -	*ndm = (struct ndmsg) { +	*ndm = (struct ndmsg){  		.ndm_family = sockunion_family(proto),  		.ndm_ifindex = ifp->ifindex,  		.ndm_type = RTN_UNICAST,  		.ndm_state = nbma ? NUD_REACHABLE : NUD_FAILED,  	}; -	znl_rta_push(zb, NDA_DST, sockunion_get_addr(proto), family2addrsize(sockunion_family(proto))); +	znl_rta_push(zb, NDA_DST, sockunion_get_addr(proto), +		     family2addrsize(sockunion_family(proto)));  	if (nbma) -		znl_rta_push(zb, NDA_LLADDR, sockunion_get_addr(nbma), family2addrsize(sockunion_family(nbma))); +		znl_rta_push(zb, NDA_LLADDR, sockunion_get_addr(nbma), +			     family2addrsize(sockunion_family(nbma)));  	znl_nlmsg_complete(zb, n);  	zbuf_send(zb, netlink_req_fd);  	zbuf_recv(zb, netlink_req_fd); @@ -63,14 +67,16 @@ static void netlink_neigh_msg(struct nlmsghdr *msg, struct zbuf *zb)  	int state;  	ndm = znl_pull(zb, sizeof(*ndm)); -	if (!ndm) return; +	if (!ndm) +		return;  	sockunion_family(&addr) = AF_UNSPEC;  	while ((rta = znl_rta_pull(zb, &payload)) != NULL) {  		len = zbuf_used(&payload);  		switch (rta->rta_type) {  		case NDA_DST: -			sockunion_set(&addr, ndm->ndm_family, zbuf_pulln(&payload, len), len); +			sockunion_set(&addr, ndm->ndm_family, +				      zbuf_pulln(&payload, len), len);  			break;  		}  	} @@ -85,19 +91,20 @@ static void netlink_neigh_msg(struct nlmsghdr *msg, struct zbuf *zb)  	if (msg->nlmsg_type == RTM_GETNEIGH) {  		debugf(NHRP_DEBUG_KERNEL, "Netlink: who-has %s dev %s", -			sockunion2str(&addr, buf, sizeof buf), -			ifp->name); +		       sockunion2str(&addr, buf, sizeof buf), ifp->name);  		if (c->cur.type >= NHRP_CACHE_CACHED) {  			nhrp_cache_set_used(c, 1); -			netlink_update_binding(ifp, &addr, &c->cur.peer->vc->remote.nbma); +			netlink_update_binding(ifp, &addr, +					       &c->cur.peer->vc->remote.nbma);  		}  	} else {  		debugf(NHRP_DEBUG_KERNEL, "Netlink: update %s dev %s nud %x", -			sockunion2str(&addr, buf, sizeof buf), -			ifp->name, ndm->ndm_state); +		       sockunion2str(&addr, buf, sizeof buf), ifp->name, +		       ndm->ndm_state); -		state = (msg->nlmsg_type == RTM_NEWNEIGH) ? ndm->ndm_state : NUD_FAILED; +		state = (msg->nlmsg_type == RTM_NEWNEIGH) ? ndm->ndm_state +							  : NUD_FAILED;  		nhrp_cache_set_used(c, state == NUD_REACHABLE);  	}  } @@ -112,8 +119,9 @@ static int netlink_route_recv(struct thread *t)  	zbuf_init(&zb, buf, sizeof(buf), 0);  	while (zbuf_recv(&zb, fd) > 0) {  		while ((n = znl_nlmsg_pull(&zb, &payload)) != 0) { -			debugf(NHRP_DEBUG_KERNEL, "Netlink: Received msg_type %u, msg_flags %u", -				n->nlmsg_type, n->nlmsg_flags); +			debugf(NHRP_DEBUG_KERNEL, +			       "Netlink: Received msg_type %u, msg_flags %u", +			       n->nlmsg_type, n->nlmsg_flags);  			switch (n->nlmsg_type) {  			case RTM_GETNEIGH:  			case RTM_NEWNEIGH: @@ -136,9 +144,10 @@ static void netlink_log_register(int fd, int group)  	struct nfulnl_msg_config_cmd cmd;  	struct zbuf *zb = zbuf_alloc(512); -	n = znl_nlmsg_push(zb, (NFNL_SUBSYS_ULOG<<8) | NFULNL_MSG_CONFIG, NLM_F_REQUEST | NLM_F_ACK); +	n = znl_nlmsg_push(zb, (NFNL_SUBSYS_ULOG << 8) | NFULNL_MSG_CONFIG, +			   NLM_F_REQUEST | NLM_F_ACK);  	nf = znl_push(zb, sizeof(*nf)); -	*nf = (struct nfgenmsg) { +	*nf = (struct nfgenmsg){  		.nfgen_family = AF_UNSPEC,  		.version = NFNETLINK_V0,  		.res_id = htons(group), @@ -161,7 +170,8 @@ static void netlink_log_indication(struct nlmsghdr *msg, struct zbuf *zb)  	uint32_t *in_ndx = NULL;  	nf = znl_pull(zb, sizeof(*nf)); -	if (!nf) return; +	if (!nf) +		return;  	memset(&pktpl, 0, sizeof(pktpl));  	while ((rta = znl_rta_pull(zb, &rtapl)) != NULL) { @@ -175,10 +185,10 @@ static void netlink_log_indication(struct nlmsghdr *msg, struct zbuf *zb)  		case NFULA_PAYLOAD:  			pktpl = rtapl;  			break; -		/* NFULA_HWHDR exists and is supposed to contain source -		 * hardware address. However, for ip_gre it seems to be -		 * the nexthop destination address if the packet matches -		 * route. */ +			/* NFULA_HWHDR exists and is supposed to contain source +			 * hardware address. However, for ip_gre it seems to be +			 * the nexthop destination address if the packet matches +			 * route. */  		}  	} @@ -204,10 +214,11 @@ static int netlink_log_recv(struct thread *t)  	zbuf_init(&zb, buf, sizeof(buf), 0);  	while (zbuf_recv(&zb, fd) > 0) {  		while ((n = znl_nlmsg_pull(&zb, &payload)) != 0) { -			debugf(NHRP_DEBUG_KERNEL, "Netlink-log: Received msg_type %u, msg_flags %u", -				n->nlmsg_type, n->nlmsg_flags); +			debugf(NHRP_DEBUG_KERNEL, +			       "Netlink-log: Received msg_type %u, msg_flags %u", +			       n->nlmsg_type, n->nlmsg_flags);  			switch (n->nlmsg_type) { -			case (NFNL_SUBSYS_ULOG<<8) | NFULNL_MSG_PACKET: +			case (NFNL_SUBSYS_ULOG << 8) | NFULNL_MSG_PACKET:  				netlink_log_indication(n, &payload);  				break;  			} @@ -229,7 +240,7 @@ void netlink_set_nflog_group(int nlgroup)  	}  	netlink_nflog_group = nlgroup;  	if (nlgroup) { -		netlink_log_fd = znl_open(NETLINK_NETFILTER,  0); +		netlink_log_fd = znl_open(NETLINK_NETFILTER, 0);  		if (netlink_log_fd < 0)  			return; @@ -249,8 +260,7 @@ void netlink_init(void)  	if (netlink_listen_fd < 0)  		return; -	thread_add_read(master, netlink_route_recv, 0, netlink_listen_fd, -			NULL); +	thread_add_read(master, netlink_route_recv, 0, netlink_listen_fd, NULL);  }  int netlink_configure_arp(unsigned int ifindex, int pf) @@ -263,11 +273,12 @@ int netlink_configure_arp(unsigned int ifindex, int pf)  	n = znl_nlmsg_push(zb, RTM_SETNEIGHTBL, NLM_F_REQUEST | NLM_F_REPLACE);  	ndtm = znl_push(zb, sizeof(*ndtm)); -	*ndtm = (struct ndtmsg) { +	*ndtm = (struct ndtmsg){  		.ndtm_family = pf,  	}; -	znl_rta_push(zb, NDTA_NAME, pf == AF_INET ? "arp_cache" : "ndisc_cache", 10); +	znl_rta_push(zb, NDTA_NAME, pf == AF_INET ? "arp_cache" : "ndisc_cache", +		     10);  	rta = znl_rta_nested_push(zb, NDTA_PARMS);  	znl_rta_push_u32(zb, NDTPA_IFINDEX, ifindex); diff --git a/nhrpd/netlink_gre.c b/nhrpd/netlink_gre.c index 93998dc5f5..75ecaa70c1 100644 --- a/nhrpd/netlink_gre.c +++ b/nhrpd/netlink_gre.c @@ -20,7 +20,8 @@  #include "netlink.h"  #include "znl.h" -static int __netlink_gre_get_data(struct zbuf *zb, struct zbuf *data, int ifindex) +static int __netlink_gre_get_data(struct zbuf *zb, struct zbuf *data, +				  int ifindex)  {  	struct nlmsghdr *n;  	struct ifinfomsg *ifi; @@ -31,17 +32,18 @@ static int __netlink_gre_get_data(struct zbuf *zb, struct zbuf *data, int ifinde  	n = znl_nlmsg_push(zb, RTM_GETLINK, NLM_F_REQUEST);  	ifi = znl_push(zb, sizeof(*ifi)); -	*ifi = (struct ifinfomsg) { +	*ifi = (struct ifinfomsg){  		.ifi_index = ifindex,  	};  	znl_nlmsg_complete(zb, n); -	if (zbuf_send(zb, netlink_req_fd) < 0 || -	    zbuf_recv(zb, netlink_req_fd) < 0) +	if (zbuf_send(zb, netlink_req_fd) < 0 +	    || zbuf_recv(zb, netlink_req_fd) < 0)  		return -1;  	n = znl_nlmsg_pull(zb, &payload); -	if (!n) return -1; +	if (!n) +		return -1;  	if (n->nlmsg_type != RTM_NEWLINK)  		return -1; @@ -50,8 +52,9 @@ static int __netlink_gre_get_data(struct zbuf *zb, struct zbuf *data, int ifinde  	if (!ifi)  		return -1; -	debugf(NHRP_DEBUG_KERNEL, "netlink-link-gre: ifindex %u, receive msg_type %u, msg_flags %u", -		ifi->ifi_index, n->nlmsg_type, n->nlmsg_flags); +	debugf(NHRP_DEBUG_KERNEL, +	       "netlink-link-gre: ifindex %u, receive msg_type %u, msg_flags %u", +	       ifi->ifi_index, n->nlmsg_type, n->nlmsg_flags);  	if (ifi->ifi_index != ifindex)  		return -1; @@ -59,19 +62,22 @@ static int __netlink_gre_get_data(struct zbuf *zb, struct zbuf *data, int ifinde  	while ((rta = znl_rta_pull(&payload, &rtapayload)) != NULL)  		if (rta->rta_type == IFLA_LINKINFO)  			break; -	if (!rta) return -1; +	if (!rta) +		return -1;  	payload = rtapayload;  	while ((rta = znl_rta_pull(&payload, &rtapayload)) != NULL)  		if (rta->rta_type == IFLA_INFO_DATA)  			break; -	if (!rta) return -1; +	if (!rta) +		return -1;  	*data = rtapayload;  	return 0;  } -void netlink_gre_get_info(unsigned int ifindex, uint32_t *gre_key, unsigned int *link_index, struct in_addr *saddr) +void netlink_gre_get_info(unsigned int ifindex, uint32_t *gre_key, +			  unsigned int *link_index, struct in_addr *saddr)  {  	struct zbuf *zb = zbuf_alloc(8192), data, rtapl;  	struct rtattr *rta; @@ -115,7 +121,7 @@ void netlink_gre_set_link(unsigned int ifindex, unsigned int link_index)  	n = znl_nlmsg_push(zb, RTM_NEWLINK, NLM_F_REQUEST);  	ifi = znl_push(zb, sizeof(*ifi)); -	*ifi = (struct ifinfomsg) { +	*ifi = (struct ifinfomsg){  		.ifi_index = ifindex,  	};  	rta_info = znl_rta_nested_push(zb, IFLA_LINKINFO); diff --git a/nhrpd/nhrp_cache.c b/nhrpd/nhrp_cache.c index 3ff1a342dc..ffc8b5a9bf 100644 --- a/nhrpd/nhrp_cache.c +++ b/nhrpd/nhrp_cache.c @@ -19,15 +19,15 @@ DEFINE_MTYPE_STATIC(NHRPD, NHRP_CACHE, "NHRP cache entry")  unsigned long nhrp_cache_counts[NHRP_CACHE_NUM_TYPES]; -const char * const nhrp_cache_type_str[] = { -	[NHRP_CACHE_INVALID]	= "invalid", -	[NHRP_CACHE_INCOMPLETE]	= "incomplete", -	[NHRP_CACHE_NEGATIVE]	= "negative", -	[NHRP_CACHE_CACHED]	= "cached", -	[NHRP_CACHE_DYNAMIC]	= "dynamic", -	[NHRP_CACHE_NHS]	= "nhs", -	[NHRP_CACHE_STATIC]	= "static", -	[NHRP_CACHE_LOCAL]	= "local", +const char *const nhrp_cache_type_str[] = { +		[NHRP_CACHE_INVALID] = "invalid", +		[NHRP_CACHE_INCOMPLETE] = "incomplete", +		[NHRP_CACHE_NEGATIVE] = "negative", +		[NHRP_CACHE_CACHED] = "cached", +		[NHRP_CACHE_DYNAMIC] = "dynamic", +		[NHRP_CACHE_NHS] = "nhs", +		[NHRP_CACHE_STATIC] = "static", +		[NHRP_CACHE_LOCAL] = "local",  };  static unsigned int nhrp_cache_protocol_key(void *peer_data) @@ -49,12 +49,13 @@ static void *nhrp_cache_alloc(void *data)  	p = XMALLOC(MTYPE_NHRP_CACHE, sizeof(struct nhrp_cache));  	if (p) { -		*p = (struct nhrp_cache) { +		*p = (struct nhrp_cache){  			.cur.type = NHRP_CACHE_INVALID,  			.new.type = NHRP_CACHE_INVALID,  			.remote_addr = key->remote_addr,  			.ifp = key->ifp, -			.notifier_list = NOTIFIER_LIST_INITIALIZER(&p->notifier_list), +			.notifier_list = +				NOTIFIER_LIST_INITIALIZER(&p->notifier_list),  		};  		nhrp_cache_counts[p->cur.type]++;  	} @@ -75,15 +76,16 @@ static void nhrp_cache_free(struct nhrp_cache *c)  	XFREE(MTYPE_NHRP_CACHE, c);  } -struct nhrp_cache *nhrp_cache_get(struct interface *ifp, union sockunion *remote_addr, int create) +struct nhrp_cache *nhrp_cache_get(struct interface *ifp, +				  union sockunion *remote_addr, int create)  {  	struct nhrp_interface *nifp = ifp->info;  	struct nhrp_cache key;  	if (!nifp->cache_hash) { -		nifp->cache_hash = hash_create(nhrp_cache_protocol_key, -					       nhrp_cache_protocol_cmp, -					       "NHRP Cache"); +		nifp->cache_hash = +			hash_create(nhrp_cache_protocol_key, +				    nhrp_cache_protocol_cmp, "NHRP Cache");  		if (!nifp->cache_hash)  			return NULL;  	} @@ -91,7 +93,8 @@ struct nhrp_cache *nhrp_cache_get(struct interface *ifp, union sockunion *remote  	key.remote_addr = *remote_addr;  	key.ifp = ifp; -	return hash_get(nifp->cache_hash, &key, create ? nhrp_cache_alloc : NULL); +	return hash_get(nifp->cache_hash, &key, +			create ? nhrp_cache_alloc : NULL);  }  static int nhrp_cache_do_free(struct thread *t) @@ -119,8 +122,10 @@ static void nhrp_cache_update_route(struct nhrp_cache *c)  	sockunion2hostprefix(&c->remote_addr, &pfx);  	if (p && nhrp_peer_check(p, 1)) { -		netlink_update_binding(p->ifp, &c->remote_addr, &p->vc->remote.nbma); -		nhrp_route_announce(1, c->cur.type, &pfx, c->ifp, NULL, c->cur.mtu); +		netlink_update_binding(p->ifp, &c->remote_addr, +				       &p->vc->remote.nbma); +		nhrp_route_announce(1, c->cur.type, &pfx, c->ifp, NULL, +				    c->cur.mtu);  		if (c->cur.type >= NHRP_CACHE_DYNAMIC) {  			nhrp_route_update_nhrp(&pfx, c->ifp);  			c->nhrp_route_installed = 1; @@ -140,15 +145,18 @@ static void nhrp_cache_update_route(struct nhrp_cache *c)  		if (c->route_installed) {  			sockunion2hostprefix(&c->remote_addr, &pfx);  			notifier_call(&c->notifier_list, NOTIFY_CACHE_DOWN); -			nhrp_route_announce(0, c->cur.type, &pfx, NULL, NULL, 0); +			nhrp_route_announce(0, c->cur.type, &pfx, NULL, NULL, +					    0);  			c->route_installed = 0;  		}  	}  } -static void nhrp_cache_peer_notifier(struct notifier_block *n, unsigned long cmd) +static void nhrp_cache_peer_notifier(struct notifier_block *n, +				     unsigned long cmd)  { -	struct nhrp_cache *c = container_of(n, struct nhrp_cache, peer_notifier); +	struct nhrp_cache *c = +		container_of(n, struct nhrp_cache, peer_notifier);  	switch (cmd) {  	case NOTIFY_PEER_UP: @@ -183,8 +191,8 @@ static void nhrp_cache_update_timers(struct nhrp_cache *c)  	switch (c->cur.type) {  	case NHRP_CACHE_INVALID:  		if (!c->t_auth) -			thread_add_timer_msec(master, nhrp_cache_do_free, c, -					      10, &c->t_timeout); +			thread_add_timer_msec(master, nhrp_cache_do_free, c, 10, +					      &c->t_timeout);  		break;  	default:  		if (c->cur.expires) @@ -200,15 +208,16 @@ static void nhrp_cache_authorize_binding(struct nhrp_reqid *r, void *arg)  	struct nhrp_cache *c = container_of(r, struct nhrp_cache, eventid);  	char buf[SU_ADDRSTRLEN]; -	debugf(NHRP_DEBUG_COMMON, "cache: %s %s: %s", -		c->ifp->name, sockunion2str(&c->remote_addr, buf, sizeof buf), -		(const char *) arg); +	debugf(NHRP_DEBUG_COMMON, "cache: %s %s: %s", c->ifp->name, +	       sockunion2str(&c->remote_addr, buf, sizeof buf), +	       (const char *)arg);  	nhrp_reqid_free(&nhrp_event_reqid, r);  	if (arg && strcmp(arg, "accept") == 0) {  		if (c->cur.peer) { -			netlink_update_binding(c->cur.peer->ifp, &c->remote_addr, NULL); +			netlink_update_binding(c->cur.peer->ifp, +					       &c->remote_addr, NULL);  			nhrp_peer_notify_del(c->cur.peer, &c->peer_notifier);  			nhrp_peer_unref(c->cur.peer);  		} @@ -218,7 +227,8 @@ static void nhrp_cache_authorize_binding(struct nhrp_reqid *r, void *arg)  		c->cur.peer = nhrp_peer_ref(c->cur.peer);  		nhrp_cache_reset_new(c);  		if (c->cur.peer) -			nhrp_peer_notify_add(c->cur.peer, &c->peer_notifier, nhrp_cache_peer_notifier); +			nhrp_peer_notify_add(c->cur.peer, &c->peer_notifier, +					     nhrp_cache_peer_notifier);  		nhrp_cache_update_route(c);  		notifier_call(&c->notifier_list, NOTIFY_CACHE_BINDING_CHANGE);  	} else { @@ -232,20 +242,23 @@ static int nhrp_cache_do_auth_timeout(struct thread *t)  {  	struct nhrp_cache *c = THREAD_ARG(t);  	c->t_auth = NULL; -	nhrp_cache_authorize_binding(&c->eventid, (void *) "timeout"); +	nhrp_cache_authorize_binding(&c->eventid, (void *)"timeout");  	return 0;  } -static void nhrp_cache_newpeer_notifier(struct notifier_block *n, unsigned long cmd) +static void nhrp_cache_newpeer_notifier(struct notifier_block *n, +					unsigned long cmd)  { -	struct nhrp_cache *c = container_of(n, struct nhrp_cache, newpeer_notifier); +	struct nhrp_cache *c = +		container_of(n, struct nhrp_cache, newpeer_notifier);  	switch (cmd) {  	case NOTIFY_PEER_UP:  		if (nhrp_peer_check(c->new.peer, 1)) { -			evmgr_notify("authorize-binding", c, nhrp_cache_authorize_binding); -			thread_add_timer(master, nhrp_cache_do_auth_timeout, -					 c, 10, &c->t_auth); +			evmgr_notify("authorize-binding", c, +				     nhrp_cache_authorize_binding); +			thread_add_timer(master, nhrp_cache_do_auth_timeout, c, +					 10, &c->t_auth);  		}  		break;  	case NOTIFY_PEER_DOWN: @@ -255,7 +268,9 @@ static void nhrp_cache_newpeer_notifier(struct notifier_block *n, unsigned long  	}  } -int nhrp_cache_update_binding(struct nhrp_cache *c, enum nhrp_cache_type type, int holding_time, struct nhrp_peer *p, uint32_t mtu, union sockunion *nbma_oa) +int nhrp_cache_update_binding(struct nhrp_cache *c, enum nhrp_cache_type type, +			      int holding_time, struct nhrp_peer *p, +			      uint32_t mtu, union sockunion *nbma_oa)  {  	if (c->cur.type > type || c->new.type > type) {  		nhrp_peer_unref(p); @@ -269,7 +284,8 @@ int nhrp_cache_update_binding(struct nhrp_cache *c, enum nhrp_cache_type type, i  			mtu = 0;  		/* Opennhrp announces nbma mtu, but we use protocol mtu.  		 * This heuristic tries to fix up it. */ -		if (mtu > 1420) mtu = (mtu & -16) - 80; +		if (mtu > 1420) +			mtu = (mtu & -16) - 80;  		break;  	default:  		mtu = 0; @@ -278,30 +294,37 @@ int nhrp_cache_update_binding(struct nhrp_cache *c, enum nhrp_cache_type type, i  	nhrp_cache_reset_new(c);  	if (c->cur.type == type && c->cur.peer == p && c->cur.mtu == mtu) { -		if (holding_time > 0) c->cur.expires = monotime(NULL) + holding_time; -		if (nbma_oa) c->cur.remote_nbma_natoa = *nbma_oa; -		else memset(&c->cur.remote_nbma_natoa, 0, sizeof c->cur.remote_nbma_natoa); +		if (holding_time > 0) +			c->cur.expires = monotime(NULL) + holding_time; +		if (nbma_oa) +			c->cur.remote_nbma_natoa = *nbma_oa; +		else +			memset(&c->cur.remote_nbma_natoa, 0, +			       sizeof c->cur.remote_nbma_natoa);  		nhrp_peer_unref(p);  	} else {  		c->new.type = type;  		c->new.peer = p;  		c->new.mtu = mtu; -		if (nbma_oa) c->new.remote_nbma_natoa = *nbma_oa; +		if (nbma_oa) +			c->new.remote_nbma_natoa = *nbma_oa;  		if (holding_time > 0)  			c->new.expires = monotime(NULL) + holding_time;  		else if (holding_time < 0)  			nhrp_cache_reset_new(c); -		if (c->new.type == NHRP_CACHE_INVALID || -		    c->new.type >= NHRP_CACHE_STATIC || -		    c->map) { -			nhrp_cache_authorize_binding(&c->eventid, (void *) "accept"); +		if (c->new.type == NHRP_CACHE_INVALID +		    || c->new.type >= NHRP_CACHE_STATIC || c->map) { +			nhrp_cache_authorize_binding(&c->eventid, +						     (void *)"accept");  		} else { -			nhrp_peer_notify_add(c->new.peer, &c->newpeer_notifier, nhrp_cache_newpeer_notifier); -			nhrp_cache_newpeer_notifier(&c->newpeer_notifier, NOTIFY_PEER_UP); -			thread_add_timer(master, nhrp_cache_do_auth_timeout, -					 c, 60, &c->t_auth); +			nhrp_peer_notify_add(c->new.peer, &c->newpeer_notifier, +					     nhrp_cache_newpeer_notifier); +			nhrp_cache_newpeer_notifier(&c->newpeer_notifier, +						    NOTIFY_PEER_UP); +			thread_add_timer(master, nhrp_cache_do_auth_timeout, c, +					 60, &c->t_auth);  		}  	}  	nhrp_cache_update_timers(c); @@ -327,19 +350,20 @@ static void nhrp_cache_iterator(struct hash_backet *b, void *ctx)  	ic->cb(b->data, ic->ctx);  } -void nhrp_cache_foreach(struct interface *ifp, void (*cb)(struct nhrp_cache *, void *), void *ctx) +void nhrp_cache_foreach(struct interface *ifp, +			void (*cb)(struct nhrp_cache *, void *), void *ctx)  {  	struct nhrp_interface *nifp = ifp->info;  	struct nhrp_cache_iterator_ctx ic = { -		.cb = cb, -		.ctx = ctx, +		.cb = cb, .ctx = ctx,  	};  	if (nifp->cache_hash)  		hash_iterate(nifp->cache_hash, nhrp_cache_iterator, &ic);  } -void nhrp_cache_notify_add(struct nhrp_cache *c, struct notifier_block *n, notifier_fn_t fn) +void nhrp_cache_notify_add(struct nhrp_cache *c, struct notifier_block *n, +			   notifier_fn_t fn)  {  	notifier_add(n, &c->notifier_list, fn);  } diff --git a/nhrpd/nhrp_event.c b/nhrpd/nhrp_event.c index 4ee58a43e5..e7adc971e5 100644 --- a/nhrpd/nhrp_event.c +++ b/nhrpd/nhrp_event.c @@ -24,7 +24,7 @@ struct event_manager {  	struct zbuf ibuf;  	struct zbuf_queue obuf;  	int fd; -	uint8_t ibuf_data[4*1024]; +	uint8_t ibuf_data[4 * 1024];  };  static int evmgr_reconnect(struct thread *t); @@ -53,7 +53,7 @@ static void evmgr_recv_message(struct event_manager *evmgr, struct zbuf *zb)  	while (zbuf_may_pull_until(zb, "\n", &zl)) {  		len = zbuf_used(&zl) - 1; -		if (len >= sizeof(buf)-1) +		if (len >= sizeof(buf) - 1)  			continue;  		memcpy(buf, zbuf_pulln(&zl, len), len);  		buf[len] = 0; @@ -64,10 +64,13 @@ static void evmgr_recv_message(struct event_manager *evmgr, struct zbuf *zb)  		if (sscanf(buf, "result=%63s", result) != 1)  			continue;  	} -	debugf(NHRP_DEBUG_EVENT, "evmgr: received: eventid=%d result=%s", eventid, result); +	debugf(NHRP_DEBUG_EVENT, "evmgr: received: eventid=%d result=%s", +	       eventid, result);  	if (eventid && result[0]) { -		struct nhrp_reqid *r = nhrp_reqid_lookup(&nhrp_event_reqid, eventid); -		if (r) r->cb(r, result); +		struct nhrp_reqid *r = +			nhrp_reqid_lookup(&nhrp_event_reqid, eventid); +		if (r) +			r->cb(r, result);  	}  } @@ -78,7 +81,7 @@ static int evmgr_read(struct thread *t)  	struct zbuf msg;  	evmgr->t_read = NULL; -	if (zbuf_read(ibuf, evmgr->fd, (size_t) -1) < 0) { +	if (zbuf_read(ibuf, evmgr->fd, (size_t)-1) < 0) {  		evmgr_connection_error(evmgr);  		return 0;  	} @@ -114,8 +117,9 @@ static void evmgr_hexdump(struct zbuf *zb, const uint8_t *val, size_t vallen)  	size_t i;  	char *ptr; -	ptr  = zbuf_pushn(zb, 2*vallen); -	if (!ptr) return; +	ptr = zbuf_pushn(zb, 2 * vallen); +	if (!ptr) +		return;  	for (i = 0; i < vallen; i++) {  		uint8_t b = val[i]; @@ -134,13 +138,15 @@ static void evmgr_put(struct zbuf *zb, const char *fmt, ...)  	va_start(va, fmt);  	for (pos = fmt; (nxt = strchr(pos, '%')) != NULL; pos = nxt + 2) { -		zbuf_put(zb, pos, nxt-pos); +		zbuf_put(zb, pos, nxt - pos);  		switch (nxt[1]) {  		case '%':  			zbuf_put8(zb, '%');  			break;  		case 'u': -			zb->tail += snprintf((char *) zb->tail, zbuf_tailroom(zb), "%u", va_arg(va, uint32_t)); +			zb->tail += +				snprintf((char *)zb->tail, zbuf_tailroom(zb), +					 "%u", va_arg(va, uint32_t));  			break;  		case 's':  			str = va_arg(va, const char *); @@ -148,8 +154,9 @@ static void evmgr_put(struct zbuf *zb, const char *fmt, ...)  			break;  		case 'U':  			su = va_arg(va, const union sockunion *); -			if (sockunion2str(su, (char *) zb->tail, zbuf_tailroom(zb))) -				zb->tail += strlen((char *) zb->tail); +			if (sockunion2str(su, (char *)zb->tail, +					  zbuf_tailroom(zb))) +				zb->tail += strlen((char *)zb->tail);  			else  				zbuf_set_werror(zb);  			break; @@ -183,12 +190,13 @@ static int evmgr_reconnect(struct thread *t)  	int fd;  	evmgr->t_reconnect = NULL; -	if (evmgr->fd >= 0 || !nhrp_event_socket_path) return 0; +	if (evmgr->fd >= 0 || !nhrp_event_socket_path) +		return 0;  	fd = sock_open_unix(nhrp_event_socket_path);  	if (fd < 0) {  		zlog_warn("%s: failure connecting nhrp-event socket: %s", -			__PRETTY_FUNCTION__, strerror(errno)); +			  __PRETTY_FUNCTION__, strerror(errno));  		zbufq_reset(&evmgr->obuf);  		thread_add_timer(master, evmgr_reconnect, evmgr, 10,  				 &evmgr->t_reconnect); @@ -218,7 +226,7 @@ void evmgr_init(void)  void evmgr_set_socket(const char *socket)  {  	if (nhrp_event_socket_path) { -		free((char *) nhrp_event_socket_path); +		free((char *)nhrp_event_socket_path);  		nhrp_event_socket_path = NULL;  	}  	if (socket) @@ -230,7 +238,8 @@ void evmgr_terminate(void)  {  } -void evmgr_notify(const char *name, struct nhrp_cache *c, void (*cb)(struct nhrp_reqid *, void *)) +void evmgr_notify(const char *name, struct nhrp_cache *c, +		  void (*cb)(struct nhrp_reqid *, void *))  {  	struct event_manager *evmgr = &evmgr_connection;  	struct nhrp_vc *vc; @@ -239,51 +248,47 @@ void evmgr_notify(const char *name, struct nhrp_cache *c, void (*cb)(struct nhrp  	afi_t afi = family2afi(sockunion_family(&c->remote_addr));  	if (!nhrp_event_socket_path) { -		cb(&c->eventid, (void*) "accept"); +		cb(&c->eventid, (void *)"accept");  		return;  	}  	debugf(NHRP_DEBUG_EVENT, "evmgr: sending event %s", name);  	vc = c->new.peer ? c->new.peer->vc : NULL; -	zb = zbuf_alloc(1024 + (vc ? (vc->local.certlen + vc->remote.certlen) * 2 : 0)); +	zb = zbuf_alloc( +		1024 + (vc ? (vc->local.certlen + vc->remote.certlen) * 2 : 0));  	if (cb) {  		nhrp_reqid_free(&nhrp_event_reqid, &c->eventid); -		evmgr_put(zb, -			"eventid=%u\n", -			nhrp_reqid_alloc(&nhrp_event_reqid, &c->eventid, cb)); +		evmgr_put(zb, "eventid=%u\n", +			  nhrp_reqid_alloc(&nhrp_event_reqid, &c->eventid, cb));  	}  	evmgr_put(zb, -		"event=%s\n" -		"type=%s\n" -		"old_type=%s\n" -		"num_nhs=%u\n" -		"interface=%s\n" -		"local_addr=%U\n", -		name, -		nhrp_cache_type_str[c->new.type], -		nhrp_cache_type_str[c->cur.type], -		(unsigned int) nhrp_cache_counts[NHRP_CACHE_NHS], -		c->ifp->name, -		&nifp->afi[afi].addr); +		  "event=%s\n" +		  "type=%s\n" +		  "old_type=%s\n" +		  "num_nhs=%u\n" +		  "interface=%s\n" +		  "local_addr=%U\n", +		  name, nhrp_cache_type_str[c->new.type], +		  nhrp_cache_type_str[c->cur.type], +		  (unsigned int)nhrp_cache_counts[NHRP_CACHE_NHS], c->ifp->name, +		  &nifp->afi[afi].addr);  	if (vc) {  		evmgr_put(zb, -			"vc_initiated=%s\n" -			"local_nbma=%U\n" -			"local_cert=%H\n" -			"remote_addr=%U\n" -			"remote_nbma=%U\n" -			"remote_cert=%H\n", -			c->new.peer->requested ? "yes" : "no", -			&vc->local.nbma, -			vc->local.cert, vc->local.certlen, -			&c->remote_addr, &vc->remote.nbma, -			vc->remote.cert, vc->remote.certlen); +			  "vc_initiated=%s\n" +			  "local_nbma=%U\n" +			  "local_cert=%H\n" +			  "remote_addr=%U\n" +			  "remote_nbma=%U\n" +			  "remote_cert=%H\n", +			  c->new.peer->requested ? "yes" : "no", +			  &vc->local.nbma, vc->local.cert, vc->local.certlen, +			  &c->remote_addr, &vc->remote.nbma, vc->remote.cert, +			  vc->remote.certlen);  	}  	evmgr_submit(evmgr, zb);  } - diff --git a/nhrpd/nhrp_interface.c b/nhrpd/nhrp_interface.c index 67e3f41b3d..fba045daeb 100644 --- a/nhrpd/nhrp_interface.c +++ b/nhrpd/nhrp_interface.c @@ -25,7 +25,8 @@ static int nhrp_if_new_hook(struct interface *ifp)  	afi_t afi;  	nifp = XCALLOC(MTYPE_NHRP_IF, sizeof(struct nhrp_interface)); -	if (!nifp) return 0; +	if (!nifp) +		return 0;  	ifp->info = nifp;  	nifp->ifp = ifp; @@ -66,9 +67,11 @@ void nhrp_interface_update_mtu(struct interface *ifp, afi_t afi)  		new_mtu = 0;  	if (new_mtu != if_ad->mtu) { -		debugf(NHRP_DEBUG_IF, "%s: MTU changed to %d", ifp->name, new_mtu); +		debugf(NHRP_DEBUG_IF, "%s: MTU changed to %d", ifp->name, +		       new_mtu);  		if_ad->mtu = new_mtu; -		notifier_call(&nifp->notifier_list, NOTIFY_INTERFACE_MTU_CHANGED); +		notifier_call(&nifp->notifier_list, +			      NOTIFY_INTERFACE_MTU_CHANGED);  	}  } @@ -76,18 +79,21 @@ static void nhrp_interface_update_source(struct interface *ifp)  {  	struct nhrp_interface *nifp = ifp->info; -	if (!nifp->source || !nifp->nbmaifp || -	    (ifindex_t)nifp->linkidx == nifp->nbmaifp->ifindex) +	if (!nifp->source || !nifp->nbmaifp +	    || (ifindex_t)nifp->linkidx == nifp->nbmaifp->ifindex)  		return;  	nifp->linkidx = nifp->nbmaifp->ifindex; -	debugf(NHRP_DEBUG_IF, "%s: bound device index changed to %d", ifp->name, nifp->linkidx); +	debugf(NHRP_DEBUG_IF, "%s: bound device index changed to %d", ifp->name, +	       nifp->linkidx);  	netlink_gre_set_link(ifp->ifindex, nifp->linkidx);  } -static void nhrp_interface_interface_notifier(struct notifier_block *n, unsigned long cmd) +static void nhrp_interface_interface_notifier(struct notifier_block *n, +					      unsigned long cmd)  { -	struct nhrp_interface *nifp = container_of(n, struct nhrp_interface, nbmanifp_notifier); +	struct nhrp_interface *nifp = +		container_of(n, struct nhrp_interface, nbmanifp_notifier);  	struct interface *nbmaifp = nifp->nbmaifp;  	struct nhrp_interface *nbmanifp = nbmaifp->info;  	char buf[SU_ADDRSTRLEN]; @@ -100,10 +106,11 @@ static void nhrp_interface_interface_notifier(struct notifier_block *n, unsigned  	case NOTIFY_INTERFACE_ADDRESS_CHANGED:  		nifp->nbma = nbmanifp->afi[AFI_IP].addr;  		nhrp_interface_update(nifp->ifp); -		notifier_call(&nifp->notifier_list, NOTIFY_INTERFACE_NBMA_CHANGED); +		notifier_call(&nifp->notifier_list, +			      NOTIFY_INTERFACE_NBMA_CHANGED);  		debugf(NHRP_DEBUG_IF, "%s: NBMA change: address %s", -			nifp->ifp->name, -			sockunion2str(&nifp->nbma, buf, sizeof buf)); +		       nifp->ifp->name, +		       sockunion2str(&nifp->nbma, buf, sizeof buf));  		break;  	}  } @@ -117,19 +124,22 @@ static void nhrp_interface_update_nbma(struct interface *ifp)  	sockunion_family(&nbma) = AF_UNSPEC;  	if (nifp->source) -          nbmaifp = if_lookup_by_name(nifp->source, VRF_DEFAULT); +		nbmaifp = if_lookup_by_name(nifp->source, VRF_DEFAULT);  	switch (ifp->ll_type) {  	case ZEBRA_LLT_IPGRE: { -			struct in_addr saddr = {0}; -			netlink_gre_get_info(ifp->ifindex, &nifp->grekey, &nifp->linkidx, &saddr); -			debugf(NHRP_DEBUG_IF, "%s: GRE: %x %x %x", ifp->name, nifp->grekey, nifp->linkidx, saddr.s_addr); -			if (saddr.s_addr) -				sockunion_set(&nbma, AF_INET, (u_char *) &saddr.s_addr, sizeof(saddr.s_addr)); -			else if (!nbmaifp && nifp->linkidx != IFINDEX_INTERNAL) -                          nbmaifp = if_lookup_by_index(nifp->linkidx, VRF_DEFAULT); -		} -		break; +		struct in_addr saddr = {0}; +		netlink_gre_get_info(ifp->ifindex, &nifp->grekey, +				     &nifp->linkidx, &saddr); +		debugf(NHRP_DEBUG_IF, "%s: GRE: %x %x %x", ifp->name, +		       nifp->grekey, nifp->linkidx, saddr.s_addr); +		if (saddr.s_addr) +			sockunion_set(&nbma, AF_INET, (u_char *)&saddr.s_addr, +				      sizeof(saddr.s_addr)); +		else if (!nbmaifp && nifp->linkidx != IFINDEX_INTERNAL) +			nbmaifp = +				if_lookup_by_index(nifp->linkidx, VRF_DEFAULT); +	} break;  	default:  		break;  	} @@ -142,8 +152,11 @@ static void nhrp_interface_update_nbma(struct interface *ifp)  			notifier_del(&nifp->nbmanifp_notifier);  		nifp->nbmaifp = nbmaifp;  		if (nbmaifp) { -			notifier_add(&nifp->nbmanifp_notifier, &nbmanifp->notifier_list, nhrp_interface_interface_notifier); -			debugf(NHRP_DEBUG_IF, "%s: bound to %s", ifp->name, nbmaifp->name); +			notifier_add(&nifp->nbmanifp_notifier, +				     &nbmanifp->notifier_list, +				     nhrp_interface_interface_notifier); +			debugf(NHRP_DEBUG_IF, "%s: bound to %s", ifp->name, +			       nbmaifp->name);  		}  	} @@ -158,13 +171,15 @@ static void nhrp_interface_update_nbma(struct interface *ifp)  		nifp->nbma = nbma;  		nhrp_interface_update(nifp->ifp);  		debugf(NHRP_DEBUG_IF, "%s: NBMA address changed", ifp->name); -		notifier_call(&nifp->notifier_list, NOTIFY_INTERFACE_NBMA_CHANGED); +		notifier_call(&nifp->notifier_list, +			      NOTIFY_INTERFACE_NBMA_CHANGED);  	}  	nhrp_interface_update(ifp);  } -static void nhrp_interface_update_address(struct interface *ifp, afi_t afi, int force) +static void nhrp_interface_update_address(struct interface *ifp, afi_t afi, +					  int force)  {  	const int family = afi2family(afi);  	struct nhrp_interface *nifp = ifp->info; @@ -184,11 +199,13 @@ static void nhrp_interface_update_address(struct interface *ifp, afi_t afi, int  			best = c;  			continue;  		} -		if ((best->flags & ZEBRA_IFA_SECONDARY) && !(c->flags & ZEBRA_IFA_SECONDARY)) { +		if ((best->flags & ZEBRA_IFA_SECONDARY) +		    && !(c->flags & ZEBRA_IFA_SECONDARY)) {  			best = c;  			continue;  		} -		if (!(best->flags & ZEBRA_IFA_SECONDARY) && (c->flags & ZEBRA_IFA_SECONDARY)) +		if (!(best->flags & ZEBRA_IFA_SECONDARY) +		    && (c->flags & ZEBRA_IFA_SECONDARY))  			continue;  		if (best->address->prefixlen > c->address->prefixlen) {  			best = c; @@ -199,9 +216,10 @@ static void nhrp_interface_update_address(struct interface *ifp, afi_t afi, int  	}  	/* On NHRP interfaces a host prefix is required */ -	if (best && if_ad->configured && best->address->prefixlen != 8 * prefix_blen(best->address)) { +	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;  	} @@ -216,17 +234,21 @@ static void nhrp_interface_update_address(struct interface *ifp, afi_t afi, int  	if (sockunion_family(&if_ad->addr) != AF_UNSPEC) {  		nc = nhrp_cache_get(ifp, &if_ad->addr, 0); -		if (nc) nhrp_cache_update_binding(nc, NHRP_CACHE_LOCAL, -1, NULL, 0, NULL); +		if (nc) +			nhrp_cache_update_binding(nc, NHRP_CACHE_LOCAL, -1, +						  NULL, 0, NULL);  	} -	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)"); +	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)");  	if_ad->addr = addr;  	if (if_ad->configured && sockunion_family(&if_ad->addr) != AF_UNSPEC) {  		nc = nhrp_cache_get(ifp, &addr, 1); -		if (nc) nhrp_cache_update_binding(nc, NHRP_CACHE_LOCAL, 0, NULL, 0, NULL); +		if (nc) +			nhrp_cache_update_binding(nc, NHRP_CACHE_LOCAL, 0, NULL, +						  0, NULL);  	}  	notifier_call(&nifp->notifier_list, NOTIFY_INTERFACE_ADDRESS_CHANGED); @@ -244,9 +266,9 @@ void nhrp_interface_update(struct interface *ifp)  	for (afi = 0; afi < AFI_MAX; afi++) {  		if_ad = &nifp->afi[afi]; -		if (sockunion_family(&nifp->nbma) == AF_UNSPEC || -		    ifp->ifindex == IFINDEX_INTERNAL || !if_is_up(ifp) || -		    !if_ad->network_id) { +		if (sockunion_family(&nifp->nbma) == AF_UNSPEC +		    || ifp->ifindex == IFINDEX_INTERNAL || !if_is_up(ifp) +		    || !if_ad->network_id) {  			if (if_ad->configured) {  				if_ad->configured = 0;  				nhrp_interface_update_address(ifp, afi, 1); @@ -255,7 +277,8 @@ void nhrp_interface_update(struct interface *ifp)  		}  		if (!if_ad->configured) { -			os_configure_dmvpn(ifp->ifindex, ifp->name, afi2family(afi)); +			os_configure_dmvpn(ifp->ifindex, ifp->name, +					   afi2family(afi));  			if_ad->configured = 1;  			nhrp_interface_update_address(ifp, afi, 1);  		} @@ -265,11 +288,14 @@ void nhrp_interface_update(struct interface *ifp)  	if (enabled != nifp->enabled) {  		nifp->enabled = enabled; -		notifier_call(&nifp->notifier_list, enabled ? NOTIFY_INTERFACE_UP : NOTIFY_INTERFACE_DOWN); +		notifier_call(&nifp->notifier_list, +			      enabled ? NOTIFY_INTERFACE_UP +				      : NOTIFY_INTERFACE_DOWN);  	}  } -int nhrp_interface_add(int cmd, struct zclient *client, zebra_size_t length, vrf_id_t vrf_id) +int nhrp_interface_add(int cmd, struct zclient *client, zebra_size_t length, +		       vrf_id_t vrf_id)  {  	struct interface *ifp; @@ -279,16 +305,16 @@ int nhrp_interface_add(int cmd, struct zclient *client, zebra_size_t length, vrf  		return 0;  	debugf(NHRP_DEBUG_IF, "if-add: %s, ifindex: %u, hw_type: %d %s", -		ifp->name, ifp->ifindex, -		ifp->ll_type, if_link_type_str(ifp->ll_type)); +	       ifp->name, ifp->ifindex, ifp->ll_type, +	       if_link_type_str(ifp->ll_type));  	nhrp_interface_update_nbma(ifp);  	return 0;  } -int nhrp_interface_delete(int cmd, struct zclient *client, -			  zebra_size_t length, vrf_id_t vrf_id) +int nhrp_interface_delete(int cmd, struct zclient *client, zebra_size_t length, +			  vrf_id_t vrf_id)  {  	struct interface *ifp;  	struct stream *s; @@ -305,8 +331,8 @@ int nhrp_interface_delete(int cmd, struct zclient *client,  	return 0;  } -int nhrp_interface_up(int cmd, struct zclient *client, -		      zebra_size_t length, vrf_id_t vrf_id) +int nhrp_interface_up(int cmd, struct zclient *client, zebra_size_t length, +		      vrf_id_t vrf_id)  {  	struct interface *ifp; @@ -320,8 +346,8 @@ int nhrp_interface_up(int cmd, struct zclient *client,  	return 0;  } -int nhrp_interface_down(int cmd, struct zclient *client, -			zebra_size_t length, vrf_id_t vrf_id) +int nhrp_interface_down(int cmd, struct zclient *client, zebra_size_t length, +			vrf_id_t vrf_id)  {  	struct interface *ifp; @@ -344,11 +370,11 @@ int nhrp_interface_address_add(int cmd, struct zclient *client,  	if (ifc == NULL)  		return 0; -	debugf(NHRP_DEBUG_IF, "if-addr-add: %s: %s", -		ifc->ifp->name, -		prefix2str(ifc->address, buf, sizeof buf)); +	debugf(NHRP_DEBUG_IF, "if-addr-add: %s: %s", ifc->ifp->name, +	       prefix2str(ifc->address, buf, sizeof buf)); -	nhrp_interface_update_address(ifc->ifp, family2afi(PREFIX_FAMILY(ifc->address)), 0); +	nhrp_interface_update_address( +		ifc->ifp, family2afi(PREFIX_FAMILY(ifc->address)), 0);  	return 0;  } @@ -363,17 +389,18 @@ int nhrp_interface_address_delete(int cmd, struct zclient *client,  	if (ifc == NULL)  		return 0; -	debugf(NHRP_DEBUG_IF, "if-addr-del: %s: %s", -		ifc->ifp->name, -		prefix2str(ifc->address, buf, sizeof buf)); +	debugf(NHRP_DEBUG_IF, "if-addr-del: %s: %s", ifc->ifp->name, +	       prefix2str(ifc->address, buf, sizeof buf)); -	nhrp_interface_update_address(ifc->ifp, family2afi(PREFIX_FAMILY(ifc->address)), 0); +	nhrp_interface_update_address( +		ifc->ifp, family2afi(PREFIX_FAMILY(ifc->address)), 0);  	connected_free(ifc);  	return 0;  } -void nhrp_interface_notify_add(struct interface *ifp, struct notifier_block *n, notifier_fn_t fn) +void nhrp_interface_notify_add(struct interface *ifp, struct notifier_block *n, +			       notifier_fn_t fn)  {  	struct nhrp_interface *nifp = ifp->info;  	notifier_add(n, &nifp->notifier_list, fn); @@ -384,15 +411,19 @@ void nhrp_interface_notify_del(struct interface *ifp, struct notifier_block *n)  	notifier_del(n);  } -void nhrp_interface_set_protection(struct interface *ifp, const char *profile, const char *fallback_profile) +void nhrp_interface_set_protection(struct interface *ifp, const char *profile, +				   const char *fallback_profile)  {  	struct nhrp_interface *nifp = ifp->info; -	if (nifp->ipsec_profile) free(nifp->ipsec_profile); +	if (nifp->ipsec_profile) +		free(nifp->ipsec_profile);  	nifp->ipsec_profile = profile ? strdup(profile) : NULL; -	if (nifp->ipsec_fallback_profile) free(nifp->ipsec_fallback_profile); -	nifp->ipsec_fallback_profile = fallback_profile ? strdup(fallback_profile) : NULL; +	if (nifp->ipsec_fallback_profile) +		free(nifp->ipsec_fallback_profile); +	nifp->ipsec_fallback_profile = +		fallback_profile ? strdup(fallback_profile) : NULL;  	notifier_call(&nifp->notifier_list, NOTIFY_INTERFACE_ADDRESS_CHANGED);  } @@ -401,7 +432,8 @@ void nhrp_interface_set_source(struct interface *ifp, const char *ifname)  {  	struct nhrp_interface *nifp = ifp->info; -	if (nifp->source) free(nifp->source); +	if (nifp->source) +		free(nifp->source);  	nifp->source = ifname ? strdup(ifname) : NULL;  	nhrp_interface_update_nbma(ifp); diff --git a/nhrpd/nhrp_main.c b/nhrpd/nhrp_main.c index 767907aa53..ba1e00dedd 100644 --- a/nhrpd/nhrp_main.c +++ b/nhrpd/nhrp_main.c @@ -32,15 +32,13 @@ struct thread_master *master;  struct timeval current_time;  /* nhrpd options. */ -struct option longopts[] = { -	{ 0 } -}; +struct option longopts[] = {{0}};  /* nhrpd privileges */ -static zebra_capabilities_t _caps_p [] = { -	ZCAP_NET_RAW, -	ZCAP_NET_ADMIN, -	ZCAP_DAC_OVERRIDE,	/* for now needed to write to /proc/sys/net/ipv4/<if>/send_redirect */ +static zebra_capabilities_t _caps_p[] = { +	ZCAP_NET_RAW, ZCAP_NET_ADMIN, +	ZCAP_DAC_OVERRIDE, /* for now needed to write to +			      /proc/sys/net/ipv4/<if>/send_redirect */  };  struct zebra_privs_t nhrpd_privs = { @@ -61,7 +59,8 @@ static void parse_arguments(int argc, char **argv)  	while (1) {  		opt = frr_getopt(argc, argv, 0); -		if(opt < 0) break; +		if (opt < 0) +			break;  		switch (opt) {  		case 0: @@ -98,21 +97,27 @@ static void nhrp_request_stop(void)  }  static struct quagga_signal_t sighandlers[] = { -	{ .signal = SIGUSR1, .handler = &nhrp_sigusr1, }, -	{ .signal = SIGINT,  .handler = &nhrp_request_stop, }, -	{ .signal = SIGTERM, .handler = &nhrp_request_stop, }, +	{ +		.signal = SIGUSR1, +		.handler = &nhrp_sigusr1, +	}, +	{ +		.signal = SIGINT, +		.handler = &nhrp_request_stop, +	}, +	{ +		.signal = SIGTERM, +		.handler = &nhrp_request_stop, +	},  }; -FRR_DAEMON_INFO(nhrpd, NHRP, -	.vty_port = NHRP_VTY_PORT, +FRR_DAEMON_INFO(nhrpd, NHRP, .vty_port = NHRP_VTY_PORT, -	.proghelp = "Implementation of the NHRP routing protocol.", +		.proghelp = "Implementation of the NHRP routing protocol.", -	.signals = sighandlers, -	.n_signals = array_size(sighandlers), +		.signals = sighandlers, .n_signals = array_size(sighandlers), -	.privs = &nhrpd_privs, -) +		.privs = &nhrpd_privs, )  int main(int argc, char **argv)  { diff --git a/nhrpd/nhrp_nhs.c b/nhrpd/nhrp_nhs.c index 6fbd6ca224..a7a8c20191 100644 --- a/nhrpd/nhrp_nhs.c +++ b/nhrpd/nhrp_nhs.c @@ -23,7 +23,8 @@ static int nhrp_reg_send_req(struct thread *t);  static void nhrp_reg_reply(struct nhrp_reqid *reqid, void *arg)  {  	struct nhrp_packet_parser *p = arg; -	struct nhrp_registration *r = container_of(reqid, struct nhrp_registration, reqid); +	struct nhrp_registration *r = +		container_of(reqid, struct nhrp_registration, reqid);  	struct nhrp_nhs *nhs = r->nhs;  	struct interface *ifp = nhs->ifp;  	struct nhrp_interface *nifp = ifp->info; @@ -45,13 +46,16 @@ static void nhrp_reg_reply(struct nhrp_reqid *reqid, void *arg)  	debugf(NHRP_DEBUG_COMMON, "NHS: Reg.reply received");  	ok = 1; -	while ((cie = nhrp_cie_pull(&p->payload, p->hdr, &cie_nbma, &cie_proto)) != NULL) { -		proto = sockunion_family(&cie_proto) != AF_UNSPEC ? &cie_proto : &p->src_proto; +	while ((cie = nhrp_cie_pull(&p->payload, p->hdr, &cie_nbma, &cie_proto)) +	       != NULL) { +		proto = sockunion_family(&cie_proto) != AF_UNSPEC +				? &cie_proto +				: &p->src_proto;  		debugf(NHRP_DEBUG_COMMON, "NHS: CIE registration: %s: %d", -			sockunion2str(proto, buf, sizeof(buf)), -			cie->code); -		if (!((cie->code == NHRP_CODE_SUCCESS) || -                      (cie->code == NHRP_CODE_ADMINISTRATIVELY_PROHIBITED && nhs->hub))) +		       sockunion2str(proto, buf, sizeof(buf)), cie->code); +		if (!((cie->code == NHRP_CODE_SUCCESS) +		      || (cie->code == NHRP_CODE_ADMINISTRATIVELY_PROHIBITED +			  && nhs->hub)))  			ok = 0;  	} @@ -64,11 +68,15 @@ static void nhrp_reg_reply(struct nhrp_reqid *reqid, void *arg)  		switch (htons(ext->type) & ~NHRP_EXTENSION_FLAG_COMPULSORY) {  		case NHRP_EXTENSION_NAT_ADDRESS:  			/* NHS adds second CIE if NAT is detected */ -			if (nhrp_cie_pull(&extpl, p->hdr, &cie_nbma, &cie_proto) && -			    nhrp_cie_pull(&extpl, p->hdr, &cie_nbma, &cie_proto)) { +			if (nhrp_cie_pull(&extpl, p->hdr, &cie_nbma, &cie_proto) +			    && nhrp_cie_pull(&extpl, p->hdr, &cie_nbma, +					     &cie_proto)) {  				nifp->nat_nbma = cie_nbma; -				debugf(NHRP_DEBUG_IF, "%s: NAT detected, real NBMA address: %s", -					ifp->name, sockunion2str(&nifp->nbma, buf, sizeof(buf))); +				debugf(NHRP_DEBUG_IF, +				       "%s: NAT detected, real NBMA address: %s", +				       ifp->name, +				       sockunion2str(&nifp->nbma, buf, +						     sizeof(buf)));  			}  			break;  		} @@ -86,7 +94,9 @@ static void nhrp_reg_reply(struct nhrp_reqid *reqid, void *arg)  	r->proto_addr = p->dst_proto;  	c = nhrp_cache_get(ifp, &p->dst_proto, 1); -	if (c) nhrp_cache_update_binding(c, NHRP_CACHE_NHS, holdtime, nhrp_peer_ref(r->peer), 0, NULL); +	if (c) +		nhrp_cache_update_binding(c, NHRP_CACHE_NHS, holdtime, +					  nhrp_peer_ref(r->peer), 0, NULL);  }  static int nhrp_reg_timeout(struct thread *t) @@ -99,21 +109,24 @@ static int nhrp_reg_timeout(struct thread *t)  	if (r->timeout >= 16 && sockunion_family(&r->proto_addr) != AF_UNSPEC) {  		nhrp_reqid_free(&nhrp_packet_reqid, &r->reqid);  		c = nhrp_cache_get(r->nhs->ifp, &r->proto_addr, 0); -		if (c) nhrp_cache_update_binding(c, NHRP_CACHE_NHS, -1, NULL, 0, NULL); +		if (c) +			nhrp_cache_update_binding(c, NHRP_CACHE_NHS, -1, NULL, +						  0, NULL);  		sockunion_family(&r->proto_addr) = AF_UNSPEC;  	}  	r->timeout <<= 1; -	if (r->timeout > 64) r->timeout = 2; -	thread_add_timer_msec(master, nhrp_reg_send_req, r, 10, -			      &r->t_register); +	if (r->timeout > 64) +		r->timeout = 2; +	thread_add_timer_msec(master, nhrp_reg_send_req, r, 10, &r->t_register);  	return 0;  }  static void nhrp_reg_peer_notify(struct notifier_block *n, unsigned long cmd)  { -	struct nhrp_registration *r = container_of(n, struct nhrp_registration, peer_notifier); +	struct nhrp_registration *r = +		container_of(n, struct nhrp_registration, peer_notifier);  	char buf[SU_ADDRSTRLEN];  	switch (cmd) { @@ -122,7 +135,8 @@ static void nhrp_reg_peer_notify(struct notifier_block *n, unsigned long cmd)  	case NOTIFY_PEER_IFCONFIG_CHANGED:  	case NOTIFY_PEER_MTU_CHANGED:  		debugf(NHRP_DEBUG_COMMON, "NHS: Flush timer for %s", -			sockunion2str(&r->peer->vc->remote.nbma, buf, sizeof buf)); +		       sockunion2str(&r->peer->vc->remote.nbma, buf, +				     sizeof buf));  		THREAD_TIMER_OFF(r->t_register);  		thread_add_timer_msec(master, nhrp_reg_send_req, r, 10,  				      &r->t_register); @@ -147,7 +161,8 @@ static int nhrp_reg_send_req(struct thread *t)  	r->t_register = NULL;  	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)); +		       sockunion2str(&r->peer->vc->remote.nbma, buf1, +				     sizeof buf1));  		thread_add_timer(master, nhrp_reg_send_req, r, 120,  				 &r->t_register);  		return 0; @@ -163,19 +178,22 @@ static int nhrp_reg_send_req(struct thread *t)  	sockunion2str(&if_ad->addr, buf1, sizeof(buf1));  	sockunion2str(dst_proto, buf2, sizeof(buf2)); -	debugf(NHRP_DEBUG_COMMON, "NHS: Register %s -> %s (timeout %d)", buf1, buf2, r->timeout); +	debugf(NHRP_DEBUG_COMMON, "NHS: Register %s -> %s (timeout %d)", buf1, +	       buf2, r->timeout);  	/* No protocol address configured for tunnel interface */  	if (sockunion_family(&if_ad->addr) == AF_UNSPEC)  		return 0;  	zb = zbuf_alloc(1400); -	hdr = nhrp_packet_push(zb, NHRP_PACKET_REGISTRATION_REQUEST, &nifp->nbma, &if_ad->addr, dst_proto); +	hdr = nhrp_packet_push(zb, NHRP_PACKET_REGISTRATION_REQUEST, +			       &nifp->nbma, &if_ad->addr, dst_proto);  	hdr->hop_count = 1;  	if (!(if_ad->flags & NHRP_IFF_REG_NO_UNIQUE))  		hdr->flags |= htons(NHRP_FLAG_REGISTRATION_UNIQUE); -	hdr->u.request_id = htonl(nhrp_reqid_alloc(&nhrp_packet_reqid, &r->reqid, nhrp_reg_reply)); +	hdr->u.request_id = htonl(nhrp_reqid_alloc(&nhrp_packet_reqid, +						   &r->reqid, nhrp_reg_reply));  	/* FIXME: push CIE for each local protocol address */  	cie = nhrp_cie_push(zb, NHRP_CODE_SUCCESS, NULL, NULL); @@ -208,17 +226,20 @@ static void nhrp_reg_delete(struct nhrp_registration *r)  	XFREE(MTYPE_NHRP_REGISTRATION, r);  } -static struct nhrp_registration *nhrp_reg_by_nbma(struct nhrp_nhs *nhs, const union sockunion *nbma_addr) +static struct nhrp_registration * +nhrp_reg_by_nbma(struct nhrp_nhs *nhs, const union sockunion *nbma_addr)  {  	struct nhrp_registration *r; -	list_for_each_entry(r, &nhs->reglist_head, reglist_entry) -		if (sockunion_same(&r->peer->vc->remote.nbma, nbma_addr)) -			return r; +	list_for_each_entry( +		r, &nhs->reglist_head, +		reglist_entry) if (sockunion_same(&r->peer->vc->remote.nbma, +						  nbma_addr)) return r;  	return NULL;  } -static void nhrp_nhs_resolve_cb(struct resolver_query *q, int n, union sockunion *addrs) +static void nhrp_nhs_resolve_cb(struct resolver_query *q, int n, +				union sockunion *addrs)  {  	struct nhrp_nhs *nhs = container_of(q, struct nhrp_nhs, dns_resolve);  	struct nhrp_interface *nifp = nhs->ifp->info; @@ -236,8 +257,8 @@ static void nhrp_nhs_resolve_cb(struct resolver_query *q, int n, union sockunion  	thread_add_timer(master, nhrp_nhs_resolve, nhs, 2 * 60 * 60,  			 &nhs->t_resolve); -	list_for_each_entry(reg, &nhs->reglist_head, reglist_entry) -		reg->mark = 1; +	list_for_each_entry(reg, &nhs->reglist_head, reglist_entry) reg->mark = +		1;  	nhs->hub = 0;  	for (i = 0; i < n; i++) { @@ -258,12 +279,14 @@ static void nhrp_nhs_resolve_cb(struct resolver_query *q, int n, union sockunion  		reg->timeout = 1;  		list_init(®->reglist_entry);  		list_add_tail(®->reglist_entry, &nhs->reglist_head); -		nhrp_peer_notify_add(reg->peer, ®->peer_notifier, nhrp_reg_peer_notify); +		nhrp_peer_notify_add(reg->peer, ®->peer_notifier, +				     nhrp_reg_peer_notify);  		thread_add_timer_msec(master, nhrp_reg_send_req, reg, 50,  				      ®->t_register);  	} -	list_for_each_entry_safe(reg, regn, &nhs->reglist_head, reglist_entry) { +	list_for_each_entry_safe(reg, regn, &nhs->reglist_head, reglist_entry) +	{  		if (reg->mark)  			nhrp_reg_delete(reg);  	} @@ -273,24 +296,27 @@ static int nhrp_nhs_resolve(struct thread *t)  {  	struct nhrp_nhs *nhs = THREAD_ARG(t); -	resolver_resolve(&nhs->dns_resolve, AF_INET, nhs->nbma_fqdn, nhrp_nhs_resolve_cb); +	resolver_resolve(&nhs->dns_resolve, AF_INET, nhs->nbma_fqdn, +			 nhrp_nhs_resolve_cb);  	return 0;  } -int nhrp_nhs_add(struct interface *ifp, afi_t afi, union sockunion *proto_addr, const char *nbma_fqdn) +int nhrp_nhs_add(struct interface *ifp, afi_t afi, union sockunion *proto_addr, +		 const char *nbma_fqdn)  {  	struct nhrp_interface *nifp = ifp->info;  	struct nhrp_nhs *nhs; -	if (sockunion_family(proto_addr) != AF_UNSPEC && -	    sockunion_family(proto_addr) != afi2family(afi)) +	if (sockunion_family(proto_addr) != AF_UNSPEC +	    && sockunion_family(proto_addr) != afi2family(afi))  		return NHRP_ERR_PROTOCOL_ADDRESS_MISMATCH; -	list_for_each_entry(nhs, &nifp->afi[afi].nhslist_head, nhslist_entry) { -		if (sockunion_family(&nhs->proto_addr) != AF_UNSPEC && -		    sockunion_family(proto_addr) != AF_UNSPEC && -		    sockunion_same(&nhs->proto_addr, proto_addr)) +	list_for_each_entry(nhs, &nifp->afi[afi].nhslist_head, nhslist_entry) +	{ +		if (sockunion_family(&nhs->proto_addr) != AF_UNSPEC +		    && sockunion_family(proto_addr) != AF_UNSPEC +		    && sockunion_same(&nhs->proto_addr, proto_addr))  			return NHRP_ERR_ENTRY_EXISTS;  		if (strcmp(nhs->nbma_fqdn, nbma_fqdn) == 0) @@ -298,9 +324,10 @@ int nhrp_nhs_add(struct interface *ifp, afi_t afi, union sockunion *proto_addr,  	}  	nhs = XMALLOC(MTYPE_NHRP_NHS, sizeof(struct nhrp_nhs)); -	if (!nhs) return NHRP_ERR_NO_MEMORY; +	if (!nhs) +		return NHRP_ERR_NO_MEMORY; -	*nhs = (struct nhrp_nhs) { +	*nhs = (struct nhrp_nhs){  		.afi = afi,  		.ifp = ifp,  		.proto_addr = *proto_addr, @@ -314,17 +341,20 @@ int nhrp_nhs_add(struct interface *ifp, afi_t afi, union sockunion *proto_addr,  	return NHRP_OK;  } -int nhrp_nhs_del(struct interface *ifp, afi_t afi, union sockunion *proto_addr, const char *nbma_fqdn) +int nhrp_nhs_del(struct interface *ifp, afi_t afi, union sockunion *proto_addr, +		 const char *nbma_fqdn)  {  	struct nhrp_interface *nifp = ifp->info;  	struct nhrp_nhs *nhs, *nnhs;  	int ret = NHRP_ERR_ENTRY_NOT_FOUND; -	if (sockunion_family(proto_addr) != AF_UNSPEC && -	    sockunion_family(proto_addr) != afi2family(afi)) +	if (sockunion_family(proto_addr) != AF_UNSPEC +	    && sockunion_family(proto_addr) != afi2family(afi))  		return NHRP_ERR_PROTOCOL_ADDRESS_MISMATCH; -	list_for_each_entry_safe(nhs, nnhs, &nifp->afi[afi].nhslist_head, nhslist_entry) { +	list_for_each_entry_safe(nhs, nnhs, &nifp->afi[afi].nhslist_head, +				 nhslist_entry) +	{  		if (!sockunion_same(&nhs->proto_addr, proto_addr))  			continue;  		if (strcmp(nhs->nbma_fqdn, nbma_fqdn) != 0) @@ -345,7 +375,7 @@ int nhrp_nhs_free(struct nhrp_nhs *nhs)  		nhrp_reg_delete(r);  	THREAD_OFF(nhs->t_resolve);  	list_del(&nhs->nhslist_entry); -	free((void*) nhs->nbma_fqdn); +	free((void *)nhs->nbma_fqdn);  	XFREE(MTYPE_NHRP_NHS, nhs);  	return 0;  } @@ -361,22 +391,27 @@ void nhrp_nhs_terminate(void)  	FOR_ALL_INTERFACES (vrf, ifp) {  		nifp = ifp->info;  		for (afi = 0; afi < AFI_MAX; afi++) { -			list_for_each_entry_safe(nhs, tmp, &nifp->afi[afi].nhslist_head, nhslist_entry) -				nhrp_nhs_free(nhs); +			list_for_each_entry_safe( +				nhs, tmp, &nifp->afi[afi].nhslist_head, +				nhslist_entry) nhrp_nhs_free(nhs);  		}  	}  } -void nhrp_nhs_foreach(struct interface *ifp, afi_t afi, void (*cb)(struct nhrp_nhs *, struct nhrp_registration *, void *), void *ctx) +void nhrp_nhs_foreach(struct interface *ifp, afi_t afi, +		      void (*cb)(struct nhrp_nhs *, struct nhrp_registration *, +				 void *), +		      void *ctx)  {  	struct nhrp_interface *nifp = ifp->info;  	struct nhrp_nhs *nhs;  	struct nhrp_registration *reg; -	list_for_each_entry(nhs, &nifp->afi[afi].nhslist_head, nhslist_entry) { +	list_for_each_entry(nhs, &nifp->afi[afi].nhslist_head, nhslist_entry) +	{  		if (!list_empty(&nhs->reglist_head)) { -			list_for_each_entry(reg, &nhs->reglist_head, reglist_entry) -				cb(nhs, reg, ctx); +			list_for_each_entry(reg, &nhs->reglist_head, +					    reglist_entry) cb(nhs, reg, ctx);  		} else  			cb(nhs, 0, ctx);  	} diff --git a/nhrpd/nhrp_packet.c b/nhrpd/nhrp_packet.c index 36281d5172..c27ebe1d90 100644 --- a/nhrpd/nhrp_packet.c +++ b/nhrpd/nhrp_packet.c @@ -21,8 +21,10 @@ struct nhrp_reqid_pool nhrp_packet_reqid;  static uint16_t family2proto(int family)  {  	switch (family) { -	case AF_INET: return ETH_P_IP; -	case AF_INET6: return ETH_P_IPV6; +	case AF_INET: +		return ETH_P_IP; +	case AF_INET6: +		return ETH_P_IPV6;  	}  	return 0;  } @@ -30,26 +32,29 @@ static uint16_t family2proto(int family)  static int proto2family(uint16_t proto)  {  	switch (proto) { -	case ETH_P_IP: return AF_INET; -	case ETH_P_IPV6: return AF_INET6; +	case ETH_P_IP: +		return AF_INET; +	case ETH_P_IPV6: +		return AF_INET6;  	}  	return AF_UNSPEC;  } -struct nhrp_packet_header *nhrp_packet_push( -	struct zbuf *zb, uint8_t type, -	const union sockunion *src_nbma, -	const union sockunion *src_proto, -	const union sockunion *dst_proto) +struct nhrp_packet_header *nhrp_packet_push(struct zbuf *zb, uint8_t type, +					    const union sockunion *src_nbma, +					    const union sockunion *src_proto, +					    const union sockunion *dst_proto)  {  	struct nhrp_packet_header *hdr;  	hdr = zbuf_push(zb, struct nhrp_packet_header); -	if (!hdr) return NULL; +	if (!hdr) +		return NULL; -	*hdr = (struct nhrp_packet_header) { +	*hdr = (struct nhrp_packet_header){  		.afnum = htons(family2afi(sockunion_family(src_nbma))), -		.protocol_type = htons(family2proto(sockunion_family(src_proto))), +		.protocol_type = +			htons(family2proto(sockunion_family(src_proto))),  		.version = NHRP_VERSION_RFC2332,  		.type = type,  		.hop_count = 64, @@ -59,42 +64,43 @@ struct nhrp_packet_header *nhrp_packet_push(  	};  	zbuf_put(zb, sockunion_get_addr(src_nbma), hdr->src_nbma_address_len); -	zbuf_put(zb, sockunion_get_addr(src_proto), hdr->src_protocol_address_len); -	zbuf_put(zb, sockunion_get_addr(dst_proto), hdr->dst_protocol_address_len); +	zbuf_put(zb, sockunion_get_addr(src_proto), +		 hdr->src_protocol_address_len); +	zbuf_put(zb, sockunion_get_addr(dst_proto), +		 hdr->dst_protocol_address_len);  	return hdr;  } -struct nhrp_packet_header *nhrp_packet_pull( -	struct zbuf *zb, -	union sockunion *src_nbma, -	union sockunion *src_proto, -	union sockunion *dst_proto) +struct nhrp_packet_header *nhrp_packet_pull(struct zbuf *zb, +					    union sockunion *src_nbma, +					    union sockunion *src_proto, +					    union sockunion *dst_proto)  {  	struct nhrp_packet_header *hdr;  	hdr = zbuf_pull(zb, struct nhrp_packet_header); -	if (!hdr) return NULL; - -	sockunion_set( -		src_nbma, afi2family(htons(hdr->afnum)), -		zbuf_pulln(zb, hdr->src_nbma_address_len + hdr->src_nbma_subaddress_len), -		hdr->src_nbma_address_len + hdr->src_nbma_subaddress_len); -	sockunion_set( -		src_proto, proto2family(htons(hdr->protocol_type)), -		zbuf_pulln(zb, hdr->src_protocol_address_len), -		hdr->src_protocol_address_len); -	sockunion_set( -		dst_proto, proto2family(htons(hdr->protocol_type)), -		zbuf_pulln(zb, hdr->dst_protocol_address_len), -		hdr->dst_protocol_address_len); +	if (!hdr) +		return NULL; + +	sockunion_set(src_nbma, afi2family(htons(hdr->afnum)), +		      zbuf_pulln(zb, +				 hdr->src_nbma_address_len +					 + hdr->src_nbma_subaddress_len), +		      hdr->src_nbma_address_len + hdr->src_nbma_subaddress_len); +	sockunion_set(src_proto, proto2family(htons(hdr->protocol_type)), +		      zbuf_pulln(zb, hdr->src_protocol_address_len), +		      hdr->src_protocol_address_len); +	sockunion_set(dst_proto, proto2family(htons(hdr->protocol_type)), +		      zbuf_pulln(zb, hdr->dst_protocol_address_len), +		      hdr->dst_protocol_address_len);  	return hdr;  }  uint16_t nhrp_packet_calculate_checksum(const uint8_t *pdu, uint16_t len)  { -	const uint16_t *pdu16 = (const uint16_t *) pdu; +	const uint16_t *pdu16 = (const uint16_t *)pdu;  	uint32_t csum = 0;  	int i; @@ -114,24 +120,24 @@ void nhrp_packet_complete(struct zbuf *zb, struct nhrp_packet_header *hdr)  	unsigned short size;  	if (hdr->extension_offset) -		nhrp_ext_push(zb, hdr, NHRP_EXTENSION_END | NHRP_EXTENSION_FLAG_COMPULSORY); +		nhrp_ext_push(zb, hdr, +			      NHRP_EXTENSION_END +				      | NHRP_EXTENSION_FLAG_COMPULSORY);  	size = zb->tail - (uint8_t *)hdr;  	hdr->packet_size = htons(size);  	hdr->checksum = 0; -	hdr->checksum = nhrp_packet_calculate_checksum((uint8_t *) hdr, size); +	hdr->checksum = nhrp_packet_calculate_checksum((uint8_t *)hdr, size);  } -struct nhrp_cie_header *nhrp_cie_push( -	struct zbuf *zb, -	uint8_t code, -	const union sockunion *nbma, -	const union sockunion *proto) +struct nhrp_cie_header *nhrp_cie_push(struct zbuf *zb, uint8_t code, +				      const union sockunion *nbma, +				      const union sockunion *proto)  {  	struct nhrp_cie_header *cie;  	cie = zbuf_push(zb, struct nhrp_cie_header); -	*cie = (struct nhrp_cie_header) { +	*cie = (struct nhrp_cie_header){  		.code = code,  	};  	if (nbma) { @@ -140,37 +146,38 @@ struct nhrp_cie_header *nhrp_cie_push(  	}  	if (proto) {  		cie->protocol_address_len = sockunion_get_addrlen(proto); -		zbuf_put(zb, sockunion_get_addr(proto), cie->protocol_address_len); +		zbuf_put(zb, sockunion_get_addr(proto), +			 cie->protocol_address_len);  	}  	return cie;  } -struct nhrp_cie_header *nhrp_cie_pull( -	struct zbuf *zb, -	struct nhrp_packet_header *hdr, -	union sockunion *nbma, -	union sockunion *proto) +struct nhrp_cie_header *nhrp_cie_pull(struct zbuf *zb, +				      struct nhrp_packet_header *hdr, +				      union sockunion *nbma, +				      union sockunion *proto)  {  	struct nhrp_cie_header *cie;  	cie = zbuf_pull(zb, struct nhrp_cie_header); -	if (!cie) return NULL; +	if (!cie) +		return NULL;  	if (cie->nbma_address_len + cie->nbma_subaddress_len) { -		sockunion_set( -			nbma, afi2family(htons(hdr->afnum)), -			zbuf_pulln(zb, cie->nbma_address_len + cie->nbma_subaddress_len), -			cie->nbma_address_len + cie->nbma_subaddress_len); +		sockunion_set(nbma, afi2family(htons(hdr->afnum)), +			      zbuf_pulln(zb, +					 cie->nbma_address_len +						 + cie->nbma_subaddress_len), +			      cie->nbma_address_len + cie->nbma_subaddress_len);  	} else {  		sockunion_family(nbma) = AF_UNSPEC;  	}  	if (cie->protocol_address_len) { -		sockunion_set( -			proto, proto2family(htons(hdr->protocol_type)), -			zbuf_pulln(zb, cie->protocol_address_len), -			cie->protocol_address_len); +		sockunion_set(proto, proto2family(htons(hdr->protocol_type)), +			      zbuf_pulln(zb, cie->protocol_address_len), +			      cie->protocol_address_len);  	} else {  		sockunion_family(proto) = AF_UNSPEC;  	} @@ -178,49 +185,64 @@ struct nhrp_cie_header *nhrp_cie_pull(  	return cie;  } -struct nhrp_extension_header *nhrp_ext_push(struct zbuf *zb, struct nhrp_packet_header *hdr, uint16_t type) +struct nhrp_extension_header * +nhrp_ext_push(struct zbuf *zb, struct nhrp_packet_header *hdr, uint16_t type)  {  	struct nhrp_extension_header *ext;  	ext = zbuf_push(zb, struct nhrp_extension_header); -	if (!ext) return NULL; +	if (!ext) +		return NULL;  	if (!hdr->extension_offset) -		hdr->extension_offset = htons(zb->tail - (uint8_t*) hdr - sizeof(struct nhrp_extension_header)); +		hdr->extension_offset = +			htons(zb->tail - (uint8_t *)hdr +			      - sizeof(struct nhrp_extension_header)); -	*ext = (struct nhrp_extension_header) { -		.type = htons(type), -		.length = 0, +	*ext = (struct nhrp_extension_header){ +		.type = htons(type), .length = 0,  	};  	return ext;  }  void nhrp_ext_complete(struct zbuf *zb, struct nhrp_extension_header *ext)  { -	ext->length = htons(zb->tail - (uint8_t*)ext - sizeof(struct nhrp_extension_header)); +	ext->length = htons(zb->tail - (uint8_t *)ext +			    - sizeof(struct nhrp_extension_header));  } -struct nhrp_extension_header *nhrp_ext_pull(struct zbuf *zb, struct zbuf *payload) +struct nhrp_extension_header *nhrp_ext_pull(struct zbuf *zb, +					    struct zbuf *payload)  {  	struct nhrp_extension_header *ext;  	uint16_t plen;  	ext = zbuf_pull(zb, struct nhrp_extension_header); -	if (!ext) return NULL; +	if (!ext) +		return NULL;  	plen = htons(ext->length);  	zbuf_init(payload, zbuf_pulln(zb, plen), plen, plen);  	return ext;  } -void nhrp_ext_request(struct zbuf *zb, struct nhrp_packet_header *hdr, struct interface *ifp) +void nhrp_ext_request(struct zbuf *zb, struct nhrp_packet_header *hdr, +		      struct interface *ifp)  {  	/* Place holders for standard extensions */ -	nhrp_ext_push(zb, hdr, NHRP_EXTENSION_FORWARD_TRANSIT_NHS | NHRP_EXTENSION_FLAG_COMPULSORY); -	nhrp_ext_push(zb, hdr, NHRP_EXTENSION_REVERSE_TRANSIT_NHS | NHRP_EXTENSION_FLAG_COMPULSORY); -	nhrp_ext_push(zb, hdr, NHRP_EXTENSION_RESPONDER_ADDRESS | NHRP_EXTENSION_FLAG_COMPULSORY); +	nhrp_ext_push(zb, hdr, +		      NHRP_EXTENSION_FORWARD_TRANSIT_NHS +			      | NHRP_EXTENSION_FLAG_COMPULSORY); +	nhrp_ext_push(zb, hdr, +		      NHRP_EXTENSION_REVERSE_TRANSIT_NHS +			      | NHRP_EXTENSION_FLAG_COMPULSORY); +	nhrp_ext_push(zb, hdr, +		      NHRP_EXTENSION_RESPONDER_ADDRESS +			      | NHRP_EXTENSION_FLAG_COMPULSORY);  } -int nhrp_ext_reply(struct zbuf *zb, struct nhrp_packet_header *hdr, struct interface *ifp, struct nhrp_extension_header *ext, struct zbuf *extpayload) +int nhrp_ext_reply(struct zbuf *zb, struct nhrp_packet_header *hdr, +		   struct interface *ifp, struct nhrp_extension_header *ext, +		   struct zbuf *extpayload)  {  	struct nhrp_interface *nifp = ifp->info;  	struct nhrp_afi_data *ad = &nifp->afi[htons(hdr->afnum)]; @@ -233,18 +255,21 @@ int nhrp_ext_reply(struct zbuf *zb, struct nhrp_packet_header *hdr, struct inter  		return 0;  	dst = nhrp_ext_push(zb, hdr, htons(ext->type)); -	if (!dst) goto err; +	if (!dst) +		goto err;  	switch (type) {  	case NHRP_EXTENSION_RESPONDER_ADDRESS: -		cie = nhrp_cie_push(zb, NHRP_CODE_SUCCESS, &nifp->nbma, &ad->addr); -		if (!cie) goto err; +		cie = nhrp_cie_push(zb, NHRP_CODE_SUCCESS, &nifp->nbma, +				    &ad->addr); +		if (!cie) +			goto err;  		cie->holding_time = htons(ad->holdtime);  		break;  	default:  		if (type & NHRP_EXTENSION_FLAG_COMPULSORY)  			goto err; -		/* fallthru */ +	/* fallthru */  	case NHRP_EXTENSION_FORWARD_TRANSIT_NHS:  	case NHRP_EXTENSION_REVERSE_TRANSIT_NHS:  		/* Supported compulsory extensions, and any @@ -273,7 +298,8 @@ static int nhrp_packet_recvraw(struct thread *t)  	thread_add_read(master, nhrp_packet_recvraw, 0, fd, NULL);  	zb = zbuf_alloc(1500); -	if (!zb) return 0; +	if (!zb) +		return 0;  	len = zbuf_size(zb);  	addrlen = sizeof(addr); @@ -292,10 +318,12 @@ static int nhrp_packet_recvraw(struct thread *t)  	}  	ifp = if_lookup_by_index(ifindex, VRF_DEFAULT); -	if (!ifp) goto err; +	if (!ifp) +		goto err;  	p = nhrp_peer_get(ifp, &remote_nbma); -	if (!p) goto err; +	if (!p) +		goto err;  	nhrp_peer_recv(p, zb);  	nhrp_peer_unref(p); diff --git a/nhrpd/nhrp_peer.c b/nhrpd/nhrp_peer.c index 2bcddc0801..8952a282e9 100644 --- a/nhrpd/nhrp_peer.c +++ b/nhrpd/nhrp_peer.c @@ -85,10 +85,12 @@ static void __nhrp_peer_check(struct nhrp_peer *p)  			nhrp_peer_ref(p);  			p->online = online;  			if (online) { -				notifier_call(&p->notifier_list, NOTIFY_PEER_UP); +				notifier_call(&p->notifier_list, +					      NOTIFY_PEER_UP);  			} else {  				p->requested = p->fallback_requested = 0; -				notifier_call(&p->notifier_list, NOTIFY_PEER_DOWN); +				notifier_call(&p->notifier_list, +					      NOTIFY_PEER_DOWN);  			}  			nhrp_peer_unref(p);  		} @@ -130,7 +132,8 @@ static void nhrp_peer_ifp_notify(struct notifier_block *n, unsigned long cmd)  		if (vc && p->vc != vc) {  			nhrp_vc_notify_del(p->vc, &p->vc_notifier);  			p->vc = vc; -			nhrp_vc_notify_add(p->vc, &p->vc_notifier, nhrp_peer_vc_notify); +			nhrp_vc_notify_add(p->vc, &p->vc_notifier, +					   nhrp_peer_vc_notify);  			__nhrp_peer_check(p);  		}  		/* fallthru */ /* to post config update */ @@ -163,47 +166,53 @@ static void *nhrp_peer_create(void *data)  	p = XMALLOC(MTYPE_NHRP_PEER, sizeof(*p));  	if (p) { -		*p = (struct nhrp_peer) { +		*p = (struct nhrp_peer){  			.ref = 0,  			.ifp = key->ifp,  			.vc = key->vc, -			.notifier_list = NOTIFIER_LIST_INITIALIZER(&p->notifier_list), +			.notifier_list = +				NOTIFIER_LIST_INITIALIZER(&p->notifier_list),  		};  		nhrp_vc_notify_add(p->vc, &p->vc_notifier, nhrp_peer_vc_notify); -		nhrp_interface_notify_add(p->ifp, &p->ifp_notifier, nhrp_peer_ifp_notify); +		nhrp_interface_notify_add(p->ifp, &p->ifp_notifier, +					  nhrp_peer_ifp_notify);  	}  	return p;  } -struct nhrp_peer *nhrp_peer_get(struct interface *ifp, const union sockunion *remote_nbma) +struct nhrp_peer *nhrp_peer_get(struct interface *ifp, +				const union sockunion *remote_nbma)  {  	struct nhrp_interface *nifp = ifp->info;  	struct nhrp_peer key, *p;  	struct nhrp_vc *vc;  	if (!nifp->peer_hash) { -		nifp->peer_hash = hash_create(nhrp_peer_key, -					      nhrp_peer_cmp, +		nifp->peer_hash = hash_create(nhrp_peer_key, nhrp_peer_cmp,  					      "NHRP Peer Hash"); -		if (!nifp->peer_hash) return NULL; +		if (!nifp->peer_hash) +			return NULL;  	}  	vc = nhrp_vc_get(&nifp->nbma, remote_nbma, 1); -	if (!vc) return NULL; +	if (!vc) +		return NULL;  	key.ifp = ifp;  	key.vc = vc;  	p = hash_get(nifp->peer_hash, &key, nhrp_peer_create);  	nhrp_peer_ref(p); -	if (p->ref == 1) __nhrp_peer_check(p); +	if (p->ref == 1) +		__nhrp_peer_check(p);  	return p;  }  struct nhrp_peer *nhrp_peer_ref(struct nhrp_peer *p)  { -	if (p) p->ref++; +	if (p) +		p->ref++;  	return p;  } @@ -227,10 +236,11 @@ static int nhrp_peer_request_timeout(struct thread *t)  	if (p->online)  		return 0; -	if (nifp->ipsec_fallback_profile && !p->prio && !p->fallback_requested) { +	if (nifp->ipsec_fallback_profile && !p->prio +	    && !p->fallback_requested) {  		p->fallback_requested = 1; -		vici_request_vc(nifp->ipsec_fallback_profile, -				&vc->local.nbma, &vc->remote.nbma, p->prio); +		vici_request_vc(nifp->ipsec_fallback_profile, &vc->local.nbma, +				&vc->remote.nbma, p->prio);  		thread_add_timer(master, nhrp_peer_request_timeout, p, 30,  				 &p->t_fallback);  	} else { @@ -259,7 +269,8 @@ int nhrp_peer_check(struct nhrp_peer *p, int establish)  	p->prio = establish > 1;  	p->requested = 1; -	vici_request_vc(nifp->ipsec_profile, &vc->local.nbma, &vc->remote.nbma, p->prio); +	vici_request_vc(nifp->ipsec_profile, &vc->local.nbma, &vc->remote.nbma, +			p->prio);  	thread_add_timer(master, nhrp_peer_request_timeout, p,  			 (nifp->ipsec_fallback_profile && !p->prio) ? 15 : 30,  			 &p->t_fallback); @@ -267,7 +278,8 @@ int nhrp_peer_check(struct nhrp_peer *p, int establish)  	return 0;  } -void nhrp_peer_notify_add(struct nhrp_peer *p, struct notifier_block *n, notifier_fn_t fn) +void nhrp_peer_notify_add(struct nhrp_peer *p, struct notifier_block *n, +			  notifier_fn_t fn)  {  	notifier_add(n, &p->notifier_list, fn);  } @@ -288,13 +300,12 @@ 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), -		sockunion_get_addrlen(&p->vc->remote.nbma)); +	os_sendmsg(zb->head, zbuf_used(zb), p->ifp->ifindex, +		   sockunion_get_addr(&p->vc->remote.nbma), +		   sockunion_get_addrlen(&p->vc->remote.nbma));  	zbuf_reset(zb);  } @@ -313,16 +324,17 @@ static void nhrp_handle_resolution_req(struct nhrp_packet_parser *p)  		return;  	} -	if (p->if_ad->network_id && -	    p->route_type == NHRP_ROUTE_OFF_NBMA && -	    p->route_prefix.prefixlen < 8) { -		debugf(NHRP_DEBUG_COMMON, "Shortcut to more generic than /8 dropped"); +	if (p->if_ad->network_id && p->route_type == NHRP_ROUTE_OFF_NBMA +	    && p->route_prefix.prefixlen < 8) { +		debugf(NHRP_DEBUG_COMMON, +		       "Shortcut to more generic than /8 dropped");  		return;  	}  	debugf(NHRP_DEBUG_COMMON, "Parsing and replying to Resolution Req"); -	if (nhrp_route_address(p->ifp, &p->src_proto, NULL, &peer) != NHRP_ROUTE_NBMA_NEXTHOP) +	if (nhrp_route_address(p->ifp, &p->src_proto, NULL, &peer) +	    != NHRP_ROUTE_NBMA_NEXTHOP)  		return;  #if 0 @@ -337,15 +349,20 @@ static void nhrp_handle_resolution_req(struct nhrp_packet_parser *p)  	/* Create reply */  	zb = zbuf_alloc(1500); -	hdr = nhrp_packet_push(zb, NHRP_PACKET_RESOLUTION_REPLY, &p->src_nbma, &p->src_proto, &p->dst_proto); +	hdr = nhrp_packet_push(zb, NHRP_PACKET_RESOLUTION_REPLY, &p->src_nbma, +			       &p->src_proto, &p->dst_proto);  	/* Copied information from request */ -	hdr->flags = p->hdr->flags & htons(NHRP_FLAG_RESOLUTION_SOURCE_IS_ROUTER|NHRP_FLAG_RESOLUTION_SOURCE_STABLE); -	hdr->flags |= htons(NHRP_FLAG_RESOLUTION_DESTINATION_STABLE | NHRP_FLAG_RESOLUTION_AUTHORATIVE); +	hdr->flags = +		p->hdr->flags & htons(NHRP_FLAG_RESOLUTION_SOURCE_IS_ROUTER +				      | NHRP_FLAG_RESOLUTION_SOURCE_STABLE); +	hdr->flags |= htons(NHRP_FLAG_RESOLUTION_DESTINATION_STABLE +			    | NHRP_FLAG_RESOLUTION_AUTHORATIVE);  	hdr->u.request_id = p->hdr->u.request_id;  	/* CIE payload */ -	cie = nhrp_cie_push(zb, NHRP_CODE_SUCCESS, &nifp->nbma, &p->if_ad->addr); +	cie = nhrp_cie_push(zb, NHRP_CODE_SUCCESS, &nifp->nbma, +			    &p->if_ad->addr);  	cie->holding_time = htons(p->if_ad->holdtime);  	cie->mtu = htons(p->if_ad->mtu);  	if (p->if_ad->network_id && p->route_type == NHRP_ROUTE_OFF_NBMA) @@ -359,10 +376,14 @@ static void nhrp_handle_resolution_req(struct nhrp_packet_parser *p)  		case NHRP_EXTENSION_NAT_ADDRESS:  			if (sockunion_family(&nifp->nat_nbma) == AF_UNSPEC)  				break; -			ext = nhrp_ext_push(zb, hdr, NHRP_EXTENSION_NAT_ADDRESS); -			if (!ext) goto err; -			cie = nhrp_cie_push(zb, NHRP_CODE_SUCCESS, &nifp->nat_nbma, &p->if_ad->addr); -			if (!cie) goto err; +			ext = nhrp_ext_push(zb, hdr, +					    NHRP_EXTENSION_NAT_ADDRESS); +			if (!ext) +				goto err; +			cie = nhrp_cie_push(zb, NHRP_CODE_SUCCESS, +					    &nifp->nat_nbma, &p->if_ad->addr); +			if (!cie) +				goto err;  			nhrp_ext_complete(zb, ext);  			break;  		default: @@ -387,7 +408,8 @@ static void nhrp_handle_registration_request(struct nhrp_packet_parser *p)  	struct nhrp_cie_header *cie;  	struct nhrp_extension_header *ext;  	struct nhrp_cache *c; -	union sockunion cie_nbma, cie_proto, *proto_addr, *nbma_addr, *nbma_natoa; +	union sockunion cie_nbma, cie_proto, *proto_addr, *nbma_addr, +		*nbma_natoa;  	int holdtime, prefix_len, hostprefix_len, natted = 0;  	size_t paylen;  	void *pay; @@ -400,26 +422,31 @@ static void nhrp_handle_registration_request(struct nhrp_packet_parser *p)  	/* Create reply */  	zb = zbuf_alloc(1500); -	hdr = nhrp_packet_push(zb, NHRP_PACKET_REGISTRATION_REPLY, -		&p->src_nbma, &p->src_proto, &p->if_ad->addr); +	hdr = nhrp_packet_push(zb, NHRP_PACKET_REGISTRATION_REPLY, &p->src_nbma, +			       &p->src_proto, &p->if_ad->addr);  	/* Copied information from request */ -	hdr->flags = p->hdr->flags & htons(NHRP_FLAG_REGISTRATION_UNIQUE | NHRP_FLAG_REGISTRATION_NAT); +	hdr->flags = p->hdr->flags & htons(NHRP_FLAG_REGISTRATION_UNIQUE +					   | NHRP_FLAG_REGISTRATION_NAT);  	hdr->u.request_id = p->hdr->u.request_id;  	/* Copy payload CIEs */  	paylen = zbuf_used(&p->payload);  	pay = zbuf_pushn(zb, paylen); -	if (!pay) goto err; +	if (!pay) +		goto err;  	memcpy(pay, zbuf_pulln(&p->payload, paylen), paylen);  	zbuf_init(&payload, pay, paylen, paylen); -	while ((cie = nhrp_cie_pull(&payload, hdr, &cie_nbma, &cie_proto)) != NULL) { +	while ((cie = nhrp_cie_pull(&payload, hdr, &cie_nbma, &cie_proto)) +	       != NULL) {  		prefix_len = cie->prefix_length;  		if (prefix_len == 0 || prefix_len >= hostprefix_len)  			prefix_len = hostprefix_len; -		if (prefix_len != hostprefix_len && !(p->hdr->flags & htons(NHRP_FLAG_REGISTRATION_UNIQUE))) { +		if (prefix_len != hostprefix_len +		    && !(p->hdr->flags +			 & htons(NHRP_FLAG_REGISTRATION_UNIQUE))) {  			cie->code = NHRP_CODE_BINDING_NON_UNIQUE;  			continue;  		} @@ -430,15 +457,20 @@ static void nhrp_handle_registration_request(struct nhrp_packet_parser *p)  			continue;  		} -		proto_addr = (sockunion_family(&cie_proto) == AF_UNSPEC) ? &p->src_proto : &cie_proto; -		nbma_addr = (sockunion_family(&cie_nbma) == AF_UNSPEC) ? &p->src_nbma : &cie_nbma; +		proto_addr = (sockunion_family(&cie_proto) == AF_UNSPEC) +				     ? &p->src_proto +				     : &cie_proto; +		nbma_addr = (sockunion_family(&cie_nbma) == AF_UNSPEC) +				    ? &p->src_nbma +				    : &cie_nbma;  		nbma_natoa = NULL;  		if (natted) {  			nbma_natoa = nbma_addr;  		}  		holdtime = htons(cie->holding_time); -		if (!holdtime) holdtime = p->if_ad->holdtime; +		if (!holdtime) +			holdtime = p->if_ad->holdtime;  		c = nhrp_cache_get(ifp, proto_addr, 1);  		if (!c) { @@ -446,7 +478,9 @@ static void nhrp_handle_registration_request(struct nhrp_packet_parser *p)  			continue;  		} -		if (!nhrp_cache_update_binding(c, NHRP_CACHE_DYNAMIC, holdtime, nhrp_peer_ref(p->peer), htons(cie->mtu), nbma_natoa)) { +		if (!nhrp_cache_update_binding(c, NHRP_CACHE_DYNAMIC, holdtime, +					       nhrp_peer_ref(p->peer), +					       htons(cie->mtu), nbma_natoa)) {  			cie->code = NHRP_CODE_ADMINISTRATIVELY_PROHIBITED;  			continue;  		} @@ -458,13 +492,15 @@ static void nhrp_handle_registration_request(struct nhrp_packet_parser *p)  	while ((ext = nhrp_ext_pull(&p->extensions, &payload)) != NULL) {  		switch (htons(ext->type) & ~NHRP_EXTENSION_FLAG_COMPULSORY) {  		case NHRP_EXTENSION_NAT_ADDRESS: -			ext = nhrp_ext_push(zb, hdr, NHRP_EXTENSION_NAT_ADDRESS); -			if (!ext) goto err; +			ext = nhrp_ext_push(zb, hdr, +					    NHRP_EXTENSION_NAT_ADDRESS); +			if (!ext) +				goto err;  			zbuf_copy(zb, &payload, zbuf_used(&payload));  			if (natted) {  				nhrp_cie_push(zb, NHRP_CODE_SUCCESS, -					&p->peer->vc->remote.nbma, -					&p->src_proto); +					      &p->peer->vc->remote.nbma, +					      &p->src_proto);  			}  			nhrp_ext_complete(zb, ext);  			break; @@ -481,32 +517,44 @@ err:  	zbuf_free(zb);  } -static int parse_ether_packet(struct zbuf *zb, uint16_t protocol_type, union sockunion *src, union sockunion *dst) +static int parse_ether_packet(struct zbuf *zb, uint16_t protocol_type, +			      union sockunion *src, union sockunion *dst)  {  	switch (protocol_type) {  	case ETH_P_IP: { -			struct iphdr *iph = zbuf_pull(zb, struct iphdr); -			if (iph) { -				if (src) sockunion_set(src, AF_INET, (uint8_t*) &iph->saddr, sizeof(iph->saddr)); -				if (dst) sockunion_set(dst, AF_INET, (uint8_t*) &iph->daddr, sizeof(iph->daddr)); -			} +		struct iphdr *iph = zbuf_pull(zb, struct iphdr); +		if (iph) { +			if (src) +				sockunion_set(src, AF_INET, +					      (uint8_t *)&iph->saddr, +					      sizeof(iph->saddr)); +			if (dst) +				sockunion_set(dst, AF_INET, +					      (uint8_t *)&iph->daddr, +					      sizeof(iph->daddr));  		} -		break; +	} break;  	case ETH_P_IPV6: { -			struct ipv6hdr *iph = zbuf_pull(zb, struct ipv6hdr); -			if (iph) { -				if (src) sockunion_set(src, AF_INET6, (uint8_t*) &iph->saddr, sizeof(iph->saddr)); -				if (dst) sockunion_set(dst, AF_INET6, (uint8_t*) &iph->daddr, sizeof(iph->daddr)); -			} +		struct ipv6hdr *iph = zbuf_pull(zb, struct ipv6hdr); +		if (iph) { +			if (src) +				sockunion_set(src, AF_INET6, +					      (uint8_t *)&iph->saddr, +					      sizeof(iph->saddr)); +			if (dst) +				sockunion_set(dst, AF_INET6, +					      (uint8_t *)&iph->daddr, +					      sizeof(iph->daddr));  		} -		break; +	} break;  	default:  		return 0;  	}  	return 1;  } -void nhrp_peer_send_indication(struct interface *ifp, uint16_t protocol_type, struct zbuf *pkt) +void nhrp_peer_send_indication(struct interface *ifp, uint16_t protocol_type, +			       struct zbuf *pkt)  {  	union sockunion dst;  	struct zbuf *zb, payload; @@ -516,7 +564,8 @@ void nhrp_peer_send_indication(struct interface *ifp, uint16_t protocol_type, st  	struct nhrp_peer *p;  	char buf[2][SU_ADDRSTRLEN]; -	if (!nifp->enabled) return; +	if (!nifp->enabled) +		return;  	payload = *pkt;  	if (!parse_ether_packet(&payload, protocol_type, &dst, NULL)) @@ -527,20 +576,23 @@ void nhrp_peer_send_indication(struct interface *ifp, uint16_t protocol_type, st  	if_ad = &nifp->afi[family2afi(sockunion_family(&dst))];  	if (!(if_ad->flags & NHRP_IFF_REDIRECT)) { -		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])); +		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]));  		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])); +	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]));  	/* Create reply */  	zb = zbuf_alloc(1500); -	hdr = nhrp_packet_push(zb, NHRP_PACKET_TRAFFIC_INDICATION, &nifp->nbma, &if_ad->addr, &dst); +	hdr = nhrp_packet_push(zb, NHRP_PACKET_TRAFFIC_INDICATION, &nifp->nbma, +			       &if_ad->addr, &dst);  	hdr->hop_count = 0;  	/* Payload is the packet causing indication */ @@ -560,11 +612,13 @@ static void nhrp_handle_error_ind(struct nhrp_packet_parser *pp)  	char buf[2][SU_ADDRSTRLEN];  	hdr = nhrp_packet_pull(&origmsg, &src_nbma, &src_proto, &dst_proto); -	if (!hdr) return; +	if (!hdr) +		return; -	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])); +	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]));  	reqid = nhrp_reqid_lookup(&nhrp_packet_reqid, htonl(hdr->u.request_id));  	if (reqid) @@ -576,13 +630,16 @@ static void nhrp_handle_traffic_ind(struct nhrp_packet_parser *p)  	union sockunion dst;  	char buf[2][SU_ADDRSTRLEN]; -	if (!parse_ether_packet(&p->payload, htons(p->hdr->protocol_type), NULL, &dst)) +	if (!parse_ether_packet(&p->payload, htons(p->hdr->protocol_type), NULL, +				&dst))  		return; -	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]), -		(p->if_ad->flags & NHRP_IFF_SHORTCUT) ? "trying shortcut" : "ignored"); +	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]), +	       (p->if_ad->flags & NHRP_IFF_SHORTCUT) ? "trying shortcut" +						     : "ignored");  	if (p->if_ad->flags & NHRP_IFF_SHORTCUT)  		nhrp_shortcut_initiate(&dst); @@ -599,50 +656,57 @@ static struct {  	enum packet_type_t type;  	const char *name;  	void (*handler)(struct nhrp_packet_parser *); -} packet_types[] = { -	[0] = { -		.type = PACKET_UNKNOWN, -		.name = "UNKNOWN", -	}, -	[NHRP_PACKET_RESOLUTION_REQUEST] = { -		.type = PACKET_REQUEST, -		.name = "Resolution-Request", -		.handler = nhrp_handle_resolution_req, -	}, -	[NHRP_PACKET_RESOLUTION_REPLY] = { -		.type = PACKET_REPLY, -		.name = "Resolution-Reply", -	}, -	[NHRP_PACKET_REGISTRATION_REQUEST] = { -		.type = PACKET_REQUEST, -		.name = "Registration-Request", -		.handler = nhrp_handle_registration_request, -	}, -	[NHRP_PACKET_REGISTRATION_REPLY] = { -		.type = PACKET_REPLY, -		.name = "Registration-Reply", -	}, -	[NHRP_PACKET_PURGE_REQUEST] = { -		.type = PACKET_REQUEST, -		.name = "Purge-Request", -	}, -	[NHRP_PACKET_PURGE_REPLY] = { -		.type = PACKET_REPLY, -		.name = "Purge-Reply", -	}, -	[NHRP_PACKET_ERROR_INDICATION] = { -		.type = PACKET_INDICATION, -		.name = "Error-Indication", -		.handler = nhrp_handle_error_ind, -	}, -	[NHRP_PACKET_TRAFFIC_INDICATION] = { -		.type = PACKET_INDICATION, -		.name = "Traffic-Indication", -		.handler = nhrp_handle_traffic_ind, -	} -}; - -static void nhrp_peer_forward(struct nhrp_peer *p, struct nhrp_packet_parser *pp) +} packet_types[] = {[0] = +			    { +				    .type = PACKET_UNKNOWN, +				    .name = "UNKNOWN", +			    }, +		    [NHRP_PACKET_RESOLUTION_REQUEST] = +			    { +				    .type = PACKET_REQUEST, +				    .name = "Resolution-Request", +				    .handler = nhrp_handle_resolution_req, +			    }, +		    [NHRP_PACKET_RESOLUTION_REPLY] = +			    { +				    .type = PACKET_REPLY, +				    .name = "Resolution-Reply", +			    }, +		    [NHRP_PACKET_REGISTRATION_REQUEST] = +			    { +				    .type = PACKET_REQUEST, +				    .name = "Registration-Request", +				    .handler = nhrp_handle_registration_request, +			    }, +		    [NHRP_PACKET_REGISTRATION_REPLY] = +			    { +				    .type = PACKET_REPLY, +				    .name = "Registration-Reply", +			    }, +		    [NHRP_PACKET_PURGE_REQUEST] = +			    { +				    .type = PACKET_REQUEST, +				    .name = "Purge-Request", +			    }, +		    [NHRP_PACKET_PURGE_REPLY] = +			    { +				    .type = PACKET_REPLY, +				    .name = "Purge-Reply", +			    }, +		    [NHRP_PACKET_ERROR_INDICATION] = +			    { +				    .type = PACKET_INDICATION, +				    .name = "Error-Indication", +				    .handler = nhrp_handle_error_ind, +			    }, +		    [NHRP_PACKET_TRAFFIC_INDICATION] = { +			    .type = PACKET_INDICATION, +			    .name = "Traffic-Indication", +			    .handler = nhrp_handle_traffic_ind, +		    }}; + +static void nhrp_peer_forward(struct nhrp_peer *p, +			      struct nhrp_packet_parser *pp)  {  	struct zbuf *zb, extpl;  	struct nhrp_packet_header *hdr; @@ -658,7 +722,8 @@ static void nhrp_peer_forward(struct nhrp_peer *p, struct nhrp_packet_parser *pp  	/* Create forward packet - copy header */  	zb = zbuf_alloc(1500); -	hdr = nhrp_packet_push(zb, pp->hdr->type, &pp->src_nbma, &pp->src_proto, &pp->dst_proto); +	hdr = nhrp_packet_push(zb, pp->hdr->type, &pp->src_nbma, &pp->src_proto, +			       &pp->dst_proto);  	hdr->flags = pp->hdr->flags;  	hdr->hop_count = pp->hdr->hop_count - 1;  	hdr->u.request_id = pp->hdr->u.request_id; @@ -675,22 +740,29 @@ static void nhrp_peer_forward(struct nhrp_peer *p, struct nhrp_packet_parser *pp  			break;  		dst = nhrp_ext_push(zb, hdr, htons(ext->type)); -		if (!dst) goto err; +		if (!dst) +			goto err;  		switch (type) {  		case NHRP_EXTENSION_FORWARD_TRANSIT_NHS:  		case NHRP_EXTENSION_REVERSE_TRANSIT_NHS:  			zbuf_put(zb, extpl.head, len); -			if ((type == NHRP_EXTENSION_REVERSE_TRANSIT_NHS) == -			    (packet_types[hdr->type].type == PACKET_REPLY)) { +			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) { -					if (sockunion_same(&p->vc->remote.nbma, &cie_nbma)) +				while ((cie = nhrp_cie_pull(&extpl, pp->hdr, +							    &cie_nbma, +							    &cie_protocol)) +				       != NULL) { +					if (sockunion_same(&p->vc->remote.nbma, +							   &cie_nbma))  						goto err;  				}  				/* Append our selves to the list */ -				cie = nhrp_cie_push(zb, NHRP_CODE_SUCCESS, &nifp->nbma, &if_ad->addr); -				if (!cie) goto err; +				cie = nhrp_cie_push(zb, NHRP_CODE_SUCCESS, +						    &nifp->nbma, &if_ad->addr); +				if (!cie) +					goto err;  				cie->holding_time = htons(if_ad->holdtime);  			}  			break; @@ -699,7 +771,7 @@ static void nhrp_peer_forward(struct nhrp_peer *p, struct nhrp_packet_parser *pp  				/* FIXME: RFC says to just copy, but not  				 * append our selves to the transit NHS list */  				goto err; -			/* fallthru */ +		/* fallthru */  		case NHRP_EXTENSION_RESPONDER_ADDRESS:  			/* Supported compulsory extensions, and any  			 * non-compulsory that is not explicitly handled, @@ -730,26 +802,25 @@ static void nhrp_packet_debug(struct zbuf *zb, const char *dir)  	if (likely(!(debug_flags & NHRP_DEBUG_COMMON)))  		return; -	zbuf_init(&zhdr, zb->buf, zb->tail-zb->buf, zb->tail-zb->buf); +	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]);  	reply = packet_types[hdr->type].type == PACKET_REPLY; -	debugf(NHRP_DEBUG_COMMON, "%s %s(%d) %s -> %s", -		dir, -		packet_types[hdr->type].name ? : "Unknown", -		hdr->type, -		reply ? buf[1] : buf[0], -		reply ? buf[0] : buf[1]); +	debugf(NHRP_DEBUG_COMMON, "%s %s(%d) %s -> %s", dir, +	       packet_types[hdr->type].name ?: "Unknown", hdr->type, +	       reply ? buf[1] : buf[0], reply ? buf[0] : buf[1]);  }  static int proto2afi(uint16_t proto)  {  	switch (proto) { -	case ETH_P_IP: return AFI_IP; -	case ETH_P_IPV6: return AFI_IP6; +	case ETH_P_IP: +		return AFI_IP; +	case ETH_P_IPV6: +		return AFI_IP6;  	}  	return AF_UNSPEC;  } @@ -776,8 +847,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"; @@ -803,16 +874,16 @@ void nhrp_peer_recv(struct nhrp_peer *p, struct zbuf *zb)  	nbma_afi = htons(hdr->afnum);  	proto_afi = proto2afi(htons(hdr->protocol_type)); -	if (hdr->type > NHRP_PACKET_MAX || -	    hdr->version != NHRP_VERSION_RFC2332 || -	    nbma_afi >= AFI_MAX || proto_afi == AF_UNSPEC || -	    packet_types[hdr->type].type == PACKET_UNKNOWN || -	    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]), -			   (int) hdr->type, (int) hdr->version, -			   (int) nbma_afi, (int) htons(hdr->protocol_type), -			   (int) htons(hdr->packet_size), (int) realsize); +	if (hdr->type > NHRP_PACKET_MAX || hdr->version != NHRP_VERSION_RFC2332 +	    || nbma_afi >= AFI_MAX || proto_afi == AF_UNSPEC +	    || packet_types[hdr->type].type == PACKET_UNKNOWN +	    || 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]), +			(int)hdr->type, (int)hdr->version, (int)nbma_afi, +			(int)htons(hdr->protocol_type), +			(int)htons(hdr->packet_size), (int)realsize);  		goto drop;  	}  	pp.if_ad = &((struct nhrp_interface *)ifp->info)->afi[proto_afi]; @@ -842,18 +913,22 @@ void nhrp_peer_recv(struct nhrp_peer *p, struct zbuf *zb)  	 * pre-handled. */  	/* Figure out if this is local */ -	target_addr = (packet_types[hdr->type].type == PACKET_REPLY) ? &pp.src_proto : &pp.dst_proto; +	target_addr = (packet_types[hdr->type].type == PACKET_REPLY) +			      ? &pp.src_proto +			      : &pp.dst_proto;  	if (sockunion_same(&pp.src_proto, &pp.dst_proto))  		pp.route_type = NHRP_ROUTE_LOCAL;  	else -		pp.route_type = nhrp_route_address(pp.ifp, target_addr, &pp.route_prefix, &peer); +		pp.route_type = nhrp_route_address(pp.ifp, target_addr, +						   &pp.route_prefix, &peer);  	switch (pp.route_type) {  	case NHRP_ROUTE_LOCAL:  		nhrp_packet_debug(zb, "!LOCAL");  		if (packet_types[hdr->type].type == PACKET_REPLY) { -			reqid = nhrp_reqid_lookup(&nhrp_packet_reqid, htonl(hdr->u.request_id)); +			reqid = nhrp_reqid_lookup(&nhrp_packet_reqid, +						  htonl(hdr->u.request_id));  			if (reqid) {  				reqid->cb(reqid, &pp);  				break; @@ -878,10 +953,12 @@ void nhrp_peer_recv(struct nhrp_peer *p, struct zbuf *zb)  drop:  	if (info) { -		zlog_info("From %s: error: %s", -			  sockunion2str(&vc->remote.nbma, buf[0], sizeof buf[0]), -			  info); +		zlog_info( +			"From %s: error: %s", +			sockunion2str(&vc->remote.nbma, buf[0], sizeof buf[0]), +			info);  	} -	if (peer) nhrp_peer_unref(peer); +	if (peer) +		nhrp_peer_unref(peer);  	zbuf_free(zb);  } diff --git a/nhrpd/nhrp_protocol.h b/nhrpd/nhrp_protocol.h index d5f120ea0b..3b94c814d6 100644 --- a/nhrpd/nhrp_protocol.h +++ b/nhrpd/nhrp_protocol.h @@ -79,51 +79,51 @@  /* NHRP Packet Structures */  struct nhrp_packet_header {  	/* Fixed header */ -	uint16_t	afnum; -	uint16_t	protocol_type; -	uint8_t		snap[5]; -	uint8_t		hop_count; -	uint16_t	packet_size; -	uint16_t	checksum; -	uint16_t	extension_offset; -	uint8_t		version; -	uint8_t		type; -	uint8_t		src_nbma_address_len; -	uint8_t		src_nbma_subaddress_len; +	uint16_t afnum; +	uint16_t protocol_type; +	uint8_t snap[5]; +	uint8_t hop_count; +	uint16_t packet_size; +	uint16_t checksum; +	uint16_t extension_offset; +	uint8_t version; +	uint8_t type; +	uint8_t src_nbma_address_len; +	uint8_t src_nbma_subaddress_len;  	/* Mandatory header */ -	uint8_t		src_protocol_address_len; -	uint8_t		dst_protocol_address_len; -	uint16_t	flags; +	uint8_t src_protocol_address_len; +	uint8_t dst_protocol_address_len; +	uint16_t flags;  	union { -		uint32_t		request_id; +		uint32_t request_id;  		struct { -			uint16_t	code; -			uint16_t	offset; +			uint16_t code; +			uint16_t offset;  		} error;  	} u;  } __attribute__((packed));  struct nhrp_cie_header { -	uint8_t		code; -	uint8_t		prefix_length; -	uint16_t	unused; -	uint16_t	mtu; -	uint16_t	holding_time; -	uint8_t		nbma_address_len; -	uint8_t		nbma_subaddress_len; -	uint8_t		protocol_address_len; -	uint8_t		preference; +	uint8_t code; +	uint8_t prefix_length; +	uint16_t unused; +	uint16_t mtu; +	uint16_t holding_time; +	uint8_t nbma_address_len; +	uint8_t nbma_subaddress_len; +	uint8_t protocol_address_len; +	uint8_t preference;  } __attribute__((packed));  struct nhrp_extension_header { -	uint16_t	type; -	uint16_t	length; +	uint16_t type; +	uint16_t length;  } __attribute__((packed));  struct nhrp_cisco_authentication_extension { -	uint32_t	type; -	uint8_t		secret[8]; +	uint32_t type; +	uint8_t secret[8];  } __attribute__((packed));  #endif diff --git a/nhrpd/nhrp_route.c b/nhrpd/nhrp_route.c index 8178a8b4b5..044529a5ca 100644 --- a/nhrpd/nhrp_route.c +++ b/nhrpd/nhrp_route.c @@ -25,7 +25,8 @@ struct route_info {  	struct interface *nhrp_ifp;  }; -static struct route_node *nhrp_route_update_get(const struct prefix *p, int create) +static struct route_node *nhrp_route_update_get(const struct prefix *p, +						int create)  {  	struct route_node *rn;  	afi_t afi = family2afi(PREFIX_FAMILY(p)); @@ -36,7 +37,8 @@ static struct route_node *nhrp_route_update_get(const struct prefix *p, int crea  	if (create) {  		rn = route_node_get(zebra_rib[afi], p);  		if (!rn->info) { -			rn->info = XCALLOC(MTYPE_NHRP_ROUTE, sizeof(struct route_info)); +			rn->info = XCALLOC(MTYPE_NHRP_ROUTE, +					   sizeof(struct route_info));  			route_lock_node(rn);  		}  		return rn; @@ -49,7 +51,8 @@ static void nhrp_route_update_put(struct route_node *rn)  {  	struct route_info *ri = rn->info; -	if (!ri->ifp && !ri->nhrp_ifp && sockunion_family(&ri->via) == AF_UNSPEC) { +	if (!ri->ifp && !ri->nhrp_ifp +	    && sockunion_family(&ri->via) == AF_UNSPEC) {  		XFREE(MTYPE_NHRP_ROUTE, rn->info);  		rn->info = NULL;  		route_unlock_node(rn); @@ -57,12 +60,15 @@ static void nhrp_route_update_put(struct route_node *rn)  	route_unlock_node(rn);  } -static void nhrp_route_update_zebra(const struct prefix *p, union sockunion *nexthop, struct interface *ifp) +static void nhrp_route_update_zebra(const struct prefix *p, +				    union sockunion *nexthop, +				    struct interface *ifp)  {  	struct route_node *rn;  	struct route_info *ri; -	rn = nhrp_route_update_get(p, (sockunion_family(nexthop) != AF_UNSPEC) || ifp); +	rn = nhrp_route_update_get( +		p, (sockunion_family(nexthop) != AF_UNSPEC) || ifp);  	if (rn) {  		ri = rn->info;  		ri->via = *nexthop; @@ -84,7 +90,9 @@ void nhrp_route_update_nhrp(const struct prefix *p, struct interface *ifp)  	}  } -void nhrp_route_announce(int add, enum nhrp_cache_type type, const struct prefix *p, struct interface *ifp, const union sockunion *nexthop, uint32_t mtu) +void nhrp_route_announce(int add, enum nhrp_cache_type type, +			 const struct prefix *p, struct interface *ifp, +			 const union sockunion *nexthop, uint32_t mtu)  {  	struct zapi_route api;  	struct zapi_nexthop *api_nh; @@ -158,10 +166,13 @@ void nhrp_route_announce(int add, enum nhrp_cache_type type, const struct prefix  		char buf[2][PREFIX_STRLEN];  		prefix2str(&api.prefix, buf[0], sizeof(buf[0])); -		zlog_debug("Zebra send: route %s %s nexthop %s metric %u" +		zlog_debug( +			"Zebra send: route %s %s nexthop %s metric %u"  			" count %d dev %s",  			add ? "add" : "del", buf[0], -			nexthop ? inet_ntop(api.prefix.family, &api_nh->gate, buf[1], sizeof(buf[1])) : "<onlink>", +			nexthop ? inet_ntop(api.prefix.family, &api_nh->gate, +					    buf[1], sizeof(buf[1])) +				: "<onlink>",  			api.metric, api.nexthop_num, ifp ? ifp->name : "none");  	} @@ -169,7 +180,8 @@ void nhrp_route_announce(int add, enum nhrp_cache_type type, const struct prefix  			   &api);  } -int nhrp_route_read(int cmd, struct zclient *zclient, zebra_size_t length, vrf_id_t vrf_id) +int nhrp_route_read(int cmd, struct zclient *zclient, zebra_size_t length, +		    vrf_id_t vrf_id)  {  	struct zapi_route api;  	struct zapi_nexthop *api_nh; @@ -200,15 +212,15 @@ int nhrp_route_read(int cmd, struct zclient *zclient, zebra_size_t length, vrf_i  		}  		if (api_nh->ifindex != IFINDEX_INTERNAL) -                       	ifp = if_lookup_by_index(api_nh->ifindex, VRF_DEFAULT); +			ifp = if_lookup_by_index(api_nh->ifindex, VRF_DEFAULT);  	}  	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]), -		ifp ? ifp->name : "(none)"); +	       added ? "add" : "del", +	       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);  	nhrp_shortcut_prefix_change(&api.prefix, !added); @@ -216,7 +228,8 @@ int nhrp_route_read(int cmd, struct zclient *zclient, zebra_size_t length, vrf_i  	return 0;  } -int nhrp_route_get_nexthop(const union sockunion *addr, struct prefix *p, union sockunion *via, struct interface **ifp) +int nhrp_route_get_nexthop(const union sockunion *addr, struct prefix *p, +			   union sockunion *via, struct interface **ifp)  {  	struct route_node *rn;  	struct route_info *ri; @@ -227,30 +240,38 @@ int nhrp_route_get_nexthop(const union sockunion *addr, struct prefix *p, union  	sockunion2hostprefix(addr, &lookup);  	rn = route_node_match(zebra_rib[afi], &lookup); -	if (!rn) return 0; +	if (!rn) +		return 0;  	ri = rn->info;  	if (ri->nhrp_ifp) {  		debugf(NHRP_DEBUG_ROUTE, "lookup %s: nhrp_if=%s", -			prefix2str(&lookup, buf, sizeof buf), -			ri->nhrp_ifp->name); +		       prefix2str(&lookup, buf, sizeof buf), +		       ri->nhrp_ifp->name); -		if (via) sockunion_family(via) = AF_UNSPEC; -		if (ifp) *ifp = ri->nhrp_ifp; +		if (via) +			sockunion_family(via) = AF_UNSPEC; +		if (ifp) +			*ifp = ri->nhrp_ifp;  	} else {  		debugf(NHRP_DEBUG_ROUTE, "lookup %s: zebra route dev %s", -			prefix2str(&lookup, buf, sizeof buf), -			ri->ifp ? ri->ifp->name : "(none)"); +		       prefix2str(&lookup, buf, sizeof buf), +		       ri->ifp ? ri->ifp->name : "(none)"); -		if (via) *via = ri->via; -		if (ifp) *ifp = ri->ifp; +		if (via) +			*via = ri->via; +		if (ifp) +			*ifp = ri->ifp;  	} -	if (p) *p = rn->p; +	if (p) +		*p = rn->p;  	route_unlock_node(rn);  	return 1;  } -enum nhrp_route_type nhrp_route_address(struct interface *in_ifp, union sockunion *addr, struct prefix *p, struct nhrp_peer **peer) +enum nhrp_route_type nhrp_route_address(struct interface *in_ifp, +					union sockunion *addr, struct prefix *p, +					struct nhrp_peer **peer)  {  	struct interface *ifp = in_ifp;  	struct nhrp_interface *nifp; @@ -266,7 +287,8 @@ enum nhrp_route_type nhrp_route_address(struct interface *in_ifp, union sockunio  		c = nhrp_cache_get(ifp, addr, 0);  		if (c && c->cur.type == NHRP_CACHE_LOCAL) { -			if (p) memset(p, 0, sizeof(*p)); +			if (p) +				memset(p, 0, sizeof(*p));  			return NHRP_ROUTE_LOCAL;  		}  	} @@ -277,7 +299,8 @@ enum nhrp_route_type nhrp_route_address(struct interface *in_ifp, union sockunio  		if (ifp) {  			/* Departing from nbma network? */  			nifp = ifp->info; -			if (network_id && network_id != nifp->afi[afi].network_id) +			if (network_id +			    && network_id != nifp->afi[afi].network_id)  				return NHRP_ROUTE_OFF_NBMA;  		}  		if (sockunion_family(&via[i]) == AF_UNSPEC) @@ -290,10 +313,12 @@ enum nhrp_route_type nhrp_route_address(struct interface *in_ifp, union sockunio  	if (ifp) {  		c = nhrp_cache_get(ifp, addr, 0);  		if (c && c->cur.type >= NHRP_CACHE_DYNAMIC) { -			if (p) memset(p, 0, sizeof(*p)); +			if (p) +				memset(p, 0, sizeof(*p));  			if (c->cur.type == NHRP_CACHE_LOCAL)  				return NHRP_ROUTE_LOCAL; -			if (peer) *peer = nhrp_peer_ref(c->cur.peer); +			if (peer) +				*peer = nhrp_peer_ref(c->cur.peer);  			return NHRP_ROUTE_NBMA_NEXTHOP;  		}  	} @@ -301,14 +326,13 @@ enum nhrp_route_type nhrp_route_address(struct interface *in_ifp, union sockunio  	return NHRP_ROUTE_BLACKHOLE;  } -static void -nhrp_zebra_connected (struct zclient *zclient) +static void nhrp_zebra_connected(struct zclient *zclient)  {  	zclient_send_reg_requests(zclient, VRF_DEFAULT);  	zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, -	    ZEBRA_ROUTE_ALL, 0, VRF_DEFAULT); +				ZEBRA_ROUTE_ALL, 0, VRF_DEFAULT);  	zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, -	    ZEBRA_ROUTE_ALL, 0, VRF_DEFAULT); +				ZEBRA_ROUTE_ALL, 0, VRF_DEFAULT);  }  void nhrp_zebra_init(void) diff --git a/nhrpd/nhrp_shortcut.c b/nhrpd/nhrp_shortcut.c index 4faa9d7863..9ed2517069 100644 --- a/nhrpd/nhrp_shortcut.c +++ b/nhrpd/nhrp_shortcut.c @@ -28,7 +28,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);  	}  } @@ -38,22 +38,25 @@ static int nhrp_shortcut_do_expire(struct thread *t)  	struct nhrp_shortcut *s = THREAD_ARG(t);  	s->t_timer = NULL; -	thread_add_timer(master, nhrp_shortcut_do_purge, s, -			 s->holding_time / 3, &s->t_timer); +	thread_add_timer(master, nhrp_shortcut_do_purge, s, s->holding_time / 3, +			 &s->t_timer);  	s->expiring = 1;  	nhrp_shortcut_check_use(s);  	return 0;  } -static void nhrp_shortcut_cache_notify(struct notifier_block *n, unsigned long cmd) +static void nhrp_shortcut_cache_notify(struct notifier_block *n, +				       unsigned long cmd)  { -	struct nhrp_shortcut *s = container_of(n, struct nhrp_shortcut, cache_notifier); +	struct nhrp_shortcut *s = +		container_of(n, struct nhrp_shortcut, cache_notifier);  	switch (cmd) {  	case NOTIFY_CACHE_UP:  		if (!s->route_installed) { -			nhrp_route_announce(1, s->type, s->p, NULL, &s->cache->remote_addr, 0); +			nhrp_route_announce(1, s->type, s->p, NULL, +					    &s->cache->remote_addr, 0);  			s->route_installed = 1;  		}  		break; @@ -63,7 +66,8 @@ static void nhrp_shortcut_cache_notify(struct notifier_block *n, unsigned long c  	case NOTIFY_CACHE_DOWN:  	case NOTIFY_CACHE_DELETE:  		if (s->route_installed) { -			nhrp_route_announce(0, NHRP_CACHE_INVALID, s->p, NULL, NULL, 0); +			nhrp_route_announce(0, NHRP_CACHE_INVALID, s->p, NULL, +					    NULL, 0);  			s->route_installed = 0;  		}  		if (cmd == NOTIFY_CACHE_DELETE) @@ -72,7 +76,9 @@ static void nhrp_shortcut_cache_notify(struct notifier_block *n, unsigned long c  	}  } -static void nhrp_shortcut_update_binding(struct nhrp_shortcut *s, enum nhrp_cache_type type, struct nhrp_cache *c, int holding_time) +static void nhrp_shortcut_update_binding(struct nhrp_shortcut *s, +					 enum nhrp_cache_type type, +					 struct nhrp_cache *c, int holding_time)  {  	s->type = type;  	if (c != s->cache) { @@ -82,15 +88,19 @@ static void nhrp_shortcut_update_binding(struct nhrp_shortcut *s, enum nhrp_cach  		}  		s->cache = c;  		if (s->cache) { -			nhrp_cache_notify_add(s->cache, &s->cache_notifier, nhrp_shortcut_cache_notify); +			nhrp_cache_notify_add(s->cache, &s->cache_notifier, +					      nhrp_shortcut_cache_notify);  			if (s->cache->route_installed) { -				/* Force renewal of Zebra announce on prefix change */ +				/* Force renewal of Zebra announce on prefix +				 * change */  				s->route_installed = 0; -				nhrp_shortcut_cache_notify(&s->cache_notifier, NOTIFY_CACHE_UP); +				nhrp_shortcut_cache_notify(&s->cache_notifier, +							   NOTIFY_CACHE_UP);  			}  		}  		if (!s->cache || !s->cache->route_installed) -			nhrp_shortcut_cache_notify(&s->cache_notifier, NOTIFY_CACHE_DOWN); +			nhrp_shortcut_cache_notify(&s->cache_notifier, +						   NOTIFY_CACHE_DOWN);  	}  	if (s->type == NHRP_CACHE_NEGATIVE && !s->route_installed) {  		nhrp_route_announce(1, s->type, s->p, NULL, NULL, 0); @@ -119,7 +129,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); @@ -153,12 +163,13 @@ static struct nhrp_shortcut *nhrp_shortcut_get(struct prefix *p)  	rn = route_node_get(shortcut_rib[afi], p);  	if (!rn->info) { -		s = rn->info = XCALLOC(MTYPE_NHRP_SHORTCUT, sizeof(struct nhrp_shortcut)); +		s = rn->info = XCALLOC(MTYPE_NHRP_SHORTCUT, +				       sizeof(struct nhrp_shortcut));  		s->type = NHRP_CACHE_INVALID;  		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); @@ -166,15 +177,18 @@ static struct nhrp_shortcut *nhrp_shortcut_get(struct prefix *p)  	return s;  } -static void nhrp_shortcut_recv_resolution_rep(struct nhrp_reqid *reqid, void *arg) +static void nhrp_shortcut_recv_resolution_rep(struct nhrp_reqid *reqid, +					      void *arg)  {  	struct nhrp_packet_parser *pp = arg; -	struct nhrp_shortcut *s = container_of(reqid, struct nhrp_shortcut, reqid); +	struct nhrp_shortcut *s = +		container_of(reqid, struct nhrp_shortcut, reqid);  	struct nhrp_shortcut *ps;  	struct nhrp_extension_header *ext;  	struct nhrp_cie_header *cie;  	struct nhrp_cache *c = NULL; -	union sockunion *proto, cie_proto, *nbma, *nbma_natoa, cie_nbma, nat_nbma; +	union sockunion *proto, cie_proto, *nbma, *nbma_natoa, cie_nbma, +		nat_nbma;  	struct prefix prefix, route_prefix;  	struct zbuf extpl;  	char bufp[PREFIX_STRLEN], buf[3][SU_ADDRSTRLEN]; @@ -185,12 +199,16 @@ static void nhrp_shortcut_recv_resolution_rep(struct nhrp_reqid *reqid, void *ar  	thread_add_timer(master, nhrp_shortcut_do_purge, s, 1, &s->t_timer);  	if (pp->hdr->type != NHRP_PACKET_RESOLUTION_REPLY) { -		if (pp->hdr->type == NHRP_PACKET_ERROR_INDICATION && -		    pp->hdr->u.error.code == NHRP_ERROR_PROTOCOL_ADDRESS_UNREACHABLE) { -			debugf(NHRP_DEBUG_COMMON, "Shortcut: Resolution: Protocol address unreachable"); -			nhrp_shortcut_update_binding(s, NHRP_CACHE_NEGATIVE, NULL, holding_time); +		if (pp->hdr->type == NHRP_PACKET_ERROR_INDICATION +		    && pp->hdr->u.error.code +			       == NHRP_ERROR_PROTOCOL_ADDRESS_UNREACHABLE) { +			debugf(NHRP_DEBUG_COMMON, +			       "Shortcut: Resolution: Protocol address unreachable"); +			nhrp_shortcut_update_binding(s, NHRP_CACHE_NEGATIVE, +						     NULL, holding_time);  		} else { -			debugf(NHRP_DEBUG_COMMON, "Shortcut: Resolution failed"); +			debugf(NHRP_DEBUG_COMMON, +			       "Shortcut: Resolution failed");  		}  		return;  	} @@ -208,19 +226,22 @@ static void nhrp_shortcut_recv_resolution_rep(struct nhrp_reqid *reqid, void *ar  	/* Minor sanity check */  	prefix2sockunion(s->p, &cie_proto);  	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])); +		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]));  	}  	/* One or more CIEs should be given as reply, we support only one */  	cie = nhrp_cie_pull(&pp->payload, pp->hdr, &cie_nbma, &cie_proto);  	if (!cie || cie->code != NHRP_CODE_SUCCESS) { -		debugf(NHRP_DEBUG_COMMON, "Shortcut: CIE code %d", cie ? cie->code : -1); +		debugf(NHRP_DEBUG_COMMON, "Shortcut: CIE code %d", +		       cie ? cie->code : -1);  		return;  	} -	proto = sockunion_family(&cie_proto) != AF_UNSPEC ? &cie_proto : &pp->dst_proto; +	proto = sockunion_family(&cie_proto) != AF_UNSPEC ? &cie_proto +							  : &pp->dst_proto;  	if (cie->holding_time)  		holding_time = htons(cie->holding_time); @@ -228,19 +249,22 @@ static void nhrp_shortcut_recv_resolution_rep(struct nhrp_reqid *reqid, void *ar  	prefix.prefixlen = cie->prefix_length;  	/* Sanity check prefix length */ -	if (prefix.prefixlen >= 8*prefix_blen(&prefix) || prefix.prefixlen == 0) { -		prefix.prefixlen = 8*prefix_blen(&prefix); -	} else if (nhrp_route_address(NULL, &pp->dst_proto, &route_prefix, NULL) == NHRP_ROUTE_NBMA_NEXTHOP) { +	if (prefix.prefixlen >= 8 * prefix_blen(&prefix) +	    || prefix.prefixlen == 0) { +		prefix.prefixlen = 8 * prefix_blen(&prefix); +	} else if (nhrp_route_address(NULL, &pp->dst_proto, &route_prefix, NULL) +		   == NHRP_ROUTE_NBMA_NEXTHOP) {  		if (prefix.prefixlen < route_prefix.prefixlen)  			prefix.prefixlen = route_prefix.prefixlen;  	} -	debugf(NHRP_DEBUG_COMMON, "Shortcut: %s is at proto %s cie-nbma %s nat-nbma %s cie-holdtime %d", -		prefix2str(&prefix, bufp, sizeof bufp), -		sockunion2str(proto, buf[0], sizeof buf[0]), -		sockunion2str(&cie_nbma, buf[1], sizeof buf[1]), -		sockunion2str(&nat_nbma, buf[2], sizeof buf[2]), -		htons(cie->holding_time)); +	debugf(NHRP_DEBUG_COMMON, +	       "Shortcut: %s is at proto %s cie-nbma %s nat-nbma %s cie-holdtime %d", +	       prefix2str(&prefix, bufp, sizeof bufp), +	       sockunion2str(proto, buf[0], sizeof buf[0]), +	       sockunion2str(&cie_nbma, buf[1], sizeof buf[1]), +	       sockunion2str(&nat_nbma, buf[2], sizeof buf[2]), +	       htons(cie->holding_time));  	/* Update cache entry for the protocol to nbma binding */  	if (sockunion_family(&nat_nbma) != AF_UNSPEC) { @@ -253,10 +277,10 @@ static void nhrp_shortcut_recv_resolution_rep(struct nhrp_reqid *reqid, void *ar  	if (sockunion_family(nbma)) {  		c = nhrp_cache_get(pp->ifp, proto, 1);  		if (c) { -			nhrp_cache_update_binding( -					c, NHRP_CACHE_CACHED, holding_time, -					nhrp_peer_get(pp->ifp, nbma), -					htons(cie->mtu), nbma_natoa); +			nhrp_cache_update_binding(c, NHRP_CACHE_CACHED, +						  holding_time, +						  nhrp_peer_get(pp->ifp, nbma), +						  htons(cie->mtu), nbma_natoa);  		}  	} @@ -265,7 +289,8 @@ static void nhrp_shortcut_recv_resolution_rep(struct nhrp_reqid *reqid, void *ar  		ps = nhrp_shortcut_get(&prefix);  		if (ps) {  			ps->addr = s->addr; -			nhrp_shortcut_update_binding(ps, NHRP_CACHE_CACHED, c, holding_time); +			nhrp_shortcut_update_binding(ps, NHRP_CACHE_CACHED, c, +						     holding_time);  		}  	} @@ -280,7 +305,8 @@ static void nhrp_shortcut_send_resolution_req(struct nhrp_shortcut *s)  	struct nhrp_interface *nifp;  	struct nhrp_peer *peer; -	if (nhrp_route_address(NULL, &s->addr, NULL, &peer) != NHRP_ROUTE_NBMA_NEXTHOP) +	if (nhrp_route_address(NULL, &s->addr, NULL, &peer) +	    != NHRP_ROUTE_NBMA_NEXTHOP)  		return;  	if (s->type == NHRP_CACHE_INVALID || s->type == NHRP_CACHE_NEGATIVE) @@ -291,12 +317,16 @@ static void nhrp_shortcut_send_resolution_req(struct nhrp_shortcut *s)  	/* Create request */  	zb = zbuf_alloc(1500); -	hdr = nhrp_packet_push(zb, NHRP_PACKET_RESOLUTION_REQUEST, -		&nifp->nbma, &nifp->afi[family2afi(sockunion_family(&s->addr))].addr, &s->addr); -	hdr->u.request_id = htonl(nhrp_reqid_alloc(&nhrp_packet_reqid, &s->reqid, nhrp_shortcut_recv_resolution_rep)); -	hdr->flags = htons(NHRP_FLAG_RESOLUTION_SOURCE_IS_ROUTER | -			   NHRP_FLAG_RESOLUTION_AUTHORATIVE | -			   NHRP_FLAG_RESOLUTION_SOURCE_STABLE); +	hdr = nhrp_packet_push( +		zb, NHRP_PACKET_RESOLUTION_REQUEST, &nifp->nbma, +		&nifp->afi[family2afi(sockunion_family(&s->addr))].addr, +		&s->addr); +	hdr->u.request_id = +		htonl(nhrp_reqid_alloc(&nhrp_packet_reqid, &s->reqid, +				       nhrp_shortcut_recv_resolution_rep)); +	hdr->flags = htons(NHRP_FLAG_RESOLUTION_SOURCE_IS_ROUTER +			   | NHRP_FLAG_RESOLUTION_AUTHORATIVE +			   | NHRP_FLAG_RESOLUTION_SOURCE_STABLE);  	/* RFC2332 - One or zero CIEs, if CIE is present contains:  	 *  - Prefix length: widest acceptable prefix we accept (if U set, 0xff) @@ -346,17 +376,21 @@ void nhrp_shortcut_terminate(void)  	route_table_finish(shortcut_rib[AFI_IP6]);  } -void nhrp_shortcut_foreach(afi_t afi, void (*cb)(struct nhrp_shortcut *, void *), void *ctx) +void nhrp_shortcut_foreach(afi_t afi, +			   void (*cb)(struct nhrp_shortcut *, void *), +			   void *ctx)  {  	struct route_table *rt = shortcut_rib[afi];  	struct route_node *rn;  	route_table_iter_t iter; -	if (!rt) return; +	if (!rt) +		return;  	route_table_iter_init(&iter, rt);  	while ((rn = route_table_iter_next(&iter)) != NULL) { -		if (rn->info) cb(rn->info, ctx); +		if (rn->info) +			cb(rn->info, ctx);  	}  	route_table_iter_cleanup(&iter);  } @@ -401,9 +435,8 @@ static void nhrp_shortcut_purge_prefix(struct nhrp_shortcut *s, void *ctx)  void nhrp_shortcut_prefix_change(const struct prefix *p, int deleted)  {  	struct purge_ctx pctx = { -		.p = p, -		.deleted = deleted, +		.p = p, .deleted = deleted,  	}; -	nhrp_shortcut_foreach(family2afi(PREFIX_FAMILY(p)), nhrp_shortcut_purge_prefix, &pctx); +	nhrp_shortcut_foreach(family2afi(PREFIX_FAMILY(p)), +			      nhrp_shortcut_purge_prefix, &pctx);  } - diff --git a/nhrpd/nhrp_vc.c b/nhrpd/nhrp_vc.c index d0915bc7a3..c373411d66 100644 --- a/nhrpd/nhrp_vc.c +++ b/nhrpd/nhrp_vc.c @@ -31,18 +31,16 @@ static struct list_head childlist_head[512];  static unsigned int nhrp_vc_key(void *peer_data)  {  	struct nhrp_vc *vc = peer_data; -	return jhash_2words( -		sockunion_hash(&vc->local.nbma), -		sockunion_hash(&vc->remote.nbma), -		0); +	return jhash_2words(sockunion_hash(&vc->local.nbma), +			    sockunion_hash(&vc->remote.nbma), 0);  }  static int nhrp_vc_cmp(const void *cache_data, const void *key_data)  {  	const struct nhrp_vc *a = cache_data;  	const struct nhrp_vc *b = key_data; -	return	sockunion_same(&a->local.nbma, &b->local.nbma) && -		sockunion_same(&a->remote.nbma, &b->remote.nbma); +	return sockunion_same(&a->local.nbma, &b->local.nbma) +	       && sockunion_same(&a->remote.nbma, &b->remote.nbma);  }  static void *nhrp_vc_alloc(void *data) @@ -51,10 +49,11 @@ static void *nhrp_vc_alloc(void *data)  	vc = XMALLOC(MTYPE_NHRP_VC, sizeof(struct nhrp_vc));  	if (vc) { -		*vc = (struct nhrp_vc) { +		*vc = (struct nhrp_vc){  			.local.nbma = key->local.nbma,  			.remote.nbma = key->remote.nbma, -			.notifier_list = NOTIFIER_LIST_INITIALIZER(&vc->notifier_list), +			.notifier_list = +				NOTIFIER_LIST_INITIALIZER(&vc->notifier_list),  		};  	} @@ -66,7 +65,8 @@ static void nhrp_vc_free(void *data)  	XFREE(MTYPE_NHRP_VC, data);  } -struct nhrp_vc *nhrp_vc_get(const union sockunion *src, const union sockunion *dst, int create) +struct nhrp_vc *nhrp_vc_get(const union sockunion *src, +			    const union sockunion *dst, int create)  {  	struct nhrp_vc key;  	key.local.nbma = *src; @@ -105,7 +105,8 @@ int nhrp_vc_ipsec_updown(uint32_t child_id, struct nhrp_vc *vc)  	uint32_t child_hash = child_id % ZEBRA_NUM_OF(childlist_head);  	int abort_migration = 0; -	list_for_each_entry(lsa, &childlist_head[child_hash], childlist_entry) { +	list_for_each_entry(lsa, &childlist_head[child_hash], childlist_entry) +	{  		if (lsa->id == child_id) {  			sa = lsa;  			break; @@ -113,17 +114,21 @@ int nhrp_vc_ipsec_updown(uint32_t child_id, struct nhrp_vc *vc)  	}  	if (!sa) { -		if (!vc) return 0; +		if (!vc) +			return 0;  		sa = XMALLOC(MTYPE_NHRP_VC, sizeof(struct child_sa)); -		if (!sa) return 0; +		if (!sa) +			return 0; -		*sa = (struct child_sa) { +		*sa = (struct child_sa){  			.id = child_id, -			.childlist_entry = LIST_INITIALIZER(sa->childlist_entry), +			.childlist_entry = +				LIST_INITIALIZER(sa->childlist_entry),  			.vc = NULL,  		}; -		list_add_tail(&sa->childlist_entry, &childlist_head[child_hash]); +		list_add_tail(&sa->childlist_entry, +			      &childlist_head[child_hash]);  	}  	if (sa->vc == vc) @@ -138,15 +143,17 @@ int nhrp_vc_ipsec_updown(uint32_t child_id, struct nhrp_vc *vc)  		/* Notify old VC of migration */  		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])); +		       sockunion2str(&sa->vc->remote.nbma, buf[0], +				     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;  	}  	if (sa->vc) {  		/* Deattach old VC */  		sa->vc->ipsec--; -		if (!sa->vc->ipsec) nhrp_vc_ipsec_reset(sa->vc); +		if (!sa->vc->ipsec) +			nhrp_vc_ipsec_reset(sa->vc);  		nhrp_vc_update(sa->vc, NOTIFY_VC_IPSEC_CHANGED);  	} @@ -160,7 +167,8 @@ int nhrp_vc_ipsec_updown(uint32_t child_id, struct nhrp_vc *vc)  	return abort_migration;  } -void nhrp_vc_notify_add(struct nhrp_vc *vc, struct notifier_block *n, notifier_fn_t action) +void nhrp_vc_notify_add(struct nhrp_vc *vc, struct notifier_block *n, +			notifier_fn_t action)  {  	notifier_add(n, &vc->notifier_list, action);  } @@ -186,8 +194,7 @@ static void nhrp_vc_iterator(struct hash_backet *b, void *ctx)  void nhrp_vc_foreach(void (*cb)(struct nhrp_vc *, void *), void *ctx)  {  	struct nhrp_vc_iterator_ctx ic = { -		.cb = cb, -		.ctx = ctx, +		.cb = cb, .ctx = ctx,  	};  	hash_iterate(nhrp_vc_hash, nhrp_vc_iterator, &ic);  } @@ -196,9 +203,7 @@ void nhrp_vc_init(void)  {  	size_t i; -	nhrp_vc_hash = hash_create(nhrp_vc_key, -				   nhrp_vc_cmp, -				   "NHRP VC hash"); +	nhrp_vc_hash = hash_create(nhrp_vc_key, nhrp_vc_cmp, "NHRP VC hash");  	for (i = 0; i < ZEBRA_NUM_OF(childlist_head); i++)  		list_init(&childlist_head[i]);  } @@ -209,7 +214,8 @@ void nhrp_vc_reset(void)  	size_t i;  	for (i = 0; i < ZEBRA_NUM_OF(childlist_head); i++) { -		list_for_each_entry_safe(sa, n, &childlist_head[i], childlist_entry) +		list_for_each_entry_safe(sa, n, &childlist_head[i], +					 childlist_entry)  			nhrp_vc_ipsec_updown(sa->id, 0);  	}  } diff --git a/nhrpd/nhrp_vty.c b/nhrpd/nhrp_vty.c index e0d0268e41..cfedc1c6b9 100644 --- a/nhrpd/nhrp_vty.c +++ b/nhrpd/nhrp_vty.c @@ -17,56 +17,53 @@  #include "netlink.h"  static struct cmd_node zebra_node = { -	.node   = ZEBRA_NODE, +	.node = ZEBRA_NODE,  	.prompt = "%s(config-router)# ", -	.vtysh  = 1, +	.vtysh = 1,  };  static struct cmd_node nhrp_interface_node = { -	.node   = INTERFACE_NODE, +	.node = INTERFACE_NODE,  	.prompt = "%s(config-if)# ", -	.vtysh  = 1, +	.vtysh = 1,  };  #define NHRP_DEBUG_FLAGS_CMD "<all|common|event|interface|kernel|route|vici>" -#define NHRP_DEBUG_FLAGS_STR		\ -	"All messages\n"		\ -	"Common messages (default)\n"	\ -	"Event manager messages\n"	\ -	"Interface messages\n"		\ -	"Kernel messages\n"		\ -	"Route messages\n"		\ +#define NHRP_DEBUG_FLAGS_STR                                                   \ +	"All messages\n"                                                       \ +	"Common messages (default)\n"                                          \ +	"Event manager messages\n"                                             \ +	"Interface messages\n"                                                 \ +	"Kernel messages\n"                                                    \ +	"Route messages\n"                                                     \  	"VICI messages\n"  static const struct message debug_flags_desc[] = { -	{ NHRP_DEBUG_ALL, "all" }, -	{ NHRP_DEBUG_COMMON, "common" }, -	{ NHRP_DEBUG_IF, "interface" }, -	{ NHRP_DEBUG_KERNEL, "kernel" }, -	{ NHRP_DEBUG_ROUTE, "route" }, -	{ NHRP_DEBUG_VICI, "vici" }, -	{ NHRP_DEBUG_EVENT, "event" }, -	{ 0 } -}; +	{NHRP_DEBUG_ALL, "all"},      {NHRP_DEBUG_COMMON, "common"}, +	{NHRP_DEBUG_IF, "interface"}, {NHRP_DEBUG_KERNEL, "kernel"}, +	{NHRP_DEBUG_ROUTE, "route"},  {NHRP_DEBUG_VICI, "vici"}, +	{NHRP_DEBUG_EVENT, "event"},  {0}};  static const struct message interface_flags_desc[] = { -	{ NHRP_IFF_SHORTCUT, "shortcut" }, -	{ NHRP_IFF_REDIRECT, "redirect" }, -	{ NHRP_IFF_REG_NO_UNIQUE, "registration no-unique" }, -	{ 0 } -}; +	{NHRP_IFF_SHORTCUT, "shortcut"}, +	{NHRP_IFF_REDIRECT, "redirect"}, +	{NHRP_IFF_REG_NO_UNIQUE, "registration no-unique"}, +	{0}};  static int nhrp_vty_return(struct vty *vty, int ret)  { -	static const char * const errmsgs[] = { -		[NHRP_ERR_FAIL]				= "Command failed", -		[NHRP_ERR_NO_MEMORY]			= "Out of memory", -		[NHRP_ERR_UNSUPPORTED_INTERFACE]	= "NHRP not supported on this interface", -		[NHRP_ERR_NHRP_NOT_ENABLED]		= "NHRP not enabled (set 'nhrp network-id' first)", -		[NHRP_ERR_ENTRY_EXISTS]			= "Entry exists already", -		[NHRP_ERR_ENTRY_NOT_FOUND]		= "Entry not found", -		[NHRP_ERR_PROTOCOL_ADDRESS_MISMATCH]	= "Protocol address family does not match command (ip/ipv6 mismatch)", +	static const char *const errmsgs[] = { +			[NHRP_ERR_FAIL] = "Command failed", +			[NHRP_ERR_NO_MEMORY] = "Out of memory", +			[NHRP_ERR_UNSUPPORTED_INTERFACE] = +				"NHRP not supported on this interface", +			[NHRP_ERR_NHRP_NOT_ENABLED] = +				"NHRP not enabled (set 'nhrp network-id' first)", +			[NHRP_ERR_ENTRY_EXISTS] = "Entry exists already", +			[NHRP_ERR_ENTRY_NOT_FOUND] = "Entry not found", +			[NHRP_ERR_PROTOCOL_ADDRESS_MISMATCH] = +				"Protocol address family does not match command (ip/ipv6 mismatch)",  	};  	const char *str = NULL;  	char buf[256]; @@ -83,14 +80,14 @@ static int nhrp_vty_return(struct vty *vty, int ret)  		snprintf(buf, sizeof(buf), "Unknown error %d", ret);  	} -	vty_out (vty, "%% %s\n", str); +	vty_out(vty, "%% %s\n", str); -	return CMD_WARNING_CONFIG_FAILED;; +	return CMD_WARNING_CONFIG_FAILED; +	;  } -static int toggle_flag( -	struct vty *vty, const struct message *flag_desc, -	const char *name, int on_off, unsigned *flags) +static int toggle_flag(struct vty *vty, const struct message *flag_desc, +		       const char *name, int on_off, unsigned *flags)  {  	int i; @@ -104,8 +101,9 @@ static int toggle_flag(  		return CMD_SUCCESS;  	} -	vty_out (vty, "%% Invalid value %s\n", name); -	return CMD_WARNING_CONFIG_FAILED;; +	vty_out(vty, "%% Invalid value %s\n", name); +	return CMD_WARNING_CONFIG_FAILED; +	;  }  #ifndef NO_DEBUG @@ -118,7 +116,7 @@ DEFUN_NOSH(show_debugging_nhrp, show_debugging_nhrp_cmd,  {  	int i; -	vty_out (vty, "NHRP debugging status:\n"); +	vty_out(vty, "NHRP debugging status:\n");  	for (i = 0; debug_flags_desc[i].str != NULL; i++) {  		if (debug_flags_desc[i].key == NHRP_DEBUG_ALL) @@ -126,7 +124,7 @@ DEFUN_NOSH(show_debugging_nhrp, show_debugging_nhrp_cmd,  		if (!(debug_flags_desc[i].key & debug_flags))  			continue; -		vty_out (vty, "  NHRP %s debugging is on\n", +		vty_out(vty, "  NHRP %s debugging is on\n",  			debug_flags_desc[i].str);  	} @@ -139,7 +137,8 @@ DEFUN(debug_nhrp, debug_nhrp_cmd,  	"NHRP information\n"  	NHRP_DEBUG_FLAGS_STR)  { -	return toggle_flag(vty, debug_flags_desc, argv[2]->text, 1, &debug_flags); +	return toggle_flag(vty, debug_flags_desc, argv[2]->text, 1, +			   &debug_flags);  }  DEFUN(no_debug_nhrp, no_debug_nhrp_cmd, @@ -149,7 +148,8 @@ DEFUN(no_debug_nhrp, no_debug_nhrp_cmd,  	"NHRP information\n"  	NHRP_DEBUG_FLAGS_STR)  { -	return toggle_flag(vty, debug_flags_desc, argv[3]->text, 0, &debug_flags); +	return toggle_flag(vty, debug_flags_desc, argv[3]->text, 0, +			   &debug_flags);  }  #endif /* NO_DEBUG */ @@ -158,7 +158,7 @@ static int nhrp_config_write(struct vty *vty)  {  #ifndef NO_DEBUG  	if (debug_flags == NHRP_DEBUG_ALL) { -		vty_out (vty, "debug nhrp all\n"); +		vty_out(vty, "debug nhrp all\n");  	} else {  		int i; @@ -167,20 +167,18 @@ static int nhrp_config_write(struct vty *vty)  				continue;  			if (!(debug_flags & debug_flags_desc[i].key))  				continue; -			vty_out (vty, "debug nhrp %s\n", -				  debug_flags_desc[i].str); +			vty_out(vty, "debug nhrp %s\n", +				debug_flags_desc[i].str);  		}  	} -	vty_out (vty, "!\n"); +	vty_out(vty, "!\n");  #endif /* NO_DEBUG */  	if (nhrp_event_socket_path) { -		vty_out (vty, "nhrp event socket %s\n", -			nhrp_event_socket_path); +		vty_out(vty, "nhrp event socket %s\n", nhrp_event_socket_path);  	}  	if (netlink_nflog_group) { -		vty_out (vty, "nhrp nflog-group %d\n", -			netlink_nflog_group); +		vty_out(vty, "nhrp nflog-group %d\n", netlink_nflog_group);  	}  	return 0; @@ -199,7 +197,8 @@ static afi_t cmd_to_afi(const struct cmd_token *tok)  static const char *afi_to_cmd(afi_t afi)  { -	if (afi == AFI_IP6) return "ipv6"; +	if (afi == AFI_IP6) +		return "ipv6";  	return "ip";  } @@ -264,7 +263,7 @@ DEFUN(tunnel_protection, tunnel_protection_cmd,  	VTY_DECLVAR_CONTEXT(interface, ifp);  	nhrp_interface_set_protection(ifp, argv[4]->arg, -			argc > 6 ? argv[6]->arg : NULL); +				      argc > 6 ? argv[6]->arg : NULL);  	return CMD_SUCCESS;  } @@ -348,7 +347,8 @@ DEFUN(if_nhrp_flags, if_nhrp_flags_cmd,  	struct nhrp_interface *nifp = ifp->info;  	afi_t afi = cmd_to_afi(argv[0]); -	return toggle_flag(vty, interface_flags_desc, argv[2]->text, 1, &nifp->afi[afi].flags); +	return toggle_flag(vty, interface_flags_desc, argv[2]->text, 1, +			   &nifp->afi[afi].flags);  }  DEFUN(if_no_nhrp_flags, if_no_nhrp_flags_cmd, @@ -363,7 +363,8 @@ DEFUN(if_no_nhrp_flags, if_no_nhrp_flags_cmd,  	struct nhrp_interface *nifp = ifp->info;  	afi_t afi = cmd_to_afi(argv[1]); -	return toggle_flag(vty, interface_flags_desc, argv[3]->text, 0, &nifp->afi[afi].flags); +	return toggle_flag(vty, interface_flags_desc, argv[3]->text, 0, +			   &nifp->afi[afi].flags);  }  DEFUN(if_nhrp_reg_flags, if_nhrp_reg_flags_cmd, @@ -378,7 +379,8 @@ DEFUN(if_nhrp_reg_flags, if_nhrp_reg_flags_cmd,  	afi_t afi = cmd_to_afi(argv[0]);  	char name[256];  	snprintf(name, sizeof(name), "registration %s", argv[3]->text); -	return toggle_flag(vty, interface_flags_desc, name, 1, &nifp->afi[afi].flags); +	return toggle_flag(vty, interface_flags_desc, name, 1, +			   &nifp->afi[afi].flags);  }  DEFUN(if_no_nhrp_reg_flags, if_no_nhrp_reg_flags_cmd, @@ -394,7 +396,8 @@ DEFUN(if_no_nhrp_reg_flags, if_no_nhrp_reg_flags_cmd,  	afi_t afi = cmd_to_afi(argv[1]);  	char name[256];  	snprintf(name, sizeof(name), "registration %s", argv[4]->text); -	return toggle_flag(vty, interface_flags_desc, name, 0, &nifp->afi[afi].flags); +	return toggle_flag(vty, interface_flags_desc, name, 0, +			   &nifp->afi[afi].flags);  }  DEFUN(if_nhrp_holdtime, if_nhrp_holdtime_cmd, @@ -446,8 +449,8 @@ DEFUN(if_nhrp_mtu, if_nhrp_mtu_cmd,  	if (argv[3]->arg[0] == 'o') {  		nifp->afi[AFI_IP].configured_mtu = -1;  	} else { -		nifp->afi[AFI_IP].configured_mtu = strtoul(argv[3]->arg, NULL, -							   10); +		nifp->afi[AFI_IP].configured_mtu = +			strtoul(argv[3]->arg, NULL, 10);  	}  	nhrp_interface_update_mtu(ifp, AFI_IP); @@ -486,8 +489,8 @@ DEFUN(if_nhrp_map, if_nhrp_map_cmd,  	union sockunion proto_addr, nbma_addr;  	struct nhrp_cache *c; -	if (str2sockunion(argv[3]->arg, &proto_addr) < 0 || -	    afi2family(afi) != sockunion_family(&proto_addr)) +	if (str2sockunion(argv[3]->arg, &proto_addr) < 0 +	    || afi2family(afi) != sockunion_family(&proto_addr))  		return nhrp_vty_return(vty, NHRP_ERR_PROTOCOL_ADDRESS_MISMATCH);  	c = nhrp_cache_get(ifp, &proto_addr, 1); @@ -496,12 +499,14 @@ DEFUN(if_nhrp_map, if_nhrp_map_cmd,  	c->map = 1;  	if (strmatch(argv[4]->text, "local")) { -		nhrp_cache_update_binding(c, NHRP_CACHE_LOCAL, 0, NULL, 0, NULL); -	} else{ +		nhrp_cache_update_binding(c, NHRP_CACHE_LOCAL, 0, NULL, 0, +					  NULL); +	} else {  		if (str2sockunion(argv[4]->arg, &nbma_addr) < 0)  			return nhrp_vty_return(vty, NHRP_ERR_FAIL);  		nhrp_cache_update_binding(c, NHRP_CACHE_STATIC, 0, -			nhrp_peer_get(ifp, &nbma_addr), 0, NULL); +					  nhrp_peer_get(ifp, &nbma_addr), 0, +					  NULL);  	}  	return CMD_SUCCESS; @@ -516,13 +521,13 @@ DEFUN(if_no_nhrp_map, if_no_nhrp_map_cmd,  	"IPv4 protocol address\n"  	"IPv6 protocol address\n")  { -	VTY_DECLVAR_CONTEXT(interface,ifp); +	VTY_DECLVAR_CONTEXT(interface, ifp);  	afi_t afi = cmd_to_afi(argv[1]);  	union sockunion proto_addr;  	struct nhrp_cache *c; -	if (str2sockunion(argv[4]->arg, &proto_addr) < 0 || -	    afi2family(afi) != sockunion_family(&proto_addr)) +	if (str2sockunion(argv[4]->arg, &proto_addr) < 0 +	    || afi2family(afi) != sockunion_family(&proto_addr))  		return nhrp_vty_return(vty, NHRP_ERR_PROTOCOL_ADDRESS_MISMATCH);  	c = nhrp_cache_get(ifp, &proto_addr, 0); @@ -598,50 +603,41 @@ static void show_ip_nhrp_cache(struct nhrp_cache *c, void *pctx)  		return;  	if (!ctx->count) { -		vty_out (vty, "%-8s %-8s %-24s %-24s %-6s %s\n", -			"Iface", -			"Type", -			"Protocol", -			"NBMA", -			"Flags", -			"Identity"); +		vty_out(vty, "%-8s %-8s %-24s %-24s %-6s %s\n", "Iface", "Type", +			"Protocol", "NBMA", "Flags", "Identity");  	}  	ctx->count++; -	vty_out(ctx->vty, "%-8s %-8s %-24s %-24s %c%c%c    %s\n", -		c->ifp->name, +	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]), -		c->cur.peer ? sockunion2str(&c->cur.peer->vc->remote.nbma, buf[1], sizeof buf[1]) : "-", -		c->used ? 'U' : ' ', -		c->t_timeout ? 'T' : ' ', +		c->cur.peer ? sockunion2str(&c->cur.peer->vc->remote.nbma, +					    buf[1], sizeof buf[1]) +			    : "-", +		c->used ? 'U' : ' ', c->t_timeout ? 'T' : ' ',  		c->t_auth ? 'A' : ' ',  		c->cur.peer ? c->cur.peer->vc->remote.id : "-");  } -static void show_ip_nhrp_nhs(struct nhrp_nhs *n, struct nhrp_registration *reg, void *pctx) +static void show_ip_nhrp_nhs(struct nhrp_nhs *n, struct nhrp_registration *reg, +			     void *pctx)  {  	struct info_ctx *ctx = pctx;  	struct vty *vty = ctx->vty;  	char buf[2][SU_ADDRSTRLEN];  	if (!ctx->count) { -		vty_out (vty, "%-8s %-24s %-16s %-16s\n", -			"Iface", -			"FQDN", -			"NBMA", -			"Protocol"); +		vty_out(vty, "%-8s %-24s %-16s %-16s\n", "Iface", "FQDN", +			"NBMA", "Protocol");  	}  	ctx->count++; -	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]) -		   		      : "-", -		   sockunion2str(reg ? ®->proto_addr : &n->proto_addr, -		     		 buf[1], sizeof buf[1])); +	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]) +				   : "-", +		sockunion2str(reg ? ®->proto_addr : &n->proto_addr, buf[1], +			      sizeof buf[1]));  }  static void show_ip_nhrp_shortcut(struct nhrp_shortcut *s, void *pctx) @@ -652,17 +648,13 @@ static void show_ip_nhrp_shortcut(struct nhrp_shortcut *s, void *pctx)  	char buf1[PREFIX_STRLEN], buf2[SU_ADDRSTRLEN];  	if (!ctx->count) { -		vty_out (vty, "%-8s %-24s %-24s %s\n", -			"Type", -			"Prefix", -			"Via", +		vty_out(vty, "%-8s %-24s %-24s %s\n", "Type", "Prefix", "Via",  			"Identity");  	}  	ctx->count++;  	c = s->cache; -	vty_out(ctx->vty, "%-8s %-24s %-24s %s\n", -		nhrp_cache_type_str[s->type], +	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) : "",  		(c && c->cur.peer) ? c->cur.peer->vc->remote.id : ""); @@ -677,26 +669,25 @@ static void show_ip_opennhrp_cache(struct nhrp_cache *c, void *pctx)  		return;  	vty_out(ctx->vty, -		  "Type: %s\n" -		  "Flags:%s%s\n" -		  "Protocol-Address: %s/%zu\n", -		  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), -		  8 * family2addrsize(sockunion_family(&c->remote_addr))); +		"Type: %s\n" +		"Flags:%s%s\n" +		"Protocol-Address: %s/%zu\n", +		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), +		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)); +		vty_out(ctx->vty, "NBMA-Address: %s\n", +			sockunion2str(&c->cur.peer->vc->remote.nbma, 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)); +		vty_out(ctx->vty, "NBMA-NAT-OA-Address: %s\n", +			sockunion2str(&c->cur.remote_nbma_natoa, buf, +				      sizeof buf));  	}  	vty_out(ctx->vty, "\n\n"); @@ -715,8 +706,7 @@ DEFUN(show_ip_nhrp, show_ip_nhrp_cmd,  	struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);  	struct interface *ifp;  	struct info_ctx ctx = { -		.vty = vty, -		.afi = cmd_to_afi(argv[1]), +		.vty = vty, .afi = cmd_to_afi(argv[1]),  	};  	if (argc <= 3 || argv[3]->text[0] == 'c') { @@ -728,14 +718,14 @@ DEFUN(show_ip_nhrp, show_ip_nhrp_cmd,  	} else if (argv[3]->text[0] == 's') {  		nhrp_shortcut_foreach(ctx.afi, show_ip_nhrp_shortcut, &ctx);  	} else { -		vty_out (vty, "Status: ok\n\n"); +		vty_out(vty, "Status: ok\n\n");  		ctx.count++;  		FOR_ALL_INTERFACES (vrf, ifp)  			nhrp_cache_foreach(ifp, show_ip_opennhrp_cache, &ctx);  	}  	if (!ctx.count) { -		vty_out (vty, "%% No entries\n"); +		vty_out(vty, "%% No entries\n");  		return CMD_WARNING;  	} @@ -747,11 +737,10 @@ static void show_dmvpn_entry(struct nhrp_vc *vc, void *ctx)  	struct vty *vty = ctx;  	char buf[2][SU_ADDRSTRLEN]; -	vty_out (vty, "%-24s %-24s %c      %-4d %-24s\n", +	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]), -		notifier_active(&vc->notifier_list) ? 'n' : ' ', -		vc->ipsec, +		notifier_active(&vc->notifier_list) ? 'n' : ' ', vc->ipsec,  		vc->remote.id);  } @@ -760,12 +749,8 @@ DEFUN(show_dmvpn, show_dmvpn_cmd,  	SHOW_STR  	"DMVPN information\n")  { -	vty_out (vty, "%-24s %-24s %-6s %-4s %-24s\n", -		"Src", -		"Dst", -		"Flags", -		"SAs", -		"Identity"); +	vty_out(vty, "%-24s %-24s %-6s %-4s %-24s\n", "Src", "Dst", "Flags", +		"SAs", "Identity");  	nhrp_vc_foreach(show_dmvpn_entry, vty); @@ -799,9 +784,7 @@ DEFUN(clear_nhrp, clear_nhrp_cmd,  	struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);  	struct interface *ifp;  	struct info_ctx ctx = { -		.vty = vty, -		.afi = cmd_to_afi(argv[1]), -		.count = 0, +		.vty = vty, .afi = cmd_to_afi(argv[1]), .count = 0,  	};  	if (argc <= 3 || argv[3]->text[0] == 'c') { @@ -812,11 +795,11 @@ DEFUN(clear_nhrp, clear_nhrp_cmd,  	}  	if (!ctx.count) { -		vty_out (vty, "%% No entries\n"); +		vty_out(vty, "%% No entries\n");  		return CMD_WARNING;  	} -	vty_out (vty, "%% %d entries cleared\n", ctx.count); +	vty_out(vty, "%% %d entries cleared\n", ctx.count);  	return CMD_SUCCESS;  } @@ -832,13 +815,17 @@ static void interface_config_write_nhrp_map(struct nhrp_cache *c, void *data)  	struct vty *vty = ctx->vty;  	char buf[2][SU_ADDRSTRLEN]; -	if (!c->map) return; -	if (sockunion_family(&c->remote_addr) != ctx->family) return; +	if (!c->map) +		return; +	if (sockunion_family(&c->remote_addr) != ctx->family) +		return; -	vty_out (vty, " %s nhrp map %s %s\n", -		ctx->aficmd, +	vty_out(vty, " %s nhrp map %s %s\n", ctx->aficmd,  		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])); +		c->cur.type == NHRP_CACHE_LOCAL +			? "local" +			: sockunion2str(&c->cur.peer->vc->remote.nbma, buf[1], +					sizeof buf[1]));  }  static int interface_config_write(struct vty *vty) @@ -856,7 +843,7 @@ static int interface_config_write(struct vty *vty)  	FOR_ALL_INTERFACES (vrf, ifp) {  		vty_frame(vty, "interface %s\n", ifp->name);  		if (ifp->desc) -			vty_out (vty, " description %s\n", ifp->desc); +			vty_out(vty, " description %s\n", ifp->desc);  		nifp = ifp->info;  		if (nifp->ipsec_profile) { @@ -865,11 +852,10 @@ static int interface_config_write(struct vty *vty)  			if (nifp->ipsec_fallback_profile)  				vty_out(vty, " fallback-profile %s",  					nifp->ipsec_fallback_profile); -			vty_out (vty, "\n"); +			vty_out(vty, "\n");  		}  		if (nifp->source) -			vty_out (vty, " tunnel source %s\n", -				nifp->source); +			vty_out(vty, " tunnel source %s\n", nifp->source);  		for (afi = 0; afi < AFI_MAX; afi++) {  			struct nhrp_afi_data *ad = &nifp->afi[afi]; @@ -877,38 +863,45 @@ static int interface_config_write(struct vty *vty)  			aficmd = afi_to_cmd(afi);  			if (ad->network_id) -				vty_out (vty, " %s nhrp network-id %u\n", -					aficmd,ad->network_id); +				vty_out(vty, " %s nhrp network-id %u\n", aficmd, +					ad->network_id);  			if (ad->holdtime != NHRPD_DEFAULT_HOLDTIME) -				vty_out (vty, " %s nhrp holdtime %u\n", -					aficmd,ad->holdtime); +				vty_out(vty, " %s nhrp holdtime %u\n", aficmd, +					ad->holdtime);  			if (ad->configured_mtu < 0) -				vty_out (vty, " %s nhrp mtu opennhrp\n", -					aficmd); +				vty_out(vty, " %s nhrp mtu opennhrp\n", aficmd);  			else if (ad->configured_mtu) -				vty_out (vty, " %s nhrp mtu %u\n", -					aficmd,ad->configured_mtu); +				vty_out(vty, " %s nhrp mtu %u\n", aficmd, +					ad->configured_mtu);  			for (i = 0; interface_flags_desc[i].str != NULL; i++) {  				if (!(ad->flags & interface_flags_desc[i].key))  					continue; -				vty_out (vty, " %s nhrp %s\n", -					aficmd, interface_flags_desc[i].str); +				vty_out(vty, " %s nhrp %s\n", aficmd, +					interface_flags_desc[i].str);  			} -			mapctx = (struct write_map_ctx) { +			mapctx = (struct write_map_ctx){  				.vty = vty,  				.family = afi2family(afi),  				.aficmd = aficmd,  			}; -			nhrp_cache_foreach(ifp, interface_config_write_nhrp_map, &mapctx); +			nhrp_cache_foreach(ifp, interface_config_write_nhrp_map, +					   &mapctx); -			list_for_each_entry(nhs, &ad->nhslist_head, nhslist_entry) { -				vty_out (vty, " %s nhrp nhs %s nbma %s\n", +			list_for_each_entry(nhs, &ad->nhslist_head, +					    nhslist_entry) +			{ +				vty_out(vty, " %s nhrp nhs %s nbma %s\n",  					aficmd, -					sockunion_family(&nhs->proto_addr) == AF_UNSPEC ? "dynamic" : sockunion2str(&nhs->proto_addr, buf, sizeof buf), +					sockunion_family(&nhs->proto_addr) +							== AF_UNSPEC +						? "dynamic" +						: sockunion2str( +							  &nhs->proto_addr, buf, +							  sizeof buf),  					nhs->nbma_fqdn);  			}  		} @@ -925,7 +918,7 @@ void nhrp_config_init(void)  	install_default(ZEBRA_NODE);  	/* access-list commands */ -	access_list_init (); +	access_list_init();  	/* global commands */  	install_element(VIEW_NODE, &show_debugging_nhrp_cmd); diff --git a/nhrpd/nhrpd.h b/nhrpd/nhrpd.h index 2ab40a4d39..8f1c63457a 100644 --- a/nhrpd/nhrpd.h +++ b/nhrpd/nhrpd.h @@ -26,17 +26,15 @@ DECLARE_MGROUP(NHRPD)  extern struct thread_master *master; -enum { -	NHRP_OK = 0, -	NHRP_ERR_FAIL, -	NHRP_ERR_NO_MEMORY, -	NHRP_ERR_UNSUPPORTED_INTERFACE, -	NHRP_ERR_NHRP_NOT_ENABLED, -	NHRP_ERR_ENTRY_EXISTS, -	NHRP_ERR_ENTRY_NOT_FOUND, -	NHRP_ERR_PROTOCOL_ADDRESS_MISMATCH, -	__NHRP_ERR_MAX -}; +enum { NHRP_OK = 0, +       NHRP_ERR_FAIL, +       NHRP_ERR_NO_MEMORY, +       NHRP_ERR_UNSUPPORTED_INTERFACE, +       NHRP_ERR_NHRP_NOT_ENABLED, +       NHRP_ERR_ENTRY_EXISTS, +       NHRP_ERR_ENTRY_NOT_FOUND, +       NHRP_ERR_PROTOCOL_ADDRESS_MISMATCH, +       __NHRP_ERR_MAX };  #define NHRP_ERR_MAX		(__NHRP_ERR_MAX - 1)  struct notifier_block; @@ -52,15 +50,18 @@ struct notifier_list {  	struct list_head notifier_head;  }; -#define NOTIFIER_LIST_INITIALIZER(l) \ -	{ .notifier_head = LIST_INITIALIZER((l)->notifier_head) } +#define NOTIFIER_LIST_INITIALIZER(l)                                           \ +	{                                                                      \ +		.notifier_head = LIST_INITIALIZER((l)->notifier_head)          \ +	}  static inline void notifier_init(struct notifier_list *l)  {  	list_init(&l->notifier_head);  } -static inline void notifier_add(struct notifier_block *n, struct notifier_list *l, notifier_fn_t action) +static inline void notifier_add(struct notifier_block *n, +				struct notifier_list *l, notifier_fn_t action)  {  	n->action = action;  	list_add_tail(&n->notifier_entry, &l->notifier_head); @@ -88,7 +89,9 @@ struct resolver_query {  };  void resolver_init(void); -void resolver_resolve(struct resolver_query *query, int af, const char *hostname, void (*cb)(struct resolver_query *, int, union sockunion *)); +void resolver_resolve(struct resolver_query *query, int af, +		      const char *hostname, void (*cb)(struct resolver_query *, +						       int, union sockunion *));  void nhrp_zebra_init(void);  void nhrp_zebra_terminate(void); @@ -198,7 +201,7 @@ enum nhrp_cache_type {  	NHRP_CACHE_NUM_TYPES  }; -extern const char * const nhrp_cache_type_str[]; +extern const char *const nhrp_cache_type_str[];  extern unsigned long nhrp_cache_counts[NHRP_CACHE_NUM_TYPES];  struct nhrp_cache { @@ -249,7 +252,7 @@ struct nhrp_nhs {  	unsigned hub : 1;  	afi_t afi;  	union sockunion proto_addr; -	const char *nbma_fqdn;			/* IP-address or FQDN */ +	const char *nbma_fqdn; /* IP-address or FQDN */  	struct thread *t_resolve;  	struct resolver_query dns_resolve; @@ -311,107 +314,141 @@ void nhrp_interface_init(void);  void nhrp_interface_update(struct interface *ifp);  void nhrp_interface_update_mtu(struct interface *ifp, afi_t afi); -int nhrp_interface_add(int cmd, struct zclient *client, zebra_size_t length, vrf_id_t vrf_id); -int nhrp_interface_delete(int cmd, struct zclient *client, zebra_size_t length, vrf_id_t vrf_id); -int nhrp_interface_up(int cmd, struct zclient *client, zebra_size_t length, vrf_id_t vrf_id); -int nhrp_interface_down(int cmd, struct zclient *client, zebra_size_t length, vrf_id_t vrf_id); -int nhrp_interface_address_add(int cmd, struct zclient *client, zebra_size_t length, vrf_id_t vrf_id); -int nhrp_interface_address_delete(int cmd, struct zclient *client, zebra_size_t length, vrf_id_t vrf_id); - -void nhrp_interface_notify_add(struct interface *ifp, struct notifier_block *n, notifier_fn_t fn); +int nhrp_interface_add(int cmd, struct zclient *client, zebra_size_t length, +		       vrf_id_t vrf_id); +int nhrp_interface_delete(int cmd, struct zclient *client, zebra_size_t length, +			  vrf_id_t vrf_id); +int nhrp_interface_up(int cmd, struct zclient *client, zebra_size_t length, +		      vrf_id_t vrf_id); +int nhrp_interface_down(int cmd, struct zclient *client, zebra_size_t length, +			vrf_id_t vrf_id); +int nhrp_interface_address_add(int cmd, struct zclient *client, +			       zebra_size_t length, vrf_id_t vrf_id); +int nhrp_interface_address_delete(int cmd, struct zclient *client, +				  zebra_size_t length, vrf_id_t vrf_id); + +void nhrp_interface_notify_add(struct interface *ifp, struct notifier_block *n, +			       notifier_fn_t fn);  void nhrp_interface_notify_del(struct interface *ifp, struct notifier_block *n); -void nhrp_interface_set_protection(struct interface *ifp, const char *profile, const char *fallback_profile); +void nhrp_interface_set_protection(struct interface *ifp, const char *profile, +				   const char *fallback_profile);  void nhrp_interface_set_source(struct interface *ifp, const char *ifname); -int nhrp_nhs_add(struct interface *ifp, afi_t afi, union sockunion *proto_addr, const char *nbma_fqdn); -int nhrp_nhs_del(struct interface *ifp, afi_t afi, union sockunion *proto_addr, const char *nbma_fqdn); +int nhrp_nhs_add(struct interface *ifp, afi_t afi, union sockunion *proto_addr, +		 const char *nbma_fqdn); +int nhrp_nhs_del(struct interface *ifp, afi_t afi, union sockunion *proto_addr, +		 const char *nbma_fqdn);  int nhrp_nhs_free(struct nhrp_nhs *nhs);  void nhrp_nhs_terminate(void); -void nhrp_nhs_foreach(struct interface *ifp, afi_t afi, void (*cb)(struct nhrp_nhs *, struct nhrp_registration *, void *), void *ctx); +void nhrp_nhs_foreach(struct interface *ifp, afi_t afi, +		      void (*cb)(struct nhrp_nhs *, struct nhrp_registration *, +				 void *), +		      void *ctx);  void nhrp_route_update_nhrp(const struct prefix *p, struct interface *ifp); -void nhrp_route_announce(int add, enum nhrp_cache_type type, const struct prefix *p, struct interface *ifp, const union sockunion *nexthop, uint32_t mtu); -int nhrp_route_read(int command, struct zclient *zclient, zebra_size_t length, vrf_id_t vrf_id); -int nhrp_route_get_nexthop(const union sockunion *addr, struct prefix *p, union sockunion *via, struct interface **ifp); -enum nhrp_route_type nhrp_route_address(struct interface *in_ifp, union sockunion *addr, struct prefix *p, struct nhrp_peer **peer); +void nhrp_route_announce(int add, enum nhrp_cache_type type, +			 const struct prefix *p, struct interface *ifp, +			 const union sockunion *nexthop, uint32_t mtu); +int nhrp_route_read(int command, struct zclient *zclient, zebra_size_t length, +		    vrf_id_t vrf_id); +int nhrp_route_get_nexthop(const union sockunion *addr, struct prefix *p, +			   union sockunion *via, struct interface **ifp); +enum nhrp_route_type nhrp_route_address(struct interface *in_ifp, +					union sockunion *addr, struct prefix *p, +					struct nhrp_peer **peer);  void nhrp_config_init(void);  void nhrp_shortcut_init(void);  void nhrp_shortcut_terminate(void);  void nhrp_shortcut_initiate(union sockunion *addr); -void nhrp_shortcut_foreach(afi_t afi, void (*cb)(struct nhrp_shortcut *, void *), void *ctx); +void nhrp_shortcut_foreach(afi_t afi, +			   void (*cb)(struct nhrp_shortcut *, void *), +			   void *ctx);  void nhrp_shortcut_purge(struct nhrp_shortcut *s, int force);  void nhrp_shortcut_prefix_change(const struct prefix *p, int deleted); -struct nhrp_cache *nhrp_cache_get(struct interface *ifp, union sockunion *remote_addr, int create); -void nhrp_cache_foreach(struct interface *ifp, void (*cb)(struct nhrp_cache *, void *), void *ctx); +struct nhrp_cache *nhrp_cache_get(struct interface *ifp, +				  union sockunion *remote_addr, int create); +void nhrp_cache_foreach(struct interface *ifp, +			void (*cb)(struct nhrp_cache *, void *), void *ctx);  void nhrp_cache_set_used(struct nhrp_cache *, int); -int nhrp_cache_update_binding(struct nhrp_cache *, enum nhrp_cache_type type, int holding_time, struct nhrp_peer *p, uint32_t mtu, union sockunion *nbma_natoa); -void nhrp_cache_notify_add(struct nhrp_cache *c, struct notifier_block *, notifier_fn_t); +int nhrp_cache_update_binding(struct nhrp_cache *, enum nhrp_cache_type type, +			      int holding_time, struct nhrp_peer *p, +			      uint32_t mtu, union sockunion *nbma_natoa); +void nhrp_cache_notify_add(struct nhrp_cache *c, struct notifier_block *, +			   notifier_fn_t);  void nhrp_cache_notify_del(struct nhrp_cache *c, struct notifier_block *);  void nhrp_vc_init(void);  void nhrp_vc_terminate(void); -struct nhrp_vc *nhrp_vc_get(const union sockunion *src, const union sockunion *dst, int create); +struct nhrp_vc *nhrp_vc_get(const union sockunion *src, +			    const union sockunion *dst, int create);  int nhrp_vc_ipsec_updown(uint32_t child_id, struct nhrp_vc *vc); -void nhrp_vc_notify_add(struct nhrp_vc *, struct notifier_block *, notifier_fn_t); +void nhrp_vc_notify_add(struct nhrp_vc *, struct notifier_block *, +			notifier_fn_t);  void nhrp_vc_notify_del(struct nhrp_vc *, struct notifier_block *);  void nhrp_vc_foreach(void (*cb)(struct nhrp_vc *, void *), void *ctx);  void nhrp_vc_reset(void);  void vici_init(void);  void vici_terminate(void); -void vici_request_vc(const char *profile, union sockunion *src, union sockunion *dst, int prio); +void vici_request_vc(const char *profile, union sockunion *src, +		     union sockunion *dst, int prio);  extern const char *nhrp_event_socket_path;  void evmgr_init(void);  void evmgr_terminate(void);  void evmgr_set_socket(const char *socket); -void evmgr_notify(const char *name, struct nhrp_cache *c, void (*cb)(struct nhrp_reqid *, void *)); +void evmgr_notify(const char *name, struct nhrp_cache *c, +		  void (*cb)(struct nhrp_reqid *, void *)); -struct nhrp_packet_header *nhrp_packet_push( -	struct zbuf *zb, uint8_t type, -	const union sockunion *src_nbma, -	const union sockunion *src_proto, -	const union sockunion *dst_proto); +struct nhrp_packet_header *nhrp_packet_push(struct zbuf *zb, uint8_t type, +					    const union sockunion *src_nbma, +					    const union sockunion *src_proto, +					    const union sockunion *dst_proto);  void nhrp_packet_complete(struct zbuf *zb, struct nhrp_packet_header *hdr);  uint16_t nhrp_packet_calculate_checksum(const uint8_t *pdu, uint16_t len); -struct nhrp_packet_header *nhrp_packet_pull( -	struct zbuf *zb, -	union sockunion *src_nbma, -	union sockunion *src_proto, -	union sockunion *dst_proto); - -struct nhrp_cie_header *nhrp_cie_push( -	struct zbuf *zb, uint8_t code, -	const union sockunion *nbma, -	const union sockunion *proto); -struct nhrp_cie_header *nhrp_cie_pull( -	struct zbuf *zb, -	struct nhrp_packet_header *hdr, -	union sockunion *nbma, -	union sockunion *proto); - -struct nhrp_extension_header *nhrp_ext_push(struct zbuf *zb, struct nhrp_packet_header *hdr, uint16_t type); +struct nhrp_packet_header *nhrp_packet_pull(struct zbuf *zb, +					    union sockunion *src_nbma, +					    union sockunion *src_proto, +					    union sockunion *dst_proto); + +struct nhrp_cie_header *nhrp_cie_push(struct zbuf *zb, uint8_t code, +				      const union sockunion *nbma, +				      const union sockunion *proto); +struct nhrp_cie_header *nhrp_cie_pull(struct zbuf *zb, +				      struct nhrp_packet_header *hdr, +				      union sockunion *nbma, +				      union sockunion *proto); + +struct nhrp_extension_header * +nhrp_ext_push(struct zbuf *zb, struct nhrp_packet_header *hdr, uint16_t type);  void nhrp_ext_complete(struct zbuf *zb, struct nhrp_extension_header *ext); -struct nhrp_extension_header *nhrp_ext_pull(struct zbuf *zb, struct zbuf *payload); -void nhrp_ext_request(struct zbuf *zb, struct nhrp_packet_header *hdr, struct interface *); -int nhrp_ext_reply(struct zbuf *zb, struct nhrp_packet_header *hdr, struct interface *ifp, struct nhrp_extension_header *ext, struct zbuf *extpayload); - -uint32_t nhrp_reqid_alloc(struct nhrp_reqid_pool *, struct nhrp_reqid *r, void (*cb)(struct nhrp_reqid *, void *)); +struct nhrp_extension_header *nhrp_ext_pull(struct zbuf *zb, +					    struct zbuf *payload); +void nhrp_ext_request(struct zbuf *zb, struct nhrp_packet_header *hdr, +		      struct interface *); +int nhrp_ext_reply(struct zbuf *zb, struct nhrp_packet_header *hdr, +		   struct interface *ifp, struct nhrp_extension_header *ext, +		   struct zbuf *extpayload); + +uint32_t nhrp_reqid_alloc(struct nhrp_reqid_pool *, struct nhrp_reqid *r, +			  void (*cb)(struct nhrp_reqid *, void *));  void nhrp_reqid_free(struct nhrp_reqid_pool *, struct nhrp_reqid *r);  struct nhrp_reqid *nhrp_reqid_lookup(struct nhrp_reqid_pool *, uint32_t reqid);  int nhrp_packet_init(void); -struct nhrp_peer *nhrp_peer_get(struct interface *ifp, const union sockunion *remote_nbma); +struct nhrp_peer *nhrp_peer_get(struct interface *ifp, +				const union sockunion *remote_nbma);  struct nhrp_peer *nhrp_peer_ref(struct nhrp_peer *p);  void nhrp_peer_unref(struct nhrp_peer *p);  int nhrp_peer_check(struct nhrp_peer *p, int establish); -void nhrp_peer_notify_add(struct nhrp_peer *p, struct notifier_block *, notifier_fn_t); +void nhrp_peer_notify_add(struct nhrp_peer *p, struct notifier_block *, +			  notifier_fn_t);  void nhrp_peer_notify_del(struct nhrp_peer *p, struct notifier_block *);  void nhrp_peer_recv(struct nhrp_peer *p, struct zbuf *zb);  void nhrp_peer_send(struct nhrp_peer *p, struct zbuf *zb); diff --git a/nhrpd/os.h b/nhrpd/os.h index 0fbe8b003f..dd65d3cbe1 100644 --- a/nhrpd/os.h +++ b/nhrpd/os.h @@ -1,5 +1,7 @@  int os_socket(void); -int os_sendmsg(const uint8_t *buf, size_t len, int ifindex, const uint8_t *addr, size_t addrlen); -int os_recvmsg(uint8_t *buf, size_t *len, int *ifindex, uint8_t *addr, size_t *addrlen); +int os_sendmsg(const uint8_t *buf, size_t len, int ifindex, const uint8_t *addr, +	       size_t addrlen); +int os_recvmsg(uint8_t *buf, size_t *len, int *ifindex, uint8_t *addr, +	       size_t *addrlen);  int os_configure_dmvpn(unsigned int ifindex, const char *ifname, int af); diff --git a/nhrpd/reqid.c b/nhrpd/reqid.c index e5bd45a8f4..e8ad518e58 100644 --- a/nhrpd/reqid.c +++ b/nhrpd/reqid.c @@ -14,18 +14,19 @@ static int nhrp_reqid_cmp(const void *data, const void *key)  	return a->request_id == b->request_id;  } -uint32_t nhrp_reqid_alloc(struct nhrp_reqid_pool *p, struct nhrp_reqid *r, void (*cb)(struct nhrp_reqid *, void *)) +uint32_t nhrp_reqid_alloc(struct nhrp_reqid_pool *p, struct nhrp_reqid *r, +			  void (*cb)(struct nhrp_reqid *, void *))  {  	if (!p->reqid_hash) { -		p->reqid_hash = hash_create(nhrp_reqid_key, -					    nhrp_reqid_cmp, +		p->reqid_hash = hash_create(nhrp_reqid_key, nhrp_reqid_cmp,  					    "NHRP reqid Hash");  		p->next_request_id = 1;  	}  	if (r->cb != cb) {  		r->request_id = p->next_request_id; -		if (++p->next_request_id == 0) p->next_request_id = 1; +		if (++p->next_request_id == 0) +			p->next_request_id = 1;  		r->cb = cb;  		hash_get(p->reqid_hash, r, hash_alloc_intern);  	} @@ -43,9 +44,8 @@ void nhrp_reqid_free(struct nhrp_reqid_pool *p, struct nhrp_reqid *r)  struct nhrp_reqid *nhrp_reqid_lookup(struct nhrp_reqid_pool *p, uint32_t reqid)  {  	struct nhrp_reqid key; -	if (!p->reqid_hash) return 0; +	if (!p->reqid_hash) +		return 0;  	key.request_id = reqid;  	return hash_lookup(p->reqid_hash, &key);  } - - diff --git a/nhrpd/resolver.c b/nhrpd/resolver.c index c29be3cbf9..6349224adc 100644 --- a/nhrpd/resolver.c +++ b/nhrpd/resolver.c @@ -47,8 +47,7 @@ static int resolver_cb_socket_readable(struct thread *t)  	ares_process_fd(r->channel, fd, ARES_SOCKET_BAD);  	if (vector_lookup(r->read_threads, fd) == THREAD_RUNNING) {  		t = NULL; -		thread_add_read(master, resolver_cb_socket_readable, r, fd, -				&t); +		thread_add_read(master, resolver_cb_socket_readable, r, fd, &t);  		vector_set_index(r->read_threads, fd, t);  	}  	resolver_update_timeouts(r); @@ -78,27 +77,29 @@ static void resolver_update_timeouts(struct resolver_state *r)  {  	struct timeval *tv, tvbuf; -	if (r->timeout == THREAD_RUNNING) return; +	if (r->timeout == THREAD_RUNNING) +		return;  	THREAD_OFF(r->timeout);  	tv = ares_timeout(r->channel, NULL, &tvbuf);  	if (tv) {  		unsigned int timeoutms = tv->tv_sec * 1000 + tv->tv_usec / 1000; -		thread_add_timer_msec(master, resolver_cb_timeout, r, -				      timeoutms, &r->timeout); +		thread_add_timer_msec(master, resolver_cb_timeout, r, timeoutms, +				      &r->timeout);  	}  } -static void ares_socket_cb(void *data, ares_socket_t fd, int readable, int writable) +static void ares_socket_cb(void *data, ares_socket_t fd, int readable, +			   int writable)  { -	struct resolver_state *r = (struct resolver_state *) data; +	struct resolver_state *r = (struct resolver_state *)data;  	struct thread *t;  	if (readable) {  		t = vector_lookup_ensure(r->read_threads, fd);  		if (!t) { -			thread_add_read(master, resolver_cb_socket_readable, -					r, fd, &t); +			thread_add_read(master, resolver_cb_socket_readable, r, +					fd, &t);  			vector_set_index(r->read_threads, fd, t);  		}  	} else { @@ -114,8 +115,8 @@ static void ares_socket_cb(void *data, ares_socket_t fd, int readable, int writa  	if (writable) {  		t = vector_lookup_ensure(r->write_threads, fd);  		if (!t) { -			thread_add_read(master, resolver_cb_socket_writable, -					r, fd, &t); +			thread_add_read(master, resolver_cb_socket_writable, r, +					fd, &t);  			vector_set_index(r->write_threads, fd, t);  		}  	} else { @@ -136,7 +137,7 @@ void resolver_init(void)  	state.read_threads = vector_init(1);  	state.write_threads = vector_init(1); -	ares_opts = (struct ares_options) { +	ares_opts = (struct ares_options){  		.sock_state_cb = &ares_socket_cb,  		.sock_state_cb_data = &state,  		.timeout = 2, @@ -144,14 +145,15 @@ void resolver_init(void)  	};  	ares_init_options(&state.channel, &ares_opts, -		ARES_OPT_SOCK_STATE_CB | ARES_OPT_TIMEOUT | -		ARES_OPT_TRIES); +			  ARES_OPT_SOCK_STATE_CB | ARES_OPT_TIMEOUT +				  | ARES_OPT_TRIES);  } -static void ares_address_cb(void *arg, int status, int timeouts, struct hostent *he) +static void ares_address_cb(void *arg, int status, int timeouts, +			    struct hostent *he)  { -	struct resolver_query *query = (struct resolver_query *) arg; +	struct resolver_query *query = (struct resolver_query *)arg;  	union sockunion addr[16];  	size_t i; @@ -167,23 +169,31 @@ static void ares_address_cb(void *arg, int status, int timeouts, struct hostent  		addr[i].sa.sa_family = he->h_addrtype;  		switch (he->h_addrtype) {  		case AF_INET: -			memcpy(&addr[i].sin.sin_addr, (uint8_t *) he->h_addr_list[i], he->h_length); +			memcpy(&addr[i].sin.sin_addr, +			       (uint8_t *)he->h_addr_list[i], he->h_length);  			break;  		case AF_INET6: -			memcpy(&addr[i].sin6.sin6_addr, (uint8_t *) he->h_addr_list[i], he->h_length); +			memcpy(&addr[i].sin6.sin6_addr, +			       (uint8_t *)he->h_addr_list[i], he->h_length);  			break;  		}  	} -	debugf(NHRP_DEBUG_COMMON, "[%p] Resolved with %d results", query, (int) i); +	debugf(NHRP_DEBUG_COMMON, "[%p] Resolved with %d results", query, +	       (int)i);  	query->callback(query, i, &addr[0]);  	query->callback = NULL;  } -void resolver_resolve(struct resolver_query *query, int af, const char *hostname, void (*callback)(struct resolver_query *, int, union sockunion *)) +void resolver_resolve(struct resolver_query *query, int af, +		      const char *hostname, +		      void (*callback)(struct resolver_query *, int, +				       union sockunion *))  {  	if (query->callback != NULL) { -		zlog_err("Trying to resolve '%s', but previous query was not finished yet", hostname); +		zlog_err( +			"Trying to resolve '%s', but previous query was not finished yet", +			hostname);  		return;  	} diff --git a/nhrpd/vici.c b/nhrpd/vici.c index fd01a4534e..e6111f9d71 100644 --- a/nhrpd/vici.c +++ b/nhrpd/vici.c @@ -27,13 +27,15 @@ struct blob {  static int blob_equal(const struct blob *b, const char *str)  { -	if (!b || b->len != (int) strlen(str)) return 0; +	if (!b || b->len != (int)strlen(str)) +		return 0;  	return memcmp(b->ptr, str, b->len) == 0;  }  static int blob2buf(const struct blob *b, char *buf, size_t n)  { -	if (!b || b->len >= (int) n) return 0; +	if (!b || b->len >= (int)n) +		return 0;  	memcpy(buf, b->ptr, b->len);  	buf[b->len] = 0;  	return 1; @@ -76,21 +78,24 @@ static void vici_connection_error(struct vici_conn *vici)  	thread_add_timer(master, vici_reconnect, vici, 2, &vici->t_reconnect);  } -static void vici_parse_message( -	struct vici_conn *vici, struct zbuf *msg, -	void (*parser)(struct vici_message_ctx *ctx, enum vici_type_t msgtype, const struct blob *key, const struct blob *val), -	struct vici_message_ctx *ctx) +static void vici_parse_message(struct vici_conn *vici, struct zbuf *msg, +			       void (*parser)(struct vici_message_ctx *ctx, +					      enum vici_type_t msgtype, +					      const struct blob *key, +					      const struct blob *val), +			       struct vici_message_ctx *ctx)  {  	uint8_t *type; -	struct blob key = { 0 }; -	struct blob val = { 0 }; +	struct blob key = {0}; +	struct blob val = {0};  	while ((type = zbuf_may_pull(msg, uint8_t)) != NULL) {  		switch (*type) {  		case VICI_SECTION_START:  			key.len = zbuf_get8(msg);  			key.ptr = zbuf_pulln(msg, key.len); -			debugf(NHRP_DEBUG_VICI, "VICI: Section start '%.*s'", key.len, key.ptr); +			debugf(NHRP_DEBUG_VICI, "VICI: Section start '%.*s'", +			       key.len, key.ptr);  			parser(ctx, *type, &key, NULL);  			ctx->nsections++;  			break; @@ -104,25 +109,30 @@ static void vici_parse_message(  			key.ptr = zbuf_pulln(msg, key.len);  			val.len = zbuf_get_be16(msg);  			val.ptr = zbuf_pulln(msg, val.len); -			debugf(NHRP_DEBUG_VICI, "VICI: Key '%.*s'='%.*s'", key.len, key.ptr, val.len, val.ptr); +			debugf(NHRP_DEBUG_VICI, "VICI: Key '%.*s'='%.*s'", +			       key.len, key.ptr, val.len, val.ptr);  			parser(ctx, *type, &key, &val);  			break;  		case VICI_LIST_START:  			key.len = zbuf_get8(msg);  			key.ptr = zbuf_pulln(msg, key.len); -			debugf(NHRP_DEBUG_VICI, "VICI: List start '%.*s'", key.len, key.ptr); +			debugf(NHRP_DEBUG_VICI, "VICI: List start '%.*s'", +			       key.len, key.ptr);  			break;  		case VICI_LIST_ITEM:  			val.len = zbuf_get_be16(msg);  			val.ptr = zbuf_pulln(msg, val.len); -			debugf(NHRP_DEBUG_VICI, "VICI: List item: '%.*s'", val.len, val.ptr); +			debugf(NHRP_DEBUG_VICI, "VICI: List item: '%.*s'", +			       val.len, val.ptr);  			parser(ctx, *type, &key, &val);  			break;  		case VICI_LIST_END:  			debugf(NHRP_DEBUG_VICI, "VICI: List end");  			break;  		default: -			debugf(NHRP_DEBUG_VICI, "VICI: Unsupported message component type %d", *type); +			debugf(NHRP_DEBUG_VICI, +			       "VICI: Unsupported message component type %d", +			       *type);  			return;  		}  	} @@ -140,12 +150,12 @@ struct handle_sa_ctx {  	} local, remote;  }; -static void parse_sa_message( -	struct vici_message_ctx *ctx, -	enum vici_type_t msgtype, -	const struct blob *key, const struct blob *val) +static void parse_sa_message(struct vici_message_ctx *ctx, +			     enum vici_type_t msgtype, const struct blob *key, +			     const struct blob *val)  { -	struct handle_sa_ctx *sactx = container_of(ctx, struct handle_sa_ctx, msgctx); +	struct handle_sa_ctx *sactx = +		container_of(ctx, struct handle_sa_ctx, msgctx);  	struct nhrp_vc *vc;  	char buf[512]; @@ -162,15 +172,28 @@ static void parse_sa_message(  			/* End of child-sa section, update nhrp_vc */  			int up = sactx->child_ok || sactx->event == 1;  			if (up) { -				vc = nhrp_vc_get(&sactx->local.host, &sactx->remote.host, up); +				vc = nhrp_vc_get(&sactx->local.host, +						 &sactx->remote.host, up);  				if (vc) { -					blob2buf(&sactx->local.id, vc->local.id, sizeof(vc->local.id)); -					if (blob2buf(&sactx->local.cert, (char*)vc->local.cert, sizeof(vc->local.cert))) -						vc->local.certlen = sactx->local.cert.len; -					blob2buf(&sactx->remote.id, vc->remote.id, sizeof(vc->remote.id)); -					if (blob2buf(&sactx->remote.cert, (char*)vc->remote.cert, sizeof(vc->remote.cert))) -						vc->remote.certlen = sactx->remote.cert.len; -					sactx->kill_ikesa |= nhrp_vc_ipsec_updown(sactx->child_uniqueid, vc); +					blob2buf(&sactx->local.id, vc->local.id, +						 sizeof(vc->local.id)); +					if (blob2buf(&sactx->local.cert, +						     (char *)vc->local.cert, +						     sizeof(vc->local.cert))) +						vc->local.certlen = +							sactx->local.cert.len; +					blob2buf(&sactx->remote.id, +						 vc->remote.id, +						 sizeof(vc->remote.id)); +					if (blob2buf(&sactx->remote.cert, +						     (char *)vc->remote.cert, +						     sizeof(vc->remote.cert))) +						vc->remote.certlen = +							sactx->remote.cert.len; +					sactx->kill_ikesa |= +						nhrp_vc_ipsec_updown( +							sactx->child_uniqueid, +							vc);  				}  			} else {  				nhrp_vc_ipsec_updown(sactx->child_uniqueid, 0); @@ -183,41 +206,58 @@ static void parse_sa_message(  		switch (key->ptr[0]) {  		case 'l': -			if (blob_equal(key, "local-host") && ctx->nsections == 1) { +			if (blob_equal(key, "local-host") +			    && ctx->nsections == 1) {  				if (blob2buf(val, buf, sizeof(buf))) -					if (str2sockunion(buf, &sactx->local.host) < 0) -						zlog_err("VICI: bad strongSwan local-host: %s", buf); -			} else if (blob_equal(key, "local-id") && ctx->nsections == 1) { +					if (str2sockunion(buf, +							  &sactx->local.host) +					    < 0) +						zlog_err( +							"VICI: bad strongSwan local-host: %s", +							buf); +			} else if (blob_equal(key, "local-id") +				   && ctx->nsections == 1) {  				sactx->local.id = *val; -			} else if (blob_equal(key, "local-cert-data") && ctx->nsections == 1) { +			} else if (blob_equal(key, "local-cert-data") +				   && ctx->nsections == 1) {  				sactx->local.cert = *val;  			}  			break;  		case 'r': -			if (blob_equal(key, "remote-host") && ctx->nsections == 1) { +			if (blob_equal(key, "remote-host") +			    && ctx->nsections == 1) {  				if (blob2buf(val, buf, sizeof(buf))) -					if (str2sockunion(buf, &sactx->remote.host) < 0) -						zlog_err("VICI: bad strongSwan remote-host: %s", buf); -			} else if (blob_equal(key, "remote-id") && ctx->nsections == 1) { +					if (str2sockunion(buf, +							  &sactx->remote.host) +					    < 0) +						zlog_err( +							"VICI: bad strongSwan remote-host: %s", +							buf); +			} else if (blob_equal(key, "remote-id") +				   && ctx->nsections == 1) {  				sactx->remote.id = *val; -			} else if (blob_equal(key, "remote-cert-data") && ctx->nsections == 1) { +			} else if (blob_equal(key, "remote-cert-data") +				   && ctx->nsections == 1) {  				sactx->remote.cert = *val;  			}  			break;  		case 'u': -			if (blob_equal(key, "uniqueid") && blob2buf(val, buf, sizeof(buf))) { +			if (blob_equal(key, "uniqueid") +			    && blob2buf(val, buf, sizeof(buf))) {  				if (ctx->nsections == 3) -					sactx->child_uniqueid = strtoul(buf, NULL, 0); +					sactx->child_uniqueid = +						strtoul(buf, NULL, 0);  				else if (ctx->nsections == 1) -					sactx->ike_uniqueid = strtoul(buf, NULL, 0); +					sactx->ike_uniqueid = +						strtoul(buf, NULL, 0);  			}  			break;  		case 's':  			if (blob_equal(key, "state") && ctx->nsections == 3) {  				sactx->child_ok = -					(sactx->event == 0 && -					 (blob_equal(val, "INSTALLED") || -					  blob_equal(val, "REKEYED"))); +					(sactx->event == 0 +					 && (blob_equal(val, "INSTALLED") +					     || blob_equal(val, "REKEYED")));  			}  			break;  		} @@ -225,16 +265,16 @@ static void parse_sa_message(  	}  } -static void parse_cmd_response( -	struct vici_message_ctx *ctx, -	enum vici_type_t msgtype, -	const struct blob *key, const struct blob *val) +static void parse_cmd_response(struct vici_message_ctx *ctx, +			       enum vici_type_t msgtype, const struct blob *key, +			       const struct blob *val)  {  	char buf[512];  	switch (msgtype) {  	case VICI_KEY_VALUE: -		if (blob_equal(key, "errmsg") && blob2buf(val, buf, sizeof(buf))) +		if (blob_equal(key, "errmsg") +		    && blob2buf(val, buf, sizeof(buf)))  			zlog_err("VICI: strongSwan: %s", buf);  		break;  	default: @@ -252,12 +292,11 @@ static void vici_recv_sa(struct vici_conn *vici, struct zbuf *msg, int event)  	vici_parse_message(vici, msg, parse_sa_message, &ctx.msgctx);  	if (ctx.kill_ikesa && ctx.ike_uniqueid) { -		debugf(NHRP_DEBUG_COMMON, "VICI: Deleting IKE_SA %u", ctx.ike_uniqueid); +		debugf(NHRP_DEBUG_COMMON, "VICI: Deleting IKE_SA %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); +		vici_submit_request(vici, "terminate", VICI_KEY_VALUE, "ike-id", +				    strlen(buf), buf, VICI_END);  	}  } @@ -277,13 +316,14 @@ static void vici_recv_message(struct vici_conn *vici, struct zbuf *msg)  		name.len = zbuf_get8(msg);  		name.ptr = zbuf_pulln(msg, name.len); -		debugf(NHRP_DEBUG_VICI, "VICI: Event '%.*s'", name.len, name.ptr); -		if (blob_equal(&name, "list-sa") || -		    blob_equal(&name, "child-updown") || -		    blob_equal(&name, "child-rekey")) +		debugf(NHRP_DEBUG_VICI, "VICI: Event '%.*s'", name.len, +		       name.ptr); +		if (blob_equal(&name, "list-sa") +		    || blob_equal(&name, "child-updown") +		    || blob_equal(&name, "child-rekey"))  			vici_recv_sa(vici, msg, 0); -		else if (blob_equal(&name, "child-state-installed") || -			 blob_equal(&name, "child-state-rekeyed")) +		else if (blob_equal(&name, "child-state-installed") +			 || blob_equal(&name, "child-state-rekeyed"))  			vici_recv_sa(vici, msg, 1);  		else if (blob_equal(&name, "child-state-destroying"))  			vici_recv_sa(vici, msg, 2); @@ -293,7 +333,8 @@ static void vici_recv_message(struct vici_conn *vici, struct zbuf *msg)  		break;  	case VICI_EVENT_UNKNOWN:  	case VICI_CMD_UNKNOWN: -		zlog_err("VICI: StrongSwan does not support mandatory events (unpatched?)"); +		zlog_err( +			"VICI: StrongSwan does not support mandatory events (unpatched?)");  		break;  	case VICI_EVENT_CONFIRM:  		break; @@ -310,7 +351,7 @@ static int vici_read(struct thread *t)  	struct zbuf pktbuf;  	vici->t_read = NULL; -	if (zbuf_read(ibuf, vici->fd, (size_t) -1) < 0) { +	if (zbuf_read(ibuf, vici->fd, (size_t)-1) < 0) {  		vici_connection_error(vici);  		return 0;  	} @@ -326,7 +367,8 @@ static int vici_read(struct thread *t)  		}  		/* Handle packet */ -		zbuf_init(&pktbuf, hdrlen, htonl(*hdrlen)+4, htonl(*hdrlen)+4); +		zbuf_init(&pktbuf, hdrlen, htonl(*hdrlen) + 4, +			  htonl(*hdrlen) + 4);  		vici_recv_message(vici, &pktbuf);  	} while (1); @@ -371,7 +413,8 @@ static void vici_submit_request(struct vici_conn *vici, const char *name, ...)  	int type;  	obuf = zbuf_alloc(256); -	if (!obuf) return; +	if (!obuf) +		return;  	hdrlen = zbuf_push(obuf, uint32_t);  	zbuf_put8(obuf, VICI_CMD_REQUEST); @@ -404,7 +447,8 @@ static void vici_register_event(struct vici_conn *vici, const char *name)  	namelen = strlen(name);  	obuf = zbuf_alloc(4 + 1 + 1 + namelen); -	if (!obuf) return; +	if (!obuf) +		return;  	hdrlen = zbuf_push(obuf, uint32_t);  	zbuf_put8(obuf, VICI_EVENT_REGISTER); @@ -421,12 +465,14 @@ static int vici_reconnect(struct thread *t)  	int fd;  	vici->t_reconnect = NULL; -	if (vici->fd >= 0) return 0; +	if (vici->fd >= 0) +		return 0;  	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)); +		debugf(NHRP_DEBUG_VICI, +		       "%s: failure connecting VICI socket: %s", +		       __PRETTY_FUNCTION__, strerror(errno));  		thread_add_timer(master, vici_reconnect, vici, 2,  				 &vici->t_reconnect);  		return 0; @@ -437,8 +483,8 @@ static int vici_reconnect(struct thread *t)  	thread_add_read(master, vici_read, vici, vici->fd, &vici->t_read);  	/* Send event subscribtions */ -	//vici_register_event(vici, "child-updown"); -	//vici_register_event(vici, "child-rekey"); +	// vici_register_event(vici, "child-updown"); +	// vici_register_event(vici, "child-rekey");  	vici_register_event(vici, "child-state-installed");  	vici_register_event(vici, "child-state-rekeyed");  	vici_register_event(vici, "child-state-destroying"); @@ -465,7 +511,8 @@ void vici_terminate(void)  {  } -void vici_request_vc(const char *profile, union sockunion *src, union sockunion *dst, int prio) +void vici_request_vc(const char *profile, union sockunion *src, +		     union sockunion *dst, int prio)  {  	struct vici_conn *vici = &vici_connection;  	char buf[2][SU_ADDRSTRLEN]; @@ -473,15 +520,13 @@ void vici_request_vc(const char *profile, union sockunion *src, union sockunion  	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", (size_t) 2, "-1", -		VICI_KEY_VALUE, "async", (size_t) 1, "1", -		VICI_KEY_VALUE, "init-limits", (size_t) 1, prio ? "0" : "1", -		VICI_KEY_VALUE, "my-host", strlen(buf[0]), buf[0], -		VICI_KEY_VALUE, "other-host", strlen(buf[1]), buf[1], -		VICI_END); +	vici_submit_request(vici, "initiate", VICI_KEY_VALUE, "child", +			    strlen(profile), profile, VICI_KEY_VALUE, "timeout", +			    (size_t)2, "-1", VICI_KEY_VALUE, "async", (size_t)1, +			    "1", VICI_KEY_VALUE, "init-limits", (size_t)1, +			    prio ? "0" : "1", VICI_KEY_VALUE, "my-host", +			    strlen(buf[0]), buf[0], VICI_KEY_VALUE, +			    "other-host", strlen(buf[1]), buf[1], VICI_END);  }  int sock_open_unix(const char *path) @@ -493,11 +538,12 @@ int sock_open_unix(const char *path)  	if (fd < 0)  		return -1; -	memset(&addr, 0, sizeof (struct sockaddr_un)); +	memset(&addr, 0, sizeof(struct sockaddr_un));  	addr.sun_family = AF_UNIX;  	strncpy(addr.sun_path, path, sizeof(addr.sun_path) - 1); -	ret = connect(fd, (struct sockaddr *) &addr, sizeof(addr.sun_family) + strlen(addr.sun_path)); +	ret = connect(fd, (struct sockaddr *)&addr, +		      sizeof(addr.sun_family) + strlen(addr.sun_path));  	if (ret < 0) {  		close(fd);  		return -1; diff --git a/nhrpd/vici.h b/nhrpd/vici.h index 24b900b43c..f2ad3a9fe3 100644 --- a/nhrpd/vici.h +++ b/nhrpd/vici.h @@ -1,13 +1,13 @@  enum vici_type_t { -	VICI_START =         0, +	VICI_START = 0,  	VICI_SECTION_START = 1, -	VICI_SECTION_END =   2, -	VICI_KEY_VALUE =     3, -	VICI_LIST_START =    4, -	VICI_LIST_ITEM =     5, -	VICI_LIST_END =      6, -	VICI_END =           7 +	VICI_SECTION_END = 2, +	VICI_KEY_VALUE = 3, +	VICI_LIST_START = 4, +	VICI_LIST_ITEM = 5, +	VICI_LIST_END = 6, +	VICI_END = 7  };  enum vici_operation_t { diff --git a/nhrpd/zbuf.c b/nhrpd/zbuf.c index 97962b9ab8..65232a3093 100644 --- a/nhrpd/zbuf.c +++ b/nhrpd/zbuf.c @@ -28,7 +28,7 @@ struct zbuf *zbuf_alloc(size_t size)  	if (!zb)  		return NULL; -	zbuf_init(zb, zb+1, size, 0); +	zbuf_init(zb, zb + 1, size, 0);  	zb->allocated = 1;  	return zb; @@ -36,7 +36,7 @@ struct zbuf *zbuf_alloc(size_t size)  void zbuf_init(struct zbuf *zb, void *buf, size_t len, size_t datalen)  { -	*zb = (struct zbuf) { +	*zb = (struct zbuf){  		.buf = buf,  		.end = (uint8_t *)buf + len,  		.head = buf, @@ -58,7 +58,7 @@ void zbuf_reset(struct zbuf *zb)  void zbuf_reset_head(struct zbuf *zb, void *ptr)  { -	zassert((void*)zb->buf <= ptr && ptr <= (void*)zb->tail); +	zassert((void *)zb->buf <= ptr && ptr <= (void *)zb->tail);  	zb->head = ptr;  } @@ -84,9 +84,12 @@ ssize_t zbuf_read(struct zbuf *zb, int fd, size_t maxlen)  		maxlen = zbuf_tailroom(zb);  	r = read(fd, zb->tail, maxlen); -	if (r > 0) zb->tail += r; -	else if (r == 0) r = -2; -	else if (r < 0 && ERRNO_IO_RETRY(errno)) r = 0; +	if (r > 0) +		zb->tail += r; +	else if (r == 0) +		r = -2; +	else if (r < 0 && ERRNO_IO_RETRY(errno)) +		r = 0;  	return r;  } @@ -103,9 +106,10 @@ ssize_t zbuf_write(struct zbuf *zb, int fd)  		zb->head += r;  		if (zb->head == zb->tail)  			zbuf_reset(zb); -	} -	else if (r == 0) r = -2; -	else if (r < 0 && ERRNO_IO_RETRY(errno)) r = 0; +	} else if (r == 0) +		r = -2; +	else if (r < 0 && ERRNO_IO_RETRY(errno)) +		r = 0;  	return r;  } @@ -119,9 +123,12 @@ ssize_t zbuf_recv(struct zbuf *zb, int fd)  	zbuf_remove_headroom(zb);  	r = recv(fd, zb->tail, zbuf_tailroom(zb), 0); -	if (r > 0) zb->tail += r; -	else if (r == 0) r = -2; -	else if (r < 0 && ERRNO_IO_RETRY(errno)) r = 0; +	if (r > 0) +		zb->tail += r; +	else if (r == 0) +		r = -2; +	else if (r < 0 && ERRNO_IO_RETRY(errno)) +		r = 0;  	return r;  } @@ -145,7 +152,8 @@ void *zbuf_may_pull_until(struct zbuf *zb, const char *sep, struct zbuf *msg)  	uint8_t *ptr;  	ptr = memmem(zb->head, zbuf_used(zb), sep, seplen); -	if (!ptr) return NULL; +	if (!ptr) +		return NULL;  	len = ptr - zb->head + seplen;  	zbuf_init(msg, zbuf_pulln(zb, len), len, len); @@ -154,7 +162,7 @@ void *zbuf_may_pull_until(struct zbuf *zb, const char *sep, struct zbuf *msg)  void zbufq_init(struct zbuf_queue *zbq)  { -	*zbq = (struct zbuf_queue) { +	*zbq = (struct zbuf_queue){  		.queue_head = LIST_INITIALIZER(zbq->queue_head),  	};  } @@ -163,7 +171,8 @@ void zbufq_reset(struct zbuf_queue *zbq)  {  	struct zbuf *buf, *bufn; -	list_for_each_entry_safe(buf, bufn, &zbq->queue_head, queue_list) { +	list_for_each_entry_safe(buf, bufn, &zbq->queue_head, queue_list) +	{  		list_del(&buf->queue_list);  		zbuf_free(buf);  	} @@ -181,10 +190,10 @@ int zbufq_write(struct zbuf_queue *zbq, int fd)  	ssize_t r;  	size_t iovcnt = 0; -	list_for_each_entry_safe(zb, zbn, &zbq->queue_head, queue_list) { -		iov[iovcnt++] = (struct iovec) { -			.iov_base = zb->head, -			.iov_len = zbuf_used(zb), +	list_for_each_entry_safe(zb, zbn, &zbq->queue_head, queue_list) +	{ +		iov[iovcnt++] = (struct iovec){ +			.iov_base = zb->head, .iov_len = zbuf_used(zb),  		};  		if (iovcnt >= ZEBRA_NUM_OF(iov))  			break; @@ -194,7 +203,8 @@ int zbufq_write(struct zbuf_queue *zbq, int fd)  	if (r < 0)  		return r; -	list_for_each_entry_safe(zb, zbn, &zbq->queue_head, queue_list) { +	list_for_each_entry_safe(zb, zbn, &zbq->queue_head, queue_list) +	{  		if (r < (ssize_t)zbuf_used(zb)) {  			zb->head += r;  			return 1; @@ -215,6 +225,7 @@ void zbuf_copy(struct zbuf *zdst, struct zbuf *zsrc, size_t len)  	dst = zbuf_pushn(zdst, len);  	src = zbuf_pulln(zsrc, len); -	if (!dst || !src) return; +	if (!dst || !src) +		return;  	memcpy(dst, src, len);  } diff --git a/nhrpd/zbuf.h b/nhrpd/zbuf.h index 73d7073447..d03f4ca3a2 100644 --- a/nhrpd/zbuf.h +++ b/nhrpd/zbuf.h @@ -77,7 +77,8 @@ static inline void *__zbuf_pull(struct zbuf *zb, size_t size, int error)  {  	void *head = zb->head;  	if (size > zbuf_used(zb)) { -		if (error) zbuf_set_rerror(zb); +		if (error) +			zbuf_set_rerror(zb);  		return NULL;  	}  	zb->head += size; @@ -94,13 +95,15 @@ void *zbuf_may_pull_until(struct zbuf *zb, const char *sep, struct zbuf *msg);  static inline void zbuf_get(struct zbuf *zb, void *dst, size_t len)  {  	void *src = zbuf_pulln(zb, len); -	if (src) memcpy(dst, src, len); +	if (src) +		memcpy(dst, src, len);  }  static inline uint8_t zbuf_get8(struct zbuf *zb)  {  	uint8_t *src = zbuf_pull(zb, uint8_t); -	if (src) return *src; +	if (src) +		return *src;  	return 0;  } @@ -111,7 +114,8 @@ static inline uint32_t zbuf_get32(struct zbuf *zb)  	} __attribute__((packed));  	struct unaligned32 *v = zbuf_pull(zb, struct unaligned32); -	if (v) return v->value; +	if (v) +		return v->value;  	return 0;  } @@ -122,7 +126,8 @@ static inline uint16_t zbuf_get_be16(struct zbuf *zb)  	} __attribute__((packed));  	struct unaligned16 *v = zbuf_pull(zb, struct unaligned16); -	if (v) return be16toh(v->value); +	if (v) +		return be16toh(v->value);  	return 0;  } @@ -135,7 +140,8 @@ static inline void *__zbuf_push(struct zbuf *zb, size_t size, int error)  {  	void *tail = zb->tail;  	if (size > zbuf_tailroom(zb)) { -		if (error) zbuf_set_werror(zb); +		if (error) +			zbuf_set_werror(zb);  		return NULL;  	}  	zb->tail += size; @@ -150,13 +156,15 @@ static inline void *__zbuf_push(struct zbuf *zb, size_t size, int error)  static inline void zbuf_put(struct zbuf *zb, const void *src, size_t len)  {  	void *dst = zbuf_pushn(zb, len); -	if (dst) memcpy(dst, src, len); +	if (dst) +		memcpy(dst, src, len);  }  static inline void zbuf_put8(struct zbuf *zb, uint8_t val)  {  	uint8_t *dst = zbuf_push(zb, uint8_t); -	if (dst) *dst = val; +	if (dst) +		*dst = val;  }  static inline void zbuf_put_be16(struct zbuf *zb, uint16_t val) @@ -166,7 +174,8 @@ static inline void zbuf_put_be16(struct zbuf *zb, uint16_t val)  	} __attribute__((packed));  	struct unaligned16 *v = zbuf_push(zb, struct unaligned16); -	if (v) v->value = htobe16(val); +	if (v) +		v->value = htobe16(val);  }  static inline void zbuf_put_be32(struct zbuf *zb, uint32_t val) @@ -176,7 +185,8 @@ static inline void zbuf_put_be32(struct zbuf *zb, uint32_t val)  	} __attribute__((packed));  	struct unaligned32 *v = zbuf_push(zb, struct unaligned32); -	if (v) v->value = htobe32(val); +	if (v) +		v->value = htobe32(val);  }  void zbuf_copy(struct zbuf *zb, struct zbuf *src, size_t len); diff --git a/nhrpd/znl.c b/nhrpd/znl.c index 5e9864c4d8..01b2f433af 100644 --- a/nhrpd/znl.c +++ b/nhrpd/znl.c @@ -35,18 +35,18 @@ struct nlmsghdr *znl_nlmsg_push(struct zbuf *zb, uint16_t type, uint16_t flags)  	struct nlmsghdr *n;  	n = znl_push(zb, sizeof(*n)); -	if (!n) return NULL; +	if (!n) +		return NULL; -	*n = (struct nlmsghdr) { -		.nlmsg_type = type, -		.nlmsg_flags = flags, +	*n = (struct nlmsghdr){ +		.nlmsg_type = type, .nlmsg_flags = flags,  	};  	return n;  }  void znl_nlmsg_complete(struct zbuf *zb, struct nlmsghdr *n)  { -	n->nlmsg_len = zb->tail - (uint8_t*)n; +	n->nlmsg_len = zb->tail - (uint8_t *)n;  }  struct nlmsghdr *znl_nlmsg_pull(struct zbuf *zb, struct zbuf *payload) @@ -55,7 +55,8 @@ struct nlmsghdr *znl_nlmsg_pull(struct zbuf *zb, struct zbuf *payload)  	size_t plen;  	n = znl_pull(zb, sizeof(*n)); -	if (!n) return NULL; +	if (!n) +		return NULL;  	plen = n->nlmsg_len - sizeof(*n);  	zbuf_init(payload, znl_pull(zb, plen), plen, plen); @@ -64,22 +65,23 @@ struct nlmsghdr *znl_nlmsg_pull(struct zbuf *zb, struct zbuf *payload)  	return n;  } -struct rtattr *znl_rta_push(struct zbuf *zb, uint16_t type, const void *val, size_t len) +struct rtattr *znl_rta_push(struct zbuf *zb, uint16_t type, const void *val, +			    size_t len)  {  	struct rtattr *rta;  	uint8_t *dst;  	rta = znl_push(zb, ZNL_ALIGN(sizeof(*rta)) + ZNL_ALIGN(len)); -	if (!rta) return NULL; +	if (!rta) +		return NULL; -	*rta = (struct rtattr) { -		.rta_type = type, -		.rta_len  = ZNL_ALIGN(sizeof(*rta)) + len, +	*rta = (struct rtattr){ +		.rta_type = type, .rta_len = ZNL_ALIGN(sizeof(*rta)) + len,  	}; -	dst = (uint8_t *)(rta+1); +	dst = (uint8_t *)(rta + 1);  	memcpy(dst, val, len); -	memset(dst+len, 0, ZNL_ALIGN(len) - len); +	memset(dst + len, 0, ZNL_ALIGN(len) - len);  	return rta;  } @@ -94,9 +96,10 @@ struct rtattr *znl_rta_nested_push(struct zbuf *zb, uint16_t type)  	struct rtattr *rta;  	rta = znl_push(zb, sizeof(*rta)); -	if (!rta) return NULL; +	if (!rta) +		return NULL; -	*rta = (struct rtattr) { +	*rta = (struct rtattr){  		.rta_type = type,  	};  	return rta; @@ -104,12 +107,13 @@ struct rtattr *znl_rta_nested_push(struct zbuf *zb, uint16_t type)  void znl_rta_nested_complete(struct zbuf *zb, struct rtattr *rta)  { -	size_t len = zb->tail - (uint8_t*) rta; +	size_t len = zb->tail - (uint8_t *)rta;  	size_t align = ZNL_ALIGN(len) - len;  	if (align) {  		void *dst = zbuf_pushn(zb, align); -		if (dst) memset(dst, 0, align); +		if (dst) +			memset(dst, 0, align);  	}  	rta->rta_len = len;  } @@ -120,7 +124,8 @@ struct rtattr *znl_rta_pull(struct zbuf *zb, struct zbuf *payload)  	size_t plen;  	rta = znl_pull(zb, sizeof(*rta)); -	if (!rta) return NULL; +	if (!rta) +		return NULL;  	if (rta->rta_len > sizeof(*rta)) {  		plen = rta->rta_len - sizeof(*rta); @@ -151,7 +156,7 @@ int znl_open(int protocol, int groups)  	memset(&addr, 0, sizeof(addr));  	addr.nl_family = AF_NETLINK;  	addr.nl_groups = groups; -	if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) +	if (bind(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0)  		goto error;  	return fd; @@ -159,4 +164,3 @@ error:  	close(fd);  	return -1;  } - diff --git a/nhrpd/znl.h b/nhrpd/znl.h index 2cd630b5d3..fd31daaf43 100644 --- a/nhrpd/znl.h +++ b/nhrpd/znl.h @@ -18,7 +18,8 @@ struct nlmsghdr *znl_nlmsg_push(struct zbuf *zb, uint16_t type, uint16_t flags);  void znl_nlmsg_complete(struct zbuf *zb, struct nlmsghdr *n);  struct nlmsghdr *znl_nlmsg_pull(struct zbuf *zb, struct zbuf *payload); -struct rtattr *znl_rta_push(struct zbuf *zb, uint16_t type, const void *val, size_t len); +struct rtattr *znl_rta_push(struct zbuf *zb, uint16_t type, const void *val, +			    size_t len);  struct rtattr *znl_rta_push_u32(struct zbuf *zb, uint16_t type, uint32_t val);  struct rtattr *znl_rta_nested_push(struct zbuf *zb, uint16_t type);  void znl_rta_nested_complete(struct zbuf *zb, struct rtattr *rta); @@ -26,4 +27,3 @@ void znl_rta_nested_complete(struct zbuf *zb, struct rtattr *rta);  struct rtattr *znl_rta_pull(struct zbuf *zb, struct zbuf *payload);  int znl_open(int protocol, int groups); - diff --git a/ospf6d/ospf6_abr.c b/ospf6d/ospf6_abr.c index 8847611492..67d18566ae 100644 --- a/ospf6d/ospf6_abr.c +++ b/ospf6d/ospf6_abr.c @@ -390,10 +390,10 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,  		if (prefix_list_apply(PREFIX_LIST_OUT(area), &route->prefix)  		    != PREFIX_PERMIT) {  			if (is_debug) { -				inet_ntop(AF_INET, -					  &(ADV_ROUTER_IN_PREFIX( -						  &route->prefix)), -					  buf, sizeof(buf)); +				inet_ntop( +					AF_INET, +					&(ADV_ROUTER_IN_PREFIX(&route->prefix)), +					buf, sizeof(buf));  				zlog_debug(  					"prefix %s was denied by filter-list out",  					buf); @@ -870,8 +870,7 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)  		if (prefix_list_apply(PREFIX_LIST_IN(oa), &prefix)  		    != PREFIX_PERMIT) {  			if (is_debug) -				zlog_debug( -					"Prefix was denied by prefix-list"); +				zlog_debug("Prefix was denied by prefix-list");  			if (old)  				ospf6_route_remove(old, table);  			return; @@ -914,8 +913,8 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)  		if (is_debug)  			zlog_debug("%s: Update route: %s nh count %u", -				__PRETTY_FUNCTION__, -				buf, listcount(route->nh_list)); +				   __PRETTY_FUNCTION__, buf, +				   listcount(route->nh_list));  		/* Update RIB/FIB */  		if (table->hook_add) @@ -925,8 +924,8 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)  		ospf6_route_delete(route);  	} else {  		if (is_debug) -			zlog_debug("Install route: %s nh count %u", -				   buf, listcount(route->nh_list)); +			zlog_debug("Install route: %s nh count %u", buf, +				   listcount(route->nh_list));  		/* ospf6_ia_add_nw_route (table, &prefix, route); */  		ospf6_route_add(route, table);  	} @@ -1123,8 +1122,7 @@ struct ospf6_lsa_handler inter_prefix_handler = {  	.lh_short_name = "IAP",  	.lh_show = ospf6_inter_area_prefix_lsa_show,  	.lh_get_prefix_str = ospf6_inter_area_prefix_lsa_get_prefix_str, -	.lh_debug = 0 -}; +	.lh_debug = 0};  struct ospf6_lsa_handler inter_router_handler = {  	.lh_type = OSPF6_LSTYPE_INTER_ROUTER, @@ -1132,8 +1130,7 @@ struct ospf6_lsa_handler inter_router_handler = {  	.lh_short_name = "IAR",  	.lh_show = ospf6_inter_area_router_lsa_show,  	.lh_get_prefix_str = ospf6_inter_area_router_lsa_get_prefix_str, -	.lh_debug = 0 -}; +	.lh_debug = 0};  void ospf6_abr_init(void)  { diff --git a/ospf6d/ospf6_area.c b/ospf6d/ospf6_area.c index ed624c6ae4..0a72806030 100644 --- a/ospf6d/ospf6_area.c +++ b/ospf6d/ospf6_area.c @@ -61,7 +61,8 @@ 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", __PRETTY_FUNCTION__, +				   lsa->name);  			zlog_debug(" Schedule SPF Calculation for %s",  				   OSPF6_AREA(lsa->lsdb->data)->name);  		} @@ -587,14 +588,14 @@ DEFUN (area_filter_list,  	if (strmatch(inout, "in")) {  		PREFIX_LIST_IN(area) = plist;  		XFREE(MTYPE_OSPF6_PLISTNAME, PREFIX_NAME_IN(area)); -		PREFIX_NAME_IN(area) = XSTRDUP(MTYPE_OSPF6_PLISTNAME, -					       plistname); +		PREFIX_NAME_IN(area) = +			XSTRDUP(MTYPE_OSPF6_PLISTNAME, plistname);  		ospf6_abr_reimport(area);  	} else {  		PREFIX_LIST_OUT(area) = plist;  		XFREE(MTYPE_OSPF6_PLISTNAME, PREFIX_NAME_OUT(area)); -		PREFIX_NAME_OUT(area) = XSTRDUP(MTYPE_OSPF6_PLISTNAME, -						plistname); +		PREFIX_NAME_OUT(area) = +			XSTRDUP(MTYPE_OSPF6_PLISTNAME, plistname);  		ospf6_abr_enable_area(area);  	} diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c index b52f1cef6c..c23fe99bc8 100644 --- a/ospf6d/ospf6_asbr.c +++ b/ospf6d/ospf6_asbr.c @@ -164,9 +164,10 @@ int ospf6_orig_as_external_lsa(struct thread *thread)  	adv_router = oi->area->ospf6->router_id;  	for (ALL_LSDB_TYPED_ADVRTR(ospf6->lsdb, type, adv_router, lsa)) {  		if (IS_OSPF6_DEBUG_ASBR) -			zlog_debug("%s: Send update of AS-External LSA %s seq 0x%x", -				   __PRETTY_FUNCTION__, lsa->name, -				   ntohl(lsa->header->seqnum)); +			zlog_debug( +				"%s: Send update of AS-External LSA %s seq 0x%x", +				__PRETTY_FUNCTION__, lsa->name, +				ntohl(lsa->header->seqnum));  		ospf6_flood_interface(NULL, lsa, oi);  	} @@ -216,34 +217,36 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old,  	for (old_route = old; old_route; old_route = old_route->next) {  		bool route_updated = false; -		if (!ospf6_route_is_same(old_route, route) || -			(old_route->path.type != route->path.type)) +		if (!ospf6_route_is_same(old_route, route) +		    || (old_route->path.type != route->path.type))  			continue;  		/* Current and New route has same origin,  		 * delete old entry.  		 */  		for (ALL_LIST_ELEMENTS(old_route->paths, anode, anext, -						  o_path)) { +				       o_path)) {  			/* Check old route path and route has same  			 * origin.  			 */ -			if (o_path->area_id != route->path.area_id || -			    (memcmp(&(o_path)->origin, &(route)->path.origin, -				   sizeof(struct ospf6_ls_origin)) != 0)) +			if (o_path->area_id != route->path.area_id +			    || (memcmp(&(o_path)->origin, &(route)->path.origin, +				       sizeof(struct ospf6_ls_origin)) +				!= 0))  				continue;  			/* Cost is not same then delete current path */ -			if ((o_path->cost == route->path.cost) && -			    (o_path->u.cost_e2 == route->path.u.cost_e2)) +			if ((o_path->cost == route->path.cost) +			    && (o_path->u.cost_e2 == route->path.u.cost_e2))  				continue;  			if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) {  				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", +					__PRETTY_FUNCTION__, buf, o_path->cost, +					route->path.cost);  			}  			/* Remove selected current rout path's nh from @@ -251,11 +254,11 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old,  			 */  			for (ALL_LIST_ELEMENTS_RO(o_path->nh_list, nnode, nh)) {  				for (ALL_LIST_ELEMENTS(old_route->nh_list, -							rnode, rnext, rnh)) { +						       rnode, rnext, rnh)) {  					if (!ospf6_nexthop_is_same(rnh, nh))  						continue;  					listnode_delete(old_route->nh_list, -								rnh); +							rnh);  					ospf6_nexthop_delete(rnh);  					route_updated = true;  				} @@ -270,14 +273,16 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old,  			 * Update FIB with effective NHs.  			 */  			if (listcount(old_route->paths)) { -				if (old_route->path.origin.id == -					route->path.origin.id && -					old_route->path.origin.adv_router == -						route->path.origin.adv_router) { +				if (old_route->path.origin.id +					    == route->path.origin.id +				    && old_route->path.origin.adv_router +					       == route->path.origin +							  .adv_router) {  					struct ospf6_path *h_path;  					h_path = (struct ospf6_path *) -					listgetdata(listhead(old_route->paths)); +						listgetdata(listhead( +							old_route->paths));  					old_route->path.origin.type =  						h_path->origin.type;  					old_route->path.origin.id = @@ -288,7 +293,8 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old,  				if (route_updated) {  					for (ALL_LIST_ELEMENTS(old_route->paths, -							anode, anext, o_path)) { +							       anode, anext, +							       o_path)) {  						ospf6_merge_nexthops(  							old_route->nh_list,  							o_path->nh_list); @@ -297,18 +303,19 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old,  					 * nh_list  					 */  					if (ospf6->route_table->hook_add) -						(*ospf6->route_table->hook_add) -							(old_route); +						(*ospf6->route_table->hook_add)( +							old_route);  					break;  				}  			} else {  				if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) {  					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.", +						__PRETTY_FUNCTION__, buf, +						old_route->path.cost, +						route->path.cost);  				}  				ospf6_route_remove(old_route,  						   ospf6->route_table); @@ -325,21 +332,22 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old,  		/* Current and New Route prefix or route type  		 * is not same skip this current node.  		 */ -		if (!ospf6_route_is_same(old_route, route) || -			(old_route->path.type != route->path.type)) +		if (!ospf6_route_is_same(old_route, route) +		    || (old_route->path.type != route->path.type))  			continue;  		/* Old Route and New Route have Equal Cost, Merge NHs */ -		if ((old_route->path.cost == route->path.cost) && -		    (old_route->path.u.cost_e2 == route->path.u.cost_e2)) { +		if ((old_route->path.cost == route->path.cost) +		    && (old_route->path.u.cost_e2 == route->path.u.cost_e2)) {  			if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) {  				prefix2str(&old_route->prefix, buf,  					   sizeof(buf)); -				zlog_debug("%s: old route %s path  cost %u e2 %u", -					   __PRETTY_FUNCTION__, buf, -					   old_route->path.cost, -					   old_route->path.u.cost_e2); +				zlog_debug( +					"%s: old route %s path  cost %u e2 %u", +					__PRETTY_FUNCTION__, buf, +					old_route->path.cost, +					old_route->path.u.cost_e2);  			}  			route_found = true;  			/* check if this path exists already in @@ -348,10 +356,11 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old,  			 */  			for (ALL_LIST_ELEMENTS_RO(old_route->paths, anode,  						  o_path)) { -				if (o_path->area_id == route->path.area_id && -				    (memcmp(&(o_path)->origin, -					&(route)->path.origin, -					sizeof(struct ospf6_ls_origin)) == 0)) +				if (o_path->area_id == route->path.area_id +				    && (memcmp(&(o_path)->origin, +					       &(route)->path.origin, +					       sizeof(struct ospf6_ls_origin)) +					== 0))  					break;  			}  			/* If path is not found in old_route paths's list, @@ -370,8 +379,8 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old,  				/* Update RIB/FIB */  				if (ospf6->route_table->hook_add) -					(*ospf6->route_table->hook_add) -						(old_route); +					(*ospf6->route_table->hook_add)( +						old_route);  				/* Add the new path to route's path list */  				listnode_add_sort(old_route->paths, ecmp_path); @@ -379,20 +388,23 @@ 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 another path added with nh %u, effective paths %u nh %u", +					zlog_debug( +						"%s: route %s another path added with nh %u, effective paths %u nh %u",  						__PRETTY_FUNCTION__, 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 {  				for (ALL_LIST_ELEMENTS_RO(o_path->nh_list,  							  nnode, nh)) {  					for (ALL_LIST_ELEMENTS( -							old_route->nh_list, -							rnode, rnext, rnh)) { +						     old_route->nh_list, rnode, +						     rnext, rnh)) {  						if (!ospf6_nexthop_is_same(rnh,  									   nh))  							continue; @@ -405,27 +417,28 @@ void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old,  				}  				list_delete_all_node(o_path->nh_list);  				ospf6_copy_nexthops(o_path->nh_list, -					    route->nh_list); +						    route->nh_list);  				/* Merge nexthop to existing route's nh_list */ -				ospf6_route_merge_nexthops(old_route, -							   route); +				ospf6_route_merge_nexthops(old_route, route);  				if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) { -					prefix2str(&route->prefix, -						   buf, sizeof(buf)); -					zlog_debug("%s: existing route %s with effective nh count %u", -						   __PRETTY_FUNCTION__, buf, -						   old_route->nh_list ? -						   listcount(old_route->nh_list) -						   : 0); +					prefix2str(&route->prefix, buf, +						   sizeof(buf)); +					zlog_debug( +						"%s: existing route %s with effective nh count %u", +						__PRETTY_FUNCTION__, buf, +						old_route->nh_list +							? listcount( +								  old_route +									  ->nh_list) +							: 0);  				}  				/* Update RIB/FIB */  				if (ospf6->route_table->hook_add) -					(*ospf6->route_table->hook_add) -						(old_route); - +					(*ospf6->route_table->hook_add)( +						old_route);  			}  			/* Delete the new route its info added to existing  			 * route. @@ -524,9 +537,9 @@ void ospf6_asbr_lsa_add(struct ospf6_lsa *lsa)  		prefix2str(&route->prefix, buf, sizeof(buf));  		zlog_debug("%s: AS-External %u route add %s cost %u(%u) nh %u",  			   __PRETTY_FUNCTION__, -			   (route->path.type == OSPF6_PATH_TYPE_EXTERNAL1) -			   ? 1 : 2, buf, route->path.cost, -			   route->path.u.cost_e2, +			   (route->path.type == OSPF6_PATH_TYPE_EXTERNAL1) ? 1 +									   : 2, +			   buf, route->path.cost, route->path.u.cost_e2,  			   listcount(route->nh_list));  	} @@ -542,7 +555,6 @@ void ospf6_asbr_lsa_add(struct ospf6_lsa *lsa)  		 */  		ospf6_asbr_update_route_ecmp_path(old, route);  	} -  }  void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa, @@ -587,9 +599,8 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa,  		} else {  			route_to_del->path.type = OSPF6_PATH_TYPE_EXTERNAL1;  			route_to_del->path.metric_type = 1; -			route_to_del->path.cost = -				asbr_entry->path.cost + -				OSPF6_ASBR_METRIC(external); +			route_to_del->path.cost = asbr_entry->path.cost +						  + OSPF6_ASBR_METRIC(external);  			route_to_del->path.u.cost_e2 = 0;  		}  	} @@ -610,15 +621,15 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa,  	if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) {  		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); +		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);  	} -	for (ospf6_route_lock(route); route && -	     ospf6_route_is_prefix(&prefix, route); route = nroute) { +	for (ospf6_route_lock(route); +	     route && ospf6_route_is_prefix(&prefix, route); route = nroute) {  		nroute = ospf6_route_next(route);  		if (route->type != OSPF6_DEST_TYPE_NETWORK) @@ -640,34 +651,36 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa,  			 * replace from paths list.  			 */  			for (ALL_LIST_ELEMENTS(route->paths, anode, anext, -						  o_path)) { +					       o_path)) {  				if ((o_path->origin.type != lsa->header->type) -				    || (o_path->origin.adv_router != -					lsa->header->adv_router) || -				    (o_path->origin.id != lsa->header->id)) +				    || (o_path->origin.adv_router +					!= lsa->header->adv_router) +				    || (o_path->origin.id != lsa->header->id))  					continue;  				/* Compare LSA cost with current  				 * route info.  				 */ -				if (!asbr_entry && (o_path->cost != -						route_to_del->path.cost || -						o_path->u.cost_e2 != -						route_to_del->path.u.cost_e2)) { +				if (!asbr_entry +				    && (o_path->cost != route_to_del->path.cost +					|| o_path->u.cost_e2 +						   != route_to_del->path.u +							      .cost_e2)) {  					if (IS_OSPF6_DEBUG_EXAMIN( -							AS_EXTERNAL)) { +						    AS_EXTERNAL)) {  						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, -						route_to_del->path.cost); +							"%s: route %s to delete is not same, cost %u del cost %u. skip", +							__PRETTY_FUNCTION__, +							buf, route->path.cost, +							route_to_del->path +								.cost);  					}  					continue;  				} -				if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL))  { +				if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) {  					prefix2str(&prefix, buf, sizeof(buf));  					zlog_debug(  						"%s: route %s path found with nh %u to remove.", @@ -681,9 +694,10 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa,  				for (ALL_LIST_ELEMENTS_RO(o_path->nh_list,  							  nnode, nh)) {  					for (ALL_LIST_ELEMENTS(route->nh_list, -							rnode, rnext, rnh)) { +							       rnode, rnext, +							       rnh)) {  						if (!ospf6_nexthop_is_same(rnh, -								nh)) +									   nh))  							continue;  						listnode_delete(route->nh_list,  								rnh); @@ -711,13 +725,15 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa,  				if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) {  					prefix2str(&route->prefix, buf,  						   sizeof(buf)); -					zlog_debug("%s: AS-External %u route %s update paths %u nh %u" -						   , __PRETTY_FUNCTION__, -						   (route->path.type == -						   OSPF6_PATH_TYPE_EXTERNAL1) -						   ? 1 : 2, buf, -						   listcount(route->paths), -						   listcount(route->nh_list)); +					zlog_debug( +						"%s: AS-External %u route %s update paths %u nh %u", +						__PRETTY_FUNCTION__, +						(route->path.type +						 == OSPF6_PATH_TYPE_EXTERNAL1) +							? 1 +							: 2, +						buf, listcount(route->paths), +						listcount(route->nh_list));  				}  				/* Update RIB/FIB with effective nh_list */ @@ -728,13 +744,14 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa,  				 * replace route's primary path with  				 * route's paths list head.  				 */ -				if (route->path.origin.id == lsa->header->id && -				    route->path.origin.adv_router == -						lsa->header->adv_router) { +				if (route->path.origin.id == lsa->header->id +				    && route->path.origin.adv_router +					       == lsa->header->adv_router) {  					struct ospf6_path *h_path;  					h_path = (struct ospf6_path *) -					listgetdata(listhead(route->paths)); +						listgetdata( +							listhead(route->paths));  					route->path.origin.type =  						h_path->origin.type;  					route->path.origin.id = @@ -749,36 +766,39 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa,  			/* Compare LSA origin and cost with current route info.  			 * if any check fails skip del this route node.  			 */ -			if (asbr_entry && (!ospf6_route_is_same_origin(route, -							route_to_del) || -			    (route->path.type != route_to_del->path.type) || -			    (route->path.cost != route_to_del->path.cost) || -			    (route->path.u.cost_e2 != -			     route_to_del->path.u.cost_e2))) { +			if (asbr_entry +			    && (!ospf6_route_is_same_origin(route, route_to_del) +				|| (route->path.type != route_to_del->path.type) +				|| (route->path.cost != route_to_del->path.cost) +				|| (route->path.u.cost_e2 +				    != route_to_del->path.u.cost_e2))) {  				if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) {  					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, -					route_to_del->path.cost); +					zlog_debug( +						"%s: route %s to delete is not same, cost %u del cost %u. skip", +						__PRETTY_FUNCTION__, buf, +						route->path.cost, +						route_to_del->path.cost);  				}  				continue;  			} -			if ((route->path.origin.type != lsa->header->type) || -			    (route->path.origin.adv_router != -					lsa->header->adv_router) || -			    (route->path.origin.id != lsa->header->id)) +			if ((route->path.origin.type != lsa->header->type) +			    || (route->path.origin.adv_router +				!= lsa->header->adv_router) +			    || (route->path.origin.id != lsa->header->id))  				continue;  		}  		if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) {  			prefix2str(&route->prefix, buf, sizeof(buf)); -			zlog_debug("%s: AS-External %u route remove %s cost %u(%u) nh %u", -				   __PRETTY_FUNCTION__, -				   route->path.type == OSPF6_PATH_TYPE_EXTERNAL1 -				   ? 1 : 2, buf, route->path.cost, -				   route->path.u.cost_e2, -				   listcount(route->nh_list)); +			zlog_debug( +				"%s: AS-External %u route remove %s cost %u(%u) nh %u", +				__PRETTY_FUNCTION__, +				route->path.type == OSPF6_PATH_TYPE_EXTERNAL1 +					? 1 +					: 2, +				buf, route->path.cost, route->path.u.cost_e2, +				listcount(route->nh_list));  		}  		ospf6_route_remove(route, ospf6->route_table);  	} @@ -852,8 +872,8 @@ static int ospf6_asbr_routemap_update_timer(struct thread *thread)  	ospf6->t_distribute_update = NULL;  	if (ospf6->rmap[arg_type].name) -		ospf6->rmap[arg_type].map = route_map_lookup_by_name( -					ospf6->rmap[arg_type].name); +		ospf6->rmap[arg_type].map = +			route_map_lookup_by_name(ospf6->rmap[arg_type].name);  	if (ospf6->rmap[arg_type].map) {  		if (IS_OSPF6_DEBUG_ASBR)  			zlog_debug("%s: route-map %s update, reset redist %s", @@ -876,7 +896,7 @@ void ospf6_asbr_distribute_list_update(int type)  	if (ospf6->t_distribute_update)  		return; -	args = XCALLOC(MTYPE_OSPF6_DIST_ARGS, sizeof(void *)*2); +	args = XCALLOC(MTYPE_OSPF6_DIST_ARGS, sizeof(void *) * 2);  	args[0] = ospf6;  	args[1] = (void *)((ptrdiff_t)type); @@ -903,12 +923,13 @@ static void ospf6_asbr_routemap_update(const char *mapname)  			ospf6->rmap[type].map = route_map_lookup_by_name(  				ospf6->rmap[type].name); -			if (mapname && ospf6->rmap[type].map && -			    (strcmp(ospf6->rmap[type].name, mapname) == 0)) { +			if (mapname && ospf6->rmap[type].map +			    && (strcmp(ospf6->rmap[type].name, mapname) == 0)) {  				if (IS_OSPF6_DEBUG_ASBR) -					zlog_debug("%s: route-map %s update, reset redist %s", -						   __PRETTY_FUNCTION__, mapname, -						   ZROUTE_NAME(type)); +					zlog_debug( +						"%s: route-map %s update, reset redist %s", +						__PRETTY_FUNCTION__, mapname, +						ZROUTE_NAME(type));  				ospf6_asbr_distribute_list_update(type);  			}  		} else @@ -923,8 +944,8 @@ static void ospf6_asbr_routemap_event(route_map_event_t event, const char *name)  	if (ospf6 == NULL)  		return;  	for (type = 0; type < ZEBRA_ROUTE_MAX; type++) { -		if ((ospf6->rmap[type].name) && -		    (strcmp(ospf6->rmap[type].name, name) == 0)) { +		if ((ospf6->rmap[type].name) +		    && (strcmp(ospf6->rmap[type].name, name) == 0)) {  			ospf6_asbr_distribute_list_update(type);  		}  	} @@ -1064,8 +1085,9 @@ void ospf6_asbr_redistribute_add(int type, ifindex_t ifindex,  			inet_ntop(AF_INET, &prefix_id.u.prefix4, ibuf,  				  sizeof(ibuf));  			prefix2str(prefix, pbuf, sizeof(pbuf)); -			zlog_debug("Advertise as AS-External Id:%s prefix %s metric %u", -				   ibuf, pbuf, match->path.metric_type); +			zlog_debug( +				"Advertise as AS-External Id:%s prefix %s metric %u", +				ibuf, pbuf, match->path.metric_type);  		}  		match->path.origin.id = htonl(info->id); @@ -1797,8 +1819,7 @@ struct ospf6_lsa_handler as_external_handler = {  	.lh_short_name = "ASE",  	.lh_show = ospf6_as_external_lsa_show,  	.lh_get_prefix_str = ospf6_as_external_lsa_get_prefix_str, -	.lh_debug = 0 -}; +	.lh_debug = 0};  void ospf6_asbr_init(void)  { diff --git a/ospf6d/ospf6_flood.c b/ospf6d/ospf6_flood.c index 17733d6099..dae10dce0d 100644 --- a/ospf6d/ospf6_flood.c +++ b/ospf6d/ospf6_flood.c @@ -237,8 +237,7 @@ void ospf6_install_lsa(struct ospf6_lsa *lsa)  	    || 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)); +			   ntohs(lsa->header->age), ntohl(lsa->header->seqnum));  	/* actually install */  	lsa->installed = now; @@ -249,9 +248,8 @@ void ospf6_install_lsa(struct ospf6_lsa *lsa)  /* RFC2740 section 3.5.2. Sending Link State Update packets */  /* RFC2328 section 13.3 Next step in the flooding procedure */ -void ospf6_flood_interface(struct ospf6_neighbor *from, -				  struct ospf6_lsa *lsa, -				  struct ospf6_interface *oi) +void ospf6_flood_interface(struct ospf6_neighbor *from, struct ospf6_lsa *lsa, +			   struct ospf6_interface *oi)  {  	struct listnode *node, *nnode;  	struct ospf6_neighbor *on; @@ -348,9 +346,10 @@ void ospf6_flood_interface(struct ospf6_neighbor *from,  		if (ospf6->inst_shutdown) {  			if (is_debug) -				zlog_debug("%s: Send LSA %s (age %d) update now", -					   __PRETTY_FUNCTION__, lsa->name, -					   ntohs(lsa->header->age)); +				zlog_debug( +					"%s: Send LSA %s (age %d) update now", +					__PRETTY_FUNCTION__, lsa->name, +					ntohs(lsa->header->age));  			ospf6_lsupdate_send_neighbor_now(on, lsa);  			continue;  		} else { @@ -818,15 +817,16 @@ void ospf6_receive_lsa(struct ospf6_neighbor *from,  				zlog_debug("Received is duplicated LSA");  			SET_FLAG(new->flag, OSPF6_LSA_DUPLICATE);  		} -		if (old->header->adv_router == -		    from->ospf6_if->area->ospf6->router_id +		if (old->header->adv_router +			    == from->ospf6_if->area->ospf6->router_id  		    && OSPF6_LSA_IS_MAXAGE(new)) {  			ospf6_acknowledge_lsa(new, ismore_recent, from);  			ospf6_lsa_delete(new);  			if (is_debug) -				zlog_debug("%s: Received is self orig MAXAGE LSA %s, discard (ismore_recent %d)", -					   __PRETTY_FUNCTION__, old->name, -					   ismore_recent); +				zlog_debug( +					"%s: Received is self orig MAXAGE LSA %s, discard (ismore_recent %d)", +					__PRETTY_FUNCTION__, old->name, +					ismore_recent);  			return;  		}  	} @@ -985,18 +985,17 @@ void ospf6_receive_lsa(struct ospf6_neighbor *from,  			/* Neighbor router sent recent age for LSA,  			 * Router could be restarted while current copy is  			 * MAXAGEd and not removed.*/ -			if (OSPF6_LSA_IS_MAXAGE(old) && -			    !OSPF6_LSA_IS_MAXAGE(new)) { +			if (OSPF6_LSA_IS_MAXAGE(old) +			    && !OSPF6_LSA_IS_MAXAGE(new)) {  				if (is_debug) -					zlog_debug("%s: Current copy of LSA %s is MAXAGE, but new has recent Age.", -						   old->name, -					   __PRETTY_FUNCTION__); +					zlog_debug( +						"%s: Current copy of LSA %s is MAXAGE, but new has recent Age.", +						old->name, __PRETTY_FUNCTION__);  				ospf6_lsa_purge(old);  				if (new->header->adv_router -						!= from->ospf6_if->area-> -							ospf6->router_id) +				    != from->ospf6_if->area->ospf6->router_id)  					ospf6_flood(from, new);  				ospf6_install_lsa(new); diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c index 5eaf617702..8524292215 100644 --- a/ospf6d/ospf6_interface.c +++ b/ospf6d/ospf6_interface.c @@ -125,7 +125,7 @@ static u_int32_t ospf6_interface_get_cost(struct ospf6_interface *oi)  		bw = oi->interface->speed;  	} else {  		bw = oi->interface->bandwidth ? oi->interface->bandwidth -			: OSPF6_INTERFACE_BANDWIDTH; +					      : OSPF6_INTERFACE_BANDWIDTH;  	}  	refbw = ospf6 ? ospf6->ref_bandwidth : OSPF6_REFERENCE_BANDWIDTH; @@ -1010,8 +1010,7 @@ DEFUN (show_ipv6_ospf6_interface,  	return CMD_SUCCESS;  } -static int ospf6_interface_show_traffic(struct vty *vty, -					uint32_t vrf_id, +static int ospf6_interface_show_traffic(struct vty *vty, uint32_t vrf_id,  					struct interface *intf_ifp,  					int display_once)  { @@ -1023,13 +1022,14 @@ static int ospf6_interface_show_traffic(struct vty *vty,  	if (!display_once) {  		vty_out(vty, "\n"); -		vty_out(vty, "%-12s%-17s%-17s%-17s%-17s%-17s\n", -			"Interface", "    HELLO", "    DB-Desc", "   LS-Req", -			"   LS-Update", "   LS-Ack"); +		vty_out(vty, "%-12s%-17s%-17s%-17s%-17s%-17s\n", "Interface", +			"    HELLO", "    DB-Desc", "   LS-Req", "   LS-Update", +			"   LS-Ack");  		vty_out(vty, "%-10s%-18s%-18s%-17s%-17s%-17s\n", "", -			"      Rx/Tx", "     Rx/Tx", "    Rx/Tx", "    Rx/Tx", "    Rx/Tx"); +			"      Rx/Tx", "     Rx/Tx", "    Rx/Tx", "    Rx/Tx", +			"    Rx/Tx");  		vty_out(vty, -		"--------------------------------------------------------------------------------------------\n"); +			"--------------------------------------------------------------------------------------------\n");  	}  	if (intf_ifp == NULL) { @@ -1040,13 +1040,11 @@ static int ospf6_interface_show_traffic(struct vty *vty,  				continue;  			vty_out(vty, -			"%-10s %8u/%-8u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u\n", +				"%-10s %8u/%-8u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u\n",  				oi->interface->name, oi->hello_in, -				oi->hello_out, -				oi->db_desc_in, oi->db_desc_out, -				oi->ls_req_in, oi->ls_req_out, -				oi->ls_upd_in, oi->ls_upd_out, -				oi->ls_ack_in, oi->ls_ack_out); +				oi->hello_out, oi->db_desc_in, oi->db_desc_out, +				oi->ls_req_in, oi->ls_req_out, oi->ls_upd_in, +				oi->ls_upd_out, oi->ls_ack_in, oi->ls_ack_out);  		}  	} else {  		oi = intf_ifp->info; @@ -1055,11 +1053,9 @@ static int ospf6_interface_show_traffic(struct vty *vty,  		vty_out(vty,  			"%-10s %8u/%-8u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u\n", -			oi->interface->name, oi->hello_in, -			oi->hello_out, -			oi->db_desc_in, oi->db_desc_out, -			oi->ls_req_in, oi->ls_req_out, -			oi->ls_upd_in, oi->ls_upd_out, +			oi->interface->name, oi->hello_in, oi->hello_out, +			oi->db_desc_in, oi->db_desc_out, oi->ls_req_in, +			oi->ls_req_out, oi->ls_upd_in, oi->ls_upd_out,  			oi->ls_ack_in, oi->ls_ack_out);  	} @@ -1086,9 +1082,7 @@ DEFUN (show_ipv6_ospf6_interface_traffic,  		intf_name = argv[idx_ifname]->arg;  		ifp = if_lookup_by_name(intf_name, VRF_DEFAULT);  		if (ifp == NULL) { -			vty_out(vty, -				"No such Interface: %s\n", -				intf_name); +			vty_out(vty, "No such Interface: %s\n", intf_name);  			return CMD_WARNING;  		}  		if (ifp->info == NULL) { @@ -1099,8 +1093,7 @@ DEFUN (show_ipv6_ospf6_interface_traffic,  		}  	} -	ospf6_interface_show_traffic(vty, VRF_DEFAULT, ifp, -				     display_once); +	ospf6_interface_show_traffic(vty, VRF_DEFAULT, ifp, display_once);  	return CMD_SUCCESS; @@ -1940,8 +1933,7 @@ void ospf6_interface_init(void)  	install_element(VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);  	install_element(VIEW_NODE,  			&show_ipv6_ospf6_interface_ifname_prefix_cmd); -	install_element(VIEW_NODE, -			&show_ipv6_ospf6_interface_traffic_cmd); +	install_element(VIEW_NODE, &show_ipv6_ospf6_interface_traffic_cmd);  	install_element(INTERFACE_NODE, &ipv6_ospf6_cost_cmd);  	install_element(INTERFACE_NODE, &no_ipv6_ospf6_cost_cmd); diff --git a/ospf6d/ospf6_intra.c b/ospf6d/ospf6_intra.c index 77653ea33f..14f12d6b6a 100644 --- a/ospf6d/ospf6_intra.c +++ b/ospf6d/ospf6_intra.c @@ -215,7 +215,8 @@ int ospf6_router_lsa_originate(struct thread *thread)  	ospf6_router_lsa_options_set(oa, router_lsa);  	/* describe links for each interfaces */ -	lsdesc = (struct ospf6_router_lsdesc *)((caddr_t)router_lsa +	lsdesc = (struct ospf6_router_lsdesc +			  *)((caddr_t)router_lsa  			     + sizeof(struct ospf6_router_lsa));  	for (ALL_LIST_ELEMENTS(oa->if_list, node, nnode, oi)) { @@ -253,10 +254,9 @@ int ospf6_router_lsa_originate(struct thread *thread)  			lsa_header->type = htons(OSPF6_LSTYPE_ROUTER);  			lsa_header->id = htonl(link_state_id);  			lsa_header->adv_router = oa->ospf6->router_id; -			lsa_header->seqnum = -				ospf6_new_ls_seqnum(lsa_header->type, -						    lsa_header->id, -				    lsa_header->adv_router, oa->lsdb); +			lsa_header->seqnum = ospf6_new_ls_seqnum( +				lsa_header->type, lsa_header->id, +				lsa_header->adv_router, oa->lsdb);  			lsa_header->length =  				htons((caddr_t)lsdesc - (caddr_t)buffer); @@ -273,15 +273,16 @@ int ospf6_router_lsa_originate(struct thread *thread)  			memset(buffer, 0, sizeof(buffer));  			lsa_header = (struct ospf6_lsa_header *)buffer;  			router_lsa = -				(struct ospf6_router_lsa *)((caddr_t)lsa_header +				(struct ospf6_router_lsa +					 *)((caddr_t)lsa_header  					    + sizeof(struct ospf6_lsa_header));  			ospf6_router_lsa_options_set(oa, router_lsa);  			/* describe links for each interfaces */ -			lsdesc = (struct ospf6_router_lsdesc *) -				((caddr_t)router_lsa + -				 sizeof(struct ospf6_router_lsa)); +			lsdesc = (struct ospf6_router_lsdesc +					  *)((caddr_t)router_lsa +					     + sizeof(struct ospf6_router_lsa));  			link_state_id++;  		} @@ -922,16 +923,15 @@ int ospf6_intra_prefix_lsa_originate_stub(struct thread *thread)  			ospf6_lsa_purge(old);  			/* find previous LSA */  			old_next = ospf6_lsdb_lookup( -					htons(OSPF6_LSTYPE_INTRA_PREFIX), -					htonl(++ls_id), -					oa->ospf6->router_id, oa->lsdb); +				htons(OSPF6_LSTYPE_INTRA_PREFIX), +				htonl(++ls_id), oa->ospf6->router_id, oa->lsdb);  			while (old_next) {  				ospf6_lsa_purge(old_next);  				old_next = ospf6_lsdb_lookup(  					htons(OSPF6_LSTYPE_INTRA_PREFIX), -					htonl(++ls_id), -					oa->ospf6->router_id, oa->lsdb); +					htonl(++ls_id), oa->ospf6->router_id, +					oa->lsdb);  			}  		}  		return 0; @@ -945,7 +945,8 @@ int ospf6_intra_prefix_lsa_originate_stub(struct thread *thread)  	/* prepare buffer */  	memset(buffer, 0, sizeof(buffer));  	lsa_header = (struct ospf6_lsa_header *)buffer; -	intra_prefix_lsa = (struct ospf6_intra_prefix_lsa *)((caddr_t)lsa_header +	intra_prefix_lsa = (struct ospf6_intra_prefix_lsa +				    *)((caddr_t)lsa_header  				       + sizeof(struct ospf6_lsa_header));  	/* Fill Intra-Area-Prefix-LSA */ @@ -999,16 +1000,15 @@ int ospf6_intra_prefix_lsa_originate_stub(struct thread *thread)  			ospf6_lsa_purge(old);  			/* find previous LSA */  			old_next = ospf6_lsdb_lookup( -					htons(OSPF6_LSTYPE_INTRA_PREFIX), -					htonl(++ls_id), -					oa->ospf6->router_id, oa->lsdb); +				htons(OSPF6_LSTYPE_INTRA_PREFIX), +				htonl(++ls_id), oa->ospf6->router_id, oa->lsdb);  			while (old_next) {  				ospf6_lsa_purge(old_next);  				old_next = ospf6_lsdb_lookup(  					htons(OSPF6_LSTYPE_INTRA_PREFIX), -					htonl(++ls_id), -					oa->ospf6->router_id, oa->lsdb); +					htonl(++ls_id), oa->ospf6->router_id, +					oa->lsdb);  			}  		}  		ospf6_route_table_delete(route_advertise); @@ -1030,13 +1030,11 @@ int ospf6_intra_prefix_lsa_originate_stub(struct thread *thread)  			lsa_header->type = htons(OSPF6_LSTYPE_INTRA_PREFIX);  			lsa_header->id = htonl(ls_id++);  			lsa_header->adv_router = oa->ospf6->router_id; -			lsa_header->seqnum = -				ospf6_new_ls_seqnum(lsa_header->type, -						    lsa_header->id, -						    lsa_header->adv_router, -						    oa->lsdb); -			lsa_header->length = htons((caddr_t)op - -						   (caddr_t)lsa_header); +			lsa_header->seqnum = ospf6_new_ls_seqnum( +				lsa_header->type, lsa_header->id, +				lsa_header->adv_router, oa->lsdb); +			lsa_header->length = +				htons((caddr_t)op - (caddr_t)lsa_header);  			/* LSA checksum */  			ospf6_lsa_checksum(lsa_header); @@ -1050,9 +1048,10 @@ int ospf6_intra_prefix_lsa_originate_stub(struct thread *thread)  			/* Prepare next buffer */  			memset(buffer, 0, sizeof(buffer));  			lsa_header = (struct ospf6_lsa_header *)buffer; -			intra_prefix_lsa = (struct ospf6_intra_prefix_lsa *) -					((caddr_t)lsa_header -				       + sizeof(struct ospf6_lsa_header)); +			intra_prefix_lsa = +				(struct ospf6_intra_prefix_lsa +					 *)((caddr_t)lsa_header +					    + sizeof(struct ospf6_lsa_header));  			/* Fill Intra-Area-Prefix-LSA */  			intra_prefix_lsa->ref_type = htons(OSPF6_LSTYPE_ROUTER); @@ -1061,8 +1060,10 @@ int ospf6_intra_prefix_lsa_originate_stub(struct thread *thread)  			/* Put next set of prefixes to advertise */  			prefix_num = 0; -			op = (struct ospf6_prefix *)((caddr_t)intra_prefix_lsa -				     + sizeof(struct ospf6_intra_prefix_lsa)); +			op = (struct ospf6_prefix +				      *)((caddr_t)intra_prefix_lsa +					 + sizeof(struct +						  ospf6_intra_prefix_lsa));  		}  		op->prefix_length = route->prefix.prefixlen; @@ -1740,32 +1741,29 @@ void ospf6_intra_brouter_calculation(struct ospf6_area *oa)  			  oa->name);  } -struct ospf6_lsa_handler router_handler = { -	.lh_type = OSPF6_LSTYPE_ROUTER, -	.lh_name = "Router", -	.lh_short_name = "Rtr", -	.lh_show = ospf6_router_lsa_show, -	.lh_get_prefix_str = ospf6_router_lsa_get_nbr_id, -	.lh_debug = 0 -}; - -struct ospf6_lsa_handler network_handler = { -	.lh_type = OSPF6_LSTYPE_NETWORK, -	.lh_name = "Network", -	.lh_short_name = "Net", -	.lh_show = ospf6_network_lsa_show, -	.lh_get_prefix_str = ospf6_network_lsa_get_ar_id, -	.lh_debug = 0 -}; - -struct ospf6_lsa_handler link_handler = { -	.lh_type = OSPF6_LSTYPE_LINK, -	.lh_name = "Link", -	.lh_short_name = "Lnk", -	.lh_show = ospf6_link_lsa_show, -	.lh_get_prefix_str = ospf6_link_lsa_get_prefix_str, -	.lh_debug = 0 -}; +struct ospf6_lsa_handler router_handler = {.lh_type = OSPF6_LSTYPE_ROUTER, +					   .lh_name = "Router", +					   .lh_short_name = "Rtr", +					   .lh_show = ospf6_router_lsa_show, +					   .lh_get_prefix_str = +						   ospf6_router_lsa_get_nbr_id, +					   .lh_debug = 0}; + +struct ospf6_lsa_handler network_handler = {.lh_type = OSPF6_LSTYPE_NETWORK, +					    .lh_name = "Network", +					    .lh_short_name = "Net", +					    .lh_show = ospf6_network_lsa_show, +					    .lh_get_prefix_str = +						    ospf6_network_lsa_get_ar_id, +					    .lh_debug = 0}; + +struct ospf6_lsa_handler link_handler = {.lh_type = OSPF6_LSTYPE_LINK, +					 .lh_name = "Link", +					 .lh_short_name = "Lnk", +					 .lh_show = ospf6_link_lsa_show, +					 .lh_get_prefix_str = +						 ospf6_link_lsa_get_prefix_str, +					 .lh_debug = 0};  struct ospf6_lsa_handler intra_prefix_handler = {  	.lh_type = OSPF6_LSTYPE_INTRA_PREFIX, @@ -1773,8 +1771,7 @@ struct ospf6_lsa_handler intra_prefix_handler = {  	.lh_short_name = "INP",  	.lh_show = ospf6_intra_prefix_lsa_show,  	.lh_get_prefix_str = ospf6_intra_prefix_lsa_get_prefix_str, -	.lh_debug = 0 -}; +	.lh_debug = 0};  void ospf6_intra_init(void)  { diff --git a/ospf6d/ospf6_intra.h b/ospf6d/ospf6_intra.h index 2ae17f0700..07f0f124ec 100644 --- a/ospf6d/ospf6_intra.h +++ b/ospf6d/ospf6_intra.h @@ -185,13 +185,11 @@ struct ospf6_intra_prefix_lsa {  				0, &(oi)->thread_intra_prefix_lsa);            \  	} while (0) -#define OSPF6_AS_EXTERN_LSA_SCHEDULE(oi)				       \ +#define OSPF6_AS_EXTERN_LSA_SCHEDULE(oi)                                       \  	do {                                                                   \  		if (!CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE))          \ -			thread_add_event(                                      \ -				master,                                        \ -				ospf6_orig_as_external_lsa, oi,		       \ -				0, &(oi)->thread_as_extern_lsa);               \ +			thread_add_event(master, ospf6_orig_as_external_lsa,   \ +					 oi, 0, &(oi)->thread_as_extern_lsa);  \  	} while (0)  #define OSPF6_NETWORK_LSA_EXECUTE(oi)                                          \ diff --git a/ospf6d/ospf6_lsa.c b/ospf6d/ospf6_lsa.c index 4a1ba992e3..e060879f4b 100644 --- a/ospf6d/ospf6_lsa.c +++ b/ospf6d/ospf6_lsa.c @@ -518,9 +518,8 @@ struct ospf6_lsa *ospf6_lsa_create(struct ospf6_lsa_header *header)  	lsa_size = ntohs(header->length); /* XXX vulnerable */  	/* allocate memory for this LSA */ -	new_header = -		(struct ospf6_lsa_header *)XMALLOC(MTYPE_OSPF6_LSA_HEADER, -						   lsa_size); +	new_header = (struct ospf6_lsa_header *)XMALLOC(MTYPE_OSPF6_LSA_HEADER, +							lsa_size);  	/* copy LSA from original header */  	memcpy(new_header, header, lsa_size); @@ -717,8 +716,8 @@ void ospf6_flush_self_originated_lsas_now(void)  	ospf6->inst_shutdown = 1;  	for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, node, oa)) { -		end = ospf6_lsdb_head(oa->lsdb_self, 0, 0, -				      ospf6->router_id, &lsa); +		end = ospf6_lsdb_head(oa->lsdb_self, 0, 0, ospf6->router_id, +				      &lsa);  		while (lsa) {  			/* RFC 2328 (14.1):  Set MAXAGE */  			lsa->header->age = htons(OSPF_LSA_MAXAGE); @@ -786,7 +785,8 @@ static char *ospf6_lsa_handler_name(const struct ospf6_lsa_handler *h)  	unsigned int i;  	unsigned int size = strlen(h->lh_name); -	if (!strcmp(h->lh_name, "unknown") && h->lh_type != OSPF6_LSTYPE_UNKNOWN) { +	if (!strcmp(h->lh_name, "unknown") +	    && h->lh_type != OSPF6_LSTYPE_UNKNOWN) {  		snprintf(buf, sizeof(buf), "%#04hx", h->lh_type);  		return buf;  	} diff --git a/ospf6d/ospf6_lsa.h b/ospf6d/ospf6_lsa.h index 369b381faa..4bf56a8c1e 100644 --- a/ospf6d/ospf6_lsa.h +++ b/ospf6d/ospf6_lsa.h @@ -142,8 +142,8 @@ struct ospf6_lsa_handler {  		const char *name;  		const char *short_name;  		int (*show)(struct vty *, struct ospf6_lsa *); -		char *(*get_prefix_str)(struct ospf6_lsa *, char *buf, int buflen, -					int pos); +		char *(*get_prefix_str)(struct ospf6_lsa *, char *buf, +					int buflen, int pos);  	} s;  #define lh_type       s.type  #define lh_name       s.name diff --git a/ospf6d/ospf6_lsdb.c b/ospf6d/ospf6_lsdb.c index 152702391b..f17b558e8b 100644 --- a/ospf6d/ospf6_lsdb.c +++ b/ospf6d/ospf6_lsdb.c @@ -392,8 +392,7 @@ void ospf6_lsdb_show(struct vty *vty, enum ospf_lsdb_show_level level,  		ospf6_lsa_show_summary_header(vty);  	end = ospf6_lsdb_head(lsdb, !!type + !!(type && adv_router), -			      type ? *type : 0, -			      adv_router ? *adv_router : 0, +			      type ? *type : 0, adv_router ? *adv_router : 0,  			      &lsa);  	while (lsa) {  		if ((!adv_router || lsa->header->adv_router == *adv_router) diff --git a/ospf6d/ospf6_message.c b/ospf6d/ospf6_message.c index fe74ddc982..b75d5b70fa 100644 --- a/ospf6d/ospf6_message.c +++ b/ospf6d/ospf6_message.c @@ -1997,9 +1997,9 @@ static void ospf6_send_lsupdate(struct ospf6_neighbor *on,  	if (on) {  		on->ospf6_if->ls_upd_out++; -		if ((on->ospf6_if->state == OSPF6_INTERFACE_POINTTOPOINT) || -		    (on->ospf6_if->state == OSPF6_INTERFACE_DR) || -		    (on->ospf6_if->state == OSPF6_INTERFACE_BDR)) { +		if ((on->ospf6_if->state == OSPF6_INTERFACE_POINTTOPOINT) +		    || (on->ospf6_if->state == OSPF6_INTERFACE_DR) +		    || (on->ospf6_if->state == OSPF6_INTERFACE_BDR)) {  			ospf6_send(on->ospf6_if->linklocal_addr,  				   &allspfrouters6, on->ospf6_if, oh);  		} else { @@ -2010,9 +2010,9 @@ static void ospf6_send_lsupdate(struct ospf6_neighbor *on,  		oi->ls_upd_out++; -		if ((oi->state == OSPF6_INTERFACE_POINTTOPOINT) || -		    (oi->state == OSPF6_INTERFACE_DR) || -		    (oi->state == OSPF6_INTERFACE_BDR)) { +		if ((oi->state == OSPF6_INTERFACE_POINTTOPOINT) +		    || (oi->state == OSPF6_INTERFACE_DR) +		    || (oi->state == OSPF6_INTERFACE_BDR)) {  			ospf6_send(oi->linklocal_addr, &allspfrouters6, oi, oh);  		} else {  			ospf6_send(oi->linklocal_addr, &alldrouters6, oi, oh); @@ -2065,8 +2065,10 @@ int ospf6_lsupdate_send_neighbor(struct thread *thread)  				memset(sendbuf, 0, iobuflen);  				oh = (struct ospf6_header *)sendbuf; -				lsupdate = (struct ospf6_lsupdate *)((caddr_t)oh -					     + sizeof(struct ospf6_header)); +				lsupdate = (struct ospf6_lsupdate +						    *)((caddr_t)oh +						       + sizeof(struct +								ospf6_header));  				p = (u_char *)((caddr_t)lsupdate  					       + sizeof(struct ospf6_lsupdate)); @@ -2110,8 +2112,8 @@ int ospf6_lsupdate_send_neighbor(struct thread *thread)  				oh->length = htons(p - sendbuf);  				lsupdate->lsa_number = htonl(lsa_cnt); -				if (on->ospf6_if->state == -				    OSPF6_INTERFACE_POINTTOPOINT) { +				if (on->ospf6_if->state +				    == OSPF6_INTERFACE_POINTTOPOINT) {  					ospf6_send(on->ospf6_if->linklocal_addr,  						   &allspfrouters6,  						   on->ospf6_if, oh); @@ -2123,10 +2125,12 @@ int ospf6_lsupdate_send_neighbor(struct thread *thread)  				memset(sendbuf, 0, iobuflen);  				oh = (struct ospf6_header *)sendbuf; -				lsupdate = (struct ospf6_lsupdate *)((caddr_t)oh -					     + sizeof(struct ospf6_header)); -				p = (u_char *)((caddr_t)lsupdate + -					       sizeof(struct ospf6_lsupdate)); +				lsupdate = (struct ospf6_lsupdate +						    *)((caddr_t)oh +						       + sizeof(struct +								ospf6_header)); +				p = (u_char *)((caddr_t)lsupdate +					       + sizeof(struct ospf6_lsupdate));  				lsa_cnt = 0;  			}  		} @@ -2186,11 +2190,11 @@ int ospf6_lsupdate_send_neighbor_now(struct ospf6_neighbor *on,  	oh->length = htons(p - sendbuf);  	lsupdate->lsa_number = htonl(lsa_cnt); -	if (IS_OSPF6_DEBUG_FLOODING || -	    IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_LSUPDATE, SEND)) +	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)); +			   __PRETTY_FUNCTION__, lsa->name, +			   ntohs(lsa->header->age));  	ospf6_send_lsupdate(on, NULL, oh); @@ -2241,18 +2245,20 @@ int ospf6_lsupdate_send_interface(struct thread *thread)  				ospf6_send_lsupdate(NULL, oi, oh);  				if (IS_OSPF6_DEBUG_MESSAGE( -					OSPF6_MESSAGE_TYPE_LSUPDATE, SEND)) +					    OSPF6_MESSAGE_TYPE_LSUPDATE, SEND))  					zlog_debug("%s: LSUpdate length %d",  						   __PRETTY_FUNCTION__,  						   ntohs(oh->length));  				memset(sendbuf, 0, iobuflen);  				oh = (struct ospf6_header *)sendbuf; -				lsupdate = (struct ospf6_lsupdate *)((caddr_t)oh -						+ sizeof(struct ospf6_header)); +				lsupdate = (struct ospf6_lsupdate +						    *)((caddr_t)oh +						       + sizeof(struct +								ospf6_header));  				p = (u_char *)((caddr_t)lsupdate -					+ sizeof(struct ospf6_lsupdate)); +					       + sizeof(struct ospf6_lsupdate));  				lsa_cnt = 0;  			}  		} @@ -2324,13 +2330,13 @@ int ospf6_lsack_send_neighbor(struct thread *thread)  				on->ospf6_if->ls_ack_out++;  				ospf6_send(on->ospf6_if->linklocal_addr, -					   &on->linklocal_addr, -					   on->ospf6_if, oh); +					   &on->linklocal_addr, on->ospf6_if, +					   oh);  				memset(sendbuf, 0, iobuflen);  				oh = (struct ospf6_header *)sendbuf; -				p = (u_char *)((caddr_t)oh + -					       sizeof(struct ospf6_header)); +				p = (u_char *)((caddr_t)oh +					       + sizeof(struct ospf6_header));  				lsa_cnt = 0;  			}  		} diff --git a/ospf6d/ospf6_neighbor.c b/ospf6d/ospf6_neighbor.c index 05bc254951..542a24bfc9 100644 --- a/ospf6d/ospf6_neighbor.c +++ b/ospf6d/ospf6_neighbor.c @@ -190,8 +190,8 @@ static void ospf6_neighbor_state_change(u_char next_state,  		}  		OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(on->ospf6_if->area); -		if (prev_state == OSPF6_NEIGHBOR_LOADING && -		    next_state == OSPF6_NEIGHBOR_FULL) { +		if (prev_state == OSPF6_NEIGHBOR_LOADING +		    && next_state == OSPF6_NEIGHBOR_FULL) {  			OSPF6_AS_EXTERN_LSA_SCHEDULE(on->ospf6_if);  			on->ospf6_if->area->full_nbrs++;  		} diff --git a/ospf6d/ospf6_route.c b/ospf6d/ospf6_route.c index ef0a093d13..5b36f6300a 100644 --- a/ospf6d/ospf6_route.c +++ b/ospf6d/ospf6_route.c @@ -377,7 +377,7 @@ struct ospf6_path *ospf6_path_dup(struct ospf6_path *path)  	memcpy(new, path, sizeof(struct ospf6_path));  	new->nh_list = list_new();  	new->nh_list->cmp = (int (*)(void *, void *))ospf6_nexthop_cmp; -	new->nh_list->del = (void (*) (void *))ospf6_nexthop_delete; +	new->nh_list->del = (void (*)(void *))ospf6_nexthop_delete;  	return new;  } @@ -388,10 +388,10 @@ struct ospf6_route *ospf6_route_create(void)  	route = XCALLOC(MTYPE_OSPF6_ROUTE, sizeof(struct ospf6_route));  	route->nh_list = list_new();  	route->nh_list->cmp = (int (*)(void *, void *))ospf6_nexthop_cmp; -	route->nh_list->del = (void (*) (void *))ospf6_nexthop_delete; +	route->nh_list->del = (void (*)(void *))ospf6_nexthop_delete;  	route->paths = list_new();  	route->paths->cmp = (int (*)(void *, void *))ospf6_path_cmp; -	route->paths->del =  (void (*)(void *))ospf6_path_free; +	route->paths->del = (void (*)(void *))ospf6_path_free;  	return route;  } @@ -502,13 +502,14 @@ ospf6_route_lookup_identical(struct ospf6_route *route,  	for (target = ospf6_route_lookup(&route->prefix, table); target;  	     target = target->next) { -		if (target->type == route->type && -		    (memcmp(&target->prefix, &route->prefix, -			   sizeof(struct prefix)) == 0) && -		    target->path.type == route->path.type && -		    target->path.cost == route->path.cost && -		    target->path.u.cost_e2 == route->path.u.cost_e2 && -		    ospf6_route_cmp_nexthops(target, route) == 0) +		if (target->type == route->type +		    && (memcmp(&target->prefix, &route->prefix, +			       sizeof(struct prefix)) +			== 0) +		    && target->path.type == route->path.type +		    && target->path.cost == route->path.cost +		    && target->path.u.cost_e2 == route->path.u.cost_e2 +		    && ospf6_route_cmp_nexthops(target, route) == 0)  			return target;  	}  	return NULL; @@ -647,10 +648,11 @@ struct ospf6_route *ospf6_route_add(struct ospf6_route *route,  		}  		if (IS_OSPF6_DEBUG_ROUTE(MEMORY)) -			zlog_debug("%s %p: route add %p cost %u: update of %p old cost %u", -				   ospf6_route_table_name(table), (void *)table, -				   (void *)route, route->path.cost, (void *)old, -				   old->path.cost); +			zlog_debug( +				"%s %p: route add %p cost %u: update of %p old cost %u", +				ospf6_route_table_name(table), (void *)table, +				(void *)route, route->path.cost, (void *)old, +				old->path.cost);  		else if (IS_OSPF6_DEBUG_ROUTE(TABLE))  			zlog_debug("%s: route add: update",  				   ospf6_route_table_name(table)); diff --git a/ospf6d/ospf6_snmp.c b/ospf6d/ospf6_snmp.c index a448645960..ed1d8bee7d 100644 --- a/ospf6d/ospf6_snmp.c +++ b/ospf6d/ospf6_snmp.c @@ -914,7 +914,7 @@ static u_char *ospfv3WwLsdbEntry(struct variable *v, oid *name, size_t *length,  	if (len)  		id = htonl(*offset);  	offset += len; -	//offsetlen -= len;  // Add back in if we need it again +	// offsetlen -= len;  // Add back in if we need it again  	if (exact) {  		if (v->magic & OSPFv3WWASTABLE) { @@ -1080,8 +1080,8 @@ static u_char *ospfv3IfEntry(struct variable *v, oid *name, size_t *length,  	len = (offsetlen < 1 ? 0 : 1);  	if (len)  		instid = *offset; -	//offset += len; // Add back in if we ever start using again -	//offsetlen -= len; +	// offset += len; // Add back in if we ever start using again +	// offsetlen -= len;  	if (exact) {  		oi = ospf6_interface_lookup_by_ifindex(ifindex); @@ -1241,8 +1241,8 @@ static u_char *ospfv3NbrEntry(struct variable *v, oid *name, size_t *length,  	len = (offsetlen < 1 ? 0 : 1);  	if (len)  		rtrid = htonl(*offset); -	//offset += len; // Add back in if we ever start looking at data -	//offsetlen -= len; +	// offset += len; // Add back in if we ever start looking at data +	// offsetlen -= len;  	if (exact) {  		oi = ospf6_interface_lookup_by_ifindex(ifindex); diff --git a/ospf6d/ospf6_spf.c b/ospf6d/ospf6_spf.c index 29ba1bcec7..8d32f3505e 100644 --- a/ospf6d/ospf6_spf.c +++ b/ospf6d/ospf6_spf.c @@ -114,12 +114,12 @@ static struct ospf6_vertex *ospf6_vertex_create(struct ospf6_lsa *lsa)  		v->type = OSPF6_VERTEX_TYPE_ROUTER;  		/* Router LSA use Link ID 0 as base in vertex_id */  		ospf6_linkstate_prefix(lsa->header->adv_router, htonl(0), -			       &v->vertex_id); +				       &v->vertex_id);  	} else if (ntohs(lsa->header->type) == OSPF6_LSTYPE_NETWORK) {  		v->type = OSPF6_VERTEX_TYPE_NETWORK;  		/* vertex_id */  		ospf6_linkstate_prefix(lsa->header->adv_router, lsa->header->id, -			       &v->vertex_id); +				       &v->vertex_id);  	} else  		assert(0); @@ -131,8 +131,8 @@ static struct ospf6_vertex *ospf6_vertex_create(struct ospf6_lsa *lsa)  			   __func__, v->name,  			   ((ntohs(lsa->header->type) == OSPF6_LSTYPE_ROUTER)  				    ? "Router" -				    : "N/W"), ntohs(lsa->header->type), -			   lsa->name); +				    : "N/W"), +			   ntohs(lsa->header->type), lsa->name);  	/* Associated LSA */ @@ -146,7 +146,7 @@ static struct ospf6_vertex *ospf6_vertex_create(struct ospf6_lsa *lsa)  	v->nh_list = list_new();  	v->nh_list->cmp = (int (*)(void *, void *))ospf6_nexthop_cmp; -	v->nh_list->del = (void (*) (void *))ospf6_nexthop_delete; +	v->nh_list->del = (void (*)(void *))ospf6_nexthop_delete;  	v->parent = NULL;  	v->child_list = list_new(); @@ -335,28 +335,29 @@ static int ospf6_spf_install(struct ospf6_vertex *v,  	} else if (route && route->path.cost == v->cost) {  		if (IS_OSPF6_DEBUG_SPF(PROCESS)) {  			prefix2str(&route->prefix, pbuf, sizeof(pbuf)); -			zlog_debug("  another path found to route %s lsa %s, merge", -				   pbuf, v->lsa->name); +			zlog_debug( +				"  another path found to route %s lsa %s, merge", +				pbuf, v->lsa->name);  		}  		ospf6_spf_merge_nexthops_to_route(route, v);  		prev = (struct ospf6_vertex *)route->route_option;  		assert(prev->hops <= v->hops); -		if ((VERTEX_IS_TYPE(ROUTER, v) && -		    route->path.origin.id != v->lsa->header->id)) { +		if ((VERTEX_IS_TYPE(ROUTER, v) +		     && route->path.origin.id != v->lsa->header->id)) {  			if (IS_OSPF6_DEBUG_SPF(PROCESS)) { -				zlog_debug("%s: V lsa %s id %u, route id %u are different", -				   __PRETTY_FUNCTION__, v->lsa->name, -				   ntohl(v->lsa->header->id), -				   ntohl(route->path.origin.id)); +				zlog_debug( +					"%s: V lsa %s id %u, route id %u are different", +					__PRETTY_FUNCTION__, v->lsa->name, +					ntohl(v->lsa->header->id), +					ntohl(route->path.origin.id));  			}  			return 0;  		}  		ospf6_vertex_delete(v);  		return -1; -  	}  	/* There should be no case where candidate being installed (variable @@ -554,7 +555,7 @@ void ospf6_spf_calculation(u_int32_t router_id,  			if (IS_OSPF6_DEBUG_SPF(PROCESS))  				zlog_debug(  					"  New candidate: %s hops %d cost %d", -						w->name, w->hops, w->cost); +					w->name, w->hops, w->cost);  			pqueue_enqueue(w, candidate_list);  		}  	} @@ -970,8 +971,8 @@ struct ospf6_lsa *ospf6_create_single_router_lsa(struct ospf6_area *area,  	uint32_t interface_id;  	caddr_t lsd; -	lsa_length = sizeof(struct ospf6_lsa_header) + -				sizeof(struct ospf6_router_lsa); +	lsa_length = sizeof(struct ospf6_lsa_header) +		     + sizeof(struct ospf6_router_lsa);  	total_lsa_length = lsa_length;  	type = htons(OSPF6_LSTYPE_ROUTER); @@ -991,15 +992,14 @@ struct ospf6_lsa *ospf6_create_single_router_lsa(struct ospf6_area *area,  			rtr_lsa = ospf6_lsdb_next(end, rtr_lsa);  			continue;  		} -		lsa_header = (struct ospf6_lsa_header *) rtr_lsa->header; -		total_lsa_length += (ntohs(lsa_header->length) -				     - lsa_length); +		lsa_header = (struct ospf6_lsa_header *)rtr_lsa->header; +		total_lsa_length += (ntohs(lsa_header->length) - lsa_length);  		num_lsa++;  		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); +			   __PRETTY_FUNCTION__, ifbuf, num_lsa);  	if (num_lsa == 1)  		return lsa; @@ -1060,13 +1060,14 @@ struct ospf6_lsa *ospf6_create_single_router_lsa(struct ospf6_area *area,  			lsd = OSPF6_LSA_HEADER_END(rtr_lsa->header) + 4;  			interface_id = ROUTER_LSDESC_GET_IFID(lsd);  			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, -				   ntohs(lsa_header->length), ifbuf); +			zlog_debug( +				"%s: Next Router LSA %s to aggreat with len %u interface_id %s", +				__PRETTY_FUNCTION__, rtr_lsa->name, +				ntohs(lsa_header->length), ifbuf);  		}  		/* Append Next Link State ID LSA */ -		lsa_header = (struct ospf6_lsa_header *) rtr_lsa->header; +		lsa_header = (struct ospf6_lsa_header *)rtr_lsa->header;  		memcpy(new_header, (OSPF6_LSA_HEADER_END(rtr_lsa->header) + 4),  		       (ntohs(lsa_header->length) - lsa_length));  		new_header += (ntohs(lsa_header->length) - lsa_length); @@ -1096,10 +1097,10 @@ void ospf6_remove_temp_router_lsa(struct ospf6_area *area)  	for (ALL_LSDB(area->temp_router_lsa_lsdb, lsa)) {  		if (IS_OSPF6_DEBUG_SPF(PROCESS)) -			zlog_debug("%s Remove LSA %s lsa->lock %u lsdb count %u", -				   __PRETTY_FUNCTION__, -				   lsa->name, lsa->lock, -				   area->temp_router_lsa_lsdb->count); +			zlog_debug( +				"%s Remove LSA %s lsa->lock %u lsdb count %u", +				__PRETTY_FUNCTION__, 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 afe2d7397b..2e14425752 100644 --- a/ospf6d/ospf6_top.c +++ b/ospf6d/ospf6_top.c @@ -403,21 +403,15 @@ DEFUN(no_ospf6_router_id,  #if CONFDATE > 20180828  CPP_NOTICE("ospf6: `router-id A.B.C.D` deprecated 2017/08/28")  #endif -ALIAS_HIDDEN(ospf6_router_id, -	     ospf6_router_id_hdn_cmd, -	     "router-id A.B.C.D", -	     "Configure OSPF6 Router-ID\n" -	     V4NOTATION_STR) +ALIAS_HIDDEN(ospf6_router_id, ospf6_router_id_hdn_cmd, "router-id A.B.C.D", +	     "Configure OSPF6 Router-ID\n" V4NOTATION_STR)  #if CONFDATE > 20180828  CPP_NOTICE("ospf6: `no router-id A.B.C.D` deprecated 2017/08/28")  #endif -ALIAS_HIDDEN(no_ospf6_router_id, -	     no_ospf6_router_id_hdn_cmd, +ALIAS_HIDDEN(no_ospf6_router_id, no_ospf6_router_id_hdn_cmd,  	     "no router-id [A.B.C.D]", -	     NO_STR -	     "Configure OSPF6 Router-ID\n" -	     V4NOTATION_STR) +	     NO_STR "Configure OSPF6 Router-ID\n" V4NOTATION_STR)  DEFUN (ospf6_log_adjacency_changes,         ospf6_log_adjacency_changes_cmd, diff --git a/ospf6d/ospf6d.c b/ospf6d/ospf6d.c index bbc1cc18f6..58a39156da 100644 --- a/ospf6d/ospf6d.c +++ b/ospf6d/ospf6d.c @@ -387,8 +387,8 @@ DEFUN_HIDDEN (show_ipv6_ospf6_database_aggr_router,  			lsdb = oa->lsdb_self;  		else  			lsdb = oa->lsdb; -		if (ospf6_create_single_router_lsa(oa, lsdb, -						   adv_router) == NULL) { +		if (ospf6_create_single_router_lsa(oa, lsdb, adv_router) +		    == NULL) {  			vty_out(vty, "Adv router is not found in LSDB.");  			return CMD_SUCCESS;  		} diff --git a/ospfd/ospf_abr.c b/ospfd/ospf_abr.c index ea94bab6b3..b29f35d7ce 100644 --- a/ospfd/ospf_abr.c +++ b/ospfd/ospf_abr.c @@ -976,7 +976,7 @@ static void ospf_abr_process_nssa_translates(struct ospf *ospf)  				"looking at area %s",  				inet_ntoa(area->area_id)); -		LSDB_LOOP(NSSA_LSDB(area), rn, lsa) +		LSDB_LOOP (NSSA_LSDB(area), rn, lsa)  			ospf_abr_translate_nssa(area, lsa);  	} @@ -1323,7 +1323,7 @@ ospf_abr_unapprove_translates(struct ospf *ospf) /* For NSSA Translations */  	/* NSSA Translator is not checked, because it may have gone away,  	  and we would want to flush any residuals anyway */ -	LSDB_LOOP(EXTERNAL_LSDB(ospf), rn, lsa) +	LSDB_LOOP (EXTERNAL_LSDB(ospf), rn, lsa)  		if (CHECK_FLAG(lsa->flags, OSPF_LSA_LOCAL_XLT)) {  			UNSET_FLAG(lsa->flags, OSPF_LSA_APPROVED);  			if (IS_DEBUG_OSPF_NSSA) @@ -1353,7 +1353,7 @@ static void ospf_abr_unapprove_summaries(struct ospf *ospf)  				"ospf_abr_unapprove_summaries(): "  				"considering area %s",  				inet_ntoa(area->area_id)); -		LSDB_LOOP(SUMMARY_LSDB(area), rn, lsa) +		LSDB_LOOP (SUMMARY_LSDB(area), rn, lsa)  			if (ospf_lsa_is_self_originated(ospf, lsa)) {  				if (IS_DEBUG_OSPF_EVENT)  					zlog_debug( @@ -1363,7 +1363,7 @@ static void ospf_abr_unapprove_summaries(struct ospf *ospf)  				UNSET_FLAG(lsa->flags, OSPF_LSA_APPROVED);  			} -		LSDB_LOOP(ASBR_SUMMARY_LSDB(area), rn, lsa) +		LSDB_LOOP (ASBR_SUMMARY_LSDB(area), rn, lsa)  			if (ospf_lsa_is_self_originated(ospf, lsa)) {  				if (IS_DEBUG_OSPF_EVENT)  					zlog_debug( @@ -1631,7 +1631,7 @@ static void ospf_abr_remove_unapproved_translates(struct ospf *ospf)  	if (IS_DEBUG_OSPF_NSSA)  		zlog_debug("ospf_abr_remove_unapproved_translates(): Start"); -	LSDB_LOOP(EXTERNAL_LSDB(ospf), rn, lsa) +	LSDB_LOOP (EXTERNAL_LSDB(ospf), rn, lsa)  		ospf_abr_remove_unapproved_translates_apply(ospf, lsa);  	if (IS_DEBUG_OSPF_NSSA) @@ -1655,12 +1655,12 @@ static void ospf_abr_remove_unapproved_summaries(struct ospf *ospf)  				"looking at area %s",  				inet_ntoa(area->area_id)); -		LSDB_LOOP(SUMMARY_LSDB(area), rn, lsa) +		LSDB_LOOP (SUMMARY_LSDB(area), rn, lsa)  			if (ospf_lsa_is_self_originated(ospf, lsa))  				if (!CHECK_FLAG(lsa->flags, OSPF_LSA_APPROVED))  					ospf_lsa_flush_area(lsa, area); -		LSDB_LOOP(ASBR_SUMMARY_LSDB(area), rn, lsa) +		LSDB_LOOP (ASBR_SUMMARY_LSDB(area), rn, lsa)  			if (ospf_lsa_is_self_originated(ospf, lsa))  				if (!CHECK_FLAG(lsa->flags, OSPF_LSA_APPROVED))  					ospf_lsa_flush_area(lsa, area); @@ -1683,13 +1683,14 @@ static void ospf_abr_manage_discard_routes(struct ospf *ospf)  				if (CHECK_FLAG(range->flags,  					       OSPF_AREA_RANGE_ADVERTISE)) {  					if (range->specifics) -						ospf_add_discard_route(ospf, -							ospf->new_table, area, +						ospf_add_discard_route( +							ospf, ospf->new_table, +							area,  							(struct prefix_ipv4  								 *)&rn->p);  					else -						ospf_delete_discard_route(ospf, -							ospf->new_table, +						ospf_delete_discard_route( +							ospf, ospf->new_table,  							(struct prefix_ipv4  								 *)&rn->p);  				} diff --git a/ospfd/ospf_api.h b/ospfd/ospf_api.h index 526e8228ff..7b055db12b 100644 --- a/ospfd/ospf_api.h +++ b/ospfd/ospf_api.h @@ -154,8 +154,6 @@ static const u_int16_t Power2[] = {  struct lsa_filter_type {  	u_int16_t typemask; /* bitmask for selecting LSA types (1..16) */  	u_char origin;      /* selects according to origin. */ -			    /* $FRR indent$ */ -			    /* clang-format off */  #define NON_SELF_ORIGINATED	0  #define	SELF_ORIGINATED  (OSPF_LSA_SELF)  #define	ANY_ORIGIN 2 diff --git a/ospfd/ospf_apiserver.c b/ospfd/ospf_apiserver.c index 9ebaeffa69..36bd49125b 100644 --- a/ospfd/ospf_apiserver.c +++ b/ospfd/ospf_apiserver.c @@ -1312,27 +1312,27 @@ int ospf_apiserver_handle_sync_lsdb(struct ospf_apiserver *apiserv,  		if (i) {  			/* Check msg type. */  			if (mask & Power2[OSPF_ROUTER_LSA]) -				LSDB_LOOP(ROUTER_LSDB(area), rn, lsa) +				LSDB_LOOP (ROUTER_LSDB(area), rn, lsa)  					apiserver_sync_callback(  						lsa, (void *)¶m, seqnum);  			if (mask & Power2[OSPF_NETWORK_LSA]) -				LSDB_LOOP(NETWORK_LSDB(area), rn, lsa) +				LSDB_LOOP (NETWORK_LSDB(area), rn, lsa)  					apiserver_sync_callback(  						lsa, (void *)¶m, seqnum);  			if (mask & Power2[OSPF_SUMMARY_LSA]) -				LSDB_LOOP(SUMMARY_LSDB(area), rn, lsa) +				LSDB_LOOP (SUMMARY_LSDB(area), rn, lsa)  					apiserver_sync_callback(  						lsa, (void *)¶m, seqnum);  			if (mask & Power2[OSPF_ASBR_SUMMARY_LSA]) -				LSDB_LOOP(ASBR_SUMMARY_LSDB(area), rn, lsa) +				LSDB_LOOP (ASBR_SUMMARY_LSDB(area), rn, lsa)  					apiserver_sync_callback(  						lsa, (void *)¶m, seqnum);  			if (mask & Power2[OSPF_OPAQUE_LINK_LSA]) -				LSDB_LOOP(OPAQUE_LINK_LSDB(area), rn, lsa) +				LSDB_LOOP (OPAQUE_LINK_LSDB(area), rn, lsa)  					apiserver_sync_callback(  						lsa, (void *)¶m, seqnum);  			if (mask & Power2[OSPF_OPAQUE_AREA_LSA]) -				LSDB_LOOP(OPAQUE_AREA_LSDB(area), rn, lsa) +				LSDB_LOOP (OPAQUE_AREA_LSDB(area), rn, lsa)  					apiserver_sync_callback(  						lsa, (void *)¶m, seqnum);  		} @@ -1341,7 +1341,7 @@ int ospf_apiserver_handle_sync_lsdb(struct ospf_apiserver *apiserv,  	/* For AS-external LSAs */  	if (ospf->lsdb) {  		if (mask & Power2[OSPF_AS_EXTERNAL_LSA]) -			LSDB_LOOP(EXTERNAL_LSDB(ospf), rn, lsa) +			LSDB_LOOP (EXTERNAL_LSDB(ospf), rn, lsa)  				apiserver_sync_callback(lsa, (void *)¶m,  							seqnum);  	} @@ -1349,7 +1349,7 @@ int ospf_apiserver_handle_sync_lsdb(struct ospf_apiserver *apiserv,  	/* For AS-external opaque LSAs */  	if (ospf->lsdb) {  		if (mask & Power2[OSPF_OPAQUE_AS_LSA]) -			LSDB_LOOP(OPAQUE_AS_LSDB(ospf), rn, lsa) +			LSDB_LOOP (OPAQUE_AS_LSDB(ospf), rn, lsa)  				apiserver_sync_callback(lsa, (void *)¶m,  							seqnum);  	} @@ -1952,18 +1952,18 @@ void ospf_apiserver_flush_opaque_lsa(struct ospf_apiserver *apiserv,  	case OSPF_OPAQUE_LINK_LSA:  		for (ALL_LIST_ELEMENTS(ospf->areas, node, nnode, area)) -			LSDB_LOOP(OPAQUE_LINK_LSDB(area), rn, lsa) +			LSDB_LOOP (OPAQUE_LINK_LSDB(area), rn, lsa)  				apiserver_flush_opaque_type_callback(  					lsa, (void *)¶m, 0);  		break;  	case OSPF_OPAQUE_AREA_LSA:  		for (ALL_LIST_ELEMENTS(ospf->areas, node, nnode, area)) -			LSDB_LOOP(OPAQUE_AREA_LSDB(area), rn, lsa) +			LSDB_LOOP (OPAQUE_AREA_LSDB(area), rn, lsa)  				apiserver_flush_opaque_type_callback(  					lsa, (void *)¶m, 0);  		break;  	case OSPF_OPAQUE_AS_LSA: -		LSDB_LOOP(OPAQUE_LINK_LSDB(ospf), rn, lsa) +		LSDB_LOOP (OPAQUE_LINK_LSDB(ospf), rn, lsa)  			apiserver_flush_opaque_type_callback(lsa,  							     (void *)¶m, 0);  		break; diff --git a/ospfd/ospf_asbr.c b/ospfd/ospf_asbr.c index 33461e6df8..b970c1183a 100644 --- a/ospfd/ospf_asbr.c +++ b/ospfd/ospf_asbr.c @@ -58,9 +58,8 @@ void ospf_external_route_remove(struct ospf *ospf, struct prefix_ipv4 *p)  			/* Remove route from zebra. */  			if (or->type == OSPF_DESTINATION_NETWORK) -				ospf_zebra_delete(ospf, -						  (struct prefix_ipv4 *)&rn->p, -						  or); +				ospf_zebra_delete( +					ospf, (struct prefix_ipv4 *)&rn->p, or);  			ospf_route_free(or);  			rn->info = NULL; @@ -127,12 +126,10 @@ int ospf_route_map_set_compare(struct route_map_set_values *values1,  }  /* Add an External info for AS-external-LSA. */ -struct external_info *ospf_external_info_add(struct ospf *ospf, u_char type, -					     u_short instance, -					     struct prefix_ipv4 p, -					     ifindex_t ifindex, -					     struct in_addr nexthop, -					     route_tag_t tag) +struct external_info * +ospf_external_info_add(struct ospf *ospf, u_char type, u_short instance, +		       struct prefix_ipv4 p, ifindex_t ifindex, +		       struct in_addr nexthop, route_tag_t tag)  {  	struct external_info *new;  	struct route_node *rn; @@ -160,8 +157,8 @@ struct external_info *ospf_external_info_add(struct ospf *ospf, u_char type,  			zlog_warn(  				"Redistribute[%s][%d][%u]: %s/%d discarding old info with NH %s.",  				ospf_redist_string(type), instance, -				ospf->vrf_id, inet_ntoa(p.prefix), -				p.prefixlen, inetbuf); +				ospf->vrf_id, inet_ntoa(p.prefix), p.prefixlen, +				inetbuf);  			XFREE(MTYPE_OSPF_EXTERNAL_INFO, rn->info);  			rn->info = NULL;  		} diff --git a/ospfd/ospf_asbr.h b/ospfd/ospf_asbr.h index 38ed95322b..d437314c82 100644 --- a/ospfd/ospf_asbr.h +++ b/ospfd/ospf_asbr.h @@ -58,16 +58,14 @@ extern struct external_info *ospf_external_info_new(u_char, u_short);  extern void ospf_reset_route_map_set_values(struct route_map_set_values *);  extern int ospf_route_map_set_compare(struct route_map_set_values *,  				      struct route_map_set_values *); -extern struct external_info *ospf_external_info_add(struct ospf *, -						    u_char, u_short, -						    struct prefix_ipv4, +extern struct external_info *ospf_external_info_add(struct ospf *, u_char, +						    u_short, struct prefix_ipv4,  						    ifindex_t, struct in_addr,  						    route_tag_t); -extern void ospf_external_info_delete(struct ospf*, u_char, u_short, +extern void ospf_external_info_delete(struct ospf *, u_char, u_short,  				      struct prefix_ipv4); -extern struct external_info *ospf_external_info_lookup(struct ospf*, u_char, -						       u_short, -						       struct prefix_ipv4 *); +extern struct external_info * +ospf_external_info_lookup(struct ospf *, u_char, u_short, struct prefix_ipv4 *);  extern struct ospf_route *ospf_external_route_lookup(struct ospf *,  						     struct prefix_ipv4 *);  extern void ospf_asbr_status_update(struct ospf *, u_char); diff --git a/ospfd/ospf_ase.c b/ospfd/ospf_ase.c index d2af974833..0c2ddc9647 100644 --- a/ospfd/ospf_ase.c +++ b/ospfd/ospf_ase.c @@ -610,9 +610,8 @@ static int ospf_ase_compare_tables(struct ospf *ospf,  		if ((or = rn->info)) {  			if (!(new_rn = route_node_lookup(new_external_route,  							 &rn->p))) -				ospf_zebra_delete(ospf, -						  (struct prefix_ipv4 *)&rn->p, -						  or); +				ospf_zebra_delete( +					ospf, (struct prefix_ipv4 *)&rn->p, or);  			else  				route_unlock_node(new_rn);  		} @@ -623,9 +622,8 @@ static int ospf_ase_compare_tables(struct ospf *ospf,  		if ((or = rn->info) != NULL)  			if (!ospf_ase_route_match_same(old_external_route,  						       &rn->p, or)) -				ospf_zebra_add(ospf, -					       (struct prefix_ipv4 *)&rn->p, -					       or); +				ospf_zebra_add( +					ospf, (struct prefix_ipv4 *)&rn->p, or);  	return 0;  } @@ -648,7 +646,7 @@ static int ospf_ase_calculate_timer(struct thread *t)  		monotime(&start_time);  		/* Calculate external route for each AS-external-LSA */ -		LSDB_LOOP(EXTERNAL_LSDB(ospf), rn, lsa) +		LSDB_LOOP (EXTERNAL_LSDB(ospf), rn, lsa)  			ospf_ase_calculate_route(ospf, lsa);  		/*  This version simple adds to the table all NSSA areas  */ @@ -660,12 +658,12 @@ static int ospf_ase_calculate_timer(struct thread *t)  						inet_ntoa(area->area_id));  				if (area->external_routing == OSPF_AREA_NSSA) -					LSDB_LOOP(NSSA_LSDB(area), rn, lsa) +					LSDB_LOOP (NSSA_LSDB(area), rn, lsa)  						ospf_ase_calculate_route(ospf,  									 lsa);  			}  		/* kevinm: And add the NSSA routes in ospf_top */ -		LSDB_LOOP(NSSA_LSDB(ospf), rn, lsa) +		LSDB_LOOP (NSSA_LSDB(ospf), rn, lsa)  			ospf_ase_calculate_route(ospf, lsa);  		/* Compare old and new external routing table and install the @@ -681,9 +679,12 @@ static int ospf_ase_calculate_timer(struct thread *t)  		monotime(&stop_time);  		if (IS_DEBUG_OSPF_EVENT) -			zlog_info("SPF Processing Time(usecs): External Routes: %lld\n", -				  (stop_time.tv_sec - start_time.tv_sec) * 1000000LL -				  + (stop_time.tv_usec - start_time.tv_usec)); +			zlog_info( +				"SPF Processing Time(usecs): External Routes: %lld\n", +				(stop_time.tv_sec - start_time.tv_sec) +						* 1000000LL +					+ (stop_time.tv_usec +					   - start_time.tv_usec));  	}  	return 0;  } diff --git a/ospfd/ospf_ext.c b/ospfd/ospf_ext.c index 95835cfd0b..10dd2f92c7 100644 --- a/ospfd/ospf_ext.c +++ b/ospfd/ospf_ext.c @@ -122,8 +122,8 @@ int ospf_ext_init(void)  	zlog_info("EXT (%s): Register Extended Link Opaque LSA", __func__);  	rc = ospf_register_opaque_functab(  		OSPF_OPAQUE_AREA_LSA, OPAQUE_TYPE_EXTENDED_LINK_LSA, -		ospf_ext_link_new_if,        /* new if */ -		ospf_ext_link_del_if,        /* del if */ +		ospf_ext_link_new_if,	/* new if */ +		ospf_ext_link_del_if,	/* del if */  		ospf_ext_link_ism_change,    /* ism change */  		ospf_ext_link_nsm_change,    /* nsm change */  		NULL,			     /* Write router config. */ @@ -316,9 +316,8 @@ static void set_prefix_sid(struct ext_itf *exti, uint8_t algorithm,  	if ((algorithm != SR_ALGORITHM_SPF)  	    && (algorithm != SR_ALGORITHM_STRICT_SPF)) { -		zlog_warn( -			"EXT (%s): unrecognized algorithm, not SPF or S-SPF", -			__func__); +		zlog_warn("EXT (%s): unrecognized algorithm, not SPF or S-SPF", +			  __func__);  		return;  	} @@ -342,7 +341,6 @@ static void set_prefix_sid(struct ext_itf *exti, uint8_t algorithm,  			htons(SID_INDEX_SIZE(EXT_SUBTLV_PREFIX_SID_SIZE));  		exti->node_sid.value = htonl(value);  	} -  }  /* Adjacency SID SubTLV - section 6.1 */ @@ -385,7 +383,6 @@ static void set_adj_sid(struct ext_itf *exti, bool backup, uint32_t value,  	exti->adj_sid[index].flags = flags; /* Set computed flags */  	exti->adj_sid[index].mtid = 0;   /* Multi-Topology is not supported */  	exti->adj_sid[index].weight = 0; /* Load-Balancing is not supported */ -  }  /* LAN Adjacency SID SubTLV - section 6.2 */ @@ -428,7 +425,6 @@ static void set_lan_adj_sid(struct ext_itf *exti, bool backup, uint32_t value,  	exti->lan_sid[index].mtid = 0;   /* Multi-Topology is not supported */  	exti->lan_sid[index].weight = 0; /* Load-Balancing is not supported */  	exti->lan_sid[index].neighbor_id = neighbor_id; -  }  /* Experimental SubTLV from Cisco */ @@ -438,7 +434,6 @@ static void set_rmt_itf_addr(struct ext_itf *exti, struct in_addr rmtif)  	TLV_TYPE(exti->rmt_itf_addr) = htons(EXT_SUBTLV_RMT_ITF_ADDR);  	TLV_LEN(exti->rmt_itf_addr) = htons(sizeof(struct in_addr));  	exti->rmt_itf_addr.value = rmtif; -  }  /* @@ -452,7 +447,7 @@ static void set_rmt_itf_addr(struct ext_itf *exti, struct in_addr rmtif)   * @return instance number if update is OK, 0 otherwise   */  uint32_t ospf_ext_schedule_prefix_index(struct interface *ifp, uint32_t index, -				   	struct prefix_ipv4 *p, uint8_t flags) +					struct prefix_ipv4 *p, uint8_t flags)  {  	int rc = 0;  	struct ext_itf *exti; @@ -483,9 +478,8 @@ uint32_t ospf_ext_schedule_prefix_index(struct interface *ifp, uint32_t index,  			ospf_ext_pref_lsa_schedule(exti, REORIGINATE_THIS_LSA);  	} else {  		if (IS_DEBUG_OSPF_SR) -			zlog_debug( -				"EXT (%s): Remove prefix for interface %s", -				__func__, ifp->name); +			zlog_debug("EXT (%s): Remove prefix for interface %s", +				   __func__, ifp->name);  		if (CHECK_FLAG(exti->flags, EXT_LPFLG_LSA_ENGAGED)) {  			ospf_ext_pref_lsa_schedule(exti, FLUSH_THIS_LSA); @@ -510,9 +504,8 @@ void ospf_ext_update_sr(bool enable)  	struct ext_itf *exti;  	if (IS_DEBUG_OSPF_SR) -		zlog_debug( -			"EXT (%s): %s Extended LSAs for Segment Routing ", -			__func__, enable ? "Enable" : "Disable"); +		zlog_debug("EXT (%s): %s Extended LSAs for Segment Routing ", +			   __func__, enable ? "Enable" : "Disable");  	if (enable) {  		OspfEXT.enabled = true; @@ -545,9 +538,8 @@ static int ospf_ext_link_new_if(struct interface *ifp)  	int rc = -1;  	if (lookup_ext_by_ifp(ifp) != NULL) { -		zlog_warn( -			"EXT (%s): interface %s is already in use", -			__func__, ifp ? ifp->name : "-"); +		zlog_warn("EXT (%s): interface %s is already in use", __func__, +			  ifp ? ifp->name : "-");  		rc = 0; /* Do nothing here. */  		return rc;  	} @@ -586,9 +578,8 @@ static int ospf_ext_link_del_if(struct interface *ifp)  		rc = 0;  	} else { -		zlog_warn( -			"EXT (%s): interface %s is not found", -			__func__, ifp ? ifp->name : "-"); +		zlog_warn("EXT (%s): interface %s is not found", __func__, +			  ifp ? ifp->name : "-");  	}  	return rc; @@ -605,9 +596,8 @@ static void ospf_ext_link_ism_change(struct ospf_interface *oi, int old_status)  	/* Get interface information for Segment Routing */  	exti = lookup_ext_by_ifp(oi->ifp);  	if (exti == NULL) { -		zlog_warn( -			"EXT (%s): Cannot get Extended info. from OI(%s)", -			__func__, IF_NAME(oi)); +		zlog_warn("EXT (%s): Cannot get Extended info. from OI(%s)", +			  __func__, IF_NAME(oi));  		return;  	} @@ -621,10 +611,9 @@ static void ospf_ext_link_ism_change(struct ospf_interface *oi, int old_status)  		exti->instance = get_ext_link_instance_value();  		exti->type = OPAQUE_TYPE_EXTENDED_LINK_LSA; -		zlog_debug( -			"EXT (%s): Set %s SID to interface %s ", __func__, -			exti->stype == ADJ_SID ? "Adj." : "LAN Adj.", -			oi->ifp->name); +		zlog_debug("EXT (%s): Set %s SID to interface %s ", __func__, +			   exti->stype == ADJ_SID ? "Adj." : "LAN Adj.", +			   oi->ifp->name);  	}  } @@ -639,9 +628,8 @@ static void ospf_ext_pref_ism_change(struct ospf_interface *oi, int old_status)  	/* Get interface information for Segment Routing */  	exti = lookup_ext_by_ifp(oi->ifp);  	if (exti == NULL) { -		zlog_warn( -			"EXT (%s): Cannot get Extended info. from OI(%s)", -			__func__, IF_NAME(oi)); +		zlog_warn("EXT (%s): Cannot get Extended info. from OI(%s)", +			  __func__, IF_NAME(oi));  		return;  	} @@ -651,9 +639,8 @@ static void ospf_ext_pref_ism_change(struct ospf_interface *oi, int old_status)  		exti->instance = get_ext_pref_instance_value();  		exti->type = OPAQUE_TYPE_EXTENDED_PREFIX_LSA; -		zlog_debug( -			"EXT (%s): Set Node SID to interface %s ", __func__, -			oi->ifp->name); +		zlog_debug("EXT (%s): Set Node SID to interface %s ", __func__, +			   oi->ifp->name);  		/* Complete SRDB if the interface belongs to a Prefix */  		if (OspfEXT.enabled) @@ -678,16 +665,14 @@ static void ospf_ext_link_nsm_change(struct ospf_neighbor *nbr, int old_status)  	/* Get interface information for Segment Routing */  	exti = lookup_ext_by_ifp(oi->ifp);  	if (exti == NULL) { -		zlog_warn( -			"EXT (%s): Cannot get Extended info. from OI(%s)", -			__func__, IF_NAME(oi)); +		zlog_warn("EXT (%s): Cannot get Extended info. from OI(%s)", +			  __func__, IF_NAME(oi));  		return;  	}  	if (oi->area == NULL || oi->area->ospf == NULL) { -		zlog_warn( -			"EXT (%s): Cannot refer to OSPF from OI(%s)", -			__func__, IF_NAME(oi)); +		zlog_warn("EXT (%s): Cannot refer to OSPF from OI(%s)", +			  __func__, IF_NAME(oi));  		return;  	} @@ -761,10 +746,10 @@ static void ospf_ext_link_nsm_change(struct ospf_neighbor *nbr, int old_status)  	}  	if (IS_DEBUG_OSPF_SR) -		zlog_debug( -			"EXT (%s): Complete %s SID to interface %s ", __func__, -			exti->stype == ADJ_SID ? "Adj." : "LAN Adj.", -			oi->ifp->name); +		zlog_debug("EXT (%s): Complete %s SID to interface %s ", +			   __func__, +			   exti->stype == ADJ_SID ? "Adj." : "LAN Adj.", +			   oi->ifp->name);  	/* flood this links params if everything is ok */  	SET_FLAG(exti->flags, EXT_LPFLG_LSA_ACTIVE); @@ -774,7 +759,6 @@ static void ospf_ext_link_nsm_change(struct ospf_neighbor *nbr, int old_status)  		else  			ospf_ext_link_lsa_schedule(exti, REORIGINATE_THIS_LSA);  	} -  }  /* Callbacks to handle Extended Link Segment Routing LSA information */ @@ -856,7 +840,6 @@ static int ospf_ext_pref_lsa_update(struct ospf_lsa *lsa)  static void build_tlv_header(struct stream *s, struct tlv_header *tlvh)  {  	stream_put(s, tlvh, sizeof(struct tlv_header)); -  }  static void build_tlv(struct stream *s, struct tlv_header *tlvh) @@ -866,7 +849,6 @@ static void build_tlv(struct stream *s, struct tlv_header *tlvh)  		build_tlv_header(s, tlvh);  		stream_put(s, TLV_DATA(tlvh), TLV_BODY_SIZE(tlvh));  	} -  }  /* Build an Extended Prefix Opaque LSA body for extended prefix TLV */ @@ -878,16 +860,14 @@ static void ospf_ext_pref_lsa_body_set(struct stream *s, struct ext_itf *exti)  		return;  	/* Adjust Extended Prefix TLV size */ -	TLV_LEN(exti->prefix) = -		htons(ntohs(TLV_LEN(exti->node_sid)) + EXT_TLV_PREFIX_SIZE -			    + TLV_HDR_SIZE); +	TLV_LEN(exti->prefix) = htons(ntohs(TLV_LEN(exti->node_sid)) +				      + EXT_TLV_PREFIX_SIZE + TLV_HDR_SIZE);  	/* Build LSA body for an Extended Prefix TLV */  	build_tlv_header(s, &exti->prefix.header);  	stream_put(s, TLV_DATA(&exti->prefix.header), EXT_TLV_PREFIX_SIZE);  	/* Then add Prefix SID SubTLV */  	build_tlv(s, &exti->node_sid.header); -  }  /* Build an Extended Link Opaque LSA body for extended link TLV */ @@ -903,10 +883,10 @@ static void ospf_ext_link_lsa_body_set(struct stream *s, struct ext_itf *exti)  	if (exti->stype == ADJ_SID) {  		/* Adjust Extended Link TLV size for Adj. SID */  		size = EXT_TLV_LINK_SIZE + 2 * EXT_SUBTLV_ADJ_SID_SIZE -			+ 2 * TLV_HDR_SIZE; +		       + 2 * TLV_HDR_SIZE;  		if (ntohs(TLV_TYPE(exti->rmt_itf_addr)) != 0)  			size = size + EXT_SUBTLV_RMT_ITF_ADDR_SIZE -				    + TLV_HDR_SIZE; +			       + TLV_HDR_SIZE;  		TLV_LEN(exti->link) = htons(size);  		/* Build LSA body for an Extended Link TLV with Adj. SID */ @@ -922,7 +902,7 @@ static void ospf_ext_link_lsa_body_set(struct stream *s, struct ext_itf *exti)  	} else {  		/* Adjust Extended Link TLV size for LAN SID */  		size = EXT_TLV_LINK_SIZE -			+ 2 * (EXT_SUBTLV_LAN_ADJ_SID_SIZE + TLV_HDR_SIZE); +		       + 2 * (EXT_SUBTLV_LAN_ADJ_SID_SIZE + TLV_HDR_SIZE);  		TLV_LEN(exti->link) = htons(size);  		/* Build LSA body for an Extended Link TLV with LAN SID */ @@ -932,7 +912,6 @@ static void ospf_ext_link_lsa_body_set(struct stream *s, struct ext_itf *exti)  		build_tlv(s, &exti->lan_sid[1].header);  		build_tlv(s, &exti->lan_sid[0].header);  	} -  }  /* Create new Extended Prefix opaque-LSA for every extended prefix */ @@ -1200,8 +1179,8 @@ static int ospf_ext_link_lsa_originate1(struct ospf_area *area,  		zlog_debug(  			"EXT (%s): LSA[Type%u:%s]: Originate Opaque-LSA "  			"Extended Link Opaque LSA: Area(%s), Link(%s)", -			 __func__, new->data->type, inet_ntoa(new->data->id), -			 area_id, exti->ifp->name); +			__func__, new->data->type, inet_ntoa(new->data->id), +			area_id, exti->ifp->name);  		ospf_lsa_header_dump(new->data);  	} @@ -1221,14 +1200,14 @@ static int ospf_ext_pref_lsa_originate(void *arg)  	if (!OspfEXT.enabled) {  		zlog_info(  			"EXT (%s): Segment Routing " -			"functionality is Disabled now", __func__); +			"functionality is Disabled now", +			__func__);  		rc = 0; /* This is not an error case. */  		return rc;  	}  	if (IS_DEBUG_OSPF_SR) -		zlog_debug( -			"EXT (%s): Start Originate Prefix LSA for area %s", -			__func__, inet_ntoa(area->area_id)); +		zlog_debug("EXT (%s): Start Originate Prefix LSA for area %s", +			   __func__, inet_ntoa(area->area_id));  	/* Check if Extended Prefix Opaque LSA is already engaged */  	for (ALL_LIST_ELEMENTS_RO(OspfEXT.iflist, node, exti)) { @@ -1247,7 +1226,8 @@ static int ospf_ext_pref_lsa_originate(void *arg)  				       EXT_LPFLG_LSA_FORCED_REFRESH)) {  				zlog_warn(  					"EXT (%s): Refresh instead of " -					"Originate", __func__); +					"Originate", +					__func__);  				UNSET_FLAG(exti->flags,  					   EXT_LPFLG_LSA_FORCED_REFRESH);  				ospf_ext_pref_lsa_schedule(exti, @@ -1281,7 +1261,8 @@ static int ospf_ext_link_lsa_originate(void *arg)  	if (!OspfEXT.enabled) {  		zlog_info(  			"EXT (%s): Segment Routing " -			"functionality is Disabled now", __func__); +			"functionality is Disabled now", +			__func__);  		rc = 0; /* This is not an error case. */  		return rc;  	} @@ -1303,7 +1284,8 @@ static int ospf_ext_link_lsa_originate(void *arg)  				       EXT_LPFLG_LSA_FORCED_REFRESH)) {  				zlog_warn(  					"EXT (%s): Refresh instead of " -					"Originate", __func__); +					"Originate", +					__func__);  				UNSET_FLAG(exti->flags,  					   EXT_LPFLG_LSA_FORCED_REFRESH);  				ospf_ext_link_lsa_schedule(exti, @@ -1343,7 +1325,8 @@ static struct ospf_lsa *ospf_ext_pref_lsa_refresh(struct ospf_lsa *lsa)  		 */  		zlog_info(  			"EXT (%s): Segment Routing functionality is " -			"Disabled", __func__); +			"Disabled", +			__func__);  		/* Flush it anyway. */  		lsa->data->ls_age = htons(OSPF_LSA_MAXAGE);  	} @@ -1359,7 +1342,7 @@ static struct ospf_lsa *ospf_ext_pref_lsa_refresh(struct ospf_lsa *lsa)  	/* Check if Interface was not disable in the interval */  	if ((exti != NULL) && !CHECK_FLAG(exti->flags, EXT_LPFLG_LSA_ACTIVE)) {  		zlog_warn("EXT (%s): Interface was Disabled: Flush it!", -			__func__); +			  __func__);  		/* Flush it anyway. */  		lsa->data->ls_age = htons(OSPF_LSA_MAXAGE);  	} @@ -1425,9 +1408,8 @@ static struct ospf_lsa *ospf_ext_link_lsa_refresh(struct ospf_lsa *lsa)  		 * This LSA must have flushed before due to OSPF-SR status  		 * change. It seems a slip among routers in the routing domain.  		 */ -		zlog_info( -			"EXT (%s): Segment Routing functionality is Disabled", -			__func__); +		zlog_info("EXT (%s): Segment Routing functionality is Disabled", +			  __func__);  		/* Flush it anyway. */  		lsa->data->ls_age = htons(OSPF_LSA_MAXAGE);  	} @@ -1442,9 +1424,8 @@ static struct ospf_lsa *ospf_ext_link_lsa_refresh(struct ospf_lsa *lsa)  	/* Check if Interface was not disable in the interval */  	if ((exti != NULL) && !CHECK_FLAG(exti->flags, EXT_LPFLG_LSA_ACTIVE)) { -		zlog_warn( -			"EXT (%s): Interface was Disabled: Flush it!", -			__func__); +		zlog_warn("EXT (%s): Interface was Disabled: Flush it!", +			  __func__);  		lsa->data->ls_age = htons(OSPF_LSA_MAXAGE);  	} @@ -1506,18 +1487,18 @@ static void ospf_ext_pref_lsa_schedule(struct ext_itf *exti,  	if (!(CHECK_FLAG(exti->flags, EXT_LPFLG_LSA_ACTIVE)))  		return; -	zlog_debug( -		"EXT (%s): Schedule %s%s%s LSA for interface %s", __func__, -		opcode == REORIGINATE_THIS_LSA ? "Re-Originate" : "", -		opcode == REFRESH_THIS_LSA ? "Refresh" : "", -		opcode == FLUSH_THIS_LSA ? "Flush" : "", -		exti->ifp ? exti->ifp->name : "-"); +	zlog_debug("EXT (%s): Schedule %s%s%s LSA for interface %s", __func__, +		   opcode == REORIGINATE_THIS_LSA ? "Re-Originate" : "", +		   opcode == REFRESH_THIS_LSA ? "Refresh" : "", +		   opcode == FLUSH_THIS_LSA ? "Flush" : "", +		   exti->ifp ? exti->ifp->name : "-");  	/* Set LSA header information */  	if (exti->area == NULL) {  		zlog_warn(  			"EXT (%s): Flooding is Area scope but area is not yet " -			"set", __func__); +			"set", +			__func__);  		if (OspfEXT.area == NULL) {  			top = ospf_lookup_by_vrf_id(VRF_DEFAULT);  			OspfEXT.area = ospf_area_lookup_by_area_id( @@ -1548,7 +1529,6 @@ static void ospf_ext_pref_lsa_schedule(struct ext_itf *exti,  		zlog_warn("EXT (%s): Unknown opcode", __func__);  		break;  	} -  }  /* Schedule Extended Link Opaque LSA origination/refreshment/flushing */ @@ -1571,18 +1551,18 @@ static void ospf_ext_link_lsa_schedule(struct ext_itf *exti,  	if (!(CHECK_FLAG(exti->flags, EXT_LPFLG_LSA_ACTIVE)))  		return; -	zlog_debug( -		"EXT (%s): Schedule %s%s%s LSA for interface %s", __func__, -		opcode == REORIGINATE_THIS_LSA ? "Re-Originate" : "", -		opcode == REFRESH_THIS_LSA ? "Refresh" : "", -		opcode == FLUSH_THIS_LSA ? "Flush" : "", -		exti->ifp ? exti->ifp->name : "-"); +	zlog_debug("EXT (%s): Schedule %s%s%s LSA for interface %s", __func__, +		   opcode == REORIGINATE_THIS_LSA ? "Re-Originate" : "", +		   opcode == REFRESH_THIS_LSA ? "Refresh" : "", +		   opcode == FLUSH_THIS_LSA ? "Flush" : "", +		   exti->ifp ? exti->ifp->name : "-");  	/* Set LSA header information */  	if (exti->area == NULL) {  		zlog_warn(  			"EXT (%s): Flooding is Area scope but area is not " -			"yet set", __func__); +			"yet set", +			__func__);  		if (OspfEXT.area == NULL) {  			top = ospf_lookup_by_vrf_id(VRF_DEFAULT);  			OspfEXT.area = ospf_area_lookup_by_area_id( @@ -1613,7 +1593,6 @@ static void ospf_ext_link_lsa_schedule(struct ext_itf *exti,  		zlog_warn("EXT (%s): Unknown opcode", __func__);  		break;  	} -  }  /* Schedule Extended Link or Prefix depending of the Type of LSA */ @@ -1634,7 +1613,7 @@ static void ospf_ext_lsa_schedule(struct ext_itf *exti, enum lsa_opcode op)  /* Cisco experimental SubTLV */  static uint16_t show_vty_ext_link_rmt_itf_addr(struct vty *vty, -						struct tlv_header *tlvh) +					       struct tlv_header *tlvh)  {  	struct ext_subtlv_rmt_itf_addr *top; @@ -1650,7 +1629,7 @@ static uint16_t show_vty_ext_link_rmt_itf_addr(struct vty *vty,  /* Adjacency SID SubTLV */  static uint16_t show_vty_ext_link_adj_sid(struct vty *vty, -					   struct tlv_header *tlvh) +					  struct tlv_header *tlvh)  {  	struct ext_subtlv_adj_sid *top = (struct ext_subtlv_adj_sid *)tlvh; @@ -1669,7 +1648,7 @@ static uint16_t show_vty_ext_link_adj_sid(struct vty *vty,  /* LAN Adjacency SubTLV */  static uint16_t show_vty_ext_link_lan_adj_sid(struct vty *vty, -					       struct tlv_header *tlvh) +					      struct tlv_header *tlvh)  {  	struct ext_subtlv_lan_adj_sid *top =  		(struct ext_subtlv_lan_adj_sid *)tlvh; @@ -1755,12 +1734,11 @@ static void ospf_ext_link_show_info(struct vty *vty, struct ospf_lsa *lsa)  			break;  		}  	} -  }  /* Prefix SID SubTLV */  static uint16_t show_vty_ext_pref_pref_sid(struct vty *vty, -					    struct tlv_header *tlvh) +					   struct tlv_header *tlvh)  {  	struct ext_subtlv_prefix_sid *top =  		(struct ext_subtlv_prefix_sid *)tlvh; @@ -1830,5 +1808,4 @@ static void ospf_ext_pref_show_info(struct vty *vty, struct ospf_lsa *lsa)  			break;  		}  	} -  } diff --git a/ospfd/ospf_ext.h b/ospfd/ospf_ext.h index 67280754dd..c3f9ae94dc 100644 --- a/ospfd/ospf_ext.h +++ b/ospfd/ospf_ext.h @@ -194,7 +194,7 @@ extern void ospf_ext_term(void);  extern void ospf_ext_finish(void);  extern void ospf_ext_update_sr(bool enable);  extern uint32_t ospf_ext_schedule_prefix_index(struct interface *ifp, -					  uint32_t index, -					  struct prefix_ipv4 *p, -					  uint8_t flags); +					       uint32_t index, +					       struct prefix_ipv4 *p, +					       uint8_t flags);  #endif /* _FRR_OSPF_EXT_PREF_H_ */ diff --git a/ospfd/ospf_flood.c b/ospfd/ospf_flood.c index 7ad9cf9f2f..183ddc0d89 100644 --- a/ospfd/ospf_flood.c +++ b/ospfd/ospf_flood.c @@ -218,7 +218,7 @@ static void ospf_process_self_originated_lsa(struct ospf *ospf,  		break;  	case OSPF_OPAQUE_AS_LSA:  		ospf_opaque_lsa_refresh(new); -			/* Reconsideration may needed. */ /* XXX */ +		/* Reconsideration may needed. */ /* XXX */  		break;  	default:  		break; diff --git a/ospfd/ospf_ia.c b/ospfd/ospf_ia.c index e570f3337a..9b74cb8c0f 100644 --- a/ospfd/ospf_ia.c +++ b/ospfd/ospf_ia.c @@ -282,7 +282,7 @@ static void ospf_examine_summaries(struct ospf_area *area,  	struct ospf_lsa *lsa;  	struct route_node *rn; -	LSDB_LOOP(lsdb_rt, rn, lsa) +	LSDB_LOOP (lsdb_rt, rn, lsa)  		process_summary_lsa(area, rt, rtrs, lsa);  } @@ -582,7 +582,7 @@ static void ospf_examine_transit_summaries(struct ospf_area *area,  	struct ospf_lsa *lsa;  	struct route_node *rn; -	LSDB_LOOP(lsdb_rt, rn, lsa) +	LSDB_LOOP (lsdb_rt, rn, lsa)  		process_transit_summary_lsa(area, rt, rtrs, lsa);  } diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c index c8f758525e..e19bfe7f55 100644 --- a/ospfd/ospf_interface.c +++ b/ospfd/ospf_interface.c @@ -849,8 +849,9 @@ struct ospf_interface *ospf_vl_new(struct ospf *ospf,  	}  	if (IS_DEBUG_OSPF_EVENT) -		zlog_debug("ospf_vl_new(): creating pseudo zebra interface vrf id %u", -			   ospf->vrf_id); +		zlog_debug( +			"ospf_vl_new(): creating pseudo zebra interface vrf id %u", +			ospf->vrf_id);  	snprintf(ifname, sizeof(ifname), "VLINK%d", vlink_count);  	vi = if_create(ifname, ospf->vrf_id); diff --git a/ospfd/ospf_interface.h b/ospfd/ospf_interface.h index ab02444f7d..85a24f0026 100644 --- a/ospfd/ospf_interface.h +++ b/ospfd/ospf_interface.h @@ -194,8 +194,6 @@ struct ospf_interface {  	/* Neighbor information. */  	struct route_table *nbrs;       /* OSPF Neighbor List */  	struct ospf_neighbor *nbr_self; /* Neighbor Self */ -					/* $FRR indent$ */ -					/* clang-format off */  #define DR(I)			((I)->nbr_self->d_router)  #define BDR(I)			((I)->nbr_self->bd_router)  #define OPTIONS(I)		((I)->nbr_self->options) diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c index 0f1dd63dfb..588a8f6724 100644 --- a/ospfd/ospf_lsa.c +++ b/ospfd/ospf_lsa.c @@ -2114,8 +2114,8 @@ int ospf_default_originate_timer(struct thread *thread)  		/* If there is no default route via redistribute,  		   then originate AS-external-LSA with nexthop 0 (self). */  		nexthop.s_addr = 0; -		ospf_external_info_add(ospf, DEFAULT_ROUTE, 0, p, 0, -				       nexthop, 0); +		ospf_external_info_add(ospf, DEFAULT_ROUTE, 0, p, 0, nexthop, +				       0);  	}  	if ((ei = ospf_default_external_info(ospf))) @@ -2133,9 +2133,8 @@ void ospf_nssa_lsa_flush(struct ospf *ospf, struct prefix_ipv4 *p)  	for (ALL_LIST_ELEMENTS(ospf->areas, node, nnode, area)) {  		if (area->external_routing == OSPF_AREA_NSSA) { -			lsa  = ospf_lsa_lookup(ospf, area, -					       OSPF_AS_NSSA_LSA, p->prefix, -					       ospf->router_id); +			lsa = ospf_lsa_lookup(ospf, area, OSPF_AS_NSSA_LSA, +					      p->prefix, ospf->router_id);  			if (!lsa) {  				if (IS_DEBUG_OSPF(lsa, LSA_FLOODING))  					zlog_debug( @@ -2260,14 +2259,14 @@ void ospf_external_lsa_refresh_type(struct ospf *ospf, u_char type,  				if (!is_prefix_default(&ei->p)) {  					struct ospf_lsa *lsa; -					lsa = ospf_external_info_find_lsa(ospf, -								&ei->p); +					lsa = ospf_external_info_find_lsa( +						ospf, &ei->p);  					if (lsa) -						ospf_external_lsa_refresh(ospf, -								lsa, ei, force); +						ospf_external_lsa_refresh( +							ospf, lsa, ei, force);  					else -						ospf_external_lsa_originate(ospf -									, ei); +						ospf_external_lsa_originate( +							ospf, ei);  				}  			}  		} @@ -2431,7 +2430,7 @@ ospf_summary_lsa_install(struct ospf *ospf, struct ospf_lsa *new, int rt_recalc)  #if 0        /* This doesn't exist yet... */        ospf_summary_incremental_update(new); */ -#else  /* #if 0 */ +#else /* #if 0 */  		ospf_spf_calculate_schedule(ospf, SPF_FLAG_SUMMARY_LSA_INSTALL);  #endif /* #if 0 */  	} @@ -3005,27 +3004,27 @@ int ospf_lsa_maxage_walker(struct thread *thread)  	ospf->t_maxage_walker = NULL;  	for (ALL_LIST_ELEMENTS(ospf->areas, node, nnode, area)) { -		LSDB_LOOP(ROUTER_LSDB(area), rn, lsa) +		LSDB_LOOP (ROUTER_LSDB(area), rn, lsa)  			ospf_lsa_maxage_walker_remover(ospf, lsa); -		LSDB_LOOP(NETWORK_LSDB(area), rn, lsa) +		LSDB_LOOP (NETWORK_LSDB(area), rn, lsa)  			ospf_lsa_maxage_walker_remover(ospf, lsa); -		LSDB_LOOP(SUMMARY_LSDB(area), rn, lsa) +		LSDB_LOOP (SUMMARY_LSDB(area), rn, lsa)  			ospf_lsa_maxage_walker_remover(ospf, lsa); -		LSDB_LOOP(ASBR_SUMMARY_LSDB(area), rn, lsa) +		LSDB_LOOP (ASBR_SUMMARY_LSDB(area), rn, lsa)  			ospf_lsa_maxage_walker_remover(ospf, lsa); -		LSDB_LOOP(OPAQUE_AREA_LSDB(area), rn, lsa) +		LSDB_LOOP (OPAQUE_AREA_LSDB(area), rn, lsa)  			ospf_lsa_maxage_walker_remover(ospf, lsa); -		LSDB_LOOP(OPAQUE_LINK_LSDB(area), rn, lsa) +		LSDB_LOOP (OPAQUE_LINK_LSDB(area), rn, lsa)  			ospf_lsa_maxage_walker_remover(ospf, lsa); -		LSDB_LOOP(NSSA_LSDB(area), rn, lsa) +		LSDB_LOOP (NSSA_LSDB(area), rn, lsa)  			ospf_lsa_maxage_walker_remover(ospf, lsa);  	}  	/* for AS-external-LSAs. */  	if (ospf->lsdb) { -		LSDB_LOOP(EXTERNAL_LSDB(ospf), rn, lsa) +		LSDB_LOOP (EXTERNAL_LSDB(ospf), rn, lsa)  			ospf_lsa_maxage_walker_remover(ospf, lsa); -		LSDB_LOOP(OPAQUE_AS_LSDB(ospf), rn, lsa) +		LSDB_LOOP (OPAQUE_AS_LSDB(ospf), rn, lsa)  			ospf_lsa_maxage_walker_remover(ospf, lsa);  	} @@ -3348,20 +3347,20 @@ void ospf_flush_self_originated_lsas_now(struct ospf *ospf)  				need_to_flush_ase = 1;  		} -		LSDB_LOOP(SUMMARY_LSDB(area), rn, lsa) +		LSDB_LOOP (SUMMARY_LSDB(area), rn, lsa)  			ospf_lsa_flush_schedule(ospf, lsa); -		LSDB_LOOP(ASBR_SUMMARY_LSDB(area), rn, lsa) +		LSDB_LOOP (ASBR_SUMMARY_LSDB(area), rn, lsa)  			ospf_lsa_flush_schedule(ospf, lsa); -		LSDB_LOOP(OPAQUE_LINK_LSDB(area), rn, lsa) +		LSDB_LOOP (OPAQUE_LINK_LSDB(area), rn, lsa)  			ospf_lsa_flush_schedule(ospf, lsa); -		LSDB_LOOP(OPAQUE_AREA_LSDB(area), rn, lsa) +		LSDB_LOOP (OPAQUE_AREA_LSDB(area), rn, lsa)  			ospf_lsa_flush_schedule(ospf, lsa);  	}  	if (need_to_flush_ase) { -		LSDB_LOOP(EXTERNAL_LSDB(ospf), rn, lsa) +		LSDB_LOOP (EXTERNAL_LSDB(ospf), rn, lsa)  			ospf_lsa_flush_schedule(ospf, lsa); -		LSDB_LOOP(OPAQUE_AS_LSDB(ospf), rn, lsa) +		LSDB_LOOP (OPAQUE_AS_LSDB(ospf), rn, lsa)  			ospf_lsa_flush_schedule(ospf, lsa);  	} diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c index 8dbf39ef5d..364f51aa7f 100644 --- a/ospfd/ospf_main.c +++ b/ospfd/ospf_main.c @@ -54,9 +54,8 @@  #include "ospfd/ospf_bfd.h"  /* ospfd privileges */ -zebra_capabilities_t _caps_p[] = { -	ZCAP_NET_RAW, ZCAP_BIND, ZCAP_NET_ADMIN, ZCAP_SYS_ADMIN -}; +zebra_capabilities_t _caps_p[] = {ZCAP_NET_RAW, ZCAP_BIND, ZCAP_NET_ADMIN, +				  ZCAP_SYS_ADMIN};  struct zebra_privs_t ospfd_privs = {  #if defined(FRR_USER) && defined(FRR_GROUP) diff --git a/ospfd/ospf_neighbor.c b/ospfd/ospf_neighbor.c index a7aac26b3b..d647525eaa 100644 --- a/ospfd/ospf_neighbor.c +++ b/ospfd/ospf_neighbor.c @@ -269,8 +269,9 @@ void ospf_nbr_add_self(struct ospf_interface *oi, struct in_addr router_id)  	rn = route_node_get(oi->nbrs, &p);  	if (rn->info) {  		/* There is already pseudo neighbor. */ -		zlog_warn("router_id %s already present in neighbor table. node refcount %u", -			  inet_ntoa(router_id), rn->lock); +		zlog_warn( +			"router_id %s already present in neighbor table. node refcount %u", +			inet_ntoa(router_id), rn->lock);  		route_unlock_node(rn);  	} else  		rn->info = oi->nbr_self; @@ -461,9 +462,8 @@ struct ospf_neighbor *ospf_nbr_get(struct ospf_interface *oi,  	if (oi->type == OSPF_IFTYPE_VIRTUALLINK  	    || oi->type == OSPF_IFTYPE_POINTOPOINT) -		key.u.prefix4 = -			ospfh->router_id; /* index vlink and ptp nbrs by -					     router-id */ +		key.u.prefix4 = ospfh->router_id; /* index vlink and ptp nbrs by +						     router-id */  	else  		key.u.prefix4 = iph->ip_src; diff --git a/ospfd/ospf_network.c b/ospfd/ospf_network.c index 045634d8ab..5e11245bc5 100644 --- a/ospfd/ospf_network.c +++ b/ospfd/ospf_network.c @@ -58,8 +58,9 @@ int ospf_if_add_allspfrouters(struct ospf *top, struct prefix *p,  			safe_strerror(errno));  	else {  		if (IS_DEBUG_OSPF_EVENT) -			zlog_debug("interface %s [%u] join AllSPFRouters Multicast group.", -				   inet_ntoa(p->u.prefix4), ifindex); +			zlog_debug( +				"interface %s [%u] join AllSPFRouters Multicast group.", +				inet_ntoa(p->u.prefix4), ifindex);  	}  	return ret; @@ -81,8 +82,9 @@ int ospf_if_drop_allspfrouters(struct ospf *top, struct prefix *p,  			safe_strerror(errno));  	else {  		if (IS_DEBUG_OSPF_EVENT) -			zlog_debug("interface %s [%u] leave AllSPFRouters Multicast group.", -				   inet_ntoa(p->u.prefix4), ifindex); +			zlog_debug( +				"interface %s [%u] leave AllSPFRouters Multicast group.", +				inet_ntoa(p->u.prefix4), ifindex);  	}  	return ret; @@ -188,8 +190,8 @@ int ospf_sock_init(struct ospf *ospf)  			 safe_strerror(errno));  	} -	ospf_sock = vrf_socket(AF_INET, SOCK_RAW, IPPROTO_OSPFIGP, -			       ospf->vrf_id, ospf->name); +	ospf_sock = vrf_socket(AF_INET, SOCK_RAW, IPPROTO_OSPFIGP, ospf->vrf_id, +			       ospf->name);  	if (ospf_sock < 0) {  		int save_errno = errno; diff --git a/ospfd/ospf_nsm.c b/ospfd/ospf_nsm.c index 54d5dd5d16..b83c9dec2c 100644 --- a/ospfd/ospf_nsm.c +++ b/ospfd/ospf_nsm.c @@ -279,37 +279,37 @@ static int nsm_negotiation_done(struct ospf_neighbor *nbr)  	/* Send proactive ARP requests */  	ospf_proactively_arp(nbr); -	LSDB_LOOP(ROUTER_LSDB(area), rn, lsa) +	LSDB_LOOP (ROUTER_LSDB(area), rn, lsa)  		ospf_db_summary_add(nbr, lsa); -	LSDB_LOOP(NETWORK_LSDB(area), rn, lsa) +	LSDB_LOOP (NETWORK_LSDB(area), rn, lsa)  		ospf_db_summary_add(nbr, lsa); -	LSDB_LOOP(SUMMARY_LSDB(area), rn, lsa) +	LSDB_LOOP (SUMMARY_LSDB(area), rn, lsa)  		ospf_db_summary_add(nbr, lsa); -	LSDB_LOOP(ASBR_SUMMARY_LSDB(area), rn, lsa) +	LSDB_LOOP (ASBR_SUMMARY_LSDB(area), rn, lsa)  		ospf_db_summary_add(nbr, lsa);  	/* Process only if the neighbor is opaque capable. */  	if (CHECK_FLAG(nbr->options, OSPF_OPTION_O)) { -		LSDB_LOOP(OPAQUE_LINK_LSDB(area), rn, lsa) +		LSDB_LOOP (OPAQUE_LINK_LSDB(area), rn, lsa)  			ospf_db_summary_add(nbr, lsa); -		LSDB_LOOP(OPAQUE_AREA_LSDB(area), rn, lsa) +		LSDB_LOOP (OPAQUE_AREA_LSDB(area), rn, lsa)  			ospf_db_summary_add(nbr, lsa);  	}  	if (CHECK_FLAG(nbr->options, OSPF_OPTION_NP)) { -		LSDB_LOOP(NSSA_LSDB(area), rn, lsa) +		LSDB_LOOP (NSSA_LSDB(area), rn, lsa)  			ospf_db_summary_add(nbr, lsa);  	}  	if (nbr->oi->type != OSPF_IFTYPE_VIRTUALLINK  	    && area->external_routing == OSPF_AREA_DEFAULT) -		LSDB_LOOP(EXTERNAL_LSDB(nbr->oi->ospf), rn, lsa) +		LSDB_LOOP (EXTERNAL_LSDB(nbr->oi->ospf), rn, lsa)  			ospf_db_summary_add(nbr, lsa);  	if (CHECK_FLAG(nbr->options, OSPF_OPTION_O)  	    && (nbr->oi->type != OSPF_IFTYPE_VIRTUALLINK  		&& area->external_routing == OSPF_AREA_DEFAULT)) -		LSDB_LOOP(OPAQUE_AS_LSDB(nbr->oi->ospf), rn, lsa) +		LSDB_LOOP (OPAQUE_AS_LSDB(nbr->oi->ospf), rn, lsa)  			ospf_db_summary_add(nbr, lsa);  	return 0; @@ -703,7 +703,8 @@ static void nsm_change_state(struct ospf_neighbor *nbr, int state)  		}  		if (CHECK_FLAG(oi->ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) -			zlog_info("%s:(%s, %s -> %s): " +			zlog_info( +				"%s:(%s, %s -> %s): "  				"scheduling new router-LSA origination",  				__PRETTY_FUNCTION__, inet_ntoa(nbr->router_id),  				lookup_msg(ospf_nsm_state_msg, old_state, NULL), diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c index 009fd997ea..6e9cf36a3d 100644 --- a/ospfd/ospf_opaque.c +++ b/ospfd/ospf_opaque.c @@ -610,28 +610,28 @@ static void free_opaque_info_owner(void *val)  {  	struct opaque_info_per_type *oipt = (struct opaque_info_per_type *)val; -        switch (oipt->lsa_type) { -        case OSPF_OPAQUE_LINK_LSA: { -                struct ospf_interface *oi = -                        (struct ospf_interface *)(oipt->owner); -                listnode_delete(oi->opaque_lsa_self, oipt); -                break; -        } -        case OSPF_OPAQUE_AREA_LSA: { -                struct ospf_area *area = (struct ospf_area *)(oipt->owner); -                listnode_delete(area->opaque_lsa_self, oipt); -                break; -        } -        case OSPF_OPAQUE_AS_LSA: { -                struct ospf *top = (struct ospf *)(oipt->owner); -                listnode_delete(top->opaque_lsa_self, oipt); -                break; -        } -        default: -                zlog_warn("free_opaque_info_owner: Unexpected LSA-type(%u)", -                          oipt->lsa_type); -                break; /* This case may not exist. */ -        } +	switch (oipt->lsa_type) { +	case OSPF_OPAQUE_LINK_LSA: { +		struct ospf_interface *oi = +			(struct ospf_interface *)(oipt->owner); +		listnode_delete(oi->opaque_lsa_self, oipt); +		break; +	} +	case OSPF_OPAQUE_AREA_LSA: { +		struct ospf_area *area = (struct ospf_area *)(oipt->owner); +		listnode_delete(area->opaque_lsa_self, oipt); +		break; +	} +	case OSPF_OPAQUE_AS_LSA: { +		struct ospf *top = (struct ospf *)(oipt->owner); +		listnode_delete(top->opaque_lsa_self, oipt); +		break; +	} +	default: +		zlog_warn("free_opaque_info_owner: Unexpected LSA-type(%u)", +			  oipt->lsa_type); +		break; /* This case may not exist. */ +	}  }  static void free_opaque_info_per_type(void *val) @@ -1393,12 +1393,11 @@ void ospf_opaque_lsa_originate_schedule(struct ospf_interface *oi, int *delay0)  			 * list_isempty (oipt->id_list)  			 * not being empty.  			 */ -			if ( -				oipt->t_opaque_lsa_self -					!= NULL /* Waiting for a thread call. */ -				|| oipt->status == PROC_SUSPEND) /* Cannot -								    originate -								    now. */ +			if (oipt->t_opaque_lsa_self +				    != NULL /* Waiting for a thread call. */ +			    || oipt->status == PROC_SUSPEND) /* Cannot +								originate +								now. */  				continue;  			ospf_opaque_lsa_reoriginate_schedule( @@ -1419,12 +1418,11 @@ void ospf_opaque_lsa_originate_schedule(struct ospf_interface *oi, int *delay0)  			 * list_isempty (oipt->id_list)  			 * not being empty.  			 */ -			if ( -				oipt->t_opaque_lsa_self -					!= NULL /* Waiting for a thread call. */ -				|| oipt->status == PROC_SUSPEND) /* Cannot -								    originate -								    now. */ +			if (oipt->t_opaque_lsa_self +				    != NULL /* Waiting for a thread call. */ +			    || oipt->status == PROC_SUSPEND) /* Cannot +								originate +								now. */  				continue;  			ospf_opaque_lsa_reoriginate_schedule( @@ -1445,12 +1443,11 @@ void ospf_opaque_lsa_originate_schedule(struct ospf_interface *oi, int *delay0)  			 * list_isempty (oipt->id_list)  			 * not being empty.  			 */ -			if ( -				oipt->t_opaque_lsa_self -					!= NULL /* Waiting for a thread call. */ -				|| oipt->status == PROC_SUSPEND) /* Cannot -								    originate -								    now. */ +			if (oipt->t_opaque_lsa_self +				    != NULL /* Waiting for a thread call. */ +			    || oipt->status == PROC_SUSPEND) /* Cannot +								originate +								now. */  				continue;  			ospf_opaque_lsa_reoriginate_schedule((void *)top, diff --git a/ospfd/ospf_opaque.h b/ospfd/ospf_opaque.h index 632b7b039e..4fc5699a29 100644 --- a/ospfd/ospf_opaque.h +++ b/ospfd/ospf_opaque.h @@ -47,7 +47,7 @@  #define SET_OPAQUE_LSID(type, id)                                              \  	((((unsigned)(type) << 24) & LSID_OPAQUE_TYPE_MASK)                    \ -	 | ((id) & LSID_OPAQUE_ID_MASK)) +	 | ((id)&LSID_OPAQUE_ID_MASK))  /*   * Opaque LSA types will be assigned by IANA. @@ -85,24 +85,23 @@   * used for various LSA opaque usage e.g. Traffic Engineering.   */  struct tlv_header { -	u_int16_t type;		/* Type of Value */ -	u_int16_t length;	/* Length of Value portion only, in bytes */ +	u_int16_t type;   /* Type of Value */ +	u_int16_t length; /* Length of Value portion only, in bytes */  };  #define TLV_HDR_SIZE	(sizeof(struct tlv_header)) -#define TLV_BODY_SIZE(tlvh) \ -	(ROUNDUP(ntohs((tlvh)->length), sizeof(u_int32_t))) +#define TLV_BODY_SIZE(tlvh) (ROUNDUP(ntohs((tlvh)->length), sizeof(u_int32_t)))  #define TLV_SIZE(tlvh)	(TLV_HDR_SIZE + TLV_BODY_SIZE(tlvh)) -#define TLV_HDR_TOP(lsah) \ +#define TLV_HDR_TOP(lsah)                                                      \  	(struct tlv_header *)((char *)(lsah) + OSPF_LSA_HEADER_SIZE) -#define TLV_HDR_NEXT(tlvh) \ +#define TLV_HDR_NEXT(tlvh)                                                     \  	(struct tlv_header *)((char *)(tlvh) + TLV_SIZE(tlvh)) -#define TLV_HDR_SUBTLV(tlvh) \ +#define TLV_HDR_SUBTLV(tlvh)                                                   \  	(struct tlv_header *)((char *)(tlvh) + TLV_HDR_SIZE)  #define TLV_DATA(tlvh)	(void *)((char *)(tlvh) + TLV_HDR_SIZE) @@ -112,11 +111,7 @@ struct tlv_header {  #define TLV_HDR(tlvh)	tlvh.header  /* Following declaration concerns the Opaque LSA management */ -enum lsa_opcode { -	REORIGINATE_THIS_LSA, -	REFRESH_THIS_LSA, -	FLUSH_THIS_LSA -}; +enum lsa_opcode { REORIGINATE_THIS_LSA, REFRESH_THIS_LSA, FLUSH_THIS_LSA };  /* Prototypes. */ diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index 881226683c..7906794411 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -518,8 +518,8 @@ int ospf_ls_upd_timer(struct thread *thread)  		}  		if (listcount(update) > 0) -			ospf_ls_upd_send(nbr, update, -					 OSPF_SEND_PACKET_DIRECT, 0); +			ospf_ls_upd_send(nbr, update, OSPF_SEND_PACKET_DIRECT, +					 0);  		list_delete_and_null(&update);  	} @@ -645,8 +645,6 @@ static int ospf_write(struct thread *thread)  	static u_int16_t ipid = 0;  	u_int16_t maxdatasize;  #endif /* WANT_OSPF_WRITE_FRAGMENT */ -       /* $FRR indent$ */ -       /* clang-format off */  #define OSPF_WRITE_IPHL_SHIFT 2  	int pkt_count = 0; @@ -777,10 +775,10 @@ static int ospf_write(struct thread *thread)  		msg.msg_controllen = cm->cmsg_len;  #endif -	/* Sadly we can not rely on kernels to fragment packets -	 * because of either IP_HDRINCL and/or multicast -	 * destination being set. -	 */ +/* Sadly we can not rely on kernels to fragment packets + * because of either IP_HDRINCL and/or multicast + * destination being set. + */  #ifdef WANT_OSPF_WRITE_FRAGMENT  		if (op->length > maxdatasize) @@ -827,23 +825,23 @@ static int ospf_write(struct thread *thread)  		}  		switch (type) { -			case OSPF_MSG_HELLO: -				oi->hello_out++; -				break; -			case OSPF_MSG_DB_DESC: -				oi->db_desc_out++; -				break; -			case OSPF_MSG_LS_REQ: -				oi->ls_req_out++; -				break; -			case OSPF_MSG_LS_UPD: -				oi->ls_upd_out++; -				break; -			case OSPF_MSG_LS_ACK: -				oi->ls_ack_out++; -				break; -			default: -				break; +		case OSPF_MSG_HELLO: +			oi->hello_out++; +			break; +		case OSPF_MSG_DB_DESC: +			oi->db_desc_out++; +			break; +		case OSPF_MSG_LS_REQ: +			oi->ls_req_out++; +			break; +		case OSPF_MSG_LS_UPD: +			oi->ls_upd_out++; +			break; +		case OSPF_MSG_LS_ACK: +			oi->ls_ack_out++; +			break; +		default: +			break;  		}  		/* Now delete packet from queue. */ @@ -1365,8 +1363,9 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh,  				/* We're Slave---obey */  				if (CHECK_FLAG(oi->ospf->config,  					       OSPF_LOG_ADJACENCY_DETAIL)) -					zlog_info("Packet[DD]: Neighbor %s Negotiation done (Slave).", -						  inet_ntoa(nbr->router_id)); +					zlog_info( +						"Packet[DD]: Neighbor %s Negotiation done (Slave).", +						inet_ntoa(nbr->router_id));  				nbr->dd_seqnum = ntohl(dd->dd_seqnum); @@ -1635,11 +1634,11 @@ static void ospf_ls_req(struct ip *iph, struct ospf_header *ospfh,  	/* Send rest of Link State Update. */  	if (listcount(ls_upd) > 0) {  		if (oi->type == OSPF_IFTYPE_NBMA) -			ospf_ls_upd_send(nbr, ls_upd, -					 OSPF_SEND_PACKET_DIRECT, 0); +			ospf_ls_upd_send(nbr, ls_upd, OSPF_SEND_PACKET_DIRECT, +					 0);  		else -			ospf_ls_upd_send(nbr, ls_upd, -					 OSPF_SEND_PACKET_INDIRECT, 0); +			ospf_ls_upd_send(nbr, ls_upd, OSPF_SEND_PACKET_INDIRECT, +					 0);  		list_delete_and_null(&ls_upd);  	} else @@ -2489,15 +2488,14 @@ static int ospf_check_auth(struct ospf_interface *oi, struct ospf_header *ospfh)  			return 0;  		}  		/* only MD5 crypto method can pass ospf_packet_examin() */ -		if ( -			NULL == (ck = listgetdata(listtail( -					 OSPF_IF_PARAM(oi, auth_crypt)))) -			|| ospfh->u.crypt.key_id != ck->key_id || -			/* Condition above uses the last key ID on the list, -			   which is -			   different from what ospf_crypt_key_lookup() does. A -			   bug? */ -			!ospf_check_md5_digest(oi, ospfh)) { +		if (NULL == (ck = listgetdata( +				     listtail(OSPF_IF_PARAM(oi, auth_crypt)))) +		    || ospfh->u.crypt.key_id != ck->key_id || +		    /* Condition above uses the last key ID on the list, +		       which is +		       different from what ospf_crypt_key_lookup() does. A +		       bug? */ +		    !ospf_check_md5_digest(oi, ospfh)) {  			if (IS_DEBUG_OSPF_PACKET(ospfh->type - 1, RECV))  				zlog_warn("interface %s: MD5 auth failed",  					  IF_NAME(oi)); @@ -3543,10 +3541,11 @@ static void ospf_hello_send_sub(struct ospf_interface *oi, in_addr_t addr)  	if (IS_DEBUG_OSPF_EVENT) {  		if (oi->ospf->vrf_id) -			zlog_debug("%s: Hello Tx interface %s ospf vrf %s id %u", -				    __PRETTY_FUNCTION__, oi->ifp->name, -				    ospf_vrf_id_to_name(oi->ospf->vrf_id), -				    oi->ospf->vrf_id); +			zlog_debug( +				"%s: Hello Tx interface %s ospf vrf %s id %u", +				__PRETTY_FUNCTION__, oi->ifp->name, +				ospf_vrf_id_to_name(oi->ospf->vrf_id), +				oi->ospf->vrf_id);  	}  	/* Add packet to the top of the interface output queue, so that they  	 * can't get delayed by things like long queues of LS Update packets @@ -4049,11 +4048,10 @@ void ospf_ls_upd_send(struct ospf_neighbor *nbr, struct list *update, int flag,  			ospf_ls_upd_queue_send(oi, send_update_list,  					       rn->p.u.prefix4, 1); -  		}  	} else  		thread_add_event(master, ospf_ls_upd_send_queue_event, oi, 0, -			 &oi->t_ls_upd_event); +				 &oi->t_ls_upd_event);  }  static void ospf_ls_ack_send_list(struct ospf_interface *oi, struct list *ack, @@ -4174,8 +4172,8 @@ void ospf_proactively_arp(struct ospf_neighbor *nbr)  		return;  	snprintf(ping_nbr, sizeof(ping_nbr), -		"ping -c 1 -I %s %s > /dev/null 2>&1 &", -		nbr->oi->ifp->name, inet_ntoa(nbr->address.u.prefix4)); +		 "ping -c 1 -I %s %s > /dev/null 2>&1 &", nbr->oi->ifp->name, +		 inet_ntoa(nbr->address.u.prefix4));  	ret = system(ping_nbr);  	if (IS_DEBUG_OSPF_EVENT) diff --git a/ospfd/ospf_ri.c b/ospfd/ospf_ri.c index 7c7a6fd795..e1d3e925ce 100644 --- a/ospfd/ospf_ri.c +++ b/ospfd/ospf_ri.c @@ -176,15 +176,12 @@ static int ospf_router_info_register(u_int8_t scope)  		scope, OPAQUE_TYPE_ROUTER_INFORMATION_LSA,  		NULL, /* new interface */  		NULL, /* del interface */ -		ospf_router_info_ism_change, -		ospf_router_info_nsm_change, +		ospf_router_info_ism_change, ospf_router_info_nsm_change,  		ospf_router_info_config_write_router,  		NULL, /* Config. write interface */  		NULL, /* Config. write debug */ -		ospf_router_info_show_info, -		ospf_router_info_lsa_originate, -		ospf_router_info_lsa_refresh, -		ospf_router_info_lsa_update, +		ospf_router_info_show_info, ospf_router_info_lsa_originate, +		ospf_router_info_lsa_refresh, ospf_router_info_lsa_update,  		NULL); /* del_lsa_hook */  	if (rc != 0) { @@ -465,7 +462,6 @@ static void set_sr_algorithm(uint8_t algo)  	/* Set TLV type and length == only 1 Algorithm */  	TLV_TYPE(OspfRI.sr_info.algo) = htons(RI_SR_TLV_SR_ALGORITHM);  	TLV_LEN(OspfRI.sr_info.algo) = htons(sizeof(uint8_t)); -  }  /* unset Aglogithm SubTLV */ @@ -478,7 +474,6 @@ static void unset_sr_algorithm(uint8_t algo)  	/* Unset TLV type and length */  	TLV_TYPE(OspfRI.sr_info.algo) = htons(0);  	TLV_LEN(OspfRI.sr_info.algo) = htons(0); -  }  /* Segment Routing Global Block SubTLV - section 3.2 */ @@ -494,7 +489,6 @@ static void set_sr_sid_label_range(struct sr_srgb srgb)  	TLV_TYPE(OspfRI.sr_info.range.lower) = htons(SUBTLV_SID_LABEL);  	TLV_LEN(OspfRI.sr_info.range.lower) = htons(SID_RANGE_LABEL_LENGTH);  	OspfRI.sr_info.range.lower.value = htonl(SET_LABEL(srgb.lower_bound)); -  }  /* Unset this SRGB SubTLV */ @@ -505,7 +499,6 @@ static void unset_sr_sid_label_range(void)  	TLV_LEN(OspfRI.sr_info.range) = htons(0);  	TLV_TYPE(OspfRI.sr_info.range.lower) = htons(0);  	TLV_LEN(OspfRI.sr_info.range.lower) = htons(0); -  }  /* Set Maximum Stack Depth for this router */ @@ -514,7 +507,6 @@ static void set_sr_node_msd(uint8_t msd)  	TLV_TYPE(OspfRI.sr_info.msd) = htons(RI_SR_TLV_NODE_MSD);  	TLV_LEN(OspfRI.sr_info.msd) = htons(sizeof(uint32_t));  	OspfRI.sr_info.msd.value = msd; -  }  /* Unset this router MSD */ @@ -522,7 +514,6 @@ static void unset_sr_node_msd(void)  {  	TLV_TYPE(OspfRI.sr_info.msd) = htons(0);  	TLV_LEN(OspfRI.sr_info.msd) = htons(0); -  }  static void unset_param(struct tlv_header *tlv) @@ -621,7 +612,7 @@ void ospf_router_info_update_sr(bool enable, struct sr_srgb srgb, uint8_t msd)  	if (IS_DEBUG_OSPF_SR)  		zlog_debug("RI-> %s Routing Information for Segment Routing", -			enable ? "Enable" : "Disable"); +			   enable ? "Enable" : "Disable");  	/* Unset or Set SR parameters */  	if (!enable) { @@ -709,7 +700,7 @@ static void ospf_router_info_lsa_body_set(struct stream *s)  	if (OspfRI.pce_info.enabled) {  		/* Compute PCE Info header first */ -		set_pce_header (&OspfRI.pce_info); +		set_pce_header(&OspfRI.pce_info);  		/* Build PCE TLV */  		build_tlv_header(s, &OspfRI.pce_info.pce_header.header); @@ -994,10 +985,12 @@ static void ospf_router_info_lsa_schedule(enum lsa_opcode opcode)  		   opcode == FLUSH_THIS_LSA ? "Flush" : "");  	/* Check LSA flags state coherence */ -	if (!CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED) && (opcode != REORIGINATE_THIS_LSA)) +	if (!CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED) +	    && (opcode != REORIGINATE_THIS_LSA))  		return; -	if (CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED) && (opcode == REORIGINATE_THIS_LSA)) +	if (CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED) +	    && (opcode == REORIGINATE_THIS_LSA))  		opcode = REFRESH_THIS_LSA;  	top = ospf_lookup_by_vrf_id(VRF_DEFAULT); @@ -1057,8 +1050,8 @@ static int ospf_router_info_lsa_update(struct ospf_lsa *lsa)  		return 0;  	/* Process only Router Information LSA */ -	if (GET_OPAQUE_TYPE(ntohl(lsa->data->id.s_addr)) != -			OPAQUE_TYPE_ROUTER_INFORMATION_LSA) +	if (GET_OPAQUE_TYPE(ntohl(lsa->data->id.s_addr)) +	    != OPAQUE_TYPE_ROUTER_INFORMATION_LSA)  		return 0;  	/* Check if it is not my LSA */ @@ -1082,8 +1075,7 @@ static int ospf_router_info_lsa_update(struct ospf_lsa *lsa)   * Followings are vty session control functions.   *------------------------------------------------------------------------*/ -static u_int16_t show_vty_router_cap(struct vty *vty, -				     struct tlv_header *tlvh) +static u_int16_t show_vty_router_cap(struct vty *vty, struct tlv_header *tlvh)  {  	struct ri_tlv_router_cap *top = (struct ri_tlv_router_cap *)tlvh; @@ -1200,8 +1192,7 @@ static u_int16_t show_vty_pce_subtlv_cap_flag(struct vty *vty,  	return TLV_SIZE(tlvh);  } -static u_int16_t show_vty_unknown_tlv(struct vty *vty, -				      struct tlv_header *tlvh) +static u_int16_t show_vty_unknown_tlv(struct vty *vty, struct tlv_header *tlvh)  {  	if (vty != NULL)  		vty_out(vty, "  Unknown TLV: [type(0x%x), length(0x%x)]\n", @@ -1496,8 +1487,8 @@ DEFUN (router_info,  	/* Refresh RI LSA if already engaged */  	if (CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED)) { -		zlog_debug ("RI-> Refresh LSA following configuration"); -		ospf_router_info_lsa_schedule (REFRESH_THIS_LSA); +		zlog_debug("RI-> Refresh LSA following configuration"); +		ospf_router_info_lsa_schedule(REFRESH_THIS_LSA);  	} else {  		zlog_debug("RI-> Initial origination following configuration");  		ospf_router_info_lsa_schedule(REORIGINATE_THIS_LSA); @@ -1891,8 +1882,7 @@ DEFUN (show_ip_opsf_router_info_pce,  						     &pce->pce_cap_flag.header);  	} else { -		vty_out(vty, -			"  PCE info is disabled on this router\n"); +		vty_out(vty, "  PCE info is disabled on this router\n");  	}  	return CMD_SUCCESS; diff --git a/ospfd/ospf_route.c b/ospfd/ospf_route.c index cc7c6d2666..60a2e2d3e8 100644 --- a/ospfd/ospf_route.c +++ b/ospfd/ospf_route.c @@ -54,7 +54,7 @@ struct ospf_route *ospf_route_new()  void ospf_route_free(struct ospf_route * or)  {  	if (or->paths) -		list_delete_and_null(&or->paths); +		list_delete_and_null(& or->paths);  	XFREE(MTYPE_OSPF_ROUTE, or);  } @@ -91,12 +91,11 @@ void ospf_route_delete(struct ospf *ospf, struct route_table *rt)  	for (rn = route_top(rt); rn; rn = route_next(rn))  		if ((or = rn->info) != NULL) {  			if (or->type == OSPF_DESTINATION_NETWORK) -				ospf_zebra_delete(ospf, -						  (struct prefix_ipv4 *)&rn->p, -						  or); +				ospf_zebra_delete( +					ospf, (struct prefix_ipv4 *)&rn->p, or);  			else if (or->type == OSPF_DESTINATION_DISCARD) -				ospf_zebra_delete_discard(ospf, -					(struct prefix_ipv4 *)&rn->p); +				ospf_zebra_delete_discard( +					ospf, (struct prefix_ipv4 *)&rn->p);  		}  } @@ -235,7 +234,8 @@ static void ospf_route_delete_uniq(struct ospf *ospf, struct route_table *rt,  						    cmprt,  						    (struct prefix_ipv4 *)&rn  							    ->p)) -						ospf_zebra_delete(ospf, +						ospf_zebra_delete( +							ospf,  							(struct prefix_ipv4  								 *)&rn->p,  							or); @@ -244,7 +244,8 @@ static void ospf_route_delete_uniq(struct ospf *ospf, struct route_table *rt,  						    cmprt,  						    (struct prefix_ipv4 *)&rn  							    ->p)) -						ospf_zebra_delete_discard(ospf, +						ospf_zebra_delete_discard( +							ospf,  							(struct prefix_ipv4  								 *)&rn->p);  			} @@ -277,14 +278,16 @@ void ospf_route_install(struct ospf *ospf, struct route_table *rt)  				if (!ospf_route_match_same(  					    ospf->old_table,  					    (struct prefix_ipv4 *)&rn->p, or)) -					ospf_zebra_add(ospf, +					ospf_zebra_add( +						ospf,  						(struct prefix_ipv4 *)&rn->p,  						or);  			} else if (or->type == OSPF_DESTINATION_DISCARD)  				if (!ospf_route_match_same(  					    ospf->old_table,  					    (struct prefix_ipv4 *)&rn->p, or)) -					ospf_zebra_add_discard(ospf, +					ospf_zebra_add_discard( +						ospf,  						(struct prefix_ipv4 *)&rn->p);  		}  } @@ -910,8 +913,7 @@ void ospf_prune_unreachable_routers(struct route_table *rtrs)  }  int ospf_add_discard_route(struct ospf *ospf, struct route_table *rt, -			   struct ospf_area *area, -			   struct prefix_ipv4 *p) +			   struct ospf_area *area, struct prefix_ipv4 *p)  {  	struct route_node *rn;  	struct ospf_route * or, *new_or; diff --git a/ospfd/ospf_routemap.c b/ospfd/ospf_routemap.c index f2769c6f38..bec0ec039b 100644 --- a/ospfd/ospf_routemap.c +++ b/ospfd/ospf_routemap.c @@ -69,15 +69,18 @@ static void ospf_route_map_update(const char *name)  					struct route_map *old = ROUTEMAP(red);  					/* Update route-map. */ -					ROUTEMAP(red) = route_map_lookup_by_name( -										 ROUTEMAP_NAME(red)); - -					/* No update for this distribute type. */ -					if (old == NULL && ROUTEMAP(red) == NULL) +					ROUTEMAP(red) = +						route_map_lookup_by_name( +							ROUTEMAP_NAME(red)); + +					/* No update for this distribute type. +					 */ +					if (old == NULL +					    && ROUTEMAP(red) == NULL)  						continue; -					ospf_distribute_list_update(ospf, type, -								    red->instance); +					ospf_distribute_list_update( +						ospf, type, red->instance);  				}  			}  		} @@ -103,8 +106,8 @@ static void ospf_route_map_event(route_map_event_t event, const char *name)  			for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) {  				if (ROUTEMAP_NAME(red) && ROUTEMAP(red)  				    && !strcmp(ROUTEMAP_NAME(red), name)) { -					ospf_distribute_list_update(ospf, type, -								red->instance); +					ospf_distribute_list_update( +						ospf, type, red->instance);  				}  			}  		} diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c index b28aebb81f..28826254e4 100644 --- a/ospfd/ospf_snmp.c +++ b/ospfd/ospf_snmp.c @@ -739,8 +739,6 @@ static u_char *ospfAreaEntry(struct variable *v, oid *name, size_t *length,  		return SNMP_INTEGER(0);  		break;  	case OSPFAREASUMMARY: /* 9 */ -			      /* $FRR indent$ */ -			      /* clang-format off */  #define OSPF_noAreaSummary   1  #define OSPF_sendAreaSummary 2  		if (area->no_summary) @@ -872,7 +870,7 @@ static u_char *ospfStubAreaEntry(struct variable *v, oid *name, size_t *length,  		return SNMP_INTEGER(SNMP_VALID);  		break;  	case OSPFSTUBMETRICTYPE: /* 5 */ -/* OSPF Metric type. */ +				 /* OSPF Metric type. */  #define OSPF_ospfMetric     1  #define OSPF_comparableCost 2  #define OSPF_nonComparable  3 @@ -1269,8 +1267,6 @@ static u_char *ospfAreaRangeEntry(struct variable *v, oid *name, size_t *length,  		return SNMP_INTEGER(SNMP_VALID);  		break;  	case OSPFAREARANGEEFFECT: /* 5 */ -				  /* $FRR indent$ */ -				  /* clang-format off */  #define OSPF_advertiseMatching      1  #define OSPF_doNotAdvertiseMatching 2  		return SNMP_INTEGER(OSPF_advertiseMatching); @@ -1744,8 +1740,6 @@ static u_char *ospfIfEntry(struct variable *v, oid *name, size_t *length,  		return SNMP_INTEGER(SNMP_VALID);  		break;  	case OSPFIFMULTICASTFORWARDING: /* 18 */ -					/* $FRR indent$ */ -					/* clang-format off */  #define ospf_snmp_multiforward_blocked    1  #define ospf_snmp_multiforward_multicast  2  #define ospf_snmp_multiforward_unicast    3 diff --git a/ospfd/ospf_spf.c b/ospfd/ospf_spf.c index 9c747cd565..f81210ffc9 100644 --- a/ospfd/ospf_spf.c +++ b/ospfd/ospf_spf.c @@ -781,8 +781,7 @@ static unsigned int ospf_nexthop_calculation(struct ospf_area *area,   * path is found to a vertex already on the candidate list, store the new cost.   */  static void ospf_spf_next(struct vertex *v, struct ospf *ospf, -			  struct ospf_area *area, -			  struct pqueue *candidate) +			  struct ospf_area *area, struct pqueue *candidate)  {  	struct ospf_lsa *w_lsa = NULL;  	u_char *p; @@ -1341,10 +1340,10 @@ static int ospf_spf_calculate_timer(struct thread *thread)  	ospf_ase_calculate_timer_add(ospf);  	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), -			   ospf->vrf_id, new_table->count); +		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), +			ospf->vrf_id, new_table->count);  	/* Update routing table. */  	monotime(&start_time);  	ospf_route_install(ospf, new_table); diff --git a/ospfd/ospf_sr.c b/ospfd/ospf_sr.c index fef77f574e..c7bc129a4b 100644 --- a/ospfd/ospf_sr.c +++ b/ospfd/ospf_sr.c @@ -105,7 +105,6 @@ static void del_sr_link(void *val)  	del_sid_nhlfe(srl->nhlfe[0]);  	del_sid_nhlfe(srl->nhlfe[1]);  	XFREE(MTYPE_OSPF_SR_PARAMS, val); -  }  /* Functions to remove an SR Prefix */ @@ -115,7 +114,6 @@ static void del_sr_pref(void *val)  	del_sid_nhlfe(srp->nhlfe);  	XFREE(MTYPE_OSPF_SR_PARAMS, val); -  }  /* Allocate new Segment Routine node */ @@ -256,8 +254,7 @@ static int ospf_sr_start(struct ospf *ospf)  	/* Start by looking to Router Info & Extended LSA in lsdb */  	if ((ospf != NULL) && (ospf->backbone != NULL)) { -		LSDB_LOOP(OPAQUE_AREA_LSDB(ospf->backbone), rn, lsa) -		{ +		LSDB_LOOP (OPAQUE_AREA_LSDB(ospf->backbone), rn, lsa) {  			if (IS_LSA_MAXAGE(lsa) || IS_LSA_SELF(lsa))  				continue;  			int lsa_id = @@ -428,7 +425,7 @@ static struct ospf_neighbor *get_neighbor_by_addr(struct ospf *top,  static struct ospf_path *get_nexthop_by_addr(struct ospf *top,  					     struct prefix_ipv4 p)  { -	struct ospf_route *or; +	struct ospf_route * or ;  	struct ospf_path *path;  	struct listnode *node;  	struct route_node *rn; @@ -835,9 +832,8 @@ static struct sr_prefix *get_ext_prefix_sid(struct tlv_header *tlvh)  		case EXT_SUBTLV_PREFIX_SID:  			psid = (struct ext_subtlv_prefix_sid *)sub_tlvh;  			if (psid->algorithm != SR_ALGORITHM_SPF) { -				zlog_err( -					"SR (%s): Unsupported Algorithm", -					__func__); +				zlog_err("SR (%s): Unsupported Algorithm", +					 __func__);  				XFREE(MTYPE_OSPF_SR_PARAMS, srp);  				return NULL;  			} @@ -1108,8 +1104,7 @@ void ospf_sr_ri_lsa_update(struct ospf_lsa *lsa)  		zlog_debug(  			"SR (%s): Process Router "  			"Information LSA 4.0.0.%u from %s", -			__func__, -			GET_OPAQUE_ID(ntohl(lsah->id.s_addr)), +			__func__, GET_OPAQUE_ID(ntohl(lsah->id.s_addr)),  			inet_ntoa(lsah->adv_router));  	/* Sanity check */ @@ -1127,9 +1122,8 @@ void ospf_sr_ri_lsa_update(struct ospf_lsa *lsa)  	/* Sanity check */  	if (srn == NULL) { -		zlog_err( -			"SR (%s): Abort! can't create SR node in hash table", -			__func__); +		zlog_err("SR (%s): Abort! can't create SR node in hash table", +			 __func__);  		return;  	} @@ -1137,8 +1131,7 @@ void ospf_sr_ri_lsa_update(struct ospf_lsa *lsa)  		zlog_err(  			"SR (%s): Abort! Wrong "  			"LSA ID 4.0.0.%u for SR node %s/%u", -			__func__, -			GET_OPAQUE_ID(ntohl(lsah->id.s_addr)), +			__func__, GET_OPAQUE_ID(ntohl(lsah->id.s_addr)),  			inet_ntoa(lsah->adv_router), srn->instance);  		return;  	} @@ -1182,9 +1175,8 @@ void ospf_sr_ri_lsa_update(struct ospf_lsa *lsa)  	/* Check that we collect mandatory parameters */  	if (srn->algo[0] == SR_ALGORITHM_UNSET || srgb.range_size == 0  	    || srgb.lower_bound == 0) { -		zlog_warn( -			"SR (%s): Missing mandatory parameters. Abort!", -			__func__); +		zlog_warn("SR (%s): Missing mandatory parameters. Abort!", +			  __func__);  		hash_release(OspfSR.neighbors, &(srn->adv_router));  		XFREE(MTYPE_OSPF_SR_PARAMS, srn);  		return; @@ -1211,7 +1203,6 @@ void ospf_sr_ri_lsa_update(struct ospf_lsa *lsa)  					       void *))update_out_nhlfe,  				     (void *)srn);  	} -  }  /* @@ -1224,10 +1215,9 @@ void ospf_sr_ri_lsa_delete(struct ospf_lsa *lsa)  	struct lsa_header *lsah = (struct lsa_header *)lsa->data;  	if (IS_DEBUG_OSPF_SR) -		zlog_debug( -			"SR (%s): Remove SR node %s from lsa_id 4.0.0.%u", -			__func__, inet_ntoa(lsah->adv_router), -			GET_OPAQUE_ID(ntohl(lsah->id.s_addr))); +		zlog_debug("SR (%s): Remove SR node %s from lsa_id 4.0.0.%u", +			   __func__, inet_ntoa(lsah->adv_router), +			   GET_OPAQUE_ID(ntohl(lsah->id.s_addr)));  	/* Sanity check */  	if (OspfSR.neighbors == NULL) { @@ -1240,23 +1230,20 @@ void ospf_sr_ri_lsa_delete(struct ospf_lsa *lsa)  	/* Sanity check */  	if (srn == NULL) { -		zlog_err( -			"SR (%s): Abort! no entry in SRDB for SR Node %s", -			__func__, inet_ntoa(lsah->adv_router)); +		zlog_err("SR (%s): Abort! no entry in SRDB for SR Node %s", +			 __func__, inet_ntoa(lsah->adv_router));  		return;  	}  	if ((srn->instance != 0) && (srn->instance != ntohl(lsah->id.s_addr))) { -		zlog_err( -			"SR (%s): Abort! Wrong LSA ID 4.0.0.%u for SR node %s", -			__func__, GET_OPAQUE_ID(ntohl(lsah->id.s_addr)), -			inet_ntoa(lsah->adv_router)); +		zlog_err("SR (%s): Abort! Wrong LSA ID 4.0.0.%u for SR node %s", +			 __func__, GET_OPAQUE_ID(ntohl(lsah->id.s_addr)), +			 inet_ntoa(lsah->adv_router));  		return;  	}  	/* Remove SR node */  	sr_node_del(srn); -  }  /* Update Segment Routing from Extended Link LSA */ @@ -1288,9 +1275,8 @@ void ospf_sr_ext_link_lsa_update(struct ospf_lsa *lsa)  	/* Sanity check */  	if (srn == NULL) { -		zlog_err( -			"SR (%s): Abort! can't create SR node in hash table", -			__func__); +		zlog_err("SR (%s): Abort! can't create SR node in hash table", +			 __func__);  		return;  	} @@ -1322,10 +1308,9 @@ void ospf_sr_ext_link_lsa_delete(struct ospf_lsa *lsa)  	uint32_t instance = ntohl(lsah->id.s_addr);  	if (IS_DEBUG_OSPF_SR) -		zlog_debug( -			"SR (%s): Remove Extended Link LSA 8.0.0.%u from %s", -			__func__, GET_OPAQUE_ID(ntohl(lsah->id.s_addr)), -			inet_ntoa(lsah->adv_router)); +		zlog_debug("SR (%s): Remove Extended Link LSA 8.0.0.%u from %s", +			   __func__, GET_OPAQUE_ID(ntohl(lsah->id.s_addr)), +			   inet_ntoa(lsah->adv_router));  	/* Sanity check */  	if (OspfSR.neighbors == NULL) { @@ -1342,9 +1327,8 @@ void ospf_sr_ext_link_lsa_delete(struct ospf_lsa *lsa)  	 * processing Router Information LSA deletion  	 */  	if (srn == NULL) { -		zlog_warn( -			"SR (%s): Stop! no entry in SRDB for SR Node %s", -			__func__, inet_ntoa(lsah->adv_router)); +		zlog_warn("SR (%s): Stop! no entry in SRDB for SR Node %s", +			  __func__, inet_ntoa(lsah->adv_router));  		return;  	} @@ -1362,11 +1346,10 @@ void ospf_sr_ext_link_lsa_delete(struct ospf_lsa *lsa)  	} else {  		zlog_warn(  			"SR (%s): Didn't found corresponding SR Link 8.0.0.%u " -			"for SR Node %s", __func__, -			GET_OPAQUE_ID(ntohl(lsah->id.s_addr)), +			"for SR Node %s", +			__func__, GET_OPAQUE_ID(ntohl(lsah->id.s_addr)),  			inet_ntoa(lsah->adv_router));  	} -  }  /* Update Segment Routing from Extended Prefix LSA */ @@ -1382,8 +1365,8 @@ void ospf_sr_ext_prefix_lsa_update(struct ospf_lsa *lsa)  	if (IS_DEBUG_OSPF_SR)  		zlog_debug(  			"SR (%s): Process Extended Prefix LSA " -			"7.0.0.%u from %s", __func__, -			GET_OPAQUE_ID(ntohl(lsah->id.s_addr)), +			"7.0.0.%u from %s", +			__func__, GET_OPAQUE_ID(ntohl(lsah->id.s_addr)),  			inet_ntoa(lsah->adv_router));  	/* Sanity check */ @@ -1399,9 +1382,8 @@ void ospf_sr_ext_prefix_lsa_update(struct ospf_lsa *lsa)  	/* Sanity check */  	if (srn == NULL) { -		zlog_err( -			"SR (%s): Abort! can't create SR node in hash table", -			__func__); +		zlog_err("SR (%s): Abort! can't create SR node in hash table", +			 __func__);  		return;  	} @@ -1453,9 +1435,8 @@ void ospf_sr_ext_prefix_lsa_delete(struct ospf_lsa *lsa)  	 * processing Router Information LSA deletion  	 */  	if (srn == NULL) { -		zlog_warn( -			"SR (%s):  Stop! no entry in SRDB for SR Node %s", -			__func__, inet_ntoa(lsah->adv_router)); +		zlog_warn("SR (%s):  Stop! no entry in SRDB for SR Node %s", +			  __func__, inet_ntoa(lsah->adv_router));  		return;  	} @@ -1472,11 +1453,10 @@ void ospf_sr_ext_prefix_lsa_delete(struct ospf_lsa *lsa)  	} else {  		zlog_warn(  			"SR (%s): Didn't found corresponding SR Prefix " -			"7.0.0.%u for SR Node %s", __func__, -			GET_OPAQUE_ID(ntohl(lsah->id.s_addr)), +			"7.0.0.%u for SR Node %s", +			__func__, GET_OPAQUE_ID(ntohl(lsah->id.s_addr)),  			inet_ntoa(lsah->adv_router));  	} -  }  /* Get Label for Extended Link SID */ @@ -1516,26 +1496,26 @@ void ospf_sr_update_prefix(struct interface *ifp, struct prefix *p)  	for (ALL_LIST_ELEMENTS_RO(OspfSR.self->ext_prefix, node, srp)) {  		if ((srp->nhlfe.ifindex == ifp->ifindex)  		    || ((IPV4_ADDR_SAME(&srp->nhlfe.prefv4.prefix, -		    &p->u.prefix4)) -		    && (srp->nhlfe.prefv4.prefixlen == p->prefixlen))) { +					&p->u.prefix4)) +			&& (srp->nhlfe.prefv4.prefixlen == p->prefixlen))) {  			/* Update Interface & Prefix info */  			srp->nhlfe.ifindex = ifp->ifindex;  			IPV4_ADDR_COPY(&srp->nhlfe.prefv4.prefix, -				&p->u.prefix4); +				       &p->u.prefix4);  			srp->nhlfe.prefv4.prefixlen = p->prefixlen;  			srp->nhlfe.prefv4.family = p->family;  			IPV4_ADDR_COPY(&srp->nhlfe.nexthop, &p->u.prefix4);  			/* OK. Let's Schedule Extended Prefix LSA */ -			srp->instance = ospf_ext_schedule_prefix_index(ifp, -				srp->sid, &srp->nhlfe.prefv4, srp->flags); +			srp->instance = ospf_ext_schedule_prefix_index( +				ifp, srp->sid, &srp->nhlfe.prefv4, srp->flags);  			/* Install NHLFE if NO-PHP is requested */  			if (CHECK_FLAG(srp->flags, -			    EXT_SUBTLV_PREFIX_SID_NPFLG)) { -				srp->nhlfe.label_in = index2label(srp->sid, -						OspfSR.self->srgb); +				       EXT_SUBTLV_PREFIX_SID_NPFLG)) { +				srp->nhlfe.label_in = index2label( +					srp->sid, OspfSR.self->srgb);  				srp->nhlfe.label_out = MPLS_LABEL_IMPLICIT_NULL;  				add_sid_nhlfe(srp->nhlfe);  			} @@ -1623,7 +1603,7 @@ static int ospf_sr_update_schedule(struct thread *t)  		zlog_debug("SR (%s): SPF Processing Time(usecs): %lld\n",  			   __func__,  			   (stop_time.tv_sec - start_time.tv_sec) * 1000000LL -			   + (stop_time.tv_usec - start_time.tv_usec)); +				   + (stop_time.tv_usec - start_time.tv_usec));  	OspfSR.update = false;  	return 1; @@ -1675,9 +1655,9 @@ void ospf_sr_config_write_router(struct vty *vty)  		if ((OspfSR.srgb.lower_bound != MPLS_DEFAULT_MIN_SRGB_LABEL)  		    || (OspfSR.srgb.range_size != MPLS_DEFAULT_MAX_SRGB_SIZE)) {  			vty_out(vty, " segment-routing global-block %u %u\n", -					OspfSR.srgb.lower_bound, -					OspfSR.srgb.lower_bound + -					OspfSR.srgb.range_size - 1); +				OspfSR.srgb.lower_bound, +				OspfSR.srgb.lower_bound + OspfSR.srgb.range_size +					- 1);  		}  		if (OspfSR.msd != 0)  			vty_out(vty, " segment-routing node-msd %u\n", @@ -1692,8 +1672,9 @@ void ospf_sr_config_write_router(struct vty *vty)  					inet_ntoa(srp->nhlfe.prefv4.prefix),  					srp->nhlfe.prefv4.prefixlen, srp->sid,  					CHECK_FLAG(srp->flags, -						EXT_SUBTLV_PREFIX_SID_NPFLG) ? -						" no-php-flag" : ""); +						   EXT_SUBTLV_PREFIX_SID_NPFLG) +						? " no-php-flag" +						: "");  			}  		}  	} @@ -1712,8 +1693,9 @@ DEFUN(ospf_sr_enable,  		return CMD_SUCCESS;  	if (ospf->vrf_id != VRF_DEFAULT) { -		vty_out(vty, "Segment Routing is only supported in default " -			     "VRF\n"); +		vty_out(vty, +			"Segment Routing is only supported in default " +			"VRF\n");  		return CMD_WARNING_CONFIG_FAILED;  	} @@ -1960,8 +1942,7 @@ DEFUN (sr_prefix_sid,  	/* Get network prefix */  	argv_find(argv, argc, "A.B.C.D/M", &idx);  	if (!str2prefix(argv[idx]->arg, &p)) { -		vty_out(vty, "Invalid prefix format %s\n", -			argv[idx]->arg); +		vty_out(vty, "Invalid prefix format %s\n", argv[idx]->arg);  		return CMD_WARNING_CONFIG_FAILED;  	} @@ -1997,10 +1978,9 @@ DEFUN (sr_prefix_sid,  	}  	if (IS_DEBUG_OSPF_SR) -		zlog_debug( -			"SR (%s): Add new index %u to Prefix %s/%u", -			__func__, index, inet_ntoa(new->nhlfe.prefv4.prefix), -			new->nhlfe.prefv4.prefixlen); +		zlog_debug("SR (%s): Add new index %u to Prefix %s/%u", +			   __func__, index, inet_ntoa(new->nhlfe.prefv4.prefix), +			   new->nhlfe.prefv4.prefixlen);  	/* Get Interface and check if it is a Loopback */  	ifp = if_lookup_prefix(&p, VRF_DEFAULT); @@ -2014,7 +1994,8 @@ DEFUN (sr_prefix_sid,  		listnode_add(OspfSR.self->ext_prefix, new);  		zlog_warn(  			"Interface for prefix %s/%u not found. Deferred LSA " -			"flooding", inet_ntoa(p.u.prefix4), p.prefixlen); +			"flooding", +			inet_ntoa(p.u.prefix4), p.prefixlen);  		return CMD_SUCCESS;  	} @@ -2028,7 +2009,7 @@ DEFUN (sr_prefix_sid,  	/* Search if this prefix already exist */  	for (ALL_LIST_ELEMENTS_RO(OspfSR.self->ext_prefix, node, srp)) {  		if ((IPV4_ADDR_SAME(&srp->nhlfe.prefv4.prefix, &p.u.prefix4) -		    && srp->nhlfe.prefv4.prefixlen == p.prefixlen)) +		     && srp->nhlfe.prefv4.prefixlen == p.prefixlen))  			break;  		else  			srp = NULL; @@ -2045,8 +2026,8 @@ DEFUN (sr_prefix_sid,  	}  	/* Finally, update Extended Prefix LSA */ -	new->instance = ospf_ext_schedule_prefix_index(ifp, new->sid, -				&new->nhlfe.prefv4, new->flags); +	new->instance = ospf_ext_schedule_prefix_index( +		ifp, new->sid, &new->nhlfe.prefv4, new->flags);  	if (new->instance == 0) {  		vty_out(vty, "Unable to set index %u for prefix %s/%u\n", index,  			inet_ntoa(p.u.prefix4), p.prefixlen); @@ -2079,8 +2060,7 @@ DEFUN (no_sr_prefix_sid,  	argv_find(argv, argc, "A.B.C.D/M", &idx);  	rc = str2prefix(argv[idx]->arg, &p);  	if (!rc) { -		vty_out(vty, "Invalid prefix format %s\n", -			argv[idx]->arg); +		vty_out(vty, "Invalid prefix format %s\n", argv[idx]->arg);  		return CMD_WARNING_CONFIG_FAILED;  	} @@ -2113,10 +2093,9 @@ DEFUN (no_sr_prefix_sid,  	}  	if (IS_DEBUG_OSPF_SR) -		zlog_debug( -			"SR (%s): Remove Prefix %s/%u with index %u", -			__func__, inet_ntoa(srp->nhlfe.prefv4.prefix), -			srp->nhlfe.prefv4.prefixlen, srp->sid); +		zlog_debug("SR (%s): Remove Prefix %s/%u with index %u", +			   __func__, inet_ntoa(srp->nhlfe.prefv4.prefix), +			   srp->nhlfe.prefv4.prefixlen, srp->sid);  	/* Delete NHLFE is NO-PHP is set */  	if (CHECK_FLAG(srp->flags, EXT_SUBTLV_PREFIX_SID_NPFLG)) @@ -2130,9 +2109,8 @@ DEFUN (no_sr_prefix_sid,  } -  static void show_sr_node(struct vty *vty, struct json_object *json, -			     struct sr_node *srn) +			 struct sr_node *srn)  {  	struct listnode *node; @@ -2152,11 +2130,11 @@ static void show_sr_node(struct vty *vty, struct json_object *json,  	if (json) {  		json_node = json_object_new_object();  		json_object_string_add(json_node, "routerID", -			inet_ntoa(srn->adv_router)); +				       inet_ntoa(srn->adv_router));  		json_object_int_add(json_node, "srgbSize", -			srn->srgb.range_size); +				    srn->srgb.range_size);  		json_object_int_add(json_node, "srgbLabel", -			srn->srgb.lower_bound); +				    srn->srgb.lower_bound);  		json_algo = json_object_new_array();  		json_object_object_add(json_node, "algorithms", json_algo);  		for (int i = 0; i < ALGORITHM_COUNT; i++) { @@ -2167,24 +2145,25 @@ static void show_sr_node(struct vty *vty, struct json_object *json,  			snprintf(tmp, 2, "%u", i);  			json_object_string_add(json_obj, tmp, -				srn->algo[i] == SR_ALGORITHM_SPF ? -						"SPF" : "S-SPF"); +					       srn->algo[i] == SR_ALGORITHM_SPF +						       ? "SPF" +						       : "S-SPF");  			json_object_array_add(json_algo, json_obj);  		}  		if (srn->msd != 0)  			json_object_int_add(json_node, "nodeMsd", srn->msd);  	} else {  		vty_out(vty, "SR-Node: %s", inet_ntoa(srn->adv_router)); -		vty_out(vty, "\tSRGB (Size/Label): %u/%u", -			srn->srgb.range_size, srn->srgb.lower_bound); +		vty_out(vty, "\tSRGB (Size/Label): %u/%u", srn->srgb.range_size, +			srn->srgb.lower_bound);  		vty_out(vty, "\tAlgorithm(s): %s",  			srn->algo[0] == SR_ALGORITHM_SPF ? "SPF" : "S-SPF");  		for (int i = 1; i < ALGORITHM_COUNT; i++) {  			if (srn->algo[i] == SR_ALGORITHM_UNSET)  				continue;  			vty_out(vty, "/%s", -				srn->algo[i] == SR_ALGORITHM_SPF ? -						"SPF" : "S-SPF"); +				srn->algo[i] == SR_ALGORITHM_SPF ? "SPF" +								 : "S-SPF");  		}  		if (srn->msd != 0)  			vty_out(vty, "\tMSD: %u", srn->msd); @@ -2199,9 +2178,8 @@ static void show_sr_node(struct vty *vty, struct json_object *json,  			"---------------------  ---------  ---------------\n");  	}  	for (ALL_LIST_ELEMENTS_RO(srn->ext_prefix, node, srp)) { -		snprintf(pref, 19, "%s/%u", -			inet_ntoa(srp->nhlfe.prefv4.prefix), -			srp->nhlfe.prefv4.prefixlen); +		snprintf(pref, 19, "%s/%u", inet_ntoa(srp->nhlfe.prefv4.prefix), +			 srp->nhlfe.prefv4.prefixlen);  		snprintf(sid, 22, "SR Pfx (idx %u)", srp->sid);  		if (srp->nhlfe.label_out == MPLS_LABEL_IMPLICIT_NULL)  			sprintf(label, "pop"); @@ -2212,32 +2190,32 @@ static void show_sr_node(struct vty *vty, struct json_object *json,  			if (!json_prefix) {  				json_prefix = json_object_new_array();  				json_object_object_add(json_node, -					"extendedPrefix", json_prefix); +						       "extendedPrefix", +						       json_prefix);  			}  			json_obj = json_object_new_object();  			json_object_string_add(json_obj, "prefix", pref);  			json_object_int_add(json_obj, "sid", srp->sid);  			json_object_int_add(json_obj, "inputLabel", -				srp->nhlfe.label_in); -			json_object_string_add(json_obj, "outputLabel", -				label); +					    srp->nhlfe.label_in); +			json_object_string_add(json_obj, "outputLabel", label);  			json_object_string_add(json_obj, "interface", -				itf ? itf->name : "-"); +					       itf ? itf->name : "-");  			json_object_string_add(json_obj, "nexthop", -				inet_ntoa(srp->nhlfe.nexthop)); +					       inet_ntoa(srp->nhlfe.nexthop));  			json_object_array_add(json_prefix, json_obj);  		} else { -			vty_out(vty, "%18s  %8u  %9s  %21s  %9s  %15s\n", -				pref, srp->nhlfe.label_in, label, -				sid, itf ? itf->name : "-", +			vty_out(vty, "%18s  %8u  %9s  %21s  %9s  %15s\n", pref, +				srp->nhlfe.label_in, label, sid, +				itf ? itf->name : "-",  				inet_ntoa(srp->nhlfe.nexthop));  		}  	}  	for (ALL_LIST_ELEMENTS_RO(srn->ext_link, node, srl)) {  		snprintf(pref, 19, "%s/%u", -			inet_ntoa(srl->nhlfe[0].prefv4.prefix), -			srl->nhlfe[0].prefv4.prefixlen); +			 inet_ntoa(srl->nhlfe[0].prefv4.prefix), +			 srl->nhlfe[0].prefv4.prefixlen);  		snprintf(sid, 22, "SR Adj. (lbl %u)", srl->sid[0]);  		if (srl->nhlfe[0].label_out == MPLS_LABEL_IMPLICIT_NULL)  			sprintf(label, "pop"); @@ -2247,20 +2225,20 @@ static void show_sr_node(struct vty *vty, struct json_object *json,  		if (json) {  			if (!json_link) {  				json_link = json_object_new_array(); -				json_object_object_add(json_node, -					"extendedLink", json_link); +				json_object_object_add( +					json_node, "extendedLink", json_link);  			}  			/* Primary Link */  			json_obj = json_object_new_object();  			json_object_string_add(json_obj, "prefix", pref);  			json_object_int_add(json_obj, "sid", srl->sid[0]);  			json_object_int_add(json_obj, "inputLabel", -				srl->nhlfe[0].label_in); -			json_object_string_add(json_obj, "outputLabel", -				label); +					    srl->nhlfe[0].label_in); +			json_object_string_add(json_obj, "outputLabel", label);  			json_object_string_add(json_obj, "interface", -				itf ? itf->name : "-"); -			json_object_string_add(json_obj, "nexthop", +					       itf ? itf->name : "-"); +			json_object_string_add( +				json_obj, "nexthop",  				inet_ntoa(srl->nhlfe[0].nexthop));  			json_object_array_add(json_link, json_obj);  			/* Backup Link */ @@ -2273,27 +2251,27 @@ static void show_sr_node(struct vty *vty, struct json_object *json,  			json_object_string_add(json_obj, "prefix", pref);  			json_object_int_add(json_obj, "sid", srl->sid[1]);  			json_object_int_add(json_obj, "inputLabel", -				srl->nhlfe[1].label_in); -			json_object_string_add(json_obj, "outputLabel", -				label); +					    srl->nhlfe[1].label_in); +			json_object_string_add(json_obj, "outputLabel", label);  			json_object_string_add(json_obj, "interface", -				itf ? itf->name : "-"); -			json_object_string_add(json_obj, "nexthop", +					       itf ? itf->name : "-"); +			json_object_string_add( +				json_obj, "nexthop",  				inet_ntoa(srl->nhlfe[1].nexthop));  			json_object_array_add(json_link, json_obj);  		} else { -			vty_out(vty, "%18s  %8u  %9s  %21s  %9s  %15s\n", -				pref, srl->nhlfe[0].label_in, -				label, sid, itf ? itf->name : "-", +			vty_out(vty, "%18s  %8u  %9s  %21s  %9s  %15s\n", pref, +				srl->nhlfe[0].label_in, label, sid, +				itf ? itf->name : "-",  				inet_ntoa(srl->nhlfe[0].nexthop));  			snprintf(sid, 22, "SR Adj. (lbl %u)", srl->sid[1]);  			if (srl->nhlfe[1].label_out == MPLS_LABEL_IMPLICIT_NULL)  				sprintf(label, "pop");  			else  				sprintf(label, "%u", srl->nhlfe[1].label_out); -			vty_out(vty, "%18s  %8u  %9s  %21s  %9s  %15s\n", -				pref, srl->nhlfe[1].label_in, -				label, sid, itf ? itf->name : "-", +			vty_out(vty, "%18s  %8u  %9s  %21s  %9s  %15s\n", pref, +				srl->nhlfe[1].label_in, label, sid, +				itf ? itf->name : "-",  				inet_ntoa(srl->nhlfe[1].nexthop));  		}  	} @@ -2347,7 +2325,7 @@ DEFUN (show_ip_opsf_srdb,  		json = json_object_new_object();  		json_node_array = json_object_new_array();  		json_object_string_add(json, "srdbID", -			inet_ntoa(OspfSR.self->adv_router)); +				       inet_ntoa(OspfSR.self->adv_router));  		json_object_object_add(json, "srNodes", json_node_array);  	} else {  		vty_out(vty, @@ -2360,8 +2338,8 @@ DEFUN (show_ip_opsf_srdb,  		show_sr_node(vty, json_node_array, srn);  		if (uj) {  			vty_out(vty, "%s\n", -				json_object_to_json_string_ext(json, -					  JSON_C_TO_STRING_PRETTY)); +				json_object_to_json_string_ext( +					json, JSON_C_TO_STRING_PRETTY));  			json_object_free(json);  		}  		return CMD_SUCCESS; @@ -2369,8 +2347,7 @@ DEFUN (show_ip_opsf_srdb,  	if (argv_find(argv, argc, "A.B.C.D", &idx)) {  		if (!inet_aton(argv[idx]->arg, &rid)) { -			vty_out(vty, -				"Specified Router ID %s is invalid\n", +			vty_out(vty, "Specified Router ID %s is invalid\n",  				argv[idx]->arg);  			return CMD_WARNING_CONFIG_FAILED;  		} @@ -2380,8 +2357,8 @@ DEFUN (show_ip_opsf_srdb,  		show_sr_node(vty, json_node_array, srn);  		if (uj) {  			vty_out(vty, "%s\n", -				json_object_to_json_string_ext(json, -					  JSON_C_TO_STRING_PRETTY)); +				json_object_to_json_string_ext( +					json, JSON_C_TO_STRING_PRETTY));  			json_object_free(json);  		}  		return CMD_SUCCESS; @@ -2389,19 +2366,16 @@ DEFUN (show_ip_opsf_srdb,  	/* No parameters have been provided, Iterate through all the SRDB */  	if (uj) { -		hash_iterate( -			OspfSR.neighbors, -			(void (*)(struct hash_backet *, void *))show_json_srdb, -			(void *)json_node_array); -		vty_out(vty, "%s\n", -			json_object_to_json_string_ext(json, -				  JSON_C_TO_STRING_PRETTY)); +		hash_iterate(OspfSR.neighbors, (void (*)(struct hash_backet *, +							 void *))show_json_srdb, +			     (void *)json_node_array); +		vty_out(vty, "%s\n", json_object_to_json_string_ext( +					     json, JSON_C_TO_STRING_PRETTY));  		json_object_free(json);  	} else { -		hash_iterate( -			OspfSR.neighbors, -			(void (*)(struct hash_backet *, void *))show_vty_srdb, -			(void *)vty); +		hash_iterate(OspfSR.neighbors, (void (*)(struct hash_backet *, +							 void *))show_vty_srdb, +			     (void *)vty);  	}  	return CMD_SUCCESS;  } @@ -2419,5 +2393,4 @@ void ospf_sr_register_vty(void)  	install_element(OSPF_NODE, &no_sr_node_msd_cmd);  	install_element(OSPF_NODE, &sr_prefix_sid_cmd);  	install_element(OSPF_NODE, &no_sr_prefix_sid_cmd); -  } diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c index ab395207b9..276a5765f8 100644 --- a/ospfd/ospf_te.c +++ b/ospfd/ospf_te.c @@ -236,9 +236,9 @@ static struct mpls_te_link *lookup_linkparams_by_instance(struct ospf_lsa *lsa)  	return NULL;  } -static void ospf_mpls_te_foreach_area(void (*func)(struct mpls_te_link *lp, -					enum lsa_opcode sched_opcode), -				      enum lsa_opcode sched_opcode) +static void ospf_mpls_te_foreach_area( +	void (*func)(struct mpls_te_link *lp, enum lsa_opcode sched_opcode), +	enum lsa_opcode sched_opcode)  {  	struct listnode *node, *nnode;  	struct listnode *node2; @@ -772,7 +772,7 @@ static void initialize_linkparams(struct mpls_te_link *lp)  			ifp->name);  	/* Search OSPF Interface parameters for this interface */ -	for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) { +	for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn)) {  		if ((oi = rn->info) == NULL)  			continue; @@ -948,9 +948,11 @@ void ospf_mpls_te_update_if(struct interface *ifp)  		if (OspfMplsTE.enabled)  			if (lp->area != NULL) {  				if (CHECK_FLAG(lp->flags, LPFLG_LSA_ENGAGED)) -					ospf_mpls_te_lsa_schedule(lp, REFRESH_THIS_LSA); +					ospf_mpls_te_lsa_schedule( +						lp, REFRESH_THIS_LSA);  				else -					ospf_mpls_te_lsa_schedule(lp, REORIGINATE_THIS_LSA); +					ospf_mpls_te_lsa_schedule( +						lp, REORIGINATE_THIS_LSA);  			}  	} else {  		/* If MPLS TE is disable on this interface, flush LSA if it is @@ -1037,7 +1039,8 @@ static void ospf_mpls_te_ism_change(struct ospf_interface *oi, int old_state)  			if (CHECK_FLAG(lp->flags, LPFLG_LSA_ENGAGED))  				ospf_mpls_te_lsa_schedule(lp, REFRESH_THIS_LSA);  			else -				ospf_mpls_te_lsa_schedule(lp, REORIGINATE_THIS_LSA); +				ospf_mpls_te_lsa_schedule(lp, +							  REORIGINATE_THIS_LSA);  		}  		break;  	default: @@ -1379,8 +1382,7 @@ static int ospf_mpls_te_lsa_originate_as(void *arg)  	struct mpls_te_link *lp;  	int rc = -1; -	if ((!OspfMplsTE.enabled) -	    || (OspfMplsTE.inter_as == Off)) { +	if ((!OspfMplsTE.enabled) || (OspfMplsTE.inter_as == Off)) {  		zlog_info(  			"ospf_mpls_te_lsa_originate_as: MPLS-TE Inter-AS is disabled for now.");  		rc = 0; /* This is not an error case. */ @@ -1395,7 +1397,7 @@ static int ospf_mpls_te_lsa_originate_as(void *arg)  		if (CHECK_FLAG(lp->flags, LPFLG_LSA_ENGAGED)) {  			if (CHECK_FLAG(lp->flags, LPFLG_LSA_FORCED_REFRESH)) { -				UNSET_FLAG(lp->flags,LPFLG_LSA_FORCED_REFRESH); +				UNSET_FLAG(lp->flags, LPFLG_LSA_FORCED_REFRESH);  				ospf_mpls_te_lsa_schedule(lp, REFRESH_THIS_LSA);  			}  			continue; @@ -1596,8 +1598,7 @@ void ospf_mpls_te_lsa_schedule(struct mpls_te_link *lp, enum lsa_opcode opcode)   * Followings are vty session control functions.   *------------------------------------------------------------------------*/ -static u_int16_t show_vty_router_addr(struct vty *vty, -				      struct tlv_header *tlvh) +static u_int16_t show_vty_router_addr(struct vty *vty, struct tlv_header *tlvh)  {  	struct te_tlv_router_addr *top = (struct te_tlv_router_addr *)tlvh; @@ -1609,8 +1610,7 @@ static u_int16_t show_vty_router_addr(struct vty *vty,  	return TLV_SIZE(tlvh);  } -static u_int16_t show_vty_link_header(struct vty *vty, -				      struct tlv_header *tlvh) +static u_int16_t show_vty_link_header(struct vty *vty, struct tlv_header *tlvh)  {  	struct te_tlv_link *top = (struct te_tlv_link *)tlvh; @@ -2037,8 +2037,7 @@ static u_int16_t show_vty_link_subtlv_use_bw(struct vty *vty,  	return TLV_SIZE(tlvh);  } -static u_int16_t show_vty_unknown_tlv(struct vty *vty, -				      struct tlv_header *tlvh) +static u_int16_t show_vty_unknown_tlv(struct vty *vty, struct tlv_header *tlvh)  {  	if (vty != NULL)  		vty_out(vty, "  Unknown TLV: [type(0x%x), length(0x%x)]\n", @@ -2411,8 +2410,7 @@ DEFUN (no_ospf_mpls_te_inter_as,  	if (IS_DEBUG_OSPF_EVENT)  		zlog_debug("MPLS-TE: Inter-AS support OFF"); -	if ((OspfMplsTE.enabled) -	    && (OspfMplsTE.inter_as != Off)) { +	if ((OspfMplsTE.enabled) && (OspfMplsTE.inter_as != Off)) {  		OspfMplsTE.inter_as = Off;  		/* Flush all Inter-AS LSA */  		for (ALL_LIST_ELEMENTS(OspfMplsTE.iflist, node, nnode, lp)) @@ -2452,8 +2450,8 @@ static void show_mpls_te_link_sub(struct vty *vty, struct interface *ifp)  {  	struct mpls_te_link *lp; -	if ((OspfMplsTE.enabled) && HAS_LINK_PARAMS(ifp) -	    && !if_is_loopback(ifp) && if_is_up(ifp) +	if ((OspfMplsTE.enabled) && HAS_LINK_PARAMS(ifp) && !if_is_loopback(ifp) +	    && if_is_up(ifp)  	    && ((lp = lookup_linkparams_by_ifp(ifp)) != NULL)) {  		/* Continue only if interface is not passive or support Inter-AS  		 * TEv2 */ @@ -2571,7 +2569,7 @@ DEFUN (show_ip_ospf_mpls_te_link,  			}  			return CMD_SUCCESS;  		} -		ospf = ospf_lookup_by_inst_name (inst, vrf_name); +		ospf = ospf_lookup_by_inst_name(inst, vrf_name);  		if (ospf == NULL || !ospf->oi_running)  			return CMD_SUCCESS;  		vrf = vrf_lookup_by_id(ospf->vrf_id); diff --git a/ospfd/ospf_te.h b/ospfd/ospf_te.h index ed71e54f54..ff93974986 100644 --- a/ospfd/ospf_te.h +++ b/ospfd/ospf_te.h @@ -132,49 +132,49 @@ struct te_link_subtlv_link_type {  #define	TE_LINK_SUBTLV_LINK_ID		2  struct te_link_subtlv_link_id {  	struct tlv_header header; /* Value length is 4 octets. */ -	struct in_addr value;	/* Same as router-lsa's link-id. */ +	struct in_addr value;     /* Same as router-lsa's link-id. */  };  /* Link Sub-TLV: Local Interface IP Address */ /* Optional */  #define	TE_LINK_SUBTLV_LCLIF_IPADDR	3  struct te_link_subtlv_lclif_ipaddr {  	struct tlv_header header; /* Value length is 4 x N octets. */ -	struct in_addr value[1];     /* Local IP address(es). */ +	struct in_addr value[1];  /* Local IP address(es). */  };  /* Link Sub-TLV: Remote Interface IP Address */ /* Optional */  #define	TE_LINK_SUBTLV_RMTIF_IPADDR	4  struct te_link_subtlv_rmtif_ipaddr {  	struct tlv_header header; /* Value length is 4 x N octets. */ -	struct in_addr value[1];     /* Neighbor's IP address(es). */ +	struct in_addr value[1];  /* Neighbor's IP address(es). */  };  /* Link Sub-TLV: Traffic Engineering Metric */ /* Optional */  #define	TE_LINK_SUBTLV_TE_METRIC	5  struct te_link_subtlv_te_metric {  	struct tlv_header header; /* Value length is 4 octets. */ -	u_int32_t value;	     /* Link metric for TE purpose. */ +	u_int32_t value;	  /* Link metric for TE purpose. */  };  /* Link Sub-TLV: Maximum Bandwidth */ /* Optional */  #define	TE_LINK_SUBTLV_MAX_BW		6  struct te_link_subtlv_max_bw {  	struct tlv_header header; /* Value length is 4 octets. */ -	float value;		     /* bytes/sec */ +	float value;		  /* bytes/sec */  };  /* Link Sub-TLV: Maximum Reservable Bandwidth */ /* Optional */  #define	TE_LINK_SUBTLV_MAX_RSV_BW	7  struct te_link_subtlv_max_rsv_bw {  	struct tlv_header header; /* Value length is 4 octets. */ -	float value;		     /* bytes/sec */ +	float value;		  /* bytes/sec */  };  /* Link Sub-TLV: Unreserved Bandwidth */ /* Optional */  #define	TE_LINK_SUBTLV_UNRSV_BW		8  #define TE_LINK_SUBTLV_UNRSV_SIZE	32  struct te_link_subtlv_unrsv_bw { -	struct tlv_header header; /* Value length is 32 octets. */ +	struct tlv_header header;    /* Value length is 32 octets. */  	float value[MAX_CLASS_TYPE]; /* One for each priority level. */  }; @@ -182,7 +182,7 @@ struct te_link_subtlv_unrsv_bw {  #define	TE_LINK_SUBTLV_RSC_CLSCLR	9  struct te_link_subtlv_rsc_clsclr {  	struct tlv_header header; /* Value length is 4 octets. */ -	u_int32_t value;	     /* Admin. group membership. */ +	u_int32_t value;	  /* Admin. group membership. */  };  /* For RFC6827 */ @@ -191,8 +191,8 @@ struct te_link_subtlv_rsc_clsclr {  #define TE_LINK_SUBTLV_LRRID_SIZE	8  struct te_link_subtlv_lrrid {  	struct tlv_header header; /* Value length is 8 octets. */ -	struct in_addr local;	/* Local TE Router Identifier */ -	struct in_addr remote;       /* Remote TE Router Identifier */ +	struct in_addr local;     /* Local TE Router Identifier */ +	struct in_addr remote;    /* Remote TE Router Identifier */  };  /* RFC4203: Link Local/Remote Identifiers */ @@ -200,8 +200,8 @@ struct te_link_subtlv_lrrid {  #define TE_LINK_SUBTLV_LLRI_SIZE	8  struct te_link_subtlv_llri {  	struct tlv_header header; /* Value length is 8 octets. */ -	u_int32_t local;	     /* Link Local Identifier */ -	u_int32_t remote;	    /* Link Remote Identifier */ +	u_int32_t local;	  /* Link Local Identifier */ +	u_int32_t remote;	 /* Link Remote Identifier */  };  /* Inter-RA Export Upward sub-TLV (12) and Inter-RA Export Downward sub-TLV (13) @@ -215,14 +215,14 @@ struct te_link_subtlv_llri {  #define TE_LINK_SUBTLV_RAS		21  struct te_link_subtlv_ras {  	struct tlv_header header; /* Value length is 4 octets. */ -	u_int32_t value;	     /* Remote AS number */ +	u_int32_t value;	  /* Remote AS number */  };  /* IPv4 Remote ASBR ID Sub-TLV */  #define TE_LINK_SUBTLV_RIP		22  struct te_link_subtlv_rip {  	struct tlv_header header; /* Value length is 4 octets. */ -	struct in_addr value;	/* Remote ASBR IP address */ +	struct in_addr value;     /* Remote ASBR IP address */  };  /* SUBTLV 24 is IPv6 Remote ASBR ID (RFC5392). see ospf6d */ diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 68fb2f5676..ee53497af1 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -126,16 +126,15 @@ int ospf_oi_count(struct interface *ifp)  	return i;  } -#define OSPF_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf) \ -	if (argv_find(argv, argc, "vrf", &idx_vrf)) { \ -		vrf_name = argv[idx_vrf + 1]->arg; \ -		all_vrf = strmatch(vrf_name, "all"); \ +#define OSPF_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf)             \ +	if (argv_find(argv, argc, "vrf", &idx_vrf)) {                          \ +		vrf_name = argv[idx_vrf + 1]->arg;                             \ +		all_vrf = strmatch(vrf_name, "all");                           \  	}  static struct ospf *ospf_cmd_lookup_ospf(struct vty *vty,  					 struct cmd_token *argv[], -					 const int argc, -					 uint32_t enable, +					 const int argc, uint32_t enable,  					 u_short *instance)  {  	struct ospf *ospf = NULL; @@ -218,9 +217,10 @@ DEFUN_NOSH (router_ospf,  		if (ospf->vrf_id != VRF_UNKNOWN)  			ospf->oi_running = 1;  		if (IS_DEBUG_OSPF_EVENT) -			zlog_debug("Config command 'router ospf %d' received, vrf %s id %u oi_running %u", -				   instance,  ospf->name ? ospf->name : "NIL", -				   ospf->vrf_id, ospf->oi_running); +			zlog_debug( +				"Config command 'router ospf %d' received, vrf %s id %u oi_running %u", +				instance, ospf->name ? ospf->name : "NIL", +				ospf->vrf_id, ospf->oi_running);  		VTY_PUSH_CONTEXT(OSPF_NODE, ospf);  		/* Activate 'ip ospf area x' configured interfaces for given @@ -240,8 +240,8 @@ DEFUN_NOSH (router_ospf,  				     rn = route_next(rn)) {  					if (rn->info != NULL) {  						vty_out(vty, -						"Interface %s has area config but please remove all network commands first.\n", -						ifp->name); +							"Interface %s has area config but please remove all network commands first.\n", +							ifp->name);  						return ret;  					}  				} @@ -463,8 +463,7 @@ DEFUN (ospf_passive_interface,  		ifp = if_get_by_name(argv[1]->arg, ospf->vrf_id, 0);  	if (ifp == NULL) { -		vty_out(vty, "interface %s not found.\n", -			(char *)argv[1]->arg); +		vty_out(vty, "interface %s not found.\n", (char *)argv[1]->arg);  		return CMD_WARNING_CONFIG_FAILED;  	} @@ -537,8 +536,7 @@ DEFUN (no_ospf_passive_interface,  		ifp = if_get_by_name(argv[2]->arg, ospf->vrf_id, 0);  	if (ifp == NULL) { -		vty_out(vty, "interface %s not found.\n", -			(char *)argv[2]->arg); +		vty_out(vty, "interface %s not found.\n", (char *)argv[2]->arg);  		return CMD_WARNING_CONFIG_FAILED;  	} @@ -605,10 +603,11 @@ DEFUN (ospf_network_area,  		vty_out(vty,  			"Please remove all ip ospf area x.x.x.x commands first.\n");  		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", -				   ospf->if_ospf_cli_count); +			zlog_debug( +				"%s ospf vrf %s num of %u ip osp area x config", +				__PRETTY_FUNCTION__, +				ospf->name ? ospf->name : "NIL", +				ospf->if_ospf_cli_count);  		return CMD_WARNING_CONFIG_FAILED;  	} @@ -1984,7 +1983,9 @@ DEFUN (ospf_area_authentication_message_digest,  	area = ospf_area_get(ospf, area_id);  	ospf_area_display_format_set(ospf, area, format); -	area->auth_type = strmatch(argv[0]->text, "no") ? OSPF_AUTH_NULL : OSPF_AUTH_CRYPTOGRAPHIC; +	area->auth_type = strmatch(argv[0]->text, "no") +				  ? OSPF_AUTH_NULL +				  : OSPF_AUTH_CRYPTOGRAPHIC;  	return CMD_SUCCESS;  } @@ -2340,25 +2341,22 @@ DEFUN (no_ospf_timers_lsa_min_arrival,  #if CONFDATE > 20180708  CPP_NOTICE("ospf: `timers lsa arrival (0-1000)` deprecated 2017/07/08")  #endif -ALIAS_HIDDEN (ospf_timers_lsa_min_arrival, -              ospf_timers_lsa_arrival_cmd, -              "timers lsa arrival (0-1000)", -              "adjust routing timers\n" -              "throttling link state advertisement delays\n" -              "ospf minimum arrival interval delay\n" -              "delay (msec) between accepted lsas\n"); +ALIAS_HIDDEN(ospf_timers_lsa_min_arrival, ospf_timers_lsa_arrival_cmd, +	     "timers lsa arrival (0-1000)", +	     "adjust routing timers\n" +	     "throttling link state advertisement delays\n" +	     "ospf minimum arrival interval delay\n" +	     "delay (msec) between accepted lsas\n");  #if CONFDATE > 20180708  CPP_NOTICE("ospf: `no timers lsa arrival (0-1000)` deprecated 2017/07/08")  #endif -ALIAS_HIDDEN (no_ospf_timers_lsa_min_arrival, -              no_ospf_timers_lsa_arrival_cmd, -              "no timers lsa arrival (0-1000)", -              NO_STR -              "adjust routing timers\n" -              "throttling link state advertisement delays\n" -              "ospf minimum arrival interval delay\n" -              "delay (msec) between accepted lsas\n"); +ALIAS_HIDDEN(no_ospf_timers_lsa_min_arrival, no_ospf_timers_lsa_arrival_cmd, +	     "no timers lsa arrival (0-1000)", NO_STR +	     "adjust routing timers\n" +	     "throttling link state advertisement delays\n" +	     "ospf minimum arrival interval delay\n" +	     "delay (msec) between accepted lsas\n");  DEFUN (ospf_neighbor, @@ -3284,7 +3282,7 @@ DEFUN (show_ip_ospf,  	if (uj)  		json = json_object_new_object(); -	  /* vrf input is provided could be all or specific vrf*/ +	/* vrf input is provided could be all or specific vrf*/  	if (vrf_name) {  		use_vrf = 1;  		if (all_vrf) { @@ -3296,8 +3294,8 @@ DEFUN (show_ip_ospf,  			}  			if (uj) {  				vty_out(vty, "%s\n", -					json_object_to_json_string_ext(json, -						  JSON_C_TO_STRING_PRETTY)); +					json_object_to_json_string_ext( +						json, JSON_C_TO_STRING_PRETTY));  				json_object_free(json);  			}  			return ret; @@ -3318,11 +3316,12 @@ DEFUN (show_ip_ospf,  		}  	} -	if (ospf)  { +	if (ospf) {  		show_ip_ospf_common(vty, ospf, json, use_vrf);  		if (uj) -			vty_out(vty, "%s\n", json_object_to_json_string_ext( -					     json, JSON_C_TO_STRING_PRETTY)); +			vty_out(vty, "%s\n", +				json_object_to_json_string_ext( +					json, JSON_C_TO_STRING_PRETTY));  	}  	if (uj) @@ -3361,8 +3360,8 @@ DEFUN (show_ip_ospf_instance,  	ret = show_ip_ospf_common(vty, ospf, json, 0);  	if (uj) { -		vty_out(vty, "%s\n", json_object_to_json_string_ext(json, -						JSON_C_TO_STRING_PRETTY)); +		vty_out(vty, "%s\n", json_object_to_json_string_ext( +					     json, JSON_C_TO_STRING_PRETTY));  		json_object_free(json);  	} @@ -3735,7 +3734,7 @@ static int show_ip_ospf_interface_common(struct vty *vty, struct ospf *ospf,  		}  		if (use_json)  			json_object_object_add(json_vrf, "interfaces", -				       json_interface); +					       json_interface);  	} else {  		/* Interface name is specified. */  		ifp = if_lookup_by_name(intf_name, ospf->vrf_id); @@ -3785,59 +3784,42 @@ static void show_ip_ospf_interface_traffic_sub(struct vty *vty,  					       u_char use_json)  {  	if (use_json) { -		json_object_int_add(json_interface_sub, -			    "ifIndex", -			    oi->ifp->ifindex); -		json_object_int_add(json_interface_sub, -			    "helloIn", -			    oi->hello_in); -		json_object_int_add(json_interface_sub, -			    "helloOut", -			    oi->hello_out); -		json_object_int_add(json_interface_sub, -			    "dbDescIn", -			    oi->db_desc_in); -		json_object_int_add(json_interface_sub, -			    "dbDescOut", -			    oi->db_desc_out); -		json_object_int_add(json_interface_sub, -			    "lsReqIn", -			    oi->ls_req_in); -		json_object_int_add(json_interface_sub, -			    "lsReqOut", -			    oi->ls_req_out); -		json_object_int_add(json_interface_sub, -			    "lsUpdIn", -			    oi->ls_upd_in); -		json_object_int_add(json_interface_sub, -			    "lsUpdOut", -			    oi->ls_upd_out); -		json_object_int_add(json_interface_sub, -			    "lsAckIn", -			    oi->ls_ack_in); -		json_object_int_add(json_interface_sub, -			    "lsAckOut", -			    oi->ls_ack_out); +		json_object_int_add(json_interface_sub, "ifIndex", +				    oi->ifp->ifindex); +		json_object_int_add(json_interface_sub, "helloIn", +				    oi->hello_in); +		json_object_int_add(json_interface_sub, "helloOut", +				    oi->hello_out); +		json_object_int_add(json_interface_sub, "dbDescIn", +				    oi->db_desc_in); +		json_object_int_add(json_interface_sub, "dbDescOut", +				    oi->db_desc_out); +		json_object_int_add(json_interface_sub, "lsReqIn", +				    oi->ls_req_in); +		json_object_int_add(json_interface_sub, "lsReqOut", +				    oi->ls_req_out); +		json_object_int_add(json_interface_sub, "lsUpdIn", +				    oi->ls_upd_in); +		json_object_int_add(json_interface_sub, "lsUpdOut", +				    oi->ls_upd_out); +		json_object_int_add(json_interface_sub, "lsAckIn", +				    oi->ls_ack_in); +		json_object_int_add(json_interface_sub, "lsAckOut", +				    oi->ls_ack_out);  	} else {  		vty_out(vty,  			"%-10s %8u/%-8u %7u/%-7u %7u/%-7u %7u/%-7u %7u/%-7u\n", -			oi->ifp->name, oi->hello_in, -			oi->hello_out, -			oi->db_desc_in, oi->db_desc_out, -			oi->ls_req_in, oi->ls_req_out, -			oi->ls_upd_in, oi->ls_upd_out, +			oi->ifp->name, oi->hello_in, oi->hello_out, +			oi->db_desc_in, oi->db_desc_out, oi->ls_req_in, +			oi->ls_req_out, oi->ls_upd_in, oi->ls_upd_out,  			oi->ls_ack_in, oi->ls_ack_out);  	}  }  /* OSPFv2 Packet Counters */ -static int show_ip_ospf_interface_traffic_common(struct vty *vty, -						 struct ospf *ospf, -						 char *intf_name, -						 json_object *json, -						 int display_once, -						 u_char use_vrf, -						 u_char use_json) +static int show_ip_ospf_interface_traffic_common( +	struct vty *vty, struct ospf *ospf, char *intf_name, json_object *json, +	int display_once, u_char use_vrf, u_char use_json)  {  	struct vrf *vrf = NULL;  	struct interface *ifp = NULL; @@ -3846,13 +3828,14 @@ static int show_ip_ospf_interface_traffic_common(struct vty *vty,  	if (!use_json && !display_once) {  		vty_out(vty, "\n"); -		vty_out(vty, "%-12s%-17s%-17s%-17s%-17s%-17s\n", -			"Interface", "    HELLO", "    DB-Desc", "   LS-Req", -			"   LS-Update", "   LS-Ack"); +		vty_out(vty, "%-12s%-17s%-17s%-17s%-17s%-17s\n", "Interface", +			"    HELLO", "    DB-Desc", "   LS-Req", "   LS-Update", +			"   LS-Ack");  		vty_out(vty, "%-10s%-18s%-18s%-17s%-17s%-17s\n", "", -			"      Rx/Tx", "     Rx/Tx", "    Rx/Tx", "    Rx/Tx", "    Rx/Tx"); +			"      Rx/Tx", "     Rx/Tx", "    Rx/Tx", "    Rx/Tx", +			"    Rx/Tx");  		vty_out(vty, -		"--------------------------------------------------------------------------------------------\n"); +			"--------------------------------------------------------------------------------------------\n");  	} else if (use_json) {  		if (use_vrf)  			json_vrf = json_object_new_object(); @@ -3872,7 +3855,7 @@ static int show_ip_ospf_interface_traffic_common(struct vty *vty,  				continue;  			for (rn = route_top(IF_OIFS(ifp)); rn; -				rn = route_next(rn)) { +			     rn = route_next(rn)) {  				oi = rn->info;  				if (oi == NULL) @@ -3883,13 +3866,12 @@ static int show_ip_ospf_interface_traffic_common(struct vty *vty,  						json_object_new_object();  				} -				show_ip_ospf_interface_traffic_sub(vty, oi, -							   json_interface_sub, -							   use_json); +				show_ip_ospf_interface_traffic_sub( +					vty, oi, json_interface_sub, use_json);  				if (use_json) { -					json_object_object_add(json_vrf, -							ifp->name, -							json_interface_sub); +					json_object_object_add( +						json_vrf, ifp->name, +						json_interface_sub);  				}  			}  		} @@ -3901,7 +3883,8 @@ static int show_ip_ospf_interface_traffic_common(struct vty *vty,  			struct ospf_interface *oi;  			if (ospf_oi_count(ifp) == 0) { -				vty_out(vty, "  OSPF not enabled on this interface %s\n", +				vty_out(vty, +					"  OSPF not enabled on this interface %s\n",  					ifp->name);  				return CMD_SUCCESS;  			} @@ -3915,13 +3898,12 @@ static int show_ip_ospf_interface_traffic_common(struct vty *vty,  						json_object_new_object();  				} -				show_ip_ospf_interface_traffic_sub(vty, oi, -							   json_interface_sub, -							   use_json); +				show_ip_ospf_interface_traffic_sub( +					vty, oi, json_interface_sub, use_json);  				if (use_json) { -					json_object_object_add(json_vrf, -							ifp->name, -							json_interface_sub); +					json_object_object_add( +						json_vrf, ifp->name, +						json_interface_sub);  				}  			}  		} @@ -3980,18 +3962,15 @@ DEFUN (show_ip_ospf_interface,  			for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {  				if (!ospf->oi_running)  					continue; -				ret = show_ip_ospf_interface_common(vty, -								    ospf, -								    intf_name, -								    use_vrf, -								    json, -								    uj); +				ret = show_ip_ospf_interface_common( +					vty, ospf, intf_name, use_vrf, json, +					uj);  			}  			if (uj) {  				vty_out(vty, "%s\n", -					json_object_to_json_string_ext(json, -						  JSON_C_TO_STRING_PRETTY)); +					json_object_to_json_string_ext( +						json, JSON_C_TO_STRING_PRETTY));  				json_object_free(json);  			} @@ -4019,8 +3998,8 @@ DEFUN (show_ip_ospf_interface,  	}  	if (uj) { -		vty_out(vty, "%s\n", json_object_to_json_string_ext(json, -						JSON_C_TO_STRING_PRETTY)); +		vty_out(vty, "%s\n", json_object_to_json_string_ext( +					     json, JSON_C_TO_STRING_PRETTY));  		json_object_free(json);  	} @@ -4064,8 +4043,8 @@ DEFUN (show_ip_ospf_instance_interface,  	ret = show_ip_ospf_interface_common(vty, ospf, intf_name, 0, json, uj);  	if (uj) { -		vty_out(vty, "%s\n", json_object_to_json_string_ext(json, -						JSON_C_TO_STRING_PRETTY)); +		vty_out(vty, "%s\n", json_object_to_json_string_ext( +					     json, JSON_C_TO_STRING_PRETTY));  		json_object_free(json);  	} @@ -4112,19 +4091,16 @@ DEFUN (show_ip_ospf_interface_traffic,  				if (!ospf->oi_running)  					continue; -				ret = show_ip_ospf_interface_traffic_common(vty, -								ospf, intf_name, -								json, -								display_once, -								use_vrf, -								uj); +				ret = show_ip_ospf_interface_traffic_common( +					vty, ospf, intf_name, json, +					display_once, use_vrf, uj);  				display_once = 1;  			}  			if (uj) {  				vty_out(vty, "%s\n", -					json_object_to_json_string_ext(json, -						  JSON_C_TO_STRING_PRETTY)); +					json_object_to_json_string_ext( +						json, JSON_C_TO_STRING_PRETTY));  				json_object_free(json);  			} @@ -4137,10 +4113,8 @@ DEFUN (show_ip_ospf_interface_traffic,  			return CMD_SUCCESS;  		} -		ret = show_ip_ospf_interface_traffic_common(vty, ospf, -							    intf_name, json, -							    display_once, -							    use_vrf, uj); +		ret = show_ip_ospf_interface_traffic_common( +			vty, ospf, intf_name, json, display_once, use_vrf, uj);  	} else {  		ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);  		if (ospf == NULL || !ospf->oi_running) { @@ -4149,15 +4123,13 @@ DEFUN (show_ip_ospf_interface_traffic,  			return CMD_SUCCESS;  		} -		ret = show_ip_ospf_interface_traffic_common(vty, ospf, -							    intf_name, json, -							    display_once, -							    use_vrf, uj); +		ret = show_ip_ospf_interface_traffic_common( +			vty, ospf, intf_name, json, display_once, use_vrf, uj);  	}  	if (uj) { -		vty_out(vty, "%s\n", json_object_to_json_string_ext(json, -						JSON_C_TO_STRING_PRETTY)); +		vty_out(vty, "%s\n", json_object_to_json_string_ext( +					     json, JSON_C_TO_STRING_PRETTY));  		json_object_free(json);  	} @@ -4193,14 +4165,15 @@ static void show_ip_ospf_neighbor_sub(struct vty *vty,  			if (use_json) {  				char neigh_str[INET_ADDRSTRLEN]; -				if (prev_nbr && -				    !IPV4_ADDR_SAME(&prev_nbr->src, &nbr->src)) { +				if (prev_nbr +				    && !IPV4_ADDR_SAME(&prev_nbr->src, +						       &nbr->src)) {  					/* Start new neigh list */  					json_neigh_array = NULL;  				} -				if (nbr->state == NSM_Attempt && -				    nbr->router_id.s_addr == 0) +				if (nbr->state == NSM_Attempt +				    && nbr->router_id.s_addr == 0)  					strlcpy(neigh_str, "neighbor",  						sizeof(neigh_str));  				else @@ -4212,72 +4185,67 @@ static void show_ip_ospf_neighbor_sub(struct vty *vty,  							  &json_neigh_array);  				if (!json_neigh_array) { -					json_neigh_array = json_object_new_array(); -					json_object_object_add(json, neigh_str, -							json_neigh_array); +					json_neigh_array = +						json_object_new_array(); +					json_object_object_add( +						json, neigh_str, +						json_neigh_array);  				} -				json_neighbor = -					json_object_new_object(); +				json_neighbor = json_object_new_object();  				ospf_nbr_state_message(nbr, msgbuf, 16);  				long time_store; -				time_store = monotime_until( +				time_store = +					monotime_until(  						&nbr->t_inactivity->u.sands, -						       NULL) / 1000LL; +						NULL) +					/ 1000LL; -				json_object_int_add(json_neighbor, -						    "priority", +				json_object_int_add(json_neighbor, "priority",  						    nbr->priority);  				json_object_string_add(json_neighbor, "state",  						       msgbuf);  				json_object_int_add(json_neighbor,  						    "deadTimeMsecs",  						    time_store); -				json_object_string_add(json_neighbor, -						       "address", +				json_object_string_add(json_neighbor, "address",  						       inet_ntoa(nbr->src));  				json_object_string_add(json_neighbor,  						       "ifaceName",  						       IF_NAME(oi)); +				json_object_int_add( +					json_neighbor, "retransmitCounter", +					ospf_ls_retransmit_count(nbr));  				json_object_int_add(json_neighbor, -						"retransmitCounter", -						ospf_ls_retransmit_count(nbr)); -				json_object_int_add(json_neighbor, -						"requestCounter", -						ospf_ls_request_count(nbr)); +						    "requestCounter", +						    ospf_ls_request_count(nbr));  				json_object_int_add(json_neighbor, -						"dbSummaryCounter", -						ospf_db_summary_count(nbr)); +						    "dbSummaryCounter", +						    ospf_db_summary_count(nbr));  				json_object_array_add(json_neigh_array,  						      json_neighbor);  			} else {  				ospf_nbr_state_message(nbr, msgbuf, 16); -				if (nbr->state == NSM_Attempt && -				    nbr->router_id.s_addr == 0) -					vty_out(vty, -						"%-15s %3d %-15s ", -						"-", -						nbr->priority, -						msgbuf); +				if (nbr->state == NSM_Attempt +				    && nbr->router_id.s_addr == 0) +					vty_out(vty, "%-15s %3d %-15s ", "-", +						nbr->priority, msgbuf);  				else -					vty_out(vty, -						"%-15s %3d %-15s ", +					vty_out(vty, "%-15s %3d %-15s ",  						inet_ntoa(nbr->router_id), -						nbr->priority, -						msgbuf); +						nbr->priority, msgbuf);  				vty_out(vty, "%9s ",  					ospf_timer_dump(nbr->t_inactivity,  							timebuf,  							sizeof(timebuf)));  				vty_out(vty, "%-15s ", inet_ntoa(nbr->src)); -				vty_out(vty, -					"%-20s %5ld %5ld %5d\n", +				vty_out(vty, "%-20s %5ld %5ld %5d\n",  					IF_NAME(oi),  					ospf_ls_retransmit_count(nbr),  					ospf_ls_request_count(nbr), @@ -4324,8 +4292,7 @@ static int show_ip_ospf_neighbor_common(struct vty *vty, struct ospf *ospf,  	}  	if (use_json) { -		json_object_object_add(json_vrf, "neighbors", -				       json_nbr_sub); +		json_object_object_add(json_vrf, "neighbors", json_nbr_sub);  		if (use_vrf) {  			if (ospf->vrf_id == VRF_DEFAULT)  				json_object_object_add(json, "default", @@ -4374,15 +4341,14 @@ DEFUN (show_ip_ospf_neighbor,  			for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {  				if (!ospf->oi_running)  					continue; -				ret = show_ip_ospf_neighbor_common(vty, ospf, -								   json, uj, -								   use_vrf); +				ret = show_ip_ospf_neighbor_common( +					vty, ospf, json, uj, use_vrf);  			}  			if (uj) {  				vty_out(vty, "%s\n", -					json_object_to_json_string_ext(json, -						  JSON_C_TO_STRING_PRETTY)); +					json_object_to_json_string_ext( +						json, JSON_C_TO_STRING_PRETTY));  				json_object_free(json);  			} @@ -4411,8 +4377,8 @@ DEFUN (show_ip_ospf_neighbor,  		if (uj) {  			vty_out(vty, "%s\n", -				json_object_to_json_string_ext(json, -						JSON_C_TO_STRING_PRETTY)); +				json_object_to_json_string_ext( +					json, JSON_C_TO_STRING_PRETTY));  		}  	} @@ -4454,8 +4420,8 @@ DEFUN (show_ip_ospf_instance_neighbor,  	ret = show_ip_ospf_neighbor_common(vty, ospf, json, uj, 0);  	if (uj) { -		vty_out(vty, "%s\n", json_object_to_json_string_ext(json, -						JSON_C_TO_STRING_PRETTY)); +		vty_out(vty, "%s\n", json_object_to_json_string_ext( +					     json, JSON_C_TO_STRING_PRETTY));  		json_object_free(json);  	} @@ -4463,8 +4429,7 @@ DEFUN (show_ip_ospf_instance_neighbor,  }  static int show_ip_ospf_neighbor_all_common(struct vty *vty, struct ospf *ospf, -					    json_object *json, -					    u_char use_json, +					    json_object *json, u_char use_json,  					    u_char use_vrf)  {  	struct listnode *node; @@ -4589,17 +4554,14 @@ DEFUN (show_ip_ospf_neighbor_all,  			for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {  				if (!ospf->oi_running)  					continue; -				ret = show_ip_ospf_neighbor_all_common(vty, -								       ospf, -								       json, -								       uj, -								       use_vrf); +				ret = show_ip_ospf_neighbor_all_common( +					vty, ospf, json, uj, use_vrf);  			}  			if (uj) {  				vty_out(vty, "%s\n", -					json_object_to_json_string_ext(json, -						  JSON_C_TO_STRING_PRETTY)); +					json_object_to_json_string_ext( +						json, JSON_C_TO_STRING_PRETTY));  				json_object_free(json);  			} @@ -4627,8 +4589,8 @@ DEFUN (show_ip_ospf_neighbor_all,  						       use_vrf);  		if (uj) {  			vty_out(vty, "%s\n", -				json_object_to_json_string_ext(json, -						JSON_C_TO_STRING_PRETTY)); +				json_object_to_json_string_ext( +					json, JSON_C_TO_STRING_PRETTY));  		}  	} @@ -4753,8 +4715,8 @@ DEFUN (show_ip_ospf_neighbor_int,  			continue;  		if (!ifp || ifp->vrf_id != ospf->vrf_id)  			continue; -		ret = show_ip_ospf_neighbor_int_common(vty, ospf, -						       idx_ifname, argv, uj, 0); +		ret = show_ip_ospf_neighbor_int_common(vty, ospf, idx_ifname, +						       argv, uj, 0);  	}  	return ret; @@ -4791,8 +4753,8 @@ DEFUN (show_ip_ospf_instance_neighbor_int,  	if (!uj)  		show_ip_ospf_neighbour_header(vty); -	return show_ip_ospf_neighbor_int_common(vty, ospf, idx_ifname, -						argv, uj, 0); +	return show_ip_ospf_neighbor_int_common(vty, ospf, idx_ifname, argv, uj, +						0);  }  static void show_ip_ospf_nbr_nbma_detail_sub(struct vty *vty, @@ -4875,8 +4837,7 @@ static void show_ip_ospf_nbr_nbma_detail_sub(struct vty *vty,  static void show_ip_ospf_neighbor_detail_sub(struct vty *vty,  					     struct ospf_interface *oi,  					     struct ospf_neighbor *nbr, -					     json_object *json, -					     u_char use_json) +					     json_object *json, u_char use_json)  {  	char timebuf[OSPF_TIME_DUMP_SIZE];  	json_object *json_sub = NULL; @@ -5092,8 +5053,7 @@ static void show_ip_ospf_neighbor_detail_sub(struct vty *vty,  static int show_ip_ospf_neighbor_id_common(struct vty *vty, struct ospf *ospf,  					   int arg_base,  					   struct cmd_token **argv, -					   u_char use_json, -					   u_char use_vrf) +					   u_char use_json, u_char use_vrf)  {  	struct listnode *node;  	struct ospf_neighbor *nbr; @@ -5161,8 +5121,8 @@ DEFUN (show_ip_ospf_neighbor_id,  	for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {  		if (!ospf->oi_running)  			continue; -		ret = show_ip_ospf_neighbor_id_common(vty, ospf, 0, -						      argv, uj, 0); +		ret = show_ip_ospf_neighbor_id_common(vty, ospf, 0, argv, uj, +						      0);  	}  	return ret; @@ -5200,8 +5160,7 @@ DEFUN (show_ip_ospf_instance_neighbor_id,  static int show_ip_ospf_neighbor_detail_common(struct vty *vty,  					       struct ospf *ospf,  					       json_object *json, -					       u_char use_json, -					       u_char use_vrf) +					       u_char use_json, u_char use_vrf)  {  	struct ospf_interface *oi;  	struct listnode *node; @@ -5290,16 +5249,13 @@ DEFUN (show_ip_ospf_neighbor_detail,  			for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {  				if (!ospf->oi_running)  					continue; -				ret = show_ip_ospf_neighbor_detail_common(vty, -								ospf, -								json, -								uj, -								use_vrf); +				ret = show_ip_ospf_neighbor_detail_common( +					vty, ospf, json, uj, use_vrf);  			}  			if (uj) {  				vty_out(vty, "%s\n", -					json_object_to_json_string_ext(json, -						  JSON_C_TO_STRING_PRETTY)); +					json_object_to_json_string_ext( +						json, JSON_C_TO_STRING_PRETTY));  				json_object_free(json);  			} @@ -5326,8 +5282,8 @@ DEFUN (show_ip_ospf_neighbor_detail,  							  use_vrf);  		if (uj) {  			vty_out(vty, "%s\n", -				json_object_to_json_string_ext(json, -					JSON_C_TO_STRING_PRETTY)); +				json_object_to_json_string_ext( +					json, JSON_C_TO_STRING_PRETTY));  		}  	} @@ -5482,17 +5438,14 @@ DEFUN (show_ip_ospf_neighbor_detail_all,  			for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {  				if (!ospf->oi_running)  					continue; -				ret = show_ip_ospf_neighbor_detail_all_common(vty, -								ospf, -								json, -								uj, -								use_vrf); +				ret = show_ip_ospf_neighbor_detail_all_common( +					vty, ospf, json, uj, use_vrf);  			}  			if (uj) {  				vty_out(vty, "%s\n", -					json_object_to_json_string_ext(json, -						  JSON_C_TO_STRING_PRETTY)); +					json_object_to_json_string_ext( +						json, JSON_C_TO_STRING_PRETTY));  				json_object_free(json);  			} @@ -5519,8 +5472,8 @@ DEFUN (show_ip_ospf_neighbor_detail_all,  							      uj, use_vrf);  		if (uj) {  			vty_out(vty, "%s\n", -				json_object_to_json_string_ext(json, -						JSON_C_TO_STRING_PRETTY)); +				json_object_to_json_string_ext( +					json, JSON_C_TO_STRING_PRETTY));  		}  	} @@ -5563,8 +5516,8 @@ DEFUN (show_ip_ospf_instance_neighbor_detail_all,  	ret = show_ip_ospf_neighbor_detail_all_common(vty, ospf, json, uj, 0);  	if (uj) { -		vty_out(vty, "%s\n", json_object_to_json_string_ext(json, -						JSON_C_TO_STRING_PRETTY)); +		vty_out(vty, "%s\n", json_object_to_json_string_ext( +					     json, JSON_C_TO_STRING_PRETTY));  		json_object_free(json);  	} @@ -5683,7 +5636,8 @@ DEFUN (show_ip_ospf_instance_neighbor_int_detail,  	if (!ospf->oi_running)  		return CMD_SUCCESS; -	return show_ip_ospf_neighbor_int_detail_common(vty, ospf, idx_ifname, argv, uj); +	return show_ip_ospf_neighbor_int_detail_common(vty, ospf, idx_ifname, +						       argv, uj);  }  /* Show functions */ @@ -6183,7 +6137,7 @@ static void show_ip_ospf_database_summary(struct vty *vty, struct ospf *ospf,  				vty_out(vty, "%s\n",  					show_database_header[type]); -				LSDB_LOOP(AREA_LSDB(area, type), rn, lsa) +				LSDB_LOOP (AREA_LSDB(area, type), rn, lsa)  					show_lsa_summary(vty, lsa, self);  				vty_out(vty, "\n"); @@ -6205,7 +6159,7 @@ static void show_ip_ospf_database_summary(struct vty *vty, struct ospf *ospf,  				show_database_desc[type]);  			vty_out(vty, "%s\n", show_database_header[type]); -			LSDB_LOOP(AS_LSDB(ospf, type), rn, lsa) +			LSDB_LOOP (AS_LSDB(ospf, type), rn, lsa)  				show_lsa_summary(vty, lsa, self);  			vty_out(vty, "\n"); @@ -6255,8 +6209,7 @@ static void show_ip_ospf_database_maxage(struct vty *vty, struct ospf *ospf)  static int show_ip_ospf_database_common(struct vty *vty, struct ospf *ospf,  					int arg_base, int argc, -					struct cmd_token **argv, -					u_char use_vrf) +					struct cmd_token **argv, u_char use_vrf)  {  	int idx_type = 4;  	int type, ret; @@ -6361,19 +6314,17 @@ DEFUN (show_ip_ospf_database_max,  			for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {  				if (!ospf->oi_running)  					continue; -				ret = show_ip_ospf_database_common(vty, ospf, -								    idx_vrf ? 2 -								    : 0, argc, -								    argv, -								    use_vrf); +				ret = show_ip_ospf_database_common( +					vty, ospf, idx_vrf ? 2 : 0, argc, argv, +					use_vrf);  			}  		} else {  			ospf = ospf_lookup_by_inst_name(inst, vrf_name);  			if (ospf == NULL || !ospf->oi_running)  				return CMD_SUCCESS; -			ret = (show_ip_ospf_database_common(vty, ospf, idx_vrf ? -							    2 : 0, argc, argv, -							    use_vrf)); +			ret = (show_ip_ospf_database_common( +				vty, ospf, idx_vrf ? 2 : 0, argc, argv, +				use_vrf));  		}  	} else {  		/* Display default ospf (instance 0) info */ @@ -6433,18 +6384,16 @@ DEFUN (show_ip_ospf_instance_database,  			for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {  				if (!ospf->oi_running)  					continue; -				ret = (show_ip_ospf_database_common(vty, ospf, -								    idx ? 2 : 0, -								    argc, argv, -								    use_vrf)); +				ret = (show_ip_ospf_database_common( +					vty, ospf, idx ? 2 : 0, argc, argv, +					use_vrf));  			}  		} else {  			ospf = ospf_lookup_by_inst_name(inst, vrf_name);  			if ((ospf == NULL) || !ospf->oi_running)  				return CMD_SUCCESS; -			ret = (show_ip_ospf_database_common(vty, ospf, idx ? 2 : -							    0, argc, argv, -							    use_vrf)); +			ret = (show_ip_ospf_database_common( +				vty, ospf, idx ? 2 : 0, argc, argv, use_vrf));  		}  	} else {  		/* Display default ospf (instance 0) info */ @@ -6571,11 +6520,8 @@ DEFUN (show_ip_ospf_instance_database_type_adv_router,  			return CMD_NOT_MY_INSTANCE;  		if (!ospf->oi_running)  			return CMD_SUCCESS; -		return (show_ip_ospf_database_type_adv_router_common(vty, ospf, -								     idx ? 1 : 0, -								     argc, -								     argv, -								     use_vrf)); +		return (show_ip_ospf_database_type_adv_router_common( +			vty, ospf, idx ? 1 : 0, argc, argv, use_vrf));  	}  	OSPF_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); @@ -6586,27 +6532,24 @@ DEFUN (show_ip_ospf_instance_database_type_adv_router,  			for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {  				if (!ospf->oi_running)  					continue; -				ret = show_ip_ospf_database_type_adv_router_common(vty, -						ospf, idx ? 1 : 0, argc, argv, -						use_vrf); +				ret = show_ip_ospf_database_type_adv_router_common( +					vty, ospf, idx ? 1 : 0, argc, argv, +					use_vrf);  			}  		} else {  			ospf = ospf_lookup_by_inst_name(inst, vrf_name);  			if ((ospf == NULL) || !ospf->oi_running)  				return CMD_SUCCESS; -			ret = show_ip_ospf_database_type_adv_router_common(vty, -						ospf, idx ? 1 : 0, argc, argv, -						use_vrf); +			ret = show_ip_ospf_database_type_adv_router_common( +				vty, ospf, idx ? 1 : 0, argc, argv, use_vrf);  		}  	} else {  		/* Display default ospf (instance 0) info */  		ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);  		if (ospf == NULL || !ospf->oi_running)  			return CMD_SUCCESS; -		ret = show_ip_ospf_database_type_adv_router_common(vty, ospf, -								   idx ? 1 : 0, -								   argc, argv, -								   use_vrf); +		ret = show_ip_ospf_database_type_adv_router_common( +			vty, ospf, idx ? 1 : 0, argc, argv, use_vrf);  	}  	return ret;  	/*return (show_ip_ospf_database_type_adv_router_common( @@ -8015,7 +7958,8 @@ DEFUN (ip_ospf_area,  	// Check if we have an address arg and proccess it  	if (argc == idx + 3) {  		if (!inet_aton(argv[idx + 2]->arg, &addr)) { -			vty_out(vty, "Please specify Intf Address by A.B.C.D\n"); +			vty_out(vty, +				"Please specify Intf Address by A.B.C.D\n");  			return CMD_WARNING_CONFIG_FAILED;  		}  		// update/create address-level params @@ -8088,7 +8032,8 @@ DEFUN (no_ip_ospf_area,  	// Check if we have an address arg and proccess it  	if (argc == idx + 3) {  		if (!inet_aton(argv[idx + 2]->arg, &addr)) { -			vty_out(vty, "Please specify Intf Address by A.B.C.D\n"); +			vty_out(vty, +				"Please specify Intf Address by A.B.C.D\n");  			return CMD_WARNING_CONFIG_FAILED;  		}  		params = ospf_lookup_if_params(ifp, addr); @@ -8910,7 +8855,8 @@ static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf,  		    *json_nexthop = NULL;  	if (!json) -		vty_out(vty, "============ OSPF network routing table ============\n"); +		vty_out(vty, +			"============ OSPF network routing table ============\n");  	for (rn = route_top(rt); rn; rn = route_next(rn)) {  		if ((or = rn->info) == NULL) @@ -8922,10 +8868,9 @@ static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf,  		json_route = json_object_new_object();  		if (json) { -			 json_object_object_add(json, buf1, json_route); -			 json_object_to_json_string_ext(json, -				JSON_C_TO_STRING_NOSLASHESCAPE); - +			json_object_object_add(json, buf1, json_route); +			json_object_to_json_string_ext( +				json, JSON_C_TO_STRING_NOSLASHESCAPE);  		}  		switch (or->path_type) { @@ -8933,28 +8878,24 @@ static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf,  			if (or->type == OSPF_DESTINATION_NETWORK) {  				if (json) {  					json_object_string_add(json_route, -							"routeType", -							"N IA"); -					json_object_int_add(json_route, -							    "cost", +							       "routeType", +							       "N IA"); +					json_object_int_add(json_route, "cost",  							    or->cost);  					json_object_string_add( -						json_route, -						"area", -						inet_ntoa( -						or->u.std.area_id)); +						json_route, "area", +						inet_ntoa(or->u.std.area_id));  				} else {  					vty_out(vty, -					"N IA %-18s    [%d] area: %s\n", +						"N IA %-18s    [%d] area: %s\n",  						buf1, or->cost, -					inet_ntoa(or->u.std.area_id)); +						inet_ntoa(or->u.std.area_id));  				} -			} else if (or->type == -					OSPF_DESTINATION_DISCARD) { +			} else if (or->type == OSPF_DESTINATION_DISCARD) {  				if (json) {  					json_object_string_add(json_route, -							"routeType", -							"D IA"); +							       "routeType", +							       "D IA");  				} else {  					vty_out(vty,  						"D IA %-18s    Discard entry\n", @@ -8964,12 +8905,13 @@ static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf,  			break;  		case OSPF_PATH_INTRA_AREA:  			if (json) { -				json_object_string_add(json_route, -							"routeType", "N"); +				json_object_string_add(json_route, "routeType", +						       "N");  				json_object_int_add(json_route, "cost", -							    or->cost); -				json_object_string_add(json_route, -					"area", inet_ntoa(or->u.std.area_id)); +						    or->cost); +				json_object_string_add( +					json_route, "area", +					inet_ntoa(or->u.std.area_id));  			} else {  				vty_out(vty, "N    %-18s    [%d] area: %s\n",  					buf1, or->cost, @@ -8984,16 +8926,16 @@ static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf,  			if (json) {  				json_nexthop_array = json_object_new_array();  				json_object_object_add(json_route, "nexthops", -					      json_nexthop_array); +						       json_nexthop_array);  			}  			for (ALL_LIST_ELEMENTS(or->paths, pnode, pnnode,  					       path)) {  				if (json) { -					json_nexthop = -					json_object_new_object(); -					json_object_array_add(json_nexthop_array, -							      json_nexthop); +					json_nexthop = json_object_new_object(); +					json_object_array_add( +						json_nexthop_array, +						json_nexthop);  				}  				if (if_lookup_by_index(path->ifindex,  						       ospf->vrf_id)) { @@ -9002,21 +8944,20 @@ static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf,  						if (json) {  							json_object_string_add(  								json_nexthop, -								"ip", -								" "); +								"ip", " ");  							json_object_string_add(  								json_nexthop,  								"directly attached to",  								ifindex2ifname( -								path->ifindex, -								ospf->vrf_id)); +									path->ifindex, +									ospf->vrf_id));  						} else {  							vty_out(vty, -							"%24s   directly attached to %s\n", -							"", -							ifindex2ifname( -								path->ifindex, -								ospf->vrf_id)); +								"%24s   directly attached to %s\n", +								"", +								ifindex2ifname( +									path->ifindex, +									ospf->vrf_id));  						}  					} else {  						if (json) { @@ -9024,22 +8965,22 @@ static void show_ip_ospf_route_network(struct vty *vty, struct ospf *ospf,  								json_nexthop,  								"ip",  								inet_ntoa( -								path->nexthop)); +									path->nexthop));  							json_object_string_add(  								json_nexthop,  								"via",  								ifindex2ifname( -								path->ifindex, -								ospf->vrf_id)); +									path->ifindex, +									ospf->vrf_id));  						} else {  							vty_out(vty, -							"%24s   via %s, %s\n", -							"", -							inet_ntoa( -								path->nexthop), -							ifindex2ifname( -								path->ifindex, -								ospf->vrf_id)); +								"%24s   via %s, %s\n", +								"", +								inet_ntoa( +									path->nexthop), +								ifindex2ifname( +									path->ifindex, +									ospf->vrf_id));  						}  					}  				} @@ -9065,7 +9006,8 @@ static void show_ip_ospf_route_router(struct vty *vty, struct ospf *ospf,  		    *json_nexthop = NULL;  	if (!json) -		vty_out(vty, "============ OSPF router routing table =============\n"); +		vty_out(vty, +			"============ OSPF router routing table =============\n");  	for (rn = route_top(rtrs); rn; rn = route_next(rn)) {  		if (rn->info == NULL) @@ -9074,18 +9016,15 @@ static void show_ip_ospf_route_router(struct vty *vty, struct ospf *ospf,  		json_route = json_object_new_object();  		if (json) { -			json_object_object_add(json, -					inet_ntoa(rn->p.u.prefix4), -					json_route); -			json_object_string_add(json_route, "routeType", -					       "R "); +			json_object_object_add(json, inet_ntoa(rn->p.u.prefix4), +					       json_route); +			json_object_string_add(json_route, "routeType", "R ");  		} else {  			vty_out(vty, "R    %-15s    ",  				inet_ntoa(rn->p.u.prefix4));  		} -		for (ALL_LIST_ELEMENTS_RO((struct list *)rn->info, node, -					  or)) { +		for (ALL_LIST_ELEMENTS_RO((struct list *)rn->info, node, or)) {  			if (flag++) {  				if (!json)  					vty_out(vty, "%24s", ""); @@ -9095,53 +9034,45 @@ static void show_ip_ospf_route_router(struct vty *vty, struct ospf *ospf,  			if (json) {  				json_object_int_add(json_route, "cost",  						    or->cost); -				json_object_string_add(json_route, -					"area", +				json_object_string_add( +					json_route, "area",  					inet_ntoa(or->u.std.area_id)); -				if (or->path_type == -				    OSPF_PATH_INTER_AREA) -					json_object_boolean_true_add( -							json_route, -							"IA"); +				if (or->path_type == OSPF_PATH_INTER_AREA) +					json_object_boolean_true_add(json_route, +								     "IA");  				if (or->u.std.flags & ROUTER_LSA_BORDER) -					json_object_string_add( -							json_route, -							"routerType", -							"abr"); -				else if (or->u.std.flags & -					 ROUTER_LSA_EXTERNAL) -					json_object_string_add( -							json_route, -							"routerType", -							"asbr"); +					json_object_string_add(json_route, +							       "routerType", +							       "abr"); +				else if (or->u.std.flags & ROUTER_LSA_EXTERNAL) +					json_object_string_add(json_route, +							       "routerType", +							       "asbr");  			} else {  				vty_out(vty, "%s [%d] area: %s", -				(or->path_type == OSPF_PATH_INTER_AREA -					 ? "IA" -					 : "  "), -				or->cost, inet_ntoa(or->u.std.area_id)); +					(or->path_type == OSPF_PATH_INTER_AREA +						 ? "IA" +						 : "  "), +					or->cost, inet_ntoa(or->u.std.area_id));  				/* Show flags. */  				vty_out(vty, "%s%s\n", -				(or->u.std.flags & ROUTER_LSA_BORDER -					 ? ", ABR" -					 : ""), -				(or->u.std.flags & ROUTER_LSA_EXTERNAL -					 ? ", ASBR" -					 : "")); +					(or->u.std.flags & ROUTER_LSA_BORDER +						 ? ", ABR" +						 : ""), +					(or->u.std.flags & ROUTER_LSA_EXTERNAL +						 ? ", ASBR" +						 : ""));  			}  			if (json) { -				json_nexthop_array = -					json_object_new_array(); +				json_nexthop_array = json_object_new_array();  				json_object_object_add(json_route, "nexthops", -					      json_nexthop_array); +						       json_nexthop_array);  			} -			for (ALL_LIST_ELEMENTS_RO(or->paths, pnode, -						  path)) { +			for (ALL_LIST_ELEMENTS_RO(or->paths, pnode, path)) {  				if (json) { -					json_nexthop = -					json_object_new_object(); +					json_nexthop = json_object_new_object();  					json_object_array_add(  						json_nexthop_array,  						json_nexthop); @@ -9152,8 +9083,7 @@ static void show_ip_ospf_route_router(struct vty *vty, struct ospf *ospf,  						if (json) {  							json_object_string_add(  								json_nexthop, -								"ip", -								" "); +								"ip", " ");  							json_object_string_add(  								json_nexthop,  								"directly attached to", @@ -9162,18 +9092,19 @@ static void show_ip_ospf_route_router(struct vty *vty, struct ospf *ospf,  									ospf->vrf_id));  						} else {  							vty_out(vty, -							"%24s   directly attached to %s\n", -							"", -							ifindex2ifname( -								path->ifindex, -								ospf->vrf_id)); +								"%24s   directly attached to %s\n", +								"", +								ifindex2ifname( +									path->ifindex, +									ospf->vrf_id));  						}  					} else {  						if (json) {  							json_object_string_add(  								json_nexthop,  								"ip", -								inet_ntoa(path->nexthop)); +								inet_ntoa( +									path->nexthop));  							json_object_string_add(  								json_nexthop,  								"via", @@ -9182,13 +9113,13 @@ static void show_ip_ospf_route_router(struct vty *vty, struct ospf *ospf,  									ospf->vrf_id));  						} else {  							vty_out(vty, -							"%24s   via %s, %s\n", -							"", -							inet_ntoa( -								path->nexthop), -							ifindex2ifname( -								path->ifindex, -								ospf->vrf_id)); +								"%24s   via %s, %s\n", +								"", +								inet_ntoa( +									path->nexthop), +								ifindex2ifname( +									path->ifindex, +									ospf->vrf_id));  						}  					}  				} @@ -9213,7 +9144,8 @@ static void show_ip_ospf_route_external(struct vty *vty, struct ospf *ospf,  		    *json_nexthop = NULL;  	if (!json) -		vty_out(vty, "============ OSPF external routing table ===========\n"); +		vty_out(vty, +			"============ OSPF external routing table ===========\n");  	for (rn = route_top(rt); rn; rn = route_next(rn)) {  		if ((er = rn->info) == NULL) @@ -9225,40 +9157,36 @@ static void show_ip_ospf_route_external(struct vty *vty, struct ospf *ospf,  			 rn->p.prefixlen);  		json_route = json_object_new_object();  		if (json) { -			 json_object_object_add(json, buf1, json_route); -			 json_object_to_json_string_ext(json, -				JSON_C_TO_STRING_NOSLASHESCAPE); - +			json_object_object_add(json, buf1, json_route); +			json_object_to_json_string_ext( +				json, JSON_C_TO_STRING_NOSLASHESCAPE);  		}  		switch (er->path_type) {  		case OSPF_PATH_TYPE1_EXTERNAL:  			if (json) { -				json_object_string_add(json_route, -						       "routeType", +				json_object_string_add(json_route, "routeType",  						       "N E1");  				json_object_int_add(json_route, "cost", -							    er->cost); +						    er->cost);  			} else {  				vty_out(vty, -				"N E1 %-18s    [%d] tag: %" ROUTE_TAG_PRI -				"\n", -				buf1, er->cost, er->u.ext.tag); +					"N E1 %-18s    [%d] tag: %" ROUTE_TAG_PRI +					"\n", +					buf1, er->cost, er->u.ext.tag);  			}  			break;  		case OSPF_PATH_TYPE2_EXTERNAL:  			if (json) { -				json_object_string_add(json_route, -						       "routeType", +				json_object_string_add(json_route, "routeType",  						       "N E2");  				json_object_int_add(json_route, "cost", -							    er->cost); +						    er->cost);  			} else {  				vty_out(vty, -					"N E2 %-18s    [%d/%d] tag: %" -					ROUTE_TAG_PRI -					"\n", buf1, er->cost, -					er->u.ext.type2_cost, +					"N E2 %-18s    [%d/%d] tag: %" ROUTE_TAG_PRI +					"\n", +					buf1, er->cost, er->u.ext.type2_cost,  					er->u.ext.tag);  			}  			break; @@ -9267,61 +9195,56 @@ static void show_ip_ospf_route_external(struct vty *vty, struct ospf *ospf,  		if (json) {  			json_nexthop_array = json_object_new_array();  			json_object_object_add(json_route, "nexthops", -					      json_nexthop_array); +					       json_nexthop_array);  		} -		for (ALL_LIST_ELEMENTS(er->paths, pnode, pnnode, -				       path)) { +		for (ALL_LIST_ELEMENTS(er->paths, pnode, pnnode, path)) {  			if (json) {  				json_nexthop = json_object_new_object(); -				json_object_array_add(json_nexthop_array -						      ,json_nexthop); +				json_object_array_add(json_nexthop_array, +						      json_nexthop);  			} -			if (if_lookup_by_index(path->ifindex, -					       ospf->vrf_id)) { +			if (if_lookup_by_index(path->ifindex, ospf->vrf_id)) {  				if (path->nexthop.s_addr == 0) {  					if (json) {  						json_object_string_add( -							json_nexthop, -								"ip", -								" "); +							json_nexthop, "ip", +							" ");  						json_object_string_add(  							json_nexthop,  							"directly attached to",  							ifindex2ifname( -							path->ifindex, -							ospf->vrf_id)); +								path->ifindex, +								ospf->vrf_id));  					} else {  						vty_out(vty, -						"%24s   directly attached to %s\n", -						"", -						ifindex2ifname( -							path->ifindex, -							ospf->vrf_id)); +							"%24s   directly attached to %s\n", +							"", +							ifindex2ifname( +								path->ifindex, +								ospf->vrf_id));  					}  				} else {  					if (json) {  						json_object_string_add( -							json_nexthop, -								"ip", +							json_nexthop, "ip",  							inet_ntoa( -							path->nexthop)); +								path->nexthop));  						json_object_string_add( -							json_nexthop, -							"via", +							json_nexthop, "via",  							ifindex2ifname( -							path->ifindex, -							ospf->vrf_id)); +								path->ifindex, +								ospf->vrf_id));  					} else {  						vty_out(vty, -						"%24s   via %s, %s\n", -						"", -						inet_ntoa( -							path->nexthop), -						ifindex2ifname( -							path->ifindex, -							ospf->vrf_id)); +							"%24s   via %s, %s\n", +							"", +							inet_ntoa( +								path->nexthop), +							ifindex2ifname( +								path->ifindex, +								ospf->vrf_id));  					}  				}  			} @@ -9334,8 +9257,7 @@ static void show_ip_ospf_route_external(struct vty *vty, struct ospf *ospf,  }  static int show_ip_ospf_border_routers_common(struct vty *vty, -					      struct ospf *ospf, -					      u_char use_vrf) +					      struct ospf *ospf, u_char use_vrf)  {  	if (ospf->instance)  		vty_out(vty, "\nOSPF Instance: %d\n\n", ospf->instance); @@ -9386,9 +9308,8 @@ DEFUN (show_ip_ospf_border_routers,  				if (!ospf->oi_running)  					continue; -				ret = show_ip_ospf_border_routers_common(vty, -								ospf, -								use_vrf); +				ret = show_ip_ospf_border_routers_common( +					vty, ospf, use_vrf);  			}  		} else {  			ospf = ospf_lookup_by_inst_name(inst, vrf_name); @@ -9468,7 +9389,8 @@ static int show_ip_ospf_route_common(struct vty *vty, struct ospf *ospf,  	if (json) {  		if (use_vrf) { -			//json_object_object_add(json_vrf, "areas", json_areas); +			// json_object_object_add(json_vrf, "areas", +			// json_areas);  			if (ospf->vrf_id == VRF_DEFAULT)  				json_object_object_add(json, "default",  						       json_vrf); @@ -9623,8 +9545,9 @@ DEFUN (show_ip_ospf_vrfs,  		else  			name = ospf->name; -		vrf_id_ui = (ospf->vrf_id == VRF_UNKNOWN) ? -1 : -			(int64_t) ospf->vrf_id; +		vrf_id_ui = (ospf->vrf_id == VRF_UNKNOWN) +				    ? -1 +				    : (int64_t)ospf->vrf_id;  		if (uj) {  			json_object_int_add(json_vrf, "vrfId", vrf_id_ui); @@ -9634,8 +9557,8 @@ DEFUN (show_ip_ospf_vrfs,  			json_object_object_add(json_vrfs, name, json_vrf);  		} else { -			vty_out(vty, "%-25s  %-5d  %-16s  \n", -				name, ospf->vrf_id, inet_ntoa(ospf->router_id)); +			vty_out(vty, "%-25s  %-5d  %-16s  \n", name, +				ospf->vrf_id, inet_ntoa(ospf->router_id));  		}  	} @@ -9643,8 +9566,8 @@ DEFUN (show_ip_ospf_vrfs,  		json_object_object_add(json, "vrfs", json_vrfs);  		json_object_int_add(json, "totalVrfs", count); -		vty_out(vty, "%s\n", json_object_to_json_string_ext(json, -						JSON_C_TO_STRING_PRETTY)); +		vty_out(vty, "%s\n", json_object_to_json_string_ext( +					     json, JSON_C_TO_STRING_PRETTY));  		json_object_free(json);  	} else {  		if (count) @@ -9685,8 +9608,8 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf)  		if (ifp->vrf_id == VRF_DEFAULT)  			vty_frame(vty, "interface %s\n", ifp->name);  		else -			vty_frame(vty, "interface %s vrf %s\n", -				ifp->name, vrf->name); +			vty_frame(vty, "interface %s vrf %s\n", ifp->name, +				  vrf->name);  		if (ifp->desc)  			vty_out(vty, " description %s\n", ifp->desc); @@ -9698,22 +9621,21 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf)  			/* Interface Network print. */  			if (OSPF_IF_PARAM_CONFIGURED(params, type)  			    && params->type != OSPF_IFTYPE_LOOPBACK) { -				if (params->type != -					ospf_default_iftype(ifp)) { +				if (params->type != ospf_default_iftype(ifp)) {  					vty_out(vty, " ip ospf network %s",  						ospf_int_type_str -						[params->type]); +							[params->type]);  					if (params != IF_DEF_PARAMS(ifp))  						vty_out(vty, " %s",  							inet_ntoa( -							rn->p.u.prefix4)); +								rn->p.u.prefix4));  					vty_out(vty, "\n");  				}  			}  			/* OSPF interface authentication print */  			if (OSPF_IF_PARAM_CONFIGURED(params, auth_type) -			&& params->auth_type != OSPF_AUTH_NOTSET) { +			    && params->auth_type != OSPF_AUTH_NOTSET) {  				const char *auth_str;  				/* Translation tables are not that much help @@ -9748,7 +9670,7 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf)  			/* Simple Authentication Password print. */  			if (OSPF_IF_PARAM_CONFIGURED(params, auth_simple) -				&& params->auth_simple[0] != '\0') { +			    && params->auth_simple[0] != '\0') {  				vty_out(vty, " ip ospf authentication-key %s",  					params->auth_simple);  				if (params != IF_DEF_PARAMS(ifp)) @@ -9759,23 +9681,21 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf)  			/* Cryptographic Authentication Key print. */  			if (params && params->auth_crypt) { -				for (ALL_LIST_ELEMENTS_RO( -						params->auth_crypt, -						node, ck)) { +				for (ALL_LIST_ELEMENTS_RO(params->auth_crypt, +							  node, ck)) {  					vty_out(vty,  						" ip ospf message-digest-key %d md5 %s", -						ck->key_id, -						ck->auth_key); +						ck->key_id, ck->auth_key);  					if (params != IF_DEF_PARAMS(ifp))  						vty_out(vty, " %s", -						inet_ntoa(rn->p.u.prefix4)); +							inet_ntoa( +								rn->p.u.prefix4));  					vty_out(vty, "\n");  				}  			}  			/* Interface Output Cost print. */ -			if (OSPF_IF_PARAM_CONFIGURED(params, -					     output_cost_cmd)) { +			if (OSPF_IF_PARAM_CONFIGURED(params, output_cost_cmd)) {  				vty_out(vty, " ip ospf cost %u",  					params->output_cost_cmd);  				if (params != IF_DEF_PARAMS(ifp)) @@ -9786,8 +9706,7 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf)  			/* Hello Interval print. */  			if (OSPF_IF_PARAM_CONFIGURED(params, v_hello) -				&& params->v_hello != -				OSPF_HELLO_INTERVAL_DEFAULT) { +			    && params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT) {  				vty_out(vty, " ip ospf hello-interval %u",  					params->v_hello);  				if (params != IF_DEF_PARAMS(ifp)) @@ -9799,19 +9718,18 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf)  			/* Router Dead Interval print. */  			if (OSPF_IF_PARAM_CONFIGURED(params, v_wait) -				&& params->v_wait -				!= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT) { +			    && params->v_wait +				       != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT) {  				vty_out(vty, " ip ospf dead-interval ");  				/* fast hello ? */  				if (OSPF_IF_PARAM_CONFIGURED(params, -						     fast_hello)) +							     fast_hello))  					vty_out(vty,  						"minimal hello-multiplier %d",  						params->fast_hello);  				else -					vty_out(vty, "%u", -						params->v_wait); +					vty_out(vty, "%u", params->v_wait);  				if (params != IF_DEF_PARAMS(ifp))  					vty_out(vty, " %s", @@ -9821,8 +9739,8 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf)  			/* Router Priority print. */  			if (OSPF_IF_PARAM_CONFIGURED(params, priority) -				&& params->priority -				!= OSPF_ROUTER_PRIORITY_DEFAULT) { +			    && params->priority +				       != OSPF_ROUTER_PRIORITY_DEFAULT) {  				vty_out(vty, " ip ospf priority %u",  					params->priority);  				if (params != IF_DEF_PARAMS(ifp)) @@ -9833,9 +9751,9 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf)  			/* Retransmit Interval print. */  			if (OSPF_IF_PARAM_CONFIGURED(params, -					     retransmit_interval) -				&& params->retransmit_interval -				!= OSPF_RETRANSMIT_INTERVAL_DEFAULT) { +						     retransmit_interval) +			    && params->retransmit_interval +				       != OSPF_RETRANSMIT_INTERVAL_DEFAULT) {  				vty_out(vty, " ip ospf retransmit-interval %u",  					params->retransmit_interval);  				if (params != IF_DEF_PARAMS(ifp)) @@ -9845,15 +9763,14 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf)  			}  			/* Transmit Delay print. */ -			if (OSPF_IF_PARAM_CONFIGURED(params, -						     transmit_delay) -				&& params->transmit_delay -				!= OSPF_TRANSMIT_DELAY_DEFAULT) { +			if (OSPF_IF_PARAM_CONFIGURED(params, transmit_delay) +			    && params->transmit_delay +				       != OSPF_TRANSMIT_DELAY_DEFAULT) {  				vty_out(vty, " ip ospf transmit-delay %u",  					params->transmit_delay);  				if (params != IF_DEF_PARAMS(ifp))  					vty_out(vty, " %s", -					inet_ntoa(rn->p.u.prefix4)); +						inet_ntoa(rn->p.u.prefix4));  				vty_out(vty, "\n");  			} @@ -9867,16 +9784,15 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf)  				size_t buflen = MAX(strlen("4294967295"), -					    strlen("255.255.255.255")); +						    strlen("255.255.255.255"));  				char buf[buflen]; -				area_id2str(buf, sizeof(buf), -					    ¶ms->if_area, -						params->if_area_id_fmt); +				area_id2str(buf, sizeof(buf), ¶ms->if_area, +					    params->if_area_id_fmt);  				vty_out(vty, " area %s", buf);  				if (params != IF_DEF_PARAMS(ifp))  					vty_out(vty, " %s", -					inet_ntoa(rn->p.u.prefix4)); +						inet_ntoa(rn->p.u.prefix4));  				vty_out(vty, "\n");  			} @@ -9886,23 +9802,21 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf)  			/* MTU ignore print. */  			if (OSPF_IF_PARAM_CONFIGURED(params, mtu_ignore) -				&& params->mtu_ignore != -				OSPF_MTU_IGNORE_DEFAULT) { +			    && params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) {  				if (params->mtu_ignore == 0)  					vty_out(vty, " no ip ospf mtu-ignore");  				else  					vty_out(vty, " ip ospf mtu-ignore");  				if (params != IF_DEF_PARAMS(ifp))  					vty_out(vty, " %s", -					inet_ntoa(rn->p.u.prefix4)); +						inet_ntoa(rn->p.u.prefix4));  				vty_out(vty, "\n");  			}  			while (1) {  				if (rn == NULL) -					rn = route_top( -						IF_OIFS_PARAMS(ifp)); +					rn = route_top(IF_OIFS_PARAMS(ifp));  				else  					rn = route_next(rn); @@ -10288,14 +10202,12 @@ static int ospf_config_write_one(struct vty *vty, struct ospf *ospf)  	/* `router ospf' print. */  	if (ospf->instance && ospf->name) { -		vty_out(vty, "router ospf %d vrf %s\n", -			ospf->instance, ospf->name); +		vty_out(vty, "router ospf %d vrf %s\n", ospf->instance, +			ospf->name);  	} else if (ospf->instance) { -		vty_out(vty, "router ospf %d\n", -			ospf->instance); +		vty_out(vty, "router ospf %d\n", ospf->instance);  	} else if (ospf->name) { -		vty_out(vty, "router ospf vrf %s\n", -			ospf->name); +		vty_out(vty, "router ospf vrf %s\n", ospf->name);  	} else  		vty_out(vty, "router ospf\n"); @@ -10342,9 +10254,8 @@ static int ospf_config_write_one(struct vty *vty, struct ospf *ospf)  	if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT  	    || ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT  	    || ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT) -		vty_out(vty, " timers throttle spf %d %d %d\n", -			ospf->spf_delay, ospf->spf_holdtime, -			ospf->spf_max_holdtime); +		vty_out(vty, " timers throttle spf %d %d %d\n", ospf->spf_delay, +			ospf->spf_holdtime, ospf->spf_max_holdtime);  	/* LSA timers print. */  	if (ospf->min_ls_interval != OSPF_MIN_LS_INTERVAL) @@ -10363,10 +10274,8 @@ static int ospf_config_write_one(struct vty *vty, struct ospf *ospf)  	config_write_stub_router(vty, ospf);  	/* SPF refresh parameters print. */ -	if (ospf->lsa_refresh_interval -	    != OSPF_LSA_REFRESH_INTERVAL_DEFAULT) -		vty_out(vty, " refresh timer %d\n", -			ospf->lsa_refresh_interval); +	if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT) +		vty_out(vty, " refresh timer %d\n", ospf->lsa_refresh_interval);  	/* Redistribute information print. */  	config_write_ospf_redistribute(vty, ospf); @@ -10379,22 +10288,19 @@ static int ospf_config_write_one(struct vty *vty, struct ospf *ospf)  		if (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp),  					     passive_interface)  		    && IF_DEF_PARAMS(ifp)->passive_interface -		    != ospf->passive_interface_default) { +			       != ospf->passive_interface_default) {  			vty_out(vty, " %spassive-interface %s\n", -				IF_DEF_PARAMS(ifp)->passive_interface -				? "" -				: "no ", +				IF_DEF_PARAMS(ifp)->passive_interface ? "" +								      : "no ",  				ifp->name);  		}  	for (ALL_LIST_ELEMENTS_RO(ospf->oiflist, node, oi)) { -		if (!OSPF_IF_PARAM_CONFIGURED(oi->params, -					      passive_interface)) +		if (!OSPF_IF_PARAM_CONFIGURED(oi->params, passive_interface))  			continue;  		if (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(oi->ifp),  					     passive_interface)) {  			if (oi->params->passive_interface -			    == IF_DEF_PARAMS(oi->ifp) -			    ->passive_interface) +			    == IF_DEF_PARAMS(oi->ifp)->passive_interface)  				continue;  		} else if (oi->params->passive_interface  			   == ospf->passive_interface_default) @@ -10402,8 +10308,7 @@ static int ospf_config_write_one(struct vty *vty, struct ospf *ospf)  		vty_out(vty, " %spassive-interface %s %s\n",  			oi->params->passive_interface ? "" : "no ", -			oi->ifp->name, -			inet_ntoa(oi->address->u.prefix4)); +			oi->ifp->name, inet_ntoa(oi->address->u.prefix4));  	}  	/* Network area print. */ diff --git a/ospfd/ospf_vty.h b/ospfd/ospf_vty.h index 5eb6842be3..559109972c 100644 --- a/ospfd/ospf_vty.h +++ b/ospfd/ospf_vty.h @@ -44,7 +44,7 @@  			vty_out(vty,                                           \  				"%% You can't configure %s to backbone\n",     \  				NAME);                                         \ -			return CMD_WARNING;                                \ +			return CMD_WARNING;                                    \  		}                                                              \  	} diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index 93aa603908..3b257fec96 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -75,8 +75,8 @@ static int ospf_router_id_update_zebra(int command, struct zclient *zclient,  	if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE)) {  		char buf[PREFIX2STR_BUFFER];  		prefix2str(&router_id, buf, sizeof(buf)); -		zlog_debug("Zebra rcvd: router id update %s vrf %s id %u", -			   buf, ospf_vrf_id_to_name(vrf_id), vrf_id); +		zlog_debug("Zebra rcvd: router id update %s vrf %s id %u", buf, +			   ospf_vrf_id_to_name(vrf_id), vrf_id);  	}  	ospf = ospf_lookup_by_vrf_id(vrf_id); @@ -89,9 +89,10 @@ static int ospf_router_id_update_zebra(int command, struct zclient *zclient,  			char buf[PREFIX2STR_BUFFER];  			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); +			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);  		}  	}  	return 0; @@ -356,29 +357,30 @@ static int ospf_interface_link_params(int command, struct zclient *zclient,  /* VRF update for an interface. */  static int ospf_interface_vrf_update(int command, struct zclient *zclient, -				      zebra_size_t length, vrf_id_t vrf_id) +				     zebra_size_t length, vrf_id_t vrf_id)  {  	struct interface *ifp = NULL;  	vrf_id_t new_vrf_id;  	ifp = zebra_interface_vrf_update_read(zclient->ibuf, vrf_id, -					       &new_vrf_id); +					      &new_vrf_id);  	if (!ifp)  		return 0;  	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, -			   ospf_vrf_id_to_name(new_vrf_id), new_vrf_id); +		zlog_debug( +			"%s: Rx Interface %s VRF change vrf_id %u New vrf %s id %u", +			__PRETTY_FUNCTION__, 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);*/  	if_update_to_new_vrf(ifp, new_vrf_id); -	 return 0; +	return 0;  }  void ospf_zebra_add(struct ospf *ospf, struct prefix_ipv4 *p, -		    struct ospf_route *or) +		    struct ospf_route * or)  {  	struct zapi_route api;  	struct zapi_nexthop *api_nh; @@ -461,7 +463,7 @@ void ospf_zebra_add(struct ospf *ospf, struct prefix_ipv4 *p,  }  void ospf_zebra_delete(struct ospf *ospf, struct prefix_ipv4 *p, -		       struct ospf_route *or) +		       struct ospf_route * or)  {  	struct zapi_route api; @@ -694,10 +696,11 @@ int ospf_redistribute_set(struct ospf *ospf, int type, u_short instance,  			     instance, ospf->vrf_id);  	if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) -		zlog_debug("Redistribute[%s][%d] vrf id %u: Start  Type[%d], Metric[%d]", -			   ospf_redist_string(type), instance, ospf->vrf_id, -			   metric_type(ospf, type, instance), -			   metric_value(ospf, type, instance)); +		zlog_debug( +			"Redistribute[%s][%d] vrf id %u: Start  Type[%d], Metric[%d]", +			ospf_redist_string(type), instance, ospf->vrf_id, +			metric_type(ospf, type, instance), +			metric_value(ospf, type, instance));  	ospf_asbr_status_update(ospf, ++ospf->redistribute); @@ -967,8 +970,8 @@ static int ospf_zebra_read_route(int command, struct zclient *zclient,  		 */  		for (i = 0; i < ZEBRA_ROUTE_MAX; i++)  			if (i != api.type) -				ospf_external_info_delete(ospf, i, -							  api.instance, p); +				ospf_external_info_delete(ospf, i, api.instance, +							  p);  		ei = ospf_external_info_add(ospf, api.type, api.instance, p,  					    ifindex, nexthop, api.tag); @@ -1068,7 +1071,7 @@ static int ospf_distribute_list_update_timer(struct thread *thread)  	struct ospf_lsa *lsa;  	int type, default_refresh = 0, arg_type;  	struct ospf *ospf = NULL; -	void **arg = THREAD_ARG (thread); +	void **arg = THREAD_ARG(thread);  	ospf = (struct ospf *)arg[0];  	arg_type = (int)(intptr_t)arg[1]; @@ -1081,9 +1084,10 @@ static int ospf_distribute_list_update_timer(struct thread *thread)  	zlog_info("Zebra[Redistribute]: distribute-list update timer fired!");  	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); +		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);  	}  	/* foreach all external info. */ @@ -1124,15 +1128,14 @@ static int ospf_distribute_list_update_timer(struct thread *thread)  }  /* Update distribute-list and set timer to apply access-list. */ -void ospf_distribute_list_update(struct ospf *ospf, int type, -				 u_short instance) +void ospf_distribute_list_update(struct ospf *ospf, int type, u_short instance)  {  	struct route_table *rt;  	struct ospf_external *ext; -	void **args = XCALLOC(MTYPE_OSPF_DIST_ARGS, sizeof(void *)*2); +	void **args = XCALLOC(MTYPE_OSPF_DIST_ARGS, sizeof(void *) * 2);  	args[0] = ospf; -	args[1] = (void *)((ptrdiff_t) type); +	args[1] = (void *)((ptrdiff_t)type);  	/* External info does not exist. */  	ext = ospf_external_lookup(ospf, type, instance); @@ -1177,13 +1180,15 @@ static void ospf_filter_update(struct access_list *access)  			red_list = ospf->redist[type];  			if (red_list) -				for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { +				for (ALL_LIST_ELEMENTS_RO(red_list, node, +							  red)) {  					if (ROUTEMAP(red)) { -						/* if route-map is not NULL it may be +						/* if route-map is not NULL it +						 * may be  						 * using this access list */  						ospf_distribute_list_update( -									    ospf, -									    type, red->instance); +							ospf, type, +							red->instance);  					}  				} @@ -1195,22 +1200,27 @@ static void ospf_filter_update(struct access_list *access)  			if (DISTRIBUTE_NAME(ospf, type)) {  				/* Keep old access-list for distribute-list. */ -				struct access_list *old = DISTRIBUTE_LIST(ospf, -									  type); +				struct access_list *old = +					DISTRIBUTE_LIST(ospf, type);  				/* Update access-list for distribute-list. */ -				DISTRIBUTE_LIST(ospf, type) = access_list_lookup( -										 AFI_IP, DISTRIBUTE_NAME(ospf, type)); +				DISTRIBUTE_LIST(ospf, type) = +					access_list_lookup( +						AFI_IP, +						DISTRIBUTE_NAME(ospf, type));  				/* No update for this distribute type. */ -				if (old == NULL && DISTRIBUTE_LIST(ospf, type) == NULL) +				if (old == NULL +				    && DISTRIBUTE_LIST(ospf, type) == NULL)  					continue;  				/* Schedule distribute-list update timer. */  				if (DISTRIBUTE_LIST(ospf, type) == NULL -				    || strcmp(DISTRIBUTE_NAME(ospf, type), access->name) -				    == 0) -					ospf_distribute_list_update(ospf, type, 0); +				    || strcmp(DISTRIBUTE_NAME(ospf, type), +					      access->name) +					       == 0) +					ospf_distribute_list_update(ospf, type, +								    0);  			}  		} @@ -1260,8 +1270,8 @@ void ospf_prefix_list_update(struct prefix_list *plist)  			red_list = ospf->redist[type];  			if (red_list) { -				for (ALL_LIST_ELEMENTS_RO(red_list, -							  node, red)) { +				for (ALL_LIST_ELEMENTS_RO(red_list, node, +							  red)) {  					if (ROUTEMAP(red)) {  						/* if route-map is not NULL  						 * it may be using @@ -1279,22 +1289,24 @@ void ospf_prefix_list_update(struct prefix_list *plist)  			/* Update filter-list in. */  			if (PREFIX_NAME_IN(area))  				if (strcmp(PREFIX_NAME_IN(area), -					   prefix_list_name(plist)) == 0) { +					   prefix_list_name(plist)) +				    == 0) {  					PREFIX_LIST_IN(area) =  						prefix_list_lookup( -								   AFI_IP, -								   PREFIX_NAME_IN(area)); +							AFI_IP, +							PREFIX_NAME_IN(area));  					abr_inv++;  				}  			/* Update filter-list out. */  			if (PREFIX_NAME_OUT(area))  				if (strcmp(PREFIX_NAME_OUT(area), -					   prefix_list_name(plist)) == 0) { +					   prefix_list_name(plist)) +				    == 0) {  					PREFIX_LIST_IN(area) =  						prefix_list_lookup( -								   AFI_IP, -								   PREFIX_NAME_OUT(area)); +							AFI_IP, +							PREFIX_NAME_OUT(area));  					abr_inv++;  				}  		} @@ -1407,7 +1419,7 @@ void ospf_distance_reset(struct ospf *ospf)  }  u_char ospf_distance_apply(struct ospf *ospf, struct prefix_ipv4 *p, -			   struct ospf_route *or) +			   struct ospf_route * or)  {  	if (ospf == NULL) diff --git a/ospfd/ospf_zebra.h b/ospfd/ospf_zebra.h index d4b00dddff..236f5a2631 100644 --- a/ospfd/ospf_zebra.h +++ b/ospfd/ospf_zebra.h @@ -59,9 +59,9 @@ extern int ospf_is_type_redistributed(struct ospf *, int, u_short);  extern void ospf_distance_reset(struct ospf *);  extern u_char ospf_distance_apply(struct ospf *ospf, struct prefix_ipv4 *,  				  struct ospf_route *); -extern struct ospf_external *ospf_external_lookup(struct ospf*, u_char, +extern struct ospf_external *ospf_external_lookup(struct ospf *, u_char,  						  u_short); -extern struct ospf_external *ospf_external_add(struct ospf*, u_char, u_short); +extern struct ospf_external *ospf_external_add(struct ospf *, u_char, u_short);  extern void ospf_external_del(struct ospf *, u_char, u_short);  extern struct ospf_redist *ospf_redist_lookup(struct ospf *, u_char, u_short);  extern struct ospf_redist *ospf_redist_add(struct ospf *, u_char, u_short); diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c index 79af4a55fb..c4a4713221 100644 --- a/ospfd/ospfd.c +++ b/ospfd/ospfd.c @@ -121,8 +121,7 @@ void ospf_router_id_update(struct ospf *ospf)  	if (IS_DEBUG_OSPF_EVENT)  		zlog_debug("Router-ID[OLD:%s]: Update to %s", -			   inet_ntoa(ospf->router_id), -			   inet_ntoa(router_id)); +			   inet_ntoa(ospf->router_id), inet_ntoa(router_id));  	if (!IPV4_ADDR_SAME(&router_id_old, &router_id)) { @@ -159,7 +158,7 @@ void ospf_router_id_update(struct ospf *ospf)  			struct route_node *rn;  			struct ospf_lsa *lsa; -			LSDB_LOOP(EXTERNAL_LSDB(ospf), rn, lsa) +			LSDB_LOOP (EXTERNAL_LSDB(ospf), rn, lsa)  				if (IS_LSA_SELF(lsa))  					ospf_lsa_flush_schedule(ospf, lsa);  		} @@ -241,8 +240,9 @@ static struct ospf *ospf_new(u_short instance, const char *name)  		new->name = XSTRDUP(MTYPE_OSPF_TOP, name);  		vrf = vrf_lookup_by_name(new->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); +			zlog_debug( +				"%s: Create new ospf instance with vrf_name %s vrf_id %u", +				__PRETTY_FUNCTION__, name, new->vrf_id);  		if (vrf)  			ospf_vrf_link(new, vrf);  	} else { @@ -329,8 +329,8 @@ static struct ospf *ospf_new(u_short instance, const char *name)  	if ((ospf_sock_init(new)) < 0) {  		if (new->vrf_id != VRF_UNKNOWN)  			zlog_warn( -				  "%s: ospf_sock_init is unable to open a socket", -				  __func__); +				"%s: ospf_sock_init is unable to open a socket", +				__func__);  		return new;  	}  	thread_add_read(master, ospf_read, new, new->fd, &new->t_read); @@ -380,9 +380,10 @@ struct ospf *ospf_lookup_by_inst_name(u_short instance, const char *name)  	struct listnode *node, *nnode;  	for (ALL_LIST_ELEMENTS(om->ospf, node, nnode, ospf)) { -		if ((ospf->instance == instance) && -		    ((ospf->name == NULL && name == NULL) || -		     (ospf->name && name && strcmp(ospf->name, name) == 0))) +		if ((ospf->instance == instance) +		    && ((ospf->name == NULL && name == NULL) +			|| (ospf->name && name +			    && strcmp(ospf->name, name) == 0)))  			return ospf;  	}  	return NULL; @@ -426,9 +427,10 @@ struct ospf *ospf_get_instance(u_short instance)  				ospf_router_id_update(ospf);  			else {  				if (IS_DEBUG_OSPF_EVENT) -					zlog_debug("%s: ospf VRF (id %d) is not active yet, skip router id update" -						    , __PRETTY_FUNCTION__, -						    ospf->vrf_id); +					zlog_debug( +						"%s: ospf VRF (id %d) is not active yet, skip router id update", +						__PRETTY_FUNCTION__, +						ospf->vrf_id);  			}  			ospf_router_id_update(ospf);  		} @@ -447,7 +449,6 @@ struct ospf *ospf_lookup_by_vrf_id(vrf_id_t vrf_id)  	if (!vrf)  		return NULL;  	return (vrf->info) ? (struct ospf *)vrf->info : NULL; -  }  /* It should only be used when processing incoming info update from zebra. @@ -461,8 +462,8 @@ static struct ospf *ospf_lookup_by_name(const char *vrf_name)  	for (ALL_LIST_ELEMENTS(om->ospf, node, nnode, ospf))  		if ((ospf->name == NULL && vrf_name == NULL) -		    || (ospf->name && vrf_name && -			strcmp(ospf->name, vrf_name) == 0)) +		    || (ospf->name && vrf_name +			&& strcmp(ospf->name, vrf_name) == 0))  			return ospf;  	return NULL;  } @@ -711,9 +712,9 @@ static void ospf_finish_final(struct ospf *ospf)  	close(ospf->fd);  	stream_free(ospf->ibuf); -	LSDB_LOOP(OPAQUE_AS_LSDB(ospf), rn, lsa) +	LSDB_LOOP (OPAQUE_AS_LSDB(ospf), rn, lsa)  		ospf_discard_from_db(ospf, ospf->lsdb, lsa); -	LSDB_LOOP(EXTERNAL_LSDB(ospf), rn, lsa) +	LSDB_LOOP (EXTERNAL_LSDB(ospf), rn, lsa)  		ospf_discard_from_db(ospf, ospf->lsdb, lsa);  	ospf_lsdb_delete_all(ospf->lsdb); @@ -848,20 +849,20 @@ static void ospf_area_free(struct ospf_area *area)  	ospf_opaque_type10_lsa_term(area);  	/* Free LSDBs. */ -	LSDB_LOOP(ROUTER_LSDB(area), rn, lsa) +	LSDB_LOOP (ROUTER_LSDB(area), rn, lsa)  		ospf_discard_from_db(area->ospf, area->lsdb, lsa); -	LSDB_LOOP(NETWORK_LSDB(area), rn, lsa) +	LSDB_LOOP (NETWORK_LSDB(area), rn, lsa)  		ospf_discard_from_db(area->ospf, area->lsdb, lsa); -	LSDB_LOOP(SUMMARY_LSDB(area), rn, lsa) +	LSDB_LOOP (SUMMARY_LSDB(area), rn, lsa)  		ospf_discard_from_db(area->ospf, area->lsdb, lsa); -	LSDB_LOOP(ASBR_SUMMARY_LSDB(area), rn, lsa) +	LSDB_LOOP (ASBR_SUMMARY_LSDB(area), rn, lsa)  		ospf_discard_from_db(area->ospf, area->lsdb, lsa); -	LSDB_LOOP(NSSA_LSDB(area), rn, lsa) +	LSDB_LOOP (NSSA_LSDB(area), rn, lsa)  		ospf_discard_from_db(area->ospf, area->lsdb, lsa); -	LSDB_LOOP(OPAQUE_AREA_LSDB(area), rn, lsa) +	LSDB_LOOP (OPAQUE_AREA_LSDB(area), rn, lsa)  		ospf_discard_from_db(area->ospf, area->lsdb, lsa); -	LSDB_LOOP(OPAQUE_LINK_LSDB(area), rn, lsa) +	LSDB_LOOP (OPAQUE_LINK_LSDB(area), rn, lsa)  		ospf_discard_from_db(area->ospf, area->lsdb, lsa);  	ospf_lsdb_delete_all(area->lsdb); @@ -998,13 +999,12 @@ static void update_redistributed(struct ospf *ospf, int add_to_ospf)  					continue;  				if (add_to_ospf) { -					if (ospf_external_info_find_lsa( -						    ospf, &ei->p)) +					if (ospf_external_info_find_lsa(ospf, +									&ei->p))  						if (!ospf_distribute_check_connected(  							    ospf, ei))  							ospf_external_lsa_flush( -								ospf, -								ei->type, +								ospf, ei->type,  								&ei->p,  								ei->ifindex /*, ei->nexthop */);  				} else { @@ -1013,8 +1013,7 @@ static void update_redistributed(struct ospf *ospf, int add_to_ospf)  						if (ospf_distribute_check_connected(  							    ospf, ei))  							ospf_external_lsa_originate( -								ospf, -								ei); +								ospf, ei);  				}  			}  		} @@ -1100,10 +1099,10 @@ int ospf_network_unset(struct ospf *ospf, struct prefix_ipv4 *p,  	/* Find interfaces that are not configured already.  */  	for (ALL_LIST_ELEMENTS(ospf->oiflist, node, nnode, oi)) { -	  if (oi->type == OSPF_IFTYPE_VIRTUALLINK) -	    continue; +		if (oi->type == OSPF_IFTYPE_VIRTUALLINK) +			continue; -	  ospf_network_run_subnet(ospf, oi->connected, NULL, NULL); +		ospf_network_run_subnet(ospf, oi->connected, NULL, NULL);  	}  	/* Update connected redistribute. */ @@ -1321,10 +1320,11 @@ void ospf_if_update(struct ospf *ospf, struct interface *ifp)  		return;  	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, -			   ospf_vrf_id_to_name(ospf->vrf_id), ospf->vrf_id, -			   inet_ntoa(ospf->router_id)); +		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, +			ospf_vrf_id_to_name(ospf->vrf_id), ospf->vrf_id, +			inet_ntoa(ospf->router_id));  	/* OSPF must be ready. */  	if (!ospf_is_ready(ospf)) @@ -2056,8 +2056,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", __PRETTY_FUNCTION__, +			   vrf->name, vrf->vrf_id);  	ospf = ospf_lookup_by_name(vrf->name);  	if (ospf) { @@ -2065,24 +2065,27 @@ static int ospf_vrf_enable(struct vrf *vrf)  		/* We have instance configured, link to VRF and make it "up". */  		ospf_vrf_link(ospf, 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); +			zlog_debug( +				"%s: ospf linked to vrf %s vrf_id %u (old id %u)", +				__PRETTY_FUNCTION__, vrf->name, ospf->vrf_id, +				old_vrf_id);  		if (old_vrf_id != ospf->vrf_id) {  			if (ospfd_privs.change(ZPRIVS_RAISE)) { -				zlog_err("ospf_sock_init: could not raise privs, %s", -					 safe_strerror(errno)); +				zlog_err( +					"ospf_sock_init: could not raise privs, %s", +					safe_strerror(errno));  			}  			ret = ospf_sock_init(ospf);  			if (ospfd_privs.change(ZPRIVS_LOWER)) { -				zlog_err("ospf_sock_init: could not lower privs, %s", -					 safe_strerror(errno)); +				zlog_err( +					"ospf_sock_init: could not lower privs, %s", +					safe_strerror(errno));  			}  			if (ret < 0 || ospf->fd <= 0)  				return 0; -			thread_add_read(master, ospf_read, ospf, -					ospf->fd, &ospf->t_read); +			thread_add_read(master, ospf_read, ospf, ospf->fd, +					&ospf->t_read);  			ospf->oi_running = 1;  			ospf_zebra_vrf_register(ospf);  			ospf_router_id_update(ospf); @@ -2102,8 +2105,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.", __PRETTY_FUNCTION__, +			   vrf->name, vrf->vrf_id);  	ospf = ospf_lookup_by_name(vrf->name);  	if (ospf) { @@ -2116,7 +2119,7 @@ static int ospf_vrf_disable(struct vrf *vrf)  		ospf->oi_running = 0;  		if (IS_DEBUG_OSPF_EVENT)  			zlog_debug("%s: ospf old_vrf_id %d unlinked", -				    __PRETTY_FUNCTION__, old_vrf_id); +				   __PRETTY_FUNCTION__, old_vrf_id);  		thread_cancel(ospf->t_read);  		close(ospf->fd);  		ospf->fd = -1; @@ -2128,8 +2131,8 @@ static int ospf_vrf_disable(struct vrf *vrf)  void ospf_vrf_init(void)  { -	vrf_init(ospf_vrf_new, ospf_vrf_enable, -		 ospf_vrf_disable, ospf_vrf_delete); +	vrf_init(ospf_vrf_new, ospf_vrf_enable, ospf_vrf_disable, +		 ospf_vrf_delete);  }  void ospf_vrf_terminate(void) diff --git a/ospfd/ospfd.h b/ospfd/ospfd.h index 6954660e02..bed446085e 100644 --- a/ospfd/ospfd.h +++ b/ospfd/ospfd.h @@ -131,8 +131,8 @@ struct ospf {  	struct in_addr router_id_static; /* Configured manually. */  	struct in_addr router_id_zebra; -	vrf_id_t vrf_id;  /* VRF Id */ -	char *name;       /* VRF name */ +	vrf_id_t vrf_id; /* VRF Id */ +	char *name;      /* VRF name */  	/* ABR/ASBR internal flags. */  	u_char flags; @@ -165,8 +165,6 @@ struct ospf {  	/* RFC3137 stub router. Configured time to stay stub / max-metric */  	unsigned int stub_router_startup_time;  /* seconds */  	unsigned int stub_router_shutdown_time; /* seconds */ -						/* $FRR indent$ */ -						/* clang-format off */  #define OSPF_STUB_ROUTER_UNCONFIGURED	  0  	u_char stub_router_admin_set;  #define OSPF_STUB_ROUTER_ADMINISTRATIVE_SET     1 @@ -187,8 +185,6 @@ struct ospf {  		spf_hold_multiplier; /* Adaptive multiplier for hold time */  	int default_originate;	/* Default information originate. */ -				      /* $FRR indent$ */ -				      /* clang-format off */  #define DEFAULT_ORIGINATE_NONE		0  #define DEFAULT_ORIGINATE_ZEBRA		1  #define DEFAULT_ORIGINATE_ALWAYS	2 @@ -343,8 +339,6 @@ struct ospf_area {  	int external_routing;    /* ExternalRoutingCapability. */  	int no_summary;		 /* Don't inject summaries into stub.*/  	int shortcut_configured; /* Area configured as shortcut. */ -				 /* $FRR indent$ */ -				 /* clang-format off */  #define OSPF_SHORTCUT_DEFAULT	0  #define OSPF_SHORTCUT_ENABLE	1  #define OSPF_SHORTCUT_DISABLE	2 @@ -354,21 +348,15 @@ struct ospf_area {  	u_char NSSATranslatorRole;  /* NSSA configured role */ -				    /* $FRR indent$ */ -				    /* clang-format off */  #define OSPF_NSSA_ROLE_NEVER     0  #define OSPF_NSSA_ROLE_CANDIDATE 1  #define OSPF_NSSA_ROLE_ALWAYS    2  	u_char NSSATranslatorState; /* NSSA operational role */ -				    /* $FRR indent$ */ -				    /* clang-format off */  #define OSPF_NSSA_TRANSLATE_DISABLED 0  #define OSPF_NSSA_TRANSLATE_ENABLED  1  	int NSSATranslatorStabilityInterval;  	u_char transit;		    /* TransitCapability. */ -				    /* $FRR indent$ */ -				    /* clang-format off */  #define OSPF_TRANSIT_FALSE      0  #define OSPF_TRANSIT_TRUE       1  	struct route_table *ranges; /* Configured Area Ranges. */ diff --git a/pimd/mtracebis.c b/pimd/mtracebis.c index 1e7aee858a..337d420d34 100644 --- a/pimd/mtracebis.c +++ b/pimd/mtracebis.c @@ -230,7 +230,7 @@ int main(int argc, char *const argv[])  		static struct option long_options[] = {  			{"help", no_argument, 0, 'h'},  			{"version", no_argument, 0, 'v'}, -			{0, 0, 0, 0} }; +			{0, 0, 0, 0}};  		int option_index = 0;  		c = getopt_long(argc, argv, "vh", long_options, &option_index); diff --git a/pimd/mtracebis_netlink.c b/pimd/mtracebis_netlink.c index 42b80b218b..a66da87e1b 100644 --- a/pimd/mtracebis_netlink.c +++ b/pimd/mtracebis_netlink.c @@ -52,12 +52,14 @@ int rtnl_open_byproto(struct rtnl_handle *rth, unsigned subscriptions,  		return -1;  	} -	if (setsockopt(rth->fd,SOL_SOCKET,SO_SNDBUF,&sndbuf,sizeof(sndbuf)) < 0) { +	if (setsockopt(rth->fd, SOL_SOCKET, SO_SNDBUF, &sndbuf, sizeof(sndbuf)) +	    < 0) {  		perror("SO_SNDBUF");  		return -1;  	} -	if (setsockopt(rth->fd,SOL_SOCKET,SO_RCVBUF,&rcvbuf,sizeof(rcvbuf)) < 0) { +	if (setsockopt(rth->fd, SOL_SOCKET, SO_RCVBUF, &rcvbuf, sizeof(rcvbuf)) +	    < 0) {  		perror("SO_RCVBUF");  		return -1;  	} @@ -66,12 +68,14 @@ int rtnl_open_byproto(struct rtnl_handle *rth, unsigned subscriptions,  	rth->local.nl_family = AF_NETLINK;  	rth->local.nl_groups = subscriptions; -	if (bind(rth->fd, (struct sockaddr*)&rth->local, sizeof(rth->local)) < 0) { +	if (bind(rth->fd, (struct sockaddr *)&rth->local, sizeof(rth->local)) +	    < 0) {  		perror("Cannot bind netlink socket");  		return -1;  	}  	addr_len = sizeof(rth->local); -	if (getsockname(rth->fd, (struct sockaddr*)&rth->local, &addr_len) < 0) { +	if (getsockname(rth->fd, (struct sockaddr *)&rth->local, &addr_len) +	    < 0) {  		perror("Cannot getsockname");  		return -1;  	} @@ -80,7 +84,8 @@ int rtnl_open_byproto(struct rtnl_handle *rth, unsigned subscriptions,  		return -1;  	}  	if (rth->local.nl_family != AF_NETLINK) { -		fprintf(stderr, "Wrong address family %d\n", rth->local.nl_family); +		fprintf(stderr, "Wrong address family %d\n", +			rth->local.nl_family);  		return -1;  	}  	rth->seq = time(NULL); @@ -102,12 +107,12 @@ int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type)  	memset(&req, 0, sizeof(req));  	req.nlh.nlmsg_len = sizeof(req);  	req.nlh.nlmsg_type = type; -	req.nlh.nlmsg_flags = NLM_F_ROOT|NLM_F_MATCH|NLM_F_REQUEST; +	req.nlh.nlmsg_flags = NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST;  	req.nlh.nlmsg_pid = 0;  	req.nlh.nlmsg_seq = rth->dump = ++rth->seq;  	req.g.rtgen_family = family; -	return send(rth->fd, (void*)&req, sizeof(req), 0); +	return send(rth->fd, (void *)&req, sizeof(req), 0);  }  int rtnl_send(struct rtnl_handle *rth, const char *buf, int len) @@ -126,7 +131,7 @@ int rtnl_send_check(struct rtnl_handle *rth, const char *buf, int len)  		return status;  	/* Check for immediate errors */ -	status = recv(rth->fd, resp, sizeof(resp), MSG_DONTWAIT|MSG_PEEK); +	status = recv(rth->fd, resp, sizeof(resp), MSG_DONTWAIT | MSG_PEEK);  	if (status < 0) {  		if (errno == EAGAIN)  			return 0; @@ -136,8 +141,9 @@ int rtnl_send_check(struct rtnl_handle *rth, const char *buf, int len)  	for (h = (struct nlmsghdr *)resp; NLMSG_OK(h, (uint32_t)status);  	     h = NLMSG_NEXT(h, status)) {  		if (h->nlmsg_type == NLMSG_ERROR) { -			struct nlmsgerr *err = (struct nlmsgerr*)NLMSG_DATA(h); -			if (h->nlmsg_len < NLMSG_LENGTH(sizeof(struct nlmsgerr))) +			struct nlmsgerr *err = (struct nlmsgerr *)NLMSG_DATA(h); +			if (h->nlmsg_len +			    < NLMSG_LENGTH(sizeof(struct nlmsgerr)))  				fprintf(stderr, "ERROR truncated\n");  			else  				errno = -err->error; @@ -152,13 +158,11 @@ int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len)  {  	struct nlmsghdr nlh;  	struct sockaddr_nl nladdr; -	struct iovec iov[2] = { -		{ .iov_base = &nlh, .iov_len = sizeof(nlh) }, -		{ .iov_base = req, .iov_len = len } -	}; +	struct iovec iov[2] = {{.iov_base = &nlh, .iov_len = sizeof(nlh)}, +			       {.iov_base = req, .iov_len = len}};  	struct msghdr msg = {  		.msg_name = &nladdr, -		.msg_namelen = 	sizeof(nladdr), +		.msg_namelen = sizeof(nladdr),  		.msg_iov = iov,  		.msg_iovlen = 2,  	}; @@ -168,7 +172,7 @@ int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len)  	nlh.nlmsg_len = NLMSG_LENGTH(len);  	nlh.nlmsg_type = type; -	nlh.nlmsg_flags = NLM_F_ROOT|NLM_F_MATCH|NLM_F_REQUEST; +	nlh.nlmsg_flags = NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST;  	nlh.nlmsg_pid = 0;  	nlh.nlmsg_seq = rth->dump = ++rth->seq; @@ -212,15 +216,15 @@ int rtnl_dump_filter_l(struct rtnl_handle *rth,  		}  		for (a = arg; a->filter; a++) { -			struct nlmsghdr *h = (struct nlmsghdr*)buf; +			struct nlmsghdr *h = (struct nlmsghdr *)buf;  			msglen = status;  			while (NLMSG_OK(h, (uint32_t)msglen)) {  				int err; -				if (nladdr.nl_pid != 0 || -				    h->nlmsg_pid != rth->local.nl_pid || -				    h->nlmsg_seq != rth->dump) { +				if (nladdr.nl_pid != 0 +				    || h->nlmsg_pid != rth->local.nl_pid +				    || h->nlmsg_seq != rth->dump) {  					if (a->junk) {  						err = a->junk(&nladdr, h,  							      a->arg2); @@ -235,8 +239,12 @@ int rtnl_dump_filter_l(struct rtnl_handle *rth,  					break; /* process next filter */  				}  				if (h->nlmsg_type == NLMSG_ERROR) { -					struct nlmsgerr *err = (struct nlmsgerr*)NLMSG_DATA(h); -					if (h->nlmsg_len < NLMSG_LENGTH(sizeof(struct nlmsgerr))) { +					struct nlmsgerr *err = +						(struct nlmsgerr *)NLMSG_DATA( +							h); +					if (h->nlmsg_len +					    < NLMSG_LENGTH(sizeof( +						      struct nlmsgerr))) {  						fprintf(stderr,  							"ERROR truncated\n");  					} else { @@ -249,7 +257,7 @@ int rtnl_dump_filter_l(struct rtnl_handle *rth,  				if (err < 0)  					return err; -skip_it: +			skip_it:  				h = NLMSG_NEXT(h, msglen);  			}  		} @@ -268,40 +276,32 @@ skip_it:  	}  } -int rtnl_dump_filter(struct rtnl_handle *rth, -		     rtnl_filter_t filter, -		     void *arg1, -		     rtnl_filter_t junk, -		     void *arg2) +int rtnl_dump_filter(struct rtnl_handle *rth, rtnl_filter_t filter, void *arg1, +		     rtnl_filter_t junk, void *arg2)  {  	const struct rtnl_dump_filter_arg a[2] = { -		{ .filter = filter, .arg1 = arg1, .junk = junk, .arg2 = arg2 }, -		{ .filter = NULL,   .arg1 = NULL, .junk = NULL, .arg2 = NULL } -	}; +		{.filter = filter, .arg1 = arg1, .junk = junk, .arg2 = arg2}, +		{.filter = NULL, .arg1 = NULL, .junk = NULL, .arg2 = NULL}};  	return rtnl_dump_filter_l(rth, a);  }  int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer, -	      unsigned groups, struct nlmsghdr *answer, -	      rtnl_filter_t junk, +	      unsigned groups, struct nlmsghdr *answer, rtnl_filter_t junk,  	      void *jarg)  {  	int status;  	unsigned seq;  	struct nlmsghdr *h;  	struct sockaddr_nl nladdr; -	struct iovec iov = { -		.iov_base = (void*) n, -		.iov_len = n->nlmsg_len -	}; +	struct iovec iov = {.iov_base = (void *)n, .iov_len = n->nlmsg_len};  	struct msghdr msg = {  		.msg_name = &nladdr,  		.msg_namelen = sizeof(nladdr),  		.msg_iov = &iov,  		.msg_iovlen = 1,  	}; -	char   buf[16384]; +	char buf[16384];  	memset(&nladdr, 0, sizeof(nladdr));  	nladdr.nl_family = AF_NETLINK; @@ -320,7 +320,7 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,  		return -1;  	} -	memset(buf,0,sizeof(buf)); +	memset(buf, 0, sizeof(buf));  	iov.iov_base = buf; @@ -340,26 +340,28 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,  			return -1;  		}  		if (msg.msg_namelen != sizeof(nladdr)) { -			fprintf(stderr, "sender address length == %d\n", msg.msg_namelen); +			fprintf(stderr, "sender address length == %d\n", +				msg.msg_namelen);  			exit(1);  		} -		for (h = (struct nlmsghdr*)buf; status >= (int)sizeof(*h); ) { +		for (h = (struct nlmsghdr *)buf; status >= (int)sizeof(*h);) {  			int err;  			int len = h->nlmsg_len;  			int l = len - sizeof(*h); -			if (l<0 || len>status) { +			if (l < 0 || len > status) {  				if (msg.msg_flags & MSG_TRUNC) {  					fprintf(stderr, "Truncated message\n");  					return -1;  				} -				fprintf(stderr, "!!!malformed message: len=%d\n", len); +				fprintf(stderr, +					"!!!malformed message: len=%d\n", len);  				exit(1);  			} -			if ((int)nladdr.nl_pid != peer || -			    h->nlmsg_pid != rtnl->local.nl_pid || -			    h->nlmsg_seq != seq) { +			if ((int)nladdr.nl_pid != peer +			    || h->nlmsg_pid != rtnl->local.nl_pid +			    || h->nlmsg_seq != seq) {  				if (junk) {  					err = junk(&nladdr, h, jarg);  					if (err < 0) @@ -367,19 +369,22 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,  				}  				/* Don't forget to skip that message. */  				status -= NLMSG_ALIGN(len); -				h = (struct nlmsghdr*)((char*)h + NLMSG_ALIGN(len)); +				h = (struct nlmsghdr *)((char *)h +							+ NLMSG_ALIGN(len));  				continue;  			}  			if (h->nlmsg_type == NLMSG_ERROR) { -				struct nlmsgerr *err = (struct nlmsgerr*)NLMSG_DATA(h); +				struct nlmsgerr *err = +					(struct nlmsgerr *)NLMSG_DATA(h);  				if (l < (int)sizeof(struct nlmsgerr)) {  					fprintf(stderr, "ERROR truncated\n");  				} else {  					errno = -err->error;  					if (errno == 0) {  						if (answer) -							memcpy(answer, h, h->nlmsg_len); +							memcpy(answer, h, +							       h->nlmsg_len);  						return 0;  					}  					perror("RTNETLINK answers"); @@ -394,7 +399,7 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,  			fprintf(stderr, "Unexpected reply!!!\n");  			status -= NLMSG_ALIGN(len); -			h = (struct nlmsghdr*)((char*)h + NLMSG_ALIGN(len)); +			h = (struct nlmsghdr *)((char *)h + NLMSG_ALIGN(len));  		}  		if (msg.msg_flags & MSG_TRUNC) {  			fprintf(stderr, "Message truncated\n"); @@ -407,9 +412,7 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,  	}  } -int rtnl_listen(struct rtnl_handle *rtnl, -		rtnl_filter_t handler, -		void *jarg) +int rtnl_listen(struct rtnl_handle *rtnl, rtnl_filter_t handler, void *jarg)  {  	int status;  	struct nlmsghdr *h; @@ -421,7 +424,7 @@ int rtnl_listen(struct rtnl_handle *rtnl,  		.msg_iov = &iov,  		.msg_iovlen = 1,  	}; -	char   buf[8192]; +	char buf[8192];  	memset(&nladdr, 0, sizeof(nladdr));  	nladdr.nl_family = AF_NETLINK; @@ -447,20 +450,22 @@ int rtnl_listen(struct rtnl_handle *rtnl,  			return -1;  		}  		if (msg.msg_namelen != sizeof(nladdr)) { -			fprintf(stderr, "Sender address length == %d\n", msg.msg_namelen); +			fprintf(stderr, "Sender address length == %d\n", +				msg.msg_namelen);  			exit(1);  		} -		for (h =(struct nlmsghdr*)buf; status >= (int)sizeof(*h); ) { +		for (h = (struct nlmsghdr *)buf; status >= (int)sizeof(*h);) {  			int err;  			int len = h->nlmsg_len;  			int l = len - sizeof(*h); -			if (l<0 || len>status) { +			if (l < 0 || len > status) {  				if (msg.msg_flags & MSG_TRUNC) {  					fprintf(stderr, "Truncated message\n");  					return -1;  				} -				fprintf(stderr, "!!!malformed message: len=%d\n", len); +				fprintf(stderr, +					"!!!malformed message: len=%d\n", len);  				exit(1);  			} @@ -469,7 +474,7 @@ int rtnl_listen(struct rtnl_handle *rtnl,  				return err;  			status -= NLMSG_ALIGN(len); -			h = (struct nlmsghdr*)((char*)h + NLMSG_ALIGN(len)); +			h = (struct nlmsghdr *)((char *)h + NLMSG_ALIGN(len));  		}  		if (msg.msg_flags & MSG_TRUNC) {  			fprintf(stderr, "Message truncated\n"); @@ -482,13 +487,12 @@ int rtnl_listen(struct rtnl_handle *rtnl,  	}  } -int rtnl_from_file(FILE *rtnl, rtnl_filter_t handler, -		   void *jarg) +int rtnl_from_file(FILE *rtnl, rtnl_filter_t handler, void *jarg)  {  	int status;  	struct sockaddr_nl nladdr; -	char   buf[8192]; -	struct nlmsghdr *h = (void*)buf; +	char buf[8192]; +	struct nlmsghdr *h = (void *)buf;  	memset(&nladdr, 0, sizeof(nladdr));  	nladdr.nl_family = AF_NETLINK; @@ -513,7 +517,7 @@ int rtnl_from_file(FILE *rtnl, rtnl_filter_t handler,  		len = h->nlmsg_len;  		l = len - sizeof(*h); -		if (l<0 || len>(int)sizeof(buf)) { +		if (l < 0 || len > (int)sizeof(buf)) {  			fprintf(stderr, "!!!malformed message: len=%d @%lu\n",  				len, ftell(rtnl));  			return -1; @@ -541,7 +545,9 @@ int addattr32(struct nlmsghdr *n, int maxlen, int type, __u32 data)  	int len = RTA_LENGTH(4);  	struct rtattr *rta;  	if ((int)(NLMSG_ALIGN(n->nlmsg_len) + len) > maxlen) { -		fprintf(stderr,"addattr32: Error! max allowed bound %d exceeded\n",maxlen); +		fprintf(stderr, +			"addattr32: Error! max allowed bound %d exceeded\n", +			maxlen);  		return -1;  	}  	rta = NLMSG_TAIL(n); @@ -559,7 +565,9 @@ int addattr_l(struct nlmsghdr *n, int maxlen, int type, const void *data,  	struct rtattr *rta;  	if ((int)(NLMSG_ALIGN(n->nlmsg_len) + RTA_ALIGN(len)) > maxlen) { -		fprintf(stderr, "addattr_l ERROR: message exceeded bound of %d\n",maxlen); +		fprintf(stderr, +			"addattr_l ERROR: message exceeded bound of %d\n", +			maxlen);  		return -1;  	}  	rta = NLMSG_TAIL(n); @@ -578,12 +586,14 @@ int addattr_l(struct nlmsghdr *n, int maxlen, int type, const void *data,  int addraw_l(struct nlmsghdr *n, int maxlen, const void *data, int len)  {  	if ((int)(NLMSG_ALIGN(n->nlmsg_len) + NLMSG_ALIGN(len)) > maxlen) { -		fprintf(stderr, "addraw_l ERROR: message exceeded bound of %d\n",maxlen); +		fprintf(stderr, +			"addraw_l ERROR: message exceeded bound of %d\n", +			maxlen);  		return -1;  	}  	memcpy(NLMSG_TAIL(n), data, len); -	memset((uint8_t *) NLMSG_TAIL(n) + len, 0, NLMSG_ALIGN(len) - len); +	memset((uint8_t *)NLMSG_TAIL(n) + len, 0, NLMSG_ALIGN(len) - len);  	n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + NLMSG_ALIGN(len);  	return 0;  } @@ -627,10 +637,12 @@ int rta_addattr32(struct rtattr *rta, int maxlen, int type, __u32 data)  	struct rtattr *subrta;  	if ((int)(RTA_ALIGN(rta->rta_len) + len) > maxlen) { -		fprintf(stderr,"rta_addattr32: Error! max allowed bound %d exceeded\n",maxlen); +		fprintf(stderr, +			"rta_addattr32: Error! max allowed bound %d exceeded\n", +			maxlen);  		return -1;  	} -	subrta = (struct rtattr*)(((char*)rta) + RTA_ALIGN(rta->rta_len)); +	subrta = (struct rtattr *)(((char *)rta) + RTA_ALIGN(rta->rta_len));  	subrta->rta_type = type;  	subrta->rta_len = len;  	memcpy(RTA_DATA(subrta), &data, 4); @@ -638,17 +650,19 @@ int rta_addattr32(struct rtattr *rta, int maxlen, int type, __u32 data)  	return 0;  } -int rta_addattr_l(struct rtattr *rta, int maxlen, int type, -		  const void *data, int alen) +int rta_addattr_l(struct rtattr *rta, int maxlen, int type, const void *data, +		  int alen)  {  	struct rtattr *subrta;  	int len = RTA_LENGTH(alen);  	if ((int)(RTA_ALIGN(rta->rta_len) + RTA_ALIGN(len)) > maxlen) { -		fprintf(stderr,"rta_addattr_l: Error! max allowed bound %d exceeded\n",maxlen); +		fprintf(stderr, +			"rta_addattr_l: Error! max allowed bound %d exceeded\n", +			maxlen);  		return -1;  	} -	subrta = (struct rtattr*)(((char*)rta) + RTA_ALIGN(rta->rta_len)); +	subrta = (struct rtattr *)(((char *)rta) + RTA_ALIGN(rta->rta_len));  	subrta->rta_type = type;  	subrta->rta_len = len;  	memcpy(RTA_DATA(subrta), data, alen); @@ -662,14 +676,16 @@ int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len)  	while (RTA_OK(rta, len)) {  		if ((rta->rta_type <= max) && (!tb[rta->rta_type]))  			tb[rta->rta_type] = rta; -		rta = RTA_NEXT(rta,len); +		rta = RTA_NEXT(rta, len);  	}  	if (len) -		fprintf(stderr, "!!!Deficit %d, rta_len=%d\n", len, rta->rta_len); +		fprintf(stderr, "!!!Deficit %d, rta_len=%d\n", len, +			rta->rta_len);  	return 0;  } -int parse_rtattr_byindex(struct rtattr *tb[], int max, struct rtattr *rta, int len) +int parse_rtattr_byindex(struct rtattr *tb[], int max, struct rtattr *rta, +			 int len)  {  	int i = 0; @@ -677,20 +693,22 @@ int parse_rtattr_byindex(struct rtattr *tb[], int max, struct rtattr *rta, int l  	while (RTA_OK(rta, len)) {  		if (rta->rta_type <= max && i < max)  			tb[i++] = rta; -		rta = RTA_NEXT(rta,len); +		rta = RTA_NEXT(rta, len);  	}  	if (len) -		fprintf(stderr, "!!!Deficit %d, rta_len=%d\n", len, rta->rta_len); +		fprintf(stderr, "!!!Deficit %d, rta_len=%d\n", len, +			rta->rta_len);  	return i;  } -int __parse_rtattr_nested_compat(struct rtattr *tb[], int max, struct rtattr *rta, -			         int len) +int __parse_rtattr_nested_compat(struct rtattr *tb[], int max, +				 struct rtattr *rta, int len)  {  	if ((int)RTA_PAYLOAD(rta) < len)  		return -1;  	if (RTA_PAYLOAD(rta) >= RTA_ALIGN(len) + sizeof(struct rtattr)) { -		rta = (struct rtattr *)(uint8_t *)RTA_DATA(rta)+RTA_ALIGN(len); +		rta = (struct rtattr *)(uint8_t *)RTA_DATA(rta) +		      + RTA_ALIGN(len);  		return parse_rtattr_nested(tb, max, rta);  	}  	memset(tb, 0, sizeof(struct rtattr *) * (max + 1)); diff --git a/pimd/mtracebis_netlink.h b/pimd/mtracebis_netlink.h index 7a60ead975..46e176e726 100644 --- a/pimd/mtracebis_netlink.h +++ b/pimd/mtracebis_netlink.h @@ -22,28 +22,28 @@  #include <linux/if_addr.h>  #include <linux/neighbour.h> -struct rtnl_handle -{ -	int			fd; -	struct sockaddr_nl	local; -	struct sockaddr_nl	peer; -	__u32			seq; -	__u32			dump; +struct rtnl_handle { +	int fd; +	struct sockaddr_nl local; +	struct sockaddr_nl peer; +	__u32 seq; +	__u32 dump;  };  extern int rcvbuf;  extern int rtnl_open(struct rtnl_handle *rth, unsigned subscriptions); -extern int rtnl_open_byproto(struct rtnl_handle *rth, unsigned subscriptions, int protocol); +extern int rtnl_open_byproto(struct rtnl_handle *rth, unsigned subscriptions, +			     int protocol);  extern void rtnl_close(struct rtnl_handle *rth);  extern int rtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type); -extern int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len); +extern int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, +			     int len); -typedef int (*rtnl_filter_t)(const struct sockaddr_nl *, -			     struct nlmsghdr *n, void *); +typedef int (*rtnl_filter_t)(const struct sockaddr_nl *, struct nlmsghdr *n, +			     void *); -struct rtnl_dump_filter_arg -{ +struct rtnl_dump_filter_arg {  	rtnl_filter_t filter;  	void *arg1;  	rtnl_filter_t junk; @@ -53,73 +53,79 @@ struct rtnl_dump_filter_arg  extern int rtnl_dump_filter_l(struct rtnl_handle *rth,  			      const struct rtnl_dump_filter_arg *arg);  extern int rtnl_dump_filter(struct rtnl_handle *rth, rtnl_filter_t filter, -			    void *arg1, -			    rtnl_filter_t junk, -			    void *arg2); +			    void *arg1, rtnl_filter_t junk, void *arg2);  extern int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,  		     unsigned groups, struct nlmsghdr *answer, -		     rtnl_filter_t junk, -		     void *jarg); +		     rtnl_filter_t junk, void *jarg);  extern int rtnl_send(struct rtnl_handle *rth, const char *buf, int);  extern int rtnl_send_check(struct rtnl_handle *rth, const char *buf, int);  extern int addattr32(struct nlmsghdr *n, int maxlen, int type, __u32 data); -extern int addattr_l(struct nlmsghdr *n, int maxlen, int type, const void *data, int alen); +extern int addattr_l(struct nlmsghdr *n, int maxlen, int type, const void *data, +		     int alen);  extern int addraw_l(struct nlmsghdr *n, int maxlen, const void *data, int len);  extern struct rtattr *addattr_nest(struct nlmsghdr *n, int maxlen, int type);  extern int addattr_nest_end(struct nlmsghdr *n, struct rtattr *nest); -extern struct rtattr *addattr_nest_compat(struct nlmsghdr *n, int maxlen, int type, const void *data, int len); +extern struct rtattr *addattr_nest_compat(struct nlmsghdr *n, int maxlen, +					  int type, const void *data, int len);  extern int addattr_nest_compat_end(struct nlmsghdr *n, struct rtattr *nest);  extern int rta_addattr32(struct rtattr *rta, int maxlen, int type, __u32 data); -extern int rta_addattr_l(struct rtattr *rta, int maxlen, int type, const void *data, int alen); +extern int rta_addattr_l(struct rtattr *rta, int maxlen, int type, +			 const void *data, int alen); -extern int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len); -extern int parse_rtattr_byindex(struct rtattr *tb[], int max, struct rtattr *rta, int len); -extern int __parse_rtattr_nested_compat(struct rtattr *tb[], int max, struct rtattr *rta, int len); +extern int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, +			int len); +extern int parse_rtattr_byindex(struct rtattr *tb[], int max, +				struct rtattr *rta, int len); +extern int __parse_rtattr_nested_compat(struct rtattr *tb[], int max, +					struct rtattr *rta, int len); -#define parse_rtattr_nested(tb, max, rta) \ +#define parse_rtattr_nested(tb, max, rta)                                      \  	(parse_rtattr((tb), (max), RTA_DATA(rta), RTA_PAYLOAD(rta))) -#define parse_rtattr_nested_compat(tb, max, rta, data, len) \ -({	data = RTA_PAYLOAD(rta) >= len ? RTA_DATA(rta) : NULL; \ -	__parse_rtattr_nested_compat(tb, max, rta, len); }) +#define parse_rtattr_nested_compat(tb, max, rta, data, len)                    \ +	({                                                                     \ +		data = RTA_PAYLOAD(rta) >= len ? RTA_DATA(rta) : NULL;         \ +		__parse_rtattr_nested_compat(tb, max, rta, len);               \ +	}) -extern int rtnl_listen(struct rtnl_handle *, rtnl_filter_t handler, -		       void *jarg); -extern int rtnl_from_file(FILE *, rtnl_filter_t handler, -		       void *jarg); +extern int rtnl_listen(struct rtnl_handle *, rtnl_filter_t handler, void *jarg); +extern int rtnl_from_file(FILE *, rtnl_filter_t handler, void *jarg); -#define NLMSG_TAIL(nmsg) \ -	((struct rtattr *) (((uint8_t *) (nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len))) +#define NLMSG_TAIL(nmsg)                                                       \ +	((struct rtattr *)(((uint8_t *)(nmsg))                                 \ +			   + NLMSG_ALIGN((nmsg)->nlmsg_len)))  #ifndef IFA_RTA -#define IFA_RTA(r) \ -	((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg)))) +#define IFA_RTA(r)                                                             \ +	((struct rtattr *)(((char *)(r))                                       \ +			   + NLMSG_ALIGN(sizeof(struct ifaddrmsg))))  #endif  #ifndef IFA_PAYLOAD  #define IFA_PAYLOAD(n)	NLMSG_PAYLOAD(n,sizeof(struct ifaddrmsg))  #endif  #ifndef IFLA_RTA -#define IFLA_RTA(r) \ -	((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg)))) +#define IFLA_RTA(r)                                                            \ +	((struct rtattr *)(((char *)(r))                                       \ +			   + NLMSG_ALIGN(sizeof(struct ifinfomsg))))  #endif  #ifndef IFLA_PAYLOAD  #define IFLA_PAYLOAD(n)	NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg))  #endif  #ifndef NDA_RTA -#define NDA_RTA(r) \ -	((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ndmsg)))) +#define NDA_RTA(r)                                                             \ +	((struct rtattr *)(((char *)(r)) + NLMSG_ALIGN(sizeof(struct ndmsg))))  #endif  #ifndef NDA_PAYLOAD  #define NDA_PAYLOAD(n)	NLMSG_PAYLOAD(n,sizeof(struct ndmsg))  #endif  #ifndef NDTA_RTA -#define NDTA_RTA(r) \ -	((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ndtmsg)))) +#define NDTA_RTA(r)                                                            \ +	((struct rtattr *)(((char *)(r)) + NLMSG_ALIGN(sizeof(struct ndtmsg))))  #endif  #ifndef NDTA_PAYLOAD  #define NDTA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ndtmsg)) diff --git a/pimd/pim_assert.c b/pimd/pim_assert.c index 934fea5a9e..3f863ebeca 100644 --- a/pimd/pim_assert.c +++ b/pimd/pim_assert.c @@ -405,9 +405,9 @@ int pim_assert_build_msg(uint8_t *pim_msg, int buf_size, struct interface *ifp,  	}  	/* Metric preference */ -	pim_write_uint32(pim_msg_curr, rpt_bit_flag -					       ? metric_preference | 0x80000000 -					       : metric_preference); +	pim_write_uint32(pim_msg_curr, +			 rpt_bit_flag ? metric_preference | 0x80000000 +				      : metric_preference);  	pim_msg_curr += 4;  	/* Route metric */ diff --git a/pimd/pim_bfd.c b/pimd/pim_bfd.c index f8903d71e9..29ff337d96 100644 --- a/pimd/pim_bfd.c +++ b/pimd/pim_bfd.c @@ -318,11 +318,12 @@ static int pim_bfd_nbr_replay(int command, struct zclient *zclient,  					char str[INET_ADDRSTRLEN];  					pim_inet4_dump("<bfd_nbr?>", -						       neigh->source_addr, -						       str, sizeof(str)); -					zlog_debug("%s: Replaying Pim Neigh %s to BFD vrf_id %u", -						   __PRETTY_FUNCTION__, str, -						   vrf->vrf_id); +						       neigh->source_addr, str, +						       sizeof(str)); +					zlog_debug( +						"%s: Replaying Pim Neigh %s to BFD vrf_id %u", +						__PRETTY_FUNCTION__, str, +						vrf->vrf_id);  				}  				pim_bfd_reg_dereg_nbr(neigh,  						      ZEBRA_BFD_DEST_UPDATE); diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index fc07b706a9..f701c94865 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -175,8 +175,7 @@ static void pim_if_membership_refresh(struct interface *ifp)  static void pim_show_assert_helper(struct vty *vty,  				   struct pim_interface *pim_ifp, -				   struct pim_ifchannel *ch, -				   time_t now) +				   struct pim_ifchannel *ch, time_t now)  {  	char ch_src_str[INET_ADDRSTRLEN];  	char ch_grp_str[INET_ADDRSTRLEN]; @@ -187,23 +186,18 @@ static void pim_show_assert_helper(struct vty *vty,  	ifaddr = pim_ifp->primary_address; -	pim_inet4_dump("<ch_src?>", ch->sg.src, ch_src_str, -		       sizeof(ch_src_str)); -	pim_inet4_dump("<ch_grp?>", ch->sg.grp, ch_grp_str, -		       sizeof(ch_grp_str)); +	pim_inet4_dump("<ch_src?>", ch->sg.src, ch_src_str, sizeof(ch_src_str)); +	pim_inet4_dump("<ch_grp?>", ch->sg.grp, ch_grp_str, sizeof(ch_grp_str));  	pim_inet4_dump("<assrt_win?>", ch->ifassert_winner, winner_str,  		       sizeof(winner_str)); -	pim_time_uptime(uptime, sizeof(uptime), -			now - ch->ifassert_creation); -	pim_time_timer_to_mmss(timer, sizeof(timer), -			       ch->t_ifassert_timer); +	pim_time_uptime(uptime, sizeof(uptime), now - ch->ifassert_creation); +	pim_time_timer_to_mmss(timer, sizeof(timer), ch->t_ifassert_timer);  	vty_out(vty, "%-9s %-15s %-15s %-15s %-6s %-15s %-8s %-5s\n", -		ch->interface->name, inet_ntoa(ifaddr), ch_src_str, -		ch_grp_str, -		pim_ifchannel_ifassert_name(ch->ifassert_state), -		winner_str, uptime, timer); +		ch->interface->name, inet_ntoa(ifaddr), ch_src_str, ch_grp_str, +		pim_ifchannel_ifassert_name(ch->ifassert_state), winner_str, +		uptime, timer);  }  static void pim_show_assert(struct pim_instance *pim, struct vty *vty) @@ -239,20 +233,15 @@ static void pim_show_assert_internal_helper(struct vty *vty,  	ifaddr = pim_ifp->primary_address; -	pim_inet4_dump("<ch_src?>", ch->sg.src, ch_src_str, -		       sizeof(ch_src_str)); -	pim_inet4_dump("<ch_grp?>", ch->sg.grp, ch_grp_str, -		       sizeof(ch_grp_str)); +	pim_inet4_dump("<ch_src?>", ch->sg.src, ch_src_str, sizeof(ch_src_str)); +	pim_inet4_dump("<ch_grp?>", ch->sg.grp, ch_grp_str, sizeof(ch_grp_str));  	vty_out(vty, "%-9s %-15s %-15s %-15s %-3s %-3s %-3s %-4s\n", -		ch->interface->name, inet_ntoa(ifaddr), ch_src_str, -		ch_grp_str, +		ch->interface->name, inet_ntoa(ifaddr), ch_src_str, ch_grp_str,  		PIM_IF_FLAG_TEST_COULD_ASSERT(ch->flags) ? "yes" : "no",  		pim_macro_ch_could_assert_eval(ch) ? "yes" : "no", -		PIM_IF_FLAG_TEST_ASSERT_TRACKING_DESIRED(ch->flags) -		? "yes" -		: "no", -		pim_macro_assert_tracking_desired_eval(ch) ? "yes" -		: "no"); +		PIM_IF_FLAG_TEST_ASSERT_TRACKING_DESIRED(ch->flags) ? "yes" +								    : "no", +		pim_macro_assert_tracking_desired_eval(ch) ? "yes" : "no");  }  static void pim_show_assert_internal(struct pim_instance *pim, struct vty *vty) @@ -295,17 +284,14 @@ static void pim_show_assert_metric_helper(struct vty *vty,  	am = pim_macro_spt_assert_metric(&ch->upstream->rpf,  					 pim_ifp->primary_address); -	pim_inet4_dump("<ch_src?>", ch->sg.src, ch_src_str, -		       sizeof(ch_src_str)); -	pim_inet4_dump("<ch_grp?>", ch->sg.grp, ch_grp_str, -		       sizeof(ch_grp_str)); -	pim_inet4_dump("<addr?>", am.ip_address, addr_str, -		       sizeof(addr_str)); +	pim_inet4_dump("<ch_src?>", ch->sg.src, ch_src_str, sizeof(ch_src_str)); +	pim_inet4_dump("<ch_grp?>", ch->sg.grp, ch_grp_str, sizeof(ch_grp_str)); +	pim_inet4_dump("<addr?>", am.ip_address, addr_str, sizeof(addr_str));  	vty_out(vty, "%-9s %-15s %-15s %-15s %-3s %4u %6u %-15s\n", -		ch->interface->name, inet_ntoa(ifaddr), ch_src_str, -		ch_grp_str, am.rpt_bit_flag ? "yes" : "no", -		am.metric_preference, am.route_metric, addr_str); +		ch->interface->name, inet_ntoa(ifaddr), ch_src_str, ch_grp_str, +		am.rpt_bit_flag ? "yes" : "no", am.metric_preference, +		am.route_metric, addr_str);  }  static void pim_show_assert_metric(struct pim_instance *pim, struct vty *vty) @@ -344,12 +330,9 @@ static void pim_show_assert_winner_metric_helper(struct vty *vty,  	am = &ch->ifassert_winner_metric; -	pim_inet4_dump("<ch_src?>", ch->sg.src, ch_src_str, -		       sizeof(ch_src_str)); -	pim_inet4_dump("<ch_grp?>", ch->sg.grp, ch_grp_str, -		       sizeof(ch_grp_str)); -	pim_inet4_dump("<addr?>", am->ip_address, addr_str, -		       sizeof(addr_str)); +	pim_inet4_dump("<ch_src?>", ch->sg.src, ch_src_str, sizeof(ch_src_str)); +	pim_inet4_dump("<ch_grp?>", ch->sg.grp, ch_grp_str, sizeof(ch_grp_str)); +	pim_inet4_dump("<addr?>", am->ip_address, addr_str, sizeof(addr_str));  	if (am->metric_preference == PIM_ASSERT_METRIC_PREFERENCE_MAX)  		snprintf(pref_str, sizeof(pref_str), "INFI"); @@ -360,13 +343,11 @@ static void pim_show_assert_winner_metric_helper(struct vty *vty,  	if (am->route_metric == PIM_ASSERT_ROUTE_METRIC_MAX)  		snprintf(metr_str, sizeof(metr_str), "INFI");  	else -		snprintf(metr_str, sizeof(metr_str), "%6u", -			 am->route_metric); +		snprintf(metr_str, sizeof(metr_str), "%6u", am->route_metric);  	vty_out(vty, "%-9s %-15s %-15s %-15s %-3s %-4s %-6s %-15s\n", -		ch->interface->name, inet_ntoa(ifaddr), ch_src_str, -		ch_grp_str, am->rpt_bit_flag ? "yes" : "no", pref_str, -		metr_str, addr_str); +		ch->interface->name, inet_ntoa(ifaddr), ch_src_str, ch_grp_str, +		am->rpt_bit_flag ? "yes" : "no", pref_str, metr_str, addr_str);  }  static void pim_show_assert_winner_metric(struct pim_instance *pim, @@ -431,30 +412,24 @@ static void pim_show_membership_helper(struct vty *vty,  	json_object *json_iface = NULL;  	json_object *json_row = NULL; -	pim_inet4_dump("<ch_src?>", ch->sg.src, ch_src_str, -		       sizeof(ch_src_str)); -	pim_inet4_dump("<ch_grp?>", ch->sg.grp, ch_grp_str, -		       sizeof(ch_grp_str)); +	pim_inet4_dump("<ch_src?>", ch->sg.src, ch_src_str, sizeof(ch_src_str)); +	pim_inet4_dump("<ch_grp?>", ch->sg.grp, ch_grp_str, sizeof(ch_grp_str)); -	json_object_object_get_ex(json, ch->interface->name, -				  &json_iface); +	json_object_object_get_ex(json, ch->interface->name, &json_iface);  	if (!json_iface) {  		json_iface = json_object_new_object();  		json_object_pim_ifp_add(json_iface, ch->interface); -		json_object_object_add(json, ch->interface->name, -				       json_iface); +		json_object_object_add(json, ch->interface->name, json_iface);  	}  	json_row = json_object_new_object();  	json_object_string_add(json_row, "source", ch_src_str);  	json_object_string_add(json_row, "group", ch_grp_str); -	json_object_string_add( -		json_row, "localMembership", -		ch->local_ifmembership == PIM_IFMEMBERSHIP_NOINFO -		? "NOINFO" -		: "INCLUDE"); +	json_object_string_add(json_row, "localMembership", +			       ch->local_ifmembership == PIM_IFMEMBERSHIP_NOINFO +				       ? "NOINFO" +				       : "INCLUDE");  	json_object_object_add(json_iface, ch_grp_str, json_row); -  }  static void pim_show_membership(struct pim_instance *pim, struct vty *vty,  				u_char uj) @@ -1060,10 +1035,10 @@ static void pim_show_interfaces_single(struct pim_instance *pim,  					json_fhr_sources =  						json_object_new_object(); -				pim_inet4_dump("<src?>", up->sg.src, -					       src_str, sizeof(src_str)); -				pim_inet4_dump("<grp?>", up->sg.grp, -					       grp_str, sizeof(grp_str)); +				pim_inet4_dump("<src?>", up->sg.src, src_str, +					       sizeof(src_str)); +				pim_inet4_dump("<grp?>", up->sg.grp, grp_str, +					       sizeof(grp_str));  				pim_time_uptime(uptime, sizeof(uptime),  						now - up->state_transition); @@ -1072,15 +1047,13 @@ static void pim_show_interfaces_single(struct pim_instance *pim,  				 * If not create it.  				 */  				json_object_object_get_ex(json_fhr_sources, -							  grp_str, -							  &json_group); +							  grp_str, &json_group);  				if (!json_group) {  					json_group = json_object_new_object(); -					json_object_object_add( -						json_fhr_sources, -						grp_str, -						json_group); +					json_object_object_add(json_fhr_sources, +							       grp_str, +							       json_group);  				}  				json_group_source = json_object_new_object(); @@ -1216,8 +1189,9 @@ static void pim_show_interfaces_single(struct pim_instance *pim,  						  up)) {  				if (strcmp(ifp->name, -					   up->rpf.source_nexthop. -					   interface->name) != 0) +					   up->rpf.source_nexthop +						   .interface->name) +				    != 0)  					continue;  				if (!(up->flags & PIM_UPSTREAM_FLAG_MASK_FHR)) @@ -1231,16 +1205,15 @@ static void pim_show_interfaces_single(struct pim_instance *pim,  					print_header = 0;  				} -				pim_inet4_dump("<src?>", up->sg.src, -					       src_str, sizeof(src_str)); -				pim_inet4_dump("<grp?>", up->sg.grp, -					       grp_str, sizeof(grp_str)); +				pim_inet4_dump("<src?>", up->sg.src, src_str, +					       sizeof(src_str)); +				pim_inet4_dump("<grp?>", up->sg.grp, grp_str, +					       sizeof(grp_str));  				pim_time_uptime(uptime, sizeof(uptime),  						now - up->state_transition);  				vty_out(vty,  					"%s : %s is a source, uptime is %s\n", -					grp_str, src_str, -					uptime); +					grp_str, src_str, uptime);  			}  			if (!print_header) { @@ -1568,12 +1541,9 @@ static void pim_show_interface_traffic_single(struct pim_instance *pim,  	}  } -static void pim_show_join_helper(struct vty *vty, -				 struct pim_interface *pim_ifp, -				 struct pim_ifchannel *ch, -				 json_object *json, -				 time_t now, -				 u_char uj) +static void pim_show_join_helper(struct vty *vty, struct pim_interface *pim_ifp, +				 struct pim_ifchannel *ch, json_object *json, +				 time_t now, u_char uj)  {  	char ch_src_str[INET_ADDRSTRLEN];  	char ch_grp_str[INET_ADDRSTRLEN]; @@ -1587,13 +1557,10 @@ static void pim_show_join_helper(struct vty *vty,  	ifaddr = pim_ifp->primary_address; -	pim_inet4_dump("<ch_src?>", ch->sg.src, ch_src_str, -		       sizeof(ch_src_str)); -	pim_inet4_dump("<ch_grp?>", ch->sg.grp, ch_grp_str, -		       sizeof(ch_grp_str)); +	pim_inet4_dump("<ch_src?>", ch->sg.src, ch_src_str, sizeof(ch_src_str)); +	pim_inet4_dump("<ch_grp?>", ch->sg.grp, ch_grp_str, sizeof(ch_grp_str)); -	pim_time_uptime_begin(uptime, sizeof(uptime), now, -			      ch->ifjoin_creation); +	pim_time_uptime_begin(uptime, sizeof(uptime), now, ch->ifjoin_creation);  	pim_time_timer_to_mmss(expire, sizeof(expire),  			       ch->t_ifjoin_expiry_timer);  	pim_time_timer_to_mmss(prune, sizeof(prune), @@ -1605,10 +1572,9 @@ static void pim_show_join_helper(struct vty *vty,  		if (!json_iface) {  			json_iface = json_object_new_object(); -			json_object_pim_ifp_add(json_iface, -						ch->interface); -			json_object_object_add( -				json, ch->interface->name, json_iface); +			json_object_pim_ifp_add(json_iface, ch->interface); +			json_object_object_add(json, ch->interface->name, +					       json_iface);  		}  		json_row = json_object_new_object(); @@ -1619,29 +1585,23 @@ static void pim_show_join_helper(struct vty *vty,  		json_object_string_add(json_row, "prune", prune);  		json_object_string_add(  			json_row, "channelJoinName", -			pim_ifchannel_ifjoin_name(ch->ifjoin_state, -						  ch->flags)); +			pim_ifchannel_ifjoin_name(ch->ifjoin_state, ch->flags));  		if (PIM_IF_FLAG_TEST_S_G_RPT(ch->flags))  			json_object_int_add(json_row, "SGRpt", 1); -		json_object_object_get_ex(json_iface, ch_grp_str, -					  &json_grp); +		json_object_object_get_ex(json_iface, ch_grp_str, &json_grp);  		if (!json_grp) {  			json_grp = json_object_new_object(); -			json_object_object_add(json_grp, ch_src_str, -					       json_row); +			json_object_object_add(json_grp, ch_src_str, json_row);  			json_object_object_add(json_iface, ch_grp_str,  					       json_grp);  		} else -			json_object_object_add(json_grp, ch_src_str, -					       json_row); +			json_object_object_add(json_grp, ch_src_str, json_row);  	} else { -		vty_out(vty, -			"%-9s %-15s %-15s %-15s %-10s %8s %-6s %5s\n", -			ch->interface->name, inet_ntoa(ifaddr), -			ch_src_str, ch_grp_str, -			pim_ifchannel_ifjoin_name(ch->ifjoin_state, -						  ch->flags), +		vty_out(vty, "%-9s %-15s %-15s %-15s %-10s %8s %-6s %5s\n", +			ch->interface->name, inet_ntoa(ifaddr), ch_src_str, +			ch_grp_str, +			pim_ifchannel_ifjoin_name(ch->ifjoin_state, ch->flags),  			uptime, expire, prune);  	}  } @@ -1674,7 +1634,7 @@ static void pim_show_join(struct pim_instance *pim, struct vty *vty, u_char uj)  	if (uj) {  		vty_out(vty, "%s\n", json_object_to_json_string_ext( -				json, JSON_C_TO_STRING_PRETTY)); +					     json, JSON_C_TO_STRING_PRETTY));  		json_object_free(json);  	}  } @@ -2374,20 +2334,20 @@ static void pim_show_upstream(struct pim_instance *pim, struct vty *vty,  			 * we are the FHR, else we just put  			 * the RP as the rpfAddress  			 */ -			if (up->flags & PIM_UPSTREAM_FLAG_MASK_FHR || -			    up->sg.src.s_addr == INADDR_ANY) { +			if (up->flags & PIM_UPSTREAM_FLAG_MASK_FHR +			    || up->sg.src.s_addr == INADDR_ANY) {  				char rpf[PREFIX_STRLEN];  				struct pim_rpf *rpg;  				rpg = RP(pim, up->sg.grp);  				pim_inet4_dump("<rpf?>", -					       rpg->rpf_addr.u.prefix4, -					       rpf, sizeof(rpf)); -				json_object_string_add(json_row, -						       "rpfAddress", rpf); +					       rpg->rpf_addr.u.prefix4, rpf, +					       sizeof(rpf)); +				json_object_string_add(json_row, "rpfAddress", +						       rpf);  			} else { -				json_object_string_add(json_row, -						       "rpfAddress", src_str); +				json_object_string_add(json_row, "rpfAddress", +						       src_str);  			}  			json_object_string_add(json_row, "source", src_str); @@ -2432,8 +2392,7 @@ static void pim_show_join_desired_helper(struct pim_instance *pim,  					 struct vty *vty,  					 struct pim_interface *pim_ifp,  					 struct pim_ifchannel *ch, -					 json_object *json, -					 u_char uj) +					 json_object *json, u_char uj)  {  	struct pim_upstream *up = ch->upstream;  	json_object *json_group = NULL; @@ -2449,8 +2408,7 @@ static void pim_show_join_desired_helper(struct pim_instance *pim,  		if (!json_group) {  			json_group = json_object_new_object(); -			json_object_object_add(json, grp_str, -					       json_group); +			json_object_object_add(json, grp_str, json_group);  		}  		json_row = json_object_new_object(); @@ -2461,36 +2419,31 @@ static void pim_show_join_desired_helper(struct pim_instance *pim,  		json_object_string_add(json_row, "group", grp_str);  		if (pim_macro_ch_lost_assert(ch)) -			json_object_boolean_true_add(json_row, -						     "lostAssert"); +			json_object_boolean_true_add(json_row, "lostAssert");  		if (pim_macro_chisin_joins(ch))  			json_object_boolean_true_add(json_row, "joins");  		if (pim_macro_chisin_pim_include(ch)) -			json_object_boolean_true_add(json_row, -						     "pimInclude"); +			json_object_boolean_true_add(json_row, "pimInclude");  		if (pim_upstream_evaluate_join_desired(pim, up)) -			json_object_boolean_true_add( -				json_row, "evaluateJoinDesired"); +			json_object_boolean_true_add(json_row, +						     "evaluateJoinDesired");  		json_object_object_add(json_group, src_str, json_row);  	} else { -		vty_out(vty, -			"%-9s %-15s %-15s %-10s %-5s %-10s %-11s %-6s\n", +		vty_out(vty, "%-9s %-15s %-15s %-10s %-5s %-10s %-11s %-6s\n",  			ch->interface->name, src_str, grp_str,  			pim_macro_ch_lost_assert(ch) ? "yes" : "no",  			pim_macro_chisin_joins(ch) ? "yes" : "no",  			pim_macro_chisin_pim_include(ch) ? "yes" : "no", -			PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED( -				up->flags) -			? "yes" -			: "no", -			pim_upstream_evaluate_join_desired(pim, up) -			? "yes" -			: "no"); +			PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED(up->flags) +				? "yes" +				: "no", +			pim_upstream_evaluate_join_desired(pim, up) ? "yes" +								    : "no");  	}  } @@ -2518,8 +2471,7 @@ static void pim_show_join_desired(struct pim_instance *pim, struct vty *vty,  		RB_FOREACH (ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) {  			/* scan all interfaces */ -			pim_show_join_desired_helper(pim, vty, -						     pim_ifp, ch, +			pim_show_join_desired_helper(pim, vty, pim_ifp, ch,  						     json, uj);  		}  	} @@ -3136,12 +3088,12 @@ static void clear_interfaces(struct pim_instance *pim)  	clear_pim_interfaces(pim);  } -#define PIM_GET_PIM_INTERFACE(pim_ifp, ifp)				\ -	pim_ifp = ifp->info;						\ -	if (!pim_ifp) {							\ -		vty_out(vty,						\ +#define PIM_GET_PIM_INTERFACE(pim_ifp, ifp)                                     \ +	pim_ifp = ifp->info;                                                    \ +	if (!pim_ifp) {                                                         \ +		vty_out(vty,                                                    \  			"%% Enable PIM and/or IGMP on this interface first\n"); \ -		return CMD_WARNING_CONFIG_FAILED;			\ +		return CMD_WARNING_CONFIG_FAILED;                               \  	}  DEFUN (clear_ip_interfaces, @@ -4251,11 +4203,12 @@ DEFUN (show_ip_pim_nexthop_lookup,  		result = pim_ecmp_nexthop_search(vrf->info, &pnc, &nexthop,  						 &nht_p, &grp, 0);  	else -		result = pim_ecmp_nexthop_lookup(vrf->info, &nexthop, vif_source, -						 &nht_p, &grp, 0); +		result = pim_ecmp_nexthop_lookup(vrf->info, &nexthop, +						 vif_source, &nht_p, &grp, 0);  	if (!result) { -		vty_out(vty, "Nexthop Lookup failed, no usable routes returned.\n"); +		vty_out(vty, +			"Nexthop Lookup failed, no usable routes returned.\n");  		return CMD_SUCCESS;  	} @@ -4428,8 +4381,8 @@ DEFUN (show_ip_multicast_vrf_all,  	return CMD_SUCCESS;  } -static void show_mroute(struct pim_instance *pim, struct vty *vty, -			bool fill, u_char uj) +static void show_mroute(struct pim_instance *pim, struct vty *vty, bool fill, +			u_char uj)  {  	struct listnode *node;  	struct channel_oil *c_oil; @@ -4682,9 +4635,11 @@ 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(oif_uptime, sizeof(oif_uptime), -					now - -					s_route->c_oil.oif_creation[oif_vif_index]); +			pim_time_uptime( +				oif_uptime, sizeof(oif_uptime), +				now +					- s_route->c_oil +						  .oif_creation[oif_vif_index]);  			found_oif = 1;  			if (ifp_out) @@ -5055,7 +5010,8 @@ static int pim_rp_cmd_worker(struct pim_instance *pim, struct vty *vty,  	}  	if (result == PIM_GROUP_OVERLAP) { -		vty_out(vty, "%% Group range specified cannot exact match another\n"); +		vty_out(vty, +			"%% Group range specified cannot exact match another\n");  		return CMD_WARNING_CONFIG_FAILED;  	} @@ -8508,10 +8464,10 @@ DEFUN (show_ip_msdp_sa_sg_vrf_all,  	int idx = 2;  	char *src_ip = argv_find(argv, argc, "A.B.C.D", &idx) ? argv[idx++]->arg -		: NULL; +							      : NULL;  	char *grp_ip = idx < argc && argv_find(argv, argc, "A.B.C.D", &idx) -		? argv[idx]->arg -		: NULL; +			       ? argv[idx]->arg +			       : NULL;  	if (uj)  		vty_out(vty, "{ "); diff --git a/pimd/pim_hello.c b/pimd/pim_hello.c index 08a1432bb0..b6c5bc432d 100644 --- a/pimd/pim_hello.c +++ b/pimd/pim_hello.c @@ -125,9 +125,9 @@ static void tlv_trace_list(const char *label, const char *tlv_name,  	}  } -#define FREE_ADDR_LIST							\ -	if (hello_option_addr_list) {					\ -		list_delete_and_null(&hello_option_addr_list);		\ +#define FREE_ADDR_LIST                                                         \ +	if (hello_option_addr_list) {                                          \ +		list_delete_and_null(&hello_option_addr_list);                 \  	}  #define FREE_ADDR_LIST_THEN_RETURN(code)                                       \ diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c index a807c69c60..998f8fc2ca 100644 --- a/pimd/pim_iface.c +++ b/pimd/pim_iface.c @@ -427,8 +427,7 @@ static int pim_sec_addr_update(struct interface *ifp)  	struct pim_secondary_addr *sec_addr;  	int changed = 0; -	for (ALL_LIST_ELEMENTS_RO(pim_ifp->sec_addr_list, node, -				  sec_addr)) { +	for (ALL_LIST_ELEMENTS_RO(pim_ifp->sec_addr_list, node, sec_addr)) {  		sec_addr->flags |= PIM_SEC_ADDRF_STALE;  	} @@ -1286,7 +1285,7 @@ static struct igmp_join *igmp_join_new(struct interface *ifp,  }  ferr_r pim_if_igmp_join_add(struct interface *ifp, struct in_addr group_addr, -			 struct in_addr source_addr) +			    struct in_addr source_addr)  {  	struct pim_interface *pim_ifp;  	struct igmp_join *ij; diff --git a/pimd/pim_iface.h b/pimd/pim_iface.h index 09bd2b06e4..5ecd07d227 100644 --- a/pimd/pim_iface.h +++ b/pimd/pim_iface.h @@ -81,10 +81,9 @@ struct pim_interface {  	struct in_addr update_source;   /* user can statically set the primary  					 * address of the interface */ -	int igmp_version;		      /* IGMP version */ -	int igmp_default_robustness_variable; /* IGMPv3 QRV */ -	int -		igmp_default_query_interval;   /* IGMPv3 secs between general +	int igmp_version;		       /* IGMP version */ +	int igmp_default_robustness_variable;  /* IGMPv3 QRV */ +	int igmp_default_query_interval;       /* IGMPv3 secs between general  						  queries */  	int igmp_query_max_response_time_dsec; /* IGMPv3 Max Response Time in  						  dsecs for general queries */ diff --git a/pimd/pim_ifchannel.c b/pimd/pim_ifchannel.c index 4d564e5046..bb56379c14 100644 --- a/pimd/pim_ifchannel.c +++ b/pimd/pim_ifchannel.c @@ -44,8 +44,7 @@  #include "pim_ssm.h"  #include "pim_rp.h" -RB_GENERATE(pim_ifchannel_rb, pim_ifchannel, -	    pim_ifp_rb, pim_ifchannel_compare); +RB_GENERATE(pim_ifchannel_rb, pim_ifchannel, pim_ifp_rb, pim_ifchannel_compare);  int pim_ifchannel_compare(const struct pim_ifchannel *ch1,  			  const struct pim_ifchannel *ch2) @@ -642,11 +641,10 @@ static int on_ifjoin_prune_pending_timer(struct thread *t)  	ch = THREAD_ARG(t);  	if (PIM_DEBUG_TRACE) -		zlog_debug("%s: IFCHANNEL%s %s Prune Pending Timer Popped", -			   __PRETTY_FUNCTION__, -			   pim_str_sg_dump(&ch->sg), -			   pim_ifchannel_ifjoin_name(ch->ifjoin_state, -						     ch->flags)); +		zlog_debug( +			"%s: IFCHANNEL%s %s Prune Pending Timer Popped", +			__PRETTY_FUNCTION__, pim_str_sg_dump(&ch->sg), +			pim_ifchannel_ifjoin_name(ch->ifjoin_state, ch->flags));  	if (ch->ifjoin_state == PIM_IFJOIN_PRUNE_PENDING) {  		ifp = ch->interface; @@ -662,9 +660,8 @@ static int on_ifjoin_prune_pending_timer(struct thread *t)  				rpf.source_nexthop.interface = ifp;  				rpf.rpf_addr.u.prefix4 =  					pim_ifp->primary_address; -				pim_jp_agg_single_upstream_send(&rpf, -								ch->upstream, -								0); +				pim_jp_agg_single_upstream_send( +					&rpf, ch->upstream, 0);  			}  			ifjoin_to_noinfo(ch, true); @@ -681,8 +678,7 @@ static int on_ifjoin_prune_pending_timer(struct thread *t)  								 ch->upstream);  				pim_jp_agg_single_upstream_send(&parent->rpf, -								parent, -								true); +								parent, true);  			}  		}  		/* from here ch may have been deleted */ @@ -1374,8 +1370,7 @@ void pim_ifchannel_set_star_g_join_state(struct pim_ifchannel *ch, int eom,  			if (child->ifjoin_state == PIM_IFJOIN_PRUNE_PENDING_TMP)  				THREAD_OFF(child->t_ifjoin_prune_pending_timer);  			THREAD_OFF(child->t_ifjoin_expiry_timer); -			struct pim_upstream *parent = -				child->upstream->parent; +			struct pim_upstream *parent = child->upstream->parent;  			PIM_IF_FLAG_UNSET_S_G_RPT(child->flags);  			child->ifjoin_state = PIM_IFJOIN_NOINFO; @@ -1383,19 +1378,16 @@ void pim_ifchannel_set_star_g_join_state(struct pim_ifchannel *ch, int eom,  			if (I_am_RP(pim, child->sg.grp)) {  				pim_channel_add_oif(  					child->upstream->channel_oil, -					ch->interface, -					PIM_OIF_FLAG_PROTO_STAR); -				pim_upstream_switch( -					pim, child->upstream, -					PIM_UPSTREAM_JOINED); +					ch->interface, PIM_OIF_FLAG_PROTO_STAR); +				pim_upstream_switch(pim, child->upstream, +						    PIM_UPSTREAM_JOINED);  				pim_jp_agg_single_upstream_send( -					&child->upstream->rpf, -					child->upstream, true); +					&child->upstream->rpf, child->upstream, +					true);  			}  			if (parent) -				pim_jp_agg_single_upstream_send( -					&parent->rpf, -					parent, true); +				pim_jp_agg_single_upstream_send(&parent->rpf, +								parent, true);  			delete_on_noinfo(child);  			break; diff --git a/pimd/pim_ifchannel.h b/pimd/pim_ifchannel.h index 0b1a8ea0e8..0af9ebf0be 100644 --- a/pimd/pim_ifchannel.h +++ b/pimd/pim_ifchannel.h @@ -111,8 +111,8 @@ struct pim_ifchannel {  };  RB_HEAD(pim_ifchannel_rb, pim_ifchannel); -RB_PROTOTYPE(pim_ifchannel_rb, pim_ifchannel, -	     pim_ifp_rb, pim_ifchannel_compare); +RB_PROTOTYPE(pim_ifchannel_rb, pim_ifchannel, pim_ifp_rb, +	     pim_ifchannel_compare);  void pim_ifchannel_free(struct pim_ifchannel *ch);  void pim_ifchannel_delete(struct pim_ifchannel *ch); diff --git a/pimd/pim_igmp.c b/pimd/pim_igmp.c index 0522420364..c0a58516d9 100644 --- a/pimd/pim_igmp.c +++ b/pimd/pim_igmp.c @@ -850,8 +850,7 @@ static struct igmp_sock *igmp_sock_new(int fd, struct in_addr ifaddr,  	snprintf(hash_name, 64, "IGMP %s hash", ifp->name);  	igmp->igmp_group_hash = hash_create(igmp_group_hash_key, -					    igmp_group_hash_equal, -					    hash_name); +					    igmp_group_hash_equal, hash_name);  	igmp->fd = fd;  	igmp->interface = ifp; diff --git a/pimd/pim_igmp_mtrace.c b/pimd/pim_igmp_mtrace.c index feb326c45c..5e2e316d85 100644 --- a/pimd/pim_igmp_mtrace.c +++ b/pimd/pim_igmp_mtrace.c @@ -99,7 +99,7 @@ static void mtrace_debug(struct pim_interface *pim_ifp,  			if (PIM_DEBUG_MTRACE)  				zlog_debug(  					"Mtrace response block of wrong" -					 " length"); +					" length");  		responses = responses / sizeof(struct igmp_mtrace_rsp); diff --git a/pimd/pim_igmp_mtrace.h b/pimd/pim_igmp_mtrace.h index b5c1008444..d47da3557a 100644 --- a/pimd/pim_igmp_mtrace.h +++ b/pimd/pim_igmp_mtrace.h @@ -28,35 +28,35 @@  #define MTRACE_UNKNOWN_COUNT (0xffffffff)  enum mtrace_fwd_code { -	MTRACE_FWD_CODE_NO_ERROR        = 0x00, -	MTRACE_FWD_CODE_WRONG_IF        = 0x01, -	MTRACE_FWD_CODE_PRUNE_SENT      = 0x02, -	MTRACE_FWD_CODE_PRUNE_RCVD      = 0x03, -	MTRACE_FWD_CODE_SCOPED          = 0x04, -	MTRACE_FWD_CODE_NO_ROUTE        = 0x05, -	MTRACE_FWD_CODE_WRONG_LAST_HOP  = 0x06, -	MTRACE_FWD_CODE_NOT_FORWARDING  = 0x07, -	MTRACE_FWD_CODE_REACHED_RP      = 0x08, -	MTRACE_FWD_CODE_RPF_IF          = 0x09, -	MTRACE_FWD_CODE_NO_MULTICAST    = 0x0A, -	MTRACE_FWD_CODE_INFO_HIDDEN     = 0x0B, -	MTRACE_FWD_CODE_NO_SPACE        = 0x81, -	MTRACE_FWD_CODE_OLD_ROUTER      = 0x82, -	MTRACE_FWD_CODE_ADMIN_PROHIB    = 0x83 +	MTRACE_FWD_CODE_NO_ERROR = 0x00, +	MTRACE_FWD_CODE_WRONG_IF = 0x01, +	MTRACE_FWD_CODE_PRUNE_SENT = 0x02, +	MTRACE_FWD_CODE_PRUNE_RCVD = 0x03, +	MTRACE_FWD_CODE_SCOPED = 0x04, +	MTRACE_FWD_CODE_NO_ROUTE = 0x05, +	MTRACE_FWD_CODE_WRONG_LAST_HOP = 0x06, +	MTRACE_FWD_CODE_NOT_FORWARDING = 0x07, +	MTRACE_FWD_CODE_REACHED_RP = 0x08, +	MTRACE_FWD_CODE_RPF_IF = 0x09, +	MTRACE_FWD_CODE_NO_MULTICAST = 0x0A, +	MTRACE_FWD_CODE_INFO_HIDDEN = 0x0B, +	MTRACE_FWD_CODE_NO_SPACE = 0x81, +	MTRACE_FWD_CODE_OLD_ROUTER = 0x82, +	MTRACE_FWD_CODE_ADMIN_PROHIB = 0x83  };  enum mtrace_rtg_proto { -	MTRACE_RTG_PROTO_DVMRP          = 1, -	MTRACE_RTG_PROTO_MOSPF          = 2, -	MTRACE_RTG_PROTO_PIM            = 3, -	MTRACE_RTG_PROTO_CBT            = 4, -	MTRACE_RTG_PROTO_PIM_SPECIAL    = 5, -	MTRACE_RTG_PROTO_PIM_STATIC     = 6, -	MTRACE_RTG_PROTO_DVMRP_STATIC   = 7, -	MTRACE_RTG_PROTO_PIM_MBGP       = 8, -	MTRACE_RTG_PROTO_CBT_SPECIAL    = 9, -	MTRACE_RTG_PROTO_CBT_STATIC     = 10, -	MTRACE_RTG_PROTO_PIM_ASSERT     = 11, +	MTRACE_RTG_PROTO_DVMRP = 1, +	MTRACE_RTG_PROTO_MOSPF = 2, +	MTRACE_RTG_PROTO_PIM = 3, +	MTRACE_RTG_PROTO_CBT = 4, +	MTRACE_RTG_PROTO_PIM_SPECIAL = 5, +	MTRACE_RTG_PROTO_PIM_STATIC = 6, +	MTRACE_RTG_PROTO_DVMRP_STATIC = 7, +	MTRACE_RTG_PROTO_PIM_MBGP = 8, +	MTRACE_RTG_PROTO_CBT_SPECIAL = 9, +	MTRACE_RTG_PROTO_CBT_STATIC = 10, +	MTRACE_RTG_PROTO_PIM_ASSERT = 11,  };  struct igmp_mtrace_rsp { diff --git a/pimd/pim_instance.c b/pimd/pim_instance.c index 9b7ef2e073..f92da7fe70 100644 --- a/pimd/pim_instance.c +++ b/pimd/pim_instance.c @@ -87,8 +87,8 @@ static struct pim_instance *pim_instance_init(struct vrf *vrf)  	pim_msdp_init(pim, master);  	snprintf(hash_name, 64, "PIM %s RPF Hash", vrf->name); -	pim->rpf_hash =	hash_create_size(256, pim_rpf_hash_key, -					 pim_rpf_equal, hash_name); +	pim->rpf_hash = hash_create_size(256, pim_rpf_hash_key, pim_rpf_equal, +					 hash_name);  	if (PIM_DEBUG_ZEBRA)  		zlog_debug("%s: NHT rpf hash init ", __PRETTY_FUNCTION__); diff --git a/pimd/pim_mroute.c b/pimd/pim_mroute.c index f8d8a602da..8462a4fdf8 100644 --- a/pimd/pim_mroute.c +++ b/pimd/pim_mroute.c @@ -530,7 +530,8 @@ static int pim_mroute_msg_wrvifwhole(int fd, struct interface *ifp,  			return -2;  		}  		PIM_UPSTREAM_FLAG_SET_SRC_STREAM(up->flags); -		pim_upstream_keep_alive_timer_start(up, pim_ifp->pim->keep_alive_time); +		pim_upstream_keep_alive_timer_start( +			up, pim_ifp->pim->keep_alive_time);  		up->channel_oil = oil;  		up->channel_oil->cc.pktcnt++;  		pim_register_join(up); @@ -720,9 +721,9 @@ int pim_mroute_socket_enable(struct pim_instance *pim)  	}  #ifdef SO_BINDTODEVICE -	if (pim->vrf->vrf_id != VRF_DEFAULT && -	    setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, pim->vrf->name, -		       strlen(pim->vrf->name))) { +	if (pim->vrf->vrf_id != VRF_DEFAULT +	    && setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, pim->vrf->name, +			  strlen(pim->vrf->name))) {  		zlog_warn("Could not setsockopt SO_BINDTODEVICE: %s",  			  safe_strerror(errno));  		close(fd); @@ -786,8 +787,8 @@ int pim_mroute_add_vif(struct interface *ifp, struct in_addr ifaddr,  	if (PIM_DEBUG_MROUTE)  		zlog_debug("%s: Add Vif %d (%s[%s])", __PRETTY_FUNCTION__, -			   pim_ifp->mroute_vif_index, -			   ifp->name, pim_ifp->pim->vrf->name); +			   pim_ifp->mroute_vif_index, ifp->name, +			   pim_ifp->pim->vrf->name);  	memset(&vc, 0, sizeof(vc));  	vc.vifc_vifi = pim_ifp->mroute_vif_index; @@ -823,9 +824,9 @@ 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)); +			__PRETTY_FUNCTION__, pim_ifp->pim->mroute_socket, +			ifp->ifindex, ifaddr_str, flags, errno, +			safe_strerror(errno));  		return -2;  	} @@ -839,9 +840,9 @@ int pim_mroute_del_vif(struct interface *ifp)  	int err;  	if (PIM_DEBUG_MROUTE) -		zlog_debug("%s: Del Vif %d (%s[%s])",  __PRETTY_FUNCTION__, -			   pim_ifp->mroute_vif_index, -			   ifp->name, pim_ifp->pim->vrf->name); +		zlog_debug("%s: Del Vif %d (%s[%s])", __PRETTY_FUNCTION__, +			   pim_ifp->mroute_vif_index, ifp->name, +			   pim_ifp->pim->vrf->name);  	memset(&vc, 0, sizeof(vc));  	vc.vifc_vifi = pim_ifp->mroute_vif_index; @@ -927,8 +928,8 @@ int pim_mroute_add(struct channel_oil *c_oil, const char *name)  	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", +			   __PRETTY_FUNCTION__, name, pim->vrf->name,  			   pim_channel_oil_dump(c_oil, buf, sizeof(buf)));  	} @@ -970,8 +971,8 @@ int pim_mroute_del(struct channel_oil *c_oil, const char *name)  	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", +			   __PRETTY_FUNCTION__, name, pim->vrf->name,  			   pim_channel_oil_dump(c_oil, buf, sizeof(buf)));  	} diff --git a/pimd/pim_msdp.h b/pimd/pim_msdp.h index 0627ee5f47..8363d50991 100644 --- a/pimd/pim_msdp.h +++ b/pimd/pim_msdp.h @@ -119,12 +119,8 @@ struct pim_msdp_peer {  /* protocol timers */  #define PIM_MSDP_PEER_HOLD_TIME 75  	struct thread *hold_timer; // 5.4 -				   /* $FRR indent$ */ -/* clang-format off */  #define PIM_MSDP_PEER_KA_TIME 60  	struct thread *ka_timer; // 5.5 -				 /* $FRR indent$ */ -				 /* clang-format off */  #define PIM_MSDP_PEER_CONNECT_RETRY_TIME 30  	struct thread *cr_timer; // 5.6 @@ -139,8 +135,6 @@ struct pim_msdp_peer {  	uint32_t conn_attempts;  	uint32_t est_flaps;  	uint32_t sa_cnt; /* number of SAs attributed to this peer */ -			 /* $FRR indent$ */ -			 /* clang-format off */  #define PIM_MSDP_PEER_LAST_RESET_STR 20  	char last_reset[PIM_MSDP_PEER_LAST_RESET_STR]; diff --git a/pimd/pim_nht.c b/pimd/pim_nht.c index 5b297253b2..94f19bea77 100644 --- a/pimd/pim_nht.c +++ b/pimd/pim_nht.c @@ -107,11 +107,9 @@ static struct pim_nexthop_cache *pim_nexthop_cache_add(struct pim_instance *pim,  	pnc->rp_list->cmp = pim_rp_list_cmp;  	snprintf(hash_name, 64, "PNC %s(%s) Upstream Hash", -		 prefix2str(&pnc->rpf.rpf_addr, buf1, 64), -		 pim->vrf->name); +		 prefix2str(&pnc->rpf.rpf_addr, buf1, 64), pim->vrf->name);  	pnc->upstream_hash = hash_create_size(8192, pim_upstream_hash_key, -					      pim_upstream_equal, -					      hash_name); +					      pim_upstream_equal, hash_name);  	return pnc;  } @@ -234,10 +232,9 @@ static void pim_update_rp_nh(struct pim_instance *pim,  			continue;  		// Compute PIM RPF using cached nexthop -		pim_ecmp_nexthop_search(pim, pnc, -					&rp_info->rp.source_nexthop, -					&rp_info->rp.rpf_addr, -					&rp_info->group, 1); +		pim_ecmp_nexthop_search(pim, pnc, &rp_info->rp.source_nexthop, +					&rp_info->rp.rpf_addr, &rp_info->group, +					1);  	}  } @@ -327,8 +324,7 @@ static int pim_update_upstream_nh_helper(struct hash_backet *backet, void *arg)  		 * We have detected a case where we might need to rescan  		 * the inherited o_list so do it.  		 */ -		if (up->channel_oil -		    && up->channel_oil->oil_inherited_rescan) { +		if (up->channel_oil && up->channel_oil->oil_inherited_rescan) {  			pim_upstream_inherited_olist_decide(pim, up);  			up->channel_oil->oil_inherited_rescan = 0;  		} @@ -339,8 +335,7 @@ static int pim_update_upstream_nh_helper(struct hash_backet *backet, void *arg)  			 * where the mroute has not been installed  			 * so install it.  			 */ -			if (up->channel_oil -			    && !up->channel_oil->installed) +			if (up->channel_oil && !up->channel_oil->installed)  				pim_mroute_add(up->channel_oil,  					       __PRETTY_FUNCTION__); @@ -627,8 +622,9 @@ int pim_parse_nexthop_update(int command, struct zclient *zclient,  	if (!zapi_nexthop_update_decode(zclient->ibuf, &nhr)) {  		if (PIM_DEBUG_PIM_NHT) -			zlog_debug("%s: Decode of nexthop update from zebra failed", -				   __PRETTY_FUNCTION__); +			zlog_debug( +				"%s: Decode of nexthop update from zebra failed", +				__PRETTY_FUNCTION__);  		return 0;  	} @@ -760,8 +756,7 @@ int pim_parse_nexthop_update(int command, struct zclient *zclient,  			"%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)); +			pnc->upstream_hash->count, listcount(pnc->rp_list));  	}  	pim_rpf_set_refresh_time(); @@ -803,11 +798,11 @@ int pim_ecmp_nexthop_lookup(struct pim_instance *pim,  	if (num_ifindex < 1) {  		if (PIM_DEBUG_PIM_NHT) {  			char addr_str[INET_ADDRSTRLEN]; -			pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str)); +			pim_inet4_dump("<addr?>", addr, addr_str, +				       sizeof(addr_str));  			zlog_warn(  				"%s: could not find nexthop ifindex for address %s(%s)", -				__PRETTY_FUNCTION__, addr_str, -				pim->vrf->name); +				__PRETTY_FUNCTION__, addr_str, pim->vrf->name);  		}  		return 0;  	} diff --git a/pimd/pim_oil.c b/pimd/pim_oil.c index 53bbf54f3e..fd3c04e8ca 100644 --- a/pimd/pim_oil.c +++ b/pimd/pim_oil.c @@ -104,10 +104,8 @@ void pim_oil_init(struct pim_instance *pim)  	char hash_name[64];  	snprintf(hash_name, 64, "PIM %s Oil Hash", pim->vrf->name); -	pim->channel_oil_hash = hash_create_size(8192, -						pim_oil_hash_key, -						pim_oil_equal, -						hash_name); +	pim->channel_oil_hash = hash_create_size(8192, pim_oil_hash_key, +						 pim_oil_equal, hash_name);  	pim->channel_oil_list = list_new();  	if (!pim->channel_oil_list) { diff --git a/pimd/pim_register.c b/pimd/pim_register.c index a393d0bbda..b9908ae22b 100644 --- a/pimd/pim_register.c +++ b/pimd/pim_register.c @@ -417,10 +417,12 @@ int pim_register_recv(struct interface *ifp, struct in_addr dest_addr,  		    || (SwitchToSptDesired(pim_ifp->pim, &sg))) {  			if (sentRegisterStop) {  				pim_upstream_keep_alive_timer_start( -					upstream, pim_ifp->pim->rp_keep_alive_time); +					upstream, +					pim_ifp->pim->rp_keep_alive_time);  			} else {  				pim_upstream_keep_alive_timer_start( -					upstream, pim_ifp->pim->keep_alive_time); +					upstream, +					pim_ifp->pim->keep_alive_time);  			}  		} diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c index d961aa4c49..2395361180 100644 --- a/pimd/pim_rp.c +++ b/pimd/pim_rp.c @@ -147,8 +147,9 @@ void pim_rp_init(struct pim_instance *pim)  	rn->info = rp_info;  	if (PIM_DEBUG_TRACE) -		zlog_debug("Allocated: %p for rp_info: %p(224.0.0.0/4) Lock: %d", -			   rn, rp_info, rn->lock); +		zlog_debug( +			"Allocated: %p for rp_info: %p(224.0.0.0/4) Lock: %d", +			rn, rp_info, rn->lock);  }  void pim_rp_free(struct pim_instance *pim) @@ -232,7 +233,8 @@ static struct rp_info *pim_rp_find_match_group(struct pim_instance *pim,  		if (rp_info->plist) {  			plist = prefix_list_lookup(AFI_IP, rp_info->plist); -			if (prefix_list_apply_which_prefix(plist, &p, group) == PREFIX_DENY) +			if (prefix_list_apply_which_prefix(plist, &p, group) +			    == PREFIX_DENY)  				continue;  			if (!best) { @@ -250,8 +252,9 @@ static struct rp_info *pim_rp_find_match_group(struct pim_instance *pim,  	rn = route_node_match(pim->rp_table, group);  	if (!rn) { -		zlog_err("%s: BUG We should have found default group information\n", -			 __PRETTY_FUNCTION__); +		zlog_err( +			"%s: BUG We should have found default group information\n", +			__PRETTY_FUNCTION__);  		return best;  	} @@ -260,8 +263,8 @@ static struct rp_info *pim_rp_find_match_group(struct pim_instance *pim,  		char buf[PREFIX_STRLEN];  		route_unlock_node(rn); -		zlog_debug("Lookedup: %p for rp_info: %p(%s) Lock: %d", -			   rn, rp_info, +		zlog_debug("Lookedup: %p for rp_info: %p(%s) Lock: %d", rn, +			   rp_info,  			   prefix2str(&rp_info->group, buf, sizeof(buf)),  			   rn->lock);  	} @@ -542,8 +545,8 @@ int pim_rp_new(struct pim_instance *pim, const char *rp,  	if (PIM_DEBUG_TRACE) {  		char buf[PREFIX_STRLEN]; -		zlog_debug("Allocated: %p for rp_info: %p(%s) Lock: %d", -			   rn, rp_info, +		zlog_debug("Allocated: %p for rp_info: %p(%s) Lock: %d", rn, +			   rp_info,  			   prefix2str(&rp_info->group, buf, sizeof(buf)),  			   rn->lock);  	} @@ -653,11 +656,12 @@ int pim_rp_del(struct pim_instance *pim, const char *rp,  			if (PIM_DEBUG_TRACE) {  				char buf[PREFIX_STRLEN]; -				zlog_debug("%s:Found for Freeing: %p for rp_info: %p(%s) Lock: %d", -					   __PRETTY_FUNCTION__, -					   rn, rp_info, -					   prefix2str(&rp_info->group, buf, sizeof(buf)), -					   rn->lock); +				zlog_debug( +					"%s:Found for Freeing: %p for rp_info: %p(%s) Lock: %d", +					__PRETTY_FUNCTION__, rn, rp_info, +					prefix2str(&rp_info->group, buf, +						   sizeof(buf)), +					rn->lock);  			}  			rn->info = NULL;  			route_unlock_node(rn); diff --git a/pimd/pim_rpf.c b/pimd/pim_rpf.c index fd09b04b8a..b5d5f006f2 100644 --- a/pimd/pim_rpf.c +++ b/pimd/pim_rpf.c @@ -241,9 +241,10 @@ enum pim_rpf_result pim_rpf_update(struct pim_instance *pim,  	} else {  		if (!pim_ecmp_nexthop_lookup(  			    pim, &rpf->source_nexthop, up->upstream_addr, &src, -			    &grp, !PIM_UPSTREAM_FLAG_TEST_FHR(up->flags) -					  && !PIM_UPSTREAM_FLAG_TEST_SRC_IGMP( -						     up->flags))) +			    &grp, +			    !PIM_UPSTREAM_FLAG_TEST_FHR(up->flags) +				    && !PIM_UPSTREAM_FLAG_TEST_SRC_IGMP( +					       up->flags)))  			return PIM_RPF_FAILURE;  	} diff --git a/pimd/pim_tlv.c b/pimd/pim_tlv.c index 3c9ef28f5a..eddec3c29e 100644 --- a/pimd/pim_tlv.c +++ b/pimd/pim_tlv.c @@ -654,12 +654,12 @@ int pim_parse_addr_source(struct prefix_sg *sg, uint8_t *flags,  	return addr - buf;  } -#define FREE_ADDR_LIST(hello_option_addr_list)				\ -	{								\ -		if (hello_option_addr_list) {				\ -			list_delete_and_null(&hello_option_addr_list);	\ -			hello_option_addr_list = 0;			\ -		}							\ +#define FREE_ADDR_LIST(hello_option_addr_list)                                 \ +	{                                                                      \ +		if (hello_option_addr_list) {                                  \ +			list_delete_and_null(&hello_option_addr_list);         \ +			hello_option_addr_list = 0;                            \ +		}                                                              \  	}  int pim_tlv_parse_addr_list(const char *ifname, struct in_addr src_addr, diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c index fdd37f2b91..b5f5f646d4 100644 --- a/pimd/pim_upstream.c +++ b/pimd/pim_upstream.c @@ -167,9 +167,9 @@ struct pim_upstream *pim_upstream_del(struct pim_instance *pim,  	if (PIM_DEBUG_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, up->ref_count, -			up->flags, up->channel_oil->oil_ref_count); +			__PRETTY_FUNCTION__, name, up->sg_str, pim->vrf->name, +			up->ref_count, up->flags, +			up->channel_oil->oil_ref_count);  	--up->ref_count; @@ -949,7 +949,8 @@ 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, +				__PRETTY_FUNCTION__, neigh_str, up->sg_str, +				pim->vrf->name,  				up->join_state == PIM_UPSTREAM_JOINED,  				rpf_addr_str);  		} @@ -1106,8 +1107,9 @@ static int pim_upstream_keep_alive_timer(struct thread *t)  	if (PIM_UPSTREAM_FLAG_TEST_SRC_STREAM(up->flags)) {  		pim_upstream_fhr_kat_expiry(pim, up);  		if (PIM_DEBUG_TRACE) -			zlog_debug("kat expired on %s[%s]; remove stream reference", -				   up->sg_str, pim->vrf->name); +			zlog_debug( +				"kat expired on %s[%s]; remove stream reference", +				up->sg_str, pim->vrf->name);  		PIM_UPSTREAM_FLAG_UNSET_SRC_STREAM(up->flags);  		pim_upstream_del(pim, up, __PRETTY_FUNCTION__);  	} else if (PIM_UPSTREAM_FLAG_TEST_SRC_LHR(up->flags)) { @@ -1117,8 +1119,8 @@ static int pim_upstream_keep_alive_timer(struct thread *t)  		pim_upstream_del(pim, up, __PRETTY_FUNCTION__);  		if (parent) { -			pim_jp_agg_single_upstream_send(&parent->rpf, -							parent, true); +			pim_jp_agg_single_upstream_send(&parent->rpf, parent, +							true);  		}  	} @@ -1620,8 +1622,8 @@ static void pim_upstream_sg_running(void *arg)  	if (!up->channel_oil->installed) {  		if (PIM_DEBUG_TRACE)  			zlog_debug("%s: %s[%s] is not installed in mroute", -				   __PRETTY_FUNCTION__, -				   up->sg_str, pim->vrf->name); +				   __PRETTY_FUNCTION__, up->sg_str, +				   pim->vrf->name);  		return;  	} @@ -1637,7 +1639,8 @@ static void pim_upstream_sg_running(void *arg)  		if (PIM_DEBUG_TRACE)  			zlog_debug(  				"%s: Handling unscanned inherited_olist for %s[%s]", -				__PRETTY_FUNCTION__, up->sg_str, pim->vrf->name); +				__PRETTY_FUNCTION__, up->sg_str, +				pim->vrf->name);  		pim_upstream_inherited_olist_decide(pim, up);  		up->channel_oil->oil_inherited_rescan = 0;  	} @@ -1765,8 +1768,7 @@ void pim_upstream_init(struct pim_instance *pim)  		wheel_init(master, 31000, 100, pim_upstream_hash_key,  			   pim_upstream_sg_running); -	snprintf(hash_name, 64, "PIM %s Upstream Hash", -		 pim->vrf->name); +	snprintf(hash_name, 64, "PIM %s Upstream Hash", pim->vrf->name);  	pim->upstream_hash = hash_create_size(8192, pim_upstream_hash_key,  					      pim_upstream_equal, hash_name); diff --git a/pimd/pim_zebra.c b/pimd/pim_zebra.c index 2970dcee5e..81c0cb6efb 100644 --- a/pimd/pim_zebra.c +++ b/pimd/pim_zebra.c @@ -185,9 +185,9 @@ static int pim_zebra_if_state_up(int command, struct zclient *zclient,  					vrf->name, vrf->vrf_id);  				if (!master) { -					zlog_debug("%s: Unable to find Master interface for %s", -						   __PRETTY_FUNCTION__, -						   vrf->name); +					zlog_debug( +						"%s: Unable to find Master interface for %s", +						__PRETTY_FUNCTION__, vrf->name);  					return 0;  				}  				zclient_interface_set_master(zclient, master, @@ -295,9 +295,10 @@ static int pim_zebra_if_address_add(int command, struct zclient *zclient,  		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, CHECK_FLAG(c->flags, ZEBRA_IFA_SECONDARY) -					     ? "secondary" -					     : "primary"); +			   c->flags, +			   CHECK_FLAG(c->flags, ZEBRA_IFA_SECONDARY) +				   ? "secondary" +				   : "primary");  #ifdef PIM_DEBUG_IFADDR_DUMP  		dump_if_address(c->ifp); diff --git a/pimd/pim_zlookup.c b/pimd/pim_zlookup.c index bcaf4a38dd..8006148f93 100644 --- a/pimd/pim_zlookup.c +++ b/pimd/pim_zlookup.c @@ -441,9 +441,8 @@ int zclient_lookup_nexthop(struct pim_instance *pim,  				nexthop_tab[0].route_metric);  		} -		addr = -			nexthop_addr.u.prefix4; /* use nexthop addr for -						   recursive lookup */ +		addr = nexthop_addr.u.prefix4; /* use nexthop addr for +						  recursive lookup */  	} /* for (max_lookup) */ diff --git a/qpb/qpb_allocator.h b/qpb/qpb_allocator.h index c9022af713..fd55592f88 100644 --- a/qpb/qpb_allocator.h +++ b/qpb/qpb_allocator.h @@ -74,7 +74,6 @@ static inline void qpb_free(qpb_allocator_t *allocator, void *ptr)   */  #define QPB_ALLOC(allocator, type) (type *)qpb_alloc(allocator, sizeof(type)) -  /*   * Externs.   */ diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c index d20954037d..3a773f2451 100644 --- a/ripd/rip_interface.c +++ b/ripd/rip_interface.c @@ -907,19 +907,17 @@ static void rip_connect_set(struct interface *ifp, int set)  			 * "network IF_OR_PREF" one */  			if ((rip_enable_if_lookup(connected->ifp->name) >= 0)  			    || (rip_enable_network_lookup2(connected) >= 0)) -				rip_redistribute_add( -					ZEBRA_ROUTE_CONNECT, -					RIP_ROUTE_INTERFACE, &address, -					&nh, 0, 0, 0); +				rip_redistribute_add(ZEBRA_ROUTE_CONNECT, +						     RIP_ROUTE_INTERFACE, +						     &address, &nh, 0, 0, 0);  		} else {  			rip_redistribute_delete(ZEBRA_ROUTE_CONNECT,  						RIP_ROUTE_INTERFACE, &address,  						connected->ifp->ifindex);  			if (rip_redistribute_check(ZEBRA_ROUTE_CONNECT)) -				rip_redistribute_add( -					ZEBRA_ROUTE_CONNECT, -					RIP_ROUTE_REDISTRIBUTE, &address, -					&nh, 0, 0, 0); +				rip_redistribute_add(ZEBRA_ROUTE_CONNECT, +						     RIP_ROUTE_REDISTRIBUTE, +						     &address, &nh, 0, 0, 0);  		}  	}  } diff --git a/ripd/rip_routemap.c b/ripd/rip_routemap.c index a37effa23c..40e7ed915b 100644 --- a/ripd/rip_routemap.c +++ b/ripd/rip_routemap.c @@ -170,9 +170,8 @@ static route_map_result_t route_match_ip_next_hop(void *rule,  	if (type == RMAP_RIP) {  		rinfo = object;  		p.family = AF_INET; -		p.prefix = -			(rinfo->nh.gate.ipv4.s_addr) ? -			rinfo->nh.gate.ipv4 : rinfo->from; +		p.prefix = (rinfo->nh.gate.ipv4.s_addr) ? rinfo->nh.gate.ipv4 +							: rinfo->from;  		p.prefixlen = IPV4_MAX_BITLEN;  		alist = access_list_lookup(AFI_IP, (char *)rule); @@ -217,9 +216,8 @@ route_match_ip_next_hop_prefix_list(void *rule, struct prefix *prefix,  	if (type == RMAP_RIP) {  		rinfo = object;  		p.family = AF_INET; -		p.prefix = -			(rinfo->nh.gate.ipv4.s_addr) ? -			rinfo->nh.gate.ipv4 : rinfo->from; +		p.prefix = (rinfo->nh.gate.ipv4.s_addr) ? rinfo->nh.gate.ipv4 +							: rinfo->from;  		p.prefixlen = IPV4_MAX_BITLEN;  		plist = prefix_list_lookup(AFI_IP, (char *)rule); @@ -427,8 +425,9 @@ static void *route_set_metric_compile(const char *arg)  		return mod;  	}  	if (metric > RIP_METRIC_INFINITY) { -		zlog_info("%s: Metric specified: %ld is greater than RIP_METRIC_INFINITY, using INFINITY instead", -			   __PRETTY_FUNCTION__, metric); +		zlog_info( +			"%s: Metric specified: %ld is greater than RIP_METRIC_INFINITY, using INFINITY instead", +			__PRETTY_FUNCTION__, metric);  		mod->metric = RIP_METRIC_INFINITY;  	} else  		mod->metric = metric; diff --git a/ripd/rip_zebra.c b/ripd/rip_zebra.c index 4f02daed42..dc972981b0 100644 --- a/ripd/rip_zebra.c +++ b/ripd/rip_zebra.c @@ -139,8 +139,7 @@ static int rip_zebra_read_route(int command, struct zclient *zclient,  	if (command == ZEBRA_REDISTRIBUTE_ROUTE_ADD)  		rip_redistribute_add(api.type, RIP_ROUTE_REDISTRIBUTE,  				     (struct prefix_ipv4 *)&api.prefix, &nh, -				     api.metric, api.distance, -				     api.tag); +				     api.metric, api.distance, api.tag);  	else if (command == ZEBRA_REDISTRIBUTE_ROUTE_DEL)  		rip_redistribute_delete(api.type, RIP_ROUTE_REDISTRIBUTE,  					(struct prefix_ipv4 *)&api.prefix, diff --git a/ripd/ripd.c b/ripd/ripd.c index 9a13250428..7575c8e1ff 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -451,9 +451,8 @@ static void rip_rte_process(struct rte *rte, struct sockaddr_in *from,  		/* Get back the object */  		rte->nexthop = newinfo.nexthop_out;  		rte->tag = htons(newinfo.tag_out); /* XXX */ -		rte->metric = -			newinfo.metric_out; /* XXX: the routemap uses the -					       metric_out field */ +		rte->metric = newinfo.metric_out;  /* XXX: the routemap uses the +						      metric_out field */  	}  	/* Once the entry has been validated, update the metric by @@ -1463,9 +1462,8 @@ static int rip_send_packet(u_char *buf, int size, struct sockaddr_in *to,  /* Add redistributed route to RIP table. */  void rip_redistribute_add(int type, int sub_type, struct prefix_ipv4 *p, -			  struct nexthop *nh, -			  unsigned int metric, unsigned char distance, -			  route_tag_t tag) +			  struct nexthop *nh, unsigned int metric, +			  unsigned char distance, route_tag_t tag)  {  	int ret;  	struct route_node *rp = NULL; @@ -1518,9 +1516,8 @@ void rip_redistribute_add(int type, int sub_type, struct prefix_ipv4 *p,  		(void)rip_ecmp_add(&newinfo);  	if (IS_RIP_DEBUG_EVENT) { -		zlog_debug( -			"Redistribute new prefix %s/%d", -			inet_ntoa(p->prefix), p->prefixlen); +		zlog_debug("Redistribute new prefix %s/%d", +			   inet_ntoa(p->prefix), p->prefixlen);  	}  	rip_event(RIP_TRIGGERED_UPDATE, 0); @@ -2319,15 +2316,14 @@ void rip_output_process(struct connected *ifc, struct sockaddr_in *to,  							  tmp_rinfo))  					if (tmp_rinfo->type == ZEBRA_ROUTE_RIP  					    && tmp_rinfo->nh.ifindex -					    == ifc->ifp->ifindex) +						       == ifc->ifp->ifindex)  						tmp_rinfo->metric_out =  							RIP_METRIC_INFINITY;  				if (rinfo->type == ZEBRA_ROUTE_CONNECT  				    && prefix_match((struct prefix *)p,  						    ifc->address)) -					rinfo->metric_out = -						RIP_METRIC_INFINITY; +					rinfo->metric_out = RIP_METRIC_INFINITY;  			}  			/* Prepare preamble, auth headers, if needs be */ @@ -2881,8 +2877,8 @@ DEFUN (rip_route,  	node->info = (void *)1; -	rip_redistribute_add(ZEBRA_ROUTE_RIP, RIP_ROUTE_STATIC, &p, &nh, 0, -			     0, 0); +	rip_redistribute_add(ZEBRA_ROUTE_RIP, RIP_ROUTE_STATIC, &p, &nh, 0, 0, +			     0);  	return CMD_SUCCESS;  } @@ -3453,7 +3449,7 @@ DEFUN (show_ip_rip,  				if (len > 0)  					vty_out(vty, "%*s", len, " "); -				switch(rinfo->nh.type) { +				switch (rinfo->nh.type) {  				case NEXTHOP_TYPE_IPV4:  				case NEXTHOP_TYPE_IPV4_IFINDEX:  					vty_out(vty, "%-20s %2d ", diff --git a/ripd/ripd.h b/ripd/ripd.h index 9a9c081bf9..abbc3a79e7 100644 --- a/ripd/ripd.h +++ b/ripd/ripd.h @@ -385,11 +385,9 @@ extern int rip_request_send(struct sockaddr_in *, struct interface *, u_char,  extern int rip_neighbor_lookup(struct sockaddr_in *);  extern int rip_redistribute_check(int); -extern void rip_redistribute_add(int type, int sub_type, -				 struct prefix_ipv4 *p, -				 struct nexthop *nh, -				 unsigned int metric, unsigned char distance, -				 route_tag_t tag); +extern void rip_redistribute_add(int type, int sub_type, struct prefix_ipv4 *p, +				 struct nexthop *nh, unsigned int metric, +				 unsigned char distance, route_tag_t tag);  extern void rip_redistribute_delete(int, int, struct prefix_ipv4 *, ifindex_t);  extern void rip_redistribute_withdraw(int);  extern void rip_zebra_ipv4_add(struct route_node *); diff --git a/sharpd/sharp_vty.c b/sharpd/sharp_vty.c index 0e7d1f2c29..3065ad19c3 100644 --- a/sharpd/sharp_vty.c +++ b/sharpd/sharp_vty.c @@ -71,7 +71,7 @@ DEFPY (install_routes,  	zlog_debug("Inserting %ld routes", routes);  	temp = ntohl(p.u.prefix4.s_addr); -	for (i = 0 ; i < routes ; i++) { +	for (i = 0; i < routes; i++) {  		route_add(&p, &nhop);  		p.u.prefix4.s_addr = htonl(++temp);  	} @@ -134,7 +134,7 @@ DEFPY (remove_routes,  	zlog_debug("Removing %ld routes", routes);  	temp = ntohl(p.u.prefix4.s_addr); -	for (i = 0; i < routes ; i++) { +	for (i = 0; i < routes; i++) {  		route_delete(&p);  		p.u.prefix4.s_addr = htonl(++temp);  	} diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c index f02ce4979c..c1c827c366 100644 --- a/sharpd/sharp_zebra.c +++ b/sharpd/sharp_zebra.c @@ -56,7 +56,7 @@ static struct interface *zebra_interface_if_lookup(struct stream *s)  /* Inteface addition message from zebra. */  static int interface_add(int command, struct zclient *zclient, -			       zebra_size_t length, vrf_id_t vrf_id) +			 zebra_size_t length, vrf_id_t vrf_id)  {  	struct interface *ifp; @@ -200,7 +200,7 @@ extern struct zebra_privs_t sharp_privs;  void sharp_zebra_init(void)  { -	struct zclient_options opt = { .receive_notify = true }; +	struct zclient_options opt = {.receive_notify = true};  	zclient = zclient_new_notify(master, &opt); diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index bf9d70bae9..f0010700a8 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -77,7 +77,7 @@ struct vtysh_client vtysh_client[] = {  	{.fd = -1, .name = "nhrpd", .flag = VTYSH_NHRPD, .next = NULL},  	{.fd = -1, .name = "eigrpd", .flag = VTYSH_EIGRPD, .next = NULL},  	{.fd = -1, .name = "babeld", .flag = VTYSH_BABELD, .next = NULL}, -        {.fd = -1, .name = "sharpd", .flag = VTYSH_SHARPD, .next = NULL}, +	{.fd = -1, .name = "sharpd", .flag = VTYSH_SHARPD, .next = NULL},  	{.fd = -1, .name = "watchfrr", .flag = VTYSH_WATCHFRR, .next = NULL},  }; @@ -748,9 +748,8 @@ int vtysh_config_from_file(struct vty *vty, FILE *fp)  		case CMD_ERR_NO_MATCH:  			fprintf(stderr, "line %d: %% Unknown command[%d]: %s",  				lineno, vty->node, vty->buf); -			retcode = -				CMD_ERR_NO_MATCH; /* once we have an error, we -						     remember & return that */ +			retcode = CMD_ERR_NO_MATCH; /* once we have an error, we +						       remember & return that */  			break;  		case CMD_ERR_INCOMPLETE:  			fprintf(stderr, @@ -1206,30 +1205,21 @@ DEFUNSH(VTYSH_BGPD, address_family_ipv6_labeled_unicast,  }  #if defined(HAVE_RPKI) -DEFUNSH(VTYSH_BGPD, -	rpki, -	rpki_cmd, -	"rpki", +DEFUNSH(VTYSH_BGPD, rpki, rpki_cmd, "rpki",  	"Enable rpki and enter rpki configuration mode\n")  {  	vty->node = RPKI_NODE;  	return CMD_SUCCESS;  } -DEFUNSH(VTYSH_BGPD, -	rpki_exit, -	rpki_exit_cmd, -	"exit", +DEFUNSH(VTYSH_BGPD, rpki_exit, rpki_exit_cmd, "exit",  	"Exit current mode and down to previous mode\n")  {  	vty->node = CONFIG_NODE;  	return CMD_SUCCESS;  } -DEFUNSH(VTYSH_BGPD, -	rpki_quit, -	rpki_quit_cmd, -	"quit", +DEFUNSH(VTYSH_BGPD, rpki_quit, rpki_quit_cmd, "quit",  	"Exit current mode and down to previous mode\n")  {  	return rpki_exit(self, vty, argc, argv); @@ -1336,8 +1326,7 @@ DEFUNSH(VTYSH_OSPFD, router_ospf, router_ospf_cmd,  	"router ospf [(1-65535)] [vrf NAME]",  	"Enable a routing process\n"  	"Start OSPF configuration\n" -	"Instance ID\n" -	VRF_CMD_HELP_STR) +	"Instance ID\n" VRF_CMD_HELP_STR)  {  	vty->node = OSPF_NODE;  	return CMD_SUCCESS; @@ -1794,12 +1783,11 @@ DEFUNSH(VTYSH_ZEBRA, vtysh_logicalrouter, vtysh_logicalrouter_cmd,  }  DEFSH(VTYSH_ZEBRA, vtysh_no_logicalrouter_cmd, -	"no logical-router (1-65535) ns NAME", -	NO_STR -	"Enable a Logical-Router\n" -	"Specify the Logical-Router identifier\n" -	"The Name Space\n" -	"The file name in " NS_RUN_DIR ", or a full pathname\n") +      "no logical-router (1-65535) ns NAME", NO_STR +      "Enable a Logical-Router\n" +      "Specify the Logical-Router identifier\n" +      "The Name Space\n" +      "The file name in " NS_RUN_DIR ", or a full pathname\n")  DEFUNSH(VTYSH_VRF, vtysh_vrf, vtysh_vrf_cmd, "vrf NAME",  	"Select a VRF to configure\n" @@ -1813,16 +1801,14 @@ DEFSH(VTYSH_ZEBRA, vtysh_no_vrf_cmd, "no vrf NAME", NO_STR        "Delete a pseudo vrf's configuration\n"        "VRF's name\n") -DEFUNSH(VTYSH_NS, vtysh_exit_logicalrouter, -	vtysh_exit_logicalrouter_cmd, "exit", -	"Exit current mode and down to previous mode\n") +DEFUNSH(VTYSH_NS, vtysh_exit_logicalrouter, vtysh_exit_logicalrouter_cmd, +	"exit", "Exit current mode and down to previous mode\n")  {  	return vtysh_exit(vty);  } -DEFUNSH(VTYSH_NS, vtysh_quit_logicalrouter, -	vtysh_quit_logicalrouter_cmd, "quit", -	"Exit current mode and down to previous mode\n") +DEFUNSH(VTYSH_NS, vtysh_quit_logicalrouter, vtysh_quit_logicalrouter_cmd, +	"quit", "Exit current mode and down to previous mode\n")  {  	return vtysh_exit_logicalrouter(self, vty, argc, argv);  } @@ -1977,8 +1963,7 @@ DEFUN (vtysh_show_debugging,         SHOW_STR         DEBUG_STR)  { -	return show_per_daemon("do show debugging\n", -			       ""); +	return show_per_daemon("do show debugging\n", "");  }  DEFUN (vtysh_show_debugging_hashtable, @@ -2011,8 +1996,7 @@ DEFUN (vtysh_show_memory,         SHOW_STR         "Memory statistics\n")  { -	return show_per_daemon("show memory\n", -			       "Memory statistics for %s:\n"); +	return show_per_daemon("show memory\n", "Memory statistics for %s:\n");  }  DEFUN (vtysh_show_modules, @@ -2563,8 +2547,8 @@ DEFUN (vtysh_show_daemons,  }  /* Execute command in child process. */ -static void execute_command(const char *command, int argc, -			    const char *arg1, const char *arg2) +static void execute_command(const char *command, int argc, const char *arg1, +			    const char *arg2)  {  	pid_t pid;  	int status; @@ -3248,10 +3232,8 @@ void vtysh_init_vty(void)  	install_element(CONFIG_NODE, &vtysh_logicalrouter_cmd);  	install_element(CONFIG_NODE, &vtysh_no_logicalrouter_cmd); -	install_element(LOGICALROUTER_NODE, -			&vtysh_exit_logicalrouter_cmd); -	install_element(LOGICALROUTER_NODE, -			&vtysh_quit_logicalrouter_cmd); +	install_element(LOGICALROUTER_NODE, &vtysh_exit_logicalrouter_cmd); +	install_element(LOGICALROUTER_NODE, &vtysh_quit_logicalrouter_cmd);  	install_element(VRF_NODE, &vtysh_end_all_cmd);  	install_element(VRF_NODE, &vtysh_exit_vrf_cmd); diff --git a/vtysh/vtysh.h b/vtysh/vtysh.h index f9b07beb7e..52a1a46105 100644 --- a/vtysh/vtysh.h +++ b/vtysh/vtysh.h @@ -39,7 +39,6 @@ DECLARE_MGROUP(MVTYSH)  #define VTYSH_BABELD 0x2000  #define VTYSH_SHARPD 0x4000 -  /* commands in REALLYALL are crucial to correct vtysh operation */  #define VTYSH_REALLYALL	  ~0U  /* watchfrr is not in ALL since library CLI functions should not be diff --git a/vtysh/vtysh_config.c b/vtysh/vtysh_config.c index c055d29d4b..e3431fac59 100644 --- a/vtysh/vtysh_config.c +++ b/vtysh/vtysh_config.c @@ -175,9 +175,9 @@ void vtysh_config_parse_line(void *arg, const char *line)  			    == 0) {  				config_add_line(config->line, line);  				config->index = LINK_PARAMS_NODE; -			} else if (strncmp(line, -					   " ip multicast boundary", -					   strlen(" ip multicast boundary")) == 0) { +			} else if (strncmp(line, " ip multicast boundary", +					   strlen(" ip multicast boundary")) +				   == 0) {  				config_add_line_end(config->line, line);  			} else if (config->index == LINK_PARAMS_NODE  				   && strncmp(line, "  exit-link-params", @@ -263,10 +263,10 @@ void vtysh_config_parse_line(void *arg, const char *line)  				 == 0  			 || strncmp(line, "ip extcommunity-list",  				    strlen("ip extcommunity-list")) -				 == 0 +				    == 0  			 || strncmp(line, "ip large-community-list",  				    strlen("ip large-community-list")) -				 == 0) +				    == 0)  			config = config_get(COMMUNITY_LIST_NODE, line);  		else if (strncmp(line, "ip route", strlen("ip route")) == 0)  			config = config_get(IP_NODE, line); diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c index ca6c7798eb..a3d2f95ec1 100644 --- a/vtysh/vtysh_main.c +++ b/vtysh/vtysh_main.c @@ -526,8 +526,8 @@ int main(int argc, char **argv, char **env)  	 */  	homedir = vtysh_get_home();  	if (homedir) { -		snprintf(history_file, sizeof(history_file), -			 "%s/.history_frr", homedir); +		snprintf(history_file, sizeof(history_file), "%s/.history_frr", +			 homedir);  		if (read_history(history_file) != 0) {  			int fp; diff --git a/zebra/connected.c b/zebra/connected.c index e28ec8d09b..ad033db390 100644 --- a/zebra/connected.c +++ b/zebra/connected.c @@ -249,9 +249,10 @@ void connected_up(struct interface *ifp, struct connected *ifc)  	if (IS_ZEBRA_DEBUG_RIB_DETAILED) {  		char buf[PREFIX_STRLEN]; -		zlog_debug("%u: IF %s address %s add/up, scheduling RIB processing", -			   ifp->vrf_id, ifp->name, -			   prefix2str(&p, buf, sizeof(buf))); +		zlog_debug( +			"%u: IF %s address %s add/up, scheduling RIB processing", +			ifp->vrf_id, ifp->name, +			prefix2str(&p, buf, sizeof(buf)));  	}  	rib_update(ifp->vrf_id, RIB_UPDATE_IF_CHANGE); @@ -260,9 +261,10 @@ void connected_up(struct interface *ifp, struct connected *ifc)  		if (IS_ZEBRA_DEBUG_MPLS) {  			char buf[PREFIX_STRLEN]; -			zlog_debug("%u: IF %s IP %s address add/up, scheduling MPLS processing", -				   ifp->vrf_id, ifp->name, -				   prefix2str(&p, buf, sizeof(buf))); +			zlog_debug( +				"%u: IF %s IP %s address add/up, scheduling MPLS processing", +				ifp->vrf_id, ifp->name, +				prefix2str(&p, buf, sizeof(buf)));  		}  		mpls_mark_lsps_for_processing(vrf_info_lookup(ifp->vrf_id));  	} @@ -402,15 +404,16 @@ void connected_down(struct interface *ifp, struct connected *ifc)  	rib_delete(afi, SAFI_UNICAST, ifp->vrf_id, ZEBRA_ROUTE_CONNECT, 0, 0,  		   &p, NULL, &nh, 0, 0, false, NULL); -	rib_delete(afi, SAFI_MULTICAST, ifp->vrf_id, ZEBRA_ROUTE_CONNECT, 0, -		   0, &p, NULL, &nh, 0, 0, false, NULL); +	rib_delete(afi, SAFI_MULTICAST, ifp->vrf_id, ZEBRA_ROUTE_CONNECT, 0, 0, +		   &p, NULL, &nh, 0, 0, false, NULL);  	if (IS_ZEBRA_DEBUG_RIB_DETAILED) {  		char buf[PREFIX_STRLEN]; -		zlog_debug("%u: IF %s IP %s address down, scheduling RIB processing", -			   ifp->vrf_id, ifp->name, -			   prefix2str(&p, buf, sizeof(buf))); +		zlog_debug( +			"%u: IF %s IP %s address down, scheduling RIB processing", +			ifp->vrf_id, ifp->name, +			prefix2str(&p, buf, sizeof(buf)));  	}  	rib_update(ifp->vrf_id, RIB_UPDATE_IF_CHANGE); @@ -420,9 +423,10 @@ void connected_down(struct interface *ifp, struct connected *ifc)  		if (IS_ZEBRA_DEBUG_MPLS) {  			char buf[PREFIX_STRLEN]; -			zlog_debug("%u: IF %s IP %s address down, scheduling MPLS processing", -				   ifp->vrf_id, ifp->name, -				   prefix2str(&p, buf, sizeof(buf))); +			zlog_debug( +				"%u: IF %s IP %s address down, scheduling MPLS processing", +				ifp->vrf_id, ifp->name, +				prefix2str(&p, buf, sizeof(buf)));  		}  		mpls_mark_lsps_for_processing(vrf_info_lookup(ifp->vrf_id));  	} @@ -441,9 +445,10 @@ static void connected_delete_helper(struct connected *ifc, struct prefix *p)  	if (IS_ZEBRA_DEBUG_RIB_DETAILED) {  		char buf[PREFIX_STRLEN]; -		zlog_debug("%u: IF %s IP %s address del, scheduling RIB processing", -			   ifp->vrf_id, ifp->name, -			   prefix2str(p, buf, sizeof(buf))); +		zlog_debug( +			"%u: IF %s IP %s address del, scheduling RIB processing", +			ifp->vrf_id, ifp->name, +			prefix2str(p, buf, sizeof(buf)));  	}  	rib_update(ifp->vrf_id, RIB_UPDATE_IF_CHANGE); @@ -452,9 +457,10 @@ static void connected_delete_helper(struct connected *ifc, struct prefix *p)  		if (IS_ZEBRA_DEBUG_MPLS) {  			char buf[PREFIX_STRLEN]; -			zlog_debug("%u: IF %s IP %s address delete, scheduling MPLS processing", -				   ifp->vrf_id, ifp->name, -				   prefix2str(p, buf, sizeof(buf))); +			zlog_debug( +				"%u: IF %s IP %s address delete, scheduling MPLS processing", +				ifp->vrf_id, ifp->name, +				prefix2str(p, buf, sizeof(buf)));  		}  		mpls_mark_lsps_for_processing(vrf_info_lookup(ifp->vrf_id));  	} diff --git a/zebra/debug.c b/zebra/debug.c index 1df547a023..14b36cb5fb 100644 --- a/zebra/debug.c +++ b/zebra/debug.c @@ -212,13 +212,15 @@ DEFUN (debug_zebra_kernel_msgdump,  		SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);  		if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND) -			UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND); +			UNSET_FLAG(zebra_debug_kernel, +				   ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);  	} else if (argv_find(argv, argc, "send", &idx)) {  		SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);  		if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV) -			UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV); +			UNSET_FLAG(zebra_debug_kernel, +				   ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);  	} else {  		SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV); @@ -400,7 +402,8 @@ static int config_write_debug(struct vty *vty)  	}  	if (IS_ZEBRA_DEBUG_KERNEL) { -		if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND && IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV) { +		if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND +		    && IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV) {  			vty_out(vty, "debug zebra kernel msgdump\n");  			write++;  		} else if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV) { diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c index 639f70a6b4..44f87f9453 100644 --- a/zebra/if_netlink.c +++ b/zebra/if_netlink.c @@ -367,8 +367,8 @@ static int get_iflink_speed(struct interface *interface)  	/* use ioctl to get IP address of an interface */  	if (zserv_privs.change(ZPRIVS_RAISE))  		zlog_err("Can't raise privileges"); -	sd = vrf_socket(PF_INET, SOCK_DGRAM, IPPROTO_IP, -			interface->vrf_id, NULL); +	sd = vrf_socket(PF_INET, SOCK_DGRAM, IPPROTO_IP, interface->vrf_id, +			NULL);  	if (sd < 0) {  		if (IS_ZEBRA_DEBUG_KERNEL)  			zlog_debug("Failure to read interface %s speed: %d %s", @@ -856,14 +856,14 @@ int kernel_address_delete_ipv4(struct interface *ifp, struct connected *ifc)  	return netlink_address(RTM_DELADDR, AF_INET, ifp, ifc);  } -int kernel_address_add_ipv6 (struct interface *ifp, struct connected *ifc) +int kernel_address_add_ipv6(struct interface *ifp, struct connected *ifc)  { -  return netlink_address (RTM_NEWADDR, AF_INET6, ifp, ifc); +	return netlink_address(RTM_NEWADDR, AF_INET6, ifp, ifc);  } -int kernel_address_delete_ipv6 (struct interface *ifp, struct connected *ifc) +int kernel_address_delete_ipv6(struct interface *ifp, struct connected *ifc)  { -  return netlink_address (RTM_DELADDR, AF_INET6, ifp, ifc); +	return netlink_address(RTM_DELADDR, AF_INET6, ifp, ifc);  }  int netlink_interface_addr(struct sockaddr_nl *snl, struct nlmsghdr *h, diff --git a/zebra/interface.c b/zebra/interface.c index 7229b8818d..01283f9122 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -52,10 +52,10 @@  #define ZEBRA_PTM_SUPPORT -DEFINE_HOOK(zebra_if_extra_info, (struct vty *vty, struct interface *ifp), -				 (vty, ifp)) -DEFINE_HOOK(zebra_if_config_wr, (struct vty *vty, struct interface *ifp), -				(vty, ifp)) +DEFINE_HOOK(zebra_if_extra_info, (struct vty * vty, struct interface *ifp), +	    (vty, ifp)) +DEFINE_HOOK(zebra_if_config_wr, (struct vty * vty, struct interface *ifp), +	    (vty, ifp))  static void if_down_del_nbr_connected(struct interface *ifp); @@ -71,8 +71,8 @@ static int if_zebra_speed_update(struct thread *thread)  	new_speed = kernel_get_speed(ifp);  	if (new_speed != ifp->speed) {  		zlog_info("%s: %s old speed: %u new speed: %u", -			  __PRETTY_FUNCTION__, ifp->name, -			  ifp->speed, new_speed); +			  __PRETTY_FUNCTION__, ifp->name, ifp->speed, +			  new_speed);  		ifp->speed = new_speed;  		if_add_update(ifp);  	} @@ -148,8 +148,8 @@ static int if_zebra_new_hook(struct interface *ifp)  	 * of seconds and ask again.  Hopefully it's all settled  	 * down upon startup.  	 */ -	thread_add_timer(zebrad.master, if_zebra_speed_update, -			 ifp, 15, &zebra_if->speed_update); +	thread_add_timer(zebrad.master, if_zebra_speed_update, ifp, 15, +			 &zebra_if->speed_update);  	return 0;  } @@ -608,16 +608,14 @@ static void if_delete_connected(struct interface *ifp)  	if (!ifp->connected)  		return; -	while ((node = (last ? last->next -			: listhead(ifp->connected)))) { +	while ((node = (last ? last->next : listhead(ifp->connected)))) {  		ifc = listgetdata(node);  		cp = *CONNECTED_PREFIX(ifc);  		apply_mask(&cp);  		if (cp.family == AF_INET -		    && (rn = route_node_lookup(zebra_if->ipv4_subnets, -					       &cp))) { +		    && (rn = route_node_lookup(zebra_if->ipv4_subnets, &cp))) {  			struct listnode *anode;  			struct listnode *next;  			struct listnode *first; @@ -1529,7 +1527,7 @@ DEFUN (show_interface_desc_vrf_all,  	struct vrf *vrf;  	RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) -		if (!RB_EMPTY (if_name_head, &vrf->ifaces_by_name)) { +		if (!RB_EMPTY(if_name_head, &vrf->ifaces_by_name)) {  			vty_out(vty, "\n\tVRF %u\n\n", vrf->vrf_id);  			if_show_description(vty, vrf->vrf_id);  		} diff --git a/zebra/interface.h b/zebra/interface.h index e13721448c..9f109fc05f 100644 --- a/zebra/interface.h +++ b/zebra/interface.h @@ -60,8 +60,6 @@ struct rtadvconf {  	   Default: 0.33 * MaxRtrAdvInterval */  	int MinRtrAdvInterval; /* This field is currently unused. */ -			       /* $FRR indent$ */ -			       /* clang-format off */  #define RTADV_MIN_RTR_ADV_INTERVAL (0.33 * RTADV_MAX_RTR_ADV_INTERVAL)  	/* Unsolicited Router Advertisements' interval timer. */ @@ -176,9 +174,8 @@ struct rtadvconf {  #define BGP_RA_CONFIGURED (1<<0)  /* BGP configured RA? */  #define VTY_RA_CONFIGURED (1<<1)  /* Operator configured RA? */  #define VTY_RA_INTERVAL_CONFIGURED (1<<2)  /* Operator configured RA interval */ -	int -		NumFastReXmitsRemain; /* Loaded first with number of fast -					 rexmits to do */ +	int NumFastReXmitsRemain; /* Loaded first with number of fast +				     rexmits to do */  #define RTADV_FAST_REXMIT_PERIOD 1 /* 1 sec */  #define RTADV_NUM_FAST_REXMITS   4 /* Fast Rexmit RA 4 times on certain events */ @@ -277,10 +274,10 @@ struct zebra_if {  	struct thread *speed_update;  }; -DECLARE_HOOK(zebra_if_extra_info, (struct vty *vty, struct interface *ifp), -				  (vty, ifp)) -DECLARE_HOOK(zebra_if_config_wr, (struct vty *vty, struct interface *ifp), -				 (vty, ifp)) +DECLARE_HOOK(zebra_if_extra_info, (struct vty * vty, struct interface *ifp), +	     (vty, ifp)) +DECLARE_HOOK(zebra_if_config_wr, (struct vty * vty, struct interface *ifp), +	     (vty, ifp))  static inline void zebra_if_set_ziftype(struct interface *ifp,  					zebra_iftype_t zif_type, diff --git a/zebra/ioctl.c b/zebra/ioctl.c index d07d37056e..a95d5d4e1b 100644 --- a/zebra/ioctl.c +++ b/zebra/ioctl.c @@ -501,14 +501,14 @@ struct in6_ifreq {  int if_prefix_add_ipv6(struct interface *ifp, struct connected *ifc)  {  #ifdef HAVE_NETLINK -	return kernel_address_add_ipv6 (ifp, ifc); +	return kernel_address_add_ipv6(ifp, ifc);  #endif /* HAVE_NETLINK */  }  int if_prefix_delete_ipv6(struct interface *ifp, struct connected *ifc)  {  #ifdef HAVE_NETLINK -	return kernel_address_delete_ipv6 (ifp, ifc); +	return kernel_address_delete_ipv6(ifp, ifc);  #endif /* HAVE_NETLINK */  }  #else /* LINUX_IPV6 */ diff --git a/zebra/irdp_interface.c b/zebra/irdp_interface.c index 8234ed6bdd..2c10ce86a0 100644 --- a/zebra/irdp_interface.c +++ b/zebra/irdp_interface.c @@ -63,14 +63,14 @@ extern int irdp_sock;  DEFINE_MTYPE_STATIC(ZEBRA, IRDP_IF, "IRDP interface data") -#define IRDP_CONFIGED							\ -	do {								\ -		if (!irdp) {						\ -			vty_out(vty, "Please Configure IRDP before using this command\n"); \ -			return CMD_WARNING_CONFIG_FAILED;		\ -		}							\ -	}								\ -	while (0) +#define IRDP_CONFIGED                                                                 \ +	do {                                                                          \ +		if (!irdp) {                                                          \ +			vty_out(vty,                                                  \ +				"Please Configure IRDP before using this command\n"); \ +			return CMD_WARNING_CONFIG_FAILED;                             \ +		}                                                                     \ +	} while (0)  static struct irdp_interface *irdp_if_get(struct interface *ifp)  { diff --git a/zebra/irdp_main.c b/zebra/irdp_main.c index 5567d53c3f..39e04480c6 100644 --- a/zebra/irdp_main.c +++ b/zebra/irdp_main.c @@ -353,9 +353,5 @@ static int irdp_module_init(void)  	return 0;  } -FRR_MODULE_SETUP( -	.name = "zebra_irdp", -	.version = FRR_VERSION, -	.description = "zebra IRDP module", -	.init = irdp_module_init, -) +FRR_MODULE_SETUP(.name = "zebra_irdp", .version = FRR_VERSION, +		 .description = "zebra IRDP module", .init = irdp_module_init, ) diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c index 3b28a9b242..eba4270efe 100644 --- a/zebra/kernel_socket.c +++ b/zebra/kernel_socket.c @@ -1384,8 +1384,8 @@ static void routing_socket(struct zebra_ns *zns)  	if (zserv_privs.change(ZPRIVS_RAISE))  		zlog_err("routing_socket: Can't raise privileges"); -	routing_sock = ns_socket(AF_ROUTE, SOCK_RAW, -				 0, (ns_id_t)zns->ns->ns_id); +	routing_sock = +		ns_socket(AF_ROUTE, SOCK_RAW, 0, (ns_id_t)zns->ns->ns_id);  	if (routing_sock < 0) {  		if (zserv_privs.change(ZPRIVS_LOWER)) diff --git a/zebra/main.c b/zebra/main.c index 749d509a86..6a08247f11 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -208,8 +208,7 @@ int main(int argc, char **argv)  #endif  	vrf_configure_backend(VRF_BACKEND_VRF_LITE); -	logicalrouter_configure_backend( -			 LOGICALROUTER_BACKEND_NETNS); +	logicalrouter_configure_backend(LOGICALROUTER_BACKEND_NETNS);  	frr_preinit(&zebra_di, argc, argv); @@ -289,7 +288,7 @@ int main(int argc, char **argv)  		case 'n':  			vrf_configure_backend(VRF_BACKEND_NETNS);  			logicalrouter_configure_backend( -					LOGICALROUTER_BACKEND_OFF); +				LOGICALROUTER_BACKEND_OFF);  			break;  #endif /* HAVE_NETLINK */  #if defined(HANDLE_ZAPI_FUZZING) @@ -333,8 +332,8 @@ int main(int argc, char **argv)  	zebra_mpls_vty_init();  	zebra_pw_vty_init(); -	/* For debug purpose. */ -	/* SET_FLAG (zebra_debug_event, ZEBRA_DEBUG_EVENT); */ +/* For debug purpose. */ +/* SET_FLAG (zebra_debug_event, ZEBRA_DEBUG_EVENT); */  #if defined(HANDLE_ZAPI_FUZZING)  	if (fuzzing) { diff --git a/zebra/redistribute.c b/zebra/redistribute.c index 3c6a2a7daf..c03d755b2a 100644 --- a/zebra/redistribute.c +++ b/zebra/redistribute.c @@ -519,8 +519,8 @@ int zebra_add_import_table_entry(struct route_node *rn, struct route_entry *re,  	afi = family2afi(rn->p.family);  	if (rmap_name)  		ret = zebra_import_table_route_map_check( -			afi, re->type, &rn->p, re->nexthop, re->vrf_id, -			re->tag, rmap_name); +			afi, re->type, &rn->p, re->nexthop, re->vrf_id, re->tag, +			rmap_name);  	if (ret != RMAP_MATCH) {  		zebra_del_import_table_entry(rn, re); @@ -533,8 +533,7 @@ int zebra_add_import_table_entry(struct route_node *rn, struct route_entry *re,  		if (CHECK_FLAG(same->status, ROUTE_ENTRY_REMOVED))  			continue; -		if (same->type == re->type -		    && same->instance == re->instance +		if (same->type == re->type && same->instance == re->instance  		    && same->table == re->table  		    && same->type != ZEBRA_ROUTE_CONNECT)  			break; @@ -543,7 +542,7 @@ int zebra_add_import_table_entry(struct route_node *rn, struct route_entry *re,  	if (same)  		zebra_del_import_table_entry(rn, same); -	newre = XCALLOC(MTYPE_RE,sizeof(struct route_entry)); +	newre = XCALLOC(MTYPE_RE, sizeof(struct route_entry));  	newre->type = ZEBRA_ROUTE_TABLE;  	newre->distance = zebra_import_table_distance[afi][re->table];  	newre->flags = re->flags; @@ -568,9 +567,9 @@ int zebra_del_import_table_entry(struct route_node *rn, struct route_entry *re)  	afi = family2afi(rn->p.family);  	prefix_copy(&p, &rn->p); -	rib_delete(afi, SAFI_UNICAST, re->vrf_id, ZEBRA_ROUTE_TABLE, -		   re->table, re->flags, &p, NULL, re->nexthop, -		   zebrad.rtm_table_default, re->metric, false, NULL); +	rib_delete(afi, SAFI_UNICAST, re->vrf_id, ZEBRA_ROUTE_TABLE, re->table, +		   re->flags, &p, NULL, re->nexthop, zebrad.rtm_table_default, +		   re->metric, false, NULL);  	return 0;  } @@ -664,19 +663,17 @@ int zebra_import_table_config(struct vty *vty)  			if (zebra_import_table_distance[afi][i]  			    != ZEBRA_TABLE_DISTANCE_DEFAULT) { -				vty_out(vty, -					"%s import-table %d distance %d", +				vty_out(vty, "%s import-table %d distance %d",  					afi_str[afi], i,  					zebra_import_table_distance[afi][i]);  			} else { -				vty_out(vty, "%s import-table %d", -					afi_str[afi], i); +				vty_out(vty, "%s import-table %d", afi_str[afi], +					i);  			}  			rmap_name = zebra_get_import_table_route_map(afi, i);  			if (rmap_name) -				vty_out(vty, " route-map %s", -					rmap_name); +				vty_out(vty, " route-map %s", rmap_name);  			vty_out(vty, "\n");  			write = 1; @@ -704,11 +701,9 @@ void zebra_import_table_rm_update()  			if (!rmap_name)  				return; -			table = zebra_vrf_other_route_table(afi, -							    i, +			table = zebra_vrf_other_route_table(afi, i,  							    VRF_DEFAULT); -			for (rn = route_top(table); rn; -			     rn = route_next(rn)) { +			for (rn = route_top(table); rn; rn = route_next(rn)) {  				/* For each entry in the non-default  				 * routing table,  				 * add the entry in the main table @@ -730,8 +725,8 @@ void zebra_import_table_rm_update()  				     && (rn->p.family == AF_INET))  				    || ((afi == AFI_IP6)  					&& (rn->p.family == AF_INET6))) -					zebra_add_import_table_entry( -						rn, re, rmap_name); +					zebra_add_import_table_entry(rn, re, +								     rmap_name);  			}  		}  	} diff --git a/zebra/rib.h b/zebra/rib.h index 9a5d88ed15..5f03f1a131 100644 --- a/zebra/rib.h +++ b/zebra/rib.h @@ -170,10 +170,10 @@ typedef struct rib_dest_t_ {  	     (re) && ((next) = (re)->next, 1); (re) = (next))  #define RNODE_FOREACH_RE(rn, re)                                               \ -	RE_DEST_FOREACH_ROUTE(rib_dest_from_rnode(rn), re) +	RE_DEST_FOREACH_ROUTE (rib_dest_from_rnode(rn), re)  #define RNODE_FOREACH_RE_SAFE(rn, re, next)                                    \ -	RE_DEST_FOREACH_ROUTE_SAFE(rib_dest_from_rnode(rn), re, next) +	RE_DEST_FOREACH_ROUTE_SAFE (rib_dest_from_rnode(rn), re, next)  #if defined(HAVE_RTADV)  /* Structure which hold status of router advertisement. */ @@ -444,8 +444,8 @@ DECLARE_HOOK(rib_update, (struct route_node * rn, const char *reason),  extern void zebra_vty_init(void); -extern int static_config(struct vty *vty, struct zebra_vrf *zvrf, -			 afi_t afi, safi_t safi, const char *cmd); +extern int static_config(struct vty *vty, struct zebra_vrf *zvrf, afi_t afi, +			 safi_t safi, const char *cmd);  extern pid_t pid;  #endif /*_ZEBRA_RIB_H */ diff --git a/zebra/rt.h b/zebra/rt.h index 472f2d7a97..399f6e8453 100644 --- a/zebra/rt.h +++ b/zebra/rt.h @@ -69,17 +69,16 @@ extern void kernel_route_rib(struct route_node *rn, struct prefix *p,   * so let's separate it out and allow the result to   * be passed back up.   */ -extern void kernel_route_rib_pass_fail(struct route_node *rn, -				       struct prefix *p, +extern void kernel_route_rib_pass_fail(struct route_node *rn, struct prefix *p,  				       struct route_entry *re,  				       enum southbound_results res);  extern int kernel_address_add_ipv4(struct interface *, struct connected *);  extern int kernel_address_delete_ipv4(struct interface *, struct connected *); -extern int kernel_address_add_ipv6 (struct interface *, struct connected *); -extern int kernel_address_delete_ipv6 (struct interface *, struct connected *); -extern int kernel_neigh_update(int cmd, int ifindex, uint32_t addr, -			       char *lla, int llalen, ns_id_t ns_id); +extern int kernel_address_add_ipv6(struct interface *, struct connected *); +extern int kernel_address_delete_ipv6(struct interface *, struct connected *); +extern int kernel_neigh_update(int cmd, int ifindex, uint32_t addr, char *lla, +			       int llalen, ns_id_t ns_id);  extern int kernel_interface_set_master(struct interface *master,  				       struct interface *slave); @@ -96,8 +95,7 @@ extern void kernel_del_lsp(zebra_lsp_t *lsp);   * the install/failure to set/unset flags and to notify   * as needed.   */ -extern void kernel_lsp_pass_fail(zebra_lsp_t *lsp, -				 enum southbound_results res); +extern void kernel_lsp_pass_fail(zebra_lsp_t *lsp, enum southbound_results res);  extern int mpls_kernel_init(void); diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index e26109badf..e95665feb4 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -160,8 +160,8 @@ static inline int proto2zebra(int proto, int family)  		proto = ZEBRA_ROUTE_BGP;  		break;  	case RTPROT_OSPF: -		proto = (family == AFI_IP) ? -			ZEBRA_ROUTE_OSPF : ZEBRA_ROUTE_OSPF6; +		proto = (family == AFI_IP) ? ZEBRA_ROUTE_OSPF +					   : ZEBRA_ROUTE_OSPF6;  		break;  	case RTPROT_ISIS:  		proto = ZEBRA_ROUTE_ISIS; @@ -340,8 +340,7 @@ static int netlink_route_change_read_unicast(struct sockaddr_nl *snl,  		struct rtattr *mxrta[RTAX_MAX + 1];  		memset(mxrta, 0, sizeof mxrta); -		netlink_parse_rtattr(mxrta, RTAX_MAX, -				     RTA_DATA(tb[RTA_METRICS]), +		netlink_parse_rtattr(mxrta, RTAX_MAX, RTA_DATA(tb[RTA_METRICS]),  				     RTA_PAYLOAD(tb[RTA_METRICS]));  		if (mxrta[RTAX_MTU]) @@ -392,19 +391,20 @@ static int netlink_route_change_read_unicast(struct sockaddr_nl *snl,  	 */  	if (proto == ZEBRA_ROUTE_KERNEL) {  		distance = (metric >> 24) & 0xFF; -		metric   = (metric & 0x00FFFFFF); +		metric = (metric & 0x00FFFFFF);  	}  	if (IS_ZEBRA_DEBUG_KERNEL) {  		char buf[PREFIX_STRLEN];  		char buf2[PREFIX_STRLEN]; -		zlog_debug( -			"%s %s%s%s vrf %u metric: %d Admin Distance: %d", nl_msg_type_to_str(h->nlmsg_type), -			prefix2str(&p, buf, sizeof(buf)), -			src_p.prefixlen ? " from " : "", -			src_p.prefixlen ? prefix2str(&src_p, buf2, sizeof(buf2)) -					: "", -			vrf_id, metric, distance); +		zlog_debug("%s %s%s%s vrf %u metric: %d Admin Distance: %d", +			   nl_msg_type_to_str(h->nlmsg_type), +			   prefix2str(&p, buf, sizeof(buf)), +			   src_p.prefixlen ? " from " : "", +			   src_p.prefixlen +				   ? prefix2str(&src_p, buf2, sizeof(buf2)) +				   : "", +			   vrf_id, metric, distance);  	}  	afi_t afi = AFI_IP; @@ -425,9 +425,10 @@ static int netlink_route_change_read_unicast(struct sockaddr_nl *snl,  				if (index && !gate)  					nh.type = NEXTHOP_TYPE_IFINDEX;  				else if (index && gate) -					nh.type = (afi == AFI_IP) -						? NEXTHOP_TYPE_IPV4_IFINDEX -						: NEXTHOP_TYPE_IPV6_IFINDEX; +					nh.type = +						(afi == AFI_IP) +							? NEXTHOP_TYPE_IPV4_IFINDEX +							: NEXTHOP_TYPE_IPV6_IFINDEX;  				else if (!index && gate)  					nh.type = (afi == AFI_IP)  							  ? NEXTHOP_TYPE_IPV4 @@ -447,8 +448,7 @@ static int netlink_route_change_read_unicast(struct sockaddr_nl *snl,  				memcpy(&nh.gate, gate, sz);  			if (index) { -				ifp = if_lookup_by_index(index, -							 VRF_UNKNOWN); +				ifp = if_lookup_by_index(index, VRF_UNKNOWN);  				if (ifp)  					nh_vrf_id = ifp->vrf_id;  			} @@ -553,8 +553,8 @@ static int netlink_route_change_read_unicast(struct sockaddr_nl *snl,  			if (re->nexthop_num == 0)  				XFREE(MTYPE_RE, re);  			else -				rib_add_multipath(afi, SAFI_UNICAST, &p, -						  NULL, re); +				rib_add_multipath(afi, SAFI_UNICAST, &p, NULL, +						  re);  		}  	} else {  		if (!tb[RTA_MULTIPATH]) { @@ -585,15 +585,13 @@ static int netlink_route_change_read_unicast(struct sockaddr_nl *snl,  			nh.ifindex = index;  			if (gate)  				memcpy(&nh.gate, gate, sz); -			rib_delete(afi, SAFI_UNICAST, vrf_id, -				   proto, 0, flags, &p, NULL, &nh, -				   table, metric, true, NULL); +			rib_delete(afi, SAFI_UNICAST, vrf_id, proto, 0, flags, +				   &p, NULL, &nh, table, metric, true, NULL);  		} else {  			/* XXX: need to compare the entire list of nexthops  			 * here for NLM_F_APPEND stupidity */ -			rib_delete(afi, SAFI_UNICAST, vrf_id, -				   proto, 0, flags, &p, NULL, NULL, -				   table, metric, true, NULL); +			rib_delete(afi, SAFI_UNICAST, vrf_id, proto, 0, flags, +				   &p, NULL, NULL, table, metric, true, NULL);  		}  	} @@ -1403,8 +1401,7 @@ static int netlink_route_multipath(int cmd, struct prefix *p,  	for (ALL_NEXTHOPS(re->nexthop, nexthop)) {  		if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_RECURSIVE))  			continue; -		if (cmd == RTM_NEWROUTE -		    && !NEXTHOP_IS_ACTIVE(nexthop->flags)) +		if (cmd == RTM_NEWROUTE && !NEXTHOP_IS_ACTIVE(nexthop->flags))  			continue;  		if (cmd == RTM_DELROUTE  		    && !CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB)) @@ -1687,15 +1684,14 @@ void kernel_route_rib(struct route_node *rn, struct prefix *p,  			 * screwed.  			 */  			if (old) -				netlink_route_multipath(RTM_DELROUTE, p, -							src_p, old, 0); -			ret = netlink_route_multipath(RTM_NEWROUTE, p, -						      src_p, new, 0); +				netlink_route_multipath(RTM_DELROUTE, p, src_p, +							old, 0); +			ret = netlink_route_multipath(RTM_NEWROUTE, p, src_p, +						      new, 0);  		}  		kernel_route_rib_pass_fail(rn, p, new, -					   (!ret) ? -					   SOUTHBOUND_INSTALL_SUCCESS : -					   SOUTHBOUND_INSTALL_FAILURE); +					   (!ret) ? SOUTHBOUND_INSTALL_SUCCESS +						  : SOUTHBOUND_INSTALL_FAILURE);  		return;  	} @@ -1703,9 +1699,8 @@ void kernel_route_rib(struct route_node *rn, struct prefix *p,  		ret = netlink_route_multipath(RTM_DELROUTE, p, src_p, old, 0);  		kernel_route_rib_pass_fail(rn, p, old, -					   (!ret) ? -					   SOUTHBOUND_DELETE_SUCCESS : -					   SOUTHBOUND_DELETE_FAILURE); +					   (!ret) ? SOUTHBOUND_DELETE_SUCCESS +						  : SOUTHBOUND_DELETE_FAILURE);  	}  } @@ -2176,7 +2171,8 @@ static int netlink_ipneigh_change(struct sockaddr_nl *snl, struct nlmsghdr *h,  					nl_msg_type_to_str(h->nlmsg_type),  					nl_family_to_str(ndm->ndm_family),  					ifp->name, ndm->ndm_ifindex, -					(unsigned long)RTA_PAYLOAD(tb[NDA_LLADDR])); +					(unsigned long)RTA_PAYLOAD( +						tb[NDA_LLADDR]));  				return 0;  			} diff --git a/zebra/rt_socket.c b/zebra/rt_socket.c index b2baee5728..1aa402672e 100644 --- a/zebra/rt_socket.c +++ b/zebra/rt_socket.c @@ -135,8 +135,7 @@ static int kernel_rtm_ipv4(int cmd, struct prefix *p, struct route_entry *re)  		 * but this if statement seems overly cautious - what about  		 * other than ADD and DELETE?  		 */ -		if ((cmd == RTM_ADD -		     && NEXTHOP_IS_ACTIVE(nexthop->flags)) +		if ((cmd == RTM_ADD && NEXTHOP_IS_ACTIVE(nexthop->flags))  		    || (cmd == RTM_DELETE  			&& CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB))) {  			if (nexthop->type == NEXTHOP_TYPE_IPV4 @@ -310,8 +309,7 @@ static int kernel_rtm_ipv6(int cmd, struct prefix *p, struct route_entry *re)  		gate = 0; -		if ((cmd == RTM_ADD -		     && NEXTHOP_IS_ACTIVE(nexthop->flags)) +		if ((cmd == RTM_ADD && NEXTHOP_IS_ACTIVE(nexthop->flags))  		    || (cmd == RTM_DELETE)) {  			if (nexthop->type == NEXTHOP_TYPE_IPV6  			    || nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX) { @@ -411,15 +409,15 @@ void kernel_route_rib(struct route_node *rn, struct prefix *p,  		zlog_err("Can't lower privileges");  	if (new) { -		kernel_route_rib_pass_fail(rn, p, new, -					   (!route) ? -					   SOUTHBOUND_INSTALL_SUCCESS : -					   SOUTHBOUND_INSTALL_FAILURE); +		kernel_route_rib_pass_fail( +			rn, p, new, +			(!route) ? SOUTHBOUND_INSTALL_SUCCESS +				 : SOUTHBOUND_INSTALL_FAILURE);  	} else {  		kernel_route_rib_pass_fail(rn, p, old, -					   (!route) ? -					   SOUTHBOUND_DELETE_SUCCESS : -					   SOUTHBOUND_DELETE_FAILURE); +					   (!route) +						   ? SOUTHBOUND_DELETE_SUCCESS +						   : SOUTHBOUND_DELETE_FAILURE);  	}  } diff --git a/zebra/rtadv.c b/zebra/rtadv.c index 860e8710d6..5eebca163b 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -842,9 +842,9 @@ void zebra_interface_radv_set(struct zserv *client, u_short length,  		SET_FLAG(zif->rtadv.ra_configured, BGP_RA_CONFIGURED);  		ipv6_nd_suppress_ra_set(ifp, RA_ENABLE);  		if (ra_interval -			&& (ra_interval * 1000) < zif->rtadv.MaxRtrAdvInterval -			&& !CHECK_FLAG(zif->rtadv.ra_configured, -				VTY_RA_INTERVAL_CONFIGURED)) +		    && (ra_interval * 1000) < zif->rtadv.MaxRtrAdvInterval +		    && !CHECK_FLAG(zif->rtadv.ra_configured, +				   VTY_RA_INTERVAL_CONFIGURED))  			zif->rtadv.MaxRtrAdvInterval = ra_interval * 1000;  	} else {  		UNSET_FLAG(zif->rtadv.ra_configured, BGP_RA_CONFIGURED); diff --git a/zebra/rtadv.h b/zebra/rtadv.h index 9ec1bffa8d..2cae6d06f9 100644 --- a/zebra/rtadv.h +++ b/zebra/rtadv.h @@ -103,8 +103,7 @@ typedef enum {  extern void rtadv_init(struct zebra_ns *);  extern void rtadv_terminate(struct zebra_ns *);  extern void rtadv_cmd_init(void); -extern void zebra_interface_radv_set(struct zserv *client, -				     u_short length, struct zebra_vrf *zvrf, -				     int enable); +extern void zebra_interface_radv_set(struct zserv *client, u_short length, +				     struct zebra_vrf *zvrf, int enable);  #endif /* _ZEBRA_RTADV_H */ diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c index a6e0882ff8..9d3133f55b 100644 --- a/zebra/zebra_fpm.c +++ b/zebra/zebra_fpm.c @@ -719,8 +719,7 @@ static int zfpm_read_cb(struct thread *thread)  				sprintf(buffer, "closed socket in read(%d): %s",  					errno, safe_strerror(errno));  				zfpm_connection_down(buffer); -			} -			else +			} else  				zfpm_connection_down("closed socket in read");  			return 0;  		} @@ -757,8 +756,7 @@ static int zfpm_read_cb(struct thread *thread)  				sprintf(buffer, "failed to read message(%d) %s",  					errno, safe_strerror(errno));  				zfpm_connection_down(buffer); -			} -			else +			} else  				zfpm_connection_down("failed to read message");  			return 0;  		} @@ -1554,9 +1552,8 @@ static int fpm_remote_srv_write(struct vty *vty)  	in.s_addr = zfpm_g->fpm_server;  	if ((zfpm_g->fpm_server != FPM_DEFAULT_IP -		&& zfpm_g->fpm_server != INADDR_ANY) -	    || (zfpm_g->fpm_port != FPM_DEFAULT_PORT -		&& zfpm_g->fpm_port != 0)) +	     && zfpm_g->fpm_server != INADDR_ANY) +	    || (zfpm_g->fpm_port != FPM_DEFAULT_PORT && zfpm_g->fpm_port != 0))  		vty_out(vty, "fpm connection ip %s port %d\n", inet_ntoa(in),  			zfpm_g->fpm_port); diff --git a/zebra/zebra_l2.h b/zebra/zebra_l2.h index d9bbcfed6f..0d0c5aaf22 100644 --- a/zebra/zebra_l2.h +++ b/zebra/zebra_l2.h @@ -67,7 +67,6 @@ union zebra_l2if_info {  #define IS_ZEBRA_IF_BRIDGE_VLAN_AWARE(zif) ((zif)->l2info.br.vlan_aware == 1) -  extern void zebra_l2_map_slave_to_bridge(struct zebra_l2info_brslave *br_slave);  extern void  zebra_l2_unmap_slave_from_bridge(struct zebra_l2info_brslave *br_slave); diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index ec80081a46..2dc98127f5 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -411,8 +411,8 @@ static int fec_change_update_lsp(struct zebra_vrf *zvrf, zebra_fec_t *fec,  	afi_t afi;  	/* Uninstall label forwarding entry, if previously installed. */ -	if (old_label != MPLS_INVALID_LABEL && -	    old_label != MPLS_LABEL_IMPLICIT_NULL) +	if (old_label != MPLS_INVALID_LABEL +	    && old_label != MPLS_LABEL_IMPLICIT_NULL)  		lsp_uninstall(zvrf, old_label);  	/* Install label forwarding entry corr. to new label, if needed. */ @@ -937,16 +937,16 @@ static wq_item_status lsp_process(struct work_queue *wq, void *data)  			 * Any NHLFE that was installed but is not  			 * selected now needs to have its flags updated.  			 */ -			for (nhlfe = lsp->nhlfe_list; -			     nhlfe; nhlfe = nhlfe->next) { +			for (nhlfe = lsp->nhlfe_list; nhlfe; +			     nhlfe = nhlfe->next) {  				nexthop = nhlfe->nexthop;  				if (!nexthop)  					continue;  				if (CHECK_FLAG(nhlfe->flags, -					       NHLFE_FLAG_INSTALLED) && -				    !CHECK_FLAG(nhlfe->flags, -						NHLFE_FLAG_SELECTED)) { +					       NHLFE_FLAG_INSTALLED) +				    && !CHECK_FLAG(nhlfe->flags, +						   NHLFE_FLAG_SELECTED)) {  					UNSET_FLAG(nhlfe->flags,  						   NHLFE_FLAG_INSTALLED);  					UNSET_FLAG(nexthop->flags, @@ -1398,9 +1398,9 @@ static void nhlfe_print(zebra_nhlfe_t *nhlfe, struct vty *vty)  	default:  		break;  	} -	vty_out(vty, "%s", CHECK_FLAG(nhlfe->flags, NHLFE_FLAG_INSTALLED) -				   ? " (installed)" -				   : ""); +	vty_out(vty, "%s", +		CHECK_FLAG(nhlfe->flags, NHLFE_FLAG_INSTALLED) ? " (installed)" +							       : "");  	vty_out(vty, "\n");  } @@ -1688,8 +1688,7 @@ static int mpls_processq_init(struct zebra_t *zebra)  /* Public functions */ -void kernel_lsp_pass_fail(zebra_lsp_t *lsp, -			  enum southbound_results res) +void kernel_lsp_pass_fail(zebra_lsp_t *lsp, enum southbound_results res)  {  	struct nexthop *nexthop;  	zebra_nhlfe_t *nhlfe; @@ -2793,8 +2792,7 @@ void zebra_mpls_print_lsp_table(struct vty *vty, struct zebra_vrf *zvrf,  				nexthop = nhlfe->nexthop;  				switch (nexthop->type) { -				case NEXTHOP_TYPE_IFINDEX: -				{ +				case NEXTHOP_TYPE_IFINDEX: {  					struct interface *ifp;  					ifp = if_lookup_by_index( @@ -2955,12 +2953,9 @@ void zebra_mpls_init_tables(struct zebra_vrf *zvrf)  {  	if (!zvrf)  		return; -	zvrf->slsp_table = hash_create(label_hash, -				       label_cmp, -				       "ZEBRA SLSP table"); -	zvrf->lsp_table = hash_create(label_hash, -				      label_cmp, -				      "ZEBRA LSP table"); +	zvrf->slsp_table = +		hash_create(label_hash, label_cmp, "ZEBRA SLSP table"); +	zvrf->lsp_table = hash_create(label_hash, label_cmp, "ZEBRA LSP table");  	zvrf->fec_table[AFI_IP] = route_table_init();  	zvrf->fec_table[AFI_IP6] = route_table_init();  	zvrf->mpls_flags = 0; diff --git a/zebra/zebra_mpls_netlink.c b/zebra/zebra_mpls_netlink.c index 3c8d25189e..d7c231c37e 100644 --- a/zebra/zebra_mpls_netlink.c +++ b/zebra/zebra_mpls_netlink.c @@ -41,9 +41,8 @@ void kernel_add_lsp(zebra_lsp_t *lsp)  	ret = netlink_mpls_multipath(RTM_NEWROUTE, lsp);  	kernel_lsp_pass_fail(lsp, -			     (!ret) ? -			     SOUTHBOUND_INSTALL_SUCCESS : -			     SOUTHBOUND_INSTALL_FAILURE); +			     (!ret) ? SOUTHBOUND_INSTALL_SUCCESS +				    : SOUTHBOUND_INSTALL_FAILURE);  }  /* @@ -69,9 +68,8 @@ void kernel_upd_lsp(zebra_lsp_t *lsp)  	ret = netlink_mpls_multipath(RTM_NEWROUTE, lsp);  	kernel_lsp_pass_fail(lsp, -			     (!ret) ? -			     SOUTHBOUND_INSTALL_SUCCESS : -			     SOUTHBOUND_INSTALL_FAILURE); +			     (!ret) ? SOUTHBOUND_INSTALL_SUCCESS +				    : SOUTHBOUND_INSTALL_FAILURE);  }  /* @@ -82,23 +80,20 @@ void kernel_del_lsp(zebra_lsp_t *lsp)  	int ret;  	if (!lsp) { // unexpected -		kernel_lsp_pass_fail(lsp, -				     SOUTHBOUND_DELETE_FAILURE); +		kernel_lsp_pass_fail(lsp, SOUTHBOUND_DELETE_FAILURE);  		return;  	}  	if (!CHECK_FLAG(lsp->flags, LSP_FLAG_INSTALLED)) { -		kernel_lsp_pass_fail(lsp, -				     SOUTHBOUND_DELETE_FAILURE); +		kernel_lsp_pass_fail(lsp, SOUTHBOUND_DELETE_FAILURE);  		return;  	}  	ret = netlink_mpls_multipath(RTM_DELROUTE, lsp);  	kernel_lsp_pass_fail(lsp, -			     (!ret) ? -			     SOUTHBOUND_DELETE_SUCCESS : -			     SOUTHBOUND_DELETE_FAILURE); +			     (!ret) ? SOUTHBOUND_DELETE_SUCCESS +				    : SOUTHBOUND_DELETE_FAILURE);  }  int mpls_kernel_init(void) diff --git a/zebra/zebra_mpls_openbsd.c b/zebra/zebra_mpls_openbsd.c index 2fc93893fa..2c7fe577ef 100644 --- a/zebra/zebra_mpls_openbsd.c +++ b/zebra/zebra_mpls_openbsd.c @@ -297,9 +297,8 @@ void kernel_add_lsp(zebra_lsp_t *lsp)  	ret = kernel_lsp_cmd(RTM_ADD, lsp);  	kernel_lsp_pass_fail(lsp, -			     (!ret) ? -			     SOUTHBOUND_INSTALL_SUCCESS : -			     SOUTHBOUND_INSTALL_FAILURE); +			     (!ret) ? SOUTHBOUND_INSTALL_SUCCESS +				    : SOUTHBOUND_INSTALL_FAILURE);  }  void kernel_upd_lsp(zebra_lsp_t *lsp) @@ -314,9 +313,8 @@ void kernel_upd_lsp(zebra_lsp_t *lsp)  	ret = kernel_lsp_cmd(RTM_CHANGE, lsp);  	kernel_lsp_pass_fail(lsp, -			     (!ret) ? -			     SOUTHBOUND_INSTALL_SUCCESS : -			     SOUTHBOUND_INSTALL_FAILURE); +			     (!ret) ? SOUTHBOUND_INSTALL_SUCCESS +				    : SOUTHBOUND_INSTALL_FAILURE);  	return;  } @@ -325,23 +323,20 @@ void kernel_del_lsp(zebra_lsp_t *lsp)  	int ret;  	if (!lsp) { // unexpected -		kernel_lsp_pass_fail(lsp, -				     SOUTHBOUND_DELETE_FAILURE); +		kernel_lsp_pass_fail(lsp, SOUTHBOUND_DELETE_FAILURE);  		return;  	}  	if (!CHECK_FLAG(lsp->flags, LSP_FLAG_INSTALLED)) { -		kernel_lsp_pass_fail(lsp, -				     SOUTHBOUND_DELETE_FAILURE); +		kernel_lsp_pass_fail(lsp, SOUTHBOUND_DELETE_FAILURE);  		return;  	}  	ret = kernel_lsp_cmd(RTM_DELETE, lsp);  	kernel_lsp_pass_fail(lsp, -			     (!ret) ? -			     SOUTHBOUND_DELETE_SUCCESS : -			     SOUTHBOUND_DELETE_FAILURE); +			     (!ret) ? SOUTHBOUND_DELETE_SUCCESS +				    : SOUTHBOUND_DELETE_FAILURE);  }  static int kmpw_install(struct zebra_pw *pw) diff --git a/zebra/zebra_netns_id.c b/zebra/zebra_netns_id.c index 966d6ed0d2..a81413f5a9 100644 --- a/zebra/zebra_netns_id.c +++ b/zebra/zebra_netns_id.c @@ -47,8 +47,8 @@  #define NETLINK_SOCKET_BUFFER_SIZE 512  #define NETLINK_ALIGNTO             4 -#define NETLINK_ALIGN(len)          (((len)+NETLINK_ALIGNTO-1)	\ -				     & ~(NETLINK_ALIGNTO-1)) +#define NETLINK_ALIGN(len)                                                     \ +	(((len) + NETLINK_ALIGNTO - 1) & ~(NETLINK_ALIGNTO - 1))  #define NETLINK_NLATTR_LEN(_a, _b)   (unsigned int)((char *)_a - (char *)_b)  #endif /* defined(HAVE_NETLINK) */ @@ -77,36 +77,33 @@ static struct nlmsghdr *initiate_nlh(char *buf, unsigned int *seq, int type)  	return nlh;  } -static int send_receive(int sock, struct nlmsghdr *nlh, -			unsigned int seq, char *buf) +static int send_receive(int sock, struct nlmsghdr *nlh, unsigned int seq, +			char *buf)  {  	int ret; -	static const struct sockaddr_nl snl = { -		.nl_family = AF_NETLINK -	}; +	static const struct sockaddr_nl snl = {.nl_family = AF_NETLINK};  	ret = sendto(sock, (const void *)nlh, (size_t)nlh->nlmsg_len, 0, -		     (struct sockaddr *) &snl, (socklen_t)sizeof(snl)); +		     (struct sockaddr *)&snl, (socklen_t)sizeof(snl));  	if (ret < 0) { -		zlog_err("netlink( %u) sendmsg() error: %s", -			 sock, safe_strerror(errno)); +		zlog_err("netlink( %u) sendmsg() error: %s", sock, +			 safe_strerror(errno));  		return -1;  	}  	/* reception */  	struct sockaddr_nl addr;  	struct iovec iov = { -		.iov_base       = buf, -		.iov_len        = NETLINK_SOCKET_BUFFER_SIZE, +		.iov_base = buf, .iov_len = NETLINK_SOCKET_BUFFER_SIZE,  	};  	struct msghdr msg = { -		.msg_name       = &addr, -		.msg_namelen    = sizeof(struct sockaddr_nl), -		.msg_iov        = &iov, -		.msg_iovlen     = 1, -		.msg_control    = NULL, +		.msg_name = &addr, +		.msg_namelen = sizeof(struct sockaddr_nl), +		.msg_iov = &iov, +		.msg_iovlen = 1, +		.msg_control = NULL,  		.msg_controllen = 0, -		.msg_flags      = 0, +		.msg_flags = 0,  	};  	ret = recvmsg(sock, &msg, 0);  	if (ret < 0) { @@ -119,8 +116,9 @@ static int send_receive(int sock, struct nlmsghdr *nlh,  	}  	/* nlh already points to buf */  	if (nlh->nlmsg_seq != seq) { -		zlog_err("netlink recvmsg: bad sequence number %x (expected %x)", -			 seq, nlh->nlmsg_seq); +		zlog_err( +			"netlink recvmsg: bad sequence number %x (expected %x)", +			seq, nlh->nlmsg_seq);  		return -1;  	}  	return ret; @@ -132,16 +130,16 @@ static int send_receive(int sock, struct nlmsghdr *nlh,  static ns_id_t extract_nsid(struct nlmsghdr *nlh, char *buf)  {  	ns_id_t ns_id = NS_UNKNOWN; -	int offset = NETLINK_ALIGN(sizeof(struct nlmsghdr)) + -		NETLINK_ALIGN(sizeof(struct rtgenmsg)); +	int offset = NETLINK_ALIGN(sizeof(struct nlmsghdr)) +		     + NETLINK_ALIGN(sizeof(struct rtgenmsg));  	int curr_length = offset;  	void *tail = (void *)((char *)nlh + NETLINK_ALIGN(nlh->nlmsg_len));  	struct nlattr *attr;  	for (attr = (struct nlattr *)((char *)buf + offset); -	     NETLINK_NLATTR_LEN(tail, attr) >= sizeof(struct nlattr) && -		     attr->nla_len >= sizeof(struct nlattr) && -		     attr->nla_len <= NETLINK_NLATTR_LEN(tail, attr); +	     NETLINK_NLATTR_LEN(tail, attr) >= sizeof(struct nlattr) +	     && attr->nla_len >= sizeof(struct nlattr) +	     && attr->nla_len <= NETLINK_NLATTR_LEN(tail, attr);  	     attr += NETLINK_ALIGN(attr->nla_len)) {  		curr_length += attr->nla_len;  		if ((attr->nla_type & NLA_TYPE_MASK) == NETNSA_NSID) { @@ -172,8 +170,8 @@ ns_id_t zebra_ns_id_get(const char *netnspath)  	/* netlink socket */  	sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);  	if (sock < 0) { -		zlog_err("netlink( %u) socket() error: %s", -			 sock, safe_strerror(errno)); +		zlog_err("netlink( %u) socket() error: %s", sock, +			 safe_strerror(errno));  		return NS_UNKNOWN;  	}  	memset(&snl, 0, sizeof(snl)); @@ -182,8 +180,8 @@ ns_id_t zebra_ns_id_get(const char *netnspath)  	snl.nl_pid = 0; /* AUTO PID */  	ret = bind(sock, (struct sockaddr *)&snl, sizeof(snl));  	if (ret < 0) { -		zlog_err("netlink( %u) socket() bind error: %s", -			 sock, safe_strerror(errno)); +		zlog_err("netlink( %u) socket() bind error: %s", sock, +			 safe_strerror(errno));  		close(sock);  		close(fd);  		return NS_UNKNOWN; @@ -222,10 +220,12 @@ ns_id_t zebra_ns_id_get(const char *netnspath)  				break;  		} else {  			if (nlh->nlmsg_type == NLMSG_ERROR) { -				struct nlmsgerr *err = (struct nlmsgerr *) -					((char *)nlh + -					 NETLINK_ALIGN(sizeof( -						struct nlmsghdr))); +				struct nlmsgerr *err = +					(struct nlmsgerr +						 *)((char *)nlh +						    + NETLINK_ALIGN(sizeof( +							      struct +							      nlmsghdr)));  				ret = -1;  				if (err->error < 0) @@ -248,14 +248,15 @@ ns_id_t zebra_ns_id_get(const char *netnspath)  			}  		}  		len = len - NETLINK_ALIGN(nlh->nlmsg_len); -		nlh = (struct nlmsghdr *)((char *)nlh + -					  NETLINK_ALIGN(nlh->nlmsg_len)); +		nlh = (struct nlmsghdr *)((char *)nlh +					  + NETLINK_ALIGN(nlh->nlmsg_len));  	} while (len != 0 && return_nsid != NS_UNKNOWN && ret == 0);  	if (ret <= 0) {  		if (errno != EEXIST && ret != 0) { -			zlog_err("netlink( %u) recvfrom() error 2 when reading: %s", -				 fd, safe_strerror(errno)); +			zlog_err( +				"netlink( %u) recvfrom() error 2 when reading: %s", +				fd, safe_strerror(errno));  			close(sock);  			close(fd);  			if (errno == ENOTSUP) { @@ -289,10 +290,12 @@ ns_id_t zebra_ns_id_get(const char *netnspath)  				if (return_nsid != NS_UNKNOWN)  					break;  			} else if (nlh->nlmsg_type == NLMSG_ERROR) { -				struct nlmsgerr *err = (struct nlmsgerr *) -					((char *)nlh + -					 NETLINK_ALIGN(sizeof( -						 struct nlmsghdr))); +				struct nlmsgerr *err = +					(struct nlmsgerr +						 *)((char *)nlh +						    + NETLINK_ALIGN(sizeof( +							      struct +							      nlmsghdr)));  				if (err->error < 0)  					errno = -err->error;  				else @@ -300,8 +303,9 @@ ns_id_t zebra_ns_id_get(const char *netnspath)  				break;  			}  			len = len - NETLINK_ALIGN(nlh->nlmsg_len); -			nlh = (struct nlmsghdr *)((char *)nlh + -				  NETLINK_ALIGN(nlh->nlmsg_len)); +			nlh = (struct nlmsghdr *)((char *)nlh +						  + NETLINK_ALIGN( +							    nlh->nlmsg_len));  		} while (len != 0 && return_nsid != NS_UNKNOWN && ret == 0);  	} @@ -348,8 +352,7 @@ ns_id_t zebra_ns_id_get_default(void)  		return NS_DEFAULT_INTERNAL;  	close(fd);  	return zebra_ns_id_get((char *)NS_DEFAULT_NAME); -#else /* HAVE_NETNS */ +#else  /* HAVE_NETNS */  	return NS_DEFAULT_INTERNAL;  #endif /* !HAVE_NETNS */  } - diff --git a/zebra/zebra_netns_notify.c b/zebra/zebra_netns_notify.c index b98d6ed703..4f55be45b6 100644 --- a/zebra/zebra_netns_notify.c +++ b/zebra/zebra_netns_notify.c @@ -83,8 +83,9 @@ static void zebra_ns_notify_create_context_from_entry_name(const char *name)  	/* if VRF with NS ID already present */  	vrf = vrf_lookup_by_id((vrf_id_t)ns_id);  	if (vrf) { -		zlog_warn("NS notify : same NSID used by VRF %s. Ignore NS %s creation", -			  vrf->name, netnspath); +		zlog_warn( +			"NS notify : same NSID used by VRF %s. Ignore NS %s creation", +			vrf->name, netnspath);  		return;  	}  	if (vrf_handler_create(NULL, name, &vrf) != CMD_SUCCESS) { @@ -96,8 +97,7 @@ static void zebra_ns_notify_create_context_from_entry_name(const char *name)  		zlog_warn("NS notify : failed to create NS %s", netnspath);  		return;  	} -	zlog_info("NS notify : created VRF %s NS %s", -		   name, netnspath); +	zlog_info("NS notify : created VRF %s NS %s", name, netnspath);  }  static int zebra_ns_continue_read(struct zebra_netns_info *zns_info, @@ -111,8 +111,8 @@ static int zebra_ns_continue_read(struct zebra_netns_info *zns_info,  		return 0;  	}  	thread_add_timer_msec(zebrad.master, zebra_ns_ready_read, -			      (void *)zns_info, -			      ZEBRA_NS_POLLING_INTERVAL_MSEC, NULL); +			      (void *)zns_info, ZEBRA_NS_POLLING_INTERVAL_MSEC, +			      NULL);  	return 0;  } @@ -160,19 +160,17 @@ static int zebra_ns_notify_read(struct thread *t)  	char buf[BUFSIZ];  	ssize_t len; -	zebra_netns_notify_current = thread_add_read(zebrad.master, -						     zebra_ns_notify_read, -						     NULL, fd_monitor, NULL); +	zebra_netns_notify_current = thread_add_read( +		zebrad.master, zebra_ns_notify_read, NULL, fd_monitor, NULL);  	len = read(fd_monitor, buf, sizeof(buf));  	if (len < 0) {  		zlog_warn("NS notify read: failed to read (%s)",  			  safe_strerror(errno));  		return 0;  	} -	for (event = (struct inotify_event *)buf; -	     (char *)event < &buf[len]; -	     event = (struct inotify_event *)((char *)event + -					      sizeof(*event) + event->len)) { +	for (event = (struct inotify_event *)buf; (char *)event < &buf[len]; +	     event = (struct inotify_event *)((char *)event + sizeof(*event) +					      + event->len)) {  		char *netnspath;  		struct zebra_netns_info *netnsinfo; @@ -187,7 +185,7 @@ static int zebra_ns_notify_read(struct thread *t)  		netnsinfo->retries = ZEBRA_NS_POLLING_MAX_RETRIES;  		netnsinfo->netnspath = netnspath;  		thread_add_timer_msec(zebrad.master, zebra_ns_ready_read, -				       (void *)netnsinfo, 0, NULL); +				      (void *)netnsinfo, 0, NULL);  	}  	return 0;  } @@ -205,7 +203,7 @@ void zebra_ns_notify_parse(void)  		struct stat st;  		if (strcmp(dent->d_name, ".") == 0 -		   || strcmp(dent->d_name, "..") == 0) +		    || strcmp(dent->d_name, "..") == 0)  			continue;  		if (fstatat(dirfd(srcdir), dent->d_name, &st, 0) < 0) {  			zlog_warn("NS parsing init: failed to parse entry %s", @@ -236,9 +234,8 @@ void zebra_ns_notify_init(void)  		zlog_warn("NS notify watch: failed to add watch (%s)",  			  safe_strerror(errno));  	} -	zebra_netns_notify_current = thread_add_read(zebrad.master, -						     zebra_ns_notify_read, -						     NULL, fd_monitor, NULL); +	zebra_netns_notify_current = thread_add_read( +		zebrad.master, zebra_ns_notify_read, NULL, fd_monitor, NULL);  }  void zebra_ns_notify_close(void) diff --git a/zebra/zebra_ns.c b/zebra/zebra_ns.c index cb302985c8..580ff3eec1 100644 --- a/zebra/zebra_ns.c +++ b/zebra/zebra_ns.c @@ -41,18 +41,16 @@ extern struct zebra_privs_t zserv_privs;  DEFINE_MTYPE(ZEBRA, ZEBRA_NS, "Zebra Name Space") -static inline int -zebra_ns_table_entry_compare(const struct zebra_ns_table *e1, -			     const struct zebra_ns_table *e2); +static inline int zebra_ns_table_entry_compare(const struct zebra_ns_table *e1, +					       const struct zebra_ns_table *e2);  RB_GENERATE(zebra_ns_table_head, zebra_ns_table, zebra_ns_table_entry,  	    zebra_ns_table_entry_compare);  static struct zebra_ns *dzns; -static inline int -zebra_ns_table_entry_compare(const struct zebra_ns_table *e1, -			     const struct zebra_ns_table *e2) +static inline int zebra_ns_table_entry_compare(const struct zebra_ns_table *e1, +					       const struct zebra_ns_table *e2)  {  	if (e1->tableid == e2->tableid)  		return (e1->afi - e2->afi); @@ -96,7 +94,7 @@ static int zebra_ns_new(struct ns *ns)  static int zebra_ns_delete(struct ns *ns)  { -	struct zebra_ns *zns = (struct zebra_ns *) ns->info; +	struct zebra_ns *zns = (struct zebra_ns *)ns->info;  	if (IS_ZEBRA_DEBUG_EVENT)  		zlog_info("ZNS %s with id %u (deleted)", ns->name, ns->ns_id); @@ -146,8 +144,8 @@ int zebra_ns_enable(ns_id_t ns_id, void **info)  	return 0;  } -struct route_table *zebra_ns_find_table(struct zebra_ns *zns, -					uint32_t tableid, afi_t afi) +struct route_table *zebra_ns_find_table(struct zebra_ns *zns, uint32_t tableid, +					afi_t afi)  {  	struct zebra_ns_table finder;  	struct zebra_ns_table *znst; @@ -275,7 +273,7 @@ static int logicalrouter_config_write(struct vty *vty)  	struct ns *ns;  	int write = 0; -	RB_FOREACH(ns, ns_head, &ns_tree) { +	RB_FOREACH (ns, ns_head, &ns_tree) {  		if (ns->ns_id == NS_DEFAULT || ns->name == NULL)  			continue;  		vty_out(vty, "logical-router %u netns %s\n", ns->ns_id, diff --git a/zebra/zebra_ptm.c b/zebra/zebra_ptm.c index 187c2594ad..f6775fa0b1 100644 --- a/zebra/zebra_ptm.c +++ b/zebra/zebra_ptm.c @@ -956,8 +956,7 @@ stream_failure:  }  /* BFD client register */ -int zebra_ptm_bfd_client_register(struct zserv *client, -				  u_short length) +int zebra_ptm_bfd_client_register(struct zserv *client, u_short length)  {  	struct stream *s;  	unsigned int pid; diff --git a/zebra/zebra_ptm.h b/zebra/zebra_ptm.h index 664221eff7..392853b599 100644 --- a/zebra/zebra_ptm.h +++ b/zebra/zebra_ptm.h @@ -67,8 +67,7 @@ int zebra_ptm_bfd_dst_register(struct zserv *client, u_short length,  int zebra_ptm_bfd_dst_deregister(struct zserv *client, u_short length,  				 struct zebra_vrf *zvrf);  void zebra_ptm_show_status(struct vty *vty, struct interface *ifp); -int zebra_ptm_bfd_client_register(struct zserv *client, -				  u_short length); +int zebra_ptm_bfd_client_register(struct zserv *client, u_short length);  void zebra_ptm_if_init(struct zebra_if *zebra_ifp);  void zebra_ptm_if_set_ptm_state(struct interface *ifp,  				struct zebra_if *zebra_ifp); diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 7f6c8aefa8..8946c9c6b5 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -267,8 +267,8 @@ struct nexthop *route_entry_nexthop_ipv4_ifindex_add(struct route_entry *re,  	/*Pending: need to think if null ifp here is ok during bootup?  	  There was a crash because ifp here was coming to be NULL */  	if (ifp) -		if (connected_is_unnumbered(ifp) || -		    CHECK_FLAG(re->flags, ZEBRA_FLAG_EVPN_ROUTE)) { +		if (connected_is_unnumbered(ifp) +		    || CHECK_FLAG(re->flags, ZEBRA_FLAG_EVPN_ROUTE)) {  			SET_FLAG(nexthop->flags, NEXTHOP_FLAG_ONLINK);  		} @@ -475,8 +475,8 @@ static int nexthop_active(afi_t afi, struct route_entry *re,  		 * host route.  		 */  		if (top && rn == top) -			if (((afi == AFI_IP) && (rn->p.prefixlen != 32)) || -			    ((afi == AFI_IP6) && (rn->p.prefixlen != 128))) +			if (((afi == AFI_IP) && (rn->p.prefixlen != 32)) +			    || ((afi == AFI_IP6) && (rn->p.prefixlen != 128)))  				return 0;  		/* Pick up selected route. */ @@ -487,10 +487,10 @@ static int nexthop_active(afi_t afi, struct route_entry *re,  			return 0;  		dest = rib_dest_from_rnode(rn); -		if (dest && dest->selected_fib && -		    !CHECK_FLAG(dest->selected_fib->status, -				ROUTE_ENTRY_REMOVED) && -		    dest->selected_fib->type != ZEBRA_ROUTE_TABLE) +		if (dest && dest->selected_fib +		    && !CHECK_FLAG(dest->selected_fib->status, +				   ROUTE_ENTRY_REMOVED) +		    && dest->selected_fib->type != ZEBRA_ROUTE_TABLE)  			match = dest->selected_fib;  		/* If there is no selected route or matched route is EGP, go up @@ -594,8 +594,9 @@ struct route_entry *rib_match(afi_t afi, safi_t safi, vrf_id_t vrf_id,  		route_unlock_node(rn);  		dest = rib_dest_from_rnode(rn); -		if (dest && dest->selected_fib && -		    !CHECK_FLAG(dest->selected_fib->status, ROUTE_ENTRY_REMOVED)) +		if (dest && dest->selected_fib +		    && !CHECK_FLAG(dest->selected_fib->status, +				   ROUTE_ENTRY_REMOVED))  			match = dest->selected_fib;  		/* If there is no selected route or matched route is EGP, go up @@ -722,8 +723,8 @@ struct route_entry *rib_lookup_ipv4(struct prefix_ipv4 *p, vrf_id_t vrf_id)  	route_unlock_node(rn);  	dest = rib_dest_from_rnode(rn); -	if (dest && dest->selected_fib && -	    !CHECK_FLAG(dest->selected_fib->status, ROUTE_ENTRY_REMOVED)) +	if (dest && dest->selected_fib +	    && !CHECK_FLAG(dest->selected_fib->status, ROUTE_ENTRY_REMOVED))  		match = dest->selected_fib;  	if (!match) @@ -779,8 +780,8 @@ int rib_lookup_ipv4_route(struct prefix_ipv4 *p, union sockunion *qgate,  	/* Find out if a "selected" RR for the discovered RIB entry exists ever.  	 */ -	if (dest && dest->selected_fib && -	    !CHECK_FLAG(dest->selected_fib->status, ROUTE_ENTRY_REMOVED)) +	if (dest && dest->selected_fib +	    && !CHECK_FLAG(dest->selected_fib->status, ROUTE_ENTRY_REMOVED))  		match = dest->selected_fib;  	/* None such found :( */ @@ -1091,13 +1092,13 @@ void rib_install_kernel(struct route_node *rn, struct route_entry *re,  		struct nexthop *prev;  		for (ALL_NEXTHOPS(re->nexthop, nexthop)) { -			UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_DUPLICATE); +			UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_DUPLICATE);  			for (ALL_NEXTHOPS(re->nexthop, prev)) {  				if (prev == nexthop)  					break; -				if (nexthop_same_firsthop (nexthop, prev)) -				{ -					SET_FLAG (nexthop->flags, NEXTHOP_FLAG_DUPLICATE); +				if (nexthop_same_firsthop(nexthop, prev)) { +					SET_FLAG(nexthop->flags, +						 NEXTHOP_FLAG_DUPLICATE);  					break;  				}  			} @@ -2111,8 +2112,8 @@ void rib_unlink(struct route_node *rn, struct route_entry *re)  	/* free RE and nexthops */  	if (re->type == ZEBRA_ROUTE_STATIC) -		zebra_deregister_rnh_static_nexthops(re->vrf_id, -						     re->nexthop, rn); +		zebra_deregister_rnh_static_nexthops(re->vrf_id, re->nexthop, +						     rn);  	nexthops_free(re->nexthop);  	XFREE(MTYPE_RE, re);  } @@ -2339,8 +2340,8 @@ int rib_add_multipath(afi_t afi, safi_t safi, struct prefix *p,  			continue;  		if (same->instance != re->instance)  			continue; -		if (same->type == ZEBRA_ROUTE_KERNEL && -		    same->metric != re->metric) +		if (same->type == ZEBRA_ROUTE_KERNEL +		    && same->metric != re->metric)  			continue;  		/*  		 * We should allow duplicate connected routes because of @@ -2436,8 +2437,7 @@ void rib_delete(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type,  			continue;  		if (re->instance != instance)  			continue; -		if (re->type == ZEBRA_ROUTE_KERNEL && -		    re->metric != metric) +		if (re->type == ZEBRA_ROUTE_KERNEL && re->metric != metric)  			continue;  		if (re->type == ZEBRA_ROUTE_CONNECT && (rtnh = re->nexthop)  		    && rtnh->type == NEXTHOP_TYPE_IFINDEX && nh) { @@ -2532,9 +2532,8 @@ void rib_delete(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type,  	}  	if (same) { -		if (fromkernel && -		    CHECK_FLAG(flags, ZEBRA_FLAG_SELFROUTE) && -		    !allow_delete) { +		if (fromkernel && CHECK_FLAG(flags, ZEBRA_FLAG_SELFROUTE) +		    && !allow_delete) {  			rib_install_kernel(rn, same, NULL);  			route_unlock_node(rn); @@ -2610,9 +2609,8 @@ static void rib_update_table(struct route_table *table,  		 * has already been queued  we don't  		 * need to queue it up again  		 */ -		if (rn->info -		    && CHECK_FLAG(rib_dest_from_rnode(rn)->flags, -				  RIB_ROUTE_ANY_QUEUED)) +		if (rn->info && CHECK_FLAG(rib_dest_from_rnode(rn)->flags, +					   RIB_ROUTE_ANY_QUEUED))  			continue;  		switch (event) {  		case RIB_UPDATE_IF_CHANGE: @@ -2629,10 +2627,10 @@ static void rib_update_table(struct route_table *table,  			RNODE_FOREACH_RE_SAFE (rn, re, next) {  				struct nexthop *nh; -				if (re->type != ZEBRA_ROUTE_SYSTEM && -				    re->type != ZEBRA_ROUTE_KERNEL && -				    re->type != ZEBRA_ROUTE_CONNECT && -				    re->type != ZEBRA_ROUTE_STATIC) +				if (re->type != ZEBRA_ROUTE_SYSTEM +				    && re->type != ZEBRA_ROUTE_KERNEL +				    && re->type != ZEBRA_ROUTE_CONNECT +				    && re->type != ZEBRA_ROUTE_STATIC)  					continue;  				if (re->type != ZEBRA_ROUTE_STATIC) { diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c index d960dbd937..1e9fe875e1 100644 --- a/zebra/zebra_rnh.c +++ b/zebra/zebra_rnh.c @@ -373,12 +373,10 @@ static int zebra_rnh_apply_nht_rmap(int family, struct route_node *prn,   * Determine appropriate route (RE entry) resolving a tracked BGP route   * for BGP route for import.   */ -static -struct route_entry *zebra_rnh_resolve_import_entry(vrf_id_t vrfid, -						   int family, -						   struct route_node *nrn, -						   struct rnh *rnh, -						   struct route_node **prn) +static struct route_entry * +zebra_rnh_resolve_import_entry(vrf_id_t vrfid, int family, +			       struct route_node *nrn, struct rnh *rnh, +			       struct route_node **prn)  {  	struct route_table *route_table;  	struct route_node *rn; @@ -397,15 +395,15 @@ struct route_entry *zebra_rnh_resolve_import_entry(vrf_id_t vrfid,  	/* Unlock route node - we don't need to lock when walking the tree. */  	route_unlock_node(rn); -	if (CHECK_FLAG(rnh->flags, ZEBRA_NHT_EXACT_MATCH) && -	     !prefix_same(&nrn->p, &rn->p)) +	if (CHECK_FLAG(rnh->flags, ZEBRA_NHT_EXACT_MATCH) +	    && !prefix_same(&nrn->p, &rn->p))  		return NULL;  	/* Identify appropriate route entry. */ -	RNODE_FOREACH_RE(rn, re) { -		if (!CHECK_FLAG(re->status, ROUTE_ENTRY_REMOVED) && -		    CHECK_FLAG(re->flags, ZEBRA_FLAG_SELECTED) && -		    (re->type != ZEBRA_ROUTE_BGP)) +	RNODE_FOREACH_RE (rn, re) { +		if (!CHECK_FLAG(re->status, ROUTE_ENTRY_REMOVED) +		    && CHECK_FLAG(re->flags, ZEBRA_FLAG_SELECTED) +		    && (re->type != ZEBRA_ROUTE_BGP))  			break;  	} @@ -628,11 +626,10 @@ static void zebra_rnh_process_static_routes(vrf_id_t vrfid, int family,   * Determine appropriate route (route entry) resolving a tracked   * nexthop.   */ -static struct route_entry *zebra_rnh_resolve_nexthop_entry(vrf_id_t vrfid, -						     int family, -						     struct route_node *nrn, -						     struct rnh *rnh, -						     struct route_node **prn) +static struct route_entry * +zebra_rnh_resolve_nexthop_entry(vrf_id_t vrfid, int family, +				struct route_node *nrn, struct rnh *rnh, +				struct route_node **prn)  {  	struct route_table *route_table;  	struct route_node *rn; @@ -658,12 +655,12 @@ static struct route_entry *zebra_rnh_resolve_nexthop_entry(vrf_id_t vrfid,  		/* Do not resolve over default route unless allowed &&  		 * match route to be exact if so specified  		 */ -		if (is_default_prefix(&rn->p) && -		    !rnh_resolve_via_default(rn->p.family)) +		if (is_default_prefix(&rn->p) +		    && !rnh_resolve_via_default(rn->p.family))  			return NULL;  		/* Identify appropriate route entry. */ -		RNODE_FOREACH_RE(rn, re) { +		RNODE_FOREACH_RE (rn, re) {  			if (CHECK_FLAG(re->status, ROUTE_ENTRY_REMOVED))  				continue;  			if (!CHECK_FLAG(re->flags, ZEBRA_FLAG_SELECTED)) @@ -676,11 +673,10 @@ static struct route_entry *zebra_rnh_resolve_nexthop_entry(vrf_id_t vrfid,  				if (re->type == ZEBRA_ROUTE_NHRP) {  					struct nexthop *nexthop; -					for (nexthop = re->nexthop; -					     nexthop; +					for (nexthop = re->nexthop; nexthop;  					     nexthop = nexthop->next)  						if (nexthop->type -						     == NEXTHOP_TYPE_IFINDEX) +						    == NEXTHOP_TYPE_IFINDEX)  							break;  					if (nexthop)  						break; @@ -779,8 +775,8 @@ static void zebra_rnh_evaluate_entry(vrf_id_t vrfid, int family, int force,  	/* Identify route entry (RE) resolving this tracked entry. */  	if (type == RNH_IMPORT_CHECK_TYPE) -		re = zebra_rnh_resolve_import_entry(vrfid, family, nrn, -						    rnh, &prn); +		re = zebra_rnh_resolve_import_entry(vrfid, family, nrn, rnh, +						    &prn);  	else  		re = zebra_rnh_resolve_nexthop_entry(vrfid, family, nrn, rnh,  						     &prn); @@ -820,8 +816,8 @@ static void zebra_rnh_clear_nhc_flag(vrf_id_t vrfid, int family,  	/* Identify route entry (RIB) resolving this tracked entry. */  	if (type == RNH_IMPORT_CHECK_TYPE) -		re = zebra_rnh_resolve_import_entry(vrfid, family, nrn, -						    rnh, &prn); +		re = zebra_rnh_resolve_import_entry(vrfid, family, nrn, rnh, +						    &prn);  	else  		re = zebra_rnh_resolve_nexthop_entry(vrfid, family, nrn, rnh,  						     &prn); diff --git a/zebra/zebra_rnh.h b/zebra/zebra_rnh.h index bd121ec83c..7af1dbeaf1 100644 --- a/zebra/zebra_rnh.h +++ b/zebra/zebra_rnh.h @@ -39,9 +39,9 @@ struct rnh {  	struct route_entry *state;  	struct prefix resolved_route;  	struct list *client_list; -	struct list * -		zebra_static_route_list; /* static routes dependent on this NH -					    */ +	struct list +		*zebra_static_route_list; /* static routes dependent on this NH +					     */  	struct list  		*zebra_pseudowire_list; /* pseudowires dependent on this NH */  	struct route_node *node; diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c index 882a03f844..64c38635fb 100644 --- a/zebra/zebra_routemap.c +++ b/zebra/zebra_routemap.c @@ -238,8 +238,8 @@ DEFUN (match_ipv6_address_prefix_len,         "Match prefix length of ipv6 address\n"         "Prefix length\n")  { -	return zebra_route_match_add(vty, "ipv6 address prefix-len", argv[4]->arg, -				     RMAP_EVENT_MATCH_ADDED); +	return zebra_route_match_add(vty, "ipv6 address prefix-len", +				     argv[4]->arg, RMAP_EVENT_MATCH_ADDED);  }  DEFUN (no_match_ipv6_address_prefix_len, diff --git a/zebra/zebra_static.c b/zebra/zebra_static.c index b42bd818af..b4c5b70da0 100644 --- a/zebra/zebra_static.c +++ b/zebra/zebra_static.c @@ -103,8 +103,8 @@ void static_install_route(afi_t afi, safi_t safi, struct prefix *p,  				re, si->ifindex, si->nh_vrf_id);  			break;  		case STATIC_BLACKHOLE: -			nexthop = route_entry_nexthop_blackhole_add( -				re, bh_type); +			nexthop = +				route_entry_nexthop_blackhole_add(re, bh_type);  			break;  		case STATIC_IPV6_GATEWAY:  			nexthop = route_entry_nexthop_ipv6_add( @@ -182,8 +182,8 @@ void static_install_route(afi_t afi, safi_t safi, struct prefix *p,  				re, si->ifindex, si->nh_vrf_id);  			break;  		case STATIC_BLACKHOLE: -			nexthop = route_entry_nexthop_blackhole_add( -				re, bh_type); +			nexthop = +				route_entry_nexthop_blackhole_add(re, bh_type);  			break;  		case STATIC_IPV6_GATEWAY:  			nexthop = route_entry_nexthop_ipv6_add( @@ -393,16 +393,14 @@ int static_add_route(afi_t afi, safi_t safi, u_char type, struct prefix *p,  	if (!stable)  		return -1; -	if (!gate -	    && (type == STATIC_IPV4_GATEWAY -		|| type == STATIC_IPV4_GATEWAY_IFNAME -		|| type == STATIC_IPV6_GATEWAY -		|| type == STATIC_IPV6_GATEWAY_IFNAME)) +	if (!gate && (type == STATIC_IPV4_GATEWAY +		      || type == STATIC_IPV4_GATEWAY_IFNAME +		      || type == STATIC_IPV6_GATEWAY +		      || type == STATIC_IPV6_GATEWAY_IFNAME))  		return -1;  	if (!ifname -	    && (type == STATIC_IFNAME -		|| type == STATIC_IPV4_GATEWAY_IFNAME +	    && (type == STATIC_IFNAME || type == STATIC_IPV4_GATEWAY_IFNAME  		|| type == STATIC_IPV6_GATEWAY_IFNAME))  		return -1; @@ -412,11 +410,12 @@ int static_add_route(afi_t afi, safi_t safi, u_char type, struct prefix *p,  	/* Do nothing if there is a same static route.  */  	for (si = rn->info; si; si = si->next) {  		if (type == si->type -		    && (!gate || ((afi == AFI_IP -				   && IPV4_ADDR_SAME(&gate->ipv4, &si->addr.ipv4)) -				  || (afi == AFI_IP6 -				      && IPV6_ADDR_SAME(gate, &si->addr.ipv6)))) -		    && (!strcmp (ifname ? ifname : "", si->ifname))) { +		    && (!gate +			|| ((afi == AFI_IP +			     && IPV4_ADDR_SAME(&gate->ipv4, &si->addr.ipv4)) +			    || (afi == AFI_IP6 +				&& IPV6_ADDR_SAME(gate, &si->addr.ipv6)))) +		    && (!strcmp(ifname ? ifname : "", si->ifname))) {  			if ((distance == si->distance) && (tag == si->tag)  			    && !memcmp(&si->snh_label, snh_label,  				       sizeof(struct static_nh_label)) @@ -531,10 +530,11 @@ int static_delete_route(afi_t afi, safi_t safi, u_char type, struct prefix *p,  	/* Find same static route is the tree */  	for (si = rn->info; si; si = si->next)  		if (type == si->type -		    && (!gate || ((afi == AFI_IP -				   && IPV4_ADDR_SAME(&gate->ipv4, &si->addr.ipv4)) -				  || (afi == AFI_IP6 -				      && IPV6_ADDR_SAME(gate, &si->addr.ipv6)))) +		    && (!gate +			|| ((afi == AFI_IP +			     && IPV4_ADDR_SAME(&gate->ipv4, &si->addr.ipv4)) +			    || (afi == AFI_IP6 +				&& IPV6_ADDR_SAME(gate, &si->addr.ipv6))))  		    && (!strcmp(ifname ? ifname : "", si->ifname))  		    && (!tag || (tag == si->tag))  		    && (!snh_label->num_labels @@ -569,8 +569,8 @@ int static_delete_route(afi_t afi, safi_t safi, u_char type, struct prefix *p,  	return 1;  } -static void static_ifindex_update_af(struct interface *ifp, bool up, -				     afi_t afi, safi_t safi) +static void static_ifindex_update_af(struct interface *ifp, bool up, afi_t afi, +				     safi_t safi)  {  	struct route_table *stable;  	struct zebra_vrf *zvrf = zebra_vrf_lookup_by_id(ifp->vrf_id); @@ -598,8 +598,7 @@ static void static_ifindex_update_af(struct interface *ifp, bool up,  			} else {  				if (si->ifindex != ifp->ifindex)  					continue; -				static_uninstall_route(afi, safi, p, src_p, -						       si); +				static_uninstall_route(afi, safi, p, src_p, si);  				si->ifindex = IFINDEX_INTERNAL;  			}  		} diff --git a/zebra/zebra_vrf.c b/zebra/zebra_vrf.c index bb15fd04f3..9e13f4ed6e 100644 --- a/zebra/zebra_vrf.c +++ b/zebra/zebra_vrf.c @@ -111,8 +111,8 @@ static int zebra_vrf_enable(struct vrf *vrf)  	assert(zvrf);  	if (IS_ZEBRA_DEBUG_EVENT) -		zlog_debug("VRF %s id %u is now active", -			   zvrf_name(zvrf), zvrf_id(zvrf)); +		zlog_debug("VRF %s id %u is now active", zvrf_name(zvrf), +			   zvrf_id(zvrf));  	if (vrf_is_backend_netns())  		zvrf->zns = zebra_ns_lookup((ns_id_t)vrf->vrf_id); @@ -182,8 +182,8 @@ static int zebra_vrf_disable(struct vrf *vrf)  	assert(zvrf);  	if (IS_ZEBRA_DEBUG_EVENT) -		zlog_debug("VRF %s id %u is now inactive", -			   zvrf_name(zvrf), zvrf_id(zvrf)); +		zlog_debug("VRF %s id %u is now inactive", zvrf_name(zvrf), +			   zvrf_id(zvrf));  	/* Uninstall any static routes configured for this VRF. */  	for (afi = AFI_IP; afi < AFI_MAX; afi++) @@ -221,7 +221,8 @@ static int zebra_vrf_disable(struct vrf *vrf)  	zebra_mpls_cleanup_tables(zvrf);  	zebra_pw_exit(zvrf); -	/* Remove link-local IPv4 addresses created for BGP unnumbered peering. */ +	/* Remove link-local IPv4 addresses created for BGP unnumbered peering. +	 */  	FOR_ALL_INTERFACES (vrf, ifp)  		if_nbr_ipv6ll_to_ipv4ll_neigh_del_all(ifp); @@ -231,8 +232,8 @@ static int zebra_vrf_disable(struct vrf *vrf)  		struct route_node *rnode;  		rib_dest_t *dest; -		for (ALL_LIST_ELEMENTS(zebrad.mq->subq[i], -				       lnode, nnode, rnode)) { +		for (ALL_LIST_ELEMENTS(zebrad.mq->subq[i], lnode, nnode, +				       rnode)) {  			dest = rib_dest_from_rnode(rnode);  			if (dest && rib_dest_vrf(dest) == zvrf) {  				route_unlock_node(rnode); @@ -273,8 +274,8 @@ static int zebra_vrf_delete(struct vrf *vrf)  	assert(zvrf);  	if (IS_ZEBRA_DEBUG_EVENT) -		zlog_debug("VRF %s id %u deleted", -			   zvrf_name(zvrf), zvrf_id(zvrf)); +		zlog_debug("VRF %s id %u deleted", zvrf_name(zvrf), +			   zvrf_id(zvrf));  	/* clean-up work queues */  	for (i = 0; i < MQ_SIZE; i++) { @@ -282,7 +283,8 @@ static int zebra_vrf_delete(struct vrf *vrf)  		struct route_node *rnode;  		rib_dest_t *dest; -		for (ALL_LIST_ELEMENTS(zebrad.mq->subq[i], lnode, nnode, rnode)) { +		for (ALL_LIST_ELEMENTS(zebrad.mq->subq[i], lnode, nnode, +				       rnode)) {  			dest = rib_dest_from_rnode(rnode);  			if (dest && rib_dest_vrf(dest) == zvrf) {  				route_unlock_node(rnode); @@ -560,10 +562,11 @@ static int vrf_config_write(struct vty *vty)  		if (vrf_is_user_cfged(vrf)) {  			vty_out(vty, "vrf %s\n", zvrf_name(zvrf));  			if (zvrf->l3vni) -				vty_out(vty, " vni %u%s\n", -					zvrf->l3vni, -					is_l3vni_for_prefix_routes_only(zvrf->l3vni) ? -					" prefix-routes-only" :""); +				vty_out(vty, " vni %u%s\n", zvrf->l3vni, +					is_l3vni_for_prefix_routes_only( +						zvrf->l3vni) +						? " prefix-routes-only" +						: "");  			zebra_ns_config_write(vty, (struct ns *)vrf->ns_ctxt);  			vty_out(vty, "!\n");  		} @@ -581,8 +584,8 @@ static int vrf_config_write(struct vty *vty)  /* Zebra VRF initialization. */  void zebra_vrf_init(void)  { -	vrf_init(zebra_vrf_new, zebra_vrf_enable, -		 zebra_vrf_disable, zebra_vrf_delete); +	vrf_init(zebra_vrf_new, zebra_vrf_enable, zebra_vrf_disable, +		 zebra_vrf_delete);  	vrf_cmd_init(vrf_config_write);  } diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 4824c09f3d..582ff3110b 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -69,25 +69,20 @@ static void vty_show_ip_route_summary_prefix(struct vty *vty,  /*   * special macro to allow us to get the correct zebra_vrf   */ -#define ZEBRA_DECLVAR_CONTEXT(A, B)			\ -	struct vrf *A = VTY_GET_CONTEXT(vrf);		\ -	struct zebra_vrf *B =				\ -		(vrf) ? vrf->info : NULL;		\ +#define ZEBRA_DECLVAR_CONTEXT(A, B)                                            \ +	struct vrf *A = VTY_GET_CONTEXT(vrf);                                  \ +	struct zebra_vrf *B = (vrf) ? vrf->info : NULL;  /* VNI range as per RFC 7432 */  #define CMD_VNI_RANGE "(1-16777215)"  /* General function for static route. */ -static int zebra_static_route_leak(struct vty *vty, -				   struct zebra_vrf *zvrf, -				   struct zebra_vrf *nh_zvrf, -				   afi_t afi, safi_t safi, -				   const char *negate, const char *dest_str, -				   const char *mask_str, const char *src_str, -				   const char *gate_str, const char *ifname, -				   const char *flag_str, const char *tag_str, -				   const char *distance_str, -				   const char *label_str) +static int zebra_static_route_leak( +	struct vty *vty, struct zebra_vrf *zvrf, struct zebra_vrf *nh_zvrf, +	afi_t afi, safi_t safi, const char *negate, const char *dest_str, +	const char *mask_str, const char *src_str, const char *gate_str, +	const char *ifname, const char *flag_str, const char *tag_str, +	const char *distance_str, const char *label_str)  {  	int ret;  	u_char distance; @@ -180,10 +175,11 @@ static int zebra_static_route_leak(struct vty *vty,  	/* Null0 static route.  */  	if (ifname != NULL) { -		if (strncasecmp(ifname, "Null0", strlen(ifname)) == 0 || -		    strncasecmp(ifname, "reject", strlen(ifname)) == 0 || -		    strncasecmp(ifname, "blackhole", strlen(ifname)) == 0) { -			vty_out(vty, "%% Nexthop interface cannot be Null0, reject or blackhole\n"); +		if (strncasecmp(ifname, "Null0", strlen(ifname)) == 0 +		    || strncasecmp(ifname, "reject", strlen(ifname)) == 0 +		    || strncasecmp(ifname, "blackhole", strlen(ifname)) == 0) { +			vty_out(vty, +				"%% Nexthop interface cannot be Null0, reject or blackhole\n");  			return CMD_WARNING_CONFIG_FAILED;  		}  	} @@ -249,12 +245,12 @@ static int zebra_static_route_leak(struct vty *vty,  }  static int zebra_static_route(struct vty *vty, afi_t afi, safi_t safi, -                             const char *negate, const char *dest_str, -                             const char *mask_str, const char *src_str, -                             const char *gate_str, const char *ifname, -                             const char *flag_str, const char *tag_str, -                             const char *distance_str, const char *vrf_name, -                             const char *label_str) +			      const char *negate, const char *dest_str, +			      const char *mask_str, const char *src_str, +			      const char *gate_str, const char *ifname, +			      const char *flag_str, const char *tag_str, +			      const char *distance_str, const char *vrf_name, +			      const char *label_str)  {  	struct zebra_vrf *zvrf;  	struct vrf *vrf; @@ -286,10 +282,9 @@ static int zebra_static_route(struct vty *vty, afi_t afi, safi_t safi,  		/* Mark as having FRR configuration */  		vrf_set_user_cfged(vrf);  	} -	return zebra_static_route_leak(vty, zvrf, zvrf, afi, safi, -				       negate, dest_str, mask_str, src_str, -				       gate_str, ifname, flag_str, tag_str, -				       distance_str, label_str); +	return zebra_static_route_leak( +		vty, zvrf, zvrf, afi, safi, negate, dest_str, mask_str, src_str, +		gate_str, ifname, flag_str, tag_str, distance_str, label_str);  } @@ -429,8 +424,8 @@ DEFPY(ip_route_blackhole,        MPLS_LABEL_HELPSTR)  {  	return zebra_static_route(vty, AFI_IP, SAFI_UNICAST, no, prefix, -				  mask_str, NULL, NULL, NULL, flag, -				  tag_str, distance_str, vrf, label); +				  mask_str, NULL, NULL, NULL, flag, tag_str, +				  distance_str, vrf, label);  }  DEFPY(ip_route_blackhole_vrf, @@ -464,10 +459,9 @@ DEFPY(ip_route_blackhole_vrf,  	 * valid.  Add an assert to make it happy  	 */  	assert(prefix); -	return zebra_static_route_leak(vty, zvrf, zvrf, -				       AFI_IP, SAFI_UNICAST, no, prefix, -				       mask_str, NULL, NULL, NULL, flag, -				       tag_str, distance_str, label); +	return zebra_static_route_leak(vty, zvrf, zvrf, AFI_IP, SAFI_UNICAST, +				       no, prefix, mask_str, NULL, NULL, NULL, +				       flag, tag_str, distance_str, label);  }  DEFPY(ip_route_address_interface, @@ -509,8 +503,7 @@ DEFPY(ip_route_address_interface,  	zvrf = zebra_vrf_lookup_by_name(vrf);  	if (!zvrf) { -		vty_out(vty, "%% vrf %s is not defined\n", -			vrf); +		vty_out(vty, "%% vrf %s is not defined\n", vrf);  		return CMD_WARNING_CONFIG_FAILED;  	} @@ -520,15 +513,13 @@ DEFPY(ip_route_address_interface,  		nh_zvrf = zvrf;  	if (!nh_zvrf) { -		vty_out(vty, "%% nexthop vrf %s is not defined\n", -			nexthop_vrf); +		vty_out(vty, "%% nexthop vrf %s is not defined\n", nexthop_vrf);  		return CMD_WARNING_CONFIG_FAILED;  	} -	return zebra_static_route_leak(vty, zvrf, nh_zvrf, -				       AFI_IP, SAFI_UNICAST, no, prefix, -				       mask_str, NULL, gate_str, ifname, flag, -				       tag_str, distance_str, label); +	return zebra_static_route_leak( +		vty, zvrf, nh_zvrf, AFI_IP, SAFI_UNICAST, no, prefix, mask_str, +		NULL, gate_str, ifname, flag, tag_str, distance_str, label);  }  DEFPY(ip_route_address_interface_vrf, @@ -573,15 +564,13 @@ DEFPY(ip_route_address_interface_vrf,  		nh_zvrf = zvrf;  	if (!nh_zvrf) { -		vty_out(vty, "%% nexthop vrf %s is not defined\n", -			nexthop_vrf); +		vty_out(vty, "%% nexthop vrf %s is not defined\n", nexthop_vrf);  		return CMD_WARNING_CONFIG_FAILED;  	} -	return zebra_static_route_leak(vty, zvrf, nh_zvrf, -				       AFI_IP, SAFI_UNICAST, no, prefix, -				       mask_str, NULL, gate_str, ifname, flag, -				       tag_str, distance_str, label); +	return zebra_static_route_leak( +		vty, zvrf, nh_zvrf, AFI_IP, SAFI_UNICAST, no, prefix, mask_str, +		NULL, gate_str, ifname, flag, tag_str, distance_str, label);  }  DEFPY(ip_route, @@ -621,8 +610,7 @@ DEFPY(ip_route,  	zvrf = zebra_vrf_lookup_by_name(vrf);  	if (!zvrf) { -		vty_out(vty, "%% vrf %s is not defined\n", -			vrf); +		vty_out(vty, "%% vrf %s is not defined\n", vrf);  		return CMD_WARNING_CONFIG_FAILED;  	} @@ -632,16 +620,14 @@ DEFPY(ip_route,  		nh_zvrf = zvrf;  	if (!nh_zvrf) { -		vty_out(vty, "%% nexthop vrf %s is not defined\n", -			nexthop_vrf); +		vty_out(vty, "%% nexthop vrf %s is not defined\n", nexthop_vrf);  		return CMD_WARNING_CONFIG_FAILED;  	} -	return zebra_static_route_leak(vty, zvrf, nh_zvrf, -				       AFI_IP, SAFI_UNICAST, no, prefix, -				       mask_str, NULL, gate_str, ifname, flag, -				       tag_str, distance_str, label); +	return zebra_static_route_leak( +		vty, zvrf, nh_zvrf, AFI_IP, SAFI_UNICAST, no, prefix, mask_str, +		NULL, gate_str, ifname, flag, tag_str, distance_str, label);  }  DEFPY(ip_route_vrf, @@ -684,15 +670,13 @@ DEFPY(ip_route_vrf,  		nh_zvrf = zvrf;  	if (!nh_zvrf) { -		vty_out(vty, "%% nexthop vrf %s is not defined\n", -			nexthop_vrf); +		vty_out(vty, "%% nexthop vrf %s is not defined\n", nexthop_vrf);  		return CMD_WARNING_CONFIG_FAILED;  	} -	return zebra_static_route_leak(vty, zvrf, nh_zvrf, -				       AFI_IP, SAFI_UNICAST, no, prefix, -				       mask_str, NULL, gate_str, ifname, flag, -				       tag_str, distance_str, label); +	return zebra_static_route_leak( +		vty, zvrf, nh_zvrf, AFI_IP, SAFI_UNICAST, no, prefix, mask_str, +		NULL, gate_str, ifname, flag, tag_str, distance_str, label);  }  /* New RIB.  Detailed information for IPv4 route. */ @@ -748,11 +732,11 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,  		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), @@ -764,8 +748,10 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,  			vty_out(vty, "  %c%s",  				CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB) -					? CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_DUPLICATE) -						? ' ' : '*' +					? CHECK_FLAG(nexthop->flags, +						     NEXTHOP_FLAG_DUPLICATE) +						  ? ' ' +						  : '*'  					: ' ',  				nexthop->rparent ? "  " : ""); @@ -924,11 +910,11 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,  		}  		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), @@ -1028,8 +1014,7 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,  				struct vrf *vrf =  					vrf_lookup_by_id(nexthop->vrf_id); -				json_object_string_add(json_nexthop, -						       "vrf", +				json_object_string_add(json_nexthop, "vrf",  						       vrf->name);  			}  			if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_DUPLICATE)) @@ -1126,8 +1111,10 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,  		} else {  			vty_out(vty, "  %c%*c",  				CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB) -					? CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_DUPLICATE) -						? ' ' : '*' +					? CHECK_FLAG(nexthop->flags, +						     NEXTHOP_FLAG_DUPLICATE) +						  ? ' ' +						  : '*'  					: ' ',  				len - 3 + (2 * nexthop_level(nexthop)), ' ');  		} @@ -1259,8 +1246,7 @@ static void do_show_route_helper(struct vty *vty, struct zebra_vrf *zvrf,  		dest = rib_dest_from_rnode(rn);  		RNODE_FOREACH_RE (rn, re) { -			if (use_fib -			    && re != dest->selected_fib) +			if (use_fib && re != dest->selected_fib)  				continue;  			if (tag && re->tag != tag) @@ -1663,7 +1649,7 @@ DEFPY (show_route_detail,  		struct vrf *vrf;  		struct zebra_vrf *zvrf; -		RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name) { +		RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {  			if ((zvrf = vrf->info) == NULL  			    || (table = zvrf->table[afi][SAFI_UNICAST]) == NULL)  				continue; @@ -1737,7 +1723,7 @@ DEFPY (show_route_summary,  		struct vrf *vrf;  		struct zebra_vrf *zvrf; -		RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name) { +		RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {  			if ((zvrf = vrf->info) == NULL  			    || (table = zvrf->table[afi][SAFI_UNICAST]) == NULL)  				continue; @@ -1905,8 +1891,8 @@ static void vty_show_ip_route_summary_prefix(struct vty *vty,  }  /* Write static route configuration. */ -int static_config(struct vty *vty, struct zebra_vrf *zvrf, -		  afi_t afi, safi_t safi, const char *cmd) +int static_config(struct vty *vty, struct zebra_vrf *zvrf, afi_t afi, +		  safi_t safi, const char *cmd)  {  	char spacing[100];  	struct route_node *rn; @@ -1918,8 +1904,7 @@ int static_config(struct vty *vty, struct zebra_vrf *zvrf,  	if ((stable = zvrf->stable[afi][safi]) == NULL)  		return write; -	sprintf(spacing, "%s%s", -		(zvrf->vrf->vrf_id == VRF_DEFAULT) ? "" : " ", +	sprintf(spacing, "%s%s", (zvrf->vrf->vrf_id == VRF_DEFAULT) ? "" : " ",  		cmd);  	for (rn = route_top(stable); rn; rn = srcdest_route_next(rn)) @@ -1929,13 +1914,11 @@ int static_config(struct vty *vty, struct zebra_vrf *zvrf,  			switch (si->type) {  			case STATIC_IPV4_GATEWAY: -				vty_out(vty, " %s", -					inet_ntoa(si->addr.ipv4)); +				vty_out(vty, " %s", inet_ntoa(si->addr.ipv4));  				break;  			case STATIC_IPV6_GATEWAY:  				vty_out(vty, " %s", -					inet_ntop(AF_INET6, -						  &si->addr.ipv6, buf, +					inet_ntop(AF_INET6, &si->addr.ipv6, buf,  						  sizeof buf));  				break;  			case STATIC_IFNAME: @@ -1956,26 +1939,22 @@ int static_config(struct vty *vty, struct zebra_vrf *zvrf,  				break;  			case STATIC_IPV4_GATEWAY_IFNAME:  				vty_out(vty, " %s %s", -					inet_ntop(AF_INET, -						  &si->addr.ipv4, buf, +					inet_ntop(AF_INET, &si->addr.ipv4, buf,  						  sizeof buf),  					si->ifname);  				break;  			case STATIC_IPV6_GATEWAY_IFNAME:  				vty_out(vty, " %s %s", -					inet_ntop(AF_INET6, -						  &si->addr.ipv6, buf, +					inet_ntop(AF_INET6, &si->addr.ipv6, buf,  						  sizeof buf),  					si->ifname);  				break;  			}  			if (si->tag) -				vty_out(vty, " tag %" ROUTE_TAG_PRI, -					si->tag); +				vty_out(vty, " tag %" ROUTE_TAG_PRI, si->tag); -			if (si->distance -			    != ZEBRA_STATIC_DISTANCE_DEFAULT) +			if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)  				vty_out(vty, " %d", si->distance);  			if (si->nh_vrf_id != si->vrf_id) { @@ -1990,8 +1969,8 @@ int static_config(struct vty *vty, struct zebra_vrf *zvrf,  			if (si->snh_label.num_labels)  				vty_out(vty, " label %s",  					mpls_label2str(si->snh_label.num_labels, -						       si->snh_label.label, -						       buf, sizeof buf, 0)); +						       si->snh_label.label, buf, +						       sizeof buf, 0));  			vty_out(vty, "\n"); @@ -2026,8 +2005,8 @@ DEFPY(ipv6_route_blackhole,        MPLS_LABEL_HELPSTR)  {  	return zebra_static_route(vty, AFI_IP6, SAFI_UNICAST, no, prefix_str, -				  NULL, from_str, NULL, NULL, flag, -				  tag_str, distance_str, vrf, label); +				  NULL, from_str, NULL, NULL, flag, tag_str, +				  distance_str, vrf, label);  }  DEFPY(ipv6_route_blackhole_vrf, @@ -2062,10 +2041,9 @@ DEFPY(ipv6_route_blackhole_vrf,  	 * valid.  Add an assert to make it happy  	 */  	assert(prefix); -	return zebra_static_route_leak(vty, zvrf, zvrf, -				       AFI_IP6, SAFI_UNICAST, no, prefix_str, -				       NULL, from_str, NULL, NULL, flag, -				       tag_str, distance_str, label); +	return zebra_static_route_leak( +		vty, zvrf, zvrf, AFI_IP6, SAFI_UNICAST, no, prefix_str, NULL, +		from_str, NULL, NULL, flag, tag_str, distance_str, label);  }  DEFPY(ipv6_route_address_interface, @@ -2100,8 +2078,7 @@ DEFPY(ipv6_route_address_interface,  	zvrf = zebra_vrf_lookup_by_name(vrf);  	if (!zvrf) { -		vty_out(vty, "%% vrf %s is not defined\n", -			vrf); +		vty_out(vty, "%% vrf %s is not defined\n", vrf);  		return CMD_WARNING_CONFIG_FAILED;  	} @@ -2111,15 +2088,13 @@ DEFPY(ipv6_route_address_interface,  		nh_zvrf = zvrf;  	if (!nh_zvrf) { -		vty_out(vty, "%% nexthop vrf %s is not defined\n", -			nexthop_vrf); +		vty_out(vty, "%% nexthop vrf %s is not defined\n", nexthop_vrf);  		return CMD_WARNING_CONFIG_FAILED;  	} -	return zebra_static_route_leak(vty, zvrf, nh_zvrf, -				       AFI_IP6, SAFI_UNICAST, no, prefix_str, -				       NULL, from_str, gate_str, ifname, NULL, -				       tag_str, distance_str, label); +	return zebra_static_route_leak( +		vty, zvrf, nh_zvrf, AFI_IP6, SAFI_UNICAST, no, prefix_str, NULL, +		from_str, gate_str, ifname, NULL, tag_str, distance_str, label);  }  DEFPY(ipv6_route_address_interface_vrf, @@ -2157,15 +2132,13 @@ DEFPY(ipv6_route_address_interface_vrf,  		nh_zvrf = zvrf;  	if (!nh_zvrf) { -		vty_out(vty, "%% nexthop vrf %s is not defined\n", -			nexthop_vrf); +		vty_out(vty, "%% nexthop vrf %s is not defined\n", nexthop_vrf);  		return CMD_WARNING_CONFIG_FAILED;  	} -	return zebra_static_route_leak(vty, zvrf, nh_zvrf, -				       AFI_IP6, SAFI_UNICAST, no, prefix_str, -				       NULL, from_str, gate_str, ifname, NULL, -				       tag_str, distance_str, label); +	return zebra_static_route_leak( +		vty, zvrf, nh_zvrf, AFI_IP6, SAFI_UNICAST, no, prefix_str, NULL, +		from_str, gate_str, ifname, NULL, tag_str, distance_str, label);  }  DEFPY(ipv6_route, @@ -2199,8 +2172,7 @@ DEFPY(ipv6_route,  	zvrf = zebra_vrf_lookup_by_name(vrf);  	if (!zvrf) { -		vty_out(vty, "%% vrf %s is not defined\n", -			vrf); +		vty_out(vty, "%% vrf %s is not defined\n", vrf);  		return CMD_WARNING_CONFIG_FAILED;  	} @@ -2210,15 +2182,13 @@ DEFPY(ipv6_route,  		nh_zvrf = zvrf;  	if (!nh_zvrf) { -		vty_out(vty, "%% nexthop vrf %s is not defined\n", -			nexthop_vrf); +		vty_out(vty, "%% nexthop vrf %s is not defined\n", nexthop_vrf);  		return CMD_WARNING_CONFIG_FAILED;  	} -	return zebra_static_route_leak(vty, zvrf, nh_zvrf, -				       AFI_IP6, SAFI_UNICAST, no, prefix_str, -				       NULL, from_str, gate_str, ifname, NULL, -				       tag_str, distance_str, label); +	return zebra_static_route_leak( +		vty, zvrf, nh_zvrf, AFI_IP6, SAFI_UNICAST, no, prefix_str, NULL, +		from_str, gate_str, ifname, NULL, tag_str, distance_str, label);  }  DEFPY(ipv6_route_vrf, @@ -2255,15 +2225,13 @@ DEFPY(ipv6_route_vrf,  		nh_zvrf = zvrf;  	if (!nh_zvrf) { -		vty_out(vty, "%% nexthop vrf %s is not defined\n", -			nexthop_vrf); +		vty_out(vty, "%% nexthop vrf %s is not defined\n", nexthop_vrf);  		return CMD_WARNING_CONFIG_FAILED;  	} -	return zebra_static_route_leak(vty, zvrf, nh_zvrf, -				       AFI_IP6, SAFI_UNICAST, no, prefix_str, -				       NULL, from_str, gate_str, ifname, NULL, -				       tag_str, distance_str, label); +	return zebra_static_route_leak( +		vty, zvrf, nh_zvrf, AFI_IP6, SAFI_UNICAST, no, prefix_str, NULL, +		from_str, gate_str, ifname, NULL, tag_str, distance_str, label);  }  /* @@ -2374,12 +2342,11 @@ DEFUN (show_vrf,  			continue;  		vty_out(vty, "vrf %s ", zvrf_name(zvrf)); -		if (zvrf_id(zvrf) == VRF_UNKNOWN -		    || !zvrf_is_active(zvrf)) +		if (zvrf_id(zvrf) == VRF_UNKNOWN || !zvrf_is_active(zvrf))  			vty_out(vty, "inactive");  		else if (zvrf_ns_name(zvrf)) -			vty_out(vty, "id %u netns %s", -				zvrf_id(zvrf), zvrf_ns_name(zvrf)); +			vty_out(vty, "id %u netns %s", zvrf_id(zvrf), +				zvrf_ns_name(zvrf));  		else  			vty_out(vty, "id %u table %u", zvrf_id(zvrf),  				zvrf->table_id); @@ -2528,10 +2495,10 @@ DEFUN (show_vrf_vni,  	}  	if (!uj) -		vty_out(vty, "%-37s %-10s %-20s %-20s %-5s %-18s\n", -			"VRF", "VNI", "VxLAN IF", "L3-SVI", "State", "Rmac"); +		vty_out(vty, "%-37s %-10s %-20s %-20s %-5s %-18s\n", "VRF", +			"VNI", "VxLAN IF", "L3-SVI", "State", "Rmac"); -	RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name) { +	RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {  		zvrf = vrf->info;  		if (!zvrf)  			continue; @@ -3029,10 +2996,10 @@ DEFUN_HIDDEN (zebra_workqueue_timer,  	      "Work Queue\n"  	      "Time in milliseconds\n")  { -       uint32_t timer = strtoul(argv[2]->arg, NULL, 10); -       zebrad.ribq->spec.hold = timer; +	uint32_t timer = strtoul(argv[2]->arg, NULL, 10); +	zebrad.ribq->spec.hold = timer; -       return CMD_SUCCESS; +	return CMD_SUCCESS;  }  DEFUN_HIDDEN (no_zebra_workqueue_timer, @@ -3043,9 +3010,9 @@ DEFUN_HIDDEN (no_zebra_workqueue_timer,  	      "Work Queue\n"  	      "Time in milliseconds\n")  { -       zebrad.ribq->spec.hold = ZEBRA_RIB_PROCESS_HOLD_TIME; +	zebrad.ribq->spec.hold = ZEBRA_RIB_PROCESS_HOLD_TIME; -       return CMD_SUCCESS; +	return CMD_SUCCESS;  }  DEFUN (no_ip_zebra_import_table, @@ -3097,8 +3064,8 @@ static int config_write_protocol(struct vty *vty)  		vty_out(vty, "zebra work-queue %u\n", zebrad.ribq->spec.hold);  	if (zebrad.packets_to_process != ZEBRA_ZAPI_PACKETS_TO_PROCESS) -		vty_out(vty, -			"zebra zapi-packets %u\n", zebrad.packets_to_process); +		vty_out(vty, "zebra zapi-packets %u\n", +			zebrad.packets_to_process);  	enum multicast_mode ipv4_multicast_mode = multicast_mode_ipv4_get(); @@ -3168,7 +3135,7 @@ DEFUN (show_zebra,  	vty_out(vty,  		"VRF                         Installs   Removals    Updates   Installs   Removals\n"); -	RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name) { +	RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {  		struct zebra_vrf *zvrf = vrf->info;  		vty_out(vty, "%-25s %10" PRIu64 " %10" PRIu64 " %10" PRIu64 @@ -3442,5 +3409,4 @@ void zebra_vty_init(void)  	install_element(CONFIG_NODE, &no_default_vrf_vni_mapping_cmd);  	install_element(VRF_NODE, &vrf_vni_mapping_cmd);  	install_element(VRF_NODE, &no_vrf_vni_mapping_cmd); -  } diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index e07dc6059f..d3ede66fb0 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -58,9 +58,8 @@ DEFINE_MTYPE_STATIC(ZEBRA, NEIGH, "VNI Neighbor");  /* static function declarations */ -static int ip_prefix_send_to_client(vrf_id_t vrf_id, -					     struct prefix *p, -					     uint16_t cmd); +static int ip_prefix_send_to_client(vrf_id_t vrf_id, struct prefix *p, +				    uint16_t cmd);  static void zvni_print_neigh(zebra_neigh_t *n, void *ctxt, json_object *json);  static void zvni_print_neigh_hash(struct hash_backet *backet, void *ctxt);  static void zvni_print_neigh_hash_all_vni(struct hash_backet *backet, @@ -75,8 +74,7 @@ static void zvni_print_mac_hash_all_vni(struct hash_backet *backet, void *ctxt);  static void zvni_print(zebra_vni_t *zvni, void **ctxt);  static void zvni_print_hash(struct hash_backet *backet, void *ctxt[]); -static int zvni_macip_send_msg_to_client(vni_t vni, -					 struct ethaddr *macaddr, +static int zvni_macip_send_msg_to_client(vni_t vni, struct ethaddr *macaddr,  					 struct ipaddr *ip, u_char flags,  					 u_int16_t cmd);  static unsigned int neigh_hash_keymake(void *p); @@ -88,21 +86,18 @@ static int zvni_neigh_del(zebra_vni_t *zvni, zebra_neigh_t *n);  static int zvni_neigh_del_hash_entry(struct hash_backet *backet, void *arg);  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, u_int32_t flags); +static void zvni_neigh_del_all(zebra_vni_t *zvni, int uninstall, int upd_client, +			       u_int32_t flags);  static zebra_neigh_t *zvni_neigh_lookup(zebra_vni_t *zvni, struct ipaddr *ip); -static int zvni_neigh_send_add_to_client(vni_t vni, -					 struct ipaddr *ip, +static int zvni_neigh_send_add_to_client(vni_t vni, struct ipaddr *ip,  					 struct ethaddr *macaddr, u_char flags); -static int zvni_neigh_send_del_to_client(vni_t vni, -					 struct ipaddr *ip, +static int zvni_neigh_send_del_to_client(vni_t vni, struct ipaddr *ip,  					 struct ethaddr *macaddr, u_char flags);  static int zvni_neigh_install(zebra_vni_t *zvni, zebra_neigh_t *n);  static int zvni_neigh_uninstall(zebra_vni_t *zvni, zebra_neigh_t *n);  static zebra_vni_t *zvni_from_svi(struct interface *ifp, -				 struct interface *br_if); -static struct interface *zvni_map_to_svi(vlanid_t vid, -					 struct interface *br_if); +				  struct interface *br_if); +static struct interface *zvni_map_to_svi(vlanid_t vid, struct interface *br_if);  /* l3-vni next-hop neigh related APIs */  static zebra_neigh_t *zl3vni_nh_lookup(zebra_l3vni_t *zl3vni, @@ -124,8 +119,7 @@ static zebra_mac_t *zl3vni_rmac_add(zebra_l3vni_t *zl3vni,  				    struct ethaddr *rmac);  static int zl3vni_rmac_del(zebra_l3vni_t *zl3vni, zebra_mac_t *zrmac);  static int zl3vni_rmac_install(zebra_l3vni_t *zl3vni, zebra_mac_t *zrmac); -static int zl3vni_rmac_uninstall(zebra_l3vni_t *zl3vni, -				 zebra_mac_t *zrmac); +static int zl3vni_rmac_uninstall(zebra_l3vni_t *zl3vni, zebra_mac_t *zrmac);  /* l3-vni related APIs*/  static zebra_l3vni_t *zl3vni_lookup(vni_t vni); @@ -146,13 +140,13 @@ static int zvni_mac_del(zebra_vni_t *zvni, zebra_mac_t *mac);  static int zvni_mac_del_hash_entry(struct hash_backet *backet, void *arg);  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, u_int32_t flags); +static void zvni_mac_del_all(zebra_vni_t *zvni, int uninstall, int upd_client, +			     u_int32_t flags);  static zebra_mac_t *zvni_mac_lookup(zebra_vni_t *zvni, struct ethaddr *macaddr); -static int zvni_mac_send_add_to_client(vni_t vni, -				       struct ethaddr *macaddr, u_char flags); -static int zvni_mac_send_del_to_client(vni_t vni, -				       struct ethaddr *macaddr, u_char flags); +static int zvni_mac_send_add_to_client(vni_t vni, struct ethaddr *macaddr, +				       u_char flags); +static int zvni_mac_send_del_to_client(vni_t vni, struct ethaddr *macaddr, +				       u_char flags);  static zebra_vni_t *zvni_map_vlan(struct interface *ifp,  				  struct interface *br_if, vlanid_t vid);  static int zvni_mac_install(zebra_vni_t *zvni, zebra_mac_t *mac); @@ -434,8 +428,7 @@ static void zvni_print_neigh_hash_all_vni(struct hash_backet *backet,  }  /* print a specific next hop for an l3vni */ -static void zl3vni_print_nh(zebra_neigh_t *n, -			    struct vty *vty, +static void zl3vni_print_nh(zebra_neigh_t *n, struct vty *vty,  			    json_object *json)  {  	char buf1[ETHER_ADDR_STRLEN]; @@ -448,7 +441,7 @@ static void zl3vni_print_nh(zebra_neigh_t *n,  		vty_out(vty, "Ip: %s\n",  			ipaddr2str(&n->ip, buf2, sizeof(buf2)));  		vty_out(vty, "  RMAC: %s\n", -		       prefix_mac2str(&n->emac, buf1, sizeof(buf1))); +			prefix_mac2str(&n->emac, buf1, sizeof(buf1)));  		vty_out(vty, "  Refcount: %d\n", listcount(n->host_list));  		vty_out(vty, "  Prefixes:\n");  		for (ALL_LIST_ELEMENTS_RO(n->host_list, node, p)) @@ -456,25 +449,22 @@ static void zl3vni_print_nh(zebra_neigh_t *n,  				prefix2str(p, buf2, sizeof(buf2)));  	} else {  		json_hosts = json_object_new_array(); -		json_object_string_add(json, "ip", -				       ipaddr2str(&(n->ip), buf2, -						  sizeof(buf2))); -		json_object_string_add(json, "routerMac", -				       prefix_mac2str(&n->emac, buf2, -						      sizeof(buf2))); +		json_object_string_add( +			json, "ip", ipaddr2str(&(n->ip), buf2, sizeof(buf2))); +		json_object_string_add( +			json, "routerMac", +			prefix_mac2str(&n->emac, buf2, sizeof(buf2)));  		json_object_int_add(json, "refCount", listcount(n->host_list));  		for (ALL_LIST_ELEMENTS_RO(n->host_list, node, p))  			json_object_array_add(json_hosts, -					      json_object_new_string( -							prefix2str(p, buf2, -								sizeof(buf2)))); +					      json_object_new_string(prefix2str( +						      p, buf2, sizeof(buf2))));  		json_object_object_add(json, "prefixList", json_hosts);  	}  }  /* Print a specific RMAC entry */ -static void zl3vni_print_rmac(zebra_mac_t *zrmac, -			      struct vty *vty, +static void zl3vni_print_rmac(zebra_mac_t *zrmac, struct vty *vty,  			      json_object *json)  {  	char buf1[ETHER_ADDR_STRLEN]; @@ -495,19 +485,17 @@ static void zl3vni_print_rmac(zebra_mac_t *zrmac,  				prefix2str(p, buf2, sizeof(buf2)));  	} else {  		json_hosts = json_object_new_array(); -		json_object_string_add(json, "routerMac", -				       prefix_mac2str(&zrmac->macaddr, -						      buf1, -						      sizeof(buf1))); +		json_object_string_add( +			json, "routerMac", +			prefix_mac2str(&zrmac->macaddr, buf1, sizeof(buf1)));  		json_object_string_add(json, "vtepIp",  				       inet_ntoa(zrmac->fwd_info.r_vtep_ip));  		json_object_int_add(json, "refCount",  				    listcount(zrmac->host_list));  		for (ALL_LIST_ELEMENTS_RO(zrmac->host_list, node, p))  			json_object_array_add(json_hosts, -					      json_object_new_string( -							prefix2str(p, buf2, -								sizeof(buf2)))); +					      json_object_new_string(prefix2str( +						      p, buf2, sizeof(buf2))));  		json_object_object_add(json, "prefixList", json_hosts);  	}  } @@ -736,8 +724,7 @@ static void zvni_print_mac_hash_all_vni(struct hash_backet *backet, void *ctxt)  	}  } -static void zl3vni_print_nh_hash(struct hash_backet *backet, -				 void *ctx) +static void zl3vni_print_nh_hash(struct hash_backet *backet, void *ctx)  {  	struct nh_walk_ctx *wctx = NULL;  	struct vty *vty = NULL; @@ -763,9 +750,9 @@ static void zl3vni_print_nh_hash(struct hash_backet *backet,  	} else {  		json_object_string_add(json_nh, "nexthopIp",  				       ipaddr2str(&n->ip, buf2, sizeof(buf2))); -		json_object_string_add(json_nh, "routerMac", -				       prefix_mac2str(&n->emac, buf1, -						      sizeof(buf1))); +		json_object_string_add( +			json_nh, "routerMac", +			prefix_mac2str(&n->emac, buf1, sizeof(buf1)));  		json_object_object_add(json_vni,  				       ipaddr2str(&(n->ip), buf2, sizeof(buf2)),  				       json_nh); @@ -803,8 +790,7 @@ static void zl3vni_print_nh_hash_all_vni(struct hash_backet *backet,  	}  	if (json == NULL) { -		vty_out(vty, "\nVNI %u #Next-Hops %u\n\n", -			zl3vni->vni, num_nh); +		vty_out(vty, "\nVNI %u #Next-Hops %u\n\n", zl3vni->vni, num_nh);  		vty_out(vty, "%-15s %-17s\n", "IP", "RMAC");  	} else  		json_object_int_add(json_vni, "numNextHops", num_nh); @@ -848,8 +834,7 @@ static void zl3vni_print_rmac_hash_all_vni(struct hash_backet *backet,  	}  	if (json == NULL) { -		vty_out(vty, "\nVNI %u #RMACs %u\n\n", -			zl3vni->vni, num_rmacs); +		vty_out(vty, "\nVNI %u #RMACs %u\n\n", zl3vni->vni, num_rmacs);  		vty_out(vty, "%-17s %-21s\n", "RMAC", "Remote VTEP");  	} else  		json_object_int_add(json_vni, "numRmacs", num_rmacs); @@ -866,8 +851,7 @@ static void zl3vni_print_rmac_hash_all_vni(struct hash_backet *backet,  		json_object_object_add(json, vni_str, json_vni);  } -static void zl3vni_print_rmac_hash(struct hash_backet *backet, -				   void *ctx) +static void zl3vni_print_rmac_hash(struct hash_backet *backet, void *ctx)  {  	zebra_mac_t *zrmac = NULL;  	struct rmac_walk_ctx *wctx = NULL; @@ -888,17 +872,16 @@ static void zl3vni_print_rmac_hash(struct hash_backet *backet,  	if (!json) {  		vty_out(vty, "%-17s %-21s\n",  			prefix_mac2str(&zrmac->macaddr, buf, sizeof(buf)), -					inet_ntoa(zrmac->fwd_info.r_vtep_ip)); +			inet_ntoa(zrmac->fwd_info.r_vtep_ip));  	} else { -		json_object_string_add(json_rmac, "routerMac", -				       prefix_mac2str(&zrmac->macaddr, buf, -						      sizeof(buf))); +		json_object_string_add( +			json_rmac, "routerMac", +			prefix_mac2str(&zrmac->macaddr, buf, sizeof(buf)));  		json_object_string_add(json_rmac, "vtepIp",  				       inet_ntoa(zrmac->fwd_info.r_vtep_ip)); -		json_object_object_add(json, -				       prefix_mac2str(&zrmac->macaddr, buf, -						      sizeof(buf)), -				       json_rmac); +		json_object_object_add( +			json, prefix_mac2str(&zrmac->macaddr, buf, sizeof(buf)), +			json_rmac);  	}  } @@ -918,19 +901,17 @@ static void zl3vni_print(zebra_l3vni_t *zl3vni, void **ctx)  	if (!json) {  		vty_out(vty, "VNI: %u\n", zl3vni->vni);  		vty_out(vty, "  Type: %s\n", "L3"); -		vty_out(vty, "  Tenant VRF: %s\n", -			zl3vni_vrf_name(zl3vni)); +		vty_out(vty, "  Tenant VRF: %s\n", zl3vni_vrf_name(zl3vni));  		vty_out(vty, "  Local Vtep Ip: %s\n",  			inet_ntoa(zl3vni->local_vtep_ip));  		vty_out(vty, "  Vxlan-Intf: %s\n",  			zl3vni_vxlan_if_name(zl3vni)); -		vty_out(vty, "  SVI-If: %s\n", -			zl3vni_svi_if_name(zl3vni)); -		vty_out(vty, "  State: %s\n", -			zl3vni_state2str(zl3vni)); +		vty_out(vty, "  SVI-If: %s\n", zl3vni_svi_if_name(zl3vni)); +		vty_out(vty, "  State: %s\n", zl3vni_state2str(zl3vni));  		vty_out(vty, "  VNI Filter: %s\n", -			CHECK_FLAG(zl3vni->filter, PREFIX_ROUTES_ONLY) ? -				"prefix-routes-only" : "none"); +			CHECK_FLAG(zl3vni->filter, PREFIX_ROUTES_ONLY) +				? "prefix-routes-only" +				: "none");  		vty_out(vty, "  Router MAC: %s\n",  			zl3vni_rmac2str(zl3vni, buf, sizeof(buf)));  		vty_out(vty, "  L2 VNIs: "); @@ -947,17 +928,16 @@ static void zl3vni_print(zebra_l3vni_t *zl3vni, void **ctx)  				       zl3vni_vxlan_if_name(zl3vni));  		json_object_string_add(json, "sviIntf",  				       zl3vni_svi_if_name(zl3vni)); -		json_object_string_add(json, "state", -				       zl3vni_state2str(zl3vni)); -		json_object_string_add(json, "vrf", -				       zl3vni_vrf_name(zl3vni)); -		json_object_string_add(json, "routerMac", -				       zl3vni_rmac2str(zl3vni, buf, -						       sizeof(buf))); -		json_object_string_add(json, "vniFilter", -				       CHECK_FLAG(zl3vni->filter, -						  PREFIX_ROUTES_ONLY) ? -						"prefix-routes-only" : "none"); +		json_object_string_add(json, "state", zl3vni_state2str(zl3vni)); +		json_object_string_add(json, "vrf", zl3vni_vrf_name(zl3vni)); +		json_object_string_add( +			json, "routerMac", +			zl3vni_rmac2str(zl3vni, buf, sizeof(buf))); +		json_object_string_add( +			json, "vniFilter", +			CHECK_FLAG(zl3vni->filter, PREFIX_ROUTES_ONLY) +				? "prefix-routes-only" +				: "none");  		for (ALL_LIST_ELEMENTS(zl3vni->l2vnis, node, nnode, zvni)) {  			json_object_array_add(json_vni_list,  					      json_object_new_int(zvni->vni)); @@ -1001,10 +981,9 @@ static void zvni_print(zebra_vni_t *zvni, void **ctxt)  	num_macs = num_valid_macs(zvni);  	num_neigh = hashcount(zvni->neigh_table);  	if (json == NULL) { -		vty_out(vty, " VxLAN interface: %s\n", -			zvni->vxlan_if->name); +		vty_out(vty, " VxLAN interface: %s\n", zvni->vxlan_if->name);  		vty_out(vty, " VxLAN ifIndex: %u\n", zvni->vxlan_if->ifindex); -		vty_out(vty," Local VTEP IP: %s\n", +		vty_out(vty, " Local VTEP IP: %s\n",  			inet_ntoa(zvni->local_vtep_ip));  	} else {  		json_object_string_add(json, "vxlanInterface", @@ -1054,8 +1033,7 @@ static void zvni_print(zebra_vni_t *zvni, void **ctxt)  }  /* print a L3 VNI hash entry */ -static void zl3vni_print_hash(struct hash_backet *backet, -			      void *ctx[]) +static void zl3vni_print_hash(struct hash_backet *backet, void *ctx[])  {  	struct vty *vty = NULL;  	json_object *json = NULL; @@ -1070,13 +1048,10 @@ static void zl3vni_print_hash(struct hash_backet *backet,  		return;  	if (!json) { -		vty_out(vty, -			"%-10u %-4s %-21s %-8lu %-8lu %-15s %-37s\n", -			zl3vni->vni, "L3", -			zl3vni_vxlan_if_name(zl3vni), +		vty_out(vty, "%-10u %-4s %-21s %-8lu %-8lu %-15s %-37s\n", +			zl3vni->vni, "L3", zl3vni_vxlan_if_name(zl3vni),  			hashcount(zl3vni->rmac_table), -			hashcount(zl3vni->nh_table), -			"n/a", +			hashcount(zl3vni->nh_table), "n/a",  			zl3vni_vrf_name(zl3vni));  	} else {  		char vni_str[VNI_STR_LEN]; @@ -1096,7 +1071,6 @@ static void zl3vni_print_hash(struct hash_backet *backet,  				       zl3vni_vrf_name(zl3vni));  		json_object_object_add(json, vni_str, json_vni);  	} -  }  /* @@ -1131,12 +1105,10 @@ static void zvni_print_hash(struct hash_backet *backet, void *ctxt[])  	num_macs = num_valid_macs(zvni);  	num_neigh = hashcount(zvni->neigh_table);  	if (json == NULL) -		vty_out(vty, -			"%-10u %-4s %-21s %-8u %-8u %-15u %-37s\n", +		vty_out(vty, "%-10u %-4s %-21s %-8u %-8u %-15u %-37s\n",  			zvni->vni, "L2",  			zvni->vxlan_if ? zvni->vxlan_if->name : "unknown", -			num_macs, num_neigh, -			num_vteps, +			num_macs, num_neigh, num_vteps,  			vrf_id_to_name(zvni->vrf_id));  	else {  		char vni_str[VNI_STR_LEN]; @@ -1170,8 +1142,7 @@ static void zvni_print_hash(struct hash_backet *backet, void *ctxt[])  /*   * Inform BGP about local MACIP.   */ -static int zvni_macip_send_msg_to_client(vni_t vni, -					 struct ethaddr *macaddr, +static int zvni_macip_send_msg_to_client(vni_t vni, struct ethaddr *macaddr,  					 struct ipaddr *ip, u_char flags,  					 u_int16_t cmd)  { @@ -1214,8 +1185,8 @@ static int zvni_macip_send_msg_to_client(vni_t vni,  	if (IS_ZEBRA_DEBUG_VXLAN)  		zlog_debug(  			"Send MACIP %s flags 0x%x MAC %s IP %s L2-VNI %u to %s", -			(cmd == ZEBRA_MACIP_ADD) ? "Add" : "Del", -			flags, prefix_mac2str(macaddr, buf, sizeof(buf)), +			(cmd == ZEBRA_MACIP_ADD) ? "Add" : "Del", flags, +			prefix_mac2str(macaddr, buf, sizeof(buf)),  			ipaddr2str(ip, buf2, sizeof(buf2)), vni,  			zebra_route_string(client->proto)); @@ -1372,8 +1343,8 @@ static void zvni_neigh_del_from_vtep(zebra_vni_t *zvni, int uninstall,  /*   * Delete all neighbor entries for this VNI.   */ -static void zvni_neigh_del_all(zebra_vni_t *zvni, -			       int uninstall, int upd_client, u_int32_t flags) +static void zvni_neigh_del_all(zebra_vni_t *zvni, int uninstall, int upd_client, +			       u_int32_t flags)  {  	struct neigh_walk_ctx wctx; @@ -1471,8 +1442,8 @@ static void zvni_process_neigh_on_local_mac_del(zebra_vni_t *zvni,  						zvni->vni);  				ZEBRA_NEIGH_SET_INACTIVE(n); -				zvni_neigh_send_del_to_client( -					zvni->vni, &n->ip, &n->emac, 0); +				zvni_neigh_send_del_to_client(zvni->vni, &n->ip, +							      &n->emac, 0);  			}  		} else if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_REMOTE)) {  			if (IS_ZEBRA_DEBUG_VXLAN) @@ -1508,8 +1479,8 @@ static void zvni_process_neigh_on_remote_mac_add(zebra_vni_t *zvni,  						zvni->vni);  				ZEBRA_NEIGH_SET_INACTIVE(n); -				zvni_neigh_send_del_to_client( -					zvni->vni, &n->ip, &n->emac, 0); +				zvni_neigh_send_del_to_client(zvni->vni, &n->ip, +							      &n->emac, 0);  			}  		}  	} @@ -1540,12 +1511,11 @@ static void zvni_process_neigh_on_remote_mac_del(zebra_vni_t *zvni,  /*   * Inform BGP about local neighbor addition.   */ -static int zvni_neigh_send_add_to_client(vni_t vni, -					 struct ipaddr *ip, +static int zvni_neigh_send_add_to_client(vni_t vni, struct ipaddr *ip,  					 struct ethaddr *macaddr,  					 u_char neigh_flags)  { -	u_char			flags = 0; +	u_char flags = 0;  	if (CHECK_FLAG(neigh_flags, ZEBRA_NEIGH_DEF_GW))  		SET_FLAG(flags, ZEBRA_MACIP_TYPE_GW); @@ -1557,8 +1527,7 @@ static int zvni_neigh_send_add_to_client(vni_t vni,  /*   * Inform BGP about local neighbor deletion.   */ -static int zvni_neigh_send_del_to_client(vni_t vni, -					 struct ipaddr *ip, +static int zvni_neigh_send_del_to_client(vni_t vni, struct ipaddr *ip,  					 struct ethaddr *macaddr, u_char flags)  {  	return zvni_macip_send_msg_to_client(vni, macaddr, ip, flags, @@ -1725,8 +1694,7 @@ static int zvni_add_macip_for_intf(struct interface *ifp, zebra_vni_t *zvni)  } -static int zvni_advertise_subnet(zebra_vni_t *zvni, -				 struct interface *ifp, +static int zvni_advertise_subnet(zebra_vni_t *zvni, struct interface *ifp,  				 int advertise)  {  	struct listnode *cnode = NULL, *cnnode = NULL; @@ -1747,7 +1715,7 @@ static int zvni_advertise_subnet(zebra_vni_t *zvni,  		apply_mask(&p);  		if (advertise)  			ip_prefix_send_to_client(ifp->vrf_id, &p, -						     ZEBRA_IP_PREFIX_ROUTE_ADD); +						 ZEBRA_IP_PREFIX_ROUTE_ADD);  		else  			ip_prefix_send_to_client(ifp->vrf_id, &p,  						 ZEBRA_IP_PREFIX_ROUTE_DEL); @@ -1823,8 +1791,7 @@ static int zvni_gw_macip_add(struct interface *ifp, zebra_vni_t *zvni,  			prefix_mac2str(macaddr, buf, sizeof(buf)),  			ipaddr2str(ip, buf2, sizeof(buf2))); -	zvni_neigh_send_add_to_client(zvni->vni, ip, macaddr, -				      n->flags); +	zvni_neigh_send_add_to_client(zvni->vni, ip, macaddr, n->flags);  	return 0;  } @@ -1860,13 +1827,11 @@ static int zvni_gw_macip_del(struct interface *ifp, zebra_vni_t *zvni,  	/* only need to delete the entry from bgp if we sent it before */  	if (IS_ZEBRA_DEBUG_VXLAN) -		zlog_debug("%u:SVI %s(%u) VNI %u, sending GW MAC %s IP %s del to BGP", -			   ifp->vrf_id, ifp->name, -			   ifp->ifindex, zvni->vni, -			   prefix_mac2str(&(n->emac), -					  NULL, -					  ETHER_ADDR_STRLEN), -			   ipaddr2str(ip, buf2, sizeof(buf2))); +		zlog_debug( +			"%u:SVI %s(%u) VNI %u, sending GW MAC %s IP %s del to BGP", +			ifp->vrf_id, ifp->name, ifp->ifindex, zvni->vni, +			prefix_mac2str(&(n->emac), NULL, ETHER_ADDR_STRLEN), +			ipaddr2str(ip, buf2, sizeof(buf2)));  	/* Remove neighbor from BGP. */  	zvni_neigh_send_del_to_client(zvni->vni, &n->ip, &n->emac, @@ -1908,7 +1873,8 @@ static void zvni_gw_macip_del_for_vni_hash(struct hash_backet *backet,  	zl2_info = zif->l2info.vxl; -	vlan_if = zvni_map_to_svi(zl2_info.access_vlan, zif->brslave_info.br_if); +	vlan_if = +		zvni_map_to_svi(zl2_info.access_vlan, zif->brslave_info.br_if);  	if (!vlan_if)  		return; @@ -1947,8 +1913,8 @@ static void zvni_gw_macip_add_for_vni_hash(struct hash_backet *backet,  		return;  	zl2_info = zif->l2info.vxl; -	vlan_if = zvni_map_to_svi(zl2_info.access_vlan, -				  zif->brslave_info.br_if); +	vlan_if = +		zvni_map_to_svi(zl2_info.access_vlan, zif->brslave_info.br_if);  	if (!vlan_if)  		return; @@ -1988,8 +1954,7 @@ static int mac_cmp(const void *p1, const void *p2)  	if (pmac1 == NULL || pmac2 == NULL)  		return 0; -	return (memcmp(pmac1->macaddr.octet, pmac2->macaddr.octet, -		       ETH_ALEN) +	return (memcmp(pmac1->macaddr.octet, pmac2->macaddr.octet, ETH_ALEN)  		== 0);  } @@ -2059,9 +2024,8 @@ static int zvni_mac_del_hash_entry(struct hash_backet *backet, void *arg)  		&& IPV4_ADDR_SAME(&mac->fwd_info.r_vtep_ip,  				  &wctx->r_vtep_ip))) {  		if (wctx->upd_client && (mac->flags & ZEBRA_MAC_LOCAL)) { -			zvni_mac_send_del_to_client( -				wctx->zvni->vni, &mac->macaddr, -				mac->flags); +			zvni_mac_send_del_to_client(wctx->zvni->vni, +						    &mac->macaddr, mac->flags);  		}  		if (wctx->uninstall) @@ -2098,8 +2062,8 @@ static void zvni_mac_del_from_vtep(zebra_vni_t *zvni, int uninstall,  /*   * Delete all MAC entries for this VNI.   */ -static void zvni_mac_del_all(zebra_vni_t *zvni, -			     int uninstall, int upd_client, u_int32_t flags) +static void zvni_mac_del_all(zebra_vni_t *zvni, int uninstall, int upd_client, +			     u_int32_t flags)  {  	struct mac_walk_ctx wctx; @@ -2135,11 +2099,10 @@ static zebra_mac_t *zvni_mac_lookup(zebra_vni_t *zvni, struct ethaddr *mac)  /*   * Inform BGP about local MAC addition.   */ -static int zvni_mac_send_add_to_client(vni_t vni, -				       struct ethaddr *macaddr, +static int zvni_mac_send_add_to_client(vni_t vni, struct ethaddr *macaddr,  				       u_char mac_flags)  { -	u_char	flags = 0; +	u_char flags = 0;  	if (CHECK_FLAG(mac_flags, ZEBRA_MAC_STICKY))  		SET_FLAG(flags, ZEBRA_MACIP_TYPE_STICKY); @@ -2153,11 +2116,10 @@ static int zvni_mac_send_add_to_client(vni_t vni,  /*   * Inform BGP about local MAC deletion.   */ -static int zvni_mac_send_del_to_client(vni_t vni, -				       struct ethaddr *macaddr, +static int zvni_mac_send_del_to_client(vni_t vni, struct ethaddr *macaddr,  				       u_char mac_flags)  { -	u_char	flags = 0; +	u_char flags = 0;  	if (CHECK_FLAG(mac_flags, ZEBRA_MAC_STICKY))  		SET_FLAG(flags, ZEBRA_MACIP_TYPE_STICKY); @@ -2448,8 +2410,7 @@ static void zvni_deref_ip2mac(zebra_vni_t *zvni, zebra_mac_t *mac,  /*   * Read and populate local MACs and neighbors corresponding to this VNI.   */ -static void zvni_read_mac_neigh(zebra_vni_t *zvni, -				struct interface *ifp) +static void zvni_read_mac_neigh(zebra_vni_t *zvni, struct interface *ifp)  {  	struct zebra_ns *zns;  	struct zebra_if *zif; @@ -2616,8 +2577,8 @@ static int zvni_send_add_to_client(zebra_vni_t *zvni)  	stream_putw_at(s, 0, stream_get_endp(s));  	if (IS_ZEBRA_DEBUG_VXLAN) -		zlog_debug("Send VNI_ADD %u %s tenant vrf %s to %s", -			   zvni->vni, inet_ntoa(zvni->local_vtep_ip), +		zlog_debug("Send VNI_ADD %u %s tenant vrf %s to %s", zvni->vni, +			   inet_ntoa(zvni->local_vtep_ip),  			   vrf_id_to_name(zvni->vrf_id),  			   zebra_route_string(client->proto)); @@ -2689,8 +2650,9 @@ static void zvni_build_hash_table()  		if (zl3vni) {  			if (IS_ZEBRA_DEBUG_VXLAN) -				zlog_debug("create L3-VNI hash for Intf %s(%u) L3-VNI %u", -					   ifp->name, ifp->ifindex, vni); +				zlog_debug( +					"create L3-VNI hash for Intf %s(%u) L3-VNI %u", +					ifp->name, ifp->ifindex, vni);  			/* associate with vxlan_if */  			zl3vni->local_vtep_ip = vxl->vtep_ip; @@ -2892,8 +2854,7 @@ static void zvni_cleanup_all(struct hash_backet *backet, void *arg)  }  /* cleanup L3VNI */ -static void zl3vni_cleanup_all(struct hash_backet *backet, -			       void *args) +static void zl3vni_cleanup_all(struct hash_backet *backet, void *args)  {  	zebra_l3vni_t *zl3vni = NULL; @@ -2904,8 +2865,7 @@ static void zl3vni_cleanup_all(struct hash_backet *backet,  	zebra_vxlan_process_l3vni_oper_down(zl3vni);  } -static int is_host_present_in_host_list(struct list *list, -					struct prefix *host) +static int is_host_present_in_host_list(struct list *list, struct prefix *host)  {  	struct listnode *node = NULL;  	struct prefix *p = NULL; @@ -2917,8 +2877,7 @@ static int is_host_present_in_host_list(struct list *list,  	return 0;  } -static void host_list_add_host(struct list *list, -			       struct prefix *host) +static void host_list_add_host(struct list *list, struct prefix *host)  {  	struct prefix *p = NULL; @@ -2928,8 +2887,7 @@ static void host_list_add_host(struct list *list,  	listnode_add_sort(list, p);  } -static void host_list_delete_host(struct list *list, -				  struct prefix *host) +static void host_list_delete_host(struct list *list, struct prefix *host)  {  	struct listnode *node = NULL, *nnode = NULL, *node_to_del = NULL;  	struct prefix *p = NULL; @@ -2978,8 +2936,7 @@ static void *zl3vni_rmac_alloc(void *p)  /*   * Add RMAC entry to l3-vni   */ -static zebra_mac_t *zl3vni_rmac_add(zebra_l3vni_t *zl3vni, -				    struct ethaddr *rmac) +static zebra_mac_t *zl3vni_rmac_add(zebra_l3vni_t *zl3vni, struct ethaddr *rmac)  {  	zebra_mac_t tmp_rmac;  	zebra_mac_t *zrmac = NULL; @@ -3001,8 +2958,7 @@ static zebra_mac_t *zl3vni_rmac_add(zebra_l3vni_t *zl3vni,  /*   * Delete MAC entry.   */ -static int zl3vni_rmac_del(zebra_l3vni_t *zl3vni, -			   zebra_mac_t *zrmac) +static int zl3vni_rmac_del(zebra_l3vni_t *zl3vni, zebra_mac_t *zrmac)  {  	zebra_mac_t *tmp_rmac; @@ -3020,14 +2976,13 @@ static int zl3vni_rmac_del(zebra_l3vni_t *zl3vni,  /*   * Install remote RMAC into the kernel.   */ -static int zl3vni_rmac_install(zebra_l3vni_t *zl3vni, -			       zebra_mac_t *zrmac) +static int zl3vni_rmac_install(zebra_l3vni_t *zl3vni, zebra_mac_t *zrmac)  {  	struct zebra_if *zif = NULL;  	struct zebra_l2info_vxlan *vxl = NULL; -	if (!(CHECK_FLAG(zrmac->flags, ZEBRA_MAC_REMOTE)) || -	    !(CHECK_FLAG(zrmac->flags, ZEBRA_MAC_REMOTE_RMAC))) +	if (!(CHECK_FLAG(zrmac->flags, ZEBRA_MAC_REMOTE)) +	    || !(CHECK_FLAG(zrmac->flags, ZEBRA_MAC_REMOTE_RMAC)))  		return 0;  	zif = zl3vni->vxlan_if->info; @@ -3037,29 +2992,27 @@ static int zl3vni_rmac_install(zebra_l3vni_t *zl3vni,  	vxl = &zif->l2info.vxl;  	return kernel_add_mac(zl3vni->vxlan_if, vxl->access_vlan, -			      &zrmac->macaddr, -			      zrmac->fwd_info.r_vtep_ip, 0); +			      &zrmac->macaddr, zrmac->fwd_info.r_vtep_ip, 0);  }  /*   * Uninstall remote RMAC from the kernel.   */ -static int zl3vni_rmac_uninstall(zebra_l3vni_t *zl3vni, -			         zebra_mac_t *zrmac) +static int zl3vni_rmac_uninstall(zebra_l3vni_t *zl3vni, zebra_mac_t *zrmac)  {  	char buf[ETHER_ADDR_STRLEN];  	struct zebra_if *zif = NULL;  	struct zebra_l2info_vxlan *vxl = NULL; -	if (!(CHECK_FLAG(zrmac->flags, ZEBRA_MAC_REMOTE)) || -	    !(CHECK_FLAG(zrmac->flags, ZEBRA_MAC_REMOTE_RMAC))) +	if (!(CHECK_FLAG(zrmac->flags, ZEBRA_MAC_REMOTE)) +	    || !(CHECK_FLAG(zrmac->flags, ZEBRA_MAC_REMOTE_RMAC)))  		return 0;  	if (!zl3vni->vxlan_if) {  		zlog_err( -			 "RMAC %s on L3-VNI %u hash %p couldn't be uninstalled - no vxlan_if", -			 prefix_mac2str(&zrmac->macaddr, buf, sizeof(buf)), -			 zl3vni->vni, zl3vni); +			"RMAC %s on L3-VNI %u hash %p couldn't be uninstalled - no vxlan_if", +			prefix_mac2str(&zrmac->macaddr, buf, sizeof(buf)), +			zl3vni->vni, zl3vni);  		return -1;  	} @@ -3074,8 +3027,7 @@ static int zl3vni_rmac_uninstall(zebra_l3vni_t *zl3vni,  }  /* handle rmac add */ -static int zl3vni_remote_rmac_add(zebra_l3vni_t *zl3vni, -				  struct ethaddr *rmac, +static int zl3vni_remote_rmac_add(zebra_l3vni_t *zl3vni, struct ethaddr *rmac,  				  struct ipaddr *vtep_ip,  				  struct prefix *host_prefix)  { @@ -3090,10 +3042,9 @@ static int zl3vni_remote_rmac_add(zebra_l3vni_t *zl3vni,  		if (!zrmac) {  			zlog_warn(  				"Failed to add RMAC %s L3VNI %u Remote VTEP %s", -				prefix_mac2str(rmac, buf, -					       sizeof(buf)), -				zl3vni->vni, ipaddr2str(vtep_ip, buf1, -							sizeof(buf1))); +				prefix_mac2str(rmac, buf, sizeof(buf)), +				zl3vni->vni, +				ipaddr2str(vtep_ip, buf1, sizeof(buf1)));  			return -1;  		}  		memset(&zrmac->fwd_info, 0, sizeof(zrmac->fwd_info)); @@ -3110,8 +3061,7 @@ static int zl3vni_remote_rmac_add(zebra_l3vni_t *zl3vni,  /* handle rmac delete */ -static int zl3vni_remote_rmac_del(zebra_l3vni_t *zl3vni, -				  struct ethaddr *rmac, +static int zl3vni_remote_rmac_del(zebra_l3vni_t *zl3vni, struct ethaddr *rmac,  				  struct prefix *host_prefix)  {  	zebra_mac_t *zrmac = NULL; @@ -3135,8 +3085,7 @@ static int zl3vni_remote_rmac_del(zebra_l3vni_t *zl3vni,  /*   * Look up nh hash entry on a l3-vni.   */ -static zebra_neigh_t *zl3vni_nh_lookup(zebra_l3vni_t *zl3vni, -				       struct ipaddr *ip) +static zebra_neigh_t *zl3vni_nh_lookup(zebra_l3vni_t *zl3vni, struct ipaddr *ip)  {  	zebra_neigh_t tmp;  	zebra_neigh_t *n; @@ -3166,8 +3115,7 @@ static void *zl3vni_nh_alloc(void *p)  /*   * Add neighbor entry.   */ -static zebra_neigh_t *zl3vni_nh_add(zebra_l3vni_t *zl3vni, -				    struct ipaddr *ip, +static zebra_neigh_t *zl3vni_nh_add(zebra_l3vni_t *zl3vni, struct ipaddr *ip,  				    struct ethaddr *mac)  {  	zebra_neigh_t tmp_n; @@ -3191,8 +3139,7 @@ static zebra_neigh_t *zl3vni_nh_add(zebra_l3vni_t *zl3vni,  /*   * Delete neighbor entry.   */ -static int zl3vni_nh_del(zebra_l3vni_t *zl3vni, -			 zebra_neigh_t *n) +static int zl3vni_nh_del(zebra_l3vni_t *zl3vni, zebra_neigh_t *n)  {  	zebra_neigh_t *tmp_n; @@ -3210,14 +3157,13 @@ static int zl3vni_nh_del(zebra_l3vni_t *zl3vni,  /*   * Install remote nh as neigh into the kernel.   */ -static int zl3vni_nh_install(zebra_l3vni_t *zl3vni, -			     zebra_neigh_t *n) +static int zl3vni_nh_install(zebra_l3vni_t *zl3vni, zebra_neigh_t *n)  {  	if (!is_l3vni_oper_up(zl3vni))  		return -1; -	if (!(n->flags & ZEBRA_NEIGH_REMOTE) || -	    !(n->flags & ZEBRA_NEIGH_REMOTE_NH)) +	if (!(n->flags & ZEBRA_NEIGH_REMOTE) +	    || !(n->flags & ZEBRA_NEIGH_REMOTE_NH))  		return 0;  	return kernel_add_neigh(zl3vni->svi_if, &n->ip, &n->emac); @@ -3226,11 +3172,10 @@ static int zl3vni_nh_install(zebra_l3vni_t *zl3vni,  /*   * Uninstall remote nh from the kernel.   */ -static int zl3vni_nh_uninstall(zebra_l3vni_t *zl3vni, -			       zebra_neigh_t *n) +static int zl3vni_nh_uninstall(zebra_l3vni_t *zl3vni, zebra_neigh_t *n)  { -	if (!(n->flags & ZEBRA_NEIGH_REMOTE) || -	    !(n->flags & ZEBRA_NEIGH_REMOTE_NH)) +	if (!(n->flags & ZEBRA_NEIGH_REMOTE) +	    || !(n->flags & ZEBRA_NEIGH_REMOTE_NH))  		return 0;  	if (!zl3vni->svi_if || !if_is_operative(zl3vni->svi_if)) @@ -3240,8 +3185,7 @@ static int zl3vni_nh_uninstall(zebra_l3vni_t *zl3vni,  }  /* add remote vtep as a neigh entry */ -static int zl3vni_remote_nh_add(zebra_l3vni_t *zl3vni, -				struct ipaddr *vtep_ip, +static int zl3vni_remote_nh_add(zebra_l3vni_t *zl3vni, struct ipaddr *vtep_ip,  				struct ethaddr *rmac,  				struct prefix *host_prefix)  { @@ -3256,10 +3200,8 @@ static int zl3vni_remote_nh_add(zebra_l3vni_t *zl3vni,  			zlog_warn(  				"Failed to add NH as Neigh (IP %s MAC %s L3-VNI %u)", -				ipaddr2str(vtep_ip, buf1, -					   sizeof(buf1)), -				prefix_mac2str(rmac, buf, -					       sizeof(buf)), +				ipaddr2str(vtep_ip, buf1, sizeof(buf1)), +				prefix_mac2str(rmac, buf, sizeof(buf)),  				zl3vni->vni);  			return -1;  		} @@ -3275,8 +3217,7 @@ static int zl3vni_remote_nh_add(zebra_l3vni_t *zl3vni,  }  /* handle nh neigh delete */ -static int zl3vni_remote_nh_del(zebra_l3vni_t *zl3vni, -				struct ipaddr *vtep_ip, +static int zl3vni_remote_nh_del(zebra_l3vni_t *zl3vni, struct ipaddr *vtep_ip,  				struct prefix *host_prefix)  {  	zebra_neigh_t *nh = NULL; @@ -3301,8 +3242,8 @@ static int zl3vni_remote_nh_del(zebra_l3vni_t *zl3vni,  /* handle neigh update from kernel - the only thing of interest is to   * readd stale entries.   */ -static int zl3vni_local_nh_add_update(zebra_l3vni_t *zl3vni, -				      struct ipaddr *ip, u_int16_t state) +static int zl3vni_local_nh_add_update(zebra_l3vni_t *zl3vni, struct ipaddr *ip, +				      u_int16_t state)  {  #ifdef GNU_LINUX  	zebra_neigh_t *n = NULL; @@ -3321,8 +3262,7 @@ static int zl3vni_local_nh_add_update(zebra_l3vni_t *zl3vni,  }  /* handle neigh delete from kernel */ -static int zl3vni_local_nh_del(zebra_l3vni_t *zl3vni, -			       struct ipaddr *ip) +static int zl3vni_local_nh_del(zebra_l3vni_t *zl3vni, struct ipaddr *ip)  {  	zebra_neigh_t *n = NULL; @@ -3416,13 +3356,12 @@ static zebra_l3vni_t *zl3vni_add(vni_t vni, vrf_id_t vrf_id)  	zl3vni->l2vnis->cmp = (int (*)(void *, void *))vni_hash_cmp;  	/* Create hash table for remote RMAC */ -	zl3vni->rmac_table = -		hash_create(mac_hash_keymake, mac_cmp, -			    "Zebra L3-VNI RMAC-Table"); +	zl3vni->rmac_table = hash_create(mac_hash_keymake, mac_cmp, +					 "Zebra L3-VNI RMAC-Table");  	/* Create hash table for neighbors */  	zl3vni->nh_table = hash_create(neigh_hash_keymake, neigh_cmp, -				     "Zebra L3-VNI next-hop table"); +				       "Zebra L3-VNI next-hop table");  	return zl3vni;  } @@ -3491,7 +3430,7 @@ static struct interface *zl3vni_map_to_vxlan_if(zebra_l3vni_t *zl3vni)  static struct interface *zl3vni_map_to_svi_if(zebra_l3vni_t *zl3vni)  { -	struct zebra_if *zif = NULL; /* zebra_if for vxlan_if */ +	struct zebra_if *zif = NULL;	   /* zebra_if for vxlan_if */  	struct zebra_l2info_vxlan *vxl = NULL; /* l2 info for vxlan_if */  	if (!zl3vni) @@ -3614,8 +3553,7 @@ static int zl3vni_send_add_to_client(zebra_l3vni_t *zl3vni)  	s = client->obuf;  	stream_reset(s); -	zclient_create_header(s, ZEBRA_L3VNI_ADD, -			    zl3vni_vrf_id(zl3vni)); +	zclient_create_header(s, ZEBRA_L3VNI_ADD, zl3vni_vrf_id(zl3vni));  	stream_putl(s, zl3vni->vni);  	stream_put(s, &rmac, sizeof(struct ethaddr));  	stream_put_in_addr(s, &zl3vni->local_vtep_ip); @@ -3626,13 +3564,14 @@ static int zl3vni_send_add_to_client(zebra_l3vni_t *zl3vni)  	if (IS_ZEBRA_DEBUG_VXLAN)  		zlog_debug( -			   "Send L3_VNI_ADD %u VRF %s RMAC %s local-ip %s filter %s to %s", -			   zl3vni->vni, vrf_id_to_name(zl3vni_vrf_id(zl3vni)), -			   prefix_mac2str(&rmac, buf, sizeof(buf)), -			   inet_ntoa(zl3vni->local_vtep_ip), -			   CHECK_FLAG(zl3vni->filter, PREFIX_ROUTES_ONLY) ? -				"prefix-routes-only" : "none", -			   zebra_route_string(client->proto)); +			"Send L3_VNI_ADD %u VRF %s RMAC %s local-ip %s filter %s to %s", +			zl3vni->vni, vrf_id_to_name(zl3vni_vrf_id(zl3vni)), +			prefix_mac2str(&rmac, buf, sizeof(buf)), +			inet_ntoa(zl3vni->local_vtep_ip), +			CHECK_FLAG(zl3vni->filter, PREFIX_ROUTES_ONLY) +				? "prefix-routes-only" +				: "none", +			zebra_route_string(client->proto));  	client->l3vniadd_cnt++;  	return zebra_server_send_message(client); @@ -3654,16 +3593,14 @@ static int zl3vni_send_del_to_client(zebra_l3vni_t *zl3vni)  	s = client->obuf;  	stream_reset(s); -	zclient_create_header(s, ZEBRA_L3VNI_DEL, -			    zl3vni_vrf_id(zl3vni)); +	zclient_create_header(s, ZEBRA_L3VNI_DEL, zl3vni_vrf_id(zl3vni));  	stream_putl(s, zl3vni->vni);  	/* Write packet size. */  	stream_putw_at(s, 0, stream_get_endp(s));  	if (IS_ZEBRA_DEBUG_VXLAN) -		zlog_debug("Send L3_VNI_DEL %u VRF %s to %s", -			   zl3vni->vni, +		zlog_debug("Send L3_VNI_DEL %u VRF %s to %s", zl3vni->vni,  			   vrf_id_to_name(zl3vni_vrf_id(zl3vni)),  			   zebra_route_string(client->proto)); @@ -3689,11 +3626,10 @@ static void zebra_vxlan_process_l3vni_oper_down(zebra_l3vni_t *zl3vni)  	zl3vni_send_del_to_client(zl3vni);  } -static void zvni_add_to_l3vni_list(struct hash_backet *backet, -				   void *ctxt) +static void zvni_add_to_l3vni_list(struct hash_backet *backet, void *ctxt)  { -	zebra_vni_t *zvni = (zebra_vni_t *) backet->data; -	zebra_l3vni_t *zl3vni = (zebra_l3vni_t *) ctxt; +	zebra_vni_t *zvni = (zebra_vni_t *)backet->data; +	zebra_l3vni_t *zl3vni = (zebra_l3vni_t *)ctxt;  	if (zvni->vrf_id == zl3vni_vrf_id(zl3vni))  		listnode_add_sort(zl3vni->l2vnis, zvni); @@ -3702,8 +3638,8 @@ static void zvni_add_to_l3vni_list(struct hash_backet *backet,  /*   *  handle transition of vni from l2 to l3 and vice versa   */ -static int zebra_vxlan_handle_vni_transition(struct zebra_vrf *zvrf, -					      vni_t vni, int add) +static int zebra_vxlan_handle_vni_transition(struct zebra_vrf *zvrf, vni_t vni, +					     int add)  {  	zebra_vni_t *zvni = NULL; @@ -3722,8 +3658,7 @@ static int zebra_vxlan_handle_vni_transition(struct zebra_vrf *zvrf,  			return 0;  		if (IS_ZEBRA_DEBUG_VXLAN) -			zlog_debug("Del L2-VNI %u - transition to L3-VNI", -				   vni); +			zlog_debug("Del L2-VNI %u - transition to L3-VNI", vni);  		/* Delete VNI from BGP. */  		zvni_send_del_to_client(zvni->vni); @@ -3737,8 +3672,8 @@ static int zebra_vxlan_handle_vni_transition(struct zebra_vrf *zvrf,  		/* Delete the hash entry. */  		if (zvni_del(zvni)) { -			zlog_err("Failed to del VNI hash %p, VNI %u", -				 zvni, zvni->vni); +			zlog_err("Failed to del VNI hash %p, VNI %u", zvni, +				 zvni->vni);  			return -1;  		}  	} else { @@ -3753,8 +3688,7 @@ static int zebra_vxlan_handle_vni_transition(struct zebra_vrf *zvrf,  }  /* delete and uninstall rmac hash entry */ -static void zl3vni_del_rmac_hash_entry(struct hash_backet *backet, -				       void *ctx) +static void zl3vni_del_rmac_hash_entry(struct hash_backet *backet, void *ctx)  {  	zebra_mac_t *zrmac = NULL;  	zebra_l3vni_t *zl3vni = NULL; @@ -3766,8 +3700,7 @@ static void zl3vni_del_rmac_hash_entry(struct hash_backet *backet,  }  /* delete and uninstall nh hash entry */ -static void zl3vni_del_nh_hash_entry(struct hash_backet *backet, -				     void *ctx) +static void zl3vni_del_nh_hash_entry(struct hash_backet *backet, void *ctx)  {  	zebra_neigh_t *n = NULL;  	zebra_l3vni_t *zl3vni = NULL; @@ -3778,9 +3711,8 @@ static void zl3vni_del_nh_hash_entry(struct hash_backet *backet,  	zl3vni_nh_del(zl3vni, n);  } -static int ip_prefix_send_to_client(vrf_id_t vrf_id, -					     struct prefix *p, -					     uint16_t cmd) +static int ip_prefix_send_to_client(vrf_id_t vrf_id, struct prefix *p, +				    uint16_t cmd)  {  	struct zserv *client = NULL;  	struct stream *s = NULL; @@ -3801,8 +3733,7 @@ static int ip_prefix_send_to_client(vrf_id_t vrf_id,  	stream_putw_at(s, 0, stream_get_endp(s));  	if (IS_ZEBRA_DEBUG_VXLAN) -		zlog_debug( -			   "Send ip prefix %s %s on vrf %s", +		zlog_debug("Send ip prefix %s %s on vrf %s",  			   prefix2str(p, buf, sizeof(buf)),  			   (cmd == ZEBRA_IP_PREFIX_ROUTE_ADD) ? "ADD" : "DEL",  			   vrf_id_to_name(vrf_id)); @@ -3817,7 +3748,7 @@ static int ip_prefix_send_to_client(vrf_id_t vrf_id,  /* re-add remote rmac if needed */  static int zebra_vxlan_readd_remote_rmac(zebra_l3vni_t *zl3vni, -				  struct ethaddr *rmac) +					 struct ethaddr *rmac)  {  	char buf[ETHER_ADDR_STRLEN];  	zebra_mac_t *zrmac = NULL; @@ -3828,8 +3759,7 @@ static int zebra_vxlan_readd_remote_rmac(zebra_l3vni_t *zl3vni,  	if (IS_ZEBRA_DEBUG_VXLAN)  		zlog_debug("Del remote RMAC %s L3VNI %u - readd", -			   prefix_mac2str(rmac, buf, sizeof(buf)), -			   zl3vni->vni); +			   prefix_mac2str(rmac, buf, sizeof(buf)), zl3vni->vni);  	zl3vni_rmac_install(zl3vni, zrmac);  	return 0; @@ -3849,10 +3779,9 @@ int is_l3vni_for_prefix_routes_only(vni_t vni)  }  /* handle evpn route in vrf table */ -void zebra_vxlan_evpn_vrf_route_add(vrf_id_t vrf_id, -				   struct ethaddr *rmac, -				   struct ipaddr *vtep_ip, -				   struct prefix *host_prefix) +void zebra_vxlan_evpn_vrf_route_add(vrf_id_t vrf_id, struct ethaddr *rmac, +				    struct ipaddr *vtep_ip, +				    struct prefix *host_prefix)  {  	zebra_l3vni_t *zl3vni = NULL; @@ -3868,10 +3797,9 @@ void zebra_vxlan_evpn_vrf_route_add(vrf_id_t vrf_id,  }  /* handle evpn vrf route delete */ -void zebra_vxlan_evpn_vrf_route_del(vrf_id_t vrf_id, -				   struct ethaddr *rmac, -				   struct ipaddr *vtep_ip, -				   struct prefix *host_prefix) +void zebra_vxlan_evpn_vrf_route_del(vrf_id_t vrf_id, struct ethaddr *rmac, +				    struct ipaddr *vtep_ip, +				    struct prefix *host_prefix)  {  	zebra_l3vni_t *zl3vni = NULL; @@ -3886,8 +3814,7 @@ void zebra_vxlan_evpn_vrf_route_del(vrf_id_t vrf_id,  	zl3vni_remote_rmac_del(zl3vni, rmac, host_prefix);  } -void zebra_vxlan_print_specific_rmac_l3vni(struct vty *vty, -					   vni_t l3vni, +void zebra_vxlan_print_specific_rmac_l3vni(struct vty *vty, vni_t l3vni,  					   struct ethaddr *rmac,  					   u_char use_json)  { @@ -3909,8 +3836,7 @@ void zebra_vxlan_print_specific_rmac_l3vni(struct vty *vty,  		if (use_json)  			vty_out(vty, "{}\n");  		else -			vty_out(vty, "%% L3-VNI %u doesnt exist\n", -				l3vni); +			vty_out(vty, "%% L3-VNI %u doesnt exist\n", l3vni);  		return;  	} @@ -3934,8 +3860,7 @@ void zebra_vxlan_print_specific_rmac_l3vni(struct vty *vty,  	}  } -void zebra_vxlan_print_rmacs_l3vni(struct vty *vty, -				   vni_t l3vni, +void zebra_vxlan_print_rmacs_l3vni(struct vty *vty, vni_t l3vni,  				   u_char use_json)  {  	zebra_l3vni_t *zl3vni; @@ -3965,8 +3890,7 @@ void zebra_vxlan_print_rmacs_l3vni(struct vty *vty,  	wctx.vty = vty;  	wctx.json = json;  	if (!use_json) { -		vty_out(vty, -			"Number of Remote RMACs known for this VNI: %u\n", +		vty_out(vty, "Number of Remote RMACs known for this VNI: %u\n",  			num_rmacs);  		vty_out(vty, "%-17s %-21s\n", "MAC", "Remote VTEP");  	} else @@ -3981,8 +3905,7 @@ void zebra_vxlan_print_rmacs_l3vni(struct vty *vty,  	}  } -void zebra_vxlan_print_rmacs_all_l3vni(struct vty *vty, -				       u_char use_json) +void zebra_vxlan_print_rmacs_all_l3vni(struct vty *vty, u_char use_json)  {  	struct zebra_ns *zns = NULL;  	json_object *json = NULL; @@ -4018,10 +3941,8 @@ void zebra_vxlan_print_rmacs_all_l3vni(struct vty *vty,  	}  } -void zebra_vxlan_print_specific_nh_l3vni(struct vty *vty, -					 vni_t l3vni, -					 struct ipaddr *ip, -					 u_char use_json) +void zebra_vxlan_print_specific_nh_l3vni(struct vty *vty, vni_t l3vni, +					 struct ipaddr *ip, u_char use_json)  {  	zebra_l3vni_t *zl3vni = NULL;  	zebra_neigh_t *n = NULL; @@ -4065,9 +3986,7 @@ void zebra_vxlan_print_specific_nh_l3vni(struct vty *vty,  	}  } -void zebra_vxlan_print_nh_l3vni(struct vty *vty, -				vni_t l3vni, -				u_char use_json) +void zebra_vxlan_print_nh_l3vni(struct vty *vty, vni_t l3vni, u_char use_json)  {  	u_int32_t num_nh;  	struct nh_walk_ctx wctx; @@ -4096,8 +4015,7 @@ void zebra_vxlan_print_nh_l3vni(struct vty *vty,  	wctx.vty = vty;  	wctx.json = json;  	if (!use_json) { -		vty_out(vty, -			"Number of NH Neighbors known for this VNI: %u\n", +		vty_out(vty, "Number of NH Neighbors known for this VNI: %u\n",  			num_nh);  		vty_out(vty, "%-15s %-17s\n", "IP", "RMAC");  	} else @@ -4112,8 +4030,7 @@ void zebra_vxlan_print_nh_l3vni(struct vty *vty,  	}  } -void zebra_vxlan_print_nh_all_l3vni(struct vty *vty, -				    u_char use_json) +void zebra_vxlan_print_nh_all_l3vni(struct vty *vty, u_char use_json)  {  	struct zebra_ns *zns = NULL;  	json_object *json = NULL; @@ -4197,17 +4114,14 @@ void zebra_vxlan_print_vrf_vni(struct vty *vty, struct zebra_vrf *zvrf,  	if (!json_vrfs) {  		vty_out(vty, "%-37s %-10u %-20s %-20s %-5s %-18s\n", -			zvrf_name(zvrf), -			zl3vni->vni, +			zvrf_name(zvrf), zl3vni->vni,  			zl3vni_vxlan_if_name(zl3vni), -			zl3vni_svi_if_name(zl3vni), -			zl3vni_state2str(zl3vni), +			zl3vni_svi_if_name(zl3vni), zl3vni_state2str(zl3vni),  			zl3vni_rmac2str(zl3vni, buf, sizeof(buf)));  	} else {  		json_object *json_vrf = NULL;  		json_vrf = json_object_new_object(); -		json_object_string_add(json_vrf, "vrf", -				       zvrf_name(zvrf)); +		json_object_string_add(json_vrf, "vrf", zvrf_name(zvrf));  		json_object_int_add(json_vrf, "vni", zl3vni->vni);  		json_object_string_add(json_vrf, "vxlanIntf",  				       zl3vni_vxlan_if_name(zl3vni)); @@ -4215,9 +4129,9 @@ void zebra_vxlan_print_vrf_vni(struct vty *vty, struct zebra_vrf *zvrf,  				       zl3vni_svi_if_name(zl3vni));  		json_object_string_add(json_vrf, "state",  				       zl3vni_state2str(zl3vni)); -		json_object_string_add(json_vrf, "routerMac", -				       zl3vni_rmac2str(zl3vni, buf, -						       sizeof(buf))); +		json_object_string_add( +			json_vrf, "routerMac", +			zl3vni_rmac2str(zl3vni, buf, sizeof(buf)));  		json_object_array_add(json_vrfs, json_vrf);  	}  } @@ -4690,10 +4604,9 @@ void zebra_vxlan_print_vnis(struct vty *vty, struct zebra_vrf *zvrf,  	if (use_json)  		json = json_object_new_object();  	else -		vty_out(vty, -			"%-10s %-4s %-21s %-8s %-8s %-15s %-37s\n", -			"VNI", "Type", "VxLAN IF", "# MACs", -			"# ARPs", "# Remote VTEPs", "Tenant VRF"); +		vty_out(vty, "%-10s %-4s %-21s %-8s %-8s %-15s %-37s\n", "VNI", +			"Type", "VxLAN IF", "# MACs", "# ARPs", +			"# Remote VTEPs", "Tenant VRF");  	args[0] = vty;  	args[1] = json; @@ -4754,8 +4667,8 @@ int zebra_vxlan_local_neigh_del(struct interface *ifp,  	if (IS_ZEBRA_DEBUG_VXLAN)  		zlog_debug("Del neighbor %s intf %s(%u) -> L2-VNI %u", -			   ipaddr2str(ip, buf, sizeof(buf)), -			   ifp->name, ifp->ifindex, zvni->vni); +			   ipaddr2str(ip, buf, sizeof(buf)), ifp->name, +			   ifp->ifindex, zvni->vni);  	/* If entry doesn't exist, nothing to do. */  	n = zvni_neigh_lookup(zvni, ip); @@ -4784,8 +4697,7 @@ int zebra_vxlan_local_neigh_del(struct interface *ifp,  	/* Remove neighbor from BGP. */  	if (IS_ZEBRA_NEIGH_ACTIVE(n)) -		zvni_neigh_send_del_to_client(zvni->vni, &n->ip, &n->emac, -					      0); +		zvni_neigh_send_del_to_client(zvni->vni, &n->ip, &n->emac, 0);  	/* Delete this neighbor entry. */  	zvni_neigh_del(zvni, n); @@ -4841,10 +4753,10 @@ int zebra_vxlan_local_neigh_add_update(struct interface *ifp,  	zmac = zvni_mac_lookup(zvni, macaddr);  	if (!zmac) {  		if (IS_ZEBRA_DEBUG_VXLAN) -			zlog_debug( -				"AUTO MAC %s created for neigh %s on VNI %u", -				prefix_mac2str(macaddr, buf, sizeof(buf)), -				ipaddr2str(ip, buf2, sizeof(buf2)), zvni->vni); +			zlog_debug("AUTO MAC %s created for neigh %s on VNI %u", +				   prefix_mac2str(macaddr, buf, sizeof(buf)), +				   ipaddr2str(ip, buf2, sizeof(buf2)), +				   zvni->vni);  		zmac = zvni_mac_add(zvni, macaddr);  		if (!zmac) { @@ -4865,8 +4777,7 @@ int zebra_vxlan_local_neigh_add_update(struct interface *ifp,  	n = zvni_neigh_lookup(zvni, ip);  	if (n) {  		if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_LOCAL)) { -			if (memcmp(n->emac.octet, macaddr->octet, -				   ETH_ALEN) +			if (memcmp(n->emac.octet, macaddr->octet, ETH_ALEN)  			    == 0) {  				/* Update any params and return - client doesn't  				 * care about a purely local change. @@ -5042,10 +4953,9 @@ int zebra_vxlan_remote_macip_del(struct zserv *client, u_short length,  			n = zvni_neigh_lookup(zvni, &ip);  		if (n && !mac) { -			zlog_err( -				"Failed to locate MAC %s for neigh %s VNI %u", -				prefix_mac2str(&macaddr, buf, sizeof(buf)), -				ipaddr2str(&ip, buf1, sizeof(buf1)), vni); +			zlog_err("Failed to locate MAC %s for neigh %s VNI %u", +				 prefix_mac2str(&macaddr, buf, sizeof(buf)), +				 ipaddr2str(&ip, buf1, sizeof(buf1)), vni);  			continue;  		} @@ -5057,13 +4967,13 @@ int zebra_vxlan_remote_macip_del(struct zserv *client, u_short length,  			continue;  		/* Ignore the delete if this mac is a gateway mac-ip */ -		if (mac && CHECK_FLAG(mac->flags, ZEBRA_MAC_LOCAL) && -		    CHECK_FLAG(mac->flags, ZEBRA_MAC_DEF_GW)) { -			zlog_err("%u: Ignore Del for  MAC %s neigh %s on VNI %u as it is configured as a default gateway", -				 zvrf_id(zvrf), -				 prefix_mac2str(&macaddr, buf, sizeof(buf)), -				 ipaddr2str(&ip, buf1, sizeof(buf1)), -				 vni); +		if (mac && CHECK_FLAG(mac->flags, ZEBRA_MAC_LOCAL) +		    && CHECK_FLAG(mac->flags, ZEBRA_MAC_DEF_GW)) { +			zlog_err( +				"%u: Ignore Del for  MAC %s neigh %s on VNI %u as it is configured as a default gateway", +				zvrf_id(zvrf), +				prefix_mac2str(&macaddr, buf, sizeof(buf)), +				ipaddr2str(&ip, buf1, sizeof(buf1)), vni);  			continue;  		} @@ -5078,8 +4988,7 @@ int zebra_vxlan_remote_macip_del(struct zserv *client, u_short length,  			 * if the MAC matches.  			 */  			if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_REMOTE) -			    && (memcmp(n->emac.octet, macaddr.octet, -				       ETH_ALEN) +			    && (memcmp(n->emac.octet, macaddr.octet, ETH_ALEN)  				== 0)) {  				zvni_neigh_uninstall(zvni, n);  				zvni_neigh_del(zvni, n); @@ -5087,8 +4996,7 @@ int zebra_vxlan_remote_macip_del(struct zserv *client, u_short length,  			}  		} else {  			if (CHECK_FLAG(mac->flags, ZEBRA_MAC_REMOTE)) { -				zvni_process_neigh_on_remote_mac_del(zvni, -								     mac); +				zvni_process_neigh_on_remote_mac_del(zvni, mac);  				if (list_isempty(mac->neigh_list)) {  					zvni_mac_uninstall(zvni, mac, 0); @@ -5134,8 +5042,9 @@ int zebra_vxlan_remote_macip_add(struct zserv *client, u_short length,  	memset(&vtep_ip, 0, sizeof(struct in_addr));  	if (!EVPN_ENABLED(zvrf)) { -		zlog_warn("%s: EVPN Not turned on yet we have received a remote_macip add zapi callback", -			  __PRETTY_FUNCTION__); +		zlog_warn( +			"%s: EVPN Not turned on yet we have received a remote_macip add zapi callback", +			__PRETTY_FUNCTION__);  		return -1;  	} @@ -5218,15 +5127,16 @@ int zebra_vxlan_remote_macip_add(struct zserv *client, u_short length,  		/* Ignore the update if the mac is already present  		   as a gateway mac */ -		if (mac && CHECK_FLAG(mac->flags, ZEBRA_MAC_DEF_GW) && -		    CHECK_FLAG(flags, ZEBRA_MACIP_TYPE_GW)) { +		if (mac && CHECK_FLAG(mac->flags, ZEBRA_MAC_DEF_GW) +		    && CHECK_FLAG(flags, ZEBRA_MACIP_TYPE_GW)) {  			if (IS_ZEBRA_DEBUG_VXLAN) -				zlog_debug("%u:Ignore MAC %s IP %s on VNI %u as MAC is already configured as gateway mac",  -					   zvrf_id(zvrf), -					   prefix_mac2str(&macaddr, -							  buf, sizeof(buf)), -					   ipaddr2str(&ip, buf1, -						      sizeof(buf1)), vni); +				zlog_debug( +					"%u:Ignore MAC %s IP %s on VNI %u as MAC is already configured as gateway mac", +					zvrf_id(zvrf), +					prefix_mac2str(&macaddr, buf, +						       sizeof(buf)), +					ipaddr2str(&ip, buf1, sizeof(buf1)), +					vni);  			continue;  		} @@ -5375,8 +5285,8 @@ int zebra_vxlan_check_del_local_mac(struct interface *ifp,  	if (IS_ZEBRA_DEBUG_VXLAN)  		zlog_debug(  			"Add/update remote MAC %s intf %s(%u) VNI %u - del local", -			prefix_mac2str(macaddr, buf, sizeof(buf)), -			ifp->name, ifp->ifindex, vni); +			prefix_mac2str(macaddr, buf, sizeof(buf)), ifp->name, +			ifp->ifindex, vni);  	/* Remove MAC from BGP. */  	zvni_mac_send_del_to_client(zvni->vni, macaddr, mac->flags); @@ -5540,11 +5450,10 @@ int zebra_vxlan_local_mac_add_update(struct interface *ifp,  	}  	if (IS_ZEBRA_DEBUG_VXLAN) -		zlog_debug( -			"Add/Update %sMAC %s intf %s(%u) VID %u -> VNI %u", -			sticky ? "sticky " : "", -			prefix_mac2str(macaddr, buf, sizeof(buf)), ifp->name, -			ifp->ifindex, vid, zvni->vni); +		zlog_debug("Add/Update %sMAC %s intf %s(%u) VID %u -> VNI %u", +			   sticky ? "sticky " : "", +			   prefix_mac2str(macaddr, buf, sizeof(buf)), ifp->name, +			   ifp->ifindex, vid, zvni->vni);  	/* If same entry already exists, nothing to do. */  	mac = zvni_mac_lookup(zvni, macaddr); @@ -5647,8 +5556,9 @@ int zebra_vxlan_remote_vtep_del(struct zserv *client, u_short length,  	struct zebra_if *zif;  	if (!is_evpn_enabled()) { -		zlog_warn("%s: EVPN is not enabled yet we have received a vtep del command", -			  __PRETTY_FUNCTION__); +		zlog_warn( +			"%s: EVPN is not enabled yet we have received a vtep del command", +			__PRETTY_FUNCTION__);  		return -1;  	} @@ -5731,8 +5641,9 @@ int zebra_vxlan_remote_vtep_add(struct zserv *client, u_short length,  	struct zebra_if *zif;  	if (!is_evpn_enabled()) { -		zlog_warn("%s: EVPN not enabled yet we received a vtep_add zapi call", -			  __PRETTY_FUNCTION__); +		zlog_warn( +			"%s: EVPN not enabled yet we received a vtep_add zapi call", +			__PRETTY_FUNCTION__);  		return -1;  	} @@ -5785,9 +5696,8 @@ int zebra_vxlan_remote_vtep_add(struct zserv *client, u_short length,  			continue;  		if (zvni_vtep_add(zvni, &vtep_ip) == NULL) { -			zlog_err( -				"Failed to add remote VTEP, VNI %u zvni %p", -				vni, zvni); +			zlog_err("Failed to add remote VTEP, VNI %u zvni %p", +				 vni, zvni);  			continue;  		} @@ -5986,9 +5896,10 @@ int zebra_vxlan_svi_up(struct interface *ifp, struct interface *link_if)  		}  		if (IS_ZEBRA_DEBUG_VXLAN) -			zlog_debug("SVI %s(%u) VNI %u VRF %s is UP, installing neighbors", -				   ifp->name, ifp->ifindex, zvni->vni, -				   vrf_id_to_name(ifp->vrf_id)); +			zlog_debug( +				"SVI %s(%u) VNI %u VRF %s is UP, installing neighbors", +				ifp->name, ifp->ifindex, zvni->vni, +				vrf_id_to_name(ifp->vrf_id));  		/* update the vrf information for l2-vni and inform bgp */  		zvni->vrf_id = ifp->vrf_id; @@ -5997,8 +5908,7 @@ int zebra_vxlan_svi_up(struct interface *ifp, struct interface *link_if)  		/* Install any remote neighbors for this VNI. */  		memset(&n_wctx, 0, sizeof(struct neigh_walk_ctx));  		n_wctx.zvni = zvni; -		hash_iterate(zvni->neigh_table, -			     zvni_install_neigh_hash, +		hash_iterate(zvni->neigh_table, zvni_install_neigh_hash,  			     &n_wctx);  	} @@ -6029,15 +5939,15 @@ int zebra_vxlan_if_down(struct interface *ifp)  	if (zl3vni) {  		/* process-if-down for l3-vni */  		if (IS_ZEBRA_DEBUG_VXLAN) -			zlog_debug("Intf %s(%u) L3-VNI %u is DOWN", -				   ifp->name, ifp->ifindex, vni); +			zlog_debug("Intf %s(%u) L3-VNI %u is DOWN", ifp->name, +				   ifp->ifindex, vni);  		zebra_vxlan_process_l3vni_oper_down(zl3vni);  	} else {  		/* process if-down for l2-vni */  		if (IS_ZEBRA_DEBUG_VXLAN) -			zlog_debug("Intf %s(%u) L2-VNI %u is DOWN", -				   ifp->name, ifp->ifindex, vni); +			zlog_debug("Intf %s(%u) L2-VNI %u is DOWN", ifp->name, +				   ifp->ifindex, vni);  		/* Locate hash entry; it is expected to exist. */  		zvni = zvni_lookup(vni); @@ -6087,8 +5997,8 @@ int zebra_vxlan_if_up(struct interface *ifp)  	if (zl3vni) {  		if (IS_ZEBRA_DEBUG_VXLAN) -			zlog_debug("Intf %s(%u) L3-VNI %u is UP", -				   ifp->name, ifp->ifindex, vni); +			zlog_debug("Intf %s(%u) L3-VNI %u is UP", ifp->name, +				   ifp->ifindex, vni);  		/* we need to associate with SVI, if any, we can associate with  		 * svi-if only after association with vxlan-intf is complete @@ -6102,8 +6012,8 @@ int zebra_vxlan_if_up(struct interface *ifp)  		struct interface *vlan_if = NULL;  		if (IS_ZEBRA_DEBUG_VXLAN) -			zlog_debug("Intf %s(%u) L2-VNI %u is UP", -				   ifp->name, ifp->ifindex, vni); +			zlog_debug("Intf %s(%u) L2-VNI %u is UP", ifp->name, +				   ifp->ifindex, vni);  		/* Locate hash entry; it is expected to exist. */  		zvni = zvni_lookup(vni); @@ -6160,8 +6070,8 @@ int zebra_vxlan_if_del(struct interface *ifp)  	if (zl3vni) {  		if (IS_ZEBRA_DEBUG_VXLAN) -			zlog_debug("Del L3-VNI %u intf %s(%u)", -				   vni, ifp->name, ifp->ifindex); +			zlog_debug("Del L3-VNI %u intf %s(%u)", vni, ifp->name, +				   ifp->ifindex);  		/* process oper-down for l3-vni */  		zebra_vxlan_process_l3vni_oper_down(zl3vni); @@ -6173,8 +6083,8 @@ int zebra_vxlan_if_del(struct interface *ifp)  		/* process if-del for l2-vni*/  		if (IS_ZEBRA_DEBUG_VXLAN) -			zlog_debug("Del L2-VNI %u intf %s(%u)", -				   vni, ifp->name, ifp->ifindex); +			zlog_debug("Del L2-VNI %u intf %s(%u)", vni, ifp->name, +				   ifp->ifindex);  		/* Locate hash entry; it is expected to exist. */  		zvni = zvni_lookup(vni); @@ -6236,8 +6146,8 @@ int zebra_vxlan_if_update(struct interface *ifp, u_int16_t chgflags)  		if (IS_ZEBRA_DEBUG_VXLAN)  			zlog_debug(  				"Update L3-VNI %u intf %s(%u) VLAN %u local IP %s master %u chg 0x%x", -				vni, ifp->name, ifp->ifindex, -				vxl->access_vlan, inet_ntoa(vxl->vtep_ip), +				vni, ifp->name, ifp->ifindex, vxl->access_vlan, +				inet_ntoa(vxl->vtep_ip),  				zif->brslave_info.bridge_ifindex, chgflags);  		/* Removed from bridge? Cleanup and return */ @@ -6258,7 +6168,7 @@ int zebra_vxlan_if_update(struct interface *ifp, u_int16_t chgflags)  				zl3vni->local_vtep_ip = vxl->vtep_ip;  				if (is_l3vni_oper_up(zl3vni))  					zebra_vxlan_process_l3vni_oper_up( -									zl3vni); +						zl3vni);  			}  		} @@ -6272,7 +6182,7 @@ int zebra_vxlan_if_update(struct interface *ifp, u_int16_t chgflags)  				zl3vni->local_vtep_ip = vxl->vtep_ip;  				if (is_l3vni_oper_up(zl3vni))  					zebra_vxlan_process_l3vni_oper_up( -									zl3vni); +						zl3vni);  			}  		} @@ -6298,8 +6208,8 @@ int zebra_vxlan_if_update(struct interface *ifp, u_int16_t chgflags)  		if (IS_ZEBRA_DEBUG_VXLAN)  			zlog_debug(  				"Update L2-VNI %u intf %s(%u) VLAN %u local IP %s master %u chg 0x%x", -				vni, ifp->name, ifp->ifindex, -				vxl->access_vlan, inet_ntoa(vxl->vtep_ip), +				vni, ifp->name, ifp->ifindex, vxl->access_vlan, +				inet_ntoa(vxl->vtep_ip),  				zif->brslave_info.bridge_ifindex, chgflags);  		/* Removed from bridge? Cleanup and return */ @@ -6353,8 +6263,7 @@ int zebra_vxlan_if_update(struct interface *ifp, u_int16_t chgflags)  			memset(&m_wctx, 0, sizeof(struct mac_walk_ctx));  			m_wctx.zvni = zvni; -			hash_iterate(zvni->mac_table, -				     zvni_install_mac_hash, +			hash_iterate(zvni->mac_table, zvni_install_mac_hash,  				     &m_wctx);  			memset(&n_wctx, 0, sizeof(struct neigh_walk_ctx)); @@ -6394,8 +6303,8 @@ int zebra_vxlan_if_add(struct interface *ifp)  		if (IS_ZEBRA_DEBUG_VXLAN)  			zlog_debug(  				"Add L3-VNI %u intf %s(%u) VLAN %u local IP %s master %u", -				vni, ifp->name, ifp->ifindex, -				vxl->access_vlan, inet_ntoa(vxl->vtep_ip), +				vni, ifp->name, ifp->ifindex, vxl->access_vlan, +				inet_ntoa(vxl->vtep_ip),  				zif->brslave_info.bridge_ifindex);  		/* associate with vxlan_if */ @@ -6440,10 +6349,10 @@ int zebra_vxlan_if_add(struct interface *ifp)  			zlog_debug(  				"Add L2-VNI %u VRF %s intf %s(%u) VLAN %u local IP %s master %u",  				vni, -				vlan_if ? vrf_id_to_name(vlan_if->vrf_id) : -					"Default", -				ifp->name, ifp->ifindex, -				vxl->access_vlan, inet_ntoa(vxl->vtep_ip), +				vlan_if ? vrf_id_to_name(vlan_if->vrf_id) +					: "Default", +				ifp->name, ifp->ifindex, vxl->access_vlan, +				inet_ntoa(vxl->vtep_ip),  				zif->brslave_info.bridge_ifindex);  		/* If down or not mapped to a bridge, we're done. */ @@ -6460,10 +6369,9 @@ int zebra_vxlan_if_add(struct interface *ifp)  	return 0;  } -int zebra_vxlan_process_vrf_vni_cmd(struct zebra_vrf *zvrf, -				    vni_t vni, -				    char *err, int err_str_sz, -				    int filter, int add) +int zebra_vxlan_process_vrf_vni_cmd(struct zebra_vrf *zvrf, vni_t vni, +				    char *err, int err_str_sz, int filter, +				    int add)  {  	zebra_l3vni_t *zl3vni = NULL;  	struct zebra_vrf *zvrf_default = NULL; @@ -6473,9 +6381,7 @@ int zebra_vxlan_process_vrf_vni_cmd(struct zebra_vrf *zvrf,  		return -1;  	if (IS_ZEBRA_DEBUG_VXLAN) -		zlog_debug("vrf %s vni %u %s", -			   zvrf_name(zvrf), -			   vni, +		zlog_debug("vrf %s vni %u %s", zvrf_name(zvrf), vni,  			   add ? "ADD" : "DEL");  	if (add) { @@ -6500,8 +6406,7 @@ int zebra_vxlan_process_vrf_vni_cmd(struct zebra_vrf *zvrf,  		/* add the L3-VNI to the global table */  		zl3vni = zl3vni_add(vni, zvrf_id(zvrf));  		if (!zl3vni) { -			snprintf(err, err_str_sz, -				 "Could not add L3-VNI"); +			snprintf(err, err_str_sz, "Could not add L3-VNI");  			return -1;  		} @@ -6526,8 +6431,8 @@ int zebra_vxlan_process_vrf_vni_cmd(struct zebra_vrf *zvrf,  		zl3vni->svi_if = zl3vni_map_to_svi_if(zl3vni);  		/* formulate l2vni list */ -		hash_iterate(zvrf_default->vni_table, -			     zvni_add_to_l3vni_list, zl3vni); +		hash_iterate(zvrf_default->vni_table, zvni_add_to_l3vni_list, +			     zl3vni);  		if (is_l3vni_oper_up(zl3vni))  			zebra_vxlan_process_l3vni_oper_up(zl3vni); @@ -6542,13 +6447,11 @@ int zebra_vxlan_process_vrf_vni_cmd(struct zebra_vrf *zvrf,  		zebra_vxlan_process_l3vni_oper_down(zl3vni);  		/* delete and uninstall all rmacs */ -		hash_iterate(zl3vni->rmac_table, -			     zl3vni_del_rmac_hash_entry, +		hash_iterate(zl3vni->rmac_table, zl3vni_del_rmac_hash_entry,  			     zl3vni);  		/* delete and uninstall all next-hops */ -		hash_iterate(zl3vni->nh_table, -			     zl3vni_del_nh_hash_entry, +		hash_iterate(zl3vni->nh_table, zl3vni_del_nh_hash_entry,  			     zl3vni);  		zvrf->l3vni = 0; @@ -6639,10 +6542,9 @@ int zebra_vxlan_advertise_subnet(struct zserv *client, u_short length,  		return 0;  	if (IS_ZEBRA_DEBUG_VXLAN) -		zlog_debug( -			"EVPN subnet Adv %s on VNI %d , currently %s", -			advertise ? "enabled" : "disabled", vni, -			zvni->advertise_subnet ? "enabled" : "disabled"); +		zlog_debug("EVPN subnet Adv %s on VNI %d , currently %s", +			   advertise ? "enabled" : "disabled", vni, +			   zvni->advertise_subnet ? "enabled" : "disabled");  	zvni->advertise_subnet = advertise; @@ -6659,8 +6561,8 @@ int zebra_vxlan_advertise_subnet(struct zserv *client, u_short length,  	zl2_info = zif->l2info.vxl; -	vlan_if = zvni_map_to_svi(zl2_info.access_vlan, -				  zif->brslave_info.br_if); +	vlan_if = +		zvni_map_to_svi(zl2_info.access_vlan, zif->brslave_info.br_if);  	if (!vlan_if)  		return 0; @@ -6729,9 +6631,8 @@ int zebra_vxlan_advertise_gw_macip(struct zserv *client, u_short length,  			zlog_debug(  				"EVPN gateway macip Adv %s on VNI %d , currently %s",  				advertise ? "enabled" : "disabled", vni, -				advertise_gw_macip_enabled(zvni) -					? "enabled" -					: "disabled"); +				advertise_gw_macip_enabled(zvni) ? "enabled" +								 : "disabled");  		if (zvni->advertise_gw_macip == advertise)  			return 0; @@ -6785,16 +6686,15 @@ stream_failure:   * when disabled, the entries should be deleted and remote VTEPs and MACs   * uninstalled from the kernel.   */ -int zebra_vxlan_advertise_all_vni(struct zserv *client, -				  u_short length, struct zebra_vrf *zvrf) +int zebra_vxlan_advertise_all_vni(struct zserv *client, u_short length, +				  struct zebra_vrf *zvrf)  {  	struct stream *s = NULL;  	int advertise = 0;  	struct zebra_ns *zns = NULL;  	if (zvrf_id(zvrf) != VRF_DEFAULT) { -		zlog_err("EVPN VNI Adv for non-default VRF %u", -			 zvrf_id(zvrf)); +		zlog_err("EVPN VNI Adv for non-default VRF %u", zvrf_id(zvrf));  		return -1;  	} diff --git a/zebra/zebra_vxlan.h b/zebra/zebra_vxlan.h index df9b07db60..7abf0050fc 100644 --- a/zebra/zebra_vxlan.h +++ b/zebra/zebra_vxlan.h @@ -36,8 +36,7 @@  /* Is EVPN enabled? */  #define EVPN_ENABLED(zvrf)  (zvrf)->advertise_all_vni -static inline int -is_evpn_enabled() +static inline int is_evpn_enabled()  {  	struct zebra_vrf *zvrf = NULL;  	zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT); @@ -97,11 +96,11 @@ extern void zebra_vxlan_print_vni(struct vty *vty, struct zebra_vrf *zvrf,  				  vni_t vni, u_char use_json);  extern void zebra_vxlan_print_vnis(struct vty *vty, struct zebra_vrf *zvrf,  				   u_char use_json); -extern void zebra_vxlan_print_rmacs_l3vni(struct vty *vty, vni_t vni, u_char -					  use_json); +extern void zebra_vxlan_print_rmacs_l3vni(struct vty *vty, vni_t vni, +					  u_char use_json);  extern void zebra_vxlan_print_rmacs_all_l3vni(struct vty *vty, u_char use_json); -extern void zebra_vxlan_print_nh_l3vni(struct vty *vty, vni_t vni, u_char -				       use_json); +extern void zebra_vxlan_print_nh_l3vni(struct vty *vty, vni_t vni, +				       u_char use_json);  extern void zebra_vxlan_print_nh_all_l3vni(struct vty *vty, u_char use_json);  extern void zebra_vxlan_print_l3vni(struct vty *vty, vni_t vni,  				    u_char use_json); @@ -118,10 +117,10 @@ extern int zebra_vxlan_local_neigh_add_update(  extern int zebra_vxlan_local_neigh_del(struct interface *ifp,  				       struct interface *link_if,  				       struct ipaddr *ip); -extern int zebra_vxlan_remote_macip_add(struct zserv *client, -					u_short length, struct zebra_vrf *zvrf); -extern int zebra_vxlan_remote_macip_del(struct zserv *client, -					u_short length, struct zebra_vrf *zvrf); +extern int zebra_vxlan_remote_macip_add(struct zserv *client, u_short length, +					struct zebra_vrf *zvrf); +extern int zebra_vxlan_remote_macip_del(struct zserv *client, u_short length, +					struct zebra_vrf *zvrf);  extern int zebra_vxlan_local_mac_add_update(struct interface *ifp,  					    struct interface *br_if,  					    struct ethaddr *mac, vlanid_t vid, @@ -141,21 +140,19 @@ extern int zebra_vxlan_if_down(struct interface *ifp);  extern int zebra_vxlan_if_add(struct interface *ifp);  extern int zebra_vxlan_if_update(struct interface *ifp, u_int16_t chgflags);  extern int zebra_vxlan_if_del(struct interface *ifp); -extern int zebra_vxlan_remote_vtep_add(struct zserv *client, -				       u_short length, struct zebra_vrf *zvrf); -extern int zebra_vxlan_remote_vtep_del(struct zserv *client, -				       u_short length, struct zebra_vrf *zvrf); +extern int zebra_vxlan_remote_vtep_add(struct zserv *client, u_short length, +				       struct zebra_vrf *zvrf); +extern int zebra_vxlan_remote_vtep_del(struct zserv *client, u_short length, +				       struct zebra_vrf *zvrf);  extern int zebra_vxlan_advertise_subnet(struct zserv *client, u_short length,  					struct zebra_vrf *zvrf); -extern int zebra_vxlan_advertise_gw_macip(struct zserv *client, -					  u_short length, +extern int zebra_vxlan_advertise_gw_macip(struct zserv *client, u_short length,  					  struct zebra_vrf *zvrf); -extern int zebra_vxlan_advertise_all_vni(struct zserv *client, -					 u_short length, +extern int zebra_vxlan_advertise_all_vni(struct zserv *client, u_short length,  					 struct zebra_vrf *zvrf);  extern int zebra_vxlan_process_vrf_vni_cmd(struct zebra_vrf *zvrf, vni_t vni, -					   char *err, -					   int err_str_sz, int filter, int add); +					   char *err, int err_str_sz, +					   int filter, int add);  extern void zebra_vxlan_init_tables(struct zebra_vrf *zvrf);  extern void zebra_vxlan_close_tables(struct zebra_vrf *);  extern void zebra_vxlan_cleanup_tables(struct zebra_vrf *); diff --git a/zebra/zebra_vxlan_null.c b/zebra/zebra_vxlan_null.c index 0eb880e848..1bac2cafb6 100644 --- a/zebra/zebra_vxlan_null.c +++ b/zebra/zebra_vxlan_null.c @@ -87,19 +87,19 @@ void zebra_vxlan_print_evpn(struct vty *vty, u_char uj)  {  } -void zebra_vxlan_print_rmacs_l3vni(struct vty*, vni_t, u_char) +void zebra_vxlan_print_rmacs_l3vni(struct vty *, vni_t, u_char)  {  } -void zebra_vxlan_print_rmacs_all_l3vni(struct vty*, u_char) +void zebra_vxlan_print_rmacs_all_l3vni(struct vty *, u_char)  {  } -void zebra_vxlan_print_nh_l3vni(struct vty*, vni_t, u_char) +void zebra_vxlan_print_nh_l3vni(struct vty *, vni_t, u_char)  {  } -void zebra_vxlan_print_nh_all_l3vni(struct vty*, u_char) +void zebra_vxlan_print_nh_all_l3vni(struct vty *, u_char)  {  } diff --git a/zebra/zebra_vxlan_private.h b/zebra/zebra_vxlan_private.h index e8de25cefd..6174c6a56d 100644 --- a/zebra/zebra_vxlan_private.h +++ b/zebra/zebra_vxlan_private.h @@ -180,10 +180,9 @@ static inline const char *zl3vni_rmac2str(zebra_l3vni_t *zl3vni, char *buf,   */  static inline int is_l3vni_oper_up(zebra_l3vni_t *zl3vni)  { -	return (is_evpn_enabled() && zl3vni && -		(zl3vni->vrf_id != VRF_UNKNOWN) && -		zl3vni->vxlan_if && if_is_operative(zl3vni->vxlan_if) && -		zl3vni->svi_if && if_is_operative(zl3vni->svi_if)); +	return (is_evpn_enabled() && zl3vni && (zl3vni->vrf_id != VRF_UNKNOWN) +		&& zl3vni->vxlan_if && if_is_operative(zl3vni->vxlan_if) +		&& zl3vni->svi_if && if_is_operative(zl3vni->svi_if));  }  static inline const char *zl3vni_state2str(zebra_l3vni_t *zl3vni) @@ -204,8 +203,7 @@ static inline vrf_id_t zl3vni_vrf_id(zebra_l3vni_t *zl3vni)  	return zl3vni->vrf_id;  } -static inline void zl3vni_get_rmac(zebra_l3vni_t *zl3vni, -				   struct ethaddr *rmac) +static inline void zl3vni_get_rmac(zebra_l3vni_t *zl3vni, struct ethaddr *rmac)  {  	if (!zl3vni)  		return; diff --git a/zebra/zserv.c b/zebra/zserv.c index bca8a509d8..8275ee1a3c 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -189,8 +189,8 @@ static void zserv_encode_vrf(struct stream *s, struct zebra_vrf *zvrf)  	data.l.table_id = zvrf->table_id;  	if (netns_name) -		strlcpy(data.l.netns_name, -			basename((char *)netns_name), NS_NAMSIZ); +		strlcpy(data.l.netns_name, basename((char *)netns_name), +			NS_NAMSIZ);  	else  		memset(data.l.netns_name, 0, NS_NAMSIZ);  	/* Pass the tableid and the netns NAME */ @@ -718,16 +718,18 @@ static int zserv_rnh_register(struct zserv *client, u_short length,  		l += 4;  		if (p.family == AF_INET) {  			if (p.prefixlen > IPV4_MAX_BITLEN) { -				zlog_warn("%s: Specified prefix length %d is too large for a v4 address", -					  __PRETTY_FUNCTION__, p.prefixlen); +				zlog_warn( +					"%s: Specified prefix length %d is too large for a v4 address", +					__PRETTY_FUNCTION__, p.prefixlen);  				return -1;  			}  			STREAM_GET(&p.u.prefix4.s_addr, s, IPV4_MAX_BYTELEN);  			l += IPV4_MAX_BYTELEN;  		} else if (p.family == AF_INET6) {  			if (p.prefixlen > IPV6_MAX_BITLEN) { -				zlog_warn("%s: Specified prefix length %d is to large for a v6 address", -					  __PRETTY_FUNCTION__, p.prefixlen); +				zlog_warn( +					"%s: Specified prefix length %d is to large for a v6 address", +					__PRETTY_FUNCTION__, p.prefixlen);  				return -1;  			}  			STREAM_GET(&p.u.prefix6, s, IPV6_MAX_BYTELEN); @@ -791,16 +793,18 @@ static int zserv_rnh_unregister(struct zserv *client, u_short length,  		l += 4;  		if (p.family == AF_INET) {  			if (p.prefixlen > IPV4_MAX_BITLEN) { -				zlog_warn("%s: Specified prefix length %d is to large for a v4 address", -					  __PRETTY_FUNCTION__, p.prefixlen); +				zlog_warn( +					"%s: Specified prefix length %d is to large for a v4 address", +					__PRETTY_FUNCTION__, p.prefixlen);  				return -1;  			}  			STREAM_GET(&p.u.prefix4.s_addr, s, IPV4_MAX_BYTELEN);  			l += IPV4_MAX_BYTELEN;  		} else if (p.family == AF_INET6) {  			if (p.prefixlen > IPV6_MAX_BITLEN) { -				zlog_warn("%s: Specified prefix length %d is to large for a v6 address", -					  __PRETTY_FUNCTION__, p.prefixlen); +				zlog_warn( +					"%s: Specified prefix length %d is to large for a v6 address", +					__PRETTY_FUNCTION__, p.prefixlen);  				return -1;  			}  			STREAM_GET(&p.u.prefix6, s, IPV6_MAX_BYTELEN); @@ -860,10 +864,12 @@ static int zserv_fec_register(struct zserv *client, u_short length)  			return -1;  		}  		STREAM_GETC(s, p.prefixlen); -		if ((p.family == AF_INET && p.prefixlen > IPV4_MAX_BITLEN) || -		    (p.family == AF_INET6 && p.prefixlen > IPV6_MAX_BITLEN)) { -			zlog_warn("%s: Specified prefix length: %d is to long for %d", -				  __PRETTY_FUNCTION__, p.prefixlen, p.family); +		if ((p.family == AF_INET && p.prefixlen > IPV4_MAX_BITLEN) +		    || (p.family == AF_INET6 +			&& p.prefixlen > IPV6_MAX_BITLEN)) { +			zlog_warn( +				"%s: Specified prefix length: %d is to long for %d", +				__PRETTY_FUNCTION__, p.prefixlen, p.family);  			return -1;  		}  		l += 5; @@ -920,10 +926,12 @@ static int zserv_fec_unregister(struct zserv *client, u_short length)  			return -1;  		}  		STREAM_GETC(s, p.prefixlen); -		if ((p.family == AF_INET && p.prefixlen > IPV4_MAX_BITLEN) || -		    (p.family == AF_INET6 && p.prefixlen > IPV6_MAX_BITLEN)) { -			zlog_warn("%s: Received prefix length %d which is greater than %d can support", -				  __PRETTY_FUNCTION__, p.prefixlen, p.family); +		if ((p.family == AF_INET && p.prefixlen > IPV4_MAX_BITLEN) +		    || (p.family == AF_INET6 +			&& p.prefixlen > IPV6_MAX_BITLEN)) { +			zlog_warn( +				"%s: Received prefix length %d which is greater than %d can support", +				__PRETTY_FUNCTION__, p.prefixlen, p.family);  			return -1;  		}  		l += 5; @@ -1180,8 +1188,7 @@ static int zread_route_add(struct zserv *client, u_short length,  				memset(&vtep_ip, 0, sizeof(struct ipaddr));  				if (CHECK_FLAG(api.flags,  					       ZEBRA_FLAG_EVPN_ROUTE)) { -					ifindex = -						get_l3vni_svi_ifindex(vrf_id); +					ifindex = get_l3vni_svi_ifindex(vrf_id);  				} else {  					ifindex = api_nh->ifindex;  				} @@ -1202,10 +1209,8 @@ static int zread_route_add(struct zserv *client, u_short length,  					       &(api_nh->gate.ipv4),  					       sizeof(struct in_addr));  					zebra_vxlan_evpn_vrf_route_add( -								vrf_id, -								&api.rmac, -								&vtep_ip, -								&api.prefix); +						vrf_id, &api.rmac, &vtep_ip, +						&api.prefix);  				}  				break;  			} @@ -1225,8 +1230,9 @@ static int zread_route_add(struct zserv *client, u_short length,  			}  			if (!nexthop) { -				zlog_warn("%s: Nexthops Specified: %d but we failed to properly create one", -					  __PRETTY_FUNCTION__, api.nexthop_num); +				zlog_warn( +					"%s: Nexthops Specified: %d but we failed to properly create one", +					__PRETTY_FUNCTION__, api.nexthop_num);  				nexthops_free(re->nexthop);  				XFREE(MTYPE_RE, re);  				return -1; @@ -1374,8 +1380,9 @@ static int zread_ipv4_add(struct zserv *client, u_short length,  	p.family = AF_INET;  	STREAM_GETC(s, p.prefixlen);  	if (p.prefixlen > IPV4_MAX_BITLEN) { -		zlog_warn("%s: Specified prefix length %d is greater than what v4 can be", -			  __PRETTY_FUNCTION__, p.prefixlen); +		zlog_warn( +			"%s: Specified prefix length %d is greater than what v4 can be", +			__PRETTY_FUNCTION__, p.prefixlen);  		XFREE(MTYPE_RE, re);  		return -1;  	} @@ -1424,8 +1431,9 @@ static int zread_ipv4_add(struct zserv *client, u_short length,  					re->vrf_id);  				break;  			case NEXTHOP_TYPE_IPV6: -				zlog_warn("%s: Please use ZEBRA_ROUTE_ADD if you want to pass v6 nexthops", -					  __PRETTY_FUNCTION__); +				zlog_warn( +					"%s: Please use ZEBRA_ROUTE_ADD if you want to pass v6 nexthops", +					__PRETTY_FUNCTION__);  				nexthops_free(re->nexthop);  				XFREE(MTYPE_RE, re);  				return -1; @@ -1434,8 +1442,9 @@ static int zread_ipv4_add(struct zserv *client, u_short length,  				route_entry_nexthop_blackhole_add(re, bh_type);  				break;  			default: -				zlog_warn("%s: Specified nexthop type: %d does not exist", -					  __PRETTY_FUNCTION__, nexthop_type); +				zlog_warn( +					"%s: Specified nexthop type: %d does not exist", +					__PRETTY_FUNCTION__, nexthop_type);  				nexthops_free(re->nexthop);  				XFREE(MTYPE_RE, re);  				return -1; @@ -1585,8 +1594,9 @@ static int zread_ipv4_route_ipv6_nexthop_add(struct zserv *client,  	p.family = AF_INET;  	STREAM_GETC(s, p.prefixlen);  	if (p.prefixlen > IPV4_MAX_BITLEN) { -		zlog_warn("%s: Prefix Length %d is greater than what a v4 address can use", -			  __PRETTY_FUNCTION__, p.prefixlen); +		zlog_warn( +			"%s: Prefix Length %d is greater than what a v4 address can use", +			__PRETTY_FUNCTION__, p.prefixlen);  		XFREE(MTYPE_RE, re);  		return -1;  	} @@ -1638,8 +1648,9 @@ static int zread_ipv4_route_ipv6_nexthop_add(struct zserv *client,  				route_entry_nexthop_blackhole_add(re, bh_type);  				break;  			default: -				zlog_warn("%s: Please use ZEBRA_ROUTE_ADD if you want to pass non v6 nexthops", -					  __PRETTY_FUNCTION__); +				zlog_warn( +					"%s: Please use ZEBRA_ROUTE_ADD if you want to pass non v6 nexthops", +					__PRETTY_FUNCTION__);  				nexthops_free(re->nexthop);  				XFREE(MTYPE_RE, re);  				return -1; @@ -1758,8 +1769,9 @@ static int zread_ipv6_add(struct zserv *client, u_short length,  	p.family = AF_INET6;  	STREAM_GETC(s, p.prefixlen);  	if (p.prefixlen > IPV6_MAX_BITLEN) { -		zlog_warn("%s: Specified prefix length %d is to large for v6 prefix", -			  __PRETTY_FUNCTION__, p.prefixlen); +		zlog_warn( +			"%s: Specified prefix length %d is to large for v6 prefix", +			__PRETTY_FUNCTION__, p.prefixlen);  		XFREE(MTYPE_RE, re);  		return -1;  	} @@ -1770,8 +1782,9 @@ static int zread_ipv6_add(struct zserv *client, u_short length,  		src_p.family = AF_INET6;  		STREAM_GETC(s, src_p.prefixlen);  		if (src_p.prefixlen > IPV6_MAX_BITLEN) { -			zlog_warn("%s: Specified src prefix length %d is to large for v6 prefix", -				  __PRETTY_FUNCTION__, src_p.prefixlen); +			zlog_warn( +				"%s: Specified src prefix length %d is to large for v6 prefix", +				__PRETTY_FUNCTION__, src_p.prefixlen);  			XFREE(MTYPE_RE, re);  			return -1;  		} @@ -1831,8 +1844,9 @@ static int zread_ipv6_add(struct zserv *client, u_short length,  				route_entry_nexthop_blackhole_add(re, bh_type);  				break;  			default: -				zlog_warn("%s: Please use ZEBRA_ROUTE_ADD if you want to pass non v6 nexthops", -					  __PRETTY_FUNCTION__); +				zlog_warn( +					"%s: Please use ZEBRA_ROUTE_ADD if you want to pass non v6 nexthops", +					__PRETTY_FUNCTION__);  				nexthops_free(re->nexthop);  				XFREE(MTYPE_RE, re);  				return -1; @@ -2035,9 +2049,9 @@ static void zread_mpls_labels(int command, struct zserv *client, u_short length,  		STREAM_GET(&prefix.u.prefix4.s_addr, s, IPV4_MAX_BYTELEN);  		STREAM_GETC(s, prefix.prefixlen);  		if (prefix.prefixlen > IPV4_MAX_BITLEN) { -			zlog_warn("%s: Specified prefix length %d is greater than a v4 address can support", -				  __PRETTY_FUNCTION__, -				  prefix.prefixlen); +			zlog_warn( +				"%s: Specified prefix length %d is greater than a v4 address can support", +				__PRETTY_FUNCTION__, prefix.prefixlen);  			return;  		}  		STREAM_GET(&gate.ipv4.s_addr, s, IPV4_MAX_BYTELEN); @@ -2046,9 +2060,9 @@ static void zread_mpls_labels(int command, struct zserv *client, u_short length,  		STREAM_GET(&prefix.u.prefix6, s, 16);  		STREAM_GETC(s, prefix.prefixlen);  		if (prefix.prefixlen > IPV6_MAX_BITLEN) { -			zlog_warn("%s: Specified prefix length %d is greater than a v6 address can support", -				  __PRETTY_FUNCTION__, -				  prefix.prefixlen); +			zlog_warn( +				"%s: Specified prefix length %d is greater than a v6 address can support", +				__PRETTY_FUNCTION__, prefix.prefixlen);  			return;  		}  		STREAM_GET(&gate.ipv6, s, 16); @@ -2237,13 +2251,11 @@ static void zread_label_manager_request(int cmd, struct zserv *client,  	/* external label manager */  	if (lm_is_external) -		zread_relay_label_manager_request(cmd, client, -						  zvrf_id(zvrf)); +		zread_relay_label_manager_request(cmd, client, zvrf_id(zvrf));  	/* this is a label manager */  	else {  		if (cmd == ZEBRA_LABEL_MANAGER_CONNECT) -			zread_label_manager_connect(client, -						    zvrf_id(zvrf)); +			zread_label_manager_connect(client, zvrf_id(zvrf));  		else {  			/* Sanity: don't allow 'unidentified' requests */  			if (!client->proto) { @@ -2252,8 +2264,7 @@ static void zread_label_manager_request(int cmd, struct zserv *client,  				return;  			}  			if (cmd == ZEBRA_GET_LABEL_CHUNK) -				zread_get_label_chunk(client, -						      zvrf_id(zvrf)); +				zread_get_label_chunk(client, zvrf_id(zvrf));  			else if (cmd == ZEBRA_RELEASE_LABEL_CHUNK)  				zread_release_label_chunk(client);  		} @@ -2479,8 +2490,7 @@ static void zebra_client_create(int sock)  	zebra_vrf_update_all(client);  } -static int zread_interface_set_master(struct zserv *client, -				      u_short length) +static int zread_interface_set_master(struct zserv *client, u_short length)  {  	struct interface *master;  	struct interface *slave; @@ -2506,8 +2516,7 @@ stream_failure:  } -static void zread_vrf_label(struct zserv *client, -			    struct zebra_vrf *zvrf) +static void zread_vrf_label(struct zserv *client, struct zebra_vrf *zvrf)  {  	struct interface *ifp;  	mpls_label_t nlabel; @@ -2546,7 +2555,7 @@ static void zread_vrf_label(struct zserv *client,  		bool really_remove;  		really_remove = true; -		for (scrubber = AFI_IP; scrubber < AFI_MAX ; scrubber++) { +		for (scrubber = AFI_IP; scrubber < AFI_MAX; scrubber++) {  			if (scrubber == afi)  				continue; @@ -2566,16 +2575,16 @@ static void zread_vrf_label(struct zserv *client,  	}  	if (nlabel != MPLS_LABEL_NONE) -		mpls_lsp_install(def_zvrf, ltype, nlabel, MPLS_LABEL_IMPLICIT_NULL, -				 NEXTHOP_TYPE_IFINDEX, NULL, ifp->ifindex); +		mpls_lsp_install(def_zvrf, ltype, nlabel, +				 MPLS_LABEL_IMPLICIT_NULL, NEXTHOP_TYPE_IFINDEX, +				 NULL, ifp->ifindex);  	zvrf->label[afi] = nlabel;  stream_failure:  	return;  } -static inline void zserv_handle_commands(struct zserv *client, -					 uint16_t command, +static inline void zserv_handle_commands(struct zserv *client, uint16_t command,  					 uint16_t length,  					 struct zebra_vrf *zvrf)  { @@ -2633,20 +2642,17 @@ static inline void zserv_handle_commands(struct zserv *client,  		zread_hello(client);  		break;  	case ZEBRA_NEXTHOP_REGISTER: -		zserv_rnh_register(client, length, RNH_NEXTHOP_TYPE, -				   zvrf); +		zserv_rnh_register(client, length, RNH_NEXTHOP_TYPE, zvrf);  		break;  	case ZEBRA_NEXTHOP_UNREGISTER: -		zserv_rnh_unregister(client, length, RNH_NEXTHOP_TYPE, -				     zvrf); +		zserv_rnh_unregister(client, length, RNH_NEXTHOP_TYPE, zvrf);  		break;  	case ZEBRA_IMPORT_ROUTE_REGISTER: -		zserv_rnh_register(client, length, RNH_IMPORT_CHECK_TYPE, -				   zvrf); +		zserv_rnh_register(client, length, RNH_IMPORT_CHECK_TYPE, zvrf);  		break;  	case ZEBRA_IMPORT_ROUTE_UNREGISTER: -		zserv_rnh_unregister(client, length, -				     RNH_IMPORT_CHECK_TYPE, zvrf); +		zserv_rnh_unregister(client, length, RNH_IMPORT_CHECK_TYPE, +				     zvrf);  		break;  	case ZEBRA_BFD_DEST_UPDATE:  	case ZEBRA_BFD_DEST_REGISTER: @@ -2779,14 +2785,15 @@ static int zebra_client_read(struct thread *thread)  		if ((already = stream_get_endp(client->ibuf))  		    < ZEBRA_HEADER_SIZE) {  			ssize_t nbyte; -			if (((nbyte = -			      stream_read_try(client->ibuf, sock, -					      ZEBRA_HEADER_SIZE - already)) +			if (((nbyte = stream_read_try(client->ibuf, sock, +						      ZEBRA_HEADER_SIZE +							      - already))  			     == 0)  			    || (nbyte == -1)) {  				if (IS_ZEBRA_DEBUG_EVENT) -					zlog_debug("connection closed socket [%d]", -						   sock); +					zlog_debug( +						"connection closed socket [%d]", +						sock);  				zebra_client_close(client);  				return -1;  			} @@ -2859,11 +2866,13 @@ static int zebra_client_read(struct thread *thread)  		/* Debug packet information. */  		if (IS_ZEBRA_DEBUG_EVENT) -			zlog_debug("zebra message comes from socket [%d]", sock); +			zlog_debug("zebra message comes from socket [%d]", +				   sock);  		if (IS_ZEBRA_DEBUG_PACKET && IS_ZEBRA_DEBUG_RECV)  			zlog_debug("zebra message received [%s] %d in VRF %u", -				   zserv_command_string(command), length, vrf_id); +				   zserv_command_string(command), length, +				   vrf_id);  		client->last_read_time = monotime(NULL);  		client->last_read_cmd = command; @@ -2871,14 +2880,16 @@ static int zebra_client_read(struct thread *thread)  		zvrf = zebra_vrf_lookup_by_id(vrf_id);  		if (!zvrf) {  			if (IS_ZEBRA_DEBUG_PACKET && IS_ZEBRA_DEBUG_RECV) -				zlog_debug("zebra received unknown VRF[%u]", vrf_id); +				zlog_debug("zebra received unknown VRF[%u]", +					   vrf_id);  			goto zclient_read_out;  		}  		zserv_handle_commands(client, command, length, zvrf);  		if (client->t_suicide) { -			/* No need to wait for thread callback, just kill immediately. +			/* No need to wait for thread callback, just kill +			 * immediately.  			 */  			zebra_client_close(client);  			return -1; @@ -3136,8 +3147,7 @@ struct zserv *zebra_find_client(u_char proto, u_short instance)  	struct zserv *client;  	for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client)) { -		if (client->proto == proto && -		    client->instance == instance) +		if (client->proto == proto && client->instance == instance)  			return client;  	} @@ -3196,7 +3206,7 @@ void zserv_read_file(char *input)  	client = zebrad.client_list->head->data;  	t.arg = client; -	fd = open(input, O_RDONLY|O_NONBLOCK); +	fd = open(input, O_RDONLY | O_NONBLOCK);  	t.u.fd = fd;  	zebra_client_read(&t); diff --git a/zebra/zserv.h b/zebra/zserv.h index 2044816227..4f0f5b0461 100644 --- a/zebra/zserv.h +++ b/zebra/zserv.h @@ -137,15 +137,15 @@ struct zebra_t {  	/* default table */  	u_int32_t rtm_table_default; -	/* rib work queue */ -	#define ZEBRA_RIB_PROCESS_HOLD_TIME 10 +/* rib work queue */ +#define ZEBRA_RIB_PROCESS_HOLD_TIME 10  	struct work_queue *ribq;  	struct meta_queue *mq;  	/* LSP work queue */  	struct work_queue *lsp_process_q; -	#define ZEBRA_ZAPI_PACKETS_TO_PROCESS 10 +#define ZEBRA_ZAPI_PACKETS_TO_PROCESS 10  	u_int32_t packets_to_process;  };  extern struct zebra_t zebrad;  | 
