aboutsummaryrefslogtreecommitdiffstats
path: root/net/netlink/genetlink.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/netlink/genetlink.c')
-rw-r--r--net/netlink/genetlink.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index e146531faf1d..8c11ca4a2121 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -184,7 +184,7 @@ int genl_register_mc_group(struct genl_family *family,
184 } 184 }
185 185
186 err = netlink_change_ngroups(genl_sock, 186 err = netlink_change_ngroups(genl_sock,
187 sizeof(unsigned long) * NETLINK_GENERIC); 187 mc_groups_longs * BITS_PER_LONG);
188 if (err) 188 if (err)
189 goto out; 189 goto out;
190 190
@@ -196,10 +196,22 @@ int genl_register_mc_group(struct genl_family *family,
196 genl_ctrl_event(CTRL_CMD_NEWMCAST_GRP, grp); 196 genl_ctrl_event(CTRL_CMD_NEWMCAST_GRP, grp);
197 out: 197 out:
198 genl_unlock(); 198 genl_unlock();
199 return 0; 199 return err;
200} 200}
201EXPORT_SYMBOL(genl_register_mc_group); 201EXPORT_SYMBOL(genl_register_mc_group);
202 202
203static void __genl_unregister_mc_group(struct genl_family *family,
204 struct genl_multicast_group *grp)
205{
206 BUG_ON(grp->family != family);
207 netlink_clear_multicast_users(genl_sock, grp->id);
208 clear_bit(grp->id, mc_groups);
209 list_del(&grp->list);
210 genl_ctrl_event(CTRL_CMD_DELMCAST_GRP, grp);
211 grp->id = 0;
212 grp->family = NULL;
213}
214
203/** 215/**
204 * genl_unregister_mc_group - unregister a multicast group 216 * genl_unregister_mc_group - unregister a multicast group
205 * 217 *
@@ -217,14 +229,8 @@ EXPORT_SYMBOL(genl_register_mc_group);
217void genl_unregister_mc_group(struct genl_family *family, 229void genl_unregister_mc_group(struct genl_family *family,
218 struct genl_multicast_group *grp) 230 struct genl_multicast_group *grp)
219{ 231{
220 BUG_ON(grp->family != family);
221 genl_lock(); 232 genl_lock();
222 netlink_clear_multicast_users(genl_sock, grp->id); 233 __genl_unregister_mc_group(family, grp);
223 clear_bit(grp->id, mc_groups);
224 list_del(&grp->list);
225 genl_ctrl_event(CTRL_CMD_DELMCAST_GRP, grp);
226 grp->id = 0;
227 grp->family = NULL;
228 genl_unlock(); 234 genl_unlock();
229} 235}
230 236
@@ -232,8 +238,10 @@ static void genl_unregister_mc_groups(struct genl_family *family)
232{ 238{
233 struct genl_multicast_group *grp, *tmp; 239 struct genl_multicast_group *grp, *tmp;
234 240
241 genl_lock();
235 list_for_each_entry_safe(grp, tmp, &family->mcast_groups, list) 242 list_for_each_entry_safe(grp, tmp, &family->mcast_groups, list)
236 genl_unregister_mc_group(family, grp); 243 __genl_unregister_mc_group(family, grp);
244 genl_unlock();
237} 245}
238 246
239/** 247/**