]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/rfapi/rfapi.c
Merge pull request #13139 from ribarroetavena/master
[mirror_frr.git] / bgpd / rfapi / rfapi.c
index f0e68d7f3f83aef3210f197bf1eed039c489a3d1..8d6db9d7759d709763f53ec4a0d4b7c504d02b74 100644 (file)
@@ -1,21 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  *
  * Copyright 2009-2016, LabN Consulting, L.L.C.
  *
- *
- * This program is free software; you can redistribute it 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.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include "lib/zebra.h"
@@ -362,7 +349,6 @@ void del_vnc_route(struct rfapi_descriptor *rfd,
        afi_t afi; /* of the VN address */
        struct bgp_dest *bn;
        struct bgp_path_info *bpi;
-       char buf2[RD_ADDRSTRLEN];
        struct prefix_rd prd0;
 
        afi = family2afi(p->family);
@@ -377,9 +363,9 @@ void del_vnc_route(struct rfapi_descriptor *rfd,
        bn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, p, prd);
 
        vnc_zlog_debug_verbose(
-               "%s: peer=%p, prefix=%pFX, prd=%s afi=%d, safi=%d bn=%p, bn->info=%p",
-               __func__, peer, p, prefix_rd2str(prd, buf2, sizeof(buf2)), afi,
-               safi, bn, (bn ? bgp_dest_get_bgp_path_info(bn) : NULL));
+               "%s: peer=%p, prefix=%pFX, prd=%pRDP afi=%d, safi=%d bn=%p, bn->info=%p",
+               __func__, peer, p, prd, afi, safi, bn,
+               (bn ? bgp_dest_get_bgp_path_info(bn) : NULL));
 
        for (bpi = (bn ? bgp_dest_get_bgp_path_info(bn) : NULL); bpi;
             bpi = bpi->next) {
@@ -577,7 +563,6 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */
 
        struct bgp_attr_encap_subtlv *encaptlv;
        char buf[PREFIX_STRLEN];
-       char buf2[RD_ADDRSTRLEN];
 
        struct rfapi_nexthop *lnh = NULL; /* local nexthop */
        struct rfapi_vn_option *vo;
@@ -616,8 +601,6 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */
        else
                label_val = MPLS_LABEL_IMPLICIT_NULL;
 
-       prefix_rd2str(prd, buf2, sizeof(buf2));
-
        afi = family2afi(p->family);
        assert(afi == AFI_IP || afi == AFI_IP6);
 
@@ -1006,7 +989,7 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */
                                bgp_aggregate_decrement(bgp, p, bpi, afi, safi);
                        bgp_attr_unintern(&bpi->attr);
                        bpi->attr = new_attr;
-                       bpi->uptime = bgp_clock();
+                       bpi->uptime = monotime(NULL);
 
 
                        if (safi == SAFI_MPLS_VPN) {
@@ -1070,8 +1053,8 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */
        bgp_process(bgp, bn, afi, safi);
 
        vnc_zlog_debug_any(
-               "%s: Added route (safi=%s) at prefix %s (bn=%p, prd=%s)",
-               __func__, safi2str(safi), buf, bn, buf2);
+               "%s: Added route (safi=%s) at prefix %s (bn=%p, prd=%pRDP)",
+               __func__, safi2str(safi), buf, bn, prd);
 
 done:
        /* Loop back to import tables */
@@ -1258,7 +1241,7 @@ static int rfapi_open_inner(struct rfapi_descriptor *rfd, struct bgp *bgp,
         * since this peer is not on the I/O thread, this lock is not strictly
         * necessary, but serves as a reminder to those who may meddle...
         */
-       frr_with_mutex(&rfd->peer->io_mtx) {
+       frr_with_mutex (&rfd->peer->io_mtx) {
                // we don't need any I/O related facilities
                if (rfd->peer->ibuf)
                        stream_fifo_free(rfd->peer->ibuf);
@@ -1277,13 +1260,15 @@ static int rfapi_open_inner(struct rfapi_descriptor *rfd, struct bgp *bgp,
        }
 
        { /* base code assumes have valid host pointer */
-               char buf[BUFSIZ];
+               char buf[INET6_ADDRSTRLEN];
                buf[0] = 0;
 
                if (rfd->vn_addr.addr_family == AF_INET) {
-                       inet_ntop(AF_INET, &rfd->vn_addr.addr.v4, buf, BUFSIZ);
+                       inet_ntop(AF_INET, &rfd->vn_addr.addr.v4, buf,
+                                 sizeof(buf));
                } else if (rfd->vn_addr.addr_family == AF_INET6) {
-                       inet_ntop(AF_INET6, &rfd->vn_addr.addr.v6, buf, BUFSIZ);
+                       inet_ntop(AF_INET6, &rfd->vn_addr.addr.v6, buf,
+                                 sizeof(buf));
                }
                rfd->peer->host = XSTRDUP(MTYPE_BGP_PEER_HOST, buf);
        }
@@ -1351,8 +1336,7 @@ int rfapi_init_and_open(struct bgp *bgp, struct rfapi_descriptor *rfd,
        struct prefix pfx_un;
        struct agg_node *rn;
 
-
-       rfapi_time(&rfd->open_time);
+       rfd->open_time = monotime(NULL);
 
        if (rfg->type == RFAPI_GROUP_CFG_VRF)
                SET_FLAG(rfd->flags, RFAPI_HD_FLAG_IS_VRF);
@@ -1521,10 +1505,10 @@ rfapi_query_inner(void *handle, struct rfapi_ip_addr *target,
        }
 
        rfd->rsp_counter++;               /* dedup: identify this generation */
-       rfd->rsp_time = rfapi_time(NULL); /* response content dedup */
+       rfd->rsp_time = monotime(NULL);   /* response content dedup */
        rfd->ftd_last_allowed_time =
-               bgp_clock()
-               bgp->rfapi_cfg->rfp_cfg.ftd_advertisement_interval;
+               monotime(NULL) -
+               bgp->rfapi_cfg->rfp_cfg.ftd_advertisement_interval;
 
        if (l2o) {
                if (!memcmp(l2o->macaddr.octet, rfapi_ethaddr0.octet,
@@ -3078,7 +3062,7 @@ DEFUN (debug_rfapi_register_vn_un,
 
 DEFUN (debug_rfapi_register_vn_un_l2o,
        debug_rfapi_register_vn_un_l2o_cmd,
-       "debug rfapi-dev register vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> prefix <A.B.C.D/M|X:X::X:X/M> lifetime SECONDS macaddr YY:YY:YY:YY:YY:YY lni (0-16777215)",
+       "debug rfapi-dev register vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> prefix <A.B.C.D/M|X:X::X:X/M> lifetime SECONDS macaddr X:X:X:X:X:X lni (0-16777215)",
        DEBUG_STR
        DEBUG_RFAPI_STR
        "rfapi_register\n"
@@ -3179,13 +3163,17 @@ DEFUN (debug_rfapi_unregister_vn_un,
        "debug rfapi-dev unregister vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> prefix <A.B.C.D/M|X:X::X:X/M> [kill]",
        DEBUG_STR
        DEBUG_RFAPI_STR
-       "rfapi_register\n"
+       "rfapi_unregister\n"
        "indicate vn addr follows\n"
        "virtual network interface address\n"
+       "virtual network interface address\n"
        "indicate xt addr follows\n"
        "underlay network interface address\n"
+       "underlay network interface address\n"
+       "prefix to remove\n"
        "prefix to remove\n"
-       "Remove without holddown")
+       "prefix to remove\n"
+       "Remove without holddown\n")
 {
        struct rfapi_ip_addr vn;
        struct rfapi_ip_addr un;
@@ -3200,7 +3188,6 @@ DEFUN (debug_rfapi_unregister_vn_un,
        if ((rc = rfapiCliGetRfapiIpAddr(vty, argv[4]->arg, &vn)))
                return rc;
 
-
        /*
         * Get UN addr
         */
@@ -3306,7 +3293,7 @@ DEFUN (debug_rfapi_query_vn_un,
 
 DEFUN (debug_rfapi_query_vn_un_l2o,
        debug_rfapi_query_vn_un_l2o_cmd,
-       "debug rfapi-dev query vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> lni LNI target YY:YY:YY:YY:YY:YY",
+       "debug rfapi-dev query vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> lni LNI target X:X:X:X:X:X",
        DEBUG_STR
        DEBUG_RFAPI_STR
        "rfapi_query\n"
@@ -3725,12 +3712,7 @@ int rfapi_set_autord_from_vn(struct prefix_rd *rd, struct rfapi_ip_addr *vn)
                memcpy(rd->val + 2, &vn->addr.v6.s6_addr32[3],
                       4); /* low order 4 bytes */
        }
-       {
-               char buf[RD_ADDRSTRLEN];
-
-               vnc_zlog_debug_verbose("%s: auto-RD is set to %s", __func__,
-                                      prefix_rd2str(rd, buf, sizeof(buf)));
-       }
+       vnc_zlog_debug_verbose("%s: auto-RD is set to %pRDP", __func__, rd);
        return 0;
 }