summaryrefslogtreecommitdiff
path: root/proto/ospf/ospf.c
diff options
context:
space:
mode:
Diffstat (limited to 'proto/ospf/ospf.c')
-rw-r--r--proto/ospf/ospf.c63
1 files changed, 43 insertions, 20 deletions
diff --git a/proto/ospf/ospf.c b/proto/ospf/ospf.c
index 1aa7407a..232f3f6c 100644
--- a/proto/ospf/ospf.c
+++ b/proto/ospf/ospf.c
@@ -167,7 +167,7 @@ ospf_area_add(struct proto_ospf *po, struct ospf_area_config *ac, int reconf)
#ifdef OSPFv2
oa->options = ac->type;
#else /* OSPFv3 */
- oa->options = OPT_R | ac->type | OPT_V6;
+ oa->options = ac->type | OPT_V6 | (po->stub_router ? 0 : OPT_R);
#endif
/*
@@ -232,7 +232,9 @@ ospf_start(struct proto *p)
struct ospf_area_config *ac;
po->router_id = proto_get_router_id(p->cf);
+ po->last_vlink_id = 0x80000000;
po->rfc1583 = c->rfc1583;
+ po->stub_router = c->stub_router;
po->ebit = 0;
po->ecmp = c->ecmp;
po->tick = c->tick;
@@ -689,7 +691,7 @@ ospf_area_reconfigure(struct ospf_area *oa, struct ospf_area_config *nac)
#ifdef OSPFv2
oa->options = nac->type;
#else /* OSPFv3 */
- oa->options = OPT_R | nac->type | OPT_V6;
+ oa->options = nac->type | OPT_V6 | (oa->po->stub_router ? 0 : OPT_R);
#endif
if (oa_is_nssa(oa) && (oa->po->areano > 1))
oa->po->ebit = 1;
@@ -728,12 +730,16 @@ ospf_reconfigure(struct proto *p, struct proto_config *c)
struct ospf_iface *ifa, *ifx;
struct ospf_iface_patt *ip;
+ if (proto_get_router_id(c) != po->router_id)
+ return 0;
+
if (po->rfc1583 != new->rfc1583)
return 0;
if (old->abr != new->abr)
return 0;
+ po->stub_router = new->stub_router;
po->ecmp = new->ecmp;
po->tick = new->tick;
po->disp_timer->recurrent = po->tick;
@@ -827,6 +833,7 @@ ospf_sh(struct proto *p)
cli_msg(-1014, "%s:", p->name);
cli_msg(-1014, "RFC1583 compatibility: %s", (po->rfc1583 ? "enable" : "disabled"));
+ cli_msg(-1014, "Stub router: %s", (po->stub_router ? "Yes" : "No"));
cli_msg(-1014, "RT scheduler tick: %d", po->tick);
cli_msg(-1014, "Number of areas: %u", po->areano);
cli_msg(-1014, "Number of LSAs in DB:\t%u", po->gr->hash_entries);
@@ -953,8 +960,10 @@ lsa_compare_for_state(const void *p1, const void *p2)
struct ospf_lsa_header *lsa1 = &(he1->lsa);
struct ospf_lsa_header *lsa2 = &(he2->lsa);
- if (he1->domain != he2->domain)
- return he1->domain - he2->domain;
+ if (he1->domain < he2->domain)
+ return -1;
+ if (he1->domain > he2->domain)
+ return 1;
#ifdef OSPFv3
struct ospf_lsa_header lsatmp1, lsatmp2;
@@ -979,14 +988,18 @@ lsa_compare_for_state(const void *p1, const void *p2)
{
#ifdef OSPFv3
/* In OSPFv3, neworks are named base on ID of DR */
- if (lsa1->rt != lsa2->rt)
- return lsa1->rt - lsa2->rt;
+ if (lsa1->rt < lsa2->rt)
+ return -1;
+ if (lsa1->rt > lsa2->rt)
+ return 1;
#endif
/* For OSPFv2, this is IP of the network,
for OSPFv3, this is interface ID */
- if (lsa1->id != lsa2->id)
- return lsa1->id - lsa2->id;
+ if (lsa1->id < lsa2->id)
+ return -1;
+ if (lsa1->id > lsa2->id)
+ return 1;
#ifdef OSPFv3
if (px1 != px2)
@@ -997,14 +1010,20 @@ lsa_compare_for_state(const void *p1, const void *p2)
}
else
{
- if (lsa1->rt != lsa2->rt)
- return lsa1->rt - lsa2->rt;
+ if (lsa1->rt < lsa2->rt)
+ return -1;
+ if (lsa1->rt > lsa2->rt)
+ return 1;
- if (lsa1->type != lsa2->type)
- return lsa1->type - lsa2->type;
-
- if (lsa1->id != lsa2->id)
- return lsa1->id - lsa2->id;
+ if (lsa1->type < lsa2->type)
+ return -1;
+ if (lsa1->type > lsa2->type)
+ return 1;
+
+ if (lsa1->id < lsa2->id)
+ return -1;
+ if (lsa1->id > lsa2->id)
+ return 1;
#ifdef OSPFv3
if (px1 != px2)
@@ -1023,12 +1042,16 @@ ext_compare_for_state(const void *p1, const void *p2)
struct ospf_lsa_header *lsa1 = &(he1->lsa);
struct ospf_lsa_header *lsa2 = &(he2->lsa);
- if (lsa1->rt != lsa2->rt)
- return lsa1->rt - lsa2->rt;
+ if (lsa1->rt < lsa2->rt)
+ return -1;
+ if (lsa1->rt > lsa2->rt)
+ return 1;
+
+ if (lsa1->id < lsa2->id)
+ return -1;
+ if (lsa1->id > lsa2->id)
+ return 1;
- if (lsa1->id != lsa2->id)
- return lsa1->id - lsa2->id;
-
return lsa1->sn - lsa2->sn;
}