* - physical/geographical location of the hardware
* - the interface's MAC address
*
- * http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames
+ * https://systemd.io/PREDICTABLE_INTERFACE_NAMES
*
* When the code here is changed, man/systemd.net-naming-scheme.xml must be updated too.
*/
#include <stdarg.h>
#include <stdlib.h>
#include <unistd.h>
+#include <linux/if.h>
#include <linux/pci_regs.h>
#include "alloc-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "fs-util.h"
-#include "naming-scheme.h"
+#include "netif-naming-scheme.h"
#include "parse-util.h"
#include "proc-cmdline.h"
#include "stdio-util.h"
bool mac_valid;
sd_device *pcidev;
- char pci_slot[IFNAMSIZ];
- char pci_path[IFNAMSIZ];
- char pci_onboard[IFNAMSIZ];
+ char pci_slot[ALTIFNAMSIZ];
+ char pci_path[ALTIFNAMSIZ];
+ char pci_onboard[ALTIFNAMSIZ];
const char *pci_onboard_label;
- char usb_ports[IFNAMSIZ];
- char bcma_core[IFNAMSIZ];
- char ccw_busid[IFNAMSIZ];
- char vio_slot[IFNAMSIZ];
- char platform_path[IFNAMSIZ];
- char netdevsim_path[IFNAMSIZ];
+ char usb_ports[ALTIFNAMSIZ];
+ char bcma_core[ALTIFNAMSIZ];
+ char ccw_busid[ALTIFNAMSIZ];
+ char vio_slot[ALTIFNAMSIZ];
+ char platform_path[ALTIFNAMSIZ];
+ char netdevsim_path[ALTIFNAMSIZ];
};
struct virtfn_info {
sd_device *physfn_pcidev;
- char suffix[IFNAMSIZ];
+ char suffix[ALTIFNAMSIZ];
};
/* skip intermediate virtio devices */
_cleanup_free_ char *virtfn_pci_syspath = NULL;
struct dirent *dent;
_cleanup_closedir_ DIR *dir = NULL;
- char suffix[IFNAMSIZ];
+ char suffix[ALTIFNAMSIZ];
int r;
assert(dev);
char str[PATH_MAX];
_cleanup_free_ char *address = NULL;
- if (dent->d_name[0] == '.')
+ if (dot_or_dot_dot(dent->d_name))
continue;
+
r = safe_atou_full(dent->d_name, 10, &i);
if (r < 0 || i <= 0)
continue;
* The Vendor (3 or 4 char), followed by hexdecimal model number : instance id.
*/
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+ DISABLE_WARNING_FORMAT_NONLITERAL;
if (sscanf(syspath, pattern, vendor, &model, &instance, ðid) != 4)
return -EINVAL;
-#pragma GCC diagnostic pop
+ REENABLE_WARNING;
if (!in_charset(vendor, validchars))
return -ENOENT;
r = names_mac(dev, &names);
if (r >= 0 && names.mac_valid) {
- char str[IFNAMSIZ];
+ char str[ALTIFNAMSIZ];
xsprintf(str, "%sx%02x%02x%02x%02x%02x%02x", prefix,
names.mac[0], names.mac[1], names.mac[2],
/* get path names for Linux on System z network devices */
if (names_ccw(dev, &names) >= 0 && names.type == NET_CCW) {
- char str[IFNAMSIZ];
+ char str[ALTIFNAMSIZ];
if (snprintf_ok(str, sizeof str, "%s%s", prefix, names.ccw_busid))
udev_builtin_add_property(dev, test, "ID_NET_NAME_PATH", str);
/* get ibmveth/ibmvnic slot-based names. */
if (names_vio(dev, &names) >= 0 && names.type == NET_VIO) {
- char str[IFNAMSIZ];
+ char str[ALTIFNAMSIZ];
if (snprintf_ok(str, sizeof str, "%s%s", prefix, names.vio_slot))
udev_builtin_add_property(dev, test, "ID_NET_NAME_SLOT", str);
/* get ACPI path names for ARM64 platform devices */
if (names_platform(dev, &names, test) >= 0 && names.type == NET_PLATFORM) {
- char str[IFNAMSIZ];
+ char str[ALTIFNAMSIZ];
if (snprintf_ok(str, sizeof str, "%s%s", prefix, names.platform_path))
udev_builtin_add_property(dev, test, "ID_NET_NAME_PATH", str);
/* get netdevsim path names */
if (names_netdevsim(dev, &names) >= 0 && names.type == NET_NETDEVSIM) {
- char str[IFNAMSIZ];
+ char str[ALTIFNAMSIZ];
if (snprintf_ok(str, sizeof str, "%s%s", prefix, names.netdevsim_path))
udev_builtin_add_property(dev, test, "ID_NET_NAME_PATH", str);
/* plain PCI device */
if (names.type == NET_PCI) {
- char str[IFNAMSIZ];
+ char str[ALTIFNAMSIZ];
if (names.pci_onboard[0] &&
snprintf_ok(str, sizeof str, "%s%s", prefix, names.pci_onboard))
/* USB device */
if (names_usb(dev, &names) >= 0 && names.type == NET_USB) {
- char str[IFNAMSIZ];
+ char str[ALTIFNAMSIZ];
if (names.pci_path[0] &&
snprintf_ok(str, sizeof str, "%s%s%s", prefix, names.pci_path, names.usb_ports))
/* Broadcom bus */
if (names_bcma(dev, &names) >= 0 && names.type == NET_BCMA) {
- char str[IFNAMSIZ];
+ char str[ALTIFNAMSIZ];
if (names.pci_path[0] &&
snprintf_ok(str, sizeof str, "%s%s%s", prefix, names.pci_path, names.bcma_core))