[PATCH] monitor: Use nl_socket_alloc() instead of nl_socket_alloc_cb()



We are using the default cb set anyways. This allows running NM with
the NLCB=debug environment variable set to get some debug messages
out of libnl related to netlink communication.

NLCB=debug won't print received netlink messages as the MSG_IN
handler is in use by NM to verify message origins. It's probably
best to introduce new handlers in libnl for debugging purpose
so both use of MSG_IN and enable debugging is possible.
---
 src/nm-netlink-monitor.c |   10 ++--------
 1 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/src/nm-netlink-monitor.c b/src/nm-netlink-monitor.c
index 040ef5a..fb85981 100644
--- a/src/nm-netlink-monitor.c
+++ b/src/nm-netlink-monitor.c
@@ -282,15 +282,12 @@ event_connection_setup (NMNetlinkMonitor *self, GError **error)
 	NMNetlinkMonitorPrivate *priv = NM_NETLINK_MONITOR_GET_PRIVATE (self);
 	GError *channel_error = NULL;
 	GIOFlags channel_flags;
-	struct nl_cb *cb;
 	int fd;
 
 	g_return_val_if_fail (priv->io_channel == NULL, FALSE);
 
 	/* Set up the event listener connection */
-	cb = nl_cb_alloc (NL_CB_DEFAULT);
-	priv->nlh_event = nl_socket_alloc_cb (cb);
-	nl_cb_put (cb);
+	priv->nlh_event = nl_socket_alloc ();
 	if (!priv->nlh_event) {
 		g_set_error (error, NM_NETLINK_MONITOR_ERROR,
 		             NM_NETLINK_MONITOR_ERROR_NETLINK_ALLOC_HANDLE,
@@ -344,16 +341,13 @@ static gboolean
 sync_connection_setup (NMNetlinkMonitor *self, GError **error)
 {
 	NMNetlinkMonitorPrivate *priv = NM_NETLINK_MONITOR_GET_PRIVATE (self);
-	struct nl_cb *cb;
 #ifdef LIBNL_NEEDS_ADDR_CACHING_WORKAROUND
 	struct nl_cache *addr_cache;
 #endif
 	int err;
 
 	/* Set up the event listener connection */
-	cb = nl_cb_alloc (NL_CB_DEFAULT);
-	priv->nlh_sync = nl_socket_alloc_cb (cb);
-	nl_cb_put (cb);
+	priv->nlh_sync = nl_socket_alloc ();
 	if (!priv->nlh_sync) {
 		g_set_error (error, NM_NETLINK_MONITOR_ERROR,
 		             NM_NETLINK_MONITOR_ERROR_NETLINK_ALLOC_HANDLE,
-- 
1.7.6



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]