chiark / gitweb /
rtnl: move set_link_properties to rtnl-utils
authorTom Gundersen <teg@jklm.no>
Tue, 29 Oct 2013 18:55:54 +0000 (19:55 +0100)
committerTom Gundersen <teg@jklm.no>
Tue, 29 Oct 2013 20:26:22 +0000 (21:26 +0100)
Makefile.am
src/systemd/sd-rtnl.h
src/udev/net/link-config.c

index a06a79b958759f2e43ab659c28be3c8959457385..85b23250b16d6cd4379dd0a3da77699b2b6d546c 100644 (file)
@@ -183,6 +183,7 @@ AM_CPPFLAGS = \
        -I $(top_srcdir)/src/udev/net \
        -I $(top_builddir)/src/udev \
        -I $(top_srcdir)/src/libsystemd-bus \
+       -I $(top_srcdir)/src/libsystemd-rtnl \
        $(OUR_CPPFLAGS)
 
 AM_CFLAGS = $(OUR_CFLAGS)
@@ -627,7 +628,9 @@ libsystemd_rtnl_la_SOURCES = \
        src/systemd/sd-rtnl.h \
        src/libsystemd-rtnl/sd-rtnl.c \
        src/libsystemd-rtnl/rtnl-internal.h \
-       src/libsystemd-rtnl/rtnl-message.c
+       src/libsystemd-rtnl/rtnl-message.c \
+       src/libsystemd-rtnl/rtnl-util.h \
+       src/libsystemd-rtnl/rtnl-util.c
 
 test_rtnl_SOURCES = \
        src/libsystemd-rtnl/test-rtnl.c
index a2400d8485d55ba620c99ebcaa4b5d359ab7125c..ae0dcd803e8a455709583ed8776a39a9e610ddad 100644 (file)
@@ -19,6 +19,8 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
+#pragma once
+
 #include <linux/rtnetlink.h>
 #include <linux/netlink.h>
 #include <stdint.h>
index f93a4d835d44b2971d60cf018892ddb5c9dacbf6..cf966bfe372f3d587adb69835ffeff992cff88dd 100644 (file)
@@ -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;