Commit Graph

29 Commits

Author SHA1 Message Date
Davide Caratti 47b04e47f7 mptcp: pm: fix backup support in signal endpoints
JIRA: https://issues.redhat.com/browse/RHEL-62871
Upstream Status: net.git commit 6834097fc38c5416701c793da94558cea49c0a1f
Conflicts:
  - net/mptcp/protocol.h: context mismatch because of missing upstream
    commit 9ae7846c4b6b ("mptcp: dump addrs in userspace pm list")

commit 6834097fc38c5416701c793da94558cea49c0a1f
Author: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Date:   Sat Jul 27 12:01:28 2024 +0200

    mptcp: pm: fix backup support in signal endpoints

    There was a support for signal endpoints, but only when the endpoint's
    flag was changed during a connection. If an endpoint with the signal and
    backup was already present, the MP_JOIN reply was not containing the
    backup flag as expected.

    That's confusing to have this inconsistent behaviour. On the other hand,
    the infrastructure to set the backup flag in the SYN + ACK + MP_JOIN was
    already there, it was just never set before. Now when requesting the
    local ID from the path-manager, the backup status is also requested.

    Note that when the userspace PM is used, the backup flag can be set if
    the local address was already used before with a backup flag, e.g. if
    the address was announced with the 'backup' flag, or a subflow was
    created with the 'backup' flag.

    Fixes: 4596a2c1b7 ("mptcp: allow creating non-backup subflows")
    Cc: stable@vger.kernel.org
    Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/507
    Reviewed-by: Mat Martineau <martineau@kernel.org>
    Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
2024-11-12 10:18:59 +01:00
Davide Caratti 89f3742fd2 mptcp: move mptcp_pm_gen.h's include
JIRA: https://issues.redhat.com/browse/RHEL-62871
Upstream Status: net.git commit 76a86686e3f0ca68b555131ceefa141a57340ed0

commit 76a86686e3f0ca68b555131ceefa141a57340ed0
Author: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Date:   Mon May 13 18:13:31 2024 -0700

    mptcp: move mptcp_pm_gen.h's include

    Nothing from protocol.h depends on mptcp_pm_gen.h, only code from
    pm_netlink.c and pm_userspace.c depends on it.

    So this include can be moved where it is needed to avoid a "unused
    includes" warning.

    Reviewed-by: Geliang Tang <geliang@kernel.org>
    Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
    Signed-off-by: Mat Martineau <martineau@kernel.org>
    Link: https://lore.kernel.org/r/20240514011335.176158-8-martineau@kernel.org
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
2024-11-12 10:18:59 +01:00
Davide Caratti a4d0a0968c mptcp: map v4 address to v6 when destroying subflow
JIRA: https://issues.redhat.com/browse/RHEL-32669
Upstream Status: net.git commit 535d620ea5ff1a033dc64ee3d912acadc7470619

commit 535d620ea5ff1a033dc64ee3d912acadc7470619
Author: Geliang Tang <tanggeliang@kylinos.cn>
Date:   Fri Feb 23 17:14:11 2024 +0100

    mptcp: map v4 address to v6 when destroying subflow

    Address family of server side mismatches with that of client side, like
    in "userspace pm add & remove address" test:

        userspace_pm_add_addr $ns1 10.0.2.1 10
        userspace_pm_rm_sf $ns1 "::ffff:10.0.2.1" $SUB_ESTABLISHED

    That's because on the server side, the family is set to AF_INET6 and the
    v4 address is mapped in a v6 one.

    This patch fixes this issue. In mptcp_pm_nl_subflow_destroy_doit(), before
    checking local address family with remote address family, map an IPv4
    address to an IPv6 address if the pair is a v4-mapped address.

    Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/387
    Fixes: 702c2f646d42 ("mptcp: netlink: allow userspace-driven subflow establishment")
    Cc: stable@vger.kernel.org
    Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
    Reviewed-by: Mat Martineau <martineau@kernel.org>
    Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
    Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
    Link: https://lore.kernel.org/r/20240223-upstream-net-20240223-misc-fixes-v1-1-162e87e48497@kernel.org
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
2024-04-18 17:25:35 +02:00
Davide Caratti 574bf2a8a0 mptcp: fix data races on local_id
JIRA: https://issues.redhat.com/browse/RHEL-32669
Upstream Status: net.git commit a7cfe776637004a4c938fde78be4bd608c32c3ef

commit a7cfe776637004a4c938fde78be4bd608c32c3ef
Author: Paolo Abeni <pabeni@redhat.com>
Date:   Thu Feb 15 19:25:31 2024 +0100

    mptcp: fix data races on local_id

    The local address id is accessed lockless by the NL PM, add
    all the required ONCE annotation. There is a caveat: the local
    id can be initialized late in the subflow life-cycle, and its
    validity is controlled by the local_id_valid flag.

    Remove such flag and encode the validity in the local_id field
    itself with negative value before initialization. That allows
    accessing the field consistently with a single read operation.

    Fixes: 0ee4261a36 ("mptcp: implement mptcp_pm_remove_subflow")
    Cc: stable@vger.kernel.org
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Reviewed-by: Mat Martineau <martineau@kernel.org>
    Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
2024-04-18 17:25:35 +02:00
Davide Caratti c155bf298f mptcp: add needs_id for userspace appending addr
JIRA: https://issues.redhat.com/browse/RHEL-32669
Upstream Status: net.git commit 6c347be62ae963b301ead8e7fa7b9973e6e0d6e1

commit 6c347be62ae963b301ead8e7fa7b9973e6e0d6e1
Author: Geliang Tang <tanggeliang@kylinos.cn>
Date:   Thu Feb 15 19:25:28 2024 +0100

    mptcp: add needs_id for userspace appending addr

    When userspace PM requires to create an ID 0 subflow in "userspace pm
    create id 0 subflow" test like this:

            userspace_pm_add_sf $ns2 10.0.3.2 0

    An ID 1 subflow, in fact, is created.

    Since in mptcp_pm_nl_append_new_local_addr(), 'id 0' will be treated as
    no ID is set by userspace, and will allocate a new ID immediately:

         if (!e->addr.id)
                 e->addr.id = find_next_zero_bit(pernet->id_bitmap,
                                                 MPTCP_PM_MAX_ADDR_ID + 1,
                                                 1);

    To solve this issue, a new parameter needs_id is added for
    mptcp_userspace_pm_append_new_local_addr() to distinguish between
    whether userspace PM has set an ID 0 or whether userspace PM has
    not set any address.

    needs_id is true in mptcp_userspace_pm_get_local_id(), but false in
    mptcp_pm_nl_announce_doit() and mptcp_pm_nl_subflow_create_doit().

    Fixes: e5ed101a6028 ("mptcp: userspace pm allow creating id 0 subflow")
    Cc: stable@vger.kernel.org
    Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
    Reviewed-by: Mat Martineau <martineau@kernel.org>
    Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
2024-04-18 17:25:35 +02:00
Davide Caratti 9d912ceafc mptcp: check addrs list in userspace_pm_get_local_id
JIRA: https://issues.redhat.com/browse/RHEL-32669
Upstream Status: net.git commit f012d796a6de662692159c539689e47e662853a8

commit f012d796a6de662692159c539689e47e662853a8
Author: Geliang Tang <geliang@kernel.org>
Date:   Thu Feb 8 19:03:53 2024 +0100

    mptcp: check addrs list in userspace_pm_get_local_id

    Before adding a new entry in mptcp_userspace_pm_get_local_id(), it's
    better to check whether this address is already in userspace pm local
    address list. If it's in the list, no need to add a new entry, just
    return it's address ID and use this address.

    Fixes: 8b20137012d9 ("mptcp: read attributes of addr entries managed by userspace PMs")
    Cc: stable@vger.kernel.org
    Signed-off-by: Geliang Tang <geliang.tang@linux.dev>
    Reviewed-by: Mat Martineau <martineau@kernel.org>
    Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
2024-04-18 17:25:35 +02:00
Paolo Abeni f208c6c1fc mptcp: define more local variables sk
JIRA: https://issues.redhat.com/browse/RHEL-15036
Tested: LNST, Tier1

Upstream commit:
commit 14cb0e0bf39bd10429ba14e9e2f905f1144226fc
Author: Geliang Tang <geliang.tang@suse.com>
Date:   Wed Oct 25 16:37:09 2023 -0700

    mptcp: define more local variables sk

    '(struct sock *)msk' is used several times in mptcp_nl_cmd_announce(),
    mptcp_nl_cmd_remove() or mptcp_userspace_pm_set_flags() in pm_userspace.c,
    it's worth adding a local variable sk to point it.

    Reviewed-by: Matthieu Baerts <matttbe@kernel.org>
    Signed-off-by: Geliang Tang <geliang.tang@suse.com>
    Signed-off-by: Mat Martineau <martineau@kernel.org>
    Link: https://lore.kernel.org/r/20231025-send-net-next-20231025-v1-8-db8f25f798eb@kernel.org
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2023-10-31 21:50:28 +01:00
Paolo Abeni 1a46c0afa2 mptcp: move sk assignment statement ahead
JIRA: https://issues.redhat.com/browse/RHEL-15036
Tested: LNST, Tier1

Upstream commit:
commit a6c85fc61c088c7ef43ba81e80b48c263a80602a
Author: Geliang Tang <geliang.tang@suse.com>
Date:   Wed Oct 25 16:37:08 2023 -0700

    mptcp: move sk assignment statement ahead

    If we move the sk assignment statement ahead in mptcp_nl_cmd_sf_create()
    or mptcp_nl_cmd_sf_destroy(), right after the msk null-check statements,
    sk can be used after the create_err or destroy_err labels instead of
    open-coding it again.

    Reviewed-by: Matthieu Baerts <matttbe@kernel.org>
    Signed-off-by: Geliang Tang <geliang.tang@suse.com>
    Signed-off-by: Mat Martineau <martineau@kernel.org>
    Link: https://lore.kernel.org/r/20231025-send-net-next-20231025-v1-7-db8f25f798eb@kernel.org
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2023-10-31 21:50:28 +01:00
Paolo Abeni 99dadb75ec mptcp: userspace pm send RM_ADDR for ID 0
JIRA: https://issues.redhat.com/browse/RHEL-15036
Tested: LNST, Tier1

Upstream commit:
commit 84c531f54ad9a124a924c9505d74e33d16965146
Author: Geliang Tang <geliang.tang@suse.com>
Date:   Wed Oct 25 16:37:04 2023 -0700

    mptcp: userspace pm send RM_ADDR for ID 0

    This patch adds the ability to send RM_ADDR for local ID 0. Check
    whether id 0 address is removed, if not, put id 0 into a removing
    list, pass it to mptcp_pm_remove_addr() to remove id 0 address.

    There is no reason not to allow the userspace to remove the initial
    address (ID 0). This special case was not taken into account not
    letting the userspace to delete all addresses as announced.

    Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/379
    Reviewed-by: Matthieu Baerts <matttbe@kernel.org>
    Signed-off-by: Geliang Tang <geliang.tang@suse.com>
    Signed-off-by: Mat Martineau <martineau@kernel.org>
    Link: https://lore.kernel.org/r/20231025-send-net-next-20231025-v1-3-db8f25f798eb@kernel.org
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2023-10-31 21:50:28 +01:00
Paolo Abeni 2fc7f6b9ec net: mptcp: rename netlink handlers to mptcp_pm_nl_<blah>_{doit,dumpit}
JIRA: https://issues.redhat.com/browse/RHEL-15036
Tested: LNST, Tier1

Upstream commit:
commit 1e07938e29c587eaae069f6c624daa4c2a56331c
Author: Davide Caratti <dcaratti@redhat.com>
Date:   Mon Oct 23 11:17:10 2023 -0700

    net: mptcp: rename netlink handlers to mptcp_pm_nl_<blah>_{doit,dumpit}

    so that they will match names generated from YAML spec.

    Link: https://github.com/multipath-tcp/mptcp_net-next/issues/340
    Suggested-by: Paolo Abeni <pabeni@redhat.com>
    Acked-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Davide Caratti <dcaratti@redhat.com>
    Signed-off-by: Mat Martineau <martineau@kernel.org>
    Link: https://lore.kernel.org/r/20231023-send-net-next-20231023-1-v2-6-16b1f701f900@kernel.org
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2023-10-31 21:50:28 +01:00
Paolo Abeni 64aed2bb6e mptcp: userspace pm allow creating id 0 subflow
JIRA: https://issues.redhat.com/browse/RHEL-15036
Tested: LNST, Tier1

Upstream commit:
commit e5ed101a602873d65d2d64edaba93e8c73ec1b0f
Author: Geliang Tang <geliang.tang@suse.com>
Date:   Wed Oct 4 13:38:12 2023 -0700

    mptcp: userspace pm allow creating id 0 subflow

    This patch drops id 0 limitation in mptcp_nl_cmd_sf_create() to allow
    creating additional subflows with the local addr ID 0.

    There is no reason not to allow additional subflows from this local
    address: we should be able to create new subflows from the initial
    endpoint. This limitation was breaking fullmesh support from userspace.

    Fixes: 702c2f646d42 ("mptcp: netlink: allow userspace-driven subflow establishment")
    Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/391
    Cc: stable@vger.kernel.org
    Suggested-by: Matthieu Baerts <matthieu.baerts@tessares.net>
    Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
    Signed-off-by: Geliang Tang <geliang.tang@suse.com>
    Signed-off-by: Mat Martineau <martineau@kernel.org>
    Link: https://lore.kernel.org/r/20231004-send-net-20231004-v1-2-28de4ac663ae@kernel.org
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2023-10-31 21:50:28 +01:00
Paolo Abeni b3feb89fbf mptcp: pass addr to mptcp_pm_alloc_anno_list
JIRA: https://issues.redhat.com/browse/RHEL-15036
Tested: LNST, Tier1

Upstream commit:
commit 528cb5f2a1e859522f36f091f29f5c81ec6d4a4c
Author: Geliang Tang <geliang.tang@suse.com>
Date:   Tue Jun 20 18:30:22 2023 +0200

    mptcp: pass addr to mptcp_pm_alloc_anno_list

    Pass addr parameter to mptcp_pm_alloc_anno_list() instead of entry. We
    can reduce the scope, e.g. in mptcp_pm_alloc_anno_list(), we only access
    "entry->addr", we can then restrict to the pointer to "addr" then.

    Signed-off-by: Geliang Tang <geliang.tang@suse.com>
    Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
    Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2023-10-31 21:50:01 +01:00
Paolo Abeni 6b11f7289e mptcp: unify pm get_flags_and_ifindex_by_id
JIRA: https://issues.redhat.com/browse/RHEL-15036
Tested: LNST, Tier1

Upstream commit:
commit f40be0db0b7680c2e9f0b1289788542813ba0f00
Author: Geliang Tang <geliang.tang@suse.com>
Date:   Thu Jun 8 15:20:51 2023 +0200

    mptcp: unify pm get_flags_and_ifindex_by_id

    This patch unifies the three PM get_flags_and_ifindex_by_id() interfaces:

    mptcp_pm_nl_get_flags_and_ifindex_by_id() in mptcp/pm_netlink.c for the
    in-kernel PM and mptcp_userspace_pm_get_flags_and_ifindex_by_id() in
    mptcp/pm_userspace.c for the userspace PM.

    They'll be switched in the common PM infterface
    mptcp_pm_get_flags_and_ifindex_by_id() in mptcp/pm.c based on whether
    mptcp_pm_is_userspace() or not.

    Signed-off-by: Geliang Tang <geliang.tang@suse.com>
    Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
    Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
    Reviewed-by: Larysa Zaremba <larysa.zaremba@intel.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2023-10-31 21:50:01 +01:00
Paolo Abeni c1c404e58b mptcp: update userspace pm infos
JIRA: https://issues.redhat.com/browse/RHEL-15036
Tested: LNST, Tier1

Upstream commit:
commit 77e4b94a3de692a09b79945ecac5b8e6b77f10c1
Author: Geliang Tang <geliang.tang@suse.com>
Date:   Sun Jun 4 20:25:21 2023 -0700

    mptcp: update userspace pm infos

    Increase pm subflows counter on both server side and client side when
    userspace pm creates a new subflow, and decrease the counter when it
    closes a subflow.

    Increase add_addr_signaled counter in mptcp_nl_cmd_announce() when the
    address is announced by userspace PM.

    This modification is similar to how the in-kernel PM is updating the
    counter: when additional subflows are created/removed.

    Fixes: 9ab4807c84a4 ("mptcp: netlink: Add MPTCP_PM_CMD_ANNOUNCE")
    Fixes: 702c2f646d42 ("mptcp: netlink: allow userspace-driven subflow establishment")
    Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/329
    Cc: stable@vger.kernel.org
    Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
    Signed-off-by: Geliang Tang <geliang.tang@suse.com>
    Signed-off-by: Mat Martineau <martineau@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2023-10-31 21:50:01 +01:00
Paolo Abeni 73d9eec76d mptcp: add address into userspace pm list
JIRA: https://issues.redhat.com/browse/RHEL-15036
Tested: LNST, Tier1

Upstream commit:
commit 24430f8bf51655c5ab7ddc2fafe939dd3cd0dd47
Author: Geliang Tang <geliang.tang@suse.com>
Date:   Sun Jun 4 20:25:19 2023 -0700

    mptcp: add address into userspace pm list

    Add the address into userspace_pm_local_addr_list when the subflow is
    created. Make sure it can be found in mptcp_nl_cmd_remove(). And delete
    it in the new helper mptcp_userspace_pm_delete_local_addr().

    By doing this, the "REMOVE" command also works with subflows that have
    been created via the "SUB_CREATE" command instead of restricting to
    the addresses that have been announced via the "ANNOUNCE" command.

    Fixes: d9a4594edabf ("mptcp: netlink: Add MPTCP_PM_CMD_REMOVE")
    Link: https://github.com/multipath-tcp/mptcp_net-next/issues/379
    Cc: stable@vger.kernel.org
    Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
    Signed-off-by: Geliang Tang <geliang.tang@suse.com>
    Signed-off-by: Mat Martineau <martineau@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2023-10-31 21:50:01 +01:00
Paolo Abeni 9bc8761d86 mptcp: only send RM_ADDR in nl_cmd_remove
JIRA: https://issues.redhat.com/browse/RHEL-15036
Tested: LNST, Tier1

Upstream commit:
commit 8b1c94da1e481090f24127b2c420b0c0b0421ce3
Author: Geliang Tang <geliang.tang@suse.com>
Date:   Sun Jun 4 20:25:17 2023 -0700

    mptcp: only send RM_ADDR in nl_cmd_remove

    The specifications from [1] about the "REMOVE" command say:

        Announce that an address has been lost to the peer

    It was then only supposed to send a RM_ADDR and not trying to delete
    associated subflows.

    A new helper mptcp_pm_remove_addrs() is then introduced to do just
    that, compared to mptcp_pm_remove_addrs_and_subflows() also removing
    subflows.

    To delete a subflow, the userspace daemon can use the "SUB_DESTROY"
    command, see mptcp_nl_cmd_sf_destroy().

    Fixes: d9a4594edabf ("mptcp: netlink: Add MPTCP_PM_CMD_REMOVE")
    Link: https://github.com/multipath-tcp/mptcp/blob/mptcp_v0.96/include/uapi/linux/mptcp.h [1]
    Cc: stable@vger.kernel.org
    Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
    Signed-off-by: Geliang Tang <geliang.tang@suse.com>
    Signed-off-by: Mat Martineau <martineau@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2023-10-31 21:50:01 +01:00
Davide Caratti 27656b7580 mptcp: make userspace_pm_append_new_local_addr static
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2193330
Upstream Status: net.git commit aa5887dca2d2

commit aa5887dca2d236fc50000e27023d4d78dce3af30
Author: Geliang Tang <geliang.tang@suse.com>
Date:   Fri Apr 14 17:47:06 2023 +0200

    mptcp: make userspace_pm_append_new_local_addr static

    mptcp_userspace_pm_append_new_local_addr() has always exclusively been
    used in pm_userspace.c since its introduction in
    commit 4638de5aefe5 ("mptcp: handle local addrs announced by userspace PMs").

    So make it static.

    Signed-off-by: Geliang Tang <geliang.tang@suse.com>
    Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
    Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
2023-05-11 11:46:50 +02:00
Davide Caratti 95f9a3a443 mptcp: userspace pm: use a single point of exit
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2193330
Upstream Status: net.git commit 40c71f763f87

commit 40c71f763f87b68fe43199c1702220c91afed288
Author: Matthieu Baerts <matthieu.baerts@tessares.net>
Date:   Wed Jan 25 11:47:24 2023 +0100

    mptcp: userspace pm: use a single point of exit

    Like in all other functions in this file, a single point of exit is used
    when extra operations are needed: unlock, decrement refcount, etc.

    There is no functional change for the moment but it is better to do the
    same here to make sure all cleanups are done in case of intermediate
    errors.

    Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
    Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
2023-05-11 11:46:47 +02:00
Davide Caratti 4081e71c20 mptcp: netlink: respect v4/v6-only sockets
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2193330
Upstream Status: net.git commit fb00ee4f3343

commit fb00ee4f3343acb2b9222ca9b73b47dd1e1a8efc
Author: Matthieu Baerts <matthieu.baerts@tessares.net>
Date:   Thu Jan 12 18:42:52 2023 +0100

    mptcp: netlink: respect v4/v6-only sockets

    If an MPTCP socket has been created with AF_INET6 and the IPV6_V6ONLY
    option has been set, the userspace PM would allow creating subflows
    using IPv4 addresses, e.g. mapped in v6.

    The kernel side of userspace PM will also accept creating subflows with
    local and remote addresses having different families. Depending on the
    subflow socket's family, different behaviours are expected:
     - If AF_INET is forced with a v6 address, the kernel will take the last
       byte of the IP and try to connect to that: a new subflow is created
       but to a non expected address.
     - If AF_INET6 is forced with a v4 address, the kernel will try to
       connect to a v4 address (v4-mapped-v6). A -EBADF error from the
       connect() part is then expected.

    It is then required to check the given families can be accepted. This is
    done by using a new helper for addresses family matching, taking care of
    IPv4 vs IPv4-mapped-IPv6 addresses. This helper will be re-used later by
    the in-kernel path-manager to use mixed IPv4 and IPv6 addresses.

    While at it, a clear error message is now reported if there are some
    conflicts with the families that have been passed by the userspace.

    Fixes: 702c2f646d42 ("mptcp: netlink: allow userspace-driven subflow establishment")
    Cc: stable@vger.kernel.org
    Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
    Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
2023-05-11 11:46:46 +02:00
Davide Caratti dd145c4433 mptcp: get sk from msk directly
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2193330
Upstream Status: net.git commit 80638684e840

commit 80638684e840684042325fa5a3fa1eb59fd123cc
Author: Geliang Tang <geliang.tang@suse.com>
Date:   Thu Nov 10 15:23:20 2022 -0800

    mptcp: get sk from msk directly

    Use '(struct sock *)msk' to get 'sk' from 'msk' in a more direct way
    instead of using '&msk->sk.icsk_inet.sk'.

    Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
    Signed-off-by: Geliang Tang <geliang.tang@suse.com>
    Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
2023-05-11 11:46:43 +02:00
Davide Caratti 72ec2c1814 mptcp: netlink: fix some error return code
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2161699
Upstream Status: net.git commit e0fe1123ab2b

commit e0fe1123ab2b07d2cd5475660bd0b4e6993ffaa7
Author: Wei Yongjun <weiyongjun1@huawei.com>
Date:   Fri Dec 9 16:28:07 2022 -0800

    mptcp: netlink: fix some error return code

    Fix to return negative error code -EINVAL from some error handling
    case instead of 0, as done elsewhere in those functions.

    Fixes: 9ab4807c84a4 ("mptcp: netlink: Add MPTCP_PM_CMD_ANNOUNCE")
    Fixes: 702c2f646d42 ("mptcp: netlink: allow userspace-driven subflow establishment")
    Cc: stable@vger.kernel.org
    Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
    Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
    Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
2023-01-24 15:54:38 +01:00
Davide Caratti db66fb8745 mptcp: update MIB_RMSUBFLOW in cmd_sf_destroy
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2137858
Upstream Status: net.git commit d2d21f175f1f

commit d2d21f175f1f9580eb5681f5b476c8d7a0a3c895
Author: Geliang Tang <geliang.tang@suse.com>
Date:   Tue Jul 5 14:32:17 2022 -0700

    mptcp: update MIB_RMSUBFLOW in cmd_sf_destroy

    This patch increases MPTCP_MIB_RMSUBFLOW mib counter in userspace pm
    destroy subflow function mptcp_nl_cmd_sf_destroy() when removing subflow.

    Fixes: 702c2f646d42 ("mptcp: netlink: allow userspace-driven subflow establishment")
    Signed-off-by: Geliang Tang <geliang.tang@suse.com>
    Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
2022-11-08 17:10:56 +01:00
Davide Caratti 2a0bbd58c8 mptcp: netlink: issue MP_PRIO signals from userspace PMs
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2137858
Upstream Status: net.git commit 892f396c8e68

commit 892f396c8e68faab7f76ff49cf39e9fbbeea4097
Author: Kishen Maloor <kishen.maloor@intel.com>
Date:   Tue Jul 5 14:32:14 2022 -0700

    mptcp: netlink: issue MP_PRIO signals from userspace PMs

    This change updates MPTCP_PM_CMD_SET_FLAGS to allow userspace PMs
    to issue MP_PRIO signals over a specific subflow selected by
    the connection token, local and remote address+port.

    Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/286
    Fixes: 702c2f646d42 ("mptcp: netlink: allow userspace-driven subflow establishment")
    Acked-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Kishen Maloor <kishen.maloor@intel.com>
    Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
2022-11-08 17:10:56 +01:00
Davide Caratti b878a64ac3 mptcp: fix locking in mptcp_nl_cmd_sf_destroy()
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2137858
Upstream Status: net.git commit 5ccecaec5c1e

commit 5ccecaec5c1e85cabfda848c6f146da0d8d55bd6
Author: Paolo Abeni <pabeni@redhat.com>
Date:   Tue Jul 5 14:32:11 2022 -0700

    mptcp: fix locking in mptcp_nl_cmd_sf_destroy()

    The user-space PM subflow removal path uses a couple of helpers
    that must be called under the msk socket lock and the current
    code lacks such requirement.

    Change the existing lock scope so that the relevant code is under
    its protection.

    Fixes: 702c2f646d42 ("mptcp: netlink: allow userspace-driven subflow establishment")
    Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/287
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
2022-11-08 17:10:56 +01:00
Davide Caratti 514e615698 mptcp: netlink: allow userspace-driven subflow establishment
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2079368
Upstream Status: net-next.git commit 702c2f646d42

commit 702c2f646d42cfd9e31133d68a8283fea48fd810
Author: Florian Westphal <fw@strlen.de>
Date:   Tue May 3 19:38:56 2022 -0700

    mptcp: netlink: allow userspace-driven subflow establishment

    This allows userspace to tell kernel to add a new subflow to an existing
    mptcp connection.

    Userspace provides the token to identify the mptcp-level connection
    that needs a change in active subflows and the local and remote
    addresses of the new or the to-be-removed subflow.

    MPTCP_PM_CMD_SUBFLOW_CREATE requires the following parameters:
    { token, { loc_id, family, loc_addr4 | loc_addr6 }, { family, rem_addr4 |
    rem_addr6, rem_port }

    MPTCP_PM_CMD_SUBFLOW_DESTROY requires the following parameters:
    { token, { family, loc_addr4 | loc_addr6, loc_port }, { family, rem_addr4 |
    rem_addr6, rem_port }

    Acked-by: Paolo Abeni <pabeni@redhat.com>
    Co-developed-by: Kishen Maloor <kishen.maloor@intel.com>
    Signed-off-by: Kishen Maloor <kishen.maloor@intel.com>
    Signed-off-by: Florian Westphal <fw@strlen.de>
    Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
2022-05-06 11:03:28 +02:00
Davide Caratti 542d9d2786 mptcp: netlink: Add MPTCP_PM_CMD_REMOVE
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2079368
Upstream Status: net-next.git commit d9a4594edabf

commit d9a4594edabf125dc17dfd52acc722c3de1cb44c
Author: Kishen Maloor <kishen.maloor@intel.com>
Date:   Tue May 3 19:38:54 2022 -0700

    mptcp: netlink: Add MPTCP_PM_CMD_REMOVE

    This change adds a MPTCP netlink command for issuing a
    REMOVE_ADDR signal for an address over the chosen MPTCP
    connection from a userspace path manager.

    The command requires the following parameters: {token, loc_id}.

    Acked-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Kishen Maloor <kishen.maloor@intel.com>
    Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
2022-05-06 11:03:27 +02:00
Davide Caratti 8d930f33fc mptcp: netlink: Add MPTCP_PM_CMD_ANNOUNCE
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2079368
Upstream Status: net-next.git commit 9ab4807c84a4

commit 9ab4807c84a4aacfc9b4f79cc81254035e0ec361
Author: Kishen Maloor <kishen.maloor@intel.com>
Date:   Tue May 3 19:38:52 2022 -0700

    mptcp: netlink: Add MPTCP_PM_CMD_ANNOUNCE

    This change adds a MPTCP netlink interface for issuing
    ADD_ADDR advertisements over the chosen MPTCP connection from a
    userspace path manager.

    The command requires the following parameters:
    { token, { loc_id, family, daddr4 | daddr6 [, dport] } [, if_idx],
    flags[signal] }.

    Acked-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Kishen Maloor <kishen.maloor@intel.com>
    Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
2022-05-06 11:03:27 +02:00
Davide Caratti 9e7e2733fe mptcp: read attributes of addr entries managed by userspace PMs
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2079368
Upstream Status: net-next.git commit 8b20137012d9

commit 8b20137012d9e521736c040328f8979cf0a144d0
Author: Kishen Maloor <kishen.maloor@intel.com>
Date:   Tue May 3 19:38:50 2022 -0700

    mptcp: read attributes of addr entries managed by userspace PMs

    This change introduces a parallel path in the kernel for retrieving
    the local id, flags, if_index for an addr entry in the context of
    an MPTCP connection that's being managed by a userspace PM. The
    userspace and in-kernel PM modes deviate in their procedures for
    obtaining this information.

    Acked-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Kishen Maloor <kishen.maloor@intel.com>
    Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
2022-05-06 11:03:26 +02:00
Davide Caratti 2b73fbfe8a mptcp: handle local addrs announced by userspace PMs
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2079368
Upstream Status: net-next.git commit 4638de5aefe5

commit 4638de5aefe56366726e5107a9da13ce5c84a1b7
Author: Kishen Maloor <kishen.maloor@intel.com>
Date:   Tue May 3 19:38:49 2022 -0700

    mptcp: handle local addrs announced by userspace PMs

    This change adds an internal function to store/retrieve local
    addrs announced by userspace PM implementations to/from its kernel
    context. The function addresses the requirements of three scenarios:
    1) ADD_ADDR announcements (which require that a local id be
    provided), 2) retrieving the local id associated with an address,
    and also where one may need to be assigned, and 3) reissuance of
    ADD_ADDRs when there's a successful match of addr/id.

    The list of all stored local addr entries is held under the
    MPTCP sock structure. Memory for these entries is allocated from
    the sock option buffer, so the list of addrs is bounded by optmem_max.
    The list if not released via REMOVE_ADDR signals is ultimately
    freed when the sock is destructed.

    Acked-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Kishen Maloor <kishen.maloor@intel.com>
    Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
2022-05-06 11:03:26 +02:00