Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib, ripngd: Remove inet6_ntoa #8376

Merged
merged 2 commits into from
Apr 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions lib/prefix.c
Original file line number Diff line number Diff line change
Expand Up @@ -1198,15 +1198,6 @@ int netmask_str2prefix_str(const char *net_str, const char *mask_str,
return 1;
}

/* Utility function for making IPv6 address string. */
const char *inet6_ntoa(struct in6_addr addr)
{
static char buf[INET6_ADDRSTRLEN];

inet_ntop(AF_INET6, &addr, buf, INET6_ADDRSTRLEN);
return buf;
}

/* converts to internal representation of mac address
* returns 1 on success, 0 otherwise
* format accepted: AA:BB:CC:DD:EE:FF
Expand Down
2 changes: 0 additions & 2 deletions lib/prefix.h
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,6 @@ extern void apply_mask_ipv6(struct prefix_ipv6 *);
extern int ip6_masklen(struct in6_addr);
extern void masklen2ip6(const int, struct in6_addr *);

extern const char *inet6_ntoa(struct in6_addr);

extern int is_zero_mac(const struct ethaddr *mac);
extern bool is_mcast_mac(const struct ethaddr *mac);
extern bool is_bcast_mac(const struct ethaddr *mac);
Expand Down
4 changes: 2 additions & 2 deletions ripngd/ripng_peer.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ void ripng_peer_display(struct vty *vty, struct ripng *ripng)
char timebuf[RIPNG_UPTIME_LEN];

for (ALL_LIST_ELEMENTS(ripng->peer_list, node, nnode, peer)) {
vty_out(vty, " %s \n%14s %10d %10d %10d %s\n",
inet6_ntoa(peer->addr), " ", peer->recv_badpackets,
vty_out(vty, " %pI6 \n%14s %10d %10d %10d %s\n",
&peer->addr, " ", peer->recv_badpackets,
peer->recv_badroutes, ZEBRA_RIPNG_DISTANCE_DEFAULT,
ripng_peer_uptime(peer, timebuf, RIPNG_UPTIME_LEN));
}
Expand Down
94 changes: 45 additions & 49 deletions ripngd/ripngd.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ int ripng_send_packet(caddr_t buf, int bufsize, struct sockaddr_in6 *to,

if (IS_RIPNG_DEBUG_SEND) {
if (to)
zlog_debug("send to %s", inet6_ntoa(to->sin6_addr));
zlog_debug("send to %pI6", &to->sin6_addr);
zlog_debug(" send interface %s", ifp->name);
zlog_debug(" send packet size %d", bufsize);
}
Expand Down Expand Up @@ -237,8 +237,8 @@ int ripng_send_packet(caddr_t buf, int bufsize, struct sockaddr_in6 *to,
if (ret < 0) {
if (to)
flog_err_sys(EC_LIB_SOCKET,
"RIPng send fail on %s to %s: %s",
ifp->name, inet6_ntoa(to->sin6_addr),
"RIPng send fail on %s to %pI6: %s",
ifp->name, &to->sin6_addr,
safe_strerror(errno));
else
flog_err_sys(EC_LIB_SOCKET, "RIPng send fail on %s: %s",
Expand Down Expand Up @@ -338,11 +338,11 @@ void ripng_packet_dump(struct ripng_packet *packet, int size,

for (lim = (caddr_t)packet + size; (caddr_t)rte < lim; rte++) {
if (rte->metric == RIPNG_METRIC_NEXTHOP)
zlog_debug(" nexthop %s/%d", inet6_ntoa(rte->addr),
zlog_debug(" nexthop %pI6/%d", &rte->addr,
rte->prefixlen);
else
zlog_debug(" %s/%d metric %d tag %" ROUTE_TAG_PRI,
inet6_ntoa(rte->addr), rte->prefixlen,
zlog_debug(" %pI6/%d metric %d tag %" ROUTE_TAG_PRI,
&rte->addr, rte->prefixlen,
rte->metric, (route_tag_t)ntohs(rte->tag));
}
}
Expand All @@ -353,9 +353,9 @@ static void ripng_nexthop_rte(struct rte *rte, struct sockaddr_in6 *from,
{
/* Logging before checking RTE. */
if (IS_RIPNG_DEBUG_RECV)
zlog_debug("RIPng nexthop RTE address %s tag %" ROUTE_TAG_PRI
zlog_debug("RIPng nexthop RTE address %pI6 tag %" ROUTE_TAG_PRI
" prefixlen %d",
inet6_ntoa(rte->addr), (route_tag_t)ntohs(rte->tag),
&rte->addr, (route_tag_t)ntohs(rte->tag),
rte->prefixlen);

/* RFC2080 2.1.1 Next Hop:
Expand All @@ -364,14 +364,13 @@ static void ripng_nexthop_rte(struct rte *rte, struct sockaddr_in6 *from,
if (ntohs(rte->tag) != 0)
zlog_warn(
"RIPng nexthop RTE with non zero tag value %" ROUTE_TAG_PRI
" from %s",
(route_tag_t)ntohs(rte->tag),
inet6_ntoa(from->sin6_addr));
" from %pI6",
(route_tag_t)ntohs(rte->tag), &from->sin6_addr);

if (rte->prefixlen != 0)
zlog_warn(
"RIPng nexthop RTE with non zero prefixlen value %d from %s",
rte->prefixlen, inet6_ntoa(from->sin6_addr));
"RIPng nexthop RTE with non zero prefixlen value %d from %pI6",
rte->prefixlen, &from->sin6_addr);

/* Specifying a value of 0:0:0:0:0:0:0:0 in the prefix field of a
next hop RTE indicates that the next hop address should be the
Expand All @@ -396,8 +395,8 @@ static void ripng_nexthop_rte(struct rte *rte, struct sockaddr_in6 *from,
information is ignored, a possibly sub-optimal, but absolutely
valid, route may be taken. If the received next hop address is not
a link-local address, it should be treated as 0:0:0:0:0:0:0:0. */
zlog_warn("RIPng nexthop RTE with non link-local address %s from %pI6",
inet6_ntoa(rte->addr), &from->sin6_addr);
zlog_warn("RIPng nexthop RTE with non link-local address %pI6 from %pI6",
&rte->addr, &from->sin6_addr);

nexthop->flag = RIPNG_NEXTHOP_UNSPEC;
memset(&nexthop->address, 0, sizeof(struct in6_addr));
Expand Down Expand Up @@ -750,8 +749,8 @@ static void ripng_route_process(struct rte *rte, struct sockaddr_in6 *from,
if (ret == RMAP_DENYMATCH) {
if (IS_RIPNG_DEBUG_PACKET)
zlog_debug(
"RIPng %s/%d is filtered by route-map in",
inet6_ntoa(p.prefix), p.prefixlen);
"RIPng %pFX is filtered by route-map in",
&p);
return;
}

Expand Down Expand Up @@ -993,8 +992,8 @@ void ripng_redistribute_add(struct ripng *ripng, int type, int sub_type,
p, ifindex2ifname(ifindex, ripng->vrf->vrf_id));
else
zlog_debug(
"Redistribute new prefix %pFX with nexthop %s on the interface %s",
p, inet6_ntoa(*nexthop),
"Redistribute new prefix %pFX with nexthop %pI6 on the interface %s",
p, nexthop,
ifindex2ifname(ifindex, ripng->vrf->vrf_id));
}

Expand Down Expand Up @@ -1106,8 +1105,8 @@ static void ripng_response_process(struct ripng_packet *packet, int size,
/* RFC2080 2.4.2 Response Messages:
The Response must be ignored if it is not from the RIPng port. */
if (ntohs(from->sin6_port) != RIPNG_PORT_DEFAULT) {
zlog_warn("RIPng packet comes from non RIPng port %d from %s",
ntohs(from->sin6_port), inet6_ntoa(from->sin6_addr));
zlog_warn("RIPng packet comes from non RIPng port %d from %pI6",
ntohs(from->sin6_port), &from->sin6_addr);
ripng_peer_bad_packet(ripng, from);
return;
}
Expand All @@ -1116,8 +1115,8 @@ static void ripng_response_process(struct ripng_packet *packet, int size,
whether the datagram is from a valid neighbor; the source of the
datagram must be a link-local address. */
if (!IN6_IS_ADDR_LINKLOCAL(&from->sin6_addr)) {
zlog_warn("RIPng packet comes from non link local address %s",
inet6_ntoa(from->sin6_addr));
zlog_warn("RIPng packet comes from non link local address %pI6",
&from->sin6_addr);
ripng_peer_bad_packet(ripng, from);
return;
}
Expand All @@ -1129,8 +1128,8 @@ static void ripng_response_process(struct ripng_packet *packet, int size,
and such datagrams must be ignored. */
if (ripng_lladdr_check(ifp, &from->sin6_addr)) {
zlog_warn(
"RIPng packet comes from my own link local address %s",
inet6_ntoa(from->sin6_addr));
"RIPng packet comes from my own link local address %pI6",
&from->sin6_addr);
ripng_peer_bad_packet(ripng, from);
return;
}
Expand All @@ -1141,8 +1140,8 @@ static void ripng_response_process(struct ripng_packet *packet, int size,
packets) must be examined to ensure that the hop count is 255. */
if (hoplimit >= 0 && hoplimit != 255) {
zlog_warn(
"RIPng packet comes with non 255 hop count %d from %s",
hoplimit, inet6_ntoa(from->sin6_addr));
"RIPng packet comes with non 255 hop count %d from %pI6",
hoplimit, &from->sin6_addr);
ripng_peer_bad_packet(ripng, from);
return;
}
Expand Down Expand Up @@ -1173,43 +1172,40 @@ static void ripng_response_process(struct ripng_packet *packet, int size,
should never be present in an RTE. */
if (IN6_IS_ADDR_MULTICAST(&rte->addr)) {
zlog_warn(
"Destination prefix is a multicast address %s/%d [%d]",
inet6_ntoa(rte->addr), rte->prefixlen,
rte->metric);
"Destination prefix is a multicast address %pI6/%d [%d]",
&rte->addr, rte->prefixlen, rte->metric);
ripng_peer_bad_route(ripng, from);
continue;
}
if (IN6_IS_ADDR_LINKLOCAL(&rte->addr)) {
zlog_warn(
"Destination prefix is a link-local address %s/%d [%d]",
inet6_ntoa(rte->addr), rte->prefixlen,
rte->metric);
"Destination prefix is a link-local address %pI6/%d [%d]",
&rte->addr, rte->prefixlen, rte->metric);
ripng_peer_bad_route(ripng, from);
continue;
}
if (IN6_IS_ADDR_LOOPBACK(&rte->addr)) {
zlog_warn(
"Destination prefix is a loopback address %s/%d [%d]",
inet6_ntoa(rte->addr), rte->prefixlen,
rte->metric);
"Destination prefix is a loopback address %pI6/%d [%d]",
&rte->addr, rte->prefixlen, rte->metric);
ripng_peer_bad_route(ripng, from);
continue;
}

/* - is the prefix length valid (i.e., between 0 and 128,
inclusive) */
if (rte->prefixlen > 128) {
zlog_warn("Invalid prefix length %s/%d from %s%%%s",
inet6_ntoa(rte->addr), rte->prefixlen,
inet6_ntoa(from->sin6_addr), ifp->name);
zlog_warn("Invalid prefix length %pI6/%d from %pI6%%%s",
&rte->addr, rte->prefixlen,
&from->sin6_addr, ifp->name);
ripng_peer_bad_route(ripng, from);
continue;
}

/* - is the metric valid (i.e., between 1 and 16, inclusive) */
if (!(rte->metric >= 1 && rte->metric <= 16)) {
zlog_warn("Invalid metric %d from %s%%%s", rte->metric,
inet6_ntoa(from->sin6_addr), ifp->name);
zlog_warn("Invalid metric %d from %pI6%%%s",
rte->metric, &from->sin6_addr, ifp->name);
ripng_peer_bad_route(ripng, from);
continue;
}
Expand Down Expand Up @@ -1342,8 +1338,8 @@ static int ripng_read(struct thread *thread)
/* Check RTE boundary. RTE size (Packet length - RIPng header size
(4)) must be multiple size of one RTE size (20). */
if (((len - 4) % 20) != 0) {
zlog_warn("RIPng invalid packet size %d from %s (VRF %s)", len,
inet6_ntoa(from.sin6_addr), ripng->vrf_name);
zlog_warn("RIPng invalid packet size %d from %pI6 (VRF %s)",
len, &from.sin6_addr, ripng->vrf_name);
ripng_peer_bad_packet(ripng, &from);
return 0;
}
Expand All @@ -1354,8 +1350,8 @@ static int ripng_read(struct thread *thread)
/* RIPng packet received. */
if (IS_RIPNG_DEBUG_EVENT)
zlog_debug(
"RIPng packet received from %s port %d on %s (VRF %s)",
inet6_ntoa(from.sin6_addr), ntohs(from.sin6_port),
"RIPng packet received from %pI6 port %d on %s (VRF %s)",
&from.sin6_addr, ntohs(from.sin6_port),
ifp ? ifp->name : "unknown", ripng->vrf_name);

/* Logging before packet checking. */
Expand Down Expand Up @@ -1581,8 +1577,8 @@ void ripng_output_process(struct interface *ifp, struct sockaddr_in6 *to,

if (IS_RIPNG_DEBUG_EVENT) {
if (to)
zlog_debug("RIPng update routes to neighbor %s",
inet6_ntoa(to->sin6_addr));
zlog_debug("RIPng update routes to neighbor %pI6",
&to->sin6_addr);
else
zlog_debug("RIPng update routes on interface %s",
ifp->name);
Expand Down Expand Up @@ -2089,8 +2085,8 @@ DEFUN (show_ipv6_ripng,
#endif /* DEBUG */
vty_out(vty, "\n");
vty_out(vty, "%*s", 18, " ");
len = vty_out(vty, "%s",
inet6_ntoa(rinfo->nexthop));
len = vty_out(vty, "%pI6",
&rinfo->nexthop);

len = 28 - len;
if (len > 0)
Expand Down