diff options
Diffstat (limited to 'staticd/static_zebra.c')
| -rw-r--r-- | staticd/static_zebra.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/staticd/static_zebra.c b/staticd/static_zebra.c index 40275908f7..538fae28aa 100644 --- a/staticd/static_zebra.c +++ b/staticd/static_zebra.c @@ -261,9 +261,10 @@ static void static_nht_hash_free(void *data) XFREE(MTYPE_TMP, nhtd); } -void static_zebra_nht_register(struct route_node *rn, struct static_nexthop *nh, - bool reg) +void static_zebra_nht_register(struct static_nexthop *nh, bool reg) { + struct static_path *pn = nh->pn; + struct route_node *rn = pn->rn; struct static_nht_data *nhtd, lookup; uint32_t cmd; struct prefix p; @@ -331,7 +332,7 @@ void static_zebra_nht_register(struct route_node *rn, struct static_nexthop *nh, static_nht_hash_free(nhtd); } - if (zclient_send_rnh(zclient, cmd, &p, false, nh->nh_vrf_id) + if (zclient_send_rnh(zclient, cmd, &p, false, false, nh->nh_vrf_id) == ZCLIENT_SEND_FAILURE) zlog_warn("%s: Failure to send nexthop to zebra", __func__); } @@ -339,8 +340,10 @@ void static_zebra_nht_register(struct route_node *rn, struct static_nexthop *nh, * When nexthop gets updated via configuration then use the * already registered NH and resend the route to zebra */ -int static_zebra_nh_update(struct route_node *rn, struct static_nexthop *nh) +int static_zebra_nh_update(struct static_nexthop *nh) { + struct static_path *pn = nh->pn; + struct route_node *rn = pn->rn; struct static_nht_data *nhtd, lookup = {}; struct prefix p = {}; afi_t afi = AFI_IP; @@ -381,25 +384,23 @@ int static_zebra_nh_update(struct route_node *rn, struct static_nexthop *nh) return 0; } -extern void static_zebra_route_add(struct route_node *rn, - struct static_path *pn, safi_t safi, - bool install) +extern void static_zebra_route_add(struct static_path *pn, bool install) { + struct route_node *rn = pn->rn; + struct static_route_info *si = rn->info; struct static_nexthop *nh; const struct prefix *p, *src_pp; struct zapi_nexthop *api_nh; struct zapi_route api; uint32_t nh_num = 0; - struct stable_info *info; p = src_pp = NULL; srcdest_rnode_prefixes(rn, &p, &src_pp); memset(&api, 0, sizeof(api)); - info = static_get_stable_info(rn); - api.vrf_id = GET_STABLE_VRF_ID(info); + api.vrf_id = si->svrf->vrf->vrf_id; api.type = ZEBRA_ROUTE_STATIC; - api.safi = safi; + api.safi = si->safi; memcpy(&api.prefix, p, sizeof(api.prefix)); if (src_pp) { @@ -507,6 +508,13 @@ extern void static_zebra_route_add(struct route_node *rn, zclient, &api); } +static zclient_handler *const static_handlers[] = { + [ZEBRA_INTERFACE_ADDRESS_ADD] = interface_address_add, + [ZEBRA_INTERFACE_ADDRESS_DELETE] = interface_address_delete, + [ZEBRA_ROUTE_NOTIFY_OWNER] = route_notify_owner, + [ZEBRA_NEXTHOP_UPDATE] = static_zebra_nexthop_update, +}; + void static_zebra_init(void) { struct zclient_options opt = { .receive_notify = true }; @@ -514,15 +522,12 @@ void static_zebra_init(void) if_zapi_callbacks(static_ifp_create, static_ifp_up, static_ifp_down, static_ifp_destroy); - zclient = zclient_new(master, &opt); + zclient = zclient_new(master, &opt, static_handlers, + array_size(static_handlers)); zclient_init(zclient, ZEBRA_ROUTE_STATIC, 0, &static_privs); zclient->zebra_capabilities = static_zebra_capabilities; zclient->zebra_connected = zebra_connected; - zclient->interface_address_add = interface_address_add; - zclient->interface_address_delete = interface_address_delete; - zclient->route_notify_owner = route_notify_owner; - zclient->nexthop_update = static_zebra_nexthop_update; static_nht_hash = hash_create(static_nht_hash_key, static_nht_hash_cmp, |
