All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geliang Tang <geliangtang@gmail.com>
To: Paolo Abeni <pabeni@redhat.com>
Cc: mptcp@lists.linux.dev, Geliang Tang <geliangtang@xiaomi.com>
Subject: Re: [MPTCP][PATCH v7 mptcp-next 1/6] mptcp: drop flags and ifindex arguments
Date: Thu, 29 Jul 2021 19:37:56 +0800	[thread overview]
Message-ID: <CA+WQbwvzpYfXr7n8WfY9+oqFhDVN90R+Cn4YHYvbbeTQKb4Mcw@mail.gmail.com> (raw)
In-Reply-To: <f7de86246eb6e6bbae3235f5d78307cc0015f23e.camel@redhat.com>

Paolo Abeni <pabeni@redhat.com> 于2021年7月29日周四 下午7:12写道:
>
> On Thu, 2021-07-29 at 15:20 +0800, Geliang Tang wrote:
> > From: Geliang Tang <geliangtang@xiaomi.com>
> >
> > This patch added a new helper mptcp_pm_get_flags_and_ifindex_by_id(),
> > and used it in __mptcp_subflow_connect() to get the flags and ifindex
> > values.
> >
> > Then the two arguments flags and ifindex of __mptcp_subflow_connect()
> > can be dropped.
> >
> > Signed-off-by: Geliang Tang <geliangtang@xiaomi.com>
> > ---
> >  net/mptcp/pm_netlink.c | 25 ++++++++++++++++++++++---
> >  net/mptcp/protocol.h   |  5 +++--
> >  net/mptcp/subflow.c    |  7 +++++--
> >  3 files changed, 30 insertions(+), 7 deletions(-)
> >
> > diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
> > index ba0e1d71504d..94c68d6093de 100644
> > --- a/net/mptcp/pm_netlink.c
> > +++ b/net/mptcp/pm_netlink.c
> > @@ -462,8 +462,7 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)
> >                       check_work_pending(msk);
> >                       remote_address((struct sock_common *)sk, &remote);
> >                       spin_unlock_bh(&msk->pm.lock);
> > -                     __mptcp_subflow_connect(sk, &local->addr, &remote,
> > -                                             local->flags, local->ifindex);
> > +                     __mptcp_subflow_connect(sk, &local->addr, &remote);
> >                       spin_lock_bh(&msk->pm.lock);
> >                       return;
> >               }
> > @@ -518,7 +517,7 @@ static void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk)
> >       local.family = remote.family;
> >
> >       spin_unlock_bh(&msk->pm.lock);
> > -     __mptcp_subflow_connect(sk, &local, &remote, 0, 0);
> > +     __mptcp_subflow_connect(sk, &local, &remote);
> >       spin_lock_bh(&msk->pm.lock);
> >
> >  add_addr_echo:
> > @@ -1103,6 +1102,26 @@ __lookup_addr_by_id(struct pm_nl_pernet *pernet, unsigned int id)
> >       return NULL;
> >  }
> >
> > +int mptcp_pm_get_flags_and_ifindex_by_id(struct net *net, unsigned int id,
> > +                                      u8 *flags, int *ifindex)
> > +{
> > +     struct mptcp_pm_addr_entry *entry;
> > +
> > +     rcu_read_lock();
> > +     entry = __lookup_addr_by_id(net_generic(net, pm_nl_pernet_id), id);
> > +     rcu_read_unlock();
> > +
> > +     if (entry) {
> > +             *flags = entry->flags;
> > +             *ifindex = entry->ifindex;
> > +     } else {
> > +             *flags = 0;
> > +             *ifindex = 0;
> > +     }
>
> You need to extend the RCU section after the entry reference above, or
> on preempt-enabled build, the entry could be deleted in between the rcu
>  unlock and the later access.

Thanks Paolo, I'll send a squash-to patch to fix this.

>
> I'm wondering if there are issues with the 0 id ?!?

The 0 id address isn't on the local_addr_list, we should set it's
flags and ifindex all to 0.

I'll add a non-zero check in the squash-to patch too.

Thanks,
-Geliang

>
> /P
>

  reply	other threads:[~2021-07-29 11:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-29  7:20 [MPTCP][PATCH v7 mptcp-next 0/6] fullmesh path manager support Geliang Tang
2021-07-29  7:20 ` [MPTCP][PATCH v7 mptcp-next 1/6] mptcp: drop flags and ifindex arguments Geliang Tang
2021-07-29  7:20   ` [MPTCP][PATCH v7 mptcp-next 2/6] mptcp: remote addresses fullmesh Geliang Tang
2021-07-29  7:20     ` [MPTCP][PATCH v7 mptcp-next 3/6] mptcp: local " Geliang Tang
2021-07-29  7:20       ` [MPTCP][PATCH v7 mptcp-next 4/6] selftests: mptcp: set and print the fullmesh flag Geliang Tang
2021-07-29  7:20         ` [MPTCP][PATCH v7 mptcp-next 5/6] selftests: mptcp: add fullmesh testcases Geliang Tang
2021-07-29  7:20           ` [MPTCP][PATCH v7 mptcp-next 6/6] selftests: mptcp: delete uncontinuous removing ids Geliang Tang
2021-07-29 11:12   ` [MPTCP][PATCH v7 mptcp-next 1/6] mptcp: drop flags and ifindex arguments Paolo Abeni
2021-07-29 11:37     ` Geliang Tang [this message]
2021-07-30 18:14 ` [MPTCP][PATCH v7 mptcp-next 0/6] fullmesh path manager support Mat Martineau
2021-08-03 15:59 ` Matthieu Baerts

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CA+WQbwvzpYfXr7n8WfY9+oqFhDVN90R+Cn4YHYvbbeTQKb4Mcw@mail.gmail.com \
    --to=geliangtang@gmail.com \
    --cc=geliangtang@xiaomi.com \
    --cc=mptcp@lists.linux.dev \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.