diff --git a/eigrpd/eigrp_zebra.c b/eigrpd/eigrp_zebra.c index 3759c64148..e8392f50b4 100644 --- a/eigrpd/eigrp_zebra.c +++ b/eigrpd/eigrp_zebra.c @@ -94,13 +94,14 @@ static int eigrp_router_id_update_zebra(int command, struct zclient *zclient, return 0; } -static int eigrp_zebra_notify_owner(int command, struct zclient *zclient, - zebra_size_t length, vrf_id_t vrf_id) +static int eigrp_zebra_route_notify_owner(int command, struct zclient *zclient, + zebra_size_t length, vrf_id_t vrf_id) { struct prefix p; enum zapi_route_notify_owner note; + uint32_t table; - if (!zapi_route_notify_decode(zclient->ibuf, &p, ¬e)) + if (!zapi_route_notify_decode(zclient->ibuf, &p, &table, ¬e)) return -1; return 0; @@ -128,7 +129,7 @@ void eigrp_zebra_init(void) zclient->interface_address_delete = eigrp_interface_address_delete; zclient->redistribute_route_add = eigrp_zebra_read_route; zclient->redistribute_route_del = eigrp_zebra_read_route; - zclient->notify_owner = eigrp_zebra_notify_owner; + zclient->route_notify_owner = eigrp_zebra_route_notify_owner; } diff --git a/lib/zclient.c b/lib/zclient.c index 9260e0b3ba..ad91eb504b 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -1210,14 +1210,20 @@ stream_failure: } bool zapi_route_notify_decode(struct stream *s, struct prefix *p, + uint32_t *tableid, enum zapi_route_notify_owner *note) { + uint32_t t; + 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)); + prefix_blen(p)); + STREAM_GETL(s, t); + + *tableid = t; return true; @@ -2363,9 +2369,9 @@ static int zclient_read(struct thread *thread) vrf_id); break; case ZEBRA_ROUTE_NOTIFY_OWNER: - if (zclient->notify_owner) - (*zclient->notify_owner)(command, zclient, - length, vrf_id); + if (zclient->route_notify_owner) + (*zclient->route_notify_owner)(command, zclient, length, + vrf_id); break; default: break; diff --git a/lib/zclient.h b/lib/zclient.h index d8a70c6cf3..4c84af1f61 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -213,8 +213,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); + int (*route_notify_owner)(int command, struct zclient *zclient, + uint16_t length, vrf_id_t vrf_id); }; /* Zebra API message flag. */ @@ -513,6 +513,7 @@ extern int zclient_send_rnh(struct zclient *zclient, int command, 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, + uint32_t *tableid, enum zapi_route_notify_owner *note); extern struct nexthop *nexthop_from_zapi_nexthop(struct zapi_nexthop *znh); extern bool zapi_nexthop_update_decode(struct stream *s, diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c index 78e8cf0adc..3b22db20aa 100644 --- a/sharpd/sharp_zebra.c +++ b/sharpd/sharp_zebra.c @@ -131,13 +131,14 @@ static int interface_state_down(int command, struct zclient *zclient, extern uint32_t total_routes; extern uint32_t installed_routes; -static int notify_owner(int command, struct zclient *zclient, - zebra_size_t length, vrf_id_t vrf_id) +static int route_notify_owner(int command, struct zclient *zclient, + zebra_size_t length, vrf_id_t vrf_id) { struct prefix p; enum zapi_route_notify_owner note; + uint32_t table; - if (!zapi_route_notify_decode(zclient->ibuf, &p, ¬e)) + if (!zapi_route_notify_decode(zclient->ibuf, &p, &table, ¬e)) return -1; installed_routes++; @@ -210,5 +211,5 @@ void sharp_zebra_init(void) zclient->interface_down = interface_state_down; zclient->interface_address_add = interface_address_add; zclient->interface_address_delete = interface_address_delete; - zclient->notify_owner = notify_owner; + zclient->route_notify_owner = route_notify_owner; } diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index b5ce17d9f8..59d9e0c2ad 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -1033,8 +1033,7 @@ void kernel_route_rib_pass_fail(struct route_node *rn, struct prefix *p, else UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB); } - zsend_route_notify_owner(re->type, re->instance, re->vrf_id, - p, ZAPI_ROUTE_INSTALLED); + zsend_route_notify_owner(re, p, ZAPI_ROUTE_INSTALLED); break; case SOUTHBOUND_INSTALL_FAILURE: /* @@ -1044,8 +1043,7 @@ void kernel_route_rib_pass_fail(struct route_node *rn, struct prefix *p, */ dest->selected_fib = re; - zsend_route_notify_owner(re->type, re->instance, re->vrf_id, - p, ZAPI_ROUTE_FAIL_INSTALL); + zsend_route_notify_owner(re, p, ZAPI_ROUTE_FAIL_INSTALL); zlog_warn("%u:%s: Route install failed", re->vrf_id, prefix2str(p, buf, sizeof(buf))); break; @@ -1112,10 +1110,8 @@ void rib_install_kernel(struct route_node *rn, struct route_entry *re, * If this is a replace to a new RE let the originator of the RE * know that they've lost */ - if (old && old != re) - zsend_route_notify_owner(old->type, old->instance, - old->vrf_id, p, - ZAPI_ROUTE_BETTER_ADMIN_WON); + if (old && (old != re) && (old->type != re->type)) + zsend_route_notify_owner(old, p, ZAPI_ROUTE_BETTER_ADMIN_WON); /* * Make sure we update the FPM any time we send new information to diff --git a/zebra/zserv.c b/zebra/zserv.c index f269422986..98cb54f7b8 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -986,29 +986,38 @@ static int zsend_ipv4_nexthop_lookup_mrib(struct zserv *client, return zebra_server_send_message(client); } -int zsend_route_notify_owner(u_char proto, u_short instance, - vrf_id_t vrf_id, struct prefix *p, +int zsend_route_notify_owner(struct route_entry *re, struct prefix *p, enum zapi_route_notify_owner note) { struct zserv *client; struct stream *s; uint8_t blen; - client = zebra_find_client(proto, instance); + client = zebra_find_client(re->type, re->instance); if (!client || !client->notify_owner) { if (IS_ZEBRA_DEBUG_PACKET) { char buff[PREFIX_STRLEN]; - zlog_debug("Not Notifying Owner: %u about prefix %s", - proto, prefix2str(p, buff, sizeof(buff))); + zlog_debug( + "Not Notifying Owner: %u about prefix %s(%u) %d", + re->type, prefix2str(p, buff, sizeof(buff)), + re->table, note); } return 0; } + if (IS_ZEBRA_DEBUG_PACKET) { + char buff[PREFIX_STRLEN]; + + zlog_debug("Notifying Owner: %u about prefix %s(%u) %d", + re->type, prefix2str(p, buff, sizeof(buff)), + re->table, note); + } + s = client->obuf; stream_reset(s); - zclient_create_header(s, ZEBRA_ROUTE_NOTIFY_OWNER, vrf_id); + zclient_create_header(s, ZEBRA_ROUTE_NOTIFY_OWNER, re->vrf_id); stream_put(s, ¬e, sizeof(note)); @@ -1018,6 +1027,8 @@ int zsend_route_notify_owner(u_char proto, u_short instance, stream_putc(s, p->prefixlen); stream_put(s, &p->u.prefix, blen); + stream_putl(s, re->table); + stream_putw_at(s, 0, stream_get_endp(s)); return zebra_server_send_message(client); diff --git a/zebra/zserv.h b/zebra/zserv.h index 7d5f6b4543..2044816227 100644 --- a/zebra/zserv.h +++ b/zebra/zserv.h @@ -175,8 +175,7 @@ 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, u_short instance, - vrf_id_t vrf_id, struct prefix *p, +extern int zsend_route_notify_owner(struct route_entry *re, struct prefix *p, enum zapi_route_notify_owner note); extern void zserv_nexthop_num_warn(const char *, const struct prefix *,