diff options
author | Stephen Worley <sworley@cumulusnetworks.com> | 2019-03-11 21:29:57 +0100 |
---|---|---|
committer | Stephen Worley <sworley@cumulusnetworks.com> | 2019-10-25 17:13:37 +0200 |
commit | 602fea614f8272c3fdd9ed7c8a490ad12575425e (patch) | |
tree | c99e759f8e28f0e5278770351e93453e4e02afc0 /zebra/interface.c | |
parent | zebra: Make route entry nexthop groups point to our hash entry (diff) | |
download | frr-602fea614f8272c3fdd9ed7c8a490ad12575425e.tar.xz frr-602fea614f8272c3fdd9ed7c8a490ad12575425e.zip |
zebra: Add nexthop hash entry list to zebra interface info
Add a nexthop hash entry list to the local zebra
interface info for each interface. This will allow
us to modify nexthops on link events.
Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
Diffstat (limited to 'zebra/interface.c')
-rw-r--r-- | zebra/interface.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/zebra/interface.c b/zebra/interface.c index ef03cf87f..6b77f3c87 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -53,6 +53,7 @@ #include "zebra/zebra_errors.h" DEFINE_MTYPE_STATIC(ZEBRA, ZINFO, "Zebra Interface Information") +DEFINE_MTYPE_STATIC(ZEBRA, NHE_CONNECTED, "Nexthops Connected") #define ZEBRA_PTM_SUPPORT @@ -120,6 +121,10 @@ static int if_zebra_new_hook(struct interface *ifp) zebra_if->multicast = IF_ZEBRA_MULTICAST_UNSPEC; zebra_if->shutdown = IF_ZEBRA_SHUTDOWN_OFF; + + zebra_if->nhe_connected = list_new(); + zebra_if->nhe_connected->del = (void (*)(void *))nhe_connected_free; + zebra_ptm_if_init(zebra_if); ifp->ptm_enable = zebra_ptm_get_enable_state(); @@ -196,6 +201,8 @@ static int if_zebra_delete_hook(struct interface *ifp) list_delete(&rtadv->AdvDNSSLList); #endif /* HAVE_RTADV */ + list_delete(&zebra_if->nhe_connected); + XFREE(MTYPE_TMP, zebra_if->desc); THREAD_OFF(zebra_if->speed_update); @@ -925,6 +932,51 @@ static void if_down_del_nbr_connected(struct interface *ifp) } } +/** + * nhe_connected_add() - Add the nexthop entry to the interfaces connected list + * + * @ifp: Interface to add to + * @nhe: Nexthop hash entry to add + * + * Return: nhe_connected struct created and added + */ +struct nhe_connected *nhe_connected_add(struct interface *ifp, + struct nhg_hash_entry *nhe) +{ + struct nhe_connected *if_nhec = NULL; + struct zebra_if *zif = (struct zebra_if *)ifp->info; + + if_nhec = nhe_connected_new(); + if_nhec->ifp = ifp; + + /* Attach the nhe */ + if_nhec->nhe = nhe; + + /* Add connected nexthop to the interface */ + listnode_add(zif->nhe_connected, if_nhec); + return if_nhec; +} + +/** + * nhe_connected() - Allocate nhe connected structure + * + * Return: Allocated nhe_connected structure + */ +struct nhe_connected *nhe_connected_new(void) +{ + return XCALLOC(MTYPE_NHE_CONNECTED, sizeof(struct nhe_connected)); +} + +/** + * nhe_connected_free() - Free nhe_connected structure + * + * @nhe_connected: nhe_connected structure to free + */ +void nhe_connected_free(struct nhe_connected *connected) +{ + XFREE(MTYPE_NHE_CONNECTED, connected); +} + /* Interface is up. */ void if_up(struct interface *ifp) { @@ -1132,6 +1184,19 @@ static void nbr_connected_dump_vty(struct vty *vty, vty_out(vty, "\n"); } +/** + * nhe_connected_dump() - Dump nexthops connected to this interface to vty + * + * @vty: Vty output + * @nhe_connected: List of connected nexthop hash entries + */ +static void nhe_connected_dump_vty(struct vty *vty, + struct nhe_connected *connected) +{ + /* Just outputing ID for now. */ + vty_out(vty, " (%u)", connected->nhe->id); +} + static const char *zebra_ziftype_2str(zebra_iftype_t zif_type) { switch (zif_type) { @@ -1279,6 +1344,7 @@ static void if_dump_vty(struct vty *vty, struct interface *ifp) { struct connected *connected; struct nbr_connected *nbr_connected; + struct nhe_connected *nhe_connected; struct listnode *node; struct route_node *rn; struct zebra_if *zebra_if; @@ -1364,6 +1430,14 @@ static void if_dump_vty(struct vty *vty, struct interface *ifp) connected_dump_vty(vty, connected); } + if (listhead(zebra_if->nhe_connected)) { + vty_out(vty, " Nexthop IDs connected:"); + for (ALL_LIST_ELEMENTS_RO(zebra_if->nhe_connected, node, + nhe_connected)) + nhe_connected_dump_vty(vty, nhe_connected); + vty_out(vty, "\n"); + } + vty_out(vty, " Interface Type %s\n", zebra_ziftype_2str(zebra_if->zif_type)); if (IS_ZEBRA_IF_BRIDGE(ifp)) { |