mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 17:51:53 +00:00
Indentation.
This commit is contained in:
parent
66261211a9
commit
2e10a170fe
@ -36,13 +36,15 @@ ospf_hello_receive(struct ospf_hello_packet *ps,
|
|||||||
|
|
||||||
if (ntohs(ps->helloint) != ifa->helloint)
|
if (ntohs(ps->helloint) != ifa->helloint)
|
||||||
{
|
{
|
||||||
log(L_WARN "%s%I%shello interval mismatch (%d).", beg, faddr, rec, ntohs(ps->helloint));
|
log(L_WARN "%s%I%shello interval mismatch (%d).", beg, faddr, rec,
|
||||||
|
ntohs(ps->helloint));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ntohl(ps->deadint) != ifa->helloint * ifa->deadc)
|
if (ntohl(ps->deadint) != ifa->helloint * ifa->deadc)
|
||||||
{
|
{
|
||||||
log(L_ERR "%s%I%sdead interval mismatch (%d).", beg, faddr, rec, ntohl(ps->deadint));
|
log(L_ERR "%s%I%sdead interval mismatch (%d).", beg, faddr, rec,
|
||||||
|
ntohl(ps->deadint));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,8 +150,7 @@ ospf_iface_sm(struct ospf_iface *ifa, int event)
|
|||||||
{
|
{
|
||||||
struct ospf_area *oa = ifa->oa;
|
struct ospf_area *oa = ifa->oa;
|
||||||
|
|
||||||
DBG("SM on iface %s. Event is \"%s\".",
|
DBG("SM on iface %s. Event is \"%s\".", ifa->iface->name, ospf_ism[event]);
|
||||||
ifa->iface->name, ospf_ism[event]);
|
|
||||||
|
|
||||||
switch (event)
|
switch (event)
|
||||||
{
|
{
|
||||||
@ -386,8 +385,7 @@ ospf_iface_notify(struct proto *p, unsigned flags, struct iface *iface)
|
|||||||
ifa->options = 2; /* FIXME what options? */
|
ifa->options = 2; /* FIXME what options? */
|
||||||
|
|
||||||
if (ip->type == OSPF_IT_UNDEF)
|
if (ip->type == OSPF_IT_UNDEF)
|
||||||
ifa->type =
|
ifa->type = ospf_iface_clasify(ifa->iface);
|
||||||
ospf_iface_clasify(ifa->iface);
|
|
||||||
else
|
else
|
||||||
ifa->type = ip->type;
|
ifa->type = ip->type;
|
||||||
|
|
||||||
|
@ -12,10 +12,12 @@ void
|
|||||||
flush_lsa(struct top_hash_entry *en, struct ospf_area *oa)
|
flush_lsa(struct top_hash_entry *en, struct ospf_area *oa)
|
||||||
{
|
{
|
||||||
struct proto *p = &oa->po->proto;
|
struct proto *p = &oa->po->proto;
|
||||||
OSPF_TRACE(D_EVENTS, "Going to remove node Type: %u, Id: %I, Rt: %I, Age: %u",
|
OSPF_TRACE(D_EVENTS,
|
||||||
|
"Going to remove node Type: %u, Id: %I, Rt: %I, Age: %u",
|
||||||
en->lsa.type, en->lsa.id, en->lsa.rt, en->lsa.age);
|
en->lsa.type, en->lsa.id, en->lsa.rt, en->lsa.age);
|
||||||
s_rem_node(SNODE en);
|
s_rem_node(SNODE en);
|
||||||
if(en->lsa_body!=NULL) mb_free(en->lsa_body);
|
if (en->lsa_body != NULL)
|
||||||
|
mb_free(en->lsa_body);
|
||||||
en->lsa_body = NULL;
|
en->lsa_body = NULL;
|
||||||
ospf_hash_delete(oa->gr, en);
|
ospf_hash_delete(oa->gr, en);
|
||||||
}
|
}
|
||||||
@ -58,10 +60,12 @@ ospf_age(struct ospf_area *oa)
|
|||||||
}
|
}
|
||||||
if (en->lsa.age == LSA_MAXAGE)
|
if (en->lsa.age == LSA_MAXAGE)
|
||||||
{
|
{
|
||||||
if(flush) flush_lsa(en,oa);
|
if (flush)
|
||||||
|
flush_lsa(en, oa);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if((en->lsa.rt==p->cf->global->router_id)&&(en->lsa.age>=LSREFRESHTIME))
|
if ((en->lsa.rt == p->cf->global->router_id) &&(en->lsa.age >=
|
||||||
|
LSREFRESHTIME))
|
||||||
{
|
{
|
||||||
OSPF_TRACE(D_EVENTS, "Refreshing my LSA: Type: %u, Id: %I, Rt: %I",
|
OSPF_TRACE(D_EVENTS, "Refreshing my LSA: Type: %u, Id: %I, Rt: %I",
|
||||||
en->lsa.type, en->lsa.id, en->lsa.rt);
|
en->lsa.type, en->lsa.id, en->lsa.rt);
|
||||||
@ -80,7 +84,8 @@ ospf_age(struct ospf_area *oa)
|
|||||||
flush_lsa(en, oa);
|
flush_lsa(en, oa);
|
||||||
schedule_rtcalc(oa);
|
schedule_rtcalc(oa);
|
||||||
}
|
}
|
||||||
else en->lsa.age=LSA_MAXAGE;
|
else
|
||||||
|
en->lsa.age = LSA_MAXAGE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -205,7 +210,8 @@ htonlsab(void *h, void *n, u8 type, u16 len)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: bug("(hton): Unknown LSA");
|
default:
|
||||||
|
bug("(hton): Unknown LSA");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -302,7 +308,8 @@ ntohlsab(void *n, void *h, u8 type, u16 len)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: bug("(ntoh): Unknown LSA");
|
default:
|
||||||
|
bug("(ntoh): Unknown LSA");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -349,7 +356,8 @@ lsasum_check(struct ospf_lsa_header *h,void *body,struct proto_ospf *po)
|
|||||||
for (ep = sp + length; sp < ep; sp = q)
|
for (ep = sp + length; sp < ep; sp = q)
|
||||||
{ /* Actually MODX is very large, do we need the for-cyclus? */
|
{ /* Actually MODX is very large, do we need the for-cyclus? */
|
||||||
q = sp + MODX;
|
q = sp + MODX;
|
||||||
if (q > ep) q = ep;
|
if (q > ep)
|
||||||
|
q = ep;
|
||||||
for (p = sp; p < q; p++)
|
for (p = sp; p < q; p++)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -374,9 +382,11 @@ lsasum_check(struct ospf_lsa_header *h,void *body,struct proto_ospf *po)
|
|||||||
}
|
}
|
||||||
|
|
||||||
x = ((length - LSA_CHECKSUM_OFFSET) * c0 - c1) % 255;
|
x = ((length - LSA_CHECKSUM_OFFSET) * c0 - c1) % 255;
|
||||||
if (x <= 0) x += 255;
|
if (x <= 0)
|
||||||
|
x += 255;
|
||||||
y = 510 - c0 - x;
|
y = 510 - c0 - x;
|
||||||
if (y > 255) y -= 255;
|
if (y > 255)
|
||||||
|
y -= 255;
|
||||||
|
|
||||||
((u8 *) & h->checksum)[0] = x;
|
((u8 *) & h->checksum)[0] = x;
|
||||||
((u8 *) & h->checksum)[1] = y;
|
((u8 *) & h->checksum)[1] = y;
|
||||||
@ -392,14 +402,18 @@ lsa_comp(struct ospf_lsa_header *l1, struct ospf_lsa_header *l2)
|
|||||||
sn1 = l1->sn - LSA_INITSEQNO + 1;
|
sn1 = l1->sn - LSA_INITSEQNO + 1;
|
||||||
sn2 = l2->sn - LSA_INITSEQNO + 1;
|
sn2 = l2->sn - LSA_INITSEQNO + 1;
|
||||||
|
|
||||||
if(sn1>sn2) return CMP_NEWER;
|
if (sn1 > sn2)
|
||||||
if(sn1<sn2) return CMP_OLDER;
|
return CMP_NEWER;
|
||||||
|
if (sn1 < sn2)
|
||||||
|
return CMP_OLDER;
|
||||||
|
|
||||||
if (l1->checksum != l2->checksum)
|
if (l1->checksum != l2->checksum)
|
||||||
return l1->checksum < l2->checksum ? CMP_OLDER : CMP_NEWER;
|
return l1->checksum < l2->checksum ? CMP_OLDER : CMP_NEWER;
|
||||||
|
|
||||||
if((l1->age==LSA_MAXAGE)&&(l2->age!=LSA_MAXAGE)) return CMP_NEWER;
|
if ((l1->age == LSA_MAXAGE) && (l2->age != LSA_MAXAGE))
|
||||||
if((l2->age==LSA_MAXAGE)&&(l1->age!=LSA_MAXAGE)) return CMP_OLDER;
|
return CMP_NEWER;
|
||||||
|
if ((l2->age == LSA_MAXAGE) && (l1->age != LSA_MAXAGE))
|
||||||
|
return CMP_OLDER;
|
||||||
|
|
||||||
if (ABS(l1->age - l2->age) > LSA_MAXAGEDIFF)
|
if (ABS(l1->age - l2->age) > LSA_MAXAGEDIFF)
|
||||||
return l1->age < l2->age ? CMP_NEWER : CMP_OLDER;
|
return l1->age < l2->age ? CMP_NEWER : CMP_OLDER;
|
||||||
@ -432,8 +446,9 @@ lsa_install_new(struct ospf_lsa_header *lsa, void *body, struct ospf_area *oa)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if((en->lsa.length!=lsa->length)||(en->lsa.options!=lsa->options)||
|
if ((en->lsa.length != lsa->length) || (en->lsa.options != lsa->options)
|
||||||
((en->lsa.age==LSA_MAXAGE)||(lsa->age==LSA_MAXAGE))) change=1;
|
|| ((en->lsa.age == LSA_MAXAGE) || (lsa->age == LSA_MAXAGE)))
|
||||||
|
change = 1;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
u8 *k = en->lsa_body, *l = body;
|
u8 *k = en->lsa_body, *l = body;
|
||||||
@ -454,7 +469,8 @@ lsa_install_new(struct ospf_lsa_header *lsa, void *body, struct ospf_area *oa)
|
|||||||
|
|
||||||
s_add_tail(&oa->lsal, SNODE en);
|
s_add_tail(&oa->lsal, SNODE en);
|
||||||
en->inst_t = now;
|
en->inst_t = now;
|
||||||
if(en->lsa_body!=NULL) mb_free(en->lsa_body);
|
if (en->lsa_body != NULL)
|
||||||
|
mb_free(en->lsa_body);
|
||||||
en->lsa_body = body;
|
en->lsa_body = body;
|
||||||
memcpy(&en->lsa, lsa, sizeof(struct ospf_lsa_header));
|
memcpy(&en->lsa, lsa, sizeof(struct ospf_lsa_header));
|
||||||
en->ini_age = en->lsa.age;
|
en->ini_age = en->lsa.age;
|
||||||
|
@ -16,13 +16,14 @@ void htonlsab(void *h, void *n, u8 type, u16 len);
|
|||||||
void ntohlsab(void *n, void *h, u8 type, u16 len);
|
void ntohlsab(void *n, void *h, u8 type, u16 len);
|
||||||
void lsasum_calculate(struct ospf_lsa_header *header, void *body,
|
void lsasum_calculate(struct ospf_lsa_header *header, void *body,
|
||||||
struct proto_ospf *p);
|
struct proto_ospf *p);
|
||||||
u16 lsasum_check(struct ospf_lsa_header *h,void *body,struct proto_ospf *po);
|
u16 lsasum_check(struct ospf_lsa_header *h, void *body,
|
||||||
|
struct proto_ospf *po);
|
||||||
#define CMP_NEWER 1
|
#define CMP_NEWER 1
|
||||||
#define CMP_SAME 0
|
#define CMP_SAME 0
|
||||||
#define CMP_OLDER -1
|
#define CMP_OLDER -1
|
||||||
int lsa_comp(struct ospf_lsa_header *l1, struct ospf_lsa_header *l2);
|
int lsa_comp(struct ospf_lsa_header *l1, struct ospf_lsa_header *l2);
|
||||||
struct top_hash_entry *lsa_install_new(struct ospf_lsa_header *lsa, void *body,
|
struct top_hash_entry *lsa_install_new(struct ospf_lsa_header *lsa,
|
||||||
struct ospf_area *oa);
|
void *body, struct ospf_area *oa);
|
||||||
void ospf_age(struct ospf_area *oa);
|
void ospf_age(struct ospf_area *oa);
|
||||||
void flush_lsa(struct top_hash_entry *en, struct ospf_area *oa);
|
void flush_lsa(struct top_hash_entry *en, struct ospf_area *oa);
|
||||||
|
|
||||||
|
@ -109,7 +109,8 @@ ospf_lsreq_receive(struct ospf_lsreq_packet *ps,
|
|||||||
if (ospf_hash_find(n->ifa->oa->gr, llsh->lsh.id, llsh->lsh.rt,
|
if (ospf_hash_find(n->ifa->oa->gr, llsh->lsh.id, llsh->lsh.rt,
|
||||||
llsh->lsh.type) == NULL)
|
llsh->lsh.type) == NULL)
|
||||||
{
|
{
|
||||||
log(L_WARN "Received bad LS req from: %I looking: RT: %I, ID: %I, Type: %u",
|
log(L_WARN
|
||||||
|
"Received bad LS req from: %I looking: RT: %I, ID: %I, Type: %u",
|
||||||
n->ip, lsh->rt, lsh->id, lsh->type);
|
n->ip, lsh->rt, lsh->id, lsh->type);
|
||||||
ospf_neigh_sm(n, INM_BADLSREQ);
|
ospf_neigh_sm(n, INM_BADLSREQ);
|
||||||
rfree(upslab);
|
rfree(upslab);
|
||||||
|
@ -15,12 +15,15 @@ char *ospf_ns[]={" down",
|
|||||||
" exstart",
|
" exstart",
|
||||||
"exchange",
|
"exchange",
|
||||||
" loading",
|
" loading",
|
||||||
" full"};
|
" full"
|
||||||
|
};
|
||||||
|
|
||||||
const char *ospf_inm[]={ "hello received", "neighbor start", "2-way received",
|
const char *ospf_inm[] =
|
||||||
|
{ "hello received", "neighbor start", "2-way received",
|
||||||
"negotiation done", "exstart done", "bad ls request", "load done",
|
"negotiation done", "exstart done", "bad ls request", "load done",
|
||||||
"adjacency ok?", "sequence mismatch", "1-way received", "kill neighbor",
|
"adjacency ok?", "sequence mismatch", "1-way received", "kill neighbor",
|
||||||
"inactivity timer", "line down" };
|
"inactivity timer", "line down"
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
void neighbor_timer_hook(timer * timer);
|
void neighbor_timer_hook(timer * timer);
|
||||||
@ -132,7 +135,8 @@ neigh_chstate(struct ospf_neighbor *n, u8 state)
|
|||||||
n->myimms.bit.m = 1;
|
n->myimms.bit.m = 1;
|
||||||
n->myimms.bit.i = 1;
|
n->myimms.bit.i = 1;
|
||||||
}
|
}
|
||||||
if(state>NEIGHBOR_EXSTART) n->myimms.bit.i=0;
|
if (state > NEIGHBOR_EXSTART)
|
||||||
|
n->myimms.bit.i = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,9 +157,11 @@ electbdr(list nl)
|
|||||||
{
|
{
|
||||||
if (n1 != NULL)
|
if (n1 != NULL)
|
||||||
{
|
{
|
||||||
if(neigh->priority>n1->priority) n1=neigh;
|
if (neigh->priority > n1->priority)
|
||||||
|
n1 = neigh;
|
||||||
else if (neigh->priority == n1->priority)
|
else if (neigh->priority == n1->priority)
|
||||||
if(neigh->rid>n1->rid) n1=neigh;
|
if (neigh->rid > n1->rid)
|
||||||
|
n1 = neigh;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -166,9 +172,11 @@ electbdr(list nl)
|
|||||||
{
|
{
|
||||||
if (n2 != NULL)
|
if (n2 != NULL)
|
||||||
{
|
{
|
||||||
if(neigh->priority>n2->priority) n2=neigh;
|
if (neigh->priority > n2->priority)
|
||||||
|
n2 = neigh;
|
||||||
else if (neigh->priority == n2->priority)
|
else if (neigh->priority == n2->priority)
|
||||||
if(neigh->rid>n2->rid) n2=neigh;
|
if (neigh->rid > n2->rid)
|
||||||
|
n2 = neigh;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -177,7 +185,8 @@ electbdr(list nl)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(n1==NULL) n1=n2;
|
if (n1 == NULL)
|
||||||
|
n1 = n2;
|
||||||
|
|
||||||
return (n1);
|
return (n1);
|
||||||
}
|
}
|
||||||
@ -196,9 +205,11 @@ electdr(list nl)
|
|||||||
{
|
{
|
||||||
if (n != NULL)
|
if (n != NULL)
|
||||||
{
|
{
|
||||||
if(neigh->priority>n->priority) n=neigh;
|
if (neigh->priority > n->priority)
|
||||||
|
n = neigh;
|
||||||
else if (neigh->priority == n->priority)
|
else if (neigh->priority == n->priority)
|
||||||
if(neigh->rid>n->rid) n=neigh;
|
if (neigh->rid > n->rid)
|
||||||
|
n = neigh;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -239,12 +250,14 @@ can_do_adj(struct ospf_neighbor *n)
|
|||||||
break;
|
break;
|
||||||
case OSPF_IS_DROTHER:
|
case OSPF_IS_DROTHER:
|
||||||
if (((n->rid == ifa->drid) || (n->rid == ifa->bdrid))
|
if (((n->rid == ifa->drid) || (n->rid == ifa->bdrid))
|
||||||
&& (n->state>=NEIGHBOR_2WAY)) i=1;
|
&& (n->state >= NEIGHBOR_2WAY))
|
||||||
|
i = 1;
|
||||||
break;
|
break;
|
||||||
case OSPF_IS_PTP:
|
case OSPF_IS_PTP:
|
||||||
case OSPF_IS_BACKUP:
|
case OSPF_IS_BACKUP:
|
||||||
case OSPF_IS_DR:
|
case OSPF_IS_DR:
|
||||||
if(n->state>=NEIGHBOR_2WAY) i=1;
|
if (n->state >= NEIGHBOR_2WAY)
|
||||||
|
i = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
bug("%s: Iface %s in unknown state?", p->name, ifa->iface->name);
|
bug("%s: Iface %s in unknown state?", p->name, ifa->iface->name);
|
||||||
@ -277,8 +290,9 @@ ospf_neigh_sm(struct ospf_neighbor *n, int event)
|
|||||||
struct proto_ospf *po = n->ifa->proto;
|
struct proto_ospf *po = n->ifa->proto;
|
||||||
struct proto *p = (struct proto *) po;
|
struct proto *p = (struct proto *) po;
|
||||||
|
|
||||||
OSPF_TRACE(D_EVENTS, "Neighbor state machine for neighbor %I, event \"%s\".",
|
OSPF_TRACE(D_EVENTS,
|
||||||
n->ip, ospf_inm[event]);
|
"Neighbor state machine for neighbor %I, event \"%s\".", n->ip,
|
||||||
|
ospf_inm[event]);
|
||||||
|
|
||||||
switch (event)
|
switch (event)
|
||||||
{
|
{
|
||||||
@ -298,7 +312,8 @@ ospf_neigh_sm(struct ospf_neighbor *n, int event)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case INM_2WAYREC:
|
case INM_2WAYREC:
|
||||||
if(n->state<NEIGHBOR_2WAY) neigh_chstate(n,NEIGHBOR_2WAY);
|
if (n->state < NEIGHBOR_2WAY)
|
||||||
|
neigh_chstate(n, NEIGHBOR_2WAY);
|
||||||
if ((n->state == NEIGHBOR_2WAY) && can_do_adj(n))
|
if ((n->state == NEIGHBOR_2WAY) && can_do_adj(n))
|
||||||
neigh_chstate(n, NEIGHBOR_EXSTART);
|
neigh_chstate(n, NEIGHBOR_EXSTART);
|
||||||
break;
|
break;
|
||||||
@ -315,7 +330,8 @@ ospf_neigh_sm(struct ospf_neighbor *n, int event)
|
|||||||
mb_free(no);
|
mb_free(no);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else bug("NEGDONE and I'm not in EXSTART?");
|
else
|
||||||
|
bug("NEGDONE and I'm not in EXSTART?");
|
||||||
break;
|
break;
|
||||||
case INM_EXDONE:
|
case INM_EXDONE:
|
||||||
neigh_chstate(n, NEIGHBOR_LOADING);
|
neigh_chstate(n, NEIGHBOR_LOADING);
|
||||||
@ -397,31 +413,41 @@ bdr_election(struct ospf_iface *ifa)
|
|||||||
nbdr = electbdr(ifa->neigh_list);
|
nbdr = electbdr(ifa->neigh_list);
|
||||||
ndr = electdr(ifa->neigh_list);
|
ndr = electdr(ifa->neigh_list);
|
||||||
|
|
||||||
if(ndr==NULL) ndr=nbdr;
|
if (ndr == NULL)
|
||||||
|
ndr = nbdr;
|
||||||
|
|
||||||
if (((ifa->drid == myid) && (ndr != &me))
|
if (((ifa->drid == myid) && (ndr != &me))
|
||||||
|| ((ifa->drid != myid) && (ndr == &me))
|
|| ((ifa->drid != myid) && (ndr == &me))
|
||||||
|| ((ifa->bdrid == myid) && (nbdr != &me))
|
|| ((ifa->bdrid == myid) && (nbdr != &me))
|
||||||
|| ((ifa->bdrid != myid) && (nbdr == &me)))
|
|| ((ifa->bdrid != myid) && (nbdr == &me)))
|
||||||
{
|
{
|
||||||
if(ndr==NULL) ifa->drip=me.dr=ipa_from_u32(0);
|
if (ndr == NULL)
|
||||||
else ifa->drip=me.dr=ndr->ip;
|
ifa->drip = me.dr = ipa_from_u32(0);
|
||||||
|
else
|
||||||
|
ifa->drip = me.dr = ndr->ip;
|
||||||
|
|
||||||
if(nbdr==NULL) ifa->bdrip=me.bdr=ipa_from_u32(0);
|
if (nbdr == NULL)
|
||||||
else ifa->bdrip=me.bdr=nbdr->ip;
|
ifa->bdrip = me.bdr = ipa_from_u32(0);
|
||||||
|
else
|
||||||
|
ifa->bdrip = me.bdr = nbdr->ip;
|
||||||
|
|
||||||
nbdr = electbdr(ifa->neigh_list);
|
nbdr = electbdr(ifa->neigh_list);
|
||||||
ndr = electdr(ifa->neigh_list);
|
ndr = electdr(ifa->neigh_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ndr==NULL) ndrip=ipa_from_u32(0);
|
if (ndr == NULL)
|
||||||
else ndrip=ndr->ip;
|
ndrip = ipa_from_u32(0);
|
||||||
|
else
|
||||||
|
ndrip = ndr->ip;
|
||||||
|
|
||||||
if(nbdr==NULL) nbdrip=ipa_from_u32(0);
|
if (nbdr == NULL)
|
||||||
else nbdrip=nbdr->ip;
|
nbdrip = ipa_from_u32(0);
|
||||||
|
else
|
||||||
|
nbdrip = nbdr->ip;
|
||||||
|
|
||||||
doadj = 0;
|
doadj = 0;
|
||||||
if((ipa_compare(ifa->drip,ndrip)!=0) || (ipa_compare(ifa->bdrip,nbdrip)!=0))
|
if ((ipa_compare(ifa->drip, ndrip) != 0)
|
||||||
|
|| (ipa_compare(ifa->bdrip, nbdrip) != 0))
|
||||||
doadj = 1;
|
doadj = 1;
|
||||||
|
|
||||||
if (ndr == NULL)
|
if (ndr == NULL)
|
||||||
@ -448,11 +474,14 @@ bdr_election(struct ospf_iface *ifa)
|
|||||||
|
|
||||||
DBG("DR=%I, BDR=%I\n", ifa->drid, ifa->bdrid);
|
DBG("DR=%I, BDR=%I\n", ifa->drid, ifa->bdrid);
|
||||||
|
|
||||||
if(myid==ifa->drid) ospf_iface_chstate(ifa, OSPF_IS_DR);
|
if (myid == ifa->drid)
|
||||||
|
ospf_iface_chstate(ifa, OSPF_IS_DR);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(myid==ifa->bdrid) ospf_iface_chstate(ifa, OSPF_IS_BACKUP);
|
if (myid == ifa->bdrid)
|
||||||
else ospf_iface_chstate(ifa, OSPF_IS_DROTHER);
|
ospf_iface_chstate(ifa, OSPF_IS_BACKUP);
|
||||||
|
else
|
||||||
|
ospf_iface_chstate(ifa, OSPF_IS_DROTHER);
|
||||||
}
|
}
|
||||||
|
|
||||||
rem_node(NODE & me);
|
rem_node(NODE & me);
|
||||||
@ -471,8 +500,7 @@ find_neigh(struct ospf_iface *ifa, u32 rid)
|
|||||||
{
|
{
|
||||||
struct ospf_neighbor *n;
|
struct ospf_neighbor *n;
|
||||||
|
|
||||||
WALK_LIST (n, ifa->neigh_list)
|
WALK_LIST(n, ifa->neigh_list) if (n->rid == rid)
|
||||||
if(n->rid == rid)
|
|
||||||
return n;
|
return n;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -485,14 +513,14 @@ find_neigh_noifa(struct proto_ospf *po, u32 rid)
|
|||||||
struct ospf_neighbor *n = NULL, *m;
|
struct ospf_neighbor *n = NULL, *m;
|
||||||
struct ospf_iface *ifa;
|
struct ospf_iface *ifa;
|
||||||
|
|
||||||
WALK_LIST (ifa, po->iface_list)
|
WALK_LIST(ifa, po->iface_list) if ((m = find_neigh(ifa, rid)) != NULL)
|
||||||
if((m=find_neigh(ifa, rid))!=NULL)
|
|
||||||
{
|
{
|
||||||
if (m->state >= NEIGHBOR_2WAY)
|
if (m->state >= NEIGHBOR_2WAY)
|
||||||
{
|
{
|
||||||
if(n==NULL) n=m;
|
if (n == NULL)
|
||||||
else
|
n = m;
|
||||||
if(m->ifa->cost < n->ifa->cost) n=m;
|
else if (m->ifa->cost < n->ifa->cost)
|
||||||
|
n = m;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return n;
|
return n;
|
||||||
@ -503,7 +531,8 @@ ospf_find_area(struct proto_ospf *po, u32 aid)
|
|||||||
{
|
{
|
||||||
struct ospf_area *oa;
|
struct ospf_area *oa;
|
||||||
WALK_LIST(NODE oa, po->area_list)
|
WALK_LIST(NODE oa, po->area_list)
|
||||||
if(((struct ospf_area *)oa)->areaid==aid) return oa;
|
if (((struct ospf_area *) oa)->areaid == aid)
|
||||||
|
return oa;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -518,7 +547,8 @@ neighbor_timer_hook(timer *timer)
|
|||||||
n = (struct ospf_neighbor *) timer->data;
|
n = (struct ospf_neighbor *) timer->data;
|
||||||
ifa = n->ifa;
|
ifa = n->ifa;
|
||||||
p = (struct proto *) (ifa->proto);
|
p = (struct proto *) (ifa->proto);
|
||||||
OSPF_TRACE(D_EVENTS,"Inactivity timer fired on interface %s for neighbor %I.",
|
OSPF_TRACE(D_EVENTS,
|
||||||
|
"Inactivity timer fired on interface %s for neighbor %I.",
|
||||||
ifa->iface->name, n->ip);
|
ifa->iface->name, n->ip);
|
||||||
ospf_neigh_remove(n);
|
ospf_neigh_remove(n);
|
||||||
}
|
}
|
||||||
@ -557,9 +587,12 @@ ospf_sh_neigh_info(struct ospf_neighbor *n)
|
|||||||
bsprintf(etime, "%02u:%02u", min, sec);
|
bsprintf(etime, "%02u:%02u", min, sec);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(n->rid==ifa->drid) pos="dr ";
|
if (n->rid == ifa->drid)
|
||||||
if(n->rid==ifa->bdrid) pos="bdr ";
|
pos = "dr ";
|
||||||
if(n->ifa->type==OSPF_IT_PTP) pos="ptp ";
|
if (n->rid == ifa->bdrid)
|
||||||
|
pos = "bdr ";
|
||||||
|
if (n->ifa->type == OSPF_IT_PTP)
|
||||||
|
pos = "ptp ";
|
||||||
|
|
||||||
cli_msg(-1013, "%-1I\t%3u\t%s/%s\t%-5s\t%-1I\t%-10s", n->rid, n->priority,
|
cli_msg(-1013, "%-1I\t%3u\t%s/%s\t%-5s\t%-1I\t%-10s", n->rid, n->priority,
|
||||||
ospf_ns[n->state], pos, etime, n->ip, ifa->iface->name);
|
ospf_ns[n->state], pos, etime, n->ip, ifa->iface->name);
|
||||||
@ -573,9 +606,11 @@ rxmt_timer_hook(timer *timer)
|
|||||||
|
|
||||||
DBG("%s: RXMT timer fired on interface %s for neigh: %I.\n",
|
DBG("%s: RXMT timer fired on interface %s for neigh: %I.\n",
|
||||||
p->name, ifa->iface->name, n->ip);
|
p->name, ifa->iface->name, n->ip);
|
||||||
if (n->state < NEIGHBOR_LOADING) ospf_dbdes_send(n);
|
if (n->state < NEIGHBOR_LOADING)
|
||||||
|
ospf_dbdes_send(n);
|
||||||
|
|
||||||
if(n->state < NEIGHBOR_FULL) ospf_lsreq_send(n);
|
if (n->state < NEIGHBOR_FULL)
|
||||||
|
ospf_lsreq_send(n);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!EMPTY_SLIST(n->lsrtl))
|
if (!EMPTY_SLIST(n->lsrtl))
|
||||||
@ -589,7 +624,8 @@ rxmt_timer_hook(timer *timer)
|
|||||||
|
|
||||||
WALK_SLIST(SNODE en, n->lsrtl)
|
WALK_SLIST(SNODE en, n->lsrtl)
|
||||||
{
|
{
|
||||||
if((SNODE en)->next==(SNODE en)) bug("RTList is cycled");
|
if ((SNODE en)->next == (SNODE en))
|
||||||
|
bug("RTList is cycled");
|
||||||
llsh = sl_alloc(upslab);
|
llsh = sl_alloc(upslab);
|
||||||
llsh->lsh.id = en->lsa.id;
|
llsh->lsh.id = en->lsa.id;
|
||||||
llsh->lsh.rt = en->lsa.rt;
|
llsh->lsh.rt = en->lsa.rt;
|
||||||
@ -610,4 +646,3 @@ ackd_timer_hook(timer *t)
|
|||||||
struct ospf_neighbor *n = t->data;
|
struct ospf_neighbor *n = t->data;
|
||||||
ospf_lsack_send(n, ACKL_DELAY);
|
ospf_lsack_send(n, ACKL_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,8 @@ ospf_start(struct proto *p)
|
|||||||
antmp->hidden = anet->hidden;
|
antmp->hidden = anet->hidden;
|
||||||
add_tail(&oa->net_list, NODE antmp);
|
add_tail(&oa->net_list, NODE antmp);
|
||||||
}
|
}
|
||||||
fib_init(&oa->infib,po->proto.pool,sizeof(struct infib),16,init_infib);
|
fib_init(&oa->infib, po->proto.pool, sizeof(struct infib), 16,
|
||||||
|
init_infib);
|
||||||
}
|
}
|
||||||
return PS_UP;
|
return PS_UP;
|
||||||
}
|
}
|
||||||
@ -152,7 +153,8 @@ ospf_dump(struct proto *p)
|
|||||||
{
|
{
|
||||||
OSPF_TRACE(D_EVENTS, "LSA graph dump for area \"%I\" start:", oa->areaid);
|
OSPF_TRACE(D_EVENTS, "LSA graph dump for area \"%I\" start:", oa->areaid);
|
||||||
ospf_top_dump(oa->gr, p);
|
ospf_top_dump(oa->gr, p);
|
||||||
OSPF_TRACE(D_EVENTS, "LSA graph dump for area \"%I\" finished", oa->areaid);
|
OSPF_TRACE(D_EVENTS, "LSA graph dump for area \"%I\" finished",
|
||||||
|
oa->areaid);
|
||||||
}
|
}
|
||||||
neigh_dump_all();
|
neigh_dump_all();
|
||||||
}
|
}
|
||||||
@ -181,23 +183,30 @@ ospf_init(struct proto_config *c)
|
|||||||
static int
|
static int
|
||||||
ospf_rte_better(struct rte *new, struct rte *old)
|
ospf_rte_better(struct rte *new, struct rte *old)
|
||||||
{
|
{
|
||||||
if(new->u.ospf.metric1==LSINFINITY) return 0;
|
if (new->u.ospf.metric1 == LSINFINITY)
|
||||||
|
return 0;
|
||||||
|
|
||||||
/* External paths are always longer that internal */
|
/* External paths are always longer that internal */
|
||||||
if(((new->attrs->source==RTS_OSPF) || (new->attrs->source==RTS_OSPF_IA))
|
if (((new->attrs->source == RTS_OSPF)
|
||||||
&& (old->attrs->source==RTS_OSPF_EXT)) return 1;
|
|| (new->attrs->source == RTS_OSPF_IA))
|
||||||
if(((old->attrs->source==RTS_OSPF) || (old->attrs->source==RTS_OSPF_IA))
|
&& (old->attrs->source == RTS_OSPF_EXT))
|
||||||
&& (new->attrs->source==RTS_OSPF_EXT)) return 0;
|
return 1;
|
||||||
|
if (((old->attrs->source == RTS_OSPF)
|
||||||
|
|| (old->attrs->source == RTS_OSPF_IA))
|
||||||
|
&& (new->attrs->source == RTS_OSPF_EXT))
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (new->u.ospf.metric2 < old->u.ospf.metric2)
|
if (new->u.ospf.metric2 < old->u.ospf.metric2)
|
||||||
{
|
{
|
||||||
if(old->u.ospf.metric2==LSINFINITY) return 0; /* Old is E1, new is E2 */
|
if (old->u.ospf.metric2 == LSINFINITY)
|
||||||
|
return 0; /* Old is E1, new is E2 */
|
||||||
return 1; /* Both are E2 */
|
return 1; /* Both are E2 */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new->u.ospf.metric2 > old->u.ospf.metric2)
|
if (new->u.ospf.metric2 > old->u.ospf.metric2)
|
||||||
{
|
{
|
||||||
if(new->u.ospf.metric2==LSINFINITY) return 1; /* New is E1, old is E2 */
|
if (new->u.ospf.metric2 == LSINFINITY)
|
||||||
|
return 1; /* New is E1, old is E2 */
|
||||||
return 0; /* Both are E2 */
|
return 0; /* Both are E2 */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,7 +216,8 @@ ospf_rte_better(struct rte *new, struct rte *old)
|
|||||||
* 2) Paths are E1.
|
* 2) Paths are E1.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if(new->u.ospf.metric1<old->u.ospf.metric1) return 1;
|
if (new->u.ospf.metric1 < old->u.ospf.metric1)
|
||||||
|
return 1;
|
||||||
return 0; /* Old is shorter or same */
|
return 0; /* Old is shorter or same */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,9 +232,11 @@ ospf_rte_same(struct rte *new, struct rte *old)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static ea_list *
|
static ea_list *
|
||||||
ospf_build_attrs(ea_list *next, struct linpool *pool, u32 m1, u32 m2, u32 tag)
|
ospf_build_attrs(ea_list * next, struct linpool *pool, u32 m1, u32 m2,
|
||||||
|
u32 tag)
|
||||||
{
|
{
|
||||||
struct ea_list *l = lp_alloc(pool, sizeof(struct ea_list) + 3*sizeof(eattr));
|
struct ea_list *l =
|
||||||
|
lp_alloc(pool, sizeof(struct ea_list) + 3 * sizeof(eattr));
|
||||||
|
|
||||||
l->next = next;
|
l->next = next;
|
||||||
l->flags = EALF_SORTED;
|
l->flags = EALF_SORTED;
|
||||||
@ -267,10 +279,10 @@ schedule_rtcalc(struct ospf_area *oa)
|
|||||||
struct proto_ospf *po = oa->po;
|
struct proto_ospf *po = oa->po;
|
||||||
struct proto *p = &po->proto;
|
struct proto *p = &po->proto;
|
||||||
|
|
||||||
if(oa->calcrt) return;
|
if (oa->calcrt)
|
||||||
|
return;
|
||||||
|
|
||||||
OSPF_TRACE(D_EVENTS, "Scheduling RT calculation for area %I.",
|
OSPF_TRACE(D_EVENTS, "Scheduling RT calculation for area %I.", oa->areaid);
|
||||||
oa->areaid);
|
|
||||||
oa->calcrt = 1;
|
oa->calcrt = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,19 +304,22 @@ area_disp(timer *timer)
|
|||||||
struct ospf_iface *ifa;
|
struct ospf_iface *ifa;
|
||||||
|
|
||||||
/* Now try to originage rt_lsa */
|
/* Now try to originage rt_lsa */
|
||||||
if(oa->origrt) originate_rt_lsa(oa);
|
if (oa->origrt)
|
||||||
|
originate_rt_lsa(oa);
|
||||||
|
|
||||||
/* Now try to originate network LSA's */
|
/* Now try to originate network LSA's */
|
||||||
WALK_LIST(ifa, po->iface_list)
|
WALK_LIST(ifa, po->iface_list)
|
||||||
{
|
{
|
||||||
if(ifa->orignet&&(ifa->an==oa->areaid)) originate_net_lsa(ifa);
|
if (ifa->orignet && (ifa->an == oa->areaid))
|
||||||
|
originate_net_lsa(ifa);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Age LSA DB */
|
/* Age LSA DB */
|
||||||
ospf_age(oa);
|
ospf_age(oa);
|
||||||
|
|
||||||
/* Calculate routing table */
|
/* Calculate routing table */
|
||||||
if(oa->calcrt) ospf_rt_spfa(oa);
|
if (oa->calcrt)
|
||||||
|
ospf_rt_spfa(oa);
|
||||||
oa->calcrt = 0;
|
oa->calcrt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,11 +335,13 @@ area_disp(timer *timer)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
int
|
||||||
ospf_import_control(struct proto *p, rte **new, ea_list **attrs, struct linpool *pool)
|
ospf_import_control(struct proto *p, rte ** new, ea_list ** attrs,
|
||||||
|
struct linpool *pool)
|
||||||
{
|
{
|
||||||
rte *e = *new;
|
rte *e = *new;
|
||||||
|
|
||||||
if(p==e->attrs->proto) return -1; /* Reject our own routes */
|
if (p == e->attrs->proto)
|
||||||
|
return -1; /* Reject our own routes */
|
||||||
*attrs = ospf_build_attrs(*attrs, pool, LSINFINITY, 10000, 0);
|
*attrs = ospf_build_attrs(*attrs, pool, LSINFINITY, 10000, 0);
|
||||||
return 0; /* Leave decision to the filters */
|
return 0; /* Leave decision to the filters */
|
||||||
}
|
}
|
||||||
@ -332,7 +349,8 @@ ospf_import_control(struct proto *p, rte **new, ea_list **attrs, struct linpool
|
|||||||
struct ea_list *
|
struct ea_list *
|
||||||
ospf_make_tmp_attrs(struct rte *rt, struct linpool *pool)
|
ospf_make_tmp_attrs(struct rte *rt, struct linpool *pool)
|
||||||
{
|
{
|
||||||
return ospf_build_attrs(NULL, pool, rt->u.ospf.metric1, rt->u.ospf.metric2, rt->u.ospf.tag);
|
return ospf_build_attrs(NULL, pool, rt->u.ospf.metric1, rt->u.ospf.metric2,
|
||||||
|
rt->u.ospf.tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -361,14 +379,14 @@ ospf_shutdown(struct proto *p)
|
|||||||
OSPF_TRACE(D_EVENTS, "Shutdown requested");
|
OSPF_TRACE(D_EVENTS, "Shutdown requested");
|
||||||
|
|
||||||
/* And send to all my neighbors 1WAY */
|
/* And send to all my neighbors 1WAY */
|
||||||
WALK_LIST(ifa, po->iface_list)
|
WALK_LIST(ifa, po->iface_list) ospf_iface_shutdown(ifa);
|
||||||
ospf_iface_shutdown(ifa);
|
|
||||||
|
|
||||||
return PS_DOWN;
|
return PS_DOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ospf_rt_notify(struct proto *p, net *n, rte *new, rte *old UNUSED, ea_list *attrs)
|
ospf_rt_notify(struct proto *p, net * n, rte * new, rte * old UNUSED,
|
||||||
|
ea_list * attrs)
|
||||||
{
|
{
|
||||||
struct proto_ospf *po = (struct proto_ospf *) p;
|
struct proto_ospf *po = (struct proto_ospf *) p;
|
||||||
|
|
||||||
@ -415,7 +433,8 @@ ospf_get_status(struct proto *p, byte *buf)
|
|||||||
{
|
{
|
||||||
struct proto_ospf *po = (struct proto_ospf *) p;
|
struct proto_ospf *po = (struct proto_ospf *) p;
|
||||||
|
|
||||||
if (p->proto_state == PS_DOWN) buf[0] = 0;
|
if (p->proto_state == PS_DOWN)
|
||||||
|
buf[0] = 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
struct ospf_iface *ifa;
|
struct ospf_iface *ifa;
|
||||||
@ -423,11 +442,13 @@ ospf_get_status(struct proto *p, byte *buf)
|
|||||||
int adj = 0;
|
int adj = 0;
|
||||||
|
|
||||||
WALK_LIST(ifa, po->iface_list)
|
WALK_LIST(ifa, po->iface_list)
|
||||||
WALK_LIST(n,ifa->neigh_list)
|
WALK_LIST(n, ifa->neigh_list) if (n->state == NEIGHBOR_FULL)
|
||||||
if(n->state==NEIGHBOR_FULL) adj=1;
|
adj = 1;
|
||||||
|
|
||||||
if(adj==0) strcpy(buf, "Alone");
|
if (adj == 0)
|
||||||
else strcpy(buf, "Running");
|
strcpy(buf, "Alone");
|
||||||
|
else
|
||||||
|
strcpy(buf, "Running");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -443,13 +464,18 @@ ospf_get_route_info(rte *rte, byte *buf, ea_list *attrs UNUSED)
|
|||||||
type = 'E';
|
type = 'E';
|
||||||
|
|
||||||
}
|
}
|
||||||
if(rte->u.ospf.metric2!=LSINFINITY) met='2';
|
if (rte->u.ospf.metric2 != LSINFINITY)
|
||||||
if(rte->attrs->source==RTS_OSPF_IA) type='A';
|
met = '2';
|
||||||
if(rte->attrs->source==RTS_OSPF) type='I';
|
if (rte->attrs->source == RTS_OSPF_IA)
|
||||||
|
type = 'A';
|
||||||
|
if (rte->attrs->source == RTS_OSPF)
|
||||||
|
type = 'I';
|
||||||
buf += bsprintf(buf, " %c", type);
|
buf += bsprintf(buf, " %c", type);
|
||||||
if(met!=' ') buf += bsprintf(buf, "%c", met);
|
if (met != ' ')
|
||||||
|
buf += bsprintf(buf, "%c", met);
|
||||||
buf += bsprintf(buf, " (%d/%d", rte->pref, rte->u.ospf.metric1);
|
buf += bsprintf(buf, " (%d/%d", rte->pref, rte->u.ospf.metric1);
|
||||||
if(rte->u.ospf.metric2!=LSINFINITY) buf += bsprintf(buf, "/%d", rte->u.ospf.metric2);
|
if (rte->u.ospf.metric2 != LSINFINITY)
|
||||||
|
buf += bsprintf(buf, "/%d", rte->u.ospf.metric2);
|
||||||
buf += bsprintf(buf, ")");
|
buf += bsprintf(buf, ")");
|
||||||
if (rte->attrs->source == RTS_OSPF_EXT && rte->u.ospf.tag)
|
if (rte->attrs->source == RTS_OSPF_EXT && rte->u.ospf.tag)
|
||||||
{
|
{
|
||||||
@ -462,10 +488,17 @@ ospf_get_attr(eattr *a, byte *buf)
|
|||||||
{
|
{
|
||||||
switch (a->id)
|
switch (a->id)
|
||||||
{
|
{
|
||||||
case EA_OSPF_METRIC1: bsprintf(buf, "metric1"); return GA_NAME;
|
case EA_OSPF_METRIC1:
|
||||||
case EA_OSPF_METRIC2: bsprintf(buf, "metric2"); return GA_NAME;
|
bsprintf(buf, "metric1");
|
||||||
case EA_OSPF_TAG: bsprintf(buf, "tag: %08x", a->u.data); return GA_FULL;
|
return GA_NAME;
|
||||||
default: return GA_UNKNOWN;
|
case EA_OSPF_METRIC2:
|
||||||
|
bsprintf(buf, "metric2");
|
||||||
|
return GA_NAME;
|
||||||
|
case EA_OSPF_TAG:
|
||||||
|
bsprintf(buf, "tag: %08x", a->u.data);
|
||||||
|
return GA_FULL;
|
||||||
|
default:
|
||||||
|
return GA_UNKNOWN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -512,13 +545,16 @@ ospf_reconfigure(struct proto *p, struct proto_config *c)
|
|||||||
|
|
||||||
while (((NODE(ac1))->next != NULL) && ((NODE(ac2))->next != NULL))
|
while (((NODE(ac1))->next != NULL) && ((NODE(ac2))->next != NULL))
|
||||||
{
|
{
|
||||||
if(ac1->areaid!=ac2->areaid) return 0;
|
if (ac1->areaid != ac2->areaid)
|
||||||
if(ac1->stub!=ac2->stub) return 0; /* FIXME: non zero values can change */
|
return 0;
|
||||||
|
if (ac1->stub != ac2->stub)
|
||||||
|
return 0; /* FIXME: non zero values can change */
|
||||||
|
|
||||||
WALK_LIST(oa,po->area_list)
|
WALK_LIST(oa, po->area_list) if (oa->areaid == ac2->areaid)
|
||||||
if(oa->areaid==ac2->areaid) break;
|
break;
|
||||||
|
|
||||||
if(!oa) return 0;
|
if (!oa)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (ac1->tick != ac2->tick)
|
if (ac1->tick != ac2->tick)
|
||||||
{
|
{
|
||||||
@ -559,7 +595,8 @@ ospf_reconfigure(struct proto *p, struct proto_config *c)
|
|||||||
{
|
{
|
||||||
/* Now reconfigure interface */
|
/* Now reconfigure interface */
|
||||||
if (!(ip2 = (struct ospf_iface_patt *)
|
if (!(ip2 = (struct ospf_iface_patt *)
|
||||||
iface_patt_match(&ac2->patt_list, ifa->iface))) return 0;
|
iface_patt_match(&ac2->patt_list, ifa->iface)))
|
||||||
|
return 0;
|
||||||
|
|
||||||
/* HELLO TIMER */
|
/* HELLO TIMER */
|
||||||
if (ip1->helloint != ip2->helloint)
|
if (ip1->helloint != ip2->helloint)
|
||||||
@ -598,8 +635,7 @@ ospf_reconfigure(struct proto *p, struct proto_config *c)
|
|||||||
{
|
{
|
||||||
ifa->strictnbma = ip2->strictnbma;
|
ifa->strictnbma = ip2->strictnbma;
|
||||||
OSPF_TRACE(D_EVENTS,
|
OSPF_TRACE(D_EVENTS,
|
||||||
"Interface %s is now strict NBMA.",
|
"Interface %s is now strict NBMA.", ifa->iface->name);
|
||||||
ifa->iface->name);
|
|
||||||
}
|
}
|
||||||
if ((ip1->strictnbma != 0) && (ip2->strictnbma == 0))
|
if ((ip1->strictnbma != 0) && (ip2->strictnbma == 0))
|
||||||
{
|
{
|
||||||
@ -613,19 +649,15 @@ ospf_reconfigure(struct proto *p, struct proto_config *c)
|
|||||||
if ((ip1->stub == 0) && (ip2->stub != 0))
|
if ((ip1->stub == 0) && (ip2->stub != 0))
|
||||||
{
|
{
|
||||||
ifa->stub = ip2->stub;
|
ifa->stub = ip2->stub;
|
||||||
OSPF_TRACE(D_EVENTS,
|
OSPF_TRACE(D_EVENTS, "Interface %s is now stub.", ifa->iface->name);
|
||||||
"Interface %s is now stub.",
|
|
||||||
ifa->iface->name);
|
|
||||||
}
|
}
|
||||||
if ((ip1->stub != 0) && (ip2->stub == 0) &&
|
if ((ip1->stub != 0) && (ip2->stub == 0) &&
|
||||||
((ifa->ioprob & OSPF_I_IP) == 0) &&
|
((ifa->ioprob & OSPF_I_IP) == 0) &&
|
||||||
(((ifa->ioprob & OSPF_I_MC)==0)||
|
(((ifa->ioprob & OSPF_I_MC) == 0) || (ifa->type == OSPF_IT_NBMA)))
|
||||||
(ifa->type==OSPF_IT_NBMA)))
|
|
||||||
{
|
{
|
||||||
ifa->stub = ip2->stub;
|
ifa->stub = ip2->stub;
|
||||||
OSPF_TRACE(D_EVENTS,
|
OSPF_TRACE(D_EVENTS,
|
||||||
"Interface %s is no longer stub.",
|
"Interface %s is no longer stub.", ifa->iface->name);
|
||||||
ifa->iface->name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* AUTHENTICATION */
|
/* AUTHENTICATION */
|
||||||
@ -640,8 +672,7 @@ ospf_reconfigure(struct proto *p, struct proto_config *c)
|
|||||||
{
|
{
|
||||||
memcpy(ifa->aukey, ip2->password, 8);
|
memcpy(ifa->aukey, ip2->password, 8);
|
||||||
OSPF_TRACE(D_EVENTS,
|
OSPF_TRACE(D_EVENTS,
|
||||||
"Changing password on interface %s",
|
"Changing password on interface %s", ifa->iface->name);
|
||||||
ifa->iface->name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* RXMT */
|
/* RXMT */
|
||||||
@ -670,7 +701,8 @@ ospf_reconfigure(struct proto *p, struct proto_config *c)
|
|||||||
ifa->inftransdelay = ip2->inftransdelay;
|
ifa->inftransdelay = ip2->inftransdelay;
|
||||||
OSPF_TRACE(D_EVENTS,
|
OSPF_TRACE(D_EVENTS,
|
||||||
"Changing transmit delay on interface %s from %d to %d",
|
"Changing transmit delay on interface %s from %d to %d",
|
||||||
ifa->iface->name,ip1->inftransdelay,ip2->inftransdelay);
|
ifa->iface->name, ip1->inftransdelay,
|
||||||
|
ip2->inftransdelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* DEAD COUNT */
|
/* DEAD COUNT */
|
||||||
@ -771,8 +803,8 @@ ospf_sh_neigh(struct proto *p, char *iff)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cli_msg(-1013, "%s:", p->name);
|
cli_msg(-1013, "%s:", p->name);
|
||||||
cli_msg(-1013,"%-12s\t%3s\t%-15s\t%-5s\t%-12s\t%-10s","Router ID","Pri",
|
cli_msg(-1013, "%-12s\t%3s\t%-15s\t%-5s\t%-12s\t%-10s", "Router ID",
|
||||||
" State", "DTime", "Router IP", "Interface");
|
"Pri", " State", "DTime", "Router IP", "Interface");
|
||||||
WALK_LIST(n, ifa->neigh_list) ospf_sh_neigh_info(n);
|
WALK_LIST(n, ifa->neigh_list) ospf_sh_neigh_info(n);
|
||||||
cli_msg(0, "");
|
cli_msg(0, "");
|
||||||
return;
|
return;
|
||||||
@ -782,8 +814,7 @@ ospf_sh_neigh(struct proto *p, char *iff)
|
|||||||
cli_msg(-1013, "%-12s\t%3s\t%-15s\t%-5s\t%-12s\t%-10s", "Router ID", "Pri",
|
cli_msg(-1013, "%-12s\t%3s\t%-15s\t%-5s\t%-12s\t%-10s", "Router ID", "Pri",
|
||||||
" State", "DTime", "Router IP", "Interface");
|
" State", "DTime", "Router IP", "Interface");
|
||||||
WALK_LIST(ifa, po->iface_list)
|
WALK_LIST(ifa, po->iface_list)
|
||||||
WALK_LIST(n, ifa->neigh_list)
|
WALK_LIST(n, ifa->neigh_list) ospf_sh_neigh_info(n);
|
||||||
ospf_sh_neigh_info(n);
|
|
||||||
cli_msg(0, "");
|
cli_msg(0, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -817,11 +848,13 @@ ospf_sh(struct proto *p)
|
|||||||
adjno = 0;
|
adjno = 0;
|
||||||
WALK_LIST(ifa, po->iface_list)
|
WALK_LIST(ifa, po->iface_list)
|
||||||
{
|
{
|
||||||
if(oa==ifa->oa) ifano++;
|
if (oa == ifa->oa)
|
||||||
|
ifano++;
|
||||||
WALK_LIST(n, ifa->neigh_list)
|
WALK_LIST(n, ifa->neigh_list)
|
||||||
{
|
{
|
||||||
nno++;
|
nno++;
|
||||||
if(n->state==NEIGHBOR_FULL) adjno++;
|
if (n->state == NEIGHBOR_FULL)
|
||||||
|
adjno++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cli_msg(-1014, "\t\tStub:\t%s", oa->stub ? "Yes" : "No");
|
cli_msg(-1014, "\t\tStub:\t%s", oa->stub ? "Yes" : "No");
|
||||||
@ -896,4 +929,3 @@ struct protocol proto_ospf = {
|
|||||||
get_status:ospf_get_status,
|
get_status:ospf_get_status,
|
||||||
reconfigure:ospf_reconfigure
|
reconfigure:ospf_reconfigure
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -53,19 +53,22 @@
|
|||||||
#define LSINFINITY 0xffff /* RFC says 0xffffff ??? */
|
#define LSINFINITY 0xffff /* RFC says 0xffffff ??? */
|
||||||
#define DISPTICK 7
|
#define DISPTICK 7
|
||||||
|
|
||||||
struct ospf_config {
|
struct ospf_config
|
||||||
|
{
|
||||||
struct proto_config c;
|
struct proto_config c;
|
||||||
int rfc1583;
|
int rfc1583;
|
||||||
list area_list;
|
list area_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct nbma_node {
|
struct nbma_node
|
||||||
|
{
|
||||||
node n;
|
node n;
|
||||||
ip_addr ip;
|
ip_addr ip;
|
||||||
int eligible;
|
int eligible;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct area_net {
|
struct area_net
|
||||||
|
{
|
||||||
node n;
|
node n;
|
||||||
struct prefix px;
|
struct prefix px;
|
||||||
int hidden;
|
int hidden;
|
||||||
@ -73,7 +76,8 @@ struct area_net {
|
|||||||
int oldactive;
|
int oldactive;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ospf_area_config {
|
struct ospf_area_config
|
||||||
|
{
|
||||||
node n;
|
node n;
|
||||||
u32 areaid;
|
u32 areaid;
|
||||||
int stub;
|
int stub;
|
||||||
@ -82,7 +86,8 @@ struct ospf_area_config {
|
|||||||
list net_list;
|
list net_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ospf_iface {
|
struct ospf_iface
|
||||||
|
{
|
||||||
node n;
|
node n;
|
||||||
struct proto_ospf *proto;
|
struct proto_ospf *proto;
|
||||||
struct iface *iface; /* Nest's iface */
|
struct iface *iface; /* Nest's iface */
|
||||||
@ -150,7 +155,8 @@ struct ospf_iface {
|
|||||||
list nbma_list;
|
list nbma_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ospf_packet {
|
struct ospf_packet
|
||||||
|
{
|
||||||
u8 version;
|
u8 version;
|
||||||
u8 type;
|
u8 type;
|
||||||
#define HELLO_P 1 /* Hello */
|
#define HELLO_P 1 /* Hello */
|
||||||
@ -167,7 +173,8 @@ struct ospf_packet {
|
|||||||
u8 authetication[8];
|
u8 authetication[8];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ospf_hello_packet {
|
struct ospf_hello_packet
|
||||||
|
{
|
||||||
struct ospf_packet ospf_packet;
|
struct ospf_packet ospf_packet;
|
||||||
ip_addr netmask;
|
ip_addr netmask;
|
||||||
u16 helloint;
|
u16 helloint;
|
||||||
@ -178,7 +185,8 @@ struct ospf_hello_packet {
|
|||||||
ip_addr bdr;
|
ip_addr bdr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct immsb {
|
struct immsb
|
||||||
|
{
|
||||||
#ifdef _BIG_ENDIAN
|
#ifdef _BIG_ENDIAN
|
||||||
u8 padding:5;
|
u8 padding:5;
|
||||||
u8 i:1;
|
u8 i:1;
|
||||||
@ -192,12 +200,14 @@ struct immsb {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
union imms {
|
union imms
|
||||||
|
{
|
||||||
u8 byte;
|
u8 byte;
|
||||||
struct immsb bit;
|
struct immsb bit;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ospf_dbdes_packet {
|
struct ospf_dbdes_packet
|
||||||
|
{
|
||||||
struct ospf_packet ospf_packet;
|
struct ospf_packet ospf_packet;
|
||||||
u16 iface_mtu;
|
u16 iface_mtu;
|
||||||
u8 options;
|
u8 options;
|
||||||
@ -209,7 +219,8 @@ struct ospf_dbdes_packet {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct ospf_lsa_header {
|
struct ospf_lsa_header
|
||||||
|
{
|
||||||
u16 age; /* LS Age */
|
u16 age; /* LS Age */
|
||||||
#define LSA_MAXAGE 3600 /* 1 hour */
|
#define LSA_MAXAGE 3600 /* 1 hour */
|
||||||
#define LSA_CHECKAGE 300 /* 5 minutes */
|
#define LSA_CHECKAGE 300 /* 5 minutes */
|
||||||
@ -230,19 +241,22 @@ struct ospf_lsa_header {
|
|||||||
u16 length;
|
u16 length;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct vebb {
|
struct vebb
|
||||||
|
{
|
||||||
u8 b:1;
|
u8 b:1;
|
||||||
u8 e:1;
|
u8 e:1;
|
||||||
u8 v:1;
|
u8 v:1;
|
||||||
u8 padding:5;
|
u8 padding:5;
|
||||||
};
|
};
|
||||||
|
|
||||||
union veb {
|
union veb
|
||||||
|
{
|
||||||
u8 byte;
|
u8 byte;
|
||||||
struct vebb bit;
|
struct vebb bit;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ospf_lsa_rt {
|
struct ospf_lsa_rt
|
||||||
|
{
|
||||||
union veb veb;
|
union veb veb;
|
||||||
#define LSA_RT_V 5
|
#define LSA_RT_V 5
|
||||||
#define LSA_RT_E 6
|
#define LSA_RT_E 6
|
||||||
@ -251,7 +265,8 @@ struct ospf_lsa_rt {
|
|||||||
u16 links;
|
u16 links;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ospf_lsa_rt_link {
|
struct ospf_lsa_rt_link
|
||||||
|
{
|
||||||
u32 id;
|
u32 id;
|
||||||
u32 data;
|
u32 data;
|
||||||
u8 type;
|
u8 type;
|
||||||
@ -263,31 +278,37 @@ struct ospf_lsa_rt_link {
|
|||||||
u16 metric;
|
u16 metric;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ospf_lsa_rt_link_tos { /* Actually we ignore TOS. This is useless */
|
struct ospf_lsa_rt_link_tos
|
||||||
|
{ /* Actually we ignore TOS. This is useless */
|
||||||
u8 tos;
|
u8 tos;
|
||||||
u8 padding;
|
u8 padding;
|
||||||
u16 metric;
|
u16 metric;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ospf_lsa_net {
|
struct ospf_lsa_net
|
||||||
|
{
|
||||||
ip_addr netmask;
|
ip_addr netmask;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ospf_lsa_summ {
|
struct ospf_lsa_summ
|
||||||
|
{
|
||||||
ip_addr netmask;
|
ip_addr netmask;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ospf_lsa_summ_net {
|
struct ospf_lsa_summ_net
|
||||||
|
{
|
||||||
u8 tos;
|
u8 tos;
|
||||||
u8 padding;
|
u8 padding;
|
||||||
u16 metric;
|
u16 metric;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ospf_lsa_ext {
|
struct ospf_lsa_ext
|
||||||
|
{
|
||||||
ip_addr netmask;
|
ip_addr netmask;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ospf_lsa_ext_tos {
|
struct ospf_lsa_ext_tos
|
||||||
|
{
|
||||||
u8 etos;
|
u8 etos;
|
||||||
u8 padding;
|
u8 padding;
|
||||||
u16 metric;
|
u16 metric;
|
||||||
@ -295,11 +316,13 @@ struct ospf_lsa_ext_tos {
|
|||||||
u32 tag;
|
u32 tag;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ospf_lsreq_packet {
|
struct ospf_lsreq_packet
|
||||||
|
{
|
||||||
struct ospf_packet ospf_packet;
|
struct ospf_packet ospf_packet;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ospf_lsreq_header {
|
struct ospf_lsreq_header
|
||||||
|
{
|
||||||
u16 padd1;
|
u16 padd1;
|
||||||
u8 padd2;
|
u8 padd2;
|
||||||
u8 type;
|
u8 type;
|
||||||
@ -307,17 +330,20 @@ struct ospf_lsreq_header {
|
|||||||
u32 rt; /* Advertising router */
|
u32 rt; /* Advertising router */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct l_lsr_head {
|
struct l_lsr_head
|
||||||
|
{
|
||||||
node n;
|
node n;
|
||||||
struct ospf_lsreq_header lsh;
|
struct ospf_lsreq_header lsh;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ospf_lsupd_packet {
|
struct ospf_lsupd_packet
|
||||||
|
{
|
||||||
struct ospf_packet ospf_packet;
|
struct ospf_packet ospf_packet;
|
||||||
u32 lsano; /* Number of LSA's */
|
u32 lsano; /* Number of LSA's */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ospf_lsack_packet {
|
struct ospf_lsack_packet
|
||||||
|
{
|
||||||
struct ospf_packet ospf_packet;
|
struct ospf_packet ospf_packet;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -387,7 +413,8 @@ struct ospf_neighbor
|
|||||||
#define INM_INACTTIM 11 /* Inactivity timer */
|
#define INM_INACTTIM 11 /* Inactivity timer */
|
||||||
#define INM_LLDOWN 12 /* Line down */
|
#define INM_LLDOWN 12 /* Line down */
|
||||||
|
|
||||||
struct ospf_area {
|
struct ospf_area
|
||||||
|
{
|
||||||
node n;
|
node n;
|
||||||
u32 areaid;
|
u32 areaid;
|
||||||
timer *disp_timer; /* Area's dispatcher hear beat */
|
timer *disp_timer; /* Area's dispatcher hear beat */
|
||||||
@ -405,7 +432,8 @@ struct ospf_area {
|
|||||||
unsigned tick;
|
unsigned tick;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct proto_ospf {
|
struct proto_ospf
|
||||||
|
{
|
||||||
struct proto proto;
|
struct proto proto;
|
||||||
list iface_list; /* Interfaces we really use */
|
list iface_list; /* Interfaces we really use */
|
||||||
list area_list;
|
list area_list;
|
||||||
@ -415,7 +443,8 @@ struct proto_ospf {
|
|||||||
int ebit; /* Did I originate any ext lsa? */
|
int ebit; /* Did I originate any ext lsa? */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ospf_iface_patt {
|
struct ospf_iface_patt
|
||||||
|
{
|
||||||
struct iface_patt i;
|
struct iface_patt i;
|
||||||
int cost;
|
int cost;
|
||||||
int helloint;
|
int helloint;
|
||||||
@ -441,7 +470,8 @@ int ospf_import_control(struct proto *p, rte **new, ea_list **attrs,
|
|||||||
struct linpool *pool);
|
struct linpool *pool);
|
||||||
struct ea_list *ospf_make_tmp_attrs(struct rte *rt, struct linpool *pool);
|
struct ea_list *ospf_make_tmp_attrs(struct rte *rt, struct linpool *pool);
|
||||||
void ospf_store_tmp_attrs(struct rte *rt, struct ea_list *attrs);
|
void ospf_store_tmp_attrs(struct rte *rt, struct ea_list *attrs);
|
||||||
void ospf_rt_notify(struct proto *p, net *n, rte *new, rte *old,ea_list *attrs);
|
void ospf_rt_notify(struct proto *p, net * n, rte * new, rte * old,
|
||||||
|
ea_list * attrs);
|
||||||
void area_disp(timer * timer);
|
void area_disp(timer * timer);
|
||||||
void schedule_rt_lsa(struct ospf_area *oa);
|
void schedule_rt_lsa(struct ospf_area *oa);
|
||||||
void schedule_rtcalc(struct ospf_area *oa);
|
void schedule_rtcalc(struct ospf_area *oa);
|
||||||
|
@ -101,16 +101,14 @@ ospf_rx_hook (sock *sk, int size)
|
|||||||
|
|
||||||
if ((unsigned) size < sizeof(struct ospf_packet))
|
if ((unsigned) size < sizeof(struct ospf_packet))
|
||||||
{
|
{
|
||||||
log ("%s: Bad OSPF packet received: too short (%u bytes)", p->name,
|
log("%s: Bad OSPF packet received: too short (%u bytes)", p->name, size);
|
||||||
size);
|
|
||||||
log("%s: Discarding", p->name);
|
log("%s: Discarding", p->name);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ntohs(ps->length) != size) || (size != (4 * (size / 4))))
|
if ((ntohs(ps->length) != size) || (size != (4 * (size / 4))))
|
||||||
{
|
{
|
||||||
log ("%s: Bad OSPF packet received: size field does not match",
|
log("%s: Bad OSPF packet received: size field does not match", p->name);
|
||||||
p->name);
|
|
||||||
log("%s: Discarding", p->name);
|
log("%s: Discarding", p->name);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
@ -138,24 +136,21 @@ ospf_rx_hook (sock *sk, int size)
|
|||||||
|
|
||||||
if (ntohl(ps->areaid) != ifa->an)
|
if (ntohl(ps->areaid) != ifa->an)
|
||||||
{
|
{
|
||||||
log ("%s: Bad OSPF packet received: other area %ld", p->name,
|
log("%s: Bad OSPF packet received: other area %ld", p->name, ps->areaid);
|
||||||
ps->areaid);
|
|
||||||
log("%s: Discarding", p->name);
|
log("%s: Discarding", p->name);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ntohl(ps->routerid) == p->cf->global->router_id)
|
if (ntohl(ps->routerid) == p->cf->global->router_id)
|
||||||
{
|
{
|
||||||
log ("%s: Bad OSPF packet received: received my own router ID!",
|
log("%s: Bad OSPF packet received: received my own router ID!", p->name);
|
||||||
p->name);
|
|
||||||
log("%s: Discarding", p->name);
|
log("%s: Discarding", p->name);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ntohl(ps->routerid) == 0)
|
if (ntohl(ps->routerid) == 0)
|
||||||
{
|
{
|
||||||
log ("%s: Bad OSPF packet received: Id 0.0.0.0 is not allowed.",
|
log("%s: Bad OSPF packet received: Id 0.0.0.0 is not allowed.", p->name);
|
||||||
p->name);
|
|
||||||
log("%s: Discarding", p->name);
|
log("%s: Discarding", p->name);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
@ -172,8 +167,7 @@ ospf_rx_hook (sock *sk, int size)
|
|||||||
{
|
{
|
||||||
case HELLO_P:
|
case HELLO_P:
|
||||||
DBG("%s: Hello received.\n", p->name);
|
DBG("%s: Hello received.\n", p->name);
|
||||||
ospf_hello_receive((struct ospf_hello_packet *) ps, ifa, size,
|
ospf_hello_receive((struct ospf_hello_packet *) ps, ifa, size, sk->faddr);
|
||||||
sk->faddr);
|
|
||||||
break;
|
break;
|
||||||
case DBDES_P:
|
case DBDES_P:
|
||||||
DBG("%s: Database description received.\n", p->name);
|
DBG("%s: Database description received.\n", p->name);
|
||||||
|
111
proto/ospf/rt.c
111
proto/ospf/rt.c
@ -60,7 +60,8 @@ ospf_rt_spfa(struct ospf_area *oa)
|
|||||||
OSPF_TRACE(D_EVENTS, "Starting routing table calculation for area %I",
|
OSPF_TRACE(D_EVENTS, "Starting routing table calculation for area %I",
|
||||||
oa->areaid);
|
oa->areaid);
|
||||||
|
|
||||||
if(oa->rt==NULL) return;
|
if (oa->rt == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
FIB_WALK(in, nftmp)
|
FIB_WALK(in, nftmp)
|
||||||
{
|
{
|
||||||
@ -99,7 +100,8 @@ ospf_rt_spfa(struct ospf_area *oa)
|
|||||||
{
|
{
|
||||||
case LSA_T_RT:
|
case LSA_T_RT:
|
||||||
rt = (struct ospf_lsa_rt *) act->lsa_body;
|
rt = (struct ospf_lsa_rt *) act->lsa_body;
|
||||||
if(rt->veb.bit.v) oa->trcap=1;
|
if (rt->veb.bit.v)
|
||||||
|
oa->trcap = 1;
|
||||||
rr = (struct ospf_lsa_rt_link *) (rt + 1);
|
rr = (struct ospf_lsa_rt_link *) (rt + 1);
|
||||||
DBG(" Number of links: %u\n", rt->links);
|
DBG(" Number of links: %u\n", rt->links);
|
||||||
for (i = 0; i < rt->links; i++)
|
for (i = 0; i < rt->links; i++)
|
||||||
@ -117,14 +119,17 @@ ospf_rt_spfa(struct ospf_area *oa)
|
|||||||
if (nf->metric > (met = act->dist + rtl->metric))
|
if (nf->metric > (met = act->dist + rtl->metric))
|
||||||
{
|
{
|
||||||
DBG(" Adding stub route....\n");
|
DBG(" Adding stub route....\n");
|
||||||
if(oa->rt==act) break;
|
if (oa->rt == act)
|
||||||
if(act->nhi==NULL) break;
|
break;
|
||||||
|
if (act->nhi == NULL)
|
||||||
|
break;
|
||||||
nf->metric = met;
|
nf->metric = met;
|
||||||
nf->en = act;
|
nf->en = act;
|
||||||
DBG(" Adding stub route: %I\n", ip);
|
DBG(" Adding stub route: %I\n", ip);
|
||||||
DBG(" Next hop=%I\n", nf->en->nh);
|
DBG(" Next hop=%I\n", nf->en->nh);
|
||||||
}
|
}
|
||||||
else DBG(" NOT adding stub route: %I\n",ip);
|
else
|
||||||
|
DBG(" NOT adding stub route: %I\n", ip);
|
||||||
break;
|
break;
|
||||||
case LSART_VLNK:
|
case LSART_VLNK:
|
||||||
DBG("Ignoring\n");
|
DBG("Ignoring\n");
|
||||||
@ -132,8 +137,10 @@ ospf_rt_spfa(struct ospf_area *oa)
|
|||||||
break;
|
break;
|
||||||
case LSART_NET:
|
case LSART_NET:
|
||||||
tmp = ospf_hash_find(oa->gr, rtl->id, rtl->id, LSA_T_NET);
|
tmp = ospf_hash_find(oa->gr, rtl->id, rtl->id, LSA_T_NET);
|
||||||
if(tmp==NULL) DBG("Not found!\n");
|
if (tmp == NULL)
|
||||||
else DBG("Found. :-)\n");
|
DBG("Not found!\n");
|
||||||
|
else
|
||||||
|
DBG("Found. :-)\n");
|
||||||
break;
|
break;
|
||||||
case LSART_PTP:
|
case LSART_PTP:
|
||||||
tmp = ospf_hash_find(oa->gr, rtl->id, rtl->id, LSA_T_RT);
|
tmp = ospf_hash_find(oa->gr, rtl->id, rtl->id, LSA_T_RT);
|
||||||
@ -143,7 +150,8 @@ ospf_rt_spfa(struct ospf_area *oa)
|
|||||||
log("Unknown link type in router lsa.");
|
log("Unknown link type in router lsa.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(tmp) DBG("Going to add cand, Mydist: %u, Req: %u\n",
|
if (tmp)
|
||||||
|
DBG("Going to add cand, Mydist: %u, Req: %u\n",
|
||||||
tmp->dist, act->dist + rtl->metric);
|
tmp->dist, act->dist + rtl->metric);
|
||||||
add_cand(&oa->cand, tmp, act, act->dist + rtl->metric, oa);
|
add_cand(&oa->cand, tmp, act, act->dist + rtl->metric, oa);
|
||||||
}
|
}
|
||||||
@ -164,8 +172,10 @@ ospf_rt_spfa(struct ospf_area *oa)
|
|||||||
{
|
{
|
||||||
DBG(" Working on router %I ", *(rts + i));
|
DBG(" Working on router %I ", *(rts + i));
|
||||||
tmp = ospf_hash_find(oa->gr, *(rts + i), *(rts + i), LSA_T_RT);
|
tmp = ospf_hash_find(oa->gr, *(rts + i), *(rts + i), LSA_T_RT);
|
||||||
if(tmp!=NULL) DBG("Found :-)\n");
|
if (tmp != NULL)
|
||||||
else DBG("Not found!\n");
|
DBG("Found :-)\n");
|
||||||
|
else
|
||||||
|
DBG("Not found!\n");
|
||||||
add_cand(&oa->cand, tmp, act, act->dist, oa);
|
add_cand(&oa->cand, tmp, act, act->dist, oa);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -228,8 +238,10 @@ again:
|
|||||||
a0.source = RTS_OSPF;
|
a0.source = RTS_OSPF;
|
||||||
a0.scope = SCOPE_UNIVERSE;
|
a0.scope = SCOPE_UNIVERSE;
|
||||||
a0.cast = RTC_UNICAST;
|
a0.cast = RTC_UNICAST;
|
||||||
if(ipa_to_u32(en->nh)==0) a0.dest=RTD_DEVICE;
|
if (ipa_to_u32(en->nh) == 0)
|
||||||
else a0.dest=RTD_ROUTER;
|
a0.dest = RTD_DEVICE;
|
||||||
|
else
|
||||||
|
a0.dest = RTD_ROUTER;
|
||||||
a0.flags = 0;
|
a0.flags = 0;
|
||||||
a0.aflags = 0;
|
a0.aflags = 0;
|
||||||
a0.iface = en->nhi;
|
a0.iface = en->nhi;
|
||||||
@ -297,16 +309,21 @@ ospf_ext_spfa(struct proto_ospf *po) /* FIXME looking into inter-area */
|
|||||||
|
|
||||||
WALK_LIST(oa, po->area_list)
|
WALK_LIST(oa, po->area_list)
|
||||||
{
|
{
|
||||||
if(!oa->stub) break;
|
if (!oa->stub)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(oa==NULL) return;
|
if (oa == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
WALK_SLIST(en, oa->lsal)
|
WALK_SLIST(en, oa->lsal)
|
||||||
{
|
{
|
||||||
if(en->lsa.type!=LSA_T_EXT) continue;
|
if (en->lsa.type != LSA_T_EXT)
|
||||||
if(en->lsa.age==LSA_MAXAGE) continue;
|
continue;
|
||||||
if(en->lsa.rt==p->cf->global->router_id) continue;
|
if (en->lsa.age == LSA_MAXAGE)
|
||||||
|
continue;
|
||||||
|
if (en->lsa.rt == p->cf->global->router_id)
|
||||||
|
continue;
|
||||||
|
|
||||||
le = en->lsa_body;
|
le = en->lsa_body;
|
||||||
lt = (struct ospf_lsa_ext_tos *) (le + 1);
|
lt = (struct ospf_lsa_ext_tos *) (le + 1);
|
||||||
@ -314,7 +331,8 @@ ospf_ext_spfa(struct proto_ospf *po) /* FIXME looking into inter-area */
|
|||||||
DBG("%s: Working on LSA. ID: %I, RT: %I, Type: %u, Mask %I\n",
|
DBG("%s: Working on LSA. ID: %I, RT: %I, Type: %u, Mask %I\n",
|
||||||
p->name, en->lsa.id, en->lsa.rt, en->lsa.type, le->netmask);
|
p->name, en->lsa.id, en->lsa.rt, en->lsa.type, le->netmask);
|
||||||
|
|
||||||
if(lt->metric==LSINFINITY) continue;
|
if (lt->metric == LSINFINITY)
|
||||||
|
continue;
|
||||||
ip = ipa_and(ipa_from_u32(en->lsa.id), le->netmask);
|
ip = ipa_and(ipa_from_u32(en->lsa.id), le->netmask);
|
||||||
mlen = ipa_mklen(le->netmask);
|
mlen = ipa_mklen(le->netmask);
|
||||||
if ((mlen < 0) || (mlen > 32))
|
if ((mlen < 0) || (mlen > 32))
|
||||||
@ -328,24 +346,30 @@ ospf_ext_spfa(struct proto_ospf *po) /* FIXME looking into inter-area */
|
|||||||
|
|
||||||
WALK_LIST(atmp, po->area_list)
|
WALK_LIST(atmp, po->area_list)
|
||||||
{
|
{
|
||||||
if((nf=fib_find(&atmp->infib,&ip, mlen))!=NULL) break;
|
if ((nf = fib_find(&atmp->infib, &ip, mlen)) != NULL)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(nf!=NULL) continue; /* Some intra area path exists */
|
if (nf != NULL)
|
||||||
|
continue; /* Some intra area path exists */
|
||||||
|
|
||||||
absr = NULL;
|
absr = NULL;
|
||||||
absroa = NULL;
|
absroa = NULL;
|
||||||
nnhi = NULL;
|
nnhi = NULL;
|
||||||
nnh = IPA_NONE;
|
nnh = IPA_NONE;
|
||||||
|
|
||||||
met=0;met2=0;tag=0;
|
met = 0;
|
||||||
|
met2 = 0;
|
||||||
|
tag = 0;
|
||||||
|
|
||||||
WALK_LIST(atmp, po->area_list) /*
|
WALK_LIST(atmp, po->area_list) /*
|
||||||
* Find shortest path
|
* Find shortest path
|
||||||
* to advertising router
|
* to advertising router
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
if((etmp=ospf_hash_find(atmp->gr,en->lsa.rt,en->lsa.rt,LSA_T_RT))!=NULL)
|
if ((etmp =
|
||||||
|
ospf_hash_find(atmp->gr, en->lsa.rt, en->lsa.rt,
|
||||||
|
LSA_T_RT)) != NULL)
|
||||||
{
|
{
|
||||||
if ((absr == NULL) || (absr->dist > etmp->dist) ||
|
if ((absr == NULL) || (absr->dist > etmp->dist) ||
|
||||||
((etmp->dist == absr->dist) && (absroa->areaid < atmp->areaid)))
|
((etmp->dist == absr->dist) && (absroa->areaid < atmp->areaid)))
|
||||||
@ -536,24 +560,30 @@ add_cand(list *l, struct top_hash_entry *en, struct top_hash_entry *par,
|
|||||||
int added = 0;
|
int added = 0;
|
||||||
struct top_hash_entry *act;
|
struct top_hash_entry *act;
|
||||||
|
|
||||||
if(en==NULL) return;
|
if (en == NULL)
|
||||||
if(en->lsa.age==LSA_MAXAGE) return;
|
return;
|
||||||
|
if (en->lsa.age == LSA_MAXAGE)
|
||||||
|
return;
|
||||||
/* FIXME Does it have link back? Test it! */
|
/* FIXME Does it have link back? Test it! */
|
||||||
if(en->color==INSPF) return;
|
if (en->color == INSPF)
|
||||||
|
return;
|
||||||
|
|
||||||
if(dist>=en->dist) return;
|
if (dist >= en->dist)
|
||||||
|
return;
|
||||||
/*
|
/*
|
||||||
* FIXME The line above is not a bug, but we don't support
|
* FIXME The line above is not a bug, but we don't support
|
||||||
* multiple next hops. I'll start as soon as nest will
|
* multiple next hops. I'll start as soon as nest will
|
||||||
*/
|
*/
|
||||||
DBG(" Adding candidate: rt: %I, id: %I, type: %u\n",en->lsa.rt,en->lsa.id,en->lsa.type);
|
DBG(" Adding candidate: rt: %I, id: %I, type: %u\n", en->lsa.rt,
|
||||||
|
en->lsa.id, en->lsa.type);
|
||||||
|
|
||||||
en->nhi = NULL;
|
en->nhi = NULL;
|
||||||
en->nh = IPA_NONE;
|
en->nh = IPA_NONE;
|
||||||
|
|
||||||
calc_next_hop(en, par, oa);
|
calc_next_hop(en, par, oa);
|
||||||
|
|
||||||
if(!en->nhi) return; /* We cannot find next hop, ignore it */
|
if (!en->nhi)
|
||||||
|
return; /* We cannot find next hop, ignore it */
|
||||||
|
|
||||||
if (en->color == CANDIDATE) /* We found a shorter path */
|
if (en->color == CANDIDATE) /* We found a shorter path */
|
||||||
{
|
{
|
||||||
@ -577,8 +607,10 @@ add_cand(list *l, struct top_hash_entry *en, struct top_hash_entry *par,
|
|||||||
if ((act->dist > dist) ||
|
if ((act->dist > dist) ||
|
||||||
((act->dist == dist) && (act->lsa.type == LSA_T_NET)))
|
((act->dist == dist) && (act->lsa.type == LSA_T_NET)))
|
||||||
{
|
{
|
||||||
if(prev==NULL) add_head(l,&en->cn);
|
if (prev == NULL)
|
||||||
else insert_node(&en->cn,prev);
|
add_head(l, &en->cn);
|
||||||
|
else
|
||||||
|
insert_node(&en->cn, prev);
|
||||||
added = 1;
|
added = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -617,7 +649,8 @@ calc_next_hop(struct top_hash_entry *en, struct top_hash_entry *par,
|
|||||||
if (en->lsa.rt == myrid)
|
if (en->lsa.rt == myrid)
|
||||||
{
|
{
|
||||||
WALK_LIST(ifa, po->iface_list)
|
WALK_LIST(ifa, po->iface_list)
|
||||||
if(ipa_compare(ifa->iface->addr->ip,ipa_from_u32(en->lsa.id))==0)
|
if (ipa_compare(ifa->iface->addr->ip, ipa_from_u32(en->lsa.id)) ==
|
||||||
|
0)
|
||||||
{
|
{
|
||||||
en->nhi = ifa->iface;
|
en->nhi = ifa->iface;
|
||||||
return;
|
return;
|
||||||
@ -630,13 +663,15 @@ calc_next_hop(struct top_hash_entry *en, struct top_hash_entry *par,
|
|||||||
{
|
{
|
||||||
ip_addr ip = ipa_from_u32(en->lsa.id);
|
ip_addr ip = ipa_from_u32(en->lsa.id);
|
||||||
nn = neigh_find(p, &ip, 0);
|
nn = neigh_find(p, &ip, 0);
|
||||||
if(nn) en->nhi=nn->iface;
|
if (nn)
|
||||||
|
en->nhi = nn->iface;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if((neigh=find_neigh_noifa(po,en->lsa.rt))==NULL) return;
|
if ((neigh = find_neigh_noifa(po, en->lsa.rt)) == NULL)
|
||||||
|
return;
|
||||||
en->nhi = neigh->ifa->iface;
|
en->nhi = neigh->ifa->iface;
|
||||||
en->nh = neigh->ip; /* Yes, neighbor is it's own next hop */
|
en->nh = neigh->ip; /* Yes, neighbor is it's own next hop */
|
||||||
return;
|
return;
|
||||||
@ -645,17 +680,20 @@ calc_next_hop(struct top_hash_entry *en, struct top_hash_entry *par,
|
|||||||
|
|
||||||
if (par->lsa.type == LSA_T_NET)
|
if (par->lsa.type == LSA_T_NET)
|
||||||
{
|
{
|
||||||
if(en->lsa.type==LSA_T_NET) bug("Parent for net is net?");
|
if (en->lsa.type == LSA_T_NET)
|
||||||
|
bug("Parent for net is net?");
|
||||||
if ((en->nhi = par->nhi) == NULL)
|
if ((en->nhi = par->nhi) == NULL)
|
||||||
bug("Did not find next hop interface for INSPF lsa!");
|
bug("Did not find next hop interface for INSPF lsa!");
|
||||||
if((neigh=find_neigh_noifa(po,en->lsa.rt))==NULL) return;
|
if ((neigh = find_neigh_noifa(po, en->lsa.rt)) == NULL)
|
||||||
|
return;
|
||||||
en->nhi = neigh->ifa->iface;
|
en->nhi = neigh->ifa->iface;
|
||||||
en->nh = neigh->ip; /* Yes, neighbor is it's own next hop */
|
en->nh = neigh->ip; /* Yes, neighbor is it's own next hop */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else /* Parent is some RT neighbor */
|
else /* Parent is some RT neighbor */
|
||||||
{
|
{
|
||||||
log(L_ERR "Router's parent has no next hop. (EN=%I, PAR=%I)", en->lsa.id, par->lsa.id);
|
log(L_ERR "Router's parent has no next hop. (EN=%I, PAR=%I)",
|
||||||
|
en->lsa.id, par->lsa.id);
|
||||||
/* I hoped this would never happen */
|
/* I hoped this would never happen */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -664,4 +702,3 @@ calc_next_hop(struct top_hash_entry *en, struct top_hash_entry *par,
|
|||||||
en->nhi = par->nhi;
|
en->nhi = par->nhi;
|
||||||
DBG(" Next hop calculated: %I.\n", en->nh);
|
DBG(" Next hop calculated: %I.\n", en->nh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,8 @@
|
|||||||
#ifndef _BIRD_OSPF_RT_H_
|
#ifndef _BIRD_OSPF_RT_H_
|
||||||
#define _BIRD_OSPF_RT_H_
|
#define _BIRD_OSPF_RT_H_
|
||||||
|
|
||||||
struct infib {
|
struct infib
|
||||||
|
{
|
||||||
struct fib_node fn;
|
struct fib_node fn;
|
||||||
u16 metric;
|
u16 metric;
|
||||||
u16 oldmetric;
|
u16 oldmetric;
|
||||||
@ -18,7 +19,8 @@ struct infib {
|
|||||||
struct top_hash_entry *olden;
|
struct top_hash_entry *olden;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct extfib {
|
struct extfib
|
||||||
|
{
|
||||||
struct fib_node fn;
|
struct fib_node fn;
|
||||||
u16 metric;
|
u16 metric;
|
||||||
u16 metric2;
|
u16 metric2;
|
||||||
|
Loading…
Reference in New Issue
Block a user