[systemd-commits] 3 commits - src/libsystemd
Tom Gundersen
tomegun at kemper.freedesktop.org
Fri Mar 13 08:55:11 PDT 2015
src/libsystemd/sd-rtnl/rtnl-internal.h | 1 +
src/libsystemd/sd-rtnl/rtnl-message.c | 8 +++++---
src/libsystemd/sd-rtnl/sd-rtnl.c | 21 +++++++++++----------
3 files changed, 17 insertions(+), 13 deletions(-)
New commits:
commit 0964dcd77213a9e229efcc2f00084e1f63fc00ca
Author: Tom Gundersen <teg at jklm.no>
Date: Fri Mar 13 16:15:03 2015 +0100
sd-rtnl: read_message - don't set group if not needed
diff --git a/src/libsystemd/sd-rtnl/rtnl-message.c b/src/libsystemd/sd-rtnl/rtnl-message.c
index d24769b..5a71900 100644
--- a/src/libsystemd/sd-rtnl/rtnl-message.c
+++ b/src/libsystemd/sd-rtnl/rtnl-message.c
@@ -1474,7 +1474,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;
@@ -1500,7 +1500,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
commit f436aa11f72e69e7b19cb4d73c78716296e3e417
Author: Tom Gundersen <teg at jklm.no>
Date: Fri Mar 13 16:13:24 2015 +0100
sd-rtnl: process - only apply matches to broadcast messages
diff --git a/src/libsystemd/sd-rtnl/sd-rtnl.c b/src/libsystemd/sd-rtnl/sd-rtnl.c
index c7a36b9..50162c3 100644
--- a/src/libsystemd/sd-rtnl/sd-rtnl.c
+++ b/src/libsystemd/sd-rtnl/sd-rtnl.c
@@ -428,9 +428,6 @@ static int process_reply(sd_rtnl *rtnl, sd_rtnl_message *m) {
assert(rtnl);
assert(m);
- if (sd_rtnl_message_is_broadcast(m))
- return 0;
-
serial = rtnl_message_get_serial(m);
c = hashmap_remove(rtnl->reply_callbacks, &serial);
if (!c)
@@ -495,13 +492,15 @@ static int process_running(sd_rtnl *rtnl, sd_rtnl_message **ret) {
if (!m)
goto null_message;
- r = process_reply(rtnl, m);
- if (r != 0)
- goto null_message;
-
- r = process_match(rtnl, m);
- if (r != 0)
- goto null_message;
+ if (sd_rtnl_message_is_broadcast(m)) {
+ r = process_match(rtnl, m);
+ if (r != 0)
+ goto null_message;
+ } else {
+ r = process_reply(rtnl, m);
+ if (r != 0)
+ goto null_message;
+ }
if (ret) {
*ret = m;
commit 3f42446d286a12292f1693d5cf9cb3ec3844e1a4
Author: Tom Gundersen <teg at jklm.no>
Date: Fri Mar 13 16:12:57 2015 +0100
sd-rtnl: improve detection of broadcast messages
Do not rely on nl_pid == 0, but check the groups instead. We currently avoid using
nl_pid == 0 for unicast anyway, so this should be redundant, but let's try to be
correct.
diff --git a/src/libsystemd/sd-rtnl/rtnl-internal.h b/src/libsystemd/sd-rtnl/rtnl-internal.h
index a192198..05b88b1 100644
--- a/src/libsystemd/sd-rtnl/rtnl-internal.h
+++ b/src/libsystemd/sd-rtnl/rtnl-internal.h
@@ -109,6 +109,7 @@ struct sd_rtnl_message {
size_t *rta_offset_tb[RTNL_CONTAINER_DEPTH];
unsigned short rta_tb_size[RTNL_CONTAINER_DEPTH];
bool sealed:1;
+ bool broadcast:1;
sd_rtnl_message *next; /* next in a chain of multi-part messages */
};
diff --git a/src/libsystemd/sd-rtnl/rtnl-message.c b/src/libsystemd/sd-rtnl/rtnl-message.c
index 8bb7bcd..d24769b 100644
--- a/src/libsystemd/sd-rtnl/rtnl-message.c
+++ b/src/libsystemd/sd-rtnl/rtnl-message.c
@@ -654,7 +654,7 @@ int sd_rtnl_message_get_family(sd_rtnl_message *m, int *family) {
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) {
@@ -1577,6 +1577,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;
diff --git a/src/libsystemd/sd-rtnl/sd-rtnl.c b/src/libsystemd/sd-rtnl/sd-rtnl.c
index f483af9..c7a36b9 100644
--- a/src/libsystemd/sd-rtnl/sd-rtnl.c
+++ b/src/libsystemd/sd-rtnl/sd-rtnl.c
@@ -262,6 +262,8 @@ static void rtnl_seal_message(sd_rtnl *rtnl, sd_rtnl_message *m) {
assert(m);
assert(m->hdr);
+ /* don't use seq == 0, as that is used for broadcasts, so we
+ would get confused by replies to such messages */
m->hdr->nlmsg_seq = rtnl->serial++ ? : rtnl->serial++;
rtnl_message_seal(m);
More information about the systemd-commits
mailing list