1
0
mirror of https://github.com/systemd/systemd synced 2025-12-27 03:14:46 +01:00

Compare commits

...

13 Commits

Author SHA1 Message Date
Luca Boccassi
32c7f02bb4
Merge pull request #17829 from anitazha/testoomdfix
test: fix TEST-56-OOMD thresholds for linux 5.9 changes
2020-12-04 12:22:46 +00:00
Zbigniew Jędrzejewski-Szmek
a2c2421a05
Merge pull request #17834 from yuwata/network-ipv6-reject-type-route
network: handle IPv6 routes with reject type correctly
2020-12-04 12:19:35 +01:00
Vito Caputo
3a595c597a mmap-cache: replace stats accessors with log func
In preparation for logging more mmap-cache statistics get rid of this
piecemeal stats accessor api and just have a debug log output function
for producing the stats.

Updates the one call site using these accessors, moving what that site
did into the new log function.  So the output is unchanged for now,
just a trivial refactor.
2020-12-04 12:09:35 +01:00
Lennart Poettering
ffac398613
Merge pull request #17843 from poettering/dlfcn-dlsym-arg
add DLSYM_ARG() macro helper
2020-12-04 12:00:53 +01:00
Lennart Poettering
5517e214c8 tree-wide: make use of new DLSYM_ARG() macro everywhere 2020-12-04 10:41:59 +01:00
Lennart Poettering
e2f03674bc dlfcn-util: add DLSYM_ARG() helper 2020-12-04 10:41:59 +01:00
Yu Watanabe
452d86a532 test-network: add tests for IPv6 routes with reject type 2020-12-04 16:50:35 +09:00
Luca Boccassi
442bc2afee meson: check that cxx variable is set before using it
In some cases it is not defined. Eg in a yocto build:

src/systemd/meson.build:61:15: ERROR: Unknown variable cxx.
2020-12-04 08:35:56 +01:00
Yu Watanabe
37b9c79e5d test-network: sleep 1s after reloading configs
As interfaces will be reconfigured asynchronously after `networkctl reload`.
So, right after `networkctl reload` is finished, interfaces may be still
in 'configured' state with the old .network files.
2020-12-04 11:28:52 +09:00
Yu Watanabe
d9d6a10bce network: set protocol to route assigned through DHCP6 or DHCP6-PD 2020-12-04 11:23:23 +09:00
Yu Watanabe
575f14eef0 network: make IPv6 routes with reject type managed by Manager 2020-12-04 11:23:23 +09:00
Yu Watanabe
6c252588df network: introduce route_type_is_reject() helper 2020-12-04 11:23:23 +09:00
Anita Zhang
14d044da23 test: fix TEST-56-OOMD thresholds for linux 5.9 changes
Fixes #17533

The memory pressure values of the units in TEST-56-OOMD seemed to be a
lot lower after updating to linux 5.9. This is likely due to a fix from
e22c6ed90a.

To account for this, I lowered memory.high on testbloat.service to
throttle it even more. This was enough to generate the 50%+ value to trigger
oomd for the test, but as an extra precaution I also lowered the oomd
threshold to 1% so it's certain to try and kill testbloat.service.
2020-12-02 15:27:15 -08:00
17 changed files with 155 additions and 60 deletions

View File

@ -8,3 +8,9 @@
DEFINE_TRIVIAL_CLEANUP_FUNC(void*, dlclose);
int dlsym_many_and_warn(void *dl, int level, ...);
/* Macro useful for putting together variable/symbol name pairs when calling dlsym_many_and_warn(). Assumes
* that each library symbol to resolve will be placed in a variable with the "sym_" prefix, i.e. a symbol
* "foobar" is loaded into a variable "sym_foobar". */
#define DLSYM_ARG(arg) \
&sym_##arg, STRINGIFY(arg)

View File

@ -537,16 +537,10 @@ int mmap_cache_get(
return add_mmap(m, f, prot, context, keep_always, offset, size, st, ret, ret_size);
}
unsigned mmap_cache_get_hit(MMapCache *m) {
void mmap_cache_stats_log_debug(MMapCache *m) {
assert(m);
return m->n_hit;
}
unsigned mmap_cache_get_missed(MMapCache *m) {
assert(m);
return m->n_missed;
log_debug("mmap cache statistics: %u hit, %u miss", m->n_hit, m->n_missed);
}
static void mmap_cache_process_sigbus(MMapCache *m) {

View File

@ -28,7 +28,6 @@ int mmap_cache_get(
MMapFileDescriptor * mmap_cache_add_fd(MMapCache *m, int fd);
void mmap_cache_free_fd(MMapCache *m, MMapFileDescriptor *f);
unsigned mmap_cache_get_hit(MMapCache *m);
unsigned mmap_cache_get_missed(MMapCache *m);
void mmap_cache_stats_log_debug(MMapCache *m);
bool mmap_cache_got_sigbus(MMapCache *m, MMapFileDescriptor *f);

View File

@ -27,16 +27,24 @@ int dlopen_pcre2(void) {
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
"PCRE2 support is not installed: %s", dlerror());
/* So here's something weird: PCRE2 actually renames the symbols exported by the library via C
* macros, so that the exported symbols carry a suffix "_8" but when used from C the suffix is
* gone. In the argument list below we ignore this mangling. Surprisingly (at least to me), we
* actually get away with that. That's because DLSYM_ARG() useses STRINGIFY() to generate a string
* version of the symbol name, and that resolves the macro mapping implicitly already, so that the
* string actually contains the "_8" suffix already due to that and we don't have to append it
* manually anymore. C is weird. 🤯 */
r = dlsym_many_and_warn(
dl,
LOG_ERR,
&sym_pcre2_match_data_create, "pcre2_match_data_create_8",
&sym_pcre2_match_data_free, "pcre2_match_data_free_8",
&sym_pcre2_code_free, "pcre2_code_free_8",
&sym_pcre2_compile, "pcre2_compile_8",
&sym_pcre2_get_error_message, "pcre2_get_error_message_8",
&sym_pcre2_match, "pcre2_match_8",
&sym_pcre2_get_ovector_pointer, "pcre2_get_ovector_pointer_8",
DLSYM_ARG(pcre2_match_data_create),
DLSYM_ARG(pcre2_match_data_free),
DLSYM_ARG(pcre2_code_free),
DLSYM_ARG(pcre2_compile),
DLSYM_ARG(pcre2_get_error_message),
DLSYM_ARG(pcre2_match),
DLSYM_ARG(pcre2_get_ovector_pointer),
NULL);
if (r < 0)
return r;

View File

@ -2170,7 +2170,7 @@ _public_ void sd_journal_close(sd_journal *j) {
safe_close(j->inotify_fd);
if (j->mmap) {
log_debug("mmap cache statistics: %u hit, %u miss", mmap_cache_get_hit(j->mmap), mmap_cache_get_missed(j->mmap));
mmap_cache_stats_log_debug(j->mmap);
mmap_cache_unref(j->mmap);
}

View File

@ -279,6 +279,7 @@ static int dhcp6_set_pd_route(Link *link, const union in_addr_union *prefix, con
route->family = AF_INET6;
route->dst = *prefix;
route->dst_prefixlen = 64;
route->protocol = RTPROT_DHCP;
r = route_configure(route, link, dhcp6_pd_route_handler, &ret);
if (r < 0)
@ -826,6 +827,7 @@ static int dhcp6_set_unreachable_route(Link *link, const union in_addr_union *ad
route->dst_prefixlen = prefixlen;
route->table = link_get_dhcp_route_table(link);
route->type = RTN_UNREACHABLE;
route->protocol = RTPROT_DHCP;
r = route_configure(route, link, dhcp6_route_handler, &ret);
if (r < 0)

View File

@ -575,6 +575,12 @@ static int route_add(Manager *manager, Link *link, const Route *in, const Multip
return 0;
}
static bool route_type_is_reject(const Route *route) {
assert(route);
return IN_SET(route->type, RTN_UNREACHABLE, RTN_PROHIBIT, RTN_BLACKHOLE, RTN_THROW);
}
static int route_set_netlink_message(const Route *route, sd_netlink_message *req, Link *link) {
unsigned flags;
int r;
@ -660,7 +666,7 @@ static int route_set_netlink_message(const Route *route, sd_netlink_message *req
if (r < 0)
return log_link_error_errno(link, r, "Could not set route type: %m");
if (!IN_SET(route->type, RTN_UNREACHABLE, RTN_PROHIBIT, RTN_BLACKHOLE, RTN_THROW)) {
if (!route_type_is_reject(route)) {
assert(link); /* Those routes must be attached to a specific link */
r = sd_netlink_message_append_u32(req, RTA_OIF, link->ifindex);
@ -927,7 +933,7 @@ static int route_add_and_setup_timer(Link *link, const Route *route, const Multi
assert(link);
assert(route);
if (IN_SET(route->type, RTN_UNREACHABLE, RTN_PROHIBIT, RTN_BLACKHOLE, RTN_THROW))
if (route_type_is_reject(route))
r = route_add(link->manager, NULL, route, NULL, &nr);
else if (!m || m->ifindex == 0 || m->ifindex == link->ifindex)
r = route_add(NULL, link, route, m, &nr);
@ -1576,6 +1582,12 @@ int manager_rtnl_process_route(sd_netlink *rtnl, sd_netlink_message *message, Ma
}
}
/* IPv6 routes with reject type are always assigned to the loopback interface. See kernel's
* fib6_nh_init() in net/ipv6/route.c. However, we'd like to manage them by Manager. Hence, set
* link to NULL here. */
if (route_type_is_reject(tmp))
link = NULL;
if (ordered_set_isempty(multipath_routes))
(void) process_route_one(m, link, type, tmp, NULL);
else {

View File

@ -43,25 +43,25 @@ int dlopen_cryptsetup(void) {
r = dlsym_many_and_warn(
dl,
LOG_DEBUG,
&sym_crypt_activate_by_passphrase, "crypt_activate_by_passphrase",
DLSYM_ARG(crypt_activate_by_passphrase),
#if HAVE_CRYPT_ACTIVATE_BY_SIGNED_KEY
&sym_crypt_activate_by_signed_key, "crypt_activate_by_signed_key",
DLSYM_ARG(crypt_activate_by_signed_key),
#endif
&sym_crypt_activate_by_volume_key, "crypt_activate_by_volume_key",
&sym_crypt_deactivate_by_name, "crypt_deactivate_by_name",
&sym_crypt_format, "crypt_format",
&sym_crypt_free, "crypt_free",
&sym_crypt_get_dir, "crypt_get_dir",
&sym_crypt_get_verity_info, "crypt_get_verity_info",
&sym_crypt_init, "crypt_init",
&sym_crypt_init_by_name, "crypt_init_by_name",
&sym_crypt_keyslot_add_by_volume_key, "crypt_keyslot_add_by_volume_key",
&sym_crypt_load, "crypt_load",
&sym_crypt_resize, "crypt_resize",
&sym_crypt_set_data_device, "crypt_set_data_device",
&sym_crypt_set_debug_level, "crypt_set_debug_level",
&sym_crypt_set_log_callback, "crypt_set_log_callback",
&sym_crypt_volume_key_get, "crypt_volume_key_get",
DLSYM_ARG(crypt_activate_by_volume_key),
DLSYM_ARG(crypt_deactivate_by_name),
DLSYM_ARG(crypt_format),
DLSYM_ARG(crypt_free),
DLSYM_ARG(crypt_get_dir),
DLSYM_ARG(crypt_get_verity_info),
DLSYM_ARG(crypt_init),
DLSYM_ARG(crypt_init_by_name),
DLSYM_ARG(crypt_keyslot_add_by_volume_key),
DLSYM_ARG(crypt_load),
DLSYM_ARG(crypt_resize),
DLSYM_ARG(crypt_set_data_device),
DLSYM_ARG(crypt_set_debug_level),
DLSYM_ARG(crypt_set_log_callback),
DLSYM_ARG(crypt_volume_key_get),
NULL);
if (r < 0)
return r;

View File

@ -35,9 +35,9 @@ int dlopen_idn(void) {
r = dlsym_many_and_warn(
dl,
LOG_DEBUG,
&sym_idn2_lookup_u8, "idn2_lookup_u8",
&sym_idn2_strerror, "idn2_strerror",
&sym_idn2_to_unicode_8z8z, "idn2_to_unicode_8z8z",
DLSYM_ARG(idn2_lookup_u8),
DLSYM_ARG(idn2_strerror),
DLSYM_ARG(idn2_to_unicode_8z8z),
NULL);
if (r < 0)
return r;
@ -76,10 +76,10 @@ int dlopen_idn(void) {
r = dlsym_many_and_warn(
dl,
LOG_DEBUG,
&sym_idna_to_ascii_4i, "idna_to_ascii_4i",
&sym_idna_to_unicode_44i, "idna_to_unicode_44i",
&sym_stringprep_ucs4_to_utf8, "stringprep_ucs4_to_utf8",
&sym_stringprep_utf8_to_ucs4, "stringprep_utf8_to_ucs4",
DLSYM_ARG(idna_to_ascii_4i),
DLSYM_ARG(idna_to_unicode_44i),
DLSYM_ARG(stringprep_ucs4_to_utf8),
DLSYM_ARG(stringprep_utf8_to_ucs4),
NULL);
if (r < 0)
return r;

View File

@ -38,14 +38,14 @@ int dlopen_pwquality(void) {
r = dlsym_many_and_warn(
dl,
LOG_DEBUG,
&sym_pwquality_check, "pwquality_check",
&sym_pwquality_default_settings, "pwquality_default_settings",
&sym_pwquality_free_settings, "pwquality_free_settings",
&sym_pwquality_generate, "pwquality_generate",
&sym_pwquality_get_str_value, "pwquality_get_str_value",
&sym_pwquality_read_config, "pwquality_read_config",
&sym_pwquality_set_int_value, "pwquality_set_int_value",
&sym_pwquality_strerror, "pwquality_strerror",
DLSYM_ARG(pwquality_check),
DLSYM_ARG(pwquality_default_settings),
DLSYM_ARG(pwquality_free_settings),
DLSYM_ARG(pwquality_generate),
DLSYM_ARG(pwquality_get_str_value),
DLSYM_ARG(pwquality_read_config),
DLSYM_ARG(pwquality_set_int_value),
DLSYM_ARG(pwquality_strerror),
NULL);
if (r < 0)
return r;

View File

@ -84,8 +84,8 @@ int print_qrcode(FILE *out, const char *header, const char *string) {
r = dlsym_many_and_warn(
dl,
LOG_DEBUG,
&sym_QRcode_encodeString, "QRcode_encodeString",
&sym_QRcode_free, "QRcode_free",
DLSYM_ARG(QRcode_encodeString),
DLSYM_ARG(QRcode_free),
NULL);
if (r < 0)
return r;

View File

@ -54,7 +54,7 @@ if cc.has_argument('-std=iso9899:2017')
opts += [['c', '-std=iso9899:2017']]
endif
if add_languages('cpp', required : false)
if cxx_cmd != ''
opts += [['c++'],
['c++', '-std=c++98'],
['c++', '-std=c++11']]

View File

@ -48,6 +48,18 @@ Destination=202.54.1.3
Type=prohibit
Destination=202.54.1.4
[Route]
Type=blackhole
Destination=2001:1234:5678::2
[Route]
Type=unreachable
Destination=2001:1234:5678::3
[Route]
Type=prohibit
Destination=2001:1234:5678::4
[Route]
Type=local
Destination=149.10.123.1

View File

@ -2216,6 +2216,21 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
print(output)
self.assertRegex(output, 'prohibit 202.54.1.4 proto static')
print('### ip -6 route show type blackhole')
output = check_output('ip -6 route show type blackhole')
print(output)
self.assertIn('blackhole 2001:1234:5678::2 dev lo proto static', output)
print('### ip -6 route show type unreachable')
output = check_output('ip -6 route show type unreachable')
print(output)
self.assertIn('unreachable 2001:1234:5678::3 dev lo proto static', output)
print('### ip -6 route show type prohibit')
output = check_output('ip -6 route show type prohibit')
print(output)
self.assertIn('prohibit 2001:1234:5678::4 dev lo proto static', output)
print('### ip route show 192.168.10.1')
output = check_output('ip route show 192.168.10.1')
print(output)
@ -2242,6 +2257,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
copy_unit_to_networkd_unit_path('25-address-static.network')
check_output(*networkctl_cmd, 'reload', env=env)
time.sleep(1)
self.wait_online(['dummy98:routable'])
# check all routes managed by Manager are removed
@ -2260,8 +2276,24 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
print(output)
self.assertEqual(output, '')
print('### ip -6 route show type blackhole')
output = check_output('ip -6 route show type blackhole')
print(output)
self.assertEqual(output, '')
print('### ip -6 route show type unreachable')
output = check_output('ip -6 route show type unreachable')
print(output)
self.assertEqual(output, '')
print('### ip -6 route show type prohibit')
output = check_output('ip -6 route show type prohibit')
print(output)
self.assertEqual(output, '')
remove_unit_from_networkd_path(['25-address-static.network'])
check_output(*networkctl_cmd, 'reload', env=env)
time.sleep(1)
self.wait_online(['dummy98:routable'])
# check all routes managed by Manager are reconfigured
@ -2280,6 +2312,21 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
print(output)
self.assertRegex(output, 'prohibit 202.54.1.4 proto static')
print('### ip -6 route show type blackhole')
output = check_output('ip -6 route show type blackhole')
print(output)
self.assertIn('blackhole 2001:1234:5678::2 dev lo proto static', output)
print('### ip -6 route show type unreachable')
output = check_output('ip -6 route show type unreachable')
print(output)
self.assertIn('unreachable 2001:1234:5678::3 dev lo proto static', output)
print('### ip -6 route show type prohibit')
output = check_output('ip -6 route show type prohibit')
print(output)
self.assertIn('prohibit 2001:1234:5678::4 dev lo proto static', output)
rc = call("ip link del dummy98")
self.assertEqual(rc, 0)
time.sleep(2)
@ -2300,6 +2347,21 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
print(output)
self.assertEqual(output, '')
print('### ip -6 route show type blackhole')
output = check_output('ip -6 route show type blackhole')
print(output)
self.assertEqual(output, '')
print('### ip -6 route show type unreachable')
output = check_output('ip -6 route show type unreachable')
print(output)
self.assertEqual(output, '')
print('### ip -6 route show type prohibit')
output = check_output('ip -6 route show type prohibit')
print(output)
self.assertEqual(output, '')
@expectedFailureIfRTA_VIAIsNotSupported()
def test_route_via_ipv6(self):
copy_unit_to_networkd_unit_path('25-route-via-ipv6.network', '12-dummy.netdev')

View File

@ -2,8 +2,8 @@
Description=Create a lot of memory pressure
[Service]
# A very small memory.high will cause the script (trying to use a lot of memory)
# to throttle and be put under heavy pressure
MemoryHigh=2M
# A VERY small memory.high will cause the script (trying to use a lot of memory)
# to throttle and be put under heavy pressure.
MemoryHigh=1M
Slice=testsuite-56-workload.slice
ExecStart=/usr/lib/systemd/tests/testdata/units/testsuite-56-slowgrowth.sh

View File

@ -7,4 +7,4 @@ MemoryAccounting=true
IOAccounting=true
TasksAccounting=true
ManagedOOMMemoryPressure=kill
ManagedOOMMemoryPressureLimitPercent=50%
ManagedOOMMemoryPressureLimitPercent=1%

View File

@ -19,7 +19,7 @@ systemctl start testsuite-56-testchill.service
# Verify systemd-oomd is monitoring the expected units
oomctl | grep "/testsuite-56-workload.slice"
oomctl | grep "50%"
oomctl | grep "1%"
# systemd-oomd watches for elevated pressure for 30 seconds before acting.
# It can take time to build up pressure so either wait 5 minutes or for the service to fail.