X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flibsystemd-rtnl%2Frtnl-util.c;h=4e7661bb7775a1185d8c7eb31e108f4793bc83d4;hb=51502af33df91237196772ac06fd50190e36e198;hp=93804bb74429ec6af002ba2f9521e45af97473c1;hpb=3e137a1b9a0eac2bf43d493d3302c3c959b6ccdb;p=elogind.git
diff --git a/src/libsystemd-rtnl/rtnl-util.c b/src/libsystemd-rtnl/rtnl-util.c
index 93804bb74..4e7661bb7 100644
--- a/src/libsystemd-rtnl/rtnl-util.c
+++ b/src/libsystemd-rtnl/rtnl-util.c
@@ -19,6 +19,7 @@
along with systemd; If not, see .
***/
+#include
#include
#include "sd-rtnl.h"
@@ -33,7 +34,7 @@ int rtnl_set_link_name(sd_rtnl *rtnl, int ifindex, const char *name) {
assert(ifindex > 0);
assert(name);
- r = sd_rtnl_message_link_new(RTM_NEWLINK, ifindex, 0, 0, &message);
+ r = sd_rtnl_message_link_new(RTM_SETLINK, ifindex, 0, 0, &message);
if (r < 0)
return r;
@@ -41,14 +42,15 @@ int rtnl_set_link_name(sd_rtnl *rtnl, int ifindex, const char *name) {
if (r < 0)
return r;
- r = sd_rtnl_send_with_reply_and_block(rtnl, message, 0, NULL);
+ r = sd_rtnl_call(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) {
+int rtnl_set_link_properties(sd_rtnl *rtnl, int ifindex, const char *alias,
+ const struct ether_addr *mac, unsigned mtu) {
_cleanup_sd_rtnl_message_unref_ sd_rtnl_message *message = NULL;
bool need_update = false;
int r;
@@ -56,13 +58,22 @@ int rtnl_set_link_properties(sd_rtnl *rtnl, int ifindex, const struct ether_addr
assert(rtnl);
assert(ifindex > 0);
- if (!mac && mtu == 0)
+ if (!alias && !mac && mtu == 0)
return 0;
- r = sd_rtnl_message_link_new(RTM_NEWLINK, ifindex, 0, 0, &message);
+ r = sd_rtnl_message_link_new(RTM_SETLINK, ifindex, 0, 0, &message);
if (r < 0)
return r;
+ if (alias) {
+ r = sd_rtnl_message_append(message, IFLA_IFALIAS, alias);
+ if (r < 0)
+ return r;
+
+ need_update = true;
+
+ }
+
if (mac) {
r = sd_rtnl_message_append(message, IFLA_ADDRESS, mac);
if (r < 0)
@@ -80,7 +91,7 @@ int rtnl_set_link_properties(sd_rtnl *rtnl, int ifindex, const struct ether_addr
}
if (need_update) {
- r = sd_rtnl_send_with_reply_and_block(rtnl, message, 0, NULL);
+ r = sd_rtnl_call(rtnl, message, 0, NULL);
if (r < 0)
return r;
}