From d5ea1185d58ab8fed07e80f2d261fa8e1b0c3624 Mon Sep 17 00:00:00 2001 From: Stephen Worley Date: Mon, 5 Apr 2021 17:12:01 -0400 Subject: [PATCH] lib: add label_type as field in zapi_nexthop Add the ability to specify the label type along with the labels you are passing to zebra in zapi_nexthop. This is needed as we abstract the label code to be re-used by evpn as well as mpls. Protocols need to be able to set the type of label they have attached. Signed-off-by: Stephen Worley --- lib/zclient.c | 3 +++ lib/zclient.h | 1 + zebra/zapi_msg.c | 5 +++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/zclient.c b/lib/zclient.c index d748bef335..42d5c33a1b 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -1035,6 +1035,7 @@ int zapi_nexthop_encode(struct stream *s, const struct zapi_nexthop *api_nh, */ if (api_nh->label_num > 0) { stream_putc(s, api_nh->label_num); + stream_putc(s, api_nh->label_type); stream_put(s, &api_nh->labels[0], api_nh->label_num * sizeof(mpls_label_t)); } @@ -1397,6 +1398,7 @@ int zapi_nexthop_decode(struct stream *s, struct zapi_nexthop *api_nh, /* MPLS labels for BGP-LU or Segment Routing */ if (CHECK_FLAG(api_nh->flags, ZAPI_NEXTHOP_FLAG_LABEL)) { STREAM_GETC(s, api_nh->label_num); + STREAM_GETC(s, api_nh->label_type); if (api_nh->label_num > MPLS_MAX_LABELS) { flog_err( EC_LIB_ZAPI_ENCODE, @@ -1948,6 +1950,7 @@ int zapi_nexthop_from_nexthop(struct zapi_nexthop *znh, znh->labels[i] = nh->nh_label->label[i]; znh->label_num = i; + znh->label_type = nh->nh_label_type; SET_FLAG(znh->flags, ZAPI_NEXTHOP_FLAG_LABEL); } diff --git a/lib/zclient.h b/lib/zclient.h index 8c4ce1b777..55957e4bee 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -427,6 +427,7 @@ struct zapi_nexthop { /* MPLS labels for BGP-LU or Segment Routing */ uint8_t label_num; + enum lsp_types_t label_type; mpls_label_t labels[MPLS_MAX_LABELS]; struct ethaddr rmac; diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index 3288373dbe..15b5790923 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -1785,8 +1785,9 @@ static bool zapi_read_nexthops(struct zserv *client, struct prefix *p, && api_nh->type != NEXTHOP_TYPE_BLACKHOLE && api_nh->label_num > 0) { - if (CHECK_FLAG(flags, ZEBRA_FLAG_EVPN_ROUTE)) - label_type = ZEBRA_LSP_EVPN; + /* If label type was passed, use it */ + if (api_nh->label_type) + label_type = api_nh->label_type; else label_type = lsp_type_from_re_type(client->proto);