mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-05 22:50:28 +01:00
platform: merge branch 'th/platform_refact_caching-bgo747981' (early part)
Merge a first part of th/platform_refact_caching-bgo747981 https://bugzilla.gnome.org/show_bug.cgi?id=747981
This commit is contained in:
commit
f628d0ad5a
9 changed files with 100 additions and 80 deletions
|
|
@ -832,9 +832,6 @@ nmtst_platform_ip4_routes_equal (const NMPlatformIP4Route *a, const NMPlatformIP
|
|||
nmtst_static_1024_02 (nm_platform_ip4_route_to_string (&b[i])));
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
/* also check with memcmp, though this might fail for valid programs (due to field alignment) */
|
||||
g_assert_cmpint (memcmp (&a[i], &b[i], sizeof (a[i])), ==, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -867,9 +864,6 @@ nmtst_platform_ip6_routes_equal (const NMPlatformIP6Route *a, const NMPlatformIP
|
|||
nmtst_static_1024_02 (nm_platform_ip6_route_to_string (&b[i])));
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
/* also check with memcmp, though this might fail for valid programs (due to field alignment) */
|
||||
g_assert_cmpint (memcmp (&a[i], &b[i], sizeof (a[i])), ==, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2516,7 +2516,7 @@ static gboolean
|
|||
link_delete (NMPlatform *platform, int ifindex)
|
||||
{
|
||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
||||
struct rtnl_link *rtnllink = rtnl_link_get (priv->link_cache, ifindex);
|
||||
auto_nl_object struct rtnl_link *rtnllink = rtnl_link_get (priv->link_cache, ifindex);
|
||||
|
||||
if (!rtnllink) {
|
||||
platform->error = NM_PLATFORM_ERROR_NOT_FOUND;
|
||||
|
|
|
|||
|
|
@ -2767,6 +2767,7 @@ int
|
|||
nm_platform_link_cmp (const NMPlatformLink *a, const NMPlatformLink *b)
|
||||
{
|
||||
_CMP_POINTER (a, b);
|
||||
_CMP_FIELD (a, b, ifindex);
|
||||
_CMP_FIELD (a, b, type);
|
||||
_CMP_FIELD_STR (a, b, name);
|
||||
_CMP_FIELD (a, b, master);
|
||||
|
|
|
|||
|
|
@ -24,10 +24,8 @@ ip4_address_callback (NMPlatform *platform, int ifindex, NMPlatformIP4Address *r
|
|||
if (data->loop)
|
||||
g_main_loop_quit (data->loop);
|
||||
|
||||
if (data->received)
|
||||
g_error ("Received signal '%s' a second time.", data->name);
|
||||
|
||||
data->received = TRUE;
|
||||
data->received_count++;
|
||||
debug ("Received signal '%s' %dth time.", data->name, data->received_count);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -46,10 +44,8 @@ ip6_address_callback (NMPlatform *platform, int ifindex, NMPlatformIP6Address *r
|
|||
if (data->loop)
|
||||
g_main_loop_quit (data->loop);
|
||||
|
||||
if (data->received)
|
||||
g_error ("Received signal '%s' a second time.", data->name);
|
||||
|
||||
data->received = TRUE;
|
||||
data->received_count++;
|
||||
debug ("Received signal '%s' %dth time.", data->name, data->received_count);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@
|
|||
|
||||
#include "nm-test-utils.h"
|
||||
|
||||
#define SIGNAL_DATA_FMT "'%s-%s' ifindex %d%s%s%s (%d times received)"
|
||||
#define SIGNAL_DATA_ARG(data) (data)->name, _change_type_to_string ((data)->change_type), (data)->ifindex, (data)->ifname ? " ifname '" : "", (data)->ifname ? (data)->ifname : "", (data)->ifname ? "'" : "", (data)->received_count
|
||||
|
||||
|
||||
gboolean
|
||||
nmtst_platform_is_root_test ()
|
||||
|
|
@ -23,7 +26,7 @@ add_signal_full (const char *name, NMPlatformSignalChangeType change_type, GCall
|
|||
|
||||
data->name = name;
|
||||
data->change_type = change_type;
|
||||
data->received = FALSE;
|
||||
data->received_count = 0;
|
||||
data->handler_id = g_signal_connect (nm_platform_get (), name, callback, data);
|
||||
data->ifindex = ifindex;
|
||||
data->ifname = ifname;
|
||||
|
|
@ -49,33 +52,51 @@ _change_type_to_string (NMPlatformSignalChangeType change_type)
|
|||
}
|
||||
|
||||
void
|
||||
accept_signal (SignalData *data)
|
||||
_accept_signal (const char *file, int line, const char *func, SignalData *data)
|
||||
{
|
||||
debug ("Accepting signal '%s-%s' ifindex %d ifname %s.", data->name, _change_type_to_string (data->change_type), data->ifindex, data->ifname);
|
||||
if (!data->received)
|
||||
g_error ("Attemted to accept a non-received signal '%s-%s'.", data->name, _change_type_to_string (data->change_type));
|
||||
|
||||
data->received = FALSE;
|
||||
debug ("NMPlatformSignalAssert: %s:%d, %s(): Accepting signal one time: "SIGNAL_DATA_FMT, file, line, func, SIGNAL_DATA_ARG (data));
|
||||
if (data->received_count != 1)
|
||||
g_error ("NMPlatformSignalAssert: %s:%d, %s(): failure to accept signal one time: "SIGNAL_DATA_FMT, file, line, func, SIGNAL_DATA_ARG (data));
|
||||
data->received_count = 0;
|
||||
}
|
||||
|
||||
void
|
||||
wait_signal (SignalData *data)
|
||||
_accept_signals (const char *file, int line, const char *func, SignalData *data, int min, int max)
|
||||
{
|
||||
if (data->received)
|
||||
g_error ("Signal '%s' received before waiting for it.", data->name);
|
||||
debug ("NMPlatformSignalAssert: %s:%d, %s(): Accepting signal [%d,%d] times: "SIGNAL_DATA_FMT, file, line, func, min, max, SIGNAL_DATA_ARG (data));
|
||||
if (data->received_count < min || data->received_count > max)
|
||||
g_error ("NMPlatformSignalAssert: %s:%d, %s(): failure to accept signal [%d,%d] times: "SIGNAL_DATA_FMT, file, line, func, min, max, SIGNAL_DATA_ARG (data));
|
||||
data->received_count = 0;
|
||||
}
|
||||
|
||||
void
|
||||
_ensure_no_signal (const char *file, int line, const char *func, SignalData *data)
|
||||
{
|
||||
debug ("NMPlatformSignalAssert: %s:%d, %s(): Accepting signal 0 times: "SIGNAL_DATA_FMT, file, line, func, SIGNAL_DATA_ARG (data));
|
||||
if (data->received_count > 0)
|
||||
g_error ("NMPlatformSignalAssert: %s:%d, %s(): failure to accept signal 0 times: "SIGNAL_DATA_FMT, file, line, func, SIGNAL_DATA_ARG (data));
|
||||
}
|
||||
|
||||
void
|
||||
_wait_signal (const char *file, int line, const char *func, SignalData *data)
|
||||
{
|
||||
debug ("NMPlatformSignalAssert: %s:%d, %s(): wait signal: "SIGNAL_DATA_FMT, file, line, func, SIGNAL_DATA_ARG (data));
|
||||
if (data->received_count)
|
||||
g_error ("NMPlatformSignalAssert: %s:%d, %s(): failure to wait for signal: "SIGNAL_DATA_FMT, file, line, func, SIGNAL_DATA_ARG (data));
|
||||
|
||||
data->loop = g_main_loop_new (NULL, FALSE);
|
||||
g_main_loop_run (data->loop);
|
||||
g_clear_pointer (&data->loop, g_main_loop_unref);
|
||||
|
||||
accept_signal (data);
|
||||
_accept_signal (file, line, func, data);
|
||||
}
|
||||
|
||||
void
|
||||
free_signal (SignalData *data)
|
||||
_free_signal (const char *file, int line, const char *func, SignalData *data)
|
||||
{
|
||||
if (data->received)
|
||||
g_error ("Attempted to free received but not accepted signal '%s-%s'.", data->name, _change_type_to_string (data->change_type));
|
||||
debug ("NMPlatformSignalAssert: %s:%d, %s(): free signal: "SIGNAL_DATA_FMT, file, line, func, SIGNAL_DATA_ARG (data));
|
||||
if (data->received_count != 0)
|
||||
g_error ("NMPlatformSignalAssert: %s:%d, %s(): failure to free non-accepted signal: "SIGNAL_DATA_FMT, file, line, func, SIGNAL_DATA_ARG (data));
|
||||
|
||||
g_signal_handler_disconnect (nm_platform_get (), data->handler_id);
|
||||
g_free (data);
|
||||
|
|
@ -84,7 +105,6 @@ free_signal (SignalData *data)
|
|||
void
|
||||
link_callback (NMPlatform *platform, int ifindex, NMPlatformLink *received, NMPlatformSignalChangeType change_type, NMPlatformReason reason, SignalData *data)
|
||||
{
|
||||
|
||||
GArray *links;
|
||||
NMPlatformLink *cached;
|
||||
int i;
|
||||
|
|
@ -106,11 +126,8 @@ link_callback (NMPlatform *platform, int ifindex, NMPlatformLink *received, NMPl
|
|||
g_main_loop_quit (data->loop);
|
||||
}
|
||||
|
||||
if (data->received)
|
||||
g_error ("Received signal '%s-%s' a second time.", data->name, _change_type_to_string (data->change_type));
|
||||
|
||||
debug ("Received signal '%s-%s' ifindex %d ifname '%s'.", data->name, _change_type_to_string (data->change_type), ifindex, received->name);
|
||||
data->received = TRUE;
|
||||
data->received_count++;
|
||||
debug ("Received signal '%s-%s' ifindex %d ifname '%s' %dth time.", data->name, _change_type_to_string (data->change_type), ifindex, received->name, data->received_count);
|
||||
|
||||
if (change_type == NM_PLATFORM_SIGNAL_REMOVED)
|
||||
g_assert (!nm_platform_link_get_name (NM_PLATFORM_GET, ifindex));
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ typedef struct {
|
|||
int handler_id;
|
||||
const char *name;
|
||||
NMPlatformSignalChangeType change_type;
|
||||
gboolean received;
|
||||
gint received_count;
|
||||
GMainLoop *loop;
|
||||
int ifindex;
|
||||
const char *ifname;
|
||||
|
|
@ -34,9 +34,16 @@ SignalData *add_signal_full (const char *name, NMPlatformSignalChangeType change
|
|||
#define add_signal(name, change_type, callback) add_signal_full (name, change_type, (GCallback) callback, 0, NULL)
|
||||
#define add_signal_ifindex(name, change_type, callback, ifindex) add_signal_full (name, change_type, (GCallback) callback, ifindex, NULL)
|
||||
#define add_signal_ifname(name, change_type, callback, ifname) add_signal_full (name, change_type, (GCallback) callback, 0, ifname)
|
||||
void accept_signal (SignalData *data);
|
||||
void wait_signal (SignalData *data);
|
||||
void free_signal (SignalData *data);
|
||||
void _accept_signal (const char *file, int line, const char *func, SignalData *data);
|
||||
void _accept_signals (const char *file, int line, const char *func, SignalData *data, int min, int max);
|
||||
void _wait_signal (const char *file, int line, const char *func, SignalData *data);
|
||||
void _ensure_no_signal (const char *file, int line, const char *func, SignalData *data);
|
||||
void _free_signal (const char *file, int line, const char *func, SignalData *data);
|
||||
#define accept_signal(data) _accept_signal(__FILE__, __LINE__, G_STRFUNC, data)
|
||||
#define accept_signals(data, min, max) _accept_signals(__FILE__, __LINE__, G_STRFUNC, data, min, max)
|
||||
#define wait_signal(data) _wait_signal(__FILE__, __LINE__, G_STRFUNC, data)
|
||||
#define ensure_no_signal(data) _ensure_no_signal(__FILE__, __LINE__, G_STRFUNC, data)
|
||||
#define free_signal(data) _free_signal(__FILE__, __LINE__, G_STRFUNC, data)
|
||||
|
||||
gboolean ip4_route_exists (const char *ifname, guint32 network, int plen, guint32 metric);
|
||||
|
||||
|
|
|
|||
|
|
@ -22,10 +22,8 @@ ip4_route_callback (NMPlatform *platform, int ifindex, NMPlatformIP4Route *recei
|
|||
if (data->loop)
|
||||
g_main_loop_quit (data->loop);
|
||||
|
||||
if (data->received)
|
||||
g_error ("Received signal '%s' a second time.", data->name);
|
||||
|
||||
data->received = TRUE;
|
||||
data->received_count++;
|
||||
debug ("Received signal '%s' %dth time.", data->name, data->received_count);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -44,10 +42,8 @@ ip6_route_callback (NMPlatform *platform, int ifindex, NMPlatformIP6Route *recei
|
|||
if (data->loop)
|
||||
g_main_loop_quit (data->loop);
|
||||
|
||||
if (data->received)
|
||||
g_error ("Received signal '%s' a second time.", data->name);
|
||||
|
||||
data->received = TRUE;
|
||||
data->received_count++;
|
||||
debug ("Received signal '%s' %dth time.", data->name, data->received_count);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -77,7 +73,7 @@ test_ip4_route_metric0 (void)
|
|||
/* Deleting route with metric 0 does nothing */
|
||||
g_assert (nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, 0));
|
||||
no_error ();
|
||||
g_assert (!route_removed->received);
|
||||
ensure_no_signal (route_removed);
|
||||
|
||||
assert_ip4_route_exists (FALSE, DEVICE_NAME, network, plen, 0);
|
||||
assert_ip4_route_exists (TRUE, DEVICE_NAME, network, plen, metric);
|
||||
|
|
@ -101,7 +97,7 @@ test_ip4_route_metric0 (void)
|
|||
/* Delete route with metric 0 again (we expect nothing to happen) */
|
||||
g_assert (nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, 0));
|
||||
no_error ();
|
||||
g_assert (!route_removed->received);
|
||||
ensure_no_signal (route_removed);
|
||||
|
||||
assert_ip4_route_exists (FALSE, DEVICE_NAME, network, plen, 0);
|
||||
assert_ip4_route_exists (TRUE, DEVICE_NAME, network, plen, metric);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ static void
|
|||
setup_dev0_ip4 (int ifindex, guint mss_of_first_route, guint32 metric_of_second_route)
|
||||
{
|
||||
GArray *routes = g_array_new (FALSE, FALSE, sizeof (NMPlatformIP4Route));
|
||||
NMPlatformIP4Route route;
|
||||
NMPlatformIP4Route route = { 0 };
|
||||
|
||||
route.ifindex = ifindex;
|
||||
route.mss = 0;
|
||||
|
|
@ -68,7 +68,7 @@ static void
|
|||
setup_dev1_ip4 (int ifindex)
|
||||
{
|
||||
GArray *routes = g_array_new (FALSE, FALSE, sizeof (NMPlatformIP4Route));
|
||||
NMPlatformIP4Route route;
|
||||
NMPlatformIP4Route route = { 0 };
|
||||
|
||||
route.ifindex = ifindex;
|
||||
route.mss = 0;
|
||||
|
|
@ -114,7 +114,7 @@ static void
|
|||
update_dev0_ip4 (int ifindex)
|
||||
{
|
||||
GArray *routes = g_array_new (FALSE, FALSE, sizeof (NMPlatformIP4Route));
|
||||
NMPlatformIP4Route route;
|
||||
NMPlatformIP4Route route = { 0 };
|
||||
|
||||
route.ifindex = ifindex;
|
||||
route.mss = 0;
|
||||
|
|
|
|||
|
|
@ -395,24 +395,14 @@
|
|||
fun:g_dbus_proxy_finalize
|
||||
...
|
||||
}
|
||||
|
||||
###############################################################
|
||||
# libnl3
|
||||
###############################################################
|
||||
|
||||
{
|
||||
libnl_01
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: definite
|
||||
fun:calloc
|
||||
fun:nl_object_alloc
|
||||
fun:link_msg_parser
|
||||
fun:__pickup_answer
|
||||
fun:nl_cb_call
|
||||
fun:recvmsgs
|
||||
fun:nl_recvmsgs_report
|
||||
fun:nl_recvmsgs
|
||||
fun:nl_pickup
|
||||
fun:rtnl_link_get_kernel
|
||||
...
|
||||
}
|
||||
{
|
||||
libnl_02
|
||||
# fixed by https://github.com/thom311/libnl/commit/d65c32a7205e679c7fc13f0e4565b13e698ba906
|
||||
libnl_rtnl_link_set_type_01
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: definite
|
||||
fun:calloc
|
||||
|
|
@ -429,22 +419,41 @@
|
|||
...
|
||||
}
|
||||
{
|
||||
libnl_03
|
||||
# fixed by https://github.com/thom311/libnl/commit/d65c32a7205e679c7fc13f0e4565b13e698ba906
|
||||
# Same issue as libnl_rtnl_link_set_type_01, but different backtrace by calling nl_msg_parse().
|
||||
libnl_rtnl_link_set_type_02
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: definite
|
||||
fun:calloc
|
||||
fun:nl_object_alloc
|
||||
fun:vlan_alloc
|
||||
fun:rtnl_link_set_type
|
||||
fun:link_msg_parser
|
||||
fun:nl_cache_parse
|
||||
fun:update_msg_parser
|
||||
fun:nl_cb_call
|
||||
fun:recvmsgs
|
||||
fun:nl_recvmsgs_report
|
||||
fun:nl_recvmsgs
|
||||
fun:__cache_pickup
|
||||
fun:nl_cache_pickup
|
||||
fun:nl_cache_refill
|
||||
fun:rtnl_link_alloc_cache
|
||||
fun:nl_msg_parse
|
||||
...
|
||||
}
|
||||
|
||||
# disable the following suppression. I cannot remember why it was needed,
|
||||
# maybe it's wrong.
|
||||
#
|
||||
# {
|
||||
# libnl_02
|
||||
# libnl_rtnl_link_alloc_cache
|
||||
# Memcheck:Leak
|
||||
# match-leak-kinds: definite
|
||||
# fun:calloc
|
||||
# fun:nl_object_alloc
|
||||
# fun:link_msg_parser
|
||||
# fun:nl_cache_parse
|
||||
# fun:update_msg_parser
|
||||
# fun:nl_cb_call
|
||||
# fun:recvmsgs
|
||||
# fun:nl_recvmsgs_report
|
||||
# fun:nl_recvmsgs
|
||||
# fun:__cache_pickup
|
||||
# fun:nl_cache_pickup
|
||||
# fun:nl_cache_refill
|
||||
# fun:rtnl_link_alloc_cache
|
||||
# ...
|
||||
# }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue