mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
Merge pull request #1055 from poettering/dhcp-updates
Various networkd and dhcp updates
This commit is contained in:
53
Makefile.am
53
Makefile.am
@@ -5167,41 +5167,48 @@ libnetworkd_core_la_SOURCES = \
|
||||
src/libsystemd-network/network-internal.h \
|
||||
src/network/networkd.h \
|
||||
src/network/networkd-link.h \
|
||||
src/network/networkd-netdev.h \
|
||||
src/network/networkd-netdev-tunnel.h \
|
||||
src/network/networkd-netdev-veth.h \
|
||||
src/network/networkd-netdev-vxlan.h \
|
||||
src/network/networkd-netdev-vlan.h \
|
||||
src/network/networkd-netdev-macvlan.h \
|
||||
src/network/networkd-netdev-ipvlan.h \
|
||||
src/network/networkd-netdev-dummy.h \
|
||||
src/network/networkd-netdev-tuntap.h \
|
||||
src/network/networkd-netdev-bond.h \
|
||||
src/network/networkd-netdev-bridge.h \
|
||||
src/network/networkd-netdev.c \
|
||||
src/network/networkd-netdev-tunnel.c \
|
||||
src/network/networkd-netdev-veth.c \
|
||||
src/network/networkd-netdev-vxlan.c \
|
||||
src/network/networkd-netdev-vlan.c \
|
||||
src/network/networkd-netdev-macvlan.c \
|
||||
src/network/networkd-netdev-ipvlan.c \
|
||||
src/network/networkd-netdev-dummy.c \
|
||||
src/network/networkd-netdev-tuntap.c \
|
||||
src/network/networkd-netdev-bond.c \
|
||||
src/network/networkd-netdev-bridge.c \
|
||||
src/network/networkd-link.c \
|
||||
src/network/networkd-netdev.h \
|
||||
src/network/networkd-netdev.c \
|
||||
src/network/networkd-netdev-tunnel.h \
|
||||
src/network/networkd-netdev-tunnel.c \
|
||||
src/network/networkd-netdev-veth.h \
|
||||
src/network/networkd-netdev-veth.c \
|
||||
src/network/networkd-netdev-vxlan.h \
|
||||
src/network/networkd-netdev-vxlan.c \
|
||||
src/network/networkd-netdev-vlan.h \
|
||||
src/network/networkd-netdev-vlan.c \
|
||||
src/network/networkd-netdev-macvlan.h \
|
||||
src/network/networkd-netdev-macvlan.c \
|
||||
src/network/networkd-netdev-ipvlan.h \
|
||||
src/network/networkd-netdev-ipvlan.c \
|
||||
src/network/networkd-netdev-dummy.h \
|
||||
src/network/networkd-netdev-dummy.c \
|
||||
src/network/networkd-netdev-tuntap.h \
|
||||
src/network/networkd-netdev-tuntap.c \
|
||||
src/network/networkd-netdev-bond.h \
|
||||
src/network/networkd-netdev-bond.c \
|
||||
src/network/networkd-netdev-bridge.h \
|
||||
src/network/networkd-netdev-bridge.c \
|
||||
src/network/networkd-link-bus.c \
|
||||
src/network/networkd-ipv4ll.c \
|
||||
src/network/networkd-dhcp4.c \
|
||||
src/network/networkd-dhcp6.c \
|
||||
src/network/networkd-network.h \
|
||||
src/network/networkd-network.c \
|
||||
src/network/networkd-network-bus.c \
|
||||
src/network/networkd-address.h \
|
||||
src/network/networkd-address.c \
|
||||
src/network/networkd-route.h \
|
||||
src/network/networkd-route.c \
|
||||
src/network/networkd-manager.c \
|
||||
src/network/networkd-manager-bus.c \
|
||||
src/network/networkd-fdb.h \
|
||||
src/network/networkd-fdb.c \
|
||||
src/network/networkd-address-pool.c
|
||||
src/network/networkd-address-pool.h \
|
||||
src/network/networkd-address-pool.c \
|
||||
src/network/networkd-util.h \
|
||||
src/network/networkd-util.c
|
||||
|
||||
nodist_libnetworkd_core_la_SOURCES = \
|
||||
src/network/networkd-network-gperf.c \
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version='1.0'?> <!--*-nxml-*-->
|
||||
<?xml version='1.0'?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*-->
|
||||
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
|
||||
|
||||
@@ -223,7 +223,7 @@
|
||||
<varlistentry>
|
||||
<term><varname>DHCP=</varname></term>
|
||||
<listitem>
|
||||
<para>Enables DHCPv4 and/or DHCPv6 support. Accepts
|
||||
<para>Enables DHCPv4 and/or DHCPv6 client support. Accepts
|
||||
<literal>yes</literal>, <literal>no</literal>,
|
||||
<literal>ipv4</literal>, or <literal>ipv6</literal>.</para>
|
||||
|
||||
@@ -235,9 +235,10 @@
|
||||
<varlistentry>
|
||||
<term><varname>DHCPServer=</varname></term>
|
||||
<listitem>
|
||||
<para>A boolean. Enables a basic DHCPv4 server on the
|
||||
device. Mostly useful for handing out leases to container
|
||||
instances.</para>
|
||||
<para>A boolean. Enables DHCPv4 server support. Defaults
|
||||
to <literal>no</literal>. Further settings for the DHCP
|
||||
server may be set in the <literal>[DHCPServer]</literal>
|
||||
section described below.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
@@ -541,7 +542,9 @@
|
||||
|
||||
<refsect1>
|
||||
<title>[DHCP] Section Options</title>
|
||||
<para>The <literal>[DHCP]</literal> section accepts the following keys:</para>
|
||||
<para>The <literal>[DHCP]</literal> section configures the
|
||||
DHCPv4 and DHCP6 client, if it is enabled with the
|
||||
<varname>DHCP=</varname> setting described above:</para>
|
||||
|
||||
<variablelist class='network-directives'>
|
||||
<varlistentry>
|
||||
@@ -552,7 +555,8 @@
|
||||
any statically configured ones.</para>
|
||||
|
||||
<para>This corresponds to the <option>nameserver</option>
|
||||
option in <citerefentry project='man-pages'><refentrytitle>resolv.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
|
||||
option in <citerefentry
|
||||
project='man-pages'><refentrytitle>resolv.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
@@ -582,7 +586,7 @@
|
||||
<term><varname>UseHostname=</varname></term>
|
||||
<listitem>
|
||||
<para>When true (the default), the hostname received from
|
||||
the DHCP server will be used as the transient hostname.
|
||||
the DHCP server will be set as the transient hostname of the system
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@@ -615,6 +619,15 @@
|
||||
table with metric of 1024.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>UseTimezone=</varname></term>
|
||||
|
||||
<listitem><para>When true, the timezone received from the
|
||||
DHCP server will be set as as timezone of the local
|
||||
system. Defaults to <literal>no</literal>.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>CriticalConnection=</varname></term>
|
||||
<listitem>
|
||||
@@ -658,10 +671,96 @@
|
||||
DHCP server.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</variablelist>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>[DHCPServer] Section Options</title>
|
||||
<para>The <literal>[DHCPServer]</literal> section contains
|
||||
settings for the DHCP server, if enabled via the
|
||||
<varname>DHCPServer=</varname> option described above:</para>
|
||||
|
||||
<variablelist class='network-directives'>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>DefaultLeaseTimeSec=</varname></term>
|
||||
<term><varname>MaxLeaseTimeSec=</varname></term>
|
||||
|
||||
<listitem><para>Control the default and maximum DHCP lease
|
||||
time to pass to clients. These settings take time values in seconds or
|
||||
another common time unit, depending on the suffix. The default
|
||||
lease time is used for clients that did not ask for a specific
|
||||
lease time. If a client asks for a lease time longer than the
|
||||
maximum lease time it is automatically shortened to the
|
||||
specified time. The default lease time defaults to 1h, the
|
||||
maximum lease time to 12h. Shorter lease times are beneficial
|
||||
if the configuration data in DHCP leases changes frequently
|
||||
and clients shall learn the new settings with shorter
|
||||
latencies. Longer lease times reduce the generated DHCP
|
||||
network traffic.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>EmitDNS=</varname></term>
|
||||
<term><varname>DNS=</varname></term>
|
||||
|
||||
<listitem><para>Configures whether the DHCP leases handed out
|
||||
to clients shall contain DNS server information. The
|
||||
<varname>EmitDNS=</varname> setting takes a boolean argument
|
||||
and defaults to <literal>yes</literal>. The DNS servers to
|
||||
pass to clients may be configured with the
|
||||
<varname>DNS=</varname> option, which takes a list of IPv4
|
||||
addresses. If the <varname>EmitDNS=</varname> option is
|
||||
enabled but no servers configured the servers are
|
||||
automatically propagated from an "uplink" interface that has
|
||||
appropriate servers set. The "uplink" interface is determined
|
||||
by the default route of the system with the highest
|
||||
priority. Note that this information is acquired at the time
|
||||
the lease is handed out, and does not take uplink interfaces
|
||||
into account that acquire DNS or NTP server information at a
|
||||
later point. DNS server propagation does not take
|
||||
<filename>/etc/resolv.conf</filename> into account. Also, note
|
||||
that the leases are not refreshed if 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>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>EmitNTP=</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>EmitTimezone=</varname></term>
|
||||
<term><varname>Timezone=</varname></term>
|
||||
|
||||
<listitem><para>Configures whether the DHCP leases handed out
|
||||
to clients shall contain timezone information. The
|
||||
<varname>EmitTimezone=</varname> setting takes a boolean
|
||||
argument and defaults to <literal>yes</literal>. The
|
||||
<varname>Timezone=</varname> setting takes a timezone string
|
||||
(such as <literal>Europe/Berlin</literal> or
|
||||
<literal>UTC</literal>) to pass to clients. If no explicit
|
||||
timezone is set the system timezone of the local host is
|
||||
propagated, as determined by the
|
||||
<filename>/etc/localtime</filename> symlink.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>[Bridge] Section Options</title>
|
||||
<para>The <literal>[Bridge]</literal> section accepts the
|
||||
|
||||
@@ -12,3 +12,6 @@ Name=host0
|
||||
[Network]
|
||||
DHCP=yes
|
||||
LinkLocalAddressing=yes
|
||||
|
||||
[DHCP]
|
||||
UseTimezone=yes
|
||||
|
||||
@@ -21,7 +21,9 @@
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
/* A type-safe atomic refcounter */
|
||||
/* A type-safe atomic refcounter.
|
||||
*
|
||||
* DO NOT USE THIS UNLESS YOU ACTUALLY CARE ABOUT THREAD SAFETY! */
|
||||
|
||||
typedef struct {
|
||||
volatile unsigned _value;
|
||||
|
||||
@@ -50,7 +50,6 @@ int ring_push(Ring *r, const void *u8, size_t size);
|
||||
void ring_pull(Ring *r, size_t size);
|
||||
|
||||
/* return size of occupied buffer in bytes */
|
||||
static inline size_t ring_get_size(Ring *r)
|
||||
{
|
||||
static inline size_t ring_get_size(Ring *r) {
|
||||
return r->used;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "util.h"
|
||||
#include "time-util.h"
|
||||
#include "path-util.h"
|
||||
#include "strv.h"
|
||||
|
||||
usec_t now(clockid_t clock_id) {
|
||||
@@ -971,7 +972,10 @@ bool timezone_is_valid(const char *name) {
|
||||
const char *p, *t;
|
||||
struct stat st;
|
||||
|
||||
if (!name || *name == 0 || *name == '/')
|
||||
if (isempty(name))
|
||||
return false;
|
||||
|
||||
if (name[0] == '/')
|
||||
return false;
|
||||
|
||||
for (p = name; *p; p++) {
|
||||
@@ -1021,3 +1025,30 @@ clockid_t clock_boottime_or_monotonic(void) {
|
||||
|
||||
return clock;
|
||||
}
|
||||
|
||||
int get_timezone(char **timezone) {
|
||||
_cleanup_free_ char *t = NULL;
|
||||
const char *e;
|
||||
char *z;
|
||||
int r;
|
||||
|
||||
r = readlink_malloc("/etc/localtime", &t);
|
||||
if (r < 0)
|
||||
return r; /* returns EINVAL if not a symlink */
|
||||
|
||||
e = path_startswith(t, "/usr/share/zoneinfo/");
|
||||
if (!e)
|
||||
e = path_startswith(t, "../usr/share/zoneinfo/");
|
||||
if (!e)
|
||||
return -EINVAL;
|
||||
|
||||
if (!timezone_is_valid(e))
|
||||
return -EINVAL;
|
||||
|
||||
z = strdup(e);
|
||||
if (!z)
|
||||
return -ENOMEM;
|
||||
|
||||
*timezone = z;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -110,3 +110,5 @@ bool timezone_is_valid(const char *name);
|
||||
clockid_t clock_boottime_or_monotonic(void);
|
||||
|
||||
#define xstrftime(buf, fmt, tm) assert_se(strftime(buf, ELEMENTSOF(buf), fmt, tm) > 0)
|
||||
|
||||
int get_timezone(char **timezone);
|
||||
|
||||
@@ -70,16 +70,14 @@ typedef struct {
|
||||
BOOLEAN no_editor;
|
||||
} Config;
|
||||
|
||||
static VOID cursor_left(UINTN *cursor, UINTN *first)
|
||||
{
|
||||
static VOID cursor_left(UINTN *cursor, UINTN *first) {
|
||||
if ((*cursor) > 0)
|
||||
(*cursor)--;
|
||||
else if ((*first) > 0)
|
||||
(*first)--;
|
||||
}
|
||||
|
||||
static VOID cursor_right(UINTN *cursor, UINTN *first, UINTN x_max, UINTN len)
|
||||
{
|
||||
static VOID cursor_right(UINTN *cursor, UINTN *first, UINTN x_max, UINTN len) {
|
||||
if ((*cursor)+1 < x_max)
|
||||
(*cursor)++;
|
||||
else if ((*first) + (*cursor) < len)
|
||||
@@ -856,13 +854,11 @@ static VOID config_entry_free(ConfigEntry *entry) {
|
||||
FreePool(entry->options);
|
||||
}
|
||||
|
||||
static BOOLEAN is_digit(CHAR16 c)
|
||||
{
|
||||
static BOOLEAN is_digit(CHAR16 c) {
|
||||
return (c >= '0') && (c <= '9');
|
||||
}
|
||||
|
||||
static UINTN c_order(CHAR16 c)
|
||||
{
|
||||
static UINTN c_order(CHAR16 c) {
|
||||
if (c == '\0')
|
||||
return 0;
|
||||
if (is_digit(c))
|
||||
@@ -873,8 +869,7 @@ static UINTN c_order(CHAR16 c)
|
||||
return c + 0x10000;
|
||||
}
|
||||
|
||||
static INTN str_verscmp(CHAR16 *s1, CHAR16 *s2)
|
||||
{
|
||||
static INTN str_verscmp(CHAR16 *s1, CHAR16 *s2) {
|
||||
CHAR16 *os1 = s1;
|
||||
CHAR16 *os2 = s2;
|
||||
|
||||
|
||||
@@ -45,10 +45,10 @@ int dhcp_option_append(DHCPMessage *message, size_t size, size_t *offset, uint8_
|
||||
uint8_t code, size_t optlen, const void *optval);
|
||||
|
||||
typedef int (*dhcp_option_cb_t)(uint8_t code, uint8_t len,
|
||||
const uint8_t *option, void *user_data);
|
||||
const void *option, void *userdata);
|
||||
|
||||
int dhcp_option_parse(DHCPMessage *message, size_t len,
|
||||
dhcp_option_cb_t cb, void *user_data);
|
||||
dhcp_option_cb_t cb, void *userdata);
|
||||
|
||||
int dhcp_message_init(DHCPMessage *message, uint8_t op, uint32_t xid,
|
||||
uint8_t type, uint16_t arp_type, size_t optlen,
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include <stdint.h>
|
||||
#include <linux/if_packet.h>
|
||||
|
||||
#include "refcnt.h"
|
||||
#include "util.h"
|
||||
#include "list.h"
|
||||
|
||||
@@ -48,54 +47,62 @@ struct sd_dhcp_raw_option {
|
||||
};
|
||||
|
||||
struct sd_dhcp_lease {
|
||||
RefCount n_ref;
|
||||
unsigned n_ref;
|
||||
|
||||
int32_t time_offset;
|
||||
/* each 0 if unset */
|
||||
uint32_t t1;
|
||||
uint32_t t2;
|
||||
uint32_t lifetime;
|
||||
uint32_t mtu_aging_timeout;
|
||||
|
||||
/* each 0 if unset */
|
||||
be32_t address;
|
||||
be32_t server_address;
|
||||
be32_t subnet_mask;
|
||||
be32_t router;
|
||||
be32_t next_server;
|
||||
|
||||
bool have_subnet_mask;
|
||||
be32_t subnet_mask;
|
||||
|
||||
bool have_broadcast;
|
||||
be32_t broadcast;
|
||||
|
||||
struct in_addr *dns;
|
||||
size_t dns_size;
|
||||
|
||||
struct in_addr *ntp;
|
||||
size_t ntp_size;
|
||||
struct in_addr *policy_filter;
|
||||
size_t policy_filter_size;
|
||||
|
||||
struct sd_dhcp_route *static_route;
|
||||
size_t static_route_size;
|
||||
size_t static_route_allocated;
|
||||
uint16_t boot_file_size;
|
||||
uint16_t mdr;
|
||||
uint16_t mtu;
|
||||
uint8_t ttl;
|
||||
bool ip_forward;
|
||||
bool ip_forward_non_local;
|
||||
size_t static_route_size, static_route_allocated;
|
||||
|
||||
uint16_t mtu; /* 0 if unset */
|
||||
|
||||
char *domainname;
|
||||
char *hostname;
|
||||
char *root_path;
|
||||
uint8_t *client_id;
|
||||
|
||||
void *client_id;
|
||||
size_t client_id_len;
|
||||
uint8_t *vendor_specific;
|
||||
|
||||
void *vendor_specific;
|
||||
size_t vendor_specific_len;
|
||||
|
||||
char *timezone;
|
||||
|
||||
LIST_HEAD(struct sd_dhcp_raw_option, private_options);
|
||||
};
|
||||
|
||||
int dhcp_lease_new(sd_dhcp_lease **ret);
|
||||
int dhcp_lease_parse_options(uint8_t code, uint8_t len, const uint8_t *option,
|
||||
void *user_data);
|
||||
int dhcp_lease_insert_private_option(sd_dhcp_lease *lease, uint8_t tag,
|
||||
const uint8_t *data, uint8_t len);
|
||||
|
||||
int dhcp_lease_parse_options(uint8_t code, uint8_t len, const void *option, void *userdata);
|
||||
int dhcp_lease_insert_private_option(sd_dhcp_lease *lease, uint8_t tag, const void *data, uint8_t len);
|
||||
|
||||
int dhcp_lease_set_default_subnet_mask(sd_dhcp_lease *lease);
|
||||
|
||||
int dhcp_lease_set_client_id(sd_dhcp_lease *lease, const uint8_t *client_id,
|
||||
size_t client_id_len);
|
||||
int dhcp_lease_set_client_id(sd_dhcp_lease *lease, const void *client_id, size_t client_id_len);
|
||||
|
||||
int dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file);
|
||||
int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file);
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(sd_dhcp_lease*, sd_dhcp_lease_unref);
|
||||
#define _cleanup_dhcp_lease_unref_ _cleanup_(sd_dhcp_lease_unrefp)
|
||||
|
||||
@@ -140,7 +140,7 @@ int dhcp_option_append(DHCPMessage *message, size_t size, size_t *offset,
|
||||
|
||||
static int parse_options(const uint8_t options[], size_t buflen, uint8_t *overload,
|
||||
uint8_t *message_type, dhcp_option_cb_t cb,
|
||||
void *user_data) {
|
||||
void *userdata) {
|
||||
uint8_t code, len;
|
||||
size_t offset = 0;
|
||||
|
||||
@@ -199,7 +199,7 @@ static int parse_options(const uint8_t options[], size_t buflen, uint8_t *overlo
|
||||
return -EINVAL;
|
||||
|
||||
if (cb)
|
||||
cb(code, len, &options[offset], user_data);
|
||||
cb(code, len, &options[offset], userdata);
|
||||
|
||||
offset += len;
|
||||
|
||||
@@ -214,7 +214,7 @@ static int parse_options(const uint8_t options[], size_t buflen, uint8_t *overlo
|
||||
}
|
||||
|
||||
int dhcp_option_parse(DHCPMessage *message, size_t len,
|
||||
dhcp_option_cb_t cb, void *user_data) {
|
||||
dhcp_option_cb_t cb, void *userdata) {
|
||||
uint8_t overload = 0;
|
||||
uint8_t message_type = 0;
|
||||
int r;
|
||||
@@ -228,20 +228,20 @@ int dhcp_option_parse(DHCPMessage *message, size_t len,
|
||||
len -= sizeof(DHCPMessage);
|
||||
|
||||
r = parse_options(message->options, len, &overload, &message_type,
|
||||
cb, user_data);
|
||||
cb, userdata);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (overload & DHCP_OVERLOAD_FILE) {
|
||||
r = parse_options(message->file, sizeof(message->file),
|
||||
NULL, &message_type, cb, user_data);
|
||||
NULL, &message_type, cb, userdata);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
if (overload & DHCP_OVERLOAD_SNAME) {
|
||||
r = parse_options(message->sname, sizeof(message->sname),
|
||||
NULL, &message_type, cb, user_data);
|
||||
NULL, &message_type, cb, userdata);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -137,6 +137,8 @@ enum {
|
||||
DHCP_OPTION_REBINDING_T2_TIME = 59,
|
||||
DHCP_OPTION_VENDOR_CLASS_IDENTIFIER = 60,
|
||||
DHCP_OPTION_CLIENT_IDENTIFIER = 61,
|
||||
DHCP_OPTION_NEW_POSIX_TIMEZONE = 100,
|
||||
DHCP_OPTION_NEW_TZDB_TIMEZONE = 101,
|
||||
DHCP_OPTION_CLASSLESS_STATIC_ROUTE = 121,
|
||||
DHCP_OPTION_PRIVATE_BASE = 224,
|
||||
DHCP_OPTION_PRIVATE_LAST = 254,
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include "sd-dhcp-server.h"
|
||||
|
||||
#include "hashmap.h"
|
||||
#include "refcnt.h"
|
||||
#include "util.h"
|
||||
#include "log.h"
|
||||
|
||||
@@ -34,7 +33,7 @@
|
||||
|
||||
typedef struct DHCPClientId {
|
||||
size_t length;
|
||||
uint8_t *data;
|
||||
void *data;
|
||||
} DHCPClientId;
|
||||
|
||||
typedef struct DHCPLease {
|
||||
@@ -47,7 +46,7 @@ typedef struct DHCPLease {
|
||||
} DHCPLease;
|
||||
|
||||
struct sd_dhcp_server {
|
||||
RefCount n_ref;
|
||||
unsigned n_ref;
|
||||
|
||||
sd_event *event;
|
||||
int event_priority;
|
||||
@@ -55,15 +54,22 @@ struct sd_dhcp_server {
|
||||
int fd;
|
||||
int fd_raw;
|
||||
|
||||
int index;
|
||||
int ifindex;
|
||||
be32_t address;
|
||||
be32_t netmask;
|
||||
be32_t pool_start;
|
||||
size_t pool_size;
|
||||
size_t next_offer;
|
||||
|
||||
char *timezone;
|
||||
|
||||
struct in_addr *ntp, *dns;
|
||||
unsigned n_ntp, n_dns;
|
||||
|
||||
Hashmap *leases_by_client_id;
|
||||
DHCPLease **bound_leases;
|
||||
|
||||
uint32_t max_lease_time, default_lease_time;
|
||||
};
|
||||
|
||||
typedef struct DHCPRequest {
|
||||
@@ -75,7 +81,7 @@ typedef struct DHCPRequest {
|
||||
size_t max_optlen;
|
||||
be32_t server_id;
|
||||
be32_t requested_ip;
|
||||
int lifetime;
|
||||
uint32_t lifetime;
|
||||
} DHCPRequest;
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(sd_dhcp_server*, sd_dhcp_server_unref);
|
||||
|
||||
@@ -24,13 +24,11 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "refcnt.h"
|
||||
|
||||
#include "sd-dhcp6-lease.h"
|
||||
#include "dhcp6-internal.h"
|
||||
|
||||
struct sd_dhcp6_lease {
|
||||
RefCount n_ref;
|
||||
unsigned n_ref;
|
||||
|
||||
uint8_t *serverid;
|
||||
size_t serverid_len;
|
||||
|
||||
@@ -41,8 +41,7 @@
|
||||
{ { { 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 } } }
|
||||
|
||||
int dhcp_network_icmp6_bind_router_solicitation(int index)
|
||||
{
|
||||
int dhcp_network_icmp6_bind_router_solicitation(int index) {
|
||||
struct icmp6_filter filter = { };
|
||||
struct ipv6_mreq mreq = {
|
||||
.ipv6mr_multiaddr = IN6ADDR_ALL_NODES_MULTICAST_INIT,
|
||||
@@ -92,8 +91,7 @@ int dhcp_network_icmp6_bind_router_solicitation(int index)
|
||||
return r;
|
||||
}
|
||||
|
||||
int dhcp_network_icmp6_send_router_solicitation(int s, const struct ether_addr *ether_addr)
|
||||
{
|
||||
int dhcp_network_icmp6_send_router_solicitation(int s, const struct ether_addr *ether_addr) {
|
||||
struct sockaddr_in6 dst = {
|
||||
.sin6_family = AF_INET6,
|
||||
.sin6_addr = IN6ADDR_ALL_ROUTERS_MULTICAST_INIT,
|
||||
|
||||
@@ -338,9 +338,7 @@ int dhcp6_option_parse_ip6addrs(uint8_t *optval, uint16_t optlen,
|
||||
return count;
|
||||
}
|
||||
|
||||
int dhcp6_option_parse_domainname(const uint8_t *optval, uint16_t optlen,
|
||||
char ***str_arr)
|
||||
{
|
||||
int dhcp6_option_parse_domainname(const uint8_t *optval, uint16_t optlen, char ***str_arr) {
|
||||
size_t pos = 0, idx = 0;
|
||||
_cleanup_free_ char **names = NULL;
|
||||
int r;
|
||||
|
||||
@@ -374,9 +374,8 @@ int lldp_mib_add_objects(Prioq *by_expiry,
|
||||
}
|
||||
|
||||
/* Admission Control: Can this port attached to the existing chassis ? */
|
||||
if (REFCNT_GET(c->n_ref) >= LLDP_MIB_MAX_PORT_PER_CHASSIS) {
|
||||
log_lldp("Port limit reached. Chassis has: %d ports. Dropping ...",
|
||||
REFCNT_GET(c->n_ref));
|
||||
if (c->n_ref >= LLDP_MIB_MAX_PORT_PER_CHASSIS) {
|
||||
log_lldp("Port limit reached. Chassis has: %d ports. Dropping ...", c->n_ref);
|
||||
|
||||
c = NULL;
|
||||
goto drop;
|
||||
@@ -394,7 +393,7 @@ int lldp_mib_add_objects(Prioq *by_expiry,
|
||||
|
||||
/* Attach new port to chassis */
|
||||
LIST_PREPEND(port, c->ports, p);
|
||||
REFCNT_INC(c->n_ref);
|
||||
c->n_ref ++;
|
||||
|
||||
p = NULL;
|
||||
c = NULL;
|
||||
@@ -424,7 +423,8 @@ void lldp_neighbour_port_remove_and_free(lldp_neighbour_port *p) {
|
||||
lldp_neighbour_port_free(p);
|
||||
|
||||
/* Drop the Chassis if no port is attached */
|
||||
if (REFCNT_DEC(c->n_ref) <= 1) {
|
||||
c->n_ref --;
|
||||
if (c->n_ref <= 1) {
|
||||
hashmap_remove(c->neighbour_mib, &c->chassis_id);
|
||||
lldp_chassis_free(c);
|
||||
}
|
||||
@@ -486,7 +486,7 @@ void lldp_chassis_free(lldp_chassis *c) {
|
||||
if (!c)
|
||||
return;
|
||||
|
||||
if (REFCNT_GET(c->n_ref) > 1)
|
||||
if (c->n_ref > 1)
|
||||
return;
|
||||
|
||||
free(c->chassis_id.data);
|
||||
@@ -513,7 +513,7 @@ int lldp_chassis_new(tlv_packet *tlv,
|
||||
if (!c)
|
||||
return -ENOMEM;
|
||||
|
||||
c->n_ref = REFCNT_INIT;
|
||||
c->n_ref = 1;
|
||||
c->chassis_id.type = type;
|
||||
c->chassis_id.length = length;
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
#include "log.h"
|
||||
#include "list.h"
|
||||
#include "refcnt.h"
|
||||
#include "lldp-tlv.h"
|
||||
#include "prioq.h"
|
||||
|
||||
@@ -63,7 +62,7 @@ struct lldp_chassis_id {
|
||||
};
|
||||
|
||||
struct lldp_chassis {
|
||||
RefCount n_ref;
|
||||
unsigned n_ref;
|
||||
|
||||
lldp_chassis_id chassis_id;
|
||||
|
||||
|
||||
@@ -525,7 +525,7 @@ int deserialize_dhcp_routes(struct sd_dhcp_route **ret, size_t *ret_size, size_t
|
||||
return 0;
|
||||
}
|
||||
|
||||
int serialize_dhcp_option(FILE *f, const char *key, const uint8_t *data, size_t size) {
|
||||
int serialize_dhcp_option(FILE *f, const char *key, const void *data, size_t size) {
|
||||
_cleanup_free_ char *hex_buf = NULL;
|
||||
|
||||
assert(f);
|
||||
@@ -541,7 +541,7 @@ int serialize_dhcp_option(FILE *f, const char *key, const uint8_t *data, size_t
|
||||
return 0;
|
||||
}
|
||||
|
||||
int deserialize_dhcp_option(uint8_t **data, size_t *data_len, const char *string) {
|
||||
int deserialize_dhcp_option(void **data, size_t *data_len, const char *string) {
|
||||
assert(data);
|
||||
assert(data_len);
|
||||
assert(string);
|
||||
|
||||
@@ -77,5 +77,5 @@ struct sd_dhcp_route;
|
||||
void serialize_dhcp_routes(FILE *f, const char *key, struct sd_dhcp_route *routes, size_t size);
|
||||
int deserialize_dhcp_routes(struct sd_dhcp_route **ret, size_t *ret_size, size_t *ret_allocated, const char *string);
|
||||
|
||||
int serialize_dhcp_option(FILE *f, const char *key, const uint8_t *data, size_t size);
|
||||
int deserialize_dhcp_option(uint8_t **data, size_t *data_len, const char *string);
|
||||
int serialize_dhcp_option(FILE *f, const char *key, const void *data, size_t size);
|
||||
int deserialize_dhcp_option(void **data, size_t *data_len, const char *string);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user