]> git.proxmox.com Git - mirror_frr.git/blobdiff - nhrpd/nhrp_peer.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / nhrpd / nhrp_peer.c
index 51cae44bd1b2bd0f0593b53580beb1c6de196062..0c9d5ade3765a703814e210da86327e1f94f6feb 100644 (file)
@@ -1,10 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /* NHRP peer functions
  * Copyright (c) 2014-2015 Timo Teräs
- *
- * This file is free software: you may copy, redistribute and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -17,6 +13,7 @@
 #include "memory.h"
 #include "thread.h"
 #include "hash.h"
+#include "network.h"
 
 #include "nhrpd.h"
 #include "nhrp_protocol.h"
@@ -54,7 +51,7 @@ static void nhrp_peer_check_delete(struct nhrp_peer *p)
        XFREE(MTYPE_NHRP_PEER, p);
 }
 
-static int nhrp_peer_notify_up(struct thread *t)
+static void nhrp_peer_notify_up(struct thread *t)
 {
        struct nhrp_peer *p = THREAD_ARG(t);
        struct nhrp_vc *vc = p->vc;
@@ -68,8 +65,6 @@ static int nhrp_peer_notify_up(struct thread *t)
                notifier_call(&p->notifier_list, NOTIFY_PEER_UP);
                nhrp_peer_unref(p);
        }
-
-       return 0;
 }
 
 static void __nhrp_peer_check(struct nhrp_peer *p)
@@ -258,7 +253,7 @@ void nhrp_peer_unref(struct nhrp_peer *p)
        }
 }
 
-static int nhrp_peer_request_timeout(struct thread *t)
+static void nhrp_peer_request_timeout(struct thread *t)
 {
        struct nhrp_peer *p = THREAD_ARG(t);
        struct nhrp_vc *vc = p->vc;
@@ -267,7 +262,7 @@ static int nhrp_peer_request_timeout(struct thread *t)
 
 
        if (p->online)
-               return 0;
+               return;
 
        if (nifp->ipsec_fallback_profile && !p->prio
            && !p->fallback_requested) {
@@ -279,11 +274,9 @@ static int nhrp_peer_request_timeout(struct thread *t)
        } else {
                p->requested = p->fallback_requested = 0;
        }
-
-       return 0;
 }
 
-static int nhrp_peer_defer_vici_request(struct thread *t)
+static void nhrp_peer_defer_vici_request(struct thread *t)
 {
        struct nhrp_peer *p = THREAD_ARG(t);
        struct nhrp_vc *vc = p->vc;
@@ -304,7 +297,6 @@ static int nhrp_peer_defer_vici_request(struct thread *t)
                        (nifp->ipsec_fallback_profile && !p->prio) ? 15 : 30,
                        &p->t_fallback);
        }
-       return 0;
 }
 
 int nhrp_peer_check(struct nhrp_peer *p, int establish)
@@ -339,7 +331,7 @@ int nhrp_peer_check(struct nhrp_peer *p, int establish)
                        &p->t_fallback);
        } else {
                /* Maximum timeout is 1 second */
-               int r_time_ms = rand() % 1000;
+               int r_time_ms = frr_weak_random() % 1000;
 
                debugf(NHRP_DEBUG_COMMON,
                       "Initiating IPsec connection request to %pSU after %d ms:",
@@ -1088,7 +1080,6 @@ err:
 
 static void nhrp_packet_debug(struct zbuf *zb, const char *dir)
 {
-       char buf[2][SU_ADDRSTRLEN];
        union sockunion src_nbma, src_proto, dst_proto;
        struct nhrp_packet_header *hdr;
        struct zbuf zhdr;
@@ -1100,14 +1091,12 @@ static void nhrp_packet_debug(struct zbuf *zb, const char *dir)
        zbuf_init(&zhdr, zb->buf, zb->tail - zb->buf, zb->tail - zb->buf);
        hdr = nhrp_packet_pull(&zhdr, &src_nbma, &src_proto, &dst_proto);
 
-       sockunion2str(&src_proto, buf[0], sizeof(buf[0]));
-       sockunion2str(&dst_proto, buf[1], sizeof(buf[1]));
-
        reply = packet_types[hdr->type].type == PACKET_REPLY;
-       debugf(NHRP_DEBUG_COMMON, "%s %s(%d) %s -> %s", dir,
+       debugf(NHRP_DEBUG_COMMON, "%s %s(%d) %pSU -> %pSU", dir,
               (packet_types[hdr->type].name ? packet_types[hdr->type].name
                                             : "Unknown"),
-              hdr->type, reply ? buf[1] : buf[0], reply ? buf[0] : buf[1]);
+              hdr->type, reply ? &dst_proto : &src_proto,
+              reply ? &src_proto : &dst_proto);
 }
 
 static int proto2afi(uint16_t proto)