diff options
| author | Renato Westphal <renato@opensourcerouting.org> | 2017-08-22 17:01:54 -0300 |
|---|---|---|
| committer | Renato Westphal <renato@opensourcerouting.org> | 2017-08-22 17:37:58 -0300 |
| commit | 5e8c8947e3fb53d2fdbdf804c6014d6ecdb0b904 (patch) | |
| tree | 6d88033457ec6eb6022ba189b90afc47827f85d1 /zebra/rt_socket.c | |
| parent | 1d84515ca9d0a5e543be7e8e7ca9afc8b744e662 (diff) | |
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/rt_socket.c')
| -rw-r--r-- | zebra/rt_socket.c | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/zebra/rt_socket.c b/zebra/rt_socket.c index 4e4d726b46..32ae41b917 100644 --- a/zebra/rt_socket.c +++ b/zebra/rt_socket.c @@ -71,6 +71,27 @@ static int sin_masklen(struct in_addr mask) } #endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */ +#ifdef __OpenBSD__ +static int kernel_rtm_add_labels(struct nexthop_label *nh_label, + struct sockaddr_mpls *smpls) +{ + if (nh_label->num_labels > 1) { + zlog_warn( + "%s: can't push %u labels at " + "once (maximum is 1)", + __func__, nh_label->num_labels); + return -1; + } + + memset(smpls, 0, sizeof(*smpls)); + smpls->smpls_len = sizeof(*smpls); + smpls->smpls_family = AF_MPLS; + smpls->smpls_label = htonl(nh_label->label[0] << MPLS_LABEL_OFFSET); + + return 0; +} +#endif + /* Interface between zebra message and rtm message. */ static int kernel_rtm_ipv4(int cmd, struct prefix *p, struct route_entry *re) @@ -150,15 +171,11 @@ static int kernel_rtm_ipv4(int cmd, struct prefix *p, struct route_entry *re) } #ifdef __OpenBSD__ - if (nexthop->nh_label) { - memset(&smpls, 0, sizeof(smpls)); - smpls.smpls_len = sizeof(smpls); - smpls.smpls_family = AF_MPLS; - smpls.smpls_label = - htonl(nexthop->nh_label->label[0] - << MPLS_LABEL_OFFSET); - smplsp = (union sockunion *)&smpls; - } + if (nexthop->nh_label + && !kernel_rtm_add_labels(nexthop->nh_label, + &smpls)) + continue; + smplsp = (union sockunion *)&smpls; #endif error = rtm_write( @@ -266,6 +283,10 @@ static int kernel_rtm_ipv6(int cmd, struct prefix *p, struct route_entry *re) { struct sockaddr_in6 *mask; struct sockaddr_in6 sin_dest, sin_mask, sin_gate; +#ifdef __OpenBSD__ + struct sockaddr_mpls smpls; +#endif + union sockunion *smplsp = NULL; struct nexthop *nexthop; int nexthop_num = 0; ifindex_t ifindex = 0; @@ -338,10 +359,17 @@ static int kernel_rtm_ipv6(int cmd, struct prefix *p, struct route_entry *re) mask = &sin_mask; } +#ifdef __OpenBSD__ + if (nexthop->nh_label + && !kernel_rtm_add_labels(nexthop->nh_label, &smpls)) + continue; + smplsp = (union sockunion *)&smpls; +#endif + error = rtm_write(cmd, (union sockunion *)&sin_dest, (union sockunion *)mask, gate ? (union sockunion *)&sin_gate : NULL, - NULL, ifindex, re->flags, re->metric); + smplsp, ifindex, re->flags, re->metric); #if 0 if (error) |
