]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #28870 from ssahani/rto-min-network
authorLuca Boccassi <bluca@debian.org>
Fri, 18 Aug 2023 08:23:45 +0000 (09:23 +0100)
committerGitHub <noreply@github.com>
Fri, 18 Aug 2023 08:23:45 +0000 (09:23 +0100)
network: Route - allow to set TCP RTO

15 files changed:
man/networkd.conf.xml
man/systemd-bsod.xml
man/systemd-dissect.xml
src/dissect/dissect.c
src/journal/bsod.c
src/journal/meson.build
src/libsystemd-network/dhcp-identifier.c
src/libsystemd-network/dhcp-identifier.h
src/libsystemd-network/sd-dhcp6-client.c
src/network/networkd-dhcp-common.c
src/network/networkd-dhcp6.c
test/test-network/conf/25-dhcp-client-ipv6-only-custom-client-identifier.network [new file with mode: 0644]
test/test-network/systemd-networkd-tests.py
units/meson.build
units/systemd-bsod.service.in [new file with mode: 0644]

index bf597cac2ecb0e70ccb5d792e95d07e5fd77bd9a..9fa925e85c87d7ff96260fcbabd918205f46b2ee 100644 (file)
             </para></listitem>
           </varlistentry>
 
+          <varlistentry>
+            <term><option>custom</option></term>
+            <listitem><para>If <literal>DUIDType=custom</literal>, then the <literal>DUIDRawData=</literal> value will
+            used be as custom identifier. If <literal>DUIDType=custom</literal> is specified then the
+            <literal>DUIDRawData=</literal> key is mandatory. Note it applies only on DHCPv6 clients.</para></listitem>
+          </varlistentry>
+
           <varlistentry>
             <term><option>uuid</option></term>
             <listitem><para>If <literal>DUIDType=uuid</literal>, and <varname>DUIDRawData=</varname> is not set,
index 7a64f4f004a1ed174aa5285b11dbc76715fe4738..86efb29db0809da215309831bc69becf6dca75af 100644 (file)
     <variablelist>
       <xi:include href="standard-options.xml" xpointer="help" />
       <xi:include href="standard-options.xml" xpointer="version" />
+
+     <varlistentry>
+        <term><option>-c</option></term>
+        <term><option>--continuous</option></term>
+
+        <listitem><para> Used to make systemd-bsod wait continuously for changes in the
+         journal's status if doesn't find any emergency messages on initial attempt.</para></listitem>
+     </varlistentry>
     </variablelist>
+
   </refsect1>
 
   <refsect1>
index 27c5d3c7a84858764afd839eeb2e1b1ce44b4211..29f19af7cc421953f7cc29d39ec2a4cc87ff93e0 100644 (file)
         use <option>--read-only</option> to switch to read-only operation. The invoked process will have the
         <varname>$SYSTEMD_DISSECT_ROOT</varname> environment variable set, containing the absolute path name
         of the temporary mount point, i.e. the same directory that is set as the current working
-        directory.</para></listitem>
+        directory. It will also have the <varname>$SYSTEMD_DISSECT_DEVICE</varname> environment variable set,
+        containing the absolute path name of the loop device the image was attached to.</para></listitem>
       </varlistentry>
 
       <varlistentry>
index 103ee41fe7fc7615e2b80fffde2004fffc949e70..291cb66375dd23bbed341ce62da37e5be2ec3774 100644 (file)
@@ -1577,6 +1577,11 @@ static int action_with(DissectedImage *m, LoopDevice *d) {
                         _exit(EXIT_FAILURE);
                 }
 
+                if (setenv("SYSTEMD_DISSECT_DEVICE", d->node, /* overwrite= */ true) < 0) {
+                        log_error_errno(errno, "Failed to set $SYSTEMD_DISSECT_DEVICE: %m");
+                        _exit(EXIT_FAILURE);
+                }
+
                 if (strv_isempty(arg_argv)) {
                         const char *sh;
 
index 2ae06dee52d35f0569048ba38b06cfdd8be6d57a..76907d2e5cb4685edfda72722c4866cb9926bd28 100644 (file)
@@ -22,6 +22,8 @@
 #include "sysctl-util.h"
 #include "terminal-util.h"
 
+static bool arg_continuous = false;
+
 static int help(void) {
         _cleanup_free_ char *link = NULL;
         int r;
@@ -36,6 +38,8 @@ static int help(void) {
                "as a string and a QR code.\n\n%s"
                "   -h --help            Show this help\n"
                "      --version         Show package version\n"
+               "   -c --continuous      Make systemd-bsod wait continuously\n"
+               "for changes in the journal\n"
                "\nSee the %s for details.\n",
                program_invocation_short_name,
                ansi_highlight(),
@@ -75,13 +79,24 @@ static int acquire_first_emergency_log_message(char **ret) {
         if (r < 0)
                 return log_error_errno(r, "Failed to seek to start of jornal: %m");
 
-        r = sd_journal_next(j);
-        if (r < 0)
-                return log_error_errno(r, "Failed to read next journal entry: %m");
-        if (r == 0) {
-                log_debug("No emergency level entries in the journal");
-                *ret = NULL;
-                return 0;
+        for(;;) {
+                r = sd_journal_next(j);
+                if (r < 0)
+                        return log_error_errno(r, "Failed to read next journal entry: %m");
+                if (r > 0)
+                        break;
+
+                if (!arg_continuous) {
+                        log_debug("No emergency level entries in the journal");
+                        *ret = NULL;
+                        return 0;
+                }
+
+                r = sd_journal_wait(j, (uint64_t) -1);
+                if (r < 0)
+                        return log_error_errno(r, "Failed to wait for changes: %m");
+
+                continue;
         }
 
         r = sd_journal_get_data(j, "MESSAGE", &d, &l);
@@ -210,6 +225,7 @@ static int parse_argv(int argc, char * argv[]) {
         static const struct option options[] = {
                 { "help",    no_argument, NULL, 'h'         },
                 { "version", no_argument, NULL, ARG_VERSION },
+                { "continuous",    no_argument, NULL, 'c'   },
                 {}
         };
 
@@ -218,7 +234,7 @@ static int parse_argv(int argc, char * argv[]) {
         assert(argc >= 0);
         assert(argv);
 
-        while ((c = getopt_long(argc, argv, "h", options, NULL)) >= 0)
+        while ((c = getopt_long(argc, argv, "hc", options, NULL)) >= 0)
 
                 switch (c) {
 
@@ -228,6 +244,10 @@ static int parse_argv(int argc, char * argv[]) {
                 case ARG_VERSION:
                         return version();
 
+                case 'c':
+                        arg_continuous = true;
+                        break;
+
                 case '?':
                         return -EINVAL;
 
index e89f9d1bc5960aba89a030fb2f69b39c85033586..32d73cca828dbfb06bfb1a719927ec58c27b90d7 100644 (file)
@@ -72,6 +72,13 @@ executables += [
                         threads,
                 ],
         },
+        libexec_template + {
+                'name' : 'systemd-bsod',
+                'conditions' : ['HAVE_QRENCODE'],
+                'sources' : files('bsod.c'),
+                'link_with' : libshared,
+                'dependencies' : libqrencode,
+        },
         executable_template + {
                 'name' : 'systemd-cat',
                 'public' : true,
@@ -95,14 +102,6 @@ executables += [
                         threads,
                 ],
         },
-        executable_template + {
-                'name' : 'systemd-bsod',
-                'conditions' : ['HAVE_QRENCODE'],
-                'public' : true,
-                'sources' : files('bsod.c'),
-                'link_with' : libshared,
-                'dependencies' : libqrencode,
-        },
         journal_test_template + {
                 'sources' : files('test-journal-append.c'),
                 'type' : 'manual',
index a27d67a315dfe685e8f45a7015d2adc234b19949..83fb6ce3408d4d79eeae58764f79cbf8302f1f17 100644 (file)
 #define USEC_2000       ((usec_t) 946684800000000) /* 2000-01-01 00:00:00 UTC */
 
 static const char * const duid_type_table[_DUID_TYPE_MAX] = {
-        [DUID_TYPE_LLT]  = "DUID-LLT",
-        [DUID_TYPE_EN]   = "DUID-EN/Vendor",
-        [DUID_TYPE_LL]   = "DUID-LL",
-        [DUID_TYPE_UUID] = "UUID",
+        [DUID_TYPE_LLT]    = "DUID-LLT",
+        [DUID_TYPE_EN]     = "DUID-EN/Vendor",
+        [DUID_TYPE_LL]     = "DUID-LL",
+        [DUID_TYPE_UUID]   = "UUID",
+        [DUID_TYPE_CUSTOM] = "Custom",
 };
 
 DEFINE_STRING_TABLE_LOOKUP_TO_STRING(duid_type, DUIDType);
index 523dfc4a71ba18df6f4cc7f0dbeaf932b3a35c07..1ac34761573ccdf8d6efd53a53fba588608cbda0 100644 (file)
@@ -17,6 +17,7 @@ typedef enum DUIDType {
         DUID_TYPE_EN        = 2,
         DUID_TYPE_LL        = 3,
         DUID_TYPE_UUID      = 4,
+        DUID_TYPE_CUSTOM    = 5,
         _DUID_TYPE_MAX,
         _DUID_TYPE_INVALID  = -EINVAL,
 } DUIDType;
index 2f4053caad01ed630478c367498ac706e28dbd03..e8d99718b301583eef66062be2bbccb35aa6b571 100644 (file)
@@ -212,10 +212,14 @@ static int dhcp6_client_set_duid_internal(
                         log_dhcp6_client(client, "Using DUID of type %i of incorrect length, proceeding.", duid_type);
                 }
 
-                client->duid.type = htobe16(duid_type);
-                memcpy(&client->duid.raw.data, duid, duid_len);
-                client->duid_len = sizeof(client->duid.type) + duid_len;
-
+                if (duid_type == DUID_TYPE_CUSTOM) {
+                        memcpy(&client->duid, duid, duid_len);
+                        client->duid_len = duid_len;
+                } else {
+                        client->duid.type = htobe16(duid_type);
+                        memcpy(&client->duid.raw.data, duid, duid_len);
+                        client->duid_len = sizeof(client->duid.type) + duid_len;
+                }
         } else {
                 r = dhcp_identifier_set_duid(duid_type, &client->hw_addr, client->arp_type, llt_time,
                                              client->test_mode, &client->duid, &client->duid_len);
index 5f9ef80e3e5b681ff9a2e7faa0dcbfcf1d8b4cef..baf80cb6442b19ce132077a0ae261333ce84bf62 100644 (file)
@@ -1106,10 +1106,11 @@ static const char * const dhcp_option_data_type_table[_DHCP_OPTION_DATA_MAX] = {
 DEFINE_STRING_TABLE_LOOKUP(dhcp_option_data_type, DHCPOptionDataType);
 
 static const char* const duid_type_table[_DUID_TYPE_MAX] = {
-        [DUID_TYPE_LLT]  = "link-layer-time",
-        [DUID_TYPE_EN]   = "vendor",
-        [DUID_TYPE_LL]   = "link-layer",
-        [DUID_TYPE_UUID] = "uuid",
+        [DUID_TYPE_LLT]    = "link-layer-time",
+        [DUID_TYPE_EN]     = "vendor",
+        [DUID_TYPE_LL]     = "link-layer",
+        [DUID_TYPE_UUID]   = "uuid",
+        [DUID_TYPE_CUSTOM] = "custom",
 };
 DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(duid_type, DUIDType);
 
index 00c767e1fb8f8411a5bafbb62da16d6990d5d04a..e0f0850898872b239051c3e1c0c79e434ab6065d 100644 (file)
@@ -555,6 +555,11 @@ static int dhcp6_set_identifier(Link *link, sd_dhcp6_client *client) {
         }
 
         duid = link_get_dhcp6_duid(link);
+
+        if (duid->type == DUID_TYPE_CUSTOM && duid->raw_data_len == 0)
+                return log_link_debug_errno(link, SYNTHETIC_ERRNO(EINVAL),
+                                            "DHCPv6 CLIENT: Missing DUID Raw Data as duid type set to 'custom': %m");
+
         if (duid->type == DUID_TYPE_LLT && duid->raw_data_len == 0)
                 r = sd_dhcp6_client_set_duid_llt(client, duid->llt_time);
         else
diff --git a/test/test-network/conf/25-dhcp-client-ipv6-only-custom-client-identifier.network b/test/test-network/conf/25-dhcp-client-ipv6-only-custom-client-identifier.network
new file mode 100644 (file)
index 0000000..edd5b7f
--- /dev/null
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+[Match]
+Name=veth99
+
+[Network]
+DHCP=ipv6
+IPv6Token=::1a:2b:3c:4d
+
+[Route]
+Gateway=_ipv6ra
+Destination=2001:1234:5:9fff:ff:ff:ff:ff/128
+
+[DHCPv6]
+DUIDType=custom
+DUIDRawData=00:00:ab:11:f9:2a:c2:77:29:f9:5c:00
index cc10bdfc96b79091975762849ccc976e14e701eb..2257003c0b4261d12b428082bd91a074b8b4227f 100755 (executable)
@@ -5019,6 +5019,41 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
         self.assertIn('DHCPREPLY(veth-peer)', output)
         self.assertNotIn('rapid-commit', output)
 
+    def test_dhcp_client_ipv6_only_with_custom_client_identifier(self):
+        copy_network_unit('25-veth.netdev', '25-dhcp-server-veth-peer.network', '25-dhcp-client-ipv6-only-custom-client-identifier.network')
+
+        start_networkd()
+        self.wait_online(['veth-peer:carrier'])
+        start_dnsmasq()
+        self.wait_online(['veth99:routable', 'veth-peer:routable'])
+
+        # checking address
+        output = check_output('ip address show dev veth99 scope global')
+        print(output)
+        self.assertRegex(output, r'inet6 2600::[0-9a-f:]*/128 scope global dynamic noprefixroute')
+        self.assertNotIn('192.168.5', output)
+
+        # checking semi-static route
+        output = check_output('ip -6 route list dev veth99 2001:1234:5:9fff:ff:ff:ff:ff')
+        print(output)
+        self.assertRegex(output, 'via fe80::1034:56ff:fe78:9abd')
+
+        # Confirm that ipv6 token is not set in the kernel
+        output = check_output('ip token show dev veth99')
+        print(output)
+        self.assertRegex(output, 'token :: dev veth99')
+
+        print('## dnsmasq log')
+        output = read_dnsmasq_log_file()
+        print(output)
+        self.assertIn('DHCPSOLICIT(veth-peer) 00:00:ab:11:f9:2a:c2:77:29:f9:5c:00', output)
+        self.assertNotIn('DHCPADVERTISE(veth-peer)', output)
+        self.assertNotIn('DHCPREQUEST(veth-peer)', output)
+        self.assertIn('DHCPREPLY(veth-peer)', output)
+        self.assertIn('sent size:  0 option: 14 rapid-commit', output)
+
+        stop_dnsmasq()
+
     def test_dhcp_client_ipv4_only(self):
         copy_network_unit('25-veth.netdev', '25-dhcp-server-veth-peer.network', '25-dhcp-client-ipv4-only.network')
 
index 20665e040874a7aad5fa42299e85417108bd4c1b..cb1be8359965080dcaf1a16644487476cfc5595d 100644 (file)
@@ -60,6 +60,11 @@ units = [
           'conditions' : ['ENABLE_INITRD'],
           'symlinks' : ['initrd.target.wants/'],
         },
+        {
+          'file' : 'systemd-bsod.service.in',
+          'conditions' : ['HAVE_QRENCODE','ENABLE_INITRD'],
+          'symlinks' : ['initrd.target.wants/'],
+        },
         {
           'file' : 'initrd-cleanup.service',
           'conditions' : ['ENABLE_INITRD'],
diff --git a/units/systemd-bsod.service.in b/units/systemd-bsod.service.in
new file mode 100644 (file)
index 0000000..306d4a6
--- /dev/null
@@ -0,0 +1,21 @@
+#  SPDX-License-Identifier: LGPL-2.1-or-later
+#
+#  This file is part of systemd.
+#
+#  systemd is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU Lesser General Public License as published by
+#  the Free Software Foundation; either version 2.1 of the License, or
+#  (at your option) any later version.
+
+[Unit]
+Description=Displays emergency message full screen.
+Documentation=man:systemd-bsod(8)
+ConditionVirtualization=no
+DefaultDependencies=no
+Conflicts=shutdown.target
+Before=shutdown.target
+After=systemd-battery-check.service
+
+[Service]
+RemainAfterExit=yes
+ExecStart={{LIBEXECDIR}}/systemd-bsod --continuous