ipvs: Pass ipvs into .conn_schedule and ip_vs_try_to_schedule
authorEric W. Biederman <ebiederm@xmission.com>
Mon, 21 Sep 2015 18:02:43 +0000 (13:02 -0500)
committerSimon Horman <horms@verge.net.au>
Thu, 24 Sep 2015 00:34:41 +0000 (09:34 +0900)
This moves the hack "net_ipvs(skb_net(skb))" up one level where it
will be easier to remove.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Acked-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Simon Horman <horms@verge.net.au>
include/net/ip_vs.h
net/netfilter/ipvs/ip_vs_core.c
net/netfilter/ipvs/ip_vs_proto_ah_esp.c
net/netfilter/ipvs/ip_vs_proto_sctp.c
net/netfilter/ipvs/ip_vs_proto_tcp.c
net/netfilter/ipvs/ip_vs_proto_udp.c

index 5ad04be64895ea845b06b428ad9aff9d83493cbf..c68c2c8ae48a60db0358c9f0440213e2c47142ff 100644 (file)
@@ -487,7 +487,8 @@ struct ip_vs_protocol {
 
        void (*exit_netns)(struct netns_ipvs *ipvs, struct ip_vs_proto_data *pd);
 
-       int (*conn_schedule)(int af, struct sk_buff *skb,
+       int (*conn_schedule)(struct netns_ipvs *ipvs,
+                            int af, struct sk_buff *skb,
                             struct ip_vs_proto_data *pd,
                             int *verdict, struct ip_vs_conn **cpp,
                             struct ip_vs_iphdr *iph);
index 9b37fe30dcac8106717a45778bbbecf90bedc717..514596b7a3243316e5410f6bfd566ad6434ef271 100644 (file)
@@ -1360,7 +1360,8 @@ ip_vs_local_reply6(void *priv, struct sk_buff *skb,
 #endif
 
 static unsigned int
-ip_vs_try_to_schedule(int af, struct sk_buff *skb, struct ip_vs_proto_data *pd,
+ip_vs_try_to_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,
+                     struct ip_vs_proto_data *pd,
                      int *verdict, struct ip_vs_conn **cpp,
                      struct ip_vs_iphdr *iph)
 {
@@ -1372,7 +1373,7 @@ ip_vs_try_to_schedule(int af, struct sk_buff *skb, struct ip_vs_proto_data *pd,
                 */
 
                /* Schedule and create new connection entry into cpp */
-               if (!pp->conn_schedule(af, skb, pd, verdict, cpp, iph))
+               if (!pp->conn_schedule(ipvs, af, skb, pd, verdict, cpp, iph))
                        return 0;
        }
 
@@ -1500,7 +1501,7 @@ ip_vs_in_icmp(struct sk_buff *skb, int *related, unsigned int hooknum)
                if (!sysctl_schedule_icmp(ipvs))
                        return NF_ACCEPT;
 
-               if (!ip_vs_try_to_schedule(AF_INET, skb, pd, &v, &cp, &ciph))
+               if (!ip_vs_try_to_schedule(ipvs, AF_INET, skb, pd, &v, &cp, &ciph))
                        return v;
                new_cp = true;
        }
@@ -1658,7 +1659,7 @@ static int ip_vs_in_icmp_v6(struct sk_buff *skb, int *related,
                if (!sysctl_schedule_icmp(ipvs))
                        return NF_ACCEPT;
 
-               if (!ip_vs_try_to_schedule(AF_INET6, skb, pd, &v, &cp, &ciph))
+               if (!ip_vs_try_to_schedule(ipvs, AF_INET6, skb, pd, &v, &cp, &ciph))
                        return v;
 
                new_cp = true;
@@ -1799,7 +1800,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
        if (unlikely(!cp)) {
                int v;
 
-               if (!ip_vs_try_to_schedule(af, skb, pd, &v, &cp, &iph))
+               if (!ip_vs_try_to_schedule(ipvs, af, skb, pd, &v, &cp, &iph))
                        return v;
        }
 
index e924455de5c0ae654f4344b9459f866e101ceb4c..5320d39976e1ddc90b5d5f2d997b60226b4ea0d3 100644 (file)
@@ -104,7 +104,8 @@ ah_esp_conn_out_get(struct netns_ipvs *ipvs, int af, const struct sk_buff *skb,
 
 
 static int
-ah_esp_conn_schedule(int af, struct sk_buff *skb, struct ip_vs_proto_data *pd,
+ah_esp_conn_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,
+                    struct ip_vs_proto_data *pd,
                     int *verdict, struct ip_vs_conn **cpp,
                     struct ip_vs_iphdr *iph)
 {
index 3e9418ab276af245ef1ebfe0f36d59671c7bdf7d..010ddeec135f50950d2f9a356bc7211c351dde9a 100644 (file)
@@ -9,20 +9,16 @@
 #include <net/ip_vs.h>
 
 static int
-sctp_conn_schedule(int af, struct sk_buff *skb, struct ip_vs_proto_data *pd,
+sctp_conn_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,
+                  struct ip_vs_proto_data *pd,
                   int *verdict, struct ip_vs_conn **cpp,
                   struct ip_vs_iphdr *iph)
 {
-       struct net *net;
        struct ip_vs_service *svc;
-       struct netns_ipvs *ipvs;
        sctp_chunkhdr_t _schunkh, *sch;
        sctp_sctphdr_t *sh, _sctph;
        __be16 _ports[2], *ports = NULL;
 
-       net = skb_net(skb);
-       ipvs = net_ipvs(net);
-
        if (likely(!ip_vs_iph_icmp(iph))) {
                sh = skb_header_pointer(skb, iph->len, sizeof(_sctph), &_sctph);
                if (sh) {
index 93ba6b1fe9d166cdab3dadf20bf77453c3757e4a..c913c2d00caf3d0f494e9cc06aa472e972d1eb0f 100644 (file)
 #include <net/ip_vs.h>
 
 static int
-tcp_conn_schedule(int af, struct sk_buff *skb, struct ip_vs_proto_data *pd,
+tcp_conn_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,
+                 struct ip_vs_proto_data *pd,
                  int *verdict, struct ip_vs_conn **cpp,
                  struct ip_vs_iphdr *iph)
 {
-       struct net *net;
        struct ip_vs_service *svc;
        struct tcphdr _tcph, *th;
-       struct netns_ipvs *ipvs;
        __be16 _ports[2], *ports = NULL;
 
-       net = skb_net(skb);
-       ipvs = net_ipvs(net);
-
        /* In the event of icmp, we're only guaranteed to have the first 8
         * bytes of the transport header, so we only check the rest of the
         * TCP packet for non-ICMP packets
index 382dcc9cfe11bd94c3f31233f46cbb63423bfd14..e494e9a88c7fb4d089845727bbc63778d352de4f 100644 (file)
 #include <net/ip6_checksum.h>
 
 static int
-udp_conn_schedule(int af, struct sk_buff *skb, struct ip_vs_proto_data *pd,
+udp_conn_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,
+                 struct ip_vs_proto_data *pd,
                  int *verdict, struct ip_vs_conn **cpp,
                  struct ip_vs_iphdr *iph)
 {
-       struct net *net;
-       struct netns_ipvs *ipvs;
        struct ip_vs_service *svc;
        struct udphdr _udph, *uh;
        __be16 _ports[2], *ports = NULL;
@@ -54,8 +53,6 @@ udp_conn_schedule(int af, struct sk_buff *skb, struct ip_vs_proto_data *pd,
                return 0;
        }
 
-       net = skb_net(skb);
-       ipvs = net_ipvs(net);
        rcu_read_lock();
        if (likely(!ip_vs_iph_inverse(iph)))
                svc = ip_vs_service_find(ipvs, af, skb->mark, iph->protocol,
@@ -67,7 +64,7 @@ udp_conn_schedule(int af, struct sk_buff *skb, struct ip_vs_proto_data *pd,
        if (svc) {
                int ignored;
 
-               if (ip_vs_todrop(net_ipvs(net))) {
+               if (ip_vs_todrop(ipvs)) {
                        /*
                         * It seems that we are very loaded.
                         * We have to drop this packet :(