summaryrefslogtreecommitdiff
path: root/src/udev/net
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2013-10-29 19:55:54 +0100
committerTom Gundersen <teg@jklm.no>2013-10-29 21:26:22 +0100
commit3aeb37bc4f32b5edc334f2ac7c5d3c7b0a121328 (patch)
treecf2d430f2196108c1f0ae92f1871cbe2a8ae75a5 /src/udev/net
parentd4bbdb77aff9abb1aaf13f1f92fb5f9513688ce1 (diff)
rtnl: move set_link_properties to rtnl-utils
Diffstat (limited to 'src/udev/net')
-rw-r--r--src/udev/net/link-config.c48
1 files changed, 2 insertions, 46 deletions
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
index f93a4d835d..cf966bfe37 100644
--- a/src/udev/net/link-config.c
+++ b/src/udev/net/link-config.c
@@ -37,6 +37,7 @@
#include "conf-files.h"
#include "fileio.h"
#include "hashmap.h"
+#include "rtnl-util.h"
struct link_config_ctx {
LIST_HEAD(link_config, links);
@@ -266,51 +267,6 @@ int link_config_get(link_config_ctx *ctx, struct udev_device *device, link_confi
return -ENOENT;
}
-static int rtnl_set_properties(sd_rtnl *rtnl, int ifindex, const char *name, const struct ether_addr *mac, unsigned int mtu) {
- _cleanup_sd_rtnl_message_unref_ sd_rtnl_message *message;
- bool need_update = false;
- int r;
-
- assert(rtnl);
- assert(ifindex > 0);
-
- 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;
-
- need_update = true;
- }
-
- if (mac) {
- r = sd_rtnl_message_append(message, IFLA_ADDRESS, mac);
- if (r < 0)
- return r;
-
- need_update = true;
- }
-
- if (mtu > 0) {
- r = sd_rtnl_message_append(message, IFLA_MTU, &mtu);
- if (r < 0)
- return r;
-
- need_update = true;
- }
-
- if (need_update) {
- r = sd_rtnl_send_with_reply_and_block(rtnl, message, 0, NULL);
- if (r < 0)
- return r;
- }
-
- return 0;
-}
-
static bool enable_name_policy(void) {
_cleanup_free_ char *line;
char *w, *state;
@@ -498,7 +454,7 @@ int link_config_apply(link_config_ctx *ctx, link_config *config, struct udev_dev
mac = config->mac;
}
- r = rtnl_set_properties(ctx->rtnl, ifindex, new_name, mac, config->mtu);
+ r = rtnl_set_link_properties(ctx->rtnl, ifindex, new_name, mac, config->mtu);
if (r < 0) {
log_warning("Could not set Name, MACAddress or MTU on %s: %s", name, strerror(-r));
return r;