summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/network-internal.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2019-06-23 01:08:51 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2019-07-01 01:24:42 +0900
commitb38de0e9cc1dfd60a89cf9ec998ed94e71610d50 (patch)
treea9116945729ad42b3769a388db14e4630d1f76b1 /src/libsystemd-network/network-internal.c
parent54a8423788ec3cc6240959ab9f5cdac40baf047a (diff)
downloadsystemd-b38de0e9cc1dfd60a89cf9ec998ed94e71610d50.tar.gz
systemd-b38de0e9cc1dfd60a89cf9ec998ed94e71610d50.tar.bz2
systemd-b38de0e9cc1dfd60a89cf9ec998ed94e71610d50.zip
network,udev: make net_match_config() take sd_device
Diffstat (limited to 'src/libsystemd-network/network-internal.c')
-rw-r--r--src/libsystemd-network/network-internal.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/libsystemd-network/network-internal.c b/src/libsystemd-network/network-internal.c
index 60227cf286..1f02a1e984 100644
--- a/src/libsystemd-network/network-internal.c
+++ b/src/libsystemd-network/network-internal.c
@@ -106,12 +106,24 @@ bool net_match_config(Set *match_mac,
char * const *match_drivers,
char * const *match_types,
char * const *match_names,
+ sd_device *device,
const struct ether_addr *dev_mac,
- const char *dev_path,
- const char *dev_driver,
- const char *dev_type,
const char *dev_name) {
+ const char *dev_path = NULL, *dev_driver = NULL, *dev_type = NULL, *mac_str;
+
+ if (device) {
+ (void) sd_device_get_property_value(device, "ID_PATH", &dev_path);
+ (void) sd_device_get_property_value(device, "ID_NET_DRIVER", &dev_driver);
+ (void) sd_device_get_devtype(device, &dev_type);
+
+ if (!dev_name)
+ (void) sd_device_get_sysname(device, &dev_name);
+ if (!dev_mac &&
+ sd_device_get_sysattr_value(device, "address", &mac_str) >= 0)
+ dev_mac = ether_aton(mac_str);
+ }
+
if (match_mac && (!dev_mac || !set_contains(match_mac, dev_mac)))
return false;