summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-09-27 10:01:23 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2023-07-29 15:14:24 +0200
commitace308a73eb107454028bf2c49b4d4befdac0f2b (patch)
tree6386f7516a120006500f732c03229df6c82f3043 /src
parentudev-builtin-net_id: use sd_device_get_sysnum() to get index of netdevsim (diff)
downloadsystemd-ace308a73eb107454028bf2c49b4d4befdac0f2b.tar.xz
systemd-ace308a73eb107454028bf2c49b4d4befdac0f2b.zip
udev-builtin-net_id: make names_xen() self-contained
It is not necessary to store its partial result into NetNames. No functional changes, just refactoring.
Diffstat (limited to 'src')
-rw-r--r--src/udev/udev-builtin-net_id.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
index b214eb1348..5e929be5b0 100644
--- a/src/udev/udev-builtin-net_id.c
+++ b/src/udev/udev-builtin-net_id.c
@@ -48,7 +48,6 @@ typedef enum NetNameType {
NET_PCI,
NET_USB,
NET_BCMA,
- NET_XENVIF,
} NetNameType;
typedef struct NetNames {
@@ -62,7 +61,6 @@ typedef struct NetNames {
char usb_ports[ALTIFNAMSIZ];
char bcma_core[ALTIFNAMSIZ];
- char xen_slot[ALTIFNAMSIZ];
} NetNames;
typedef struct LinkInfo {
@@ -1075,14 +1073,16 @@ static int names_netdevsim(sd_device *dev, const char *prefix, bool test) {
return 0;
}
-static int names_xen(sd_device *dev, NetNames *names) {
+static int names_xen(sd_device *dev, const char *prefix, bool test) {
sd_device *parent;
unsigned id;
const char *syspath, *subsystem, *p, *p2;
int r;
assert(dev);
- assert(names);
+ assert(prefix);
+
+ /* get xen vif "slot" based names. */
if (!naming_scheme_has(NAMING_XEN_VIF))
return 0;
@@ -1123,8 +1123,12 @@ static int names_xen(sd_device *dev, NetNames *names) {
SAFE_ATO_REFUSE_LEADING_WHITESPACE | 10, &id);
if (r < 0)
return r;
- xsprintf(names->xen_slot, "X%u", id);
- names->type = NET_XENVIF;
+
+ char str[ALTIFNAMSIZ];
+ if (snprintf_ok(str, sizeof str, "%sX%u", prefix, id))
+ udev_builtin_add_property(dev, test, "ID_NET_NAME_SLOT", str);
+ log_device_debug(dev, "Xen identifier: id=%u %s %s",
+ id, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), str + strlen(prefix));
return 0;
}
@@ -1229,15 +1233,7 @@ static int builtin_net_id(UdevEvent *event, int argc, char *argv[], bool test) {
(void) names_vio(dev, prefix, test);
(void) names_platform(dev, prefix, test);
(void) names_netdevsim(dev, prefix, test);
-
- /* get xen vif "slot" based names. */
- if (names_xen(dev, &names) >= 0 && names.type == NET_XENVIF) {
- char str[ALTIFNAMSIZ];
-
- if (snprintf_ok(str, sizeof str, "%s%s", prefix, names.xen_slot))
- udev_builtin_add_property(dev, test, "ID_NET_NAME_SLOT", str);
- return 0;
- }
+ (void) names_xen(dev, prefix, test);
/* get PCI based path names */
r = names_pci(dev, &info, &names);