]> Pileus Git - ~andy/linux/blobdiff - net/netfilter/ipvs/ip_vs_core.c
Merge branch 'linus' into release
[~andy/linux] / net / netfilter / ipvs / ip_vs_core.c
index 2d1f932add46566efbaa2f9ef5d2fd2ec8e18fc4..07accf6b2401a05aa89b4a543e89741781547ff6 100644 (file)
@@ -132,7 +132,7 @@ ip_vs_in_stats(struct ip_vs_conn *cp, struct sk_buff *skb)
                s->ustats.inbytes += skb->len;
                u64_stats_update_end(&s->syncp);
 
-               s = this_cpu_ptr(ipvs->cpustats);
+               s = this_cpu_ptr(ipvs->tot_stats.cpustats);
                s->ustats.inpkts++;
                u64_stats_update_begin(&s->syncp);
                s->ustats.inbytes += skb->len;
@@ -162,7 +162,7 @@ ip_vs_out_stats(struct ip_vs_conn *cp, struct sk_buff *skb)
                s->ustats.outbytes += skb->len;
                u64_stats_update_end(&s->syncp);
 
-               s = this_cpu_ptr(ipvs->cpustats);
+               s = this_cpu_ptr(ipvs->tot_stats.cpustats);
                s->ustats.outpkts++;
                u64_stats_update_begin(&s->syncp);
                s->ustats.outbytes += skb->len;
@@ -183,7 +183,7 @@ ip_vs_conn_stats(struct ip_vs_conn *cp, struct ip_vs_service *svc)
        s = this_cpu_ptr(svc->stats.cpustats);
        s->ustats.conns++;
 
-       s = this_cpu_ptr(ipvs->cpustats);
+       s = this_cpu_ptr(ipvs->tot_stats.cpustats);
        s->ustats.conns++;
 }
 
@@ -499,11 +499,13 @@ ip_vs_schedule(struct ip_vs_service *svc, struct sk_buff *skb,
 int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
                struct ip_vs_proto_data *pd)
 {
-       struct net *net;
-       struct netns_ipvs *ipvs;
        __be16 _ports[2], *pptr;
        struct ip_vs_iphdr iph;
+#ifdef CONFIG_SYSCTL
+       struct net *net;
+       struct netns_ipvs *ipvs;
        int unicast;
+#endif
 
        ip_vs_fill_iphdr(svc->af, skb_network_header(skb), &iph);
 
@@ -512,6 +514,8 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
                ip_vs_service_put(svc);
                return NF_DROP;
        }
+
+#ifdef CONFIG_SYSCTL
        net = skb_net(skb);
 
 #ifdef CONFIG_IP_VS_IPV6
@@ -563,6 +567,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
                ip_vs_conn_put(cp);
                return ret;
        }
+#endif
 
        /*
         * When the virtual ftp service is presented, packets destined
@@ -599,6 +604,33 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
        return NF_DROP;
 }
 
+#ifdef CONFIG_SYSCTL
+
+static int sysctl_snat_reroute(struct sk_buff *skb)
+{
+       struct netns_ipvs *ipvs = net_ipvs(skb_net(skb));
+       return ipvs->sysctl_snat_reroute;
+}
+
+static int sysctl_nat_icmp_send(struct net *net)
+{
+       struct netns_ipvs *ipvs = net_ipvs(net);
+       return ipvs->sysctl_nat_icmp_send;
+}
+
+static int sysctl_expire_nodest_conn(struct netns_ipvs *ipvs)
+{
+       return ipvs->sysctl_expire_nodest_conn;
+}
+
+#else
+
+static int sysctl_snat_reroute(struct sk_buff *skb) { return 0; }
+static int sysctl_nat_icmp_send(struct net *net) { return 0; }
+static int sysctl_expire_nodest_conn(struct netns_ipvs *ipvs) { return 0; }
+
+#endif
+
 __sum16 ip_vs_checksum_complete(struct sk_buff *skb, int offset)
 {
        return csum_fold(skb_checksum(skb, offset, skb->len - offset, 0));
@@ -631,6 +663,22 @@ static inline int ip_vs_gather_frags_v6(struct sk_buff *skb, u_int32_t user)
 }
 #endif
 
+static int ip_vs_route_me_harder(int af, struct sk_buff *skb)
+{
+#ifdef CONFIG_IP_VS_IPV6
+       if (af == AF_INET6) {
+               if (sysctl_snat_reroute(skb) && ip6_route_me_harder(skb) != 0)
+                       return 1;
+       } else
+#endif
+               if ((sysctl_snat_reroute(skb) ||
+                    skb_rtable(skb)->rt_flags & RTCF_LOCAL) &&
+                   ip_route_me_harder(skb, RTN_LOCAL) != 0)
+                       return 1;
+
+       return 0;
+}
+
 /*
  * Packet has been made sufficiently writable in caller
  * - inout: 1=in->out, 0=out->in
@@ -737,7 +785,6 @@ static int handle_response_icmp(int af, struct sk_buff *skb,
                                struct ip_vs_protocol *pp,
                                unsigned int offset, unsigned int ihl)
 {
-       struct netns_ipvs *ipvs;
        unsigned int verdict = NF_DROP;
 
        if (IP_VS_FWD_METHOD(cp) != 0) {
@@ -759,8 +806,6 @@ static int handle_response_icmp(int af, struct sk_buff *skb,
        if (!skb_make_writable(skb, offset))
                goto out;
 
-       ipvs = net_ipvs(skb_net(skb));
-
 #ifdef CONFIG_IP_VS_IPV6
        if (af == AF_INET6)
                ip_vs_nat_icmp_v6(skb, pp, cp, 1);
@@ -768,16 +813,8 @@ static int handle_response_icmp(int af, struct sk_buff *skb,
 #endif
                ip_vs_nat_icmp(skb, pp, cp, 1);
 
-#ifdef CONFIG_IP_VS_IPV6
-       if (af == AF_INET6) {
-               if (ipvs->sysctl_snat_reroute && ip6_route_me_harder(skb) != 0)
-                       goto out;
-       } else
-#endif
-               if ((ipvs->sysctl_snat_reroute ||
-                    skb_rtable(skb)->rt_flags & RTCF_LOCAL) &&
-                   ip_route_me_harder(skb, RTN_LOCAL) != 0)
-                       goto out;
+       if (ip_vs_route_me_harder(af, skb))
+               goto out;
 
        /* do the statistics and put it back */
        ip_vs_out_stats(cp, skb);
@@ -985,7 +1022,6 @@ handle_response(int af, struct sk_buff *skb, struct ip_vs_proto_data *pd,
                struct ip_vs_conn *cp, int ihl)
 {
        struct ip_vs_protocol *pp = pd->pp;
-       struct netns_ipvs *ipvs;
 
        IP_VS_DBG_PKT(11, af, pp, skb, 0, "Outgoing packet");
 
@@ -1021,18 +1057,8 @@ handle_response(int af, struct sk_buff *skb, struct ip_vs_proto_data *pd,
         * if it came from this machine itself.  So re-compute
         * the routing information.
         */
-       ipvs = net_ipvs(skb_net(skb));
-
-#ifdef CONFIG_IP_VS_IPV6
-       if (af == AF_INET6) {
-               if (ipvs->sysctl_snat_reroute && ip6_route_me_harder(skb) != 0)
-                       goto drop;
-       } else
-#endif
-               if ((ipvs->sysctl_snat_reroute ||
-                    skb_rtable(skb)->rt_flags & RTCF_LOCAL) &&
-                   ip_route_me_harder(skb, RTN_LOCAL) != 0)
-                       goto drop;
+       if (ip_vs_route_me_harder(af, skb))
+               goto drop;
 
        IP_VS_DBG_PKT(10, af, pp, skb, 0, "After SNAT");
 
@@ -1066,7 +1092,6 @@ ip_vs_out(unsigned int hooknum, struct sk_buff *skb, int af)
        struct ip_vs_protocol *pp;
        struct ip_vs_proto_data *pd;
        struct ip_vs_conn *cp;
-       struct netns_ipvs *ipvs;
 
        EnterFunction(11);
 
@@ -1141,11 +1166,10 @@ ip_vs_out(unsigned int hooknum, struct sk_buff *skb, int af)
         * Check if the packet belongs to an existing entry
         */
        cp = pp->conn_out_get(af, skb, &iph, iph.len, 0);
-       ipvs = net_ipvs(net);
 
        if (likely(cp))
                return handle_response(af, skb, pd, cp, iph.len);
-       if (ipvs->sysctl_nat_icmp_send &&
+       if (sysctl_nat_icmp_send(net) &&
            (pp->protocol == IPPROTO_TCP ||
             pp->protocol == IPPROTO_UDP ||
             pp->protocol == IPPROTO_SCTP)) {
@@ -1570,7 +1594,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
        if (cp->dest && !(cp->dest->flags & IP_VS_DEST_F_AVAILABLE)) {
                /* the destination server is not available */
 
-               if (ipvs->sysctl_expire_nodest_conn) {
+               if (sysctl_expire_nodest_conn(ipvs)) {
                        /* try to expire the connection immediately */
                        ip_vs_conn_expire_now(cp);
                }
@@ -1600,15 +1624,15 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
         */
 
        if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
-               pkts = ipvs->sysctl_sync_threshold[0];
+               pkts = sysctl_sync_threshold(ipvs);
        else
                pkts = atomic_add_return(1, &cp->in_pkts);
 
        if ((ipvs->sync_state & IP_VS_STATE_MASTER) &&
            cp->protocol == IPPROTO_SCTP) {
                if ((cp->state == IP_VS_SCTP_S_ESTABLISHED &&
-                       (pkts % ipvs->sysctl_sync_threshold[1]
-                        == ipvs->sysctl_sync_threshold[0])) ||
+                       (pkts % sysctl_sync_period(ipvs)
+                        == sysctl_sync_threshold(ipvs))) ||
                                (cp->old_state != cp->state &&
                                 ((cp->state == IP_VS_SCTP_S_CLOSED) ||
                                  (cp->state == IP_VS_SCTP_S_SHUT_ACK_CLI) ||
@@ -1622,8 +1646,8 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
        else if ((ipvs->sync_state & IP_VS_STATE_MASTER) &&
            (((cp->protocol != IPPROTO_TCP ||
               cp->state == IP_VS_TCP_S_ESTABLISHED) &&
-             (pkts % ipvs->sysctl_sync_threshold[1]
-              == ipvs->sysctl_sync_threshold[0])) ||
+             (pkts % sysctl_sync_period(ipvs)
+              == sysctl_sync_threshold(ipvs))) ||
             ((cp->protocol == IPPROTO_TCP) && (cp->old_state != cp->state) &&
              ((cp->state == IP_VS_TCP_S_FIN_WAIT) ||
               (cp->state == IP_VS_TCP_S_CLOSE) ||