summaryrefslogtreecommitdiffstats
path: root/src/udev
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-02-17 13:06:12 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-02-17 15:10:26 +0100
commit65022cd7abc64da553a037d2e918adddce34ceda (patch)
tree8ddeed47ad9ac00b60df7ca5cd716ac00690343a /src/udev
parentnetworkctl: show netdev kind (diff)
downloadsystemd-65022cd7abc64da553a037d2e918adddce34ceda.tar.xz
systemd-65022cd7abc64da553a037d2e918adddce34ceda.zip
network,udev/net: add Kind= settings in [Match] section
This may be useful for writing .network or .link files matching with virtual interfaces. Closes #22541.
Diffstat (limited to 'src/udev')
-rw-r--r--src/udev/net/link-config-gperf.gperf1
-rw-r--r--src/udev/net/link-config.c5
-rw-r--r--src/udev/net/link-config.h1
-rw-r--r--src/udev/udev-event.c2
4 files changed, 7 insertions, 2 deletions
diff --git a/src/udev/net/link-config-gperf.gperf b/src/udev/net/link-config-gperf.gperf
index 17b3697077..96280148c7 100644
--- a/src/udev/net/link-config-gperf.gperf
+++ b/src/udev/net/link-config-gperf.gperf
@@ -28,6 +28,7 @@ Match.OriginalName, config_parse_match_ifnames,
Match.Path, config_parse_match_strv, 0, offsetof(LinkConfig, match.path)
Match.Driver, config_parse_match_strv, 0, offsetof(LinkConfig, match.driver)
Match.Type, config_parse_match_strv, 0, offsetof(LinkConfig, match.iftype)
+Match.Kind, config_parse_match_strv, 0, offsetof(LinkConfig, match.kind)
Match.Property, config_parse_match_property, 0, offsetof(LinkConfig, match.property)
Match.Host, config_parse_net_condition, CONDITION_HOST, offsetof(LinkConfig, conditions)
Match.Virtualization, config_parse_net_condition, CONDITION_VIRTUALIZATION, offsetof(LinkConfig, conditions)
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
index 29e960acc0..9b51025c6a 100644
--- a/src/udev/net/link-config.c
+++ b/src/udev/net/link-config.c
@@ -361,6 +361,7 @@ Link *link_free(Link *link) {
return NULL;
sd_device_unref(link->device);
+ free(link->kind);
free(link->driver);
return mfree(link);
}
@@ -402,7 +403,8 @@ int link_new(LinkConfigContext *ctx, sd_netlink **rtnl, sd_device *device, Link
if (r < 0)
log_link_debug_errno(link, r, "Failed to get \"addr_assign_type\" attribute, ignoring: %m");
- r = rtnl_get_link_info(rtnl, link->ifindex, &link->iftype, &link->flags, &link->hw_addr, &link->permanent_hw_addr);
+ r = rtnl_get_link_info(rtnl, link->ifindex, &link->iftype, &link->flags,
+ &link->kind, &link->hw_addr, &link->permanent_hw_addr);
if (r < 0)
return r;
@@ -439,6 +441,7 @@ int link_get_config(LinkConfigContext *ctx, Link *link) {
&link->permanent_hw_addr,
link->driver,
link->iftype,
+ link->kind,
link->ifname,
/* alternative_names = */ NULL,
/* wlan_iftype = */ 0,
diff --git a/src/udev/net/link-config.h b/src/udev/net/link-config.h
index 90cb438e4b..ea9f560f45 100644
--- a/src/udev/net/link-config.h
+++ b/src/udev/net/link-config.h
@@ -32,6 +32,7 @@ typedef struct Link {
sd_device *device;
sd_device_action_t action;
+ char *kind;
char *driver;
uint16_t iftype;
uint32_t flags;
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index aa7d229816..85f89fadd8 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -900,7 +900,7 @@ static int rename_netif(UdevEvent *event) {
return 0;
}
- r = rtnl_get_link_info(&event->rtnl, ifindex, NULL, &flags, NULL, NULL);
+ r = rtnl_get_link_info(&event->rtnl, ifindex, NULL, &flags, NULL, NULL, NULL);
if (r < 0)
return log_device_warning_errno(dev, r, "Failed to get link flags: %m");