chiark / gitweb /
sd-rtnl: always include linux/rtnetlink.h
[elogind.git] / src / libsystemd / sd-rtnl / rtnl-message.c
index 226329f314d82dab3017b02b8986e056adc6ed6f..15e3247aca90dff62178320b78a8c3d7f5647664 100644 (file)
@@ -19,7 +19,6 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include <linux/rtnetlink.h>
 #include <netinet/in.h>
 #include <netinet/ether.h>
 #include <stdbool.h>
@@ -232,6 +231,8 @@ int sd_rtnl_message_new_addr(uint16_t nlmsg_type, int index, unsigned char famil
 
         (*ret)->hdr->nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg));
         (*ret)->hdr->nlmsg_type = nlmsg_type;
+        if (nlmsg_type == RTM_GETADDR && family == AF_INET)
+                (*ret)->hdr->nlmsg_flags |= NLM_F_DUMP;
 
         ifa = NLMSG_DATA((*ret)->hdr);
 
@@ -699,7 +700,7 @@ int sd_rtnl_message_append_ether_addr(sd_rtnl_message *m, unsigned short type, c
         return 0;
 }
 
-int sd_rtnl_message_open_container(sd_rtnl_message *m, unsigned short type, size_t extra) {
+int sd_rtnl_message_open_container(sd_rtnl_message *m, unsigned short type) {
         uint16_t rtm_type;
 
         assert_return(m, -EINVAL);
@@ -710,9 +711,13 @@ int sd_rtnl_message_open_container(sd_rtnl_message *m, unsigned short type, size
         if (rtnl_message_type_is_link(rtm_type)) {
 
                 if ((type == IFLA_LINKINFO && m->n_containers == 0) ||
-                    (type == IFLA_INFO_DATA && m->n_containers == 1 && GET_CONTAINER(m, 0)->rta_type == IFLA_LINKINFO) ||
-                    (type == VETH_INFO_PEER && m->n_containers == 2 && GET_CONTAINER(m, 1)->rta_type == IFLA_INFO_DATA))
-                        return add_rtattr(m, type, NULL, extra);
+                    (type == IFLA_INFO_DATA && m->n_containers == 1 &&
+                     GET_CONTAINER(m, 0)->rta_type == IFLA_LINKINFO))
+                        return add_rtattr(m, type, NULL, 0);
+                else if (type == VETH_INFO_PEER && m->n_containers == 2 &&
+                         GET_CONTAINER(m, 1)->rta_type == IFLA_INFO_DATA &&
+                         GET_CONTAINER(m, 0)->rta_type == IFLA_LINKINFO)
+                        return add_rtattr(m, type, NULL, sizeof(struct ifinfomsg));
         }
 
         return -ENOTSUP;