bgpd, lib: memory cleanups for valgrind, plus debug changes
Description:
We use valgrind memcheck quite a bit to spot leaks in
our work with bgpd. In order to eliminate false positives,
we added code in the exit path to release the remaining
allocated memory.
Bgpd startup log message now includes pid.
Some little tweaks by Paul Jakma <paul.jakma@hpe.com>:
* bgp_mplsvpn.c: (str2prefix_rd) do the cleanup in common code at the end
and goto it.
diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c
index 8621854..3c5e6c5 100644
--- a/bgpd/bgp_network.c
+++ b/bgpd/bgp_network.c
@@ -276,6 +276,7 @@
#ifdef SO_BINDTODEVICE
int ret;
struct ifreq ifreq;
+ int myerrno;
if (! peer->ifname)
return 0;
@@ -287,13 +288,15 @@
ret = setsockopt (peer->fd, SOL_SOCKET, SO_BINDTODEVICE,
&ifreq, sizeof (ifreq));
-
+ myerrno = errno;
+
if (bgpd_privs.change (ZPRIVS_LOWER) )
zlog_err ("bgp_bind: could not lower privs");
if (ret < 0)
{
- zlog (peer->log, LOG_INFO, "bind to interface %s failed", peer->ifname);
+ zlog (peer->log, LOG_INFO, "bind to interface %s failed, errno=%d",
+ peer->ifname, myerrno);
return ret;
}
#endif /* SO_BINDTODEVICE */