mirror of
https://github.com/systemd/systemd
synced 2025-10-01 17:54:45 +02:00
Compare commits
17 Commits
1f3315b8bd
...
bfe6043454
Author | SHA1 | Date | |
---|---|---|---|
![]() |
bfe6043454 | ||
![]() |
f345918d8d | ||
![]() |
b480543cf0 | ||
![]() |
63f48ab3fa | ||
![]() |
5be5d1f2a1 | ||
![]() |
09db71a4a3 | ||
![]() |
71894e1831 | ||
![]() |
d06e7fb532 | ||
![]() |
d9d3f05def | ||
![]() |
1ead0b2a79 | ||
![]() |
9cba32bcde | ||
![]() |
3b6e71ad03 | ||
![]() |
38d0c27006 | ||
![]() |
ed5033fd6c | ||
![]() |
60dcf3dc1b | ||
![]() |
fe845b5e76 | ||
![]() |
75b86b564a |
1
.github/workflows/labeler.yml
vendored
1
.github/workflows/labeler.yml
vendored
@ -10,3 +10,4 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
configuration-path: .github/labeler.yml
|
configuration-path: .github/labeler.yml
|
||||||
|
sync-labels: "" # This is a workaround for issue 18671
|
||||||
|
8
NEWS
8
NEWS
@ -153,8 +153,8 @@ CHANGES WITH 248:
|
|||||||
ManageTemporaryAddress= switch.
|
ManageTemporaryAddress= switch.
|
||||||
|
|
||||||
.network files gained a new ActivationPolicy= setting which allows
|
.network files gained a new ActivationPolicy= setting which allows
|
||||||
configuraiton how the UP state of an interface shall be managed,
|
configuration how the UP state of an interface shall be managed,
|
||||||
i.e. whether the iterface is always upped, always downed, or may be
|
i.e. whether the interface is always upped, always downed, or may be
|
||||||
upped/downed by the user using "ip dev".
|
upped/downed by the user using "ip dev".
|
||||||
|
|
||||||
* systemd.netdev files gained a [VLAN] Protocol=, IngressQOSMaps=,
|
* systemd.netdev files gained a [VLAN] Protocol=, IngressQOSMaps=,
|
||||||
@ -261,7 +261,7 @@ CHANGES WITH 248:
|
|||||||
specific variables, and not the full inherited environment.
|
specific variables, and not the full inherited environment.
|
||||||
|
|
||||||
* systemctl's status output now shows unit state with a more careful
|
* systemctl's status output now shows unit state with a more careful
|
||||||
selection of Unicode characters: units in maintainance show a "○"
|
selection of Unicode characters: units in maintenance show a "○"
|
||||||
symbol instead of the usual "●", failed units show "×", and services
|
symbol instead of the usual "●", failed units show "×", and services
|
||||||
being reloaded "↻".
|
being reloaded "↻".
|
||||||
|
|
||||||
@ -277,7 +277,7 @@ CHANGES WITH 248:
|
|||||||
many terminal colours are used in output.
|
many terminal colours are used in output.
|
||||||
|
|
||||||
* less 568 or newer is now required. Hyperlink ANSI sequences in
|
* less 568 or newer is now required. Hyperlink ANSI sequences in
|
||||||
termina output are now used even if a pager is used, and older
|
terminal output are now used even if a pager is used, and older
|
||||||
versions of less are not able to display these sequences
|
versions of less are not able to display these sequences
|
||||||
correctly. SYSTEMD_URLIFY=0 may be used to disable it.
|
correctly. SYSTEMD_URLIFY=0 may be used to disable it.
|
||||||
|
|
||||||
|
@ -48,36 +48,38 @@
|
|||||||
|
|
||||||
<variablelist class='config-directives'>
|
<variablelist class='config-directives'>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><varname>SwapUsedLimitPercent=</varname></term>
|
<term><varname>SwapUsedLimit=</varname></term>
|
||||||
|
|
||||||
<listitem><para>Sets the limit for swap usage on the system before <command>systemd-oomd</command> will
|
<listitem><para>Sets the limit for swap usage on the system before <command>systemd-oomd</command>
|
||||||
take action. If the percentage of swap used on the system is more than what is defined here,
|
will take action. If the fraction of swap used on the system is more than what is defined here,
|
||||||
<command>systemd-oomd</command> will act on eligible descendant cgroups, starting from the ones with the
|
<command>systemd-oomd</command> will act on eligible descendant control groups, starting from the
|
||||||
highest swap usage to the lowest swap usage. Which cgroups are monitored and what
|
ones with the highest swap usage to the lowest swap usage. Which control groups are monitored and
|
||||||
action gets taken depends on what the unit has configured for <varname>ManagedOOMSwap=</varname>.
|
what action gets taken depends on what the unit has configured for
|
||||||
Takes a percentage value between 0% and 100%, inclusive. Defaults to 90%.</para></listitem>
|
<varname>ManagedOOMSwap=</varname>. Takes a value specified in percent (when suffixed with "%"),
|
||||||
|
permille ("‰") or permyriad ("‱"), between 0% and 100%, inclusive. Defaults to 90%.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><varname>DefaultMemoryPressureLimit=</varname></term>
|
<term><varname>DefaultMemoryPressureLimit=</varname></term>
|
||||||
|
|
||||||
<listitem><para>Sets the limit for memory pressure on the unit's cgroup before <command>systemd-oomd</command>
|
<listitem><para>Sets the limit for memory pressure on the unit's control group before
|
||||||
will take action. A unit can override this value with <varname>ManagedOOMMemoryPressureLimit=</varname>.
|
<command>systemd-oomd</command> will take action. A unit can override this value with
|
||||||
The memory pressure for this property represents the fraction of time in a 10 second window in which all tasks
|
<varname>ManagedOOMMemoryPressureLimit=</varname>. The memory pressure for this property represents
|
||||||
in the cgroup were delayed. For each monitored cgroup, if the memory pressure on that cgroup exceeds the
|
the fraction of time in a 10 second window in which all tasks in the control group were delayed. For
|
||||||
limit set for longer than the duration set by <varname>DefaultMemoryPressureDurationSec=</varname>,
|
each monitored control group, if the memory pressure on that control group exceeds the limit set for
|
||||||
<command>systemd-oomd</command> will act on eligible descendant cgroups,
|
longer than the duration set by <varname>DefaultMemoryPressureDurationSec=</varname>,
|
||||||
starting from the ones with the most reclaim activity to the least reclaim activity. Which cgroups are
|
<command>systemd-oomd</command> will act on eligible descendant control groups, starting from the
|
||||||
monitored and what action gets taken depends on what the unit has configured for
|
ones with the most reclaim activity to the least reclaim activity. Which control groups are monitored
|
||||||
<varname>ManagedOOMMemoryPressure=</varname>. Takes a percentage value between 0% and 100%, inclusive.
|
and what action gets taken depends on what the unit has configured for
|
||||||
Defaults to 60%.</para></listitem>
|
<varname>ManagedOOMMemoryPressure=</varname>. Takes a fraction specified in the same way as
|
||||||
|
<varname>SwapUsedLimit=</varname> above. Defaults to 60%.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><varname>DefaultMemoryPressureDurationSec=</varname></term>
|
<term><varname>DefaultMemoryPressureDurationSec=</varname></term>
|
||||||
|
|
||||||
<listitem><para>Sets the amount of time a unit's cgroup needs to have exceeded memory pressure limits before
|
<listitem><para>Sets the amount of time a unit's control group needs to have exceeded memory pressure
|
||||||
<command>systemd-oomd</command> will take action. Memory pressure limits are defined by
|
limits before <command>systemd-oomd</command> will take action. Memory pressure limits are defined by
|
||||||
<varname>DefaultMemoryPressureLimit=</varname> and <varname>ManagedOOMMemoryPressureLimit=</varname>.
|
<varname>DefaultMemoryPressureLimit=</varname> and <varname>ManagedOOMMemoryPressureLimit=</varname>.
|
||||||
Defaults to 30 seconds when this property is unset or set to 0.</para></listitem>
|
Defaults to 30 seconds when this property is unset or set to 0.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
@ -2469,7 +2469,7 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice {
|
|||||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||||
readonly s ManagedOOMMemoryPressure = '...';
|
readonly s ManagedOOMMemoryPressure = '...';
|
||||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||||
readonly u ManagedOOMMemoryPressureLimitPermyriad = ...;
|
readonly u ManagedOOMMemoryPressureLimit = ...;
|
||||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||||
readonly s ManagedOOMPreference = '...';
|
readonly s ManagedOOMPreference = '...';
|
||||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
|
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
|
||||||
@ -2994,7 +2994,7 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice {
|
|||||||
|
|
||||||
<!--property ManagedOOMMemoryPressure is not documented!-->
|
<!--property ManagedOOMMemoryPressure is not documented!-->
|
||||||
|
|
||||||
<!--property ManagedOOMMemoryPressureLimitPermyriad is not documented!-->
|
<!--property ManagedOOMMemoryPressureLimit is not documented!-->
|
||||||
|
|
||||||
<!--property ManagedOOMPreference is not documented!-->
|
<!--property ManagedOOMPreference is not documented!-->
|
||||||
|
|
||||||
@ -3560,7 +3560,7 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice {
|
|||||||
|
|
||||||
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMMemoryPressure"/>
|
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMMemoryPressure"/>
|
||||||
|
|
||||||
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMMemoryPressureLimitPermyriad"/>
|
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMMemoryPressureLimit"/>
|
||||||
|
|
||||||
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMPreference"/>
|
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMPreference"/>
|
||||||
|
|
||||||
@ -4229,7 +4229,7 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2esocket {
|
|||||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||||
readonly s ManagedOOMMemoryPressure = '...';
|
readonly s ManagedOOMMemoryPressure = '...';
|
||||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||||
readonly u ManagedOOMMemoryPressureLimitPermyriad = ...;
|
readonly u ManagedOOMMemoryPressureLimit = ...;
|
||||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||||
readonly s ManagedOOMPreference = '...';
|
readonly s ManagedOOMPreference = '...';
|
||||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
|
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
|
||||||
@ -4782,7 +4782,7 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2esocket {
|
|||||||
|
|
||||||
<!--property ManagedOOMMemoryPressure is not documented!-->
|
<!--property ManagedOOMMemoryPressure is not documented!-->
|
||||||
|
|
||||||
<!--property ManagedOOMMemoryPressureLimitPermyriad is not documented!-->
|
<!--property ManagedOOMMemoryPressureLimit is not documented!-->
|
||||||
|
|
||||||
<!--property ManagedOOMPreference is not documented!-->
|
<!--property ManagedOOMPreference is not documented!-->
|
||||||
|
|
||||||
@ -5346,7 +5346,7 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2esocket {
|
|||||||
|
|
||||||
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMMemoryPressure"/>
|
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMMemoryPressure"/>
|
||||||
|
|
||||||
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMMemoryPressureLimitPermyriad"/>
|
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMMemoryPressureLimit"/>
|
||||||
|
|
||||||
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMPreference"/>
|
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMPreference"/>
|
||||||
|
|
||||||
@ -5928,7 +5928,7 @@ node /org/freedesktop/systemd1/unit/home_2emount {
|
|||||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||||
readonly s ManagedOOMMemoryPressure = '...';
|
readonly s ManagedOOMMemoryPressure = '...';
|
||||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||||
readonly u ManagedOOMMemoryPressureLimitPermyriad = ...;
|
readonly u ManagedOOMMemoryPressureLimit = ...;
|
||||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||||
readonly s ManagedOOMPreference = '...';
|
readonly s ManagedOOMPreference = '...';
|
||||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
|
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
|
||||||
@ -6409,7 +6409,7 @@ node /org/freedesktop/systemd1/unit/home_2emount {
|
|||||||
|
|
||||||
<!--property ManagedOOMMemoryPressure is not documented!-->
|
<!--property ManagedOOMMemoryPressure is not documented!-->
|
||||||
|
|
||||||
<!--property ManagedOOMMemoryPressureLimitPermyriad is not documented!-->
|
<!--property ManagedOOMMemoryPressureLimit is not documented!-->
|
||||||
|
|
||||||
<!--property ManagedOOMPreference is not documented!-->
|
<!--property ManagedOOMPreference is not documented!-->
|
||||||
|
|
||||||
@ -6891,7 +6891,7 @@ node /org/freedesktop/systemd1/unit/home_2emount {
|
|||||||
|
|
||||||
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMMemoryPressure"/>
|
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMMemoryPressure"/>
|
||||||
|
|
||||||
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMMemoryPressureLimitPermyriad"/>
|
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMMemoryPressureLimit"/>
|
||||||
|
|
||||||
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMPreference"/>
|
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMPreference"/>
|
||||||
|
|
||||||
@ -7594,7 +7594,7 @@ node /org/freedesktop/systemd1/unit/dev_2dsda3_2eswap {
|
|||||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||||
readonly s ManagedOOMMemoryPressure = '...';
|
readonly s ManagedOOMMemoryPressure = '...';
|
||||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||||
readonly u ManagedOOMMemoryPressureLimitPermyriad = ...;
|
readonly u ManagedOOMMemoryPressureLimit = ...;
|
||||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||||
readonly s ManagedOOMPreference = '...';
|
readonly s ManagedOOMPreference = '...';
|
||||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
|
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
|
||||||
@ -8061,7 +8061,7 @@ node /org/freedesktop/systemd1/unit/dev_2dsda3_2eswap {
|
|||||||
|
|
||||||
<!--property ManagedOOMMemoryPressure is not documented!-->
|
<!--property ManagedOOMMemoryPressure is not documented!-->
|
||||||
|
|
||||||
<!--property ManagedOOMMemoryPressureLimitPermyriad is not documented!-->
|
<!--property ManagedOOMMemoryPressureLimit is not documented!-->
|
||||||
|
|
||||||
<!--property ManagedOOMPreference is not documented!-->
|
<!--property ManagedOOMPreference is not documented!-->
|
||||||
|
|
||||||
@ -8529,7 +8529,7 @@ node /org/freedesktop/systemd1/unit/dev_2dsda3_2eswap {
|
|||||||
|
|
||||||
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMMemoryPressure"/>
|
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMMemoryPressure"/>
|
||||||
|
|
||||||
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMMemoryPressureLimitPermyriad"/>
|
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMMemoryPressureLimit"/>
|
||||||
|
|
||||||
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMPreference"/>
|
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMPreference"/>
|
||||||
|
|
||||||
@ -9085,7 +9085,7 @@ node /org/freedesktop/systemd1/unit/system_2eslice {
|
|||||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||||
readonly s ManagedOOMMemoryPressure = '...';
|
readonly s ManagedOOMMemoryPressure = '...';
|
||||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||||
readonly u ManagedOOMMemoryPressureLimitPermyriad = ...;
|
readonly u ManagedOOMMemoryPressureLimit = ...;
|
||||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||||
readonly s ManagedOOMPreference = '...';
|
readonly s ManagedOOMPreference = '...';
|
||||||
};
|
};
|
||||||
@ -9222,7 +9222,7 @@ node /org/freedesktop/systemd1/unit/system_2eslice {
|
|||||||
|
|
||||||
<!--property ManagedOOMMemoryPressure is not documented!-->
|
<!--property ManagedOOMMemoryPressure is not documented!-->
|
||||||
|
|
||||||
<!--property ManagedOOMMemoryPressureLimitPermyriad is not documented!-->
|
<!--property ManagedOOMMemoryPressureLimit is not documented!-->
|
||||||
|
|
||||||
<!--property ManagedOOMPreference is not documented!-->
|
<!--property ManagedOOMPreference is not documented!-->
|
||||||
|
|
||||||
@ -9364,7 +9364,7 @@ node /org/freedesktop/systemd1/unit/system_2eslice {
|
|||||||
|
|
||||||
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMMemoryPressure"/>
|
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMMemoryPressure"/>
|
||||||
|
|
||||||
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMMemoryPressureLimitPermyriad"/>
|
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMMemoryPressureLimit"/>
|
||||||
|
|
||||||
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMPreference"/>
|
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMPreference"/>
|
||||||
|
|
||||||
@ -9526,7 +9526,7 @@ node /org/freedesktop/systemd1/unit/session_2d1_2escope {
|
|||||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||||
readonly s ManagedOOMMemoryPressure = '...';
|
readonly s ManagedOOMMemoryPressure = '...';
|
||||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||||
readonly u ManagedOOMMemoryPressureLimitPermyriad = ...;
|
readonly u ManagedOOMMemoryPressureLimit = ...;
|
||||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||||
readonly s ManagedOOMPreference = '...';
|
readonly s ManagedOOMPreference = '...';
|
||||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
|
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
|
||||||
@ -9679,7 +9679,7 @@ node /org/freedesktop/systemd1/unit/session_2d1_2escope {
|
|||||||
|
|
||||||
<!--property ManagedOOMMemoryPressure is not documented!-->
|
<!--property ManagedOOMMemoryPressure is not documented!-->
|
||||||
|
|
||||||
<!--property ManagedOOMMemoryPressureLimitPermyriad is not documented!-->
|
<!--property ManagedOOMMemoryPressureLimit is not documented!-->
|
||||||
|
|
||||||
<!--property ManagedOOMPreference is not documented!-->
|
<!--property ManagedOOMPreference is not documented!-->
|
||||||
|
|
||||||
@ -9847,7 +9847,7 @@ node /org/freedesktop/systemd1/unit/session_2d1_2escope {
|
|||||||
|
|
||||||
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMMemoryPressure"/>
|
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMMemoryPressure"/>
|
||||||
|
|
||||||
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMMemoryPressureLimitPermyriad"/>
|
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMMemoryPressureLimit"/>
|
||||||
|
|
||||||
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMPreference"/>
|
<variablelist class="dbus-property" generated="True" extra-ref="ManagedOOMPreference"/>
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><command>query</command> <replaceable>HOSTNAME|ADDRESS</replaceable>…</term>
|
<term><command>query</command> <replaceable>HOSTNAME|ADDRESS</replaceable>…</term>
|
||||||
|
|
||||||
<listitem><para>Resolve domain names, as well as IPv4 and IPv6 addresses. When used in conjuntion
|
<listitem><para>Resolve domain names, as well as IPv4 and IPv6 addresses. When used in conjunction
|
||||||
with <option>--type=</option> or <option>--class=</option> (see below), resolves low-level DNS
|
with <option>--type=</option> or <option>--class=</option> (see below), resolves low-level DNS
|
||||||
resource records.</para>
|
resource records.</para>
|
||||||
|
|
||||||
|
@ -44,8 +44,9 @@
|
|||||||
<para>The default configuration is set during compilation, so configuration is only needed when it is
|
<para>The default configuration is set during compilation, so configuration is only needed when it is
|
||||||
necessary to deviate from those defaults. Initially, the main configuration file in
|
necessary to deviate from those defaults. Initially, the main configuration file in
|
||||||
<filename>/etc/systemd/</filename> contains commented out entries showing the defaults as a guide to the
|
<filename>/etc/systemd/</filename> contains commented out entries showing the defaults as a guide to the
|
||||||
administrator. Local overrides can be created by editing this file or by creating drop-ins, see below.
|
administrator. Local overrides can be created by editing this file or by creating drop-ins, as described
|
||||||
</para>
|
below. Using drop-ins for local configuration is recommended over modifications to the main configuration
|
||||||
|
file.</para>
|
||||||
|
|
||||||
<para>In addition to the "main" configuration file, drop-in configuration snippets are read from
|
<para>In addition to the "main" configuration file, drop-in configuration snippets are read from
|
||||||
<filename>/usr/lib/systemd/*.conf.d/</filename>, <filename>/usr/local/lib/systemd/*.conf.d/</filename>,
|
<filename>/usr/lib/systemd/*.conf.d/</filename>, <filename>/usr/local/lib/systemd/*.conf.d/</filename>,
|
||||||
|
@ -77,7 +77,13 @@ uint64_t physical_memory(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint64_t physical_memory_scale(uint64_t v, uint64_t max) {
|
uint64_t physical_memory_scale(uint64_t v, uint64_t max) {
|
||||||
uint64_t p, m, ps, r;
|
uint64_t p, m, ps;
|
||||||
|
|
||||||
|
/* Shortcut two special cases */
|
||||||
|
if (v == 0)
|
||||||
|
return 0;
|
||||||
|
if (v == max)
|
||||||
|
return physical_memory();
|
||||||
|
|
||||||
assert(max > 0);
|
assert(max > 0);
|
||||||
|
|
||||||
@ -90,17 +96,16 @@ uint64_t physical_memory_scale(uint64_t v, uint64_t max) {
|
|||||||
p = physical_memory() / ps;
|
p = physical_memory() / ps;
|
||||||
assert(p > 0);
|
assert(p > 0);
|
||||||
|
|
||||||
m = p * v;
|
if (v > UINT64_MAX / p)
|
||||||
if (m / p != v)
|
|
||||||
return UINT64_MAX;
|
return UINT64_MAX;
|
||||||
|
|
||||||
|
m = p * v;
|
||||||
m /= max;
|
m /= max;
|
||||||
|
|
||||||
r = m * ps;
|
if (m > UINT64_MAX / ps)
|
||||||
if (r / ps != m)
|
|
||||||
return UINT64_MAX;
|
return UINT64_MAX;
|
||||||
|
|
||||||
return r;
|
return m * ps;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t system_tasks_max(void) {
|
uint64_t system_tasks_max(void) {
|
||||||
@ -138,6 +143,12 @@ uint64_t system_tasks_max(void) {
|
|||||||
uint64_t system_tasks_max_scale(uint64_t v, uint64_t max) {
|
uint64_t system_tasks_max_scale(uint64_t v, uint64_t max) {
|
||||||
uint64_t t, m;
|
uint64_t t, m;
|
||||||
|
|
||||||
|
/* Shortcut two special cases */
|
||||||
|
if (v == 0)
|
||||||
|
return 0;
|
||||||
|
if (v == max)
|
||||||
|
return system_tasks_max();
|
||||||
|
|
||||||
assert(max > 0);
|
assert(max > 0);
|
||||||
|
|
||||||
/* Multiply the system's task value by the fraction v/max. Hence, if max==100 this calculates percentages
|
/* Multiply the system's task value by the fraction v/max. Hence, if max==100 this calculates percentages
|
||||||
@ -146,9 +157,9 @@ uint64_t system_tasks_max_scale(uint64_t v, uint64_t max) {
|
|||||||
t = system_tasks_max();
|
t = system_tasks_max();
|
||||||
assert(t > 0);
|
assert(t > 0);
|
||||||
|
|
||||||
m = t * v;
|
if (v > UINT64_MAX / t) /* overflow? */
|
||||||
if (m / t != v) /* overflow? */
|
|
||||||
return UINT64_MAX;
|
return UINT64_MAX;
|
||||||
|
|
||||||
|
m = t * v;
|
||||||
return m / max;
|
return m / max;
|
||||||
}
|
}
|
||||||
|
@ -176,6 +176,8 @@ basic_sources = files('''
|
|||||||
path-lookup.h
|
path-lookup.h
|
||||||
path-util.c
|
path-util.c
|
||||||
path-util.h
|
path-util.h
|
||||||
|
percent-util.c
|
||||||
|
percent-util.h
|
||||||
prioq.c
|
prioq.c
|
||||||
prioq.h
|
prioq.h
|
||||||
proc-cmdline.c
|
proc-cmdline.c
|
||||||
|
@ -627,146 +627,6 @@ int parse_fractional_part_u(const char **p, size_t digits, unsigned *res) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int parse_parts_value_whole(const char *p, const char *symbol) {
|
|
||||||
const char *pc, *n;
|
|
||||||
int r, v;
|
|
||||||
|
|
||||||
pc = endswith(p, symbol);
|
|
||||||
if (!pc)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
n = strndupa(p, pc - p);
|
|
||||||
r = safe_atoi(n, &v);
|
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
if (v < 0)
|
|
||||||
return -ERANGE;
|
|
||||||
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int parse_parts_value_with_tenths_place(const char *p, const char *symbol) {
|
|
||||||
const char *pc, *dot, *n;
|
|
||||||
int r, q, v;
|
|
||||||
|
|
||||||
pc = endswith(p, symbol);
|
|
||||||
if (!pc)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
dot = memchr(p, '.', pc - p);
|
|
||||||
if (dot) {
|
|
||||||
if (dot + 2 != pc)
|
|
||||||
return -EINVAL;
|
|
||||||
if (dot[1] < '0' || dot[1] > '9')
|
|
||||||
return -EINVAL;
|
|
||||||
q = dot[1] - '0';
|
|
||||||
n = strndupa(p, dot - p);
|
|
||||||
} else {
|
|
||||||
q = 0;
|
|
||||||
n = strndupa(p, pc - p);
|
|
||||||
}
|
|
||||||
r = safe_atoi(n, &v);
|
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
if (v < 0)
|
|
||||||
return -ERANGE;
|
|
||||||
if (v > (INT_MAX - q) / 10)
|
|
||||||
return -ERANGE;
|
|
||||||
|
|
||||||
v = v * 10 + q;
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int parse_parts_value_with_hundredths_place(const char *p, const char *symbol) {
|
|
||||||
const char *pc, *dot, *n;
|
|
||||||
int r, q, v;
|
|
||||||
|
|
||||||
pc = endswith(p, symbol);
|
|
||||||
if (!pc)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
dot = memchr(p, '.', pc - p);
|
|
||||||
if (dot) {
|
|
||||||
if (dot + 3 != pc)
|
|
||||||
return -EINVAL;
|
|
||||||
if (dot[1] < '0' || dot[1] > '9' || dot[2] < '0' || dot[2] > '9')
|
|
||||||
return -EINVAL;
|
|
||||||
q = (dot[1] - '0') * 10 + (dot[2] - '0');
|
|
||||||
n = strndupa(p, dot - p);
|
|
||||||
} else {
|
|
||||||
q = 0;
|
|
||||||
n = strndupa(p, pc - p);
|
|
||||||
}
|
|
||||||
r = safe_atoi(n, &v);
|
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
if (v < 0)
|
|
||||||
return -ERANGE;
|
|
||||||
if (v > (INT_MAX - q) / 100)
|
|
||||||
return -ERANGE;
|
|
||||||
|
|
||||||
v = v * 100 + q;
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
int parse_percent_unbounded(const char *p) {
|
|
||||||
return parse_parts_value_whole(p, "%");
|
|
||||||
}
|
|
||||||
|
|
||||||
int parse_percent(const char *p) {
|
|
||||||
int v;
|
|
||||||
|
|
||||||
v = parse_percent_unbounded(p);
|
|
||||||
if (v > 100)
|
|
||||||
return -ERANGE;
|
|
||||||
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
int parse_permille_unbounded(const char *p) {
|
|
||||||
const char *pm;
|
|
||||||
|
|
||||||
pm = endswith(p, "‰");
|
|
||||||
if (pm)
|
|
||||||
return parse_parts_value_whole(p, "‰");
|
|
||||||
|
|
||||||
return parse_parts_value_with_tenths_place(p, "%");
|
|
||||||
}
|
|
||||||
|
|
||||||
int parse_permille(const char *p) {
|
|
||||||
int v;
|
|
||||||
|
|
||||||
v = parse_permille_unbounded(p);
|
|
||||||
if (v > 1000)
|
|
||||||
return -ERANGE;
|
|
||||||
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
int parse_permyriad_unbounded(const char *p) {
|
|
||||||
const char *pm;
|
|
||||||
|
|
||||||
pm = endswith(p, "‱");
|
|
||||||
if (pm)
|
|
||||||
return parse_parts_value_whole(p, "‱");
|
|
||||||
|
|
||||||
pm = endswith(p, "‰");
|
|
||||||
if (pm)
|
|
||||||
return parse_parts_value_with_tenths_place(p, "‰");
|
|
||||||
|
|
||||||
return parse_parts_value_with_hundredths_place(p, "%");
|
|
||||||
}
|
|
||||||
|
|
||||||
int parse_permyriad(const char *p) {
|
|
||||||
int v;
|
|
||||||
|
|
||||||
v = parse_permyriad_unbounded(p);
|
|
||||||
if (v > 10000)
|
|
||||||
return -ERANGE;
|
|
||||||
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
int parse_nice(const char *p, int *ret) {
|
int parse_nice(const char *p, int *ret) {
|
||||||
int n, r;
|
int n, r;
|
||||||
|
|
||||||
|
@ -127,15 +127,6 @@ int safe_atod(const char *s, double *ret_d);
|
|||||||
|
|
||||||
int parse_fractional_part_u(const char **s, size_t digits, unsigned *res);
|
int parse_fractional_part_u(const char **s, size_t digits, unsigned *res);
|
||||||
|
|
||||||
int parse_percent_unbounded(const char *p);
|
|
||||||
int parse_percent(const char *p);
|
|
||||||
|
|
||||||
int parse_permille_unbounded(const char *p);
|
|
||||||
int parse_permille(const char *p);
|
|
||||||
|
|
||||||
int parse_permyriad_unbounded(const char *p);
|
|
||||||
int parse_permyriad(const char *p);
|
|
||||||
|
|
||||||
int parse_nice(const char *p, int *ret);
|
int parse_nice(const char *p, int *ret);
|
||||||
|
|
||||||
int parse_ip_port(const char *s, uint16_t *ret);
|
int parse_ip_port(const char *s, uint16_t *ret);
|
||||||
|
157
src/basic/percent-util.c
Normal file
157
src/basic/percent-util.c
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||||
|
|
||||||
|
#include "percent-util.h"
|
||||||
|
#include "string-util.h"
|
||||||
|
#include "parse-util.h"
|
||||||
|
|
||||||
|
static int parse_parts_value_whole(const char *p, const char *symbol) {
|
||||||
|
const char *pc, *n;
|
||||||
|
int r, v;
|
||||||
|
|
||||||
|
pc = endswith(p, symbol);
|
||||||
|
if (!pc)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
n = strndupa(p, pc - p);
|
||||||
|
r = safe_atoi(n, &v);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
if (v < 0)
|
||||||
|
return -ERANGE;
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int parse_parts_value_with_tenths_place(const char *p, const char *symbol) {
|
||||||
|
const char *pc, *dot, *n;
|
||||||
|
int r, q, v;
|
||||||
|
|
||||||
|
pc = endswith(p, symbol);
|
||||||
|
if (!pc)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
dot = memchr(p, '.', pc - p);
|
||||||
|
if (dot) {
|
||||||
|
if (dot + 2 != pc)
|
||||||
|
return -EINVAL;
|
||||||
|
if (dot[1] < '0' || dot[1] > '9')
|
||||||
|
return -EINVAL;
|
||||||
|
q = dot[1] - '0';
|
||||||
|
n = strndupa(p, dot - p);
|
||||||
|
} else {
|
||||||
|
q = 0;
|
||||||
|
n = strndupa(p, pc - p);
|
||||||
|
}
|
||||||
|
r = safe_atoi(n, &v);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
if (v < 0)
|
||||||
|
return -ERANGE;
|
||||||
|
if (v > (INT_MAX - q) / 10)
|
||||||
|
return -ERANGE;
|
||||||
|
|
||||||
|
v = v * 10 + q;
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int parse_parts_value_with_hundredths_place(const char *p, const char *symbol) {
|
||||||
|
const char *pc, *dot, *n;
|
||||||
|
int r, q, v;
|
||||||
|
|
||||||
|
pc = endswith(p, symbol);
|
||||||
|
if (!pc)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
dot = memchr(p, '.', pc - p);
|
||||||
|
if (dot) {
|
||||||
|
if (dot + 3 == pc) {
|
||||||
|
/* Support two places after the dot */
|
||||||
|
|
||||||
|
if (dot[1] < '0' || dot[1] > '9' || dot[2] < '0' || dot[2] > '9')
|
||||||
|
return -EINVAL;
|
||||||
|
q = (dot[1] - '0') * 10 + (dot[2] - '0');
|
||||||
|
|
||||||
|
} else if (dot + 2 == pc) {
|
||||||
|
/* Support one place after the dot */
|
||||||
|
|
||||||
|
if (dot[1] < '0' || dot[1] > '9')
|
||||||
|
return -EINVAL;
|
||||||
|
q = (dot[1] - '0') * 10;
|
||||||
|
} else
|
||||||
|
/* We do not support zero or more than two places */
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
n = strndupa(p, dot - p);
|
||||||
|
} else {
|
||||||
|
q = 0;
|
||||||
|
n = strndupa(p, pc - p);
|
||||||
|
}
|
||||||
|
r = safe_atoi(n, &v);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
if (v < 0)
|
||||||
|
return -ERANGE;
|
||||||
|
if (v > (INT_MAX - q) / 100)
|
||||||
|
return -ERANGE;
|
||||||
|
|
||||||
|
v = v * 100 + q;
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
int parse_percent_unbounded(const char *p) {
|
||||||
|
return parse_parts_value_whole(p, "%");
|
||||||
|
}
|
||||||
|
|
||||||
|
int parse_percent(const char *p) {
|
||||||
|
int v;
|
||||||
|
|
||||||
|
v = parse_percent_unbounded(p);
|
||||||
|
if (v > 100)
|
||||||
|
return -ERANGE;
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
int parse_permille_unbounded(const char *p) {
|
||||||
|
const char *pm;
|
||||||
|
|
||||||
|
pm = endswith(p, "‰");
|
||||||
|
if (pm)
|
||||||
|
return parse_parts_value_whole(p, "‰");
|
||||||
|
|
||||||
|
return parse_parts_value_with_tenths_place(p, "%");
|
||||||
|
}
|
||||||
|
|
||||||
|
int parse_permille(const char *p) {
|
||||||
|
int v;
|
||||||
|
|
||||||
|
v = parse_permille_unbounded(p);
|
||||||
|
if (v > 1000)
|
||||||
|
return -ERANGE;
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
int parse_permyriad_unbounded(const char *p) {
|
||||||
|
const char *pm;
|
||||||
|
|
||||||
|
pm = endswith(p, "‱");
|
||||||
|
if (pm)
|
||||||
|
return parse_parts_value_whole(p, "‱");
|
||||||
|
|
||||||
|
pm = endswith(p, "‰");
|
||||||
|
if (pm)
|
||||||
|
return parse_parts_value_with_tenths_place(p, "‰");
|
||||||
|
|
||||||
|
return parse_parts_value_with_hundredths_place(p, "%");
|
||||||
|
}
|
||||||
|
|
||||||
|
int parse_permyriad(const char *p) {
|
||||||
|
int v;
|
||||||
|
|
||||||
|
v = parse_permyriad_unbounded(p);
|
||||||
|
if (v > 10000)
|
||||||
|
return -ERANGE;
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
64
src/basic/percent-util.h
Normal file
64
src/basic/percent-util.h
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
#include "macro.h"
|
||||||
|
|
||||||
|
int parse_percent_unbounded(const char *p);
|
||||||
|
int parse_percent(const char *p);
|
||||||
|
|
||||||
|
int parse_permille_unbounded(const char *p);
|
||||||
|
int parse_permille(const char *p);
|
||||||
|
|
||||||
|
int parse_permyriad_unbounded(const char *p);
|
||||||
|
int parse_permyriad(const char *p);
|
||||||
|
|
||||||
|
/* Some macro-like helpers that convert a percent/permille/permyriad value (as parsed by parse_percent()) to
|
||||||
|
* a value relative to 100% == 2^32-1. Rounds to closest. */
|
||||||
|
static inline uint32_t UINT32_SCALE_FROM_PERCENT(int percent) {
|
||||||
|
assert_cc(INT_MAX <= UINT32_MAX);
|
||||||
|
return (uint32_t) (((uint64_t) percent * UINT32_MAX + 50) / 100U);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t UINT32_SCALE_FROM_PERMILLE(int permille) {
|
||||||
|
return (uint32_t) (((uint64_t) permille * UINT32_MAX + 500) / 1000U);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t UINT32_SCALE_FROM_PERMYRIAD(int permyriad) {
|
||||||
|
return (uint32_t) (((uint64_t) permyriad * UINT32_MAX + 5000) / 10000U);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int UINT32_SCALE_TO_PERCENT(uint32_t scale) {
|
||||||
|
uint32_t u;
|
||||||
|
|
||||||
|
u = (uint32_t) ((((uint64_t) scale) * 100U + UINT32_MAX/2) / UINT32_MAX);
|
||||||
|
if (u > INT_MAX)
|
||||||
|
return -ERANGE;
|
||||||
|
|
||||||
|
return (int) u;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int UINT32_SCALE_TO_PERMILLE(uint32_t scale) {
|
||||||
|
uint32_t u;
|
||||||
|
|
||||||
|
u = (uint32_t) ((((uint64_t) scale) * 1000U + UINT32_MAX/2) / UINT32_MAX);
|
||||||
|
if (u > INT_MAX)
|
||||||
|
return -ERANGE;
|
||||||
|
|
||||||
|
return (int) u;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int UINT32_SCALE_TO_PERMYRIAD(uint32_t scale) {
|
||||||
|
uint32_t u;
|
||||||
|
|
||||||
|
u = (uint32_t) ((((uint64_t) scale) * 10000U + UINT32_MAX/2) / UINT32_MAX);
|
||||||
|
if (u > INT_MAX)
|
||||||
|
return -ERANGE;
|
||||||
|
|
||||||
|
return (int) u;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define PERMYRIAD_AS_PERCENT_FORMAT_STR "%i.%02i%%"
|
||||||
|
#define PERMYRIAD_AS_PERCENT_FORMAT_VAL(x) ((x)/100), ((x)%100)
|
@ -21,6 +21,7 @@
|
|||||||
#include "nulstr-util.h"
|
#include "nulstr-util.h"
|
||||||
#include "parse-util.h"
|
#include "parse-util.h"
|
||||||
#include "path-util.h"
|
#include "path-util.h"
|
||||||
|
#include "percent-util.h"
|
||||||
#include "process-util.h"
|
#include "process-util.h"
|
||||||
#include "procfs-util.h"
|
#include "procfs-util.h"
|
||||||
#include "special.h"
|
#include "special.h"
|
||||||
@ -418,7 +419,7 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) {
|
|||||||
"%sDelegate: %s\n"
|
"%sDelegate: %s\n"
|
||||||
"%sManagedOOMSwap: %s\n"
|
"%sManagedOOMSwap: %s\n"
|
||||||
"%sManagedOOMMemoryPressure: %s\n"
|
"%sManagedOOMMemoryPressure: %s\n"
|
||||||
"%sManagedOOMMemoryPressureLimit: %" PRIu32 ".%02" PRIu32 "%%\n"
|
"%sManagedOOMMemoryPressureLimit: " PERMYRIAD_AS_PERCENT_FORMAT_STR "\n"
|
||||||
"%sManagedOOMPreference: %s%%\n",
|
"%sManagedOOMPreference: %s%%\n",
|
||||||
prefix, yes_no(c->cpu_accounting),
|
prefix, yes_no(c->cpu_accounting),
|
||||||
prefix, yes_no(c->io_accounting),
|
prefix, yes_no(c->io_accounting),
|
||||||
@ -452,7 +453,7 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) {
|
|||||||
prefix, yes_no(c->delegate),
|
prefix, yes_no(c->delegate),
|
||||||
prefix, managed_oom_mode_to_string(c->moom_swap),
|
prefix, managed_oom_mode_to_string(c->moom_swap),
|
||||||
prefix, managed_oom_mode_to_string(c->moom_mem_pressure),
|
prefix, managed_oom_mode_to_string(c->moom_mem_pressure),
|
||||||
prefix, c->moom_mem_pressure_limit_permyriad / 100, c->moom_mem_pressure_limit_permyriad % 100,
|
prefix, PERMYRIAD_AS_PERCENT_FORMAT_VAL(UINT32_SCALE_TO_PERMYRIAD(c->moom_mem_pressure_limit)),
|
||||||
prefix, managed_oom_preference_to_string(c->moom_preference));
|
prefix, managed_oom_preference_to_string(c->moom_preference));
|
||||||
|
|
||||||
if (c->delegate) {
|
if (c->delegate) {
|
||||||
|
@ -163,7 +163,7 @@ struct CGroupContext {
|
|||||||
/* Settings for systemd-oomd */
|
/* Settings for systemd-oomd */
|
||||||
ManagedOOMMode moom_swap;
|
ManagedOOMMode moom_swap;
|
||||||
ManagedOOMMode moom_mem_pressure;
|
ManagedOOMMode moom_mem_pressure;
|
||||||
uint32_t moom_mem_pressure_limit_permyriad;
|
uint32_t moom_mem_pressure_limit; /* Normalized to 2^32-1 == 100% */
|
||||||
ManagedOOMPreference moom_preference;
|
ManagedOOMPreference moom_preference;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ static int build_managed_oom_json_array_element(Unit *u, const char *property, J
|
|||||||
JSON_BUILD_PAIR("mode", JSON_BUILD_STRING(mode)),
|
JSON_BUILD_PAIR("mode", JSON_BUILD_STRING(mode)),
|
||||||
JSON_BUILD_PAIR("path", JSON_BUILD_STRING(u->cgroup_path)),
|
JSON_BUILD_PAIR("path", JSON_BUILD_STRING(u->cgroup_path)),
|
||||||
JSON_BUILD_PAIR("property", JSON_BUILD_STRING(property)),
|
JSON_BUILD_PAIR("property", JSON_BUILD_STRING(property)),
|
||||||
JSON_BUILD_PAIR_CONDITION(use_limit, "limit", JSON_BUILD_UNSIGNED(c->moom_mem_pressure_limit_permyriad))));
|
JSON_BUILD_PAIR_CONDITION(use_limit, "limit", JSON_BUILD_UNSIGNED(c->moom_mem_pressure_limit))));
|
||||||
}
|
}
|
||||||
|
|
||||||
int manager_varlink_send_managed_oom_update(Unit *u) {
|
int manager_varlink_send_managed_oom_update(Unit *u) {
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "fileio.h"
|
#include "fileio.h"
|
||||||
#include "limits-util.h"
|
#include "limits-util.h"
|
||||||
#include "path-util.h"
|
#include "path-util.h"
|
||||||
|
#include "percent-util.h"
|
||||||
|
|
||||||
BUS_DEFINE_PROPERTY_GET(bus_property_get_tasks_max, "t", TasksMax, tasks_max_resolve);
|
BUS_DEFINE_PROPERTY_GET(bus_property_get_tasks_max, "t", TasksMax, tasks_max_resolve);
|
||||||
|
|
||||||
@ -395,7 +396,7 @@ const sd_bus_vtable bus_cgroup_vtable[] = {
|
|||||||
SD_BUS_PROPERTY("DisableControllers", "as", property_get_cgroup_mask, offsetof(CGroupContext, disable_controllers), 0),
|
SD_BUS_PROPERTY("DisableControllers", "as", property_get_cgroup_mask, offsetof(CGroupContext, disable_controllers), 0),
|
||||||
SD_BUS_PROPERTY("ManagedOOMSwap", "s", property_get_managed_oom_mode, offsetof(CGroupContext, moom_swap), 0),
|
SD_BUS_PROPERTY("ManagedOOMSwap", "s", property_get_managed_oom_mode, offsetof(CGroupContext, moom_swap), 0),
|
||||||
SD_BUS_PROPERTY("ManagedOOMMemoryPressure", "s", property_get_managed_oom_mode, offsetof(CGroupContext, moom_mem_pressure), 0),
|
SD_BUS_PROPERTY("ManagedOOMMemoryPressure", "s", property_get_managed_oom_mode, offsetof(CGroupContext, moom_mem_pressure), 0),
|
||||||
SD_BUS_PROPERTY("ManagedOOMMemoryPressureLimitPermyriad", "u", NULL, offsetof(CGroupContext, moom_mem_pressure_limit_permyriad), 0),
|
SD_BUS_PROPERTY("ManagedOOMMemoryPressureLimit", "u", NULL, offsetof(CGroupContext, moom_mem_pressure_limit), 0),
|
||||||
SD_BUS_PROPERTY("ManagedOOMPreference", "s", property_get_managed_oom_preference, offsetof(CGroupContext, moom_preference), 0),
|
SD_BUS_PROPERTY("ManagedOOMPreference", "s", property_get_managed_oom_preference, offsetof(CGroupContext, moom_preference), 0),
|
||||||
SD_BUS_VTABLE_END
|
SD_BUS_VTABLE_END
|
||||||
};
|
};
|
||||||
@ -704,10 +705,10 @@ static int bus_cgroup_set_boolean(
|
|||||||
/* Prepare to chop off suffix */ \
|
/* Prepare to chop off suffix */ \
|
||||||
assert_se(endswith(name, "Scale")); \
|
assert_se(endswith(name, "Scale")); \
|
||||||
\
|
\
|
||||||
uint32_t scaled = DIV_ROUND_UP((uint64_t) raw * 1000, (uint64_t) UINT32_MAX); \
|
int scaled = UINT32_SCALE_TO_PERMYRIAD(raw); \
|
||||||
unit_write_settingf(u, flags, name, "%.*s=%" PRIu32 ".%" PRIu32 "%%", \
|
unit_write_settingf(u, flags, name, "%.*s=" PERMYRIAD_AS_PERCENT_FORMAT_STR, \
|
||||||
(int)(strlen(name) - strlen("Scale")), name, \
|
(int)(strlen(name) - strlen("Scale")), name, \
|
||||||
scaled / 10, scaled % 10); \
|
PERMYRIAD_AS_PERCENT_FORMAT_VAL(scaled)); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
return 1; \
|
return 1; \
|
||||||
@ -1698,7 +1699,7 @@ int bus_cgroup_set_property(
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (streq(name, "ManagedOOMMemoryPressureLimitPermyriad")) {
|
if (streq(name, "ManagedOOMMemoryPressureLimit")) {
|
||||||
uint32_t v;
|
uint32_t v;
|
||||||
|
|
||||||
if (!UNIT_VTABLE(u)->can_set_managed_oom)
|
if (!UNIT_VTABLE(u)->can_set_managed_oom)
|
||||||
@ -1708,12 +1709,11 @@ int bus_cgroup_set_property(
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
if (v > 10000)
|
|
||||||
return -ERANGE;
|
|
||||||
|
|
||||||
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
|
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
|
||||||
c->moom_mem_pressure_limit_permyriad = v;
|
c->moom_mem_pressure_limit = v;
|
||||||
unit_write_settingf(u, flags, name, "ManagedOOMMemoryPressureLimit=%" PRIu32 ".%02" PRIu32 "%%", v / 100, v % 100);
|
unit_write_settingf(u, flags, name,
|
||||||
|
"ManagedOOMMemoryPressureLimit=" PERMYRIAD_AS_PERCENT_FORMAT_STR,
|
||||||
|
PERMYRIAD_AS_PERCENT_FORMAT_VAL(UINT32_SCALE_TO_PERMYRIAD(v)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c->moom_mem_pressure == MANAGED_OOM_KILL)
|
if (c->moom_mem_pressure == MANAGED_OOM_KILL)
|
||||||
|
@ -229,7 +229,7 @@ $1.IPIngressFilterPath, config_parse_ip_filter_bpf_progs,
|
|||||||
$1.IPEgressFilterPath, config_parse_ip_filter_bpf_progs, 0, offsetof($1, cgroup_context.ip_filters_egress)
|
$1.IPEgressFilterPath, config_parse_ip_filter_bpf_progs, 0, offsetof($1, cgroup_context.ip_filters_egress)
|
||||||
$1.ManagedOOMSwap, config_parse_managed_oom_mode, 0, offsetof($1, cgroup_context.moom_swap)
|
$1.ManagedOOMSwap, config_parse_managed_oom_mode, 0, offsetof($1, cgroup_context.moom_swap)
|
||||||
$1.ManagedOOMMemoryPressure, config_parse_managed_oom_mode, 0, offsetof($1, cgroup_context.moom_mem_pressure)
|
$1.ManagedOOMMemoryPressure, config_parse_managed_oom_mode, 0, offsetof($1, cgroup_context.moom_mem_pressure)
|
||||||
$1.ManagedOOMMemoryPressureLimit, config_parse_managed_oom_mem_pressure_limit, 0, offsetof($1, cgroup_context.moom_mem_pressure_limit_permyriad)
|
$1.ManagedOOMMemoryPressureLimit, config_parse_managed_oom_mem_pressure_limit, 0, offsetof($1, cgroup_context.moom_mem_pressure_limit)
|
||||||
$1.ManagedOOMPreference, config_parse_managed_oom_preference, 0, offsetof($1, cgroup_context.moom_preference)
|
$1.ManagedOOMPreference, config_parse_managed_oom_preference, 0, offsetof($1, cgroup_context.moom_preference)
|
||||||
$1.NetClass, config_parse_warn_compat, DISABLED_LEGACY, 0'
|
$1.NetClass, config_parse_warn_compat, DISABLED_LEGACY, 0'
|
||||||
)m4_dnl
|
)m4_dnl
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
#include "nulstr-util.h"
|
#include "nulstr-util.h"
|
||||||
#include "parse-util.h"
|
#include "parse-util.h"
|
||||||
#include "path-util.h"
|
#include "path-util.h"
|
||||||
|
#include "percent-util.h"
|
||||||
#include "process-util.h"
|
#include "process-util.h"
|
||||||
#if HAVE_SECCOMP
|
#if HAVE_SECCOMP
|
||||||
#include "seccomp-util.h"
|
#include "seccomp-util.h"
|
||||||
@ -3593,13 +3594,13 @@ int config_parse_cpu_quota(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = parse_permille_unbounded(rvalue);
|
r = parse_permyriad_unbounded(rvalue);
|
||||||
if (r <= 0) {
|
if (r <= 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid CPU quota '%s', ignoring.", rvalue);
|
log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid CPU quota '%s', ignoring.", rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
c->cpu_quota_per_sec_usec = ((usec_t) r * USEC_PER_SEC) / 1000U;
|
c->cpu_quota_per_sec_usec = ((usec_t) r * USEC_PER_SEC) / 10000U;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3664,7 +3665,7 @@ int config_parse_memory_limit(
|
|||||||
bytes = CGROUP_LIMIT_MIN;
|
bytes = CGROUP_LIMIT_MIN;
|
||||||
else if (!isempty(rvalue) && !streq(rvalue, "infinity")) {
|
else if (!isempty(rvalue) && !streq(rvalue, "infinity")) {
|
||||||
|
|
||||||
r = parse_permille(rvalue);
|
r = parse_permyriad(rvalue);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
r = parse_size(rvalue, 1024, &bytes);
|
r = parse_size(rvalue, 1024, &bytes);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
@ -3672,7 +3673,7 @@ int config_parse_memory_limit(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
bytes = physical_memory_scale(r, 1000U);
|
bytes = physical_memory_scale(r, 10000U);
|
||||||
|
|
||||||
if (bytes >= UINT64_MAX ||
|
if (bytes >= UINT64_MAX ||
|
||||||
(bytes <= 0 && !STR_IN_SET(lvalue, "MemorySwapMax", "MemoryLow", "MemoryMin", "DefaultMemoryLow", "DefaultMemoryMin"))) {
|
(bytes <= 0 && !STR_IN_SET(lvalue, "MemorySwapMax", "MemoryLow", "MemoryMin", "DefaultMemoryLow", "DefaultMemoryMin"))) {
|
||||||
@ -3734,9 +3735,9 @@ int config_parse_tasks_max(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = parse_permille(rvalue);
|
r = parse_permyriad(rvalue);
|
||||||
if (r >= 0)
|
if (r >= 0)
|
||||||
*tasks_max = (TasksMax) { r, 1000U }; /* r‰ */
|
*tasks_max = (TasksMax) { r, 10000U }; /* r‱ */
|
||||||
else {
|
else {
|
||||||
r = safe_atou64(rvalue, &v);
|
r = safe_atou64(rvalue, &v);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
@ -3842,6 +3843,7 @@ int config_parse_managed_oom_mode(
|
|||||||
const char *rvalue,
|
const char *rvalue,
|
||||||
void *data,
|
void *data,
|
||||||
void *userdata) {
|
void *userdata) {
|
||||||
|
|
||||||
ManagedOOMMode *mode = data, m;
|
ManagedOOMMode *mode = data, m;
|
||||||
UnitType t;
|
UnitType t;
|
||||||
|
|
||||||
@ -3861,6 +3863,7 @@ int config_parse_managed_oom_mode(
|
|||||||
log_syntax(unit, LOG_WARNING, filename, line, m, "Invalid syntax, ignoring: %s", rvalue);
|
log_syntax(unit, LOG_WARNING, filename, line, m, "Invalid syntax, ignoring: %s", rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
*mode = m;
|
*mode = m;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -3876,6 +3879,7 @@ int config_parse_managed_oom_mem_pressure_limit(
|
|||||||
const char *rvalue,
|
const char *rvalue,
|
||||||
void *data,
|
void *data,
|
||||||
void *userdata) {
|
void *userdata) {
|
||||||
|
|
||||||
uint32_t *limit = data;
|
uint32_t *limit = data;
|
||||||
UnitType t;
|
UnitType t;
|
||||||
int r;
|
int r;
|
||||||
@ -3897,7 +3901,8 @@ int config_parse_managed_oom_mem_pressure_limit(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
*limit = r;
|
/* Normalize to 2^32-1 == 100% */
|
||||||
|
*limit = UINT32_SCALE_FROM_PERMYRIAD(r);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1256,8 +1256,8 @@ static int bump_rlimit_memlock(struct rlimit *saved_rlimit) {
|
|||||||
* must be unsigned, hence this is a given, but let's make this clear here. */
|
* must be unsigned, hence this is a given, but let's make this clear here. */
|
||||||
assert_cc(RLIM_INFINITY > 0);
|
assert_cc(RLIM_INFINITY > 0);
|
||||||
|
|
||||||
mm = physical_memory() / 8; /* Let's scale how much we allow to be locked by the amount of physical
|
mm = physical_memory_scale(1, 8); /* Let's scale how much we allow to be locked by the amount of physical
|
||||||
* RAM. We allow an eighth to be locked by us, just to pick a value. */
|
* RAM. We allow an eighth to be locked by us, just to pick a value. */
|
||||||
|
|
||||||
new_rlimit = (struct rlimit) {
|
new_rlimit = (struct rlimit) {
|
||||||
.rlim_cur = MAX3(HIGH_RLIMIT_MEMLOCK, saved_rlimit->rlim_cur, mm),
|
.rlim_cur = MAX3(HIGH_RLIMIT_MEMLOCK, saved_rlimit->rlim_cur, mm),
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
# This file is part of systemd.
|
# This file is part of systemd.
|
||||||
#
|
#
|
||||||
# systemd is free software; you can redistribute it and/or modify it
|
# systemd is free software; you can redistribute it and/or modify it under the
|
||||||
# under the terms of the GNU Lesser General Public License as published by
|
# terms of the GNU Lesser General Public License as published by the Free
|
||||||
# the Free Software Foundation; either version 2.1 of the License, or
|
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||||
# (at your option) any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# Entries in this file show the compile time defaults.
|
# Entries in this file show the compile time defaults. Local configuration
|
||||||
# You can change settings by editing this file.
|
# should be created by either modifying this file, or by creating "drop-ins" in
|
||||||
# Defaults can be restored by simply deleting this file.
|
# the system.conf.d/ subdirectory. The latter is generally recommended.
|
||||||
|
# Defaults can be restored by simply deleting this file and all drop-ins.
|
||||||
#
|
#
|
||||||
# See systemd-system.conf(5) for details.
|
# See systemd-system.conf(5) for details.
|
||||||
|
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
# This file is part of systemd.
|
# This file is part of systemd.
|
||||||
#
|
#
|
||||||
# systemd is free software; you can redistribute it and/or modify it
|
# systemd is free software; you can redistribute it and/or modify it under the
|
||||||
# under the terms of the GNU Lesser General Public License as published by
|
# terms of the GNU Lesser General Public License as published by the Free
|
||||||
# the Free Software Foundation; either version 2.1 of the License, or
|
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||||
# (at your option) any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# You can override the directives in this file by creating files in
|
# Entries in this file show the compile time defaults. Local configuration
|
||||||
# /etc/systemd/user.conf.d/*.conf.
|
# should be created by either modifying this file, or by creating "drop-ins" in
|
||||||
|
# the system.conf.d/ subdirectory. The latter is generally recommended.
|
||||||
|
# Defaults can be restored by simply deleting this file and all drop-ins.
|
||||||
#
|
#
|
||||||
# See systemd-user.conf(5) for details
|
# See systemd-user.conf(5) for details.
|
||||||
|
|
||||||
[Manager]
|
[Manager]
|
||||||
#LogLevel=info
|
#LogLevel=info
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
# This file is part of systemd.
|
# This file is part of systemd.
|
||||||
#
|
#
|
||||||
# systemd is free software; you can redistribute it and/or modify it
|
# systemd is free software; you can redistribute it and/or modify it under the
|
||||||
# under the terms of the GNU Lesser General Public License as published by
|
# terms of the GNU Lesser General Public License as published by the Free
|
||||||
# the Free Software Foundation; either version 2.1 of the License, or
|
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||||
# (at your option) any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# Entries in this file show the compile time defaults.
|
# Entries in this file show the compile time defaults. Local configuration
|
||||||
# You can change settings by editing this file.
|
# should be created by either modifying this file, or by creating "drop-ins" in
|
||||||
# Defaults can be restored by simply deleting this file.
|
# the system.conf.d/ subdirectory. The latter is generally recommended.
|
||||||
|
# Defaults can be restored by simply deleting this file and all drop-ins.
|
||||||
#
|
#
|
||||||
# See coredump.conf(5) for details.
|
# See coredump.conf(5) for details.
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "parse-argument.h"
|
#include "parse-argument.h"
|
||||||
#include "parse-util.h"
|
#include "parse-util.h"
|
||||||
#include "path-util.h"
|
#include "path-util.h"
|
||||||
|
#include "percent-util.h"
|
||||||
#include "pkcs11-util.h"
|
#include "pkcs11-util.h"
|
||||||
#include "pretty-print.h"
|
#include "pretty-print.h"
|
||||||
#include "process-util.h"
|
#include "process-util.h"
|
||||||
@ -1567,7 +1568,7 @@ static int resize_home(int argc, char *argv[], void *userdata) {
|
|||||||
(void) polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
(void) polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||||
|
|
||||||
if (arg_disk_size_relative != UINT64_MAX ||
|
if (arg_disk_size_relative != UINT64_MAX ||
|
||||||
(argc > 2 && parse_percent(argv[2]) >= 0))
|
(argc > 2 && parse_permyriad(argv[2]) >= 0))
|
||||||
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
|
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
|
||||||
"Relative disk size specification currently not supported when resizing.");
|
"Relative disk size specification currently not supported when resizing.");
|
||||||
|
|
||||||
@ -2653,7 +2654,7 @@ static int parse_argv(int argc, char *argv[]) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = parse_permille(optarg);
|
r = parse_permyriad(optarg);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
r = parse_size(optarg, 1024, &arg_disk_size);
|
r = parse_size(optarg, 1024, &arg_disk_size);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
@ -2670,7 +2671,7 @@ static int parse_argv(int argc, char *argv[]) {
|
|||||||
arg_disk_size_relative = UINT64_MAX;
|
arg_disk_size_relative = UINT64_MAX;
|
||||||
} else {
|
} else {
|
||||||
/* Normalize to UINT32_MAX == 100% */
|
/* Normalize to UINT32_MAX == 100% */
|
||||||
arg_disk_size_relative = (uint64_t) r * UINT32_MAX / 1000U;
|
arg_disk_size_relative = UINT32_SCALE_FROM_PERMYRIAD(r);
|
||||||
|
|
||||||
r = drop_from_identity("diskSize");
|
r = drop_from_identity("diskSize");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
# This file is part of systemd.
|
# This file is part of systemd.
|
||||||
#
|
#
|
||||||
# systemd is free software; you can redistribute it and/or modify it
|
# systemd is free software; you can redistribute it and/or modify it under the
|
||||||
# under the terms of the GNU Lesser General Public License as published by
|
# terms of the GNU Lesser General Public License as published by the Free
|
||||||
# the Free Software Foundation; either version 2.1 of the License, or
|
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||||
# (at your option) any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# Entries in this file show the compile time defaults.
|
# Entries in this file show the compile time defaults. Local configuration
|
||||||
# You can change settings by editing this file.
|
# should be created by either modifying this file, or by creating "drop-ins" in
|
||||||
# Defaults can be restored by simply deleting this file.
|
# the system.conf.d/ subdirectory. The latter is generally recommended.
|
||||||
|
# Defaults can be restored by simply deleting this file and all drop-ins.
|
||||||
#
|
#
|
||||||
# See homed.conf(5) for details
|
# See homed.conf(5) for details.
|
||||||
|
|
||||||
[Home]
|
[Home]
|
||||||
#DefaultStorage=
|
#DefaultStorage=
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "mkdir.h"
|
#include "mkdir.h"
|
||||||
#include "parse-util.h"
|
#include "parse-util.h"
|
||||||
#include "path-util.h"
|
#include "path-util.h"
|
||||||
|
#include "percent-util.h"
|
||||||
#include "process-util.h"
|
#include "process-util.h"
|
||||||
#include "service-util.h"
|
#include "service-util.h"
|
||||||
#include "signal-util.h"
|
#include "signal-util.h"
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
# This file is part of systemd.
|
# This file is part of systemd.
|
||||||
#
|
#
|
||||||
# systemd is free software; you can redistribute it and/or modify it
|
# systemd is free software; you can redistribute it and/or modify it under the
|
||||||
# under the terms of the GNU Lesser General Public License as published by
|
# terms of the GNU Lesser General Public License as published by the Free
|
||||||
# the Free Software Foundation; either version 2.1 of the License, or
|
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||||
# (at your option) any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# Entries in this file show the compile time defaults.
|
# Entries in this file show the compile time defaults. Local configuration
|
||||||
# You can change settings by editing this file.
|
# should be created by either modifying this file, or by creating "drop-ins" in
|
||||||
# Defaults can be restored by simply deleting this file.
|
# the system.conf.d/ subdirectory. The latter is generally recommended.
|
||||||
|
# Defaults can be restored by simply deleting this file and all drop-ins.
|
||||||
#
|
#
|
||||||
# See journal-remote.conf(5) for details
|
# See journal-remote.conf(5) for details.
|
||||||
|
|
||||||
[Remote]
|
[Remote]
|
||||||
# Seal=false
|
# Seal=false
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
# This file is part of systemd.
|
# This file is part of systemd.
|
||||||
#
|
#
|
||||||
# systemd is free software; you can redistribute it and/or modify it
|
# systemd is free software; you can redistribute it and/or modify it under the
|
||||||
# under the terms of the GNU Lesser General Public License as published by
|
# terms of the GNU Lesser General Public License as published by the Free
|
||||||
# the Free Software Foundation; either version 2.1 of the License, or
|
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||||
# (at your option) any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# Entries in this file show the compile time defaults.
|
# Entries in this file show the compile time defaults. Local configuration
|
||||||
# You can change settings by editing this file.
|
# should be created by either modifying this file, or by creating "drop-ins" in
|
||||||
# Defaults can be restored by simply deleting this file.
|
# the system.conf.d/ subdirectory. The latter is generally recommended.
|
||||||
|
# Defaults can be restored by simply deleting this file and all drop-ins.
|
||||||
#
|
#
|
||||||
# See journal-upload.conf(5) for details
|
# See journal-upload.conf(5) for details.
|
||||||
|
|
||||||
[Upload]
|
[Upload]
|
||||||
# URL=
|
# URL=
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
# This file is part of systemd.
|
# This file is part of systemd.
|
||||||
#
|
#
|
||||||
# systemd is free software; you can redistribute it and/or modify it
|
# systemd is free software; you can redistribute it and/or modify it under the
|
||||||
# under the terms of the GNU Lesser General Public License as published by
|
# terms of the GNU Lesser General Public License as published by the Free
|
||||||
# the Free Software Foundation; either version 2.1 of the License, or
|
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||||
# (at your option) any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# Entries in this file show the compile time defaults.
|
# Entries in this file show the compile time defaults. Local configuration
|
||||||
# You can change settings by editing this file.
|
# should be created by either modifying this file, or by creating "drop-ins" in
|
||||||
# Defaults can be restored by simply deleting this file.
|
# the system.conf.d/ subdirectory. The latter is generally recommended.
|
||||||
|
# Defaults can be restored by simply deleting this file and all drop-ins.
|
||||||
#
|
#
|
||||||
# See journald.conf(5) for details.
|
# See journald.conf(5) for details.
|
||||||
|
|
||||||
|
@ -19,11 +19,12 @@
|
|||||||
#include "label.h"
|
#include "label.h"
|
||||||
#include "limits-util.h"
|
#include "limits-util.h"
|
||||||
#include "logind-dbus.h"
|
#include "logind-dbus.h"
|
||||||
#include "logind-user.h"
|
|
||||||
#include "logind-user-dbus.h"
|
#include "logind-user-dbus.h"
|
||||||
|
#include "logind-user.h"
|
||||||
#include "mkdir.h"
|
#include "mkdir.h"
|
||||||
#include "parse-util.h"
|
#include "parse-util.h"
|
||||||
#include "path-util.h"
|
#include "path-util.h"
|
||||||
|
#include "percent-util.h"
|
||||||
#include "rm-rf.h"
|
#include "rm-rf.h"
|
||||||
#include "serialize.h"
|
#include "serialize.h"
|
||||||
#include "special.h"
|
#include "special.h"
|
||||||
@ -907,9 +908,9 @@ int config_parse_tmpfs_size(
|
|||||||
assert(data);
|
assert(data);
|
||||||
|
|
||||||
/* First, try to parse as percentage */
|
/* First, try to parse as percentage */
|
||||||
r = parse_permille(rvalue);
|
r = parse_permyriad(rvalue);
|
||||||
if (r > 0 && r < 1000)
|
if (r > 0)
|
||||||
*sz = physical_memory_scale(r, 1000U);
|
*sz = physical_memory_scale(r, 10000U);
|
||||||
else {
|
else {
|
||||||
uint64_t k;
|
uint64_t k;
|
||||||
|
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
# This file is part of systemd.
|
# This file is part of systemd.
|
||||||
#
|
#
|
||||||
# systemd is free software; you can redistribute it and/or modify it
|
# systemd is free software; you can redistribute it and/or modify it under the
|
||||||
# under the terms of the GNU Lesser General Public License as published by
|
# terms of the GNU Lesser General Public License as published by the Free
|
||||||
# the Free Software Foundation; either version 2.1 of the License, or
|
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||||
# (at your option) any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# Entries in this file show the compile time defaults.
|
# Entries in this file show the compile time defaults. Local configuration
|
||||||
# You can change settings by editing this file.
|
# should be created by either modifying this file, or by creating "drop-ins" in
|
||||||
# Defaults can be restored by simply deleting this file.
|
# the system.conf.d/ subdirectory. The latter is generally recommended.
|
||||||
|
# Defaults can be restored by simply deleting this file and all drop-ins.
|
||||||
#
|
#
|
||||||
# See logind.conf(5) for details.
|
# See logind.conf(5) for details.
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include "pam-util.h"
|
#include "pam-util.h"
|
||||||
#include "parse-util.h"
|
#include "parse-util.h"
|
||||||
#include "path-util.h"
|
#include "path-util.h"
|
||||||
|
#include "percent-util.h"
|
||||||
#include "process-util.h"
|
#include "process-util.h"
|
||||||
#include "rlimit-util.h"
|
#include "rlimit-util.h"
|
||||||
#include "socket-util.h"
|
#include "socket-util.h"
|
||||||
@ -334,9 +335,9 @@ static int append_session_memory_max(pam_handle_t *handle, sd_bus_message *m, co
|
|||||||
return PAM_SUCCESS;
|
return PAM_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = parse_permille(limit);
|
r = parse_permyriad(limit);
|
||||||
if (r >= 0) {
|
if (r >= 0) {
|
||||||
r = sd_bus_message_append(m, "(sv)", "MemoryMaxScale", "u", (uint32_t) (((uint64_t) r * UINT32_MAX) / 1000U));
|
r = sd_bus_message_append(m, "(sv)", "MemoryMaxScale", "u", UINT32_SCALE_FROM_PERMYRIAD(r));
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return pam_bus_log_create_error(handle, r);
|
return pam_bus_log_create_error(handle, r);
|
||||||
|
|
||||||
|
@ -217,7 +217,44 @@ static int nexthop_add(Link *link, const NextHop *in, NextHop **ret) {
|
|||||||
return is_new;
|
return is_new;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void log_nexthop_debug(const NextHop *nexthop, const char *str, const Link *link) {
|
static int nexthop_update(Link *link, NextHop *nexthop, const NextHop *in) {
|
||||||
|
int r;
|
||||||
|
|
||||||
|
assert(link);
|
||||||
|
assert(nexthop);
|
||||||
|
assert(in);
|
||||||
|
assert(in->id > 0);
|
||||||
|
|
||||||
|
/* Currently, this only updates ID. */
|
||||||
|
|
||||||
|
if (nexthop->id > 0)
|
||||||
|
return nexthop->id == in->id ? 0 : -EINVAL;
|
||||||
|
|
||||||
|
nexthop = set_remove(link->nexthops, nexthop);
|
||||||
|
if (!nexthop)
|
||||||
|
return -ENOENT;
|
||||||
|
|
||||||
|
nexthop->id = in->id;
|
||||||
|
|
||||||
|
r = set_put(link->nexthops, nexthop);
|
||||||
|
if (r <= 0) {
|
||||||
|
int k;
|
||||||
|
|
||||||
|
/* On failure, revert the change. */
|
||||||
|
nexthop->id = 0;
|
||||||
|
k = set_put(link->nexthops, nexthop);
|
||||||
|
if (k <= 0) {
|
||||||
|
nexthop_free(nexthop);
|
||||||
|
return k < 0 ? k : -EEXIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
return r < 0 ? r : -EEXIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void log_nexthop_debug(const NextHop *nexthop, uint32_t id, const char *str, const Link *link) {
|
||||||
assert(nexthop);
|
assert(nexthop);
|
||||||
assert(str);
|
assert(str);
|
||||||
assert(link);
|
assert(link);
|
||||||
@ -227,8 +264,12 @@ static void log_nexthop_debug(const NextHop *nexthop, const char *str, const Lin
|
|||||||
|
|
||||||
(void) in_addr_to_string(nexthop->family, &nexthop->gw, &gw);
|
(void) in_addr_to_string(nexthop->family, &nexthop->gw, &gw);
|
||||||
|
|
||||||
log_link_debug(link, "%s nexthop: id: %"PRIu32", gw: %s",
|
if (nexthop->id == id)
|
||||||
str, nexthop->id, strna(gw));
|
log_link_debug(link, "%s nexthop: id: %"PRIu32", gw: %s",
|
||||||
|
str, nexthop->id, strna(gw));
|
||||||
|
else
|
||||||
|
log_link_debug(link, "%s nexthop: id: %"PRIu32"→%"PRIu32", gw: %s",
|
||||||
|
str, nexthop->id, id, strna(gw));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,9 +292,12 @@ static int nexthop_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (link->nexthop_messages == 0) {
|
if (link->nexthop_messages == 0) {
|
||||||
log_link_debug(link, "Nexthop set");
|
log_link_debug(link, "Nexthops set");
|
||||||
link->static_nexthops_configured = true;
|
link->static_nexthops_configured = true;
|
||||||
link_check_ready(link);
|
/* Now all nexthops are configured. Let's configure remaining routes. */
|
||||||
|
r = link_set_routes_with_gateway(link);
|
||||||
|
if (r < 0)
|
||||||
|
link_enter_failed(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -269,7 +313,7 @@ static int nexthop_configure(const NextHop *nexthop, Link *link) {
|
|||||||
assert(link->ifindex > 0);
|
assert(link->ifindex > 0);
|
||||||
assert(IN_SET(nexthop->family, AF_INET, AF_INET6));
|
assert(IN_SET(nexthop->family, AF_INET, AF_INET6));
|
||||||
|
|
||||||
log_nexthop_debug(nexthop, "Configuring", link);
|
log_nexthop_debug(nexthop, nexthop->id, "Configuring", link);
|
||||||
|
|
||||||
r = sd_rtnl_message_new_nexthop(link->manager->rtnl, &req,
|
r = sd_rtnl_message_new_nexthop(link->manager->rtnl, &req,
|
||||||
RTM_NEWNEXTHOP, nexthop->family,
|
RTM_NEWNEXTHOP, nexthop->family,
|
||||||
@ -307,7 +351,7 @@ static int nexthop_configure(const NextHop *nexthop, Link *link) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
int link_set_nexthop(Link *link) {
|
int link_set_nexthops(Link *link) {
|
||||||
enum {
|
enum {
|
||||||
PHASE_ID, /* First phase: Nexthops with ID */
|
PHASE_ID, /* First phase: Nexthops with ID */
|
||||||
PHASE_WITHOUT_ID, /* Second phase: Nexthops without ID */
|
PHASE_WITHOUT_ID, /* Second phase: Nexthops without ID */
|
||||||
@ -340,13 +384,14 @@ int link_set_nexthop(Link *link) {
|
|||||||
|
|
||||||
if (link->nexthop_messages == 0) {
|
if (link->nexthop_messages == 0) {
|
||||||
link->static_nexthops_configured = true;
|
link->static_nexthops_configured = true;
|
||||||
link_check_ready(link);
|
/* Finaly, configure routes with gateways. */
|
||||||
} else {
|
return link_set_routes_with_gateway(link);
|
||||||
log_link_debug(link, "Setting nexthop");
|
|
||||||
link_set_state(link, LINK_STATE_CONFIGURING);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
log_link_debug(link, "Setting nexthops");
|
||||||
|
link_set_state(link, LINK_STATE_CONFIGURING);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int manager_rtnl_process_nexthop(sd_netlink *rtnl, sd_netlink_message *message, Manager *m) {
|
int manager_rtnl_process_nexthop(sd_netlink *rtnl, sd_netlink_message *message, Manager *m) {
|
||||||
@ -426,23 +471,41 @@ int manager_rtnl_process_nexthop(sd_netlink *rtnl, sd_netlink_message *message,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
(void) nexthop_get(link, tmp, &nexthop);
|
r = nexthop_get(link, tmp, &nexthop);
|
||||||
|
if (r < 0) {
|
||||||
|
uint32_t id;
|
||||||
|
|
||||||
|
/* The nexthop may be created without setting NHA_ID. */
|
||||||
|
|
||||||
|
id = tmp->id;
|
||||||
|
tmp->id = 0;
|
||||||
|
|
||||||
|
(void) nexthop_get(link, tmp, &nexthop);
|
||||||
|
|
||||||
|
tmp->id = id;
|
||||||
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case RTM_NEWNEXTHOP:
|
case RTM_NEWNEXTHOP:
|
||||||
if (nexthop)
|
if (nexthop)
|
||||||
log_nexthop_debug(tmp, "Received remembered", link);
|
log_nexthop_debug(nexthop, tmp->id, "Received remembered", link);
|
||||||
else {
|
else {
|
||||||
log_nexthop_debug(tmp, "Remembering foreign", link);
|
log_nexthop_debug(tmp, tmp->id, "Remembering foreign", link);
|
||||||
r = nexthop_add_foreign(link, tmp, &nexthop);
|
r = nexthop_add_foreign(link, tmp, &nexthop);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
log_link_warning_errno(link, r, "Could not remember foreign nexthop, ignoring: %m");
|
log_link_warning_errno(link, r, "Could not remember foreign nexthop, ignoring: %m");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r = nexthop_update(link, nexthop, tmp);
|
||||||
|
if (r < 0) {
|
||||||
|
log_link_warning_errno(link, r, "Could not update nexthop, ignoring: %m");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case RTM_DELNEXTHOP:
|
case RTM_DELNEXTHOP:
|
||||||
log_nexthop_debug(tmp, nexthop ? "Forgetting" : "Kernel removed unknown", link);
|
log_nexthop_debug(tmp, tmp->id, nexthop ? "Forgetting" : "Kernel removed unknown", link);
|
||||||
nexthop_free(nexthop);
|
nexthop_free(nexthop);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ NextHop *nexthop_free(NextHop *nexthop);
|
|||||||
|
|
||||||
void network_drop_invalid_nexthops(Network *network);
|
void network_drop_invalid_nexthops(Network *network);
|
||||||
|
|
||||||
int link_set_nexthop(Link *link);
|
int link_set_nexthops(Link *link);
|
||||||
|
|
||||||
int manager_rtnl_process_nexthop(sd_netlink *rtnl, sd_netlink_message *message, Manager *m);
|
int manager_rtnl_process_nexthop(sd_netlink *rtnl, sd_netlink_message *message, Manager *m);
|
||||||
|
|
||||||
|
@ -1193,7 +1193,7 @@ int route_configure(
|
|||||||
return k;
|
return k;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int route_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
static int route_handler_with_gateway(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(link);
|
assert(link);
|
||||||
@ -1206,29 +1206,115 @@ static int route_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
|||||||
|
|
||||||
r = sd_netlink_message_get_errno(m);
|
r = sd_netlink_message_get_errno(m);
|
||||||
if (r < 0 && r != -EEXIST) {
|
if (r < 0 && r != -EEXIST) {
|
||||||
log_link_message_warning_errno(link, m, r, "Could not set route");
|
log_link_message_warning_errno(link, m, r, "Could not set route with gateway");
|
||||||
link_enter_failed(link);
|
link_enter_failed(link);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (link->route_messages == 0) {
|
if (link->route_messages == 0) {
|
||||||
log_link_debug(link, "Routes set");
|
log_link_debug(link, "Routes with gateway set");
|
||||||
link->static_routes_configured = true;
|
link->static_routes_configured = true;
|
||||||
link_set_nexthop(link);
|
link_check_ready(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int link_set_routes(Link *link) {
|
static int route_handler_without_gateway(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||||
enum {
|
int r;
|
||||||
PHASE_NON_GATEWAY, /* First phase: Routes without a gateway */
|
|
||||||
PHASE_GATEWAY, /* Second phase: Routes with a gateway */
|
assert(link);
|
||||||
_PHASE_MAX
|
assert(link->route_messages > 0);
|
||||||
} phase;
|
|
||||||
|
link->route_messages--;
|
||||||
|
|
||||||
|
if (IN_SET(link->state, LINK_STATE_FAILED, LINK_STATE_LINGER))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
r = sd_netlink_message_get_errno(m);
|
||||||
|
if (r < 0 && r != -EEXIST) {
|
||||||
|
log_link_message_warning_errno(link, m, r, "Could not set route without gateway");
|
||||||
|
link_enter_failed(link);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (link->route_messages == 0) {
|
||||||
|
log_link_debug(link, "Routes set without gateway");
|
||||||
|
/* Now, we can talk to gateways, let's configure nexthops. */
|
||||||
|
r = link_set_nexthops(link);
|
||||||
|
if (r < 0)
|
||||||
|
link_enter_failed(link);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool route_has_gateway(const Route *route) {
|
||||||
|
assert(route);
|
||||||
|
|
||||||
|
if (in_addr_is_set(route->gw_family, &route->gw))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (!ordered_set_isempty(route->multipath_routes))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int link_set_routes_internal(Link *link, bool with_gateway) {
|
||||||
Route *rt;
|
Route *rt;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
assert(link);
|
||||||
|
assert(link->network);
|
||||||
|
|
||||||
|
HASHMAP_FOREACH(rt, link->network->routes_by_section) {
|
||||||
|
if (rt->gateway_from_dhcp_or_ra)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (route_has_gateway(rt) != with_gateway)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
r = route_configure(rt, link, with_gateway ? route_handler_with_gateway : route_handler_without_gateway, NULL);
|
||||||
|
if (r < 0)
|
||||||
|
return log_link_warning_errno(link, r, "Could not set routes: %m");
|
||||||
|
|
||||||
|
link->route_messages++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int link_set_routes_with_gateway(Link *link) {
|
||||||
|
int r;
|
||||||
|
|
||||||
|
assert(link);
|
||||||
|
assert(link->network);
|
||||||
|
|
||||||
|
if (!link_has_carrier(link) && !link->network->configure_without_carrier)
|
||||||
|
/* During configuring addresses, the link lost its carrier. As networkd is dropping
|
||||||
|
* the addresses now, let's not configure the routes either. */
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Finaly, add routes that needs a gateway. */
|
||||||
|
r = link_set_routes_internal(link, true);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
if (link->route_messages == 0) {
|
||||||
|
link->static_routes_configured = true;
|
||||||
|
link_check_ready(link);
|
||||||
|
} else {
|
||||||
|
log_link_debug(link, "Setting routes with gateway");
|
||||||
|
link_set_state(link, LINK_STATE_CONFIGURING);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int link_set_routes(Link *link) {
|
||||||
|
int r;
|
||||||
|
|
||||||
assert(link);
|
assert(link);
|
||||||
assert(link->network);
|
assert(link->network);
|
||||||
assert(link->state != _LINK_STATE_INVALID);
|
assert(link->state != _LINK_STATE_INVALID);
|
||||||
@ -1252,29 +1338,17 @@ int link_set_routes(Link *link) {
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
/* First add the routes that enable us to talk to gateways, then add in the others that need a gateway. */
|
/* First, add the routes that enable us to talk to gateways. */
|
||||||
for (phase = 0; phase < _PHASE_MAX; phase++)
|
r = link_set_routes_internal(link, false);
|
||||||
HASHMAP_FOREACH(rt, link->network->routes_by_section) {
|
if (r < 0)
|
||||||
if (rt->gateway_from_dhcp_or_ra)
|
return r;
|
||||||
continue;
|
|
||||||
|
|
||||||
if ((!in_addr_is_set(rt->gw_family, &rt->gw) && ordered_set_isempty(rt->multipath_routes)) != (phase == PHASE_NON_GATEWAY))
|
if (link->route_messages == 0)
|
||||||
continue;
|
/* If no route is configured, then configure nexthops. */
|
||||||
|
return link_set_nexthops(link);
|
||||||
|
|
||||||
r = route_configure(rt, link, route_handler, NULL);
|
log_link_debug(link, "Setting routes without gateway");
|
||||||
if (r < 0)
|
link_set_state(link, LINK_STATE_CONFIGURING);
|
||||||
return log_link_warning_errno(link, r, "Could not set routes: %m");
|
|
||||||
|
|
||||||
link->route_messages++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (link->route_messages == 0) {
|
|
||||||
link->static_routes_configured = true;
|
|
||||||
link_set_nexthop(link);
|
|
||||||
} else {
|
|
||||||
log_link_debug(link, "Setting routes");
|
|
||||||
link_set_state(link, LINK_STATE_CONFIGURING);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,7 @@ int route_configure(const Route *route, Link *link, link_netlink_message_handler
|
|||||||
int route_remove(const Route *route, Manager *manager, Link *link, link_netlink_message_handler_t callback);
|
int route_remove(const Route *route, Manager *manager, Link *link, link_netlink_message_handler_t callback);
|
||||||
|
|
||||||
int link_set_routes(Link *link);
|
int link_set_routes(Link *link);
|
||||||
|
int link_set_routes_with_gateway(Link *link);
|
||||||
int link_drop_routes(Link *link);
|
int link_drop_routes(Link *link);
|
||||||
int link_drop_foreign_routes(Link *link);
|
int link_drop_foreign_routes(Link *link);
|
||||||
|
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
# This file is part of systemd.
|
# This file is part of systemd.
|
||||||
#
|
#
|
||||||
# systemd is free software; you can redistribute it and/or modify it
|
# systemd is free software; you can redistribute it and/or modify it under the
|
||||||
# under the terms of the GNU Lesser General Public License as published by
|
# terms of the GNU Lesser General Public License as published by the Free
|
||||||
# the Free Software Foundation; either version 2.1 of the License, or
|
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||||
# (at your option) any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# Entries in this file show the compile time defaults.
|
# Entries in this file show the compile time defaults. Local configuration
|
||||||
# You can change settings by editing this file.
|
# should be created by either modifying this file, or by creating "drop-ins" in
|
||||||
# Defaults can be restored by simply deleting this file.
|
# the system.conf.d/ subdirectory. The latter is generally recommended.
|
||||||
|
# Defaults can be restored by simply deleting this file and all drop-ins.
|
||||||
#
|
#
|
||||||
# See networkd.conf(5) for details
|
# See networkd.conf(5) for details.
|
||||||
|
|
||||||
[Network]
|
[Network]
|
||||||
#SpeedMeter=no
|
#SpeedMeter=no
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "extract-word.h"
|
#include "extract-word.h"
|
||||||
#include "fileio.h"
|
#include "fileio.h"
|
||||||
#include "parse-util.h"
|
#include "parse-util.h"
|
||||||
|
#include "percent-util.h"
|
||||||
#include "tc-util.h"
|
#include "tc-util.h"
|
||||||
#include "time-util.h"
|
#include "time-util.h"
|
||||||
|
|
||||||
@ -57,17 +58,17 @@ int tc_time_to_tick(usec_t t, uint32_t *ret) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int parse_tc_percent(const char *s, uint32_t *percent) {
|
int parse_tc_percent(const char *s, uint32_t *ret_fraction) {
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(s);
|
assert(s);
|
||||||
assert(percent);
|
assert(ret_fraction);
|
||||||
|
|
||||||
r = parse_permille(s);
|
r = parse_permyriad(s);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
*percent = (double) r / 1000 * UINT32_MAX;
|
*ret_fraction = (double) r / 10000 * UINT32_MAX;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,12 +10,13 @@
|
|||||||
#include "oomd-manager-bus.h"
|
#include "oomd-manager-bus.h"
|
||||||
#include "oomd-manager.h"
|
#include "oomd-manager.h"
|
||||||
#include "path-util.h"
|
#include "path-util.h"
|
||||||
|
#include "percent-util.h"
|
||||||
|
|
||||||
typedef struct ManagedOOMReply {
|
typedef struct ManagedOOMReply {
|
||||||
ManagedOOMMode mode;
|
ManagedOOMMode mode;
|
||||||
char *path;
|
char *path;
|
||||||
char *property;
|
char *property;
|
||||||
unsigned limit;
|
uint32_t limit;
|
||||||
} ManagedOOMReply;
|
} ManagedOOMReply;
|
||||||
|
|
||||||
static void managed_oom_reply_destroy(ManagedOOMReply *reply) {
|
static void managed_oom_reply_destroy(ManagedOOMReply *reply) {
|
||||||
@ -52,10 +53,10 @@ static int process_managed_oom_reply(
|
|||||||
assert(m);
|
assert(m);
|
||||||
|
|
||||||
static const JsonDispatch dispatch_table[] = {
|
static const JsonDispatch dispatch_table[] = {
|
||||||
{ "mode", JSON_VARIANT_STRING, managed_oom_mode, offsetof(ManagedOOMReply, mode), JSON_MANDATORY },
|
{ "mode", JSON_VARIANT_STRING, managed_oom_mode, offsetof(ManagedOOMReply, mode), JSON_MANDATORY },
|
||||||
{ "path", JSON_VARIANT_STRING, json_dispatch_string, offsetof(ManagedOOMReply, path), JSON_MANDATORY },
|
{ "path", JSON_VARIANT_STRING, json_dispatch_string, offsetof(ManagedOOMReply, path), JSON_MANDATORY },
|
||||||
{ "property", JSON_VARIANT_STRING, json_dispatch_string, offsetof(ManagedOOMReply, property), JSON_MANDATORY },
|
{ "property", JSON_VARIANT_STRING, json_dispatch_string, offsetof(ManagedOOMReply, property), JSON_MANDATORY },
|
||||||
{ "limit", JSON_VARIANT_UNSIGNED, json_dispatch_unsigned, offsetof(ManagedOOMReply, limit), 0 },
|
{ "limit", JSON_VARIANT_UNSIGNED, json_dispatch_uint32, offsetof(ManagedOOMReply, limit), 0 },
|
||||||
{},
|
{},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -86,7 +87,8 @@ static int process_managed_oom_reply(
|
|||||||
if (ret == -ENOMEM) {
|
if (ret == -ENOMEM) {
|
||||||
r = ret;
|
r = ret;
|
||||||
goto finish;
|
goto finish;
|
||||||
} else if (ret < 0)
|
}
|
||||||
|
if (ret < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
monitor_hm = streq(reply.property, "ManagedOOMSwap") ?
|
monitor_hm = streq(reply.property, "ManagedOOMSwap") ?
|
||||||
@ -99,14 +101,15 @@ static int process_managed_oom_reply(
|
|||||||
|
|
||||||
limit = m->default_mem_pressure_limit;
|
limit = m->default_mem_pressure_limit;
|
||||||
|
|
||||||
if (streq(reply.property, "ManagedOOMMemoryPressure")) {
|
if (streq(reply.property, "ManagedOOMMemoryPressure") && reply.limit > 0) {
|
||||||
if (reply.limit > 10000)
|
int permyriad = UINT32_SCALE_TO_PERMYRIAD(reply.limit);
|
||||||
|
|
||||||
|
ret = store_loadavg_fixed_point(
|
||||||
|
(unsigned long) permyriad / 100,
|
||||||
|
(unsigned long) permyriad % 100,
|
||||||
|
&limit);
|
||||||
|
if (ret < 0)
|
||||||
continue;
|
continue;
|
||||||
else if (reply.limit != 0) {
|
|
||||||
ret = store_loadavg_fixed_point((unsigned long) reply.limit / 100, (unsigned long) reply.limit % 100, &limit);
|
|
||||||
if (ret < 0)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = oomd_insert_cgroup_context(NULL, monitor_hm, empty_to_root(reply.path));
|
ret = oomd_insert_cgroup_context(NULL, monitor_hm, empty_to_root(reply.path));
|
||||||
@ -348,11 +351,11 @@ static int monitor_cgroup_contexts_handler(sd_event_source *s, uint64_t usec, vo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oomd_swap_free_below(&m->system_context, (100 - m->swap_used_limit))) {
|
if (oomd_swap_free_below(&m->system_context, 10000 - m->swap_used_limit_permyriad)) {
|
||||||
_cleanup_hashmap_free_ Hashmap *candidates = NULL;
|
_cleanup_hashmap_free_ Hashmap *candidates = NULL;
|
||||||
|
|
||||||
log_notice("Swap used (%"PRIu64") / total (%"PRIu64") is more than %u%%",
|
log_notice("Swap used (%"PRIu64") / total (%"PRIu64") is more than " PERMYRIAD_AS_PERCENT_FORMAT_STR,
|
||||||
m->system_context.swap_used, m->system_context.swap_total, m->swap_used_limit);
|
m->system_context.swap_used, m->system_context.swap_total, PERMYRIAD_AS_PERCENT_FORMAT_VAL(m->swap_used_limit_permyriad));
|
||||||
|
|
||||||
r = get_monitored_cgroup_contexts_candidates(m->monitored_swap_cgroup_contexts, &candidates);
|
r = get_monitored_cgroup_contexts_candidates(m->monitored_swap_cgroup_contexts, &candidates);
|
||||||
if (r == -ENOMEM)
|
if (r == -ENOMEM)
|
||||||
@ -478,7 +481,13 @@ static int manager_connect_bus(Manager *m) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int manager_start(Manager *m, bool dry_run, int swap_used_limit, int mem_pressure_limit_permyriad, usec_t mem_pressure_usec) {
|
int manager_start(
|
||||||
|
Manager *m,
|
||||||
|
bool dry_run,
|
||||||
|
int swap_used_limit_permyriad,
|
||||||
|
int mem_pressure_limit_permyriad,
|
||||||
|
usec_t mem_pressure_usec) {
|
||||||
|
|
||||||
unsigned long l, f;
|
unsigned long l, f;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -486,10 +495,10 @@ int manager_start(Manager *m, bool dry_run, int swap_used_limit, int mem_pressur
|
|||||||
|
|
||||||
m->dry_run = dry_run;
|
m->dry_run = dry_run;
|
||||||
|
|
||||||
m->swap_used_limit = swap_used_limit != -1 ? swap_used_limit : DEFAULT_SWAP_USED_LIMIT;
|
m->swap_used_limit_permyriad = swap_used_limit_permyriad >= 0 ? swap_used_limit_permyriad : DEFAULT_SWAP_USED_LIMIT_PERCENT * 100;
|
||||||
assert(m->swap_used_limit <= 100);
|
assert(m->swap_used_limit_permyriad <= 10000);
|
||||||
|
|
||||||
if (mem_pressure_limit_permyriad != -1) {
|
if (mem_pressure_limit_permyriad >= 0) {
|
||||||
assert(mem_pressure_limit_permyriad <= 10000);
|
assert(mem_pressure_limit_permyriad <= 10000);
|
||||||
|
|
||||||
l = mem_pressure_limit_permyriad / 100;
|
l = mem_pressure_limit_permyriad / 100;
|
||||||
@ -537,12 +546,12 @@ int manager_get_dump_string(Manager *m, char **ret) {
|
|||||||
|
|
||||||
fprintf(f,
|
fprintf(f,
|
||||||
"Dry Run: %s\n"
|
"Dry Run: %s\n"
|
||||||
"Swap Used Limit: %u%%\n"
|
"Swap Used Limit: " PERMYRIAD_AS_PERCENT_FORMAT_STR "\n"
|
||||||
"Default Memory Pressure Limit: %lu.%02lu%%\n"
|
"Default Memory Pressure Limit: %lu.%02lu%%\n"
|
||||||
"Default Memory Pressure Duration: %s\n"
|
"Default Memory Pressure Duration: %s\n"
|
||||||
"System Context:\n",
|
"System Context:\n",
|
||||||
yes_no(m->dry_run),
|
yes_no(m->dry_run),
|
||||||
m->swap_used_limit,
|
PERMYRIAD_AS_PERCENT_FORMAT_VAL(m->swap_used_limit_permyriad),
|
||||||
LOAD_INT(m->default_mem_pressure_limit), LOAD_FRAC(m->default_mem_pressure_limit),
|
LOAD_INT(m->default_mem_pressure_limit), LOAD_FRAC(m->default_mem_pressure_limit),
|
||||||
format_timespan(buf, sizeof(buf), m->default_mem_pressure_duration_usec, USEC_PER_SEC));
|
format_timespan(buf, sizeof(buf), m->default_mem_pressure_duration_usec, USEC_PER_SEC));
|
||||||
oomd_dump_system_context(&m->system_context, f, "\t");
|
oomd_dump_system_context(&m->system_context, f, "\t");
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
* system.slice are assumed to be less latency sensitive. */
|
* system.slice are assumed to be less latency sensitive. */
|
||||||
#define DEFAULT_MEM_PRESSURE_DURATION_USEC (30 * USEC_PER_SEC)
|
#define DEFAULT_MEM_PRESSURE_DURATION_USEC (30 * USEC_PER_SEC)
|
||||||
#define DEFAULT_MEM_PRESSURE_LIMIT_PERCENT 60
|
#define DEFAULT_MEM_PRESSURE_LIMIT_PERCENT 60
|
||||||
#define DEFAULT_SWAP_USED_LIMIT 90
|
#define DEFAULT_SWAP_USED_LIMIT_PERCENT 90
|
||||||
|
|
||||||
#define RECLAIM_DURATION_USEC (30 * USEC_PER_SEC)
|
#define RECLAIM_DURATION_USEC (30 * USEC_PER_SEC)
|
||||||
#define POST_ACTION_DELAY_USEC (15 * USEC_PER_SEC)
|
#define POST_ACTION_DELAY_USEC (15 * USEC_PER_SEC)
|
||||||
@ -32,7 +32,7 @@ struct Manager {
|
|||||||
Hashmap *polkit_registry;
|
Hashmap *polkit_registry;
|
||||||
|
|
||||||
bool dry_run;
|
bool dry_run;
|
||||||
unsigned swap_used_limit;
|
int swap_used_limit_permyriad;
|
||||||
loadavg_t default_mem_pressure_limit;
|
loadavg_t default_mem_pressure_limit;
|
||||||
usec_t default_mem_pressure_duration_usec;
|
usec_t default_mem_pressure_duration_usec;
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
|
|||||||
|
|
||||||
int manager_new(Manager **ret);
|
int manager_new(Manager **ret);
|
||||||
|
|
||||||
int manager_start(Manager *m, bool dry_run, int swap_used_limit, int mem_pressure_limit_permyriad, usec_t mem_pressure_usec);
|
int manager_start(Manager *m, bool dry_run, int swap_used_limit_permyriad, int mem_pressure_limit_permyriad, usec_t mem_pressure_usec);
|
||||||
|
|
||||||
int manager_get_dump_string(Manager *m, char **ret);
|
int manager_get_dump_string(Manager *m, char **ret);
|
||||||
|
|
||||||
|
@ -134,13 +134,13 @@ bool oomd_memory_reclaim(Hashmap *h) {
|
|||||||
return pgscan_of > last_pgscan_of;
|
return pgscan_of > last_pgscan_of;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool oomd_swap_free_below(const OomdSystemContext *ctx, uint64_t threshold_percent) {
|
bool oomd_swap_free_below(const OomdSystemContext *ctx, int threshold_permyriad) {
|
||||||
uint64_t swap_threshold;
|
uint64_t swap_threshold;
|
||||||
|
|
||||||
assert(ctx);
|
assert(ctx);
|
||||||
assert(threshold_percent <= 100);
|
assert(threshold_permyriad <= 10000);
|
||||||
|
|
||||||
swap_threshold = ctx->swap_total * threshold_percent / ((uint64_t) 100);
|
swap_threshold = ctx->swap_total * threshold_permyriad / (uint64_t) 10000;
|
||||||
return (ctx->swap_total - ctx->swap_used) < swap_threshold;
|
return (ctx->swap_total - ctx->swap_used) < swap_threshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,8 +61,8 @@ int oomd_pressure_above(Hashmap *h, usec_t duration, Set **ret);
|
|||||||
* current sum is higher than the last interval's sum (there was some reclaim activity). */
|
* current sum is higher than the last interval's sum (there was some reclaim activity). */
|
||||||
bool oomd_memory_reclaim(Hashmap *h);
|
bool oomd_memory_reclaim(Hashmap *h);
|
||||||
|
|
||||||
/* Returns true if the amount of swap free is below the percentage of swap specified by `threshold_percent`. */
|
/* Returns true if the amount of swap free is below the permyriad of swap specified by `threshold_permyriad`. */
|
||||||
bool oomd_swap_free_below(const OomdSystemContext *ctx, uint64_t threshold_percent);
|
bool oomd_swap_free_below(const OomdSystemContext *ctx, int threshold_permyriad);
|
||||||
|
|
||||||
/* The compare functions will sort from largest to smallest, putting all the contexts with "avoid" at the end
|
/* The compare functions will sort from largest to smallest, putting all the contexts with "avoid" at the end
|
||||||
* (after the smallest values). */
|
* (after the smallest values). */
|
||||||
|
@ -17,13 +17,13 @@
|
|||||||
#include "signal-util.h"
|
#include "signal-util.h"
|
||||||
|
|
||||||
static bool arg_dry_run = false;
|
static bool arg_dry_run = false;
|
||||||
static int arg_swap_used_limit = -1;
|
static int arg_swap_used_limit_permyriad = -1;
|
||||||
static int arg_mem_pressure_limit_permyriad = -1;
|
static int arg_mem_pressure_limit_permyriad = -1;
|
||||||
static usec_t arg_mem_pressure_usec = 0;
|
static usec_t arg_mem_pressure_usec = 0;
|
||||||
|
|
||||||
static int parse_config(void) {
|
static int parse_config(void) {
|
||||||
static const ConfigTableItem items[] = {
|
static const ConfigTableItem items[] = {
|
||||||
{ "OOM", "SwapUsedLimitPercent", config_parse_percent, 0, &arg_swap_used_limit },
|
{ "OOM", "SwapUsedLimit", config_parse_permyriad, 0, &arg_swap_used_limit_permyriad },
|
||||||
{ "OOM", "DefaultMemoryPressureLimit", config_parse_permyriad, 0, &arg_mem_pressure_limit_permyriad },
|
{ "OOM", "DefaultMemoryPressureLimit", config_parse_permyriad, 0, &arg_mem_pressure_limit_permyriad },
|
||||||
{ "OOM", "DefaultMemoryPressureDurationSec", config_parse_sec, 0, &arg_mem_pressure_usec },
|
{ "OOM", "DefaultMemoryPressureDurationSec", config_parse_sec, 0, &arg_mem_pressure_usec },
|
||||||
{}
|
{}
|
||||||
@ -159,7 +159,12 @@ static int run(int argc, char *argv[]) {
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to create manager: %m");
|
return log_error_errno(r, "Failed to create manager: %m");
|
||||||
|
|
||||||
r = manager_start(m, arg_dry_run, arg_swap_used_limit, arg_mem_pressure_limit_permyriad, arg_mem_pressure_usec);
|
r = manager_start(
|
||||||
|
m,
|
||||||
|
arg_dry_run,
|
||||||
|
arg_swap_used_limit_permyriad,
|
||||||
|
arg_mem_pressure_limit_permyriad,
|
||||||
|
arg_mem_pressure_usec);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to start up daemon: %m");
|
return log_error_errno(r, "Failed to start up daemon: %m");
|
||||||
|
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
# This file is part of systemd.
|
# This file is part of systemd.
|
||||||
#
|
#
|
||||||
# systemd is free software; you can redistribute it and/or modify it
|
# systemd is free software; you can redistribute it and/or modify it under the
|
||||||
# under the terms of the GNU Lesser General Public License as published by
|
# terms of the GNU Lesser General Public License as published by the Free
|
||||||
# the Free Software Foundation; either version 2.1 of the License, or
|
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||||
# (at your option) any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# Entries in this file show the compile time defaults.
|
# Entries in this file show the compile time defaults. Local configuration
|
||||||
# You can change settings by editing this file.
|
# should be created by either modifying this file, or by creating "drop-ins" in
|
||||||
# Defaults can be restored by simply deleting this file.
|
# the system.conf.d/ subdirectory. The latter is generally recommended.
|
||||||
|
# Defaults can be restored by simply deleting this file and all drop-ins.
|
||||||
#
|
#
|
||||||
# See oomd.conf(5) for details
|
# See oomd.conf(5) for details
|
||||||
|
|
||||||
[OOM]
|
[OOM]
|
||||||
#SwapUsedLimitPercent=90%
|
#SwapUsedLimit=90%
|
||||||
#DefaultMemoryPressureLimit=60%
|
#DefaultMemoryPressureLimit=60%
|
||||||
#DefaultMemoryPressureDurationSec=30s
|
#DefaultMemoryPressureDurationSec=30s
|
||||||
|
@ -302,19 +302,19 @@ static void test_oomd_swap_free_below(void) {
|
|||||||
.swap_total = 20971512 * 1024U,
|
.swap_total = 20971512 * 1024U,
|
||||||
.swap_used = 20971440 * 1024U,
|
.swap_used = 20971440 * 1024U,
|
||||||
};
|
};
|
||||||
assert_se(oomd_swap_free_below(&ctx, 20) == true);
|
assert_se(oomd_swap_free_below(&ctx, 2000) == true);
|
||||||
|
|
||||||
ctx = (OomdSystemContext) {
|
ctx = (OomdSystemContext) {
|
||||||
.swap_total = 20971512 * 1024U,
|
.swap_total = 20971512 * 1024U,
|
||||||
.swap_used = 3310136 * 1024U,
|
.swap_used = 3310136 * 1024U,
|
||||||
};
|
};
|
||||||
assert_se(oomd_swap_free_below(&ctx, 20) == false);
|
assert_se(oomd_swap_free_below(&ctx, 2000) == false);
|
||||||
|
|
||||||
ctx = (OomdSystemContext) {
|
ctx = (OomdSystemContext) {
|
||||||
.swap_total = 0,
|
.swap_total = 0,
|
||||||
.swap_used = 0,
|
.swap_used = 0,
|
||||||
};
|
};
|
||||||
assert_se(oomd_swap_free_below(&ctx, 20) == false);
|
assert_se(oomd_swap_free_below(&ctx, 2000) == false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_oomd_sort_cgroups(void) {
|
static void test_oomd_sort_cgroups(void) {
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
# This file is part of systemd.
|
# This file is part of systemd.
|
||||||
#
|
#
|
||||||
# systemd is free software; you can redistribute it and/or modify it
|
# systemd is free software; you can redistribute it and/or modify it under the
|
||||||
# under the terms of the GNU Lesser General Public License as published by
|
# terms of the GNU Lesser General Public License as published by the Free
|
||||||
# the Free Software Foundation; either version 2.1 of the License, or
|
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||||
# (at your option) any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# Entries in this file show the compile time defaults.
|
# Entries in this file show the compile time defaults. Local configuration
|
||||||
# You can change settings by editing this file.
|
# should be created by either modifying this file, or by creating "drop-ins" in
|
||||||
# Defaults can be restored by simply deleting this file.
|
# the system.conf.d/ subdirectory. The latter is generally recommended.
|
||||||
|
# Defaults can be restored by simply deleting this file and all drop-ins.
|
||||||
#
|
#
|
||||||
# See pstore.conf(5) for details.
|
# See pstore.conf(5) for details.
|
||||||
|
|
||||||
|
@ -679,7 +679,7 @@ DnsScopeMatch dns_scope_good_domain(
|
|||||||
dns_name_endswith(domain, "local") > 0)
|
dns_name_endswith(domain, "local") > 0)
|
||||||
return DNS_SCOPE_NO;
|
return DNS_SCOPE_NO;
|
||||||
|
|
||||||
/* If the IP address to look up matches the local subnet, then implicity synthesizes
|
/* If the IP address to look up matches the local subnet, then implicitly synthesizes
|
||||||
* DNS_SCOPE_YES_BASE + 0 on this interface, i.e. preferably resolve IP addresses via the DNS
|
* DNS_SCOPE_YES_BASE + 0 on this interface, i.e. preferably resolve IP addresses via the DNS
|
||||||
* server belonging to this interface. */
|
* server belonging to this interface. */
|
||||||
m = match_subnet_reverse_lookups(s, domain, false);
|
m = match_subnet_reverse_lookups(s, domain, false);
|
||||||
|
@ -639,8 +639,8 @@ int dns_server_adjust_opt(DnsServer *server, DnsPacket *packet, DnsServerFeature
|
|||||||
if (server->packet_fragmented)
|
if (server->packet_fragmented)
|
||||||
packet_size = MIN(server->received_udp_fragment_max, packet_size);
|
packet_size = MIN(server->received_udp_fragment_max, packet_size);
|
||||||
|
|
||||||
/* Let's not pick ridiculously large sizes, i.e. not more than 4K. Noone appears to
|
/* Let's not pick ridiculously large sizes, i.e. not more than 4K. No one appears
|
||||||
* ever use such large sized on the Internet IRL, hence let's not either. */
|
* to ever use such large sized on the Internet IRL, hence let's not either. */
|
||||||
packet_size = MIN(packet_size, 4096U);
|
packet_size = MIN(packet_size, 4096U);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,7 +415,7 @@ static const char *nsid_string(void) {
|
|||||||
SD_ID128_MAKE(ed,d3,12,5d,16,b9,41,f9,a1,49,5f,ab,15,62,ab,27),
|
SD_ID128_MAKE(ed,d3,12,5d,16,b9,41,f9,a1,49,5f,ab,15,62,ab,27),
|
||||||
&id);
|
&id);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
log_debug_errno(r, "Failed to determine machine ID, igoring: %m");
|
log_debug_errno(r, "Failed to determine machine ID, ignoring: %m");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
# This file is part of systemd.
|
# This file is part of systemd.
|
||||||
#
|
#
|
||||||
# systemd is free software; you can redistribute it and/or modify it
|
# systemd is free software; you can redistribute it and/or modify it under the
|
||||||
# under the terms of the GNU Lesser General Public License as published by
|
# terms of the GNU Lesser General Public License as published by the Free
|
||||||
# the Free Software Foundation; either version 2.1 of the License, or
|
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||||
# (at your option) any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# Entries in this file show the compile time defaults.
|
# Entries in this file show the compile time defaults. Local configuration
|
||||||
# You can change settings by editing this file.
|
# should be created by either modifying this file, or by creating "drop-ins" in
|
||||||
# Defaults can be restored by simply deleting this file.
|
# the system.conf.d/ subdirectory. The latter is generally recommended.
|
||||||
|
# Defaults can be restored by simply deleting this file and all drop-ins.
|
||||||
#
|
#
|
||||||
# See resolved.conf(5) for details
|
# See resolved.conf(5) for details.
|
||||||
|
|
||||||
[Resolve]
|
[Resolve]
|
||||||
# Some examples of DNS servers which may be used for DNS= and FallbackDNS=:
|
# Some examples of DNS servers which may be used for DNS= and FallbackDNS=:
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "numa-util.h"
|
#include "numa-util.h"
|
||||||
#include "parse-util.h"
|
#include "parse-util.h"
|
||||||
#include "path-util.h"
|
#include "path-util.h"
|
||||||
|
#include "percent-util.h"
|
||||||
#include "process-util.h"
|
#include "process-util.h"
|
||||||
#include "rlimit-util.h"
|
#include "rlimit-util.h"
|
||||||
#if HAVE_SECCOMP
|
#if HAVE_SECCOMP
|
||||||
@ -440,15 +441,12 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
|
|||||||
return bus_append_string(m, field, eq);
|
return bus_append_string(m, field, eq);
|
||||||
|
|
||||||
if (STR_IN_SET(field, "ManagedOOMMemoryPressureLimit")) {
|
if (STR_IN_SET(field, "ManagedOOMMemoryPressureLimit")) {
|
||||||
char *n;
|
|
||||||
|
|
||||||
r = parse_permyriad(eq);
|
r = parse_permyriad(eq);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to parse %s value: %s", field, eq);
|
return log_error_errno(r, "Failed to parse %s value: %s", field, eq);
|
||||||
|
|
||||||
n = strjoina(field, "Permyriad");
|
/* Pass around scaled to 2^32-1 == 100% */
|
||||||
|
r = sd_bus_message_append(m, "(sv)", field, "u", UINT32_SCALE_FROM_PERMYRIAD(r));
|
||||||
r = sd_bus_message_append(m, "(sv)", n, "u", (uint32_t) r);
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_create_error(r);
|
return bus_log_create_error(r);
|
||||||
|
|
||||||
@ -539,7 +537,7 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = parse_permille(eq);
|
r = parse_permyriad(eq);
|
||||||
if (r >= 0) {
|
if (r >= 0) {
|
||||||
char *n;
|
char *n;
|
||||||
|
|
||||||
@ -548,7 +546,7 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
|
|||||||
* size can be determined server-side. */
|
* size can be determined server-side. */
|
||||||
|
|
||||||
n = strjoina(field, "Scale");
|
n = strjoina(field, "Scale");
|
||||||
r = sd_bus_message_append(m, "(sv)", n, "u", (uint32_t) (((uint64_t) r * UINT32_MAX) / 1000U));
|
r = sd_bus_message_append(m, "(sv)", n, "u", UINT32_SCALE_FROM_PERMYRIAD(r));
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_create_error(r);
|
return bus_log_create_error(r);
|
||||||
|
|
||||||
@ -565,14 +563,14 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
|
|||||||
if (isempty(eq))
|
if (isempty(eq))
|
||||||
r = sd_bus_message_append(m, "(sv)", "CPUQuotaPerSecUSec", "t", USEC_INFINITY);
|
r = sd_bus_message_append(m, "(sv)", "CPUQuotaPerSecUSec", "t", USEC_INFINITY);
|
||||||
else {
|
else {
|
||||||
r = parse_permille_unbounded(eq);
|
r = parse_permyriad_unbounded(eq);
|
||||||
if (r == 0)
|
if (r == 0)
|
||||||
return log_error_errno(SYNTHETIC_ERRNO(ERANGE),
|
return log_error_errno(SYNTHETIC_ERRNO(ERANGE),
|
||||||
"CPU quota too small.");
|
"CPU quota too small.");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "CPU quota '%s' invalid.", eq);
|
return log_error_errno(r, "CPU quota '%s' invalid.", eq);
|
||||||
|
|
||||||
r = sd_bus_message_append(m, "(sv)", "CPUQuotaPerSecUSec", "t", (((uint64_t) r * USEC_PER_SEC) / 1000U));
|
r = sd_bus_message_append(m, "(sv)", "CPUQuotaPerSecUSec", "t", (((uint64_t) r * USEC_PER_SEC) / 10000U));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "nulstr-util.h"
|
#include "nulstr-util.h"
|
||||||
#include "parse-util.h"
|
#include "parse-util.h"
|
||||||
#include "path-util.h"
|
#include "path-util.h"
|
||||||
|
#include "percent-util.h"
|
||||||
#include "process-util.h"
|
#include "process-util.h"
|
||||||
#include "rlimit-util.h"
|
#include "rlimit-util.h"
|
||||||
#include "sd-id128.h"
|
#include "sd-id128.h"
|
||||||
|
@ -2258,6 +2258,12 @@ int table_print(Table *t, FILE *f) {
|
|||||||
if (!aligned)
|
if (!aligned)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
/* Drop trailing white spaces of last column when no cosmetics is set. */
|
||||||
|
if (j == display_columns - 1 &&
|
||||||
|
(!colors_enabled() || !table_data_color(d)) &&
|
||||||
|
(!urlify_enabled() || !d->url))
|
||||||
|
delete_trailing_chars(aligned, NULL);
|
||||||
|
|
||||||
free_and_replace(buffer, aligned);
|
free_and_replace(buffer, aligned);
|
||||||
field = buffer;
|
field = buffer;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include "string-table.h"
|
#include "string-table.h"
|
||||||
#include "string-util.h"
|
#include "string-util.h"
|
||||||
|
|
||||||
/* All functions in this file emit warnigs. */
|
/* All functions in this file emit warnings. */
|
||||||
|
|
||||||
int parse_boolean_argument(const char *optname, const char *s, bool *ret) {
|
int parse_boolean_argument(const char *optname, const char *s, bool *ret) {
|
||||||
int r;
|
int r;
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
# This file is part of systemd.
|
# This file is part of systemd.
|
||||||
#
|
#
|
||||||
# systemd is free software; you can redistribute it and/or modify it
|
# systemd is free software; you can redistribute it and/or modify it under the
|
||||||
# under the terms of the GNU Lesser General Public License as published by
|
# terms of the GNU Lesser General Public License as published by the Free
|
||||||
# the Free Software Foundation; either version 2.1 of the License, or
|
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||||
# (at your option) any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# Entries in this file show the compile time defaults.
|
# Entries in this file show the compile time defaults. Local configuration
|
||||||
# You can change settings by editing this file.
|
# should be created by either modifying this file, or by creating "drop-ins" in
|
||||||
# Defaults can be restored by simply deleting this file.
|
# the system.conf.d/ subdirectory. The latter is generally recommended.
|
||||||
|
# Defaults can be restored by simply deleting this file and all drop-ins.
|
||||||
#
|
#
|
||||||
# See systemd-sleep.conf(5) for details
|
# See systemd-sleep.conf(5) for details.
|
||||||
|
|
||||||
[Sleep]
|
[Sleep]
|
||||||
#AllowSuspend=yes
|
#AllowSuspend=yes
|
||||||
|
@ -63,7 +63,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|||||||
mac_selinux_finish();
|
mac_selinux_finish();
|
||||||
|
|
||||||
/* Call static destructors to do global state cleanup. We do it here, and not in fuzz-main.c so that
|
/* Call static destructors to do global state cleanup. We do it here, and not in fuzz-main.c so that
|
||||||
* any global state is destoyed between fuzzer runs. */
|
* any global state is destroyed between fuzzer runs. */
|
||||||
static_destruct();
|
static_destruct();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -547,6 +547,8 @@ tests += [
|
|||||||
|
|
||||||
[['src/test/test-bus-util.c']],
|
[['src/test/test-bus-util.c']],
|
||||||
|
|
||||||
|
[['src/test/test-percent-util.c']],
|
||||||
|
|
||||||
[['src/test/test-sd-hwdb.c']],
|
[['src/test/test-sd-hwdb.c']],
|
||||||
|
|
||||||
[['src/test/test-sd-path.c']],
|
[['src/test/test-sd-path.c']],
|
||||||
|
@ -29,7 +29,7 @@ static void test_issue_9549(void) {
|
|||||||
|
|
||||||
printf("%s\n", formatted);
|
printf("%s\n", formatted);
|
||||||
assert_se(streq(formatted,
|
assert_se(streq(formatted,
|
||||||
"NAME TYPE RO USAGE CREATED MODIFIED \n"
|
"NAME TYPE RO USAGE CREATED MODIFIED\n"
|
||||||
"foooo raw no 673.6M Wed 2018-07-11 00:10:33 J… Wed 2018-07-11 00:16:00 JST\n"
|
"foooo raw no 673.6M Wed 2018-07-11 00:10:33 J… Wed 2018-07-11 00:16:00 JST\n"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -72,7 +72,7 @@ static void test_multiline(void) {
|
|||||||
"FOO BAR\n"
|
"FOO BAR\n"
|
||||||
"three two\n"
|
"three two\n"
|
||||||
"different lines\n"
|
"different lines\n"
|
||||||
"lines \n"));
|
"lines \n"));
|
||||||
formatted = mfree(formatted);
|
formatted = mfree(formatted);
|
||||||
|
|
||||||
table_set_cell_height_max(table, (size_t) -1);
|
table_set_cell_height_max(table, (size_t) -1);
|
||||||
@ -82,7 +82,7 @@ static void test_multiline(void) {
|
|||||||
"FOO BAR\n"
|
"FOO BAR\n"
|
||||||
"three two\n"
|
"three two\n"
|
||||||
"different lines\n"
|
"different lines\n"
|
||||||
"lines \n"));
|
"lines \n"));
|
||||||
formatted = mfree(formatted);
|
formatted = mfree(formatted);
|
||||||
|
|
||||||
assert_se(table_add_many(table,
|
assert_se(table_add_many(table,
|
||||||
@ -123,7 +123,7 @@ static void test_multiline(void) {
|
|||||||
"FOO BAR\n"
|
"FOO BAR\n"
|
||||||
"three two\n"
|
"three two\n"
|
||||||
"different lines\n"
|
"different lines\n"
|
||||||
"lines \n"
|
"lines \n"
|
||||||
"short a\n"
|
"short a\n"
|
||||||
" pair\n"
|
" pair\n"
|
||||||
"short2 a\n"
|
"short2 a\n"
|
||||||
@ -138,7 +138,7 @@ static void test_multiline(void) {
|
|||||||
"FOO BAR\n"
|
"FOO BAR\n"
|
||||||
"three two\n"
|
"three two\n"
|
||||||
"different lines\n"
|
"different lines\n"
|
||||||
"lines \n"
|
"lines \n"
|
||||||
"short a\n"
|
"short a\n"
|
||||||
" pair\n"
|
" pair\n"
|
||||||
"short2 a\n"
|
"short2 a\n"
|
||||||
@ -186,7 +186,7 @@ static void test_strv(void) {
|
|||||||
"FOO BAR\n"
|
"FOO BAR\n"
|
||||||
"three two\n"
|
"three two\n"
|
||||||
"different lines\n"
|
"different lines\n"
|
||||||
"lines \n"));
|
"lines \n"));
|
||||||
formatted = mfree(formatted);
|
formatted = mfree(formatted);
|
||||||
|
|
||||||
table_set_cell_height_max(table, (size_t) -1);
|
table_set_cell_height_max(table, (size_t) -1);
|
||||||
@ -196,7 +196,7 @@ static void test_strv(void) {
|
|||||||
"FOO BAR\n"
|
"FOO BAR\n"
|
||||||
"three two\n"
|
"three two\n"
|
||||||
"different lines\n"
|
"different lines\n"
|
||||||
"lines \n"));
|
"lines \n"));
|
||||||
formatted = mfree(formatted);
|
formatted = mfree(formatted);
|
||||||
|
|
||||||
assert_se(table_add_many(table,
|
assert_se(table_add_many(table,
|
||||||
@ -237,7 +237,7 @@ static void test_strv(void) {
|
|||||||
"FOO BAR\n"
|
"FOO BAR\n"
|
||||||
"three two\n"
|
"three two\n"
|
||||||
"different lines\n"
|
"different lines\n"
|
||||||
"lines \n"
|
"lines \n"
|
||||||
"short a\n"
|
"short a\n"
|
||||||
" pair\n"
|
" pair\n"
|
||||||
"short2 a\n"
|
"short2 a\n"
|
||||||
@ -252,7 +252,7 @@ static void test_strv(void) {
|
|||||||
"FOO BAR\n"
|
"FOO BAR\n"
|
||||||
"three two\n"
|
"three two\n"
|
||||||
"different lines\n"
|
"different lines\n"
|
||||||
"lines \n"
|
"lines \n"
|
||||||
"short a\n"
|
"short a\n"
|
||||||
" pair\n"
|
" pair\n"
|
||||||
"short2 a\n"
|
"short2 a\n"
|
||||||
@ -333,7 +333,7 @@ static void test_strv_wrapped(void) {
|
|||||||
assert_se(streq(formatted,
|
assert_se(streq(formatted,
|
||||||
"FOO BAR\n"
|
"FOO BAR\n"
|
||||||
"three different two lines\n"
|
"three different two lines\n"
|
||||||
"lines \n"
|
"lines \n"
|
||||||
"short a pair\n"
|
"short a pair\n"
|
||||||
"short2 a eight line ćęłł\n"
|
"short2 a eight line ćęłł\n"
|
||||||
" ___5___ ___6___…\n"));
|
" ___5___ ___6___…\n"));
|
||||||
@ -345,7 +345,7 @@ static void test_strv_wrapped(void) {
|
|||||||
assert_se(streq(formatted,
|
assert_se(streq(formatted,
|
||||||
"FOO BAR\n"
|
"FOO BAR\n"
|
||||||
"three different two lines\n"
|
"three different two lines\n"
|
||||||
"lines \n"
|
"lines \n"
|
||||||
"short a pair\n"
|
"short a pair\n"
|
||||||
"short2 a eight line ćęłł\n"
|
"short2 a eight line ćęłł\n"
|
||||||
" ___5___ ___6___\n"
|
" ___5___ ___6___\n"
|
||||||
@ -358,7 +358,7 @@ static void test_strv_wrapped(void) {
|
|||||||
assert_se(streq(formatted,
|
assert_se(streq(formatted,
|
||||||
"FOO BAR\n"
|
"FOO BAR\n"
|
||||||
"three different two lines\n"
|
"three different two lines\n"
|
||||||
"lines \n"
|
"lines \n"
|
||||||
"short a pair\n"
|
"short a pair\n"
|
||||||
"short2 a eight line ćęłł\n"
|
"short2 a eight line ćęłł\n"
|
||||||
" ___5___ ___6___\n"
|
" ___5___ ___6___\n"
|
||||||
@ -493,17 +493,17 @@ int main(int argc, char *argv[]) {
|
|||||||
if (isatty(STDOUT_FILENO))
|
if (isatty(STDOUT_FILENO))
|
||||||
assert_se(streq(formatted,
|
assert_se(streq(formatted,
|
||||||
" no a long f… no a long f… a long fi…\n"
|
" no a long f… no a long f… a long fi…\n"
|
||||||
" no fäää no fäää fäää \n"
|
" no fäää no fäää fäää\n"
|
||||||
" yes fäää yes fäää fäää \n"
|
" yes fäää yes fäää fäää\n"
|
||||||
" yes xxx yes xxx xxx \n"
|
" yes xxx yes xxx xxx\n"
|
||||||
"5min 5min \n"));
|
"5min 5min \n"));
|
||||||
else
|
else
|
||||||
assert_se(streq(formatted,
|
assert_se(streq(formatted,
|
||||||
" no a long field no a long field a long field\n"
|
" no a long field no a long field a long field\n"
|
||||||
" no fäää no fäää fäää \n"
|
" no fäää no fäää fäää\n"
|
||||||
" yes fäää yes fäää fäää \n"
|
" yes fäää yes fäää fäää\n"
|
||||||
" yes xxx yes xxx xxx \n"
|
" yes xxx yes xxx xxx\n"
|
||||||
"5min 5min \n"));
|
"5min 5min \n"));
|
||||||
|
|
||||||
test_issue_9549();
|
test_issue_9549();
|
||||||
test_multiline();
|
test_multiline();
|
||||||
|
@ -718,144 +718,6 @@ static void test_safe_atod(void) {
|
|||||||
assert_se(r == -EINVAL);
|
assert_se(r == -EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_parse_percent(void) {
|
|
||||||
assert_se(parse_percent("") == -EINVAL);
|
|
||||||
assert_se(parse_percent("foo") == -EINVAL);
|
|
||||||
assert_se(parse_percent("0") == -EINVAL);
|
|
||||||
assert_se(parse_percent("50") == -EINVAL);
|
|
||||||
assert_se(parse_percent("100") == -EINVAL);
|
|
||||||
assert_se(parse_percent("-1") == -EINVAL);
|
|
||||||
assert_se(parse_percent("0%") == 0);
|
|
||||||
assert_se(parse_percent("55%") == 55);
|
|
||||||
assert_se(parse_percent("100%") == 100);
|
|
||||||
assert_se(parse_percent("-7%") == -ERANGE);
|
|
||||||
assert_se(parse_percent("107%") == -ERANGE);
|
|
||||||
assert_se(parse_percent("%") == -EINVAL);
|
|
||||||
assert_se(parse_percent("%%") == -EINVAL);
|
|
||||||
assert_se(parse_percent("%1") == -EINVAL);
|
|
||||||
assert_se(parse_percent("1%%") == -EINVAL);
|
|
||||||
assert_se(parse_percent("3.2%") == -EINVAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void test_parse_percent_unbounded(void) {
|
|
||||||
assert_se(parse_percent_unbounded("101%") == 101);
|
|
||||||
assert_se(parse_percent_unbounded("400%") == 400);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void test_parse_permille(void) {
|
|
||||||
assert_se(parse_permille("") == -EINVAL);
|
|
||||||
assert_se(parse_permille("foo") == -EINVAL);
|
|
||||||
assert_se(parse_permille("0") == -EINVAL);
|
|
||||||
assert_se(parse_permille("50") == -EINVAL);
|
|
||||||
assert_se(parse_permille("100") == -EINVAL);
|
|
||||||
assert_se(parse_permille("-1") == -EINVAL);
|
|
||||||
|
|
||||||
assert_se(parse_permille("0‰") == 0);
|
|
||||||
assert_se(parse_permille("555‰") == 555);
|
|
||||||
assert_se(parse_permille("1000‰") == 1000);
|
|
||||||
assert_se(parse_permille("-7‰") == -ERANGE);
|
|
||||||
assert_se(parse_permille("1007‰") == -ERANGE);
|
|
||||||
assert_se(parse_permille("‰") == -EINVAL);
|
|
||||||
assert_se(parse_permille("‰‰") == -EINVAL);
|
|
||||||
assert_se(parse_permille("‰1") == -EINVAL);
|
|
||||||
assert_se(parse_permille("1‰‰") == -EINVAL);
|
|
||||||
assert_se(parse_permille("3.2‰") == -EINVAL);
|
|
||||||
|
|
||||||
assert_se(parse_permille("0%") == 0);
|
|
||||||
assert_se(parse_permille("55%") == 550);
|
|
||||||
assert_se(parse_permille("55.5%") == 555);
|
|
||||||
assert_se(parse_permille("100%") == 1000);
|
|
||||||
assert_se(parse_permille("-7%") == -ERANGE);
|
|
||||||
assert_se(parse_permille("107%") == -ERANGE);
|
|
||||||
assert_se(parse_permille("%") == -EINVAL);
|
|
||||||
assert_se(parse_permille("%%") == -EINVAL);
|
|
||||||
assert_se(parse_permille("%1") == -EINVAL);
|
|
||||||
assert_se(parse_permille("1%%") == -EINVAL);
|
|
||||||
assert_se(parse_permille("3.21%") == -EINVAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void test_parse_permille_unbounded(void) {
|
|
||||||
assert_se(parse_permille_unbounded("1001‰") == 1001);
|
|
||||||
assert_se(parse_permille_unbounded("4000‰") == 4000);
|
|
||||||
assert_se(parse_permille_unbounded("2147483647‰") == 2147483647);
|
|
||||||
assert_se(parse_permille_unbounded("2147483648‰") == -ERANGE);
|
|
||||||
assert_se(parse_permille_unbounded("4294967295‰") == -ERANGE);
|
|
||||||
assert_se(parse_permille_unbounded("4294967296‰") == -ERANGE);
|
|
||||||
|
|
||||||
assert_se(parse_permille_unbounded("101%") == 1010);
|
|
||||||
assert_se(parse_permille_unbounded("400%") == 4000);
|
|
||||||
assert_se(parse_permille_unbounded("214748364.7%") == 2147483647);
|
|
||||||
assert_se(parse_permille_unbounded("214748364.8%") == -ERANGE);
|
|
||||||
assert_se(parse_permille_unbounded("429496729.5%") == -ERANGE);
|
|
||||||
assert_se(parse_permille_unbounded("429496729.6%") == -ERANGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void test_parse_permyriad(void) {
|
|
||||||
assert_se(parse_permyriad("") == -EINVAL);
|
|
||||||
assert_se(parse_permyriad("foo") == -EINVAL);
|
|
||||||
assert_se(parse_permyriad("0") == -EINVAL);
|
|
||||||
assert_se(parse_permyriad("50") == -EINVAL);
|
|
||||||
assert_se(parse_permyriad("100") == -EINVAL);
|
|
||||||
assert_se(parse_permyriad("-1") == -EINVAL);
|
|
||||||
|
|
||||||
assert_se(parse_permyriad("0‱") == 0);
|
|
||||||
assert_se(parse_permyriad("555‱") == 555);
|
|
||||||
assert_se(parse_permyriad("1000‱") == 1000);
|
|
||||||
assert_se(parse_permyriad("-7‱") == -ERANGE);
|
|
||||||
assert_se(parse_permyriad("10007‱") == -ERANGE);
|
|
||||||
assert_se(parse_permyriad("‱") == -EINVAL);
|
|
||||||
assert_se(parse_permyriad("‱‱") == -EINVAL);
|
|
||||||
assert_se(parse_permyriad("‱1") == -EINVAL);
|
|
||||||
assert_se(parse_permyriad("1‱‱") == -EINVAL);
|
|
||||||
assert_se(parse_permyriad("3.2‱") == -EINVAL);
|
|
||||||
|
|
||||||
assert_se(parse_permyriad("0‰") == 0);
|
|
||||||
assert_se(parse_permyriad("555.5‰") == 5555);
|
|
||||||
assert_se(parse_permyriad("1000.0‰") == 10000);
|
|
||||||
assert_se(parse_permyriad("-7‰") == -ERANGE);
|
|
||||||
assert_se(parse_permyriad("1007‰") == -ERANGE);
|
|
||||||
assert_se(parse_permyriad("‰") == -EINVAL);
|
|
||||||
assert_se(parse_permyriad("‰‰") == -EINVAL);
|
|
||||||
assert_se(parse_permyriad("‰1") == -EINVAL);
|
|
||||||
assert_se(parse_permyriad("1‰‰") == -EINVAL);
|
|
||||||
assert_se(parse_permyriad("3.22‰") == -EINVAL);
|
|
||||||
|
|
||||||
assert_se(parse_permyriad("0%") == 0);
|
|
||||||
assert_se(parse_permyriad("55%") == 5500);
|
|
||||||
assert_se(parse_permyriad("55.53%") == 5553);
|
|
||||||
assert_se(parse_permyriad("100%") == 10000);
|
|
||||||
assert_se(parse_permyriad("-7%") == -ERANGE);
|
|
||||||
assert_se(parse_permyriad("107%") == -ERANGE);
|
|
||||||
assert_se(parse_permyriad("%") == -EINVAL);
|
|
||||||
assert_se(parse_permyriad("%%") == -EINVAL);
|
|
||||||
assert_se(parse_permyriad("%1") == -EINVAL);
|
|
||||||
assert_se(parse_permyriad("1%%") == -EINVAL);
|
|
||||||
assert_se(parse_permyriad("3.212%") == -EINVAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void test_parse_permyriad_unbounded(void) {
|
|
||||||
assert_se(parse_permyriad_unbounded("1001‱") == 1001);
|
|
||||||
assert_se(parse_permyriad_unbounded("4000‱") == 4000);
|
|
||||||
assert_se(parse_permyriad_unbounded("2147483647‱") == 2147483647);
|
|
||||||
assert_se(parse_permyriad_unbounded("2147483648‱") == -ERANGE);
|
|
||||||
assert_se(parse_permyriad_unbounded("4294967295‱") == -ERANGE);
|
|
||||||
assert_se(parse_permyriad_unbounded("4294967296‱") == -ERANGE);
|
|
||||||
|
|
||||||
assert_se(parse_permyriad_unbounded("101‰") == 1010);
|
|
||||||
assert_se(parse_permyriad_unbounded("400‰") == 4000);
|
|
||||||
assert_se(parse_permyriad_unbounded("214748364.7‰") == 2147483647);
|
|
||||||
assert_se(parse_permyriad_unbounded("214748364.8‰") == -ERANGE);
|
|
||||||
assert_se(parse_permyriad_unbounded("429496729.5‰") == -ERANGE);
|
|
||||||
assert_se(parse_permyriad_unbounded("429496729.6‰") == -ERANGE);
|
|
||||||
|
|
||||||
assert_se(parse_permyriad_unbounded("99%") == 9900);
|
|
||||||
assert_se(parse_permyriad_unbounded("40%") == 4000);
|
|
||||||
assert_se(parse_permyriad_unbounded("21474836.47%") == 2147483647);
|
|
||||||
assert_se(parse_permyriad_unbounded("21474836.48%") == -ERANGE);
|
|
||||||
assert_se(parse_permyriad_unbounded("42949672.95%") == -ERANGE);
|
|
||||||
assert_se(parse_permyriad_unbounded("42949672.96%") == -ERANGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void test_parse_nice(void) {
|
static void test_parse_nice(void) {
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
@ -1049,12 +911,6 @@ int main(int argc, char *argv[]) {
|
|||||||
test_safe_atoi64();
|
test_safe_atoi64();
|
||||||
test_safe_atoux64();
|
test_safe_atoux64();
|
||||||
test_safe_atod();
|
test_safe_atod();
|
||||||
test_parse_percent();
|
|
||||||
test_parse_percent_unbounded();
|
|
||||||
test_parse_permille();
|
|
||||||
test_parse_permille_unbounded();
|
|
||||||
test_parse_permyriad();
|
|
||||||
test_parse_permyriad_unbounded();
|
|
||||||
test_parse_nice();
|
test_parse_nice();
|
||||||
test_parse_dev();
|
test_parse_dev();
|
||||||
test_parse_errno();
|
test_parse_errno();
|
||||||
|
211
src/test/test-percent-util.c
Normal file
211
src/test/test-percent-util.c
Normal file
@ -0,0 +1,211 @@
|
|||||||
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||||
|
|
||||||
|
#include "percent-util.h"
|
||||||
|
#include "tests.h"
|
||||||
|
#include "time-util.h"
|
||||||
|
|
||||||
|
static void test_parse_percent(void) {
|
||||||
|
assert_se(parse_percent("") == -EINVAL);
|
||||||
|
assert_se(parse_percent("foo") == -EINVAL);
|
||||||
|
assert_se(parse_percent("0") == -EINVAL);
|
||||||
|
assert_se(parse_percent("0.1") == -EINVAL);
|
||||||
|
assert_se(parse_percent("50") == -EINVAL);
|
||||||
|
assert_se(parse_percent("100") == -EINVAL);
|
||||||
|
assert_se(parse_percent("-1") == -EINVAL);
|
||||||
|
assert_se(parse_percent("0%") == 0);
|
||||||
|
assert_se(parse_percent("55%") == 55);
|
||||||
|
assert_se(parse_percent("100%") == 100);
|
||||||
|
assert_se(parse_percent("-7%") == -ERANGE);
|
||||||
|
assert_se(parse_percent("107%") == -ERANGE);
|
||||||
|
assert_se(parse_percent("%") == -EINVAL);
|
||||||
|
assert_se(parse_percent("%%") == -EINVAL);
|
||||||
|
assert_se(parse_percent("%1") == -EINVAL);
|
||||||
|
assert_se(parse_percent("1%%") == -EINVAL);
|
||||||
|
assert_se(parse_percent("3.2%") == -EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_parse_percent_unbounded(void) {
|
||||||
|
assert_se(parse_percent_unbounded("101%") == 101);
|
||||||
|
assert_se(parse_percent_unbounded("400%") == 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_parse_permille(void) {
|
||||||
|
assert_se(parse_permille("") == -EINVAL);
|
||||||
|
assert_se(parse_permille("foo") == -EINVAL);
|
||||||
|
assert_se(parse_permille("0") == -EINVAL);
|
||||||
|
assert_se(parse_permille("50") == -EINVAL);
|
||||||
|
assert_se(parse_permille("100") == -EINVAL);
|
||||||
|
assert_se(parse_permille("-1") == -EINVAL);
|
||||||
|
assert_se(parse_permille("0.1") == -EINVAL);
|
||||||
|
assert_se(parse_permille("5%") == 50);
|
||||||
|
assert_se(parse_permille("5.5%") == 55);
|
||||||
|
assert_se(parse_permille("5.12%") == -EINVAL);
|
||||||
|
|
||||||
|
assert_se(parse_permille("0‰") == 0);
|
||||||
|
assert_se(parse_permille("555‰") == 555);
|
||||||
|
assert_se(parse_permille("1000‰") == 1000);
|
||||||
|
assert_se(parse_permille("-7‰") == -ERANGE);
|
||||||
|
assert_se(parse_permille("1007‰") == -ERANGE);
|
||||||
|
assert_se(parse_permille("‰") == -EINVAL);
|
||||||
|
assert_se(parse_permille("‰‰") == -EINVAL);
|
||||||
|
assert_se(parse_permille("‰1") == -EINVAL);
|
||||||
|
assert_se(parse_permille("1‰‰") == -EINVAL);
|
||||||
|
assert_se(parse_permille("3.2‰") == -EINVAL);
|
||||||
|
assert_se(parse_permille("0.1‰") == -EINVAL);
|
||||||
|
|
||||||
|
assert_se(parse_permille("0%") == 0);
|
||||||
|
assert_se(parse_permille("55%") == 550);
|
||||||
|
assert_se(parse_permille("55.5%") == 555);
|
||||||
|
assert_se(parse_permille("100%") == 1000);
|
||||||
|
assert_se(parse_permille("-7%") == -ERANGE);
|
||||||
|
assert_se(parse_permille("107%") == -ERANGE);
|
||||||
|
assert_se(parse_permille("%") == -EINVAL);
|
||||||
|
assert_se(parse_permille("%%") == -EINVAL);
|
||||||
|
assert_se(parse_permille("%1") == -EINVAL);
|
||||||
|
assert_se(parse_permille("1%%") == -EINVAL);
|
||||||
|
assert_se(parse_permille("3.21%") == -EINVAL);
|
||||||
|
assert_se(parse_permille("0.1%") == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_parse_permille_unbounded(void) {
|
||||||
|
assert_se(parse_permille_unbounded("1001‰") == 1001);
|
||||||
|
assert_se(parse_permille_unbounded("4000‰") == 4000);
|
||||||
|
assert_se(parse_permille_unbounded("2147483647‰") == 2147483647);
|
||||||
|
assert_se(parse_permille_unbounded("2147483648‰") == -ERANGE);
|
||||||
|
assert_se(parse_permille_unbounded("4294967295‰") == -ERANGE);
|
||||||
|
assert_se(parse_permille_unbounded("4294967296‰") == -ERANGE);
|
||||||
|
|
||||||
|
assert_se(parse_permille_unbounded("101%") == 1010);
|
||||||
|
assert_se(parse_permille_unbounded("400%") == 4000);
|
||||||
|
assert_se(parse_permille_unbounded("214748364.7%") == 2147483647);
|
||||||
|
assert_se(parse_permille_unbounded("214748364.8%") == -ERANGE);
|
||||||
|
assert_se(parse_permille_unbounded("429496729.5%") == -ERANGE);
|
||||||
|
assert_se(parse_permille_unbounded("429496729.6%") == -ERANGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_parse_permyriad(void) {
|
||||||
|
assert_se(parse_permyriad("") == -EINVAL);
|
||||||
|
assert_se(parse_permyriad("foo") == -EINVAL);
|
||||||
|
assert_se(parse_permyriad("0") == -EINVAL);
|
||||||
|
assert_se(parse_permyriad("50") == -EINVAL);
|
||||||
|
assert_se(parse_permyriad("100") == -EINVAL);
|
||||||
|
assert_se(parse_permyriad("-1") == -EINVAL);
|
||||||
|
|
||||||
|
assert_se(parse_permyriad("0‱") == 0);
|
||||||
|
assert_se(parse_permyriad("555‱") == 555);
|
||||||
|
assert_se(parse_permyriad("1000‱") == 1000);
|
||||||
|
assert_se(parse_permyriad("-7‱") == -ERANGE);
|
||||||
|
assert_se(parse_permyriad("10007‱") == -ERANGE);
|
||||||
|
assert_se(parse_permyriad("‱") == -EINVAL);
|
||||||
|
assert_se(parse_permyriad("‱‱") == -EINVAL);
|
||||||
|
assert_se(parse_permyriad("‱1") == -EINVAL);
|
||||||
|
assert_se(parse_permyriad("1‱‱") == -EINVAL);
|
||||||
|
assert_se(parse_permyriad("3.2‱") == -EINVAL);
|
||||||
|
|
||||||
|
assert_se(parse_permyriad("0‰") == 0);
|
||||||
|
assert_se(parse_permyriad("555.5‰") == 5555);
|
||||||
|
assert_se(parse_permyriad("1000.0‰") == 10000);
|
||||||
|
assert_se(parse_permyriad("-7‰") == -ERANGE);
|
||||||
|
assert_se(parse_permyriad("1007‰") == -ERANGE);
|
||||||
|
assert_se(parse_permyriad("‰") == -EINVAL);
|
||||||
|
assert_se(parse_permyriad("‰‰") == -EINVAL);
|
||||||
|
assert_se(parse_permyriad("‰1") == -EINVAL);
|
||||||
|
assert_se(parse_permyriad("1‰‰") == -EINVAL);
|
||||||
|
assert_se(parse_permyriad("3.22‰") == -EINVAL);
|
||||||
|
|
||||||
|
assert_se(parse_permyriad("0%") == 0);
|
||||||
|
assert_se(parse_permyriad("55%") == 5500);
|
||||||
|
assert_se(parse_permyriad("55.5%") == 5550);
|
||||||
|
assert_se(parse_permyriad("55.50%") == 5550);
|
||||||
|
assert_se(parse_permyriad("55.53%") == 5553);
|
||||||
|
assert_se(parse_permyriad("100%") == 10000);
|
||||||
|
assert_se(parse_permyriad("-7%") == -ERANGE);
|
||||||
|
assert_se(parse_permyriad("107%") == -ERANGE);
|
||||||
|
assert_se(parse_permyriad("%") == -EINVAL);
|
||||||
|
assert_se(parse_permyriad("%%") == -EINVAL);
|
||||||
|
assert_se(parse_permyriad("%1") == -EINVAL);
|
||||||
|
assert_se(parse_permyriad("1%%") == -EINVAL);
|
||||||
|
assert_se(parse_permyriad("3.212%") == -EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_parse_permyriad_unbounded(void) {
|
||||||
|
assert_se(parse_permyriad_unbounded("1001‱") == 1001);
|
||||||
|
assert_se(parse_permyriad_unbounded("4000‱") == 4000);
|
||||||
|
assert_se(parse_permyriad_unbounded("2147483647‱") == 2147483647);
|
||||||
|
assert_se(parse_permyriad_unbounded("2147483648‱") == -ERANGE);
|
||||||
|
assert_se(parse_permyriad_unbounded("4294967295‱") == -ERANGE);
|
||||||
|
assert_se(parse_permyriad_unbounded("4294967296‱") == -ERANGE);
|
||||||
|
|
||||||
|
assert_se(parse_permyriad_unbounded("101‰") == 1010);
|
||||||
|
assert_se(parse_permyriad_unbounded("400‰") == 4000);
|
||||||
|
assert_se(parse_permyriad_unbounded("214748364.7‰") == 2147483647);
|
||||||
|
assert_se(parse_permyriad_unbounded("214748364.8‰") == -ERANGE);
|
||||||
|
assert_se(parse_permyriad_unbounded("429496729.5‰") == -ERANGE);
|
||||||
|
assert_se(parse_permyriad_unbounded("429496729.6‰") == -ERANGE);
|
||||||
|
|
||||||
|
assert_se(parse_permyriad_unbounded("99%") == 9900);
|
||||||
|
assert_se(parse_permyriad_unbounded("40%") == 4000);
|
||||||
|
assert_se(parse_permyriad_unbounded("21474836.47%") == 2147483647);
|
||||||
|
assert_se(parse_permyriad_unbounded("21474836.48%") == -ERANGE);
|
||||||
|
assert_se(parse_permyriad_unbounded("42949672.95%") == -ERANGE);
|
||||||
|
assert_se(parse_permyriad_unbounded("42949672.96%") == -ERANGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_scale(void) {
|
||||||
|
/* Check some fixed values */
|
||||||
|
assert_se(UINT32_SCALE_FROM_PERCENT(0) == 0);
|
||||||
|
assert_se(UINT32_SCALE_FROM_PERCENT(50) == UINT32_MAX/2+1);
|
||||||
|
assert_se(UINT32_SCALE_FROM_PERCENT(100) == UINT32_MAX);
|
||||||
|
|
||||||
|
assert_se(UINT32_SCALE_FROM_PERMILLE(0) == 0);
|
||||||
|
assert_se(UINT32_SCALE_FROM_PERMILLE(500) == UINT32_MAX/2+1);
|
||||||
|
assert_se(UINT32_SCALE_FROM_PERMILLE(1000) == UINT32_MAX);
|
||||||
|
|
||||||
|
assert_se(UINT32_SCALE_FROM_PERMYRIAD(0) == 0);
|
||||||
|
assert_se(UINT32_SCALE_FROM_PERMYRIAD(5000) == UINT32_MAX/2+1);
|
||||||
|
assert_se(UINT32_SCALE_FROM_PERMYRIAD(10000) == UINT32_MAX);
|
||||||
|
|
||||||
|
/* Make sure there's no numeric noise on the 0%…100% scale when converting from percent and back. */
|
||||||
|
for (int percent = 0; percent <= 100; percent++) {
|
||||||
|
log_debug("%i%% → %" PRIu32 " → %i%%",
|
||||||
|
percent,
|
||||||
|
UINT32_SCALE_FROM_PERCENT(percent),
|
||||||
|
UINT32_SCALE_TO_PERCENT(UINT32_SCALE_FROM_PERCENT(percent)));
|
||||||
|
|
||||||
|
assert_se(UINT32_SCALE_TO_PERCENT(UINT32_SCALE_FROM_PERCENT(percent)) == percent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Make sure there's no numeric noise on the 0‰…1000‰ scale when converting from permille and back. */
|
||||||
|
for (int permille = 0; permille <= 1000; permille++) {
|
||||||
|
log_debug("%i‰ → %" PRIu32 " → %i‰",
|
||||||
|
permille,
|
||||||
|
UINT32_SCALE_FROM_PERMILLE(permille),
|
||||||
|
UINT32_SCALE_TO_PERMILLE(UINT32_SCALE_FROM_PERMILLE(permille)));
|
||||||
|
|
||||||
|
assert_se(UINT32_SCALE_TO_PERMILLE(UINT32_SCALE_FROM_PERMILLE(permille)) == permille);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Make sure there's no numeric noise on the 0‱…10000‱ scale when converting from permyriad and back. */
|
||||||
|
for (int permyriad = 0; permyriad <= 10000; permyriad++) {
|
||||||
|
log_debug("%i‱ → %" PRIu32 " → %i‱",
|
||||||
|
permyriad,
|
||||||
|
UINT32_SCALE_FROM_PERMYRIAD(permyriad),
|
||||||
|
UINT32_SCALE_TO_PERMYRIAD(UINT32_SCALE_FROM_PERMYRIAD(permyriad)));
|
||||||
|
|
||||||
|
assert_se(UINT32_SCALE_TO_PERMYRIAD(UINT32_SCALE_FROM_PERMYRIAD(permyriad)) == permyriad);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
test_setup_logging(LOG_DEBUG);
|
||||||
|
|
||||||
|
test_parse_percent();
|
||||||
|
test_parse_percent_unbounded();
|
||||||
|
test_parse_permille();
|
||||||
|
test_parse_permille_unbounded();
|
||||||
|
test_parse_permyriad();
|
||||||
|
test_parse_permyriad_unbounded();
|
||||||
|
test_scale();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
@ -1,13 +1,14 @@
|
|||||||
# This file is part of systemd.
|
# This file is part of systemd.
|
||||||
#
|
#
|
||||||
# systemd is free software; you can redistribute it and/or modify it
|
# systemd is free software; you can redistribute it and/or modify it under the
|
||||||
# under the terms of the GNU Lesser General Public License as published by
|
# terms of the GNU Lesser General Public License as published by the Free
|
||||||
# the Free Software Foundation; either version 2.1 of the License, or
|
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||||
# (at your option) any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# Entries in this file show the compile time defaults.
|
# Entries in this file show the compile time defaults. Local configuration
|
||||||
# You can change settings by editing this file.
|
# should be created by either modifying this file, or by creating "drop-ins" in
|
||||||
# Defaults can be restored by simply deleting this file.
|
# the system.conf.d/ subdirectory. The latter is generally recommended.
|
||||||
|
# Defaults can be restored by simply deleting this file and all drop-ins.
|
||||||
#
|
#
|
||||||
# See timesyncd.conf(5) for details.
|
# See timesyncd.conf(5) for details.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user