summaryrefslogtreecommitdiff
path: root/nest/a-path.c
diff options
context:
space:
mode:
authorIgor Putovny <igor.putovny@nic.cz>2023-06-21 13:15:07 +0200
committerOndrej Zajicek <santiago@crfreenet.org>2023-09-26 15:46:24 +0200
commit977b82fba49b22d9548546d88b105945921efaed (patch)
treec62f27e9923c25336263883e2c069f8e87d150dc /nest/a-path.c
parent0a729b509c2c4476cbf66c64620a863e6a381c8c (diff)
Basic route aggregation
Add a new protocol offering route aggregation. User can specify list of route attributes in the configuration file and run route aggregation on the export side of the pipe protocol. Routes are sorted and for every group of equivalent routes new route is created and exported to the routing table. It is also possible to specify filter which will run for every route before aggregation. Furthermore, it will be possible to set attributes of new routes according to attributes of the aggregated routes. This is a work in progress. Original work by Igor Putovny, subsequent cleanups and finalization by Maria Matejka.
Diffstat (limited to 'nest/a-path.c')
-rw-r--r--nest/a-path.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/nest/a-path.c b/nest/a-path.c
index c421b41f..aba2c86d 100644
--- a/nest/a-path.c
+++ b/nest/a-path.c
@@ -670,6 +670,29 @@ as_path_filter(struct linpool *pool, const struct adata *path, const struct f_va
}
int
+as_path_compare(const struct adata *path1, const struct adata *path2)
+{
+ uint pos1 = 0;
+ uint pos2 = 0;
+ uint val1 = 0;
+ uint val2 = 0;
+
+ while (1)
+ {
+ int res1 = as_path_walk(path1, &pos1, &val1);
+ int res2 = as_path_walk(path2, &pos2, &val2);
+
+ if (res1 == 0 && res2 == 0)
+ return 0;
+
+ if (val1 == val2)
+ continue;
+
+ return val1 < val2 ? -1 : 1;
+ }
+}
+
+int
as_path_walk(const struct adata *path, uint *pos, uint *val)
{
if (!path)