]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - net/ipv6/tcp_ipv6.c
Merge branch 'kconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
[karo-tx-linux.git] / net / ipv6 / tcp_ipv6.c
index 3c9fa618b69daae984931c171d4cb54b150c8166..36131d122a6f3f9007776ff343a9197bd0430b0a 100644 (file)
@@ -114,7 +114,7 @@ static __inline__ __sum16 tcp_v6_check(int len,
        return csum_ipv6_magic(saddr, daddr, len, IPPROTO_TCP, base);
 }
 
-static __u32 tcp_v6_init_sequence(struct sk_buff *skb)
+static __u32 tcp_v6_init_sequence(const struct sk_buff *skb)
 {
        return secure_tcpv6_sequence_number(ipv6_hdr(skb)->daddr.s6_addr32,
                                            ipv6_hdr(skb)->saddr.s6_addr32,
@@ -513,7 +513,7 @@ static int tcp_v6_send_synack(struct sock *sk, struct request_sock *req,
                __tcp_v6_send_check(skb, &treq->loc_addr, &treq->rmt_addr);
 
                ipv6_addr_copy(&fl6.daddr, &treq->rmt_addr);
-               err = ip6_xmit(sk, skb, &fl6, opt);
+               err = ip6_xmit(sk, skb, &fl6, opt, np->tclass);
                err = net_xmit_eval(err);
        }
 
@@ -591,7 +591,8 @@ static int tcp_v6_md5_do_add(struct sock *sk, const struct in6_addr *peer,
                        }
                        sk_nocaps_add(sk, NETIF_F_GSO_MASK);
                }
-               if (tcp_alloc_md5sig_pool(sk) == NULL) {
+               if (tp->md5sig_info->entries6 == 0 &&
+                       tcp_alloc_md5sig_pool(sk) == NULL) {
                        kfree(newkey);
                        return -ENOMEM;
                }
@@ -600,8 +601,9 @@ static int tcp_v6_md5_do_add(struct sock *sk, const struct in6_addr *peer,
                                       (tp->md5sig_info->entries6 + 1)), GFP_ATOMIC);
 
                        if (!keys) {
-                               tcp_free_md5sig_pool();
                                kfree(newkey);
+                               if (tp->md5sig_info->entries6 == 0)
+                                       tcp_free_md5sig_pool();
                                return -ENOMEM;
                        }
 
@@ -647,6 +649,7 @@ static int tcp_v6_md5_do_del(struct sock *sk, const struct in6_addr *peer)
                                kfree(tp->md5sig_info->keys6);
                                tp->md5sig_info->keys6 = NULL;
                                tp->md5sig_info->alloced6 = 0;
+                               tcp_free_md5sig_pool();
                        } else {
                                /* shrink the database */
                                if (tp->md5sig_info->entries6 != i)
@@ -655,7 +658,6 @@ static int tcp_v6_md5_do_del(struct sock *sk, const struct in6_addr *peer)
                                                (tp->md5sig_info->entries6 - i)
                                                * sizeof (tp->md5sig_info->keys6[0]));
                        }
-                       tcp_free_md5sig_pool();
                        return 0;
                }
        }
@@ -759,7 +761,7 @@ static int tcp_v6_md5_hash_pseudoheader(struct tcp_md5sig_pool *hp,
 
 static int tcp_v6_md5_hash_hdr(char *md5_hash, struct tcp_md5sig_key *key,
                               const struct in6_addr *daddr, struct in6_addr *saddr,
-                              struct tcphdr *th)
+                              const struct tcphdr *th)
 {
        struct tcp_md5sig_pool *hp;
        struct hash_desc *desc;
@@ -791,13 +793,14 @@ clear_hash_noput:
 }
 
 static int tcp_v6_md5_hash_skb(char *md5_hash, struct tcp_md5sig_key *key,
-                              struct sock *sk, struct request_sock *req,
-                              struct sk_buff *skb)
+                              const struct sock *sk,
+                              const struct request_sock *req,
+                              const struct sk_buff *skb)
 {
        const struct in6_addr *saddr, *daddr;
        struct tcp_md5sig_pool *hp;
        struct hash_desc *desc;
-       struct tcphdr *th = tcp_hdr(skb);
+       const struct tcphdr *th = tcp_hdr(skb);
 
        if (sk) {
                saddr = &inet6_sk(sk)->saddr;
@@ -840,12 +843,12 @@ clear_hash_noput:
        return 1;
 }
 
-static int tcp_v6_inbound_md5_hash (struct sock *sk, struct sk_buff *skb)
+static int tcp_v6_inbound_md5_hash(struct sock *sk, const struct sk_buff *skb)
 {
-       __u8 *hash_location = NULL;
+       const __u8 *hash_location = NULL;
        struct tcp_md5sig_key *hash_expected;
        const struct ipv6hdr *ip6h = ipv6_hdr(skb);
-       struct tcphdr *th = tcp_hdr(skb);
+       const struct tcphdr *th = tcp_hdr(skb);
        int genhash;
        u8 newhash[16];
 
@@ -976,9 +979,10 @@ static int tcp6_gro_complete(struct sk_buff *skb)
 }
 
 static void tcp_v6_send_response(struct sk_buff *skb, u32 seq, u32 ack, u32 win,
-                                u32 ts, struct tcp_md5sig_key *key, int rst)
+                                u32 ts, struct tcp_md5sig_key *key, int rst, u8 tclass)
 {
-       struct tcphdr *th = tcp_hdr(skb), *t1;
+       const struct tcphdr *th = tcp_hdr(skb);
+       struct tcphdr *t1;
        struct sk_buff *buff;
        struct flowi6 fl6;
        struct net *net = dev_net(skb_dst(skb)->dev);
@@ -1056,7 +1060,7 @@ static void tcp_v6_send_response(struct sk_buff *skb, u32 seq, u32 ack, u32 win,
        dst = ip6_dst_lookup_flow(ctl_sk, &fl6, NULL, false);
        if (!IS_ERR(dst)) {
                skb_dst_set(buff, dst);
-               ip6_xmit(ctl_sk, buff, &fl6, NULL);
+               ip6_xmit(ctl_sk, buff, &fl6, NULL, tclass);
                TCP_INC_STATS_BH(net, TCP_MIB_OUTSEGS);
                if (rst)
                        TCP_INC_STATS_BH(net, TCP_MIB_OUTRSTS);
@@ -1068,7 +1072,7 @@ static void tcp_v6_send_response(struct sk_buff *skb, u32 seq, u32 ack, u32 win,
 
 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb)
 {
-       struct tcphdr *th = tcp_hdr(skb);
+       const struct tcphdr *th = tcp_hdr(skb);
        u32 seq = 0, ack_seq = 0;
        struct tcp_md5sig_key *key = NULL;
 
@@ -1089,13 +1093,13 @@ static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb)
                ack_seq = ntohl(th->seq) + th->syn + th->fin + skb->len -
                          (th->doff << 2);
 
-       tcp_v6_send_response(skb, seq, ack_seq, 0, 0, key, 1);
+       tcp_v6_send_response(skb, seq, ack_seq, 0, 0, key, 1, 0);
 }
 
 static void tcp_v6_send_ack(struct sk_buff *skb, u32 seq, u32 ack, u32 win, u32 ts,
-                           struct tcp_md5sig_key *key)
+                           struct tcp_md5sig_key *key, u8 tclass)
 {
-       tcp_v6_send_response(skb, seq, ack, win, ts, key, 0);
+       tcp_v6_send_response(skb, seq, ack, win, ts, key, 0, tclass);
 }
 
 static void tcp_v6_timewait_ack(struct sock *sk, struct sk_buff *skb)
@@ -1105,7 +1109,8 @@ static void tcp_v6_timewait_ack(struct sock *sk, struct sk_buff *skb)
 
        tcp_v6_send_ack(skb, tcptw->tw_snd_nxt, tcptw->tw_rcv_nxt,
                        tcptw->tw_rcv_wnd >> tw->tw_rcv_wscale,
-                       tcptw->tw_ts_recent, tcp_twsk_md5_key(tcptw));
+                       tcptw->tw_ts_recent, tcp_twsk_md5_key(tcptw),
+                       tw->tw_tclass);
 
        inet_twsk_put(tw);
 }
@@ -1114,7 +1119,7 @@ static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
                                  struct request_sock *req)
 {
        tcp_v6_send_ack(skb, tcp_rsk(req)->snt_isn + 1, tcp_rsk(req)->rcv_isn + 1, req->rcv_wnd, req->ts_recent,
-                       tcp_v6_md5_do_lookup(sk, &ipv6_hdr(skb)->daddr));
+                       tcp_v6_md5_do_lookup(sk, &ipv6_hdr(skb)->daddr), 0);
 }
 
 
@@ -1158,7 +1163,7 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
 {
        struct tcp_extend_values tmp_ext;
        struct tcp_options_received tmp_opt;
-       u8 *hash_location;
+       const u8 *hash_location;
        struct request_sock *req;
        struct inet6_request_sock *treq;
        struct ipv6_pinfo *np = inet6_sk(sk);
@@ -1383,6 +1388,8 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
                newtp->af_specific = &tcp_sock_ipv6_mapped_specific;
 #endif
 
+               newnp->ipv6_ac_list = NULL;
+               newnp->ipv6_fl_list = NULL;
                newnp->pktoptions  = NULL;
                newnp->opt         = NULL;
                newnp->mcast_oif   = inet6_iif(skb);
@@ -1447,6 +1454,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
           First: no IPv4 options.
         */
        newinet->inet_opt = NULL;
+       newnp->ipv6_ac_list = NULL;
        newnp->ipv6_fl_list = NULL;
 
        /* Clone RX bits */
@@ -1603,7 +1611,7 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
                opt_skb = skb_clone(skb, GFP_ATOMIC);
 
        if (sk->sk_state == TCP_ESTABLISHED) { /* Fast path */
-               sock_rps_save_rxhash(sk, skb->rxhash);
+               sock_rps_save_rxhash(sk, skb);
                if (tcp_rcv_established(sk, skb, tcp_hdr(skb), skb->len))
                        goto reset;
                if (opt_skb)
@@ -1625,7 +1633,7 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
                 * the new socket..
                 */
                if(nsk != sk) {
-                       sock_rps_save_rxhash(nsk, skb->rxhash);
+                       sock_rps_save_rxhash(nsk, skb);
                        if (tcp_child_process(sk, nsk, skb))
                                goto reset;
                        if (opt_skb)
@@ -1633,7 +1641,7 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
                        return 0;
                }
        } else
-               sock_rps_save_rxhash(sk, skb->rxhash);
+               sock_rps_save_rxhash(sk, skb);
 
        if (tcp_rcv_state_process(sk, skb, tcp_hdr(skb), skb->len))
                goto reset;
@@ -1683,7 +1691,7 @@ ipv6_pktoptions:
 
 static int tcp_v6_rcv(struct sk_buff *skb)
 {
-       struct tcphdr *th;
+       const struct tcphdr *th;
        const struct ipv6hdr *hdr;
        struct sock *sk;
        int ret;
@@ -1717,7 +1725,7 @@ static int tcp_v6_rcv(struct sk_buff *skb)
                                    skb->len - th->doff*4);
        TCP_SKB_CB(skb)->ack_seq = ntohl(th->ack_seq);
        TCP_SKB_CB(skb)->when = 0;
-       TCP_SKB_CB(skb)->flags = ipv6_get_dsfield(hdr);
+       TCP_SKB_CB(skb)->ip_dsfield = ipv6_get_dsfield(hdr);
        TCP_SKB_CB(skb)->sacked = 0;
 
        sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
@@ -1851,8 +1859,8 @@ static struct inet_peer *tcp_v6_get_peer(struct sock *sk, bool *release_it)
 
 static void *tcp_v6_tw_get_peer(struct sock *sk)
 {
-       struct inet6_timewait_sock *tw6 = inet6_twsk(sk);
-       struct inet_timewait_sock *tw = inet_twsk(sk);
+       const struct inet6_timewait_sock *tw6 = inet6_twsk(sk);
+       const struct inet_timewait_sock *tw = inet_twsk(sk);
 
        if (tw->tw_family == AF_INET)
                return tcp_v4_tw_get_peer(sk);
@@ -2007,7 +2015,7 @@ static void tcp_v6_destroy_sock(struct sock *sk)
 #ifdef CONFIG_PROC_FS
 /* Proc filesystem TCPv6 sock list dumping. */
 static void get_openreq6(struct seq_file *seq,
-                        struct sock *sk, struct request_sock *req, int i, int uid)
+                        const struct sock *sk, struct request_sock *req, int i, int uid)
 {
        int ttd = req->expires - jiffies;
        const struct in6_addr *src = &inet6_rsk(req)->loc_addr;
@@ -2043,10 +2051,10 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
        __u16 destp, srcp;
        int timer_active;
        unsigned long timer_expires;
-       struct inet_sock *inet = inet_sk(sp);
-       struct tcp_sock *tp = tcp_sk(sp);
+       const struct inet_sock *inet = inet_sk(sp);
+       const struct tcp_sock *tp = tcp_sk(sp);
        const struct inet_connection_sock *icsk = inet_csk(sp);
-       struct ipv6_pinfo *np = inet6_sk(sp);
+       const struct ipv6_pinfo *np = inet6_sk(sp);
 
        dest  = &np->daddr;
        src   = &np->rcv_saddr;
@@ -2098,7 +2106,7 @@ static void get_timewait6_sock(struct seq_file *seq,
 {
        const struct in6_addr *dest, *src;
        __u16 destp, srcp;
-       struct inet6_timewait_sock *tw6 = inet6_twsk((struct sock *)tw);
+       const struct inet6_timewait_sock *tw6 = inet6_twsk((struct sock *)tw);
        int ttd = tw->tw_ttd - jiffies;
 
        if (ttd < 0)
@@ -2153,12 +2161,18 @@ out:
        return 0;
 }
 
+static const struct file_operations tcp6_afinfo_seq_fops = {
+       .owner   = THIS_MODULE,
+       .open    = tcp_seq_open,
+       .read    = seq_read,
+       .llseek  = seq_lseek,
+       .release = seq_release_net
+};
+
 static struct tcp_seq_afinfo tcp6_seq_afinfo = {
        .name           = "tcp6",
        .family         = AF_INET6,
-       .seq_fops       = {
-               .owner          = THIS_MODULE,
-       },
+       .seq_fops       = &tcp6_afinfo_seq_fops,
        .seq_ops        = {
                .show           = tcp6_seq_show,
        },