summaryrefslogtreecommitdiffstats
path: root/ripd/ripd.c
diff options
context:
space:
mode:
Diffstat (limited to 'ripd/ripd.c')
-rw-r--r--ripd/ripd.c128
1 files changed, 61 insertions, 67 deletions
diff --git a/ripd/ripd.c b/ripd/ripd.c
index 49caf3f6d..07f24b5a9 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -45,6 +45,7 @@
#include "lib_errors.h"
#include "northbound_cli.h"
#include "network.h"
+#include "lib/printfrr.h"
#include "ripd/ripd.h"
#include "ripd/rip_nb.h"
@@ -466,8 +467,8 @@ static void rip_rte_process(struct rte *rte, struct sockaddr_in *from,
if (ret == RMAP_DENYMATCH) {
if (IS_RIP_DEBUG_PACKET)
zlog_debug(
- "RIP %s/%d is filtered by route-map in",
- inet_ntoa(p.prefix), p.prefixlen);
+ "RIP %pFX is filtered by route-map in",
+ &p);
return;
}
@@ -502,8 +503,8 @@ static void rip_rte_process(struct rte *rte, struct sockaddr_in *from,
/* Check if nexthop address is myself, then do nothing. */
if (rip_nexthop_check(rip, nexthop) < 0) {
if (IS_RIP_DEBUG_PACKET)
- zlog_debug("Nexthop address %s is myself",
- inet_ntoa(*nexthop));
+ zlog_debug("Nexthop address %pI4 is myself",
+ nexthop);
return;
}
@@ -830,8 +831,8 @@ static int rip_auth_simple_password(struct rte *rte, struct sockaddr_in *from,
}
if (IS_RIP_DEBUG_EVENT)
- zlog_debug("RIPv2 simple password authentication from %s",
- inet_ntoa(from->sin_addr));
+ zlog_debug("RIPv2 simple password authentication from %pI4",
+ &from->sin_addr);
ri = ifp->info;
@@ -878,8 +879,8 @@ static int rip_auth_md5(struct rip_packet *packet, struct sockaddr_in *from,
char auth_str[RIP_AUTH_MD5_SIZE] = {};
if (IS_RIP_DEBUG_EVENT)
- zlog_debug("RIPv2 MD5 authentication from %s",
- inet_ntoa(from->sin_addr));
+ zlog_debug("RIPv2 MD5 authentication from %pI4",
+ &from->sin_addr);
ri = ifp->info;
md5 = (struct rip_md5_info *)&packet->rte;
@@ -1160,8 +1161,8 @@ static void rip_response_process(struct rip_packet *packet, int size,
rip->vrf->vrf_id)
== NULL) {
zlog_info(
- "This datagram doesn't came from a valid neighbor: %s",
- inet_ntoa(from->sin_addr));
+ "This datagram doesn't come from a valid neighbor: %pI4",
+ &from->sin_addr);
rip_peer_bad_packet(rip, from);
return;
}
@@ -1190,9 +1191,9 @@ static void rip_response_process(struct rip_packet *packet, int size,
if (rte->family != htons(AF_INET)) {
/* Address family check. RIP only supports AF_INET. */
- zlog_info("Unsupported family %d from %s.",
+ zlog_info("Unsupported family %d from %pI4",
ntohs(rte->family),
- inet_ntoa(from->sin_addr));
+ &from->sin_addr);
continue;
}
@@ -1218,8 +1219,8 @@ static void rip_response_process(struct rip_packet *packet, int size,
/* RIPv1 does not have nexthop value. */
if (packet->version == RIPv1
&& rte->nexthop.s_addr != INADDR_ANY) {
- zlog_info("RIPv1 packet with nexthop value %s",
- inet_ntoa(rte->nexthop));
+ zlog_info("RIPv1 packet with nexthop value %pI4",
+ &rte->nexthop);
rip_peer_bad_route(rip, from);
continue;
}
@@ -1236,8 +1237,8 @@ static void rip_response_process(struct rip_packet *packet, int size,
addrval = ntohl(rte->nexthop.s_addr);
if (IN_CLASSD(addrval)) {
zlog_info(
- "Nexthop %s is multicast address, skip this rte",
- inet_ntoa(rte->nexthop));
+ "Nexthop %pI4 is multicast address, skip this rte",
+ &rte->nexthop);
continue;
}
@@ -1257,16 +1258,14 @@ static void rip_response_process(struct rip_packet *packet, int size,
== RIP_ROUTE_RTE) {
if (IS_RIP_DEBUG_EVENT)
zlog_debug(
- "Next hop %s is on RIP network. Set nexthop to the packet's originator",
- inet_ntoa(
- rte->nexthop));
+ "Next hop %pI4 is on RIP network. Set nexthop to the packet's originator",
+ &rte->nexthop);
rte->nexthop = rinfo->from;
} else {
if (IS_RIP_DEBUG_EVENT)
zlog_debug(
- "Next hop %s is not directly reachable. Treat it as 0.0.0.0",
- inet_ntoa(
- rte->nexthop));
+ "Next hop %pI4 is not directly reachable. Treat it as 0.0.0.0",
+ &rte->nexthop);
rte->nexthop.s_addr =
INADDR_ANY;
}
@@ -1275,9 +1274,8 @@ static void rip_response_process(struct rip_packet *packet, int size,
} else {
if (IS_RIP_DEBUG_EVENT)
zlog_debug(
- "Next hop %s is not directly reachable. Treat it as 0.0.0.0",
- inet_ntoa(
- rte->nexthop));
+ "Next hop %pI4 is not directly reachable. Treat it as 0.0.0.0",
+ &rte->nexthop);
rte->nexthop.s_addr = INADDR_ANY;
}
}
@@ -1331,8 +1329,8 @@ static void rip_response_process(struct rip_packet *packet, int size,
!= rte->prefix.s_addr)
masklen2ip(32, &rte->mask);
if (IS_RIP_DEBUG_EVENT)
- zlog_debug("Subnetted route %s",
- inet_ntoa(rte->prefix));
+ zlog_debug("Subnetted route %pI4",
+ &rte->prefix);
} else {
if ((rte->prefix.s_addr & rte->mask.s_addr)
!= rte->prefix.s_addr)
@@ -1340,10 +1338,10 @@ static void rip_response_process(struct rip_packet *packet, int size,
}
if (IS_RIP_DEBUG_EVENT) {
- zlog_debug("Resultant route %s",
- inet_ntoa(rte->prefix));
- zlog_debug("Resultant mask %s",
- inet_ntoa(rte->mask));
+ zlog_debug("Resultant route %pI4",
+ &rte->prefix);
+ zlog_debug("Resultant mask %pI4",
+ &rte->mask);
}
}
@@ -1354,8 +1352,8 @@ static void rip_response_process(struct rip_packet *packet, int size,
&& ((rte->prefix.s_addr & rte->mask.s_addr)
!= rte->prefix.s_addr)) {
zlog_warn(
- "RIPv2 address %s is not mask /%d applied one",
- inet_ntoa(rte->prefix), ip_masklen(rte->mask));
+ "RIPv2 address %pI4 is not mask /%d applied one",
+ &rte->prefix, ip_masklen(rte->mask));
rip_peer_bad_route(rip, from);
continue;
}
@@ -1418,8 +1416,8 @@ int rip_create_socket(struct vrf *vrf)
frr_with_privs(&ripd_privs) {
if ((ret = bind(sock, (struct sockaddr *)&addr, sizeof(addr)))
< 0) {
- zlog_err("%s: Can't bind socket %d to %s port %d: %s",
- __func__, sock, inet_ntoa(addr.sin_addr),
+ zlog_err("%s: Can't bind socket %d to %pI4 port %d: %s",
+ __func__, sock, &addr.sin_addr,
(int)ntohs(addr.sin_port),
safe_strerror(errno));
@@ -1459,14 +1457,14 @@ static int rip_send_packet(uint8_t *buf, int size, struct sockaddr_in *to,
char dst[ADDRESS_SIZE];
if (to) {
- strlcpy(dst, inet_ntoa(to->sin_addr), sizeof(dst));
+ inet_ntop(AF_INET, &to->sin_addr, dst, sizeof(dst));
} else {
sin.sin_addr.s_addr = htonl(INADDR_RIP_GROUP);
- strlcpy(dst, inet_ntoa(sin.sin_addr), sizeof(dst));
+ inet_ntop(AF_INET, &sin.sin_addr, dst, sizeof(dst));
}
#undef ADDRESS_SIZE
- zlog_debug("rip_send_packet %s > %s (%s)",
- inet_ntoa(ifc->address->u.prefix4), dst,
+ zlog_debug("rip_send_packet %pI4 > %s (%s)",
+ &ifc->address->u.prefix4, dst,
ifc->ifp->name);
}
@@ -1533,7 +1531,7 @@ static int rip_send_packet(uint8_t *buf, int size, struct sockaddr_in *to,
ret = sendmsg(rip->sock, &msg, 0);
if (IS_RIP_DEBUG_EVENT)
- zlog_debug("SEND to %s.%d", inet_ntoa(sin.sin_addr),
+ zlog_debug("SEND to %pI4%d", &sin.sin_addr,
ntohs(sin.sin_port));
if (ret < 0)
@@ -1782,15 +1780,15 @@ static int rip_read(struct thread *t)
/* RIP packet received */
if (IS_RIP_DEBUG_EVENT)
- zlog_debug("RECV packet from %s port %d on %s (VRF %s)",
- inet_ntoa(from.sin_addr), ntohs(from.sin_port),
+ zlog_debug("RECV packet from %pI4 port %d on %s (VRF %s)",
+ &from.sin_addr, ntohs(from.sin_port),
ifp ? ifp->name : "unknown", rip->vrf_name);
/* If this packet come from unknown interface, ignore it. */
if (ifp == NULL) {
zlog_info(
- "rip_read: cannot find interface for packet from %s port %d (VRF %s)",
- inet_ntoa(from.sin_addr), ntohs(from.sin_port),
+ "rip_read: cannot find interface for packet from %pI4 port %d (VRF %s)",
+ &from.sin_addr, ntohs(from.sin_port),
rip->vrf_name);
return -1;
}
@@ -1803,8 +1801,8 @@ static int rip_read(struct thread *t)
if (ifc == NULL) {
zlog_info(
- "rip_read: cannot find connected address for packet from %s port %d on interface %s (VRF %s)",
- inet_ntoa(from.sin_addr), ntohs(from.sin_port),
+ "rip_read: cannot find connected address for packet from %pI4 port %d on interface %s (VRF %s)",
+ &from.sin_addr, ntohs(from.sin_port),
ifp->name, rip->vrf_name);
return -1;
}
@@ -2077,8 +2075,8 @@ void rip_output_process(struct connected *ifc, struct sockaddr_in *to,
/* Logging output event. */
if (IS_RIP_DEBUG_EVENT) {
if (to)
- zlog_debug("update routes to neighbor %s",
- inet_ntoa(to->sin_addr));
+ zlog_debug("update routes to neighbor %pI4",
+ &to->sin_addr);
else
zlog_debug("update routes on interface %s ifindex %d",
ifc->ifp->name, ifc->ifp->ifindex);
@@ -2143,9 +2141,8 @@ void rip_output_process(struct connected *ifc, struct sockaddr_in *to,
if (IS_RIP_DEBUG_PACKET)
zlog_debug(
- "RIPv1 mask check, %s/%d considered for output",
- inet_ntoa(rp->p.u.prefix4),
- rp->p.prefixlen);
+ "RIPv1 mask check, %pFX considered for output",
+ &rp->p);
if (subnetted
&& prefix_match(
@@ -2166,9 +2163,8 @@ void rip_output_process(struct connected *ifc, struct sockaddr_in *to,
}
if (IS_RIP_DEBUG_PACKET)
zlog_debug(
- "RIPv1 mask check, %s/%d made it through",
- inet_ntoa(rp->p.u.prefix4),
- rp->p.prefixlen);
+ "RIPv1 mask check, %pFX made it through",
+ &rp->p);
} else
p = (struct prefix_ipv4 *)&rp->p;
@@ -2452,10 +2448,10 @@ static void rip_update_interface(struct connected *ifc, uint8_t version,
to.sin_port = htons(RIP_PORT_DEFAULT);
if (IS_RIP_DEBUG_EVENT)
- zlog_debug("%s announce to %s on %s",
+ zlog_debug("%s announce to %pI4 on %s",
CONNECTED_PEER(ifc) ? "unicast"
: "broadcast",
- inet_ntoa(to.sin_addr), ifp->name);
+ &to.sin_addr, ifp->name);
rip_output_process(ifc, &to, route_type, version);
}
@@ -2530,8 +2526,8 @@ static void rip_update_process(struct rip *rip, int route_type)
rip->vrf->vrf_id);
if (!connected) {
zlog_warn(
- "Neighbor %s doesn't have connected interface!",
- inet_ntoa(p->u.prefix4));
+ "Neighbor %pI4 doesn't have connected interface!",
+ &p->u.prefix4);
continue;
}
@@ -2957,8 +2953,7 @@ static void rip_distance_show(struct vty *vty, struct rip *rip)
" Address Distance List\n");
header = 0;
}
- snprintf(buf, sizeof(buf), "%s/%d",
- inet_ntoa(rn->p.u.prefix4), rn->p.prefixlen);
+ snprintfrr(buf, sizeof(buf), "%pFX", &rn->p);
vty_out(vty, " %-20s %4d %s\n", buf,
rdistance->distance,
rdistance->access_list ? rdistance->access_list
@@ -3085,12 +3080,11 @@ DEFUN (show_ip_rip,
int len;
len = vty_out(
- vty, "%c(%s) %s/%d",
+ vty, "%c(%s) %pFX",
/* np->lock, For debugging. */
zebra_route_char(rinfo->type),
rip_route_type_print(rinfo->sub_type),
- inet_ntoa(np->p.u.prefix4),
- np->p.prefixlen);
+ &np->p);
len = 24 - len;
@@ -3100,8 +3094,8 @@ DEFUN (show_ip_rip,
switch (rinfo->nh.type) {
case NEXTHOP_TYPE_IPV4:
case NEXTHOP_TYPE_IPV4_IFINDEX:
- vty_out(vty, "%-20s %2d ",
- inet_ntoa(rinfo->nh.gate.ipv4),
+ vty_out(vty, "%-20pI4 %2d ",
+ &rinfo->nh.gate.ipv4,
rinfo->metric);
break;
case NEXTHOP_TYPE_IFINDEX:
@@ -3125,8 +3119,8 @@ DEFUN (show_ip_rip,
/* Route which exist in kernel routing table. */
if ((rinfo->type == ZEBRA_ROUTE_RIP)
&& (rinfo->sub_type == RIP_ROUTE_RTE)) {
- vty_out(vty, "%-15s ",
- inet_ntoa(rinfo->from));
+ vty_out(vty, "%-15pI4 ",
+ &rinfo->from);
vty_out(vty, "%3" ROUTE_TAG_PRI " ",
(route_tag_t)rinfo->tag);
rip_vty_out_uptime(vty, rinfo);