mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-04-22 12:50:40 +02:00
merge branch 'backport' into nm-1-0
Backport a few bug fixes from master. Also backport the valgrind suppression file and changes to platform's 'test-common.c'.
This commit is contained in:
commit
8be0592107
9 changed files with 134 additions and 55 deletions
|
|
@ -799,9 +799,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -834,9 +831,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2365,7 +2365,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;
|
||||
|
|
|
|||
|
|
@ -2623,6 +2623,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
|
||||
|
|
|
|||
|
|
@ -4,6 +4,18 @@
|
|||
|
||||
#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 ()
|
||||
{
|
||||
NM_PRAGMA_WARNING_DISABLE("-Wtautological-compare")
|
||||
return (SETUP == nm_linux_platform_setup);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
|
||||
SignalData *
|
||||
add_signal_full (const char *name, NMPlatformSignalChangeType change_type, GCallback callback, int ifindex, const char *ifname)
|
||||
{
|
||||
|
|
@ -11,7 +23,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;
|
||||
|
|
@ -37,33 +49,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);
|
||||
|
|
@ -72,7 +102,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;
|
||||
|
|
@ -94,11 +123,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 (ifindex));
|
||||
|
|
@ -257,8 +283,7 @@ main (int argc, char **argv)
|
|||
|
||||
init_tests (&argc, &argv);
|
||||
|
||||
NM_PRAGMA_WARNING_DISABLE("-Wtautological-compare")
|
||||
if (SETUP == nm_linux_platform_setup && getuid() != 0) {
|
||||
if (nmtst_platform_is_root_test () && getuid() != 0) {
|
||||
/* Try to exec as sudo, this function does not return, if a sudo-cmd is set. */
|
||||
nmtst_reexec_sudo ();
|
||||
|
||||
|
|
@ -270,7 +295,6 @@ main (int argc, char **argv)
|
|||
return 77;
|
||||
#endif
|
||||
}
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
|
||||
SETUP ();
|
||||
|
||||
|
|
|
|||
|
|
@ -22,19 +22,28 @@ typedef struct {
|
|||
int handler_id;
|
||||
const char *name;
|
||||
NMPlatformSignalChangeType change_type;
|
||||
gboolean received;
|
||||
gint received_count;
|
||||
GMainLoop *loop;
|
||||
int ifindex;
|
||||
const char *ifname;
|
||||
} SignalData;
|
||||
|
||||
gboolean nmtst_platform_is_root_test (void);
|
||||
|
||||
SignalData *add_signal_full (const char *name, NMPlatformSignalChangeType change_type, GCallback callback, int ifindex, const char *ifname);
|
||||
#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);
|
||||
|
||||
|
|
|
|||
|
|
@ -365,14 +365,12 @@ test_bridge (void)
|
|||
static void
|
||||
test_bond (void)
|
||||
{
|
||||
NM_PRAGMA_WARNING_DISABLE("-Wtautological-compare")
|
||||
if (SETUP == nm_linux_platform_setup &&
|
||||
if (nmtst_platform_is_root_test () &&
|
||||
!g_file_test ("/proc/1/net/bonding", G_FILE_TEST_IS_DIR) &&
|
||||
system("modprobe --show bonding") != 0) {
|
||||
g_test_skip ("Skipping test for bonding: bonding module not available");
|
||||
return;
|
||||
}
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
|
||||
test_software (NM_LINK_TYPE_BOND, "bond");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 (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 (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);
|
||||
|
|
|
|||
|
|
@ -396,3 +396,64 @@
|
|||
...
|
||||
}
|
||||
|
||||
###############################################################
|
||||
# libnl3
|
||||
###############################################################
|
||||
|
||||
{
|
||||
# fixed by https://github.com/thom311/libnl/commit/d65c32a7205e679c7fc13f0e4565b13e698ba906
|
||||
libnl_rtnl_link_set_type_01
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: definite
|
||||
fun:calloc
|
||||
fun:vlan_alloc
|
||||
fun:rtnl_link_set_type
|
||||
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
|
||||
...
|
||||
}
|
||||
{
|
||||
# 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:vlan_alloc
|
||||
fun:rtnl_link_set_type
|
||||
fun:link_msg_parser
|
||||
fun:nl_cache_parse
|
||||
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