mac80211: correct typos in "unavailable upon resume" warning
[safe/jmp/linux-2.6] / net / ipv6 / syncookies.c
index 3a622e7..34d1f06 100644 (file)
@@ -74,12 +74,13 @@ static inline struct sock *get_cookie_sock(struct sock *sk, struct sk_buff *skb,
        return child;
 }
 
-static DEFINE_PER_CPU(__u32, cookie_scratch)[16 + 5 + SHA_WORKSPACE_WORDS];
+static DEFINE_PER_CPU(__u32 [16 + 5 + SHA_WORKSPACE_WORDS],
+                     ipv6_cookie_scratch);
 
 static u32 cookie_hash(struct in6_addr *saddr, struct in6_addr *daddr,
                       __be16 sport, __be16 dport, u32 count, int c)
 {
-       __u32 *tmp = __get_cpu_var(cookie_scratch);
+       __u32 *tmp = __get_cpu_var(ipv6_cookie_scratch);
 
        /*
         * we have 320 bits of information to hash, copy in the remaining
@@ -131,13 +132,13 @@ __u32 cookie_v6_init_sequence(struct sock *sk, struct sk_buff *skb, __u16 *mssp)
        int mssind;
        const __u16 mss = *mssp;
 
-       tcp_sk(sk)->last_synq_overflow = jiffies;
+       tcp_synq_overflow(sk);
 
        for (mssind = 0; mss > msstab[mssind + 1]; mssind++)
                ;
        *mssp = msstab[mssind] + 1;
 
-       NET_INC_STATS_BH(LINUX_MIB_SYNCOOKIESSENT);
+       NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESSENT);
 
        return secure_tcp_syn_cookie(&iph->saddr, &iph->daddr, th->source,
                                     th->dest, ntohl(th->seq),
@@ -158,6 +159,8 @@ static inline int cookie_check(struct sk_buff *skb, __u32 cookie)
 
 struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
 {
+       struct tcp_options_received tcp_opt;
+       u8 *hash_location;
        struct inet_request_sock *ireq;
        struct inet6_request_sock *ireq6;
        struct tcp_request_sock *treq;
@@ -174,13 +177,20 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
        if (!sysctl_tcp_syncookies || !th->ack)
                goto out;
 
-       if (time_after(jiffies, tp->last_synq_overflow + TCP_TIMEOUT_INIT) ||
+       if (tcp_synq_no_recent_overflow(sk) ||
                (mss = cookie_check(skb, cookie)) == 0) {
-               NET_INC_STATS_BH(LINUX_MIB_SYNCOOKIESFAILED);
+               NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESFAILED);
                goto out;
        }
 
-       NET_INC_STATS_BH(LINUX_MIB_SYNCOOKIESRECV);
+       NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESRECV);
+
+       /* check for timestamp cookie support */
+       memset(&tcp_opt, 0, sizeof(tcp_opt));
+       tcp_parse_options(skb, &tcp_opt, &hash_location, 0);
+
+       if (tcp_opt.saw_tstamp)
+               cookie_check_timestamp(&tcp_opt);
 
        ret = NULL;
        req = inet6_reqsk_alloc(&tcp6_request_sock_ops);
@@ -190,15 +200,13 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
        ireq = inet_rsk(req);
        ireq6 = inet6_rsk(req);
        treq = tcp_rsk(req);
-       ireq6->pktopts = NULL;
 
-       if (security_inet_conn_request(sk, skb, req)) {
-               reqsk_free(req);
-               goto out;
-       }
+       if (security_inet_conn_request(sk, skb, req))
+               goto out_free;
 
        req->mss = mss;
        ireq->rmt_port = th->source;
+       ireq->loc_port = th->dest;
        ipv6_addr_copy(&ireq6->rmt_addr, &ipv6_hdr(skb)->saddr);
        ipv6_addr_copy(&ireq6->loc_addr, &ipv6_hdr(skb)->daddr);
        if (ipv6_opt_accepted(sk, skb) ||
@@ -216,8 +224,13 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
 
        req->expires = 0UL;
        req->retrans = 0;
-       ireq->snd_wscale = ireq->rcv_wscale = ireq->tstamp_ok = 0;
-       ireq->wscale_ok = ireq->sack_ok = 0;
+       ireq->ecn_ok            = 0;
+       ireq->snd_wscale        = tcp_opt.snd_wscale;
+       ireq->rcv_wscale        = tcp_opt.rcv_wscale;
+       ireq->sack_ok           = tcp_opt.sack_ok;
+       ireq->wscale_ok         = tcp_opt.wscale_ok;
+       ireq->tstamp_ok         = tcp_opt.saw_tstamp;
+       req->ts_recent          = tcp_opt.saw_tstamp ? tcp_opt.rcv_tsval : 0;
        treq->rcv_isn = ntohl(th->seq) - 1;
        treq->snt_isn = cookie;
 
@@ -240,28 +253,32 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
                }
                ipv6_addr_copy(&fl.fl6_src, &ireq6->loc_addr);
                fl.oif = sk->sk_bound_dev_if;
+               fl.mark = sk->sk_mark;
                fl.fl_ip_dport = inet_rsk(req)->rmt_port;
-               fl.fl_ip_sport = inet_sk(sk)->sport;
+               fl.fl_ip_sport = inet_sk(sk)->inet_sport;
                security_req_classify_flow(req, &fl);
-               if (ip6_dst_lookup(sk, &dst, &fl)) {
-                       reqsk_free(req);
-                       goto out;
-               }
+               if (ip6_dst_lookup(sk, &dst, &fl))
+                       goto out_free;
+
                if (final_p)
                        ipv6_addr_copy(&fl.fl6_dst, final_p);
-               if ((xfrm_lookup(&dst, &fl, sk, 0)) < 0)
-                       goto out;
+               if ((xfrm_lookup(sock_net(sk), &dst, &fl, sk, 0)) < 0)
+                       goto out_free;
        }
 
-       req->window_clamp = dst_metric(dst, RTAX_WINDOW);
+       req->window_clamp = tp->window_clamp ? :dst_metric(dst, RTAX_WINDOW);
        tcp_select_initial_window(tcp_full_space(sk), req->mss,
                                  &req->rcv_wnd, &req->window_clamp,
-                                 0, &rcv_wscale);
+                                 ireq->wscale_ok, &rcv_wscale,
+                                 dst_metric(dst, RTAX_INITRWND));
 
        ireq->rcv_wscale = rcv_wscale;
 
        ret = get_cookie_sock(sk, skb, req, dst);
-
-out:   return ret;
+out:
+       return ret;
+out_free:
+       reqsk_free(req);
+       return NULL;
 }