]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib, zebra: Signal the existence of labels on a nexthop for nht
authorDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 16 Mar 2018 14:53:58 +0000 (10:53 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 16 Mar 2018 16:27:22 +0000 (12:27 -0400)
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>
lib/zclient.c
zebra/zebra_rnh.c

index 777f6fcf9bf32fac3f57f27d62ffed8b4b7562f1..2cac71ac45a37e1d78b0499cdf067854ac030f81 100644 (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;
index c9fb782ba615076f2092ea656dca5814c756d206..48f9f4f366b2be6badf1a27f08436d4d1bb13d21 100644 (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);