lib, zebra: Signal the existence of labels on a nexthop for nht

When we are signaling to a client from zebra that a nexthop
has changed, include the labels on the nexthop as well.
Upper level protocols need to know if the labels exist
in order to make intelligent decisions about what to do.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2018-03-16 10:53:58 -04:00
parent 8f77d0ee6c
commit 0acf4df095
2 changed files with 33 additions and 15 deletions

View File

@ -1340,6 +1340,16 @@ bool zapi_nexthop_update_decode(struct stream *s, struct zapi_route *nhr)
case NEXTHOP_TYPE_BLACKHOLE:
break;
}
STREAM_GETC(s, nhr->nexthops[i].label_num);
if (nhr->nexthops[i].label_num > MPLS_MAX_LABELS) {
zlog_warn("%s: invalid number of MPLS labels (%u)",
__func__, nhr->nexthops[i].label_num);
return false;
}
if (nhr->nexthops[i].label_num)
STREAM_GET(&nhr->nexthops[i].labels[0], s,
nhr->nexthops[i].label_num
* sizeof(mpls_label_t));
}
return true;

View File

@ -986,7 +986,7 @@ static int send_client(struct rnh *rnh, struct zserv *client, rnh_type_t type,
struct route_entry *re;
unsigned long nump;
u_char num;
struct nexthop *nexthop;
struct nexthop *nh;
struct route_node *rn;
int cmd = (type == RNH_IMPORT_CHECK_TYPE) ? ZEBRA_IMPORT_CHECK_UPDATE
: ZEBRA_NEXTHOP_UPDATE;
@ -1022,32 +1022,40 @@ static int send_client(struct rnh *rnh, struct zserv *client, rnh_type_t type,
num = 0;
nump = stream_get_endp(s);
stream_putc(s, 0);
for (nexthop = re->ng.nexthop; nexthop; nexthop = nexthop->next)
if ((CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB)
|| CHECK_FLAG(nexthop->flags,
NEXTHOP_FLAG_RECURSIVE))
&& CHECK_FLAG(nexthop->flags,
NEXTHOP_FLAG_ACTIVE)) {
stream_putc(s, nexthop->type);
switch (nexthop->type) {
for (nh = re->ng.nexthop; nh; nh = nh->next)
if ((CHECK_FLAG(nh->flags, NEXTHOP_FLAG_FIB)
|| CHECK_FLAG(nh->flags, NEXTHOP_FLAG_RECURSIVE))
&& CHECK_FLAG(nh->flags, NEXTHOP_FLAG_ACTIVE)) {
stream_putc(s, nh->type);
switch (nh->type) {
case NEXTHOP_TYPE_IPV4:
case NEXTHOP_TYPE_IPV4_IFINDEX:
stream_put_in_addr(s,
&nexthop->gate.ipv4);
stream_putl(s, nexthop->ifindex);
stream_put_in_addr(s, &nh->gate.ipv4);
stream_putl(s, nh->ifindex);
break;
case NEXTHOP_TYPE_IFINDEX:
stream_putl(s, nexthop->ifindex);
stream_putl(s, nh->ifindex);
break;
case NEXTHOP_TYPE_IPV6:
case NEXTHOP_TYPE_IPV6_IFINDEX:
stream_put(s, &nexthop->gate.ipv6, 16);
stream_putl(s, nexthop->ifindex);
stream_put(s, &nh->gate.ipv6, 16);
stream_putl(s, nh->ifindex);
break;
default:
/* do nothing */
break;
}
if (nh->nh_label) {
stream_putc(s,
nh->nh_label->num_labels);
if (nh->nh_label->num_labels)
stream_put(
s,
&nh->nh_label->label[0],
nh->nh_label->num_labels
* sizeof(mpls_label_t));
} else
stream_putc(s, 0);
num++;
}
stream_putc_at(s, nump, num);