From f9876d6106263632287fcef2912ba4223b145672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zoran=20Peri=C4=8Di=C4=87?= Date: Mon, 20 Sep 2021 23:51:06 +0200 Subject: [PATCH 11/11] nhrp: Peer should not be connected if interface is active --- nhrpd/nhrp_interface.c | 1 + nhrpd/nhrp_nhs.c | 21 +++++++++++++++++++-- nhrpd/nhrp_peer.c | 2 ++ nhrpd/nhrpd.h | 1 + 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/nhrpd/nhrp_interface.c b/nhrpd/nhrp_interface.c index 4ac30a7d75..6a8b6e6997 100644 --- a/nhrpd/nhrp_interface.c +++ b/nhrpd/nhrp_interface.c @@ -461,6 +461,7 @@ int nhrp_ifp_up(struct interface *ifp) { debugf(NHRP_DEBUG_IF, "if-up: %s", ifp->name); nhrp_interface_update_nbma(ifp, NULL); + nhrp_nhs_interface_add(ifp); return 0; } diff --git a/nhrpd/nhrp_nhs.c b/nhrpd/nhrp_nhs.c index 03b4b533bb..bd05813d28 100644 --- a/nhrpd/nhrp_nhs.c +++ b/nhrpd/nhrp_nhs.c @@ -351,8 +351,9 @@ int nhrp_nhs_add(struct interface *ifp, afi_t afi, union sockunion *proto_addr, .reglist_head = INIT_DLIST(nhs->reglist_head), }; nhrp_nhslist_add_tail(&nifp->afi[afi].nhslist_head, nhs); - thread_add_timer_msec(master, nhrp_nhs_resolve, nhs, 1000, - &nhs->t_resolve); + if (CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_ACTIVE)) + thread_add_timer_msec(master, nhrp_nhs_resolve, nhs, 1000, + &nhs->t_resolve); return NHRP_OK; } @@ -394,6 +395,22 @@ int nhrp_nhs_free(struct nhrp_interface *nifp, afi_t afi, struct nhrp_nhs *nhs) return 0; } +void nhrp_nhs_interface_add(struct interface *ifp) +{ + struct nhrp_interface *nifp = ifp->info; + struct nhrp_nhs *nhs; + afi_t afi; + + for (afi = 0; afi < AFI_MAX; afi++) { + debugf(NHRP_DEBUG_COMMON, "Adding nhs entries (%zu)", + nhrp_nhslist_count(&nifp->afi[afi].nhslist_head)); + frr_each (nhrp_nhslist, &nifp->afi[afi].nhslist_head, nhs) { + thread_add_timer_msec(master, nhrp_nhs_resolve, nhs, 1000, + &nhs->t_resolve); + } + } +} + void nhrp_nhs_interface_del(struct interface *ifp) { struct nhrp_interface *nifp = ifp->info; diff --git a/nhrpd/nhrp_peer.c b/nhrpd/nhrp_peer.c index e7f2eaf5a7..9e76d16db3 100644 --- a/nhrpd/nhrp_peer.c +++ b/nhrpd/nhrp_peer.c @@ -309,6 +309,8 @@ int nhrp_peer_check(struct nhrp_peer *p, int establish) struct interface *ifp = p->ifp; struct nhrp_interface *nifp = ifp->info; + if (!CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_ACTIVE)) + return 0; if (p->online) return 1; if (!establish) diff --git a/nhrpd/nhrpd.h b/nhrpd/nhrpd.h index 753c6e9b22..4850c12b49 100644 --- a/nhrpd/nhrpd.h +++ b/nhrpd/nhrpd.h @@ -400,6 +400,7 @@ void nhrp_nhs_foreach(struct interface *ifp, afi_t afi, void (*cb)(struct nhrp_nhs *, struct nhrp_registration *, void *), void *ctx); +void nhrp_nhs_interface_add(struct interface *ifp); void nhrp_nhs_interface_del(struct interface *ifp); int nhrp_multicast_add(struct interface *ifp, afi_t afi, -- 2.41.0