sd-netlink: also check multicast group to find suitable match callback

This commit is contained in:
Yu Watanabe
2021-09-29 15:36:42 +09:00
parent ec44d3f407
commit 4d4d898a4b
4 changed files with 13 additions and 4 deletions
+1 -1
View File
@@ -123,8 +123,8 @@ struct sd_netlink_message {
struct nlmsghdr *hdr;
struct netlink_container containers[NETLINK_CONTAINER_DEPTH];
unsigned n_containers; /* number of containers */
uint32_t multicast_group;
bool sealed:1;
bool broadcast:1;
sd_netlink_message *next; /* next in a chain of multi-part messages */
};
+1 -1
View File
@@ -166,7 +166,7 @@ int sd_netlink_message_set_flags(sd_netlink_message *m, uint16_t flags) {
int sd_netlink_message_is_broadcast(sd_netlink_message *m) {
assert_return(m, -EINVAL);
return m->broadcast;
return m->multicast_group != 0;
}
/* If successful the updated message will be correctly aligned, if
+1 -2
View File
@@ -363,8 +363,7 @@ int socket_read_message(sd_netlink *nl) {
if (r < 0)
return r;
m->broadcast = group != 0;
m->multicast_group = group;
m->hdr = memdup(new_msg, new_msg->nlmsg_len);
if (!m->hdr)
return -ENOMEM;
+10
View File
@@ -445,12 +445,22 @@ static int process_match(sd_netlink *nl, sd_netlink_message *m) {
LIST_FOREACH(match_callbacks, c, nl->match_callbacks) {
sd_netlink_slot *slot;
bool found = false;
if (c->type != type)
continue;
if (c->cmd != 0 && c->cmd != cmd)
continue;
for (size_t i = 0; i < c->n_groups; i++)
if (c->groups[i] == m->multicast_group) {
found = true;
break;
}
if (!found)
continue;
slot = container_of(c, sd_netlink_slot, match_callback);
r = c->callback(nl, m, slot->userdata);