diff options
Diffstat (limited to 'zebra/zapi_msg.c')
| -rw-r--r-- | zebra/zapi_msg.c | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index f2ff8d53f2..46171df848 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -62,6 +62,8 @@ #include "zebra/zebra_opaque.h" #include "zebra/zebra_srte.h" +static int zapi_nhg_decode(struct stream *s, int cmd, struct zapi_nhg *api_nhg); + /* Encoding helpers -------------------------------------------------------- */ static void zserv_encode_interface(struct stream *s, struct interface *ifp) @@ -102,6 +104,7 @@ static void zserv_encode_vrf(struct stream *s, struct zebra_vrf *zvrf) struct vrf_data data; const char *netns_name = zvrf_ns_name(zvrf); + memset(&data, 0, sizeof(data)); data.l.table_id = zvrf->table_id; if (netns_name) @@ -707,13 +710,13 @@ static int zsend_ipv4_nexthop_lookup_mrib(struct zserv *client, return zserv_send_message(client, s); } -static int nhg_notify(uint16_t type, uint16_t instance, uint32_t id, - enum zapi_nhg_notify_owner note) +int zsend_nhg_notify(uint16_t type, uint16_t instance, uint32_t session_id, + uint32_t id, enum zapi_nhg_notify_owner note) { struct zserv *client; struct stream *s; - client = zserv_find_client(type, instance); + client = zserv_find_client_session(type, instance, session_id); if (!client) { if (IS_ZEBRA_DEBUG_PACKET) { zlog_debug("Not Notifying Owner: %u(%u) about %u(%d)", @@ -722,6 +725,10 @@ static int nhg_notify(uint16_t type, uint16_t instance, uint32_t id, return 0; } + if (IS_ZEBRA_DEBUG_SEND) + zlog_debug("%s: type %d, id %d, note %d", + __func__, type, id, note); + s = stream_new(ZEBRA_MAX_PACKET_SIZ); stream_reset(s); @@ -1139,7 +1146,7 @@ static void zread_rnh_register(ZAPI_HANDLER_ARGS) } else { flog_err( EC_ZEBRA_UNKNOWN_FAMILY, - "rnh_register: Received unknown family type %d\n", + "rnh_register: Received unknown family type %d", p.family); return; } @@ -1230,7 +1237,7 @@ static void zread_rnh_unregister(ZAPI_HANDLER_ARGS) } else { flog_err( EC_ZEBRA_UNKNOWN_FAMILY, - "rnh_register: Received unknown family type %d\n", + "rnh_register: Received unknown family type %d", p.family); return; } @@ -1280,7 +1287,7 @@ static void zread_fec_register(ZAPI_HANDLER_ARGS) if (p.family != AF_INET && p.family != AF_INET6) { flog_err( EC_ZEBRA_UNKNOWN_FAMILY, - "fec_register: Received unknown family type %d\n", + "fec_register: Received unknown family type %d", p.family); return; } @@ -1346,7 +1353,7 @@ static void zread_fec_unregister(ZAPI_HANDLER_ARGS) if (p.family != AF_INET && p.family != AF_INET6) { flog_err( EC_ZEBRA_UNKNOWN_FAMILY, - "fec_unregister: Received unknown family type %d\n", + "fec_unregister: Received unknown family type %d", p.family); return; } @@ -1742,7 +1749,7 @@ static bool zapi_read_nexthops(struct zserv *client, struct prefix *p, return true; } -int zapi_nhg_decode(struct stream *s, int cmd, struct zapi_nhg *api_nhg) +static int zapi_nhg_decode(struct stream *s, int cmd, struct zapi_nhg *api_nhg) { uint16_t i; struct zapi_nexthop *znh; @@ -1820,16 +1827,17 @@ static void zread_nhg_del(ZAPI_HANDLER_ARGS) /* * Delete the received nhg id */ - nhe = zebra_nhg_proto_del(api_nhg.id, api_nhg.proto); if (nhe) { zebra_nhg_decrement_ref(nhe); - nhg_notify(api_nhg.proto, client->instance, api_nhg.id, - ZAPI_NHG_REMOVED); + zsend_nhg_notify(api_nhg.proto, client->instance, + client->session_id, api_nhg.id, + ZAPI_NHG_REMOVED); } else - nhg_notify(api_nhg.proto, client->instance, api_nhg.id, - ZAPI_NHG_REMOVE_FAIL); + zsend_nhg_notify(api_nhg.proto, client->instance, + client->session_id, api_nhg.id, + ZAPI_NHG_REMOVE_FAIL); } static void zread_nhg_add(ZAPI_HANDLER_ARGS) @@ -1863,7 +1871,8 @@ static void zread_nhg_add(ZAPI_HANDLER_ARGS) /* * Create the nhg */ - nhe = zebra_nhg_proto_add(api_nhg.id, api_nhg.proto, nhg, 0); + nhe = zebra_nhg_proto_add(api_nhg.id, api_nhg.proto, client->instance, + client->session_id, nhg, 0); nexthop_group_delete(&nhg); zebra_nhg_backup_free(&bnhg); @@ -1874,12 +1883,12 @@ static void zread_nhg_add(ZAPI_HANDLER_ARGS) * * Resolution is going to need some more work. */ - if (nhe) - nhg_notify(api_nhg.proto, client->instance, api_nhg.id, - ZAPI_NHG_INSTALLED); - else - nhg_notify(api_nhg.proto, client->instance, api_nhg.id, - ZAPI_NHG_FAIL_INSTALL); + + /* If there's a failure, notify sender immediately */ + if (nhe == NULL) + zsend_nhg_notify(api_nhg.proto, client->instance, + client->session_id, api_nhg.id, + ZAPI_NHG_FAIL_INSTALL); } static void zread_route_add(ZAPI_HANDLER_ARGS) @@ -2080,7 +2089,7 @@ static void zread_route_del(ZAPI_HANDLER_ARGS) rib_delete(afi, api.safi, zvrf_id(zvrf), api.type, api.instance, api.flags, &api.prefix, src_p, NULL, 0, table_id, api.metric, - api.distance, false, false); + api.distance, false); /* Stats */ switch (api.prefix.family) { |
