chiark / gitweb /
sd-rtnl: route - allow setting multiple matching routes
[elogind.git] / src / libsystemd / sd-rtnl / rtnl-message.c
index 3362958f360a11309672e961d93636723a822979..150b46fcef2d3610793db2325ac04beb82df8aaf 100644 (file)
@@ -146,7 +146,7 @@ int sd_rtnl_message_new_route(sd_rtnl *rtnl, sd_rtnl_message **ret,
                 return r;
 
         if (nlmsg_type == RTM_NEWROUTE)
-                (*ret)->hdr->nlmsg_flags |= NLM_F_CREATE | NLM_F_EXCL;
+                (*ret)->hdr->nlmsg_flags |= NLM_F_CREATE | NLM_F_APPEND;
 
         rtm = NLMSG_DATA((*ret)->hdr);
 
@@ -1092,7 +1092,7 @@ int socket_read_message(sd_rtnl *rtnl) {
         struct nlmsghdr *new_msg;
         size_t len;
         int r;
-        unsigned i;
+        unsigned i = 0;
 
         assert(rtnl);
         assert(rtnl->rbuffer);
@@ -1226,16 +1226,16 @@ int socket_read_message(sd_rtnl *rtnl) {
                 if (r < 0)
                         return r;
 
-                if (i < rtnl->rqueue_partial_size) {
+                rtnl->rqueue[rtnl->rqueue_size ++] = first;
+                first = NULL;
+
+                if (multi_part && (i < rtnl->rqueue_partial_size)) {
                         /* remove the message form the partial read queue */
                         memmove(rtnl->rqueue_partial + i,rtnl->rqueue_partial + i + 1,
                                 sizeof(sd_rtnl_message*) * (rtnl->rqueue_partial_size - i - 1));
                         rtnl->rqueue_partial_size --;
                 }
 
-                rtnl->rqueue[rtnl->rqueue_size ++] = first;
-                first = NULL;
-
                 return 1;
         } else {
                 /* we only got a partial multi-part message, push it on the