Skip to content

Commit 318cf7a

Browse files
Eric Dumazetdavem330
authored andcommitted
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>
1 parent 8f9f466 commit 318cf7a

File tree

3 files changed

+22
-20
lines changed

3 files changed

+22
-20
lines changed

include/net/tcp.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,8 +1185,9 @@ struct tcp_md5sig_pool {
11851185

11861186
/* - functions */
11871187
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);
11901191
extern struct tcp_md5sig_key * tcp_v4_md5_lookup(struct sock *sk,
11911192
struct sock *addr_sk);
11921193
extern int tcp_v4_md5_do_add(struct sock *sk, __be32 addr, u8 *newkey,
@@ -1448,9 +1449,9 @@ struct tcp_sock_af_ops {
14481449
struct sock *addr_sk);
14491450
int (*calc_md5_hash) (char *location,
14501451
struct tcp_md5sig_key *md5,
1451-
struct sock *sk,
1452-
struct request_sock *req,
1453-
struct sk_buff *skb);
1452+
const struct sock *sk,
1453+
const struct request_sock *req,
1454+
const struct sk_buff *skb);
14541455
int (*md5_add) (struct sock *sk,
14551456
struct sock *addr_sk,
14561457
u8 *newkey,
@@ -1467,9 +1468,9 @@ struct tcp_request_sock_ops {
14671468
struct request_sock *req);
14681469
int (*calc_md5_hash) (char *location,
14691470
struct tcp_md5sig_key *md5,
1470-
struct sock *sk,
1471-
struct request_sock *req,
1472-
struct sk_buff *skb);
1471+
const struct sock *sk,
1472+
const struct request_sock *req,
1473+
const struct sk_buff *skb);
14731474
#endif
14741475
};
14751476

net/ipv4/tcp_ipv4.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ EXPORT_SYMBOL(sysctl_tcp_low_latency);
9292
static struct tcp_md5sig_key *tcp_v4_md5_do_lookup(struct sock *sk,
9393
__be32 addr);
9494
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);
9696
#else
9797
static inline
9898
struct tcp_md5sig_key *tcp_v4_md5_do_lookup(struct sock *sk, __be32 addr)
@@ -1090,7 +1090,7 @@ static int tcp_v4_md5_hash_pseudoheader(struct tcp_md5sig_pool *hp,
10901090
}
10911091

10921092
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)
10941094
{
10951095
struct tcp_md5sig_pool *hp;
10961096
struct hash_desc *desc;
@@ -1122,12 +1122,12 @@ static int tcp_v4_md5_hash_hdr(char *md5_hash, struct tcp_md5sig_key *key,
11221122
}
11231123

11241124
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)
11271127
{
11281128
struct tcp_md5sig_pool *hp;
11291129
struct hash_desc *desc;
1130-
struct tcphdr *th = tcp_hdr(skb);
1130+
const struct tcphdr *th = tcp_hdr(skb);
11311131
__be32 saddr, daddr;
11321132

11331133
if (sk) {
@@ -1172,7 +1172,7 @@ int tcp_v4_md5_hash_skb(char *md5_hash, struct tcp_md5sig_key *key,
11721172
}
11731173
EXPORT_SYMBOL(tcp_v4_md5_hash_skb);
11741174

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)
11761176
{
11771177
/*
11781178
* This gets called for each TCP segment that arrives

net/ipv6/tcp_ipv6.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ static int tcp_v6_md5_hash_pseudoheader(struct tcp_md5sig_pool *hp,
761761

762762
static int tcp_v6_md5_hash_hdr(char *md5_hash, struct tcp_md5sig_key *key,
763763
const struct in6_addr *daddr, struct in6_addr *saddr,
764-
struct tcphdr *th)
764+
const struct tcphdr *th)
765765
{
766766
struct tcp_md5sig_pool *hp;
767767
struct hash_desc *desc;
@@ -793,13 +793,14 @@ static int tcp_v6_md5_hash_hdr(char *md5_hash, struct tcp_md5sig_key *key,
793793
}
794794

795795
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)
798799
{
799800
const struct in6_addr *saddr, *daddr;
800801
struct tcp_md5sig_pool *hp;
801802
struct hash_desc *desc;
802-
struct tcphdr *th = tcp_hdr(skb);
803+
const struct tcphdr *th = tcp_hdr(skb);
803804

804805
if (sk) {
805806
saddr = &inet6_sk(sk)->saddr;
@@ -842,12 +843,12 @@ static int tcp_v6_md5_hash_skb(char *md5_hash, struct tcp_md5sig_key *key,
842843
return 1;
843844
}
844845

845-
static int tcp_v6_inbound_md5_hash (struct sock *sk, struct sk_buff *skb)
846+
static int tcp_v6_inbound_md5_hash(struct sock *sk, const struct sk_buff *skb)
846847
{
847848
const __u8 *hash_location = NULL;
848849
struct tcp_md5sig_key *hash_expected;
849850
const struct ipv6hdr *ip6h = ipv6_hdr(skb);
850-
struct tcphdr *th = tcp_hdr(skb);
851+
const struct tcphdr *th = tcp_hdr(skb);
851852
int genhash;
852853
u8 newhash[16];
853854

0 commit comments

Comments
 (0)