Skip to content

Commit

Permalink
mptcp: drop unneeded checks
Browse files Browse the repository at this point in the history
After the previous patch subflow->conn is always != NULL and
is never changed. We can drop a bunch of now unneeded checks.

v1 -> v2:
 - rebased on top of commit 2398e39 ("mptcp: always
   include dack if possible.")

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Paolo Abeni authored and David S. Miller committed Mar 15, 2020
1 parent 58b0991 commit dc093db
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
14 changes: 2 additions & 12 deletions net/mptcp/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb,
unsigned int ack_size;
bool ret = false;
bool can_ack;
u64 ack_seq;
u8 tcp_fin;

if (skb) {
Expand Down Expand Up @@ -368,16 +367,7 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb,
can_ack = true;
opts->ext_copy.use_ack = 0;
msk = mptcp_sk(subflow->conn);
if (likely(msk && READ_ONCE(msk->can_ack))) {
ack_seq = msk->ack_seq;
} else if (subflow->can_ack) {
mptcp_crypto_key_sha(subflow->remote_key, NULL, &ack_seq);
ack_seq++;
} else {
can_ack = false;
}

if (unlikely(!can_ack)) {
if (!READ_ONCE(msk->can_ack)) {
*size = ALIGN(dss_size, 4);
return ret;
}
Expand All @@ -390,7 +380,7 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb,

dss_size += ack_size;

opts->ext_copy.data_ack = ack_seq;
opts->ext_copy.data_ack = msk->ack_seq;
opts->ext_copy.ack64 = 1;
opts->ext_copy.use_ack = 1;

Expand Down
18 changes: 7 additions & 11 deletions net/mptcp/subflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb)

subflow->icsk_af_ops->sk_rx_dst_set(sk, skb);

if (subflow->conn && !subflow->conn_finished) {
if (!subflow->conn_finished) {
pr_debug("subflow=%p, remote_key=%llu", mptcp_subflow_ctx(sk),
subflow->remote_key);
mptcp_finish_connect(sk);
Expand Down Expand Up @@ -439,9 +439,6 @@ static bool subflow_check_data_avail(struct sock *ssk)
if (subflow->data_avail)
return true;

if (!subflow->conn)
return false;

msk = mptcp_sk(subflow->conn);
for (;;) {
u32 map_remaining;
Expand Down Expand Up @@ -561,11 +558,10 @@ static void subflow_data_ready(struct sock *sk)
struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
struct sock *parent = subflow->conn;

if (!parent || !subflow->mp_capable) {
if (!subflow->mp_capable) {
subflow->tcp_data_ready(sk);

if (parent)
parent->sk_data_ready(parent);
parent->sk_data_ready(parent);
return;
}

Expand All @@ -579,7 +575,7 @@ static void subflow_write_space(struct sock *sk)
struct sock *parent = subflow->conn;

sk_stream_write_space(sk);
if (parent && sk_stream_is_writeable(sk)) {
if (sk_stream_is_writeable(sk)) {
set_bit(MPTCP_SEND_SPACE, &mptcp_sk(parent)->flags);
smp_mb__after_atomic();
/* set SEND_SPACE before sk_stream_write_space clears NOSPACE */
Expand Down Expand Up @@ -694,18 +690,18 @@ static bool subflow_is_done(const struct sock *sk)
static void subflow_state_change(struct sock *sk)
{
struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
struct sock *parent = READ_ONCE(subflow->conn);
struct sock *parent = subflow->conn;

__subflow_state_change(sk);

/* as recvmsg() does not acquire the subflow socket for ssk selection
* a fin packet carrying a DSS can be unnoticed if we don't trigger
* the data available machinery here.
*/
if (parent && subflow->mp_capable && mptcp_subflow_data_available(sk))
if (subflow->mp_capable && mptcp_subflow_data_available(sk))
mptcp_data_ready(parent, sk);

if (parent && !(parent->sk_shutdown & RCV_SHUTDOWN) &&
if (!(parent->sk_shutdown & RCV_SHUTDOWN) &&
!subflow->rx_eof && subflow_is_done(sk)) {
subflow->rx_eof = 1;
parent->sk_shutdown |= RCV_SHUTDOWN;
Expand Down

0 comments on commit dc093db

Please sign in to comment.