]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - net/netlink/af_netlink.c
[NETLINK]: Remove unused groups variable
[net-next-2.6.git] / net / netlink / af_netlink.c
index 383dd4e82ee150fc33a3a8b726c0d5e02ff7f4b8..8488c15f26434a6f05aa67430563bad101c9b74f 100644 (file)
@@ -8,7 +8,7 @@
  *             modify it under the terms of the GNU General Public License
  *             as published by the Free Software Foundation; either version
  *             2 of the License, or (at your option) any later version.
- * 
+ *
  * Tue Jun 26 14:36:48 MEST 2001 Herbert "herp" Rosmanith
  *                               added netlink_proto_exit
  * Tue Jan 22 18:32:44 BRST 2002 Arnaldo C. de Melo <acme@conectiva.com.br>
@@ -396,7 +396,6 @@ static int netlink_create(struct socket *sock, int protocol)
 {
        struct module *module = NULL;
        struct netlink_sock *nlk;
-       unsigned int groups;
        int err = 0;
 
        sock->state = SS_UNCONNECTED;
@@ -418,7 +417,6 @@ static int netlink_create(struct socket *sock, int protocol)
        if (nl_table[protocol].registered &&
            try_module_get(nl_table[protocol].module))
                module = nl_table[protocol].module;
-       groups = nl_table[protocol].groups;
        netlink_unlock_table();
 
        if ((err = __netlink_create(sock, protocol)) < 0)
@@ -443,6 +441,7 @@ static int netlink_release(struct socket *sock)
                return 0;
 
        netlink_remove(sk);
+       sock_orphan(sk);
        nlk = nlk_sk(sk);
 
        spin_lock(&nlk->cb_lock);
@@ -457,7 +456,6 @@ static int netlink_release(struct socket *sock)
        /* OK. Socket is unlinked, and, therefore,
           no new packets will arrive */
 
-       sock_orphan(sk);
        sock->sk = NULL;
        wake_up_interruptible_all(&nlk->wait);
 
@@ -470,7 +468,7 @@ static int netlink_release(struct socket *sock)
                                          };
                atomic_notifier_call_chain(&netlink_chain,
                                NETLINK_URELEASE, &n);
-       }       
+       }
 
        module_put(nlk->module);
 
@@ -528,11 +526,11 @@ retry:
        return err;
 }
 
-static inline int netlink_capable(struct socket *sock, unsigned int flag) 
-{ 
+static inline int netlink_capable(struct socket *sock, unsigned int flag)
+{
        return (nl_table[sock->sk->sk_protocol].nl_nonroot & flag) ||
               capable(CAP_NET_ADMIN);
-} 
+}
 
 static void
 netlink_update_subscriptions(struct sock *sk, unsigned int subscriptions)
@@ -574,7 +572,7 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr, int addr_len
        struct netlink_sock *nlk = nlk_sk(sk);
        struct sockaddr_nl *nladdr = (struct sockaddr_nl *)addr;
        int err;
-       
+
        if (nladdr->nl_family != AF_NETLINK)
                return -EINVAL;
 
@@ -605,9 +603,9 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr, int addr_len
 
        netlink_table_grab();
        netlink_update_subscriptions(sk, nlk->subscriptions +
-                                        hweight32(nladdr->nl_groups) -
-                                        hweight32(nlk->groups[0]));
-       nlk->groups[0] = (nlk->groups[0] & ~0xffffffffUL) | nladdr->nl_groups; 
+                                        hweight32(nladdr->nl_groups) -
+                                        hweight32(nlk->groups[0]));
+       nlk->groups[0] = (nlk->groups[0] & ~0xffffffffUL) | nladdr->nl_groups;
        netlink_update_listeners(sk);
        netlink_table_ungrab();
 
@@ -652,7 +650,7 @@ static int netlink_getname(struct socket *sock, struct sockaddr *addr, int *addr
        struct sock *sk = sock->sk;
        struct netlink_sock *nlk = nlk_sk(sk);
        struct sockaddr_nl *nladdr=(struct sockaddr_nl *)addr;
-       
+
        nladdr->nl_family = AF_NETLINK;
        nladdr->nl_pad = 0;
        *addr_len = sizeof(*nladdr);
@@ -999,7 +997,7 @@ void netlink_set_err(struct sock *ssk, u32 pid, u32 group, int code)
 }
 
 static int netlink_setsockopt(struct socket *sock, int level, int optname,
-                              char __user *optval, int optlen)
+                             char __user *optval, int optlen)
 {
        struct sock *sk = sock->sk;
        struct netlink_sock *nlk = nlk_sk(sk);
@@ -1054,7 +1052,7 @@ static int netlink_setsockopt(struct socket *sock, int level, int optname,
 }
 
 static int netlink_getsockopt(struct socket *sock, int level, int optname,
-                              char __user *optval, int __user *optlen)
+                             char __user *optval, int __user *optlen)
 {
        struct sock *sk = sock->sk;
        struct netlink_sock *nlk = nlk_sk(sk);
@@ -1215,7 +1213,7 @@ static int netlink_recvmsg(struct kiocb *kiocb, struct socket *sock,
                copied = len;
        }
 
-       skb->h.raw = skb->data;
+       skb_reset_transport_header(skb);
        err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);
 
        if (msg->msg_name) {
@@ -1242,6 +1240,9 @@ static int netlink_recvmsg(struct kiocb *kiocb, struct socket *sock,
 
        scm_recv(sock, msg, siocb->scm, flags);
 
+       if (flags & MSG_TRUNC)
+               copied = skb->len;
+
 out:
        netlink_rcv_wake(sk);
        return err ? : copied;
@@ -1257,15 +1258,15 @@ static void netlink_data_ready(struct sock *sk, int len)
 }
 
 /*
- *     We export these functions to other modules. They provide a 
+ *     We export these functions to other modules. They provide a
  *     complete set of kernel non-blocking support for message
  *     queueing.
  */
 
 struct sock *
 netlink_kernel_create(int unit, unsigned int groups,
-                      void (*input)(struct sock *sk, int len),
-                      struct module *module)
+                     void (*input)(struct sock *sk, int len),
+                     struct module *module)
 {
        struct socket *sock;
        struct sock *sk;
@@ -1317,10 +1318,10 @@ out_sock_release:
 }
 
 void netlink_set_nonroot(int protocol, unsigned int flags)
-{ 
-       if ((unsigned int)protocol < MAX_LINKS) 
+{
+       if ((unsigned int)protocol < MAX_LINKS)
                nl_table[protocol].nl_nonroot = flags;
-} 
+}
 
 static void netlink_destroy_callback(struct netlink_callback *cb)
 {
@@ -1341,7 +1342,7 @@ static int netlink_dump(struct sock *sk)
        struct sk_buff *skb;
        struct nlmsghdr *nlh;
        int len, err = -ENOBUFS;
-       
+
        skb = sock_rmalloc(sk, NLMSG_GOODSIZE, 0, GFP_KERNEL);
        if (!skb)
                goto errout;
@@ -1412,9 +1413,9 @@ int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
                return -ECONNREFUSED;
        }
        nlk = nlk_sk(sk);
-       /* A dump is in progress... */
+       /* A dump or destruction is in progress... */
        spin_lock(&nlk->cb_lock);
-       if (nlk->cb) {
+       if (nlk->cb || sock_flag(sk, SOCK_DEAD)) {
                spin_unlock(&nlk->cb_lock);
                netlink_destroy_callback(cb);
                sock_put(sk);
@@ -1468,7 +1469,7 @@ static int netlink_rcv_skb(struct sk_buff *skb, int (*cb)(struct sk_buff *,
        int err;
 
        while (skb->len >= nlmsg_total_size(0)) {
-               nlh = (struct nlmsghdr *) skb->data;
+               nlh = nlmsg_hdr(skb);
 
                if (nlh->nlmsg_len < NLMSG_HDRLEN || skb->len < nlh->nlmsg_len)
                        return 0;
@@ -1626,7 +1627,7 @@ static void *netlink_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 
        if (v == SEQ_START_TOKEN)
                return netlink_seq_socket_idx(seq, 0);
-               
+
        s = sk_next(v);
        if (s)
                return s;
@@ -1713,7 +1714,7 @@ static int netlink_seq_open(struct inode *inode, struct file *file)
        return 0;
 }
 
-static struct file_operations netlink_seq_fops = {
+static const struct file_operations netlink_seq_fops = {
        .owner          = THIS_MODULE,
        .open           = netlink_seq_open,
        .read           = seq_read,
@@ -1732,7 +1733,7 @@ int netlink_unregister_notifier(struct notifier_block *nb)
 {
        return atomic_notifier_chain_unregister(&netlink_chain, nb);
 }
-                
+
 static const struct proto_ops netlink_ops = {
        .family =       PF_NETLINK,
        .owner =        THIS_MODULE,
@@ -1808,7 +1809,7 @@ static int __init netlink_proto_init(void)
 #ifdef CONFIG_PROC_FS
        proc_net_fops_create("netlink", 0, &netlink_seq_fops);
 #endif
-       /* The netlink device handler may be needed early. */ 
+       /* The netlink device handler may be needed early. */
        rtnetlink_init();
 out:
        return err;
@@ -1825,7 +1826,6 @@ EXPORT_SYMBOL(netlink_broadcast);
 EXPORT_SYMBOL(netlink_dump_start);
 EXPORT_SYMBOL(netlink_kernel_create);
 EXPORT_SYMBOL(netlink_register_notifier);
-EXPORT_SYMBOL(netlink_set_err);
 EXPORT_SYMBOL(netlink_set_nonroot);
 EXPORT_SYMBOL(netlink_unicast);
 EXPORT_SYMBOL(netlink_unregister_notifier);