summaryrefslogtreecommitdiff
path: root/ospfd/ospf_zebra.c
diff options
context:
space:
mode:
Diffstat (limited to 'ospfd/ospf_zebra.c')
-rw-r--r--ospfd/ospf_zebra.c98
1 files changed, 39 insertions, 59 deletions
diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c
index 0b770a8364..bb6cc3a89c 100644
--- a/ospfd/ospf_zebra.c
+++ b/ospfd/ospf_zebra.c
@@ -47,7 +47,7 @@ DEFINE_MTYPE_STATIC(OSPFD, OSPF_REDISTRIBUTE, "OSPF Redistriute");
/* Zebra structure to hold current status. */
struct zclient *zclient = NULL;
/* and for the Synchronous connection to the Label Manager */
-static struct zclient *zclient_sync;
+struct zclient *zclient_sync;
/* For registering threads. */
extern struct event_loop *master;
@@ -162,29 +162,6 @@ static int ospf_interface_link_params(ZAPI_CALLBACK_ARGS)
return 0;
}
-/* VRF update for an interface. */
-static int ospf_interface_vrf_update(ZAPI_CALLBACK_ARGS)
-{
- struct interface *ifp = NULL;
- vrf_id_t new_vrf_id;
-
- ifp = zebra_interface_vrf_update_read(zclient->ibuf, vrf_id,
- &new_vrf_id);
- if (!ifp)
- return 0;
-
- if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "%s: Rx Interface %s VRF change vrf_id %u New vrf %s id %u",
- __func__, ifp->name, vrf_id,
- ospf_vrf_id_to_name(new_vrf_id), new_vrf_id);
-
- /*if_update(ifp, ifp->name, strlen(ifp->name), new_vrf_id);*/
- if_update_to_new_vrf(ifp, new_vrf_id);
-
- return 0;
-}
-
/* Nexthop, ifindex, distance and metric information. */
static void ospf_zebra_add_nexthop(struct ospf *ospf, struct ospf_path *path,
struct zapi_route *api)
@@ -814,16 +791,16 @@ int ospf_is_type_redistributed(struct ospf *ospf, int type,
unsigned short instance)
{
return (DEFAULT_ROUTE_TYPE(type)
- ? vrf_bitmap_check(zclient->default_information[AFI_IP],
- ospf->vrf_id)
- : ((instance
- && redist_check_instance(
+ ? vrf_bitmap_check(
+ &zclient->default_information[AFI_IP],
+ ospf->vrf_id)
+ : ((instance &&
+ redist_check_instance(
&zclient->mi_redist[AFI_IP][type],
- instance))
- || (!instance
- && vrf_bitmap_check(
- zclient->redist[AFI_IP][type],
- ospf->vrf_id))));
+ instance)) ||
+ (!instance &&
+ vrf_bitmap_check(&zclient->redist[AFI_IP][type],
+ ospf->vrf_id))));
}
int ospf_redistribute_update(struct ospf *ospf, struct ospf_redist *red,
@@ -1252,12 +1229,18 @@ static int ospf_zebra_gr_update(struct ospf *ospf, int command,
int ospf_zebra_gr_enable(struct ospf *ospf, uint32_t stale_time)
{
+ if (IS_DEBUG_OSPF_GR)
+ zlog_debug("Zebra enable GR [stale time %u]", stale_time);
+
return ospf_zebra_gr_update(ospf, ZEBRA_CLIENT_GR_CAPABILITIES,
stale_time);
}
int ospf_zebra_gr_disable(struct ospf *ospf)
{
+ if (IS_DEBUG_OSPF_GR)
+ zlog_debug("Zebra disable GR");
+
return ospf_zebra_gr_update(ospf, ZEBRA_CLIENT_GR_DISABLE, 0);
}
@@ -1504,30 +1487,20 @@ void ospf_zebra_import_default_route(struct ospf *ospf, bool unreg)
__func__);
}
-static int ospf_zebra_import_check_update(ZAPI_CALLBACK_ARGS)
+static void ospf_zebra_import_check_update(struct vrf *vrf, struct prefix *match,
+ struct zapi_route *nhr)
{
- struct ospf *ospf;
- struct zapi_route nhr;
- struct prefix matched;
+ struct ospf *ospf = vrf->info;
- ospf = ospf_lookup_by_vrf_id(vrf_id);
if (ospf == NULL || !IS_OSPF_ASBR(ospf))
- return 0;
-
- if (!zapi_nexthop_update_decode(zclient->ibuf, &matched, &nhr)) {
- zlog_err("%s[%u]: Failure to decode route", __func__,
- ospf->vrf_id);
- return -1;
- }
+ return;
- if (matched.family != AF_INET || matched.prefixlen != 0 ||
- nhr.type == ZEBRA_ROUTE_OSPF)
- return 0;
+ if (match->family != AF_INET || match->prefixlen != 0 ||
+ nhr->type == ZEBRA_ROUTE_OSPF)
+ return;
- ospf->nssa_default_import_check.status = !!nhr.nexthop_num;
+ ospf->nssa_default_import_check.status = !!nhr->nexthop_num;
ospf_abr_nssa_type7_defaults(ospf);
-
- return 0;
}
int ospf_distribute_list_out_set(struct ospf *ospf, int type, const char *name)
@@ -2120,10 +2093,20 @@ int ospf_zebra_label_manager_connect(void)
static void ospf_zebra_connected(struct zclient *zclient)
{
+ struct ospf *ospf;
+ struct listnode *node;
+
/* Send the client registration */
bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_REGISTER, VRF_DEFAULT);
zclient_send_reg_requests(zclient, VRF_DEFAULT);
+
+ /* Activate graceful restart if configured. */
+ for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {
+ if (!ospf->gr_info.restart_support)
+ continue;
+ (void)ospf_zebra_gr_enable(ospf, ospf->gr_info.grace_period);
+ }
}
/*
@@ -2145,9 +2128,9 @@ static int ospf_opaque_msg_handler(ZAPI_CALLBACK_ARGS)
switch (info.type) {
case LINK_STATE_SYNC:
- STREAM_GETC(s, dst.proto);
- STREAM_GETW(s, dst.instance);
- STREAM_GETL(s, dst.session_id);
+ dst.proto = info.src_proto;
+ dst.instance = info.src_instance;
+ dst.session_id = info.src_session_id;
dst.type = LINK_STATE_SYNC;
ret = ospf_te_sync_ted(dst);
break;
@@ -2187,11 +2170,9 @@ static zclient_handler *const ospf_handlers[] = {
[ZEBRA_INTERFACE_ADDRESS_ADD] = ospf_interface_address_add,
[ZEBRA_INTERFACE_ADDRESS_DELETE] = ospf_interface_address_delete,
[ZEBRA_INTERFACE_LINK_PARAMS] = ospf_interface_link_params,
- [ZEBRA_INTERFACE_VRF_UPDATE] = ospf_interface_vrf_update,
[ZEBRA_REDISTRIBUTE_ROUTE_ADD] = ospf_zebra_read_route,
[ZEBRA_REDISTRIBUTE_ROUTE_DEL] = ospf_zebra_read_route,
- [ZEBRA_NEXTHOP_UPDATE] = ospf_zebra_import_check_update,
[ZEBRA_OPAQUE_MESSAGE] = ospf_opaque_msg_handler,
@@ -2205,11 +2186,10 @@ void ospf_zebra_init(struct event_loop *master, unsigned short instance)
array_size(ospf_handlers));
zclient_init(zclient, ZEBRA_ROUTE_OSPF, instance, &ospfd_privs);
zclient->zebra_connected = ospf_zebra_connected;
+ zclient->nexthop_update = ospf_zebra_import_check_update;
/* Initialize special zclient for synchronous message exchanges. */
- struct zclient_options options = zclient_options_default;
- options.synchronous = true;
- zclient_sync = zclient_new(master, &options, NULL, 0);
+ zclient_sync = zclient_new(master, &zclient_options_sync, NULL, 0);
zclient_sync->sock = -1;
zclient_sync->redist_default = ZEBRA_ROUTE_OSPF;
zclient_sync->instance = instance;