summaryrefslogtreecommitdiff
path: root/lib/mpls.c
diff options
context:
space:
mode:
authorStephen Worley <sworley@nvidia.com>2021-04-01 11:31:44 -0400
committerStephen Worley <sworley@nvidia.com>2023-02-13 18:12:05 -0500
commit4645cb6bc2a4635925dae16533d6277b8da376c4 (patch)
tree4b1c93288f7125cb20dda7e5e3b81bd29dd06364 /lib/mpls.c
parent78d106e1cbb0af335409f60ababe5a2649da9704 (diff)
lib,zebra,bgpd,staticd: use label code to store VNI info
Use the already existing mpls label code to store VNI info for vxlan. VNI's are defined as labels just like mpls, we should be using the same code for both. This patch is the first part of that. Next we will need to abstract the label code to not be so mpls specific. Currently in this, we are just treating VXLAN as a label type and storing it that way. Signed-off-by: Stephen Worley <sworley@nvidia.com>
Diffstat (limited to 'lib/mpls.c')
-rw-r--r--lib/mpls.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/mpls.c b/lib/mpls.c
index ac5792a686..1b21dd29ff 100644
--- a/lib/mpls.c
+++ b/lib/mpls.c
@@ -80,7 +80,7 @@ int mpls_str2label(const char *label_str, uint8_t *num_labels,
* Label to string conversion, labels in string separated by '/'.
*/
char *mpls_label2str(uint8_t num_labels, const mpls_label_t *labels, char *buf,
- int len, int pretty)
+ int len, enum lsp_types_t type, int pretty)
{
char label_buf[BUFSIZ];
int i;
@@ -90,9 +90,14 @@ char *mpls_label2str(uint8_t num_labels, const mpls_label_t *labels, char *buf,
if (i != 0)
strlcat(buf, "/", len);
if (pretty)
- label2str(labels[i], label_buf, sizeof(label_buf));
+ label2str(labels[i], type, label_buf,
+ sizeof(label_buf));
else
- snprintf(label_buf, sizeof(label_buf), "%u", labels[i]);
+ snprintf(label_buf, sizeof(label_buf), "%u",
+ ((type == ZEBRA_LSP_EVPN)
+ ? label2vni(&labels[i])
+ : labels[i]));
+
strlcat(buf, label_buf, len);
}