summaryrefslogtreecommitdiffstats
path: root/zebra/zebra_mpls.c
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2017-08-22 22:01:54 +0200
committerRenato Westphal <renato@opensourcerouting.org>2017-08-22 22:37:58 +0200
commit5e8c8947e3fb53d2fdbdf804c6014d6ecdb0b904 (patch)
tree6d88033457ec6eb6022ba189b90afc47827f85d1 /zebra/zebra_mpls.c
parentMerge pull request #1025 from qlyoung/no-ospf (diff)
downloadfrr-5e8c8947e3fb53d2fdbdf804c6014d6ecdb0b904.tar.xz
frr-5e8c8947e3fb53d2fdbdf804c6014d6ecdb0b904.zip
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 <renato@opensourcerouting.org>
Diffstat (limited to 'zebra/zebra_mpls.c')
-rw-r--r--zebra/zebra_mpls.c31
1 files changed, 12 insertions, 19 deletions
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;
}