Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tcp: md5: add more const attributes

Now tcp_md5_hash_header() has a const tcphdr argument, we can add more
const attributes to callers.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Eric Dumazet and committed by
David S. Miller
318cf7aa 8f9f4668

+22 -20
+9 -8
include/net/tcp.h
··· 1185 1185 1186 1186 /* - functions */ 1187 1187 extern int tcp_v4_md5_hash_skb(char *md5_hash, struct tcp_md5sig_key *key, 1188 - struct sock *sk, struct request_sock *req, 1189 - struct sk_buff *skb); 1188 + const struct sock *sk, 1189 + const struct request_sock *req, 1190 + const struct sk_buff *skb); 1190 1191 extern struct tcp_md5sig_key * tcp_v4_md5_lookup(struct sock *sk, 1191 1192 struct sock *addr_sk); 1192 1193 extern int tcp_v4_md5_do_add(struct sock *sk, __be32 addr, u8 *newkey, ··· 1449 1448 struct sock *addr_sk); 1450 1449 int (*calc_md5_hash) (char *location, 1451 1450 struct tcp_md5sig_key *md5, 1452 - struct sock *sk, 1453 - struct request_sock *req, 1454 - struct sk_buff *skb); 1451 + const struct sock *sk, 1452 + const struct request_sock *req, 1453 + const struct sk_buff *skb); 1455 1454 int (*md5_add) (struct sock *sk, 1456 1455 struct sock *addr_sk, 1457 1456 u8 *newkey, ··· 1468 1467 struct request_sock *req); 1469 1468 int (*calc_md5_hash) (char *location, 1470 1469 struct tcp_md5sig_key *md5, 1471 - struct sock *sk, 1472 - struct request_sock *req, 1473 - struct sk_buff *skb); 1470 + const struct sock *sk, 1471 + const struct request_sock *req, 1472 + const struct sk_buff *skb); 1474 1473 #endif 1475 1474 }; 1476 1475
+6 -6
net/ipv4/tcp_ipv4.c
··· 92 92 static struct tcp_md5sig_key *tcp_v4_md5_do_lookup(struct sock *sk, 93 93 __be32 addr); 94 94 static int tcp_v4_md5_hash_hdr(char *md5_hash, struct tcp_md5sig_key *key, 95 - __be32 daddr, __be32 saddr, struct tcphdr *th); 95 + __be32 daddr, __be32 saddr, const struct tcphdr *th); 96 96 #else 97 97 static inline 98 98 struct tcp_md5sig_key *tcp_v4_md5_do_lookup(struct sock *sk, __be32 addr) ··· 1090 1090 } 1091 1091 1092 1092 static int tcp_v4_md5_hash_hdr(char *md5_hash, struct tcp_md5sig_key *key, 1093 - __be32 daddr, __be32 saddr, struct tcphdr *th) 1093 + __be32 daddr, __be32 saddr, const struct tcphdr *th) 1094 1094 { 1095 1095 struct tcp_md5sig_pool *hp; 1096 1096 struct hash_desc *desc; ··· 1122 1122 } 1123 1123 1124 1124 int tcp_v4_md5_hash_skb(char *md5_hash, struct tcp_md5sig_key *key, 1125 - struct sock *sk, struct request_sock *req, 1126 - struct sk_buff *skb) 1125 + const struct sock *sk, const struct request_sock *req, 1126 + const struct sk_buff *skb) 1127 1127 { 1128 1128 struct tcp_md5sig_pool *hp; 1129 1129 struct hash_desc *desc; 1130 - struct tcphdr *th = tcp_hdr(skb); 1130 + const struct tcphdr *th = tcp_hdr(skb); 1131 1131 __be32 saddr, daddr; 1132 1132 1133 1133 if (sk) { ··· 1172 1172 } 1173 1173 EXPORT_SYMBOL(tcp_v4_md5_hash_skb); 1174 1174 1175 - static int tcp_v4_inbound_md5_hash(struct sock *sk, struct sk_buff *skb) 1175 + static int tcp_v4_inbound_md5_hash(struct sock *sk, const struct sk_buff *skb) 1176 1176 { 1177 1177 /* 1178 1178 * This gets called for each TCP segment that arrives
+7 -6
net/ipv6/tcp_ipv6.c
··· 761 761 762 762 static int tcp_v6_md5_hash_hdr(char *md5_hash, struct tcp_md5sig_key *key, 763 763 const struct in6_addr *daddr, struct in6_addr *saddr, 764 - struct tcphdr *th) 764 + const struct tcphdr *th) 765 765 { 766 766 struct tcp_md5sig_pool *hp; 767 767 struct hash_desc *desc; ··· 793 793 } 794 794 795 795 static int tcp_v6_md5_hash_skb(char *md5_hash, struct tcp_md5sig_key *key, 796 - struct sock *sk, struct request_sock *req, 797 - struct sk_buff *skb) 796 + const struct sock *sk, 797 + const struct request_sock *req, 798 + const struct sk_buff *skb) 798 799 { 799 800 const struct in6_addr *saddr, *daddr; 800 801 struct tcp_md5sig_pool *hp; 801 802 struct hash_desc *desc; 802 - struct tcphdr *th = tcp_hdr(skb); 803 + const struct tcphdr *th = tcp_hdr(skb); 803 804 804 805 if (sk) { 805 806 saddr = &inet6_sk(sk)->saddr; ··· 843 842 return 1; 844 843 } 845 844 846 - static int tcp_v6_inbound_md5_hash (struct sock *sk, struct sk_buff *skb) 845 + static int tcp_v6_inbound_md5_hash(struct sock *sk, const struct sk_buff *skb) 847 846 { 848 847 const __u8 *hash_location = NULL; 849 848 struct tcp_md5sig_key *hash_expected; 850 849 const struct ipv6hdr *ip6h = ipv6_hdr(skb); 851 - struct tcphdr *th = tcp_hdr(skb); 850 + const struct tcphdr *th = tcp_hdr(skb); 852 851 int genhash; 853 852 u8 newhash[16]; 854 853