[frr] [PATCH 02/11] bgpd: detect if bgp_info is multipath entry
Philippe Guibert
philippe.guibert at 6wind.com
Wed Dec 21 09:13:47 EST 2016
Enhance a function that permits knowing if two entries belong to the
same multipath group.
Signed-off-by: Philippe Guibert <philippe.guibert at 6wind.com>
---
bgpd/bgp_mpath.c | 15 +++++++++++++++
bgpd/bgp_mpath.h | 1 +
2 files changed, 16 insertions(+)
diff --git a/bgpd/bgp_mpath.c b/bgpd/bgp_mpath.c
index e7272cc0aa44..e6b77b4deebf 100644
--- a/bgpd/bgp_mpath.c
+++ b/bgpd/bgp_mpath.c
@@ -777,3 +777,18 @@ bgp_info_mpath_aggregate_update (struct bgp_info *new_best,
else
bgp_attr_unintern (&new_attr);
}
+
+/* returns 1 if ri is part of the mpath list from new_select */
+int bgp_is_mpath_entry(struct bgp_info *ri, struct bgp_info *curr)
+{
+ struct bgp_info *mpinfo;
+
+ /* not a multipath entry */
+ if(!curr || !curr->mpath)
+ return 0;
+ for (mpinfo = bgp_info_mpath_first (curr); mpinfo;
+ mpinfo = bgp_info_mpath_next (mpinfo))
+ if(mpinfo == ri)
+ return 1;
+ return 0;
+}
diff --git a/bgpd/bgp_mpath.h b/bgpd/bgp_mpath.h
index 0a51c98d0660..22f6a361a2bb 100644
--- a/bgpd/bgp_mpath.h
+++ b/bgpd/bgp_mpath.h
@@ -75,5 +75,6 @@ extern struct bgp_info *bgp_info_mpath_next (struct bgp_info *);
/* Accessors for multipath information */
extern u_int32_t bgp_info_mpath_count (struct bgp_info *);
extern struct attr *bgp_info_mpath_attr (struct bgp_info *);
+extern int bgp_is_mpath_entry(struct bgp_info *ri, struct bgp_info *curr);
#endif /* _QUAGGA_BGP_MPATH_H */
--
2.1.4
More information about the dev
mailing list