summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-rtnl/rtnl-message.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsystemd/sd-rtnl/rtnl-message.c')
-rw-r--r--src/libsystemd/sd-rtnl/rtnl-message.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/libsystemd/sd-rtnl/rtnl-message.c b/src/libsystemd/sd-rtnl/rtnl-message.c
index 276591f31b..bab2a4ff08 100644
--- a/src/libsystemd/sd-rtnl/rtnl-message.c
+++ b/src/libsystemd/sd-rtnl/rtnl-message.c
@@ -20,11 +20,11 @@
***/
#include <netinet/in.h>
-#include <netinet/ether.h>
#include <stdbool.h>
#include <unistd.h>
#include "util.h"
+#include "formats-util.h"
#include "refcnt.h"
#include "missing.h"
@@ -45,7 +45,7 @@ static int message_new_empty(sd_rtnl *rtnl, sd_rtnl_message **ret) {
/* Note that 'rtnl' is currently unused, if we start using it internally
we must take care to avoid problems due to mutual references between
- busses and their queued messages. See sd-bus.
+ buses and their queued messages. See sd-bus.
*/
m = new0(sd_rtnl_message, 1);
@@ -649,13 +649,13 @@ int sd_rtnl_message_get_family(sd_rtnl_message *m, int *family) {
return 0;
}
- return -ENOTSUP;
+ return -EOPNOTSUPP;
}
int sd_rtnl_message_is_broadcast(sd_rtnl_message *m) {
assert_return(m, -EINVAL);
- return !m->hdr->nlmsg_pid;
+ return m->broadcast;
}
int sd_rtnl_message_link_get_ifindex(sd_rtnl_message *m, int *ifindex) {
@@ -1475,7 +1475,7 @@ static int socket_recv_message(int fd, struct iovec *iov, uint32_t *_group, bool
return 0;
}
- if (group)
+ if (_group)
*_group = group;
return r;
@@ -1501,7 +1501,7 @@ int socket_read_message(sd_rtnl *rtnl) {
assert(rtnl->rbuffer_allocated >= sizeof(struct nlmsghdr));
/* read nothing, just get the pending message size */
- r = socket_recv_message(rtnl->fd, &iov, &group, true);
+ r = socket_recv_message(rtnl->fd, &iov, NULL, true);
if (r <= 0)
return r;
else
@@ -1555,13 +1555,15 @@ int socket_read_message(sd_rtnl *rtnl) {
/* finished reading multi-part message */
done = true;
- continue;
+ /* if first is not defined, put NLMSG_DONE into the receive queue. */
+ if (first)
+ continue;
}
/* check that we support this message type */
r = type_system_get_type(NULL, &nl_type, new_msg->nlmsg_type);
if (r < 0) {
- if (r == -ENOTSUP)
+ if (r == -EOPNOTSUPP)
log_debug("sd-rtnl: ignored message with unknown type: %i",
new_msg->nlmsg_type);
@@ -1578,6 +1580,8 @@ int socket_read_message(sd_rtnl *rtnl) {
if (r < 0)
return r;
+ m->broadcast = !!group;
+
m->hdr = memdup(new_msg, new_msg->nlmsg_len);
if (!m->hdr)
return -ENOMEM;