Custom nhrp patches

This commit is contained in:
2024-05-19 21:51:40 +02:00
parent 9d79f89e3c
commit b72719fb5c
3 changed files with 144 additions and 2 deletions

View File

@@ -0,0 +1,49 @@
From 114bd532ac0c3b6d819f516eb41021eb250b65bd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zoran=20Peri=C4=8Di=C4=87?= <zpericic@netst.org>
Date: Wed, 15 Sep 2021 19:44:56 +0200
Subject: [PATCH 10/11] nhrpd, zebra: Read GRE addresses only if sent
GRE addresses are not send if interface is missing in kernel. We
should first check if they have been sent.
---
nhrpd/nhrp_route.c | 7 ++++---
zebra/zapi_msg.c | 2 --
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/nhrpd/nhrp_route.c b/nhrpd/nhrp_route.c
index 698c6d0cdf..2e7923bf33 100644
--- a/nhrpd/nhrp_route.c
+++ b/nhrpd/nhrp_route.c
@@ -493,12 +493,13 @@ int nhrp_gre_update(ZAPI_CALLBACK_ARGS)
STREAM_GETL(s, gre_info.okey);
STREAM_GETL(s, gre_info.ifindex_link);
STREAM_GETL(s, gre_info.vrfid_link);
- STREAM_GETL(s, gre_info.vtep_ip.s_addr);
- STREAM_GETL(s, gre_info.vtep_ip_remote.s_addr);
if (gre_info.ifindex == IFINDEX_INTERNAL)
val = NULL;
- else
+ else {
val = hash_lookup(nhrp_gre_list, &gre_info);
+ STREAM_GETL(s, gre_info.vtep_ip.s_addr);
+ STREAM_GETL(s, gre_info.vtep_ip_remote.s_addr);
+ }
if (val) {
if (gre_info.vtep_ip.s_addr != val->vtep_ip.s_addr ||
gre_info.vrfid_link != val->vrfid_link ||
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c
index 68bb9783f8..72d06d71ea 100644
--- a/zebra/zapi_msg.c
+++ b/zebra/zapi_msg.c
@@ -3618,8 +3618,6 @@ static inline void zebra_gre_get(ZAPI_HANDLER_ARGS)
stream_putl(s, 0);
stream_putl(s, IFINDEX_INTERNAL);
stream_putl(s, VRF_UNKNOWN);
- stream_putl(s, 0);
- stream_putl(s, 0);
}
/* Write packet size. */
stream_putw_at(s, 0, stream_get_endp(s));
--
2.41.0

View File

@@ -0,0 +1,92 @@
From f9876d6106263632287fcef2912ba4223b145672 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zoran=20Peri=C4=8Di=C4=87?= <zpericic@netst.org>
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

View File

@@ -1,4 +1,4 @@
%global dist .ims.1%{?dist}
%global dist .ims.2%{?dist}
%global frr_libdir %{_libexecdir}/frr
@@ -28,7 +28,8 @@ Patch0002: 0002-enable-openssl.patch
Patch0003: 0003-disable-eigrp-crypto.patch
Patch0004: 0004-fips-mode.patch
Patch0005: 0005-remove-grpc-test.patch
Patch0010: 0010-nhrpd-zebra-Read-GRE-addresses-only-if-sent.patch
Patch0011: 0011-nhrp-Peer-should-not-be-connected-if-interface-is-ac.patch
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: bison >= 2.7