Sync with nest's rt table and some minor improvements.

This commit is contained in:
Ondrej Filip 2000-04-30 11:31:05 +00:00
parent e80e9d0da5
commit c6c5626436
9 changed files with 84 additions and 24 deletions

View file

@ -87,7 +87,7 @@ htonlsab(void *h, void *n, u8 type, u16 len)
hs=h;
ns=n;
ns->netmask=htonl(hs->netmask);
ns->netmask=ipa_hton(hs->netmask);
hn=(struct ospf_lsa_summ_net *)(hs+1);
nn=(struct ospf_lsa_summ_net *)(ns+1);
@ -109,7 +109,7 @@ htonlsab(void *h, void *n, u8 type, u16 len)
he=h;
ne=n;
ne->netmask=htonl(he->netmask);
ne->netmask=ipa_hton(he->netmask);
ht=(struct ospf_lsa_ext_tos *)(he+1);
nt=(struct ospf_lsa_ext_tos *)(ne+1);
@ -181,7 +181,7 @@ ntohlsab(void *n, void *h, u8 type, u16 len)
hs=h;
ns=n;
hs->netmask=ntohl(ns->netmask);
hs->netmask=ipa_ntoh(ns->netmask);
hn=(struct ospf_lsa_summ_net *)(hs+1);
nn=(struct ospf_lsa_summ_net *)(ns+1);
@ -203,7 +203,7 @@ ntohlsab(void *n, void *h, u8 type, u16 len)
he=h;
ne=n;
he->netmask=ntohl(ne->netmask);
he->netmask=ipa_ntoh(ne->netmask);
ht=(struct ospf_lsa_ext_tos *)(he+1);
nt=(struct ospf_lsa_ext_tos *)(ne+1);

View file

@ -368,6 +368,18 @@ find_neigh(struct ospf_iface *ifa, u32 rid)
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 *
ospf_find_area(struct proto_ospf *po, u32 aid)
{

View file

@ -18,6 +18,7 @@ void tryadj(struct ospf_neighbor *n, struct proto *p);
void ospf_neigh_sm(struct ospf_neighbor *n, int event);
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_noifa(struct proto_ospf *po, u32 rid);
struct ospf_area *ospf_find_area(struct proto_ospf *po, u32 aid);
#endif /* _BIRD_OSPF_NEIGHBOR_H_ */

View file

@ -50,6 +50,7 @@ ospf_dump(struct proto *p)
debug("%s: LSA graph dump for area \"%I\" finished\n\n", p->name,
oa->areaid);
}
neigh_dump_all();
}

View file

@ -32,6 +32,7 @@
#define OSPF_VERSION 2
#define AllSPFRouters ipa_from_u32(0xe0000005) /* 224.0.0.5 */
#define AllDRouters ipa_from_u32(0xe0000006) /* 224.0.0.6 */
#define DEFAULTDES ipa_from_u32(0)
#else
#error Multicast address not defined in IPv6
#endif
@ -40,8 +41,7 @@
#define LSREFRESHTIME 1800 /* 30 minutes */
#define MINLSINTERVAL 5
#define MINLSARRIVAL 1
#define LSINFINITY 0xffffff
/*#define DEFAULTDES 0.0.0.0 FIXME: How to define it? */
#define LSINFINITY 0xffff /* RFC says 0xffffff ??? */
struct ospf_config {
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 {
u32 netmask;
ip_addr netmask;
};
struct ospf_lsa_summ {
u32 netmask;
ip_addr netmask;
};
struct ospf_lsa_summ_net {
@ -217,7 +217,7 @@ struct ospf_lsa_summ_net {
};
struct ospf_lsa_ext {
u32 netmask;
ip_addr netmask;
};
struct ospf_lsa_ext_tos {

View file

@ -40,7 +40,7 @@ ospf_rt_spfa(struct ospf_area *oa, struct proto *p)
{
struct top_hash_entry *act,*tmp;
node *n;
struct ospf_lsa_net *net;
struct ospf_lsa_net *netw;
n=HEAD(oa->cand);
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");
break;
}
add_cand(&oa->cand,tmp,act,act->dist+rtl->metric);
add_cand(&oa->cand,tmp,act,act->dist+rtl->metric,p);
}
break;
case LSA_T_NET:
net=(struct ospf_lsa_net *)act->lsa_body;
rts=(u32 *)(net+1);
netw=(struct ospf_lsa_net *)act->lsa_body;
rts=(u32 *)(netw+1);
for(i=0;i<(act->lsa.length-sizeof(struct ospf_lsa_header)-
sizeof(struct ospf_lsa_net))/sizeof(u32);i++)
{
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;
}
/* 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 */
@ -121,7 +153,7 @@ 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,
u16 dist)
u16 dist, struct proto *p)
{
node *prev,*n;
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
*/
en->nh=calc_next_hop(par);
en->nhi=NULL;
calc_next_hop(par,en,p);
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 *
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)
{
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;
}

View file

@ -12,7 +12,8 @@
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,
u16 dist);
struct top_hash_entry *calc_next_hop(struct top_hash_entry *par);
u16 dist, struct proto *p);
void calc_next_hop(struct top_hash_entry *par, struct top_hash_entry *en,
struct proto *p);
#endif /* _BIRD_OSPF_RT_H_ */

View file

@ -349,6 +349,7 @@ ospf_hash_get(struct top_graph *f, u32 lsa, u32 rtr, u32 type)
e->lsa.rt = rtr;
e->lsa.type = type;
e->lsa_body = NULL;
e->nhi=NULL;
e->next=*ee; /* MJ you forgot this :-) */
*ee=e;
if (f->hash_entries++ > f->hash_entries_max)

View file

@ -16,7 +16,8 @@ struct top_hash_entry { /* Index for fast mapping (type,rtrid,LSid)->vertex */
struct ospf_lsa_header lsa;
void *lsa_body;
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 */
u8 color;
#define OUTSPF 0