aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/tcp_ipv6.c
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2011-10-21 05:22:42 -0400
committerDavid S. Miller <davem@davemloft.net>2011-10-21 05:22:42 -0400
commitcf533ea53ebfae41be15b103d78e7ebec30b9969 (patch)
tree51ed3c69f4a15117fefe5cbd291a75010beb0f4b /net/ipv6/tcp_ipv6.c
parentf04565ddf52e401880f8ba51de0dff8ba51c99fd (diff)
tcp: add const qualifiers where possible
Adding const qualifiers to pointers can ease code review, and spot some bugs. It might allow compiler to optimize code further. For example, is it legal to temporary write a null cksum into tcphdr in tcp_md5_hash_header() ? I am afraid a sniffer could catch the temporary null value... Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/tcp_ipv6.c')
-rw-r--r--net/ipv6/tcp_ipv6.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 5357902c7978..da2ada881cfa 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,
@@ -844,7 +844,7 @@ clear_hash_noput:
844 844
845static int tcp_v6_inbound_md5_hash (struct sock *sk, struct sk_buff *skb) 845static int tcp_v6_inbound_md5_hash (struct sock *sk, struct sk_buff *skb)
846{ 846{
847 __u8 *hash_location = NULL; 847 const __u8 *hash_location = NULL;
848 struct tcp_md5sig_key *hash_expected; 848 struct tcp_md5sig_key *hash_expected;
849 const struct ipv6hdr *ip6h = ipv6_hdr(skb); 849 const struct ipv6hdr *ip6h = ipv6_hdr(skb);
850 struct tcphdr *th = tcp_hdr(skb); 850 struct tcphdr *th = tcp_hdr(skb);
@@ -980,7 +980,8 @@ static int tcp6_gro_complete(struct sk_buff *skb)
980static void tcp_v6_send_response(struct sk_buff *skb, u32 seq, u32 ack, u32 win, 980static 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) 981 u32 ts, struct tcp_md5sig_key *key, int rst)
982{ 982{
983 struct tcphdr *th = tcp_hdr(skb), *t1; 983 const struct tcphdr *th = tcp_hdr(skb);
984 struct tcphdr *t1;
984 struct sk_buff *buff; 985 struct sk_buff *buff;
985 struct flowi6 fl6; 986 struct flowi6 fl6;
986 struct net *net = dev_net(skb_dst(skb)->dev); 987 struct net *net = dev_net(skb_dst(skb)->dev);
@@ -1070,7 +1071,7 @@ static void tcp_v6_send_response(struct sk_buff *skb, u32 seq, u32 ack, u32 win,
1070 1071
1071static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb) 1072static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb)
1072{ 1073{
1073 struct tcphdr *th = tcp_hdr(skb); 1074 const struct tcphdr *th = tcp_hdr(skb);
1074 u32 seq = 0, ack_seq = 0; 1075 u32 seq = 0, ack_seq = 0;
1075 struct tcp_md5sig_key *key = NULL; 1076 struct tcp_md5sig_key *key = NULL;
1076 1077
@@ -1160,7 +1161,7 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
1160{ 1161{
1161 struct tcp_extend_values tmp_ext; 1162 struct tcp_extend_values tmp_ext;
1162 struct tcp_options_received tmp_opt; 1163 struct tcp_options_received tmp_opt;
1163 u8 *hash_location; 1164 const u8 *hash_location;
1164 struct request_sock *req; 1165 struct request_sock *req;
1165 struct inet6_request_sock *treq; 1166 struct inet6_request_sock *treq;
1166 struct ipv6_pinfo *np = inet6_sk(sk); 1167 struct ipv6_pinfo *np = inet6_sk(sk);
@@ -1688,7 +1689,7 @@ ipv6_pktoptions:
1688 1689
1689static int tcp_v6_rcv(struct sk_buff *skb) 1690static int tcp_v6_rcv(struct sk_buff *skb)
1690{ 1691{
1691 struct tcphdr *th; 1692 const struct tcphdr *th;
1692 const struct ipv6hdr *hdr; 1693 const struct ipv6hdr *hdr;
1693 struct sock *sk; 1694 struct sock *sk;
1694 int ret; 1695 int ret;
@@ -1856,8 +1857,8 @@ static struct inet_peer *tcp_v6_get_peer(struct sock *sk, bool *release_it)
1856 1857
1857static void *tcp_v6_tw_get_peer(struct sock *sk) 1858static void *tcp_v6_tw_get_peer(struct sock *sk)
1858{ 1859{
1859 struct inet6_timewait_sock *tw6 = inet6_twsk(sk); 1860 const struct inet6_timewait_sock *tw6 = inet6_twsk(sk);
1860 struct inet_timewait_sock *tw = inet_twsk(sk); 1861 const struct inet_timewait_sock *tw = inet_twsk(sk);
1861 1862
1862 if (tw->tw_family == AF_INET) 1863 if (tw->tw_family == AF_INET)
1863 return tcp_v4_tw_get_peer(sk); 1864 return tcp_v4_tw_get_peer(sk);
@@ -2012,7 +2013,7 @@ static void tcp_v6_destroy_sock(struct sock *sk)
2012#ifdef CONFIG_PROC_FS 2013#ifdef CONFIG_PROC_FS
2013/* Proc filesystem TCPv6 sock list dumping. */ 2014/* Proc filesystem TCPv6 sock list dumping. */
2014static void get_openreq6(struct seq_file *seq, 2015static void get_openreq6(struct seq_file *seq,
2015 struct sock *sk, struct request_sock *req, int i, int uid) 2016 const struct sock *sk, struct request_sock *req, int i, int uid)
2016{ 2017{
2017 int ttd = req->expires - jiffies; 2018 int ttd = req->expires - jiffies;
2018 const struct in6_addr *src = &inet6_rsk(req)->loc_addr; 2019 const struct in6_addr *src = &inet6_rsk(req)->loc_addr;
@@ -2048,10 +2049,10 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
2048 __u16 destp, srcp; 2049 __u16 destp, srcp;
2049 int timer_active; 2050 int timer_active;
2050 unsigned long timer_expires; 2051 unsigned long timer_expires;
2051 struct inet_sock *inet = inet_sk(sp); 2052 const struct inet_sock *inet = inet_sk(sp);
2052 struct tcp_sock *tp = tcp_sk(sp); 2053 const struct tcp_sock *tp = tcp_sk(sp);
2053 const struct inet_connection_sock *icsk = inet_csk(sp); 2054 const struct inet_connection_sock *icsk = inet_csk(sp);
2054 struct ipv6_pinfo *np = inet6_sk(sp); 2055 const struct ipv6_pinfo *np = inet6_sk(sp);
2055 2056
2056 dest = &np->daddr; 2057 dest = &np->daddr;
2057 src = &np->rcv_saddr; 2058 src = &np->rcv_saddr;
@@ -2103,7 +2104,7 @@ static void get_timewait6_sock(struct seq_file *seq,
2103{ 2104{
2104 const struct in6_addr *dest, *src; 2105 const struct in6_addr *dest, *src;
2105 __u16 destp, srcp; 2106 __u16 destp, srcp;
2106 struct inet6_timewait_sock *tw6 = inet6_twsk((struct sock *)tw); 2107 const struct inet6_timewait_sock *tw6 = inet6_twsk((struct sock *)tw);
2107 int ttd = tw->tw_ttd - jiffies; 2108 int ttd = tw->tw_ttd - jiffies;
2108 2109
2109 if (ttd < 0) 2110 if (ttd < 0)