nhrpd: Change sockunion2str to %pSU in a few places

Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
This commit is contained in:
Reuben Dowle 2021-04-08 08:30:57 +12:00
parent c2bb9917b1
commit 46d3c1859b
2 changed files with 25 additions and 35 deletions

View File

@ -41,7 +41,6 @@ struct mcast_ctx {
static void nhrp_multicast_send(struct nhrp_peer *p, struct zbuf *zb) static void nhrp_multicast_send(struct nhrp_peer *p, struct zbuf *zb)
{ {
char buf[2][256];
size_t addrlen; size_t addrlen;
int ret; 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); addrlen == 4 ? ETH_P_IP : ETH_P_IPV6);
debugf(NHRP_DEBUG_COMMON, debugf(NHRP_DEBUG_COMMON,
"Multicast Packet: %s -> %s, ret = %d, size = %zu, addrlen = %zu", "Multicast Packet: %pSU -> %pSU, ret = %d, size = %zu, addrlen = %zu",
sockunion2str(&p->vc->local.nbma, buf[0], sizeof(buf[0])), &p->vc->local.nbma, &p->vc->remote.nbma, ret, zbuf_used(zb),
sockunion2str(&p->vc->remote.nbma, buf[1], sizeof(buf[1])), ret, addrlen);
zbuf_used(zb), addrlen);
} }
static void nhrp_multicast_forward_nbma(union sockunion *nbma_addr, 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_interface *nifp = ifp->info;
struct nhrp_multicast *mcast; struct nhrp_multicast *mcast;
char buf[SU_ADDRSTRLEN];
list_for_each_entry(mcast, &nifp->afi[afi].mcastlist_head, list_entry) 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); list_add_tail(&mcast->list_entry, &nifp->afi[afi].mcastlist_head);
sockunion2str(nbma_addr, buf, sizeof(buf)); debugf(NHRP_DEBUG_COMMON, "Adding multicast entry (%pSU)", nbma_addr);
debugf(NHRP_DEBUG_COMMON, "Adding multicast entry (%s)", buf);
return NHRP_OK; 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_interface *nifp = ifp->info;
struct nhrp_multicast *mcast, *tmp; struct nhrp_multicast *mcast, *tmp;
char buf[SU_ADDRSTRLEN];
list_for_each_entry_safe(mcast, tmp, &nifp->afi[afi].mcastlist_head, list_for_each_entry_safe(mcast, tmp, &nifp->afi[afi].mcastlist_head,
list_entry) list_entry)
@ -266,8 +261,8 @@ int nhrp_multicast_del(struct interface *ifp, afi_t afi,
if (!sockunion_same(&mcast->nbma_addr, nbma_addr)) if (!sockunion_same(&mcast->nbma_addr, nbma_addr))
continue; continue;
sockunion2str(nbma_addr, buf, sizeof(buf)); debugf(NHRP_DEBUG_COMMON, "Deleting multicast entry (%pSU)",
debugf(NHRP_DEBUG_COMMON, "Deleting multicast entry (%s)", buf); nbma_addr);
nhrp_multicast_free(ifp, mcast); nhrp_multicast_free(ifp, mcast);

View File

@ -1127,16 +1127,15 @@ static void interface_config_write_nhrp_map(struct nhrp_cache_config *c,
{ {
struct write_map_ctx *ctx = data; struct write_map_ctx *ctx = data;
struct vty *vty = ctx->vty; struct vty *vty = ctx->vty;
char buf[2][SU_ADDRSTRLEN];
if (sockunion_family(&c->remote_addr) != ctx->family) if (sockunion_family(&c->remote_addr) != ctx->family)
return; return;
vty_out(vty, " %s nhrp map %s %s\n", ctx->aficmd, vty_out(vty, " %s nhrp map %pSU ", ctx->aficmd, &c->remote_addr);
sockunion2str(&c->remote_addr, buf[0], sizeof(buf[0])), if (c->type == NHRP_CACHE_LOCAL)
c->type == NHRP_CACHE_LOCAL vty_out(vty, "local\n");
? "local" else
: sockunion2str(&c->nbma, buf[1], sizeof(buf[1]))); vty_out(vty, "%pSU\n", &c->nbma);
} }
static int interface_config_write(struct vty *vty) static int interface_config_write(struct vty *vty)
@ -1149,7 +1148,6 @@ static int interface_config_write(struct vty *vty)
struct nhrp_multicast *mcast; struct nhrp_multicast *mcast;
const char *aficmd; const char *aficmd;
afi_t afi; afi_t afi;
char buf[SU_ADDRSTRLEN];
int i; int i;
FOR_ALL_INTERFACES (vrf, ifp) { 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, list_for_each_entry(nhs, &ad->nhslist_head,
nhslist_entry) nhslist_entry)
{ {
vty_out(vty, " %s nhrp nhs %s nbma %s\n", vty_out(vty, " %s nhrp nhs ", aficmd);
aficmd, if (sockunion_family(&nhs->proto_addr)
sockunion_family(&nhs->proto_addr) == AF_UNSPEC)
== AF_UNSPEC vty_out(vty, "dynamic");
? "dynamic" else
: sockunion2str( vty_out(vty, "%pSU", &nhs->proto_addr);
&nhs->proto_addr, buf, vty_out(vty, "nbma %s\n", nhs->nbma_fqdn);
sizeof(buf)),
nhs->nbma_fqdn);
} }
list_for_each_entry(mcast, &ad->mcastlist_head, list_for_each_entry(mcast, &ad->mcastlist_head,
list_entry) list_entry)
{ {
vty_out(vty, " %s nhrp map multicast %s\n", vty_out(vty, " %s nhrp map multicast ", aficmd);
aficmd, if (sockunion_family(&mcast->nbma_addr)
sockunion_family(&mcast->nbma_addr) == AF_UNSPEC)
== AF_UNSPEC vty_out(vty, "dynamic\n");
? "dynamic" else
: sockunion2str( vty_out(vty, "%pSU\n",
&mcast->nbma_addr, &mcast->nbma_addr);
buf, sizeof(buf)));
} }
} }