]> git.proxmox.com Git - mirror_frr.git/blobdiff - ldpd/hello.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / ldpd / hello.c
index caf63c13d7b959b08ba682691ff90a901106764a..83c0b2f8ca00c981a571a090bf5f45df18d617ee 100644 (file)
@@ -1,20 +1,9 @@
+// SPDX-License-Identifier: ISC
 /*     $OpenBSD$ */
 
 /*
  * Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
  * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
 #include <zebra.h>
@@ -67,7 +56,8 @@ send_hello(enum hello_type type, struct iface_af *ia, struct tnbr *tnbr)
                af = tnbr->af;
                holdtime = tnbr_get_hello_holdtime(tnbr);
                flags = F_HELLO_TARGETED;
-               if ((tnbr->flags & F_TNBR_CONFIGURED) || tnbr->pw_count)
+               if ((tnbr->flags & F_TNBR_CONFIGURED) || tnbr->pw_count
+                   || tnbr->rlfa_count)
                        flags |= F_HELLO_REQ_TARG;
                fd = (ldp_af_global_get(&global, af))->ldp_edisc_socket;
 
@@ -179,24 +169,24 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *msg, int af,
 
        r = tlv_decode_hello_prms(buf, len, &holdtime, &flags);
        if (r == -1) {
-               log_debug("%s: lsr-id %s: failed to decode params", __func__,
-                   inet_ntoa(lsr_id));
+               log_debug("%s: lsr-id %pI4: failed to decode params", __func__,
+                   &lsr_id);
                return;
        }
        /* safety checks */
        if (holdtime != 0 && holdtime < MIN_HOLDTIME) {
-               log_debug("%s: lsr-id %s: invalid hello holdtime (%u)",
-                   __func__, inet_ntoa(lsr_id), holdtime);
+               log_debug("%s: lsr-id %pI4: invalid hello holdtime (%u)",
+                   __func__, &lsr_id, holdtime);
                return;
        }
        if (multicast && (flags & F_HELLO_TARGETED)) {
-               log_debug("%s: lsr-id %s: multicast targeted hello", __func__,
-                   inet_ntoa(lsr_id));
+               log_debug("%s: lsr-id %pI4: multicast targeted hello", __func__,
+                   &lsr_id);
                return;
        }
        if (!multicast && !((flags & F_HELLO_TARGETED))) {
-               log_debug("%s: lsr-id %s: unicast link hello", __func__,
-                   inet_ntoa(lsr_id));
+               log_debug("%s: lsr-id %pI4: unicast link hello", __func__,
+                   &lsr_id);
                return;
        }
        buf += r;
@@ -205,13 +195,13 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *msg, int af,
        r = tlv_decode_opt_hello_prms(buf, len, &tlvs_rcvd, af, &trans_addr,
            &conf_seqnum, &trans_pref);
        if (r == -1) {
-               log_debug("%s: lsr-id %s: failed to decode optional params",
-                   __func__, inet_ntoa(lsr_id));
+               log_debug("%s: lsr-id %pI4: failed to decode optional params",
+                   __func__, &lsr_id);
                return;
        }
        if (r != len) {
-               log_debug("%s: lsr-id %s: unexpected data in message",
-                   __func__, inet_ntoa(lsr_id));
+               log_debug("%s: lsr-id %pI4: unexpected data in message",
+                   __func__, &lsr_id);
                return;
        }
        ds_tlv = (tlvs_rcvd & F_HELLO_TLV_RCVD_DS) ? 1 : 0;
@@ -220,8 +210,8 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *msg, int af,
        if (!(tlvs_rcvd & F_HELLO_TLV_RCVD_ADDR))
                trans_addr = *src;
        if (bad_addr(af, &trans_addr)) {
-               log_debug("%s: lsr-id %s: invalid transport address %s",
-                   __func__, inet_ntoa(lsr_id), log_addr(af, &trans_addr));
+               log_debug("%s: lsr-id %pI4: invalid transport address %s",
+                   __func__, &lsr_id, log_addr(af, &trans_addr));
                return;
        }
        if (af == AF_INET6 && IN6_IS_SCOPE_EMBED(&trans_addr.v6)) {
@@ -234,7 +224,7 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *msg, int af,
                 * check)".
                 */
                if (flags & F_HELLO_TARGETED) {
-                       log_debug("%s: lsr-id %s: invalid targeted hello transport address %s", __func__, inet_ntoa(lsr_id),
+                       log_debug("%s: lsr-id %pI4: invalid targeted hello transport address %s", __func__, &lsr_id,
                             log_addr(af, &trans_addr));
                        return;
                }
@@ -249,8 +239,8 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *msg, int af,
                * targeted LDP Hello packet's source or destination addresses".
                */
                if (af == AF_INET6 && IN6_IS_SCOPE_EMBED(&src->v6)) {
-                       log_debug("%s: lsr-id %s: targeted hello with link-local source address", __func__,
-                           inet_ntoa(lsr_id));
+                       log_debug("%s: lsr-id %pI4: targeted hello with link-local source address", __func__,
+                           &lsr_id);
                        return;
                }
 
@@ -290,8 +280,8 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *msg, int af,
                source.link.src_addr = *src;
        }
 
-       debug_hello_recv("%s lsr-id %s transport-address %s holdtime %u%s",
-           log_hello_src(&source), inet_ntoa(lsr_id), log_addr(af, &trans_addr),
+       debug_hello_recv("%s lsr-id %pI4 transport-address %s holdtime %u%s",
+           log_hello_src(&source), &lsr_id, log_addr(af, &trans_addr),
             holdtime, (ds_tlv) ? " (dual stack TLV present)" : "");
 
        adj = adj_find(lsr_id, &source);
@@ -316,7 +306,7 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *msg, int af,
                 * send a fatal Notification message with status code of
                 * 'Transport Connection Mismatch' and reset the session".
                 */
-               log_debug("%s: lsr-id %s: remote transport preference does not match the local preference", __func__, inet_ntoa(lsr_id));
+               log_debug("%s: lsr-id %pI4: remote transport preference does not match the local preference", __func__, &lsr_id);
                if (nbr)
                        session_shutdown(nbr, S_TRANS_MISMTCH, msg->id,
                            msg->type);
@@ -356,7 +346,7 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *msg, int af,
        if (nbr && nbr->af == af &&
            (ldp_addrcmp(af, &nbr->raddr, &trans_addr) ||
            nbr->raddr_scope != scope_id)) {
-               log_warnx("%s: lsr-id %s: hello packet advertising a different transport address", __func__, inet_ntoa(lsr_id));
+               log_warnx("%s: lsr-id %pI4: hello packet advertising a different transport address", __func__, &lsr_id);
                if (adj)
                        adj_del(adj, S_SHUTDOWN);
                return;
@@ -364,8 +354,8 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *msg, int af,
        if (nbr == NULL) {
                nbrt = nbr_find_addr(af, &trans_addr);
                if (nbrt) {
-                       log_debug("%s: transport address %s is already being used by lsr-id %s", __func__, log_addr(af,
-                           &trans_addr), inet_ntoa(nbrt->id));
+                       log_debug("%s: transport address %s is already being used by lsr-id %pI4", __func__, log_addr(af,
+                           &trans_addr), &nbrt->id);
                        if (adj)
                                adj_del(adj, S_SHUTDOWN);
                        return;
@@ -414,13 +404,13 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *msg, int af,
                if (holdtime == 0)
                        holdtime = LINK_DFLT_HOLDTIME;
 
-               adj->holdtime = min(if_get_hello_holdtime(ia), holdtime);
+               adj->holdtime = MIN(if_get_hello_holdtime(ia), holdtime);
                break;
        case HELLO_TARGETED:
                if (holdtime == 0)
                        holdtime = TARGETED_DFLT_HOLDTIME;
 
-               adj->holdtime = min(tnbr_get_hello_holdtime(tnbr), holdtime);
+               adj->holdtime = MIN(tnbr_get_hello_holdtime(tnbr), holdtime);
        }
        if (adj->holdtime != INFINITE_HOLDTIME)
                adj_start_itimer(adj);