From 57592a53b5c02094f915a8444d40d2361d31e972 Mon Sep 17 00:00:00 2001 From: Anton Degtyarev Date: Wed, 14 Nov 2018 06:14:04 +0300 Subject: bgpd, zebra: auto assign labels from label pool to regular prefixes in BGP labeled unicast This commit is the last missing piece to complete BGP LU support in bgpd. To this moment, bgpd (and zebra) supported auto label assignment only for prefixes leaked from VRFs to vpn and for MPLS SR prefixes. This adds auto label assignment to other routes types in bgpd. The following enhancements have been made: * bgp_route.c:bgp_process_main_one() now sets implicit-null local_label to all local, aggregate and redistributed routes. * bgp_route.c:bgp_process_main_one() now will request a label from the label pool for any prefix that loses the label for some reason (for example, when the static label assignment config is removed) * bgp_label.c:bgp_reg_dereg_for_label() now requests labels from label pool for routes which have no associated label index * zebra_mpls.c:zebra_mpls_fec_register() now expects both label and label_index from the calling function, one of which must be set to MPLS_INVALID_LABEL or MPLS_INVALID_LABEL_INDEX, based on this it will decide how to register the provided FEC. Signed-off-by: Anton Degtyarev --- zebra/zapi_msg.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'zebra/zapi_msg.c') diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index 9b84a6e58a..26a3cd5b42 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -1187,6 +1187,7 @@ static void zread_fec_register(ZAPI_HANDLER_ARGS) unsigned short l = 0; struct prefix p; uint16_t flags; + uint32_t label = MPLS_INVALID_LABEL; uint32_t label_index = MPLS_INVALID_LABEL_INDEX; s = msg; @@ -1229,12 +1230,15 @@ static void zread_fec_register(ZAPI_HANDLER_ARGS) l += 5; STREAM_GET(&p.u.prefix, s, PSIZE(p.prefixlen)); l += PSIZE(p.prefixlen); - if (flags & ZEBRA_FEC_REGISTER_LABEL_INDEX) { + if (flags & ZEBRA_FEC_REGISTER_LABEL) { + STREAM_GETL(s, label); + l += 4; + } else if (flags & ZEBRA_FEC_REGISTER_LABEL_INDEX) { STREAM_GETL(s, label_index); l += 4; - } else - label_index = MPLS_INVALID_LABEL_INDEX; - zebra_mpls_fec_register(zvrf, &p, label_index, client); + } + + zebra_mpls_fec_register(zvrf, &p, label, label_index, client); } stream_failure: -- cgit v1.2.3