[PATCH 5/9] Adding source prefixes in prefix LSAs.
Dean Luga
dluga93 at gmail.com
Tue Mar 7 00:56:29 CET 2017
From: dean <dluga93 at gmail.com>
Instead of prefix LSAs containing destination prefixes, they now
contain pairs of (destination, source) prefixes. Meaning there will
always be an even number of prefixes in the LSAs if SADR is enabled.
Functions that process the prefix LSAs now also take into account
that there are pairs of prefixes. So they read the prefixes two by
two or skip the source prefixes (until a following patch allows them
to process source prefixes as well).
---
proto/ospf/ospf.c | 6 ++++++
proto/ospf/rt.c | 21 +++++++++++++++++++++
proto/ospf/topology.c | 36 +++++++++++++++++++++++++++++++++++-
3 files changed, 62 insertions(+), 1 deletion(-)
diff --git a/proto/ospf/ospf.c b/proto/ospf/ospf.c
index d5d5d35..92545e3 100644
--- a/proto/ospf/ospf.c
+++ b/proto/ospf/ospf.c
@@ -1148,6 +1148,12 @@ show_lsa_prefix(struct top_hash_entry *he, struct top_hash_entry *cnode)
cli_msg(-1016, "\t\tstubnet %I/%d metric %u", pxa, pxlen, metric);
else
cli_msg(-1016, "\t\taddress %I/%d", pxa, pxlen);
+
+ #ifdef SADR_OSPF
+ // skip source prefix
+ buf = lsa_get_ipv6_prefix(buf, &pxa, &pxlen, &pxopts, &metric);
+ i++;
+ #endif
}
}
diff --git a/proto/ospf/rt.c b/proto/ospf/rt.c
index cdf8012..fdcecae 100644
--- a/proto/ospf/rt.c
+++ b/proto/ospf/rt.c
@@ -587,10 +587,31 @@ spfa_process_prefixes(struct ospf_proto *p, struct ospf_area *oa)
continue;
buf = px->rest;
+ #ifdef SADR_OSPF
+ for (i = 0; i < px->pxcount; i+=2)
+ #else
for (i = 0; i < px->pxcount; i++)
+ #endif
{
+ addr_data addr = addr_data_init_empty();
+
buf = lsa_get_ipv6_prefix(buf, &pxa, &pxlen, &pxopts, &metric);
+ addr.prefix = &pxa;
+ addr.pxlen = pxlen;
+
+ #ifdef SADR_OSPF
+ // src prefix
+ ip_addr src_pxa;
+ int src_pxlen;
+ u8 src_pxopts;
+ u16 dummy_src_metric;
+ buf = lsa_get_ipv6_prefix(buf, &src_pxa, &src_pxlen, &src_pxopts, &dummy_src_metric);
+
+ addr.src_prefix = &src_pxa;
+ addr.src_pxlen = src_pxlen;
+ #endif
+
if (pxopts & OPT_PX_NU)
continue;
diff --git a/proto/ospf/topology.c b/proto/ospf/topology.c
index 7558d4a..e8a3772 100644
--- a/proto/ospf/topology.c
+++ b/proto/ospf/topology.c
@@ -1415,10 +1415,22 @@ prepare_prefix_rt_lsa_body(struct ospf_proto *p, struct ospf_area *oa)
(ifa->type == OSPF_IT_PTMP))
{
lsab_put_prefix(p, a->ip, MAX_PREFIX_LENGTH, 0);
+ #ifdef SADR_OSPF
+ // src prefix
+ lsab_put_prefix(p, IPA_NONE, 0, 0);
+ i++;
+ #endif
host_addr = 1;
}
- else
+ else {
+ // put destination prefix
lsab_put_prefix(p, a->prefix, a->pxlen, ifa->cost);
+ #ifdef SADR_OSPF
+ // put source prefix
+ lsab_put_prefix(p, IPA_NONE, 0, 0);
+ i++;
+ #endif
+ }
i++;
}
@@ -1433,6 +1445,11 @@ prepare_prefix_rt_lsa_body(struct ospf_proto *p, struct ospf_area *oa)
if (sn->px.len == MAX_PREFIX_LENGTH)
host_addr = 1;
i++;
+
+ #ifdef SADR_OSPF
+ lsab_put_prefix(p, IPA_NONE, 0, 0);
+ i++;
+ #endif
}
/* If there are some configured vlinks, find some global address
@@ -1453,6 +1470,12 @@ prepare_prefix_rt_lsa_body(struct ospf_proto *p, struct ospf_area *oa)
/* Found some IP */
lsab_put_prefix(p, a->ip, MAX_PREFIX_LENGTH, 0);
i++;
+
+ #ifdef SADR_OSPF
+ lsab_put_prefix(p, IPA_NONE, 0, 0);
+ i++;
+ #endif
+
goto done;
}
}
@@ -1538,6 +1561,17 @@ add_prefix(struct ospf_proto *p, u32 *px, int offset, int *pxc)
pxl = lsab_alloc(p, pxspace);
memcpy(pxl, px, pxspace);
*pxl &= 0xFFFF0000; /* Set metric to zero */
+
+ #ifdef SADR_OSPF
+ // adding src_prefix
+ u32 spx = 0;
+ int spxspace = prefix_space(&spx);
+ u32* spxl = lsab_alloc(p, spxspace);
+ memcpy(spxl, &spx, spxspace);
+
+ (*pxc)++;
+ #endif
+
(*pxc)++;
}
--
2.7.4
More information about the Bird-users
mailing list