aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2011-09-06 09:34:17 +0200
committerNatanael Copa <ncopa@alpinelinux.org>2011-09-06 09:34:17 +0200
commit57abc32e14ac85edf71203013e73abccbd1b922b (patch)
tree311ae0b4807e8c1162895d9f9bb7295440c73904
parentd106c8956ca335b47a28c49c6821c0600eff4af9 (diff)
downloadpingu-57abc32e14ac85edf71203013e73abccbd1b922b.tar.bz2
pingu-57abc32e14ac85edf71203013e73abccbd1b922b.tar.xz
pingu_netlink: fix logging of routes
Sometimes we have via a gateway and sometimes we don't.
-rw-r--r--pingu_netlink.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/pingu_netlink.c b/pingu_netlink.c
index b794394..de5a721 100644
--- a/pingu_netlink.c
+++ b/pingu_netlink.c
@@ -563,15 +563,17 @@ static struct pingu_gateway *gw_from_rtmsg(struct pingu_gateway *gw,
static void log_route_change(struct pingu_gateway *route,
char *ifname, int table, int action)
{
- char deststr[64], gwstr[64];
+ char deststr[64] = "", gwstr[64] = "", viastr[68] = "";
char *actionstr = "New";
if (action == RTM_DELROUTE)
actionstr = "Delete";
sockaddr_to_string(&route->dest, deststr, sizeof(deststr));
sockaddr_to_string(&route->gw_addr, gwstr, sizeof(gwstr));
- log_debug("%s route to %s/%i via %s dev %s table %i", actionstr,
- deststr, route->dst_len, gwstr, ifname, table);
+ if (gwstr[0] != '\0')
+ snprintf(viastr, sizeof(viastr), "via %s ", gwstr);
+ log_debug("%s route to %s/%i %sdev %s table %i", actionstr,
+ deststr, route->dst_len, viastr, ifname, table);
}
static void netlink_route_cb_action(struct nlmsghdr *msg, int action)