Skip to content

Commit

Permalink
mptcp: mark ops structures as ro_after_init
Browse files Browse the repository at this point in the history
commit 51fa7f8 upstream.

These structures are initialised from the init hooks, so we can't make
them 'const'.  But no writes occur afterwards, so we can use ro_after_init.

Also, remove bogus EXPORT_SYMBOL, the only access comes from ip
stack, not from kernel modules.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Florian Westphal authored and gregkh committed Jan 12, 2023
1 parent b2120ed commit 13b9fd0
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions net/mptcp/subflow.c
Expand Up @@ -484,8 +484,7 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb)
}

struct request_sock_ops mptcp_subflow_request_sock_ops;
EXPORT_SYMBOL_GPL(mptcp_subflow_request_sock_ops);
static struct tcp_request_sock_ops subflow_request_sock_ipv4_ops;
static struct tcp_request_sock_ops subflow_request_sock_ipv4_ops __ro_after_init;

static int subflow_v4_conn_request(struct sock *sk, struct sk_buff *skb)
{
Expand All @@ -506,9 +505,9 @@ static int subflow_v4_conn_request(struct sock *sk, struct sk_buff *skb)
}

#if IS_ENABLED(CONFIG_MPTCP_IPV6)
static struct tcp_request_sock_ops subflow_request_sock_ipv6_ops;
static struct inet_connection_sock_af_ops subflow_v6_specific;
static struct inet_connection_sock_af_ops subflow_v6m_specific;
static struct tcp_request_sock_ops subflow_request_sock_ipv6_ops __ro_after_init;
static struct inet_connection_sock_af_ops subflow_v6_specific __ro_after_init;
static struct inet_connection_sock_af_ops subflow_v6m_specific __ro_after_init;
static struct proto tcpv6_prot_override;

static int subflow_v6_conn_request(struct sock *sk, struct sk_buff *skb)
Expand Down Expand Up @@ -790,7 +789,7 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,
return child;
}

static struct inet_connection_sock_af_ops subflow_specific;
static struct inet_connection_sock_af_ops subflow_specific __ro_after_init;
static struct proto tcp_prot_override;

enum mapping_status {
Expand Down Expand Up @@ -1327,7 +1326,7 @@ static void subflow_write_space(struct sock *ssk)
mptcp_write_space(sk);
}

static struct inet_connection_sock_af_ops *
static const struct inet_connection_sock_af_ops *
subflow_default_af_ops(struct sock *sk)
{
#if IS_ENABLED(CONFIG_MPTCP_IPV6)
Expand All @@ -1342,7 +1341,7 @@ void mptcpv6_handle_mapped(struct sock *sk, bool mapped)
{
struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
struct inet_connection_sock *icsk = inet_csk(sk);
struct inet_connection_sock_af_ops *target;
const struct inet_connection_sock_af_ops *target;

target = mapped ? &subflow_v6m_specific : subflow_default_af_ops(sk);

Expand Down

0 comments on commit 13b9fd0

Please sign in to comment.