Beniamino Galvani 2020-06-12 16:05:40 +02:00
commit 707d7c9ef9
22 changed files with 1597 additions and 942 deletions

View file

@ -203,6 +203,8 @@ _metagen_device_detail_general_get_fcn (NMC_META_GENERIC_INFO_GET_FCN_ARGS)
get_type));
case NMC_GENERIC_INFO_TYPE_DEVICE_DETAIL_GENERAL_UDI:
return nm_device_get_udi (d);
case NMC_GENERIC_INFO_TYPE_DEVICE_DETAIL_GENERAL_PATH:
return nm_device_get_path (d);
case NMC_GENERIC_INFO_TYPE_DEVICE_DETAIL_GENERAL_IP_IFACE:
return nm_device_get_ip_iface (d);
case NMC_GENERIC_INFO_TYPE_DEVICE_DETAIL_GENERAL_IS_SOFTWARE:
@ -255,6 +257,7 @@ const NmcMetaGenericInfo *const metagen_device_detail_general[_NMC_GENERIC_INFO_
_METAGEN_DEVICE_DETAIL_GENERAL (NMC_GENERIC_INFO_TYPE_DEVICE_DETAIL_GENERAL_IP4_CONNECTIVITY, "IP4-CONNECTIVITY"),
_METAGEN_DEVICE_DETAIL_GENERAL (NMC_GENERIC_INFO_TYPE_DEVICE_DETAIL_GENERAL_IP6_CONNECTIVITY, "IP6-CONNECTIVITY"),
_METAGEN_DEVICE_DETAIL_GENERAL (NMC_GENERIC_INFO_TYPE_DEVICE_DETAIL_GENERAL_UDI, "UDI"),
_METAGEN_DEVICE_DETAIL_GENERAL (NMC_GENERIC_INFO_TYPE_DEVICE_DETAIL_GENERAL_PATH, "PATH"),
_METAGEN_DEVICE_DETAIL_GENERAL (NMC_GENERIC_INFO_TYPE_DEVICE_DETAIL_GENERAL_IP_IFACE, "IP-IFACE"),
_METAGEN_DEVICE_DETAIL_GENERAL (NMC_GENERIC_INFO_TYPE_DEVICE_DETAIL_GENERAL_IS_SOFTWARE, "IS-SOFTWARE"),
_METAGEN_DEVICE_DETAIL_GENERAL (NMC_GENERIC_INFO_TYPE_DEVICE_DETAIL_GENERAL_NM_MANAGED, "NM-MANAGED"),

View file

@ -179,6 +179,7 @@ typedef enum {
NMC_GENERIC_INFO_TYPE_DEVICE_DETAIL_GENERAL_IP4_CONNECTIVITY,
NMC_GENERIC_INFO_TYPE_DEVICE_DETAIL_GENERAL_IP6_CONNECTIVITY,
NMC_GENERIC_INFO_TYPE_DEVICE_DETAIL_GENERAL_UDI,
NMC_GENERIC_INFO_TYPE_DEVICE_DETAIL_GENERAL_PATH,
NMC_GENERIC_INFO_TYPE_DEVICE_DETAIL_GENERAL_IP_IFACE,
NMC_GENERIC_INFO_TYPE_DEVICE_DETAIL_GENERAL_IS_SOFTWARE,
NMC_GENERIC_INFO_TYPE_DEVICE_DETAIL_GENERAL_NM_MANAGED,

View file

@ -6265,6 +6265,18 @@ static const NMMetaPropertyInfo *const property_infos_MATCH[] = {
),
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_MATCH_PATH,
.property_type = &_pt_multilist,
.property_typ_data = DEFINE_PROPERTY_TYP_DATA (
PROPERTY_TYP_DATA_SUBTYPE (multilist,
.get_num_fcn_u = MULTILIST_GET_NUM_FCN_U (NMSettingMatch, nm_setting_match_get_num_paths),
.add2_fcn = MULTILIST_ADD2_FCN (NMSettingMatch, nm_setting_match_add_path),
.remove_by_idx_fcn_u = MULTILIST_REMOVE_BY_IDX_FCN_U (NMSettingMatch, nm_setting_match_remove_path),
.remove_by_value_fcn = MULTILIST_REMOVE_BY_VALUE_FCN (NMSettingMatch, nm_setting_match_remove_path_by_value),
.strsplit_with_spaces = TRUE,
),
),
),
NULL
};

View file

@ -283,6 +283,7 @@
#define DESCRIBE_DOC_NM_SETTING_MATCH_DRIVER N_("A list of driver names to match. Each element is a shell wildcard pattern. When an element is prefixed with exclamation mark (!) the condition is inverted. A candidate driver name is considered matching when both these conditions are satisfied: (a) any of the elements not prefixed with '!' matches or there aren't such elements; (b) none of the elements prefixed with '!' match.")
#define DESCRIBE_DOC_NM_SETTING_MATCH_INTERFACE_NAME N_("A list of interface names to match. Each element is a shell wildcard pattern. When an element is prefixed with exclamation mark (!) the condition is inverted. A candidate interface name is considered matching when both these conditions are satisfied: (a) any of the elements not prefixed with '!' matches or there aren't such elements; (b) none of the elements prefixed with '!' match.")
#define DESCRIBE_DOC_NM_SETTING_MATCH_KERNEL_COMMAND_LINE N_("A list of kernel command line arguments to match. This may be used to check whether a specific kernel command line option is set (or if prefixed with the exclamation mark unset). The argument must either be a single word, or an assignment (i.e. two words, separated \"=\"). In the former case the kernel command line is searched for the word appearing as is, or as left hand side of an assignment. In the latter case, the exact assignment is looked for with right and left hand side matching.")
#define DESCRIBE_DOC_NM_SETTING_MATCH_PATH N_("A list of paths to match against the ID_PATH udev property of devices. ID_PATH represents the topological persistent path of a device. It typically contains a subsystem string (pci, usb, platform, etc.) and a subsystem-specific identifier. For PCI devices the path has the form \"pci-$domain:$bus:$device.$function\", where each variable is an hexadecimal value; for example \"pci-0000:0a:00.0\". The path of a device can be obtained with \"udevadm info /sys/class/net/$dev | grep ID_PATH=\" or by looking at the \"path\" property exported by NetworkManager (\"nmcli -f general.path device show $dev\"). Each element of the list is a shell wildcard pattern. When an element is prefixed with exclamation mark (!) the condition is inverted. A candidate path is considered matching when both these conditions are satisfied: (a) any of the elements not prefixed with '!' matches or there aren't such elements; (b) none of the elements prefixed with '!' match.")
#define DESCRIBE_DOC_NM_SETTING_OVS_BRIDGE_DATAPATH_TYPE N_("The data path type. One of \"system\", \"netdev\" or empty.")
#define DESCRIBE_DOC_NM_SETTING_OVS_BRIDGE_FAIL_MODE N_("The bridge failure mode. One of \"secure\", \"standalone\" or empty.")
#define DESCRIBE_DOC_NM_SETTING_OVS_BRIDGE_MCAST_SNOOPING_ENABLE N_("Enable or disable multicast snooping.")

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -27,6 +27,16 @@
-->
<property name="Udi" type="s" access="read"/>
<!--
Path:
The path of the device as exposed by the udev property ID_PATH.
Note that non-UTF-8 characters are backslash escaped. Use g_strcompress()
to obtain the true (non-UTF-8) string.
-->
<property name="Path" type="s" access="read"/>
<!--
Interface:

View file

@ -22,6 +22,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMSettingMatch,
PROP_INTERFACE_NAME,
PROP_KERNEL_COMMAND_LINE,
PROP_DRIVER,
PROP_PATH,
);
/**
@ -36,6 +37,7 @@ struct _NMSettingMatch {
GArray *interface_name;
GArray *kernel_command_line;
GArray *driver;
GArray *path;
};
struct _NMSettingMatchClass {
@ -499,6 +501,156 @@ nm_setting_match_get_drivers (NMSettingMatch *setting, guint *length)
/*****************************************************************************/
/**
* nm_setting_match_get_num_paths:
* @setting: the #NMSettingMatch
*
* Returns: the number of configured paths
*
* Since: 1.26
**/
guint
nm_setting_match_get_num_paths (NMSettingMatch *setting)
{
g_return_val_if_fail (NM_IS_SETTING_MATCH (setting), 0);
return nm_g_array_len (setting->path);
}
/**
* nm_setting_match_get_path:
* @setting: the #NMSettingMatch
* @idx: index number of the path to return
*
* Returns: the path at index @idx
*
* Since: 1.26
**/
const char *
nm_setting_match_get_path (NMSettingMatch *setting, guint idx)
{
g_return_val_if_fail (NM_IS_SETTING_MATCH (setting), NULL);
g_return_val_if_fail (setting->path && idx < setting->path->len, NULL);
return g_array_index (setting->path, const char *, idx);
}
/**
* nm_setting_match_add_path:
* @setting: the #NMSettingMatch
* @path: the path to add
*
* Adds a new path to the setting.
*
* Since: 1.26
**/
void
nm_setting_match_add_path (NMSettingMatch *setting,
const char *path)
{
g_return_if_fail (NM_IS_SETTING_MATCH (setting));
g_return_if_fail (path != NULL);
g_return_if_fail (path[0] != '\0');
nm_strvarray_add (nm_strvarray_ensure (&setting->path), path);
_notify (setting, PROP_PATH);
}
/**
* nm_setting_match_remove_path:
* @setting: the #NMSettingMatch
* @idx: index number of the path
*
* Removes the path at index @idx.
*
* Since: 1.26
**/
void
nm_setting_match_remove_path (NMSettingMatch *setting, guint idx)
{
g_return_if_fail (NM_IS_SETTING_MATCH (setting));
g_return_if_fail (setting->path && idx < setting->path->len);
g_array_remove_index (setting->path, idx);
_notify (setting, PROP_PATH);
}
/**
* nm_setting_match_remove_path_by_value:
* @setting: the #NMSettingMatch
* @path: the path to remove
*
* Removes @path.
*
* Returns: %TRUE if the path was found and removed; %FALSE if it was not.
*
* Since: 1.26
**/
gboolean
nm_setting_match_remove_path_by_value (NMSettingMatch *setting,
const char *path)
{
guint i;
g_return_val_if_fail (NM_IS_SETTING_MATCH (setting), FALSE);
g_return_val_if_fail (path != NULL, FALSE);
g_return_val_if_fail (path[0] != '\0', FALSE);
if (!setting->path)
return FALSE;
for (i = 0; i < setting->path->len; i++) {
if (nm_streq (path, g_array_index (setting->path, const char *, i))) {
g_array_remove_index (setting->path, i);
_notify (setting, PROP_PATH);
return TRUE;
}
}
return FALSE;
}
/**
* nm_setting_match_clear_paths:
* @setting: the #NMSettingMatch
*
* Removes all configured paths.
*
* Since: 1.26
**/
void
nm_setting_match_clear_paths (NMSettingMatch *setting)
{
g_return_if_fail (NM_IS_SETTING_MATCH (setting));
if (nm_g_array_len (setting->path) != 0) {
nm_clear_pointer (&setting->path, g_array_unref);
_notify (setting, PROP_PATH);
}
}
/**
* nm_setting_match_get_paths:
* @setting: the #NMSettingMatch
* @length: (out) (allow-none): the length of the returned paths array.
*
* Returns all the paths.
*
* Returns: (transfer none) (array length=length): the configured paths.
*
* Since: 1.26
**/
const char *const *
nm_setting_match_get_paths (NMSettingMatch *setting, guint *length)
{
g_return_val_if_fail (NM_IS_SETTING_MATCH (setting), NULL);
return nm_strvarray_get_strv (&setting->path, length);
}
/*****************************************************************************/
static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
@ -515,6 +667,9 @@ get_property (GObject *object, guint prop_id,
case PROP_DRIVER:
g_value_set_boxed (value, nm_strvarray_get_strv (&self->driver, NULL));
break;
case PROP_PATH:
g_value_set_boxed (value, nm_strvarray_get_strv (&self->path, NULL));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -537,6 +692,9 @@ set_property (GObject *object, guint prop_id,
case PROP_DRIVER:
nm_strvarray_set_strv (&self->driver, g_value_get_boxed (value));
break;
case PROP_PATH:
nm_strvarray_set_strv (&self->path, g_value_get_boxed (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -613,6 +771,20 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
}
}
if (self->path) {
for (i = 0; i < self->path->len; i++) {
if (nm_str_is_empty (g_array_index (self->path, const char *, i))) {
g_set_error (error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_INVALID_PROPERTY,
_("is empty"));
g_prefix_error (error, "%s.%s: ", NM_SETTING_MATCH_SETTING_NAME,
NM_SETTING_MATCH_PATH);
return FALSE;
}
}
}
return TRUE;
}
@ -700,6 +872,50 @@ nm_setting_match_class_init (NMSettingMatchClass *klass)
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS);
/**
* NMSettingMatch:path
*
* A list of paths to match against the ID_PATH udev property of
* devices. ID_PATH represents the topological persistent path of a
* device. It typically contains a subsystem string (pci, usb, platform,
* etc.) and a subsystem-specific identifier.
*
* For PCI devices the path has the form
* "pci-$domain:$bus:$device.$function", where each variable is an
* hexadecimal value; for example "pci-0000:0a:00.0".
*
* The path of a device can be obtained with "udevadm info
* /sys/class/net/$dev | grep ID_PATH=" or by looking at the "path"
* property exported by NetworkManager ("nmcli -f general.path device
* show $dev").
*
* Each element of the list is a shell wildcard pattern. When an
* element is prefixed with exclamation mark (!) the condition is
* inverted.
*
* A candidate path is considered matching when both these
* conditions are satisfied: (a) any of the elements not prefixed with '!'
* matches or there aren't such elements; (b) none of the elements
* prefixed with '!' match.
*
* Since: 1.26
**/
/* ---ifcfg-rh---
* property: path
* variable: MATCH_PATH
* description: space-separated list of paths to match against the udev
* property ID_PATHS of devices
* example: MATCH_PATH="pci-0000:01:00.0 pci-0000:0c:00.0"
* ---end---
*/
obj_properties[PROP_PATH] =
g_param_spec_boxed (NM_SETTING_MATCH_PATH, "", "",
G_TYPE_STRV,
NM_SETTING_PARAM_FUZZY_IGNORE |
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
_nm_setting_class_commit (setting_class, NM_META_SETTING_TYPE_MATCH);

View file

@ -23,9 +23,10 @@ G_BEGIN_DECLS
#define NM_SETTING_MATCH_SETTING_NAME "match"
#define NM_SETTING_MATCH_INTERFACE_NAME "interface-name"
#define NM_SETTING_MATCH_KERNEL_COMMAND_LINE "kernel-command-line"
#define NM_SETTING_MATCH_DRIVER "driver"
#define NM_SETTING_MATCH_INTERFACE_NAME "interface-name"
#define NM_SETTING_MATCH_KERNEL_COMMAND_LINE "kernel-command-line"
#define NM_SETTING_MATCH_DRIVER "driver"
#define NM_SETTING_MATCH_PATH "path"
typedef struct _NMSettingMatchClass NMSettingMatchClass;
@ -88,6 +89,24 @@ void nm_setting_match_clear_drivers (NMSettingMatch *setting);
NM_AVAILABLE_IN_1_26
const char *const *nm_setting_match_get_drivers (NMSettingMatch *setting, guint *length);
NM_AVAILABLE_IN_1_26
guint nm_setting_match_get_num_paths (NMSettingMatch *setting);
NM_AVAILABLE_IN_1_26
const char *nm_setting_match_get_path (NMSettingMatch *setting, guint idx);
NM_AVAILABLE_IN_1_26
void nm_setting_match_remove_path (NMSettingMatch *setting, guint idx);
NM_AVAILABLE_IN_1_26
gboolean nm_setting_match_remove_path_by_value (NMSettingMatch *setting,
const char *path);
NM_AVAILABLE_IN_1_26
void nm_setting_match_add_path (NMSettingMatch *setting,
const char *path);
NM_AVAILABLE_IN_1_26
void nm_setting_match_clear_paths (NMSettingMatch *setting);
NM_AVAILABLE_IN_1_26
const char *const *nm_setting_match_get_paths (NMSettingMatch *setting, guint *length);
G_END_DECLS
#endif /* NM_SETTING_MATCH_H */

View file

@ -1698,6 +1698,7 @@ global:
libnm_1_26_0 {
global:
nm_device_get_path;
nm_ethtool_optname_is_coalesce;
nm_ethtool_optname_is_ring;
nm_setting_bridge_get_multicast_hash_max;
@ -1712,18 +1713,25 @@ global:
nm_setting_connection_get_mud_url;
nm_setting_match_add_driver;
nm_setting_match_add_kernel_command_line;
nm_setting_match_add_path;
nm_setting_match_clear_drivers;
nm_setting_match_clear_kernel_command_lines;
nm_setting_match_clear_paths;
nm_setting_match_get_driver;
nm_setting_match_get_drivers;
nm_setting_match_get_kernel_command_line;
nm_setting_match_get_kernel_command_lines;
nm_setting_match_get_num_drivers;
nm_setting_match_get_num_kernel_command_lines;
nm_setting_match_get_num_paths;
nm_setting_match_get_path;
nm_setting_match_get_paths;
nm_setting_match_remove_driver;
nm_setting_match_remove_driver_by_value;
nm_setting_match_remove_kernel_command_line;
nm_setting_match_remove_kernel_command_line_by_value;
nm_setting_match_remove_path;
nm_setting_match_remove_path_by_value;
nm_setting_option_clear_by_name;
nm_setting_option_get;
nm_setting_option_get_all_names;

View file

@ -32,6 +32,7 @@
NM_GOBJECT_PROPERTIES_DEFINE (NMDevice,
PROP_INTERFACE,
PROP_UDI,
PROP_PATH,
PROP_DRIVER,
PROP_DRIVER_VERSION,
PROP_FIRMWARE_VERSION,
@ -92,6 +93,7 @@ typedef struct _NMDevicePrivate {
char *firmware_version;
char *physical_port_id;
char *udi;
char *path;
guint32 capabilities;
guint32 device_type;
guint32 ip4_connectivity;
@ -334,6 +336,7 @@ finalize (GObject *object)
g_free (priv->interface);
g_free (priv->ip_interface);
g_free (priv->udi);
g_free (priv->path);
g_free (priv->driver);
g_free (priv->driver_version);
g_free (priv->firmware_version);
@ -366,6 +369,9 @@ get_property (GObject *object,
case PROP_UDI:
g_value_set_string (value, nm_device_get_udi (device));
break;
case PROP_PATH:
g_value_set_string (value, nm_device_get_path (device));
break;
case PROP_INTERFACE:
g_value_set_string (value, nm_device_get_iface (device));
break;
@ -523,6 +529,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device = NML_DBUS_META_IFACE_INIT
NML_DBUS_META_PROPERTY_INIT_U ("Metered", PROP_METERED, NMDevicePrivate, metered ),
NML_DBUS_META_PROPERTY_INIT_U ("Mtu", PROP_MTU, NMDevicePrivate, mtu ),
NML_DBUS_META_PROPERTY_INIT_B ("NmPluginMissing", PROP_NM_PLUGIN_MISSING, NMDevicePrivate, nm_plugin_missing ),
NML_DBUS_META_PROPERTY_INIT_S ("Path", PROP_PATH, NMDevicePrivate, path ),
NML_DBUS_META_PROPERTY_INIT_S ("PhysicalPortId", PROP_PHYSICAL_PORT_ID, NMDevicePrivate, physical_port_id ),
NML_DBUS_META_PROPERTY_INIT_B ("Real", PROP_REAL, NMDevicePrivate, real ),
NML_DBUS_META_PROPERTY_INIT_IGNORE ("State", "u" ),
@ -603,6 +610,23 @@ nm_device_class_init (NMDeviceClass *klass)
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS);
/**
* NMDevice:path:
*
* The device path as exposed by the udev property ID_PATH.
*
* The string is backslash escaped (C escaping) for invalid
* characters. The escaping can be reverted with g_strcompress(),
* however the result may not be valid UTF-8.
*
* Since: 1.26
**/
obj_properties[PROP_PATH] =
g_param_spec_string (NM_DEVICE_PATH, "", "",
NULL,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS);
/**
* NMDevice:driver:
*
@ -1014,6 +1038,27 @@ nm_device_get_udi (NMDevice *device)
return _nml_coerce_property_str_not_empty (NM_DEVICE_GET_PRIVATE (device)->udi);
}
/**
* nm_device_get_path:
* @device: a #NMDevice
*
* Gets the path of the #NMDevice as exposed by the udev property ID_PATH.
*
* Returns: the path of the device.
*
* The string is backslash escaped (C escaping) for invalid characters. The escaping
* can be reverted with g_strcompress(), however the result may not be valid UTF-8.
*
* Since: 1.26
**/
const char *
nm_device_get_path (NMDevice *device)
{
g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
return _nml_coerce_property_str_not_empty (NM_DEVICE_GET_PRIVATE (device)->path);
}
/**
* nm_device_get_driver:
* @device: a #NMDevice

View file

@ -24,6 +24,7 @@ G_BEGIN_DECLS
#define NM_DEVICE_DEVICE_TYPE "device-type"
#define NM_DEVICE_UDI "udi"
#define NM_DEVICE_PATH "path"
#define NM_DEVICE_INTERFACE "interface"
#define NM_DEVICE_IP_INTERFACE "ip-interface"
#define NM_DEVICE_DRIVER "driver"
@ -70,6 +71,8 @@ const char * nm_device_get_iface (NMDevice *device);
const char * nm_device_get_ip_iface (NMDevice *device);
NMDeviceType nm_device_get_device_type (NMDevice *device);
const char * nm_device_get_udi (NMDevice *device);
NM_AVAILABLE_IN_1_26
const char * nm_device_get_path (NMDevice *device);
const char * nm_device_get_driver (NMDevice *device);
const char * nm_device_get_driver_version (NMDevice *device);
const char * nm_device_get_firmware_version (NMDevice *device);

View file

@ -207,6 +207,7 @@ static guint signals[LAST_SIGNAL] = { 0 };
NM_GOBJECT_PROPERTIES_DEFINE (NMDevice,
PROP_UDI,
PROP_PATH,
PROP_IFACE,
PROP_IP_IFACE,
PROP_DRIVER,
@ -281,6 +282,7 @@ typedef struct _NMDevicePrivate {
NMDBusTrackObjPath parent_device;
char * udi;
char * path;
char * iface; /* may change, could be renamed by user */
int ifindex;
@ -4238,6 +4240,13 @@ device_link_changed (NMDevice *self)
_notify (self, PROP_UDI);
}
str = nm_platform_link_get_path (nm_device_get_platform (self), pllink->ifindex);
if (!nm_streq0 (str, priv->path)) {
g_free (priv->path);
priv->path = g_strdup (str);
_notify (self, PROP_PATH);
}
if (!nm_streq0 (pllink->driver, priv->driver)) {
g_free (priv->driver);
priv->driver = g_strdup (pllink->driver);
@ -4623,6 +4632,13 @@ nm_device_update_from_platform_link (NMDevice *self, const NMPlatformLink *plink
_notify (self, PROP_UDI);
}
str = plink ? nm_platform_link_get_path (nm_device_get_platform (self), plink->ifindex) : NULL;
if (g_strcmp0 (str, priv->path)) {
g_free (priv->path);
priv->path = g_strdup (str);
_notify (self, PROP_PATH);
}
str = plink ? plink->name : NULL;
if (str && g_strcmp0 (str, priv->iface)) {
g_free (priv->iface);
@ -5153,6 +5169,10 @@ nm_device_unrealize (NMDevice *self, gboolean remove_resources, GError **error)
nm_clear_g_free (&priv->udi);
_notify (self, PROP_UDI);
}
if (priv->path) {
nm_clear_g_free (&priv->path);
_notify (self, PROP_PATH);
}
if (priv->physical_port_id) {
nm_clear_g_free (&priv->physical_port_id);
_notify (self, PROP_PHYSICAL_PORT_ID);
@ -6275,6 +6295,7 @@ nm_device_match_parent_hwaddr (NMDevice *device,
static gboolean
check_connection_compatible (NMDevice *self, NMConnection *connection, GError **error)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
const char *device_iface = nm_device_get_iface (self);
gs_free_error GError *local = NULL;
gs_free char *conn_iface = NULL;
@ -6419,6 +6440,13 @@ check_connection_compatible (NMDevice *self, NMConnection *connection, GError **
"device does not satisfy match.driver property");
return FALSE;
}
patterns = nm_setting_match_get_paths (s_match, &num_patterns);
if (!nm_wildcard_match_check (priv->path, patterns, num_patterns)) {
nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_INCOMPATIBLE,
"device does not satisfy match.path property");
return FALSE;
}
}
return TRUE;
@ -17372,6 +17400,11 @@ get_property (GObject *object, guint prop_id,
nm_utils_str_utf8safe_escape_cp (priv->udi,
NM_UTILS_STR_UTF8_SAFE_FLAG_NONE));
break;
case PROP_PATH:
g_value_take_string (value,
nm_utils_str_utf8safe_escape_cp (priv->path,
NM_UTILS_STR_UTF8_SAFE_FLAG_NONE));
break;
case PROP_IFACE:
g_value_take_string (value,
nm_utils_str_utf8safe_escape_cp (priv->iface,
@ -17889,6 +17922,7 @@ finalize (GObject *object)
g_slist_free_full (priv->dad6_failed_addrs, (GDestroyNotify) nmp_object_unref);
nm_clear_g_free (&priv->physical_port_id);
g_free (priv->udi);
g_free (priv->path);
g_free (priv->iface);
g_free (priv->ip_iface);
g_free (priv->driver);
@ -17973,6 +18007,7 @@ static const NMDBusInterfaceInfoExtended interface_info_device = {
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Udi", "s", NM_DEVICE_UDI),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Path", "s", NM_DEVICE_PATH),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Interface", "s", NM_DEVICE_IFACE),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("IpInterface", "s", NM_DEVICE_IP_IFACE),
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Driver", "s", NM_DEVICE_DRIVER),
@ -18068,6 +18103,11 @@ nm_device_class_init (NMDeviceClass *klass)
NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
obj_properties[PROP_PATH] =
g_param_spec_string (NM_DEVICE_PATH, "", "",
NULL,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS);
obj_properties[PROP_IFACE] =
g_param_spec_string (NM_DEVICE_IFACE, "", "",
NULL,

View file

@ -66,6 +66,7 @@ nm_device_state_reason_check (NMDeviceStateReason reason)
/* Properties */
#define NM_DEVICE_UDI "udi"
#define NM_DEVICE_PATH "path"
#define NM_DEVICE_IFACE "interface"
#define NM_DEVICE_IP_IFACE "ip-interface"
#define NM_DEVICE_DRIVER "driver"

View file

@ -268,7 +268,6 @@ link_add_pre (NMPlatform *platform,
g_assert (address_len == 0);
device->obj = o;
device->udi = g_strdup_printf ("fake:%d", ifindex);
device->ip6_lladdr = *nmtst_inet6_from_string (ip6_lladdr);
return device;
@ -420,7 +419,6 @@ link_delete (NMPlatform *platform, int ifindex)
return FALSE;
obj_old = g_steal_pointer (&device->obj);
nm_clear_g_free (&device->udi);
cache_op = nmp_cache_remove (nm_platform_get_cache (platform),
obj_old,
@ -633,16 +631,6 @@ link_set_mtu (NMPlatform *platform, int ifindex, guint32 mtu)
return 0;
}
static const char *
link_get_udi (NMPlatform *platform, int ifindex)
{
NMFakePlatformLink *device = link_get (platform, ifindex);
if (!device)
return NULL;
return device->udi;
}
static gboolean
link_get_driver_info (NMPlatform *platform,
int ifindex,
@ -1345,7 +1333,6 @@ finalize (GObject *object)
for (i = 0; i < priv->links->len; i++) {
NMFakePlatformLink *device = &g_array_index (priv->links, NMFakePlatformLink, i);
g_free (device->udi);
nm_clear_pointer (&device->obj, nmp_object_unref);
}
g_array_unref (priv->links);
@ -1371,8 +1358,6 @@ nm_fake_platform_class_init (NMFakePlatformClass *klass)
platform_class->link_add = link_add;
platform_class->link_delete = link_delete;
platform_class->link_get_udi = link_get_udi;
platform_class->link_set_up = link_set_up;
platform_class->link_set_down = link_set_down;
platform_class->link_set_arp = link_set_arp;

View file

@ -7165,18 +7165,6 @@ link_set_noarp (NMPlatform *platform, int ifindex)
return (link_change_flags (platform, ifindex, IFF_NOARP, IFF_NOARP) >= 0);
}
static const char *
link_get_udi (NMPlatform *platform, int ifindex)
{
const NMPObject *obj = nm_platform_link_get_obj (platform, ifindex, TRUE);
if ( !obj
|| !obj->_link.netlink.is_in_netlink
|| !obj->_link.udev.device)
return NULL;
return udev_device_get_syspath (obj->_link.udev.device);
}
static int
link_set_user_ipv6ll_enabled (NMPlatform *platform, int ifindex, gboolean enabled)
{
@ -9318,8 +9306,6 @@ nm_linux_platform_class_init (NMLinuxPlatformClass *klass)
platform_class->link_set_arp = link_set_arp;
platform_class->link_set_noarp = link_set_noarp;
platform_class->link_get_udi = link_get_udi;
platform_class->link_set_user_ipv6ll_enabled = link_set_user_ipv6ll_enabled;
platform_class->link_set_token = link_set_token;

View file

@ -1412,6 +1412,27 @@ nm_platform_link_get_type_name (NMPlatform *self, int ifindex)
return obj->link.kind ?: "unknown";
}
static gboolean
link_get_udev_property (NMPlatform *self,
int ifindex,
const char *name,
const char **out_value)
{
struct udev_device *udevice = NULL;
const char *uproperty;
udevice = nm_platform_link_get_udev_device (self, ifindex);
if (!udevice)
return FALSE;
uproperty = udev_device_get_property_value (udevice, name);
if (!uproperty)
return FALSE;
NM_SET_OUT (out_value, uproperty);
return TRUE;
}
/**
* nm_platform_link_get_unmanaged:
* @self: platform instance
@ -1424,26 +1445,14 @@ nm_platform_link_get_type_name (NMPlatform *self, int ifindex)
gboolean
nm_platform_link_get_unmanaged (NMPlatform *self, int ifindex, gboolean *unmanaged)
{
const NMPObject *link;
struct udev_device *udevice = NULL;
const char *uproperty;
const char *value;
_CHECK_SELF (self, klass, FALSE);
if (link_get_udev_property (self, ifindex, "NM_UNMANAGED", &value)) {
NM_SET_OUT (unmanaged, nm_udev_utils_property_as_boolean (value));
return TRUE;
}
link = nmp_cache_lookup_link (nm_platform_get_cache (self), ifindex);
if (!link)
return FALSE;
udevice = link->_link.udev.device;
if (!udevice)
return FALSE;
uproperty = udev_device_get_property_value (udevice, "NM_UNMANAGED");
if (!uproperty)
return FALSE;
*unmanaged = nm_udev_utils_property_as_boolean (uproperty);
return TRUE;
return FALSE;
}
/**
@ -1589,13 +1598,20 @@ nm_platform_link_set_ipv6_token (NMPlatform *self, int ifindex, NMUtilsIPv6Iface
const char *
nm_platform_link_get_udi (NMPlatform *self, int ifindex)
{
_CHECK_SELF (self, klass, FALSE);
struct udev_device *device;
g_return_val_if_fail (ifindex >= 0, NULL);
device = nm_platform_link_get_udev_device (self, ifindex);
return device ? udev_device_get_syspath (device) : NULL;
}
if (klass->link_get_udi)
return klass->link_get_udi (self, ifindex);
return NULL;
const char *
nm_platform_link_get_path (NMPlatform *self, int ifindex)
{
const char *value = NULL;
link_get_udev_property (self, ifindex, "ID_PATH", &value);
return value;
}
struct udev_device *

View file

@ -1010,9 +1010,6 @@ typedef struct {
gboolean (*link_set_arp) (NMPlatform *self, int ifindex);
gboolean (*link_set_noarp) (NMPlatform *self, int ifindex);
const char *(*link_get_udi) (NMPlatform *self, int ifindex);
struct udev_device *(*link_get_udev_device) (NMPlatform *self, int ifindex);
int (*link_set_user_ipv6ll_enabled) (NMPlatform *self, int ifindex, gboolean enabled);
gboolean (*link_set_token) (NMPlatform *self, int ifindex, NMUtilsIPv6IfaceId iid);
@ -1633,6 +1630,7 @@ gboolean nm_platform_link_set_arp (NMPlatform *self, int ifindex);
gboolean nm_platform_link_set_noarp (NMPlatform *self, int ifindex);
const char *nm_platform_link_get_udi (NMPlatform *self, int ifindex);
const char *nm_platform_link_get_path (NMPlatform *self, int ifindex);
struct udev_device *nm_platform_link_get_udev_device (NMPlatform *self, int ifindex);

View file

@ -1563,14 +1563,17 @@ make_match_setting (shvarFile *ifcfg)
gs_free char *value_ifn = NULL;
gs_free char *value_kcl = NULL;
gs_free char *value_d = NULL;
gs_free char *value_p = NULL;
const char *v;
v = svGetValueStr (ifcfg, "MATCH_INTERFACE_NAME", &value_ifn);
make_match_setting_prop(v, &s_match, nm_setting_match_add_interface_name);
make_match_setting_prop (v, &s_match, nm_setting_match_add_interface_name);
v = svGetValueStr (ifcfg, "MATCH_KERNEL_COMMAND_LINE", &value_kcl);
make_match_setting_prop(v, &s_match, nm_setting_match_add_kernel_command_line);
make_match_setting_prop (v, &s_match, nm_setting_match_add_kernel_command_line);
v = svGetValueStr (ifcfg, "MATCH_DRIVER", &value_d);
make_match_setting_prop(v, &s_match, nm_setting_match_add_driver);
make_match_setting_prop (v, &s_match, nm_setting_match_add_driver);
v = svGetValueStr (ifcfg, "MATCH_PATH", &value_p);
make_match_setting_prop (v, &s_match, nm_setting_match_add_path);
return NM_SETTING (s_match);
}

View file

@ -977,6 +977,7 @@ const NMSIfcfgKeyTypeInfo nms_ifcfg_well_known_keys[] = {
_KEY_TYPE ("MATCH_DRIVER", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
_KEY_TYPE ("MATCH_INTERFACE_NAME", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
_KEY_TYPE ("MATCH_KERNEL_COMMAND_LINE", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
_KEY_TYPE ("MATCH_PATH", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
_KEY_TYPE ("MDNS", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
_KEY_TYPE ("METRIC", NMS_IFCFG_KEY_TYPE_IS_NUMBERED ),
_KEY_TYPE ("MODE", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),

View file

@ -33,7 +33,7 @@ typedef struct {
NMSIfcfgKeyTypeFlags key_flags;
} NMSIfcfgKeyTypeInfo;
extern const NMSIfcfgKeyTypeInfo nms_ifcfg_well_known_keys[239];
extern const NMSIfcfgKeyTypeInfo nms_ifcfg_well_known_keys[240];
const NMSIfcfgKeyTypeInfo *nms_ifcfg_well_known_key_find_info (const char *key, gssize *out_idx);

View file

@ -2438,6 +2438,17 @@ write_match_setting (NMConnection *connection, shvarFile *ifcfg)
}
svSetValueStr (ifcfg, "MATCH_KERNEL_COMMAND_LINE", str->str);
}
num = nm_setting_match_get_num_paths (s_match);
if (num > 0) {
nm_gstring_prepare (&str);
for (i = 0; i < num; i++) {
name = nm_setting_match_get_path (s_match, i);
nm_gstring_add_space_delimiter (str);
nm_utils_escaped_tokens_escape_gstr (name, NM_ASCII_SPACES, str);
}
svSetValueStr (ifcfg, "MATCH_PATH", str->str);
}
}
static void