]> git.karo-electronics.de Git - linux-beck.git/blobdiff - net/core/drop_monitor.c
Merge branch 'drm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied...
[linux-beck.git] / net / core / drop_monitor.c
index ad41529fb60f766ad095de5c40b9d537473314f1..36e603c78ce9fd3a5f989716d59bff20a2699293 100644 (file)
@@ -223,6 +223,11 @@ static int set_all_monitor_traces(int state)
 
        spin_lock(&trace_state_lock);
 
+       if (state == trace_state) {
+               rc = -EAGAIN;
+               goto out_unlock;
+       }
+
        switch (state) {
        case TRACE_ON:
                rc |= register_trace_kfree_skb(trace_kfree_skb_hit, NULL);
@@ -251,11 +256,12 @@ static int set_all_monitor_traces(int state)
 
        if (!rc)
                trace_state = state;
+       else
+               rc = -EINPROGRESS;
 
+out_unlock:
        spin_unlock(&trace_state_lock);
 
-       if (rc)
-               return -EINPROGRESS;
        return rc;
 }
 
@@ -341,9 +347,9 @@ static struct notifier_block dropmon_net_notifier = {
 
 static int __init init_net_drop_monitor(void)
 {
-       int cpu;
-       int rc, i, ret;
        struct per_cpu_dm_data *data;
+       int cpu, rc;
+
        printk(KERN_INFO "Initalizing network drop monitor service\n");
 
        if (sizeof(void *) > 8) {
@@ -351,21 +357,12 @@ static int __init init_net_drop_monitor(void)
                return -ENOSPC;
        }
 
-       if (genl_register_family(&net_drop_monitor_family) < 0) {
+       rc = genl_register_family_with_ops(&net_drop_monitor_family,
+                                          dropmon_ops,
+                                          ARRAY_SIZE(dropmon_ops));
+       if (rc) {
                printk(KERN_ERR "Could not create drop monitor netlink family\n");
-               return -EFAULT;
-       }
-
-       rc = -EFAULT;
-
-       for (i = 0; i < ARRAY_SIZE(dropmon_ops); i++) {
-               ret = genl_register_ops(&net_drop_monitor_family,
-                                       &dropmon_ops[i]);
-               if (ret) {
-                       printk(KERN_CRIT "Failed to register operation %d\n",
-                               dropmon_ops[i].cmd);
-                       goto out_unreg;
-               }
+               return rc;
        }
 
        rc = register_netdevice_notifier(&dropmon_net_notifier);