ipvs: Pass ipvs into .conn_in_get and ip_vs_conn_in_get_proto
[deliverable/linux.git] / net / netfilter / ipvs / ip_vs_conn.c
index b0f7b626b56da755222c0a1bd9a3a7b276ba32c8..439d6fb8bc296da1ca48d61722281506a7b3fdc1 100644 (file)
@@ -141,14 +141,14 @@ static unsigned int ip_vs_conn_hashkey_param(const struct ip_vs_conn_param *p,
                port = p->vport;
        }
 
-       return ip_vs_conn_hashkey(p->net, p->af, p->protocol, addr, port);
+       return ip_vs_conn_hashkey(p->ipvs->net, p->af, p->protocol, addr, port);
 }
 
 static unsigned int ip_vs_conn_hashkey_conn(const struct ip_vs_conn *cp)
 {
        struct ip_vs_conn_param p;
 
-       ip_vs_conn_fill_param(ip_vs_conn_net(cp), cp->af, cp->protocol,
+       ip_vs_conn_fill_param(cp->ipvs, cp->af, cp->protocol,
                              &cp->caddr, cp->cport, NULL, 0, &p);
 
        if (cp->pe) {
@@ -279,7 +279,7 @@ __ip_vs_conn_in_get(const struct ip_vs_conn_param *p)
                    ip_vs_addr_equal(p->af, p->vaddr, &cp->vaddr) &&
                    ((!p->cport) ^ (!(cp->flags & IP_VS_CONN_F_NO_CPORT))) &&
                    p->protocol == cp->protocol &&
-                   ip_vs_conn_net_eq(cp, p->net)) {
+                   cp->ipvs == p->ipvs) {
                        if (!__ip_vs_conn_get(cp))
                                continue;
                        /* HIT */
@@ -314,33 +314,34 @@ struct ip_vs_conn *ip_vs_conn_in_get(const struct ip_vs_conn_param *p)
 }
 
 static int
-ip_vs_conn_fill_param_proto(int af, const struct sk_buff *skb,
+ip_vs_conn_fill_param_proto(struct netns_ipvs *ipvs,
+                           int af, const struct sk_buff *skb,
                            const struct ip_vs_iphdr *iph,
-                           int inverse, struct ip_vs_conn_param *p)
+                           struct ip_vs_conn_param *p)
 {
        __be16 _ports[2], *pptr;
-       struct net *net = skb_net(skb);
 
        pptr = frag_safe_skb_hp(skb, iph->len, sizeof(_ports), _ports, iph);
        if (pptr == NULL)
                return 1;
 
-       if (likely(!inverse))
-               ip_vs_conn_fill_param(net, af, iph->protocol, &iph->saddr,
+       if (likely(!ip_vs_iph_inverse(iph)))
+               ip_vs_conn_fill_param(ipvs, af, iph->protocol, &iph->saddr,
                                      pptr[0], &iph->daddr, pptr[1], p);
        else
-               ip_vs_conn_fill_param(net, af, iph->protocol, &iph->daddr,
+               ip_vs_conn_fill_param(ipvs, af, iph->protocol, &iph->daddr,
                                      pptr[1], &iph->saddr, pptr[0], p);
        return 0;
 }
 
 struct ip_vs_conn *
-ip_vs_conn_in_get_proto(int af, const struct sk_buff *skb,
-                       const struct ip_vs_iphdr *iph, int inverse)
+ip_vs_conn_in_get_proto(struct netns_ipvs *ipvs, int af,
+                       const struct sk_buff *skb,
+                       const struct ip_vs_iphdr *iph)
 {
        struct ip_vs_conn_param p;
 
-       if (ip_vs_conn_fill_param_proto(af, skb, iph, inverse, &p))
+       if (ip_vs_conn_fill_param_proto(ipvs, af, skb, iph, &p))
                return NULL;
 
        return ip_vs_conn_in_get(&p);
@@ -359,7 +360,7 @@ struct ip_vs_conn *ip_vs_ct_in_get(const struct ip_vs_conn_param *p)
 
        hlist_for_each_entry_rcu(cp, &ip_vs_conn_tab[hash], c_list) {
                if (unlikely(p->pe_data && p->pe->ct_match)) {
-                       if (!ip_vs_conn_net_eq(cp, p->net))
+                       if (cp->ipvs != p->ipvs)
                                continue;
                        if (p->pe == cp->pe && p->pe->ct_match(p, cp)) {
                                if (__ip_vs_conn_get(cp))
@@ -377,7 +378,7 @@ struct ip_vs_conn *ip_vs_ct_in_get(const struct ip_vs_conn_param *p)
                    p->vport == cp->vport && p->cport == cp->cport &&
                    cp->flags & IP_VS_CONN_F_TEMPLATE &&
                    p->protocol == cp->protocol &&
-                   ip_vs_conn_net_eq(cp, p->net)) {
+                   cp->ipvs == p->ipvs) {
                        if (__ip_vs_conn_get(cp))
                                goto out;
                }
@@ -418,7 +419,7 @@ struct ip_vs_conn *ip_vs_conn_out_get(const struct ip_vs_conn_param *p)
                    ip_vs_addr_equal(p->af, p->vaddr, &cp->caddr) &&
                    ip_vs_addr_equal(p->af, p->caddr, &cp->daddr) &&
                    p->protocol == cp->protocol &&
-                   ip_vs_conn_net_eq(cp, p->net)) {
+                   cp->ipvs == p->ipvs) {
                        if (!__ip_vs_conn_get(cp))
                                continue;
                        /* HIT */
@@ -440,11 +441,12 @@ struct ip_vs_conn *ip_vs_conn_out_get(const struct ip_vs_conn_param *p)
 
 struct ip_vs_conn *
 ip_vs_conn_out_get_proto(int af, const struct sk_buff *skb,
-                        const struct ip_vs_iphdr *iph, int inverse)
+                        const struct ip_vs_iphdr *iph)
 {
+       struct netns_ipvs *ipvs = net_ipvs(skb_net(skb));
        struct ip_vs_conn_param p;
 
-       if (ip_vs_conn_fill_param_proto(af, skb, iph, inverse, &p))
+       if (ip_vs_conn_fill_param_proto(ipvs, af, skb, iph, &p))
                return NULL;
 
        return ip_vs_conn_out_get(&p);
@@ -638,7 +640,7 @@ void ip_vs_try_bind_dest(struct ip_vs_conn *cp)
         * so we can make the assumption that the svc_af is the same as the
         * dest_af
         */
-       dest = ip_vs_find_dest(ip_vs_conn_net(cp), cp->af, cp->af, &cp->daddr,
+       dest = ip_vs_find_dest(cp->ipvs, cp->af, cp->af, &cp->daddr,
                               cp->dport, &cp->vaddr, cp->vport,
                               cp->protocol, cp->fwmark, cp->flags);
        if (dest) {
@@ -668,7 +670,7 @@ void ip_vs_try_bind_dest(struct ip_vs_conn *cp)
 #endif
                        ip_vs_bind_xmit(cp);
 
-               pd = ip_vs_proto_data_get(ip_vs_conn_net(cp), cp->protocol);
+               pd = ip_vs_proto_data_get(cp->ipvs, cp->protocol);
                if (pd && atomic_read(&pd->appcnt))
                        ip_vs_bind_app(cp, pd->pp);
        }
@@ -746,7 +748,7 @@ static int expire_quiescent_template(struct netns_ipvs *ipvs,
 int ip_vs_check_template(struct ip_vs_conn *ct)
 {
        struct ip_vs_dest *dest = ct->dest;
-       struct netns_ipvs *ipvs = net_ipvs(ip_vs_conn_net(ct));
+       struct netns_ipvs *ipvs = ct->ipvs;
 
        /*
         * Checking the dest server status.
@@ -800,8 +802,7 @@ static void ip_vs_conn_rcu_free(struct rcu_head *head)
 static void ip_vs_conn_expire(unsigned long data)
 {
        struct ip_vs_conn *cp = (struct ip_vs_conn *)data;
-       struct net *net = ip_vs_conn_net(cp);
-       struct netns_ipvs *ipvs = net_ipvs(net);
+       struct netns_ipvs *ipvs = cp->ipvs;
 
        /*
         *      do I control anybody?
@@ -847,7 +848,7 @@ static void ip_vs_conn_expire(unsigned long data)
        cp->timeout = 60*HZ;
 
        if (ipvs->sync_state & IP_VS_STATE_MASTER)
-               ip_vs_sync_conn(net, cp, sysctl_sync_threshold(ipvs));
+               ip_vs_sync_conn(ipvs, cp, sysctl_sync_threshold(ipvs));
 
        ip_vs_conn_put(cp);
 }
@@ -875,8 +876,8 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p, int dest_af,
               struct ip_vs_dest *dest, __u32 fwmark)
 {
        struct ip_vs_conn *cp;
-       struct netns_ipvs *ipvs = net_ipvs(p->net);
-       struct ip_vs_proto_data *pd = ip_vs_proto_data_get(p->net,
+       struct netns_ipvs *ipvs = p->ipvs;
+       struct ip_vs_proto_data *pd = ip_vs_proto_data_get(p->ipvs,
                                                           p->protocol);
 
        cp = kmem_cache_alloc(ip_vs_conn_cachep, GFP_ATOMIC);
@@ -887,7 +888,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p, int dest_af,
 
        INIT_HLIST_NODE(&cp->c_list);
        setup_timer(&cp->timer, ip_vs_conn_expire, (unsigned long)cp);
-       ip_vs_conn_net_set(cp, p->net);
+       cp->ipvs           = ipvs;
        cp->af             = p->af;
        cp->daf            = dest_af;
        cp->protocol       = p->protocol;
@@ -1061,7 +1062,7 @@ static int ip_vs_conn_seq_show(struct seq_file *seq, void *v)
                size_t len = 0;
                char dbuf[IP_VS_ADDRSTRLEN];
 
-               if (!ip_vs_conn_net_eq(cp, net))
+               if (!net_eq(cp->ipvs->net, net))
                        return 0;
                if (cp->pe_data) {
                        pe_data[0] = ' ';
@@ -1146,7 +1147,7 @@ static int ip_vs_conn_sync_seq_show(struct seq_file *seq, void *v)
                const struct ip_vs_conn *cp = v;
                struct net *net = seq_file_net(seq);
 
-               if (!ip_vs_conn_net_eq(cp, net))
+               if (!net_eq(cp->ipvs->net, net))
                        return 0;
 
 #ifdef CONFIG_IP_VS_IPV6
@@ -1240,7 +1241,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
 }
 
 /* Called from keventd and must protect itself from softirqs */
-void ip_vs_random_dropentry(struct net *net)
+void ip_vs_random_dropentry(struct netns_ipvs *ipvs)
 {
        int idx;
        struct ip_vs_conn *cp, *cp_c;
@@ -1256,7 +1257,7 @@ void ip_vs_random_dropentry(struct net *net)
                        if (cp->flags & IP_VS_CONN_F_TEMPLATE)
                                /* connection template */
                                continue;
-                       if (!ip_vs_conn_net_eq(cp, net))
+                       if (cp->ipvs != ipvs)
                                continue;
                        if (cp->protocol == IPPROTO_TCP) {
                                switch(cp->state) {
@@ -1319,7 +1320,7 @@ flush_again:
        for (idx = 0; idx < ip_vs_conn_tab_size; idx++) {
 
                hlist_for_each_entry_rcu(cp, &ip_vs_conn_tab[idx], c_list) {
-                       if (!ip_vs_conn_net_eq(cp, net))
+                       if (cp->ipvs != ipvs)
                                continue;
                        IP_VS_DBG(4, "del connection\n");
                        ip_vs_conn_expire_now(cp);
This page took 0.043634 seconds and 5 git commands to generate.