Skip to content

Commit

Permalink
nhrpd: Change sockunion2str to %pSU in a few places
Browse files Browse the repository at this point in the history
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
  • Loading branch information
reubendowle committed Apr 7, 2021
1 parent c2bb991 commit 46d3c18
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 35 deletions.
17 changes: 6 additions & 11 deletions nhrpd/nhrp_multicast.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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,
Expand Down Expand Up @@ -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)
{
Expand All @@ -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;
}
Expand All @@ -258,16 +254,15 @@ 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)
{
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);

Expand Down
43 changes: 19 additions & 24 deletions nhrpd/nhrp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 46d3c18

Please sign in to comment.