aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp.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.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.c')
-rw-r--r--net/ipv4/tcp.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 132be081cd00..704adad8f07f 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -374,7 +374,7 @@ unsigned int tcp_poll(struct file *file, struct socket *sock, poll_table *wait)
374{ 374{
375 unsigned int mask; 375 unsigned int mask;
376 struct sock *sk = sock->sk; 376 struct sock *sk = sock->sk;
377 struct tcp_sock *tp = tcp_sk(sk); 377 const struct tcp_sock *tp = tcp_sk(sk);
378 378
379 sock_poll_wait(file, sk_sleep(sk), wait); 379 sock_poll_wait(file, sk_sleep(sk), wait);
380 if (sk->sk_state == TCP_LISTEN) 380 if (sk->sk_state == TCP_LISTEN)
@@ -528,7 +528,7 @@ static inline void tcp_mark_push(struct tcp_sock *tp, struct sk_buff *skb)
528 tp->pushed_seq = tp->write_seq; 528 tp->pushed_seq = tp->write_seq;
529} 529}
530 530
531static inline int forced_push(struct tcp_sock *tp) 531static inline int forced_push(const struct tcp_sock *tp)
532{ 532{
533 return after(tp->write_seq, tp->pushed_seq + (tp->max_window >> 1)); 533 return after(tp->write_seq, tp->pushed_seq + (tp->max_window >> 1));
534} 534}
@@ -891,9 +891,9 @@ EXPORT_SYMBOL(tcp_sendpage);
891#define TCP_PAGE(sk) (sk->sk_sndmsg_page) 891#define TCP_PAGE(sk) (sk->sk_sndmsg_page)
892#define TCP_OFF(sk) (sk->sk_sndmsg_off) 892#define TCP_OFF(sk) (sk->sk_sndmsg_off)
893 893
894static inline int select_size(struct sock *sk, int sg) 894static inline int select_size(const struct sock *sk, int sg)
895{ 895{
896 struct tcp_sock *tp = tcp_sk(sk); 896 const struct tcp_sock *tp = tcp_sk(sk);
897 int tmp = tp->mss_cache; 897 int tmp = tp->mss_cache;
898 898
899 if (sg) { 899 if (sg) {
@@ -2408,7 +2408,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
2408int tcp_setsockopt(struct sock *sk, int level, int optname, char __user *optval, 2408int tcp_setsockopt(struct sock *sk, int level, int optname, char __user *optval,
2409 unsigned int optlen) 2409 unsigned int optlen)
2410{ 2410{
2411 struct inet_connection_sock *icsk = inet_csk(sk); 2411 const struct inet_connection_sock *icsk = inet_csk(sk);
2412 2412
2413 if (level != SOL_TCP) 2413 if (level != SOL_TCP)
2414 return icsk->icsk_af_ops->setsockopt(sk, level, optname, 2414 return icsk->icsk_af_ops->setsockopt(sk, level, optname,
@@ -2430,9 +2430,9 @@ EXPORT_SYMBOL(compat_tcp_setsockopt);
2430#endif 2430#endif
2431 2431
2432/* Return information about state of tcp endpoint in API format. */ 2432/* Return information about state of tcp endpoint in API format. */
2433void tcp_get_info(struct sock *sk, struct tcp_info *info) 2433void tcp_get_info(const struct sock *sk, struct tcp_info *info)
2434{ 2434{
2435 struct tcp_sock *tp = tcp_sk(sk); 2435 const struct tcp_sock *tp = tcp_sk(sk);
2436 const struct inet_connection_sock *icsk = inet_csk(sk); 2436 const struct inet_connection_sock *icsk = inet_csk(sk);
2437 u32 now = tcp_time_stamp; 2437 u32 now = tcp_time_stamp;
2438 2438
@@ -3010,7 +3010,7 @@ int tcp_md5_hash_header(struct tcp_md5sig_pool *hp,
3010EXPORT_SYMBOL(tcp_md5_hash_header); 3010EXPORT_SYMBOL(tcp_md5_hash_header);
3011 3011
3012int tcp_md5_hash_skb_data(struct tcp_md5sig_pool *hp, 3012int tcp_md5_hash_skb_data(struct tcp_md5sig_pool *hp,
3013 struct sk_buff *skb, unsigned header_len) 3013 const struct sk_buff *skb, unsigned int header_len)
3014{ 3014{
3015 struct scatterlist sg; 3015 struct scatterlist sg;
3016 const struct tcphdr *tp = tcp_hdr(skb); 3016 const struct tcphdr *tp = tcp_hdr(skb);
@@ -3043,7 +3043,7 @@ int tcp_md5_hash_skb_data(struct tcp_md5sig_pool *hp,
3043} 3043}
3044EXPORT_SYMBOL(tcp_md5_hash_skb_data); 3044EXPORT_SYMBOL(tcp_md5_hash_skb_data);
3045 3045
3046int tcp_md5_hash_key(struct tcp_md5sig_pool *hp, struct tcp_md5sig_key *key) 3046int tcp_md5_hash_key(struct tcp_md5sig_pool *hp, const struct tcp_md5sig_key *key)
3047{ 3047{
3048 struct scatterlist sg; 3048 struct scatterlist sg;
3049 3049