diff options
| author | Mark Stapp <mjs@voltanet.io> | 2019-11-13 16:06:06 -0500 |
|---|---|---|
| committer | Mark Stapp <mjs@voltanet.io> | 2019-12-06 10:17:20 -0500 |
| commit | 68a02e06e5f103048d947262c08c569056f74d1c (patch) | |
| tree | 2916c9a6284473d8d6b42e69458226ee97943543 /zebra/zebra_rnh.c | |
| parent | d3d77ec42f9ece5a52e5af26b7ff2fb5607ad6c4 (diff) | |
*: revise zapi nexthop encoding
Use a per-nexthop flag to indicate the presence of labels; add
some utility zapi encode/decode apis for nexthops; use the zapi
apis more consistently.
Signed-off-by: Mark Stapp <mjs@voltanet.io>
Diffstat (limited to 'zebra/zebra_rnh.c')
| -rw-r--r-- | zebra/zebra_rnh.c | 35 |
1 files changed, 4 insertions, 31 deletions
diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c index 9a6631a59a..2d9c83becb 100644 --- a/zebra/zebra_rnh.c +++ b/zebra/zebra_rnh.c @@ -1034,6 +1034,8 @@ static int send_client(struct rnh *rnh, struct zserv *client, rnh_type_t type, break; } if (re) { + struct zapi_nexthop znh; + stream_putc(s, re->type); stream_putw(s, re->instance); stream_putc(s, re->distance); @@ -1043,37 +1045,8 @@ static int send_client(struct rnh *rnh, struct zserv *client, rnh_type_t type, stream_putc(s, 0); for (ALL_NEXTHOPS_PTR(re->nhe->nhg, nh)) if (rnh_nexthop_valid(re, nh)) { - stream_putl(s, nh->vrf_id); - stream_putc(s, nh->type); - switch (nh->type) { - case NEXTHOP_TYPE_IPV4: - case NEXTHOP_TYPE_IPV4_IFINDEX: - stream_put_in_addr(s, &nh->gate.ipv4); - stream_putl(s, nh->ifindex); - break; - case NEXTHOP_TYPE_IFINDEX: - stream_putl(s, nh->ifindex); - break; - case NEXTHOP_TYPE_IPV6: - case NEXTHOP_TYPE_IPV6_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); + zapi_nexthop_from_nexthop(&znh, nh); + zapi_nexthop_encode(s, &znh, 0 /* flags */); num++; } stream_putc_at(s, nump, num); |
