ipvs: Pass ipvs not net to start_sync_thread
[firefly-linux-kernel-4.4.55.git] / net / netfilter / ipvs / ip_vs_ctl.c
index eb3911c690372707800a703b5ab1e40526a90ee2..b63b4c186040dd62cdd9ee22079ff1a54ee468bb 100644 (file)
@@ -2202,10 +2202,9 @@ static const struct file_operations ip_vs_stats_percpu_fops = {
 /*
  *     Set timeout values for tcp tcpfin udp in the timeout_table.
  */
-static int ip_vs_set_timeout(struct net *net, struct ip_vs_timeout_user *u)
+static int ip_vs_set_timeout(struct netns_ipvs *ipvs, struct ip_vs_timeout_user *u)
 {
 #if defined(CONFIG_IP_VS_PROTO_TCP) || defined(CONFIG_IP_VS_PROTO_UDP)
-       struct netns_ipvs *ipvs = net_ipvs(net);
        struct ip_vs_proto_data *pd;
 #endif
 
@@ -2351,7 +2350,7 @@ do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len)
                        cfg.syncid = dm->syncid;
                        rtnl_lock();
                        mutex_lock(&ipvs->sync_mutex);
-                       ret = start_sync_thread(net, &cfg, dm->state);
+                       ret = start_sync_thread(ipvs, &cfg, dm->state);
                        mutex_unlock(&ipvs->sync_mutex);
                        rtnl_unlock();
                } else {
@@ -2369,7 +2368,7 @@ do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len)
                goto out_unlock;
        } else if (cmd == IP_VS_SO_SET_TIMEOUT) {
                /* Set timeout values for (tcp tcpfin udp) */
-               ret = ip_vs_set_timeout(net, (struct ip_vs_timeout_user *)arg);
+               ret = ip_vs_set_timeout(ipvs, (struct ip_vs_timeout_user *)arg);
                goto out_unlock;
        }
 
@@ -2478,11 +2477,10 @@ ip_vs_copy_service(struct ip_vs_service_entry *dst, struct ip_vs_service *src)
 }
 
 static inline int
-__ip_vs_get_service_entries(struct net *net,
+__ip_vs_get_service_entries(struct netns_ipvs *ipvs,
                            const struct ip_vs_get_services *get,
                            struct ip_vs_get_services __user *uptr)
 {
-       struct netns_ipvs *ipvs = net_ipvs(net);
        int idx, count=0;
        struct ip_vs_service *svc;
        struct ip_vs_service_entry entry;
@@ -2530,10 +2528,9 @@ out:
 }
 
 static inline int
-__ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
+__ip_vs_get_dest_entries(struct netns_ipvs *ipvs, const struct ip_vs_get_dests *get,
                         struct ip_vs_get_dests __user *uptr)
 {
-       struct netns_ipvs *ipvs = net_ipvs(net);
        struct ip_vs_service *svc;
        union nf_inet_addr addr = { .ip = get->addr };
        int ret = 0;
@@ -2587,10 +2584,9 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
 }
 
 static inline void
-__ip_vs_get_timeouts(struct net *net, struct ip_vs_timeout_user *u)
+__ip_vs_get_timeouts(struct netns_ipvs *ipvs, struct ip_vs_timeout_user *u)
 {
 #if defined(CONFIG_IP_VS_PROTO_TCP) || defined(CONFIG_IP_VS_PROTO_UDP)
-       struct netns_ipvs *ipvs = net_ipvs(net);
        struct ip_vs_proto_data *pd;
 #endif
 
@@ -2721,7 +2717,7 @@ do_ip_vs_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
                        ret = -EINVAL;
                        goto out;
                }
-               ret = __ip_vs_get_service_entries(net, get, user);
+               ret = __ip_vs_get_service_entries(ipvs, get, user);
        }
        break;
 
@@ -2763,7 +2759,7 @@ do_ip_vs_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
                        ret = -EINVAL;
                        goto out;
                }
-               ret = __ip_vs_get_dest_entries(net, get, user);
+               ret = __ip_vs_get_dest_entries(ipvs, get, user);
        }
        break;
 
@@ -2771,7 +2767,7 @@ do_ip_vs_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
        {
                struct ip_vs_timeout_user t;
 
-               __ip_vs_get_timeouts(net, &t);
+               __ip_vs_get_timeouts(ipvs, &t);
                if (copy_to_user(user, &t, sizeof(t)) != 0)
                        ret = -EFAULT;
        }
@@ -3038,12 +3034,11 @@ nla_put_failure:
        return skb->len;
 }
 
-static int ip_vs_genl_parse_service(struct net *net,
+static int ip_vs_genl_parse_service(struct netns_ipvs *ipvs,
                                    struct ip_vs_service_user_kern *usvc,
                                    struct nlattr *nla, int full_entry,
                                    struct ip_vs_service **ret_svc)
 {
-       struct netns_ipvs *ipvs = net_ipvs(net);
        struct nlattr *attrs[IPVS_SVC_ATTR_MAX + 1];
        struct nlattr *nla_af, *nla_port, *nla_fwmark, *nla_protocol, *nla_addr;
        struct ip_vs_service *svc;
@@ -3124,14 +3119,14 @@ static int ip_vs_genl_parse_service(struct net *net,
        return 0;
 }
 
-static struct ip_vs_service *ip_vs_genl_find_service(struct net *net,
+static struct ip_vs_service *ip_vs_genl_find_service(struct netns_ipvs *ipvs,
                                                     struct nlattr *nla)
 {
        struct ip_vs_service_user_kern usvc;
        struct ip_vs_service *svc;
        int ret;
 
-       ret = ip_vs_genl_parse_service(net, &usvc, nla, 0, &svc);
+       ret = ip_vs_genl_parse_service(ipvs, &usvc, nla, 0, &svc);
        return ret ? ERR_PTR(ret) : svc;
 }
 
@@ -3207,6 +3202,7 @@ static int ip_vs_genl_dump_dests(struct sk_buff *skb,
        struct ip_vs_dest *dest;
        struct nlattr *attrs[IPVS_CMD_ATTR_MAX + 1];
        struct net *net = skb_sknet(skb);
+       struct netns_ipvs *ipvs = net_ipvs(net);
 
        mutex_lock(&__ip_vs_mutex);
 
@@ -3216,7 +3212,7 @@ static int ip_vs_genl_dump_dests(struct sk_buff *skb,
                goto out_err;
 
 
-       svc = ip_vs_genl_find_service(net, attrs[IPVS_CMD_ATTR_SERVICE]);
+       svc = ip_vs_genl_find_service(ipvs, attrs[IPVS_CMD_ATTR_SERVICE]);
        if (IS_ERR(svc) || svc == NULL)
                goto out_err;
 
@@ -3378,9 +3374,8 @@ nla_put_failure:
        return skb->len;
 }
 
-static int ip_vs_genl_new_daemon(struct net *net, struct nlattr **attrs)
+static int ip_vs_genl_new_daemon(struct netns_ipvs *ipvs, struct nlattr **attrs)
 {
-       struct netns_ipvs *ipvs = net_ipvs(net);
        struct ipvs_sync_daemon_cfg c;
        struct nlattr *a;
        int ret;
@@ -3437,23 +3432,22 @@ static int ip_vs_genl_new_daemon(struct net *net, struct nlattr **attrs)
 
        rtnl_lock();
        mutex_lock(&ipvs->sync_mutex);
-       ret = start_sync_thread(net, &c,
+       ret = start_sync_thread(ipvs, &c,
                                nla_get_u32(attrs[IPVS_DAEMON_ATTR_STATE]));
        mutex_unlock(&ipvs->sync_mutex);
        rtnl_unlock();
        return ret;
 }
 
-static int ip_vs_genl_del_daemon(struct net *net, struct nlattr **attrs)
+static int ip_vs_genl_del_daemon(struct netns_ipvs *ipvs, struct nlattr **attrs)
 {
-       struct netns_ipvs *ipvs = net_ipvs(net);
        int ret;
 
        if (!attrs[IPVS_DAEMON_ATTR_STATE])
                return -EINVAL;
 
        mutex_lock(&ipvs->sync_mutex);
-       ret = stop_sync_thread(net,
+       ret = stop_sync_thread(ipvs->net,
                               nla_get_u32(attrs[IPVS_DAEMON_ATTR_STATE]));
        mutex_unlock(&ipvs->sync_mutex);
        return ret;
@@ -3461,9 +3455,10 @@ static int ip_vs_genl_del_daemon(struct net *net, struct nlattr **attrs)
 
 static int ip_vs_genl_set_config(struct net *net, struct nlattr **attrs)
 {
+       struct netns_ipvs *ipvs = net_ipvs(net);
        struct ip_vs_timeout_user t;
 
-       __ip_vs_get_timeouts(net, &t);
+       __ip_vs_get_timeouts(ipvs, &t);
 
        if (attrs[IPVS_CMD_ATTR_TIMEOUT_TCP])
                t.tcp_timeout = nla_get_u32(attrs[IPVS_CMD_ATTR_TIMEOUT_TCP]);
@@ -3475,7 +3470,7 @@ static int ip_vs_genl_set_config(struct net *net, struct nlattr **attrs)
        if (attrs[IPVS_CMD_ATTR_TIMEOUT_UDP])
                t.udp_timeout = nla_get_u32(attrs[IPVS_CMD_ATTR_TIMEOUT_UDP]);
 
-       return ip_vs_set_timeout(net, &t);
+       return ip_vs_set_timeout(ipvs, &t);
 }
 
 static int ip_vs_genl_set_daemon(struct sk_buff *skb, struct genl_info *info)
@@ -3498,9 +3493,9 @@ static int ip_vs_genl_set_daemon(struct sk_buff *skb, struct genl_info *info)
                        goto out;
 
                if (cmd == IPVS_CMD_NEW_DAEMON)
-                       ret = ip_vs_genl_new_daemon(net, daemon_attrs);
+                       ret = ip_vs_genl_new_daemon(ipvs, daemon_attrs);
                else
-                       ret = ip_vs_genl_del_daemon(net, daemon_attrs);
+                       ret = ip_vs_genl_del_daemon(ipvs, daemon_attrs);
        }
 
 out:
@@ -3541,7 +3536,7 @@ static int ip_vs_genl_set_cmd(struct sk_buff *skb, struct genl_info *info)
        if (cmd == IPVS_CMD_NEW_SERVICE || cmd == IPVS_CMD_SET_SERVICE)
                need_full_svc = 1;
 
-       ret = ip_vs_genl_parse_service(net, &usvc,
+       ret = ip_vs_genl_parse_service(ipvs, &usvc,
                                       info->attrs[IPVS_CMD_ATTR_SERVICE],
                                       need_full_svc, &svc);
        if (ret)
@@ -3639,8 +3634,10 @@ static int ip_vs_genl_get_cmd(struct sk_buff *skb, struct genl_info *info)
        void *reply;
        int ret, cmd, reply_cmd;
        struct net *net;
+       struct netns_ipvs *ipvs;
 
        net = skb_sknet(skb);
+       ipvs = net_ipvs(net);
        cmd = info->genlhdr->cmd;
 
        if (cmd == IPVS_CMD_GET_SERVICE)
@@ -3669,7 +3666,7 @@ static int ip_vs_genl_get_cmd(struct sk_buff *skb, struct genl_info *info)
        {
                struct ip_vs_service *svc;
 
-               svc = ip_vs_genl_find_service(net,
+               svc = ip_vs_genl_find_service(ipvs,
                                              info->attrs[IPVS_CMD_ATTR_SERVICE]);
                if (IS_ERR(svc)) {
                        ret = PTR_ERR(svc);
@@ -3690,7 +3687,7 @@ static int ip_vs_genl_get_cmd(struct sk_buff *skb, struct genl_info *info)
        {
                struct ip_vs_timeout_user t;
 
-               __ip_vs_get_timeouts(net, &t);
+               __ip_vs_get_timeouts(ipvs, &t);
 #ifdef CONFIG_IP_VS_PROTO_TCP
                if (nla_put_u32(msg, IPVS_CMD_ATTR_TIMEOUT_TCP,
                                t.tcp_timeout) ||