X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Flibsystemd-rtnl%2Frtnl-util.c;h=93804bb74429ec6af002ba2f9521e45af97473c1;hp=bf6bf27bb45e036d781b4a385ddef9359f4ad762;hb=3e137a1b9a0eac2bf43d493d3302c3c959b6ccdb;hpb=d8921c6d5c7f1047762c2929908fa6c9b506d59d diff --git a/src/libsystemd-rtnl/rtnl-util.c b/src/libsystemd-rtnl/rtnl-util.c index bf6bf27bb..93804bb74 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);