1
0
mirror of https://github.com/systemd/systemd synced 2026-03-25 16:25:04 +01:00

Compare commits

..

14 Commits

Author SHA1 Message Date
Yu Watanabe
bdbb61f69f tree-wide: fix typo 2021-08-18 13:36:14 +02:00
Luca Boccassi
66e093def8 docs: portable services are no longer in preview
Reword the intro to the document, as portable services are a stable interface
and no longer a preview.
2021-08-18 11:30:53 +02:00
Vladimir Panteleev
e9aee93240 fstab-generator: Respect nofail when ordering 2021-08-18 16:00:49 +09:00
Vladimir Panteleev
ecfcf0244a Fix typo in dbus property name ("OnSuccesJobMode") 2021-08-18 16:00:05 +09:00
Yu Watanabe
21ee8eda50
Merge pull request #20460 from yuwata/udevadm-test-builtin-introduce-action
udevadm: introduce --action option for test-builtin
2021-08-18 15:59:40 +09:00
Daan De Meyer
406041b7de
udev: Support "max" string for BufferSize options (#20458)
"max" indicates the hardware advertised maximum queue buffer size
should be used.

The max sizes can be checked by running `ethtool -g <dev>` (Preset maximums).
Since the buffer sizes can't be set to 0 by users, internally we use 0 to
indicate that the hardware advertised maximum should be used.
2021-08-18 15:59:13 +09:00
Yu Watanabe
91546abf9e
Merge pull request #20456 from tomty89/man
Adding a few notes in the systemd.network man page
2021-08-18 15:58:06 +09:00
Yu Watanabe
c4f7a34756 network: do not assume the highest priority when Priority= is unspecified
Previously, when Priority= is unspecified, networkd configured the rule with
the highest (=0) priority. This commit makes networkd distinguish the case
the setting is unspecified and one explicitly specified as Priority=0.

Note.
1) If the priority is unspecified on configure, then kernel dynamically picks
   a priority for the rule.
2) The new behavior is consistent with 'ip rule' command.

Replaces #15606.
2021-08-18 15:57:45 +09:00
Yu Watanabe
7ce05a8d66 udevadm: introduce -a|--action option for test-builtin command
As net_setup_link builtin requires that a device action is set for the
sd_device object.
2021-08-18 00:08:08 +09:00
Tom Yan
5cf9069f08 man: network: mention that RouteMetric= in [DHCPv4] is also applied to the prefix route 2021-08-17 22:53:49 +08:00
Tom Yan
5ea859ef01 man: network: mention that Promiscuous= can be used to set nopromisc for passthru MACV{LAN,TAP} 2021-08-17 22:53:29 +08:00
Yu Watanabe
74614801f6 shell-completion: add missing uevent actions for udevadm 2021-08-17 23:22:26 +09:00
Yu Watanabe
6de7fa8759 udevadm: introduce parse_device_action() helper function 2021-08-17 23:22:26 +09:00
Yu Watanabe
d1429d8f78 udevadm: introduce find_device_with_action() helper function 2021-08-17 23:22:26 +09:00
25 changed files with 281 additions and 112 deletions

View File

@ -6,21 +6,17 @@ layout: default
# Portable Services Introduction # Portable Services Introduction
This systemd version includes a preview of the "portable service" systemd (since version 239) supports a concept of "Portable Services".
concept. "Portable Services" are supposed to be an incremental improvement over "Portable Services" are a delivery method for system services that uses
traditional system services, making two specific facets of container management two specific features of container management:
available to system services more readily. Specifically:
1. The bundling of applications, i.e. packing up multiple services, their 1. Applications are bundled. I.e. multiple services, their binaries and all
binaries and all their dependencies in an image, and running them their dependencies are packaged in an image, and are run directly from it.
directly from it.
2. Stricter default security policies, i.e. sand-boxing of applications. 2. Stricter default security policies, i.e. sand-boxing of applications.
The primary tool for interfacing with "portable services" is the new The primary tool for interacting with Portable Services is `portablectl`,
"portablectl" program. It's currently shipped in /usr/lib/systemd/portablectl and they are managed by the `systemd-portabled` service.
(i.e. not in the `$PATH`), since it's not yet considered part of the officially
supported systemd interfaces — it's a preview still after all.
Portable services don't bring anything inherently new to the table. All they do Portable services don't bring anything inherently new to the table. All they do
is put together known concepts in a slightly nicer way to cover a specific set is put together known concepts in a slightly nicer way to cover a specific set

View File

@ -80,7 +80,7 @@
<filename>/etc/hosts</filename>.</para> <filename>/etc/hosts</filename>.</para>
<para>Please keep in mind that <command>nss-myhostname</command> (and <command>nss-resolve</command>) also resolve <para>Please keep in mind that <command>nss-myhostname</command> (and <command>nss-resolve</command>) also resolve
in the other direction — from locally attached IP adresses to in the other direction — from locally attached IP addresses to
hostnames. If you rely on that lookup being provided by DNS, you might hostnames. If you rely on that lookup being provided by DNS, you might
want to order things differently. want to order things differently.
</para> </para>

View File

@ -54,7 +54,7 @@
<command>systemd-resolved</command> is not running.</para> <command>systemd-resolved</command> is not running.</para>
<para>Please keep in mind that <command>nss-myhostname</command> (and <command>nss-resolve</command>) also resolve <para>Please keep in mind that <command>nss-myhostname</command> (and <command>nss-resolve</command>) also resolve
in the other direction — from locally attached IP adresses to in the other direction — from locally attached IP addresses to
hostnames. If you rely on that lookup being provided by DNS, you might hostnames. If you rely on that lookup being provided by DNS, you might
want to order things differently. want to order things differently.
</para> </para>

View File

@ -1706,7 +1706,7 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice {
@org.freedesktop.DBus.Property.EmitsChangedSignal("const") @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly b DefaultDependencies = ...; readonly b DefaultDependencies = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("const") @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s OnSuccesJobMode = '...'; readonly s OnSuccessJobMode = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const") @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s OnFailureJobMode = '...'; readonly s OnFailureJobMode = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const") @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
@ -1815,7 +1815,7 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice {
<!--property CanFreeze is not documented!--> <!--property CanFreeze is not documented!-->
<!--property OnSuccesJobMode is not documented!--> <!--property OnSuccessJobMode is not documented!-->
<!--property OnFailureJobMode is not documented!--> <!--property OnFailureJobMode is not documented!-->
@ -2019,7 +2019,7 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice {
<variablelist class="dbus-property" generated="True" extra-ref="DefaultDependencies"/> <variablelist class="dbus-property" generated="True" extra-ref="DefaultDependencies"/>
<variablelist class="dbus-property" generated="True" extra-ref="OnSuccesJobMode"/> <variablelist class="dbus-property" generated="True" extra-ref="OnSuccessJobMode"/>
<variablelist class="dbus-property" generated="True" extra-ref="OnFailureJobMode"/> <variablelist class="dbus-property" generated="True" extra-ref="OnFailureJobMode"/>

View File

@ -735,29 +735,33 @@
<varlistentry> <varlistentry>
<term><varname>RxBufferSize=</varname></term> <term><varname>RxBufferSize=</varname></term>
<listitem> <listitem>
<para>Takes an integer. Specifies the maximum number of pending packets in the NIC receive buffer. <para>Takes an integer or <literal>max</literal>. Specifies the maximum number of pending packets
When unset, the kernel's default will be used.</para> in the NIC receive buffer. When unset, the kernel's default will be used. If set to
<literal>max</literal>, the hardware's advertised maximum size will be used.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><varname>RxMiniBufferSize=</varname></term> <term><varname>RxMiniBufferSize=</varname></term>
<listitem> <listitem>
<para>Takes an integer. Specifies the maximum number of pending packets in the NIC mini receive buffer. <para>Takes an integer or <literal>max</literal>. Specifies the maximum number of pending packets
When unset, the kernel's default will be used.</para> in the NIC mini receive buffer. When unset, the kernel's default will be used. If set to
<literal>max</literal>, the hardware's advertised maximum size will be used.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><varname>RxJumboBufferSize=</varname></term> <term><varname>RxJumboBufferSize=</varname></term>
<listitem> <listitem>
<para>Takes an integer. Specifies the maximum number of pending packets in the NIC jumbo receive buffer. <para>Takes an integer or <literal>max</literal>. Specifies the maximum number of pending packets
When unset, the kernel's default will be used.</para> in the NIC jumbo receive buffer. When unset, the kernel's default will be used. If set to
<literal>max</literal>, the hardware's advertised maximum size will be used.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><varname>TxBufferSize=</varname></term> <term><varname>TxBufferSize=</varname></term>
<listitem> <listitem>
<para>Takes an integer. Specifies the maximum number of pending packets in the NIC transmit buffer. <para>Takes an integer or <literal>max</literal>. Specifies the maximum number of pending packets
When unset, the kernel's default will be used.</para> in the NIC transmit buffer. When unset, the kernel's default will be used. If set to
<literal>max</literal>, the hardware's advertised maximum size will be used.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>

View File

@ -187,6 +187,8 @@
<listitem> <listitem>
<para>Takes a boolean. If set to true, promiscuous mode of the interface is enabled. <para>Takes a boolean. If set to true, promiscuous mode of the interface is enabled.
Defaults to unset.</para> Defaults to unset.</para>
<para>If this is set to false for the underlying link of a <literal>passthru</literal> mode MACVLAN/MACVTAP,
the virtual interface will be created with the <literal>nopromisc</literal> flag set.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
@ -1239,7 +1241,9 @@ IPv6Token=prefixstable:2002:da8:1::</programlisting></para>
<term><varname>Priority=</varname></term> <term><varname>Priority=</varname></term>
<listitem> <listitem>
<para>Specifies the priority of this rule. <varname>Priority=</varname> is an unsigned <para>Specifies the priority of this rule. <varname>Priority=</varname> is an unsigned
integer. Higher number means lower priority, and rules get processed in order of increasing number.</para> integer in the range 0…4294967295. Higher number means lower priority, and rules get
processed in order of increasing number. Defaults to unset, and the kernel will pick
a value dynamically.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
@ -1879,8 +1883,9 @@ IPv6Token=prefixstable:2002:da8:1::</programlisting></para>
<varlistentry> <varlistentry>
<term><varname>RouteMetric=</varname></term> <term><varname>RouteMetric=</varname></term>
<listitem> <listitem>
<para>Set the routing metric for routes specified by the DHCP server. Takes an unsigned <para>Set the routing metric for routes specified by the DHCP server (including the prefix
integer in the range 0…4294967295. Defaults to 1024.</para> route added for the specified prefix). Takes an unsigned integer in the range 0…4294967295.
Defaults to 1024.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>

View File

@ -619,6 +619,18 @@
for device <replaceable>DEVPATH</replaceable>, and print debug for device <replaceable>DEVPATH</replaceable>, and print debug
output.</para> output.</para>
<variablelist> <variablelist>
<varlistentry>
<term><option>-a</option></term>
<term><option>--action=<replaceable>ACTION</replaceable></option></term>
<listitem>
<para>Type of event to be simulated. Possible actions are <literal>add</literal>,
<literal>remove</literal>, <literal>change</literal>, <literal>move</literal>,
<literal>online</literal>, <literal>offline</literal>, <literal>bind</literal>,
and <literal>unbind</literal>. Also, the special value <literal>help</literal> can be used
to list the possible actions. The default value is <literal>add</literal>.</para>
</listitem>
</varlistentry>
<xi:include href="standard-options.xml" xpointer="help" /> <xi:include href="standard-options.xml" xpointer="help" />
</variablelist> </variablelist>
</refsect2> </refsect2>

View File

@ -61,6 +61,7 @@ _udevadm() {
[MONITOR_STANDALONE]='-k --kernel -u --udev -p --property' [MONITOR_STANDALONE]='-k --kernel -u --udev -p --property'
[MONITOR_ARG]='-s --subsystem-match -t --tag-match' [MONITOR_ARG]='-s --subsystem-match -t --tag-match'
[TEST]='-a --action -N --resolve-names' [TEST]='-a --action -N --resolve-names'
[TEST_BUILTIN]='-a --action'
) )
local verbs=(info trigger settle control monitor test-builtin test) local verbs=(info trigger settle control monitor test-builtin test)
@ -215,6 +216,16 @@ _udevadm() {
;; ;;
'test-builtin') 'test-builtin')
if __contains_word "$prev" ${OPTS[TEST_BUILTIN]}; then
case $prev in
-a|--action)
comps=$( udevadm test-builtin --action help )
;;
esac
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
return 0
fi
for ((i=0; i < COMP_CWORD; i++)); do for ((i=0; i < COMP_CWORD; i++)); do
if __contains_word "${COMP_WORDS[i]}" "${builtins[@]}"; then if __contains_word "${COMP_WORDS[i]}" "${builtins[@]}"; then
builtin=${COMP_WORDS[i]} builtin=${COMP_WORDS[i]}
@ -225,7 +236,7 @@ _udevadm() {
if [[ -z $builtin ]]; then if [[ -z $builtin ]]; then
comps="${builtins[@]}" comps="${builtins[@]}"
elif [[ $cur = -* ]]; then elif [[ $cur = -* ]]; then
comps="${OPTS[COMMON]}" comps="${OPTS[COMMON]} ${OPTS[TEST_BUILTIN]}"
else else
comps=$( __get_all_sysdevs ) comps=$( __get_all_sysdevs )
local IFS=$'\n' local IFS=$'\n'

View File

@ -23,7 +23,7 @@ _udevadm_trigger(){
'--dry-run[Do not actually trigger the event.]' \ '--dry-run[Do not actually trigger the event.]' \
'--quiet[Suppress error logging in triggering events.]' \ '--quiet[Suppress error logging in triggering events.]' \
'--type=[Trigger a specific type of devices.]:types:(devices subsystems failed)' \ '--type=[Trigger a specific type of devices.]:types:(devices subsystems failed)' \
'--action=[Type of event to be triggered.]:actions:(add change remove)' \ '--action=[Type of event to be triggered.]:actions:(add change remove move online offline bind unbind)' \
'--subsystem-match=[Trigger events for devices which belong to a matching subsystem.]' \ '--subsystem-match=[Trigger events for devices which belong to a matching subsystem.]' \
'--subsystem-nomatch=[Do not trigger events for devices which belong to a matching subsystem.]' \ '--subsystem-nomatch=[Do not trigger events for devices which belong to a matching subsystem.]' \
'--attr-match=attribute=[Trigger events for devices with a matching sysfs attribute.]' \ '--attr-match=attribute=[Trigger events for devices with a matching sysfs attribute.]' \
@ -74,7 +74,7 @@ _udevadm_monitor(){
(( $+functions[_udevadm_test] )) || (( $+functions[_udevadm_test] )) ||
_udevadm_test(){ _udevadm_test(){
_arguments \ _arguments \
'--action=[The action string.]:actions:(add change remove)' \ '--action=[The action string.]:actions:(add change remove move online offline bind unbind)' \
'--subsystem=[The subsystem string.]' \ '--subsystem=[The subsystem string.]' \
'--help[Print help text.]' \ '--help[Print help text.]' \
'*::devpath:_files -P /sys/ -W /sys' '*::devpath:_files -P /sys/ -W /sys'
@ -84,14 +84,17 @@ _udevadm_test(){
_udevadm_test-builtin(){ _udevadm_test-builtin(){
if (( CURRENT == 2 )); then if (( CURRENT == 2 )); then
_arguments \ _arguments \
'--action=[The action string.]:actions:(add change remove move online offline bind unbind)' \
'--help[Print help text]' \ '--help[Print help text]' \
'*::builtins:(blkid btrfs hwdb input_id net_id net_setup_link kmod path_id usb_id uaccess)' '*::builtins:(blkid btrfs hwdb input_id net_id net_setup_link kmod path_id usb_id uaccess)'
elif (( CURRENT == 3 )); then elif (( CURRENT == 3 )); then
_arguments \ _arguments \
'--action=[The action string.]:actions:(add change remove move online offline bind unbind)' \
'--help[Print help text]' \ '--help[Print help text]' \
'*::syspath:_files -P /sys -W /sys' '*::syspath:_files -P /sys -W /sys'
else else
_arguments \ _arguments \
'--action=[The action string.]:actions:(add change remove move online offline bind unbind)' \
'--help[Print help text]' '--help[Print help text]'
fi fi
} }

View File

@ -905,7 +905,8 @@ const sd_bus_vtable bus_unit_vtable[] = {
SD_BUS_PROPERTY("RefuseManualStop", "b", bus_property_get_bool, offsetof(Unit, refuse_manual_stop), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("RefuseManualStop", "b", bus_property_get_bool, offsetof(Unit, refuse_manual_stop), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("AllowIsolate", "b", bus_property_get_bool, offsetof(Unit, allow_isolate), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("AllowIsolate", "b", bus_property_get_bool, offsetof(Unit, allow_isolate), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("DefaultDependencies", "b", bus_property_get_bool, offsetof(Unit, default_dependencies), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("DefaultDependencies", "b", bus_property_get_bool, offsetof(Unit, default_dependencies), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("OnSuccesJobMode", "s", property_get_job_mode, offsetof(Unit, on_success_job_mode), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("OnSuccesJobMode", "s", property_get_job_mode, offsetof(Unit, on_success_job_mode), SD_BUS_VTABLE_PROPERTY_CONST|SD_BUS_VTABLE_HIDDEN), /* deprecated */
SD_BUS_PROPERTY("OnSuccessJobMode", "s", property_get_job_mode, offsetof(Unit, on_success_job_mode), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("OnFailureJobMode", "s", property_get_job_mode, offsetof(Unit, on_failure_job_mode), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("OnFailureJobMode", "s", property_get_job_mode, offsetof(Unit, on_failure_job_mode), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("IgnoreOnIsolate", "b", bus_property_get_bool, offsetof(Unit, ignore_on_isolate), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("IgnoreOnIsolate", "b", bus_property_get_bool, offsetof(Unit, ignore_on_isolate), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("NeedDaemonReload", "b", property_get_need_daemon_reload, 0, SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("NeedDaemonReload", "b", property_get_need_daemon_reload, 0, SD_BUS_VTABLE_PROPERTY_CONST),

View File

@ -43,7 +43,7 @@ static int log_debug_open_error(struct crypt_device *cd, int r) {
* (alternatively: name is set to null, flags contains CRYPT_ACTIVATE_ALLOW_UNBOUND_KEY * (alternatively: name is set to null, flags contains CRYPT_ACTIVATE_ALLOW_UNBOUND_KEY
* and token is assigned to at least single keyslot). * and token is assigned to at least single keyslot).
* *
* - if plugin defines validate funtion (see cryptsetup_token_validate below) it must have * - if plugin defines validate function (see cryptsetup_token_validate below) it must have
* passed the check (aka return 0) * passed the check (aka return 0)
*/ */
_public_ int cryptsetup_token_open( _public_ int cryptsetup_token_open(
@ -110,7 +110,7 @@ _public_ int cryptsetup_token_open(
if (r < 0) if (r < 0)
return log_debug_open_error(cd, r); return log_debug_open_error(cd, r);
/* free'd automaticaly by libcryptsetup */ /* free'd automatically by libcryptsetup */
*password_len = strlen(base64_encoded); *password_len = strlen(base64_encoded);
*password = TAKE_PTR(base64_encoded); *password = TAKE_PTR(base64_encoded);

View File

@ -434,7 +434,8 @@ static int add_mount(
/* Order the mount unit we generate relative to the post unit, so that DefaultDependencies= on the /* Order the mount unit we generate relative to the post unit, so that DefaultDependencies= on the
* target unit won't affect us. */ * target unit won't affect us. */
if (post && !FLAGS_SET(flags, MOUNT_AUTOMOUNT) && !FLAGS_SET(flags, MOUNT_NOAUTO)) if (post && !FLAGS_SET(flags, MOUNT_AUTOMOUNT) && !FLAGS_SET(flags, MOUNT_NOAUTO) &&
!FLAGS_SET(flags, MOUNT_NOFAIL))
fprintf(f, "Before=%s\n", post); fprintf(f, "Before=%s\n", post);
if (passno != 0) { if (passno != 0) {

View File

@ -349,7 +349,7 @@ static int parse_argv(int argc, char *argv[]) {
char *hh; char *hh;
size_t n; size_t n;
/* If this is not a vaid verification mode, maybe it's a literally specified /* If this is not a valid verification mode, maybe it's a literally specified
* SHA256 hash? We can handle that too... */ * SHA256 hash? We can handle that too... */
r = unhexmem(optarg, (size_t) -1, &h, &n); r = unhexmem(optarg, (size_t) -1, &h, &n);

View File

@ -163,6 +163,8 @@ void routing_policy_rule_hash_func(const RoutingPolicyRule *rule, struct siphash
siphash24_compress(&rule->type, sizeof(rule->type), state); siphash24_compress(&rule->type, sizeof(rule->type), state);
siphash24_compress(&rule->fwmark, sizeof(rule->fwmark), state); siphash24_compress(&rule->fwmark, sizeof(rule->fwmark), state);
siphash24_compress(&rule->fwmask, sizeof(rule->fwmask), state); siphash24_compress(&rule->fwmask, sizeof(rule->fwmask), state);
siphash24_compress_boolean(rule->priority_set, state);
if (rule->priority_set)
siphash24_compress(&rule->priority, sizeof(rule->priority), state); siphash24_compress(&rule->priority, sizeof(rule->priority), state);
siphash24_compress(&rule->table, sizeof(rule->table), state); siphash24_compress(&rule->table, sizeof(rule->table), state);
siphash24_compress(&rule->suppress_prefixlen, sizeof(rule->suppress_prefixlen), state); siphash24_compress(&rule->suppress_prefixlen, sizeof(rule->suppress_prefixlen), state);
@ -229,9 +231,15 @@ int routing_policy_rule_compare_func(const RoutingPolicyRule *a, const RoutingPo
if (r != 0) if (r != 0)
return r; return r;
r = CMP(a->priority_set, b->priority_set);
if (r != 0)
return r;
if (a->priority_set) {
r = CMP(a->priority, b->priority); r = CMP(a->priority, b->priority);
if (r != 0) if (r != 0)
return r; return r;
}
r = CMP(a->table, b->table); r = CMP(a->table, b->table);
if (r != 0) if (r != 0)
@ -293,8 +301,9 @@ DEFINE_PRIVATE_HASH_OPS_WITH_KEY_DESTRUCTOR(
routing_policy_rule_compare_func, routing_policy_rule_compare_func,
routing_policy_rule_free); routing_policy_rule_free);
static int routing_policy_rule_get(Manager *m, const RoutingPolicyRule *rule, RoutingPolicyRule **ret) { static int routing_policy_rule_get(Manager *m, const RoutingPolicyRule *rule, bool require_priority, RoutingPolicyRule **ret) {
RoutingPolicyRule *existing; RoutingPolicyRule *existing;
int r;
assert(m); assert(m);
@ -312,6 +321,23 @@ static int routing_policy_rule_get(Manager *m, const RoutingPolicyRule *rule, Ro
return 0; return 0;
} }
if (!require_priority && rule->priority_set) {
_cleanup_(routing_policy_rule_freep) RoutingPolicyRule *tmp = NULL;
r = routing_policy_rule_dup(rule, &tmp);
if (r < 0)
return r;
tmp->priority_set = false;
existing = set_get(m->rules, tmp);
if (existing) {
if (ret)
*ret = existing;
return 1;
}
}
return -ENOENT; return -ENOENT;
} }
@ -328,7 +354,7 @@ static int routing_policy_rule_add(Manager *m, const RoutingPolicyRule *in, Rout
if (r < 0) if (r < 0)
return r; return r;
r = routing_policy_rule_get(m, rule, &existing); r = routing_policy_rule_get(m, rule, true, &existing);
if (r == -ENOENT) { if (r == -ENOENT) {
/* Rule does not exist, use a new one. */ /* Rule does not exist, use a new one. */
r = set_ensure_put(&m->rules, &routing_policy_rule_hash_ops, rule); r = set_ensure_put(&m->rules, &routing_policy_rule_hash_ops, rule);
@ -371,6 +397,32 @@ static int routing_policy_rule_consume_foreign(Manager *m, RoutingPolicyRule *ru
return 1; return 1;
} }
static int routing_policy_rule_update_priority(RoutingPolicyRule *rule, uint32_t priority) {
int r;
assert(rule);
assert(rule->manager);
if (rule->priority_set)
return 0;
if (!set_remove(rule->manager->rules, rule))
return -ENOENT;
rule->priority = priority;
rule->priority_set = true;
r = set_put(rule->manager->rules, rule);
if (r <= 0) {
/* Undo */
rule->priority_set = false;
assert_se(set_put(rule->manager->rules, rule) > 0);
return r == 0 ? -EEXIST : r;
}
return 1;
}
static void log_routing_policy_rule_debug(const RoutingPolicyRule *rule, const char *str, const Link *link, const Manager *m) { static void log_routing_policy_rule_debug(const RoutingPolicyRule *rule, const char *str, const Link *link, const Manager *m) {
_cleanup_free_ char *from = NULL, *to = NULL, *table = NULL; _cleanup_free_ char *from = NULL, *to = NULL, *table = NULL;
@ -422,9 +474,11 @@ static int routing_policy_rule_set_netlink_message(const RoutingPolicyRule *rule
return log_link_error_errno(link, r, "Could not set destination prefix length: %m"); return log_link_error_errno(link, r, "Could not set destination prefix length: %m");
} }
if (rule->priority_set) {
r = sd_netlink_message_append_u32(m, FRA_PRIORITY, rule->priority); r = sd_netlink_message_append_u32(m, FRA_PRIORITY, rule->priority);
if (r < 0) if (r < 0)
return log_link_error_errno(link, r, "Could not append FRA_PRIORITY attribute: %m"); return log_link_error_errno(link, r, "Could not append FRA_PRIORITY attribute: %m");
}
if (rule->tos > 0) { if (rule->tos > 0) {
r = sd_rtnl_message_routing_policy_rule_set_tos(m, rule->tos); r = sd_rtnl_message_routing_policy_rule_set_tos(m, rule->tos);
@ -662,6 +716,28 @@ int manager_drop_routing_policy_rules_internal(Manager *m, bool foreign, const L
continue; continue;
} }
if (!foreign) {
_cleanup_(routing_policy_rule_freep) RoutingPolicyRule *tmp = NULL;
/* The rule may be configured without priority. Try to find without priority. */
k = routing_policy_rule_dup(rule, &tmp);
if (k < 0) {
if (r >= 0)
r = k;
continue;
}
tmp->priority_set = false;
k = links_have_routing_policy_rule(m, tmp, except);
if (k != 0) {
if (k < 0 && r >= 0)
r = k;
continue;
}
}
k = routing_policy_rule_remove(rule, m); k = routing_policy_rule_remove(rule, m);
if (k < 0 && r >= 0) if (k < 0 && r >= 0)
r = k; r = k;
@ -821,11 +897,11 @@ int request_process_routing_policy_rule(Request *req) {
} }
static const RoutingPolicyRule kernel_rules[] = { static const RoutingPolicyRule kernel_rules[] = {
{ .family = AF_INET, .priority = 0, .table = RT_TABLE_LOCAL, .type = FR_ACT_TO_TBL, .uid_range.start = UID_INVALID, .uid_range.end = UID_INVALID, .suppress_prefixlen = -1, }, { .family = AF_INET, .priority_set = true, .priority = 0, .table = RT_TABLE_LOCAL, .type = FR_ACT_TO_TBL, .uid_range.start = UID_INVALID, .uid_range.end = UID_INVALID, .suppress_prefixlen = -1, },
{ .family = AF_INET, .priority = 32766, .table = RT_TABLE_MAIN, .type = FR_ACT_TO_TBL, .uid_range.start = UID_INVALID, .uid_range.end = UID_INVALID, .suppress_prefixlen = -1, }, { .family = AF_INET, .priority_set = true, .priority = 32766, .table = RT_TABLE_MAIN, .type = FR_ACT_TO_TBL, .uid_range.start = UID_INVALID, .uid_range.end = UID_INVALID, .suppress_prefixlen = -1, },
{ .family = AF_INET, .priority = 32767, .table = RT_TABLE_DEFAULT, .type = FR_ACT_TO_TBL, .uid_range.start = UID_INVALID, .uid_range.end = UID_INVALID, .suppress_prefixlen = -1, }, { .family = AF_INET, .priority_set = true, .priority = 32767, .table = RT_TABLE_DEFAULT, .type = FR_ACT_TO_TBL, .uid_range.start = UID_INVALID, .uid_range.end = UID_INVALID, .suppress_prefixlen = -1, },
{ .family = AF_INET6, .priority = 0, .table = RT_TABLE_LOCAL, .type = FR_ACT_TO_TBL, .uid_range.start = UID_INVALID, .uid_range.end = UID_INVALID, .suppress_prefixlen = -1, }, { .family = AF_INET6, .priority_set = true, .priority = 0, .table = RT_TABLE_LOCAL, .type = FR_ACT_TO_TBL, .uid_range.start = UID_INVALID, .uid_range.end = UID_INVALID, .suppress_prefixlen = -1, },
{ .family = AF_INET6, .priority = 32766, .table = RT_TABLE_MAIN, .type = FR_ACT_TO_TBL, .uid_range.start = UID_INVALID, .uid_range.end = UID_INVALID, .suppress_prefixlen = -1, }, { .family = AF_INET6, .priority_set = true, .priority = 32766, .table = RT_TABLE_MAIN, .type = FR_ACT_TO_TBL, .uid_range.start = UID_INVALID, .uid_range.end = UID_INVALID, .suppress_prefixlen = -1, },
}; };
static bool routing_policy_rule_is_created_by_kernel(const RoutingPolicyRule *rule) { static bool routing_policy_rule_is_created_by_kernel(const RoutingPolicyRule *rule) {
@ -936,6 +1012,9 @@ int manager_rtnl_process_rule(sd_netlink *rtnl, sd_netlink_message *message, Man
log_warning_errno(r, "rtnl: could not get FRA_PRIORITY attribute, ignoring: %m"); log_warning_errno(r, "rtnl: could not get FRA_PRIORITY attribute, ignoring: %m");
return 0; return 0;
} }
/* The kernel does not send priority if priority is zero. So, the flag below must be always set
* even if the message does not contain FRA_PRIORITY. */
tmp->priority_set = true;
r = sd_netlink_message_read_u32(message, FRA_TABLE, &tmp->table); r = sd_netlink_message_read_u32(message, FRA_TABLE, &tmp->table);
if (r < 0 && r != -ENODATA) { if (r < 0 && r != -ENODATA) {
@ -1027,13 +1106,16 @@ int manager_rtnl_process_rule(sd_netlink *rtnl, sd_netlink_message *message, Man
* protocol of the received rule is RTPROT_KERNEL or RTPROT_STATIC. */ * protocol of the received rule is RTPROT_KERNEL or RTPROT_STATIC. */
tmp->protocol = routing_policy_rule_is_created_by_kernel(tmp) ? RTPROT_KERNEL : RTPROT_STATIC; tmp->protocol = routing_policy_rule_is_created_by_kernel(tmp) ? RTPROT_KERNEL : RTPROT_STATIC;
(void) routing_policy_rule_get(m, tmp, &rule); (void) routing_policy_rule_get(m, tmp, false, &rule);
switch (type) { switch (type) {
case RTM_NEWRULE: case RTM_NEWRULE:
if (rule) if (rule) {
log_routing_policy_rule_debug(tmp, "Received remembered", NULL, m); log_routing_policy_rule_debug(tmp, "Received remembered", NULL, m);
else if (!m->manage_foreign_routes) r = routing_policy_rule_update_priority(rule, tmp->priority);
if (r < 0)
log_warning_errno(r, "Failed to update priority of remembered routing policy rule, ignoring: %m");
} else if (!m->manage_foreign_routes)
log_routing_policy_rule_debug(tmp, "Ignoring received foreign", NULL, m); log_routing_policy_rule_debug(tmp, "Ignoring received foreign", NULL, m);
else { else {
log_routing_policy_rule_debug(tmp, "Remembering foreign", NULL, m); log_routing_policy_rule_debug(tmp, "Remembering foreign", NULL, m);
@ -1155,11 +1237,19 @@ int config_parse_routing_policy_rule_priority(
if (r < 0) if (r < 0)
return log_oom(); return log_oom();
if (isempty(rvalue)) {
n->priority = 0;
n->priority_set = false;
TAKE_PTR(n);
return 0;
}
r = safe_atou32(rvalue, &n->priority); r = safe_atou32(rvalue, &n->priority);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse RPDB rule priority, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse RPDB rule priority, ignoring: %s", rvalue);
return 0; return 0;
} }
n->priority_set = true;
TAKE_PTR(n); TAKE_PTR(n);
return 0; return 0;

View File

@ -20,6 +20,7 @@ typedef struct RoutingPolicyRule {
NetworkConfigSection *section; NetworkConfigSection *section;
bool invert_rule; bool invert_rule;
bool priority_set;
uint8_t tos; uint8_t tos;
uint8_t type; uint8_t type;

View File

@ -399,16 +399,24 @@ int ethtool_set_nic_buffer_size(int *ethtool_fd, const char *ifname, const netde
return -errno; return -errno;
if (ring->rx_pending_set) if (ring->rx_pending_set)
UPDATE(ecmd.rx_pending, ring->rx_pending, need_update); UPDATE(ecmd.rx_pending,
ring->rx_pending == 0 ? ecmd.rx_max_pending : ring->rx_pending,
need_update);
if (ring->rx_mini_pending_set) if (ring->rx_mini_pending_set)
UPDATE(ecmd.rx_mini_pending, ring->rx_mini_pending, need_update); UPDATE(ecmd.rx_mini_pending,
ring->rx_mini_pending == 0 ? ecmd.rx_mini_max_pending : ring->rx_mini_pending,
need_update);
if (ring->rx_jumbo_pending_set) if (ring->rx_jumbo_pending_set)
UPDATE(ecmd.rx_jumbo_pending, ring->rx_jumbo_pending, need_update); UPDATE(ecmd.rx_jumbo_pending,
ring->rx_jumbo_pending == 0 ? ecmd.rx_jumbo_max_pending : ring->rx_jumbo_pending,
need_update);
if (ring->tx_pending_set) if (ring->tx_pending_set)
UPDATE(ecmd.tx_pending, ring->tx_pending, need_update); UPDATE(ecmd.tx_pending,
ring->tx_pending == 0 ? ecmd.tx_max_pending : ring->tx_pending,
need_update);
if (!need_update) if (!need_update)
return 0; return 0;
@ -1047,6 +1055,9 @@ int config_parse_nic_buffer_size(
assert(rvalue); assert(rvalue);
assert(data); assert(data);
if (streq(rvalue, "max"))
k = 0;
else {
r = safe_atou32(rvalue, &k); r = safe_atou32(rvalue, &k);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
@ -1058,6 +1069,7 @@ int config_parse_nic_buffer_size(
"Invalid %s= value, ignoring: %s", lvalue, rvalue); "Invalid %s= value, ignoring: %s", lvalue, rvalue);
return 0; return 0;
} }
}
if (streq(lvalue, "RxBufferSize")) { if (streq(lvalue, "RxBufferSize")) {
ring->rx_pending = k; ring->rx_pending = k;

View File

@ -70,6 +70,8 @@ typedef struct netdev_channels {
} netdev_channels; } netdev_channels;
typedef struct netdev_ring_param { typedef struct netdev_ring_param {
/* For any of the 4 following settings, a value of 0 indicates the hardware advertised maximum should
* be used. */
uint32_t rx_pending; uint32_t rx_pending;
uint32_t rx_mini_pending; uint32_t rx_mini_pending;
uint32_t rx_jumbo_pending; uint32_t rx_jumbo_pending;

View File

@ -19,9 +19,9 @@
#include "stat-util.h" #include "stat-util.h"
#include "string-util.h" #include "string-util.h"
/* We treat tmpfs/ramfs + cgroupfs as non-physical file sytems. cgroupfs is similar to tmpfs in a way after /* We treat tmpfs/ramfs + cgroupfs as non-physical file systems. cgroupfs is similar to tmpfs in a way
* all: we can create arbitrary directory hierarchies in it, and hence can also use rm_rf() on it to remove * after all: we can create arbitrary directory hierarchies in it, and hence can also use rm_rf() on it
* those again. */ * to remove those again. */
static bool is_physical_fs(const struct statfs *sfs) { static bool is_physical_fs(const struct statfs *sfs) {
return !is_temporary_fs(sfs) && !is_cgroup_fs(sfs); return !is_temporary_fs(sfs) && !is_cgroup_fs(sfs);
} }

View File

@ -353,7 +353,7 @@ static int tpm2_get_best_pcr_bank(
assert_cc(TPM2_PCRS_MAX % 8 == 0); assert_cc(TPM2_PCRS_MAX % 8 == 0);
/* It's not enought to check how many PCRs there are, we also need to check that the 24 are /* It's not enough to check how many PCRs there are, we also need to check that the 24 are
* enabled for this bank. Otherwise this TPM doesn't qualify. */ * enabled for this bank. Otherwise this TPM doesn't qualify. */
for (size_t j = 0; j < TPM2_PCRS_MAX/8; j++) for (size_t j = 0; j < TPM2_PCRS_MAX/8; j++)
if (pcap->data.assignedPCR.pcrSelections[i].pcrSelect[j] != 0xFF) { if (pcap->data.assignedPCR.pcrSelections[i].pcrSelect[j] != 0xFF) {
@ -411,7 +411,7 @@ static int tpm2_make_pcr_session(
}; };
TPML_PCR_SELECTION pcr_selection = { TPML_PCR_SELECTION pcr_selection = {
.count = 1, .count = 1,
.pcrSelections[0].hash = TPM2_ALG_SHA256, /* overriden below, depending on TPM2 capabilities */ .pcrSelections[0].hash = TPM2_ALG_SHA256, /* overridden below, depending on TPM2 capabilities */
.pcrSelections[0].sizeofSelect = 3, .pcrSelections[0].sizeofSelect = 3,
.pcrSelections[0].pcrSelect[0] = pcr_mask & 0xFF, .pcrSelections[0].pcrSelect[0] = pcr_mask & 0xFF,
.pcrSelections[0].pcrSelect[1] = (pcr_mask >> 8) & 0xFF, .pcrSelections[0].pcrSelect[1] = (pcr_mask >> 8) & 0xFF,

View File

@ -11,6 +11,7 @@
#include "udevadm.h" #include "udevadm.h"
#include "udevadm-util.h" #include "udevadm-util.h"
static sd_device_action_t arg_action = SD_DEVICE_ADD;
static const char *arg_command = NULL; static const char *arg_command = NULL;
static const char *arg_syspath = NULL; static const char *arg_syspath = NULL;
@ -19,6 +20,7 @@ static int help(void) {
"Test a built-in command.\n\n" "Test a built-in command.\n\n"
" -h --help Print this message\n" " -h --help Print this message\n"
" -V --version Print version of the program\n\n" " -V --version Print version of the program\n\n"
" -a --action=ACTION|help Set action string\n"
"Commands:\n", "Commands:\n",
program_invocation_short_name); program_invocation_short_name);
@ -29,15 +31,23 @@ static int help(void) {
static int parse_argv(int argc, char *argv[]) { static int parse_argv(int argc, char *argv[]) {
static const struct option options[] = { static const struct option options[] = {
{ "action", required_argument, NULL, 'a' },
{ "version", no_argument, NULL, 'V' }, { "version", no_argument, NULL, 'V' },
{ "help", no_argument, NULL, 'h' }, { "help", no_argument, NULL, 'h' },
{} {}
}; };
int c; int r, c;
while ((c = getopt_long(argc, argv, "Vh", options, NULL)) >= 0) while ((c = getopt_long(argc, argv, "a:Vh", options, NULL)) >= 0)
switch (c) { switch (c) {
case 'a':
r = parse_device_action(optarg, &arg_action);
if (r < 0)
return log_error_errno(r, "Invalid action '%s'", optarg);
if (r == 0)
return 0;
break;
case 'V': case 'V':
return print_version(); return print_version();
case 'h': case 'h':
@ -81,7 +91,7 @@ int builtin_main(int argc, char *argv[], void *userdata) {
goto finish; goto finish;
} }
r = find_device(arg_syspath, "/sys", &dev); r = find_device_with_action(arg_syspath, arg_action, &dev);
if (r < 0) { if (r < 0) {
log_error_errno(r, "Failed to open device '%s': %m", arg_syspath); log_error_errno(r, "Failed to open device '%s': %m", arg_syspath);
goto finish; goto finish;

View File

@ -21,11 +21,12 @@
#include "strxcpyx.h" #include "strxcpyx.h"
#include "udev-builtin.h" #include "udev-builtin.h"
#include "udev-event.h" #include "udev-event.h"
#include "udevadm-util.h"
#include "udevadm.h" #include "udevadm.h"
static const char *arg_action = "add"; static sd_device_action_t arg_action = SD_DEVICE_ADD;
static ResolveNameTiming arg_resolve_name_timing = RESOLVE_NAME_EARLY; static ResolveNameTiming arg_resolve_name_timing = RESOLVE_NAME_EARLY;
static char arg_syspath[UDEV_PATH_SIZE] = {}; static const char *arg_syspath = NULL;
static int help(void) { static int help(void) {
@ -49,25 +50,17 @@ static int parse_argv(int argc, char *argv[]) {
{} {}
}; };
int c; int r, c;
while ((c = getopt_long(argc, argv, "a:N:Vh", options, NULL)) >= 0) while ((c = getopt_long(argc, argv, "a:N:Vh", options, NULL)) >= 0)
switch (c) { switch (c) {
case 'a': { case 'a':
sd_device_action_t a; r = parse_device_action(optarg, &arg_action);
if (r < 0)
if (streq(optarg, "help")) { return log_error_errno(r, "Invalid action '%s'", optarg);
dump_device_action_table(); if (r == 0)
return 0; return 0;
}
a = device_action_from_string(optarg);
if (a < 0)
return log_error_errno(a, "Invalid action '%s'", optarg);
arg_action = device_action_to_string(a);
break; break;
}
case 'N': case 'N':
arg_resolve_name_timing = resolve_name_timing_from_string(optarg); arg_resolve_name_timing = resolve_name_timing_from_string(optarg);
if (arg_resolve_name_timing < 0) if (arg_resolve_name_timing < 0)
@ -84,15 +77,9 @@ static int parse_argv(int argc, char *argv[]) {
assert_not_reached(); assert_not_reached();
} }
if (!argv[optind]) arg_syspath = argv[optind];
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), if (!arg_syspath)
"syspath parameter missing."); return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "syspath parameter missing.");
/* add /sys if needed */
if (!path_startswith(argv[optind], "/sys"))
strscpyl(arg_syspath, sizeof(arg_syspath), "/sys", argv[optind], NULL);
else
strscpy(arg_syspath, sizeof(arg_syspath), argv[optind]);
return 1; return 1;
} }
@ -127,7 +114,7 @@ int test_main(int argc, char *argv[], void *userdata) {
goto out; goto out;
} }
r = device_new_from_synthetic_event(&dev, arg_syspath, arg_action); r = find_device_with_action(arg_syspath, arg_action, &dev);
if (r < 0) { if (r < 0) {
log_error_errno(r, "Failed to open device '%s': %m", arg_syspath); log_error_errno(r, "Failed to open device '%s': %m", arg_syspath);
goto out; goto out;

View File

@ -312,17 +312,13 @@ int trigger_main(int argc, char *argv[], void *userdata) {
else else
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown type --type=%s", optarg); return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown type --type=%s", optarg);
break; break;
case 'c': { case 'c':
if (streq(optarg, "help")) { r = parse_device_action(optarg, &action);
dump_device_action_table(); if (r < 0)
return log_error_errno(r, "Unknown action '%s'", optarg);
if (r == 0)
return 0; return 0;
}
action = device_action_from_string(optarg);
if (action < 0)
return log_error_errno(action, "Unknown action '%s'", optarg);
break; break;
}
case 's': case 's':
r = sd_device_enumerator_add_match_subsystem(e, optarg, true); r = sd_device_enumerator_add_match_subsystem(e, optarg, true);
if (r < 0) if (r < 0)

View File

@ -93,3 +93,39 @@ int find_device(const char *id, const char *prefix, sd_device **ret) {
return find_device_from_path(id, ret); return find_device_from_path(id, ret);
} }
int find_device_with_action(const char *id, sd_device_action_t action, sd_device **ret) {
_cleanup_free_ char *path = NULL;
assert(id);
assert(ret);
assert(action >= 0 && action < _SD_DEVICE_ACTION_MAX);
if (!path_startswith(id, "/sys")) {
path = path_join("/sys", id);
if (!path)
return -ENOMEM;
id = path;
}
return device_new_from_synthetic_event(ret, id, device_action_to_string(action));
}
int parse_device_action(const char *str, sd_device_action_t *action) {
sd_device_action_t a;
assert(str);
assert(action);
if (streq(str, "help")) {
dump_device_action_table();
return 0;
}
a = device_action_from_string(str);
if (a < 0)
return a;
*action = a;
return 1;
}

View File

@ -4,3 +4,5 @@
#include "sd-device.h" #include "sd-device.h"
int find_device(const char *id, const char *prefix, sd_device **ret); int find_device(const char *id, const char *prefix, sd_device **ret);
int find_device_with_action(const char *id, sd_device_action_t action, sd_device **ret);
int parse_device_action(const char *str, sd_device_action_t *action);

View File

@ -3719,7 +3719,7 @@ class NetworkdBridgeTests(unittest.TestCase, Utilities):
output = check_output('ip rule list table 100') output = check_output('ip rule list table 100')
print(output) print(output)
self.assertIn('0: from all to 8.8.8.8 lookup 100', output) self.assertIn('from all to 8.8.8.8 lookup 100', output)
class NetworkdLLDPTests(unittest.TestCase, Utilities): class NetworkdLLDPTests(unittest.TestCase, Utilities):
links = ['veth99'] links = ['veth99']