Compare commits
No commits in common. "7f16ef9fba3ba16c66452ca1d96c6c68cc8ebe3e" and "b5ef66101a7b1126b67fa58c68fb3ef246327276" have entirely different histories.
7f16ef9fba
...
b5ef66101a
79
man/udev.xml
79
man/udev.xml
|
@ -280,17 +280,13 @@
|
|||
<varlistentry>
|
||||
<term><varname>PROGRAM</varname></term>
|
||||
<listitem>
|
||||
<para>Execute a program to determine whether there is a match; the key is true if the program
|
||||
returns successfully. The device properties are made available to the executed program in the
|
||||
environment. The program's standard output is available in the <varname>RESULT</varname>
|
||||
key.</para>
|
||||
|
||||
<para>This can only be used for very short-running foreground tasks. For details, see
|
||||
<varname>RUN</varname>.</para>
|
||||
|
||||
<para>Note that multiple <varname>PROGRAM</varname> keys may be specified in one rule, and
|
||||
<literal>=</literal>, <literal>:=</literal>, and <literal>+=</literal> have the same effect as
|
||||
<literal>==</literal>.</para>
|
||||
<para>Execute a program to determine whether there
|
||||
is a match; the key is true if the program returns
|
||||
successfully. The device properties are made available to the
|
||||
executed program in the environment. The program's standard output
|
||||
is available in the <varname>RESULT</varname> key.</para>
|
||||
<para>This can only be used for very short-running foreground tasks. For details,
|
||||
see <varname>RUN</varname>.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
@ -433,14 +429,9 @@
|
|||
<varlistentry>
|
||||
<term><varname>RUN{<replaceable>type</replaceable>}</varname></term>
|
||||
<listitem>
|
||||
<para>Specify a program to be executed after processing of all the rules for the event. With
|
||||
<literal>+=</literal>, this invocation is added to the list, and with <literal>=</literal> or
|
||||
<literal>:=</literal>, it replaces any previous contents of the list. Please note that both
|
||||
<literal>program</literal> and <literal>builtin</literal> types described below use a single
|
||||
list, so clearing the list with <literal>:=</literal> and <literal>=</literal> affects both
|
||||
types.</para>
|
||||
|
||||
<para><replaceable>type</replaceable> may be:</para>
|
||||
<para>Add a program to the list of programs to be executed after
|
||||
processing all the rules for a specific event, depending on
|
||||
<literal>type</literal>:</para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><literal>program</literal></term>
|
||||
|
@ -461,21 +452,21 @@
|
|||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
|
||||
<para>The program name and following arguments are separated by spaces. Single quotes can be
|
||||
used to specify arguments with spaces.</para>
|
||||
|
||||
<para>This can only be used for very short-running foreground tasks. Running an event process for
|
||||
a long period of time may block all further events for this or a dependent device.</para>
|
||||
|
||||
<para>Note that running programs that access the network or mount/unmount filesystems is not
|
||||
allowed inside of udev rules, due to the default sandbox that is enforced on
|
||||
<filename>systemd-udevd.service</filename>.</para>
|
||||
|
||||
<para>Starting daemons or other long-running processes is not allowed; the forked processes,
|
||||
detached or not, will be unconditionally killed after the event handling has finished. In order
|
||||
to activate long-running processes from udev rules, provide a service unit and pull it in from a
|
||||
udev device using the <varname>SYSTEMD_WANTS</varname> device property. See
|
||||
<para>The program name and following arguments are separated by spaces.
|
||||
Single quotes can be used to specify arguments with spaces.</para>
|
||||
<para>This can only be used for very short-running foreground tasks. Running an
|
||||
event process for a long period of time may block all further events for
|
||||
this or a dependent device.</para>
|
||||
<para>Starting daemons or other long-running processes is not appropriate
|
||||
for udev; the forked processes, detached or not, will be unconditionally
|
||||
killed after the event handling has finished.</para>
|
||||
<para>Note that running programs that access the network or mount/unmount
|
||||
filesystems is not allowed inside of udev rules, due to the default sandbox
|
||||
that is enforced on <filename>systemd-udevd.service</filename>.</para>
|
||||
<para>Please also note that <literal>:=</literal> and <literal>=</literal> are clearing
|
||||
both, program and builtin commands.</para>
|
||||
<para>In order to activate long-running processes from udev rules, provide a service unit, and
|
||||
pull it in from a udev device using the <varname>SYSTEMD_WANTS</varname> device property. See
|
||||
<citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry>
|
||||
for details.</para>
|
||||
</listitem>
|
||||
|
@ -498,9 +489,8 @@
|
|||
<varlistentry>
|
||||
<term><varname>IMPORT{<replaceable>type</replaceable>}</varname></term>
|
||||
<listitem>
|
||||
<para>Import a set of variables as device properties, depending on
|
||||
<replaceable>type</replaceable>:</para>
|
||||
|
||||
<para>Import a set of variables as device properties,
|
||||
depending on <literal>type</literal>:</para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><literal>program</literal></term>
|
||||
|
@ -552,14 +542,8 @@
|
|||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
|
||||
<para>This can only be used for very short-running foreground tasks. For details see
|
||||
<option>RUN</option>.</para>
|
||||
|
||||
<para>Note that multiple <varname>IMPORT{}</varname> keys may be specified in one rule, and
|
||||
<literal>=</literal>, <literal>:=</literal>, and <literal>+=</literal> have the same effect as
|
||||
<literal>==</literal>. The key is true if the import is successful, unless <literal>!=</literal>
|
||||
is used as the operator which causes the key to be true if the import failed.</para>
|
||||
<para>This can only be used for very short-running foreground tasks. For details
|
||||
see <option>RUN</option>.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
@ -649,8 +633,9 @@
|
|||
<varlistentry>
|
||||
<term><option>$number</option>, <option>%n</option></term>
|
||||
<listitem>
|
||||
<para>The kernel number for this device. For example, <literal>sda3</literal> has kernel number
|
||||
3.</para>
|
||||
<para>The kernel number for this device. For example,
|
||||
<literal>sda3</literal> has kernel number <literal>3</literal>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
|
|
@ -4,10 +4,12 @@
|
|||
#include "string-util.h"
|
||||
|
||||
ssize_t string_table_lookup(const char * const *table, size_t len, const char *key) {
|
||||
size_t i;
|
||||
|
||||
if (!key)
|
||||
return -1;
|
||||
|
||||
for (size_t i = 0; i < len; ++i)
|
||||
for (i = 0; i < len; ++i)
|
||||
if (streq_ptr(table[i], key))
|
||||
return (ssize_t) i;
|
||||
|
||||
|
|
|
@ -94,8 +94,8 @@ int device_read_uevent_file(sd_device *device);
|
|||
int device_set_syspath(sd_device *device, const char *_syspath, bool verify);
|
||||
int device_set_ifindex(sd_device *device, const char *ifindex);
|
||||
int device_set_devmode(sd_device *device, const char *devmode);
|
||||
int device_set_devname(sd_device *device, const char *devname);
|
||||
int device_set_devtype(sd_device *device, const char *devtype);
|
||||
int device_set_devname(sd_device *device, const char *_devname);
|
||||
int device_set_devtype(sd_device *device, const char *_devtype);
|
||||
int device_set_devnum(sd_device *device, const char *major, const char *minor);
|
||||
int device_set_subsystem(sd_device *device, const char *_subsystem);
|
||||
int device_set_driver(sd_device *device, const char *_driver);
|
||||
|
|
|
@ -558,9 +558,10 @@ int device_monitor_send_device(
|
|||
r = device_get_properties_nulstr(device, (const uint8_t **) &buf, &blen);
|
||||
if (r < 0)
|
||||
return log_device_debug_errno(device, r, "sd-device-monitor: Failed to get device properties: %m");
|
||||
if (blen < 32)
|
||||
log_device_debug_errno(device, SYNTHETIC_ERRNO(EINVAL),
|
||||
"sd-device-monitor: Length of device property nulstr is too small to contain valid device information");
|
||||
if (blen < 32) {
|
||||
log_device_debug(device, "sd-device-monitor: Length of device property nulstr is too small to contain valid device information");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* fill in versioned header */
|
||||
r = sd_device_get_subsystem(device, &val);
|
||||
|
|
|
@ -363,9 +363,10 @@ static int device_append(sd_device *device, char *key, const char **_major, cons
|
|||
assert(_minor);
|
||||
|
||||
value = strchr(key, '=');
|
||||
if (!value)
|
||||
return log_device_debug_errno(device, SYNTHETIC_ERRNO(EINVAL),
|
||||
"sd-device: Not a key-value pair: '%s'", key);
|
||||
if (!value) {
|
||||
log_device_debug(device, "sd-device: Not a key-value pair: '%s'", key);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
*value = '\0';
|
||||
|
||||
|
@ -399,9 +400,10 @@ void device_seal(sd_device *device) {
|
|||
static int device_verify(sd_device *device) {
|
||||
assert(device);
|
||||
|
||||
if (!device->devpath || !device->subsystem || device->action < 0 || device->seqnum == 0)
|
||||
return log_device_debug_errno(device, SYNTHETIC_ERRNO(EINVAL),
|
||||
"sd-device: Device created from strv or nulstr lacks devpath, subsystem, action or seqnum.");
|
||||
if (!device->devpath || !device->subsystem || device->action < 0 || device->seqnum == 0) {
|
||||
log_device_debug(device, "sd-device: Device created from strv or nulstr lacks devpath, subsystem, action or seqnum.");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
device->sealed = true;
|
||||
|
||||
|
@ -462,10 +464,10 @@ int device_new_from_nulstr(sd_device **ret, uint8_t *nulstr, size_t len) {
|
|||
|
||||
key = (char*)&nulstr[i];
|
||||
end = memchr(key, '\0', len - i);
|
||||
if (!end)
|
||||
return log_device_debug_errno(device, SYNTHETIC_ERRNO(EINVAL),
|
||||
"sd-device: Failed to parse nulstr");
|
||||
|
||||
if (!end) {
|
||||
log_device_debug(device, "sd-device: Failed to parse nulstr");
|
||||
return -EINVAL;
|
||||
}
|
||||
i += end - key + 1;
|
||||
|
||||
r = device_append(device, key, &major, &minor);
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
sd_device *_d = (device); \
|
||||
int _level = (level), _error = (error); \
|
||||
\
|
||||
if (_d && _unlikely_(log_get_max_level() >= LOG_PRI(_level))) \
|
||||
if (_d && _unlikely_(log_get_max_level() >= _level)) \
|
||||
(void) sd_device_get_sysname(_d, &_sysname); \
|
||||
log_object_internal(_level, _error, PROJECT_FILE, __LINE__, __func__, \
|
||||
_sysname ? "DEVICE=" : NULL, _sysname, \
|
||||
|
|
|
@ -320,22 +320,24 @@ _public_ int sd_device_new_from_subsystem_sysname(sd_device **ret, const char *s
|
|||
return -ENODEV;
|
||||
}
|
||||
|
||||
int device_set_devtype(sd_device *device, const char *devtype) {
|
||||
_cleanup_free_ char *t = NULL;
|
||||
int device_set_devtype(sd_device *device, const char *_devtype) {
|
||||
_cleanup_free_ char *devtype = NULL;
|
||||
int r;
|
||||
|
||||
assert(device);
|
||||
assert(devtype);
|
||||
assert(_devtype);
|
||||
|
||||
t = strdup(devtype);
|
||||
if (!t)
|
||||
devtype = strdup(_devtype);
|
||||
if (!devtype)
|
||||
return -ENOMEM;
|
||||
|
||||
r = device_add_property_internal(device, "DEVTYPE", t);
|
||||
r = device_add_property_internal(device, "DEVTYPE", devtype);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return free_and_replace(device->devtype, t);
|
||||
free_and_replace(device->devtype, devtype);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int device_set_ifindex(sd_device *device, const char *name) {
|
||||
|
@ -357,25 +359,30 @@ int device_set_ifindex(sd_device *device, const char *name) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int device_set_devname(sd_device *device, const char *devname) {
|
||||
_cleanup_free_ char *t = NULL;
|
||||
int device_set_devname(sd_device *device, const char *_devname) {
|
||||
_cleanup_free_ char *devname = NULL;
|
||||
int r;
|
||||
|
||||
assert(device);
|
||||
assert(devname);
|
||||
assert(_devname);
|
||||
|
||||
if (devname[0] != '/')
|
||||
t = strjoin("/dev/", devname);
|
||||
else
|
||||
t = strdup(devname);
|
||||
if (!t)
|
||||
if (_devname[0] != '/') {
|
||||
r = asprintf(&devname, "/dev/%s", _devname);
|
||||
if (r < 0)
|
||||
return -ENOMEM;
|
||||
} else {
|
||||
devname = strdup(_devname);
|
||||
if (!devname)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
r = device_add_property_internal(device, "DEVNAME", t);
|
||||
r = device_add_property_internal(device, "DEVNAME", devname);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return free_and_replace(device->devname, t);
|
||||
free_and_replace(device->devname, devname);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int device_set_devmode(sd_device *device, const char *_devmode) {
|
||||
|
@ -1243,15 +1250,17 @@ int device_get_id_filename(sd_device *device, const char **ret) {
|
|||
if (!subsystem)
|
||||
return -EINVAL;
|
||||
|
||||
|
||||
if (streq(subsystem, "drivers"))
|
||||
if (streq(subsystem, "drivers")) {
|
||||
/* the 'drivers' pseudo-subsystem is special, and needs the real subsystem
|
||||
* encoded as well */
|
||||
id = strjoin("+drivers:", device->driver_subsystem, ":", sysname);
|
||||
else
|
||||
id = strjoin("+", subsystem, ":", sysname);
|
||||
if (!id)
|
||||
r = asprintf(&id, "+drivers:%s:%s", device->driver_subsystem, sysname);
|
||||
if (r < 0)
|
||||
return -ENOMEM;
|
||||
} else {
|
||||
r = asprintf(&id, "+%s:%s", subsystem, sysname);
|
||||
if (r < 0)
|
||||
return -ENOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
device->id_filename = TAKE_PTR(id);
|
||||
|
|
|
@ -936,9 +936,10 @@ static int umount_by_device(sd_bus *bus, const char *what) {
|
|||
if (r < 0)
|
||||
return log_device_error_errno(d, r, "Failed to get device property: %m");
|
||||
|
||||
if (!streq(v, "filesystem"))
|
||||
return log_device_error_errno(d, SYNTHETIC_ERRNO(EINVAL),
|
||||
"%s does not contain a known file system.", what);
|
||||
if (!streq(v, "filesystem")) {
|
||||
log_device_error(d, "%s does not contain a known file system.", what);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (sd_device_get_property_value(d, "SYSTEMD_MOUNT_WHERE", &v) >= 0)
|
||||
r2 = stop_mounts(bus, v);
|
||||
|
@ -1274,9 +1275,10 @@ static int discover_loop_backing_file(void) {
|
|||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to get device from device number: %m");
|
||||
|
||||
if (sd_device_get_property_value(d, "ID_FS_USAGE", &v) < 0 || !streq(v, "filesystem"))
|
||||
return log_device_error_errno(d, SYNTHETIC_ERRNO(EINVAL),
|
||||
"%s does not contain a known file system.", arg_mount_what);
|
||||
if (sd_device_get_property_value(d, "ID_FS_USAGE", &v) < 0 || !streq(v, "filesystem")) {
|
||||
log_device_error(d, "%s does not contain a known file system.", arg_mount_what);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
r = acquire_mount_type(d);
|
||||
if (r < 0)
|
||||
|
|
|
@ -148,35 +148,33 @@ static int ndisc_router_process_default(Link *link, sd_ndisc_router *rt) {
|
|||
unsigned preference;
|
||||
uint32_t mtu;
|
||||
usec_t time_now;
|
||||
int r;
|
||||
Address *address;
|
||||
Iterator i;
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
assert(rt);
|
||||
|
||||
r = sd_ndisc_router_get_lifetime(rt, &lifetime);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Failed to get gateway lifetime from RA: %m");
|
||||
return log_link_warning_errno(link, r, "Failed to get gateway address from RA: %m");
|
||||
|
||||
if (lifetime == 0) /* not a default router */
|
||||
return 0;
|
||||
|
||||
r = sd_ndisc_router_get_address(rt, &gateway.in6);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Failed to get gateway address from RA: %m");
|
||||
return log_link_warning_errno(link, r, "Failed to get gateway address from RA: %m");
|
||||
|
||||
SET_FOREACH(address, link->addresses, i) {
|
||||
if (address->family != AF_INET6)
|
||||
continue;
|
||||
if (in_addr_equal(AF_INET6, &gateway, &address->in_addr)) {
|
||||
if (DEBUG_LOGGING) {
|
||||
_cleanup_free_ char *buffer = NULL;
|
||||
|
||||
(void) in_addr_to_string(AF_INET6, &address->in_addr, &buffer);
|
||||
log_link_debug(link, "No NDisc route added, gateway %s matches local address",
|
||||
strnull(buffer));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -185,34 +183,32 @@ static int ndisc_router_process_default(Link *link, sd_ndisc_router *rt) {
|
|||
if (address->family != AF_INET6)
|
||||
continue;
|
||||
if (in_addr_equal(AF_INET6, &gateway, &address->in_addr)) {
|
||||
if (DEBUG_LOGGING) {
|
||||
_cleanup_free_ char *buffer = NULL;
|
||||
|
||||
(void) in_addr_to_string(AF_INET6, &address->in_addr, &buffer);
|
||||
log_link_debug(link, "No NDisc route added, gateway %s matches local address",
|
||||
strnull(buffer));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
r = sd_ndisc_router_get_preference(rt, &preference);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Failed to get default router preference from RA: %m");
|
||||
return log_link_warning_errno(link, r, "Failed to get default router preference from RA: %m");
|
||||
|
||||
r = sd_ndisc_router_get_timestamp(rt, clock_boottime_or_monotonic(), &time_now);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Failed to get RA timestamp: %m");
|
||||
return log_link_warning_errno(link, r, "Failed to get RA timestamp: %m");
|
||||
|
||||
r = sd_ndisc_router_get_mtu(rt, &mtu);
|
||||
if (r == -ENODATA)
|
||||
mtu = 0;
|
||||
else if (r < 0)
|
||||
return log_link_error_errno(link, r, "Failed to get default router MTU from RA: %m");
|
||||
return log_link_warning_errno(link, r, "Failed to get default router MTU from RA: %m");
|
||||
|
||||
r = route_new(&route);
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
return log_link_error_errno(link, r, "Could not allocate route: %m");
|
||||
|
||||
route->family = AF_INET6;
|
||||
route->table = link_get_ipv6_accept_ra_route_table(link);
|
||||
|
@ -224,8 +220,11 @@ static int ndisc_router_process_default(Link *link, sd_ndisc_router *rt) {
|
|||
route->mtu = mtu;
|
||||
|
||||
r = route_configure(route, link, ndisc_route_handler);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not set default route: %m");
|
||||
if (r < 0) {
|
||||
log_link_warning_errno(link, r, "Could not set default route: %m");
|
||||
link_enter_failed(link);
|
||||
return r;
|
||||
}
|
||||
if (r > 0)
|
||||
link->ndisc_routes_messages++;
|
||||
|
||||
|
@ -240,8 +239,11 @@ static int ndisc_router_process_default(Link *link, sd_ndisc_router *rt) {
|
|||
route_gw->gw = gateway;
|
||||
|
||||
r = route_configure(route_gw, link, ndisc_route_handler);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not set gateway: %m");
|
||||
if (r < 0) {
|
||||
log_link_error_errno(link, r, "Could not set gateway: %m");
|
||||
link_enter_failed(link);
|
||||
return r;
|
||||
}
|
||||
if (r > 0)
|
||||
link->ndisc_routes_messages++;
|
||||
}
|
||||
|
@ -304,7 +306,7 @@ static int ndisc_router_generate_addresses(Link *link, unsigned prefixlen, uint3
|
|||
|
||||
r = set_put(addresses, new_address);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Failed to store SLAAC address: %m");
|
||||
return log_link_warning_errno(link, r, "Failed to store address: %m");
|
||||
TAKE_PTR(new_address);
|
||||
}
|
||||
}
|
||||
|
@ -329,7 +331,7 @@ static int ndisc_router_generate_addresses(Link *link, unsigned prefixlen, uint3
|
|||
|
||||
r = set_put(addresses, new_address);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Failed to store SLAAC address: %m");
|
||||
return log_link_warning_errno(link, r, "Failed to store address: %m");
|
||||
TAKE_PTR(new_address);
|
||||
}
|
||||
|
||||
|
@ -344,7 +346,7 @@ static int ndisc_router_process_autonomous_prefix(Link *link, sd_ndisc_router *r
|
|||
_cleanup_(address_freep) Address *address = NULL;
|
||||
unsigned prefixlen;
|
||||
usec_t time_now;
|
||||
Address *a;
|
||||
Address *existing_address, *a;
|
||||
Iterator i;
|
||||
int r;
|
||||
|
||||
|
@ -353,7 +355,7 @@ static int ndisc_router_process_autonomous_prefix(Link *link, sd_ndisc_router *r
|
|||
|
||||
r = sd_ndisc_router_get_timestamp(rt, clock_boottime_or_monotonic(), &time_now);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Failed to get RA timestamp: %m");
|
||||
return log_link_warning_errno(link, r, "Failed to get RA timestamp: %m");
|
||||
|
||||
r = sd_ndisc_router_prefix_get_prefixlen(rt, &prefixlen);
|
||||
if (r < 0)
|
||||
|
@ -373,7 +375,7 @@ static int ndisc_router_process_autonomous_prefix(Link *link, sd_ndisc_router *r
|
|||
|
||||
r = address_new(&address);
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
return log_link_error_errno(link, r, "Could not allocate address: %m");
|
||||
|
||||
address->family = AF_INET6;
|
||||
r = sd_ndisc_router_prefix_get_address(rt, &address->in_addr.in6);
|
||||
|
@ -382,11 +384,9 @@ static int ndisc_router_process_autonomous_prefix(Link *link, sd_ndisc_router *r
|
|||
|
||||
r = ndisc_router_generate_addresses(link, prefixlen, lifetime_preferred, address, &addresses);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return log_link_error_errno(link, r, "Failed to generate SLAAC addresses: %m");
|
||||
|
||||
SET_FOREACH(a, addresses, i) {
|
||||
Address *existing_address;
|
||||
|
||||
/* see RFC4862 section 5.5.3.e */
|
||||
r = address_get(link, a->family, &a->in_addr, a->prefixlen, &existing_address);
|
||||
if (r > 0) {
|
||||
|
@ -406,8 +406,11 @@ static int ndisc_router_process_autonomous_prefix(Link *link, sd_ndisc_router *r
|
|||
continue;
|
||||
|
||||
r = address_configure(a, link, ndisc_address_handler, true);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not set SLAAC address: %m");
|
||||
if (r < 0) {
|
||||
log_link_warning_errno(link, r, "Could not set SLAAC address: %m");
|
||||
link_enter_failed(link);
|
||||
return r;
|
||||
}
|
||||
if (r > 0)
|
||||
link->ndisc_addresses_messages++;
|
||||
}
|
||||
|
@ -427,7 +430,7 @@ static int ndisc_router_process_onlink_prefix(Link *link, sd_ndisc_router *rt) {
|
|||
|
||||
r = sd_ndisc_router_get_timestamp(rt, clock_boottime_or_monotonic(), &time_now);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Failed to get RA timestamp: %m");
|
||||
return log_link_warning_errno(link, r, "Failed to get RA timestamp: %m");
|
||||
|
||||
r = sd_ndisc_router_prefix_get_prefixlen(rt, &prefixlen);
|
||||
if (r < 0)
|
||||
|
@ -439,7 +442,7 @@ static int ndisc_router_process_onlink_prefix(Link *link, sd_ndisc_router *rt) {
|
|||
|
||||
r = route_new(&route);
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
return log_link_error_errno(link, r, "Could not allocate route: %m");
|
||||
|
||||
route->family = AF_INET6;
|
||||
route->table = link_get_ipv6_accept_ra_route_table(link);
|
||||
|
@ -454,8 +457,11 @@ static int ndisc_router_process_onlink_prefix(Link *link, sd_ndisc_router *rt) {
|
|||
return log_link_error_errno(link, r, "Failed to get prefix address: %m");
|
||||
|
||||
r = route_configure(route, link, ndisc_route_handler);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not set prefix route: %m");;
|
||||
if (r < 0) {
|
||||
log_link_warning_errno(link, r, "Could not set prefix route: %m");
|
||||
link_enter_failed(link);
|
||||
return r;
|
||||
}
|
||||
if (r > 0)
|
||||
link->ndisc_routes_messages++;
|
||||
|
||||
|
@ -474,30 +480,30 @@ static int ndisc_router_process_route(Link *link, sd_ndisc_router *rt) {
|
|||
|
||||
r = sd_ndisc_router_route_get_lifetime(rt, &lifetime);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Failed to get gateway lifetime from RA: %m");
|
||||
return log_link_warning_errno(link, r, "Failed to get gateway address from RA: %m");
|
||||
|
||||
if (lifetime == 0)
|
||||
return 0;
|
||||
|
||||
r = sd_ndisc_router_get_address(rt, &gateway);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Failed to get gateway address from RA: %m");
|
||||
return log_link_warning_errno(link, r, "Failed to get gateway address from RA: %m");
|
||||
|
||||
r = sd_ndisc_router_route_get_prefixlen(rt, &prefixlen);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Failed to get route prefix length: %m");
|
||||
return log_link_warning_errno(link, r, "Failed to get route prefix length: %m");
|
||||
|
||||
r = sd_ndisc_router_route_get_preference(rt, &preference);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Failed to get default router preference from RA: %m");
|
||||
return log_link_warning_errno(link, r, "Failed to get default router preference from RA: %m");
|
||||
|
||||
r = sd_ndisc_router_get_timestamp(rt, clock_boottime_or_monotonic(), &time_now);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Failed to get RA timestamp: %m");
|
||||
return log_link_warning_errno(link, r, "Failed to get RA timestamp: %m");
|
||||
|
||||
r = route_new(&route);
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
return log_link_error_errno(link, r, "Could not allocate route: %m");
|
||||
|
||||
route->family = AF_INET6;
|
||||
route->table = link_get_ipv6_accept_ra_route_table(link);
|
||||
|
@ -513,8 +519,11 @@ static int ndisc_router_process_route(Link *link, sd_ndisc_router *rt) {
|
|||
return log_link_error_errno(link, r, "Failed to get route address: %m");
|
||||
|
||||
r = route_configure(route, link, ndisc_route_handler);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not set additional route: %m");
|
||||
if (r < 0) {
|
||||
log_link_warning_errno(link, r, "Could not set additional route: %m");
|
||||
link_enter_failed(link);
|
||||
return r;
|
||||
}
|
||||
if (r > 0)
|
||||
link->ndisc_routes_messages++;
|
||||
|
||||
|
@ -535,24 +544,24 @@ static int ndisc_router_process_rdnss(Link *link, sd_ndisc_router *rt) {
|
|||
uint32_t lifetime;
|
||||
const struct in6_addr *a;
|
||||
usec_t time_now;
|
||||
int n, r;
|
||||
int i, n, r;
|
||||
|
||||
assert(link);
|
||||
assert(rt);
|
||||
|
||||
r = sd_ndisc_router_get_timestamp(rt, clock_boottime_or_monotonic(), &time_now);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Failed to get RA timestamp: %m");
|
||||
return log_link_warning_errno(link, r, "Failed to get RA timestamp: %m");
|
||||
|
||||
r = sd_ndisc_router_rdnss_get_lifetime(rt, &lifetime);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Failed to get RDNSS lifetime: %m");
|
||||
return log_link_warning_errno(link, r, "Failed to get RDNSS lifetime: %m");
|
||||
|
||||
n = sd_ndisc_router_rdnss_get_addresses(rt, &a);
|
||||
if (n < 0)
|
||||
return log_link_error_errno(link, n, "Failed to get RDNSS addresses: %m");
|
||||
return log_link_warning_errno(link, n, "Failed to get RDNSS addresses: %m");
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (i = 0; i < n; i++) {
|
||||
_cleanup_free_ NDiscRDNSS *x = NULL;
|
||||
NDiscRDNSS d = {
|
||||
.address = a[i],
|
||||
|
@ -607,7 +616,7 @@ static int ndisc_dnssl_compare_func(const NDiscDNSSL *a, const NDiscDNSSL *b) {
|
|||
|
||||
DEFINE_PRIVATE_HASH_OPS(ndisc_dnssl_hash_ops, NDiscDNSSL, ndisc_dnssl_hash_func, ndisc_dnssl_compare_func);
|
||||
|
||||
static int ndisc_router_process_dnssl(Link *link, sd_ndisc_router *rt) {
|
||||
static void ndisc_router_process_dnssl(Link *link, sd_ndisc_router *rt) {
|
||||
_cleanup_strv_free_ char **l = NULL;
|
||||
uint32_t lifetime;
|
||||
usec_t time_now;
|
||||
|
@ -618,24 +627,32 @@ static int ndisc_router_process_dnssl(Link *link, sd_ndisc_router *rt) {
|
|||
assert(rt);
|
||||
|
||||
r = sd_ndisc_router_get_timestamp(rt, clock_boottime_or_monotonic(), &time_now);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Failed to get RA timestamp: %m");
|
||||
if (r < 0) {
|
||||
log_link_warning_errno(link, r, "Failed to get RA timestamp: %m");
|
||||
return;
|
||||
}
|
||||
|
||||
r = sd_ndisc_router_dnssl_get_lifetime(rt, &lifetime);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Failed to get DNSSL lifetime: %m");
|
||||
if (r < 0) {
|
||||
log_link_warning_errno(link, r, "Failed to get RDNSS lifetime: %m");
|
||||
return;
|
||||
}
|
||||
|
||||
r = sd_ndisc_router_dnssl_get_domains(rt, &l);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Failed to get DNSSL addresses: %m");
|
||||
if (r < 0) {
|
||||
log_link_warning_errno(link, r, "Failed to get RDNSS addresses: %m");
|
||||
return;
|
||||
}
|
||||
|
||||
STRV_FOREACH(i, l) {
|
||||
_cleanup_free_ NDiscDNSSL *s = NULL;
|
||||
_cleanup_free_ NDiscDNSSL *s;
|
||||
NDiscDNSSL *x;
|
||||
|
||||
s = malloc0(ALIGN(sizeof(NDiscDNSSL)) + strlen(*i) + 1);
|
||||
if (!s)
|
||||
return log_oom();
|
||||
if (!s) {
|
||||
log_oom();
|
||||
return;
|
||||
}
|
||||
|
||||
strcpy(NDISC_DNSSL_DOMAIN(s), *i);
|
||||
|
||||
|
@ -661,32 +678,35 @@ static int ndisc_router_process_dnssl(Link *link, sd_ndisc_router *rt) {
|
|||
s->valid_until = time_now + lifetime * USEC_PER_SEC;
|
||||
|
||||
r = set_ensure_consume(&link->ndisc_dnssl, &ndisc_dnssl_hash_ops, TAKE_PTR(s));
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
if (r < 0) {
|
||||
log_oom();
|
||||
return;
|
||||
}
|
||||
assert(r > 0);
|
||||
|
||||
link_dirty(link);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ndisc_router_process_options(Link *link, sd_ndisc_router *rt) {
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
assert(link->network);
|
||||
assert(rt);
|
||||
|
||||
for (int r = sd_ndisc_router_option_rewind(rt); ; r = sd_ndisc_router_option_next(rt)) {
|
||||
r = sd_ndisc_router_option_rewind(rt);
|
||||
for (;;) {
|
||||
uint8_t type;
|
||||
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Failed to iterate through options: %m");
|
||||
return log_link_warning_errno(link, r, "Failed to iterate through options: %m");
|
||||
if (r == 0) /* EOF */
|
||||
return 0;
|
||||
break;
|
||||
|
||||
r = sd_ndisc_router_option_get_type(rt, &type);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Failed to get RA option type: %m");
|
||||
return log_link_warning_errno(link, r, "Failed to get RA option type: %m");
|
||||
|
||||
switch (type) {
|
||||
|
||||
|
@ -705,52 +725,44 @@ static int ndisc_router_process_options(Link *link, sd_ndisc_router *rt) {
|
|||
(void) in_addr_to_string(AF_INET6, &a, &b);
|
||||
log_link_debug(link, "Prefix '%s' is deny-listed, ignoring", strna(b));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
r = sd_ndisc_router_prefix_get_flags(rt, &flags);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Failed to get RA prefix flags: %m");
|
||||
return log_link_warning_errno(link, r, "Failed to get RA prefix flags: %m");
|
||||
|
||||
if (link->network->ipv6_accept_ra_use_onlink_prefix &&
|
||||
FLAGS_SET(flags, ND_OPT_PI_FLAG_ONLINK)) {
|
||||
r = ndisc_router_process_onlink_prefix(link, rt);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
FLAGS_SET(flags, ND_OPT_PI_FLAG_ONLINK))
|
||||
(void) ndisc_router_process_onlink_prefix(link, rt);
|
||||
|
||||
if (link->network->ipv6_accept_ra_use_autonomous_prefix &&
|
||||
FLAGS_SET(flags, ND_OPT_PI_FLAG_AUTO)) {
|
||||
r = ndisc_router_process_autonomous_prefix(link, rt);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
FLAGS_SET(flags, ND_OPT_PI_FLAG_AUTO))
|
||||
(void) ndisc_router_process_autonomous_prefix(link, rt);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case SD_NDISC_OPTION_ROUTE_INFORMATION:
|
||||
r = ndisc_router_process_route(link, rt);
|
||||
if (r < 0)
|
||||
return r;
|
||||
(void) ndisc_router_process_route(link, rt);
|
||||
break;
|
||||
|
||||
case SD_NDISC_OPTION_RDNSS:
|
||||
if (link->network->ipv6_accept_ra_use_dns) {
|
||||
r = ndisc_router_process_rdnss(link, rt);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
if (link->network->ipv6_accept_ra_use_dns)
|
||||
(void) ndisc_router_process_rdnss(link, rt);
|
||||
break;
|
||||
|
||||
case SD_NDISC_OPTION_DNSSL:
|
||||
if (link->network->ipv6_accept_ra_use_dns) {
|
||||
r = ndisc_router_process_dnssl(link, rt);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
if (link->network->ipv6_accept_ra_use_dns)
|
||||
(void) ndisc_router_process_dnssl(link, rt);
|
||||
break;
|
||||
}
|
||||
|
||||
r = sd_ndisc_router_option_next(rt);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ndisc_router_handler(Link *link, sd_ndisc_router *rt) {
|
||||
|
@ -764,7 +776,7 @@ static int ndisc_router_handler(Link *link, sd_ndisc_router *rt) {
|
|||
|
||||
r = sd_ndisc_router_get_flags(rt, &flags);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Failed to get RA flags: %m");
|
||||
return log_link_warning_errno(link, r, "Failed to get RA flags: %m");
|
||||
|
||||
if ((flags & (ND_RA_FLAG_MANAGED | ND_RA_FLAG_OTHER) && link->network->ipv6_accept_ra_start_dhcp6_client)) {
|
||||
|
||||
|
@ -773,27 +785,23 @@ static int ndisc_router_handler(Link *link, sd_ndisc_router *rt) {
|
|||
else
|
||||
/* (re)start DHCPv6 client in stateful or stateless mode according to RA flags */
|
||||
r = dhcp6_request_address(link, !(flags & ND_RA_FLAG_MANAGED));
|
||||
|
||||
if (r < 0 && r != -EBUSY)
|
||||
return log_link_error_errno(link, r, "Could not acquire DHCPv6 lease on NDisc request: %m");
|
||||
log_link_warning_errno(link, r, "Could not acquire DHCPv6 lease on NDisc request: %m");
|
||||
else {
|
||||
log_link_debug(link, "Acquiring DHCPv6 lease on NDisc request");
|
||||
r = 0;
|
||||
}
|
||||
}
|
||||
|
||||
r = ndisc_router_process_default(link, rt);
|
||||
if (r < 0)
|
||||
return r;
|
||||
r = ndisc_router_process_options(link, rt);
|
||||
if (r < 0)
|
||||
return r;
|
||||
(void) ndisc_router_process_default(link, rt);
|
||||
(void) ndisc_router_process_options(link, rt);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static void ndisc_handler(sd_ndisc *nd, sd_ndisc_event event, sd_ndisc_router *rt, void *userdata) {
|
||||
Link *link = userdata;
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
|
||||
|
@ -806,11 +814,7 @@ static void ndisc_handler(sd_ndisc *nd, sd_ndisc_event event, sd_ndisc_router *r
|
|||
link->ndisc_addresses_configured = false;
|
||||
link->ndisc_routes_configured = false;
|
||||
|
||||
r = ndisc_router_handler(link, rt);
|
||||
if (r < 0) {
|
||||
link_enter_failed(link);
|
||||
return;
|
||||
}
|
||||
(void) ndisc_router_handler(link, rt);
|
||||
|
||||
if (link->ndisc_addresses_messages == 0)
|
||||
link->ndisc_addresses_configured = true;
|
||||
|
@ -843,7 +847,7 @@ static void ndisc_handler(sd_ndisc *nd, sd_ndisc_event event, sd_ndisc_router *r
|
|||
|
||||
break;
|
||||
default:
|
||||
assert_not_reached("IPv6 Neighbor Discovery unknown event");
|
||||
log_link_warning(link, "IPv6 Neighbor Discovery unknown event: %d", event);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -270,7 +270,7 @@ BridgeFDB.AssociatedWith, config_parse_fdb_ntf_flags,
|
|||
BridgeVLAN.PVID, config_parse_brvlan_pvid, 0, 0
|
||||
BridgeVLAN.VLAN, config_parse_brvlan_vlan, 0, 0
|
||||
BridgeVLAN.EgressUntagged, config_parse_brvlan_untagged, 0, 0
|
||||
Network.IPv6PrefixDelegation, config_parse_router_prefix_delegation, 0, offsetof(Network, router_prefix_delegation)
|
||||
Network.IPv6PrefixDelegation, config_parse_router_prefix_delegation, 0, 0
|
||||
Network.IPv6PDSubnetId, config_parse_router_prefix_subnet_id, 0, 0
|
||||
IPv6PrefixDelegation.RouterLifetimeSec, config_parse_sec, 0, offsetof(Network, router_lifetime_usec)
|
||||
IPv6PrefixDelegation.Managed, config_parse_bool, 0, offsetof(Network, router_managed)
|
||||
|
|
|
@ -219,11 +219,10 @@ int config_parse_prefix(const char *unit,
|
|||
return 0;
|
||||
}
|
||||
|
||||
r = sd_radv_prefix_set_prefix(p->radv_prefix, &in6addr.in6, prefixlen);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to set radv prefix, ignoring assignment: %s", rvalue);
|
||||
return 0;
|
||||
}
|
||||
if (sd_radv_prefix_set_prefix(p->radv_prefix, &in6addr.in6, prefixlen) < 0)
|
||||
return -EADDRNOTAVAIL;
|
||||
|
||||
log_syntax(unit, LOG_INFO, filename, line, r, "Found prefix %s", rvalue);
|
||||
|
||||
p = NULL;
|
||||
|
||||
|
@ -242,7 +241,7 @@ int config_parse_prefix_flags(const char *unit,
|
|||
void *userdata) {
|
||||
Network *network = userdata;
|
||||
_cleanup_(prefix_free_or_set_invalidp) Prefix *p = NULL;
|
||||
int r;
|
||||
int r, val;
|
||||
|
||||
assert(filename);
|
||||
assert(section);
|
||||
|
@ -256,18 +255,18 @@ int config_parse_prefix_flags(const char *unit,
|
|||
|
||||
r = parse_boolean(rvalue);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse %s=, ignoring assignment: %s", lvalue, rvalue);
|
||||
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse address flag, ignoring: %s", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
val = r;
|
||||
|
||||
if (streq(lvalue, "OnLink"))
|
||||
r = sd_radv_prefix_set_onlink(p->radv_prefix, r);
|
||||
r = sd_radv_prefix_set_onlink(p->radv_prefix, val);
|
||||
else if (streq(lvalue, "AddressAutoconfiguration"))
|
||||
r = sd_radv_prefix_set_address_autoconfiguration(p->radv_prefix, r);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to set %s=, ignoring assignment: %m", lvalue);
|
||||
return 0;
|
||||
}
|
||||
r = sd_radv_prefix_set_address_autoconfiguration(p->radv_prefix, val);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
p = NULL;
|
||||
|
||||
|
@ -312,10 +311,8 @@ int config_parse_prefix_lifetime(const char *unit,
|
|||
else if (streq(lvalue, "ValidLifetimeSec"))
|
||||
r = sd_radv_prefix_set_valid_lifetime(p->radv_prefix,
|
||||
DIV_ROUND_UP(usec, USEC_PER_SEC));
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to set %s=, ignoring assignment: %m", lvalue);
|
||||
return 0;
|
||||
}
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
p = NULL;
|
||||
|
||||
|
@ -395,11 +392,10 @@ int config_parse_route_prefix(const char *unit,
|
|||
return 0;
|
||||
}
|
||||
|
||||
r = sd_radv_prefix_set_route_prefix(p->radv_route_prefix, &in6addr.in6, prefixlen);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to set route prefix, ignoring assignment: %m");
|
||||
return 0;
|
||||
}
|
||||
if (sd_radv_prefix_set_route_prefix(p->radv_route_prefix, &in6addr.in6, prefixlen) < 0)
|
||||
return -EADDRNOTAVAIL;
|
||||
|
||||
log_syntax(unit, LOG_INFO, filename, line, r, "Found route prefix %s", rvalue);
|
||||
|
||||
p = NULL;
|
||||
|
||||
|
@ -440,11 +436,8 @@ int config_parse_route_prefix_lifetime(const char *unit,
|
|||
|
||||
/* a value of 0xffffffff represents infinity */
|
||||
r = sd_radv_route_prefix_set_lifetime(p->radv_route_prefix, DIV_ROUND_UP(usec, USEC_PER_SEC));
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, r,
|
||||
"Failed to set route lifetime, ignoring assignment: %m");
|
||||
return 0;
|
||||
}
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
p = NULL;
|
||||
|
||||
|
@ -835,10 +828,38 @@ DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(
|
|||
RADVPrefixDelegation,
|
||||
RADV_PREFIX_DELEGATION_BOTH);
|
||||
|
||||
DEFINE_CONFIG_PARSE_ENUM(config_parse_router_prefix_delegation,
|
||||
radv_prefix_delegation,
|
||||
RADVPrefixDelegation,
|
||||
"Invalid router prefix delegation");
|
||||
int config_parse_router_prefix_delegation(
|
||||
const char *unit,
|
||||
const char *filename,
|
||||
unsigned line,
|
||||
const char *section,
|
||||
unsigned section_line,
|
||||
const char *lvalue,
|
||||
int ltype,
|
||||
const char *rvalue,
|
||||
void *data,
|
||||
void *userdata) {
|
||||
|
||||
Network *network = userdata;
|
||||
RADVPrefixDelegation d;
|
||||
|
||||
assert(filename);
|
||||
assert(section);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
|
||||
d = radv_prefix_delegation_from_string(rvalue);
|
||||
if (d < 0) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, SYNTHETIC_ERRNO(EINVAL),
|
||||
"Invalid router prefix delegation '%s', ignoring assignment.", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
network->router_prefix_delegation = d;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_parse_router_preference(const char *unit,
|
||||
const char *filename,
|
||||
|
@ -896,15 +917,9 @@ int config_parse_router_prefix_subnet_id(const char *unit,
|
|||
}
|
||||
|
||||
r = safe_atoux64(rvalue, &t);
|
||||
if (r < 0) {
|
||||
if (r < 0 || t > INT64_MAX) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, r,
|
||||
"Failed to parse %s=, ignoring assignment: %s",
|
||||
lvalue, rvalue);
|
||||
return 0;
|
||||
}
|
||||
if (t > INT64_MAX) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, r,
|
||||
"Invalid subnet id '%s', ignoring assignment.",
|
||||
"Subnet id '%s' is invalid, ignoring assignment.",
|
||||
rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -47,10 +47,10 @@ static int node_symlink(sd_device *dev, const char *node, const char *slink) {
|
|||
|
||||
/* preserve link with correct target, do not replace node of other device */
|
||||
if (lstat(slink, &stats) == 0) {
|
||||
if (S_ISBLK(stats.st_mode) || S_ISCHR(stats.st_mode))
|
||||
return log_device_error_errno(dev, SYNTHETIC_ERRNO(EOPNOTSUPP),
|
||||
"Conflicting device node '%s' found, link to '%s' will not be created.", slink, node);
|
||||
else if (S_ISLNK(stats.st_mode)) {
|
||||
if (S_ISBLK(stats.st_mode) || S_ISCHR(stats.st_mode)) {
|
||||
log_device_error(dev, "Conflicting device node '%s' found, link to '%s' will not be created.", slink, node);
|
||||
return -EOPNOTSUPP;
|
||||
} else if (S_ISLNK(stats.st_mode)) {
|
||||
_cleanup_free_ char *buf = NULL;
|
||||
|
||||
if (readlink_malloc(slink, &buf) >= 0 &&
|
||||
|
|
|
@ -595,7 +595,7 @@ static int parse_token(UdevRules *rules, const char *key, char *attr, UdevRuleOp
|
|||
if (!is_match) {
|
||||
if (streq(value, "%k"))
|
||||
return log_token_error_errno(rules, SYNTHETIC_ERRNO(EINVAL),
|
||||
"NAME=\"%%k\" is ignored, as it breaks kernel supplied names.");
|
||||
"Ignoring NAME=\"%%k\" is ignored, as it breaks kernel supplied names.");
|
||||
if (isempty(value))
|
||||
return log_token_error_errno(rules, SYNTHETIC_ERRNO(EINVAL),
|
||||
"Ignoring NAME=\"\", as udev will not delete any device nodes.");
|
||||
|
@ -755,8 +755,10 @@ static int parse_token(UdevRules *rules, const char *key, char *attr, UdevRuleOp
|
|||
check_value_format_and_warn(rules, key, value, true);
|
||||
if (op == OP_REMOVE)
|
||||
return log_token_invalid_op(rules, key);
|
||||
if (!is_match)
|
||||
if (!is_match) {
|
||||
log_token_debug(rules, "%s key takes '==' or '!=' operator, assuming '=='.", key);
|
||||
op = OP_MATCH;
|
||||
}
|
||||
|
||||
r = rule_line_add_token(rule_line, TK_M_PROGRAM, op, value, NULL);
|
||||
} else if (streq(key, "IMPORT")) {
|
||||
|
@ -765,8 +767,10 @@ static int parse_token(UdevRules *rules, const char *key, char *attr, UdevRuleOp
|
|||
check_value_format_and_warn(rules, key, value, true);
|
||||
if (op == OP_REMOVE)
|
||||
return log_token_invalid_op(rules, key);
|
||||
if (!is_match)
|
||||
if (!is_match) {
|
||||
log_token_debug(rules, "%s key takes '==' or '!=' operator, assuming '=='.", key);
|
||||
op = OP_MATCH;
|
||||
}
|
||||
|
||||
if (streq(attr, "file"))
|
||||
r = rule_line_add_token(rule_line, TK_M_IMPORT_FILE, op, value, NULL);
|
||||
|
@ -809,8 +813,10 @@ static int parse_token(UdevRules *rules, const char *key, char *attr, UdevRuleOp
|
|||
return log_token_invalid_attr(rules, key);
|
||||
if (is_match || op == OP_REMOVE)
|
||||
return log_token_invalid_op(rules, key);
|
||||
if (op == OP_ADD)
|
||||
if (op == OP_ADD) {
|
||||
log_token_debug(rules, "Operator '+=' is specified to %s key, assuming '='.", key);
|
||||
op = OP_ASSIGN;
|
||||
}
|
||||
|
||||
if (streq(value, "string_escape=none"))
|
||||
r = rule_line_add_token(rule_line, TK_A_OPTIONS_STRING_ESCAPE_NONE, op, NULL, NULL);
|
||||
|
@ -860,7 +866,7 @@ static int parse_token(UdevRules *rules, const char *key, char *attr, UdevRuleOp
|
|||
check_value_format_and_warn(rules, key, value, true);
|
||||
r = rule_line_add_token(rule_line, TK_A_OWNER, op, value, NULL);
|
||||
} else {
|
||||
log_token_debug(rules, "User name resolution is disabled, ignoring %s=%s", key, value);
|
||||
log_token_debug(rules, "Resolving user name is disabled, ignoring %s=%s", key, value);
|
||||
return 0;
|
||||
}
|
||||
} else if (streq(key, "GROUP")) {
|
||||
|
@ -943,7 +949,7 @@ static int parse_token(UdevRules *rules, const char *key, char *attr, UdevRuleOp
|
|||
if (op != OP_ASSIGN)
|
||||
return log_token_invalid_op(rules, key);
|
||||
if (FLAGS_SET(rule_line->type, LINE_HAS_GOTO)) {
|
||||
log_token_warning(rules, "Contains multiple GOTO keys, ignoring GOTO=\"%s\".", value);
|
||||
log_token_warning(rules, "Contains multiple GOTO key, ignoring GOTO=\"%s\".", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1655,7 +1661,7 @@ static int udev_rule_apply_token_to_event(
|
|||
if (r == -ENOENT)
|
||||
return token->op == OP_NOMATCH;
|
||||
if (r < 0)
|
||||
return log_rule_error_errno(dev, rules, r, "Failed to test for the existence of '%s': %m", buf);
|
||||
return log_rule_error_errno(dev, rules, r, "Failed to test the existence of '%s': %m", buf);
|
||||
|
||||
if (stat(buf, &statbuf) < 0)
|
||||
return token->op == OP_NOMATCH;
|
||||
|
@ -1676,16 +1682,16 @@ static int udev_rule_apply_token_to_event(
|
|||
r = udev_event_spawn(event, timeout_usec, timeout_signal, true, buf, result, sizeof(result));
|
||||
if (r != 0) {
|
||||
if (r < 0)
|
||||
log_rule_warning_errno(dev, rules, r, "Failed to execute \"%s\": %m", buf);
|
||||
log_rule_warning_errno(dev, rules, r, "Failed to execute '%s', ignoring: %m", buf);
|
||||
else /* returned value is positive when program fails */
|
||||
log_rule_debug(dev, rules, "Command \"%s\" returned %d (error)", buf, r);
|
||||
log_rule_debug(dev, rules, "Command \"%s\" returned %d (error), ignoring", buf, r);
|
||||
return token->op == OP_NOMATCH;
|
||||
}
|
||||
|
||||
delete_trailing_chars(result, "\n");
|
||||
count = util_replace_chars(result, UDEV_ALLOWED_CHARS_INPUT);
|
||||
if (count > 0)
|
||||
log_rule_debug(dev, rules, "Replaced %zu character(s) in result of \"%s\"",
|
||||
log_rule_debug(dev, rules, "Replaced %zu character(s) from result of '%s'",
|
||||
count, buf);
|
||||
|
||||
event->program_result = strdup(result);
|
||||
|
|
|
@ -125,7 +125,8 @@ int udev_watch_end(sd_device *dev) {
|
|||
int wd, r;
|
||||
|
||||
if (inotify_fd < 0)
|
||||
return 0; /* Nothing to do. */
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Invalid inotify descriptor.");
|
||||
|
||||
r = device_get_watch_handle(dev, &wd);
|
||||
if (r == -ENOENT)
|
||||
|
|
|
@ -44,15 +44,17 @@ static const char *arg_export_prefix = NULL;
|
|||
static usec_t arg_wait_for_initialization_timeout = 0;
|
||||
|
||||
static bool skip_attribute(const char *name) {
|
||||
/* Those are either displayed separately or should not be shown at all. */
|
||||
return STR_IN_SET(name,
|
||||
static const char* const skip[] = {
|
||||
"uevent",
|
||||
"dev",
|
||||
"modalias",
|
||||
"resource",
|
||||
"driver",
|
||||
"subsystem",
|
||||
"module");
|
||||
"module",
|
||||
};
|
||||
|
||||
return string_table_lookup(skip, ELEMENTSOF(skip), name) >= 0;
|
||||
}
|
||||
|
||||
typedef struct SysAttr {
|
||||
|
|
Loading…
Reference in New Issue