@@ -4023,14 +4023,21 @@ static void bgp_mplsvpn_nh_label_bind_send_nexthop_label(
4023
4023
}
4024
4024
p = & pfx_nh ;
4025
4025
if (nh -> nh_label ) {
4026
- if (nh -> nh_label -> num_labels >
4027
- MPLS_MAX_LABELS - num_labels )
4028
- lsp_num_labels = MPLS_MAX_LABELS - num_labels ;
4029
- else
4030
- lsp_num_labels = nh -> nh_label -> num_labels ;
4026
+ if (nh -> nh_label -> num_labels + 1 > MPLS_MAX_LABELS ) {
4027
+ /* label stack overflow. no label switching will be performed
4028
+ */
4029
+ flog_err (EC_BGP_LABEL ,
4030
+ "%s [Error] BGP label %u->%u to %pFX, forged label stack too big: %u. Abort LSP installation" ,
4031
+ bmnc -> bgp_vpn -> name_pretty ,
4032
+ bmnc -> new_label , bmnc -> orig_label ,
4033
+ & bmnc -> nexthop ,
4034
+ nh -> nh_label -> num_labels + 1 );
4035
+ return ;
4036
+ }
4037
+ lsp_num_labels = nh -> nh_label -> num_labels ;
4031
4038
for (i = 0 ; i < lsp_num_labels ; i ++ )
4032
4039
label [num_labels + i ] = nh -> nh_label -> label [i ];
4033
- num_labels + = lsp_num_labels ;
4040
+ num_labels = lsp_num_labels ;
4034
4041
}
4035
4042
label [num_labels ] = bmnc -> orig_label ;
4036
4043
num_labels += 1 ;
@@ -4239,15 +4246,13 @@ void bgp_mplsvpn_nh_label_bind_register_local_label(struct bgp *bgp,
4239
4246
return ;
4240
4247
4241
4248
bgp_mplsvpn_path_nh_label_bind_unlink (pi );
4242
- if (bmnc ) {
4243
- /* updates NHT pi list reference */
4244
- LIST_INSERT_HEAD (& (bmnc -> paths ), pi ,
4245
- mplsvpn .bmnc .nh_label_bind_thread );
4246
- pi -> mplsvpn .bmnc .nh_label_bind_cache = bmnc ;
4247
- pi -> mplsvpn .bmnc .nh_label_bind_cache -> path_count ++ ;
4248
- SET_FLAG (pi -> flags , BGP_PATH_MPLSVPN_NH_LABEL_BIND );
4249
- bmnc -> last_update = monotime (NULL );
4250
- }
4249
+
4250
+ /* updates NHT pi list reference */
4251
+ LIST_INSERT_HEAD (& (bmnc -> paths ), pi , mplsvpn .bmnc .nh_label_bind_thread );
4252
+ pi -> mplsvpn .bmnc .nh_label_bind_cache = bmnc ;
4253
+ pi -> mplsvpn .bmnc .nh_label_bind_cache -> path_count ++ ;
4254
+ SET_FLAG (pi -> flags , BGP_PATH_MPLSVPN_NH_LABEL_BIND );
4255
+ bmnc -> last_update = monotime (NULL );
4251
4256
4252
4257
/* Add or update the selected nexthop */
4253
4258
if (!bmnc -> nh )
0 commit comments