aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/tcp_ipv6.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv6/tcp_ipv6.c')
-rw-r--r--net/ipv6/tcp_ipv6.c77
1 files changed, 43 insertions, 34 deletions
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 7b8fc5794352..36131d122a6f 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -114,7 +114,7 @@ static __inline__ __sum16 tcp_v6_check(int len,
114 return csum_ipv6_magic(saddr, daddr, len, IPPROTO_TCP, base); 114 return csum_ipv6_magic(saddr, daddr, len, IPPROTO_TCP, base);
115} 115}
116 116
117static __u32 tcp_v6_init_sequence(struct sk_buff *skb) 117static __u32 tcp_v6_init_sequence(const struct sk_buff *skb)
118{ 118{
119 return secure_tcpv6_sequence_number(ipv6_hdr(skb)->daddr.s6_addr32, 119 return secure_tcpv6_sequence_number(ipv6_hdr(skb)->daddr.s6_addr32,
120 ipv6_hdr(skb)->saddr.s6_addr32, 120 ipv6_hdr(skb)->saddr.s6_addr32,
@@ -513,7 +513,7 @@ static int tcp_v6_send_synack(struct sock *sk, struct request_sock *req,
513 __tcp_v6_send_check(skb, &treq->loc_addr, &treq->rmt_addr); 513 __tcp_v6_send_check(skb, &treq->loc_addr, &treq->rmt_addr);
514 514
515 ipv6_addr_copy(&fl6.daddr, &treq->rmt_addr); 515 ipv6_addr_copy(&fl6.daddr, &treq->rmt_addr);
516 err = ip6_xmit(sk, skb, &fl6, opt); 516 err = ip6_xmit(sk, skb, &fl6, opt, np->tclass);
517 err = net_xmit_eval(err); 517 err = net_xmit_eval(err);
518 } 518 }
519 519
@@ -761,7 +761,7 @@ static int tcp_v6_md5_hash_pseudoheader(struct tcp_md5sig_pool *hp,
761 761
762static int tcp_v6_md5_hash_hdr(char *md5_hash, struct tcp_md5sig_key *key, 762static int tcp_v6_md5_hash_hdr(char *md5_hash, struct tcp_md5sig_key *key,
763 const struct in6_addr *daddr, struct in6_addr *saddr, 763 const struct in6_addr *daddr, struct in6_addr *saddr,
764 struct tcphdr *th) 764 const struct tcphdr *th)
765{ 765{
766 struct tcp_md5sig_pool *hp; 766 struct tcp_md5sig_pool *hp;
767 struct hash_desc *desc; 767 struct hash_desc *desc;
@@ -793,13 +793,14 @@ clear_hash_noput:
793} 793}
794 794
795static int tcp_v6_md5_hash_skb(char *md5_hash, struct tcp_md5sig_key *key, 795static int tcp_v6_md5_hash_skb(char *md5_hash, struct tcp_md5sig_key *key,
796 struct sock *sk, struct request_sock *req, 796 const struct sock *sk,
797 struct sk_buff *skb) 797 const struct request_sock *req,
798 const struct sk_buff *skb)
798{ 799{
799 const struct in6_addr *saddr, *daddr; 800 const struct in6_addr *saddr, *daddr;
800 struct tcp_md5sig_pool *hp; 801 struct tcp_md5sig_pool *hp;
801 struct hash_desc *desc; 802 struct hash_desc *desc;
802 struct tcphdr *th = tcp_hdr(skb); 803 const struct tcphdr *th = tcp_hdr(skb);
803 804
804 if (sk) { 805 if (sk) {
805 saddr = &inet6_sk(sk)->saddr; 806 saddr = &inet6_sk(sk)->saddr;
@@ -842,12 +843,12 @@ clear_hash_noput:
842 return 1; 843 return 1;
843} 844}
844 845
845static int tcp_v6_inbound_md5_hash (struct sock *sk, struct sk_buff *skb) 846static int tcp_v6_inbound_md5_hash(struct sock *sk, const struct sk_buff *skb)
846{ 847{
847 __u8 *hash_location = NULL; 848 const __u8 *hash_location = NULL;
848 struct tcp_md5sig_key *hash_expected; 849 struct tcp_md5sig_key *hash_expected;
849 const struct ipv6hdr *ip6h = ipv6_hdr(skb); 850 const struct ipv6hdr *ip6h = ipv6_hdr(skb);
850 struct tcphdr *th = tcp_hdr(skb); 851 const struct tcphdr *th = tcp_hdr(skb);
851 int genhash; 852 int genhash;
852 u8 newhash[16]; 853 u8 newhash[16];
853 854
@@ -978,9 +979,10 @@ static int tcp6_gro_complete(struct sk_buff *skb)
978} 979}
979 980
980static void tcp_v6_send_response(struct sk_buff *skb, u32 seq, u32 ack, u32 win, 981static void tcp_v6_send_response(struct sk_buff *skb, u32 seq, u32 ack, u32 win,
981 u32 ts, struct tcp_md5sig_key *key, int rst) 982 u32 ts, struct tcp_md5sig_key *key, int rst, u8 tclass)
982{ 983{
983 struct tcphdr *th = tcp_hdr(skb), *t1; 984 const struct tcphdr *th = tcp_hdr(skb);
985 struct tcphdr *t1;
984 struct sk_buff *buff; 986 struct sk_buff *buff;
985 struct flowi6 fl6; 987 struct flowi6 fl6;
986 struct net *net = dev_net(skb_dst(skb)->dev); 988 struct net *net = dev_net(skb_dst(skb)->dev);
@@ -1058,7 +1060,7 @@ static void tcp_v6_send_response(struct sk_buff *skb, u32 seq, u32 ack, u32 win,
1058 dst = ip6_dst_lookup_flow(ctl_sk, &fl6, NULL, false); 1060 dst = ip6_dst_lookup_flow(ctl_sk, &fl6, NULL, false);
1059 if (!IS_ERR(dst)) { 1061 if (!IS_ERR(dst)) {
1060 skb_dst_set(buff, dst); 1062 skb_dst_set(buff, dst);
1061 ip6_xmit(ctl_sk, buff, &fl6, NULL); 1063 ip6_xmit(ctl_sk, buff, &fl6, NULL, tclass);
1062 TCP_INC_STATS_BH(net, TCP_MIB_OUTSEGS); 1064 TCP_INC_STATS_BH(net, TCP_MIB_OUTSEGS);
1063 if (rst) 1065 if (rst)
1064 TCP_INC_STATS_BH(net, TCP_MIB_OUTRSTS); 1066 TCP_INC_STATS_BH(net, TCP_MIB_OUTRSTS);
@@ -1070,7 +1072,7 @@ static void tcp_v6_send_response(struct sk_buff *skb, u32 seq, u32 ack, u32 win,
1070 1072
1071static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb) 1073static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb)
1072{ 1074{
1073 struct tcphdr *th = tcp_hdr(skb); 1075 const struct tcphdr *th = tcp_hdr(skb);
1074 u32 seq = 0, ack_seq = 0; 1076 u32 seq = 0, ack_seq = 0;
1075 struct tcp_md5sig_key *key = NULL; 1077 struct tcp_md5sig_key *key = NULL;
1076 1078
@@ -1091,13 +1093,13 @@ static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb)
1091 ack_seq = ntohl(th->seq) + th->syn + th->fin + skb->len - 1093 ack_seq = ntohl(th->seq) + th->syn + th->fin + skb->len -
1092 (th->doff << 2); 1094 (th->doff << 2);
1093 1095
1094 tcp_v6_send_response(skb, seq, ack_seq, 0, 0, key, 1); 1096 tcp_v6_send_response(skb, seq, ack_seq, 0, 0, key, 1, 0);
1095} 1097}
1096 1098
1097static void tcp_v6_send_ack(struct sk_buff *skb, u32 seq, u32 ack, u32 win, u32 ts, 1099static void tcp_v6_send_ack(struct sk_buff *skb, u32 seq, u32 ack, u32 win, u32 ts,
1098 struct tcp_md5sig_key *key) 1100 struct tcp_md5sig_key *key, u8 tclass)
1099{ 1101{
1100 tcp_v6_send_response(skb, seq, ack, win, ts, key, 0); 1102 tcp_v6_send_response(skb, seq, ack, win, ts, key, 0, tclass);
1101} 1103}
1102 1104
1103static void tcp_v6_timewait_ack(struct sock *sk, struct sk_buff *skb) 1105static void tcp_v6_timewait_ack(struct sock *sk, struct sk_buff *skb)
@@ -1107,7 +1109,8 @@ static void tcp_v6_timewait_ack(struct sock *sk, struct sk_buff *skb)
1107 1109
1108 tcp_v6_send_ack(skb, tcptw->tw_snd_nxt, tcptw->tw_rcv_nxt, 1110 tcp_v6_send_ack(skb, tcptw->tw_snd_nxt, tcptw->tw_rcv_nxt,
1109 tcptw->tw_rcv_wnd >> tw->tw_rcv_wscale, 1111 tcptw->tw_rcv_wnd >> tw->tw_rcv_wscale,
1110 tcptw->tw_ts_recent, tcp_twsk_md5_key(tcptw)); 1112 tcptw->tw_ts_recent, tcp_twsk_md5_key(tcptw),
1113 tw->tw_tclass);
1111 1114
1112 inet_twsk_put(tw); 1115 inet_twsk_put(tw);
1113} 1116}
@@ -1116,7 +1119,7 @@ static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
1116 struct request_sock *req) 1119 struct request_sock *req)
1117{ 1120{
1118 tcp_v6_send_ack(skb, tcp_rsk(req)->snt_isn + 1, tcp_rsk(req)->rcv_isn + 1, req->rcv_wnd, req->ts_recent, 1121 tcp_v6_send_ack(skb, tcp_rsk(req)->snt_isn + 1, tcp_rsk(req)->rcv_isn + 1, req->rcv_wnd, req->ts_recent,
1119 tcp_v6_md5_do_lookup(sk, &ipv6_hdr(skb)->daddr)); 1122 tcp_v6_md5_do_lookup(sk, &ipv6_hdr(skb)->daddr), 0);
1120} 1123}
1121 1124
1122 1125
@@ -1160,7 +1163,7 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
1160{ 1163{
1161 struct tcp_extend_values tmp_ext; 1164 struct tcp_extend_values tmp_ext;
1162 struct tcp_options_received tmp_opt; 1165 struct tcp_options_received tmp_opt;
1163 u8 *hash_location; 1166 const u8 *hash_location;
1164 struct request_sock *req; 1167 struct request_sock *req;
1165 struct inet6_request_sock *treq; 1168 struct inet6_request_sock *treq;
1166 struct ipv6_pinfo *np = inet6_sk(sk); 1169 struct ipv6_pinfo *np = inet6_sk(sk);
@@ -1608,7 +1611,7 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
1608 opt_skb = skb_clone(skb, GFP_ATOMIC); 1611 opt_skb = skb_clone(skb, GFP_ATOMIC);
1609 1612
1610 if (sk->sk_state == TCP_ESTABLISHED) { /* Fast path */ 1613 if (sk->sk_state == TCP_ESTABLISHED) { /* Fast path */
1611 sock_rps_save_rxhash(sk, skb->rxhash); 1614 sock_rps_save_rxhash(sk, skb);
1612 if (tcp_rcv_established(sk, skb, tcp_hdr(skb), skb->len)) 1615 if (tcp_rcv_established(sk, skb, tcp_hdr(skb), skb->len))
1613 goto reset; 1616 goto reset;
1614 if (opt_skb) 1617 if (opt_skb)
@@ -1630,7 +1633,7 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
1630 * the new socket.. 1633 * the new socket..
1631 */ 1634 */
1632 if(nsk != sk) { 1635 if(nsk != sk) {
1633 sock_rps_save_rxhash(nsk, skb->rxhash); 1636 sock_rps_save_rxhash(nsk, skb);
1634 if (tcp_child_process(sk, nsk, skb)) 1637 if (tcp_child_process(sk, nsk, skb))
1635 goto reset; 1638 goto reset;
1636 if (opt_skb) 1639 if (opt_skb)
@@ -1638,7 +1641,7 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
1638 return 0; 1641 return 0;
1639 } 1642 }
1640 } else 1643 } else
1641 sock_rps_save_rxhash(sk, skb->rxhash); 1644 sock_rps_save_rxhash(sk, skb);
1642 1645
1643 if (tcp_rcv_state_process(sk, skb, tcp_hdr(skb), skb->len)) 1646 if (tcp_rcv_state_process(sk, skb, tcp_hdr(skb), skb->len))
1644 goto reset; 1647 goto reset;
@@ -1688,7 +1691,7 @@ ipv6_pktoptions:
1688 1691
1689static int tcp_v6_rcv(struct sk_buff *skb) 1692static int tcp_v6_rcv(struct sk_buff *skb)
1690{ 1693{
1691 struct tcphdr *th; 1694 const struct tcphdr *th;
1692 const struct ipv6hdr *hdr; 1695 const struct ipv6hdr *hdr;
1693 struct sock *sk; 1696 struct sock *sk;
1694 int ret; 1697 int ret;
@@ -1722,7 +1725,7 @@ static int tcp_v6_rcv(struct sk_buff *skb)
1722 skb->len - th->doff*4); 1725 skb->len - th->doff*4);
1723 TCP_SKB_CB(skb)->ack_seq = ntohl(th->ack_seq); 1726 TCP_SKB_CB(skb)->ack_seq = ntohl(th->ack_seq);
1724 TCP_SKB_CB(skb)->when = 0; 1727 TCP_SKB_CB(skb)->when = 0;
1725 TCP_SKB_CB(skb)->flags = ipv6_get_dsfield(hdr); 1728 TCP_SKB_CB(skb)->ip_dsfield = ipv6_get_dsfield(hdr);
1726 TCP_SKB_CB(skb)->sacked = 0; 1729 TCP_SKB_CB(skb)->sacked = 0;
1727 1730
1728 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest); 1731 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
@@ -1856,8 +1859,8 @@ static struct inet_peer *tcp_v6_get_peer(struct sock *sk, bool *release_it)
1856 1859
1857static void *tcp_v6_tw_get_peer(struct sock *sk) 1860static void *tcp_v6_tw_get_peer(struct sock *sk)
1858{ 1861{
1859 struct inet6_timewait_sock *tw6 = inet6_twsk(sk); 1862 const struct inet6_timewait_sock *tw6 = inet6_twsk(sk);
1860 struct inet_timewait_sock *tw = inet_twsk(sk); 1863 const struct inet_timewait_sock *tw = inet_twsk(sk);
1861 1864
1862 if (tw->tw_family == AF_INET) 1865 if (tw->tw_family == AF_INET)
1863 return tcp_v4_tw_get_peer(sk); 1866 return tcp_v4_tw_get_peer(sk);
@@ -2012,7 +2015,7 @@ static void tcp_v6_destroy_sock(struct sock *sk)
2012#ifdef CONFIG_PROC_FS 2015#ifdef CONFIG_PROC_FS
2013/* Proc filesystem TCPv6 sock list dumping. */ 2016/* Proc filesystem TCPv6 sock list dumping. */
2014static void get_openreq6(struct seq_file *seq, 2017static void get_openreq6(struct seq_file *seq,
2015 struct sock *sk, struct request_sock *req, int i, int uid) 2018 const struct sock *sk, struct request_sock *req, int i, int uid)
2016{ 2019{
2017 int ttd = req->expires - jiffies; 2020 int ttd = req->expires - jiffies;
2018 const struct in6_addr *src = &inet6_rsk(req)->loc_addr; 2021 const struct in6_addr *src = &inet6_rsk(req)->loc_addr;
@@ -2048,10 +2051,10 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
2048 __u16 destp, srcp; 2051 __u16 destp, srcp;
2049 int timer_active; 2052 int timer_active;
2050 unsigned long timer_expires; 2053 unsigned long timer_expires;
2051 struct inet_sock *inet = inet_sk(sp); 2054 const struct inet_sock *inet = inet_sk(sp);
2052 struct tcp_sock *tp = tcp_sk(sp); 2055 const struct tcp_sock *tp = tcp_sk(sp);
2053 const struct inet_connection_sock *icsk = inet_csk(sp); 2056 const struct inet_connection_sock *icsk = inet_csk(sp);
2054 struct ipv6_pinfo *np = inet6_sk(sp); 2057 const struct ipv6_pinfo *np = inet6_sk(sp);
2055 2058
2056 dest = &np->daddr; 2059 dest = &np->daddr;
2057 src = &np->rcv_saddr; 2060 src = &np->rcv_saddr;
@@ -2103,7 +2106,7 @@ static void get_timewait6_sock(struct seq_file *seq,
2103{ 2106{
2104 const struct in6_addr *dest, *src; 2107 const struct in6_addr *dest, *src;
2105 __u16 destp, srcp; 2108 __u16 destp, srcp;
2106 struct inet6_timewait_sock *tw6 = inet6_twsk((struct sock *)tw); 2109 const struct inet6_timewait_sock *tw6 = inet6_twsk((struct sock *)tw);
2107 int ttd = tw->tw_ttd - jiffies; 2110 int ttd = tw->tw_ttd - jiffies;
2108 2111
2109 if (ttd < 0) 2112 if (ttd < 0)
@@ -2158,12 +2161,18 @@ out:
2158 return 0; 2161 return 0;
2159} 2162}
2160 2163
2164static const struct file_operations tcp6_afinfo_seq_fops = {
2165 .owner = THIS_MODULE,
2166 .open = tcp_seq_open,
2167 .read = seq_read,
2168 .llseek = seq_lseek,
2169 .release = seq_release_net
2170};
2171
2161static struct tcp_seq_afinfo tcp6_seq_afinfo = { 2172static struct tcp_seq_afinfo tcp6_seq_afinfo = {
2162 .name = "tcp6", 2173 .name = "tcp6",
2163 .family = AF_INET6, 2174 .family = AF_INET6,
2164 .seq_fops = { 2175 .seq_fops = &tcp6_afinfo_seq_fops,
2165 .owner = THIS_MODULE,
2166 },
2167 .seq_ops = { 2176 .seq_ops = {
2168 .show = tcp6_seq_show, 2177 .show = tcp6_seq_show,
2169 }, 2178 },