udev: refuse invalid ifname earlier

This commit is contained in:
Yu Watanabe 2021-06-23 16:17:21 +09:00
parent b4d885f0e8
commit 068b0f7728

View File

@ -17,6 +17,7 @@
#include "fd-util.h"
#include "fs-util.h"
#include "format-util.h"
#include "netif-naming-scheme.h"
#include "netlink-util.h"
#include "parse-util.h"
#include "path-util.h"
@ -848,6 +849,12 @@ static int rename_netif(UdevEvent *event) {
if (r < 0)
return log_device_error_errno(dev, r, "Failed to get ifindex: %m");
if (naming_scheme_has(NAMING_REPLACE_STRICTLY) &&
!ifname_valid(event->name)) {
log_device_warning(dev, "Invalid network interface name, ignoring: %s", event->name);
return 0;
}
/* Set ID_RENAMING boolean property here, and drop it in the corresponding move uevent later. */
r = device_add_property(dev, "ID_RENAMING", "1");
if (r < 0)