mirror of
https://github.com/systemd/systemd
synced 2026-04-13 10:35:08 +02:00
Compare commits
No commits in common. "007721e939a3a549e8ff456fdfbc196e7e1f0086" and "4d6455c0754e31ddc9590c7b9c9a373d82ec0ed4" have entirely different histories.
007721e939
...
4d6455c075
9
.github/workflows/build_test.sh
vendored
9
.github/workflows/build_test.sh
vendored
@ -117,21 +117,12 @@ ninja --version
|
|||||||
for args in "${ARGS[@]}"; do
|
for args in "${ARGS[@]}"; do
|
||||||
SECONDS=0
|
SECONDS=0
|
||||||
|
|
||||||
# meson fails with
|
|
||||||
# src/boot/efi/meson.build:52: WARNING: Not using lld as efi-ld, falling back to bfd
|
|
||||||
# src/boot/efi/meson.build:52:16: ERROR: Fatal warnings enabled, aborting
|
|
||||||
# when LINKER is set to lld so let's just not turn meson warnings into errors with lld
|
|
||||||
# to make sure that the build systemd can pick up the correct efi-ld linker automatically.
|
|
||||||
if [[ "$LINKER" != lld ]]; then
|
|
||||||
additional_meson_args="--fatal-meson-warnings"
|
|
||||||
fi
|
|
||||||
info "Checking build with $args"
|
info "Checking build with $args"
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
if ! AR="$AR" \
|
if ! AR="$AR" \
|
||||||
CC="$CC" CC_LD="$LINKER" CFLAGS="-Werror" \
|
CC="$CC" CC_LD="$LINKER" CFLAGS="-Werror" \
|
||||||
CXX="$CXX" CXX_LD="$LINKER" CXXFLAGS="-Werror" \
|
CXX="$CXX" CXX_LD="$LINKER" CXXFLAGS="-Werror" \
|
||||||
meson -Dtests=unsafe -Dslow-tests=true -Dfuzz-tests=true --werror \
|
meson -Dtests=unsafe -Dslow-tests=true -Dfuzz-tests=true --werror \
|
||||||
-Dnobody-group=nogroup $additional_meson_args \
|
|
||||||
-Dcryptolib="${CRYPTOLIB:?}" $args build; then
|
-Dcryptolib="${CRYPTOLIB:?}" $args build; then
|
||||||
|
|
||||||
cat build/meson-logs/meson-log.txt
|
cat build/meson-logs/meson-log.txt
|
||||||
|
|||||||
4
.github/workflows/unit_tests.sh
vendored
4
.github/workflows/unit_tests.sh
vendored
@ -56,7 +56,7 @@ for phase in "${PHASES[@]}"; do
|
|||||||
# The docs build is slow and is not affected by compiler/flags, so do it just once
|
# The docs build is slow and is not affected by compiler/flags, so do it just once
|
||||||
MESON_ARGS+=(-Dman=true)
|
MESON_ARGS+=(-Dman=true)
|
||||||
fi
|
fi
|
||||||
run_meson --fatal-meson-warnings -Dnobody-group=nogroup --werror -Dtests=unsafe -Dslow-tests=true -Dfuzz-tests=true "${MESON_ARGS[@]}" build
|
run_meson --werror -Dtests=unsafe -Dslow-tests=true -Dfuzz-tests=true "${MESON_ARGS[@]}" build
|
||||||
ninja -C build -v
|
ninja -C build -v
|
||||||
meson test -C build --print-errorlogs
|
meson test -C build --print-errorlogs
|
||||||
;;
|
;;
|
||||||
@ -71,7 +71,7 @@ for phase in "${PHASES[@]}"; do
|
|||||||
# -Db_lundef=false: See https://github.com/mesonbuild/meson/issues/764
|
# -Db_lundef=false: See https://github.com/mesonbuild/meson/issues/764
|
||||||
MESON_ARGS+=(-Db_lundef=false -Dfuzz-tests=true)
|
MESON_ARGS+=(-Db_lundef=false -Dfuzz-tests=true)
|
||||||
fi
|
fi
|
||||||
run_meson --fatal-meson-warnings -Dnobody-group=nogroup --werror -Dtests=unsafe -Db_sanitize=address,undefined "${MESON_ARGS[@]}" build
|
run_meson --werror -Dtests=unsafe -Db_sanitize=address,undefined "${MESON_ARGS[@]}" build
|
||||||
ninja -C build -v
|
ninja -C build -v
|
||||||
|
|
||||||
export ASAN_OPTIONS=strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1
|
export ASAN_OPTIONS=strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1
|
||||||
|
|||||||
@ -1547,9 +1547,9 @@ Table=1234</programlisting></para>
|
|||||||
|
|
||||||
<para>For IPv4 route, defaults to <literal>host</literal> if <varname>Type=</varname> is
|
<para>For IPv4 route, defaults to <literal>host</literal> if <varname>Type=</varname> is
|
||||||
<literal>local</literal> or <literal>nat</literal>, and <literal>link</literal> if
|
<literal>local</literal> or <literal>nat</literal>, and <literal>link</literal> if
|
||||||
<varname>Type=</varname> is <literal>broadcast</literal>, <literal>multicast</literal>,
|
<varname>Type=</varname> is <literal>broadcast</literal>, <literal>multicast</literal>, or
|
||||||
<literal>anycast</literal>, or direct <literal>unicast</literal> routes. In other cases,
|
<literal>anycast</literal>. In other cases, defaults to <literal>global</literal>. The value
|
||||||
defaults to <literal>global</literal>. The value is not used for IPv6.</para>
|
is not used for IPv6.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
|||||||
@ -1309,9 +1309,12 @@ good:
|
|||||||
entry->next_name = xpool_print(L"%s+%u-%u%s", prefix, next_left, next_done, suffix ?: L"");
|
entry->next_name = xpool_print(L"%s+%u-%u%s", prefix, next_left, next_done, suffix ?: L"");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void config_entry_bump_counters(ConfigEntry *entry, EFI_FILE *root_dir) {
|
static void config_entry_bump_counters(
|
||||||
|
ConfigEntry *entry,
|
||||||
|
EFI_FILE_HANDLE root_dir) {
|
||||||
|
|
||||||
_cleanup_freepool_ CHAR16* old_path = NULL, *new_path = NULL;
|
_cleanup_freepool_ CHAR16* old_path = NULL, *new_path = NULL;
|
||||||
_cleanup_(file_closep) EFI_FILE *handle = NULL;
|
_cleanup_(file_handle_closep) EFI_FILE_HANDLE handle = NULL;
|
||||||
_cleanup_freepool_ EFI_FILE_INFO *file_info = NULL;
|
_cleanup_freepool_ EFI_FILE_INFO *file_info = NULL;
|
||||||
UINTN file_info_size;
|
UINTN file_info_size;
|
||||||
EFI_STATUS err;
|
EFI_STATUS err;
|
||||||
@ -1372,6 +1375,7 @@ static void config_entry_add_from_file(
|
|||||||
UINTN pos = 0;
|
UINTN pos = 0;
|
||||||
CHAR8 *key, *value;
|
CHAR8 *key, *value;
|
||||||
EFI_STATUS err;
|
EFI_STATUS err;
|
||||||
|
EFI_FILE_HANDLE handle;
|
||||||
_cleanup_freepool_ CHAR16 *initrd = NULL;
|
_cleanup_freepool_ CHAR16 *initrd = NULL;
|
||||||
|
|
||||||
assert(config);
|
assert(config);
|
||||||
@ -1479,10 +1483,10 @@ static void config_entry_add_from_file(
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* check existence */
|
/* check existence */
|
||||||
_cleanup_(file_closep) EFI_FILE *handle = NULL;
|
|
||||||
err = root_dir->Open(root_dir, &handle, entry->loader, EFI_FILE_MODE_READ, 0ULL);
|
err = root_dir->Open(root_dir, &handle, entry->loader, EFI_FILE_MODE_READ, 0ULL);
|
||||||
if (EFI_ERROR(err))
|
if (EFI_ERROR(err))
|
||||||
return;
|
return;
|
||||||
|
handle->Close(handle);
|
||||||
|
|
||||||
/* add initrd= to options */
|
/* add initrd= to options */
|
||||||
if (entry->type == LOADER_LINUX && initrd) {
|
if (entry->type == LOADER_LINUX && initrd) {
|
||||||
@ -1567,7 +1571,7 @@ static void config_load_entries(
|
|||||||
EFI_FILE *root_dir,
|
EFI_FILE *root_dir,
|
||||||
const CHAR16 *loaded_image_path) {
|
const CHAR16 *loaded_image_path) {
|
||||||
|
|
||||||
_cleanup_(file_closep) EFI_FILE *entries_dir = NULL;
|
_cleanup_(file_handle_closep) EFI_FILE_HANDLE entries_dir = NULL;
|
||||||
_cleanup_freepool_ EFI_FILE_INFO *f = NULL;
|
_cleanup_freepool_ EFI_FILE_INFO *f = NULL;
|
||||||
UINTN f_size = 0;
|
UINTN f_size = 0;
|
||||||
EFI_STATUS err;
|
EFI_STATUS err;
|
||||||
@ -1884,6 +1888,9 @@ static ConfigEntry *config_entry_add_loader_auto(
|
|||||||
const CHAR16 *title,
|
const CHAR16 *title,
|
||||||
const CHAR16 *loader) {
|
const CHAR16 *loader) {
|
||||||
|
|
||||||
|
EFI_FILE_HANDLE handle;
|
||||||
|
EFI_STATUS err;
|
||||||
|
|
||||||
assert(config);
|
assert(config);
|
||||||
assert(device);
|
assert(device);
|
||||||
assert(root_dir);
|
assert(root_dir);
|
||||||
@ -1909,10 +1916,10 @@ static ConfigEntry *config_entry_add_loader_auto(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* check existence */
|
/* check existence */
|
||||||
_cleanup_(file_closep) EFI_FILE *handle = NULL;
|
err = root_dir->Open(root_dir, &handle, (CHAR16*) loader, EFI_FILE_MODE_READ, 0ULL);
|
||||||
EFI_STATUS err = root_dir->Open(root_dir, &handle, (CHAR16*) loader, EFI_FILE_MODE_READ, 0ULL);
|
|
||||||
if (EFI_ERROR(err))
|
if (EFI_ERROR(err))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
handle->Close(handle);
|
||||||
|
|
||||||
return config_entry_add_loader(config, device, LOADER_AUTO, id, key, title, loader, NULL);
|
return config_entry_add_loader(config, device, LOADER_AUTO, id, key, title, loader, NULL);
|
||||||
}
|
}
|
||||||
@ -1932,7 +1939,7 @@ static void config_entry_add_osx(Config *config) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
for (UINTN i = 0; i < n_handles; i++) {
|
for (UINTN i = 0; i < n_handles; i++) {
|
||||||
_cleanup_(file_closep) EFI_FILE *root = LibOpenRoot(handles[i]);
|
_cleanup_(file_handle_closep) EFI_FILE *root = LibOpenRoot(handles[i]);
|
||||||
if (!root)
|
if (!root)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -2059,7 +2066,7 @@ static void config_entry_add_linux(
|
|||||||
EFI_HANDLE *device,
|
EFI_HANDLE *device,
|
||||||
EFI_FILE *root_dir) {
|
EFI_FILE *root_dir) {
|
||||||
|
|
||||||
_cleanup_(file_closep) EFI_FILE *linux_dir = NULL;
|
_cleanup_(file_handle_closep) EFI_FILE_HANDLE linux_dir = NULL;
|
||||||
_cleanup_freepool_ EFI_FILE_INFO *f = NULL;
|
_cleanup_freepool_ EFI_FILE_INFO *f = NULL;
|
||||||
ConfigEntry *entry;
|
ConfigEntry *entry;
|
||||||
UINTN f_size = 0;
|
UINTN f_size = 0;
|
||||||
@ -2217,7 +2224,7 @@ static void config_load_xbootldr(
|
|||||||
Config *config,
|
Config *config,
|
||||||
EFI_HANDLE *device) {
|
EFI_HANDLE *device) {
|
||||||
|
|
||||||
_cleanup_(file_closep) EFI_FILE *root_dir = NULL;
|
_cleanup_(file_handle_closep) EFI_FILE *root_dir = NULL;
|
||||||
EFI_HANDLE new_device;
|
EFI_HANDLE new_device;
|
||||||
EFI_STATUS err;
|
EFI_STATUS err;
|
||||||
|
|
||||||
@ -2233,7 +2240,7 @@ static void config_load_xbootldr(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static EFI_STATUS image_start(
|
static EFI_STATUS image_start(
|
||||||
EFI_FILE *root_dir,
|
EFI_FILE_HANDLE root_dir,
|
||||||
EFI_HANDLE parent_image,
|
EFI_HANDLE parent_image,
|
||||||
const Config *config,
|
const Config *config,
|
||||||
const ConfigEntry *entry) {
|
const ConfigEntry *entry) {
|
||||||
@ -2448,8 +2455,8 @@ static void config_load_all_entries(
|
|||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
|
EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
|
||||||
EFI_LOADED_IMAGE *loaded_image;
|
_cleanup_freepool_ EFI_LOADED_IMAGE *loaded_image = NULL;
|
||||||
_cleanup_(file_closep) EFI_FILE *root_dir = NULL;
|
_cleanup_(file_handle_closep) EFI_FILE *root_dir = NULL;
|
||||||
_cleanup_(config_free) Config config = {};
|
_cleanup_(config_free) Config config = {};
|
||||||
CHAR16 *loaded_image_path;
|
CHAR16 *loaded_image_path;
|
||||||
EFI_STATUS err;
|
EFI_STATUS err;
|
||||||
|
|||||||
@ -316,7 +316,7 @@ EFI_STATUS pack_cpio(
|
|||||||
void **ret_buffer,
|
void **ret_buffer,
|
||||||
UINTN *ret_buffer_size) {
|
UINTN *ret_buffer_size) {
|
||||||
|
|
||||||
_cleanup_(file_closep) EFI_FILE *root = NULL, *extra_dir = NULL;
|
_cleanup_(file_handle_closep) EFI_FILE_HANDLE root = NULL, extra_dir = NULL;
|
||||||
UINTN dirent_size = 0, buffer_size = 0, n_items = 0, n_allocated = 0;
|
UINTN dirent_size = 0, buffer_size = 0, n_items = 0, n_allocated = 0;
|
||||||
_cleanup_freepool_ CHAR16 *rel_dropin_dir = NULL;
|
_cleanup_freepool_ CHAR16 *rel_dropin_dir = NULL;
|
||||||
_cleanup_freepool_ EFI_FILE_INFO *dirent = NULL;
|
_cleanup_freepool_ EFI_FILE_INFO *dirent = NULL;
|
||||||
|
|||||||
@ -64,8 +64,9 @@ static EFI_STATUS devicetree_fixup(struct devicetree_state *state, UINTN len) {
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS devicetree_install(struct devicetree_state *state, EFI_FILE *root_dir, CHAR16 *name) {
|
EFI_STATUS devicetree_install(struct devicetree_state *state,
|
||||||
_cleanup_(file_closep) EFI_FILE *handle = NULL;
|
EFI_FILE_HANDLE root_dir, CHAR16 *name) {
|
||||||
|
_cleanup_(file_handle_closep) EFI_FILE_HANDLE handle = NULL;
|
||||||
_cleanup_freepool_ EFI_FILE_INFO *info = NULL;
|
_cleanup_freepool_ EFI_FILE_INFO *info = NULL;
|
||||||
UINTN len;
|
UINTN len;
|
||||||
EFI_STATUS err;
|
EFI_STATUS err;
|
||||||
|
|||||||
@ -7,7 +7,7 @@ struct devicetree_state {
|
|||||||
void *orig;
|
void *orig;
|
||||||
};
|
};
|
||||||
|
|
||||||
EFI_STATUS devicetree_install(struct devicetree_state *state, EFI_FILE *root_dir, CHAR16 *name);
|
EFI_STATUS devicetree_install(struct devicetree_state *state, EFI_FILE_HANDLE root_dir, CHAR16 *name);
|
||||||
EFI_STATUS devicetree_install_from_memory(
|
EFI_STATUS devicetree_install_from_memory(
|
||||||
struct devicetree_state *state, const VOID *dtb_buffer, UINTN dtb_length);
|
struct devicetree_state *state, const VOID *dtb_buffer, UINTN dtb_length);
|
||||||
void devicetree_cleanup(struct devicetree_state *state);
|
void devicetree_cleanup(struct devicetree_state *state);
|
||||||
|
|||||||
@ -80,9 +80,9 @@ static EFI_STATUS reconnect(void) {
|
|||||||
EFI_STATUS load_drivers(
|
EFI_STATUS load_drivers(
|
||||||
EFI_HANDLE parent_image,
|
EFI_HANDLE parent_image,
|
||||||
EFI_LOADED_IMAGE *loaded_image,
|
EFI_LOADED_IMAGE *loaded_image,
|
||||||
EFI_FILE *root_dir) {
|
EFI_FILE_HANDLE root_dir) {
|
||||||
|
|
||||||
_cleanup_(file_closep) EFI_FILE *drivers_dir = NULL;
|
_cleanup_(file_handle_closep) EFI_FILE_HANDLE drivers_dir = NULL;
|
||||||
_cleanup_freepool_ EFI_FILE_INFO *dirent = NULL;
|
_cleanup_freepool_ EFI_FILE_INFO *dirent = NULL;
|
||||||
UINTN dirent_size = 0, n_succeeded = 0;
|
UINTN dirent_size = 0, n_succeeded = 0;
|
||||||
EFI_STATUS err;
|
EFI_STATUS err;
|
||||||
|
|||||||
@ -6,4 +6,4 @@
|
|||||||
EFI_STATUS load_drivers(
|
EFI_STATUS load_drivers(
|
||||||
EFI_HANDLE parent_image,
|
EFI_HANDLE parent_image,
|
||||||
EFI_LOADED_IMAGE *loaded_image,
|
EFI_LOADED_IMAGE *loaded_image,
|
||||||
EFI_FILE *root_dir);
|
EFI_FILE_HANDLE root_dir);
|
||||||
|
|||||||
@ -224,7 +224,7 @@ EFI_STATUS pe_file_locate_sections(
|
|||||||
UINTN *offsets,
|
UINTN *offsets,
|
||||||
UINTN *sizes) {
|
UINTN *sizes) {
|
||||||
_cleanup_freepool_ struct PeSectionHeader *section_table = NULL;
|
_cleanup_freepool_ struct PeSectionHeader *section_table = NULL;
|
||||||
_cleanup_(file_closep) EFI_FILE *handle = NULL;
|
_cleanup_(file_handle_closep) EFI_FILE_HANDLE handle = NULL;
|
||||||
struct DosFileHeader dos;
|
struct DosFileHeader dos;
|
||||||
struct PeFileHeader pe;
|
struct PeFileHeader pe;
|
||||||
UINTN len, section_table_len;
|
UINTN len, section_table_len;
|
||||||
|
|||||||
@ -225,7 +225,7 @@ static void validate_sha256(void) {
|
|||||||
|
|
||||||
EFI_STATUS process_random_seed(EFI_FILE *root_dir, RandomSeedMode mode) {
|
EFI_STATUS process_random_seed(EFI_FILE *root_dir, RandomSeedMode mode) {
|
||||||
_cleanup_freepool_ void *seed = NULL, *new_seed = NULL, *rng = NULL, *for_kernel = NULL, *system_token = NULL;
|
_cleanup_freepool_ void *seed = NULL, *new_seed = NULL, *rng = NULL, *for_kernel = NULL, *system_token = NULL;
|
||||||
_cleanup_(file_closep) EFI_FILE *handle = NULL;
|
_cleanup_(file_handle_closep) EFI_FILE_HANDLE handle = NULL;
|
||||||
UINTN size, rsize, wsize, system_token_size = 0;
|
UINTN size, rsize, wsize, system_token_size = 0;
|
||||||
_cleanup_freepool_ EFI_FILE_INFO *info = NULL;
|
_cleanup_freepool_ EFI_FILE_INFO *info = NULL;
|
||||||
EFI_STATUS err;
|
EFI_STATUS err;
|
||||||
|
|||||||
@ -105,6 +105,7 @@ static EFIAPI EFI_STATUS security_policy_authentication (const EFI_SECURITY_PROT
|
|||||||
_cleanup_freepool_ EFI_DEVICE_PATH *dev_path = NULL;
|
_cleanup_freepool_ EFI_DEVICE_PATH *dev_path = NULL;
|
||||||
_cleanup_freepool_ CHAR16 *dev_path_str = NULL;
|
_cleanup_freepool_ CHAR16 *dev_path_str = NULL;
|
||||||
EFI_HANDLE h;
|
EFI_HANDLE h;
|
||||||
|
EFI_FILE *root;
|
||||||
_cleanup_freepool_ CHAR8 *file_buffer = NULL;
|
_cleanup_freepool_ CHAR8 *file_buffer = NULL;
|
||||||
UINTN file_size;
|
UINTN file_size;
|
||||||
|
|
||||||
@ -117,22 +118,20 @@ static EFIAPI EFI_STATUS security_policy_authentication (const EFI_SECURITY_PROT
|
|||||||
if (!dev_path)
|
if (!dev_path)
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
|
|
||||||
EFI_DEVICE_PATH *dp = dev_path;
|
status = BS->LocateDevicePath(&FileSystemProtocol, &dev_path, &h);
|
||||||
status = BS->LocateDevicePath(&FileSystemProtocol, &dp, &h);
|
|
||||||
if (EFI_ERROR(status))
|
if (EFI_ERROR(status))
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
_cleanup_(file_closep) EFI_FILE *root = LibOpenRoot(h);
|
/* No need to check return value, this already happened in efi_main() */
|
||||||
if (!root)
|
root = LibOpenRoot(h);
|
||||||
return EFI_NOT_FOUND;
|
dev_path_str = DevicePathToStr(dev_path);
|
||||||
|
|
||||||
dev_path_str = DevicePathToStr(dp);
|
|
||||||
if (!dev_path_str)
|
if (!dev_path_str)
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
|
|
||||||
status = file_read(root, dev_path_str, 0, 0, &file_buffer, &file_size);
|
status = file_read(root, dev_path_str, 0, 0, &file_buffer, &file_size);
|
||||||
if (EFI_ERROR(status))
|
if (EFI_ERROR(status))
|
||||||
return status;
|
return status;
|
||||||
|
root->Close(root);
|
||||||
|
|
||||||
if (shim_validate(file_buffer, file_size))
|
if (shim_validate(file_buffer, file_size))
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
|
|||||||
@ -435,12 +435,11 @@ CHAR8 *strchra(const CHAR8 *s, CHAR8 c) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS file_read(EFI_FILE *dir, const CHAR16 *name, UINTN off, UINTN size, CHAR8 **ret, UINTN *ret_size) {
|
EFI_STATUS file_read(EFI_FILE_HANDLE dir, const CHAR16 *name, UINTN off, UINTN size, CHAR8 **ret, UINTN *ret_size) {
|
||||||
_cleanup_(file_closep) EFI_FILE *handle = NULL;
|
_cleanup_(file_handle_closep) EFI_FILE_HANDLE handle = NULL;
|
||||||
_cleanup_freepool_ CHAR8 *buf = NULL;
|
_cleanup_freepool_ CHAR8 *buf = NULL;
|
||||||
EFI_STATUS err;
|
EFI_STATUS err;
|
||||||
|
|
||||||
assert(dir);
|
|
||||||
assert(name);
|
assert(name);
|
||||||
assert(ret);
|
assert(ret);
|
||||||
|
|
||||||
@ -545,7 +544,7 @@ void sort_pointer_array(
|
|||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS get_file_info_harder(
|
EFI_STATUS get_file_info_harder(
|
||||||
EFI_FILE *handle,
|
EFI_FILE_HANDLE handle,
|
||||||
EFI_FILE_INFO **ret,
|
EFI_FILE_INFO **ret,
|
||||||
UINTN *ret_size) {
|
UINTN *ret_size) {
|
||||||
|
|
||||||
@ -578,7 +577,7 @@ EFI_STATUS get_file_info_harder(
|
|||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS readdir_harder(
|
EFI_STATUS readdir_harder(
|
||||||
EFI_FILE *handle,
|
EFI_FILE_HANDLE handle,
|
||||||
EFI_FILE_INFO **buffer,
|
EFI_FILE_INFO **buffer,
|
||||||
UINTN *buffer_size) {
|
UINTN *buffer_size) {
|
||||||
|
|
||||||
@ -701,11 +700,11 @@ CHAR16 **strv_free(CHAR16 **v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS open_directory(
|
EFI_STATUS open_directory(
|
||||||
EFI_FILE *root,
|
EFI_FILE_HANDLE root,
|
||||||
const CHAR16 *path,
|
const CHAR16 *path,
|
||||||
EFI_FILE **ret) {
|
EFI_FILE_HANDLE *ret) {
|
||||||
|
|
||||||
_cleanup_(file_closep) EFI_FILE *dir = NULL;
|
_cleanup_(file_handle_closep) EFI_FILE_HANDLE dir = NULL;
|
||||||
_cleanup_freepool_ EFI_FILE_INFO *file_info = NULL;
|
_cleanup_freepool_ EFI_FILE_INFO *file_info = NULL;
|
||||||
EFI_STATUS err;
|
EFI_STATUS err;
|
||||||
|
|
||||||
|
|||||||
@ -71,7 +71,7 @@ CHAR8 *strchra(const CHAR8 *s, CHAR8 c);
|
|||||||
CHAR16 *xstra_to_path(const CHAR8 *stra);
|
CHAR16 *xstra_to_path(const CHAR8 *stra);
|
||||||
CHAR16 *xstra_to_str(const CHAR8 *stra);
|
CHAR16 *xstra_to_str(const CHAR8 *stra);
|
||||||
|
|
||||||
EFI_STATUS file_read(EFI_FILE *dir, const CHAR16 *name, UINTN off, UINTN size, CHAR8 **content, UINTN *content_size);
|
EFI_STATUS file_read(EFI_FILE_HANDLE dir, const CHAR16 *name, UINTN off, UINTN size, CHAR8 **content, UINTN *content_size);
|
||||||
|
|
||||||
static inline void free_poolp(void *p) {
|
static inline void free_poolp(void *p) {
|
||||||
void *q = *(void**) p;
|
void *q = *(void**) p;
|
||||||
@ -79,12 +79,12 @@ static inline void free_poolp(void *p) {
|
|||||||
if (!q)
|
if (!q)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
(void) BS->FreePool(q);
|
FreePool(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define _cleanup_freepool_ _cleanup_(free_poolp)
|
#define _cleanup_freepool_ _cleanup_(free_poolp)
|
||||||
|
|
||||||
static inline void file_closep(EFI_FILE **handle) {
|
static inline void file_handle_closep(EFI_FILE_HANDLE *handle) {
|
||||||
if (!*handle)
|
if (!*handle)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -117,9 +117,9 @@ void clear_screen(UINTN attr);
|
|||||||
typedef INTN (*compare_pointer_func_t)(const void *a, const void *b);
|
typedef INTN (*compare_pointer_func_t)(const void *a, const void *b);
|
||||||
void sort_pointer_array(void **array, UINTN n_members, compare_pointer_func_t compare);
|
void sort_pointer_array(void **array, UINTN n_members, compare_pointer_func_t compare);
|
||||||
|
|
||||||
EFI_STATUS get_file_info_harder(EFI_FILE *handle, EFI_FILE_INFO **ret, UINTN *ret_size);
|
EFI_STATUS get_file_info_harder(EFI_FILE_HANDLE handle, EFI_FILE_INFO **ret, UINTN *ret_size);
|
||||||
|
|
||||||
EFI_STATUS readdir_harder(EFI_FILE *handle, EFI_FILE_INFO **buffer, UINTN *buffer_size);
|
EFI_STATUS readdir_harder(EFI_FILE_HANDLE handle, EFI_FILE_INFO **buffer, UINTN *buffer_size);
|
||||||
|
|
||||||
UINTN strnlena(const CHAR8 *p, UINTN maxlen);
|
UINTN strnlena(const CHAR8 *p, UINTN maxlen);
|
||||||
CHAR8 *xstrndup8(const CHAR8 *p, UINTN sz);
|
CHAR8 *xstrndup8(const CHAR8 *p, UINTN sz);
|
||||||
@ -136,7 +136,7 @@ static inline void strv_freep(CHAR16 ***p) {
|
|||||||
strv_free(*p);
|
strv_free(*p);
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS open_directory(EFI_FILE *root_dir, const CHAR16 *path, EFI_FILE **ret);
|
EFI_STATUS open_directory(EFI_FILE_HANDLE root_dir, const CHAR16 *path, EFI_FILE_HANDLE *ret);
|
||||||
|
|
||||||
/* Conversion between EFI_PHYSICAL_ADDRESS and pointers is not obvious. The former is always 64bit, even on
|
/* Conversion between EFI_PHYSICAL_ADDRESS and pointers is not obvious. The former is always 64bit, even on
|
||||||
* 32bit archs. And gcc complains if we cast a pointer to an integer of a different size. Hence let's do the
|
* 32bit archs. And gcc complains if we cast a pointer to an integer of a different size. Hence let's do the
|
||||||
|
|||||||
@ -286,8 +286,7 @@ EFI_STATUS xbootldr_open(EFI_HANDLE *device, EFI_HANDLE *ret_device, EFI_FILE **
|
|||||||
hd->SignatureType = SIGNATURE_TYPE_GUID;
|
hd->SignatureType = SIGNATURE_TYPE_GUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_DEVICE_PATH *dp = partition_path;
|
err = BS->LocateDevicePath(&BlockIoProtocol, &partition_path, &new_device);
|
||||||
err = BS->LocateDevicePath(&BlockIoProtocol, &dp, &new_device);
|
|
||||||
if (EFI_ERROR(err))
|
if (EFI_ERROR(err))
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,6 @@
|
|||||||
#include "sd-event.h"
|
#include "sd-event.h"
|
||||||
#include "sd-dhcp6-client.h"
|
#include "sd-dhcp6-client.h"
|
||||||
|
|
||||||
#include "dhcp6-protocol.h"
|
|
||||||
#include "hashmap.h"
|
#include "hashmap.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "macro.h"
|
#include "macro.h"
|
||||||
@ -131,12 +130,6 @@ int dhcp6_network_bind_udp_socket(int ifindex, struct in6_addr *address);
|
|||||||
int dhcp6_network_send_udp_socket(int s, struct in6_addr *address,
|
int dhcp6_network_send_udp_socket(int s, struct in6_addr *address,
|
||||||
const void *packet, size_t len);
|
const void *packet, size_t len);
|
||||||
|
|
||||||
int client_parse_message(
|
|
||||||
sd_dhcp6_client *client,
|
|
||||||
DHCP6Message *message,
|
|
||||||
size_t len,
|
|
||||||
sd_dhcp6_lease *lease);
|
|
||||||
|
|
||||||
const char *dhcp6_message_type_to_string(int s) _const_;
|
const char *dhcp6_message_type_to_string(int s) _const_;
|
||||||
int dhcp6_message_type_from_string(const char *s) _pure_;
|
int dhcp6_message_type_from_string(const char *s) _pure_;
|
||||||
const char *dhcp6_message_status_to_string(int s) _const_;
|
const char *dhcp6_message_status_to_string(int s) _const_;
|
||||||
|
|||||||
@ -1124,7 +1124,7 @@ static int client_ensure_iaid(sd_dhcp6_client *client) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int client_parse_message(
|
static int client_parse_message(
|
||||||
sd_dhcp6_client *client,
|
sd_dhcp6_client *client,
|
||||||
DHCP6Message *message,
|
DHCP6Message *message,
|
||||||
size_t len,
|
size_t len,
|
||||||
@ -1261,35 +1261,35 @@ int client_parse_message(
|
|||||||
case SD_DHCP6_OPTION_DNS_SERVERS:
|
case SD_DHCP6_OPTION_DNS_SERVERS:
|
||||||
r = dhcp6_lease_add_dns(lease, optval, optlen);
|
r = dhcp6_lease_add_dns(lease, optval, optlen);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
log_dhcp6_client_errno(client, r, "Failed to parse DNS server option, ignoring: %m");
|
return r;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SD_DHCP6_OPTION_DOMAIN_LIST:
|
case SD_DHCP6_OPTION_DOMAIN_LIST:
|
||||||
r = dhcp6_lease_add_domains(lease, optval, optlen);
|
r = dhcp6_lease_add_domains(lease, optval, optlen);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
log_dhcp6_client_errno(client, r, "Failed to parse domain list option, ignoring: %m");
|
return r;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SD_DHCP6_OPTION_NTP_SERVER:
|
case SD_DHCP6_OPTION_NTP_SERVER:
|
||||||
r = dhcp6_lease_add_ntp(lease, optval, optlen);
|
r = dhcp6_lease_add_ntp(lease, optval, optlen);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
log_dhcp6_client_errno(client, r, "Failed to parse NTP server option, ignoring: %m");
|
return r;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SD_DHCP6_OPTION_SNTP_SERVERS:
|
case SD_DHCP6_OPTION_SNTP_SERVERS:
|
||||||
r = dhcp6_lease_add_sntp(lease, optval, optlen);
|
r = dhcp6_lease_add_sntp(lease, optval, optlen);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
log_dhcp6_client_errno(client, r, "Failed to parse SNTP server option, ignoring: %m");
|
return r;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SD_DHCP6_OPTION_CLIENT_FQDN:
|
case SD_DHCP6_OPTION_CLIENT_FQDN:
|
||||||
r = dhcp6_lease_set_fqdn(lease, optval, optlen);
|
r = dhcp6_lease_set_fqdn(lease, optval, optlen);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
log_dhcp6_client_errno(client, r, "Failed to parse FQDN option, ignoring: %m");
|
return r;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,7 @@ static int test_client_message_num;
|
|||||||
static be32_t test_iaid = 0;
|
static be32_t test_iaid = 0;
|
||||||
static uint8_t test_duid[14] = { };
|
static uint8_t test_duid[14] = { };
|
||||||
|
|
||||||
static void test_client_basic(sd_event *e) {
|
static int test_client_basic(sd_event *e) {
|
||||||
sd_dhcp6_client *client;
|
sd_dhcp6_client *client;
|
||||||
int v;
|
int v;
|
||||||
|
|
||||||
@ -108,9 +108,11 @@ static void test_client_basic(sd_event *e) {
|
|||||||
|
|
||||||
assert_se(sd_dhcp6_client_detach_event(client) >= 0);
|
assert_se(sd_dhcp6_client_detach_event(client) >= 0);
|
||||||
assert_se(!sd_dhcp6_client_unref(client));
|
assert_se(!sd_dhcp6_client_unref(client));
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_parse_domain(void) {
|
static int test_parse_domain(sd_event *e) {
|
||||||
uint8_t *data;
|
uint8_t *data;
|
||||||
char *domain;
|
char *domain;
|
||||||
char **list;
|
char **list;
|
||||||
@ -152,9 +154,11 @@ static void test_parse_domain(void) {
|
|||||||
data = (uint8_t []) { 0 , 0 };
|
data = (uint8_t []) { 0 , 0 };
|
||||||
r = dhcp6_option_parse_domainname_list(data, 2, &list);
|
r = dhcp6_option_parse_domainname_list(data, 2, &list);
|
||||||
assert_se(r < 0);
|
assert_se(r < 0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_option(void) {
|
static int test_option(sd_event *e) {
|
||||||
uint8_t packet[] = {
|
uint8_t packet[] = {
|
||||||
'F', 'O', 'O', 'H', 'O', 'G', 'E',
|
'F', 'O', 'O', 'H', 'O', 'G', 'E',
|
||||||
0x00, SD_DHCP6_OPTION_ORO, 0x00, 0x07,
|
0x00, SD_DHCP6_OPTION_ORO, 0x00, 0x07,
|
||||||
@ -228,9 +232,11 @@ static void test_option(void) {
|
|||||||
assert_se(*out == 'B');
|
assert_se(*out == 'B');
|
||||||
|
|
||||||
assert_se(memcmp(packet, result, sizeof(packet)) == 0);
|
assert_se(memcmp(packet, result, sizeof(packet)) == 0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_option_status(void) {
|
static int test_option_status(sd_event *e) {
|
||||||
uint8_t option1[] = {
|
uint8_t option1[] = {
|
||||||
/* IA NA */
|
/* IA NA */
|
||||||
0x00, 0x03, 0x00, 0x12, 0x1a, 0x1d, 0x1a, 0x1d,
|
0x00, 0x03, 0x00, 0x12, 0x1a, 0x1d, 0x1a, 0x1d,
|
||||||
@ -364,56 +370,8 @@ static void test_option_status(void) {
|
|||||||
assert_se(r >= 0);
|
assert_se(r >= 0);
|
||||||
assert_se(pd.addresses);
|
assert_se(pd.addresses);
|
||||||
dhcp6_lease_free_ia(&pd);
|
dhcp6_lease_free_ia(&pd);
|
||||||
}
|
|
||||||
|
|
||||||
static void test_client_parse_message_issue_22099(void) {
|
return 0;
|
||||||
static const uint8_t msg[] = {
|
|
||||||
/* xid */
|
|
||||||
0x07, 0x7c, 0x4c, 0x16,
|
|
||||||
/* status code (zero length) */
|
|
||||||
0x00, 0x0e, 0x00, 0x00,
|
|
||||||
/* NTP servers (broken sub option and sub option length) */
|
|
||||||
0x00, 0x38, 0x00, 0x14, 0x01, 0x00, 0x10, 0x00, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0xde, 0x15, 0xc8, 0xff, 0xfe, 0xef, 0x1e, 0x4e,
|
|
||||||
/* client ID */
|
|
||||||
0x00, 0x01, 0x00, 0x0e, 0x00, 0x02, 0x00, 0x00, 0xab, 0x11, 0x5c, 0x6b, 0x90, 0xec, 0xda, 0x95,
|
|
||||||
0x15, 0x45,
|
|
||||||
/* server ID */
|
|
||||||
0x00, 0x02, 0x00, 0x0a, 0x00, 0x03, 0x00, 0x01, 0xdc, 0x15, 0xc8, 0xef, 0x1e, 0x4e,
|
|
||||||
/* preference */
|
|
||||||
0x00, 0x07, 0x00, 0x01, 0x00,
|
|
||||||
/* DNS servers */
|
|
||||||
0x00, 0x17, 0x00, 0x10, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xde, 0x15, 0xc8, 0xff,
|
|
||||||
0xfe, 0xef, 0x1e, 0x4e,
|
|
||||||
/* v6 pcp server */
|
|
||||||
0x00, 0x56, 0x00, 0x10, 0x2a, 0x02, 0x81, 0x0d, 0x98, 0x80, 0x37, 0x00, 0xde, 0x15, 0xc8, 0xff,
|
|
||||||
0xfe, 0xef, 0x1e, 0x4e,
|
|
||||||
/* IA_NA */
|
|
||||||
0x00, 0x03, 0x00, 0x28, 0xcc, 0x59, 0x11, 0x7b, 0x00, 0x00, 0x07, 0x08, 0x00, 0x00, 0x0b, 0x40,
|
|
||||||
/* IA_NA (iaaddr) */
|
|
||||||
0x00, 0x05, 0x00, 0x18, 0x2a, 0x02, 0x81, 0x0d, 0x98, 0x80, 0x37, 0x00, 0x6a, 0x05, 0xca, 0xff,
|
|
||||||
0xfe, 0xf1, 0x51, 0x53, 0x00, 0x00, 0x0e, 0x10, 0x00, 0x00, 0x1c, 0x20,
|
|
||||||
/* IA_PD */
|
|
||||||
0x00, 0x19, 0x00, 0x29, 0xcc, 0x59, 0x11, 0x7b, 0x00, 0x00, 0x07, 0x08, 0x00, 0x00, 0x0b, 0x40,
|
|
||||||
/* IA_PD (iaprefix) */
|
|
||||||
0x00, 0x1a, 0x00, 0x19, 0x00, 0x00, 0x0e, 0x10, 0x00, 0x00, 0x1c, 0x20, 0x3a, 0x2a, 0x02, 0x81,
|
|
||||||
0x0d, 0x98, 0x80, 0x37, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
};
|
|
||||||
static const uint8_t duid[] = {
|
|
||||||
0x00, 0x00, 0xab, 0x11, 0x5c, 0x6b, 0x90, 0xec, 0xda, 0x95, 0x15, 0x45,
|
|
||||||
};
|
|
||||||
_cleanup_(sd_dhcp6_client_unrefp) sd_dhcp6_client *client = NULL;
|
|
||||||
_cleanup_(sd_dhcp6_lease_unrefp) sd_dhcp6_lease *lease = NULL;
|
|
||||||
|
|
||||||
log_debug("/* %s */", __func__);
|
|
||||||
|
|
||||||
assert_se(sd_dhcp6_client_new(&client) >= 0);
|
|
||||||
assert_se(sd_dhcp6_client_set_iaid(client, 0xcc59117b) >= 0);
|
|
||||||
assert_se(sd_dhcp6_client_set_duid(client, 2, duid, sizeof(duid)) >= 0);
|
|
||||||
|
|
||||||
assert_se(dhcp6_lease_new(&lease) >= 0);
|
|
||||||
|
|
||||||
assert_se(client_parse_message(client, (DHCP6Message*) msg, sizeof(msg), lease) >= 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t msg_advertise[198] = {
|
static uint8_t msg_advertise[198] = {
|
||||||
@ -476,7 +434,7 @@ static uint8_t fqdn_wire[16] = {
|
|||||||
0x05, 'i', 'n', 't', 'r', 'a', 0x00
|
0x05, 'i', 'n', 't', 'r', 'a', 0x00
|
||||||
};
|
};
|
||||||
|
|
||||||
static void test_advertise_option(sd_event *e) {
|
static int test_advertise_option(sd_event *e) {
|
||||||
_cleanup_(sd_dhcp6_lease_unrefp) sd_dhcp6_lease *lease = NULL;
|
_cleanup_(sd_dhcp6_lease_unrefp) sd_dhcp6_lease *lease = NULL;
|
||||||
DHCP6Message *advertise = (DHCP6Message *)msg_advertise;
|
DHCP6Message *advertise = (DHCP6Message *)msg_advertise;
|
||||||
size_t len = sizeof(msg_advertise) - sizeof(DHCP6Message), pos = 0;
|
size_t len = sizeof(msg_advertise) - sizeof(DHCP6Message), pos = 0;
|
||||||
@ -497,7 +455,8 @@ static void test_advertise_option(sd_event *e) {
|
|||||||
assert_se(dhcp6_lease_new(&lease) >= 0);
|
assert_se(dhcp6_lease_new(&lease) >= 0);
|
||||||
|
|
||||||
assert_se(advertise->type == DHCP6_MESSAGE_ADVERTISE);
|
assert_se(advertise->type == DHCP6_MESSAGE_ADVERTISE);
|
||||||
assert_se((be32toh(advertise->transaction_id) & 0x00ffffff) == 0x0fb4e5);
|
assert_se((be32toh(advertise->transaction_id) & 0x00ffffff) ==
|
||||||
|
0x0fb4e5);
|
||||||
|
|
||||||
while (pos < len) {
|
while (pos < len) {
|
||||||
DHCP6Option *option = (DHCP6Option *)&advertise->options[pos];
|
DHCP6Option *option = (DHCP6Option *)&advertise->options[pos];
|
||||||
@ -536,14 +495,16 @@ static void test_advertise_option(sd_event *e) {
|
|||||||
assert_se(optval == &msg_advertise[179]);
|
assert_se(optval == &msg_advertise[179]);
|
||||||
assert_se(!memcmp(optval, &msg_advertise[179], optlen));
|
assert_se(!memcmp(optval, &msg_advertise[179], optlen));
|
||||||
|
|
||||||
assert_se(dhcp6_lease_set_serverid(lease, optval, optlen) >= 0);
|
assert_se(dhcp6_lease_set_serverid(lease, optval,
|
||||||
|
optlen) >= 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SD_DHCP6_OPTION_PREFERENCE:
|
case SD_DHCP6_OPTION_PREFERENCE:
|
||||||
assert_se(optlen == 1);
|
assert_se(optlen == 1);
|
||||||
assert_se(!*optval);
|
assert_se(!*optval);
|
||||||
|
|
||||||
assert_se(dhcp6_lease_set_preference(lease, *optval) >= 0);
|
assert_se(dhcp6_lease_set_preference(lease,
|
||||||
|
*optval) >= 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SD_DHCP6_OPTION_ELAPSED_TIME:
|
case SD_DHCP6_OPTION_ELAPSED_TIME:
|
||||||
@ -577,20 +538,26 @@ static void test_advertise_option(sd_event *e) {
|
|||||||
assert_se(opt_clientid);
|
assert_se(opt_clientid);
|
||||||
|
|
||||||
sd_dhcp6_lease_reset_address_iter(lease);
|
sd_dhcp6_lease_reset_address_iter(lease);
|
||||||
assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref, <_valid) >= 0);
|
assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref,
|
||||||
|
<_valid) >= 0);
|
||||||
assert_se(!memcmp(&addr, &msg_advertise[42], sizeof(addr)));
|
assert_se(!memcmp(&addr, &msg_advertise[42], sizeof(addr)));
|
||||||
assert_se(lt_pref == 150);
|
assert_se(lt_pref == 150);
|
||||||
assert_se(lt_valid == 180);
|
assert_se(lt_valid == 180);
|
||||||
assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref, <_valid) == -ENOMSG);
|
assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref,
|
||||||
|
<_valid) == -ENOMSG);
|
||||||
|
|
||||||
sd_dhcp6_lease_reset_address_iter(lease);
|
sd_dhcp6_lease_reset_address_iter(lease);
|
||||||
assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref, <_valid) >= 0);
|
assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref,
|
||||||
|
<_valid) >= 0);
|
||||||
assert_se(!memcmp(&addr, &msg_advertise[42], sizeof(addr)));
|
assert_se(!memcmp(&addr, &msg_advertise[42], sizeof(addr)));
|
||||||
assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref, <_valid) == -ENOMSG);
|
assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref,
|
||||||
|
<_valid) == -ENOMSG);
|
||||||
sd_dhcp6_lease_reset_address_iter(lease);
|
sd_dhcp6_lease_reset_address_iter(lease);
|
||||||
assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref, <_valid) >= 0);
|
assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref,
|
||||||
|
<_valid) >= 0);
|
||||||
assert_se(!memcmp(&addr, &msg_advertise[42], sizeof(addr)));
|
assert_se(!memcmp(&addr, &msg_advertise[42], sizeof(addr)));
|
||||||
assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref, <_valid) == -ENOMSG);
|
assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref,
|
||||||
|
<_valid) == -ENOMSG);
|
||||||
|
|
||||||
assert_se(dhcp6_lease_get_serverid(lease, &opt, &len) >= 0);
|
assert_se(dhcp6_lease_get_serverid(lease, &opt, &len) >= 0);
|
||||||
assert_se(len == 14);
|
assert_se(len == 14);
|
||||||
@ -611,6 +578,8 @@ static void test_advertise_option(sd_event *e) {
|
|||||||
r = sd_dhcp6_lease_get_ntp_addrs(lease, &addrs);
|
r = sd_dhcp6_lease_get_ntp_addrs(lease, &addrs);
|
||||||
assert_se(r == 1);
|
assert_se(r == 1);
|
||||||
assert_se(!memcmp(addrs, &msg_advertise[159], r * 16));
|
assert_se(!memcmp(addrs, &msg_advertise[159], r * 16));
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int test_check_completed_in_2_seconds(sd_event_source *s, uint64_t usec, void *userdata) {
|
static int test_check_completed_in_2_seconds(sd_event_source *s, uint64_t usec, void *userdata) {
|
||||||
@ -646,7 +615,7 @@ static void test_client_solicit_cb(sd_dhcp6_client *client, int event,
|
|||||||
sd_event_exit(e, 0);
|
sd_event_exit(e, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_client_send_reply(DHCP6Message *request) {
|
static int test_client_send_reply(DHCP6Message *request) {
|
||||||
DHCP6Message reply;
|
DHCP6Message reply;
|
||||||
|
|
||||||
log_debug("/* %s */", __func__);
|
log_debug("/* %s */", __func__);
|
||||||
@ -660,10 +629,13 @@ static void test_client_send_reply(DHCP6Message *request) {
|
|||||||
|
|
||||||
memcpy(&msg_reply[44], &test_iaid, sizeof(test_iaid));
|
memcpy(&msg_reply[44], &test_iaid, sizeof(test_iaid));
|
||||||
|
|
||||||
assert_se(write(test_dhcp_fd[1], msg_reply, sizeof(msg_reply)) == sizeof(msg_reply));
|
assert_se(write(test_dhcp_fd[1], msg_reply, sizeof(msg_reply))
|
||||||
|
== sizeof(msg_reply));
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_client_verify_request(DHCP6Message *request, size_t len) {
|
static int test_client_verify_request(DHCP6Message *request, size_t len) {
|
||||||
_cleanup_(sd_dhcp6_lease_unrefp) sd_dhcp6_lease *lease = NULL;
|
_cleanup_(sd_dhcp6_lease_unrefp) sd_dhcp6_lease *lease = NULL;
|
||||||
bool found_clientid = false, found_iana = false, found_serverid = false,
|
bool found_clientid = false, found_iana = false, found_serverid = false,
|
||||||
found_elapsed_time = false, found_fqdn = false;
|
found_elapsed_time = false, found_fqdn = false;
|
||||||
@ -742,13 +714,16 @@ static void test_client_verify_request(DHCP6Message *request, size_t len) {
|
|||||||
pos += sizeof(*option) + optlen;
|
pos += sizeof(*option) + optlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_se(found_clientid && found_iana && found_serverid && found_elapsed_time);
|
assert_se(found_clientid && found_iana && found_serverid &&
|
||||||
|
found_elapsed_time);
|
||||||
|
|
||||||
sd_dhcp6_lease_reset_address_iter(lease);
|
sd_dhcp6_lease_reset_address_iter(lease);
|
||||||
assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref, <_valid) == -ENOMSG);
|
assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref, <_valid) == -ENOMSG);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_client_send_advertise(DHCP6Message *solicit) {
|
static int test_client_send_advertise(DHCP6Message *solicit) {
|
||||||
DHCP6Message advertise;
|
DHCP6Message advertise;
|
||||||
|
|
||||||
log_debug("/* %s */", __func__);
|
log_debug("/* %s */", __func__);
|
||||||
@ -762,10 +737,13 @@ static void test_client_send_advertise(DHCP6Message *solicit) {
|
|||||||
|
|
||||||
memcpy(&msg_advertise[26], &test_iaid, sizeof(test_iaid));
|
memcpy(&msg_advertise[26], &test_iaid, sizeof(test_iaid));
|
||||||
|
|
||||||
assert_se(write(test_dhcp_fd[1], msg_advertise, sizeof(msg_advertise)) == sizeof(msg_advertise));
|
assert_se(write(test_dhcp_fd[1], msg_advertise, sizeof(msg_advertise))
|
||||||
|
== sizeof(msg_advertise));
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_client_verify_solicit(DHCP6Message *solicit, size_t len) {
|
static int test_client_verify_solicit(DHCP6Message *solicit, size_t len) {
|
||||||
bool found_clientid = false, found_iana = false,
|
bool found_clientid = false, found_iana = false,
|
||||||
found_elapsed_time = false, found_fqdn = false;
|
found_elapsed_time = false, found_fqdn = false;
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
@ -827,9 +805,12 @@ static void test_client_verify_solicit(DHCP6Message *solicit, size_t len) {
|
|||||||
|
|
||||||
assert_se(pos == len);
|
assert_se(pos == len);
|
||||||
assert_se(found_clientid && found_iana && found_elapsed_time);
|
assert_se(found_clientid && found_iana && found_elapsed_time);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_client_information_cb(sd_dhcp6_client *client, int event, void *userdata) {
|
static void test_client_information_cb(sd_dhcp6_client *client, int event,
|
||||||
|
void *userdata) {
|
||||||
sd_event *e = userdata;
|
sd_event *e = userdata;
|
||||||
sd_dhcp6_lease *lease;
|
sd_dhcp6_lease *lease;
|
||||||
const struct in6_addr *addrs;
|
const struct in6_addr *addrs;
|
||||||
@ -862,14 +843,18 @@ static void test_client_information_cb(sd_dhcp6_client *client, int event, void
|
|||||||
assert_se(sd_dhcp6_client_stop(client) >= 0);
|
assert_se(sd_dhcp6_client_stop(client) >= 0);
|
||||||
assert_se(sd_dhcp6_client_set_information_request(client, false) >= 0);
|
assert_se(sd_dhcp6_client_set_information_request(client, false) >= 0);
|
||||||
|
|
||||||
assert_se(sd_dhcp6_client_set_callback(client, test_client_solicit_cb, e) >= 0);
|
assert_se(sd_dhcp6_client_set_callback(client,
|
||||||
|
test_client_solicit_cb, e) >= 0);
|
||||||
|
|
||||||
assert_se(sd_dhcp6_client_set_local_address(client, &address) >= 0);
|
assert_se(sd_dhcp6_client_set_local_address(client, &address) >= 0);
|
||||||
|
|
||||||
assert_se(sd_dhcp6_client_start(client) >= 0);
|
assert_se(sd_dhcp6_client_start(client) >= 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_client_verify_information_request(DHCP6Message *information_request, size_t len) {
|
static int test_client_verify_information_request(DHCP6Message *information_request,
|
||||||
|
size_t len) {
|
||||||
|
|
||||||
_cleanup_(sd_dhcp6_lease_unrefp) sd_dhcp6_lease *lease = NULL;
|
_cleanup_(sd_dhcp6_lease_unrefp) sd_dhcp6_lease *lease = NULL;
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
bool found_clientid = false, found_elapsed_time = false;
|
bool found_clientid = false, found_elapsed_time = false;
|
||||||
@ -920,12 +905,16 @@ static void test_client_verify_information_request(DHCP6Message *information_req
|
|||||||
|
|
||||||
sd_dhcp6_lease_reset_address_iter(lease);
|
sd_dhcp6_lease_reset_address_iter(lease);
|
||||||
|
|
||||||
assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref, <_valid) == -ENOMSG);
|
assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref,
|
||||||
|
<_valid) == -ENOMSG);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dhcp6_network_send_udp_socket(int s, struct in6_addr *server_address,
|
int dhcp6_network_send_udp_socket(int s, struct in6_addr *server_address,
|
||||||
const void *packet, size_t len) {
|
const void *packet, size_t len) {
|
||||||
struct in6_addr mcast = IN6ADDR_ALL_DHCP6_RELAY_AGENTS_AND_SERVERS_INIT;
|
struct in6_addr mcast =
|
||||||
|
IN6ADDR_ALL_DHCP6_RELAY_AGENTS_AND_SERVERS_INIT;
|
||||||
DHCP6Message *message;
|
DHCP6Message *message;
|
||||||
|
|
||||||
log_debug("/* %s */", __func__);
|
log_debug("/* %s */", __func__);
|
||||||
@ -966,7 +955,7 @@ int dhcp6_network_bind_udp_socket(int ifindex, struct in6_addr *local_address) {
|
|||||||
return test_dhcp_fd[0];
|
return test_dhcp_fd[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_client_solicit(sd_event *e) {
|
static int test_client_solicit(sd_event *e) {
|
||||||
sd_dhcp6_client *client;
|
sd_dhcp6_client *client;
|
||||||
struct in6_addr address = { { { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01 } } };
|
struct in6_addr address = { { { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01 } } };
|
||||||
int val;
|
int val;
|
||||||
@ -1009,6 +998,8 @@ static void test_client_solicit(sd_event *e) {
|
|||||||
assert_se(!sd_dhcp6_client_unref(client));
|
assert_se(!sd_dhcp6_client_unref(client));
|
||||||
|
|
||||||
test_dhcp_fd[1] = safe_close(test_dhcp_fd[1]);
|
test_dhcp_fd[1] = safe_close(test_dhcp_fd[1]);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
@ -1019,12 +1010,11 @@ int main(int argc, char *argv[]) {
|
|||||||
test_setup_logging(LOG_DEBUG);
|
test_setup_logging(LOG_DEBUG);
|
||||||
|
|
||||||
test_client_basic(e);
|
test_client_basic(e);
|
||||||
test_parse_domain();
|
test_option(e);
|
||||||
test_option();
|
test_option_status(e);
|
||||||
test_option_status();
|
|
||||||
test_client_parse_message_issue_22099();
|
|
||||||
test_advertise_option(e);
|
test_advertise_option(e);
|
||||||
test_client_solicit(e);
|
test_client_solicit(e);
|
||||||
|
test_parse_domain(e);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2846,12 +2846,6 @@ static int route_section_verify(Route *route, Network *network) {
|
|||||||
route->scope = RT_SCOPE_HOST;
|
route->scope = RT_SCOPE_HOST;
|
||||||
else if (IN_SET(route->type, RTN_BROADCAST, RTN_ANYCAST, RTN_MULTICAST))
|
else if (IN_SET(route->type, RTN_BROADCAST, RTN_ANYCAST, RTN_MULTICAST))
|
||||||
route->scope = RT_SCOPE_LINK;
|
route->scope = RT_SCOPE_LINK;
|
||||||
else if (IN_SET(route->type, RTN_UNICAST, RTN_UNSPEC) &&
|
|
||||||
!route->gateway_from_dhcp_or_ra &&
|
|
||||||
!in_addr_is_set(route->gw_family, &route->gw) &&
|
|
||||||
ordered_set_isempty(route->multipath_routes) &&
|
|
||||||
route->nexthop_id == 0)
|
|
||||||
route->scope = RT_SCOPE_LINK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (route->scope != RT_SCOPE_UNIVERSE && route->family == AF_INET6) {
|
if (route->scope != RT_SCOPE_UNIVERSE && route->family == AF_INET6) {
|
||||||
|
|||||||
@ -24,6 +24,7 @@ Gateway=fe80::222:4dff:ff:ff:ff:ff
|
|||||||
|
|
||||||
[Route]
|
[Route]
|
||||||
Destination=149.10.124.64
|
Destination=149.10.124.64
|
||||||
|
Scope=link
|
||||||
|
|
||||||
[Route]
|
[Route]
|
||||||
Gateway=149.10.124.64
|
Gateway=149.10.124.64
|
||||||
|
|||||||
@ -2542,9 +2542,9 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
|
|||||||
self.assertIn('149.10.124.48/28 proto kernel scope link src 149.10.124.58', output)
|
self.assertIn('149.10.124.48/28 proto kernel scope link src 149.10.124.58', output)
|
||||||
self.assertIn('149.10.124.64 proto static scope link', output)
|
self.assertIn('149.10.124.64 proto static scope link', output)
|
||||||
self.assertIn('169.254.0.0/16 proto static scope link metric 2048', output)
|
self.assertIn('169.254.0.0/16 proto static scope link metric 2048', output)
|
||||||
self.assertIn('192.168.1.1 proto static scope link initcwnd 20', output)
|
self.assertIn('192.168.1.1 proto static initcwnd 20', output)
|
||||||
self.assertIn('192.168.1.2 proto static scope link initrwnd 30', output)
|
self.assertIn('192.168.1.2 proto static initrwnd 30', output)
|
||||||
self.assertIn('192.168.1.3 proto static scope link advmss 30', output)
|
self.assertIn('192.168.1.3 proto static advmss 30', output)
|
||||||
self.assertIn('multicast 149.10.123.4 proto static', output)
|
self.assertIn('multicast 149.10.123.4 proto static', output)
|
||||||
|
|
||||||
print('### ip -4 route show dev dummy98 default')
|
print('### ip -4 route show dev dummy98 default')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user