summaryrefslogtreecommitdiffstats
path: root/staticd/static_zebra.c
diff options
context:
space:
mode:
Diffstat (limited to 'staticd/static_zebra.c')
-rw-r--r--staticd/static_zebra.c64
1 files changed, 31 insertions, 33 deletions
diff --git a/staticd/static_zebra.c b/staticd/static_zebra.c
index 6abbdad..c4efc14 100644
--- a/staticd/static_zebra.c
+++ b/staticd/static_zebra.c
@@ -111,8 +111,6 @@ static int interface_address_delete(ZAPI_CALLBACK_ARGS)
static int static_ifp_up(struct interface *ifp)
{
- /* Install any static reliant on this interface coming up */
- static_install_intf_nh(ifp);
static_ifindex_update(ifp, true);
return 0;
@@ -166,9 +164,14 @@ static int route_notify_owner(ZAPI_CALLBACK_ARGS)
static void zebra_connected(struct zclient *zclient)
{
+ struct vrf *vrf;
+
+ zebra_route_notify_send(ZEBRA_ROUTE_NOTIFY_REQUEST, zclient, true);
zclient_send_reg_requests(zclient, VRF_DEFAULT);
- static_fixup_vrf_ids(vrf_info_lookup(VRF_DEFAULT));
+ vrf = vrf_lookup_by_id(VRF_DEFAULT);
+ assert(vrf);
+ static_fixup_vrf_ids(vrf);
}
/* API to check whether the configured nexthop address is
@@ -186,48 +189,40 @@ static_nexthop_is_local(vrf_id_t vrfid, struct prefix *addr, int family)
}
return false;
}
-static int static_zebra_nexthop_update(ZAPI_CALLBACK_ARGS)
+
+static void static_zebra_nexthop_update(struct vrf *vrf, struct prefix *matched,
+ struct zapi_route *nhr)
{
struct static_nht_data *nhtd, lookup;
- struct zapi_route nhr;
- struct prefix matched;
afi_t afi = AFI_IP;
- if (!zapi_nexthop_update_decode(zclient->ibuf, &matched, &nhr)) {
- zlog_err("Failure to decode nexthop update message");
- return 1;
- }
-
if (zclient->bfd_integration)
- bfd_nht_update(&matched, &nhr);
+ bfd_nht_update(matched, nhr);
- if (matched.family == AF_INET6)
+ if (matched->family == AF_INET6)
afi = AFI_IP6;
- if (nhr.type == ZEBRA_ROUTE_CONNECT) {
- if (static_nexthop_is_local(vrf_id, &matched,
- nhr.prefix.family))
- nhr.nexthop_num = 0;
+ if (nhr->type == ZEBRA_ROUTE_CONNECT) {
+ if (static_nexthop_is_local(vrf->vrf_id, matched,
+ nhr->prefix.family))
+ nhr->nexthop_num = 0;
}
memset(&lookup, 0, sizeof(lookup));
- lookup.nh = matched;
- lookup.nh_vrf_id = vrf_id;
- lookup.safi = nhr.safi;
+ lookup.nh = *matched;
+ lookup.nh_vrf_id = vrf->vrf_id;
+ lookup.safi = nhr->safi;
nhtd = static_nht_hash_find(static_nht_hash, &lookup);
if (nhtd) {
- nhtd->nh_num = nhr.nexthop_num;
+ nhtd->nh_num = nhr->nexthop_num;
- static_nht_reset_start(&matched, afi, nhr.safi,
- nhtd->nh_vrf_id);
- static_nht_update(NULL, &matched, nhr.nexthop_num, afi,
- nhr.safi, nhtd->nh_vrf_id);
+ static_nht_reset_start(matched, afi, nhr->safi, nhtd->nh_vrf_id);
+ static_nht_update(NULL, matched, nhr->nexthop_num, afi,
+ nhr->safi, nhtd->nh_vrf_id);
} else
zlog_err("No nhtd?");
-
- return 1;
}
static void static_zebra_capabilities(struct zclient_capabilities *cap)
@@ -395,6 +390,9 @@ extern void static_zebra_route_add(struct static_path *pn, bool install)
struct zapi_route api;
uint32_t nh_num = 0;
+ if (!si->svrf->vrf || si->svrf->vrf->vrf_id == VRF_UNKNOWN)
+ return;
+
p = src_pp = NULL;
srcdest_rnode_prefixes(rn, &p, &src_pp);
@@ -535,22 +533,22 @@ 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 };
-
- if_zapi_callbacks(static_ifp_create, static_ifp_up,
- static_ifp_down, static_ifp_destroy);
+ hook_register_prio(if_real, 0, static_ifp_create);
+ hook_register_prio(if_up, 0, static_ifp_up);
+ hook_register_prio(if_down, 0, static_ifp_down);
+ hook_register_prio(if_unreal, 0, static_ifp_destroy);
- zclient = zclient_new(master, &opt, static_handlers,
+ zclient = zclient_new(master, &zclient_options_default, 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->nexthop_update = static_zebra_nexthop_update;
static_nht_hash_init(static_nht_hash);
static_bfd_initialize(zclient, master);