SHA256
1
0
forked from pool/systemd
Dr. Werner Fink 2014-12-16 09:15:56 +00:00 committed by Git OBS Bridge
parent dcb2a6c851
commit fe5ead02e2
3 changed files with 58 additions and 27 deletions

View File

@ -18,7 +18,7 @@ claims to have named in a predictable way.
5 files changed, 79 insertions(+), 11 deletions(-)
--- man/udev.xml
+++ man/udev.xml 2014-12-05 11:43:18.670867575 +0000
+++ man/udev.xml
@@ -914,10 +914,21 @@
successful one is used. The name is not set directly, but
is exported to udev as the property <literal>ID_NET_NAME</literal>,
@ -43,14 +43,14 @@ claims to have named in a predictable way.
<listitem>
<para>The name is set based on entries in the Hardware
--- network/99-default.link
+++ network/99-default.link 2014-12-05 00:00:00.000000000 +0000
+++ network/99-default.link
@@ -1,3 +1,3 @@
[Link]
-NamePolicy=database onboard slot path
+NamePolicy=kernel database onboard slot path
MACAddressPolicy=persistent
--- src/shared/missing.h
+++ src/shared/missing.h 2014-12-05 11:33:06.120057836 +0000
+++ src/shared/missing.h
@@ -362,3 +362,24 @@ static inline int setns(int fd, int nsty
return syscall(__NR_setns, fd, nstype);
}
@ -77,7 +77,7 @@ claims to have named in a predictable way.
+#endif
+
--- src/udev/net/link-config.c
+++ src/udev/net/link-config.c 2014-12-05 11:36:51.658018542 +0000
+++ src/udev/net/link-config.c
@@ -20,10 +20,11 @@
***/
@ -91,26 +91,31 @@ claims to have named in a predictable way.
#include "link-config.h"
#include "ethtool-util.h"
@@ -297,7 +298,33 @@ static bool mac_is_random(struct udev_de
@@ -297,23 +298,33 @@ static bool mac_is_random(struct udev_de
return false;
/* check for NET_ADDR_RANDOM */
- return type == 1;
+ return type == NET_ADDR_RANDOM;
+}
+
}
-static bool mac_is_permanent(struct udev_device *device) {
+static bool should_rename(struct udev_device *device, bool respect_predictable) {
+ const char *s;
+ unsigned type;
+ int r;
+
const char *s;
unsigned type;
int r;
- s = udev_device_get_sysattr_value(device, "addr_assign_type");
+ s = udev_device_get_sysattr_value(device, "name_assign_type");
+ if (!s)
if (!s)
- return true; /* if we don't know, assume it is permanent */
+ return true; /* if we don't know, assume we should rename */
+ r = safe_atou(s, &type);
+ if (r < 0)
+ return true;
+
r = safe_atou(s, &type);
if (r < 0)
return true;
- /* check for NET_ADDR_PERM */
- return type == 0;
+ switch (type) {
+ case NET_NAME_USER:
+ case NET_NAME_RENAMED:
@ -125,8 +130,8 @@ claims to have named in a predictable way.
+ }
}
static bool mac_is_permanent(struct udev_device *device) {
@@ -371,6 +398,7 @@ int link_config_apply(link_config_ctx *c
#define HASH_KEY SD_ID128_MAKE(d3,1e,48,fa,90,fe,4b,4c,9d,af,d5,d7,a1,b1,2e,8a)
@@ -371,6 +382,7 @@ int link_config_apply(link_config_ctx *c
const char *new_name = NULL;
struct ether_addr generated_mac;
struct ether_addr *mac = NULL;
@ -134,7 +139,7 @@ claims to have named in a predictable way.
int r, ifindex;
assert(ctx);
@@ -406,8 +434,12 @@ int link_config_apply(link_config_ctx *c
@@ -406,8 +418,12 @@ int link_config_apply(link_config_ctx *c
if (ctx->enable_name_policy && config->name_policy) {
NamePolicy *policy;
@ -148,7 +153,7 @@ claims to have named in a predictable way.
case NAMEPOLICY_DATABASE:
new_name = udev_device_get_property_value(device, "ID_NET_NAME_FROM_DATABASE");
break;
@@ -429,12 +461,14 @@ int link_config_apply(link_config_ctx *c
@@ -429,16 +445,16 @@ int link_config_apply(link_config_ctx *c
}
}
@ -164,12 +169,24 @@ claims to have named in a predictable way.
+ new_name = config->name;
+ } else
+ new_name = NULL;
+
+ *name = new_name;
switch (config->mac_policy) {
case MACPOLICY_PERSISTENT:
@@ -500,6 +534,7 @@ DEFINE_STRING_TABLE_LOOKUP(mac_policy, M
- if (!mac_is_permanent(device)) {
+ if (mac_is_random(device)) {
r = get_mac(device, false, &generated_mac);
if (r == -ENOENT)
break;
@@ -467,6 +483,8 @@ int link_config_apply(link_config_ctx *c
return r;
}
+ *name = new_name;
+
return 0;
}
@@ -500,6 +518,7 @@ DEFINE_STRING_TABLE_LOOKUP(mac_policy, M
DEFINE_CONFIG_PARSE_ENUM(config_parse_mac_policy, mac_policy, MACPolicy, "Failed to parse MAC address policy");
static const char* const name_policy_table[] = {
@ -178,7 +195,7 @@ claims to have named in a predictable way.
[NAMEPOLICY_ONBOARD] = "onboard",
[NAMEPOLICY_SLOT] = "slot",
--- src/udev/net/link-config.h
+++ src/udev/net/link-config.h 2014-12-05 00:00:00.000000000 +0000
+++ src/udev/net/link-config.h
@@ -39,6 +39,7 @@ typedef enum MACPolicy {
} MACPolicy;

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Tue Dec 16 08:59:08 UTC 2014 - werner@suse.de
- Update patch
1098-udev-link_setup-respect-kernel-name-assign-policy.patch
to Robert's version
-------------------------------------------------------------------
Mon Dec 15 15:02:22 UTC 2014 - werner@suse.de

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Tue Dec 16 08:59:08 UTC 2014 - werner@suse.de
- Update patch
1098-udev-link_setup-respect-kernel-name-assign-policy.patch
to Robert's version
-------------------------------------------------------------------
Mon Dec 15 15:02:22 UTC 2014 - werner@suse.de