Skip to content

Commit b83e3de

Browse files
Eric Dumazetdavem330
authored andcommitted
tcp: md5: constify tcp_md5_do_lookup() socket argument
When TCP new listener is done, these functions will be called without socket lock being held. Make sure they don't change anything. Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4e3f5d7 commit b83e3de

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

include/net/tcp.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,16 +1372,16 @@ int tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr,
13721372
int family, const u8 *newkey, u8 newkeylen, gfp_t gfp);
13731373
int tcp_md5_do_del(struct sock *sk, const union tcp_md5_addr *addr,
13741374
int family);
1375-
struct tcp_md5sig_key *tcp_v4_md5_lookup(struct sock *sk,
1375+
struct tcp_md5sig_key *tcp_v4_md5_lookup(const struct sock *sk,
13761376
const struct sock *addr_sk);
13771377

13781378
#ifdef CONFIG_TCP_MD5SIG
1379-
struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk,
1379+
struct tcp_md5sig_key *tcp_md5_do_lookup(const struct sock *sk,
13801380
const union tcp_md5_addr *addr,
13811381
int family);
13821382
#define tcp_twsk_md5_key(twsk) ((twsk)->tw_md5_key)
13831383
#else
1384-
static inline struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk,
1384+
static inline struct tcp_md5sig_key *tcp_md5_do_lookup(const struct sock *sk,
13851385
const union tcp_md5_addr *addr,
13861386
int family)
13871387
{
@@ -1684,7 +1684,7 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops,
16841684
/* TCP af-specific functions */
16851685
struct tcp_sock_af_ops {
16861686
#ifdef CONFIG_TCP_MD5SIG
1687-
struct tcp_md5sig_key *(*md5_lookup) (struct sock *sk,
1687+
struct tcp_md5sig_key *(*md5_lookup) (const struct sock *sk,
16881688
const struct sock *addr_sk);
16891689
int (*calc_md5_hash)(char *location,
16901690
const struct tcp_md5sig_key *md5,
@@ -1699,7 +1699,7 @@ struct tcp_sock_af_ops {
16991699
struct tcp_request_sock_ops {
17001700
u16 mss_clamp;
17011701
#ifdef CONFIG_TCP_MD5SIG
1702-
struct tcp_md5sig_key *(*req_md5_lookup)(struct sock *sk,
1702+
struct tcp_md5sig_key *(*req_md5_lookup)(const struct sock *sk,
17031703
const struct sock *addr_sk);
17041704
int (*calc_md5_hash) (char *location,
17051705
const struct tcp_md5sig_key *md5,

net/ipv4/tcp_ipv4.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ static void tcp_v4_reqsk_destructor(struct request_sock *req)
865865
*/
866866

867867
/* Find the Key structure for an address. */
868-
struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk,
868+
struct tcp_md5sig_key *tcp_md5_do_lookup(const struct sock *sk,
869869
const union tcp_md5_addr *addr,
870870
int family)
871871
{
@@ -877,7 +877,7 @@ struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk,
877877
/* caller either holds rcu_read_lock() or socket lock */
878878
md5sig = rcu_dereference_check(tp->md5sig_info,
879879
sock_owned_by_user(sk) ||
880-
lockdep_is_held(&sk->sk_lock.slock));
880+
lockdep_is_held((spinlock_t *)&sk->sk_lock.slock));
881881
if (!md5sig)
882882
return NULL;
883883
#if IS_ENABLED(CONFIG_IPV6)
@@ -894,7 +894,7 @@ struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk,
894894
}
895895
EXPORT_SYMBOL(tcp_md5_do_lookup);
896896

897-
struct tcp_md5sig_key *tcp_v4_md5_lookup(struct sock *sk,
897+
struct tcp_md5sig_key *tcp_v4_md5_lookup(const struct sock *sk,
898898
const struct sock *addr_sk)
899899
{
900900
const union tcp_md5_addr *addr;

net/ipv6/tcp_ipv6.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,13 +476,13 @@ static void tcp_v6_reqsk_destructor(struct request_sock *req)
476476
}
477477

478478
#ifdef CONFIG_TCP_MD5SIG
479-
static struct tcp_md5sig_key *tcp_v6_md5_do_lookup(struct sock *sk,
479+
static struct tcp_md5sig_key *tcp_v6_md5_do_lookup(const struct sock *sk,
480480
const struct in6_addr *addr)
481481
{
482482
return tcp_md5_do_lookup(sk, (union tcp_md5_addr *)addr, AF_INET6);
483483
}
484484

485-
static struct tcp_md5sig_key *tcp_v6_md5_lookup(struct sock *sk,
485+
static struct tcp_md5sig_key *tcp_v6_md5_lookup(const struct sock *sk,
486486
const struct sock *addr_sk)
487487
{
488488
return tcp_v6_md5_do_lookup(sk, &addr_sk->sk_v6_daddr);

0 commit comments

Comments
 (0)