mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-30 14:20:17 +01:00
dhcp: merge branch 'bg/dhcp-dscp'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1824
(cherry picked from commit 9c67bf9ab6)
This commit is contained in:
commit
b7fa330ac5
33 changed files with 1233 additions and 816 deletions
|
|
@ -924,6 +924,9 @@ ipv6.ip6-privacy=0
|
|||
<varlistentry>
|
||||
<term><varname>ipv4.dhcp-client-id</varname></term>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>ipv4.dhcp-dscp</varname></term>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>ipv4.dhcp-iaid</varname></term>
|
||||
<listitem><para>If left unspecified, it defaults to "ifname".</para></listitem>
|
||||
|
|
|
|||
|
|
@ -160,6 +160,7 @@
|
|||
<member><option>rd.net.timeout.dhcp</option></member>
|
||||
<member><option>rd.net.dhcp.retry</option></member>
|
||||
<member><option>rd.net.dhcp.vendor-class</option></member>
|
||||
<member><option>rd.net.dhcp.dscp</option></member>
|
||||
<member><option>rd.net.timeout.carrier</option></member>
|
||||
<member><option>rd.znet</option></member>
|
||||
<member><option>rd.znet_ifname</option></member>
|
||||
|
|
@ -223,6 +224,15 @@
|
|||
<replaceable>SPEED</replaceable> accepts positive integer values.
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>NetworkManager supports the
|
||||
<option>rd.net.dhcp.dscp</option>={<replaceable>CS0</replaceable>|<replaceable>CS4</replaceable>|<replaceable>CS6</replaceable>}
|
||||
kernel command line option to set a specific DSCP (TOS) value
|
||||
in the IP header of DHCP messages.
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
</itemizedlist>
|
||||
</refsect1>
|
||||
|
||||
|
|
|
|||
|
|
@ -2185,6 +2185,52 @@ out_good:
|
|||
return result;
|
||||
}
|
||||
|
||||
static guint8
|
||||
_prop_get_ipv4_dhcp_dscp(NMDevice *self, gboolean *out_dscp_explicit)
|
||||
{
|
||||
gs_free_error GError *error = NULL;
|
||||
NMConnection *connection;
|
||||
NMSettingIPConfig *s_ip;
|
||||
const char *str;
|
||||
|
||||
connection = nm_device_get_applied_connection(self);
|
||||
s_ip = nm_connection_get_setting_ip_config(connection, AF_INET);
|
||||
g_return_val_if_fail(s_ip, 0);
|
||||
|
||||
NM_SET_OUT(out_dscp_explicit, TRUE);
|
||||
|
||||
str = nm_setting_ip_config_get_dhcp_dscp(s_ip);
|
||||
if (str) {
|
||||
nm_assert(nm_utils_validate_dhcp_dscp(str, NULL));
|
||||
} else {
|
||||
str = nm_config_data_get_connection_default(NM_CONFIG_GET_DATA,
|
||||
NM_CON_DEFAULT("ipv4.dhcp-dscp"),
|
||||
self);
|
||||
if (!str || !str[0]) {
|
||||
str = "CS0";
|
||||
NM_SET_OUT(out_dscp_explicit, FALSE);
|
||||
} else if (!nm_utils_validate_dhcp_dscp(str, &error)) {
|
||||
_LOGW(LOGD_DEVICE,
|
||||
"invalid global default value '%s' for ipv4.%s: %s",
|
||||
str,
|
||||
NM_SETTING_IP_CONFIG_DHCP_DSCP,
|
||||
error->message);
|
||||
str = "CS0";
|
||||
NM_SET_OUT(out_dscp_explicit, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
if (nm_streq(str, "CS0")) {
|
||||
return 0;
|
||||
} else if (nm_streq(str, "CS6")) {
|
||||
return 0x30;
|
||||
} else if (nm_streq(str, "CS4")) {
|
||||
return 0x20;
|
||||
};
|
||||
|
||||
nm_assert_unreachable_val(0);
|
||||
}
|
||||
|
||||
static GBytes *
|
||||
_prop_get_ipv4_dhcp_vendor_class_identifier(NMDevice *self, NMSettingIP4Config *s_ip4)
|
||||
{
|
||||
|
|
@ -10970,8 +11016,11 @@ _dev_ipdhcpx_start(NMDevice *self, int addr_family)
|
|||
const char *hostname;
|
||||
gboolean hostname_is_fqdn;
|
||||
gboolean send_client_id;
|
||||
guint8 dscp;
|
||||
gboolean dscp_explicit = FALSE;
|
||||
|
||||
client_id = _prop_get_ipv4_dhcp_client_id(self, connection, hwaddr, &send_client_id);
|
||||
dscp = _prop_get_ipv4_dhcp_dscp(self, &dscp_explicit);
|
||||
|
||||
vendor_class_identifier =
|
||||
_prop_get_ipv4_dhcp_vendor_class_identifier(self, NM_SETTING_IP4_CONFIG(s_ip));
|
||||
|
|
@ -11010,6 +11059,8 @@ _dev_ipdhcpx_start(NMDevice *self, int addr_family)
|
|||
.request_broadcast = request_broadcast,
|
||||
.acd_timeout_msec = _prop_get_ipv4_dad_timeout(self),
|
||||
.send_client_id = send_client_id,
|
||||
.dscp = dscp,
|
||||
.dscp_explicit = dscp_explicit,
|
||||
},
|
||||
.previous_lease = priv->l3cds[L3_CONFIG_DATA_TYPE_DHCP_X(IS_IPv4)].d,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -158,6 +158,13 @@ typedef struct {
|
|||
* is disabled. */
|
||||
guint acd_timeout_msec;
|
||||
|
||||
/* The DSCP value to use */
|
||||
guint8 dscp;
|
||||
|
||||
/* Whether the DSCP value is explicitly set (or it is the default
|
||||
* one) */
|
||||
bool dscp_explicit : 1;
|
||||
|
||||
/* Set BOOTP broadcast flag in request packets, so that servers
|
||||
* will always broadcast replies. */
|
||||
bool request_broadcast : 1;
|
||||
|
|
|
|||
|
|
@ -457,6 +457,11 @@ dhclient_start(NMDhcpClient *client,
|
|||
g_ptr_array_add(argv, (gpointer) priv->conf_file);
|
||||
}
|
||||
|
||||
if (client_config->v4.dscp_explicit) {
|
||||
_LOGW("dhclient does not support specifying a custom DSCP value; the TOS field will be set "
|
||||
"to LOWDELAY (0x10).");
|
||||
}
|
||||
|
||||
/* Usually the system bus address is well-known; but if it's supposed
|
||||
* to be something else, we need to push it to dhclient, since dhclient
|
||||
* sanitizes the environment it gives the action scripts.
|
||||
|
|
|
|||
|
|
@ -1388,6 +1388,8 @@ ip4_start(NMDhcpClient *client, GError **error)
|
|||
}
|
||||
}
|
||||
|
||||
n_dhcp4_client_probe_config_set_dscp(config, client_config->v4.dscp);
|
||||
|
||||
if (client_config->hostname) {
|
||||
if (client_config->use_fqdn) {
|
||||
uint8_t buffer[255];
|
||||
|
|
|
|||
|
|
@ -3360,6 +3360,8 @@ do_write_construct(NMConnection *connection,
|
|||
GError **error)
|
||||
{
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
NMSettingIPConfig *s_ip6;
|
||||
nm_auto_shvar_file_close shvarFile *ifcfg = NULL;
|
||||
const char *ifcfg_name;
|
||||
gs_free char *ifcfg_name_free = NULL;
|
||||
|
|
@ -3546,8 +3548,6 @@ do_write_construct(NMConnection *connection,
|
|||
has_complex_routes_v6 = utils_has_complex_routes(ifcfg_name, AF_INET6);
|
||||
|
||||
if (has_complex_routes_v4 || has_complex_routes_v6) {
|
||||
NMSettingIPConfig *s_ip4, *s_ip6;
|
||||
|
||||
s_ip4 = nm_connection_get_setting_ip4_config(connection);
|
||||
s_ip6 = nm_connection_get_setting_ip6_config(connection);
|
||||
if ((s_ip4 && nm_setting_ip_config_get_num_routes(s_ip4) > 0)
|
||||
|
|
@ -3584,6 +3584,15 @@ do_write_construct(NMConnection *connection,
|
|||
} else
|
||||
route_ignore = FALSE;
|
||||
|
||||
if ((s_ip4 = nm_connection_get_setting_ip4_config(connection))
|
||||
&& nm_setting_ip_config_get_dhcp_dscp(s_ip4)) {
|
||||
set_error_unsupported(error,
|
||||
connection,
|
||||
NM_SETTING_IP4_CONFIG_SETTING_NAME "." NM_SETTING_IP_CONFIG_DHCP_DSCP,
|
||||
FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
write_ip4_setting(connection,
|
||||
ifcfg,
|
||||
!route_ignore && route_path_is_svformat ? &route_content_svformat : NULL,
|
||||
|
|
|
|||
|
|
@ -1965,4 +1965,5 @@ global:
|
|||
nm_setting_hsr_get_prp;
|
||||
nm_setting_hsr_get_type;
|
||||
nm_setting_hsr_new;
|
||||
nm_setting_ip_config_get_dhcp_dscp;
|
||||
} libnm_1_44_0;
|
||||
|
|
|
|||
|
|
@ -461,6 +461,23 @@ nm_utils_validate_dhcp4_vendor_class_id(const char *vci, GError **error)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_utils_validate_dhcp_dscp(const char *dscp, GError **error)
|
||||
{
|
||||
g_return_val_if_fail(!error || !(*error), FALSE);
|
||||
g_return_val_if_fail(dscp, FALSE);
|
||||
|
||||
if (!NM_IN_STRSET(dscp, "CS0", "CS4", "CS6")) {
|
||||
g_set_error_literal(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("invalid DSCP value; allowed values are: 'CS0', 'CS4', 'CS6'"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_settings_connection_validate_permission_user(const char *item, gssize len)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -273,6 +273,7 @@ NMClientPermissionResult nm_client_permission_result_from_string(const char *nm)
|
|||
const char *nm_client_permission_result_to_string(NMClientPermissionResult permission);
|
||||
|
||||
gboolean nm_utils_validate_dhcp4_vendor_class_id(const char *vci, GError **error);
|
||||
gboolean nm_utils_validate_dhcp_dscp(const char *dscp, GError **error);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
|
|
|||
|
|
@ -1564,6 +1564,10 @@
|
|||
dbus-type="s"
|
||||
gprop-type="gchararray"
|
||||
/>
|
||||
<property name="dhcp-dscp"
|
||||
dbus-type="s"
|
||||
gprop-type="gchararray"
|
||||
/>
|
||||
<property name="dhcp-fqdn"
|
||||
dbus-type="s"
|
||||
gprop-type="gchararray"
|
||||
|
|
@ -1695,6 +1699,10 @@
|
|||
dbus-type="i"
|
||||
gprop-type="gint"
|
||||
/>
|
||||
<property name="dhcp-dscp"
|
||||
dbus-type="s"
|
||||
gprop-type="gchararray"
|
||||
/>
|
||||
<property name="dhcp-duid"
|
||||
dbus-type="s"
|
||||
gprop-type="gchararray"
|
||||
|
|
|
|||
|
|
@ -3993,6 +3993,7 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingIPConfig,
|
|||
PROP_IGNORE_AUTO_ROUTES,
|
||||
PROP_IGNORE_AUTO_DNS,
|
||||
PROP_DHCP_HOSTNAME,
|
||||
PROP_DHCP_DSCP,
|
||||
PROP_DHCP_HOSTNAME_FLAGS,
|
||||
PROP_DHCP_SEND_HOSTNAME,
|
||||
PROP_NEVER_DEFAULT,
|
||||
|
|
@ -5200,6 +5201,25 @@ nm_setting_ip_config_get_dhcp_send_hostname(NMSettingIPConfig *setting)
|
|||
return NM_SETTING_IP_CONFIG_GET_PRIVATE(setting)->dhcp_send_hostname;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_ip_config_get_dhcp_dscp:
|
||||
* @setting: the #NMSettingIPConfig
|
||||
*
|
||||
* Returns the value contained in the #NMSettingIPConfig:dhcp-dscp
|
||||
* property.
|
||||
*
|
||||
* Returns: the value for the DSCP field for DHCP
|
||||
*
|
||||
* Since: 1.46
|
||||
**/
|
||||
const char *
|
||||
nm_setting_ip_config_get_dhcp_dscp(NMSettingIPConfig *setting)
|
||||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_IP_CONFIG(setting), NULL);
|
||||
|
||||
return NM_SETTING_IP_CONFIG_GET_PRIVATE(setting)->dhcp_dscp;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_ip_config_get_never_default:
|
||||
* @setting: the #NMSettingIPConfig
|
||||
|
|
@ -5731,6 +5751,14 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
}
|
||||
}
|
||||
|
||||
if (priv->dhcp_dscp && !nm_utils_validate_dhcp_dscp(priv->dhcp_dscp, error)) {
|
||||
g_prefix_error(error,
|
||||
"%s.%s: ",
|
||||
nm_setting_get_name(setting),
|
||||
NM_SETTING_IP_CONFIG_DHCP_DSCP);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Normalizable errors */
|
||||
if (priv->gateway && priv->never_default) {
|
||||
g_set_error(error,
|
||||
|
|
@ -5983,6 +6011,12 @@ _nm_sett_info_property_override_create_array_ip_config(int addr_family)
|
|||
.direct_offset = NM_STRUCT_OFFSET_ENSURE_TYPE(char *, NMSettingIPConfigPrivate, dhcp_iaid),
|
||||
.direct_string_allow_empty = TRUE);
|
||||
|
||||
_nm_properties_override_gobj(
|
||||
properties_override,
|
||||
obj_properties[PROP_DHCP_DSCP],
|
||||
&nm_sett_info_propert_type_direct_string,
|
||||
.direct_offset = NM_STRUCT_OFFSET_ENSURE_TYPE(char *, NMSettingIPConfigPrivate, dhcp_dscp));
|
||||
|
||||
/* ---dbus---
|
||||
* property: routing-rules
|
||||
* format: array of 'a{sv}'
|
||||
|
|
@ -6614,6 +6648,25 @@ nm_setting_ip_config_class_init(NMSettingIPConfigClass *klass)
|
|||
TRUE,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* NMSettingIPConfig:dhcp-dscp:
|
||||
*
|
||||
* Specifies the value for the DSCP field (traffic class) of the IP header. When
|
||||
* empty, the global default value is used; if no global default is specified, it is
|
||||
* assumed to be "CS0". Allowed values are: "CS0", "CS4" and "CS6".
|
||||
*
|
||||
* The property is currently valid only for IPv4, and it is supported only by the
|
||||
* "internal" DHCP plugin.
|
||||
*
|
||||
* Since: 1.46
|
||||
**/
|
||||
obj_properties[PROP_DHCP_DSCP] =
|
||||
g_param_spec_string(NM_SETTING_IP_CONFIG_DHCP_DSCP,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* NMSettingIPConfig:never-default:
|
||||
*
|
||||
|
|
|
|||
|
|
@ -386,6 +386,18 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
}
|
||||
}
|
||||
|
||||
if (nm_setting_ip_config_get_dhcp_dscp(s_ip)) {
|
||||
g_set_error_literal(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("DHCP DSCP is not supported for IPv6"));
|
||||
g_prefix_error(error,
|
||||
"%s.%s: ",
|
||||
NM_SETTING_IP6_CONFIG_SETTING_NAME,
|
||||
NM_SETTING_IP_CONFIG_DHCP_DSCP);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Failures from here on, are NORMALIZABLE_ERROR... */
|
||||
|
||||
if (token_needs_normalization) {
|
||||
|
|
|
|||
|
|
@ -185,6 +185,7 @@ typedef struct {
|
|||
char *gateway;
|
||||
char *dhcp_hostname;
|
||||
char *dhcp_iaid;
|
||||
char *dhcp_dscp;
|
||||
gint64 route_metric;
|
||||
int auto_route_ext_gw;
|
||||
int replace_local_rule;
|
||||
|
|
|
|||
|
|
@ -4082,6 +4082,7 @@ test_connection_diff_a_only(void)
|
|||
{NM_SETTING_IP_CONFIG_REQUIRED_TIMEOUT, NM_SETTING_DIFF_RESULT_IN_A},
|
||||
{NM_SETTING_IP_CONFIG_DNS_PRIORITY, NM_SETTING_DIFF_RESULT_IN_A},
|
||||
{NM_SETTING_IP_CONFIG_DHCP_IAID, NM_SETTING_DIFF_RESULT_IN_A},
|
||||
{NM_SETTING_IP_CONFIG_DHCP_DSCP, NM_SETTING_DIFF_RESULT_IN_A},
|
||||
{NM_SETTING_IP4_CONFIG_DHCP_VENDOR_CLASS_IDENTIFIER, NM_SETTING_DIFF_RESULT_IN_A},
|
||||
{NM_SETTING_IP_CONFIG_DHCP_REJECT_SERVERS, NM_SETTING_DIFF_RESULT_IN_A},
|
||||
{NM_SETTING_IP4_CONFIG_LINK_LOCAL, NM_SETTING_DIFF_RESULT_IN_A},
|
||||
|
|
|
|||
|
|
@ -332,6 +332,7 @@ char *nm_ip_routing_rule_to_string(const NMIPRoutingRule *self,
|
|||
#define NM_SETTING_IP_CONFIG_DHCP_HOSTNAME "dhcp-hostname"
|
||||
#define NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME "dhcp-send-hostname"
|
||||
#define NM_SETTING_IP_CONFIG_DHCP_HOSTNAME_FLAGS "dhcp-hostname-flags"
|
||||
#define NM_SETTING_IP_CONFIG_DHCP_DSCP "dhcp-dscp"
|
||||
#define NM_SETTING_IP_CONFIG_NEVER_DEFAULT "never-default"
|
||||
#define NM_SETTING_IP_CONFIG_MAY_FAIL "may-fail"
|
||||
#define NM_SETTING_IP_CONFIG_DAD_TIMEOUT "dad-timeout"
|
||||
|
|
@ -478,6 +479,8 @@ gboolean nm_setting_ip_config_get_ignore_auto_dns(NMSettingIPConfig *setting);
|
|||
|
||||
const char *nm_setting_ip_config_get_dhcp_hostname(NMSettingIPConfig *setting);
|
||||
gboolean nm_setting_ip_config_get_dhcp_send_hostname(NMSettingIPConfig *setting);
|
||||
NM_AVAILABLE_IN_1_46
|
||||
const char *nm_setting_ip_config_get_dhcp_dscp(NMSettingIPConfig *setting);
|
||||
|
||||
gboolean nm_setting_ip_config_get_never_default(NMSettingIPConfig *setting);
|
||||
gboolean nm_setting_ip_config_get_may_fail(NMSettingIPConfig *setting);
|
||||
|
|
|
|||
|
|
@ -6368,6 +6368,12 @@ static const NMMetaPropertyInfo *const property_infos_IP4_CONFIG[] = {
|
|||
PROPERTY_INFO (NM_SETTING_IP_CONFIG_DHCP_IAID, DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DHCP_IAID,
|
||||
.property_type = &_pt_gobject_string,
|
||||
),
|
||||
PROPERTY_INFO (NM_SETTING_IP_CONFIG_DHCP_DSCP, DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DHCP_DSCP,
|
||||
.property_type = &_pt_gobject_string,
|
||||
.property_typ_data = DEFINE_PROPERTY_TYP_DATA (
|
||||
.values_static = NM_MAKE_STRV ("CS0", "CS4", "CS6"),
|
||||
),
|
||||
),
|
||||
PROPERTY_INFO (NM_SETTING_IP_CONFIG_DHCP_TIMEOUT, DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DHCP_TIMEOUT,
|
||||
.property_type = &_pt_gobject_int,
|
||||
.property_typ_data = &_ptd_gobject_int_timeout,
|
||||
|
|
|
|||
|
|
@ -165,6 +165,7 @@
|
|||
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_AUTO_ROUTE_EXT_GW N_("VPN connections will default to add the route automatically unless this setting is set to FALSE. For other connection types, adding such an automatic route is currently not supported and setting this to TRUE has no effect.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DAD_TIMEOUT N_("Maximum timeout in milliseconds used to check for the presence of duplicate IP addresses on the network. If an address conflict is detected, the activation will fail. The property is currently implemented only for IPv4. A zero value means that no duplicate address detection is performed, -1 means the default value (either the value configured globally in NetworkManger.conf or 200ms). A value greater than zero is a timeout in milliseconds. Note that the time intervals are subject to randomization as per RFC 5227 and so the actual duration can be between half and the full time specified in this property.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID N_("A string sent to the DHCP server to identify the local machine which the DHCP server may use to customize the DHCP lease and options. When the property is a hex string ('aa:bb:cc') it is interpreted as a binary client ID, in which case the first byte is assumed to be the 'type' field as per RFC 2132 section 9.14 and the remaining bytes may be an hardware address (e.g. '01:xx:xx:xx:xx:xx:xx' where 1 is the Ethernet ARP type and the rest is a MAC address). If the property is not a hex string it is considered as a non-hardware-address client ID and the 'type' field is set to 0. The special values \"mac\" and \"perm-mac\" are supported, which use the current or permanent MAC address of the device to generate a client identifier with type ethernet (01). Currently, these options only work for ethernet type of links. The special value \"ipv6-duid\" uses the DUID from \"ipv6.dhcp-duid\" property as an RFC4361-compliant client identifier. As IAID it uses \"ipv4.dhcp-iaid\" and falls back to \"ipv6.dhcp-iaid\" if unset. The special value \"duid\" generates a RFC4361-compliant client identifier based on \"ipv4.dhcp-iaid\" and uses a DUID generated by hashing /etc/machine-id. The special value \"stable\" is supported to generate a type 0 client identifier based on the stable-id (see connection.stable-id) and a per-host key. If you set the stable-id, you may want to include the \"${DEVICE}\" or \"${MAC}\" specifier to get a per-device key. The special value \"none\" prevents any client identifier from being sent. Note that this is normally not recommended. If unset, a globally configured default from NetworkManager.conf is used. If still unset, the default depends on the DHCP plugin. The internal dhcp client will default to \"mac\" and the dhclient plugin will try to use one from its config file if present, or won't sent any client-id otherwise.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DHCP_DSCP N_("Specifies the value for the DSCP field (traffic class) of the IP header. When empty, the global default value is used; if no global default is specified, it is assumed to be \"CS0\". Allowed values are: \"CS0\", \"CS4\" and \"CS6\". The property is currently valid only for IPv4, and it is supported only by the \"internal\" DHCP plugin.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DHCP_FQDN N_("If the \"dhcp-send-hostname\" property is TRUE, then the specified FQDN will be sent to the DHCP server when acquiring a lease. This property and \"dhcp-hostname\" are mutually exclusive and cannot be set at the same time.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DHCP_HOSTNAME N_("If the \"dhcp-send-hostname\" property is TRUE, then the specified name will be sent to the DHCP server when acquiring a lease. This property and \"dhcp-fqdn\" are mutually exclusive and cannot be set at the same time.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DHCP_HOSTNAME_FLAGS N_("Flags for the DHCP hostname and FQDN. Currently, this property only includes flags to control the FQDN flags set in the DHCP FQDN option. Supported FQDN flags are \"fqdn-serv-update\" (0x1), \"fqdn-encoded\" (0x2) and \"fqdn-no-update\" (0x4). When no FQDN flag is set and \"fqdn-clear-flags\" (0x8) is set, the DHCP FQDN option will contain no flag. Otherwise, if no FQDN flag is set and \"fqdn-clear-flags\" (0x8) is not set, the standard FQDN flags are set in the request: \"fqdn-serv-update\" (0x1), \"fqdn-encoded\" (0x2) for IPv4 and \"fqdn-serv-update\" (0x1) for IPv6. When this property is set to the default value \"none\" (0x0), a global default is looked up in NetworkManager configuration. If that value is unset or also \"none\" (0x0), then the standard FQDN flags described above are sent in the DHCP requests.")
|
||||
|
|
@ -194,6 +195,7 @@
|
|||
#define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_ADDRESSES N_("A list of IPv6 addresses and their prefix length. Multiple addresses can be separated by comma. For example \"2001:db8:85a3::8a2e:370:7334/64, 2001:db8:85a3::5/64\". The addresses are listed in decreasing priority, meaning the first address will be the primary address. This can make a difference with IPv6 source address selection (RFC 6724, section 5).")
|
||||
#define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_AUTO_ROUTE_EXT_GW N_("VPN connections will default to add the route automatically unless this setting is set to FALSE. For other connection types, adding such an automatic route is currently not supported and setting this to TRUE has no effect.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DAD_TIMEOUT N_("Maximum timeout in milliseconds used to check for the presence of duplicate IP addresses on the network. If an address conflict is detected, the activation will fail. The property is currently implemented only for IPv4. A zero value means that no duplicate address detection is performed, -1 means the default value (either the value configured globally in NetworkManger.conf or 200ms). A value greater than zero is a timeout in milliseconds. Note that the time intervals are subject to randomization as per RFC 5227 and so the actual duration can be between half and the full time specified in this property.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DHCP_DSCP N_("Specifies the value for the DSCP field (traffic class) of the IP header. When empty, the global default value is used; if no global default is specified, it is assumed to be \"CS0\". Allowed values are: \"CS0\", \"CS4\" and \"CS6\". The property is currently valid only for IPv4, and it is supported only by the \"internal\" DHCP plugin.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DHCP_DUID N_("A string containing the DHCPv6 Unique Identifier (DUID) used by the dhcp client to identify itself to DHCPv6 servers (RFC 3315). The DUID is carried in the Client Identifier option. If the property is a hex string ('aa:bb:cc') it is interpreted as a binary DUID and filled as an opaque value in the Client Identifier option. The special value \"lease\" will retrieve the DUID previously used from the lease file belonging to the connection. If no DUID is found and \"dhclient\" is the configured dhcp client, the DUID is searched in the system-wide dhclient lease file. If still no DUID is found, or another dhcp client is used, a global and permanent DUID-UUID (RFC 6355) will be generated based on the machine-id. The special values \"llt\" and \"ll\" will generate a DUID of type LLT or LL (see RFC 3315) based on the current MAC address of the device. In order to try providing a stable DUID-LLT, the time field will contain a constant timestamp that is used globally (for all profiles) and persisted to disk. The special values \"stable-llt\", \"stable-ll\" and \"stable-uuid\" will generate a DUID of the corresponding type, derived from the connection's stable-id and a per-host unique key. You may want to include the \"${DEVICE}\" or \"${MAC}\" specifier in the stable-id, in case this profile gets activated on multiple devices. So, the link-layer address of \"stable-ll\" and \"stable-llt\" will be a generated address derived from the stable id. The DUID-LLT time value in the \"stable-llt\" option will be picked among a static timespan of three years (the upper bound of the interval is the same constant timestamp used in \"llt\"). When the property is unset, the global value provided for \"ipv6.dhcp-duid\" is used. If no global value is provided, the default \"lease\" value is assumed.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DHCP_HOSTNAME N_("If the \"dhcp-send-hostname\" property is TRUE, then the specified name will be sent to the DHCP server when acquiring a lease. This property and \"dhcp-fqdn\" are mutually exclusive and cannot be set at the same time.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DHCP_HOSTNAME_FLAGS N_("Flags for the DHCP hostname and FQDN. Currently, this property only includes flags to control the FQDN flags set in the DHCP FQDN option. Supported FQDN flags are \"fqdn-serv-update\" (0x1), \"fqdn-encoded\" (0x2) and \"fqdn-no-update\" (0x4). When no FQDN flag is set and \"fqdn-clear-flags\" (0x8) is set, the DHCP FQDN option will contain no flag. Otherwise, if no FQDN flag is set and \"fqdn-clear-flags\" (0x8) is not set, the standard FQDN flags are set in the request: \"fqdn-serv-update\" (0x1), \"fqdn-encoded\" (0x2) for IPv4 and \"fqdn-serv-update\" (0x1) for IPv6. When this property is set to the default value \"none\" (0x0), a global default is looked up in NetworkManager configuration. If that value is unset or also \"none\" (0x0), then the standard FQDN flags described above are sent in the DHCP requests.")
|
||||
|
|
|
|||
|
|
@ -191,7 +191,8 @@ int n_dhcp4_c_connection_connect(NDhcp4CConnection *connection,
|
|||
r = n_dhcp4_c_socket_udp_new(&fd_udp,
|
||||
connection->client_config->ifindex,
|
||||
client,
|
||||
server);
|
||||
server,
|
||||
connection->probe_config->dscp);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
|
|
@ -388,6 +389,7 @@ static int n_dhcp4_c_connection_packet_broadcast(NDhcp4CConnection *connection,
|
|||
connection->client_config->ifindex,
|
||||
connection->client_config->broadcast_mac,
|
||||
connection->client_config->n_broadcast_mac,
|
||||
connection->probe_config->dscp,
|
||||
message);
|
||||
if (r)
|
||||
return r;
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ int n_dhcp4_client_probe_config_dup(NDhcp4ClientProbeConfig *config,
|
|||
dup->init_reboot = config->init_reboot;
|
||||
dup->requested_ip = config->requested_ip;
|
||||
dup->ms_start_delay = config->ms_start_delay;
|
||||
dup->dscp = config->dscp;
|
||||
|
||||
for (unsigned int i = 0; i < config->n_request_parameters; ++i)
|
||||
dup->request_parameters[dup->n_request_parameters++] = config->request_parameters[i];
|
||||
|
|
@ -190,6 +191,19 @@ _c_public_ void n_dhcp4_client_probe_config_set_init_reboot(NDhcp4ClientProbeCon
|
|||
config->init_reboot = init_reboot;
|
||||
}
|
||||
|
||||
/**
|
||||
* n_dhcp4_client_probe_config_set_dscp() - set the IP DSCP value
|
||||
* @config: configuration to operate on
|
||||
* @dscp: value to set
|
||||
*
|
||||
* This sets the DSCP property of the configuration object, which specifies
|
||||
* the DSCP value to set in the first six bits of the DS field in the IPv4
|
||||
* header. If this function is not called, the DSCP will be set to CS0.
|
||||
*/
|
||||
_c_public_ void n_dhcp4_client_probe_config_set_dscp(NDhcp4ClientProbeConfig *config, uint8_t dscp) {
|
||||
config->dscp = dscp & 0x3F;
|
||||
}
|
||||
|
||||
/**
|
||||
* n_dhcp4_client_probe_config_set_requested_ip() - set requested-ip property
|
||||
* @config: configuration to operate on
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include <endian.h>
|
||||
#include <inttypes.h>
|
||||
#include <limits.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
|
@ -34,6 +35,7 @@ typedef struct NDhcp4LogQueue NDhcp4LogQueue;
|
|||
#define N_DHCP4_NETWORK_CLIENT_PORT (68)
|
||||
#define N_DHCP4_MESSAGE_MAGIC ((uint32_t)(0x63825363))
|
||||
#define N_DHCP4_MESSAGE_FLAG_BROADCAST (htons(0x8000))
|
||||
#define N_DHCP4_DSCP_DEFAULT (IPTOS_CLASS_CS0 >> 2)
|
||||
|
||||
enum {
|
||||
N_DHCP4_OP_BOOTREQUEST = 1,
|
||||
|
|
@ -263,6 +265,7 @@ struct NDhcp4ClientProbeOption {
|
|||
struct NDhcp4ClientProbeConfig {
|
||||
bool inform_only;
|
||||
bool init_reboot;
|
||||
uint8_t dscp;
|
||||
struct in_addr requested_ip;
|
||||
unsigned short int entropy[3];
|
||||
uint64_t ms_start_delay; /* max ms to wait before starting probe */
|
||||
|
|
@ -273,6 +276,7 @@ struct NDhcp4ClientProbeConfig {
|
|||
|
||||
#define N_DHCP4_CLIENT_PROBE_CONFIG_NULL(_x) { \
|
||||
.ms_start_delay = N_DHCP4_CLIENT_START_DELAY_RFC2131, \
|
||||
.dscp = N_DHCP4_DSCP_DEFAULT, \
|
||||
}
|
||||
|
||||
struct NDhcp4CEventNode {
|
||||
|
|
@ -536,7 +540,8 @@ int n_dhcp4_c_socket_packet_new(int *sockfdp, int ifindex);
|
|||
int n_dhcp4_c_socket_udp_new(int *sockfdp,
|
||||
int ifindex,
|
||||
const struct in_addr *client_addr,
|
||||
const struct in_addr *server_addr);
|
||||
const struct in_addr *server_addr,
|
||||
uint8_t dscp);
|
||||
int n_dhcp4_s_socket_packet_new(int *sockfdp);
|
||||
int n_dhcp4_s_socket_udp_new(int *sockfdp, int ifindex);
|
||||
|
||||
|
|
@ -544,6 +549,7 @@ int n_dhcp4_c_socket_packet_send(int sockfd,
|
|||
int ifindex,
|
||||
const unsigned char *dest_haddr,
|
||||
unsigned char halen,
|
||||
uint8_t dscp,
|
||||
NDhcp4Outgoing *message);
|
||||
int n_dhcp4_c_socket_udp_send(int sockfd, NDhcp4Outgoing *message);
|
||||
int n_dhcp4_c_socket_udp_broadcast(int sockfd, NDhcp4Outgoing *message);
|
||||
|
|
@ -553,6 +559,7 @@ int n_dhcp4_s_socket_packet_send(int sockfd,
|
|||
const unsigned char *dest_haddr,
|
||||
unsigned char halen,
|
||||
const struct in_addr *dest_inaddr,
|
||||
uint8_t dscp,
|
||||
NDhcp4Outgoing *message);
|
||||
int n_dhcp4_s_socket_udp_send(int sockfd,
|
||||
const struct in_addr *inaddr_src,
|
||||
|
|
|
|||
|
|
@ -202,6 +202,7 @@ int n_dhcp4_s_connection_send_reply(NDhcp4SConnection *connection,
|
|||
header->chaddr,
|
||||
header->hlen,
|
||||
&(struct in_addr){header->yiaddr},
|
||||
N_DHCP4_DSCP_DEFAULT,
|
||||
message);
|
||||
if (r)
|
||||
return r;
|
||||
|
|
|
|||
|
|
@ -133,6 +133,7 @@ int n_dhcp4_c_socket_packet_new(int *sockfdp, int ifindex) {
|
|||
* @ifindex: interface index to bind to
|
||||
* @client_addr: client address to bind to
|
||||
* @server_addr: server address to connect to
|
||||
* @dscp: the DSCP value
|
||||
*
|
||||
* Create a new AF_INET/SOCK_DGRAM socket usable to listen to and send DHCP client
|
||||
* packets.
|
||||
|
|
@ -145,7 +146,8 @@ int n_dhcp4_c_socket_packet_new(int *sockfdp, int ifindex) {
|
|||
int n_dhcp4_c_socket_udp_new(int *sockfdp,
|
||||
int ifindex,
|
||||
const struct in_addr *client_addr,
|
||||
const struct in_addr *server_addr) {
|
||||
const struct in_addr *server_addr,
|
||||
uint8_t dscp) {
|
||||
_c_cleanup_(c_closep) int sockfd = -1;
|
||||
struct sock_filter filter[] = {
|
||||
/*
|
||||
|
|
@ -189,7 +191,8 @@ int n_dhcp4_c_socket_udp_new(int *sockfdp,
|
|||
.sin_addr = *server_addr,
|
||||
.sin_port = htons(N_DHCP4_NETWORK_SERVER_PORT),
|
||||
};
|
||||
int r, tos = IPTOS_CLASS_CS6, on = 1;
|
||||
int r, on = 1;
|
||||
int tos = dscp << 2;
|
||||
|
||||
sockfd = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0);
|
||||
if (sockfd < 0)
|
||||
|
|
@ -340,6 +343,7 @@ static int n_dhcp4_socket_packet_send(int sockfd,
|
|||
const unsigned char *dest_haddr,
|
||||
unsigned char halen,
|
||||
const struct sockaddr_in *dest_paddr,
|
||||
uint8_t dscp,
|
||||
NDhcp4Outgoing *message) {
|
||||
struct packet_sockaddr_ll haddr = {
|
||||
.sll_family = AF_PACKET,
|
||||
|
|
@ -357,7 +361,7 @@ static int n_dhcp4_socket_packet_send(int sockfd,
|
|||
|
||||
n_buf = n_dhcp4_outgoing_get_raw(message, &buf);
|
||||
|
||||
r = packet_sendto_udp(sockfd, buf, n_buf, &len, src_paddr, &haddr, dest_paddr);
|
||||
r = packet_sendto_udp(sockfd, buf, n_buf, &len, src_paddr, &haddr, dest_paddr, dscp);
|
||||
if (r < 0) {
|
||||
if (r == -EAGAIN || r == -ENOBUFS)
|
||||
return N_DHCP4_E_DROPPED;
|
||||
|
|
@ -379,6 +383,7 @@ int n_dhcp4_c_socket_packet_send(int sockfd,
|
|||
int ifindex,
|
||||
const unsigned char *dest_haddr,
|
||||
unsigned char halen,
|
||||
uint8_t dscp,
|
||||
NDhcp4Outgoing *message) {
|
||||
struct sockaddr_in src_paddr = {
|
||||
.sin_family = AF_INET,
|
||||
|
|
@ -397,6 +402,7 @@ int n_dhcp4_c_socket_packet_send(int sockfd,
|
|||
dest_haddr,
|
||||
halen,
|
||||
&dest_paddr,
|
||||
dscp,
|
||||
message);
|
||||
}
|
||||
|
||||
|
|
@ -468,6 +474,7 @@ int n_dhcp4_s_socket_packet_send(int sockfd,
|
|||
const unsigned char *dest_haddr,
|
||||
unsigned char halen,
|
||||
const struct in_addr *dest_inaddr,
|
||||
uint8_t dscp,
|
||||
NDhcp4Outgoing *message) {
|
||||
struct sockaddr_in src_paddr = {
|
||||
.sin_family = AF_INET,
|
||||
|
|
@ -486,6 +493,7 @@ int n_dhcp4_s_socket_packet_send(int sockfd,
|
|||
dest_haddr,
|
||||
halen,
|
||||
&dest_paddr,
|
||||
dscp,
|
||||
message);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -128,6 +128,7 @@ NDhcp4ClientProbeConfig *n_dhcp4_client_probe_config_free(NDhcp4ClientProbeConfi
|
|||
|
||||
void n_dhcp4_client_probe_config_set_inform_only(NDhcp4ClientProbeConfig *config, bool inform_only);
|
||||
void n_dhcp4_client_probe_config_set_init_reboot(NDhcp4ClientProbeConfig *config, bool init_reboot);
|
||||
void n_dhcp4_client_probe_config_set_dscp(NDhcp4ClientProbeConfig *config, uint8_t dscp);
|
||||
void n_dhcp4_client_probe_config_set_requested_ip(NDhcp4ClientProbeConfig *config, struct in_addr ip);
|
||||
void n_dhcp4_client_probe_config_set_start_delay(NDhcp4ClientProbeConfig *config, uint64_t msecs);
|
||||
void n_dhcp4_client_probe_config_request_option(NDhcp4ClientProbeConfig *config, uint8_t option);
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ static void test_client_udp_socket_new(Link *link,
|
|||
netns_get(&oldns);
|
||||
netns_set(link->netns);
|
||||
|
||||
r = n_dhcp4_c_socket_udp_new(skp, link->ifindex, addr_client, addr_server);
|
||||
r = n_dhcp4_c_socket_udp_new(skp, link->ifindex, addr_client, addr_server, N_DHCP4_DSCP_DEFAULT);
|
||||
c_assert(r >= 0);
|
||||
|
||||
netns_set(oldns);
|
||||
|
|
@ -95,6 +95,7 @@ static void test_client_server_packet(Link *link_server, Link *link_client) {
|
|||
link_client->ifindex,
|
||||
(const unsigned char[]){0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
|
||||
ETH_ALEN,
|
||||
-1,
|
||||
outgoing);
|
||||
c_assert(!r);
|
||||
|
||||
|
|
@ -178,6 +179,7 @@ static void test_server_client_packet(Link *link_server, Link *link_client) {
|
|||
link_client->mac.ether_addr_octet,
|
||||
ETH_ALEN,
|
||||
&addr_client,
|
||||
N_DHCP4_DSCP_DEFAULT,
|
||||
outgoing);
|
||||
c_assert(!r);
|
||||
r = n_dhcp4_s_socket_packet_send(sk_server,
|
||||
|
|
@ -188,6 +190,7 @@ static void test_server_client_packet(Link *link_server, Link *link_client) {
|
|||
},
|
||||
ETH_ALEN,
|
||||
&addr_client,
|
||||
N_DHCP4_DSCP_DEFAULT,
|
||||
outgoing);
|
||||
c_assert(!r);
|
||||
|
||||
|
|
|
|||
|
|
@ -150,6 +150,7 @@ uint16_t packet_internet_checksum_udp(const struct in_addr *src_addr,
|
|||
* @src_paddr: source protocol address, see ip(7)
|
||||
* @dest_haddr: destination hardware address, see packet(7)
|
||||
* @dest_paddr: destination protocol address, see ip(7)
|
||||
* @dscp: the DSCP value
|
||||
*
|
||||
* Sends an UDP packet on a AF_PACKET socket directly to a hardware
|
||||
* address. The difference between this and sendto() on an AF_INET
|
||||
|
|
@ -165,11 +166,12 @@ int packet_sendto_udp(int sockfd,
|
|||
size_t *n_transmittedp,
|
||||
const struct sockaddr_in *src_paddr,
|
||||
const struct packet_sockaddr_ll *dest_haddr,
|
||||
const struct sockaddr_in *dest_paddr) {
|
||||
const struct sockaddr_in *dest_paddr,
|
||||
uint8_t dscp) {
|
||||
struct iphdr ip_hdr = {
|
||||
.version = IPVERSION,
|
||||
.ihl = sizeof(ip_hdr) / 4, /* Length of header in multiples of four bytes */
|
||||
.tos = IPTOS_CLASS_CS6, /* Class Selector for network control */
|
||||
.tos = dscp << 2,
|
||||
.tot_len = htons(sizeof(struct iphdr) + sizeof(struct udphdr) + n_buf),
|
||||
.frag_off = htons(IP_DF), /* Do not fragment */
|
||||
.ttl = IPDEFTTL,
|
||||
|
|
|
|||
|
|
@ -42,7 +42,8 @@ int packet_sendto_udp(int sockfd,
|
|||
size_t *n_transmittedp,
|
||||
const struct sockaddr_in *src_paddr,
|
||||
const struct packet_sockaddr_ll *dest_haddr,
|
||||
const struct sockaddr_in *dest_paddr);
|
||||
const struct sockaddr_in *dest_paddr,
|
||||
uint8_t dscp);
|
||||
int packet_recvfrom_udp(int sockfd,
|
||||
void *buf,
|
||||
size_t n_buf,
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ static void test_packet_unicast(int ifindex, int sk, void *buf, size_t n_buf,
|
|||
|
||||
memcpy(addr.sll_addr, haddr_dst, ETH_ALEN);
|
||||
|
||||
r = packet_sendto_udp(sk, buf, n_buf, &len, paddr_src, &addr, paddr_dst);
|
||||
r = packet_sendto_udp(sk, buf, n_buf, &len, paddr_src, &addr, paddr_dst, N_DHCP4_DSCP_DEFAULT);
|
||||
c_assert(!r);
|
||||
c_assert(len == n_buf);
|
||||
}
|
||||
|
|
@ -142,7 +142,7 @@ static void test_packet_broadcast(int ifindex, int sk, void *buf, size_t n_buf,
|
|||
|
||||
memcpy(addr.sll_addr, (unsigned char[]){ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, }, ETH_ALEN);
|
||||
|
||||
r = packet_sendto_udp(sk, buf, n_buf, &len, paddr_src, &addr, paddr_dst);
|
||||
r = packet_sendto_udp(sk, buf, n_buf, &len, paddr_src, &addr, paddr_dst, N_DHCP4_DSCP_DEFAULT);
|
||||
c_assert(!r);
|
||||
c_assert(len == n_buf);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ typedef struct {
|
|||
gboolean ignore_auto_dns;
|
||||
int dhcp_timeout;
|
||||
char *dhcp4_vci;
|
||||
char *dhcp_dscp;
|
||||
|
||||
gint64 carrier_timeout_sec;
|
||||
} Reader;
|
||||
|
|
@ -73,6 +74,7 @@ reader_destroy(Reader *reader, gboolean free_hash)
|
|||
nm_clear_g_free(&reader->hostname);
|
||||
g_hash_table_unref(reader->znet_ifnames);
|
||||
nm_clear_g_free(&reader->dhcp4_vci);
|
||||
nm_clear_g_free(&reader->dhcp_dscp);
|
||||
nm_g_slice_free(reader);
|
||||
if (!free_hash)
|
||||
return g_steal_pointer(&hash);
|
||||
|
|
@ -122,6 +124,8 @@ reader_create_connection(Reader *reader,
|
|||
reader->dhcp_timeout,
|
||||
NM_SETTING_IP4_CONFIG_DHCP_VENDOR_CLASS_IDENTIFIER,
|
||||
reader->dhcp4_vci,
|
||||
NM_SETTING_IP_CONFIG_DHCP_DSCP,
|
||||
reader->dhcp_dscp,
|
||||
NM_SETTING_IP_CONFIG_REQUIRED_TIMEOUT,
|
||||
NMI_IP_REQUIRED_TIMEOUT_MSEC,
|
||||
NULL);
|
||||
|
|
@ -1289,6 +1293,8 @@ _normalize_conn(gpointer key, gpointer value, gpointer user_data)
|
|||
NULL,
|
||||
NM_SETTING_IP4_CONFIG_DHCP_VENDOR_CLASS_IDENTIFIER,
|
||||
NULL,
|
||||
NM_SETTING_IP_CONFIG_DHCP_DSCP,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
|
@ -1429,6 +1435,13 @@ nmi_cmdline_reader_parse(const char *etc_connections_dir,
|
|||
} else if (nm_streq(tag, "rd.net.dhcp.vendor-class")) {
|
||||
if (nm_utils_validate_dhcp4_vendor_class_id(argument, NULL))
|
||||
nm_strdup_reset(&reader->dhcp4_vci, argument);
|
||||
} else if (nm_streq(tag, "rd.net.dhcp.dscp")) {
|
||||
gs_free_error GError *error = NULL;
|
||||
|
||||
if (nm_utils_validate_dhcp_dscp(argument, &error))
|
||||
nm_strdup_reset(&reader->dhcp_dscp, argument);
|
||||
else
|
||||
_LOGW(LOGD_CORE, "Ignoring 'rd.net.dhcp.dscp=%s': %s", argument, error->message);
|
||||
} else if (nm_streq(tag, "rd.net.timeout.carrier")) {
|
||||
reader->carrier_timeout_sec =
|
||||
_nm_utils_ascii_str_to_int64(argument, 10, 0, G_MAXINT32, 0);
|
||||
|
|
@ -1491,8 +1504,9 @@ nmi_cmdline_reader_parse(const char *etc_connections_dir,
|
|||
} else if (g_ascii_strcasecmp(tag, "BOOTIF") == 0) {
|
||||
nm_clear_g_free(&bootif_val);
|
||||
bootif_val = g_strdup(argument);
|
||||
} else if (nm_streq(tag, "rd.ethtool"))
|
||||
} else if (nm_streq(tag, "rd.ethtool")) {
|
||||
reader_parse_ethtool(reader, argument);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < reader->vlan_parents->len; i++) {
|
||||
|
|
|
|||
|
|
@ -2354,6 +2354,33 @@ test_dhcp_vendor_class_id(void)
|
|||
g_assert(nm_setting_ip4_config_get_dhcp_vendor_class_identifier(s_ip4) == NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
test_dhcp_dscp(void)
|
||||
{
|
||||
const char *const *ARGV;
|
||||
gs_unref_object NMConnection *connection = NULL;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
|
||||
ARGV = NM_MAKE_STRV("rd.net.dhcp.dscp=CS4", "ip=eno1:dhcp");
|
||||
connection = _parse_con(ARGV, "eno1");
|
||||
s_ip4 = NM_SETTING_IP_CONFIG(nm_connection_get_setting_ip4_config(connection));
|
||||
g_assert_cmpstr(nm_setting_ip_config_get_dhcp_dscp(s_ip4), ==, "CS4");
|
||||
|
||||
g_clear_object(&connection);
|
||||
|
||||
ARGV = NM_MAKE_STRV("rd.net.dhcp.dscp=CS0", "ip=eno1:dhcp");
|
||||
connection = _parse_con(ARGV, "eno1");
|
||||
s_ip4 = NM_SETTING_IP_CONFIG(nm_connection_get_setting_ip4_config(connection));
|
||||
g_assert_cmpstr(nm_setting_ip_config_get_dhcp_dscp(s_ip4), ==, "CS0");
|
||||
|
||||
g_clear_object(&connection);
|
||||
|
||||
ARGV = NM_MAKE_STRV("ip=eno1:dhcp");
|
||||
connection = _parse_con(ARGV, "eno1");
|
||||
s_ip4 = NM_SETTING_IP_CONFIG(nm_connection_get_setting_ip4_config(connection));
|
||||
g_assert_cmpstr(nm_setting_ip_config_get_dhcp_dscp(s_ip4), ==, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
test_infiniband_iface(void)
|
||||
{
|
||||
|
|
@ -2652,6 +2679,7 @@ main(int argc, char **argv)
|
|||
g_test_add_func("/initrd/cmdline/neednet/no_args", test_neednet_no_args);
|
||||
g_test_add_func("/initrd/cmdline/neednet/args", test_neednet_args);
|
||||
g_test_add_func("/initrd/cmdline/dhcp/vendor_class_id", test_dhcp_vendor_class_id);
|
||||
g_test_add_func("/initrd/cmdline/dhcp/dscp", test_dhcp_dscp);
|
||||
g_test_add_func("/initrd/cmdline/infiniband/iface", test_infiniband_iface);
|
||||
g_test_add_func("/initrd/cmdline/infiniband/mac", test_infiniband_mac);
|
||||
g_test_add_func("/initrd/cmdline/infiniband/pkey", test_infiniband_pkey);
|
||||
|
|
|
|||
|
|
@ -1308,6 +1308,10 @@
|
|||
<property name="dhcp-iaid"
|
||||
nmcli-description="A string containing the "Identity Association Identifier" (IAID) used by the DHCP client. The string can be a 32-bit number (either decimal, hexadecimal or as colon separated hexadecimal numbers). Alternatively it can be set to the special values "mac", "perm-mac", "ifname" or "stable". When set to "mac" (or "perm-mac"), the last 4 bytes of the current (or permanent) MAC address are used as IAID. When set to "ifname", the IAID is computed by hashing the interface name. The special value "stable" can be used to generate an IAID based on the stable-id (see connection.stable-id), a per-host key and the interface name. When the property is unset, the value from global configuration is used; if no global default is set then the IAID is assumed to be "ifname". For DHCPv4, the IAID is only used with "ipv4.dhcp-client-id" values "duid" and "ipv6-duid" to generate the client-id. For DHCPv6, note that at the moment this property is only supported by the "internal" DHCPv6 plugin. The "dhclient" DHCPv6 plugin always derives the IAID from the MAC address. The actually used DHCPv6 IAID for a currently activated interface is exposed in the lease information of the device."
|
||||
format="string" />
|
||||
<property name="dhcp-dscp"
|
||||
nmcli-description="Specifies the value for the DSCP field (traffic class) of the IP header. When empty, the global default value is used; if no global default is specified, it is assumed to be "CS0". Allowed values are: "CS0", "CS4" and "CS6". The property is currently valid only for IPv4, and it is supported only by the "internal" DHCP plugin."
|
||||
format="string"
|
||||
values="CS0, CS4, CS6" />
|
||||
<property name="dhcp-timeout"
|
||||
nmcli-description="A timeout for a DHCP transaction in seconds. If zero (the default), a globally configured default is used. If still unspecified, a device specific timeout is used (usually 45 seconds). Set to 2147483647 (MAXINT32) for infinity."
|
||||
format="integer"
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue