summaryrefslogtreecommitdiffstats
path: root/nhrpd
diff options
context:
space:
mode:
authorReuben Dowle <reuben.dowle@4rf.com>2021-03-15 05:03:58 +0100
committerReuben Dowle <reuben.dowle@4rf.com>2021-03-18 21:31:45 +0100
commit00683a1479c4cfee2060aba864532da8d7cd6b2e (patch)
tree7e2bc6c063afcc49d1483f6f3a9f97b54b5aadfa /nhrpd
parentnhrpd: Set prefix length in NAT extension in resolution-reply (diff)
downloadfrr-00683a1479c4cfee2060aba864532da8d7cd6b2e.tar.xz
frr-00683a1479c4cfee2060aba864532da8d7cd6b2e.zip
nhrpd: Fix some style issues
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
Diffstat (limited to 'nhrpd')
-rw-r--r--nhrpd/nhrp_nhs.c1
-rw-r--r--nhrpd/nhrp_peer.c77
-rw-r--r--nhrpd/nhrp_shortcut.c29
-rw-r--r--nhrpd/nhrp_vty.c14
4 files changed, 69 insertions, 52 deletions
diff --git a/nhrpd/nhrp_nhs.c b/nhrpd/nhrp_nhs.c
index 1e53c1659..5f8bbd702 100644
--- a/nhrpd/nhrp_nhs.c
+++ b/nhrpd/nhrp_nhs.c
@@ -476,6 +476,7 @@ int nhrp_nhs_match_ip(union sockunion *in_ip, struct nhrp_interface *nifp)
int i;
struct nhrp_nhs *nhs;
struct nhrp_registration *reg;
+
for (i = 0; i < AFI_MAX; i++) {
list_for_each_entry(nhs, &nifp->afi[i].nhslist_head,
nhslist_entry)
diff --git a/nhrpd/nhrp_peer.c b/nhrpd/nhrp_peer.c
index a4c93bd2a..d89e82b52 100644
--- a/nhrpd/nhrp_peer.c
+++ b/nhrpd/nhrp_peer.c
@@ -290,6 +290,7 @@ static int nhrp_peer_defer_vici_request(struct thread *t)
struct interface *ifp = p->ifp;
struct nhrp_interface *nifp = ifp->info;
char buf[SU_ADDRSTRLEN];
+
THREAD_OFF(p->t_timer);
if (p->online) {
@@ -341,7 +342,9 @@ int nhrp_peer_check(struct nhrp_peer *p, int establish)
(nifp->ipsec_fallback_profile && !p->prio) ? 15 : 30,
&p->t_fallback);
} else {
- int r_time_ms = rand() % 1000; // Maximum timeout is 1 seconds
+ /* Maximum timeout is 1 second */
+ int r_time_ms = rand() % 1000;
+
debugf(NHRP_DEBUG_COMMON,
"Initiating IPsec connection request to %s after %d ms:\n",
sockunion2str(&vc->remote.nbma, buf, sizeof(buf))
@@ -414,7 +417,8 @@ static void nhrp_process_nat_extension(struct nhrp_packet_parser *pp,
* extension and update the cache without which
* the neighbor table in the kernel contains the
* source NBMA address which is not reachable
- * since it is behind a NAT device */
+ * since it is behind a NAT device
+ */
if (!sockunion2str(proto, buf1, sizeof(buf1)))
strlcpy(buf1, "NULL", sizeof(buf1));
debugf(NHRP_DEBUG_COMMON,
@@ -506,19 +510,18 @@ static void nhrp_handle_resolution_req(struct nhrp_packet_parser *pp)
continue;
}
-
proto_addr = (sockunion_family(&cie_proto) == AF_UNSPEC)
? &pp->src_proto
: &cie_proto;
- /* Check if there is an entry for this proto_addr in
- * NHRP_NAT_EXTENSION */
+ /* Check for this proto_addr in NHRP_NAT_EXTENSION */
nhrp_process_nat_extension(pp, proto_addr, &cie_nbma_nat);
if (sockunion_family(&cie_nbma_nat) == AF_UNSPEC) {
/* It may be possible that this resolution reply is
* coming directly from NATTED Spoke and there is not
- * NAT Extension present */
+ * NAT Extension present
+ */
debugf(NHRP_DEBUG_COMMON, "No NAT Extension for %s",
sockunion2str(proto_addr, buf, sizeof(buf))
? buf
@@ -569,7 +572,6 @@ static void nhrp_handle_resolution_req(struct nhrp_packet_parser *pp)
if (nbma_addr)
sockunion2str(nbma_addr, buf, sizeof(buf));
-
debugf(NHRP_DEBUG_COMMON,
"shortcut res_rep: updating binding for nmba addr %s",
nbma_addr ? buf : "(NULL)");
@@ -961,7 +963,7 @@ static void nhrp_peer_forward(struct nhrp_peer *p,
union sockunion cie_nbma, cie_protocol, cie_protocol_mandatory,
*proto = NULL;
uint16_t type, len;
- struct nhrp_cache *c;
+ struct nhrp_cache *c = NULL;
char buf[SU_ADDRSTRLEN];
if (pp->hdr->hop_count == 0)
@@ -1037,7 +1039,8 @@ static void nhrp_peer_forward(struct nhrp_peer *p,
"Processing NHRP_EXTENSION_NAT_ADDRESS while forwarding the reply packet");
/* For reply packet use protocol
* specified in CIE of mandatory part
- * for cache lookup */
+ * for cache lookup
+ */
if (sockunion_family(
&cie_protocol_mandatory)
!= AF_UNSPEC)
@@ -1049,34 +1052,32 @@ static void nhrp_peer_forward(struct nhrp_peer *p,
sockunion2str(proto, buf,
sizeof(buf)));
c = nhrp_cache_get(nifp->ifp, proto, 0);
- if (c) {
- debugf(NHRP_DEBUG_COMMON,
- "c->cur.remote_nbma_natoa is %s",
- sockunion2str(
- &c->cur.remote_nbma_natoa,
- buf, sizeof(buf))
- ? buf
- : "NULL");
- if (sockunion_family(
- &c->cur.remote_nbma_natoa)
- != AF_UNSPEC) {
- cie = nhrp_cie_push(
- zb,
- NHRP_CODE_SUCCESS,
- &c->cur.remote_nbma_natoa,
- proto);
- if (!cie)
- goto err;
- }
- } else {
- debugf(NHRP_DEBUG_COMMON,
- "No cache entry for Proto is %s",
- sockunion2str(
- proto, buf,
- sizeof(buf)));
- zbuf_put(zb, extpl.head, len);
+ }
+
+ if (c) {
+ debugf(NHRP_DEBUG_COMMON,
+ "c->cur.remote_nbma_natoa is %s",
+ sockunion2str(
+ &c->cur.remote_nbma_natoa,
+ buf, sizeof(buf))
+ ? buf
+ : "NULL");
+ if (sockunion_family(
+ &c->cur.remote_nbma_natoa)
+ != AF_UNSPEC) {
+ cie = nhrp_cie_push(
+ zb,
+ NHRP_CODE_SUCCESS,
+ &c->cur.remote_nbma_natoa,
+ proto);
+ if (!cie)
+ goto err;
}
} else {
+ if (proto)
+ debugf(NHRP_DEBUG_COMMON,
+ "No cache entry for proto %s",
+ buf);
zbuf_put(zb, extpl.head, len);
}
}
@@ -1084,13 +1085,15 @@ static void nhrp_peer_forward(struct nhrp_peer *p,
default:
if (htons(ext->type) & NHRP_EXTENSION_FLAG_COMPULSORY)
/* FIXME: RFC says to just copy, but not
- * append our selves to the transit NHS list */
+ * append our selves to the transit NHS list
+ */
goto err;
/* fallthru */
case NHRP_EXTENSION_RESPONDER_ADDRESS:
/* Supported compulsory extensions, and any
* non-compulsory that is not explicitly handled,
- * should be just copied. */
+ * should be just copied.
+ */
zbuf_copy(zb, &extpl, len);
break;
}
diff --git a/nhrpd/nhrp_shortcut.c b/nhrpd/nhrp_shortcut.c
index cf4b5972c..dd6392237 100644
--- a/nhrpd/nhrp_shortcut.c
+++ b/nhrpd/nhrp_shortcut.c
@@ -211,7 +211,7 @@ static void nhrp_shortcut_recv_resolution_rep(struct nhrp_reqid *reqid,
struct nhrp_extension_header *ext;
struct nhrp_cie_header *cie;
struct nhrp_cache *c = NULL;
- struct nhrp_cache *c_dst_proto = NULL;
+ struct nhrp_cache *c_dst = NULL;
union sockunion *proto, cie_proto, *nbma, cie_nbma, nat_nbma;
struct prefix prefix, route_prefix;
struct zbuf extpl;
@@ -278,8 +278,10 @@ static void nhrp_shortcut_recv_resolution_rep(struct nhrp_reqid *reqid,
switch (htons(ext->type) & ~NHRP_EXTENSION_FLAG_COMPULSORY) {
case NHRP_EXTENSION_NAT_ADDRESS: {
struct nhrp_cie_header *cie_nat;
+
do {
union sockunion cie_nat_proto, cie_nat_nbma;
+
sockunion_family(&cie_nat_proto) = AF_UNSPEC;
sockunion_family(&cie_nat_nbma) = AF_UNSPEC;
cie_nat = nhrp_cie_pull(&extpl, pp->hdr,
@@ -307,7 +309,8 @@ static void nhrp_shortcut_recv_resolution_rep(struct nhrp_reqid *reqid,
nbma = &nat_nbma;
}
/* For NHRP resolution reply the cie_nbma in mandatory part is the
- * address of the actual address of the sender */
+ * address of the actual address of the sender
+ */
else if (!sockunion_same(&cie_nbma, &pp->peer->vc->remote.nbma)
&& !nhrp_nhs_match_ip(&pp->peer->vc->remote.nbma, nifp)) {
debugf(NHRP_DEBUG_COMMON,
@@ -316,7 +319,7 @@ static void nhrp_shortcut_recv_resolution_rep(struct nhrp_reqid *reqid,
debugf(NHRP_DEBUG_COMMON, "cie_nbma %s",
sockunion2str(&cie_nbma, buf[1], sizeof(buf[1])));
debugf(NHRP_DEBUG_COMMON, "remote.nbma %s",
- sockunion2str(&pp->peer->vc->remote.nbma, buf[1],
+ sockunion2str(&pp->peer->vc->remote.nbma, buf[1],
sizeof(buf[1])));
nbma = &pp->peer->vc->remote.nbma;
nat_nbma = *nbma;
@@ -338,7 +341,9 @@ static void nhrp_shortcut_recv_resolution_rep(struct nhrp_reqid *reqid,
nhrp_cache_update_binding(c, NHRP_CACHE_DYNAMIC,
holding_time,
nhrp_peer_get(pp->ifp, nbma),
- htons(cie->mtu), nbma, &cie_nbma);
+ htons(cie->mtu),
+ nbma,
+ &cie_nbma);
} else {
debugf(NHRP_DEBUG_COMMON,
"Shortcut: no cache for nbma %s", buf[2]);
@@ -346,17 +351,21 @@ static void nhrp_shortcut_recv_resolution_rep(struct nhrp_reqid *reqid,
/* Update cache binding for dst_proto as well */
if (sockunion_cmp(proto, &pp->dst_proto)) {
- c_dst_proto = nhrp_cache_get(pp->ifp, &pp->dst_proto, 1);
- if (c_dst_proto) {
+ c_dst = nhrp_cache_get(pp->ifp, &pp->dst_proto, 1);
+ if (c_dst) {
debugf(NHRP_DEBUG_COMMON,
- "Shortcut: cache found, update binding");
- nhrp_cache_update_binding(c_dst_proto, NHRP_CACHE_DYNAMIC,
+ "Shortcut: cache found, update binding");
+ nhrp_cache_update_binding(c_dst,
+ NHRP_CACHE_DYNAMIC,
holding_time,
nhrp_peer_get(pp->ifp, nbma),
- htons(cie->mtu), nbma, &cie_nbma);
+ htons(cie->mtu),
+ nbma,
+ &cie_nbma);
} else {
debugf(NHRP_DEBUG_COMMON,
- "Shortcut: no cache for nbma %s", buf[2]);
+ "Shortcut: no cache for nbma %s",
+ buf[2]);
}
}
}
diff --git a/nhrpd/nhrp_vty.c b/nhrpd/nhrp_vty.c
index a55903707..08900cfc6 100644
--- a/nhrpd/nhrp_vty.c
+++ b/nhrpd/nhrp_vty.c
@@ -565,7 +565,8 @@ DEFUN(if_no_nhrp_map, if_no_nhrp_map_cmd,
return CMD_SUCCESS;
nhrp_cache_update_binding(c, c->cur.type, -1,
- nhrp_peer_get(ifp, &nbma_addr), 0, NULL, NULL);
+ nhrp_peer_get(ifp, &nbma_addr), 0, NULL,
+ NULL);
return CMD_SUCCESS;
}
@@ -637,8 +638,9 @@ static void show_ip_nhrp_cache(struct nhrp_cache *c, void *pctx)
if (!ctx->count && !ctx->json) {
- vty_out(vty, "%-8s %-8s %-24s %-24s %-24s %-6s %s\n", "Iface", "Type",
- "Protocol", "NBMA", "Claimed NBMA", "Flags", "Identity");
+ vty_out(vty, "%-8s %-8s %-24s %-24s %-24s %-6s %s\n", "Iface",
+ "Type", "Protocol", "NBMA", "Claimed NBMA", "Flags",
+ "Identity");
}
ctx->count++;
@@ -649,7 +651,8 @@ static void show_ip_nhrp_cache(struct nhrp_cache *c, void *pctx)
else
snprintf(buf[1], sizeof(buf[1]), "-");
- if (c->cur.peer && sockunion_family(&c->cur.remote_nbma_claimed) != AF_UNSPEC)
+ if (c->cur.peer
+ && sockunion_family(&c->cur.remote_nbma_claimed) != AF_UNSPEC)
sockunion2str(&c->cur.remote_nbma_claimed,
buf[2], sizeof(buf[2]));
@@ -979,7 +982,8 @@ static void clear_nhrp_cache(struct nhrp_cache *c, void *data)
{
struct info_ctx *ctx = data;
if (c->cur.type <= NHRP_CACHE_DYNAMIC) {
- nhrp_cache_update_binding(c, c->cur.type, -1, NULL, 0, NULL, NULL);
+ nhrp_cache_update_binding(c, c->cur.type, -1, NULL, 0, NULL,
+ NULL);
ctx->count++;
}
}