}
/* Add an External info for AS-external-LSA. */
-struct external_info *ospf_external_info_add(u_char type, u_short instance,
+struct external_info *ospf_external_info_add(struct ospf *ospf, u_char type,
+ u_short instance,
struct prefix_ipv4 p,
ifindex_t ifindex,
struct in_addr nexthop,
struct ospf_external *ext;
char inetbuf[INET6_BUFSIZ];
- ext = ospf_external_lookup(type, instance);
+ ext = ospf_external_lookup(ospf, type, instance);
if (!ext)
- ext = ospf_external_add(type, instance);
+ ext = ospf_external_add(ospf, type, instance);
rn = route_node_get(EXTERNAL_INFO(ext), (struct prefix *)&p);
/* If old info exists, -- discard new one or overwrite with new one? */
inet_ntop(AF_INET, (void *)&nexthop.s_addr, inetbuf,
INET6_BUFSIZ);
zlog_warn(
- "Redistribute[%s][%d]: %s/%d discarding old info with NH %s.",
+ "Redistribute[%s][%d][%u]: %s/%d discarding old info with NH %s.",
ospf_redist_string(type), instance,
- inet_ntoa(p.prefix), p.prefixlen, inetbuf);
+ ospf->vrf_id, inet_ntoa(p.prefix),
+ p.prefixlen, inetbuf);
XFREE(MTYPE_OSPF_EXTERNAL_INFO, rn->info);
rn->info = NULL;
}
inet_ntop(AF_INET, (void *)&nexthop.s_addr, inetbuf,
INET6_BUFSIZ);
zlog_debug(
- "Redistribute[%s]: %s/%d external info created, with NH %s",
- ospf_redist_string(type), inet_ntoa(p.prefix),
- p.prefixlen, inetbuf);
+ "Redistribute[%s][%u]: %s/%d external info created, with NH %s",
+ ospf_redist_string(type), ospf->vrf_id,
+ inet_ntoa(p.prefix), p.prefixlen, inetbuf);
}
return new;
}
-void ospf_external_info_delete(u_char type, u_short instance,
+void ospf_external_info_delete(struct ospf *ospf, u_char type, u_short instance,
struct prefix_ipv4 p)
{
struct route_node *rn;
struct ospf_external *ext;
- ext = ospf_external_lookup(type, instance);
+ ext = ospf_external_lookup(ospf, type, instance);
if (!ext)
return;
}
}
-struct external_info *ospf_external_info_lookup(u_char type, u_short instance,
+struct external_info *ospf_external_info_lookup(struct ospf *ospf, u_char type,
+ u_short instance,
struct prefix_ipv4 *p)
{
struct route_node *rn;
struct ospf_external *ext;
- ext = ospf_external_lookup(type, instance);
+ ext = ospf_external_lookup(ospf, type, instance);
if (!ext)
return NULL;
struct external_info *ei;
struct ospf_external *ext;
- ext = ospf_external_lookup(type, instance);
+ ext = ospf_external_lookup(ospf, type, instance);
if (!ext)
return;
extern void ospf_reset_route_map_set_values(struct route_map_set_values *);
extern int ospf_route_map_set_compare(struct route_map_set_values *,
struct route_map_set_values *);
-extern struct external_info *ospf_external_info_add(u_char, u_short,
+extern struct external_info *ospf_external_info_add(struct ospf *,
+ u_char, u_short,
struct prefix_ipv4,
ifindex_t, struct in_addr,
route_tag_t);
-extern void ospf_external_info_delete(u_char, u_short, struct prefix_ipv4);
-extern struct external_info *ospf_external_info_lookup(u_char, u_short,
+extern void ospf_external_info_delete(struct ospf*, u_char, u_short,
+ struct prefix_ipv4);
+extern struct external_info *ospf_external_info_lookup(struct ospf*, u_char,
+ u_short,
struct prefix_ipv4 *);
extern struct ospf_route *ospf_external_route_lookup(struct ospf *,
struct prefix_ipv4 *);
struct listnode *node;
struct ospf_external *ext;
- ext_list = om->external[type];
+ ext_list = ospf->external[type];
if (!ext_list)
continue;
ospf->t_external_lsa = NULL;
- ext_list = om->external[type];
+ ext_list = ospf->external[type];
if (!ext_list)
return 0;
if (type == ZEBRA_ROUTE_OSPF)
continue;
- ext_list = om->external[type];
+ ext_list = ospf->external[type];
if (!ext_list)
continue;
/* If there is no default route via redistribute,
then originate AS-external-LSA with nexthop 0 (self). */
nexthop.s_addr = 0;
- ospf_external_info_add(DEFAULT_ROUTE, 0, p, 0, nexthop, 0);
+ ospf_external_info_add(ospf, DEFAULT_ROUTE, 0, p, 0,
+ nexthop, 0);
}
if ((ei = ospf_default_external_info(ospf)))
struct external_info *ei;
struct ospf_external *ext;
- if (type != DEFAULT_ROUTE)
- if ((ext = ospf_external_lookup(type, instance))
- && EXTERNAL_INFO(ext))
- /* Refresh each redistributed AS-external-LSAs. */
- for (rn = route_top(EXTERNAL_INFO(ext)); rn;
- rn = route_next(rn))
- if ((ei = rn->info))
- if (!is_prefix_default(&ei->p)) {
- struct ospf_lsa *lsa;
-
- if ((lsa = ospf_external_info_find_lsa(
- ospf, &ei->p)))
- ospf_external_lsa_refresh(
- ospf, lsa, ei,
- force);
- else
- ospf_external_lsa_originate(
- ospf, ei);
- }
+ if (type == DEFAULT_ROUTE)
+ return;
+
+ ext = ospf_external_lookup(ospf, type, instance);
+
+ if (ext && EXTERNAL_INFO(ext)) {
+ /* Refresh each redistributed AS-external-LSAs. */
+ for (rn = route_top(EXTERNAL_INFO(ext)); rn;
+ rn = route_next(rn)) {
+ ei = rn->info;
+ if (ei) {
+ if (!is_prefix_default(&ei->p)) {
+ struct ospf_lsa *lsa;
+
+ lsa = ospf_external_info_find_lsa(ospf,
+ &ei->p);
+ if (lsa)
+ ospf_external_lsa_refresh(ospf,
+ lsa, ei, force);
+ else
+ ospf_external_lsa_originate(ospf
+ , ei);
+ }
+ }
+ }
+ }
}
/* Refresh AS-external-LSA. */
ospf_external_lsa_flush(ospf, DEFAULT_ROUTE, &p, 0);
- if ((ext = ospf_external_lookup(DEFAULT_ROUTE, 0))
- && EXTERNAL_INFO(ext)) {
- ospf_external_info_delete(DEFAULT_ROUTE, 0, p);
- ospf_external_del(DEFAULT_ROUTE, 0);
+ ext = ospf_external_lookup(ospf, DEFAULT_ROUTE, 0);
+ if (ext && EXTERNAL_INFO(ext)) {
+ ospf_external_info_delete(ospf, DEFAULT_ROUTE, 0, p);
+ ospf_external_del(ospf, DEFAULT_ROUTE, 0);
}
red = ospf_redist_lookup(ospf, DEFAULT_ROUTE, 0);
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;
extern void ospf_distance_reset(struct ospf *);
extern u_char ospf_distance_apply(struct ospf *ospf, struct prefix_ipv4 *,
struct ospf_route *);
-extern struct ospf_external *ospf_external_lookup(u_char, u_short);
-extern struct ospf_external *ospf_external_add(u_char, u_short);
-extern void ospf_external_del(u_char, u_short);
+extern struct ospf_external *ospf_external_lookup(struct ospf*, u_char,
+ u_short);
+extern struct ospf_external *ospf_external_add(struct ospf*, u_char, u_short);
+extern void ospf_external_del(struct ospf *, u_char, u_short);
extern struct ospf_redist *ospf_redist_lookup(struct ospf *, u_char, u_short);
extern struct ospf_redist *ospf_redist_add(struct ospf *, u_char, u_short);
extern void ospf_redist_del(struct ospf *, u_char, u_short);
struct listnode *node;
struct ospf_external *ext;
- ext_list = om->external[i];
+ ext_list = ospf->external[i];
if (!ext_list)
continue;
struct external_info *ei;
struct ospf_external *ext;
- if (ospf_is_type_redistributed(ospf, ZEBRA_ROUTE_CONNECT, 0))
- if ((ext = ospf_external_lookup(ZEBRA_ROUTE_CONNECT, 0))
- && EXTERNAL_INFO(ext)) {
+ if (ospf_is_type_redistributed(ospf, ZEBRA_ROUTE_CONNECT, 0)) {
+ ext = ospf_external_lookup(ospf, ZEBRA_ROUTE_CONNECT, 0);
+ if ((ext) && EXTERNAL_INFO(ext)) {
for (rn = route_top(EXTERNAL_INFO(ext)); rn;
rn = route_next(rn)) {
- if ((ei = rn->info) != NULL) {
- if (add_to_ospf) {
- if (ospf_external_info_find_lsa(
- ospf, &ei->p))
- if (!ospf_distribute_check_connected(
- ospf, ei))
- ospf_external_lsa_flush(
- ospf,
- ei->type,
- &ei->p,
- ei->ifindex /*, ei->nexthop */);
- } else {
- if (!ospf_external_info_find_lsa(
- ospf, &ei->p))
- if (ospf_distribute_check_connected(
- ospf, ei))
- ospf_external_lsa_originate(
- ospf,
- ei);
- }
+ ei = rn->info;
+ if (ei == NULL)
+ continue;
+
+ if (add_to_ospf) {
+ if (ospf_external_info_find_lsa(
+ ospf, &ei->p))
+ if (!ospf_distribute_check_connected(
+ ospf, ei))
+ ospf_external_lsa_flush(
+ ospf,
+ ei->type,
+ &ei->p,
+ ei->ifindex /*, ei->nexthop */);
+ } else {
+ if (!ospf_external_info_find_lsa(
+ ospf, &ei->p))
+ if (ospf_distribute_check_connected(
+ ospf, ei))
+ ospf_external_lsa_originate(
+ ospf,
+ ei);
}
}
}
+ }
}
/* Config network statement related functions. */
/* OSPF thread master. */
struct thread_master *master;
-
- /* Redistributed external information. */
- struct list *external[ZEBRA_ROUTE_MAX + 1];
-#define EXTERNAL_INFO(E) (E->external_info)
-
/* Various OSPF global configuration. */
u_char options;
#define OSPF_MASTER_SHUTDOWN (1 << 0) /* deferred-shutdown */
* update to neighbors immediatly */
uint8_t inst_shutdown;
+ /* Redistributed external information. */
+ struct list *external[ZEBRA_ROUTE_MAX + 1];
+#define EXTERNAL_INFO(E) (E->external_info)
+
QOBJ_FIELDS
};
DECLARE_QOBJ_TYPE(ospf)