|
|
698723 |
From 22dd44ae3cfd66e622e0b672af96728b6f505ad1 Mon Sep 17 00:00:00 2001
|
|
|
698723 |
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
|
|
698723 |
Date: Tue, 17 Dec 2019 11:01:35 +0900
|
|
|
698723 |
Subject: [PATCH] udev: extend the length of ID_NET_NAME_XXX= to ALTIFNAMSIZ
|
|
|
698723 |
|
|
|
698723 |
(cherry picked from commit 78f8849f84ca0939796edb840e878a9d2e124a4d)
|
|
|
698723 |
|
|
|
698723 |
Related: #1850986
|
|
|
698723 |
---
|
|
|
698723 |
src/udev/net/link-config.c | 5 ++++-
|
|
|
698723 |
src/udev/udev-builtin-net_id.c | 33 +++++++++++++++++----------------
|
|
|
698723 |
src/udev/udev-event.c | 4 ++--
|
|
|
698723 |
3 files changed, 23 insertions(+), 19 deletions(-)
|
|
|
698723 |
|
|
|
698723 |
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
|
|
|
698723 |
index e5052f8f29..4de8ee7d7e 100644
|
|
|
698723 |
--- a/src/udev/net/link-config.c
|
|
|
698723 |
+++ b/src/udev/net/link-config.c
|
|
|
698723 |
@@ -19,6 +19,7 @@
|
|
|
698723 |
#include "path-util.h"
|
|
|
698723 |
#include "proc-cmdline.h"
|
|
|
698723 |
#include "random-util.h"
|
|
|
698723 |
+#include "socket-util.h"
|
|
|
698723 |
#include "stat-util.h"
|
|
|
698723 |
#include "string-table.h"
|
|
|
698723 |
#include "string-util.h"
|
|
|
698723 |
@@ -405,7 +406,7 @@ int link_config_apply(link_config_ctx *ctx, link_config *config,
|
|
|
698723 |
NamePolicy *policy;
|
|
|
698723 |
|
|
|
698723 |
for (policy = config->name_policy;
|
|
|
698723 |
- !new_name && *policy != _NAMEPOLICY_INVALID; policy++) {
|
|
|
698723 |
+ *policy != _NAMEPOLICY_INVALID; policy++) {
|
|
|
698723 |
switch (*policy) {
|
|
|
698723 |
case NAMEPOLICY_KERNEL:
|
|
|
698723 |
respect_predictable = true;
|
|
|
698723 |
@@ -428,6 +429,8 @@ int link_config_apply(link_config_ctx *ctx, link_config *config,
|
|
|
698723 |
default:
|
|
|
698723 |
break;
|
|
|
698723 |
}
|
|
|
698723 |
+ if (ifname_valid(new_name))
|
|
|
698723 |
+ break;
|
|
|
698723 |
}
|
|
|
698723 |
}
|
|
|
698723 |
|
|
|
698723 |
diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
|
|
|
698723 |
index 7c153f0aef..0611c08234 100644
|
|
|
698723 |
--- a/src/udev/udev-builtin-net_id.c
|
|
|
698723 |
+++ b/src/udev/udev-builtin-net_id.c
|
|
|
698723 |
@@ -90,6 +90,7 @@
|
|
|
698723 |
#include <stdlib.h>
|
|
|
698723 |
#include <string.h>
|
|
|
698723 |
#include <unistd.h>
|
|
|
698723 |
+#include <linux/if.h>
|
|
|
698723 |
#include <linux/pci_regs.h>
|
|
|
698723 |
|
|
|
698723 |
#include "dirent-util.h"
|
|
|
698723 |
@@ -172,21 +173,21 @@ struct netnames {
|
|
|
698723 |
bool mac_valid;
|
|
|
698723 |
|
|
|
698723 |
struct udev_device *pcidev;
|
|
|
698723 |
- char pci_slot[IFNAMSIZ];
|
|
|
698723 |
- char pci_path[IFNAMSIZ];
|
|
|
698723 |
- char pci_onboard[IFNAMSIZ];
|
|
|
698723 |
+ char pci_slot[ALTIFNAMSIZ];
|
|
|
698723 |
+ char pci_path[ALTIFNAMSIZ];
|
|
|
698723 |
+ char pci_onboard[ALTIFNAMSIZ];
|
|
|
698723 |
const char *pci_onboard_label;
|
|
|
698723 |
|
|
|
698723 |
- char usb_ports[IFNAMSIZ];
|
|
|
698723 |
- char bcma_core[IFNAMSIZ];
|
|
|
698723 |
- char ccw_busid[IFNAMSIZ];
|
|
|
698723 |
- char vio_slot[IFNAMSIZ];
|
|
|
698723 |
- char platform_path[IFNAMSIZ];
|
|
|
698723 |
+ char usb_ports[ALTIFNAMSIZ];
|
|
|
698723 |
+ char bcma_core[ALTIFNAMSIZ];
|
|
|
698723 |
+ char ccw_busid[ALTIFNAMSIZ];
|
|
|
698723 |
+ char vio_slot[ALTIFNAMSIZ];
|
|
|
698723 |
+ char platform_path[ALTIFNAMSIZ];
|
|
|
698723 |
};
|
|
|
698723 |
|
|
|
698723 |
struct virtfn_info {
|
|
|
698723 |
struct udev_device *physfn_pcidev;
|
|
|
698723 |
- char suffix[IFNAMSIZ];
|
|
|
698723 |
+ char suffix[ALTIFNAMSIZ];
|
|
|
698723 |
};
|
|
|
698723 |
|
|
|
698723 |
static const NamingScheme* naming_scheme_from_name(const char *name) {
|
|
|
698723 |
@@ -883,7 +884,7 @@ static int builtin_net_id(struct udev_device *dev, int argc, char *argv[], bool
|
|
|
698723 |
|
|
|
698723 |
err = names_mac(dev, &names);
|
|
|
698723 |
if (err >= 0 && names.mac_valid) {
|
|
|
698723 |
- char str[IFNAMSIZ];
|
|
|
698723 |
+ char str[ALTIFNAMSIZ];
|
|
|
698723 |
|
|
|
698723 |
xsprintf(str, "%sx%02x%02x%02x%02x%02x%02x", prefix,
|
|
|
698723 |
names.mac[0], names.mac[1], names.mac[2],
|
|
|
698723 |
@@ -896,7 +897,7 @@ static int builtin_net_id(struct udev_device *dev, int argc, char *argv[], bool
|
|
|
698723 |
/* get path names for Linux on System z network devices */
|
|
|
698723 |
err = names_ccw(dev, &names);
|
|
|
698723 |
if (err >= 0 && names.type == NET_CCW) {
|
|
|
698723 |
- char str[IFNAMSIZ];
|
|
|
698723 |
+ char str[ALTIFNAMSIZ];
|
|
|
698723 |
|
|
|
698723 |
if (snprintf_ok(str, sizeof str, "%s%s", prefix, names.ccw_busid))
|
|
|
698723 |
udev_builtin_add_property(dev, test, "ID_NET_NAME_PATH", str);
|
|
|
698723 |
@@ -906,7 +907,7 @@ static int builtin_net_id(struct udev_device *dev, int argc, char *argv[], bool
|
|
|
698723 |
/* get ibmveth/ibmvnic slot-based names. */
|
|
|
698723 |
err = names_vio(dev, &names);
|
|
|
698723 |
if (err >= 0 && names.type == NET_VIO) {
|
|
|
698723 |
- char str[IFNAMSIZ];
|
|
|
698723 |
+ char str[ALTIFNAMSIZ];
|
|
|
698723 |
|
|
|
698723 |
if (snprintf_ok(str, sizeof str, "%s%s", prefix, names.vio_slot))
|
|
|
698723 |
udev_builtin_add_property(dev, test, "ID_NET_NAME_SLOT", str);
|
|
|
698723 |
@@ -916,7 +917,7 @@ static int builtin_net_id(struct udev_device *dev, int argc, char *argv[], bool
|
|
|
698723 |
/* get ACPI path names for ARM64 platform devices */
|
|
|
698723 |
err = names_platform(dev, &names, test);
|
|
|
698723 |
if (err >= 0 && names.type == NET_PLATFORM) {
|
|
|
698723 |
- char str[IFNAMSIZ];
|
|
|
698723 |
+ char str[ALTIFNAMSIZ];
|
|
|
698723 |
|
|
|
698723 |
if (snprintf_ok(str, sizeof str, "%s%s", prefix, names.platform_path))
|
|
|
698723 |
udev_builtin_add_property(dev, test, "ID_NET_NAME_PATH", str);
|
|
|
698723 |
@@ -930,7 +931,7 @@ static int builtin_net_id(struct udev_device *dev, int argc, char *argv[], bool
|
|
|
698723 |
|
|
|
698723 |
/* plain PCI device */
|
|
|
698723 |
if (names.type == NET_PCI) {
|
|
|
698723 |
- char str[IFNAMSIZ];
|
|
|
698723 |
+ char str[ALTIFNAMSIZ];
|
|
|
698723 |
|
|
|
698723 |
if (names.pci_onboard[0] &&
|
|
|
698723 |
snprintf_ok(str, sizeof str, "%s%s", prefix, names.pci_onboard))
|
|
|
698723 |
@@ -953,7 +954,7 @@ static int builtin_net_id(struct udev_device *dev, int argc, char *argv[], bool
|
|
|
698723 |
/* USB device */
|
|
|
698723 |
err = names_usb(dev, &names);
|
|
|
698723 |
if (err >= 0 && names.type == NET_USB) {
|
|
|
698723 |
- char str[IFNAMSIZ];
|
|
|
698723 |
+ char str[ALTIFNAMSIZ];
|
|
|
698723 |
|
|
|
698723 |
if (names.pci_path[0] &&
|
|
|
698723 |
snprintf_ok(str, sizeof str, "%s%s%s", prefix, names.pci_path, names.usb_ports))
|
|
|
698723 |
@@ -968,7 +969,7 @@ static int builtin_net_id(struct udev_device *dev, int argc, char *argv[], bool
|
|
|
698723 |
/* Broadcom bus */
|
|
|
698723 |
err = names_bcma(dev, &names);
|
|
|
698723 |
if (err >= 0 && names.type == NET_BCMA) {
|
|
|
698723 |
- char str[IFNAMSIZ];
|
|
|
698723 |
+ char str[ALTIFNAMSIZ];
|
|
|
698723 |
|
|
|
698723 |
if (names.pci_path[0] &&
|
|
|
698723 |
snprintf_ok(str, sizeof str, "%s%s%s", prefix, names.pci_path, names.bcma_core))
|
|
|
698723 |
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
|
|
|
698723 |
index fd8406d959..19b100d4f8 100644
|
|
|
698723 |
--- a/src/udev/udev-event.c
|
|
|
698723 |
+++ b/src/udev/udev-event.c
|
|
|
698723 |
@@ -816,13 +816,13 @@ out:
|
|
|
698723 |
|
|
|
698723 |
static int rename_netif(struct udev_event *event) {
|
|
|
698723 |
struct udev_device *dev = event->dev;
|
|
|
698723 |
- char name[IFNAMSIZ];
|
|
|
698723 |
+ char name[ALTIFNAMSIZ];
|
|
|
698723 |
const char *oldname;
|
|
|
698723 |
int r;
|
|
|
698723 |
|
|
|
698723 |
oldname = udev_device_get_sysname(dev);
|
|
|
698723 |
|
|
|
698723 |
- strscpy(name, IFNAMSIZ, event->name);
|
|
|
698723 |
+ strscpy(name, ALTIFNAMSIZ, event->name);
|
|
|
698723 |
|
|
|
698723 |
r = rtnl_set_link_name(&event->rtnl, udev_device_get_ifindex(dev), name);
|
|
|
698723 |
if (r < 0)
|