diff options
-rw-r--r-- | lib/log.c | 1 | ||||
-rw-r--r-- | lib/zclient.c | 21 | ||||
-rw-r--r-- | lib/zclient.h | 11 | ||||
-rw-r--r-- | zebra/zserv.c | 34 | ||||
-rw-r--r-- | zebra/zserv.h | 4 |
5 files changed, 71 insertions, 0 deletions
@@ -897,6 +897,7 @@ static const struct zebra_desc_table command_types[] = { DESC_ENTRY(ZEBRA_INTERFACE_SET_MASTER), DESC_ENTRY(ZEBRA_ROUTE_ADD), DESC_ENTRY(ZEBRA_ROUTE_DELETE), + DESC_ENTRY(ZEBRA_ROUTE_NOTIFY_OWNER), DESC_ENTRY(ZEBRA_IPV4_ROUTE_ADD), DESC_ENTRY(ZEBRA_IPV4_ROUTE_DELETE), DESC_ENTRY(ZEBRA_IPV6_ROUTE_ADD), diff --git a/lib/zclient.c b/lib/zclient.c index 6d6d44fb1..e76990601 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -1144,6 +1144,22 @@ stream_failure: return 0; } +bool zapi_route_notify_decode(struct stream *s, struct prefix *p, + enum zapi_route_notify_owner *note) +{ + STREAM_GET(note, s, sizeof(*note)); + + STREAM_GETC(s, p->family); + STREAM_GETC(s, p->prefixlen); + STREAM_GET(&p->u.prefix, s, + PSIZE(p->prefixlen)); + + return true; + +stream_failure: + return false; +} + /* * send a ZEBRA_REDISTRIBUTE_ADD or ZEBRA_REDISTRIBUTE_DELETE * for the route type (ZEBRA_ROUTE_KERNEL etc.). The zebra server will @@ -2194,6 +2210,11 @@ static int zclient_read(struct thread *thread) (*zclient->pw_status_update)(command, zclient, length, vrf_id); break; + case ZEBRA_ROUTE_NOTIFY_OWNER: + if (zclient->notify_owner) + (*zclient->notify_owner)(command, zclient, + length, vrf_id); + break; default: break; } diff --git a/lib/zclient.h b/lib/zclient.h index e9b2cb895..025a3ac23 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -61,6 +61,7 @@ typedef enum { ZEBRA_INTERFACE_SET_MASTER, ZEBRA_ROUTE_ADD, ZEBRA_ROUTE_DELETE, + ZEBRA_ROUTE_NOTIFY_OWNER, ZEBRA_IPV4_ROUTE_ADD, ZEBRA_IPV4_ROUTE_DELETE, ZEBRA_IPV6_ROUTE_ADD, @@ -199,6 +200,8 @@ struct zclient { int (*local_macip_add)(int, struct zclient *, uint16_t, vrf_id_t); int (*local_macip_del)(int, struct zclient *, uint16_t, vrf_id_t); int (*pw_status_update)(int, struct zclient *, uint16_t, vrf_id_t); + int (*notify_owner)(int command, struct zclient *zclient, + uint16_t length, vrf_id_t vrf_id); }; /* Zebra API message flag. */ @@ -323,6 +326,12 @@ struct zapi_pw_status { uint32_t status; }; +enum zapi_route_notify_owner { + ZAPI_ROUTE_FAIL_INSTALL, + ZAPI_ROUTE_BETTER_ADMIN_WON, + ZAPI_ROUTE_INSTALLED, +}; + /* Zebra MAC types */ #define ZEBRA_MAC_TYPE_STICKY 0x01 /* Sticky MAC*/ #define ZEBRA_MAC_TYPE_GW 0x02 /* gateway (SVI) mac*/ @@ -445,6 +454,8 @@ extern int zapi_ipv4_route_ipv6_nexthop(u_char, struct zclient *, extern int zclient_route_send(u_char, struct zclient *, struct zapi_route *); extern int zapi_route_encode(u_char, struct stream *, struct zapi_route *); extern int zapi_route_decode(struct stream *, struct zapi_route *); +bool zapi_route_notify_decode(struct stream *s, struct prefix *p, + enum zapi_route_notify_owner *note); static inline void zapi_route_set_blackhole(struct zapi_route *api, enum blackhole_type bh_type) diff --git a/zebra/zserv.c b/zebra/zserv.c index 2389944e8..f76490861 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -988,6 +988,40 @@ static int zsend_ipv4_nexthop_lookup_mrib(struct zserv *client, return zebra_server_send_message(client); } +int zsend_route_notify_owner(u_char proto, vrf_id_t vrf_id, + struct prefix *p, + enum zapi_route_notify_owner note) +{ + struct zserv *client; + struct stream *s; + uint8_t blen; + + client = zebra_find_client(proto); + if (!client) { + if (IS_ZEBRA_DEBUG_PACKET) + zlog_debug("Attempting to notify a client for proto: %u but did not find one", + proto); + return -1; + } + + s = client->obuf; + stream_reset(s); + + zserv_create_header(s, ZEBRA_ROUTE_NOTIFY_OWNER, vrf_id); + + stream_put(s, ¬e, sizeof(note)); + + stream_putc(s, p->family); + + blen = prefix_blen(p); + stream_putc(s, p->prefixlen); + stream_put(s, &p->u.prefix, blen); + + stream_putw_at(s, 0, stream_get_endp(s)); + + return zebra_server_send_message(client); +} + /* Router-id is updated. Send ZEBRA_ROUTER_ID_ADD to client. */ int zsend_router_id_update(struct zserv *client, struct prefix *p, vrf_id_t vrf_id) diff --git a/zebra/zserv.h b/zebra/zserv.h index 60e055088..9978c6d89 100644 --- a/zebra/zserv.h +++ b/zebra/zserv.h @@ -183,6 +183,10 @@ extern int zsend_interface_vrf_update(struct zserv *, struct interface *, extern int zsend_interface_link_params(struct zserv *, struct interface *); extern int zsend_pw_update(struct zserv *, struct zebra_pw *); +extern int zsend_route_notify_owner(u_char proto, vrf_id_t vrf_id, + struct prefix *p, + enum zapi_route_notify_owner note); + extern pid_t pid; extern void zserv_create_header(struct stream *s, uint16_t cmd, |