Sync with nest's rt table and some minor improvements.
This commit is contained in:
parent
e80e9d0da5
commit
c6c5626436
9 changed files with 84 additions and 24 deletions
|
@ -87,7 +87,7 @@ htonlsab(void *h, void *n, u8 type, u16 len)
|
||||||
hs=h;
|
hs=h;
|
||||||
ns=n;
|
ns=n;
|
||||||
|
|
||||||
ns->netmask=htonl(hs->netmask);
|
ns->netmask=ipa_hton(hs->netmask);
|
||||||
|
|
||||||
hn=(struct ospf_lsa_summ_net *)(hs+1);
|
hn=(struct ospf_lsa_summ_net *)(hs+1);
|
||||||
nn=(struct ospf_lsa_summ_net *)(ns+1);
|
nn=(struct ospf_lsa_summ_net *)(ns+1);
|
||||||
|
@ -109,7 +109,7 @@ htonlsab(void *h, void *n, u8 type, u16 len)
|
||||||
he=h;
|
he=h;
|
||||||
ne=n;
|
ne=n;
|
||||||
|
|
||||||
ne->netmask=htonl(he->netmask);
|
ne->netmask=ipa_hton(he->netmask);
|
||||||
|
|
||||||
ht=(struct ospf_lsa_ext_tos *)(he+1);
|
ht=(struct ospf_lsa_ext_tos *)(he+1);
|
||||||
nt=(struct ospf_lsa_ext_tos *)(ne+1);
|
nt=(struct ospf_lsa_ext_tos *)(ne+1);
|
||||||
|
@ -181,7 +181,7 @@ ntohlsab(void *n, void *h, u8 type, u16 len)
|
||||||
hs=h;
|
hs=h;
|
||||||
ns=n;
|
ns=n;
|
||||||
|
|
||||||
hs->netmask=ntohl(ns->netmask);
|
hs->netmask=ipa_ntoh(ns->netmask);
|
||||||
|
|
||||||
hn=(struct ospf_lsa_summ_net *)(hs+1);
|
hn=(struct ospf_lsa_summ_net *)(hs+1);
|
||||||
nn=(struct ospf_lsa_summ_net *)(ns+1);
|
nn=(struct ospf_lsa_summ_net *)(ns+1);
|
||||||
|
@ -203,7 +203,7 @@ ntohlsab(void *n, void *h, u8 type, u16 len)
|
||||||
he=h;
|
he=h;
|
||||||
ne=n;
|
ne=n;
|
||||||
|
|
||||||
he->netmask=ntohl(ne->netmask);
|
he->netmask=ipa_ntoh(ne->netmask);
|
||||||
|
|
||||||
ht=(struct ospf_lsa_ext_tos *)(he+1);
|
ht=(struct ospf_lsa_ext_tos *)(he+1);
|
||||||
nt=(struct ospf_lsa_ext_tos *)(ne+1);
|
nt=(struct ospf_lsa_ext_tos *)(ne+1);
|
||||||
|
|
|
@ -368,6 +368,18 @@ find_neigh(struct ospf_iface *ifa, u32 rid)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct ospf_neighbor *
|
||||||
|
find_neigh_noifa(struct proto_ospf *po, u32 rid)
|
||||||
|
{
|
||||||
|
struct ospf_neighbor *n;
|
||||||
|
struct ospf_iface *ifa;
|
||||||
|
|
||||||
|
WALK_LIST (ifa, po->iface_list)
|
||||||
|
if((n=find_neigh(ifa, rid))!=NULL)
|
||||||
|
return n;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
struct ospf_area *
|
struct ospf_area *
|
||||||
ospf_find_area(struct proto_ospf *po, u32 aid)
|
ospf_find_area(struct proto_ospf *po, u32 aid)
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,6 +18,7 @@ void tryadj(struct ospf_neighbor *n, struct proto *p);
|
||||||
void ospf_neigh_sm(struct ospf_neighbor *n, int event);
|
void ospf_neigh_sm(struct ospf_neighbor *n, int event);
|
||||||
void bdr_election(struct ospf_iface *ifa, struct proto *p);
|
void bdr_election(struct ospf_iface *ifa, struct proto *p);
|
||||||
struct ospf_neighbor *find_neigh(struct ospf_iface *ifa, u32 rid);
|
struct ospf_neighbor *find_neigh(struct ospf_iface *ifa, u32 rid);
|
||||||
|
struct ospf_neighbor *find_neigh_noifa(struct proto_ospf *po, u32 rid);
|
||||||
struct ospf_area *ospf_find_area(struct proto_ospf *po, u32 aid);
|
struct ospf_area *ospf_find_area(struct proto_ospf *po, u32 aid);
|
||||||
|
|
||||||
#endif /* _BIRD_OSPF_NEIGHBOR_H_ */
|
#endif /* _BIRD_OSPF_NEIGHBOR_H_ */
|
||||||
|
|
|
@ -50,6 +50,7 @@ ospf_dump(struct proto *p)
|
||||||
debug("%s: LSA graph dump for area \"%I\" finished\n\n", p->name,
|
debug("%s: LSA graph dump for area \"%I\" finished\n\n", p->name,
|
||||||
oa->areaid);
|
oa->areaid);
|
||||||
}
|
}
|
||||||
|
neigh_dump_all();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#define OSPF_VERSION 2
|
#define OSPF_VERSION 2
|
||||||
#define AllSPFRouters ipa_from_u32(0xe0000005) /* 224.0.0.5 */
|
#define AllSPFRouters ipa_from_u32(0xe0000005) /* 224.0.0.5 */
|
||||||
#define AllDRouters ipa_from_u32(0xe0000006) /* 224.0.0.6 */
|
#define AllDRouters ipa_from_u32(0xe0000006) /* 224.0.0.6 */
|
||||||
|
#define DEFAULTDES ipa_from_u32(0)
|
||||||
#else
|
#else
|
||||||
#error Multicast address not defined in IPv6
|
#error Multicast address not defined in IPv6
|
||||||
#endif
|
#endif
|
||||||
|
@ -40,8 +41,7 @@
|
||||||
#define LSREFRESHTIME 1800 /* 30 minutes */
|
#define LSREFRESHTIME 1800 /* 30 minutes */
|
||||||
#define MINLSINTERVAL 5
|
#define MINLSINTERVAL 5
|
||||||
#define MINLSARRIVAL 1
|
#define MINLSARRIVAL 1
|
||||||
#define LSINFINITY 0xffffff
|
#define LSINFINITY 0xffff /* RFC says 0xffffff ??? */
|
||||||
/*#define DEFAULTDES 0.0.0.0 FIXME: How to define it? */
|
|
||||||
|
|
||||||
struct ospf_config {
|
struct ospf_config {
|
||||||
struct proto_config c;
|
struct proto_config c;
|
||||||
|
@ -203,11 +203,11 @@ struct ospf_lsa_rt_link_tos { /* Actually we ignore TOS. This is useless */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ospf_lsa_net {
|
struct ospf_lsa_net {
|
||||||
u32 netmask;
|
ip_addr netmask;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ospf_lsa_summ {
|
struct ospf_lsa_summ {
|
||||||
u32 netmask;
|
ip_addr netmask;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ospf_lsa_summ_net {
|
struct ospf_lsa_summ_net {
|
||||||
|
@ -217,7 +217,7 @@ struct ospf_lsa_summ_net {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ospf_lsa_ext {
|
struct ospf_lsa_ext {
|
||||||
u32 netmask;
|
ip_addr netmask;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ospf_lsa_ext_tos {
|
struct ospf_lsa_ext_tos {
|
||||||
|
|
|
@ -40,7 +40,7 @@ ospf_rt_spfa(struct ospf_area *oa, struct proto *p)
|
||||||
{
|
{
|
||||||
struct top_hash_entry *act,*tmp;
|
struct top_hash_entry *act,*tmp;
|
||||||
node *n;
|
node *n;
|
||||||
struct ospf_lsa_net *net;
|
struct ospf_lsa_net *netw;
|
||||||
|
|
||||||
n=HEAD(oa->cand);
|
n=HEAD(oa->cand);
|
||||||
act=SKIP_BACK(struct top_hash_entry, cn, n);
|
act=SKIP_BACK(struct top_hash_entry, cn, n);
|
||||||
|
@ -72,21 +72,53 @@ ospf_rt_spfa(struct ospf_area *oa, struct proto *p)
|
||||||
log("Unknown link type in router lsa.\n");
|
log("Unknown link type in router lsa.\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
add_cand(&oa->cand,tmp,act,act->dist+rtl->metric);
|
add_cand(&oa->cand,tmp,act,act->dist+rtl->metric,p);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LSA_T_NET:
|
case LSA_T_NET:
|
||||||
net=(struct ospf_lsa_net *)act->lsa_body;
|
netw=(struct ospf_lsa_net *)act->lsa_body;
|
||||||
rts=(u32 *)(net+1);
|
rts=(u32 *)(netw+1);
|
||||||
for(i=0;i<(act->lsa.length-sizeof(struct ospf_lsa_header)-
|
for(i=0;i<(act->lsa.length-sizeof(struct ospf_lsa_header)-
|
||||||
sizeof(struct ospf_lsa_net))/sizeof(u32);i++)
|
sizeof(struct ospf_lsa_net))/sizeof(u32);i++)
|
||||||
{
|
{
|
||||||
tmp=ospf_hash_find(oa->gr, *rts, *rts, LSA_T_RT);
|
tmp=ospf_hash_find(oa->gr, *rts, *rts, LSA_T_RT);
|
||||||
add_cand(&oa->cand,tmp,act,act->dist);
|
add_cand(&oa->cand,tmp,act,act->dist,p);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* FIXME Now modify rt for this entry */
|
/* FIXME Now modify rt for this entry */
|
||||||
|
if((act->lsa.type==LSA_T_NET)&&(act->nhi!=NULL))
|
||||||
|
{
|
||||||
|
net *ne;
|
||||||
|
rte *e;
|
||||||
|
ip_addr ip;
|
||||||
|
struct ospf_lsa_net *ln=en->lsa_body;
|
||||||
|
|
||||||
|
a0.proto=p;
|
||||||
|
a0.source=RTS_OSPF;
|
||||||
|
a0.scope=SCOPE_UNIVERSE; /* What's this good for? */
|
||||||
|
a0.cast=RTC_UNICAST;
|
||||||
|
a0.dest=RTD_ROUTER; /* FIXME */
|
||||||
|
a0.flags=0;
|
||||||
|
a0.iface=act->nhi;
|
||||||
|
a0.gw=act->nh;
|
||||||
|
ip=ipa_from_u32(act->lsa.id);
|
||||||
|
|
||||||
|
|
||||||
|
ne=net_get(p->table, ip, ipa_mklen(ln->netmask));
|
||||||
|
e=rte_get_temp(&a0);
|
||||||
|
e->u.ospf.metric1=en->dist;
|
||||||
|
e->u.ospf.metric2=0;
|
||||||
|
e->u.ospf.tag=0; /* FIXME Some config? */
|
||||||
|
|
||||||
|
rte_update(p->table, ne, p, e);
|
||||||
|
|
||||||
|
//a0.from=act->lsa.rt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now calculate routes to stub networks */
|
/* Now calculate routes to stub networks */
|
||||||
|
@ -121,7 +153,7 @@ ospf_rt_spfa(struct ospf_area *oa, struct proto *p)
|
||||||
|
|
||||||
void
|
void
|
||||||
add_cand(list *l, struct top_hash_entry *en, struct top_hash_entry *par,
|
add_cand(list *l, struct top_hash_entry *en, struct top_hash_entry *par,
|
||||||
u16 dist)
|
u16 dist, struct proto *p)
|
||||||
{
|
{
|
||||||
node *prev,*n;
|
node *prev,*n;
|
||||||
int flag=0;
|
int flag=0;
|
||||||
|
@ -138,7 +170,9 @@ add_cand(list *l, struct top_hash_entry *en, struct top_hash_entry *par,
|
||||||
* multiple next hops. I'll start as soon as nest will
|
* multiple next hops. I'll start as soon as nest will
|
||||||
*/
|
*/
|
||||||
|
|
||||||
en->nh=calc_next_hop(par);
|
en->nhi=NULL;
|
||||||
|
|
||||||
|
calc_next_hop(par,en,p);
|
||||||
|
|
||||||
if(en->color==CANDIDATE) /* We found shorter path */
|
if(en->color==CANDIDATE) /* We found shorter path */
|
||||||
{
|
{
|
||||||
|
@ -166,12 +200,21 @@ add_cand(list *l, struct top_hash_entry *en, struct top_hash_entry *par,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct top_hash_entry *
|
void
|
||||||
calc_next_hop(struct top_hash_entry *par)
|
calc_next_hop(struct top_hash_entry *par, struct top_hash_entry *en,
|
||||||
|
struct proto *p)
|
||||||
{
|
{
|
||||||
if(par->nh==NULL)
|
struct ospf_neighbor *neigh;
|
||||||
|
struct proto_ospf *po=(struct proto_ospf *)p;
|
||||||
|
if(par->nhi==NULL)
|
||||||
{
|
{
|
||||||
if(par->lsa.type!=LSA_T_RT) return NULL;
|
neighbor *nn;
|
||||||
|
if(par->lsa.type!=LSA_T_RT) return;
|
||||||
|
if((neigh=find_neigh_noifa(po,en->lsa.rt))==NULL) bug("XXX\n");
|
||||||
|
nn=neigh_find(p,&neigh->ip,0);
|
||||||
|
en->nh=nn->addr;
|
||||||
|
en->nhi=nn->iface;
|
||||||
}
|
}
|
||||||
return par;
|
en->nh=par->nh;
|
||||||
|
en->nhi=par->nhi;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,8 @@
|
||||||
|
|
||||||
void ospf_rt_spfa(struct ospf_area *oa, struct proto *p);
|
void ospf_rt_spfa(struct ospf_area *oa, struct proto *p);
|
||||||
void add_cand(list *l, struct top_hash_entry *en, struct top_hash_entry *par,
|
void add_cand(list *l, struct top_hash_entry *en, struct top_hash_entry *par,
|
||||||
u16 dist);
|
u16 dist, struct proto *p);
|
||||||
struct top_hash_entry *calc_next_hop(struct top_hash_entry *par);
|
void calc_next_hop(struct top_hash_entry *par, struct top_hash_entry *en,
|
||||||
|
struct proto *p);
|
||||||
|
|
||||||
#endif /* _BIRD_OSPF_RT_H_ */
|
#endif /* _BIRD_OSPF_RT_H_ */
|
||||||
|
|
|
@ -349,6 +349,7 @@ ospf_hash_get(struct top_graph *f, u32 lsa, u32 rtr, u32 type)
|
||||||
e->lsa.rt = rtr;
|
e->lsa.rt = rtr;
|
||||||
e->lsa.type = type;
|
e->lsa.type = type;
|
||||||
e->lsa_body = NULL;
|
e->lsa_body = NULL;
|
||||||
|
e->nhi=NULL;
|
||||||
e->next=*ee; /* MJ you forgot this :-) */
|
e->next=*ee; /* MJ you forgot this :-) */
|
||||||
*ee=e;
|
*ee=e;
|
||||||
if (f->hash_entries++ > f->hash_entries_max)
|
if (f->hash_entries++ > f->hash_entries_max)
|
||||||
|
|
|
@ -16,7 +16,8 @@ struct top_hash_entry { /* Index for fast mapping (type,rtrid,LSid)->vertex */
|
||||||
struct ospf_lsa_header lsa;
|
struct ospf_lsa_header lsa;
|
||||||
void *lsa_body;
|
void *lsa_body;
|
||||||
bird_clock_t inst_t; /* Time of installation into DB */
|
bird_clock_t inst_t; /* Time of installation into DB */
|
||||||
struct top_hash_entry *nh; /* Next hop */
|
ip_addr nh; /* Next hop */
|
||||||
|
struct iface *nhi;
|
||||||
u16 dist; /* Distance from the root */
|
u16 dist; /* Distance from the root */
|
||||||
u8 color;
|
u8 color;
|
||||||
#define OUTSPF 0
|
#define OUTSPF 0
|
||||||
|
|
Loading…
Reference in a new issue