diff options
author | Tom Gundersen <teg@jklm.no> | 2013-10-30 04:10:19 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2013-10-30 15:36:04 +0100 |
commit | 3e137a1b9a0eac2bf43d493d3302c3c959b6ccdb (patch) | |
tree | c62ca7aa5a75856fcf58ae14ba4f4cc545cca3f0 /src/libsystemd-rtnl | |
parent | 415e7f65dbc66089f0d1b9de6785026596df88e7 (diff) |
udev: link-config - let udevd set the ifname
Diffstat (limited to 'src/libsystemd-rtnl')
-rw-r--r-- | src/libsystemd-rtnl/rtnl-util.c | 36 | ||||
-rw-r--r-- | src/libsystemd-rtnl/rtnl-util.h | 3 |
2 files changed, 29 insertions, 10 deletions
diff --git a/src/libsystemd-rtnl/rtnl-util.c b/src/libsystemd-rtnl/rtnl-util.c index bf6bf27bb4..93804bb744 100644 --- a/src/libsystemd-rtnl/rtnl-util.c +++ b/src/libsystemd-rtnl/rtnl-util.c @@ -25,25 +25,43 @@ #include "rtnl-util.h" -int rtnl_set_link_properties(sd_rtnl *rtnl, int ifindex, const char *name, const struct ether_addr *mac, unsigned mtu) { - _cleanup_sd_rtnl_message_unref_ sd_rtnl_message *message; - bool need_update = false; +int rtnl_set_link_name(sd_rtnl *rtnl, int ifindex, const char *name) { + _cleanup_sd_rtnl_message_unref_ sd_rtnl_message *message = NULL; int r; assert(rtnl); assert(ifindex > 0); + assert(name); r = sd_rtnl_message_link_new(RTM_NEWLINK, ifindex, 0, 0, &message); if (r < 0) return r; - if (name) { - r = sd_rtnl_message_append(message, IFLA_IFNAME, name); - if (r < 0) - return r; + r = sd_rtnl_message_append(message, IFLA_IFNAME, name); + if (r < 0) + return r; - need_update = true; - } + r = sd_rtnl_send_with_reply_and_block(rtnl, message, 0, NULL); + if (r < 0) + return r; + + return 0; +} + +int rtnl_set_link_properties(sd_rtnl *rtnl, int ifindex, const struct ether_addr *mac, unsigned mtu) { + _cleanup_sd_rtnl_message_unref_ sd_rtnl_message *message = NULL; + bool need_update = false; + int r; + + assert(rtnl); + assert(ifindex > 0); + + if (!mac && mtu == 0) + return 0; + + r = sd_rtnl_message_link_new(RTM_NEWLINK, ifindex, 0, 0, &message); + if (r < 0) + return r; if (mac) { r = sd_rtnl_message_append(message, IFLA_ADDRESS, mac); diff --git a/src/libsystemd-rtnl/rtnl-util.h b/src/libsystemd-rtnl/rtnl-util.h index dd8300b827..a6ac4b62c9 100644 --- a/src/libsystemd-rtnl/rtnl-util.h +++ b/src/libsystemd-rtnl/rtnl-util.h @@ -23,4 +23,5 @@ #include "sd-rtnl.h" -int rtnl_set_link_properties(sd_rtnl *rtnl, int ifindex, const char *name, const struct ether_addr *mac, unsigned mtu); +int rtnl_set_link_name(sd_rtnl *rtnl, int ifindex, const char *name); +int rtnl_set_link_properties(sd_rtnl *rtnl, int ifindex, const struct ether_addr *mac, unsigned mtu); |