From 5e8c8947e3fb53d2fdbdf804c6014d6ecdb0b904 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Tue, 22 Aug 2017 17:01:54 -0300 Subject: zebra: increase maximum label stack depth * Bump MPLS_MAX_LABELS from 2 to 16; * Adjust the static_nh_label structure and the mpls_label2str() function; * On OpenBSD, print an error message when trying to push more than one label at once (kernel limitation). While here, add support for MPLSv6 FTNs in OpenBSD. This is not the full package. We still can't pop multiple labels at once, or do things like swap a label and push other ones. We'll address that in the future. Signed-off-by: Renato Westphal --- zebra/zebra_mpls.c | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) (limited to 'zebra/zebra_mpls.c') diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index 47cf7a3cb..cee3a0385 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -1671,27 +1671,20 @@ int mpls_str2label(const char *label_str, u_int8_t *num_labels, char *mpls_label2str(u_int8_t num_labels, mpls_label_t *labels, char *buf, int len, int pretty) { - char *buf_ptr = buf; - buf[0] = '\0'; - - if (pretty) { - if (num_labels == 1) { - label2str(labels[0], buf, len); - } else if (num_labels == 2) { - label2str(labels[0], buf, len); - buf_ptr += strlen(buf); + char label_buf[BUFSIZ]; + int i; - snprintf(buf_ptr, len, "/"); - buf_ptr++; - - label2str(labels[1], buf_ptr, len); - } - } else { - if (num_labels == 1) - snprintf(buf, len, "%u", labels[0]); - else if (num_labels == 2) - snprintf(buf, len, "%u/%u", labels[0], labels[1]); + buf[0] = '\0'; + for (i = 0; i < num_labels; i++) { + if (i != 0) + strlcat(buf, "/", len); + if (pretty) + label2str(labels[i], label_buf, sizeof(label_buf)); + else + snprintf(label_buf, sizeof(label_buf), "%u", labels[i]); + strlcat(buf, label_buf, len); } + return buf; } -- cgit v1.2.3