diff options
Diffstat (limited to 'lib/zclient.c')
| -rw-r--r-- | lib/zclient.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/lib/zclient.c b/lib/zclient.c index 5deea8f0cf..bdb62befb9 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -1326,6 +1326,24 @@ enum zclient_send_status zclient_nhg_send(struct zclient *zclient, int cmd, return zclient_send_message(zclient); } +/* size needed by a stream for redistributing a route */ +int zapi_redistribute_stream_size(struct zapi_route *api) +{ + size_t msg_size = 0; + size_t nh_size = sizeof(struct zapi_nexthop); + + msg_size = sizeof(struct zapi_route); + /* remove unused nexthop structures */ + msg_size -= (MULTIPATH_NUM - api->nexthop_num) * nh_size; + /* remove unused backup nexthop structures */ + msg_size -= (MULTIPATH_NUM - api->backup_nexthop_num) * nh_size; + /* remove unused opaque values */ + msg_size -= ZAPI_MESSAGE_OPAQUE_LENGTH - api->opaque.length; + + return msg_size; +} + + int zapi_route_encode(uint8_t cmd, struct stream *s, struct zapi_route *api) { struct zapi_nexthop *api_nh; @@ -1344,6 +1362,8 @@ int zapi_route_encode(uint8_t cmd, struct stream *s, struct zapi_route *api) stream_putc(s, api->type); stream_putw(s, api->instance); + if (CHECK_FLAG(api->message, ZAPI_MESSAGE_TABLEID)) + SET_FLAG(api->flags, ZEBRA_FLAG_TABLEID); stream_putl(s, api->flags); stream_putl(s, api->message); @@ -1403,6 +1423,8 @@ int zapi_route_encode(uint8_t cmd, struct stream *s, struct zapi_route *api) return -1; } + if (CHECK_FLAG(api->message, ZAPI_MESSAGE_TABLEID)) + SET_FLAG(api->flags, ZEBRA_FLAG_TABLEID); if (zapi_nexthop_encode(s, api_nh, api->flags, api->message) != 0) @@ -1442,6 +1464,9 @@ int zapi_route_encode(uint8_t cmd, struct stream *s, struct zapi_route *api) return -1; } + if (CHECK_FLAG(api->message, ZAPI_MESSAGE_TABLEID)) + SET_FLAG(api->flags, ZEBRA_FLAG_TABLEID); + if (zapi_nexthop_encode(s, api_nh, api->flags, api->message) != 0) @@ -3664,7 +3689,7 @@ int lm_get_label_chunk(struct zclient *zclient, uint8_t keep, uint32_t base, if (zclient_debug) zlog_debug("Getting Label Chunk"); - if (zclient->sock < 0) + if (!zclient || zclient->sock < 0) return -1; /* send request */ |
