netlink: implement unbind to netlink_setsockopt NETLINK_DROP_MEMBERSHIP
authorRichard Guy Briggs <rgb@redhat.com>
Wed, 23 Apr 2014 01:31:55 +0000 (21:31 -0400)
committerDavid S. Miller <davem@davemloft.net>
Wed, 23 Apr 2014 01:42:26 +0000 (21:42 -0400)
Call the per-protocol unbind function rather than bind function on
NETLINK_DROP_MEMBERSHIP in netlink_setsockopt().

Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/netlink/af_netlink.c

index 7e8d229bc0102218a3f53a536ba79134c548c1e9..92f4b6915e8989ee6cb504dd3c84d505bd12b395 100644 (file)
@@ -2129,7 +2129,7 @@ static int netlink_setsockopt(struct socket *sock, int level, int optname,
                        return err;
                if (!val || val - 1 >= nlk->ngroups)
                        return -EINVAL;
-               if (nlk->netlink_bind) {
+               if (optname == NETLINK_ADD_MEMBERSHIP && nlk->netlink_bind) {
                        err = nlk->netlink_bind(val);
                        if (err)
                                return err;
@@ -2138,6 +2138,8 @@ static int netlink_setsockopt(struct socket *sock, int level, int optname,
                netlink_update_socket_mc(nlk, val,
                                         optname == NETLINK_ADD_MEMBERSHIP);
                netlink_table_ungrab();
+               if (optname == NETLINK_DROP_MEMBERSHIP && nlk->netlink_unbind)
+                       nlk->netlink_unbind(val);
 
                err = 0;
                break;