0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2025-01-24 18:01:54 +00:00

Temporary OSPF commit.

This commit is contained in:
Ondrej Zajicek 2013-04-16 01:14:57 +02:00
parent 0596b3dbf9
commit 6667d0c4a1
8 changed files with 537 additions and 638 deletions

View File

@ -268,7 +268,7 @@ ospf_dbdes_process(struct ospf_neighbor *n, struct ospf_packet *pkt, unsigned pl
if (ospf_hash_is_new(req)) if (ospf_hash_is_new(req))
s_add_tail(&(n->lsrql), SNODE req); s_add_tail(&(n->lsrql), SNODE req);
en->lsa = lsa; en->lsa = lsa; // XXXX ??? should be req->lsa ?
} }
} }
} }

View File

@ -91,6 +91,7 @@ ospf_lsreq_send(struct ospf_neighbor *n)
ospf_send_to(ifa, n->ip); ospf_send_to(ifa, n->ip);
} }
void void
ospf_lsreq_receive(struct ospf_packet *pkt, struct ospf_iface *ifa, ospf_lsreq_receive(struct ospf_packet *pkt, struct ospf_iface *ifa,
struct ospf_neighbor *n) struct ospf_neighbor *n)
@ -99,11 +100,6 @@ ospf_lsreq_receive(struct ospf_packet *pkt, struct ospf_iface *ifa,
struct ospf_lsreq_header *lsrs; struct ospf_lsreq_header *lsrs;
unsigned i, lsr_count; unsigned i, lsr_count;
struct ospf_lsreq_item *lsr_head, *lsr;
struct ospf_lsreq_item **lsr_pos = &lsr_head;
slab *upslab;
/* No need to check length, lsreq has only basic header */ /* No need to check length, lsreq has only basic header */
OSPF_PACKET(ospf_lsreq_dump, pkt, "LSREQ packet received from %I via %s", OSPF_PACKET(ospf_lsreq_dump, pkt, "LSREQ packet received from %I via %s",
@ -114,9 +110,10 @@ ospf_lsreq_receive(struct ospf_packet *pkt, struct ospf_iface *ifa,
ospf_neigh_sm(n, INM_HELLOREC); /* Not in RFC */ ospf_neigh_sm(n, INM_HELLOREC); /* Not in RFC */
upslab = sl_new(n->pool, sizeof(struct ospf_lsreq_item));
ospf_lsreq_body(po, pkt, ntohs(pkt->length), &lsrs, &lsr_count); ospf_lsreq_body(po, pkt, ntohs(pkt->length), &lsrs, &lsr_count);
struct top_hash_entry *en, *entries[lsr_count];
for (i = 0; i < lsr_count; i++) for (i = 0; i < lsr_count; i++)
{ {
u32 id, rt, type, dom; u32 id, rt, type, dom;
@ -127,26 +124,17 @@ ospf_lsreq_receive(struct ospf_packet *pkt, struct ospf_iface *ifa,
DBG("Processing requested LSA: Type: %04x, Id: %R, Rt: %R\n", type, id, rt); DBG("Processing requested LSA: Type: %04x, Id: %R, Rt: %R\n", type, id, rt);
if (ospf_hash_find(po->gr, dom, id, rt, type) == NULL) en = ospf_hash_find(po->gr, dom, id, rt, type);
if (!en)
{ {
log(L_WARN "Received bad LSREQ from %I: Type: %04x, Id: %R, Rt: %R", log(L_WARN "%s: Received LSREQ from %I for missing LSA (Type: %04x, Id: %R, Rt: %R)",
n->ip, type, id, rt); po->proto.name, n->ip, type, id, rt);
ospf_neigh_sm(n, INM_BADLSREQ); ospf_neigh_sm(n, INM_BADLSREQ);
rfree(upslab);
return; return;
} }
lsr = sl_alloc(upslab); entries[i] = en;
lsr->domain = dom;
lsr->type = type;
lsr->id = id;
lsr->rt = rt;
*lsr_pos = lsr;
lsr_pos = &(lsr->next);
} }
*lsr_pos = NULL;
ospf_lsupd_send_list(n, lsr_head); ospf_lsupd_send(n, entries, lsr_count);
rfree(upslab);
} }

File diff suppressed because it is too large Load Diff

View File

@ -12,14 +12,9 @@
void ospf_dump_lsahdr(struct proto_ospf *po, struct ospf_lsa_header *lsa_n); void ospf_dump_lsahdr(struct proto_ospf *po, struct ospf_lsa_header *lsa_n);
void ospf_dump_common(struct proto_ospf *po, struct ospf_packet *pkt); void ospf_dump_common(struct proto_ospf *po, struct ospf_packet *pkt);
void ospf_lsupd_send_list(struct ospf_neighbor *n, struct ospf_lsreq_item *lsr); void ospf_lsupd_receive(struct ospf_packet *ps_i, struct ospf_iface *ifa, struct ospf_neighbor *n);
void ospf_lsupd_receive(struct ospf_packet *ps_i, int ospf_lsupd_flood(struct proto_ospf *po, struct top_hash_entry *en, struct ospf_neighbor *from);
struct ospf_iface *ifa, struct ospf_neighbor *n); int ospf_lsupd_send(struct ospf_neighbor *n, struct top_hash_entry **lsa_list, unsigned lsa_count);
int ospf_lsupd_flood(struct proto_ospf *po,
struct ospf_neighbor *n, struct ospf_lsa_header *hn,
struct ospf_lsa_header *hh, u32 domain, int rtl);
void ospf_lsupd_flush_nlsa(struct proto_ospf *po, struct top_hash_entry *en);
int ospf_lsa_flooding_allowed(struct ospf_lsa_header *lsa, u32 domain, struct ospf_iface *ifa);
#endif /* _BIRD_OSPF_LSUPD_H_ */ #endif /* _BIRD_OSPF_LSUPD_H_ */

View File

@ -600,51 +600,30 @@ rxmt_timer_hook(timer * timer)
// struct proto *p = &n->ifa->oa->po->proto; // struct proto *p = &n->ifa->oa->po->proto;
struct top_hash_entry *en; struct top_hash_entry *en;
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, n->ifa->iface->name, n->ip); p->name, n->ifa->iface->name, n->ip);
if(n->state < NEIGHBOR_EXSTART) return; switch (n->state)
if (n->state == NEIGHBOR_EXSTART)
{ {
case NEIGHBOR_EXSTART:
ospf_dbdes_send(n, 1); ospf_dbdes_send(n, 1);
return; return;
}
if ((n->state == NEIGHBOR_EXCHANGE) && (n->myimms & DBDES_MS)) /* I'm master */ case NEIGHBOR_EXCHANGE:
if (n->myimms & DBDES_MS)
ospf_dbdes_send(n, 0); ospf_dbdes_send(n, 0);
case NEIGHBOR_LOADING:
ospf_lsreq_send(n);
return;
case NEIGHBOR_FULL:
/* LSA retransmissions */
if (!EMPTY_SLIST(n->lsrtl))
ospf_lsupd_rxmt(n);
return;
if (n->state < NEIGHBOR_FULL) default:
ospf_lsreq_send(n); /* EXCHANGE or LOADING */ return;
else
{
if (!EMPTY_SLIST(n->lsrtl)) /* FULL */
{
struct ospf_lsreq_item *lsr_head, *lsr;
struct ospf_lsreq_item **lsr_pos = &lsr_head;
slab *upslab = sl_new(n->pool, sizeof(struct ospf_lsreq_item));
WALK_SLIST(en, n->lsrtl)
{
if ((SNODE en)->next == (SNODE en))
bug("RTList is cycled");
lsr = sl_alloc(upslab);
lsr->domain = en->domain;
lsr->type = en->lsa_type;
lsr->id = en->lsa.id;
lsr->rt = en->lsa.rt;
*lsr_pos = lsr;
lsr_pos = &(lsr->next);
}
*lsr_pos = NULL;
ospf_lsupd_send_list(n, lsr_head);
rfree(upslab);
}
} }
} }

View File

@ -586,15 +586,6 @@ struct ospf_lsreq_header
u32 rt; u32 rt;
}; };
struct ospf_lsreq_item
{
struct ospf_lsreq_item *next;
u32 domain;
u32 type;
u32 id;
u32 rt;
};
struct ospf_neighbor struct ospf_neighbor
{ {

View File

@ -429,23 +429,23 @@ void
originate_rt_lsa(struct ospf_area *oa) originate_rt_lsa(struct ospf_area *oa)
{ {
struct proto_ospf *po = oa->po; struct proto_ospf *po = oa->po;
struct ospf_lsa_header lsa; struct ospf_lsa_new lsa;
u32 dom = oa->areaid;
void *body;
OSPF_TRACE(D_EVENTS, "Originating router-LSA for area %R", oa->areaid); OSPF_TRACE(D_EVENTS, "Originating router-LSA for area %R", oa->areaid);
lsa.age = 0; lsa.type = LSA_T_RT;
lsa.type_raw = LSA_T_RT; lsa.dom = oa->areaid;
lsa.id = ospf_is_v2(po) ? po->router_id : 0; lsa.id = ospf_is_v2(po) ? po->router_id : 0;
lsa.rt = po->router_id; lsa.opts = oa->options;
lsa.sn = get_seqnum(oa->rt); lsa.body = originate_rt_lsa_body(po, oa, &lsa.length);
lsa_fix_options(po, &lsa, oa->options);
body = originate_rt_lsa_body(po, oa, &lsa.length); ospf_originate_lsa(po, &lsa, &oa->rt);
lsasum_calculate(&lsa, body);
oa->rt = lsa_install_new(po, &lsa, dom, body); // lsa.rt = po->router_id;
ospf_lsupd_flood(po, NULL, NULL, &lsa, dom, 1); // lsa_fix_options(po, &lsa, oa->options);
// lsasum_calculate(&lsa, body);
// ospf_lsupd_flood(po, NULL, NULL, &lsa, dom, 1);
// lsa_install_new(po, &lsa, oa->rt);
} }
void void
@ -559,24 +559,17 @@ void
originate_net_lsa(struct ospf_iface *ifa) originate_net_lsa(struct ospf_iface *ifa)
{ {
struct proto_ospf *po = ifa->oa->po; struct proto_ospf *po = ifa->oa->po;
struct ospf_lsa_header lsa; struct ospf_lsa_new lsa;
u32 dom = ifa->oa->areaid;
void *body;
OSPF_TRACE(D_EVENTS, "Originating network-LSA for iface %s", OSPF_TRACE(D_EVENTS, "Originating network-LSA for iface %s", ifa->iface->name);
ifa->iface->name);
lsa.age = 0; lsa.type = LSA_T_NET;
lsa.type_raw = LSA_T_NET; lsa.dom = ifa->oa->areaid;
lsa.id = ospf_is_v2(po) ? ipa_to_u32(ifa->addr->ip) : ifa->iface_id; lsa.id = ospf_is_v2(po) ? ipa_to_u32(ifa->addr->ip) : ifa->iface_id;
lsa.rt = po->router_id; lsa.opts = ifa->oa->options;
lsa.sn = get_seqnum(ifa->net_lsa); lsa.body = originate_net_lsa_body(po, ifa, &lsa.length);
lsa_fix_options(po, &lsa, ifa->oa->options);
body = originate_net_lsa_body(po, ifa, &lsa.length); ifa->net_lsa = ospf_originate_lsa(po, &lsa, ifa->net_lsa);
lsasum_calculate(&lsa, body);
ifa->net_lsa = lsa_install_new(po, &lsa, dom, body);
ospf_lsupd_flood(po, NULL, NULL, &lsa, dom, 1);
} }
void void
@ -755,89 +748,76 @@ void
originate_sum_net_lsa(struct ospf_area *oa, struct fib_node *fn, int metric) originate_sum_net_lsa(struct ospf_area *oa, struct fib_node *fn, int metric)
{ {
struct proto_ospf *po = oa->po; struct proto_ospf *po = oa->po;
struct ospf_lsa_header lsa; struct ospf_lsa_new lsa;
struct top_hash_entry *en; struct top_hash_entry *en;
u32 dom = oa->areaid;
void *body;
OSPF_TRACE(D_EVENTS, "Originating net-summary-LSA for %I/%d (metric %d)", OSPF_TRACE(D_EVENTS, "Originating net-summary-LSA for %I/%d (metric %d)", fn->prefix, fn->pxlen, metric);
fn->prefix, fn->pxlen, metric);
lsa.age = 0; lsa.type = LSA_T_SUM_NET;
lsa.type_raw = LSA_T_SUM_NET; lsa.dom = oa->areaid;
lsa.id = fibnode_to_lsaid(po, fn); lsa.id = fibnode_to_lsaid(po, fn);
lsa.rt = po->router_id; lsa.opts = oa->options;
lsa_fix_options(po, &lsa, oa->options);
en = ospf_hash_find_header(po->gr, dom, &lsa); en = ospf_hash_find(po->gr, lsa.dom, lsa.id, po->router_id, lsa.type);
if (en && check_sum_net_lsa(po, en, fn, metric)) if (en && check_sum_net_lsa(po, en, fn, metric))
return; return;
lsa.sn = get_seqnum(en);
body = originate_sum_net_lsa_body(po, &lsa.length, fn, metric); lsa.body = originate_sum_net_lsa_body(po, &lsa.length, fn, metric);
lsasum_calculate(&lsa, body);
lsa_install_new(po, &lsa, dom, body); ospf_originate_lsa(po, &lsa, en);
ospf_lsupd_flood(po, NULL, NULL, &lsa, dom, 1);
} }
void void
originate_sum_rt_lsa(struct ospf_area *oa, struct fib_node *fn, int metric, u32 options) originate_sum_rt_lsa(struct ospf_area *oa, struct fib_node *fn, int metric, u32 options)
{ {
struct proto_ospf *po = oa->po; struct proto_ospf *po = oa->po;
struct ospf_lsa_header lsa; struct ospf_lsa_new lsa;
struct top_hash_entry *en; struct top_hash_entry *en;
u32 rid = ipa_to_rid(fn->prefix); u32 rid = ipa_to_rid(fn->prefix);
u32 dom = oa->areaid;
void *body;
OSPF_TRACE(D_EVENTS, "Originating rt-summary-LSA for %R (metric %d)", OSPF_TRACE(D_EVENTS, "Originating rt-summary-LSA for %R (metric %d)", rid, metric);
rid, metric);
lsa.age = 0; lsa.type = LSA_T_SUM_RT;
lsa.type_raw = LSA_T_SUM_RT; lsa.dom = oa->areaid;
lsa.id = rid; /* In OSPFv3, LSA ID is meaningless, but we still use Router ID of ASBR */ lsa.id = rid; /* In OSPFv3, LSA ID is meaningless, but we still use Router ID of ASBR */
lsa.rt = po->router_id; lsa.opts = oa->options;
lsa_fix_options(po, &lsa, oa->options);
options &= OPTIONS_MASK; options &= OPTIONS_MASK;
en = ospf_hash_find_header(po->gr, dom, &lsa); en = ospf_hash_find(po->gr, lsa.dom, lsa.id, po->router_id, lsa.type);
if (en && check_sum_rt_lsa(po, en, rid, metric, options)) if (en && check_sum_rt_lsa(po, en, rid, metric, options))
return; return;
lsa.sn = get_seqnum(en);
body = originate_sum_rt_lsa_body(po, &lsa.length, rid, metric, options); lsa.body = originate_sum_rt_lsa_body(po, &lsa.length, rid, metric, options);
lsasum_calculate(&lsa, body);
lsa_install_new(po, &lsa, dom, body); ospf_originate_lsa(po, &lsa, en);
ospf_lsupd_flood(po, NULL, NULL, &lsa, dom, 1);
} }
void void
flush_sum_lsa(struct ospf_area *oa, struct fib_node *fn, int type) flush_sum_lsa(struct ospf_area *oa, struct fib_node *fn, int type)
{ {
struct proto_ospf *po = oa->po; struct proto_ospf *po = oa->po;
struct ospf_lsa_header lsa;
struct top_hash_entry *en; struct top_hash_entry *en;
u32 dom = oa->areaid; u32 dom, lsid, type;
lsa.rt = po->router_id;
if (type == ORT_NET) if (type == ORT_NET)
{ {
lsa.id = fibnode_to_lsaid(po, fn); dom = oa->areaid;
lsa.type_raw = LSA_T_SUM_NET; type = LSA_T_SUM_NET;
lsid = fibnode_to_lsaid(po, fn);
} }
else else
{ {
/* In OSPFv3, LSA ID is meaningless, but we still use Router ID of ASBR */ /* In OSPFv3, LSA ID is meaningless, but we still use Router ID of ASBR */
lsa.id = ipa_to_rid(fn->prefix); dom = oa->areaid;
lsa.type_raw = LSA_T_SUM_RT; type = LSA_T_SUM_RT;
lsid = ipa_to_rid(fn->prefix);
} }
en = ospf_hash_find_header(po->gr, dom, &lsa); en = ospf_hash_find(po->gr, dom, lsid, po->router_id, type);
if (en) if (en)
{ {
OSPF_TRACE(D_EVENTS, "Flushing summary-LSA (id=%R, type=%d)", OSPF_TRACE(D_EVENTS, "Flushing summary-LSA (id=%R, type=%x)", lsid, type);
en->lsa.id, en->lsa.type_raw);
if ((type == ORT_NET) && (check_sum_net_lsa(po, en, fn, 0) < 0)) if ((type == ORT_NET) && (check_sum_net_lsa(po, en, fn, 0) < 0))
return; return;
@ -1061,42 +1041,45 @@ originate_ext_lsa(struct ospf_area *oa, struct fib_node *fn, int src,
u32 metric, ip_addr fwaddr, u32 tag, int pbit) u32 metric, ip_addr fwaddr, u32 tag, int pbit)
{ {
struct proto_ospf *po = oa->po; struct proto_ospf *po = oa->po;
struct proto *p = &po->proto; struct ospf_lsa_new lsa;
struct ospf_lsa_header lsa;
struct top_hash_entry *en; struct top_hash_entry *en;
int nssa = oa_is_nssa(oa); int nssa = oa_is_nssa(oa);
u32 dom = nssa ? oa->areaid : 0;
void *body;
OSPF_TRACE(D_EVENTS, "Originating %s-LSA for %I/%d", OSPF_TRACE(D_EVENTS, "Originating %s-LSA for %I/%d",
nssa ? "NSSA" : "AS-external", fn->prefix, fn->pxlen); nssa ? "NSSA" : "AS-external", fn->prefix, fn->pxlen);
lsa.age = 0; if (! nssa)
lsa.type_raw = nssa ? LSA_T_NSSA : LSA_T_EXT;
lsa.id = fibnode_to_lsaid(po, fn);
lsa.rt = po->router_id;
lsa_fix_options(po, &lsa, nssa ? (pbit ? OPT_P : 0) : OPT_E);
if (nssa && pbit && ipa_zero(fwaddr))
{ {
/* NSSA-LSA with P-bit set must have non-zero forwarding address */ lsa.type = LSA_T_EXT;
lsa.dom = 0;
lsa.id = fibnode_to_lsaid(po, fn);
lsa.opts = OPT_E;
}
else
{
lsa.type = LSA_T_NSSA;
lsa.dom = oa->areaid;
lsa.id = fibnode_to_lsaid(po, fn);
lsa.opts = pbit ? OPT_P : 0;
/* NSSA-LSA with P-bit set must have non-zero forwarding address */
if (pbit && ipa_zero(fwaddr))
{
fwaddr = find_surrogate_fwaddr(oa); fwaddr = find_surrogate_fwaddr(oa);
if (ipa_zero(fwaddr)) if (ipa_zero(fwaddr))
{ {
log(L_ERR "%s: Cannot find forwarding address for NSSA-LSA %I/%d", log(L_ERR "%s: Cannot find forwarding address for NSSA-LSA %I/%d",
p->name, fn->prefix, fn->pxlen); po->proto.name, fn->prefix, fn->pxlen);
return; return;
} }
} }
}
en = ospf_hash_find_header(po->gr, dom, &lsa); en = ospf_hash_find(po->gr, lsa.dom, lsa.id, po->router_id, lsa.type);
if (en && check_ext_lsa(po, en, fn, metric, fwaddr, tag)) if (en && check_ext_lsa(po, en, fn, metric, fwaddr, tag))
return; return;
lsa.sn = get_seqnum(en);
body = originate_ext_lsa_body(po, &lsa.length, fn, metric, fwaddr, tag, pbit); lsa.body = originate_ext_lsa_body(po, &lsa.length, fn, metric, fwaddr, tag, pbit);
lsasum_calculate(&lsa, body);
if (src) if (src)
{ {
@ -1104,8 +1087,7 @@ originate_ext_lsa(struct ospf_area *oa, struct fib_node *fn, int src,
fn->flags |= src; fn->flags |= src;
} }
lsa_install_new(po, &lsa, dom, body); ospf_originate_lsa(po, &lsa, en);
ospf_lsupd_flood(po, NULL, NULL, &lsa, dom, 1);
if (po->ebit == 0) if (po->ebit == 0)
{ {
@ -1126,20 +1108,16 @@ flush_ext_lsa(struct ospf_area *oa, struct fib_node *fn, int src, int nssa)
u32 dom = nssa ? oa->areaid : 0; u32 dom = nssa ? oa->areaid : 0;
u32 type = nssa ? LSA_T_NSSA : LSA_T_EXT; u32 type = nssa ? LSA_T_NSSA : LSA_T_EXT;
u32 lsaid = fibnode_to_lsaid(po, fn); u32 lsid = fibnode_to_lsaid(po, fn);
en = ospf_hash_find(po->gr, dom, lsaid, po->router_id, type); en = ospf_hash_find(po->gr, dom, lsid, po->router_id, type);
if (en) if (en)
{ {
OSPF_TRACE(D_EVENTS, "Flushing %s-LSA for %I/%d", OSPF_TRACE(D_EVENTS, "Flushing %s-LSA for %I/%d",
nssa ? "NSSA" : "AS-external", fn->prefix, fn->pxlen); nssa ? "NSSA" : "AS-external", fn->prefix, fn->pxlen);
if (check_ext_lsa(po, en, fn, 0, IPA_NONE, 0) < 0) if (check_ext_lsa(po, en, fn, 0, IPA_NONE, 0) < 0)
{
log(L_ERR "%s: LSAID collision for %I/%d",
p->name, fn->prefix, fn->pxlen);
return; return;
}
/* Clean up source bits */ /* Clean up source bits */
if (src) // XXXX ??? if (src) // XXXX ???
@ -1192,22 +1170,17 @@ originate_link_lsa(struct ospf_iface *ifa)
{ {
struct proto_ospf *po = ifa->oa->po; struct proto_ospf *po = ifa->oa->po;
struct ospf_lsa_header lsa; struct ospf_lsa_header lsa;
u32 dom = ifa->iface_id;
void *body;
/* FIXME check for vlink and skip that? */ /* FIXME check for vlink and skip that? */
OSPF_TRACE(D_EVENTS, "Originating link-LSA for iface %s", ifa->iface->name); OSPF_TRACE(D_EVENTS, "Originating link-LSA for iface %s", ifa->iface->name);
lsa.age = 0; lsa.type = LSA_T_LINK;
lsa.type_raw = LSA_T_LINK; lsa.dom = ifa->iface_id;
lsa.id = ifa->iface_id; lsa.id = ifa->iface_id;
lsa.rt = po->router_id; lsa.opts = 0;
lsa.sn = get_seqnum(ifa->link_lsa); lsa.body = originate_link_lsa_body(ifa, &lsa.length);
body = originate_link_lsa_body(ifa, &lsa.length); ifa->link_lsa = ospf_originate_lsa(po, &lsa, ifa->link_lsa);
lsasum_calculate(&lsa, body);
ifa->link_lsa = lsa_install_new(po, &lsa, dom, body);
ospf_lsupd_flood(po, NULL, NULL, &lsa, dom, 1);
/* Just to be sure to not forget on our link LSA */ /* Just to be sure to not forget on our link LSA */
if (ifa->state == OSPF_IS_DR) if (ifa->state == OSPF_IS_DR)
@ -1344,21 +1317,16 @@ originate_prefix_rt_lsa(struct ospf_area *oa)
{ {
struct proto_ospf *po = oa->po; struct proto_ospf *po = oa->po;
struct ospf_lsa_header lsa; struct ospf_lsa_header lsa;
u32 dom = oa->areaid;
void *body;
OSPF_TRACE(D_EVENTS, "Originating router prefix-LSA for area %R", oa->areaid); OSPF_TRACE(D_EVENTS, "Originating router prefix-LSA for area %R", oa->areaid);
lsa.age = 0; lsa.type = LSA_T_PREFIX;
lsa.type_raw = LSA_T_PREFIX; lsa.dom = oa->areaid;
lsa.id = 0; lsa.id = 0;
lsa.rt = po->router_id; lsa.opts = 0;
lsa.sn = get_seqnum(oa->pxr_lsa); lsa.body = originate_prefix_rt_lsa_body(oa, &lsa.length);
body = originate_prefix_rt_lsa_body(oa, &lsa.length); oa->pxr_lsa = ospf_originate_lsa(po, &lsa, oa->pxr_lsa);
lsasum_calculate(&lsa, body);
oa->pxr_lsa = lsa_install_new(po, &lsa, dom, body);
ospf_lsupd_flood(po, NULL, NULL, &lsa, dom, 1);
} }
@ -1485,23 +1453,17 @@ void
originate_prefix_net_lsa(struct ospf_iface *ifa) originate_prefix_net_lsa(struct ospf_iface *ifa)
{ {
struct proto_ospf *po = ifa->oa->po; struct proto_ospf *po = ifa->oa->po;
struct ospf_lsa_header lsa; struct ospf_lsa_new lsa;
u32 dom = ifa->oa->areaid;
void *body;
OSPF_TRACE(D_EVENTS, "Originating network prefix-LSA for iface %s", OSPF_TRACE(D_EVENTS, "Originating network prefix-LSA for iface %s", ifa->iface->name);
ifa->iface->name);
lsa.age = 0; lsa.type = LSA_T_PREFIX;
lsa.type_raw = LSA_T_PREFIX; lsa.dom = ifa->oa->areaid;
lsa.id = ifa->iface_id; lsa.id = ifa->iface_id;
lsa.rt = po->router_id; lsa.opts = 0;
lsa.sn = get_seqnum(ifa->pxn_lsa); lsa.body = originate_prefix_net_lsa_body(ifa, &lsa.length);
body = originate_prefix_net_lsa_body(ifa, &lsa.length); ifa->pxn_lsa = ospf_originate_lsa(po, &lsa, ifa->pxn_lsa);
lsasum_calculate(&lsa, body);
ifa->pxn_lsa = lsa_install_new(po, &lsa, dom, body);
ospf_lsupd_flood(po, NULL, NULL, &lsa, dom, 1);
} }
void void
@ -1638,18 +1600,6 @@ ospf_top_rehash(struct top_graph *f, int step)
ospf_top_ht_free(oldt); ospf_top_ht_free(oldt);
} }
struct top_hash_entry *
ospf_hash_find_header(struct top_graph *f, u32 domain, struct ospf_lsa_header *h)
{
return ospf_hash_find(f, domain, h->id, h->rt, h->type);
}
struct top_hash_entry *
ospf_hash_get_header(struct top_graph *f, u32 domain, struct ospf_lsa_header *h)
{
return ospf_hash_get(f, domain, h->id, h->rt, h->type);
}
struct top_hash_entry * struct top_hash_entry *
ospf_hash_find(struct top_graph *f, u32 domain, u32 lsa, u32 rtr, u32 type) ospf_hash_find(struct top_graph *f, u32 domain, u32 lsa, u32 rtr, u32 type)
{ {
@ -1861,3 +1811,13 @@ can_flush_lsa(struct proto_ospf *po)
return 1; return 1;
} }
ospf_originate_lsa(struct proto_ospf *po, struct ospf_lsa_header *lsa)
{
struct ospf_lsa_header hdr;
lsasum_calculate(&lsa, body);
xx = lsa_install_new(po, &lsa, dom, body);
ospf_lsupd_flood(po, NULL, NULL, &lsa, dom, 1);
}

View File

@ -47,18 +47,22 @@ struct top_graph
unsigned int hash_entries_min, hash_entries_max; unsigned int hash_entries_min, hash_entries_max;
}; };
struct ospf_lsa_new
{
u16 type;
u32 dom;
u32 id;
u16 opts;
u16 length;
void *body;
};
struct top_graph *ospf_top_new(pool *); struct top_graph *ospf_top_new(pool *);
void ospf_top_free(struct top_graph *); void ospf_top_free(struct top_graph *);
void ospf_top_dump(struct top_graph *, struct proto *); void ospf_top_dump(struct top_graph *, struct proto *);
struct top_hash_entry *ospf_hash_find_header(struct top_graph *f, u32 domain,
struct ospf_lsa_header *h);
struct top_hash_entry *ospf_hash_get_header(struct top_graph *f, u32 domain,
struct ospf_lsa_header *h);
struct top_hash_entry *ospf_hash_find(struct top_graph *, u32 domain, u32 lsa, u32 rtr, u32 type);
struct top_hash_entry *ospf_hash_get(struct top_graph *, u32 domain, u32 lsa, u32 rtr, u32 type);
void ospf_hash_delete(struct top_graph *, struct top_hash_entry *);
void originate_rt_lsa(struct ospf_area *oa); void originate_rt_lsa(struct ospf_area *oa);
void update_rt_lsa(struct ospf_area *oa); void update_rt_lsa(struct ospf_area *oa);
void originate_net_lsa(struct ospf_iface *ifa); void originate_net_lsa(struct ospf_iface *ifa);
@ -72,6 +76,17 @@ void flush_sum_lsa(struct ospf_area *oa, struct fib_node *fn, int type);
void originate_ext_lsa(struct ospf_area *oa, struct fib_node *fn, int src, u32 metric, ip_addr fwaddr, u32 tag, int pbit); void originate_ext_lsa(struct ospf_area *oa, struct fib_node *fn, int src, u32 metric, ip_addr fwaddr, u32 tag, int pbit);
void flush_ext_lsa(struct ospf_area *oa, struct fib_node *fn, int src, int nssa); void flush_ext_lsa(struct ospf_area *oa, struct fib_node *fn, int src, int nssa);
struct top_hash_entry *ospf_hash_find(struct top_graph *, u32 domain, u32 lsa, u32 rtr, u32 type);
struct top_hash_entry *ospf_hash_get(struct top_graph *, u32 domain, u32 lsa, u32 rtr, u32 type);
void ospf_hash_delete(struct top_graph *, struct top_hash_entry *);
static inline struct top_hash_entry * ospf_hash_find_entry(struct top_graph *f, struct top_hash_entry *en)
{ return ospf_hash_find(f, en->domain, en->lsa.id, en->lsa.rt, en->lsa_type); }
static inline struct top_hash_entry * ospf_hash_get_entry(struct top_graph *f, struct top_hash_entry *en)
{ return ospf_hash_get(f, en->domain, en->lsa.id, en->lsa.rt, en->lsa_type); }
struct top_hash_entry * ospf_hash_find_rt(struct top_graph *f, u32 domain, u32 rtr); struct top_hash_entry * ospf_hash_find_rt(struct top_graph *f, u32 domain, u32 rtr);
struct top_hash_entry * ospf_hash_find_rt3_first(struct top_graph *f, u32 domain, u32 rtr); struct top_hash_entry * ospf_hash_find_rt3_first(struct top_graph *f, u32 domain, u32 rtr);
struct top_hash_entry * ospf_hash_find_rt3_next(struct top_hash_entry *e); struct top_hash_entry * ospf_hash_find_rt3_next(struct top_hash_entry *e);