summaryrefslogtreecommitdiffstats
path: root/lib/nexthop_group.h
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2018-01-26 16:12:35 +0100
committerDonald Sharp <sharpd@cumulusnetworks.com>2018-03-09 17:07:41 +0100
commit7ee30f288e9d572d971c2a36b68775c7d2fac299 (patch)
tree6e24b4fde63b53cff251a69fa54fa69afff046b1 /lib/nexthop_group.h
parentlib, zebra: Allow zapi to send down the tableid (diff)
downloadfrr-7ee30f288e9d572d971c2a36b68775c7d2fac299.tar.xz
frr-7ee30f288e9d572d971c2a36b68775c7d2fac299.zip
lib: Isolate nexthop_group functions to nexthop_group.c
Also modify `struct route_entry` to use nexthop_groups. Move ALL_NEXTHOPS loop to nexthop_group.h Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'lib/nexthop_group.h')
-rw-r--r--lib/nexthop_group.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/lib/nexthop_group.h b/lib/nexthop_group.h
new file mode 100644
index 000000000..26900959c
--- /dev/null
+++ b/lib/nexthop_group.h
@@ -0,0 +1,52 @@
+/*
+ * Nexthop Group structure definition.
+ * Copyright (C) 2018 Cumulus Networks, Inc.
+ * Donald Sharp
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __NEXTHOP_GROUP__
+#define __NEXTHOP_GROUP__
+
+/*
+ * What is a nexthop group?
+ *
+ * A nexthop group is a collection of nexthops that make up
+ * the ECMP path for the route.
+ *
+ * This module provides a proper abstraction to this idea.
+ */
+struct nexthop_group {
+ struct nexthop *nexthop;
+};
+
+void nexthop_add(struct nexthop **target, struct nexthop *nexthop);
+void copy_nexthops(struct nexthop **tnh, struct nexthop *nh,
+ struct nexthop *rparent);
+
+/* The following for loop allows to iterate over the nexthop
+ * structure of routes.
+ *
+ * head: The pointer to the first nexthop in the chain.
+ *
+ * nexthop: The pointer to the current nexthop, either in the
+ * top-level chain or in a resolved chain.
+ */
+#define ALL_NEXTHOPS(head, nhop) \
+ (nhop) = (head.nexthop); \
+ (nhop); \
+ (nhop) = nexthop_next(nhop)
+#endif