[PATCH 7/9] Adding source constrained networks to OSPF table.
Dean Luga
dluga93 at gmail.com
Tue Mar 7 00:56:31 CET 2017
From: dean <dluga93 at gmail.com>
The add_network and ri_install_net functions that install networks
in the OSPF routing tables when processing intra-area and inter-area
routes were changed to use addr_data objects and support SADR entries.
The respective calls to these functions also use addr_data objects.
---
proto/ospf/rt.c | 41 ++++++++++++++++++++++++++++++-----------
1 file changed, 30 insertions(+), 11 deletions(-)
diff --git a/proto/ospf/rt.c b/proto/ospf/rt.c
index 67ea04e..c8eaa0f 100644
--- a/proto/ospf/rt.c
+++ b/proto/ospf/rt.c
@@ -334,9 +334,9 @@ ort_merge_ext(struct ospf_proto *p, ort *o, const orta *new)
static inline void
-ri_install_net(struct ospf_proto *p, ip_addr prefix, int pxlen, const orta *new)
+ri_install_net(struct ospf_proto *p, addr_data addr, const orta *new)
{
- ort *old = (ort *) fib_get(&p->rtf, &prefix, pxlen);
+ ort *old = (ort *) fib_get2(&p->rtf, addr);
int cmp = orta_compare(p, new, &old->n);
if (cmp > 0)
@@ -404,7 +404,8 @@ px_pos_to_ifa(struct ospf_area *oa, int pos)
static void
-add_network(struct ospf_area *oa, ip_addr px, int pxlen, int metric, struct top_hash_entry *en, int pos)
+add_network(struct ospf_area *oa, addr_data addr, int metric,
+ struct top_hash_entry *en, int pos)
{
struct ospf_proto *p = oa->po;
@@ -419,13 +420,22 @@ add_network(struct ospf_area *oa, ip_addr px, int pxlen, int metric, struct top_
.nhs = en->nhs
};
- if (pxlen < 0 || pxlen > MAX_PREFIX_LENGTH)
+ if (addr.pxlen < 0 || addr.pxlen > MAX_PREFIX_LENGTH)
{
log(L_WARN "%s: Invalid prefix in LSA (Type: %04x, Id: %R, Rt: %R)",
p->p.name, en->lsa_type, en->lsa.id, en->lsa.rt);
return;
}
+ #ifdef SADR_OSPF
+ if (addr.src_pxlen < 0 || addr.src_pxlen > MAX_PREFIX_LENGTH)
+ {
+ log(L_WARN "%s: Invalid src prefix in LSA (Type: %04x, Id: %R, Rt: %R)",
+ p->p.name, en->lsa_type, en->lsa.id, en->lsa.rt);
+ return;
+ }
+ #endif
+
if (en == oa->rt)
{
/*
@@ -441,7 +451,7 @@ add_network(struct ospf_area *oa, ip_addr px, int pxlen, int metric, struct top_
nf.nhs = ifa ? new_nexthop(p, IPA_NONE, ifa->iface, ifa->ecmp_weight) : NULL;
}
- ri_install_net(p, px, pxlen, &nf);
+ ri_install_net(p, addr, &nf);
}
@@ -505,7 +515,12 @@ spfa_process_rt(struct ospf_proto *p, struct ospf_area *oa, struct top_hash_entr
*/
prefix = ipa_from_u32(rtl.id & rtl.data);
pxlen = u32_masklen(rtl.data);
- add_network(oa, prefix, pxlen, act->dist + rtl.metric, act, i);
+
+ addr_data addr = addr_data_init_empty();
+ addr.prefix = &prefix;
+ addr.pxlen = pxlen;
+
+ add_network(oa, addr, act->dist + rtl.metric, act, i);
break;
case LSART_NET:
@@ -528,13 +543,17 @@ spfa_process_net(struct ospf_proto *p, struct ospf_area *oa, struct top_hash_ent
struct ospf_lsa_net *ln = act->lsa_body;
struct top_hash_entry *tmp;
ip_addr prefix;
- int pxlen, i, cnt;
+ int i, cnt;
if (ospf_is_v2(p))
{
prefix = ipa_from_u32(act->lsa.id & ln->optx);
- pxlen = u32_masklen(ln->optx);
- add_network(oa, prefix, pxlen, act->dist, act, -1);
+
+ addr_data addr = addr_data_init_empty();
+ addr.prefix = &prefix;
+ addr.pxlen = u32_masklen(ln->optx);
+
+ add_network(oa, addr, act->dist, act, -1);
}
cnt = lsa_net_count(&act->lsa);
@@ -619,7 +638,7 @@ spfa_process_prefixes(struct ospf_proto *p, struct ospf_area *oa)
if ((pxopts & OPT_PX_LA) && ipa_zero(src->lb))
src->lb = pxa;
- add_network(oa, pxa, pxlen, src->dist + metric, src, i);
+ add_network(oa, addr, src->dist + metric, src, i);
}
}
}
@@ -859,7 +878,7 @@ ospf_rt_sum(struct ospf_area *oa)
};
if (type == ORT_NET)
- ri_install_net(p, *addr.prefix, addr.pxlen, &nf);
+ ri_install_net(p, addr, &nf);
else
ri_install_rt(oa, dst_rid, &nf);
}
--
2.7.4
More information about the Bird-users
mailing list