]> git.puffer.fish Git - mirror/frr.git/commitdiff
nhrpd: Change sockunion2str to %pSU in a few places 8153/head
authorReuben Dowle <reuben.dowle@4rf.com>
Wed, 7 Apr 2021 20:30:57 +0000 (08:30 +1200)
committerReuben Dowle <reuben.dowle@4rf.com>
Wed, 7 Apr 2021 20:45:51 +0000 (08:45 +1200)
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
nhrpd/nhrp_multicast.c
nhrpd/nhrp_vty.c

index 93e92e79b30be3df75498539e069640d62687068..b78afda2c40bfbe7ab7636aa3e96b889fe1e7434 100644 (file)
@@ -41,7 +41,6 @@ struct mcast_ctx {
 
 static void nhrp_multicast_send(struct nhrp_peer *p, struct zbuf *zb)
 {
-       char buf[2][256];
        size_t addrlen;
        int ret;
 
@@ -51,10 +50,9 @@ static void nhrp_multicast_send(struct nhrp_peer *p, struct zbuf *zb)
                         addrlen == 4 ? ETH_P_IP : ETH_P_IPV6);
 
        debugf(NHRP_DEBUG_COMMON,
-              "Multicast Packet: %s -> %s, ret = %d, size = %zu, addrlen = %zu",
-              sockunion2str(&p->vc->local.nbma, buf[0], sizeof(buf[0])),
-              sockunion2str(&p->vc->remote.nbma, buf[1], sizeof(buf[1])), ret,
-              zbuf_used(zb), addrlen);
+              "Multicast Packet: %pSU -> %pSU, ret = %d, size = %zu, addrlen = %zu",
+              &p->vc->local.nbma, &p->vc->remote.nbma, ret, zbuf_used(zb),
+              addrlen);
 }
 
 static void nhrp_multicast_forward_nbma(union sockunion *nbma_addr,
@@ -232,7 +230,6 @@ int nhrp_multicast_add(struct interface *ifp, afi_t afi,
 {
        struct nhrp_interface *nifp = ifp->info;
        struct nhrp_multicast *mcast;
-       char buf[SU_ADDRSTRLEN];
 
        list_for_each_entry(mcast, &nifp->afi[afi].mcastlist_head, list_entry)
        {
@@ -247,8 +244,7 @@ int nhrp_multicast_add(struct interface *ifp, afi_t afi,
        };
        list_add_tail(&mcast->list_entry, &nifp->afi[afi].mcastlist_head);
 
-       sockunion2str(nbma_addr, buf, sizeof(buf));
-       debugf(NHRP_DEBUG_COMMON, "Adding multicast entry (%s)", buf);
+       debugf(NHRP_DEBUG_COMMON, "Adding multicast entry (%pSU)", nbma_addr);
 
        return NHRP_OK;
 }
@@ -258,7 +254,6 @@ int nhrp_multicast_del(struct interface *ifp, afi_t afi,
 {
        struct nhrp_interface *nifp = ifp->info;
        struct nhrp_multicast *mcast, *tmp;
-       char buf[SU_ADDRSTRLEN];
 
        list_for_each_entry_safe(mcast, tmp, &nifp->afi[afi].mcastlist_head,
                                 list_entry)
@@ -266,8 +261,8 @@ int nhrp_multicast_del(struct interface *ifp, afi_t afi,
                if (!sockunion_same(&mcast->nbma_addr, nbma_addr))
                        continue;
 
-               sockunion2str(nbma_addr, buf, sizeof(buf));
-               debugf(NHRP_DEBUG_COMMON, "Deleting multicast entry (%s)", buf);
+               debugf(NHRP_DEBUG_COMMON, "Deleting multicast entry (%pSU)",
+                      nbma_addr);
 
                nhrp_multicast_free(ifp, mcast);
 
index 48365bafb36422ecbb767a028bcee5210ba9ddf9..420ea12ec1e23c9771370a11aaee54af9d216ed0 100644 (file)
@@ -1127,16 +1127,15 @@ static void interface_config_write_nhrp_map(struct nhrp_cache_config *c,
 {
        struct write_map_ctx *ctx = data;
        struct vty *vty = ctx->vty;
-       char buf[2][SU_ADDRSTRLEN];
 
        if (sockunion_family(&c->remote_addr) != ctx->family)
                return;
 
-       vty_out(vty, " %s nhrp map %s %s\n", ctx->aficmd,
-               sockunion2str(&c->remote_addr, buf[0], sizeof(buf[0])),
-               c->type == NHRP_CACHE_LOCAL
-                       ? "local"
-                       : sockunion2str(&c->nbma, buf[1], sizeof(buf[1])));
+       vty_out(vty, " %s nhrp map %pSU ", ctx->aficmd, &c->remote_addr);
+       if (c->type == NHRP_CACHE_LOCAL)
+               vty_out(vty, "local\n");
+       else
+               vty_out(vty, "%pSU\n", &c->nbma);
 }
 
 static int interface_config_write(struct vty *vty)
@@ -1149,7 +1148,6 @@ static int interface_config_write(struct vty *vty)
        struct nhrp_multicast *mcast;
        const char *aficmd;
        afi_t afi;
-       char buf[SU_ADDRSTRLEN];
        int i;
 
        FOR_ALL_INTERFACES (vrf, ifp) {
@@ -1206,28 +1204,25 @@ static int interface_config_write(struct vty *vty)
                        list_for_each_entry(nhs, &ad->nhslist_head,
                                            nhslist_entry)
                        {
-                               vty_out(vty, " %s nhrp nhs %s nbma %s\n",
-                                       aficmd,
-                                       sockunion_family(&nhs->proto_addr)
-                                                       == AF_UNSPEC
-                                               ? "dynamic"
-                                               : sockunion2str(
-                                                         &nhs->proto_addr, buf,
-                                                         sizeof(buf)),
-                                       nhs->nbma_fqdn);
+                               vty_out(vty, " %s nhrp nhs ", aficmd);
+                               if (sockunion_family(&nhs->proto_addr)
+                                  == AF_UNSPEC)
+                                       vty_out(vty, "dynamic");
+                               else
+                                       vty_out(vty, "%pSU", &nhs->proto_addr);
+                               vty_out(vty, "nbma %s\n", nhs->nbma_fqdn);
                        }
 
                        list_for_each_entry(mcast, &ad->mcastlist_head,
                                            list_entry)
                        {
-                               vty_out(vty, " %s nhrp map multicast %s\n",
-                                       aficmd,
-                                       sockunion_family(&mcast->nbma_addr)
-                                                       == AF_UNSPEC
-                                               ? "dynamic"
-                                               : sockunion2str(
-                                                         &mcast->nbma_addr,
-                                                         buf, sizeof(buf)));
+                               vty_out(vty, " %s nhrp map multicast ", aficmd);
+                               if (sockunion_family(&mcast->nbma_addr)
+                                  == AF_UNSPEC)
+                                       vty_out(vty, "dynamic\n");
+                               else
+                                       vty_out(vty, "%pSU\n",
+                                               &mcast->nbma_addr);
                        }
                }