/* For registering threads. */
extern struct thread_master *master;
-struct in_addr router_id_zebra;
/* Router-id update message from zebra. */
static int ospf_router_id_update_zebra(int command, struct zclient *zclient,
buf, ospf_vrf_id_to_name(vrf_id), vrf_id);
}
- router_id_zebra = router_id.u.prefix4;
-
ospf = ospf_lookup_by_vrf_id(vrf_id);
- if (ospf != NULL)
+ if (ospf != NULL) {
+ ospf->router_id_zebra = router_id.u.prefix4;
ospf_router_id_update(ospf);
- else {
+ } else {
if (IS_DEBUG_OSPF_EVENT) {
char buf[PREFIX2STR_BUFFER];
if (rn->info)
ospf_if_free((struct ospf_interface *)rn->info);
- ifp->ifindex = IFINDEX_DELETED;
+ if_set_index(ifp, IFINDEX_INTERNAL);
return 0;
}
stream_get(ifname_tmp, s, INTERFACE_NAMSIZ);
/* And look it up. */
- return if_lookup_by_name_len(
- ifname_tmp, strnlen(ifname_tmp, INTERFACE_NAMSIZ), vrf_id);
+ return if_lookup_by_name(ifname_tmp, vrf_id);
}
static int ospf_interface_state_up(int command, struct zclient *zclient,
memset(&api, 0, sizeof(api));
api.vrf_id = ospf->vrf_id;
+ api.nh_vrf_id = ospf->vrf_id;
api.type = ZEBRA_ROUTE_OSPF;
api.instance = ospf->instance;
api.safi = SAFI_UNICAST;
memset(&api, 0, sizeof(api));
api.vrf_id = ospf->vrf_id;
+ api.nh_vrf_id = ospf->vrf_id;
api.type = ZEBRA_ROUTE_OSPF;
api.instance = ospf->instance;
api.safi = SAFI_UNICAST;
memset(&api, 0, sizeof(api));
api.vrf_id = ospf->vrf_id;
+ api.nh_vrf_id = ospf->vrf_id;
api.type = ZEBRA_ROUTE_OSPF;
api.instance = ospf->instance;
api.safi = SAFI_UNICAST;
memset(&api, 0, sizeof(api));
api.vrf_id = ospf->vrf_id;
+ api.nh_vrf_id = ospf->vrf_id;
api.type = ZEBRA_ROUTE_OSPF;
api.instance = ospf->instance;
api.safi = SAFI_UNICAST;
inet_ntoa(p->prefix), p->prefixlen);
}
-struct ospf_external *ospf_external_lookup(u_char type, u_short instance)
+struct ospf_external *ospf_external_lookup(struct ospf *ospf, u_char type,
+ u_short instance)
{
struct list *ext_list;
struct listnode *node;
struct ospf_external *ext;
- ext_list = om->external[type];
+ ext_list = ospf->external[type];
if (!ext_list)
return (NULL);
return NULL;
}
-struct ospf_external *ospf_external_add(u_char type, u_short instance)
+struct ospf_external *ospf_external_add(struct ospf *ospf, u_char type,
+ u_short instance)
{
struct list *ext_list;
struct ospf_external *ext;
- ext = ospf_external_lookup(type, instance);
+ ext = ospf_external_lookup(ospf, type, instance);
if (ext)
return ext;
- if (!om->external[type])
- om->external[type] = list_new();
+ if (!ospf->external[type])
+ ospf->external[type] = list_new();
- ext_list = om->external[type];
+ ext_list = ospf->external[type];
ext = (struct ospf_external *)XCALLOC(MTYPE_OSPF_EXTERNAL,
sizeof(struct ospf_external));
ext->instance = instance;
return ext;
}
-void ospf_external_del(u_char type, u_short instance)
+void ospf_external_del(struct ospf *ospf, u_char type, u_short instance)
{
struct ospf_external *ext;
- ext = ospf_external_lookup(type, instance);
+ ext = ospf_external_lookup(ospf, type, instance);
if (ext) {
if (EXTERNAL_INFO(ext))
route_table_finish(EXTERNAL_INFO(ext));
- listnode_delete(om->external[type], ext);
- if (!om->external[type]->count) {
- list_delete_and_null(&om->external[type]);
- }
+ listnode_delete(ospf->external[type], ext);
+
+ if (!ospf->external[type]->count)
+ list_delete_and_null(&ospf->external[type]);
+
XFREE(MTYPE_OSPF_EXTERNAL, ext);
}
}
red->dmetric.type = mtype;
red->dmetric.value = mvalue;
- ospf_external_add(type, instance);
+ ospf_external_add(ospf, type, instance);
zclient_redistribute(ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, type,
instance, ospf->vrf_id);
/* Remove the routes from OSPF table. */
ospf_redistribute_withdraw(ospf, type, instance);
- ospf_external_del(type, instance);
+ ospf_external_del(ospf, type, instance);
ospf_asbr_status_update(ospf, --ospf->redistribute);
red->dmetric.type = mtype;
red->dmetric.value = mvalue;
- ospf_external_add(DEFAULT_ROUTE, 0);
+ ospf_external_add(ospf, DEFAULT_ROUTE, 0);
if (ospf_is_type_redistributed(ospf, DEFAULT_ROUTE, 0)) {
/* if ospf->default_originate changes value, is calling
*/
for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
if (i != api.type)
- ospf_external_info_delete(i, api.instance, p);
+ ospf_external_info_delete(ospf, i,
+ api.instance, p);
- ei = ospf_external_info_add(api.type, api.instance, p, ifindex,
- nexthop, api.tag);
+ ei = ospf_external_info_add(ospf, api.type, api.instance, p,
+ ifindex, nexthop, api.tag);
if (ei == NULL) {
/* Nothing has changed, so nothing to do; return */
return 0;
}
} else /* if (command == ZEBRA_REDISTRIBUTE_ROUTE_DEL) */
{
- ospf_external_info_delete(api.type, api.instance, p);
+ ospf_external_info_delete(ospf, api.type, api.instance, p);
if (is_prefix_default(&p))
ospf_external_lsa_refresh_default(ospf);
else
struct listnode *node;
struct ospf_external *ext;
- ext_list = om->external[type];
+ ext_list = ospf->external[type];
if (!ext_list)
continue;
args[1] = (void *)((ptrdiff_t) type);
/* External info does not exist. */
- ext = ospf_external_lookup(type, instance);
+ ext = ospf_external_lookup(ospf, type, instance);
if (!ext || !(rt = EXTERNAL_INFO(ext))) {
XFREE(MTYPE_OSPF_DIST_ARGS, args);
return;
if (!zclient || zclient->sock < 0 || !ospf)
return;
- if (ospf->vrf_id != VRF_DEFAULT && ospf->vrf_id != VRF_UNKNOWN) {
+ if (ospf->vrf_id != VRF_UNKNOWN) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug("%s: Register VRF %s id %u",
__PRETTY_FUNCTION__,
ospf_vrf_id_to_name(ospf->vrf_id),
ospf->vrf_id);
+ /* Deregister for router-id, interfaces,
+ * redistributed routes. */
zclient_send_reg_requests(zclient, ospf->vrf_id);
}
}
if (ospf->vrf_id != VRF_DEFAULT && ospf->vrf_id != VRF_UNKNOWN) {
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug("%s: De-Register VRF %s id %u",
+ zlog_debug("%s: De-Register VRF %s id %u to Zebra.",
__PRETTY_FUNCTION__,
ospf_vrf_id_to_name(ospf->vrf_id),
ospf->vrf_id);
void ospf_zebra_init(struct thread_master *master, u_short instance)
{
/* Allocate zebra structure. */
- zclient = zclient_new(master);
- zclient_init(zclient, ZEBRA_ROUTE_OSPF, instance);
+ zclient = zclient_new_notify(master, &zclient_options_default);
+ zclient_init(zclient, ZEBRA_ROUTE_OSPF, instance, &ospfd_privs);
zclient->zebra_connected = ospf_zebra_connected;
zclient->router_id_update = ospf_router_id_update_zebra;
zclient->interface_add = ospf_interface_add;