mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	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 <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
		
							parent
							
								
									4e3f5d727d
								
							
						
					
					
						commit
						b83e3deb97
					
				
					 3 changed files with 10 additions and 10 deletions
				
			
		| 
						 | 
					@ -1372,16 +1372,16 @@ int tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr,
 | 
				
			||||||
		   int family, const u8 *newkey, u8 newkeylen, gfp_t gfp);
 | 
							   int family, const u8 *newkey, u8 newkeylen, gfp_t gfp);
 | 
				
			||||||
int tcp_md5_do_del(struct sock *sk, const union tcp_md5_addr *addr,
 | 
					int tcp_md5_do_del(struct sock *sk, const union tcp_md5_addr *addr,
 | 
				
			||||||
		   int family);
 | 
							   int family);
 | 
				
			||||||
struct tcp_md5sig_key *tcp_v4_md5_lookup(struct sock *sk,
 | 
					struct tcp_md5sig_key *tcp_v4_md5_lookup(const struct sock *sk,
 | 
				
			||||||
					 const struct sock *addr_sk);
 | 
										 const struct sock *addr_sk);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CONFIG_TCP_MD5SIG
 | 
					#ifdef CONFIG_TCP_MD5SIG
 | 
				
			||||||
struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk,
 | 
					struct tcp_md5sig_key *tcp_md5_do_lookup(const struct sock *sk,
 | 
				
			||||||
					 const union tcp_md5_addr *addr,
 | 
										 const union tcp_md5_addr *addr,
 | 
				
			||||||
					 int family);
 | 
										 int family);
 | 
				
			||||||
#define tcp_twsk_md5_key(twsk)	((twsk)->tw_md5_key)
 | 
					#define tcp_twsk_md5_key(twsk)	((twsk)->tw_md5_key)
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
static inline struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk,
 | 
					static inline struct tcp_md5sig_key *tcp_md5_do_lookup(const struct sock *sk,
 | 
				
			||||||
					 const union tcp_md5_addr *addr,
 | 
										 const union tcp_md5_addr *addr,
 | 
				
			||||||
					 int family)
 | 
										 int family)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -1684,7 +1684,7 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops,
 | 
				
			||||||
/* TCP af-specific functions */
 | 
					/* TCP af-specific functions */
 | 
				
			||||||
struct tcp_sock_af_ops {
 | 
					struct tcp_sock_af_ops {
 | 
				
			||||||
#ifdef CONFIG_TCP_MD5SIG
 | 
					#ifdef CONFIG_TCP_MD5SIG
 | 
				
			||||||
	struct tcp_md5sig_key	*(*md5_lookup) (struct sock *sk,
 | 
						struct tcp_md5sig_key	*(*md5_lookup) (const struct sock *sk,
 | 
				
			||||||
						const struct sock *addr_sk);
 | 
											const struct sock *addr_sk);
 | 
				
			||||||
	int		(*calc_md5_hash)(char *location,
 | 
						int		(*calc_md5_hash)(char *location,
 | 
				
			||||||
					 const struct tcp_md5sig_key *md5,
 | 
										 const struct tcp_md5sig_key *md5,
 | 
				
			||||||
| 
						 | 
					@ -1699,7 +1699,7 @@ struct tcp_sock_af_ops {
 | 
				
			||||||
struct tcp_request_sock_ops {
 | 
					struct tcp_request_sock_ops {
 | 
				
			||||||
	u16 mss_clamp;
 | 
						u16 mss_clamp;
 | 
				
			||||||
#ifdef CONFIG_TCP_MD5SIG
 | 
					#ifdef CONFIG_TCP_MD5SIG
 | 
				
			||||||
	struct tcp_md5sig_key *(*req_md5_lookup)(struct sock *sk,
 | 
						struct tcp_md5sig_key *(*req_md5_lookup)(const struct sock *sk,
 | 
				
			||||||
						 const struct sock *addr_sk);
 | 
											 const struct sock *addr_sk);
 | 
				
			||||||
	int		(*calc_md5_hash) (char *location,
 | 
						int		(*calc_md5_hash) (char *location,
 | 
				
			||||||
					  const struct tcp_md5sig_key *md5,
 | 
										  const struct tcp_md5sig_key *md5,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -865,7 +865,7 @@ static void tcp_v4_reqsk_destructor(struct request_sock *req)
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Find the Key structure for an address.  */
 | 
					/* Find the Key structure for an address.  */
 | 
				
			||||||
struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk,
 | 
					struct tcp_md5sig_key *tcp_md5_do_lookup(const struct sock *sk,
 | 
				
			||||||
					 const union tcp_md5_addr *addr,
 | 
										 const union tcp_md5_addr *addr,
 | 
				
			||||||
					 int family)
 | 
										 int family)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -877,7 +877,7 @@ struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk,
 | 
				
			||||||
	/* caller either holds rcu_read_lock() or socket lock */
 | 
						/* caller either holds rcu_read_lock() or socket lock */
 | 
				
			||||||
	md5sig = rcu_dereference_check(tp->md5sig_info,
 | 
						md5sig = rcu_dereference_check(tp->md5sig_info,
 | 
				
			||||||
				       sock_owned_by_user(sk) ||
 | 
									       sock_owned_by_user(sk) ||
 | 
				
			||||||
				       lockdep_is_held(&sk->sk_lock.slock));
 | 
									       lockdep_is_held((spinlock_t *)&sk->sk_lock.slock));
 | 
				
			||||||
	if (!md5sig)
 | 
						if (!md5sig)
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
#if IS_ENABLED(CONFIG_IPV6)
 | 
					#if IS_ENABLED(CONFIG_IPV6)
 | 
				
			||||||
| 
						 | 
					@ -894,7 +894,7 @@ struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
EXPORT_SYMBOL(tcp_md5_do_lookup);
 | 
					EXPORT_SYMBOL(tcp_md5_do_lookup);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct tcp_md5sig_key *tcp_v4_md5_lookup(struct sock *sk,
 | 
					struct tcp_md5sig_key *tcp_v4_md5_lookup(const struct sock *sk,
 | 
				
			||||||
					 const struct sock *addr_sk)
 | 
										 const struct sock *addr_sk)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	const union tcp_md5_addr *addr;
 | 
						const union tcp_md5_addr *addr;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -476,13 +476,13 @@ static void tcp_v6_reqsk_destructor(struct request_sock *req)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CONFIG_TCP_MD5SIG
 | 
					#ifdef CONFIG_TCP_MD5SIG
 | 
				
			||||||
static struct tcp_md5sig_key *tcp_v6_md5_do_lookup(struct sock *sk,
 | 
					static struct tcp_md5sig_key *tcp_v6_md5_do_lookup(const struct sock *sk,
 | 
				
			||||||
						   const struct in6_addr *addr)
 | 
											   const struct in6_addr *addr)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return tcp_md5_do_lookup(sk, (union tcp_md5_addr *)addr, AF_INET6);
 | 
						return tcp_md5_do_lookup(sk, (union tcp_md5_addr *)addr, AF_INET6);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static struct tcp_md5sig_key *tcp_v6_md5_lookup(struct sock *sk,
 | 
					static struct tcp_md5sig_key *tcp_v6_md5_lookup(const struct sock *sk,
 | 
				
			||||||
						const struct sock *addr_sk)
 | 
											const struct sock *addr_sk)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return tcp_v6_md5_do_lookup(sk, &addr_sk->sk_v6_daddr);
 | 
						return tcp_v6_md5_do_lookup(sk, &addr_sk->sk_v6_daddr);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue