1
0
mirror of https://github.com/systemd/systemd synced 2025-12-29 12:24:45 +01:00

Compare commits

..

No commits in common. "32c7f02bb49bb348ff2256dbfd35a5f0136915ff" and "62e3a988f23f906e231a80a768d43e3f0b7a9161" have entirely different histories.

17 changed files with 60 additions and 155 deletions

View File

@ -8,9 +8,3 @@
DEFINE_TRIVIAL_CLEANUP_FUNC(void*, dlclose); DEFINE_TRIVIAL_CLEANUP_FUNC(void*, dlclose);
int dlsym_many_and_warn(void *dl, int level, ...); 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,10 +537,16 @@ int mmap_cache_get(
return add_mmap(m, f, prot, context, keep_always, offset, size, st, ret, ret_size); return add_mmap(m, f, prot, context, keep_always, offset, size, st, ret, ret_size);
} }
void mmap_cache_stats_log_debug(MMapCache *m) { unsigned mmap_cache_get_hit(MMapCache *m) {
assert(m); assert(m);
log_debug("mmap cache statistics: %u hit, %u miss", m->n_hit, m->n_missed); return m->n_hit;
}
unsigned mmap_cache_get_missed(MMapCache *m) {
assert(m);
return m->n_missed;
} }
static void mmap_cache_process_sigbus(MMapCache *m) { static void mmap_cache_process_sigbus(MMapCache *m) {

View File

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

View File

@ -27,24 +27,16 @@ int dlopen_pcre2(void) {
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
"PCRE2 support is not installed: %s", dlerror()); "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( r = dlsym_many_and_warn(
dl, dl,
LOG_ERR, LOG_ERR,
DLSYM_ARG(pcre2_match_data_create), &sym_pcre2_match_data_create, "pcre2_match_data_create_8",
DLSYM_ARG(pcre2_match_data_free), &sym_pcre2_match_data_free, "pcre2_match_data_free_8",
DLSYM_ARG(pcre2_code_free), &sym_pcre2_code_free, "pcre2_code_free_8",
DLSYM_ARG(pcre2_compile), &sym_pcre2_compile, "pcre2_compile_8",
DLSYM_ARG(pcre2_get_error_message), &sym_pcre2_get_error_message, "pcre2_get_error_message_8",
DLSYM_ARG(pcre2_match), &sym_pcre2_match, "pcre2_match_8",
DLSYM_ARG(pcre2_get_ovector_pointer), &sym_pcre2_get_ovector_pointer, "pcre2_get_ovector_pointer_8",
NULL); NULL);
if (r < 0) if (r < 0)
return r; return r;

View File

@ -2170,7 +2170,7 @@ _public_ void sd_journal_close(sd_journal *j) {
safe_close(j->inotify_fd); safe_close(j->inotify_fd);
if (j->mmap) { if (j->mmap) {
mmap_cache_stats_log_debug(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_unref(j->mmap); mmap_cache_unref(j->mmap);
} }

View File

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

View File

@ -575,12 +575,6 @@ static int route_add(Manager *manager, Link *link, const Route *in, const Multip
return 0; 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) { static int route_set_netlink_message(const Route *route, sd_netlink_message *req, Link *link) {
unsigned flags; unsigned flags;
int r; int r;
@ -666,7 +660,7 @@ static int route_set_netlink_message(const Route *route, sd_netlink_message *req
if (r < 0) if (r < 0)
return log_link_error_errno(link, r, "Could not set route type: %m"); return log_link_error_errno(link, r, "Could not set route type: %m");
if (!route_type_is_reject(route)) { if (!IN_SET(route->type, RTN_UNREACHABLE, RTN_PROHIBIT, RTN_BLACKHOLE, RTN_THROW)) {
assert(link); /* Those routes must be attached to a specific link */ assert(link); /* Those routes must be attached to a specific link */
r = sd_netlink_message_append_u32(req, RTA_OIF, link->ifindex); r = sd_netlink_message_append_u32(req, RTA_OIF, link->ifindex);
@ -933,7 +927,7 @@ static int route_add_and_setup_timer(Link *link, const Route *route, const Multi
assert(link); assert(link);
assert(route); assert(route);
if (route_type_is_reject(route)) if (IN_SET(route->type, RTN_UNREACHABLE, RTN_PROHIBIT, RTN_BLACKHOLE, RTN_THROW))
r = route_add(link->manager, NULL, route, NULL, &nr); r = route_add(link->manager, NULL, route, NULL, &nr);
else if (!m || m->ifindex == 0 || m->ifindex == link->ifindex) else if (!m || m->ifindex == 0 || m->ifindex == link->ifindex)
r = route_add(NULL, link, route, m, &nr); r = route_add(NULL, link, route, m, &nr);
@ -1582,12 +1576,6 @@ 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)) if (ordered_set_isempty(multipath_routes))
(void) process_route_one(m, link, type, tmp, NULL); (void) process_route_one(m, link, type, tmp, NULL);
else { else {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -48,18 +48,6 @@ Destination=202.54.1.3
Type=prohibit Type=prohibit
Destination=202.54.1.4 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] [Route]
Type=local Type=local
Destination=149.10.123.1 Destination=149.10.123.1

View File

@ -2216,21 +2216,6 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
print(output) print(output)
self.assertRegex(output, 'prohibit 202.54.1.4 proto static') 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') print('### ip route show 192.168.10.1')
output = check_output('ip route show 192.168.10.1') output = check_output('ip route show 192.168.10.1')
print(output) print(output)
@ -2257,7 +2242,6 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
copy_unit_to_networkd_unit_path('25-address-static.network') copy_unit_to_networkd_unit_path('25-address-static.network')
check_output(*networkctl_cmd, 'reload', env=env) check_output(*networkctl_cmd, 'reload', env=env)
time.sleep(1)
self.wait_online(['dummy98:routable']) self.wait_online(['dummy98:routable'])
# check all routes managed by Manager are removed # check all routes managed by Manager are removed
@ -2276,24 +2260,8 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
print(output) print(output)
self.assertEqual(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']) remove_unit_from_networkd_path(['25-address-static.network'])
check_output(*networkctl_cmd, 'reload', env=env) check_output(*networkctl_cmd, 'reload', env=env)
time.sleep(1)
self.wait_online(['dummy98:routable']) self.wait_online(['dummy98:routable'])
# check all routes managed by Manager are reconfigured # check all routes managed by Manager are reconfigured
@ -2312,21 +2280,6 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
print(output) print(output)
self.assertRegex(output, 'prohibit 202.54.1.4 proto static') 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") rc = call("ip link del dummy98")
self.assertEqual(rc, 0) self.assertEqual(rc, 0)
time.sleep(2) time.sleep(2)
@ -2347,21 +2300,6 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
print(output) print(output)
self.assertEqual(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() @expectedFailureIfRTA_VIAIsNotSupported()
def test_route_via_ipv6(self): def test_route_via_ipv6(self):
copy_unit_to_networkd_unit_path('25-route-via-ipv6.network', '12-dummy.netdev') 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 Description=Create a lot of memory pressure
[Service] [Service]
# A VERY small memory.high will cause the script (trying to use a lot of memory) # A very small memory.high will cause the script (trying to use a lot of memory)
# to throttle and be put under heavy pressure. # to throttle and be put under heavy pressure
MemoryHigh=1M MemoryHigh=2M
Slice=testsuite-56-workload.slice Slice=testsuite-56-workload.slice
ExecStart=/usr/lib/systemd/tests/testdata/units/testsuite-56-slowgrowth.sh ExecStart=/usr/lib/systemd/tests/testdata/units/testsuite-56-slowgrowth.sh

View File

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

View File

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