X Tutup
Skip to content

Commit 2a71d57

Browse files
poetteringyuwata
authored andcommitted
network: clean-up DHCP lease server data configuration
This is an attempt to clean up the POP3/SMTP/LPR/… DHCP lease server data logic in networkd. This reduces code duplication and fixes a number of bugs. This removes any support for collecting POP3/SMPT/LPR servers acquired via local DHCP client releases since noone uses that, and given how old these protocols are I doubt this will change. It keeps support for configuring them for the dhcp server however. The differences between the DNS/NTP/SIP/POP3/SMTP/LPR configuration logics are minimized. This removes the relevant symbols from sd-network.h (which is an internal API only at this point after all). This is unfortunately not well test, given the old code for this had barely any tests. But the new code should not perform worse at least, and allow us to release, since it corrects some interfaces visible in the .network configuration format. Fixes: systemd#15943
1 parent d5da3ad commit 2a71d57

File tree

15 files changed

+178
-506
lines changed

15 files changed

+178
-506
lines changed

NEWS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ CHANGES WITH 246 in spe:
7676
field.
7777

7878
* systemd-networkd's [DHCPServer] section gained a new set of options
79-
POP3Servers=, SMTPServers=, LPRServers= for including server
79+
EmitPOP3=/POP3=, EmitSMTP=/SMTP=, EmitLPR=/LPR= for including server
8080
information about these three protocols in the DHCP lease. It also
8181
gained support for including "MUD" URLs ("Manufacturer Usage
8282
Description"). Support for "MUD" URLs was also added to the LLDP

man/systemd.network.xml

Lines changed: 29 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@
578578
<varlistentry>
579579
<term><varname>NTP=</varname></term>
580580
<listitem>
581-
<para>An NTP server address. This option may be specified more than once. This setting is read by
581+
<para>An NTP server address (either an IP address, or a hostname). This option may be specified more than once. This setting is read by
582582
<citerefentry><refentrytitle>systemd-timesyncd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
583583
</listitem>
584584
</varlistentry>
@@ -1412,17 +1412,16 @@
14121412
<varlistentry>
14131413
<term><varname>UseNTP=</varname></term>
14141414
<listitem>
1415-
<para>When true (the default), the NTP servers received
1416-
from the DHCP server will be used by systemd-timesyncd
1417-
and take precedence over any statically configured ones.</para>
1415+
<para>When true (the default), the NTP servers received from the DHCP server will be used by
1416+
<filename>systemd-timesyncd.service</filename> and take precedence over any statically configured
1417+
ones.</para>
14181418
</listitem>
14191419
</varlistentry>
14201420
<varlistentry>
14211421
<term><varname>UseSIP=</varname></term>
14221422
<listitem>
1423-
<para>When true (the default), the SIP servers received
1424-
from the DHCP server will be saved at the state files and can be
1425-
read via <function>sd_network_link_get_sip_servers()</function> function.</para>
1423+
<para>When true (the default), the SIP servers received from the DHCP server will be collected
1424+
and made available to client programs.</para>
14261425
</listitem>
14271426
</varlistentry>
14281427

@@ -2010,79 +2009,37 @@
20102009
<term><varname>EmitDNS=</varname></term>
20112010
<term><varname>DNS=</varname></term>
20122011

2013-
<listitem><para>Takes a boolean. Configures whether the DHCP leases handed out
2014-
to clients shall contain DNS server information. Defaults to <literal>yes</literal>.
2015-
The DNS servers to pass to clients may be configured with the
2016-
<varname>DNS=</varname> option, which takes a list of IPv4
2017-
addresses. If the <varname>EmitDNS=</varname> option is
2018-
enabled but no servers configured, the servers are
2019-
automatically propagated from an "uplink" interface that has
2020-
appropriate servers set. The "uplink" interface is determined
2021-
by the default route of the system with the highest
2022-
priority. Note that this information is acquired at the time
2023-
the lease is handed out, and does not take uplink interfaces
2024-
into account that acquire DNS or NTP server information at a
2025-
later point. DNS server propagation does not take
2026-
<filename>/etc/resolv.conf</filename> into account. Also, note
2027-
that the leases are not refreshed if the uplink network
2028-
configuration changes. To ensure clients regularly acquire the
2029-
most current uplink DNS server information, it is thus
2030-
advisable to shorten the DHCP lease time via
2031-
<varname>MaxLeaseTimeSec=</varname> described
2012+
<listitem><para><varname>EmitDNS=</varname> takes a boolean. Configures whether the DHCP leases
2013+
handed out to clients shall contain DNS server information. Defaults to <literal>yes</literal>. The
2014+
DNS servers to pass to clients may be configured with the <varname>DNS=</varname> option, which takes
2015+
a list of IPv4 addresses. If the <varname>EmitDNS=</varname> option is enabled but no servers
2016+
configured, the servers are automatically propagated from an "uplink" interface that has appropriate
2017+
servers set. The "uplink" interface is determined by the default route of the system with the highest
2018+
priority. Note that this information is acquired at the time the lease is handed out, and does not
2019+
take uplink interfaces into account that acquire DNS server information at a later point. If no
2020+
suitable uplinkg interface is found the DNS server data from <filename>/etc/resolv.conf</filename> is
2021+
used. Also, note that the leases are not refreshed if the uplink network configuration changes. To
2022+
ensure clients regularly acquire the most current uplink DNS server information, it is thus advisable
2023+
to shorten the DHCP lease time via <varname>MaxLeaseTimeSec=</varname> described
20322024
above.</para></listitem>
20332025
</varlistentry>
20342026

20352027
<varlistentry>
20362028
<term><varname>EmitNTP=</varname></term>
20372029
<term><varname>NTP=</varname></term>
2038-
2039-
<listitem><para>Similar to the <varname>EmitDNS=</varname> and
2040-
<varname>DNS=</varname> settings described above, these
2041-
settings configure whether and what NTP server information
2042-
shall be emitted as part of the DHCP lease. The same syntax,
2043-
propagation semantics and defaults apply as for
2044-
<varname>EmitDNS=</varname> and
2045-
<varname>DNS=</varname>.</para></listitem>
2046-
</varlistentry>
2047-
2048-
<varlistentry>
20492030
<term><varname>EmitSIP=</varname></term>
20502031
<term><varname>SIP=</varname></term>
2051-
2052-
<listitem><para>Similar to the <varname>EmitDNS=</varname> and
2053-
<varname>DNS=</varname> settings described above, these
2054-
settings configure whether and what SIP server information
2055-
shall be emitted as part of the DHCP lease. The same syntax,
2056-
propagation semantics and defaults apply as for
2057-
<varname>EmitDNS=</varname> and
2058-
<varname>DNS=</varname>.</para></listitem>
2059-
</varlistentry>
2060-
2061-
<varlistentry>
2062-
<term><varname>POP3Servers=</varname></term>
2063-
2064-
<listitem><para>Similar to the <varname>DNS=</varname> setting described above, this setting
2065-
configures whether and what POP3 server information shall be emitted as part of the DHCP lease. The
2066-
same syntax, propagation semantics and defaults apply as for
2067-
<varname>DNS=</varname>.</para></listitem>
2068-
</varlistentry>
2069-
2070-
<varlistentry>
2071-
<term><varname>SMTPServers=</varname></term>
2072-
2073-
<listitem><para>Similar to the <varname>DNS=</varname> setting described above, this
2074-
setting configures whether and what SMTP server information shall be emitted as part of
2075-
the DHCP lease. The same syntax, propagation semantics and defaults apply as for
2076-
<varname>DNS=</varname>.</para></listitem>
2077-
</varlistentry>
2078-
2079-
<varlistentry>
2080-
<term><varname>LPRServers=</varname></term>
2081-
2082-
<listitem><para>Similar to the <varname>DNS=</varname> setting described above, this
2083-
setting configures whether and what LPR (line printer) server information shall be emitted
2084-
as part of the DHCP lease. The same syntax, propagation semantics and defaults apply as for
2085-
<varname>DNS=</varname>.</para></listitem>
2032+
<term><varname>EmitPOP3=</varname></term>
2033+
<term><varname>POP3=</varname></term>
2034+
<term><varname>EmitSMTP=</varname></term>
2035+
<term><varname>SMTP=</varname></term>
2036+
<term><varname>EmitLPR=</varname></term>
2037+
<term><varname>LPR=</varname></term>
2038+
2039+
<listitem><para>Similar to the <varname>EmitDNS=</varname> and <varname>DNS=</varname> settings
2040+
described above, these settings configure whether and what server information for the indicate
2041+
protocol shall be emitted as part of the DHCP lease. The same syntax, propagation semantics and
2042+
defaults apply as for <varname>EmitDNS=</varname> and <varname>DNS=</varname>.</para></listitem>
20862043
</varlistentry>
20872044

20882045
<varlistentry>

src/libsystemd/sd-network/sd-network.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -264,22 +264,6 @@ _public_ int sd_network_link_get_route_domains(int ifindex, char ***ret) {
264264
return network_link_get_strv(ifindex, "ROUTE_DOMAINS", ret);
265265
}
266266

267-
_public_ int sd_network_link_get_sip_servers(int ifindex, char ***ret) {
268-
return network_link_get_strv(ifindex, "SIP", ret);
269-
}
270-
271-
_public_ int sd_network_link_get_pop3_servers(int ifindex, char ***pop3) {
272-
return network_link_get_strv(ifindex, "POP3_SERVERS", pop3);
273-
}
274-
275-
_public_ int sd_network_link_get_smtp_servers(int ifindex, char ***ret) {
276-
return network_link_get_strv(ifindex, "SMTP_SERVERS", ret);
277-
}
278-
279-
_public_ int sd_network_link_get_lpr_servers(int ifindex, char ***ret) {
280-
return network_link_get_strv(ifindex, "LPR_SERVERS", ret);
281-
}
282-
283267
_public_ int sd_network_link_get_dns_default_route(int ifindex) {
284268
char path[STRLEN("/run/systemd/netif/links/") + DECIMAL_STR_MAX(ifindex) + 1];
285269
_cleanup_free_ char *s = NULL;

src/network/networkctl.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,8 +1378,7 @@ static int link_status_one(
13781378
sd_hwdb *hwdb,
13791379
const LinkInfo *info) {
13801380

1381-
_cleanup_strv_free_ char **dns = NULL, **ntp = NULL, **sip = NULL, **search_domains = NULL, **route_domains = NULL,
1382-
**pop3_server = NULL, **smtp_server = NULL, **lpr_server = NULL;
1381+
_cleanup_strv_free_ char **dns = NULL, **ntp = NULL, **sip = NULL, **search_domains = NULL, **route_domains = NULL;
13831382
_cleanup_free_ char *t = NULL, *network = NULL, *client_id = NULL, *iaid = NULL, *duid = NULL;
13841383
const char *driver = NULL, *path = NULL, *vendor = NULL, *model = NULL, *link = NULL;
13851384
_cleanup_free_ char *setup_state = NULL, *operational_state = NULL, *tz = NULL;
@@ -1406,9 +1405,6 @@ static int link_status_one(
14061405
(void) sd_network_link_get_route_domains(info->ifindex, &route_domains);
14071406
(void) sd_network_link_get_ntp(info->ifindex, &ntp);
14081407
(void) sd_network_link_get_sip(info->ifindex, &sip);
1409-
(void) sd_network_link_get_pop3_servers(info->ifindex, &pop3_server);
1410-
(void) sd_network_link_get_smtp_servers(info->ifindex, &smtp_server);
1411-
(void) sd_network_link_get_lpr_servers(info->ifindex, &lpr_server);
14121408

14131409
if (info->sd_device) {
14141410
(void) sd_device_get_property_value(info->sd_device, "ID_NET_LINK_FILE", &link);
@@ -2045,15 +2041,6 @@ static int link_status_one(
20452041
if (r < 0)
20462042
return r;
20472043
r = dump_list(table, "SIP:", sip);
2048-
if (r < 0)
2049-
return r;
2050-
r = dump_list(table, "POP3 servers:", pop3_server);
2051-
if (r < 0)
2052-
return r;
2053-
r = dump_list(table, "SMTP servers:", smtp_server);
2054-
if (r < 0)
2055-
return r;
2056-
r = dump_list(table, "LPR servers:", lpr_server);
20572044
if (r < 0)
20582045
return r;
20592046
r = dump_ifindexes(table, "Carrier Bound To:", carrier_bound_to);

0 commit comments

Comments
 (0)
X Tutup