chiark / gitweb /
sd-rtnl: fix self-reference leaks
[elogind.git] / src / libsystemd / sd-rtnl / rtnl-util.c
index 29250c90a72bc1ffb789a4c87afa63e1a19f03e9..c8b20d109e476c7ea589f7d79a30654e3d158101 100644 (file)
@@ -19,7 +19,6 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include <linux/rtnetlink.h>
 #include <netinet/ether.h>
 
 #include "sd-rtnl.h"
 #include "rtnl-internal.h"
 
 int rtnl_set_link_name(sd_rtnl *rtnl, int ifindex, const char *name) {
-        _cleanup_sd_rtnl_message_unref_ sd_rtnl_message *message = NULL;
+        _cleanup_rtnl_message_unref_ sd_rtnl_message *message = NULL;
         int r;
 
         assert(rtnl);
         assert(ifindex > 0);
         assert(name);
 
-        r = sd_rtnl_message_link_new(RTM_SETLINK, ifindex, &message);
+        r = sd_rtnl_message_new_link(rtnl, &message, RTM_SETLINK, ifindex);
         if (r < 0)
                 return r;
 
@@ -52,7 +51,7 @@ int rtnl_set_link_name(sd_rtnl *rtnl, int ifindex, const char *name) {
 
 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;
+        _cleanup_rtnl_message_unref_ sd_rtnl_message *message = NULL;
         bool need_update = false;
         int r;
 
@@ -62,7 +61,7 @@ int rtnl_set_link_properties(sd_rtnl *rtnl, int ifindex, const char *alias,
         if (!alias && !mac && mtu == 0)
                 return 0;
 
-        r = sd_rtnl_message_link_new(RTM_SETLINK, ifindex, &message);
+        r = sd_rtnl_message_new_link(rtnl, &message, RTM_SETLINK, ifindex);
         if (r < 0)
                 return r;
 
@@ -106,7 +105,7 @@ int rtnl_message_new_synthetic_error(int error, uint32_t serial, sd_rtnl_message
 
         assert(error <= 0);
 
-        r = message_new(ret, NLMSG_SPACE(sizeof(struct nlmsgerr)));
+        r = message_new(NULL, ret, NLMSG_SPACE(sizeof(struct nlmsgerr)));
         if (r < 0)
                 return r;
 
@@ -154,19 +153,3 @@ bool rtnl_message_type_is_addr(uint16_t type) {
                         return false;
         }
 }
-
-int rtnl_message_link_get_ifname(sd_rtnl_message *message, const char **ret) {
-        unsigned short type;
-        void *name;
-
-        assert(rtnl_message_type_is_link(message->hdr->nlmsg_type));
-
-        while (sd_rtnl_message_read(message, &type, &name)) {
-                if (type == IFLA_IFNAME) {
-                        *ret = name;
-                        return 0;
-                }
-        }
-
-        return -ENOENT;
-}