summaryrefslogtreecommitdiffstats
path: root/zebra/rt_socket.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2015-05-23 11:08:41 +0300
committerDavid Lamparter <equinox@opensourcerouting.org>2015-06-01 16:50:58 +0200
commitbe6335d682c5ee1b6930345193eda875705fbab2 (patch)
tree2107740224a8a6b3f44241ba71d9be562f138232 /zebra/rt_socket.c
parent53a5c39c705f917567d5b1764f1fe12ad5c5e577 (diff)
downloadquagga-be6335d682c5ee1b6930345193eda875705fbab2.tar.bz2
quagga-be6335d682c5ee1b6930345193eda875705fbab2.tar.xz
zebra: use prefix2str for logging where possible
This makes code more robust, consice and readable. Signed-off-by: Timo Teräs <timo.teras@iki.fi> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'zebra/rt_socket.c')
-rw-r--r--zebra/rt_socket.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/zebra/rt_socket.c b/zebra/rt_socket.c
index d8c947c6..bf21ca95 100644
--- a/zebra/rt_socket.c
+++ b/zebra/rt_socket.c
@@ -77,10 +77,10 @@ kernel_rtm_ipv4 (int cmd, struct prefix *p, struct rib *rib, int family)
unsigned int ifindex = 0;
int gate = 0;
int error;
- char prefix_buf[INET_ADDRSTRLEN];
+ char prefix_buf[PREFIX_STRLEN];
if (IS_ZEBRA_DEBUG_RIB)
- inet_ntop (AF_INET, &p->u.prefix, prefix_buf, INET_ADDRSTRLEN);
+ prefix2str (p, prefix_buf, sizeof(prefix_buf));
memset (&sin_dest, 0, sizeof (struct sockaddr_in));
sin_dest.sin_family = AF_INET;
#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
@@ -158,8 +158,8 @@ kernel_rtm_ipv4 (int cmd, struct prefix *p, struct rib *rib, int family)
{
if (!gate)
{
- zlog_debug ("%s: %s/%d: attention! gate not found for rib %p",
- __func__, prefix_buf, p->prefixlen, rib);
+ zlog_debug ("%s: %s: attention! gate not found for rib %p",
+ __func__, prefix_buf, rib);
rib_dump (p, rib);
}
else
@@ -172,8 +172,8 @@ kernel_rtm_ipv4 (int cmd, struct prefix *p, struct rib *rib, int family)
case ZEBRA_ERR_NOERROR:
nexthop_num++;
if (IS_ZEBRA_DEBUG_RIB)
- zlog_debug ("%s: %s/%d: successfully did NH %s",
- __func__, prefix_buf, p->prefixlen, gate_buf);
+ zlog_debug ("%s: %s: successfully did NH %s",
+ __func__, prefix_buf, gate_buf);
if (cmd == RTM_ADD)
SET_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB);
break;
@@ -195,11 +195,9 @@ kernel_rtm_ipv4 (int cmd, struct prefix *p, struct rib *rib, int family)
case ZEBRA_ERR_RTNOEXIST:
case ZEBRA_ERR_RTUNREACH:
default:
- /* This point is reachable regardless of debugging mode. */
- if (!IS_ZEBRA_DEBUG_RIB)
- inet_ntop (AF_INET, &p->u.prefix, prefix_buf, INET_ADDRSTRLEN);
- zlog_err ("%s: %s/%d: rtm_write() unexpectedly returned %d for command %s",
- __func__, prefix_buf, p->prefixlen, error, lookup (rtm_type_str, cmd));
+ zlog_err ("%s: %s: rtm_write() unexpectedly returned %d for command %s",
+ __func__, prefix2str(p, prefix_buf, sizeof(prefix_buf)),
+ error, lookup (rtm_type_str, cmd));
break;
}
} /* if (cmd and flags make sense) */