diff options
author | Chirag Shah <chirag@cumulusnetworks.com> | 2017-08-25 22:51:12 +0200 |
---|---|---|
committer | Chirag Shah <chirag@cumulusnetworks.com> | 2017-10-03 18:15:19 +0200 |
commit | b5a8894de6454e1dc0b75e1d676c5ed0fcf3438b (patch) | |
tree | 8da7790f9c160dc34874e260a910f0886b24e79c /ospfd/ospf_ri.c | |
parent | Merge pull request #1278 from chiragshah6/ospf_vrf_dev (diff) | |
download | frr-b5a8894de6454e1dc0b75e1d676c5ed0fcf3438b.tar.xz frr-b5a8894de6454e1dc0b75e1d676c5ed0fcf3438b.zip |
ospfd: OSPFv2 VRF Support
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
Diffstat (limited to 'ospfd/ospf_ri.c')
-rw-r--r-- | ospfd/ospf_ri.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/ospfd/ospf_ri.c b/ospfd/ospf_ri.c index 13013bf8c..f9e346b1d 100644 --- a/ospfd/ospf_ri.c +++ b/ospfd/ospf_ri.c @@ -427,7 +427,7 @@ static void initialize_params(struct ospf_router_info *ori) /* If Area address is not null and exist, retrieve corresponding * structure */ - top = ospf_lookup(); + top = ospf_lookup_by_vrf_id(VRF_DEFAULT); zlog_info("RI-> Initialize Router Info for %s scope within area %s", OspfRI.scope == OSPF_OPAQUE_AREA_LSA ? "Area" : "AS", inet_ntoa(OspfRI.area_id)); @@ -586,7 +586,7 @@ static struct ospf_lsa *ospf_router_info_lsa_new() "LSA[Type%d:%s]: Create an Opaque-LSA/ROUTER INFORMATION instance", lsa_type, inet_ntoa(lsa_id)); - top = ospf_lookup(); + top = ospf_lookup_by_vrf_id(VRF_DEFAULT); /* Set opaque-LSA header fields. */ lsa_header_set(s, options, lsa_type, lsa_id, top->router_id); @@ -615,6 +615,11 @@ static struct ospf_lsa *ospf_router_info_lsa_new() new->area = OspfRI.area; /* Area must be null if the Opaque type is AS scope, fulfill otherwise */ + if (new->area && new->area->ospf) + new->vrf_id = new->area->ospf->vrf_id; + else + new->vrf_id = VRF_DEFAULT; + SET_FLAG(new->flags, OSPF_LSA_SELF); memcpy(new->data, lsah, length); stream_free(s); @@ -628,6 +633,7 @@ static int ospf_router_info_lsa_originate1(void *arg) struct ospf *top; struct ospf_area *area; int rc = -1; + vrf_id_t vrf_id = VRF_DEFAULT; /* First check if the area is known if flooding scope is Area */ if (OspfRI.scope == OSPF_OPAQUE_AREA_LSA) { @@ -638,6 +644,8 @@ static int ospf_router_info_lsa_originate1(void *arg) return rc; } OspfRI.area = area; + if (area->ospf) + vrf_id = area->ospf->vrf_id; } /* Create new Opaque-LSA/ROUTER INFORMATION instance. */ @@ -646,9 +654,15 @@ static int ospf_router_info_lsa_originate1(void *arg) "ospf_router_info_lsa_originate1: ospf_router_info_lsa_new() ?"); return rc; } + new->vrf_id = vrf_id; /* Get ospf info */ - top = ospf_lookup(); + top = ospf_lookup_by_vrf_id(vrf_id); + if (top == NULL) { + zlog_debug("%s: ospf instance not found for vrf id %u", + __PRETTY_FUNCTION__, vrf_id); + return rc; + } /* Install this LSA into LSDB. */ if (ospf_lsa_install(top, NULL /*oi */, new) == NULL) { @@ -751,10 +765,11 @@ static struct ospf_lsa *ospf_router_info_lsa_refresh(struct ospf_lsa *lsa) return NULL; } new->data->ls_seqnum = lsa_seqnum_increment(lsa); + new->vrf_id = lsa->vrf_id; /* Install this LSA into LSDB. */ /* Given "lsa" will be freed in the next function. */ - top = ospf_lookup(); + top = ospf_lookup_by_vrf_id(lsa->vrf_id); if (ospf_lsa_install(top, NULL /*oi */, new) == NULL) { zlog_warn("ospf_router_info_lsa_refresh: ospf_lsa_install() ?"); ospf_lsa_unlock(&new); @@ -800,7 +815,7 @@ static void ospf_router_info_lsa_schedule(enum lsa_opcode opcode) if (CHECK_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED) && (opcode == REORIGINATE_THIS_LSA)) opcode = REFRESH_THIS_LSA; - top = ospf_lookup(); + top = ospf_lookup_by_vrf_id(VRF_DEFAULT); if ((OspfRI.scope == OSPF_OPAQUE_AREA_LSA) && (OspfRI.area == NULL)) { zlog_warn( "ospf_router_info_lsa_schedule(): Router Info is Area scope flooding but area is not set"); |