diff options
| author | Mark Stapp <mjs@voltanet.io> | 2019-11-08 14:13:33 -0500 | 
|---|---|---|
| committer | Mark Stapp <mjs@voltanet.io> | 2020-03-27 09:37:02 -0400 | 
| commit | e4a1ec7454490af0ea45013cb279eb9b15edef51 (patch) | |
| tree | eb93d94f2b0e726a70dea73eeb8deeb18bb2be57 /lib/nexthop.c | |
| parent | ee8606ee39a50b8a644352be4881a77a5822911d (diff) | |
zebra,lib: use const in more apis
Use const with some args to ipaddr, zebra vxlan, mpls
lsp, and nexthop apis; add some extra checks to some
nexthop-related apis.
Signed-off-by: Mark Stapp <mjs@voltanet.io>
Diffstat (limited to 'lib/nexthop.c')
| -rw-r--r-- | lib/nexthop.c | 13 | 
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/nexthop.c b/lib/nexthop.c index c3be0a71e6..68ce81c293 100644 --- a/lib/nexthop.c +++ b/lib/nexthop.c @@ -393,8 +393,8 @@ struct nexthop *nexthop_from_blackhole(enum blackhole_type bh_type)  }  /* Update nexthop with label information. */ -void nexthop_add_labels(struct nexthop *nexthop, enum lsp_types_t type, -			uint8_t num_labels, mpls_label_t *label) +void nexthop_add_labels(struct nexthop *nexthop, enum lsp_types_t ltype, +			uint8_t num_labels, const mpls_label_t *labels)  {  	struct mpls_label_stack *nh_label;  	int i; @@ -402,13 +402,18 @@ void nexthop_add_labels(struct nexthop *nexthop, enum lsp_types_t type,  	if (num_labels == 0)  		return; -	nexthop->nh_label_type = type; +	/* Enforce limit on label stack size */ +	if (num_labels > MPLS_MAX_LABELS) +		num_labels = MPLS_MAX_LABELS; + +	nexthop->nh_label_type = ltype; +  	nh_label = XCALLOC(MTYPE_NH_LABEL,  			   sizeof(struct mpls_label_stack)  				   + num_labels * sizeof(mpls_label_t));  	nh_label->num_labels = num_labels;  	for (i = 0; i < num_labels; i++) -		nh_label->label[i] = *(label + i); +		nh_label->label[i] = *(labels + i);  	nexthop->nh_label = nh_label;  }  | 
