mirror of
https://github.com/systemd/systemd.git
synced 2025-01-10 05:18:17 +03:00
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: #15943
This commit is contained in:
parent
d5da3ada8e
commit
2a71d57f4e
2
NEWS
2
NEWS
@ -76,7 +76,7 @@ CHANGES WITH 246 in spe:
|
|||||||
field.
|
field.
|
||||||
|
|
||||||
* systemd-networkd's [DHCPServer] section gained a new set of options
|
* systemd-networkd's [DHCPServer] section gained a new set of options
|
||||||
POP3Servers=, SMTPServers=, LPRServers= for including server
|
EmitPOP3=/POP3=, EmitSMTP=/SMTP=, EmitLPR=/LPR= for including server
|
||||||
information about these three protocols in the DHCP lease. It also
|
information about these three protocols in the DHCP lease. It also
|
||||||
gained support for including "MUD" URLs ("Manufacturer Usage
|
gained support for including "MUD" URLs ("Manufacturer Usage
|
||||||
Description"). Support for "MUD" URLs was also added to the LLDP
|
Description"). Support for "MUD" URLs was also added to the LLDP
|
||||||
|
@ -578,7 +578,7 @@
|
|||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><varname>NTP=</varname></term>
|
<term><varname>NTP=</varname></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>An NTP server address. This option may be specified more than once. This setting is read by
|
<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
|
||||||
<citerefentry><refentrytitle>systemd-timesyncd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
|
<citerefentry><refentrytitle>systemd-timesyncd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
@ -1412,17 +1412,16 @@
|
|||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><varname>UseNTP=</varname></term>
|
<term><varname>UseNTP=</varname></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>When true (the default), the NTP servers received
|
<para>When true (the default), the NTP servers received from the DHCP server will be used by
|
||||||
from the DHCP server will be used by systemd-timesyncd
|
<filename>systemd-timesyncd.service</filename> and take precedence over any statically configured
|
||||||
and take precedence over any statically configured ones.</para>
|
ones.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><varname>UseSIP=</varname></term>
|
<term><varname>UseSIP=</varname></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>When true (the default), the SIP servers received
|
<para>When true (the default), the SIP servers received from the DHCP server will be collected
|
||||||
from the DHCP server will be saved at the state files and can be
|
and made available to client programs.</para>
|
||||||
read via <function>sd_network_link_get_sip_servers()</function> function.</para>
|
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
@ -2010,79 +2009,37 @@
|
|||||||
<term><varname>EmitDNS=</varname></term>
|
<term><varname>EmitDNS=</varname></term>
|
||||||
<term><varname>DNS=</varname></term>
|
<term><varname>DNS=</varname></term>
|
||||||
|
|
||||||
<listitem><para>Takes a boolean. Configures whether the DHCP leases handed out
|
<listitem><para><varname>EmitDNS=</varname> takes a boolean. Configures whether the DHCP leases
|
||||||
to clients shall contain DNS server information. Defaults to <literal>yes</literal>.
|
handed out to clients shall contain DNS server information. Defaults to <literal>yes</literal>. The
|
||||||
The DNS servers to pass to clients may be configured with the
|
DNS servers to pass to clients may be configured with the <varname>DNS=</varname> option, which takes
|
||||||
<varname>DNS=</varname> option, which takes a list of IPv4
|
a list of IPv4 addresses. If the <varname>EmitDNS=</varname> option is enabled but no servers
|
||||||
addresses. If the <varname>EmitDNS=</varname> option is
|
configured, the servers are automatically propagated from an "uplink" interface that has appropriate
|
||||||
enabled but no servers configured, the servers are
|
servers set. The "uplink" interface is determined by the default route of the system with the highest
|
||||||
automatically propagated from an "uplink" interface that has
|
priority. Note that this information is acquired at the time the lease is handed out, and does not
|
||||||
appropriate servers set. The "uplink" interface is determined
|
take uplink interfaces into account that acquire DNS server information at a later point. If no
|
||||||
by the default route of the system with the highest
|
suitable uplinkg interface is found the DNS server data from <filename>/etc/resolv.conf</filename> is
|
||||||
priority. Note that this information is acquired at the time
|
used. Also, note that the leases are not refreshed if the uplink network configuration changes. To
|
||||||
the lease is handed out, and does not take uplink interfaces
|
ensure clients regularly acquire the most current uplink DNS server information, it is thus advisable
|
||||||
into account that acquire DNS or NTP server information at a
|
to shorten the DHCP lease time via <varname>MaxLeaseTimeSec=</varname> described
|
||||||
later point. DNS server propagation does not take
|
|
||||||
<filename>/etc/resolv.conf</filename> into account. Also, note
|
|
||||||
that the leases are not refreshed if the uplink network
|
|
||||||
configuration changes. To ensure clients regularly acquire the
|
|
||||||
most current uplink DNS server information, it is thus
|
|
||||||
advisable to shorten the DHCP lease time via
|
|
||||||
<varname>MaxLeaseTimeSec=</varname> described
|
|
||||||
above.</para></listitem>
|
above.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><varname>EmitNTP=</varname></term>
|
<term><varname>EmitNTP=</varname></term>
|
||||||
<term><varname>NTP=</varname></term>
|
<term><varname>NTP=</varname></term>
|
||||||
|
|
||||||
<listitem><para>Similar to the <varname>EmitDNS=</varname> and
|
|
||||||
<varname>DNS=</varname> settings described above, these
|
|
||||||
settings configure whether and what NTP server information
|
|
||||||
shall be emitted as part of the DHCP lease. The same syntax,
|
|
||||||
propagation semantics and defaults apply as for
|
|
||||||
<varname>EmitDNS=</varname> and
|
|
||||||
<varname>DNS=</varname>.</para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><varname>EmitSIP=</varname></term>
|
<term><varname>EmitSIP=</varname></term>
|
||||||
<term><varname>SIP=</varname></term>
|
<term><varname>SIP=</varname></term>
|
||||||
|
<term><varname>EmitPOP3=</varname></term>
|
||||||
|
<term><varname>POP3=</varname></term>
|
||||||
|
<term><varname>EmitSMTP=</varname></term>
|
||||||
|
<term><varname>SMTP=</varname></term>
|
||||||
|
<term><varname>EmitLPR=</varname></term>
|
||||||
|
<term><varname>LPR=</varname></term>
|
||||||
|
|
||||||
<listitem><para>Similar to the <varname>EmitDNS=</varname> and
|
<listitem><para>Similar to the <varname>EmitDNS=</varname> and <varname>DNS=</varname> settings
|
||||||
<varname>DNS=</varname> settings described above, these
|
described above, these settings configure whether and what server information for the indicate
|
||||||
settings configure whether and what SIP server information
|
protocol shall be emitted as part of the DHCP lease. The same syntax, propagation semantics and
|
||||||
shall be emitted as part of the DHCP lease. The same syntax,
|
defaults apply as for <varname>EmitDNS=</varname> and <varname>DNS=</varname>.</para></listitem>
|
||||||
propagation semantics and defaults apply as for
|
|
||||||
<varname>EmitDNS=</varname> and
|
|
||||||
<varname>DNS=</varname>.</para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><varname>POP3Servers=</varname></term>
|
|
||||||
|
|
||||||
<listitem><para>Similar to the <varname>DNS=</varname> setting described above, this setting
|
|
||||||
configures whether and what POP3 server information shall be emitted as part of the DHCP lease. The
|
|
||||||
same syntax, propagation semantics and defaults apply as for
|
|
||||||
<varname>DNS=</varname>.</para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><varname>SMTPServers=</varname></term>
|
|
||||||
|
|
||||||
<listitem><para>Similar to the <varname>DNS=</varname> setting described above, this
|
|
||||||
setting configures whether and what SMTP server information shall be emitted as part of
|
|
||||||
the DHCP lease. The same syntax, propagation semantics and defaults apply as for
|
|
||||||
<varname>DNS=</varname>.</para></listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><varname>LPRServers=</varname></term>
|
|
||||||
|
|
||||||
<listitem><para>Similar to the <varname>DNS=</varname> setting described above, this
|
|
||||||
setting configures whether and what LPR (line printer) server information shall be emitted
|
|
||||||
as part of the DHCP lease. The same syntax, propagation semantics and defaults apply as for
|
|
||||||
<varname>DNS=</varname>.</para></listitem>
|
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
|
@ -264,22 +264,6 @@ _public_ int sd_network_link_get_route_domains(int ifindex, char ***ret) {
|
|||||||
return network_link_get_strv(ifindex, "ROUTE_DOMAINS", ret);
|
return network_link_get_strv(ifindex, "ROUTE_DOMAINS", ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
_public_ int sd_network_link_get_sip_servers(int ifindex, char ***ret) {
|
|
||||||
return network_link_get_strv(ifindex, "SIP", ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
_public_ int sd_network_link_get_pop3_servers(int ifindex, char ***pop3) {
|
|
||||||
return network_link_get_strv(ifindex, "POP3_SERVERS", pop3);
|
|
||||||
}
|
|
||||||
|
|
||||||
_public_ int sd_network_link_get_smtp_servers(int ifindex, char ***ret) {
|
|
||||||
return network_link_get_strv(ifindex, "SMTP_SERVERS", ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
_public_ int sd_network_link_get_lpr_servers(int ifindex, char ***ret) {
|
|
||||||
return network_link_get_strv(ifindex, "LPR_SERVERS", ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
_public_ int sd_network_link_get_dns_default_route(int ifindex) {
|
_public_ int sd_network_link_get_dns_default_route(int ifindex) {
|
||||||
char path[STRLEN("/run/systemd/netif/links/") + DECIMAL_STR_MAX(ifindex) + 1];
|
char path[STRLEN("/run/systemd/netif/links/") + DECIMAL_STR_MAX(ifindex) + 1];
|
||||||
_cleanup_free_ char *s = NULL;
|
_cleanup_free_ char *s = NULL;
|
||||||
|
@ -1378,8 +1378,7 @@ static int link_status_one(
|
|||||||
sd_hwdb *hwdb,
|
sd_hwdb *hwdb,
|
||||||
const LinkInfo *info) {
|
const LinkInfo *info) {
|
||||||
|
|
||||||
_cleanup_strv_free_ char **dns = NULL, **ntp = NULL, **sip = NULL, **search_domains = NULL, **route_domains = NULL,
|
_cleanup_strv_free_ char **dns = NULL, **ntp = NULL, **sip = NULL, **search_domains = NULL, **route_domains = NULL;
|
||||||
**pop3_server = NULL, **smtp_server = NULL, **lpr_server = NULL;
|
|
||||||
_cleanup_free_ char *t = NULL, *network = NULL, *client_id = NULL, *iaid = NULL, *duid = NULL;
|
_cleanup_free_ char *t = NULL, *network = NULL, *client_id = NULL, *iaid = NULL, *duid = NULL;
|
||||||
const char *driver = NULL, *path = NULL, *vendor = NULL, *model = NULL, *link = NULL;
|
const char *driver = NULL, *path = NULL, *vendor = NULL, *model = NULL, *link = NULL;
|
||||||
_cleanup_free_ char *setup_state = NULL, *operational_state = NULL, *tz = NULL;
|
_cleanup_free_ char *setup_state = NULL, *operational_state = NULL, *tz = NULL;
|
||||||
@ -1406,9 +1405,6 @@ static int link_status_one(
|
|||||||
(void) sd_network_link_get_route_domains(info->ifindex, &route_domains);
|
(void) sd_network_link_get_route_domains(info->ifindex, &route_domains);
|
||||||
(void) sd_network_link_get_ntp(info->ifindex, &ntp);
|
(void) sd_network_link_get_ntp(info->ifindex, &ntp);
|
||||||
(void) sd_network_link_get_sip(info->ifindex, &sip);
|
(void) sd_network_link_get_sip(info->ifindex, &sip);
|
||||||
(void) sd_network_link_get_pop3_servers(info->ifindex, &pop3_server);
|
|
||||||
(void) sd_network_link_get_smtp_servers(info->ifindex, &smtp_server);
|
|
||||||
(void) sd_network_link_get_lpr_servers(info->ifindex, &lpr_server);
|
|
||||||
|
|
||||||
if (info->sd_device) {
|
if (info->sd_device) {
|
||||||
(void) sd_device_get_property_value(info->sd_device, "ID_NET_LINK_FILE", &link);
|
(void) sd_device_get_property_value(info->sd_device, "ID_NET_LINK_FILE", &link);
|
||||||
@ -2045,15 +2041,6 @@ static int link_status_one(
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
r = dump_list(table, "SIP:", sip);
|
r = dump_list(table, "SIP:", sip);
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
r = dump_list(table, "POP3 servers:", pop3_server);
|
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
r = dump_list(table, "SMTP servers:", smtp_server);
|
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
r = dump_list(table, "LPR servers:", lpr_server);
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
r = dump_ifindexes(table, "Carrier Bound To:", carrier_bound_to);
|
r = dump_ifindexes(table, "Carrier Bound To:", carrier_bound_to);
|
||||||
|
@ -34,49 +34,6 @@ static Address* link_find_dhcp_server_address(Link *link) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int link_push_uplink_dns_to_dhcp_server(Link *link, sd_dhcp_server *s) {
|
|
||||||
_cleanup_free_ struct in_addr *addresses = NULL;
|
|
||||||
size_t n_addresses = 0, n_allocated = 0;
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < link->network->n_dns; i++) {
|
|
||||||
struct in_addr ia;
|
|
||||||
|
|
||||||
/* Only look for IPv4 addresses */
|
|
||||||
if (link->network->dns[i].family != AF_INET)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
ia = link->network->dns[i].address.in;
|
|
||||||
|
|
||||||
/* Never propagate obviously borked data */
|
|
||||||
if (in4_addr_is_null(&ia) || in4_addr_is_localhost(&ia))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!GREEDY_REALLOC(addresses, n_allocated, n_addresses + 1))
|
|
||||||
return log_oom();
|
|
||||||
|
|
||||||
addresses[n_addresses++] = ia;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (link->network->dhcp_use_dns && link->dhcp_lease) {
|
|
||||||
const struct in_addr *da;
|
|
||||||
|
|
||||||
int n = sd_dhcp_lease_get_dns(link->dhcp_lease, &da);
|
|
||||||
if (n > 0) {
|
|
||||||
if (!GREEDY_REALLOC(addresses, n_allocated, n_addresses + n))
|
|
||||||
return log_oom();
|
|
||||||
|
|
||||||
for (int j = 0; j < n; j++)
|
|
||||||
if (in4_addr_is_non_local(&da[j]))
|
|
||||||
addresses[n_addresses++] = da[j];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (n_addresses <= 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return sd_dhcp_server_set_dns(s, addresses, n_addresses);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int link_push_uplink_to_dhcp_server(
|
static int link_push_uplink_to_dhcp_server(
|
||||||
Link *link,
|
Link *link,
|
||||||
sd_dhcp_lease_server_type what,
|
sd_dhcp_lease_server_type what,
|
||||||
@ -84,68 +41,88 @@ static int link_push_uplink_to_dhcp_server(
|
|||||||
|
|
||||||
_cleanup_free_ struct in_addr *addresses = NULL;
|
_cleanup_free_ struct in_addr *addresses = NULL;
|
||||||
size_t n_addresses = 0, n_allocated = 0;
|
size_t n_addresses = 0, n_allocated = 0;
|
||||||
bool lease_condition;
|
bool use_dhcp_lease_data = true;
|
||||||
char **servers;
|
|
||||||
|
assert(link);
|
||||||
|
|
||||||
if (!link->network)
|
if (!link->network)
|
||||||
return 0;
|
return 0;
|
||||||
|
assert(link->network);
|
||||||
|
|
||||||
log_link_debug(link, "Copying %s from link", dhcp_lease_server_type_to_string(what));
|
log_link_debug(link, "Copying %s from link", dhcp_lease_server_type_to_string(what));
|
||||||
|
|
||||||
switch (what) {
|
switch (what) {
|
||||||
case SD_DHCP_LEASE_DNS:
|
|
||||||
/* DNS servers are stored as parsed data, so special handling is required.
|
|
||||||
* TODO: check if DNS servers should be stored unparsed too. */
|
|
||||||
return link_push_uplink_dns_to_dhcp_server(link, s);
|
|
||||||
|
|
||||||
case SD_DHCP_LEASE_NTP:
|
case SD_DHCP_LEASE_DNS:
|
||||||
servers = link->network->ntp;
|
/* For DNS we have a special case. We the data configured explicitly locally along with the
|
||||||
lease_condition = link->network->dhcp_use_ntp;
|
* data from the DHCP lease. */
|
||||||
|
|
||||||
|
for (unsigned i = 0; i < link->network->n_dns; i++) {
|
||||||
|
struct in_addr ia;
|
||||||
|
|
||||||
|
/* Only look for IPv4 addresses */
|
||||||
|
if (link->network->dns[i].family != AF_INET)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
ia = link->network->dns[i].address.in;
|
||||||
|
|
||||||
|
/* Never propagate obviously borked data */
|
||||||
|
if (in4_addr_is_null(&ia) || in4_addr_is_localhost(&ia))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!GREEDY_REALLOC(addresses, n_allocated, n_addresses + 1))
|
||||||
|
return log_oom();
|
||||||
|
|
||||||
|
addresses[n_addresses++] = ia;
|
||||||
|
}
|
||||||
|
|
||||||
|
use_dhcp_lease_data = link->network->dhcp_use_dns;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SD_DHCP_LEASE_NTP: {
|
||||||
|
char **i;
|
||||||
|
|
||||||
|
/* For NTP things are similar, but for NTP hostnames can be configured too, which we cannot
|
||||||
|
* propagate via DHCP. Hence let's only propagate those which are IP addresses. */
|
||||||
|
|
||||||
|
STRV_FOREACH(i, link->network->ntp) {
|
||||||
|
union in_addr_union ia;
|
||||||
|
|
||||||
|
if (in_addr_from_string(AF_INET, *i, &ia) < 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* Never propagate obviously borked data */
|
||||||
|
if (in4_addr_is_null(&ia.in) || in4_addr_is_localhost(&ia.in))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!GREEDY_REALLOC(addresses, n_allocated, n_addresses + 1))
|
||||||
|
return log_oom();
|
||||||
|
|
||||||
|
addresses[n_addresses++] = ia.in;
|
||||||
|
}
|
||||||
|
|
||||||
|
use_dhcp_lease_data = link->network->dhcp_use_ntp;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case SD_DHCP_LEASE_SIP:
|
||||||
|
|
||||||
|
/* For SIP we don't allow explicit, local configuration, but there's control whether to use the data */
|
||||||
|
use_dhcp_lease_data = link->network->dhcp_use_sip;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SD_DHCP_LEASE_POP3:
|
case SD_DHCP_LEASE_POP3:
|
||||||
servers = link->network->pop3;
|
|
||||||
lease_condition = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SD_DHCP_LEASE_SMTP:
|
case SD_DHCP_LEASE_SMTP:
|
||||||
servers = link->network->smtp;
|
|
||||||
lease_condition = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SD_DHCP_LEASE_SIP:
|
|
||||||
servers = link->network->sip;
|
|
||||||
lease_condition = link->network->dhcp_use_sip;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SD_DHCP_LEASE_LPR:
|
case SD_DHCP_LEASE_LPR:
|
||||||
servers = link->network->lpr;
|
/* For the other server types we currently do not allow local configuration of server data,
|
||||||
lease_condition = true;
|
* since there are typically no local consumers of the data. */
|
||||||
break;
|
;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert_not_reached("Unknown DHCP lease info item");
|
assert_not_reached("Unexpected server type");
|
||||||
}
|
}
|
||||||
|
|
||||||
char **a;
|
if (use_dhcp_lease_data && link->dhcp_lease) {
|
||||||
STRV_FOREACH(a, servers) {
|
|
||||||
union in_addr_union ia;
|
|
||||||
|
|
||||||
/* Only look for IPv4 addresses */
|
|
||||||
if (in_addr_from_string(AF_INET, *a, &ia) <= 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* Never propagate obviously borked data */
|
|
||||||
if (in4_addr_is_null(&ia.in) || in4_addr_is_localhost(&ia.in))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!GREEDY_REALLOC(addresses, n_allocated, n_addresses + 1))
|
|
||||||
return log_oom();
|
|
||||||
|
|
||||||
addresses[n_addresses++] = ia.in;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lease_condition && link->dhcp_lease) {
|
|
||||||
const struct in_addr *da;
|
const struct in_addr *da;
|
||||||
|
|
||||||
int n = sd_dhcp_lease_get_servers(link->dhcp_lease, what, &da);
|
int n = sd_dhcp_lease_get_servers(link->dhcp_lease, what, &da);
|
||||||
@ -153,9 +130,9 @@ static int link_push_uplink_to_dhcp_server(
|
|||||||
if (!GREEDY_REALLOC(addresses, n_allocated, n_addresses + n))
|
if (!GREEDY_REALLOC(addresses, n_allocated, n_addresses + n))
|
||||||
return log_oom();
|
return log_oom();
|
||||||
|
|
||||||
for (int i = 0; i < n; i++)
|
for (int j = 0; j < n; j++)
|
||||||
if (in4_addr_is_non_local(&da[i]))
|
if (in4_addr_is_non_local(&da[j]))
|
||||||
addresses[n_addresses++] = da[i];
|
addresses[n_addresses++] = da[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,71 +262,43 @@ int dhcp4_server_configure(Link *link) {
|
|||||||
return log_link_error_errno(link, r, "Failed to set default lease time for DHCPv4 server instance: %m");
|
return log_link_error_errno(link, r, "Failed to set default lease time for DHCPv4 server instance: %m");
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct {
|
for (sd_dhcp_lease_server_type type = 0; type < _SD_DHCP_LEASE_SERVER_TYPE_MAX; type ++) {
|
||||||
bool condition;
|
|
||||||
const struct in_addr *servers;
|
|
||||||
unsigned n_servers;
|
|
||||||
} configs[] = {
|
|
||||||
[SD_DHCP_LEASE_DNS] = {
|
|
||||||
link->network->dhcp_server_emit_dns,
|
|
||||||
link->network->dhcp_server_dns,
|
|
||||||
link->network->n_dhcp_server_dns,
|
|
||||||
},
|
|
||||||
[SD_DHCP_LEASE_NTP] = {
|
|
||||||
link->network->dhcp_server_emit_ntp,
|
|
||||||
link->network->dhcp_server_ntp,
|
|
||||||
link->network->n_dhcp_server_ntp,
|
|
||||||
},
|
|
||||||
[SD_DHCP_LEASE_SIP] = {
|
|
||||||
link->network->dhcp_server_emit_sip,
|
|
||||||
link->network->dhcp_server_sip,
|
|
||||||
link->network->n_dhcp_server_sip,
|
|
||||||
},
|
|
||||||
[SD_DHCP_LEASE_POP3] = {
|
|
||||||
true,
|
|
||||||
link->network->dhcp_server_pop3,
|
|
||||||
link->network->n_dhcp_server_pop3,
|
|
||||||
},
|
|
||||||
[SD_DHCP_LEASE_SMTP] = {
|
|
||||||
true,
|
|
||||||
link->network->dhcp_server_smtp,
|
|
||||||
link->network->n_dhcp_server_smtp,
|
|
||||||
},
|
|
||||||
[SD_DHCP_LEASE_LPR] = {
|
|
||||||
true,
|
|
||||||
link->network->dhcp_server_lpr,
|
|
||||||
link->network->n_dhcp_server_lpr,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
assert_cc(ELEMENTSOF(configs) == _SD_DHCP_LEASE_SERVER_TYPE_MAX);
|
|
||||||
|
|
||||||
for (unsigned n = 0; n < ELEMENTSOF(configs); n++)
|
if (!link->network->dhcp_server_emit[type].emit)
|
||||||
if (configs[n].condition) {
|
continue;
|
||||||
if (configs[n].n_servers > 0)
|
|
||||||
r = sd_dhcp_server_set_servers(link->dhcp_server, n,
|
|
||||||
configs[n].servers, configs[n].n_servers);
|
|
||||||
else {
|
|
||||||
if (!acquired_uplink) {
|
|
||||||
uplink = manager_find_uplink(link->manager, link);
|
|
||||||
acquired_uplink = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!uplink) {
|
if (link->network->dhcp_server_emit[type].n_addresses > 0)
|
||||||
log_link_debug(link,
|
/* Explicitly specified servers to emit */
|
||||||
"Not emitting %s on link, couldn't find suitable uplink.",
|
r = sd_dhcp_server_set_servers(
|
||||||
dhcp_lease_server_type_to_string(n));
|
link->dhcp_server,
|
||||||
r = 0;
|
type,
|
||||||
} else if (uplink->network)
|
link->network->dhcp_server_emit[type].addresses,
|
||||||
r = link_push_uplink_to_dhcp_server(uplink, n, link->dhcp_server);
|
link->network->dhcp_server_emit[type].n_addresses);
|
||||||
else if (n == SD_DHCP_LEASE_DNS)
|
else {
|
||||||
r = dhcp4_server_set_dns_from_resolve_conf(link);
|
/* Emission is requested, but nothing explicitly configured. Let's find a suitable upling */
|
||||||
|
if (!acquired_uplink) {
|
||||||
|
uplink = manager_find_uplink(link->manager, link);
|
||||||
|
acquired_uplink = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uplink && uplink->network)
|
||||||
|
r = link_push_uplink_to_dhcp_server(uplink, type, link->dhcp_server);
|
||||||
|
else if (type == SD_DHCP_LEASE_DNS)
|
||||||
|
r = dhcp4_server_set_dns_from_resolve_conf(link);
|
||||||
|
else {
|
||||||
|
log_link_debug(link,
|
||||||
|
"Not emitting %s on link, couldn't find suitable uplink.",
|
||||||
|
dhcp_lease_server_type_to_string(type));
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
if (r < 0)
|
|
||||||
log_link_warning_errno(link, r,
|
|
||||||
"Failed to set %s for DHCP server, ignoring: %m",
|
|
||||||
dhcp_lease_server_type_to_string(n));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (r < 0)
|
||||||
|
log_link_warning_errno(link, r,
|
||||||
|
"Failed to set %s for DHCP server, ignoring: %m",
|
||||||
|
dhcp_lease_server_type_to_string(type));
|
||||||
|
}
|
||||||
|
|
||||||
r = sd_dhcp_server_set_emit_router(link->dhcp_server, link->network->dhcp_server_emit_router);
|
r = sd_dhcp_server_set_emit_router(link->dhcp_server, link->network->dhcp_server_emit_router);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_link_error_errno(link, r, "Failed to set router emission for DHCP server: %m");
|
return log_link_error_errno(link, r, "Failed to set router emission for DHCP server: %m");
|
||||||
@ -398,17 +347,21 @@ int dhcp4_server_configure(Link *link) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int config_parse_dhcp_lease_server_list(
|
int config_parse_dhcp_server_emit(
|
||||||
const char *unit,
|
const char *unit,
|
||||||
const char *filename,
|
const char *filename,
|
||||||
unsigned line,
|
unsigned line,
|
||||||
|
const char *section,
|
||||||
|
unsigned section_line,
|
||||||
const char *lvalue,
|
const char *lvalue,
|
||||||
|
int ltype,
|
||||||
const char *rvalue,
|
const char *rvalue,
|
||||||
struct in_addr **addresses,
|
void *data,
|
||||||
unsigned *n_addresses) {
|
void *userdata) {
|
||||||
|
|
||||||
assert(filename);
|
NetworkDHCPServerEmitAddress *emit = data;
|
||||||
assert(lvalue);
|
|
||||||
|
assert(emit);
|
||||||
assert(rvalue);
|
assert(rvalue);
|
||||||
|
|
||||||
for (const char *p = rvalue;;) {
|
for (const char *p = rvalue;;) {
|
||||||
@ -434,127 +387,11 @@ static int config_parse_dhcp_lease_server_list(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct in_addr *m = reallocarray(*addresses, *n_addresses + 1, sizeof(struct in_addr));
|
struct in_addr *m = reallocarray(emit->addresses, emit->n_addresses + 1, sizeof(struct in_addr));
|
||||||
if (!m)
|
if (!m)
|
||||||
return log_oom();
|
return log_oom();
|
||||||
|
|
||||||
m[(*n_addresses)++] = a.in;
|
emit->addresses = m;
|
||||||
*addresses = m;
|
emit->addresses[emit->n_addresses++] = a.in;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int config_parse_dhcp_server_dns(
|
|
||||||
const char *unit,
|
|
||||||
const char *filename,
|
|
||||||
unsigned line,
|
|
||||||
const char *section,
|
|
||||||
unsigned section_line,
|
|
||||||
const char *lvalue,
|
|
||||||
int ltype,
|
|
||||||
const char *rvalue,
|
|
||||||
void *data,
|
|
||||||
void *userdata) {
|
|
||||||
|
|
||||||
Network *n = data;
|
|
||||||
|
|
||||||
return config_parse_dhcp_lease_server_list(unit, filename, line,
|
|
||||||
lvalue, rvalue,
|
|
||||||
&n->dhcp_server_dns, &n->n_dhcp_server_dns);
|
|
||||||
}
|
|
||||||
|
|
||||||
int config_parse_dhcp_server_ntp(
|
|
||||||
const char *unit,
|
|
||||||
const char *filename,
|
|
||||||
unsigned line,
|
|
||||||
const char *section,
|
|
||||||
unsigned section_line,
|
|
||||||
const char *lvalue,
|
|
||||||
int ltype,
|
|
||||||
const char *rvalue,
|
|
||||||
void *data,
|
|
||||||
void *userdata) {
|
|
||||||
|
|
||||||
Network *n = data;
|
|
||||||
|
|
||||||
return config_parse_dhcp_lease_server_list(unit, filename, line,
|
|
||||||
lvalue, rvalue,
|
|
||||||
&n->dhcp_server_ntp, &n->n_dhcp_server_ntp);
|
|
||||||
}
|
|
||||||
|
|
||||||
int config_parse_dhcp_server_sip(
|
|
||||||
const char *unit,
|
|
||||||
const char *filename,
|
|
||||||
unsigned line,
|
|
||||||
const char *section,
|
|
||||||
unsigned section_line,
|
|
||||||
const char *lvalue,
|
|
||||||
int ltype,
|
|
||||||
const char *rvalue,
|
|
||||||
void *data,
|
|
||||||
void *userdata) {
|
|
||||||
|
|
||||||
Network *n = data;
|
|
||||||
|
|
||||||
return config_parse_dhcp_lease_server_list(unit, filename, line,
|
|
||||||
lvalue, rvalue,
|
|
||||||
&n->dhcp_server_sip, &n->n_dhcp_server_sip);
|
|
||||||
}
|
|
||||||
|
|
||||||
int config_parse_dhcp_server_pop3_servers(
|
|
||||||
const char *unit,
|
|
||||||
const char *filename,
|
|
||||||
unsigned line,
|
|
||||||
const char *section,
|
|
||||||
unsigned section_line,
|
|
||||||
const char *lvalue,
|
|
||||||
int ltype,
|
|
||||||
const char *rvalue,
|
|
||||||
void *data,
|
|
||||||
void *userdata) {
|
|
||||||
|
|
||||||
Network *n = data;
|
|
||||||
|
|
||||||
return config_parse_dhcp_lease_server_list(unit, filename, line,
|
|
||||||
lvalue, rvalue,
|
|
||||||
&n->dhcp_server_pop3, &n->n_dhcp_server_pop3);
|
|
||||||
}
|
|
||||||
|
|
||||||
int config_parse_dhcp_server_smtp_servers(
|
|
||||||
const char *unit,
|
|
||||||
const char *filename,
|
|
||||||
unsigned line,
|
|
||||||
const char *section,
|
|
||||||
unsigned section_line,
|
|
||||||
const char *lvalue,
|
|
||||||
int ltype,
|
|
||||||
const char *rvalue,
|
|
||||||
void *data,
|
|
||||||
void *userdata) {
|
|
||||||
|
|
||||||
Network *n = data;
|
|
||||||
|
|
||||||
return config_parse_dhcp_lease_server_list(unit, filename, line,
|
|
||||||
lvalue, rvalue,
|
|
||||||
&n->dhcp_server_smtp, &n->n_dhcp_server_smtp);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int config_parse_dhcp_server_lpr_servers(
|
|
||||||
const char *unit,
|
|
||||||
const char *filename,
|
|
||||||
unsigned line,
|
|
||||||
const char *section,
|
|
||||||
unsigned section_line,
|
|
||||||
const char *lvalue,
|
|
||||||
int ltype,
|
|
||||||
const char *rvalue,
|
|
||||||
void *data,
|
|
||||||
void *userdata) {
|
|
||||||
|
|
||||||
Network *n = data;
|
|
||||||
|
|
||||||
return config_parse_dhcp_lease_server_list(unit, filename, line,
|
|
||||||
lvalue, rvalue,
|
|
||||||
&n->dhcp_server_lpr, &n->n_dhcp_server_lpr);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -9,9 +9,4 @@ typedef struct Link Link;
|
|||||||
|
|
||||||
int dhcp4_server_configure(Link *link);
|
int dhcp4_server_configure(Link *link);
|
||||||
|
|
||||||
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_server_dns);
|
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_server_emit);
|
||||||
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_server_ntp);
|
|
||||||
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_server_sip);
|
|
||||||
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_server_pop3_servers);
|
|
||||||
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_server_smtp_servers);
|
|
||||||
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_server_lpr_servers);
|
|
||||||
|
@ -4196,32 +4196,11 @@ int link_save(Link *link) {
|
|||||||
sd_dhcp6_lease_get_ntp_fqdn);
|
sd_dhcp6_lease_get_ntp_fqdn);
|
||||||
|
|
||||||
serialize_addresses(f, "SIP", NULL,
|
serialize_addresses(f, "SIP", NULL,
|
||||||
link->network->sip,
|
NULL,
|
||||||
link->dhcp_lease,
|
link->dhcp_lease,
|
||||||
link->network->dhcp_use_sip,
|
link->network->dhcp_use_sip,
|
||||||
SD_DHCP_LEASE_SIP,
|
SD_DHCP_LEASE_SIP,
|
||||||
false, NULL, NULL, NULL);
|
NULL, false, NULL, NULL);
|
||||||
|
|
||||||
serialize_addresses(f, "POP3", NULL,
|
|
||||||
link->network->pop3,
|
|
||||||
link->dhcp_lease,
|
|
||||||
true,
|
|
||||||
SD_DHCP_LEASE_POP3,
|
|
||||||
false, NULL, NULL, NULL);
|
|
||||||
|
|
||||||
serialize_addresses(f, "SMTP", NULL,
|
|
||||||
link->network->smtp,
|
|
||||||
link->dhcp_lease,
|
|
||||||
true,
|
|
||||||
SD_DHCP_LEASE_SMTP,
|
|
||||||
false, NULL, NULL, NULL);
|
|
||||||
|
|
||||||
serialize_addresses(f, "LPR", NULL,
|
|
||||||
link->network->lpr,
|
|
||||||
link->dhcp_lease,
|
|
||||||
true,
|
|
||||||
SD_DHCP_LEASE_LPR,
|
|
||||||
false, NULL, NULL, NULL);
|
|
||||||
|
|
||||||
/************************************************************/
|
/************************************************************/
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ typedef struct Link {
|
|||||||
struct rtnl_link_stats64 stats_old, stats_new;
|
struct rtnl_link_stats64 stats_old, stats_new;
|
||||||
bool stats_updated;
|
bool stats_updated;
|
||||||
|
|
||||||
/* All kinds of DNS configuration */
|
/* All kinds of DNS configuration the user configured via D-Bus */
|
||||||
struct in_addr_data *dns;
|
struct in_addr_data *dns;
|
||||||
unsigned n_dns;
|
unsigned n_dns;
|
||||||
OrderedSet *search_domains, *route_domains;
|
OrderedSet *search_domains, *route_domains;
|
||||||
@ -171,6 +171,7 @@ typedef struct Link {
|
|||||||
DnsOverTlsMode dns_over_tls_mode;
|
DnsOverTlsMode dns_over_tls_mode;
|
||||||
Set *dnssec_negative_trust_anchors;
|
Set *dnssec_negative_trust_anchors;
|
||||||
|
|
||||||
|
/* Similar, but NTP server configuration */
|
||||||
char **ntp;
|
char **ntp;
|
||||||
} Link;
|
} Link;
|
||||||
|
|
||||||
|
@ -1499,8 +1499,7 @@ static int ordered_set_put_in4_addrv(OrderedSet *s,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int manager_save(Manager *m) {
|
static int manager_save(Manager *m) {
|
||||||
_cleanup_ordered_set_free_free_ OrderedSet *dns = NULL, *ntp = NULL, *sip = NULL, *pop3 = NULL,
|
_cleanup_ordered_set_free_free_ OrderedSet *dns = NULL, *ntp = NULL, *sip = NULL, *search_domains = NULL, *route_domains = NULL;
|
||||||
*smtp = NULL, *lpr = NULL, *search_domains = NULL, *route_domains = NULL;
|
|
||||||
const char *operstate_str, *carrier_state_str, *address_state_str;
|
const char *operstate_str, *carrier_state_str, *address_state_str;
|
||||||
LinkOperationalState operstate = LINK_OPERSTATE_OFF;
|
LinkOperationalState operstate = LINK_OPERSTATE_OFF;
|
||||||
LinkCarrierState carrier_state = LINK_CARRIER_STATE_OFF;
|
LinkCarrierState carrier_state = LINK_CARRIER_STATE_OFF;
|
||||||
@ -1508,7 +1507,6 @@ static int manager_save(Manager *m) {
|
|||||||
_cleanup_free_ char *temp_path = NULL;
|
_cleanup_free_ char *temp_path = NULL;
|
||||||
_cleanup_strv_free_ char **p = NULL;
|
_cleanup_strv_free_ char **p = NULL;
|
||||||
_cleanup_fclose_ FILE *f = NULL;
|
_cleanup_fclose_ FILE *f = NULL;
|
||||||
const struct in_addr *addresses;
|
|
||||||
Link *link;
|
Link *link;
|
||||||
Iterator i;
|
Iterator i;
|
||||||
int r;
|
int r;
|
||||||
@ -1529,18 +1527,6 @@ static int manager_save(Manager *m) {
|
|||||||
if (!sip)
|
if (!sip)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
pop3 = ordered_set_new(&string_hash_ops);
|
|
||||||
if (!pop3)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
smtp = ordered_set_new(&string_hash_ops);
|
|
||||||
if (!smtp)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
lpr = ordered_set_new(&string_hash_ops);
|
|
||||||
if (!lpr)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
search_domains = ordered_set_new(&dns_name_hash_ops);
|
search_domains = ordered_set_new(&dns_name_hash_ops);
|
||||||
if (!search_domains)
|
if (!search_domains)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
@ -1550,6 +1536,8 @@ static int manager_save(Manager *m) {
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
HASHMAP_FOREACH(link, m->links, i) {
|
HASHMAP_FOREACH(link, m->links, i) {
|
||||||
|
const struct in_addr *addresses;
|
||||||
|
|
||||||
if (link->flags & IFF_LOOPBACK)
|
if (link->flags & IFF_LOOPBACK)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -1616,30 +1604,6 @@ static int manager_save(Manager *m) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = sd_dhcp_lease_get_pop3(link->dhcp_lease, &addresses);
|
|
||||||
if (r > 0) {
|
|
||||||
r = ordered_set_put_in4_addrv(pop3, addresses, r, in4_addr_is_non_local);
|
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
} else if (r < 0 && r != -ENODATA)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
r = sd_dhcp_lease_get_smtp(link->dhcp_lease, &addresses);
|
|
||||||
if (r > 0) {
|
|
||||||
r = ordered_set_put_in4_addrv(smtp, addresses, r, in4_addr_is_non_local);
|
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
} else if (r < 0 && r != -ENODATA)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
r = sd_dhcp_lease_get_lpr(link->dhcp_lease, &addresses);
|
|
||||||
if (r > 0) {
|
|
||||||
r = ordered_set_put_in4_addrv(lpr, addresses, r, in4_addr_is_non_local);
|
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
} else if (r < 0 && r != -ENODATA)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
if (link->network->dhcp_use_domains != DHCP_USE_DOMAINS_NO) {
|
if (link->network->dhcp_use_domains != DHCP_USE_DOMAINS_NO) {
|
||||||
const char *domainname;
|
const char *domainname;
|
||||||
char **domains = NULL;
|
char **domains = NULL;
|
||||||
@ -1691,9 +1655,6 @@ static int manager_save(Manager *m) {
|
|||||||
ordered_set_print(f, "DNS=", dns);
|
ordered_set_print(f, "DNS=", dns);
|
||||||
ordered_set_print(f, "NTP=", ntp);
|
ordered_set_print(f, "NTP=", ntp);
|
||||||
ordered_set_print(f, "SIP=", sip);
|
ordered_set_print(f, "SIP=", sip);
|
||||||
ordered_set_print(f, "POP3_SERVERS=", pop3);
|
|
||||||
ordered_set_print(f, "SMTP_SERVERS=", smtp);
|
|
||||||
ordered_set_print(f, "LPR_SERVERS=", lpr);
|
|
||||||
ordered_set_print(f, "DOMAINS=", search_domains);
|
ordered_set_print(f, "DOMAINS=", search_domains);
|
||||||
ordered_set_print(f, "ROUTE_DOMAINS=", route_domains);
|
ordered_set_print(f, "ROUTE_DOMAINS=", route_domains);
|
||||||
|
|
||||||
|
@ -217,15 +217,18 @@ IPv6AcceptRA.RouteTable, config_parse_section_route_table,
|
|||||||
IPv6AcceptRA.BlackList, config_parse_ndisc_black_listed_prefix, 0, 0
|
IPv6AcceptRA.BlackList, config_parse_ndisc_black_listed_prefix, 0, 0
|
||||||
DHCPServer.MaxLeaseTimeSec, config_parse_sec, 0, offsetof(Network, dhcp_server_max_lease_time_usec)
|
DHCPServer.MaxLeaseTimeSec, config_parse_sec, 0, offsetof(Network, dhcp_server_max_lease_time_usec)
|
||||||
DHCPServer.DefaultLeaseTimeSec, config_parse_sec, 0, offsetof(Network, dhcp_server_default_lease_time_usec)
|
DHCPServer.DefaultLeaseTimeSec, config_parse_sec, 0, offsetof(Network, dhcp_server_default_lease_time_usec)
|
||||||
DHCPServer.EmitDNS, config_parse_bool, 0, offsetof(Network, dhcp_server_emit_dns)
|
DHCPServer.EmitDNS, config_parse_bool, 0, offsetof(Network, dhcp_server_emit[SD_DHCP_LEASE_DNS].emit)
|
||||||
DHCPServer.DNS, config_parse_dhcp_server_dns, 0, 0
|
DHCPServer.DNS, config_parse_dhcp_server_emit, 0, offsetof(Network, dhcp_server_emit[SD_DHCP_LEASE_DNS])
|
||||||
DHCPServer.EmitNTP, config_parse_bool, 0, offsetof(Network, dhcp_server_emit_ntp)
|
DHCPServer.EmitNTP, config_parse_bool, 0, offsetof(Network, dhcp_server_emit[SD_DHCP_LEASE_NTP].emit)
|
||||||
DHCPServer.NTP, config_parse_dhcp_server_ntp, 0, 0
|
DHCPServer.NTP, config_parse_dhcp_server_emit, 0, offsetof(Network, dhcp_server_emit[SD_DHCP_LEASE_NTP])
|
||||||
DHCPServer.EmitSIP, config_parse_bool, 0, offsetof(Network, dhcp_server_emit_sip)
|
DHCPServer.EmitSIP, config_parse_bool, 0, offsetof(Network, dhcp_server_emit[SD_DHCP_LEASE_SIP].emit)
|
||||||
DHCPServer.SIP, config_parse_dhcp_server_sip, 0, 0
|
DHCPServer.SIP, config_parse_dhcp_server_emit, 0, offsetof(Network, dhcp_server_emit[SD_DHCP_LEASE_SIP])
|
||||||
DHCPServer.POP3Servers, config_parse_dhcp_server_pop3_servers, 0, 0
|
DHCPServer.EmitPOP3, config_parse_bool, 0, offsetof(Network, dhcp_server_emit[SD_DHCP_LEASE_POP3].emit)
|
||||||
DHCPServer.SMTPServers, config_parse_dhcp_server_smtp_servers, 0, 0
|
DHCPServer.POP3, config_parse_dhcp_server_emit, 0, offsetof(Network, dhcp_server_emit[SD_DHCP_LEASE_POP3])
|
||||||
DHCPServer.LPRServers, config_parse_dhcp_server_lpr_servers, 0, 0
|
DHCPServer.EmitSMTP, config_parse_bool, 0, offsetof(Network, dhcp_server_emit[SD_DHCP_LEASE_SMTP].emit)
|
||||||
|
DHCPServer.SMTP, config_parse_dhcp_server_emit, 0, offsetof(Network, dhcp_server_emit[SD_DHCP_LEASE_SMTP])
|
||||||
|
DHCPServer.EmitLPR, config_parse_bool, 0, offsetof(Network, dhcp_server_emit[SD_DHCP_LEASE_LPR].emit)
|
||||||
|
DHCPServer.LPR, config_parse_dhcp_server_emit, 0, offsetof(Network, dhcp_server_emit[SD_DHCP_LEASE_LPR])
|
||||||
DHCPServer.EmitRouter, config_parse_bool, 0, offsetof(Network, dhcp_server_emit_router)
|
DHCPServer.EmitRouter, config_parse_bool, 0, offsetof(Network, dhcp_server_emit_router)
|
||||||
DHCPServer.EmitTimezone, config_parse_bool, 0, offsetof(Network, dhcp_server_emit_timezone)
|
DHCPServer.EmitTimezone, config_parse_bool, 0, offsetof(Network, dhcp_server_emit_timezone)
|
||||||
DHCPServer.Timezone, config_parse_timezone, 0, offsetof(Network, dhcp_server_timezone)
|
DHCPServer.Timezone, config_parse_timezone, 0, offsetof(Network, dhcp_server_timezone)
|
||||||
|
@ -416,9 +416,10 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
|
|||||||
|
|
||||||
.dhcp6_pd_assign_prefix = true,
|
.dhcp6_pd_assign_prefix = true,
|
||||||
|
|
||||||
.dhcp_server_emit_dns = true,
|
.dhcp_server_emit[SD_DHCP_LEASE_DNS].emit = true,
|
||||||
.dhcp_server_emit_ntp = true,
|
.dhcp_server_emit[SD_DHCP_LEASE_NTP].emit = true,
|
||||||
.dhcp_server_emit_sip = true,
|
.dhcp_server_emit[SD_DHCP_LEASE_SIP].emit = true,
|
||||||
|
|
||||||
.dhcp_server_emit_router = true,
|
.dhcp_server_emit_router = true,
|
||||||
.dhcp_server_emit_timezone = true,
|
.dhcp_server_emit_timezone = true,
|
||||||
|
|
||||||
@ -673,8 +674,6 @@ static Network *network_free(Network *network) {
|
|||||||
|
|
||||||
strv_free(network->ntp);
|
strv_free(network->ntp);
|
||||||
free(network->dns);
|
free(network->dns);
|
||||||
strv_free(network->sip);
|
|
||||||
strv_free(network->smtp);
|
|
||||||
ordered_set_free_free(network->search_domains);
|
ordered_set_free_free(network->search_domains);
|
||||||
ordered_set_free_free(network->route_domains);
|
ordered_set_free_free(network->route_domains);
|
||||||
strv_free(network->bind_carrier);
|
strv_free(network->bind_carrier);
|
||||||
@ -740,12 +739,9 @@ static Network *network_free(Network *network) {
|
|||||||
free(network->name);
|
free(network->name);
|
||||||
|
|
||||||
free(network->dhcp_server_timezone);
|
free(network->dhcp_server_timezone);
|
||||||
free(network->dhcp_server_dns);
|
|
||||||
free(network->dhcp_server_ntp);
|
for (sd_dhcp_lease_server_type t = 0; t < _SD_DHCP_LEASE_SERVER_TYPE_MAX; t++)
|
||||||
free(network->dhcp_server_sip);
|
free(network->dhcp_server_emit[t].addresses);
|
||||||
free(network->dhcp_server_pop3);
|
|
||||||
free(network->dhcp_server_smtp);
|
|
||||||
free(network->dhcp_server_lpr);
|
|
||||||
|
|
||||||
set_free_free(network->dnssec_negative_trust_anchors);
|
set_free_free(network->dnssec_negative_trust_anchors);
|
||||||
|
|
||||||
|
@ -54,6 +54,12 @@ typedef enum KeepConfiguration {
|
|||||||
|
|
||||||
typedef struct Manager Manager;
|
typedef struct Manager Manager;
|
||||||
|
|
||||||
|
typedef struct NetworkDHCPServerEmitAddress {
|
||||||
|
bool emit;
|
||||||
|
struct in_addr *addresses;
|
||||||
|
size_t n_addresses;
|
||||||
|
} NetworkDHCPServerEmitAddress;
|
||||||
|
|
||||||
struct Network {
|
struct Network {
|
||||||
Manager *manager;
|
Manager *manager;
|
||||||
|
|
||||||
@ -149,28 +155,7 @@ struct Network {
|
|||||||
|
|
||||||
/* DHCP Server Support */
|
/* DHCP Server Support */
|
||||||
bool dhcp_server;
|
bool dhcp_server;
|
||||||
|
NetworkDHCPServerEmitAddress dhcp_server_emit[_SD_DHCP_LEASE_SERVER_TYPE_MAX];
|
||||||
bool dhcp_server_emit_dns;
|
|
||||||
struct in_addr *dhcp_server_dns;
|
|
||||||
unsigned n_dhcp_server_dns;
|
|
||||||
|
|
||||||
bool dhcp_server_emit_ntp;
|
|
||||||
struct in_addr *dhcp_server_ntp;
|
|
||||||
unsigned n_dhcp_server_ntp;
|
|
||||||
|
|
||||||
bool dhcp_server_emit_sip;
|
|
||||||
struct in_addr *dhcp_server_sip;
|
|
||||||
unsigned n_dhcp_server_sip;
|
|
||||||
|
|
||||||
struct in_addr *dhcp_server_pop3;
|
|
||||||
unsigned n_dhcp_server_pop3;
|
|
||||||
|
|
||||||
struct in_addr *dhcp_server_smtp;
|
|
||||||
unsigned n_dhcp_server_smtp;
|
|
||||||
|
|
||||||
struct in_addr *dhcp_server_lpr;
|
|
||||||
unsigned n_dhcp_server_lpr;
|
|
||||||
|
|
||||||
bool dhcp_server_emit_router;
|
bool dhcp_server_emit_router;
|
||||||
bool dhcp_server_emit_timezone;
|
bool dhcp_server_emit_timezone;
|
||||||
char *dhcp_server_timezone;
|
char *dhcp_server_timezone;
|
||||||
@ -331,10 +316,6 @@ struct Network {
|
|||||||
Set *dnssec_negative_trust_anchors;
|
Set *dnssec_negative_trust_anchors;
|
||||||
|
|
||||||
char **ntp;
|
char **ntp;
|
||||||
char **sip;
|
|
||||||
char **pop3;
|
|
||||||
char **smtp;
|
|
||||||
char **lpr;
|
|
||||||
char **bind_carrier;
|
char **bind_carrier;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -68,8 +68,8 @@ int sd_dhcp_server_set_lpr(sd_dhcp_server *server, const struct in_addr lpr[], s
|
|||||||
int sd_dhcp_server_set_dns(sd_dhcp_server *server, const struct in_addr dns[], size_t n);
|
int sd_dhcp_server_set_dns(sd_dhcp_server *server, const struct in_addr dns[], size_t n);
|
||||||
int sd_dhcp_server_set_ntp(sd_dhcp_server *server, const struct in_addr ntp[], size_t n);
|
int sd_dhcp_server_set_ntp(sd_dhcp_server *server, const struct in_addr ntp[], size_t n);
|
||||||
int sd_dhcp_server_set_sip(sd_dhcp_server *server, const struct in_addr sip[], size_t n);
|
int sd_dhcp_server_set_sip(sd_dhcp_server *server, const struct in_addr sip[], size_t n);
|
||||||
int sd_dhcp_server_set_pop3(sd_dhcp_server *server, const struct in_addr pop3_server[], size_t n);
|
int sd_dhcp_server_set_pop3(sd_dhcp_server *server, const struct in_addr pop3[], size_t n);
|
||||||
int sd_dhcp_server_set_smtp(sd_dhcp_server *server, const struct in_addr smtp_server[], size_t n);
|
int sd_dhcp_server_set_smtp(sd_dhcp_server *server, const struct in_addr smtp[], size_t n);
|
||||||
|
|
||||||
int sd_dhcp_server_add_option(sd_dhcp_server *server, sd_dhcp_option *v);
|
int sd_dhcp_server_add_option(sd_dhcp_server *server, sd_dhcp_option *v);
|
||||||
int sd_dhcp_server_add_vendor_option(sd_dhcp_server *server, sd_dhcp_option *v);
|
int sd_dhcp_server_add_vendor_option(sd_dhcp_server *server, sd_dhcp_option *v);
|
||||||
|
@ -164,18 +164,6 @@ int sd_network_link_get_search_domains(int ifindex, char ***domains);
|
|||||||
/* Get the route DNS domain names for a given link. */
|
/* Get the route DNS domain names for a given link. */
|
||||||
int sd_network_link_get_route_domains(int ifindex, char ***domains);
|
int sd_network_link_get_route_domains(int ifindex, char ***domains);
|
||||||
|
|
||||||
/* Get the sip servers for a given link. */
|
|
||||||
int sd_network_link_get_sip_servers(int ifindex, char ***sip);
|
|
||||||
|
|
||||||
/* Get the pop3 servers for a given link. */
|
|
||||||
int sd_network_link_get_pop3_servers(int ifindex, char ***pop3);
|
|
||||||
|
|
||||||
/* Get the SMTP servers for a given link. */
|
|
||||||
int sd_network_link_get_smtp_servers(int ifindex, char ***smtp);
|
|
||||||
|
|
||||||
/* Get the LPR servers for a given link. */
|
|
||||||
int sd_network_link_get_lpr_servers(int ifindex, char ***lpr);
|
|
||||||
|
|
||||||
/* Get whether this link shall be used as 'default route' for DNS queries */
|
/* Get whether this link shall be used as 'default route' for DNS queries */
|
||||||
int sd_network_link_get_dns_default_route(int ifindex);
|
int sd_network_link_get_dns_default_route(int ifindex);
|
||||||
|
|
||||||
|
@ -289,9 +289,12 @@ EmitDNS=
|
|||||||
NTP=
|
NTP=
|
||||||
EmitSIP=
|
EmitSIP=
|
||||||
SIP=
|
SIP=
|
||||||
POP3Servers=
|
EmitPOP3=
|
||||||
SMTPServers=
|
POP3=
|
||||||
LPRServers=
|
EmitSMTP=
|
||||||
|
SMTP=
|
||||||
|
EmitLPR=
|
||||||
|
LPR=
|
||||||
EmitRouter=
|
EmitRouter=
|
||||||
MaxLeaseTimeSec=
|
MaxLeaseTimeSec=
|
||||||
DefaultLeaseTimeSec=
|
DefaultLeaseTimeSec=
|
||||||
|
Loading…
Reference in New Issue
Block a user