ospfd: OSPFv2 VRF Changes II

Accomodate review comments

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
This commit is contained in:
Chirag Shah 2017-09-07 08:08:09 -07:00
parent c0f3f7cdf8
commit 43b8d1d8a1
8 changed files with 516 additions and 489 deletions

1
ospfd/.gitignore vendored
View File

@ -15,3 +15,4 @@ TAGS
*~
*.loT
*.a
*.clippy.c

View File

@ -51,7 +51,7 @@ static void ospf_route_map_update(const char *name)
if (listcount(om->ospf) == 0)
return;
for (ALL_LIST_ELEMENTS_RO (om->ospf, n1, ospf)) {
for (ALL_LIST_ELEMENTS_RO(om->ospf, n1, ospf)) {
/* Update route-map */
for (type = 0; type <= ZEBRA_ROUTE_MAX; type++) {
struct list *red_list;

View File

@ -2570,10 +2570,13 @@ DEFUN (show_ip_ospf_mpls_te_link,
}
/* Show All Interfaces. */
if (argc == 5) {
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
for (ALL_LIST_ELEMENTS(vrf_iflist(ospf->vrf_id), node, nnode,
ifp))
show_mpls_te_link_sub(vty, ifp);
for (ALL_LIST_ELEMENTS_RO(om->ospf, n1, ospf)) {
if (!ospf->oi_running)
continue;
for (ALL_LIST_ELEMENTS(vrf_iflist(ospf->vrf_id), node,
nnode, ifp))
show_mpls_te_link_sub(vty, ifp);
}
}
/* Interface name is specified. */
else {

File diff suppressed because it is too large Load Diff

View File

@ -107,6 +107,8 @@ static int ospf_interface_add(int command, struct zclient *zclient,
struct ospf *ospf = NULL;
ifp = zebra_interface_add_read(zclient->ibuf, vrf_id);
if (ifp == NULL)
return 0;
if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE))
zlog_debug(
@ -123,6 +125,8 @@ static int ospf_interface_add(int command, struct zclient *zclient,
}
ospf = ospf_lookup_by_vrf_id(vrf_id);
if (!ospf)
return 0;
ospf_if_update(ospf, ifp);
@ -282,6 +286,8 @@ static int ospf_interface_address_add(int command, struct zclient *zclient,
}
ospf = ospf_lookup_by_vrf_id(vrf_id);
if (!ospf)
return 0;
ospf_if_update(ospf, c->ifp);
@ -1123,8 +1129,8 @@ void ospf_distribute_list_update(struct ospf *ospf, int type,
{
struct route_table *rt;
struct ospf_external *ext;
void **args = XCALLOC(MTYPE_OSPF_DIST_ARGS, sizeof(void *)*2);
void **args = XCALLOC(MTYPE_OSPF_DIST_ARGS, sizeof (void * )*2);
args[0] = ospf;
args[1] = (void *)((ptrdiff_t) type);
@ -1158,7 +1164,7 @@ static void ospf_filter_update(struct access_list *access)
return;
/* Iterate all ospf [VRF] instances */
for (ALL_LIST_ELEMENTS_RO (om->ospf, n1, ospf)) {
for (ALL_LIST_ELEMENTS_RO(om->ospf, n1, ospf)) {
/* Update distribute-list, and apply filter. */
for (type = 0; type <= ZEBRA_ROUTE_MAX; type++) {
struct list *red_list;

View File

@ -447,14 +447,19 @@ struct ospf *ospf_lookup_by_vrf_id(vrf_id_t vrf_id)
}
struct ospf *ospf_lookup_by_name(const char *name)
/* It should only be used when processing incoming info update from zebra.
* Other situations, it is not sufficient to lookup the ospf instance by
* vrf_name only without using the instance number.
*/
static struct ospf *ospf_lookup_by_name(const char *vrf_name)
{
struct ospf *ospf = NULL;
struct listnode *node, *nnode;
for (ALL_LIST_ELEMENTS(om->ospf, node, nnode, ospf))
if ((ospf->name == NULL && name == NULL)
|| (ospf->name && name && strcmp(ospf->name, name) == 0))
if ((ospf->name == NULL && vrf_name == NULL)
|| (ospf->name && vrf_name &&
strcmp(ospf->name, vrf_name) == 0))
return ospf;
return NULL;
}
@ -1283,8 +1288,9 @@ void ospf_ls_upd_queue_empty(struct ospf_interface *oi)
void ospf_if_update(struct ospf *ospf, struct interface *ifp)
{
if (!ospf)
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
return;
if (IS_DEBUG_OSPF_EVENT)
zlog_debug("%s: interface %s ifp->vrf_id %u ospf vrf %s vrf_id %u router_id %s",

View File

@ -510,14 +510,9 @@ extern const char *ospf_redist_string(u_int route_type);
extern struct ospf *ospf_lookup_instance(u_short);
extern struct ospf *ospf_get(u_short instance, const char *name);
extern struct ospf *ospf_get_instance(u_short);
extern struct ospf *ospf_lookup_by_name(const char *name);
extern struct ospf *ospf_lookup_by_inst_name(u_short instance,
const char *name);
extern struct ospf *ospf_lookup_by_vrf_id(vrf_id_t vrf_id);
extern struct ospf *ospf_lookup_by_name(const char *name);
extern struct ospf *ospf_lookup_by_inst_name(u_short instance,
const char *name);
extern struct ospf *ospf_lookup_by_vrf_id(vrf_id_t vrf_id);
extern void ospf_finish(struct ospf *);
extern void ospf_router_id_update(struct ospf *ospf);
extern int ospf_network_set(struct ospf *, struct prefix_ipv4 *, struct in_addr,

View File

@ -58,6 +58,9 @@ ospfdheader_HEADERS = \
# end
endif
ospfd/ospf_vty_clippy.c: $(CLIPPY_DEPS)
ospfd/ospf_vty.$(OBJEXT): ospfd/ospf_vty_clippy.c
noinst_HEADERS += \
ospfd/ospf_abr.h \
ospfd/ospf_apiserver.h \