diff options
Diffstat (limited to 'proto')
-rw-r--r-- | proto/ospf/ospf.c | 2 | ||||
-rw-r--r-- | proto/ospf/ospf.h | 4 | ||||
-rw-r--r-- | proto/ospf/rt.c | 3 | ||||
-rw-r--r-- | proto/ospf/rt.h | 1 | ||||
-rw-r--r-- | proto/ospf/topology.c | 16 |
5 files changed, 17 insertions, 9 deletions
diff --git a/proto/ospf/ospf.c b/proto/ospf/ospf.c index 4ffb187d..1c128794 100644 --- a/proto/ospf/ospf.c +++ b/proto/ospf/ospf.c @@ -240,6 +240,8 @@ ospf_start(struct proto *P) init_list(&(p->area_list)); fib_init(&p->rtf, P->pool, p->ospf2 ? NET_IP4 : NET_IP6, sizeof(ort), OFFSETOF(ort, fn), 0, NULL); + if (ospf_is_v3(p)) + idm_init(&p->idm, P->pool, 16); p->areano = 0; p->gr = ospf_top_new(p, P->pool); s_init_list(&(p->lsal)); diff --git a/proto/ospf/ospf.h b/proto/ospf/ospf.h index b1e02b24..3d70df7b 100644 --- a/proto/ospf/ospf.h +++ b/proto/ospf/ospf.h @@ -14,7 +14,7 @@ #include "nest/bird.h" #include "lib/checksum.h" -#include "lib/ip.h" +#include "lib/idm.h" #include "lib/lists.h" #include "lib/slists.h" #include "lib/socket.h" @@ -79,7 +79,6 @@ #define OSPF_VLINK_ID_OFFSET 0x80000000 - struct ospf_config { struct proto_config c; @@ -215,6 +214,7 @@ struct ospf_proto int areano; /* Number of area I belong to */ int padj; /* Number of neighbors in Exchange or Loading state */ struct fib rtf; /* Routing table */ + struct idm idm; /* OSPFv3 LSA ID map */ byte ospf2; /* OSPF v2 or v3 */ byte rfc1583; /* RFC1583 compatibility */ byte stub_router; /* Do not forward transit traffic */ diff --git a/proto/ospf/rt.c b/proto/ospf/rt.c index 707e376c..21a3e300 100644 --- a/proto/ospf/rt.c +++ b/proto/ospf/rt.c @@ -2005,6 +2005,9 @@ again1: /* Remove unused rt entry, some special entries are persistent */ if (!nf->n.type && !nf->external_rte && !nf->area_net) { + if (nf->lsa_id) + idm_free(&p->idm, nf->lsa_id); + FIB_ITERATE_PUT(&fit); fib_delete(fib, nf); goto again1; diff --git a/proto/ospf/rt.h b/proto/ospf/rt.h index 80243c9a..959d12e9 100644 --- a/proto/ospf/rt.h +++ b/proto/ospf/rt.h @@ -81,6 +81,7 @@ typedef struct ort orta n; u32 old_metric1, old_metric2, old_tag, old_rid; rta *old_rta; + u32 lsa_id; u8 external_rte; u8 area_net; diff --git a/proto/ospf/topology.c b/proto/ospf/topology.c index 59e76019..89bf87c7 100644 --- a/proto/ospf/topology.c +++ b/proto/ospf/topology.c @@ -513,8 +513,7 @@ ospf_update_lsadb(struct ospf_proto *p) } } - -static inline u32 +static u32 ort_to_lsaid(struct ospf_proto *p, ort *nf) { /* @@ -542,14 +541,17 @@ ort_to_lsaid(struct ospf_proto *p, ort *nf) * network appeared, we choose a different way. * * In OSPFv3, it is simpler. There is not a requirement for membership of the - * result in the input network, so we just use a hash-based unique ID of a - * routing table entry for a route that originated given LSA. For ext-LSA, it - * is an imported route in the nest's routing table (p->table). For summary-LSA, - * it is a 'source' route in the protocol internal routing table (p->rtf). + * result in the input network, so we just allocate a unique ID from ID map + * and store it in nf->lsa_id for further reference. */ if (ospf_is_v3(p)) - return nf->fn.uid; + { + if (!nf->lsa_id) + nf->lsa_id = idm_alloc(&p->idm); + + return nf->lsa_id; + } net_addr_ip4 *net = (void *) nf->fn.addr; u32 id = ip4_to_u32(net->prefix); |