ospf6d: Store ospf6 back pointer in route struct

Storing the pointer to ospf6 struct in route struct.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
This commit is contained in:
Mobashshera Rasool 2021-07-15 15:47:36 +00:00
parent 789828186e
commit 22813fdb86
8 changed files with 23 additions and 15 deletions

View File

@ -715,7 +715,7 @@ void ospf6_abr_defaults_to_stub(struct ospf6 *o)
if (!o->backbone)
return;
def = ospf6_route_create();
def = ospf6_route_create(o);
def->type = OSPF6_DEST_TYPE_NETWORK;
def->prefix.family = AF_INET6;
def->prefix.prefixlen = 0;
@ -1150,7 +1150,7 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
/* (5),(6): the path preference is handled by the sorting
in the routing table. Always install the path by substituting
old route (if any). */
route = ospf6_route_create();
route = ospf6_route_create(oa->ospf6);
route->type = type;
route->prefix = prefix;
@ -1237,7 +1237,9 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
listcount(old_route->nh_list));
}
} else {
struct ospf6_route *tmp_route = ospf6_route_create();
struct ospf6_route *tmp_route;
tmp_route = ospf6_route_create(oa->ospf6);
ospf6_copy_nexthops(tmp_route->nh_list,
o_path->nh_list);

View File

@ -519,7 +519,7 @@ DEFUN (area_range,
range = ospf6_route_lookup(&prefix, oa->range_table);
if (range == NULL) {
range = ospf6_route_create();
range = ospf6_route_create(ospf6);
range->type = OSPF6_DEST_TYPE_RANGE;
range->prefix = prefix;
range->path.area_id = oa->area_id;

View File

@ -605,7 +605,7 @@ void ospf6_asbr_lsa_add(struct ospf6_lsa *lsa)
}
}
route = ospf6_route_create();
route = ospf6_route_create(ospf6);
route->type = OSPF6_DEST_TYPE_NETWORK;
route->prefix.family = AF_INET6;
route->prefix.prefixlen = external->prefix.prefix_length;
@ -727,7 +727,7 @@ void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa,
return;
}
route_to_del = ospf6_route_create();
route_to_del = ospf6_route_create(ospf6);
route_to_del->type = OSPF6_DEST_TYPE_NETWORK;
route_to_del->prefix.family = AF_INET6;
route_to_del->prefix.prefixlen = external->prefix.prefix_length;
@ -1465,9 +1465,10 @@ void ospf6_asbr_redistribute_add(int type, ifindex_t ifindex,
}
/* create new entry */
route = ospf6_route_create();
route = ospf6_route_create(ospf6);
route->type = OSPF6_DEST_TYPE_NETWORK;
prefix_copy(&route->prefix, prefix);
route->ospf6 = ospf6;
info = (struct ospf6_external_info *)XCALLOC(
MTYPE_OSPF6_EXTERNAL_INFO, sizeof(struct ospf6_external_info));
@ -2742,7 +2743,7 @@ static void ospf6_originate_new_aggr_lsa(struct ospf6 *ospf6,
&prefix_id.u.prefix4, &aggr->p, aggr->metric);
/* Create summary route and save it. */
rt_aggr = ospf6_route_create();
rt_aggr = ospf6_route_create(ospf6);
rt_aggr->type = OSPF6_DEST_TYPE_NETWORK;
/* Needed to install route while calling zebra api */
SET_FLAG(rt_aggr->flag, OSPF6_ROUTE_BEST);

View File

@ -448,7 +448,7 @@ void ospf6_interface_connected_route_update(struct interface *ifp)
}
}
route = ospf6_route_create();
route = ospf6_route_create(oi->area->ospf6);
memcpy(&route->prefix, c->address, sizeof(struct prefix));
apply_mask(&route->prefix);
route->type = OSPF6_DEST_TYPE_NETWORK;

View File

@ -1347,7 +1347,7 @@ int ospf6_intra_prefix_lsa_originate_transit(struct thread *thread)
|| current + OSPF6_PREFIX_SIZE(op) > end)
break;
route = ospf6_route_create();
route = ospf6_route_create(oi->area->ospf6);
route->type = OSPF6_DEST_TYPE_NETWORK;
route->prefix.family = AF_INET6;
@ -1810,7 +1810,7 @@ void ospf6_intra_prefix_lsa_add(struct ospf6_lsa *lsa)
continue;
}
route = ospf6_route_create();
route = ospf6_route_create(oa->ospf6);
memset(&route->prefix, 0, sizeof(struct prefix));
route->prefix.family = AF_INET6;

View File

@ -453,7 +453,7 @@ void ospf6_copy_paths(struct list *dst, struct list *src)
}
}
struct ospf6_route *ospf6_route_create(void)
struct ospf6_route *ospf6_route_create(struct ospf6 *ospf6)
{
struct ospf6_route *route;
@ -464,6 +464,8 @@ struct ospf6_route *ospf6_route_create(void)
route->paths = list_new();
route->paths->cmp = (int (*)(void *, void *))ospf6_path_cmp;
route->paths->del = (void (*)(void *))ospf6_path_free;
route->ospf6 = ospf6;
return route;
}
@ -482,7 +484,7 @@ struct ospf6_route *ospf6_route_copy(struct ospf6_route *route)
{
struct ospf6_route *new;
new = ospf6_route_create();
new = ospf6_route_create(route->ospf6);
new->type = route->type;
memcpy(&new->prefix, &route->prefix, sizeof(struct prefix));
new->installed = route->installed;

View File

@ -165,6 +165,9 @@ struct ospf6_route {
struct ospf6_route *prev;
struct ospf6_route *next;
/* Back pointer to ospf6 */
struct ospf6 *ospf6;
unsigned int lock;
/* Destination Type */
@ -339,7 +342,7 @@ extern int ospf6_route_get_first_nh_index(struct ospf6_route *route);
#define ospf6_route_add_nexthop(route, ifindex, addr) \
ospf6_add_nexthop(route->nh_list, ifindex, addr)
extern struct ospf6_route *ospf6_route_create(void);
extern struct ospf6_route *ospf6_route_create(struct ospf6 *ospf6);
extern void ospf6_route_delete(struct ospf6_route *);
extern struct ospf6_route *ospf6_route_copy(struct ospf6_route *route);
extern int ospf6_route_cmp(struct ospf6_route *ra, struct ospf6_route *rb);

View File

@ -374,7 +374,7 @@ static int ospf6_spf_install(struct ospf6_vertex *v,
up to here. */
assert(route == NULL);
route = ospf6_route_create();
route = ospf6_route_create(v->area->ospf6);
memcpy(&route->prefix, &v->vertex_id, sizeof(struct prefix));
route->type = OSPF6_DEST_TYPE_LINKSTATE;
route->path.type = OSPF6_PATH_TYPE_INTRA;