From e0630023e5652d27688b1379e3ea863a7d9ba707 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 2 Jul 2015 14:33:37 +0200 Subject: [PATCH 1/5] platform: add logging macros _LOGx() to nm-platform.c --- src/platform/nm-platform.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index 911b4516d2..5327f8bb57 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -43,6 +43,44 @@ G_STATIC_ASSERT (sizeof ( ((NMPlatformLink *) NULL)->addr.data ) == NM_UTILS_HWADDR_LEN_MAX); +#define _LOG_DOMAIN LOGD_PLATFORM +#define _LOG_PREFIX_NAME "platform" + +#define _LOG(level, domain, self, ...) \ + G_STMT_START { \ + const NMLogLevel __level = (level); \ + const NMLogDomain __domain = (domain); \ + \ + if (nm_logging_enabled (__level, __domain)) { \ + char __prefix[32]; \ + const char *__p_prefix = _LOG_PREFIX_NAME; \ + const void *const __self = (self); \ + \ + if (__self && __self != nm_platform_try_get ()) { \ + g_snprintf (__prefix, sizeof (__prefix), "%s[%p]", _LOG_PREFIX_NAME, __self); \ + __p_prefix = __prefix; \ + } \ + _nm_log (__level, __domain, 0, \ + "%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ + __p_prefix _NM_UTILS_MACRO_REST (__VA_ARGS__)); \ + } \ + } G_STMT_END +#define _LOG_LEVEL_ENABLED(level, domain) \ + ( nm_logging_enabled ((level), (domain)) ) + +#ifdef NM_MORE_LOGGING +#define _LOGT_ENABLED() _LOG_LEVEL_ENABLED (LOGL_TRACE, _LOG_DOMAIN) +#define _LOGT(...) _LOG (LOGL_TRACE, _LOG_DOMAIN, self, __VA_ARGS__) +#else +#define _LOGT_ENABLED() FALSE +#define _LOGT(...) G_STMT_START { if (FALSE) { _LOG (LOGL_TRACE, _LOG_DOMAIN, self, __VA_ARGS__); } } G_STMT_END +#endif + +#define _LOGD(...) _LOG (LOGL_DEBUG, _LOG_DOMAIN, self, __VA_ARGS__) +#define _LOGI(...) _LOG (LOGL_INFO , _LOG_DOMAIN, self, __VA_ARGS__) +#define _LOGW(...) _LOG (LOGL_WARN , _LOG_DOMAIN, self, __VA_ARGS__) +#define _LOGE(...) _LOG (LOGL_ERR , _LOG_DOMAIN, self, __VA_ARGS__) + #define debug(...) nm_log_dbg (LOGD_PLATFORM, __VA_ARGS__) #define NM_PLATFORM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_PLATFORM, NMPlatformPrivate)) From c9aeefb5a18511f930328a3d3a4e7e08cb8564df Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 2 Jul 2015 14:35:38 +0200 Subject: [PATCH 2/5] platform: replace debug() log macro with _LOGD() --- src/platform/nm-platform.c | 68 ++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index 5327f8bb57..6a549d4ff0 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -81,8 +81,6 @@ G_STATIC_ASSERT (sizeof ( ((NMPlatformLink *) NULL)->addr.data ) == NM_UTILS_HWA #define _LOGW(...) _LOG (LOGL_WARN , _LOG_DOMAIN, self, __VA_ARGS__) #define _LOGE(...) _LOG (LOGL_ERR , _LOG_DOMAIN, self, __VA_ARGS__) -#define debug(...) nm_log_dbg (LOGD_PLATFORM, __VA_ARGS__) - #define NM_PLATFORM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_PLATFORM, NMPlatformPrivate)) G_DEFINE_TYPE (NMPlatform, nm_platform, G_TYPE_OBJECT) @@ -598,7 +596,7 @@ _link_add_check_existing (NMPlatform *self, const char *name, NMLinkType type, N gboolean wrong_type; wrong_type = type != NM_LINK_TYPE_NONE && pllink->type != type; - debug ("link: skip adding link due to existing interface '%s' of type %s%s%s", + _LOGD ("link: skip adding link due to existing interface '%s' of type %s%s%s", name, nm_link_type_to_string (pllink->type), wrong_type ? ", expected " : "", @@ -651,7 +649,7 @@ nm_platform_link_add (NMPlatform *self, if (plerr != NM_PLATFORM_ERROR_SUCCESS) return plerr; - debug ("link: adding %s '%s'", nm_link_type_to_string (type), name); + _LOGD ("link: adding %s '%s'", nm_link_type_to_string (type), name); if (!klass->link_add (self, name, type, address, address_len, out_link)) return NM_PLATFORM_ERROR_UNSPECIFIED; return NM_PLATFORM_ERROR_SUCCESS; @@ -687,7 +685,7 @@ nm_platform_link_delete (NMPlatform *self, int ifindex) if (!pllink) return FALSE; - debug ("link: deleting '%s' (%d)", pllink->name, ifindex); + _LOGD ("link: deleting '%s' (%d)", pllink->name, ifindex); return klass->link_delete (self, ifindex); } @@ -1020,7 +1018,7 @@ nm_platform_link_set_address (NMPlatform *self, int ifindex, gconstpointer addre g_return_val_if_fail (length > 0, FALSE); g_return_val_if_fail (klass->link_set_address, FALSE); - debug ("link: setting '%s' (%d) hardware address", nm_platform_link_get_name (self, ifindex), ifindex); + _LOGD ("link: setting '%s' (%d) hardware address", nm_platform_link_get_name (self, ifindex), ifindex); return klass->link_set_address (self, ifindex, address, length); } @@ -1129,7 +1127,7 @@ nm_platform_link_set_up (NMPlatform *self, int ifindex, gboolean *out_no_firmwar g_return_val_if_fail (ifindex > 0, FALSE); g_return_val_if_fail (klass->link_set_up, FALSE); - debug ("link: setting up '%s' (%d)", nm_platform_link_get_name (self, ifindex), ifindex); + _LOGD ("link: setting up '%s' (%d)", nm_platform_link_get_name (self, ifindex), ifindex); return klass->link_set_up (self, ifindex, out_no_firmware); } @@ -1148,7 +1146,7 @@ nm_platform_link_set_down (NMPlatform *self, int ifindex) g_return_val_if_fail (ifindex > 0, FALSE); g_return_val_if_fail (klass->link_set_down, FALSE); - debug ("link: setting down '%s' (%d)", nm_platform_link_get_name (self, ifindex), ifindex); + _LOGD ("link: setting down '%s' (%d)", nm_platform_link_get_name (self, ifindex), ifindex); return klass->link_set_down (self, ifindex); } @@ -1167,7 +1165,7 @@ nm_platform_link_set_arp (NMPlatform *self, int ifindex) g_return_val_if_fail (ifindex >= 0, FALSE); g_return_val_if_fail (klass->link_set_arp, FALSE); - debug ("link: setting arp '%s' (%d)", nm_platform_link_get_name (self, ifindex), ifindex); + _LOGD ("link: setting arp '%s' (%d)", nm_platform_link_get_name (self, ifindex), ifindex); return klass->link_set_arp (self, ifindex); } @@ -1186,7 +1184,7 @@ nm_platform_link_set_noarp (NMPlatform *self, int ifindex) g_return_val_if_fail (ifindex >= 0, FALSE); g_return_val_if_fail (klass->link_set_noarp, FALSE); - debug ("link: setting noarp '%s' (%d)", nm_platform_link_get_name (self, ifindex), ifindex); + _LOGD ("link: setting noarp '%s' (%d)", nm_platform_link_get_name (self, ifindex), ifindex); return klass->link_set_noarp (self, ifindex); } @@ -1207,7 +1205,7 @@ nm_platform_link_set_mtu (NMPlatform *self, int ifindex, guint32 mtu) g_return_val_if_fail (mtu > 0, FALSE); g_return_val_if_fail (klass->link_set_mtu, FALSE); - debug ("link: setting '%s' (%d) mtu %"G_GUINT32_FORMAT, nm_platform_link_get_name (self, ifindex), ifindex, mtu); + _LOGD ("link: setting '%s' (%d) mtu %"G_GUINT32_FORMAT, nm_platform_link_get_name (self, ifindex), ifindex, mtu); return klass->link_set_mtu (self, ifindex, mtu); } @@ -1346,7 +1344,7 @@ nm_platform_link_enslave (NMPlatform *self, int master, int slave) g_return_val_if_fail (slave> 0, FALSE); g_return_val_if_fail (klass->link_enslave, FALSE); - debug ("link: enslaving '%s' (%d) to master '%s' (%d)", + _LOGD ("link: enslaving '%s' (%d) to master '%s' (%d)", nm_platform_link_get_name (self, slave), slave, nm_platform_link_get_name (self, master), master); return klass->link_enslave (self, master, slave); @@ -1372,7 +1370,7 @@ nm_platform_link_release (NMPlatform *self, int master, int slave) if (nm_platform_link_get_master (self, slave) != master) return FALSE; - debug ("link: releasing '%s' (%d) from master '%s' (%d)", + _LOGD ("link: releasing '%s' (%d) from master '%s' (%d)", nm_platform_link_get_name (self, slave), slave, nm_platform_link_get_name (self, master), master); return klass->link_release (self, master, slave); @@ -1477,7 +1475,7 @@ nm_platform_vlan_add (NMPlatform *self, if (plerr != NM_PLATFORM_ERROR_SUCCESS) return plerr; - debug ("link: adding vlan '%s' parent %d vlanid %d vlanflags %x", + _LOGD ("link: adding vlan '%s' parent %d vlanid %d vlanflags %x", name, parent, vlanid, vlanflags); if (!klass->vlan_add (self, name, parent, vlanid, vlanflags, out_link)) return NM_PLATFORM_ERROR_UNSPECIFIED; @@ -1559,7 +1557,7 @@ nm_platform_vlan_set_ingress_map (NMPlatform *self, int ifindex, int from, int t g_return_val_if_fail (klass->vlan_set_ingress_map, FALSE); - debug ("link: setting vlan ingress map for %d from %d to %d", ifindex, from, to); + _LOGD ("link: setting vlan ingress map for %d from %d to %d", ifindex, from, to); return klass->vlan_set_ingress_map (self, ifindex, from, to); } @@ -1570,7 +1568,7 @@ nm_platform_vlan_set_egress_map (NMPlatform *self, int ifindex, int from, int to g_return_val_if_fail (klass->vlan_set_egress_map, FALSE); - debug ("link: setting vlan egress map for %d from %d to %d", ifindex, from, to); + _LOGD ("link: setting vlan egress map for %d from %d to %d", ifindex, from, to); return klass->vlan_set_egress_map (self, ifindex, from, to); } @@ -1597,7 +1595,7 @@ nm_platform_infiniband_partition_add (NMPlatform *self, int parent, int p_key, N if (plerr != NM_PLATFORM_ERROR_SUCCESS) return plerr; - debug ("link: adding infiniband partition %s for parent '%s' (%d), key %d", + _LOGD ("link: adding infiniband partition %s for parent '%s' (%d), key %d", name, parent_name, parent, p_key); if (!klass->infiniband_partition_add (self, parent, p_key, out_link)) return NM_PLATFORM_ERROR_UNSPECIFIED; @@ -1892,7 +1890,7 @@ nm_platform_ip4_address_add (NMPlatform *self, if (label) g_strlcpy (addr.label, label, sizeof (addr.label)); - debug ("address: adding or updating IPv4 address: %s", nm_platform_ip4_address_to_string (&addr)); + _LOGD ("address: adding or updating IPv4 address: %s", nm_platform_ip4_address_to_string (&addr)); } return klass->ip4_address_add (self, ifindex, address, peer_address, plen, lifetime, preferred, label); } @@ -1927,7 +1925,7 @@ nm_platform_ip6_address_add (NMPlatform *self, addr.preferred = preferred; addr.flags = flags; - debug ("address: adding or updating IPv6 address: %s", nm_platform_ip6_address_to_string (&addr)); + _LOGD ("address: adding or updating IPv6 address: %s", nm_platform_ip6_address_to_string (&addr)); } return klass->ip6_address_add (self, ifindex, address, peer_address, plen, lifetime, preferred, flags); } @@ -1944,7 +1942,7 @@ nm_platform_ip4_address_delete (NMPlatform *self, int ifindex, in_addr_t address g_return_val_if_fail (plen > 0, FALSE); g_return_val_if_fail (klass->ip4_address_delete, FALSE); - debug ("address: deleting IPv4 address %s/%d, %s%s%sifindex %d%s", + _LOGD ("address: deleting IPv4 address %s/%d, %s%s%sifindex %d%s", nm_utils_inet4_ntop (address, NULL), plen, peer_address ? "peer " : "", peer_address ? nm_utils_inet4_ntop (peer_address, str_peer) : "", @@ -1965,7 +1963,7 @@ nm_platform_ip6_address_delete (NMPlatform *self, int ifindex, struct in6_addr a g_return_val_if_fail (plen > 0, FALSE); g_return_val_if_fail (klass->ip6_address_delete, FALSE); - debug ("address: deleting IPv6 address %s/%d, ifindex %d%s", + _LOGD ("address: deleting IPv6 address %s/%d, ifindex %d%s", nm_utils_inet6_ntop (&address, NULL), plen, ifindex, _to_string_dev (self, ifindex, str_dev, sizeof (str_dev))); return klass->ip6_address_delete (self, ifindex, address, plen); @@ -2210,7 +2208,7 @@ nm_platform_ip4_route_add (NMPlatform *self, route.mss = mss; route.pref_src = pref_src; - debug ("route: adding or updating IPv4 route: %s", nm_platform_ip4_route_to_string (&route)); + _LOGD ("route: adding or updating IPv4 route: %s", nm_platform_ip4_route_to_string (&route)); } return klass->ip4_route_add (self, ifindex, source, network, plen, gateway, pref_src, metric, mss); } @@ -2237,7 +2235,7 @@ nm_platform_ip6_route_add (NMPlatform *self, route.metric = metric; route.mss = mss; - debug ("route: adding or updating IPv6 route: %s", nm_platform_ip6_route_to_string (&route)); + _LOGD ("route: adding or updating IPv6 route: %s", nm_platform_ip6_route_to_string (&route)); } return klass->ip6_route_add (self, ifindex, source, network, plen, gateway, metric, mss); } @@ -2251,7 +2249,7 @@ nm_platform_ip4_route_delete (NMPlatform *self, int ifindex, in_addr_t network, g_return_val_if_fail (klass->ip4_route_delete, FALSE); - debug ("route: deleting IPv4 route %s/%d, metric=%"G_GUINT32_FORMAT", ifindex %d%s", + _LOGD ("route: deleting IPv4 route %s/%d, metric=%"G_GUINT32_FORMAT", ifindex %d%s", nm_utils_inet4_ntop (network, NULL), plen, metric, ifindex, _to_string_dev (self, ifindex, str_dev, sizeof (str_dev))); return klass->ip4_route_delete (self, ifindex, network, plen, metric); @@ -2266,7 +2264,7 @@ nm_platform_ip6_route_delete (NMPlatform *self, int ifindex, struct in6_addr net g_return_val_if_fail (klass->ip6_route_delete, FALSE); - debug ("route: deleting IPv6 route %s/%d, metric=%"G_GUINT32_FORMAT", ifindex %d%s", + _LOGD ("route: deleting IPv6 route %s/%d, metric=%"G_GUINT32_FORMAT", ifindex %d%s", nm_utils_inet6_ntop (&network, NULL), plen, metric, ifindex, _to_string_dev (self, ifindex, str_dev, sizeof (str_dev))); return klass->ip6_route_delete (self, ifindex, network, plen, metric); @@ -2914,34 +2912,34 @@ nm_platform_signal_change_type_to_string (NMPlatformSignalChangeType change_type } static void -log_link (NMPlatform *p, NMPObjectType obj_type, int ifindex, NMPlatformLink *device, NMPlatformSignalChangeType change_type, gpointer user_data) +log_link (NMPlatform *self, NMPObjectType obj_type, int ifindex, NMPlatformLink *device, NMPlatformSignalChangeType change_type, gpointer user_data) { - debug ("signal: link %7s: %s", nm_platform_signal_change_type_to_string (change_type), nm_platform_link_to_string (device)); + _LOGD ("signal: link %7s: %s", nm_platform_signal_change_type_to_string (change_type), nm_platform_link_to_string (device)); } static void -log_ip4_address (NMPlatform *p, NMPObjectType obj_type, int ifindex, NMPlatformIP4Address *address, NMPlatformSignalChangeType change_type, gpointer user_data) +log_ip4_address (NMPlatform *self, NMPObjectType obj_type, int ifindex, NMPlatformIP4Address *address, NMPlatformSignalChangeType change_type, gpointer user_data) { - debug ("signal: address 4 %7s: %s", nm_platform_signal_change_type_to_string (change_type), nm_platform_ip4_address_to_string (address)); + _LOGD ("signal: address 4 %7s: %s", nm_platform_signal_change_type_to_string (change_type), nm_platform_ip4_address_to_string (address)); } static void -log_ip6_address (NMPlatform *p, NMPObjectType obj_type, int ifindex, NMPlatformIP6Address *address, NMPlatformSignalChangeType change_type, gpointer user_data) +log_ip6_address (NMPlatform *self, NMPObjectType obj_type, int ifindex, NMPlatformIP6Address *address, NMPlatformSignalChangeType change_type, gpointer user_data) { - debug ("signal: address 6 %7s: %s", nm_platform_signal_change_type_to_string (change_type), nm_platform_ip6_address_to_string (address)); + _LOGD ("signal: address 6 %7s: %s", nm_platform_signal_change_type_to_string (change_type), nm_platform_ip6_address_to_string (address)); } static void -log_ip4_route (NMPlatform *p, NMPObjectType obj_type, int ifindex, NMPlatformIP4Route *route, NMPlatformSignalChangeType change_type, gpointer user_data) +log_ip4_route (NMPlatform *self, NMPObjectType obj_type, int ifindex, NMPlatformIP4Route *route, NMPlatformSignalChangeType change_type, gpointer user_data) { - debug ("signal: route 4 %7s: %s", nm_platform_signal_change_type_to_string (change_type), nm_platform_ip4_route_to_string (route)); + _LOGD ("signal: route 4 %7s: %s", nm_platform_signal_change_type_to_string (change_type), nm_platform_ip4_route_to_string (route)); } static void -log_ip6_route (NMPlatform *p, NMPObjectType obj_type, int ifindex, NMPlatformIP6Route *route, NMPlatformSignalChangeType change_type, gpointer user_data) +log_ip6_route (NMPlatform *self, NMPObjectType obj_type, int ifindex, NMPlatformIP6Route *route, NMPlatformSignalChangeType change_type, gpointer user_data) { - debug ("signal: route 6 %7s: %s", nm_platform_signal_change_type_to_string (change_type), nm_platform_ip6_route_to_string (route)); + _LOGD ("signal: route 6 %7s: %s", nm_platform_signal_change_type_to_string (change_type), nm_platform_ip6_route_to_string (route)); } /******************************************************************/ From 987515ea736a6be25ecdd0de309e0844bde637a2 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 2 Jul 2015 14:42:08 +0200 Subject: [PATCH 3/5] platform: add trace-logging to nm_platform_link_get_all() --- src/platform/nm-platform.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index 6a549d4ff0..d200df61fd 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -445,11 +445,14 @@ nm_platform_link_get_all (NMPlatform *self) item = &g_array_index (links, NMPlatformLink, i); if (item->ifindex <= 0 || g_hash_table_contains (unseen, GINT_TO_POINTER (item->ifindex))) { + _LOGT ("link-get: SKIP: %3d: %s", i, nm_platform_link_to_string (item)); g_warn_if_reached (); item->ifindex = 0; continue; } + _LOGT ("link-get: %3d: %s", i, nm_platform_link_to_string (item)); + g_hash_table_insert (unseen, GINT_TO_POINTER (item->ifindex), NULL); } @@ -499,6 +502,8 @@ nm_platform_link_get_all (NMPlatform *self) if (item->parent > 0 && g_hash_table_contains (unseen, GINT_TO_POINTER (item->parent))) continue; + _LOGT ("link-get: add %3d -> %3d: %s", i, j, nm_platform_link_to_string (item)); + g_hash_table_remove (unseen, GINT_TO_POINTER (item->ifindex)); g_array_index (result, NMPlatformLink, j++) = *item; item->ifindex = 0; @@ -507,9 +512,11 @@ nm_platform_link_get_all (NMPlatform *self) if (!found_something) { /* there is a circle, pop the first (remaining) element from the list */ - g_warn_if_reached (); item = &g_array_index (links, NMPlatformLink, first_idx); + _LOGT ("link-get: add (circle) %3d -> %3d: %s", first_idx, j, nm_platform_link_to_string (item)); + g_warn_if_reached (); + g_hash_table_remove (unseen, GINT_TO_POINTER (item->ifindex)); g_array_index (result, NMPlatformLink, j++) = *item; item->ifindex = 0; From 6f5cb596ba44ee0f639c9c9e6c03fef0a8527e0b Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 2 Jul 2015 14:52:21 +0200 Subject: [PATCH 4/5] platform/test: add test to call nm_platform_link_get_all() --- src/platform/tests/test-general.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/platform/tests/test-general.c b/src/platform/tests/test-general.c index 5684b67b81..0a397b3788 100644 --- a/src/platform/tests/test-general.c +++ b/src/platform/tests/test-general.c @@ -40,6 +40,19 @@ test_init_linux_platform (void) /******************************************************************/ +static void +test_link_get_all (void) +{ + gs_unref_object NMPlatform *platform = NULL; + gs_unref_array GArray *links = NULL; + + platform = g_object_new (NM_TYPE_LINUX_PLATFORM, NULL); + + links = nm_platform_link_get_all (platform); +} + +/******************************************************************/ + NMTST_DEFINE (); int @@ -48,6 +61,7 @@ main (int argc, char **argv) nmtst_init_assert_logging (&argc, &argv, "INFO", "DEFAULT"); g_test_add_func ("/general/init_linux_platform", test_init_linux_platform); + g_test_add_func ("/general/link_get_all", test_link_get_all); return g_test_run (); } From 5b208e718a3f431c2ab157556b811469e3486a03 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 2 Jul 2015 15:00:37 +0200 Subject: [PATCH 5/5] platform: remove unreachable code in nm_platform_link_get_all() Linux platform tracks links by ifindex. Hence an ifindex must be unique and positive. Just assert against it. --- src/platform/nm-platform.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index d200df61fd..ed0d3c4340 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -444,15 +444,10 @@ nm_platform_link_get_all (NMPlatform *self) for (i = 0; i < links->len; i++) { item = &g_array_index (links, NMPlatformLink, i); - if (item->ifindex <= 0 || g_hash_table_contains (unseen, GINT_TO_POINTER (item->ifindex))) { - _LOGT ("link-get: SKIP: %3d: %s", i, nm_platform_link_to_string (item)); - g_warn_if_reached (); - item->ifindex = 0; - continue; - } - _LOGT ("link-get: %3d: %s", i, nm_platform_link_to_string (item)); + nm_assert (item->ifindex > 0 && !g_hash_table_contains (unseen, GINT_TO_POINTER (item->ifindex))); + g_hash_table_insert (unseen, GINT_TO_POINTER (item->ifindex), NULL); }