]> err.no Git - linux-2.6/blobdiff - net/netlink/genetlink.c
net: use software GSO for SG+CSUM capable netdevices
[linux-2.6] / net / netlink / genetlink.c
index e146531faf1d349434c89306eafc7968f506baa1..3e1191cecaf03131d5ad2ff321f171f9168bc6ad 100644 (file)
@@ -22,22 +22,14 @@ struct sock *genl_sock = NULL;
 
 static DEFINE_MUTEX(genl_mutex); /* serialization of message processing */
 
-static void genl_lock(void)
+static inline void genl_lock(void)
 {
        mutex_lock(&genl_mutex);
 }
 
-static int genl_trylock(void)
-{
-       return !mutex_trylock(&genl_mutex);
-}
-
-static void genl_unlock(void)
+static inline void genl_unlock(void)
 {
        mutex_unlock(&genl_mutex);
-
-       if (genl_sock && genl_sock->sk_receive_queue.qlen)
-               genl_sock->sk_data_ready(genl_sock, 0);
 }
 
 #define GENL_FAM_TAB_SIZE      16
@@ -184,7 +176,7 @@ int genl_register_mc_group(struct genl_family *family,
        }
 
        err = netlink_change_ngroups(genl_sock,
-                                    sizeof(unsigned long) * NETLINK_GENERIC);
+                                    mc_groups_longs * BITS_PER_LONG);
        if (err)
                goto out;
 
@@ -196,10 +188,22 @@ int genl_register_mc_group(struct genl_family *family,
        genl_ctrl_event(CTRL_CMD_NEWMCAST_GRP, grp);
  out:
        genl_unlock();
-       return 0;
+       return err;
 }
 EXPORT_SYMBOL(genl_register_mc_group);
 
+static void __genl_unregister_mc_group(struct genl_family *family,
+                                      struct genl_multicast_group *grp)
+{
+       BUG_ON(grp->family != family);
+       netlink_clear_multicast_users(genl_sock, grp->id);
+       clear_bit(grp->id, mc_groups);
+       list_del(&grp->list);
+       genl_ctrl_event(CTRL_CMD_DELMCAST_GRP, grp);
+       grp->id = 0;
+       grp->family = NULL;
+}
+
 /**
  * genl_unregister_mc_group - unregister a multicast group
  *
@@ -217,14 +221,8 @@ EXPORT_SYMBOL(genl_register_mc_group);
 void genl_unregister_mc_group(struct genl_family *family,
                              struct genl_multicast_group *grp)
 {
-       BUG_ON(grp->family != family);
        genl_lock();
-       netlink_clear_multicast_users(genl_sock, grp->id);
-       clear_bit(grp->id, mc_groups);
-       list_del(&grp->list);
-       genl_ctrl_event(CTRL_CMD_DELMCAST_GRP, grp);
-       grp->id = 0;
-       grp->family = NULL;
+       __genl_unregister_mc_group(family, grp);
        genl_unlock();
 }
 
@@ -233,7 +231,7 @@ static void genl_unregister_mc_groups(struct genl_family *family)
        struct genl_multicast_group *grp, *tmp;
 
        list_for_each_entry_safe(grp, tmp, &family->mcast_groups, list)
-               genl_unregister_mc_group(family, grp);
+               __genl_unregister_mc_group(family, grp);
 }
 
 /**
@@ -396,10 +394,10 @@ int genl_unregister_family(struct genl_family *family)
 {
        struct genl_family *rc;
 
-       genl_unregister_mc_groups(family);
-
        genl_lock();
 
+       genl_unregister_mc_groups(family);
+
        list_for_each_entry(rc, genl_family_chain(family->id), family_list) {
                if (family->id != rc->id || strcmp(rc->name, family->name))
                        continue;
@@ -446,8 +444,11 @@ static int genl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
                if (ops->dumpit == NULL)
                        return -EOPNOTSUPP;
 
-               return netlink_dump_start(genl_sock, skb, nlh,
-                                         ops->dumpit, ops->done);
+               genl_unlock();
+               err = netlink_dump_start(genl_sock, skb, nlh,
+                                        ops->dumpit, ops->done);
+               genl_lock();
+               return err;
        }
 
        if (ops->doit == NULL)
@@ -470,16 +471,11 @@ static int genl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
        return ops->doit(skb, &info);
 }
 
-static void genl_rcv(struct sock *sk, int len)
+static void genl_rcv(struct sk_buff *skb)
 {
-       unsigned int qlen = 0;
-
-       do {
-               if (genl_trylock())
-                       return;
-               netlink_run_queue(sk, &qlen, genl_rcv_msg);
-               genl_unlock();
-       } while (qlen && genl_sock && genl_sock->sk_receive_queue.qlen);
+       genl_lock();
+       netlink_rcv_skb(skb, &genl_rcv_msg);
+       genl_unlock();
 }
 
 /**************************************************************************
@@ -561,7 +557,8 @@ static int ctrl_fill_info(struct genl_family *family, u32 pid, u32 seq,
        return genlmsg_end(skb, hdr);
 
 nla_put_failure:
-       return genlmsg_cancel(skb, hdr);
+       genlmsg_cancel(skb, hdr);
+       return -EMSGSIZE;
 }
 
 static int ctrl_fill_mcgrp_info(struct genl_multicast_group *grp, u32 pid,
@@ -597,7 +594,8 @@ static int ctrl_fill_mcgrp_info(struct genl_multicast_group *grp, u32 pid,
        return genlmsg_end(skb, hdr);
 
 nla_put_failure:
-       return genlmsg_cancel(skb, hdr);
+       genlmsg_cancel(skb, hdr);
+       return -EMSGSIZE;
 }
 
 static int ctrl_dumpfamily(struct sk_buff *skb, struct netlink_callback *cb)
@@ -608,9 +606,6 @@ static int ctrl_dumpfamily(struct sk_buff *skb, struct netlink_callback *cb)
        int chains_to_skip = cb->args[0];
        int fams_to_skip = cb->args[1];
 
-       if (chains_to_skip != 0)
-               genl_lock();
-
        for (i = 0; i < GENL_FAM_TAB_SIZE; i++) {
                if (i < chains_to_skip)
                        continue;
@@ -628,9 +623,6 @@ static int ctrl_dumpfamily(struct sk_buff *skb, struct netlink_callback *cb)
        }
 
 errout:
-       if (chains_to_skip != 0)
-               genl_unlock();
-
        cb->args[0] = i;
        cb->args[1] = n;
 
@@ -774,8 +766,8 @@ static int __init genl_init(void)
        netlink_set_nonroot(NETLINK_GENERIC, NL_NONROOT_RECV);
 
        /* we'll bump the group number right afterwards */
-       genl_sock = netlink_kernel_create(NETLINK_GENERIC, 0, genl_rcv,
-                                         NULL, THIS_MODULE);
+       genl_sock = netlink_kernel_create(&init_net, NETLINK_GENERIC, 0,
+                                         genl_rcv, &genl_mutex, THIS_MODULE);
        if (genl_sock == NULL)
                panic("GENL: Cannot initialize generic netlink\n");