1
0
mirror of https://github.com/systemd/systemd synced 2026-03-28 17:54:51 +01:00

Compare commits

..

6 Commits

Author SHA1 Message Date
Dan Streetman
cf7c7512f5 userdb: fix if-else to allow NameServiceSwitch lookups
Fixes: #20809. Bug introduced in 8fbb1941f1a8c3d9eda920891b2b51a67f2a2375
2021-09-22 22:34:37 +01:00
Yu Watanabe
469fd57f18 sd-dhcp6-client: ignore IAs whose IAID do not match client's IAID
But do not refuse whole message.

Fixes #20803.
2021-09-22 21:19:54 +01:00
Luca Boccassi
2982084827
Merge pull request #20736 from keszybz/ioprio-simplification
Use a simple kernel-compatible header for ioprio
2021-09-22 15:46:50 +01:00
Zbigniew Jędrzejewski-Szmek
5bead76e46 Get rid of ioprio.h and add a minimalistic reimplementation of the api 2021-09-22 12:58:47 +02:00
Zbigniew Jędrzejewski-Szmek
51fe206fb3 Define ioprio_{get,set} the same as other compat syscalls 2021-09-22 12:58:47 +02:00
Zbigniew Jędrzejewski-Szmek
3c9fbb993b variuos: add missing includes 2021-09-22 12:58:46 +02:00
25 changed files with 177 additions and 113 deletions

View File

@ -501,6 +501,8 @@ foreach ident : [
#include <unistd.h>'''],
['pivot_root', '''#include <stdlib.h>
#include <unistd.h>'''], # no known header declares pivot_root
['ioprio_get', '''#include <sched.h>'''], # no known header declares ioprio_get
['ioprio_set', '''#include <sched.h>'''], # no known header declares ioprio_set
['name_to_handle_at', '''#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>'''],

View File

@ -1,56 +0,0 @@
#ifndef IOPRIO_H
#define IOPRIO_H
/* This is minimal version of Linux' linux/ioprio.h header file, which
* is licensed GPL2 */
#include <sys/syscall.h>
#include <unistd.h>
/*
* Gives us 8 prio classes with 13-bits of data for each class
*/
#define IOPRIO_BITS 16
#define IOPRIO_N_CLASSES 8
#define IOPRIO_CLASS_SHIFT 13
#define IOPRIO_PRIO_MASK ((1UL << IOPRIO_CLASS_SHIFT) - 1)
#define IOPRIO_PRIO_CLASS(mask) ((mask) >> IOPRIO_CLASS_SHIFT)
#define IOPRIO_PRIO_DATA(mask) ((mask) & IOPRIO_PRIO_MASK)
#define IOPRIO_PRIO_VALUE(class, data) (((class) << IOPRIO_CLASS_SHIFT) | data)
#define ioprio_valid(mask) (IOPRIO_PRIO_CLASS((mask)) != IOPRIO_CLASS_NONE)
/*
* These are the io priority groups as implemented by CFQ. RT is the realtime
* class, it always gets premium service. BE is the best-effort scheduling
* class, the default for any process. IDLE is the idle scheduling class, it
* is only served when no one else is using the disk.
*/
enum {
IOPRIO_CLASS_NONE,
IOPRIO_CLASS_RT,
IOPRIO_CLASS_BE,
IOPRIO_CLASS_IDLE,
};
/*
* 8 best effort priority levels are supported
*/
#define IOPRIO_BE_NR (8)
enum {
IOPRIO_WHO_PROCESS = 1,
IOPRIO_WHO_PGRP,
IOPRIO_WHO_USER,
};
static inline int ioprio_set(int which, int who, int ioprio) {
return syscall(__NR_ioprio_set, which, who, ioprio);
}
static inline int ioprio_get(int which, int who) {
return syscall(__NR_ioprio_get, which, who);
}
#endif

View File

@ -1,5 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <unistd.h>
#include "alloc-util.h"
#include "cgroup-util.h"
#include "limits-util.h"

View File

@ -72,7 +72,6 @@ basic_sources = files('''
in-addr-util.h
io-util.c
io-util.h
ioprio.h
khash.c
khash.h
limits-util.c
@ -131,6 +130,7 @@ basic_sources = files('''
missing_fcntl.h
missing_fs.h
missing_input.h
missing_ioprio.h
missing_keyctl.h
missing_magic.h
missing_mman.h

View File

@ -0,0 +1,59 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <sched.h>
/* Match values uses by the kernel internally, as no public header seems to exist. */
#ifndef IOPRIO_N_CLASSES
# define IOPRIO_N_CLASSES 8
#endif
#ifndef IOPRIO_BE_NR
# define IOPRIO_BE_NR 8
#endif
#ifndef IOPRIO_CLASS_NONE
# define IOPRIO_CLASS_NONE 0
#endif
#ifndef IOPRIO_CLASS_RT
# define IOPRIO_CLASS_RT 1
#endif
#ifndef IOPRIO_CLASS_BE
# define IOPRIO_CLASS_BE 2
#endif
#ifndef IOPRIO_CLASS_IDLE
# define IOPRIO_CLASS_IDLE 3
#endif
#ifndef IOPRIO_WHO_PROCESS
# define IOPRIO_WHO_PROCESS 1
#endif
#ifndef IOPRIO_WHO_PGRP
# define IOPRIO_WHO_PGRP 2
#endif
#ifndef IOPRIO_WHO_USER
# define IOPRIO_WHO_USER 3
#endif
#ifndef IOPRIO_BITS
# define IOPRIO_BITS 16
#endif
#ifndef IOPRIO_N_CLASSES
# define IOPRIO_N_CLASSES 8
#endif
#ifndef IOPRIO_CLASS_SHIFT
# define IOPRIO_CLASS_SHIFT 13
#endif
static inline int ioprio_prio_class(int value) {
return value >> IOPRIO_CLASS_SHIFT;
}
static inline int ioprio_prio_data(int value) {
return value & ((1 << IOPRIO_CLASS_SHIFT) - 1);
}
static inline int ioprio_prio_value(int class, int data) {
return (class << IOPRIO_CLASS_SHIFT) | data;
}

View File

@ -41,6 +41,26 @@ static inline int missing_pivot_root(const char *new_root, const char *put_old)
/* ======================================================================= */
#if !HAVE_IOPRIO_GET
static inline int missing_ioprio_get(int which, int who) {
return syscall(__NR_ioprio_get, which, who);
}
# define ioprio_get missing_ioprio_get
#endif
/* ======================================================================= */
#if !HAVE_IOPRIO_SET
static inline int missing_ioprio_set(int which, int who, int ioprio) {
return syscall(__NR_ioprio_set, which, who, ioprio);
}
# define ioprio_set missing_ioprio_set
#endif
/* ======================================================================= */
#if !HAVE_MEMFD_CREATE
static inline int missing_memfd_create(const char *name, unsigned int flags) {
# ifdef __NR_memfd_create

View File

@ -27,7 +27,6 @@
#include "fd-util.h"
#include "fileio.h"
#include "fs-util.h"
#include "ioprio.h"
#include "locale-util.h"
#include "log.h"
#include "macro.h"

View File

@ -13,8 +13,8 @@
#include "alloc-util.h"
#include "format-util.h"
#include "ioprio.h"
#include "macro.h"
#include "missing_ioprio.h"
#include "time-util.h"
#define procfs_file_alloca(pid, field) \

View File

@ -1,6 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <errno.h>
#include <unistd.h>
#include "alloc-util.h"
#include "def.h"

View File

@ -24,8 +24,8 @@
#include "fileio.h"
#include "hexdecoct.h"
#include "io-util.h"
#include "ioprio.h"
#include "journal-file.h"
#include "missing_ioprio.h"
#include "mountpoint-util.h"
#include "namespace.h"
#include "parse-util.h"
@ -55,8 +55,8 @@ static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_protect_system, protect_system,
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_personality, personality, unsigned long);
static BUS_DEFINE_PROPERTY_GET(property_get_ioprio, "i", ExecContext, exec_context_get_effective_ioprio);
static BUS_DEFINE_PROPERTY_GET(property_get_mount_apivfs, "b", ExecContext, exec_context_get_effective_mount_apivfs);
static BUS_DEFINE_PROPERTY_GET2(property_get_ioprio_class, "i", ExecContext, exec_context_get_effective_ioprio, IOPRIO_PRIO_CLASS);
static BUS_DEFINE_PROPERTY_GET2(property_get_ioprio_priority, "i", ExecContext, exec_context_get_effective_ioprio, IOPRIO_PRIO_DATA);
static BUS_DEFINE_PROPERTY_GET2(property_get_ioprio_class, "i", ExecContext, exec_context_get_effective_ioprio, ioprio_prio_class);
static BUS_DEFINE_PROPERTY_GET2(property_get_ioprio_priority, "i", ExecContext, exec_context_get_effective_ioprio, ioprio_prio_data);
static BUS_DEFINE_PROPERTY_GET_GLOBAL(property_get_empty_string, "s", NULL);
static BUS_DEFINE_PROPERTY_GET_REF(property_get_syslog_level, "i", int, LOG_PRI);
static BUS_DEFINE_PROPERTY_GET_REF(property_get_syslog_facility, "i", int, LOG_FAC);
@ -2637,7 +2637,7 @@ int bus_exec_context_set_transient_property(
if (r < 0)
return r;
c->ioprio = IOPRIO_PRIO_VALUE(q, IOPRIO_PRIO_DATA(c->ioprio));
c->ioprio = ioprio_prio_value(q, ioprio_prio_data(c->ioprio));
c->ioprio_set = true;
unit_write_settingf(u, flags, name, "IOSchedulingClass=%s", s);
@ -2656,7 +2656,7 @@ int bus_exec_context_set_transient_property(
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid IO scheduling priority: %i", p);
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
c->ioprio = IOPRIO_PRIO_VALUE(IOPRIO_PRIO_CLASS(c->ioprio), p);
c->ioprio = ioprio_prio_value(ioprio_prio_class(c->ioprio), p);
c->ioprio_set = true;
unit_write_settingf(u, flags, name, "IOSchedulingPriority=%i", p);

View File

@ -62,7 +62,6 @@
#include "glob-util.h"
#include "hexdecoct.h"
#include "io-util.h"
#include "ioprio.h"
#include "label.h"
#include "log.h"
#include "macro.h"
@ -70,6 +69,7 @@
#include "manager-dump.h"
#include "memory-util.h"
#include "missing_fs.h"
#include "missing_ioprio.h"
#include "mkdir.h"
#include "mount-util.h"
#include "mountpoint-util.h"
@ -4865,7 +4865,7 @@ void exec_context_init(ExecContext *c) {
assert(c);
c->umask = 0022;
c->ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 0);
c->ioprio = ioprio_prio_value(IOPRIO_CLASS_BE, 0);
c->cpu_sched_policy = SCHED_OTHER;
c->syslog_priority = LOG_DAEMON|LOG_INFO;
c->syslog_level_prefix = true;
@ -5427,11 +5427,11 @@ void exec_context_dump(const ExecContext *c, FILE* f, const char *prefix) {
if (c->ioprio_set) {
_cleanup_free_ char *class_str = NULL;
r = ioprio_class_to_string_alloc(IOPRIO_PRIO_CLASS(c->ioprio), &class_str);
r = ioprio_class_to_string_alloc(ioprio_prio_class(c->ioprio), &class_str);
if (r >= 0)
fprintf(f, "%sIOSchedulingClass: %s\n", prefix, class_str);
fprintf(f, "%sIOPriority: %lu\n", prefix, IOPRIO_PRIO_DATA(c->ioprio));
fprintf(f, "%sIOPriority: %d\n", prefix, ioprio_prio_data(c->ioprio));
}
if (c->cpu_sched_set) {
@ -5784,7 +5784,7 @@ int exec_context_get_effective_ioprio(const ExecContext *c) {
p = ioprio_get(IOPRIO_WHO_PROCESS, 0);
if (p < 0)
return IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 4);
return ioprio_prio_value(IOPRIO_CLASS_BE, 4);
return p;
}

View File

@ -39,12 +39,12 @@
#include "fs-util.h"
#include "hexdecoct.h"
#include "io-util.h"
#include "ioprio.h"
#include "ip-protocol-list.h"
#include "journal-file.h"
#include "limits-util.h"
#include "load-fragment.h"
#include "log.h"
#include "missing_ioprio.h"
#include "mountpoint-util.h"
#include "nulstr-util.h"
#include "parse-socket-bind-item.h"
@ -1266,7 +1266,7 @@ int config_parse_exec_io_class(const char *unit,
if (isempty(rvalue)) {
c->ioprio_set = false;
c->ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 0);
c->ioprio = ioprio_prio_value(IOPRIO_CLASS_BE, 0);
return 0;
}
@ -1276,7 +1276,7 @@ int config_parse_exec_io_class(const char *unit,
return 0;
}
c->ioprio = IOPRIO_PRIO_VALUE(x, IOPRIO_PRIO_DATA(c->ioprio));
c->ioprio = ioprio_prio_value(x, ioprio_prio_data(c->ioprio));
c->ioprio_set = true;
return 0;
@ -1303,7 +1303,7 @@ int config_parse_exec_io_priority(const char *unit,
if (isempty(rvalue)) {
c->ioprio_set = false;
c->ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 0);
c->ioprio = ioprio_prio_value(IOPRIO_CLASS_BE, 0);
return 0;
}
@ -1313,7 +1313,7 @@ int config_parse_exec_io_priority(const char *unit,
return 0;
}
c->ioprio = IOPRIO_PRIO_VALUE(IOPRIO_PRIO_CLASS(c->ioprio), i);
c->ioprio = ioprio_prio_value(ioprio_prio_class(c->ioprio), i);
c->ioprio_set = true;
return 0;

View File

@ -1,6 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <getopt.h>
#include <unistd.h>
#include "creds-util.h"
#include "dirent-util.h"

View File

@ -5,6 +5,7 @@
#include <getopt.h>
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
#include "sd-daemon.h"

View File

@ -104,7 +104,7 @@ int dhcp6_option_append_vendor_option(uint8_t **buf, size_t *buflen, OrderedHash
int dhcp6_option_parse(uint8_t **buf, size_t *buflen, uint16_t *optcode,
size_t *optlen, uint8_t **optvalue);
int dhcp6_option_parse_status(DHCP6Option *option, size_t len);
int dhcp6_option_parse_ia(sd_dhcp6_client *client, DHCP6Option *iaoption, DHCP6IA *ia, uint16_t *ret_status_code);
int dhcp6_option_parse_ia(sd_dhcp6_client *client, DHCP6Option *iaoption, be32_t iaid, DHCP6IA *ia, uint16_t *ret_status_code);
int dhcp6_option_parse_ip6addrs(uint8_t *optval, uint16_t optlen,
struct in6_addr **addrs, size_t count);
int dhcp6_option_parse_domainname_list(const uint8_t *optval, uint16_t optlen,

View File

@ -509,7 +509,13 @@ static int dhcp6_option_parse_pdprefix(sd_dhcp6_client *client, DHCP6Option *opt
return 0;
}
int dhcp6_option_parse_ia(sd_dhcp6_client *client, DHCP6Option *iaoption, DHCP6IA *ia, uint16_t *ret_status_code) {
int dhcp6_option_parse_ia(
sd_dhcp6_client *client,
DHCP6Option *iaoption,
be32_t iaid,
DHCP6IA *ia,
uint16_t *ret_status_code) {
uint32_t lt_t1, lt_t2, lt_valid = 0, lt_min = UINT32_MAX;
uint16_t iatype, optlen;
size_t iaaddr_offset;
@ -529,6 +535,14 @@ int dhcp6_option_parse_ia(sd_dhcp6_client *client, DHCP6Option *iaoption, DHCP6I
if (len < DHCP6_OPTION_IA_NA_LEN)
return -ENOBUFS;
/* According to RFC8415, IAs which do not match the client's IAID should be ignored,
* but not necessary to ignore or refuse the whole message. */
if (((const struct ia_na*) iaoption->data)->id != iaid)
/* ENOANO indicates the option should be ignored. */
return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(ENOANO),
"Received an IA_NA option with a different IAID "
"from the one chosen by the client, ignoring.");
iaaddr_offset = DHCP6_OPTION_IA_NA_LEN;
memcpy(&ia->ia_na, iaoption->data, sizeof(ia->ia_na));
@ -547,6 +561,14 @@ int dhcp6_option_parse_ia(sd_dhcp6_client *client, DHCP6Option *iaoption, DHCP6I
if (len < sizeof(ia->ia_pd))
return -ENOBUFS;
/* According to RFC8415, IAs which do not match the client's IAID should be ignored,
* but not necessary to ignore or refuse the whole message. */
if (((const struct ia_pd*) iaoption->data)->id != iaid)
/* ENOANO indicates the option should be ignored. */
return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(ENOANO),
"Received an IA_PD option with a different IAID "
"from the one chosen by the client, ignoring.");
iaaddr_offset = sizeof(ia->ia_pd);
memcpy(&ia->ia_pd, iaoption->data, sizeof(ia->ia_pd));
@ -564,13 +586,21 @@ int dhcp6_option_parse_ia(sd_dhcp6_client *client, DHCP6Option *iaoption, DHCP6I
if (len < DHCP6_OPTION_IA_TA_LEN)
return -ENOBUFS;
/* According to RFC8415, IAs which do not match the client's IAID should be ignored,
* but not necessary to ignore or refuse the whole message. */
if (((const struct ia_ta*) iaoption->data)->id != iaid)
/* ENOANO indicates the option should be ignored. */
return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(ENOANO),
"Received an IA_TA option with a different IAID "
"from the one chosen by the client, ignoring.");
iaaddr_offset = DHCP6_OPTION_IA_TA_LEN;
memcpy(&ia->ia_ta.id, iaoption->data, sizeof(ia->ia_ta));
memcpy(&ia->ia_ta, iaoption->data, sizeof(ia->ia_ta));
break;
default:
return -ENOMSG;
return -EINVAL;
}
ia->type = iatype;

View File

@ -1118,7 +1118,6 @@ static int client_parse_message(
while (pos < len) {
DHCP6Option *option = (DHCP6Option *) &message->options[pos];
uint16_t optcode, optlen;
be32_t iaid_lease;
int status;
uint8_t *optval;
@ -1187,8 +1186,8 @@ static int client_parse_message(
break;
}
r = dhcp6_option_parse_ia(client, option, &lease->ia, &ia_na_status);
if (r < 0 && r != -ENOMSG)
r = dhcp6_option_parse_ia(client, option, client->ia_pd.ia_na.id, &lease->ia, &ia_na_status);
if (r < 0 && r != -ENOANO)
return r;
if (ia_na_status == DHCP6_STATUS_NO_ADDRS_AVAIL) {
@ -1196,14 +1195,6 @@ static int client_parse_message(
continue;
}
r = dhcp6_lease_get_iaid(lease, &iaid_lease);
if (r < 0)
return r;
if (client->ia_na.ia_na.id != iaid_lease)
return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL), "%s has wrong IAID for IA NA",
dhcp6_message_type_to_string(message->type));
if (lease->ia.addresses) {
lt_t1 = MIN(lt_t1, be32toh(lease->ia.ia_na.lifetime_t1));
lt_t2 = MIN(lt_t2, be32toh(lease->ia.ia_na.lifetime_t2));
@ -1217,8 +1208,8 @@ static int client_parse_message(
break;
}
r = dhcp6_option_parse_ia(client, option, &lease->pd, &ia_pd_status);
if (r < 0 && r != -ENOMSG)
r = dhcp6_option_parse_ia(client, option, client->ia_pd.ia_pd.id, &lease->pd, &ia_pd_status);
if (r < 0 && r != -ENOANO)
return r;
if (ia_pd_status == DHCP6_STATUS_NO_PREFIX_AVAIL) {
@ -1226,14 +1217,6 @@ static int client_parse_message(
continue;
}
r = dhcp6_lease_get_pd_iaid(lease, &iaid_lease);
if (r < 0)
return r;
if (client->ia_pd.ia_pd.id != iaid_lease)
return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL), "%s has wrong IAID for IA PD",
dhcp6_message_type_to_string(message->type));
if (lease->pd.addresses) {
lt_t1 = MIN(lt_t1, be32toh(lease->pd.ia_pd.lifetime_t1));
lt_t2 = MIN(lt_t2, be32toh(lease->pd.ia_pd.lifetime_t2));

View File

@ -287,25 +287,31 @@ static int test_option_status(sd_event *e) {
};
DHCP6Option *option;
DHCP6IA ia, pd;
be32_t iaid;
int r = 0;
log_debug("/* %s */", __func__);
memcpy(&iaid, option1 + 4, sizeof(iaid));
zero(ia);
option = (DHCP6Option *)option1;
assert_se(sizeof(option1) == sizeof(DHCP6Option) + be16toh(option->len));
r = dhcp6_option_parse_ia(NULL, option, &ia, NULL);
r = dhcp6_option_parse_ia(NULL, option, 0, &ia, NULL);
assert_se(r == -ENOANO);
r = dhcp6_option_parse_ia(NULL, option, iaid, &ia, NULL);
assert_se(r == 0);
assert_se(ia.addresses == NULL);
option->len = htobe16(17);
r = dhcp6_option_parse_ia(NULL, option, &ia, NULL);
r = dhcp6_option_parse_ia(NULL, option, iaid, &ia, NULL);
assert_se(r == -ENOBUFS);
assert_se(ia.addresses == NULL);
option->len = htobe16(sizeof(DHCP6Option));
r = dhcp6_option_parse_ia(NULL, option, &ia, NULL);
r = dhcp6_option_parse_ia(NULL, option, iaid, &ia, NULL);
assert_se(r == -ENOBUFS);
assert_se(ia.addresses == NULL);
@ -313,7 +319,7 @@ static int test_option_status(sd_event *e) {
option = (DHCP6Option *)option2;
assert_se(sizeof(option2) == sizeof(DHCP6Option) + be16toh(option->len));
r = dhcp6_option_parse_ia(NULL, option, &ia, NULL);
r = dhcp6_option_parse_ia(NULL, option, iaid, &ia, NULL);
assert_se(r >= 0);
assert_se(ia.addresses == NULL);
@ -321,7 +327,7 @@ static int test_option_status(sd_event *e) {
option = (DHCP6Option *)option3;
assert_se(sizeof(option3) == sizeof(DHCP6Option) + be16toh(option->len));
r = dhcp6_option_parse_ia(NULL, option, &ia, NULL);
r = dhcp6_option_parse_ia(NULL, option, iaid, &ia, NULL);
assert_se(r >= 0);
assert_se(ia.addresses != NULL);
dhcp6_lease_free_ia(&ia);
@ -330,7 +336,7 @@ static int test_option_status(sd_event *e) {
option = (DHCP6Option *)option4;
assert_se(sizeof(option4) == sizeof(DHCP6Option) + be16toh(option->len));
r = dhcp6_option_parse_ia(NULL, option, &pd, NULL);
r = dhcp6_option_parse_ia(NULL, option, iaid, &pd, NULL);
assert_se(r >= 0);
assert_se(pd.addresses != NULL);
assert_se(memcmp(&pd.ia_pd.id, &option4[4], 4) == 0);
@ -342,7 +348,7 @@ static int test_option_status(sd_event *e) {
option = (DHCP6Option *)option5;
assert_se(sizeof(option5) == sizeof(DHCP6Option) + be16toh(option->len));
r = dhcp6_option_parse_ia(NULL, option, &pd, NULL);
r = dhcp6_option_parse_ia(NULL, option, iaid, &pd, NULL);
assert_se(r >= 0);
assert_se(pd.addresses != NULL);
dhcp6_lease_free_ia(&pd);
@ -447,13 +453,14 @@ static int test_advertise_option(sd_event *e) {
opt_clientid = true;
break;
case SD_DHCP6_OPTION_IA_NA:
case SD_DHCP6_OPTION_IA_NA: {
be32_t iaid = htobe32(0x0ecfa37d);
assert_se(optlen == 94);
assert_se(optval == &msg_advertise[26]);
assert_se(!memcmp(optval, &msg_advertise[26], optlen));
val = htobe32(0x0ecfa37d);
assert_se(!memcmp(optval, &val, sizeof(val)));
assert_se(!memcmp(optval, &iaid, sizeof(val)));
val = htobe32(80);
assert_se(!memcmp(optval + 4, &val, sizeof(val)));
@ -461,10 +468,10 @@ static int test_advertise_option(sd_event *e) {
val = htobe32(120);
assert_se(!memcmp(optval + 8, &val, sizeof(val)));
assert_se(dhcp6_option_parse_ia(NULL, option, &lease->ia, NULL) >= 0);
assert_se(dhcp6_option_parse_ia(NULL, option, iaid, &lease->ia, NULL) >= 0);
break;
}
case SD_DHCP6_OPTION_SERVERID:
assert_se(optlen == 14);
assert_se(optval == &msg_advertise[179]);
@ -596,6 +603,8 @@ static void test_client_solicit_cb(sd_dhcp6_client *client, int event,
static int test_client_send_reply(DHCP6Message *request) {
DHCP6Message reply;
log_debug("/* %s */", __func__);
reply.transaction_id = request->transaction_id;
reply.type = DHCP6_REPLY;
@ -656,7 +665,7 @@ static int test_client_verify_request(DHCP6Message *request, size_t len) {
assert_se(!memcmp(optval + 8, &val, sizeof(val)));
/* Then, this should refuse all addresses. */
assert_se(dhcp6_option_parse_ia(NULL, option, &lease->ia, NULL) >= 0);
assert_se(dhcp6_option_parse_ia(NULL, option, test_iaid, &lease->ia, NULL) >= 0);
break;
@ -702,6 +711,8 @@ static int test_client_verify_request(DHCP6Message *request, size_t len) {
static int test_client_send_advertise(DHCP6Message *solicit) {
DHCP6Message advertise;
log_debug("/* %s */", __func__);
advertise.transaction_id = solicit->transaction_id;
advertise.type = DHCP6_ADVERTISE;
@ -891,6 +902,8 @@ int dhcp6_network_send_udp_socket(int s, struct in6_addr *server_address,
IN6ADDR_ALL_DHCP6_RELAY_AGENTS_AND_SERVERS_INIT;
DHCP6Message *message;
log_debug("/* %s */", __func__);
assert_se(s == test_dhcp_fd[0]);
assert_se(server_address);
assert_se(packet);

View File

@ -1,6 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <sys/wait.h>
#include <unistd.h>
#include "alloc-util.h"
#include "fd-util.h"

View File

@ -1,5 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <unistd.h>
#include "alloc-util.h"
#include "fd-util.h"
#include "portabled-operation.h"

View File

@ -7,6 +7,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <unistd.h>
#include "alloc-util.h"
#include "calendarspec.h"

View File

@ -1,5 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <unistd.h>
#include "id128-util.h"
#include "mkfs-util.h"
#include "path-util.h"

View File

@ -1,5 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <unistd.h>
#include "bootspec.h"
#include "bus-error.h"
#include "bus-locator.h"

View File

@ -3,6 +3,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include "data-fd-util.h"
#include "fd-util.h"

View File

@ -119,7 +119,7 @@ static int userdb_flags_from_service(Varlink *link, const char *service, UserDBF
if (streq_ptr(service, "io.systemd.NameServiceSwitch"))
*ret = USERDB_NSS_ONLY|USERDB_AVOID_MULTIPLEXER;
if (streq_ptr(service, "io.systemd.DropIn"))
else if (streq_ptr(service, "io.systemd.DropIn"))
*ret = USERDB_DROPIN_ONLY|USERDB_AVOID_MULTIPLEXER;
else if (streq_ptr(service, "io.systemd.Multiplexer"))
*ret = USERDB_AVOID_MULTIPLEXER;