summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-03-13 16:12:57 +0100
committerTom Gundersen <teg@jklm.no>2015-03-13 16:12:57 +0100
commit3f42446d286a12292f1693d5cf9cb3ec3844e1a4 (patch)
treec0eda6f1a12d051bbd6c079518c838aba09326b6
parent913b0eef1a01e0c78f0453b0174e75d5caae1023 (diff)
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.
-rw-r--r--src/libsystemd/sd-rtnl/rtnl-internal.h1
-rw-r--r--src/libsystemd/sd-rtnl/rtnl-message.c4
-rw-r--r--src/libsystemd/sd-rtnl/sd-rtnl.c2
3 files changed, 6 insertions, 1 deletions
diff --git a/src/libsystemd/sd-rtnl/rtnl-internal.h b/src/libsystemd/sd-rtnl/rtnl-internal.h
index a192198419..05b88b1ad8 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 8bb7bcdd05..d24769b4b9 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 f483af991b..c7a36b9efb 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);