mirror of
https://github.com/torvalds/linux.git
synced 2024-11-21 19:41:42 +00:00
inet: preserve const qualifier in inet_csk()
We can change inet_csk() to propagate its argument const qualifier, thanks to container_of_const(). We have to fix few places that had mistakes, like tcp_bound_rto(). Signed-off-by: Eric Dumazet <edumazet@google.com> Link: https://lore.kernel.org/r/20240329144931.295800-1-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
513bebc4de
commit
58169ec9c4
@ -32,7 +32,7 @@ struct espintcp_ctx {
|
|||||||
|
|
||||||
static inline struct espintcp_ctx *espintcp_getctx(const struct sock *sk)
|
static inline struct espintcp_ctx *espintcp_getctx(const struct sock *sk)
|
||||||
{
|
{
|
||||||
struct inet_connection_sock *icsk = inet_csk(sk);
|
const struct inet_connection_sock *icsk = inet_csk(sk);
|
||||||
|
|
||||||
/* RCU is only needed for diag */
|
/* RCU is only needed for diag */
|
||||||
return (__force void *)icsk->icsk_ulp_data;
|
return (__force void *)icsk->icsk_ulp_data;
|
||||||
|
@ -147,10 +147,7 @@ struct inet_connection_sock {
|
|||||||
#define ICSK_TIME_LOSS_PROBE 5 /* Tail loss probe timer */
|
#define ICSK_TIME_LOSS_PROBE 5 /* Tail loss probe timer */
|
||||||
#define ICSK_TIME_REO_TIMEOUT 6 /* Reordering timer */
|
#define ICSK_TIME_REO_TIMEOUT 6 /* Reordering timer */
|
||||||
|
|
||||||
static inline struct inet_connection_sock *inet_csk(const struct sock *sk)
|
#define inet_csk(ptr) container_of_const(ptr, struct inet_connection_sock, icsk_inet.sk)
|
||||||
{
|
|
||||||
return (struct inet_connection_sock *)sk;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void *inet_csk_ca(const struct sock *sk)
|
static inline void *inet_csk_ca(const struct sock *sk)
|
||||||
{
|
{
|
||||||
|
@ -742,7 +742,7 @@ int tcp_mtu_to_mss(struct sock *sk, int pmtu);
|
|||||||
int tcp_mss_to_mtu(struct sock *sk, int mss);
|
int tcp_mss_to_mtu(struct sock *sk, int mss);
|
||||||
void tcp_mtup_init(struct sock *sk);
|
void tcp_mtup_init(struct sock *sk);
|
||||||
|
|
||||||
static inline void tcp_bound_rto(const struct sock *sk)
|
static inline void tcp_bound_rto(struct sock *sk)
|
||||||
{
|
{
|
||||||
if (inet_csk(sk)->icsk_rto > TCP_RTO_MAX)
|
if (inet_csk(sk)->icsk_rto > TCP_RTO_MAX)
|
||||||
inet_csk(sk)->icsk_rto = TCP_RTO_MAX;
|
inet_csk(sk)->icsk_rto = TCP_RTO_MAX;
|
||||||
|
@ -361,7 +361,7 @@ static inline bool tls_is_skb_tx_device_offloaded(const struct sk_buff *skb)
|
|||||||
|
|
||||||
static inline struct tls_context *tls_get_ctx(const struct sock *sk)
|
static inline struct tls_context *tls_get_ctx(const struct sock *sk)
|
||||||
{
|
{
|
||||||
struct inet_connection_sock *icsk = inet_csk(sk);
|
const struct inet_connection_sock *icsk = inet_csk(sk);
|
||||||
|
|
||||||
/* Use RCU on icsk_ulp_data only for sock diag code,
|
/* Use RCU on icsk_ulp_data only for sock diag code,
|
||||||
* TLS data path doesn't need rcu_dereference().
|
* TLS data path doesn't need rcu_dereference().
|
||||||
|
@ -6999,7 +6999,7 @@ EXPORT_SYMBOL(inet_reqsk_alloc);
|
|||||||
/*
|
/*
|
||||||
* Return true if a syncookie should be sent
|
* Return true if a syncookie should be sent
|
||||||
*/
|
*/
|
||||||
static bool tcp_syn_flood_action(const struct sock *sk, const char *proto)
|
static bool tcp_syn_flood_action(struct sock *sk, const char *proto)
|
||||||
{
|
{
|
||||||
struct request_sock_queue *queue = &inet_csk(sk)->icsk_accept_queue;
|
struct request_sock_queue *queue = &inet_csk(sk)->icsk_accept_queue;
|
||||||
const char *msg = "Dropping request";
|
const char *msg = "Dropping request";
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
static u32 tcp_clamp_rto_to_user_timeout(const struct sock *sk)
|
static u32 tcp_clamp_rto_to_user_timeout(const struct sock *sk)
|
||||||
{
|
{
|
||||||
struct inet_connection_sock *icsk = inet_csk(sk);
|
const struct inet_connection_sock *icsk = inet_csk(sk);
|
||||||
const struct tcp_sock *tp = tcp_sk(sk);
|
const struct tcp_sock *tp = tcp_sk(sk);
|
||||||
u32 elapsed, user_timeout;
|
u32 elapsed, user_timeout;
|
||||||
s32 remaining;
|
s32 remaining;
|
||||||
@ -47,7 +47,7 @@ static u32 tcp_clamp_rto_to_user_timeout(const struct sock *sk)
|
|||||||
|
|
||||||
u32 tcp_clamp_probe0_to_user_timeout(const struct sock *sk, u32 when)
|
u32 tcp_clamp_probe0_to_user_timeout(const struct sock *sk, u32 when)
|
||||||
{
|
{
|
||||||
struct inet_connection_sock *icsk = inet_csk(sk);
|
const struct inet_connection_sock *icsk = inet_csk(sk);
|
||||||
u32 remaining, user_timeout;
|
u32 remaining, user_timeout;
|
||||||
s32 elapsed;
|
s32 elapsed;
|
||||||
|
|
||||||
|
@ -558,7 +558,7 @@ struct mptcp_subflow_context {
|
|||||||
static inline struct mptcp_subflow_context *
|
static inline struct mptcp_subflow_context *
|
||||||
mptcp_subflow_ctx(const struct sock *sk)
|
mptcp_subflow_ctx(const struct sock *sk)
|
||||||
{
|
{
|
||||||
struct inet_connection_sock *icsk = inet_csk(sk);
|
const struct inet_connection_sock *icsk = inet_csk(sk);
|
||||||
|
|
||||||
/* Use RCU on icsk_ulp_data only for sock diag code */
|
/* Use RCU on icsk_ulp_data only for sock diag code */
|
||||||
return (__force struct mptcp_subflow_context *)icsk->icsk_ulp_data;
|
return (__force struct mptcp_subflow_context *)icsk->icsk_ulp_data;
|
||||||
|
Loading…
Reference in New Issue
Block a user