aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_ipv4.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/ipv4/tcp_ipv4.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/ipv4/tcp_ipv4.c')
-rw-r--r--net/ipv4/tcp_ipv4.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 48da7cc41e23..955c9255cd98 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -104,7 +104,7 @@ struct tcp_md5sig_key *tcp_v4_md5_do_lookup(struct sock *sk, __be32 addr)
104struct inet_hashinfo tcp_hashinfo; 104struct inet_hashinfo tcp_hashinfo;
105EXPORT_SYMBOL(tcp_hashinfo); 105EXPORT_SYMBOL(tcp_hashinfo);
106 106
107static inline __u32 tcp_v4_init_sequence(struct sk_buff *skb) 107static inline __u32 tcp_v4_init_sequence(const struct sk_buff *skb)
108{ 108{
109 return secure_tcp_sequence_number(ip_hdr(skb)->daddr, 109 return secure_tcp_sequence_number(ip_hdr(skb)->daddr,
110 ip_hdr(skb)->saddr, 110 ip_hdr(skb)->saddr,
@@ -552,7 +552,7 @@ static void __tcp_v4_send_check(struct sk_buff *skb,
552/* This routine computes an IPv4 TCP checksum. */ 552/* This routine computes an IPv4 TCP checksum. */
553void tcp_v4_send_check(struct sock *sk, struct sk_buff *skb) 553void tcp_v4_send_check(struct sock *sk, struct sk_buff *skb)
554{ 554{
555 struct inet_sock *inet = inet_sk(sk); 555 const struct inet_sock *inet = inet_sk(sk);
556 556
557 __tcp_v4_send_check(skb, inet->inet_saddr, inet->inet_daddr); 557 __tcp_v4_send_check(skb, inet->inet_saddr, inet->inet_daddr);
558} 558}
@@ -590,7 +590,7 @@ int tcp_v4_gso_send_check(struct sk_buff *skb)
590 590
591static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb) 591static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb)
592{ 592{
593 struct tcphdr *th = tcp_hdr(skb); 593 const struct tcphdr *th = tcp_hdr(skb);
594 struct { 594 struct {
595 struct tcphdr th; 595 struct tcphdr th;
596#ifdef CONFIG_TCP_MD5SIG 596#ifdef CONFIG_TCP_MD5SIG
@@ -668,7 +668,7 @@ static void tcp_v4_send_ack(struct sk_buff *skb, u32 seq, u32 ack,
668 struct tcp_md5sig_key *key, 668 struct tcp_md5sig_key *key,
669 int reply_flags) 669 int reply_flags)
670{ 670{
671 struct tcphdr *th = tcp_hdr(skb); 671 const struct tcphdr *th = tcp_hdr(skb);
672 struct { 672 struct {
673 struct tcphdr th; 673 struct tcphdr th;
674 __be32 opt[(TCPOLEN_TSTAMP_ALIGNED >> 2) 674 __be32 opt[(TCPOLEN_TSTAMP_ALIGNED >> 2)
@@ -1182,10 +1182,10 @@ static int tcp_v4_inbound_md5_hash(struct sock *sk, struct sk_buff *skb)
1182 * o MD5 hash and we're not expecting one. 1182 * o MD5 hash and we're not expecting one.
1183 * o MD5 hash and its wrong. 1183 * o MD5 hash and its wrong.
1184 */ 1184 */
1185 __u8 *hash_location = NULL; 1185 const __u8 *hash_location = NULL;
1186 struct tcp_md5sig_key *hash_expected; 1186 struct tcp_md5sig_key *hash_expected;
1187 const struct iphdr *iph = ip_hdr(skb); 1187 const struct iphdr *iph = ip_hdr(skb);
1188 struct tcphdr *th = tcp_hdr(skb); 1188 const struct tcphdr *th = tcp_hdr(skb);
1189 int genhash; 1189 int genhash;
1190 unsigned char newhash[16]; 1190 unsigned char newhash[16];
1191 1191
@@ -1248,7 +1248,7 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
1248{ 1248{
1249 struct tcp_extend_values tmp_ext; 1249 struct tcp_extend_values tmp_ext;
1250 struct tcp_options_received tmp_opt; 1250 struct tcp_options_received tmp_opt;
1251 u8 *hash_location; 1251 const u8 *hash_location;
1252 struct request_sock *req; 1252 struct request_sock *req;
1253 struct inet_request_sock *ireq; 1253 struct inet_request_sock *ireq;
1254 struct tcp_sock *tp = tcp_sk(sk); 1254 struct tcp_sock *tp = tcp_sk(sk);
@@ -1645,7 +1645,7 @@ EXPORT_SYMBOL(tcp_v4_do_rcv);
1645int tcp_v4_rcv(struct sk_buff *skb) 1645int tcp_v4_rcv(struct sk_buff *skb)
1646{ 1646{
1647 const struct iphdr *iph; 1647 const struct iphdr *iph;
1648 struct tcphdr *th; 1648 const struct tcphdr *th;
1649 struct sock *sk; 1649 struct sock *sk;
1650 int ret; 1650 int ret;
1651 struct net *net = dev_net(skb->dev); 1651 struct net *net = dev_net(skb->dev);
@@ -1809,7 +1809,7 @@ EXPORT_SYMBOL(tcp_v4_get_peer);
1809 1809
1810void *tcp_v4_tw_get_peer(struct sock *sk) 1810void *tcp_v4_tw_get_peer(struct sock *sk)
1811{ 1811{
1812 struct inet_timewait_sock *tw = inet_twsk(sk); 1812 const struct inet_timewait_sock *tw = inet_twsk(sk);
1813 1813
1814 return inet_getpeer_v4(tw->tw_daddr, 1); 1814 return inet_getpeer_v4(tw->tw_daddr, 1);
1815} 1815}
@@ -2381,7 +2381,7 @@ void tcp_proc_unregister(struct net *net, struct tcp_seq_afinfo *afinfo)
2381} 2381}
2382EXPORT_SYMBOL(tcp_proc_unregister); 2382EXPORT_SYMBOL(tcp_proc_unregister);
2383 2383
2384static void get_openreq4(struct sock *sk, struct request_sock *req, 2384static void get_openreq4(const struct sock *sk, const struct request_sock *req,
2385 struct seq_file *f, int i, int uid, int *len) 2385 struct seq_file *f, int i, int uid, int *len)
2386{ 2386{
2387 const struct inet_request_sock *ireq = inet_rsk(req); 2387 const struct inet_request_sock *ireq = inet_rsk(req);
@@ -2411,9 +2411,9 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i, int *len)
2411{ 2411{
2412 int timer_active; 2412 int timer_active;
2413 unsigned long timer_expires; 2413 unsigned long timer_expires;
2414 struct tcp_sock *tp = tcp_sk(sk); 2414 const struct tcp_sock *tp = tcp_sk(sk);
2415 const struct inet_connection_sock *icsk = inet_csk(sk); 2415 const struct inet_connection_sock *icsk = inet_csk(sk);
2416 struct inet_sock *inet = inet_sk(sk); 2416 const struct inet_sock *inet = inet_sk(sk);
2417 __be32 dest = inet->inet_daddr; 2417 __be32 dest = inet->inet_daddr;
2418 __be32 src = inet->inet_rcv_saddr; 2418 __be32 src = inet->inet_rcv_saddr;
2419 __u16 destp = ntohs(inet->inet_dport); 2419 __u16 destp = ntohs(inet->inet_dport);
@@ -2462,7 +2462,7 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i, int *len)
2462 len); 2462 len);
2463} 2463}
2464 2464
2465static void get_timewait4_sock(struct inet_timewait_sock *tw, 2465static void get_timewait4_sock(const struct inet_timewait_sock *tw,
2466 struct seq_file *f, int i, int *len) 2466 struct seq_file *f, int i, int *len)
2467{ 2467{
2468 __be32 dest, src; 2468 __be32 dest, src;