BPF path manager, part 4
Subsystems (2)
Geliang Tang
reviewerv2 cover BPF path manager, part 4
From: Geliang Tang <[email protected]>
v2:
- update get_local_id interface in patch 2.
Depends on: "BPF path manager, part 3" v3
Based-on: <[email protected]>
get_addr() and dump_addr() interfaces of BPF userspace pm are dropped as Matt suggested.
In order to implement BPF userspace path manager, it is necessary to unify the interfaces of the path manager. This set contains some cleanups and refactoring to unify the interfaces in kernel space. Finally, define a struct mptcp_pm_ops for a userspace path manager like this:
struct mptcp_pm_ops {
int (*address_announce)(struct mptcp_sock *msk,
struct mptcp_pm_addr_entry *local);
int (*address_remove)(struct mptcp_sock *msk, u8 id);
int (*subflow_create)(struct mptcp_sock *msk,
struct mptcp_pm_addr_entry *local,
struct mptcp_addr_info *remote);
int (*subflow_destroy)(struct mptcp_sock *msk,
struct mptcp_pm_addr_entry *local,
struct mptcp_addr_info *remote);
int (*get_local_id)(struct mptcp_sock *msk,
struct mptcp_pm_addr_entry *local);
u8 (*get_flags)(struct mptcp_sock *msk,
struct mptcp_addr_info *skc);
int (*set_flags)(struct mptcp_sock *msk,
struct mptcp_pm_addr_entry *local,
struct mptcp_addr_info *remote);
u8 type;
struct module *owner;
struct list_head list;
void (*init)(struct mptcp_sock *msk);
void (*release)(struct mptcp_sock *msk);
} ____cacheline_aligned_in_smp;Geliang Tang (3):
mptcp: define struct mptcp_pm_ops
mptcp: register default userspace pm
mptcp: init and release mptcp_pm_ops
include/net/mptcp.h | 27 +++ net/mptcp/pm.c | 8 + net/mptcp/pm_userspace.c | 376 ++++++++++++++++++++++++++++----------- net/mptcp/protocol.c | 1 + net/mptcp/protocol.h | 9 + 5 files changed, 317 insertions(+), 104 deletions(-)
Signature · 1 line
2.43.0
Geliang Tang
reviewerPATCH v2 1/3 mptcp: define struct mptcp_pm_ops
From: Geliang Tang <[email protected]>
In order to allow users to develop their own BPF-based path manager, this patch defines a struct ops "mptcp_pm_ops" for a userspace path manager, which contains a set of interfaces.
Add a set of functions to register, unregister, find and validate a given struct ops.
--- include/net/mptcp.h | 27 +++++++++++++++++++ net/mptcp/pm_userspace.c | 57 ++++++++++++++++++++++++++++++++++++++++ net/mptcp/protocol.h | 5 ++++ 3 files changed, 89 insertions(+)
include/net/mptcp.h +27 -0
@@ -14,6 +14,7 @@struct mptcp_info ;struct mptcp_sock ; +struct mptcp_pm_addr_entry ;struct seq_file ;/* MPTCP sk_buff extension data */
@@ -120,6 +121,32 @@ struct mptcp_sched_ops {void (*release)(struct mptcp_sock *msk); }____cacheline_aligned_in_smp ; +struct mptcp_pm_ops { +int (*address_announce)(struct mptcp_sock *msk, +struct mptcp_pm_addr_entry *local); +int (*address_remove)(struct mptcp_sock *msk,u8 id); +int (*subflow_create)(struct mptcp_sock *msk, +struct mptcp_pm_addr_entry *local, +struct mptcp_addr_info *remote); +int (*subflow_destroy)(struct mptcp_sock *msk, +struct mptcp_pm_addr_entry *local, +struct mptcp_addr_info *remote); +int (*get_local_id)(struct mptcp_sock *msk, +struct mptcp_pm_addr_entry *local); +u8 (*get_flags)(struct mptcp_sock *msk, +struct mptcp_addr_info *skc); +int (*set_flags)(struct mptcp_sock *msk, +struct mptcp_pm_addr_entry *local, +struct mptcp_addr_info *remote); + +u8 type; +struct module *owner; +struct list_head list; + +void (*init)(struct mptcp_sock *msk); +void (*release)(struct mptcp_sock *msk); +}____cacheline_aligned_in_smp ; +#ifdef CONFIG_MPTCP void mptcp_init (void );
net/mptcp/pm_userspace.c +57 -0
72 lines not on this page · raw message
net/mptcp/protocol.h +5 -0
@@ -1048,6 +1048,11 @@ int mptcp_pm_remove_addr(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_void mptcp_pm_remove_addr_entry (struct mptcp_sock *msk,struct mptcp_pm_addr_entry *entry); +struct mptcp_pm_ops *mptcp_pm_find (enum mptcp_pm_type type); +int mptcp_validate_path_manager (struct mptcp_pm_ops *pm); +int mptcp_register_path_manager (struct mptcp_pm_ops *pm); +void mptcp_unregister_path_manager (struct mptcp_pm_ops *pm); +void mptcp_free_local_addr_list (struct mptcp_sock *msk); void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk,
Signature · 1 line
2.43.0
Geliang Tang
reviewerPATCH v2 2/3 mptcp: register default userspace pm
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
This patch defines the original userspace pm as the default path manager, named mptcp_userspace_pm, and register it in mptcp_pm_data_init().
Extract address_announce() interface of the userspace PM from the handler of netlink commond MPTCP_PM_CMD_ANNOUNCE mptcp_pm_nl_announce_doit(), only leave the code for obtaining msk through "info" and parsing address entry in the handler.
Extract address_remove() interface of the userspace PM from the handler of netlink commond MPTCP_PM_CMD_REMOVE mptcp_pm_nl_remove_doit(), only leave the code for parsing address id and obtaining msk through "info" in the handler.
Extract subflow_create() interface of the userspace PM from the handler of netlink commond MPTCP_PM_CMD_SUBFLOW_CREATE
mptcp_pm_nl_subflow_create_doit(),
only leave the code for obtaining msk through "info", parsing local address entry and parsing remote address info in the handler.
Extract subflow_destroy() interface of the userspace PM from the handler of netlink commond MPTCP_PM_CMD_SUBFLOW_DESTROY
mptcp_pm_nl_subflow_destroy_doit(),
only leave the code for obtaining msk through "info", parsing local address entry and parsing remote address info in the handler.
Extract set_flags() interface of the userspace PM from function mptcp_userspace_pm_set_flags(), only leave the code for obtaining msk through "info" in this function.
All fives interfaces are invoked under holding the msk socket lock.
Extract get_local_id() interface of the userspace PM from function mptcp_userspace_pm_get_local_id(), only leave the code for setting new address entry in this function.
get_flags() interface of the userspace PM is defined as the same as the function mptcp_userspace_pm_get_flags(), then this function becomes a wrapper.
--- net/mptcp/pm.c | 1 + net/mptcp/pm_userspace.c | 275 ++++++++++++++++++++++++--------------- net/mptcp/protocol.h | 1 + 3 files changed, 173 insertions(+), 104 deletions(-)
net/mptcp/pm.c +1 -0
@@ -646,4 +646,5 @@ void mptcp_pm_data_init(struct mptcp_sock *msk)void __init mptcp_pm_init (void ) {mptcp_pm_nl_init (); +mptcp_userspace_pm_init (); }
net/mptcp/pm_userspace.c +171 -104
410 lines not on this page · raw message
net/mptcp/protocol.h +1 -0
@@ -1160,6 +1160,7 @@ static inline u8 subflow_get_local_id(const struct mptcp_subflow_context *subflo }void __init mptcp_pm_nl_init (void ); +void __init mptcp_userspace_pm_init (void );void mptcp_pm_nl_work (struct mptcp_sock *msk);unsigned int mptcp_pm_get_add_addr_signal_max (const struct mptcp_sock *msk);unsigned int mptcp_pm_get_add_addr_accept_max (const struct mptcp_sock *msk);
Signature · 1 line
2.43.0
Geliang Tang
reviewerRe: [PATCH mptcp-next v2 2/3] mptcp: register default userspace pm
Quoted 9 lines · Geliang Tang
From: Geliang Tang <[email protected]>
This patch defines the original userspace pm as the default path manager,
namedmptcp_userspace_pm, and register it inmptcp_pm_data_init().Extract
address_announce()interface of the userspace PM from the handler
of netlink commondMPTCP_PM_CMD_ANNOUNCEmptcp_pm_nl_announce_doit(),
CI reports some warnings:
WARNING: 'commond' may be misspelled - perhaps 'command'?
Will update them in the next version.
Thanks,
-Geliang
Quoted 549 lines
only
leave the code for obtaining msk through "info" and parsing address entry
in the handler.Extract
address_remove()interface of the userspace PM from the handler
of netlink commondMPTCP_PM_CMD_REMOVEmptcp_pm_nl_remove_doit(), only
leave the code for parsing address id and obtaining msk through "info"
in the handler.Extract
subflow_create()interface of the userspace PM from the handler of
netlink commondMPTCP_PM_CMD_SUBFLOW_CREATE
mptcp_pm_nl_subflow_create_doit(),only leave the code for obtaining msk through "info", parsing local address
entry and parsing remote address info in the handler.Extract
subflow_destroy()interface of the userspace PM from the handler of
netlink commondMPTCP_PM_CMD_SUBFLOW_DESTROY
mptcp_pm_nl_subflow_destroy_doit(),only leave the code for obtaining msk through "info", parsing local address
entry and parsing remote address info in the handler.Extract
set_flags()interface of the userspace PM from functionmptcp_userspace_pm_set_flags(), only leave the code for obtaining msk through "info" in this function.All fives interfaces are invoked under holding the msk socket lock.
Extract
get_local_id()interface of the userspace PM from functionmptcp_userspace_pm_get_local_id(), only leave the code for setting new address entry in this function.
get_flags()interface of the userspace PM is defined as the same as the functionmptcp_userspace_pm_get_flags(), then this function becomes a wrapper.Signed-off-by Geliang Tang <[email protected]>---
net/mptcp/pm.c | 1 +
net/mptcp/pm_userspace.c | 275 ++++++++++++++++++++++++------------- --
net/mptcp/protocol.h | 1 +3 files changed, 173 insertions(+), 104 deletions(-)net/mptcp/pm.c +1
-0@@ -646,4 +646,5 @@ void mptcp_pm_data_init(struct mptcp_sock *msk) void __init mptcp_pm_init(void) { mptcp_pm_nl_init(); +mptcp_userspace_pm_init (); }net/mptcp/pm_userspace.c +0
-0@@ -135,32 +135,40 @@ mptcp_userspace_pm_lookup_addr_by_id(struct mptcp_sock *msk, unsigned int id) return NULL; }net/mptcp/pm_userspace.c +2
-2-int mptcp_userspace_pm_get_local_id (struct mptcp_sock *msk, - struct mptcp_addr_info *skc) +static int userspace_pm_get_local_id (struct mptcp_sock *msk, + struct mptcp_pm_addr_entry*local)
{net/mptcp/pm_userspace.c +0
-1-struct mptcp_pm_addr_entry *entry =NULL , new_entry;
__be16msk_sport= ((structinet_sock*)inet_sk((struct sock *)msk))-Quoted 1 line
inet_sport;net/mptcp/pm_userspace.c +1
-0+struct mptcp_pm_addr_entry *entry;
spin_lock_bh(&msk->pm.lock);net/mptcp/pm_userspace.c +1
-1- entry =mptcp_userspace_pm_lookup_addr (msk, skc); + entry =mptcp_userspace_pm_lookup_addr (msk, &local->addr);
spin_unlock_bh(&msk->pm.lock);
if (entry)
returnentry->addr.id;net/mptcp/pm_userspace.c +4
-0+if (local->addr.port == msk_sport) + local->addr.port =0 ; + + return mptcp_userspace_pm_append_new_local_addr(msk, local,true);
net/mptcp/pm_userspace.c +7
-0+} + +int mptcp_userspace_pm_get_local_id (struct mptcp_sock *msk, + struct mptcp_addr_info *skc) +{ +struct mptcp_pm_addr_entry new_entry; +
memset(&new_entry, 0, sizeof(struct mptcp_pm_addr_entry)); new_entry.addr = *skc;
new_entry.addr.id = 0;
new_entry.flags =MPTCP_PM_ADDR_FLAG_IMPLICIT;net/mptcp/pm_userspace.c +0
-4-if (new_entry.addr.port == msk_sport) - new_entry.addr.port =0 ; - - return mptcp_userspace_pm_append_new_local_addr(msk,
&new_entry, true);net/mptcp/pm_userspace.c +1
-0+return userspace_pm_get_local_id (msk, &new_entry);}
net/mptcp/pm_userspace.c +2
-2-u8 mptcp_userspace_pm_get_flags (struct mptcp_sock *msk, -struct mptcp_addr_info *skc) +static u8 userspace_pm_get_flags (struct mptcp_sock *msk, +struct mptcp_addr_info *skc){
structmptcp_pm_addr_entry*entry;
u8 flags;net/mptcp/pm_userspace.c +0
-0@@ -173,6 +181,12 @@ u8 mptcp_userspace_pm_get_flags(structmptcp_sock *msk, return flags; }net/mptcp/pm_userspace.c +6
-0+u8 mptcp_userspace_pm_get_flags (struct mptcp_sock *msk, +struct mptcp_addr_info *skc) +{ +return userspace_pm_get_flags (msk, skc); +} +static struct
mptcp_sock*mptcp_userspace_pm_get_sock(const structgenl_info*info)
{
structmptcp_sock*msk;net/mptcp/pm_userspace.c +0
-0@@ -198,6 +212,28 @@ static struct mptcp_sock *mptcp_userspace_pm_get_sock(const struct genl_info *in return msk; }net/mptcp/pm_userspace.c +2
-0+static int userspace_pm_address_announce (struct mptcp_sock *msk, + struct mptcp_pm_addr_entry*local)
net/mptcp/pm_userspace.c +4
-0+{ +int err; + + err = mptcp_userspace_pm_append_new_local_addr(msk, local,false);
net/mptcp/pm_userspace.c +16
-0+if (err <0 ) +return err; + +spin_lock_bh (&msk->pm.lock); + +if (mptcp_pm_alloc_anno_list (msk, &local->addr)) { + msk->pm.add_addr_signaled++; +mptcp_pm_announce_addr (msk, &local->addr, false); +mptcp_pm_nl_addr_send_ack (msk); + } + +spin_unlock_bh (&msk->pm.lock); + +return 0 ; +} +int
mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info)
{
structmptcp_pm_addr_entryaddr_val;net/mptcp/pm_userspace.c +0
-0@@ -232,26 +268,13 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info) goto announce_err; }net/mptcp/pm_userspace.c +0
-1- err = mptcp_userspace_pm_append_new_local_addr(msk,
&addr_val, false);net/mptcp/pm_userspace.c +0
-6-if (err <0 ) { -NL_SET_ERR_MSG_ATTR (info->extack, addr, - "did not match address and id"); - goto announce_err; - } -
lock_sock(sk);net/mptcp/pm_userspace.c +1
-9-spin_lock_bh (&msk->pm.lock); - -if (mptcp_pm_alloc_anno_list (msk, &addr_val.addr)) { - msk->pm.add_addr_signaled++; -mptcp_pm_announce_addr (msk, &addr_val.addr, false); -mptcp_pm_nl_addr_send_ack (msk); - } - -spin_unlock_bh (&msk->pm.lock); + err =userspace_pm_address_announce (msk, &addr_val);
release_sock(sk);net/mptcp/pm_userspace.c +3
-0+if (err) +NL_SET_ERR_MSG_ATTR (info->extack, addr, + "did not match address and id");net/mptcp/pm_userspace.c +0
-1- err =0 ;
announce_err:
sock_put(sk);
return err;net/mptcp/pm_userspace.c +0
-0@@ -301,9 +324,32 @@ void mptcp_pm_remove_addr_entry(structmptcp_sock *msk, spin_unlock_bh(&msk->pm.lock); }
+static intuserspace_pm_address_remove(struct mptcp_sock *msk, u8 id)net/mptcp/pm_userspace.c +5
-0+{ +struct mptcp_pm_addr_entry *entry; + +if (id ==0 ) +return
mptcp_userspace_pm_remove_id_zero_address(msk);net/mptcp/pm_userspace.c +18
-0+ +spin_lock_bh (&msk->pm.lock); + entry =mptcp_userspace_pm_lookup_addr_by_id (msk, id); +if (!entry) { +spin_unlock_bh (&msk->pm.lock); +return -EINVAL ; + } + +list_del_rcu (&entry->list); +spin_unlock_bh (&msk->pm.lock); + +mptcp_pm_remove_addr_entry (msk, entry); + +sock_kfree_s ((struct sock *)msk, entry,sizeof (*entry)); + +return 0 ; +} +int
mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info)
{net/mptcp/pm_userspace.c +0
-1-struct mptcp_pm_addr_entry *match;struct
mptcp_sock*msk;
struct nlattr *id;
int err =-EINVAL;net/mptcp/pm_userspace.c +0
-0@@ -323,32 +369,8 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) sk = (struct sock *)msk;
lock_sock(sk);net/mptcp/pm_userspace.c +0
-3- -if (id_val ==0 ) { - err =
mptcp_userspace_pm_remove_id_zero_address(msk);net/mptcp/pm_userspace.c +1
-17-release_sock (sk); - goto out; - } - -spin_lock_bh (&msk->pm.lock); - match =mptcp_userspace_pm_lookup_addr_by_id (msk, id_val); -if (!match) { -spin_unlock_bh (&msk->pm.lock); -release_sock (sk); - goto out; - } - -list_del_rcu (&match->list); -spin_unlock_bh (&msk->pm.lock); - -mptcp_pm_remove_addr_entry (msk, match); - + err =userspace_pm_address_remove (msk, id_val);
release_sock(sk);net/mptcp/pm_userspace.c +0
-5- -sock_kfree_s (sk, match,sizeof (*match)); - - err =0 ; -out:if (err) NL_SET_ERR_MSG_ATTR_FMT(info->extack, id, "address with id %u not found",
net/mptcp/pm_userspace.c +0
-0@@ -358,12 +380,38 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) return err; }net/mptcp/pm_userspace.c +2
-0+static int userspace_pm_subflow_create (struct mptcp_sock *msk, + struct mptcp_pm_addr_entry*entry,
net/mptcp/pm_userspace.c +1
-0+ struct mptcp_addr_info*remote)
net/mptcp/pm_userspace.c +6
-0+{ +struct sock *sk = (struct sock *)msk; +struct mptcp_pm_local local; +int err; + + err = mptcp_userspace_pm_append_new_local_addr(msk, entry,false);
net/mptcp/pm_userspace.c +18
-0+if (err <0 ) +return err; + + local.addr = entry->addr; + local.flags = entry->flags; + local.ifindex = entry->ifindex; + + err =__mptcp_subflow_connect (sk, &local, remote); +spin_lock_bh (&msk->pm.lock); +if (err) +mptcp_userspace_pm_delete_local_addr (msk, entry); +else + msk->pm.subflows++; +spin_unlock_bh (&msk->pm.lock); + +return 0 ; +} +int
mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info)
{
structmptcp_pm_addr_entryentry = { 0 }; structmptcp_addr_infoaddr_r;
struct nlattr *raddr, *laddr;net/mptcp/pm_userspace.c +0
-1-struct mptcp_pm_local local;struct
mptcp_sock*msk;
int err =-EINVAL;
struct sock *sk;net/mptcp/pm_userspace.c +0
-0@@ -401,31 +449,13 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) goto create_err; }net/mptcp/pm_userspace.c +0
-1- err = mptcp_userspace_pm_append_new_local_addr(msk, &entry,false);
net/mptcp/pm_userspace.c +0
-10-if (err <0 ) { -NL_SET_ERR_MSG_ATTR (info->extack, laddr, - "did not match address and id"); - goto create_err; - } - - local.addr = entry.addr; - local.flags = entry.flags; - local.ifindex = entry.ifindex; -
lock_sock(sk);net/mptcp/pm_userspace.c +1
-1- err =__mptcp_subflow_connect (sk, &local, &addr_r); + err =userspace_pm_subflow_create (msk, &entry, &addr_r);
release_sock(sk);
if (err)
GENL_SET_ERR_MSG_FMT(info, "connect error: %d", err);net/mptcp/pm_userspace.c +0
-7-spin_lock_bh (&msk->pm.lock); -if (err) -mptcp_userspace_pm_delete_local_addr (msk, &entry); -else - msk->pm.subflows++; -spin_unlock_bh (&msk->pm.lock); -
create_err:
sock_put(sk);
return err;net/mptcp/pm_userspace.c +0
-0@@ -477,14 +507,34 @@ static struct sock *mptcp_nl_find_ssk(struct mptcp_sock *msk, return NULL; }net/mptcp/pm_userspace.c +2
-0+static int userspace_pm_subflow_destroy (struct mptcp_sock *msk, + struct mptcp_pm_addr_entry*local,
net/mptcp/pm_userspace.c +1
-0+struct mptcp_addr_info *remote)
net/mptcp/pm_userspace.c +11
-0+{ +struct sock *ssk, *sk = (struct sock *)msk; + + ssk =mptcp_nl_find_ssk (msk, &local->addr, remote); +if (!ssk) +return -ESRCH ; + +spin_lock_bh (&msk->pm.lock); +mptcp_userspace_pm_delete_local_addr (msk, local); +spin_unlock_bh (&msk->pm.lock); + mptcp_subflow_shutdown(sk, ssk, RCV_SHUTDOWN |
SEND_SHUTDOWN);net/mptcp/pm_userspace.c +6
-0+mptcp_close_ssk (sk, ssk,mptcp_subflow_ctx (ssk)); +MPTCP_INC_STATS (sock_net (sk),MPTCP_MIB_RMSUBFLOW ); + +return 0 ; +} +int
mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info)
{
structmptcp_pm_addr_entryaddr_l;
structmptcp_addr_infoaddr_r;
struct nlattr *raddr, *laddr;
structmptcp_sock*msk;net/mptcp/pm_userspace.c +0
-1-struct sock *sk, *ssk;int err =
-EINVAL;net/mptcp/pm_userspace.c +1
-0+struct sock *sk;
if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR)||GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR_REMOTE))net/mptcp/pm_userspace.c +0
-0@@ -535,37 +585,47 @@ int mptcp_pm_nl_subflow_destroy_doit(struct
sk_buff*skb, structgenl_info*info
}
lock_sock(sk);net/mptcp/pm_userspace.c +0
-11- ssk =mptcp_nl_find_ssk (msk, &addr_l.addr, &addr_r); -if (!ssk) { -GENL_SET_ERR_MSG (info,"subflow not found" ); - err = -ESRCH ; - goto release_sock; - } - -spin_lock_bh (&msk->pm.lock); -mptcp_userspace_pm_delete_local_addr (msk, &addr_l); -spin_unlock_bh (&msk->pm.lock); - mptcp_subflow_shutdown(sk, ssk, RCV_SHUTDOWN |
SEND_SHUTDOWN);net/mptcp/pm_userspace.c +1
-3-mptcp_close_ssk (sk, ssk,mptcp_subflow_ctx (ssk)); -MPTCP_INC_STATS (sock_net (sk),MPTCP_MIB_RMSUBFLOW ); -release_sock: + err =userspace_pm_subflow_destroy (msk, &addr_l, &addr_r);
release_sock(sk);net/mptcp/pm_userspace.c +2
-0+if (err) +GENL_SET_ERR_MSG (info,"subflow not found" );
destroy_err:
sock_put(sk);
return err;
}net/mptcp/pm_userspace.c +21
-0+static int userspace_pm_set_flags (struct mptcp_sock *msk, + struct mptcp_pm_addr_entry *local, + struct mptcp_addr_info *remote) +{ +struct mptcp_pm_addr_entry *entry; +u8 bkup =0 ; + +if (local->flags &MPTCP_PM_ADDR_FLAG_BACKUP ) + bkup =1 ; + +spin_lock_bh (&msk->pm.lock); + entry =mptcp_userspace_pm_lookup_addr (msk, &local->addr); +if (entry) { +if (bkup) + entry->flags |=MPTCP_PM_ADDR_FLAG_BACKUP ; +else + entry->flags &= ~MPTCP_PM_ADDR_FLAG_BACKUP ; + } +spin_unlock_bh (&msk->pm.lock); + + return mptcp_pm_nl_mp_prio_send_ack(msk, &local->addr,remote, bkup);
net/mptcp/pm_userspace.c +2
-0+} +int
mptcp_userspace_pm_set_flags(struct mptcp_pm_addr_entry *local, struct genl_info *info){
structmptcp_addr_inforem = { .family =AF_UNSPEC, };net/mptcp/pm_userspace.c +0
-1-struct mptcp_pm_addr_entry *entry;struct nlattr *attr,
*attr_rem;
structmptcp_sock*msk;
int ret =-EINVAL;
struct sock *sk;net/mptcp/pm_userspace.c +0
-1-u8 bkup =0 ;
if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR_REMOTE)) return ret;net/mptcp/pm_userspace.c +0
-0@@ -596,21 +656,8 @@ int mptcp_userspace_pm_set_flags(structmptcp_pm_addr_entry *local, goto set_flags_err; }net/mptcp/pm_userspace.c +0
-13-if (local->flags &MPTCP_PM_ADDR_FLAG_BACKUP ) - bkup =1 ; - -spin_lock_bh (&msk->pm.lock); - entry =mptcp_userspace_pm_lookup_addr (msk, &local->addr); -if (entry) { -if (bkup) - entry->flags |=MPTCP_PM_ADDR_FLAG_BACKUP ; -else - entry->flags &= ~MPTCP_PM_ADDR_FLAG_BACKUP ; - } -spin_unlock_bh (&msk->pm.lock); -
lock_sock(sk);net/mptcp/pm_userspace.c +0
-1- ret = mptcp_pm_nl_mp_prio_send_ack(msk, &local->addr, &rem,bkup);
net/mptcp/pm_userspace.c +1
-0+ ret =userspace_pm_set_flags (msk, local, &rem);
release_sock(sk);
/*mptcp_pm_nl_mp_prio_send_ack()only fails in one case */net/mptcp/pm_userspace.c +0
-0@@ -687,6 +734,18 @@ int mptcp_userspace_pm_get_addr(u8 id, structmptcp_pm_addr_entry *addr, return ret; }net/mptcp/pm_userspace.c +3
-0+static struct mptcp_pm_ops mptcp_userspace_pm = { + .address_announce = userspace_pm_address_announce, + .address_remove =
userspace_pm_address_remove,net/mptcp/pm_userspace.c +1
-0+ .subflow_create =
userspace_pm_subflow_create,net/mptcp/pm_userspace.c +8
-0+ .subflow_destroy = userspace_pm_subflow_destroy, + .get_local_id = userspace_pm_get_local_id, + .get_flags = userspace_pm_get_flags, + .set_flags = userspace_pm_set_flags, + .type = MPTCP_PM_TYPE_USERSPACE, + .owner = THIS_MODULE, +}; +/* Must be called with rcu read lock held */ struct
mptcp_pm_ops*mptcp_pm_find(enummptcp_pm_typetype) {net/mptcp/pm_userspace.c +0
-0@@ -734,7 +793,15 @@ int mptcp_register_path_manager(struct mptcp_pm_ops *pm)
voidmptcp_unregister_path_manager(struct mptcp_pm_ops *pm){net/mptcp/pm_userspace.c +3
-0+if (pm == &mptcp_userspace_pm) +return ; +
spin_lock(&mptcp_pm_list_lock);
list_del_rcu(&pm->list);
spin_unlock(&mptcp_pm_list_lock);
}net/mptcp/pm_userspace.c +5
-0+ +void __init mptcp_userspace_pm_init (void ) +{ +mptcp_register_path_manager (&mptcp_userspace_pm); +}net/mptcp/protocol.h +0
-0@@ -1160,6 +1160,7 @@ static inline u8 subflow_get_local_id(conststruct
mptcp_subflow_context*subflo
}
void__initmptcp_pm_nl_init(void);
+void__initmptcp_userspace_pm_init(void);
voidmptcp_pm_nl_work(struct mptcp_sock *msk); unsigned intmptcp_pm_get_add_addr_signal_max(const struct mptcp_sock *msk);
unsigned intmptcp_pm_get_add_addr_accept_max(const struct mptcp_sock *msk);
Geliang Tang
reviewerRe: [PATCH mptcp-next v2 2/3] mptcp: register default userspace pm
In reply to Geliang TangQuoted 313 lines · Geliang Tang
From: Geliang Tang <[email protected]>
This patch defines the original userspace pm as the default path manager,
namedmptcp_userspace_pm, and register it inmptcp_pm_data_init().Extract
address_announce()interface of the userspace PM from the handler
of netlink commondMPTCP_PM_CMD_ANNOUNCEmptcp_pm_nl_announce_doit(), only
leave the code for obtaining msk through "info" and parsing address entry
in the handler.Extract
address_remove()interface of the userspace PM from the handler
of netlink commondMPTCP_PM_CMD_REMOVEmptcp_pm_nl_remove_doit(), only
leave the code for parsing address id and obtaining msk through "info"
in the handler.Extract
subflow_create()interface of the userspace PM from the handler of
netlink commondMPTCP_PM_CMD_SUBFLOW_CREATE
mptcp_pm_nl_subflow_create_doit(),only leave the code for obtaining msk through "info", parsing local address
entry and parsing remote address info in the handler.Extract
subflow_destroy()interface of the userspace PM from the handler of
netlink commondMPTCP_PM_CMD_SUBFLOW_DESTROY
mptcp_pm_nl_subflow_destroy_doit(),only leave the code for obtaining msk through "info", parsing local address
entry and parsing remote address info in the handler.Extract
set_flags()interface of the userspace PM from functionmptcp_userspace_pm_set_flags(), only leave the code for obtaining msk through "info" in this function.All fives interfaces are invoked under holding the msk socket lock.
Extract
get_local_id()interface of the userspace PM from functionmptcp_userspace_pm_get_local_id(), only leave the code for setting new address entry in this function.
get_flags()interface of the userspace PM is defined as the same as the functionmptcp_userspace_pm_get_flags(), then this function becomes a wrapper.Signed-off-by Geliang Tang <[email protected]>---
net/mptcp/pm.c | 1 +
net/mptcp/pm_userspace.c | 275 ++++++++++++++++++++++++------------- --
net/mptcp/protocol.h | 1 +3 files changed, 173 insertions(+), 104 deletions(-)net/mptcp/pm.c +1
-0@@ -646,4 +646,5 @@ void mptcp_pm_data_init(struct mptcp_sock *msk) void __init mptcp_pm_init(void) { mptcp_pm_nl_init(); +mptcp_userspace_pm_init (); }net/mptcp/pm_userspace.c +0
-0@@ -135,32 +135,40 @@ mptcp_userspace_pm_lookup_addr_by_id(struct mptcp_sock *msk, unsigned int id) return NULL; }net/mptcp/pm_userspace.c +2
-2-int mptcp_userspace_pm_get_local_id (struct mptcp_sock *msk, - struct mptcp_addr_info *skc) +static int userspace_pm_get_local_id (struct mptcp_sock *msk, + struct mptcp_pm_addr_entry*local)
{net/mptcp/pm_userspace.c +0
-1-struct mptcp_pm_addr_entry *entry =NULL , new_entry;
__be16msk_sport= ((structinet_sock*)inet_sk((struct sock *)msk))-Quoted 1 line
inet_sport;net/mptcp/pm_userspace.c +1
-0+struct mptcp_pm_addr_entry *entry;
spin_lock_bh(&msk->pm.lock);net/mptcp/pm_userspace.c +1
-1- entry =mptcp_userspace_pm_lookup_addr (msk, skc); + entry =mptcp_userspace_pm_lookup_addr (msk, &local->addr);
spin_unlock_bh(&msk->pm.lock);
if (entry)
returnentry->addr.id;net/mptcp/pm_userspace.c +4
-0+if (local->addr.port == msk_sport) + local->addr.port =0 ; + + return mptcp_userspace_pm_append_new_local_addr(msk, local,true);
net/mptcp/pm_userspace.c +7
-0+} + +int mptcp_userspace_pm_get_local_id (struct mptcp_sock *msk, + struct mptcp_addr_info *skc) +{ +struct mptcp_pm_addr_entry new_entry; +
memset(&new_entry, 0, sizeof(struct mptcp_pm_addr_entry)); new_entry.addr = *skc;
new_entry.addr.id = 0;
new_entry.flags =MPTCP_PM_ADDR_FLAG_IMPLICIT;net/mptcp/pm_userspace.c +0
-4-if (new_entry.addr.port == msk_sport) - new_entry.addr.port =0 ; - - return mptcp_userspace_pm_append_new_local_addr(msk,
&new_entry, true);net/mptcp/pm_userspace.c +1
-0+return userspace_pm_get_local_id (msk, &new_entry);}
net/mptcp/pm_userspace.c +2
-2-u8 mptcp_userspace_pm_get_flags (struct mptcp_sock *msk, -struct mptcp_addr_info *skc) +static u8 userspace_pm_get_flags (struct mptcp_sock *msk, +struct mptcp_addr_info *skc){
structmptcp_pm_addr_entry*entry;
u8 flags;net/mptcp/pm_userspace.c +0
-0@@ -173,6 +181,12 @@ u8 mptcp_userspace_pm_get_flags(structmptcp_sock *msk, return flags; }net/mptcp/pm_userspace.c +6
-0+u8 mptcp_userspace_pm_get_flags (struct mptcp_sock *msk, +struct mptcp_addr_info *skc) +{ +return userspace_pm_get_flags (msk, skc); +} +static struct
mptcp_sock*mptcp_userspace_pm_get_sock(const structgenl_info*info)
{
structmptcp_sock*msk;net/mptcp/pm_userspace.c +0
-0@@ -198,6 +212,28 @@ static struct mptcp_sock *mptcp_userspace_pm_get_sock(const struct genl_info *in return msk; }net/mptcp/pm_userspace.c +2
-0+static int userspace_pm_address_announce (struct mptcp_sock *msk, + struct mptcp_pm_addr_entry*local)
net/mptcp/pm_userspace.c +4
-0+{ +int err; + + err = mptcp_userspace_pm_append_new_local_addr(msk, local,false);
net/mptcp/pm_userspace.c +16
-0+if (err <0 ) +return err; + +spin_lock_bh (&msk->pm.lock); + +if (mptcp_pm_alloc_anno_list (msk, &local->addr)) { + msk->pm.add_addr_signaled++; +mptcp_pm_announce_addr (msk, &local->addr, false); +mptcp_pm_nl_addr_send_ack (msk); + } + +spin_unlock_bh (&msk->pm.lock); + +return 0 ; +} +int
mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info)
{
structmptcp_pm_addr_entryaddr_val;net/mptcp/pm_userspace.c +0
-0@@ -232,26 +268,13 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info) goto announce_err; }net/mptcp/pm_userspace.c +0
-1- err = mptcp_userspace_pm_append_new_local_addr(msk,
&addr_val, false);net/mptcp/pm_userspace.c +0
-6-if (err <0 ) { -NL_SET_ERR_MSG_ATTR (info->extack, addr, - "did not match address and id"); - goto announce_err; - } -
lock_sock(sk);net/mptcp/pm_userspace.c +1
-9-spin_lock_bh (&msk->pm.lock); - -if (mptcp_pm_alloc_anno_list (msk, &addr_val.addr)) { - msk->pm.add_addr_signaled++; -mptcp_pm_announce_addr (msk, &addr_val.addr, false); -mptcp_pm_nl_addr_send_ack (msk); - } - -spin_unlock_bh (&msk->pm.lock); + err =userspace_pm_address_announce (msk, &addr_val);
release_sock(sk);net/mptcp/pm_userspace.c +3
-0+if (err) +NL_SET_ERR_MSG_ATTR (info->extack, addr, + "did not match address and id");net/mptcp/pm_userspace.c +0
-1- err =0 ;
announce_err:
sock_put(sk);
return err;net/mptcp/pm_userspace.c +0
-0@@ -301,9 +324,32 @@ void mptcp_pm_remove_addr_entry(structmptcp_sock *msk, spin_unlock_bh(&msk->pm.lock); }
+static intuserspace_pm_address_remove(struct mptcp_sock *msk, u8 id)net/mptcp/pm_userspace.c +5
-0+{ +struct mptcp_pm_addr_entry *entry; + +if (id ==0 ) +return
mptcp_userspace_pm_remove_id_zero_address(msk);net/mptcp/pm_userspace.c +18
-0+ +spin_lock_bh (&msk->pm.lock); + entry =mptcp_userspace_pm_lookup_addr_by_id (msk, id); +if (!entry) { +spin_unlock_bh (&msk->pm.lock); +return -EINVAL ; + } + +list_del_rcu (&entry->list); +spin_unlock_bh (&msk->pm.lock); + +mptcp_pm_remove_addr_entry (msk, entry); + +sock_kfree_s ((struct sock *)msk, entry,sizeof (*entry)); + +return 0 ; +} +int
mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info)
{net/mptcp/pm_userspace.c +0
-1-struct mptcp_pm_addr_entry *match;struct
mptcp_sock*msk;
struct nlattr *id;
int err =-EINVAL;net/mptcp/pm_userspace.c +0
-0@@ -323,32 +369,8 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) sk = (struct sock *)msk;
lock_sock(sk);net/mptcp/pm_userspace.c +0
-3- -if (id_val ==0 ) { - err =
mptcp_userspace_pm_remove_id_zero_address(msk);net/mptcp/pm_userspace.c +1
-17-release_sock (sk); - goto out; - } - -spin_lock_bh (&msk->pm.lock); - match =mptcp_userspace_pm_lookup_addr_by_id (msk, id_val); -if (!match) { -spin_unlock_bh (&msk->pm.lock); -release_sock (sk); - goto out; - } - -list_del_rcu (&match->list); -spin_unlock_bh (&msk->pm.lock); - -mptcp_pm_remove_addr_entry (msk, match); - + err =userspace_pm_address_remove (msk, id_val);
release_sock(sk);net/mptcp/pm_userspace.c +0
-5- -sock_kfree_s (sk, match,sizeof (*match)); - - err =0 ; -out:if (err) NL_SET_ERR_MSG_ATTR_FMT(info->extack, id, "address with id %u not found",
net/mptcp/pm_userspace.c +0
-0@@ -358,12 +380,38 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) return err; }net/mptcp/pm_userspace.c +2
-0+static int userspace_pm_subflow_create (struct mptcp_sock *msk, + struct mptcp_pm_addr_entry*entry,
net/mptcp/pm_userspace.c +1
-0+ struct mptcp_addr_info*remote)
net/mptcp/pm_userspace.c +6
-0+{ +struct sock *sk = (struct sock *)msk; +struct mptcp_pm_local local; +int err; + + err = mptcp_userspace_pm_append_new_local_addr(msk, entry,false);
net/mptcp/pm_userspace.c +6
-0+if (err <0 ) +return err; + + local.addr = entry->addr; + local.flags = entry->flags; + local.ifindex = entry->ifindex;
net/mptcp/pm_userspace.c int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) · line 407
Quoted 10 lines
net/mptcp/pm_userspace.c +10
-0+ + err =__mptcp_subflow_connect (sk, &local, remote); +spin_lock_bh (&msk->pm.lock); +if (err) +mptcp_userspace_pm_delete_local_addr (msk, entry); +else + msk->pm.subflows++; +spin_unlock_bh (&msk->pm.lock); + +return 0 ;
Should be 'return err;' here.
Will update it in the next version.
Thanks,
-Geliang
Quoted 235 lines
net/mptcp/pm_userspace.c +2
-0+} +int
mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info)
{
structmptcp_pm_addr_entryentry = { 0 }; structmptcp_addr_infoaddr_r;
struct nlattr *raddr, *laddr;net/mptcp/pm_userspace.c +0
-1-struct mptcp_pm_local local;struct
mptcp_sock*msk;
int err =-EINVAL;
struct sock *sk;net/mptcp/pm_userspace.c +0
-0@@ -401,31 +449,13 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) goto create_err; }net/mptcp/pm_userspace.c +0
-1- err = mptcp_userspace_pm_append_new_local_addr(msk, &entry,false);
net/mptcp/pm_userspace.c +0
-10-if (err <0 ) { -NL_SET_ERR_MSG_ATTR (info->extack, laddr, - "did not match address and id"); - goto create_err; - } - - local.addr = entry.addr; - local.flags = entry.flags; - local.ifindex = entry.ifindex; -
lock_sock(sk);net/mptcp/pm_userspace.c +1
-1- err =__mptcp_subflow_connect (sk, &local, &addr_r); + err =userspace_pm_subflow_create (msk, &entry, &addr_r);
release_sock(sk);
if (err)
GENL_SET_ERR_MSG_FMT(info, "connect error: %d", err);net/mptcp/pm_userspace.c +0
-7-spin_lock_bh (&msk->pm.lock); -if (err) -mptcp_userspace_pm_delete_local_addr (msk, &entry); -else - msk->pm.subflows++; -spin_unlock_bh (&msk->pm.lock); -
create_err:
sock_put(sk);
return err;net/mptcp/pm_userspace.c +0
-0@@ -477,14 +507,34 @@ static struct sock *mptcp_nl_find_ssk(struct mptcp_sock *msk, return NULL; }net/mptcp/pm_userspace.c +2
-0+static int userspace_pm_subflow_destroy (struct mptcp_sock *msk, + struct mptcp_pm_addr_entry*local,
net/mptcp/pm_userspace.c +1
-0+struct mptcp_addr_info *remote)
net/mptcp/pm_userspace.c +11
-0+{ +struct sock *ssk, *sk = (struct sock *)msk; + + ssk =mptcp_nl_find_ssk (msk, &local->addr, remote); +if (!ssk) +return -ESRCH ; + +spin_lock_bh (&msk->pm.lock); +mptcp_userspace_pm_delete_local_addr (msk, local); +spin_unlock_bh (&msk->pm.lock); + mptcp_subflow_shutdown(sk, ssk, RCV_SHUTDOWN |
SEND_SHUTDOWN);net/mptcp/pm_userspace.c +6
-0+mptcp_close_ssk (sk, ssk,mptcp_subflow_ctx (ssk)); +MPTCP_INC_STATS (sock_net (sk),MPTCP_MIB_RMSUBFLOW ); + +return 0 ; +} +int
mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info)
{
structmptcp_pm_addr_entryaddr_l;
structmptcp_addr_infoaddr_r;
struct nlattr *raddr, *laddr;
structmptcp_sock*msk;net/mptcp/pm_userspace.c +0
-1-struct sock *sk, *ssk;int err =
-EINVAL;net/mptcp/pm_userspace.c +1
-0+struct sock *sk;
if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR)||GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR_REMOTE))net/mptcp/pm_userspace.c +0
-0@@ -535,37 +585,47 @@ int mptcp_pm_nl_subflow_destroy_doit(struct
sk_buff*skb, structgenl_info*info
}
lock_sock(sk);net/mptcp/pm_userspace.c +0
-11- ssk =mptcp_nl_find_ssk (msk, &addr_l.addr, &addr_r); -if (!ssk) { -GENL_SET_ERR_MSG (info,"subflow not found" ); - err = -ESRCH ; - goto release_sock; - } - -spin_lock_bh (&msk->pm.lock); -mptcp_userspace_pm_delete_local_addr (msk, &addr_l); -spin_unlock_bh (&msk->pm.lock); - mptcp_subflow_shutdown(sk, ssk, RCV_SHUTDOWN |
SEND_SHUTDOWN);net/mptcp/pm_userspace.c +1
-3-mptcp_close_ssk (sk, ssk,mptcp_subflow_ctx (ssk)); -MPTCP_INC_STATS (sock_net (sk),MPTCP_MIB_RMSUBFLOW ); -release_sock: + err =userspace_pm_subflow_destroy (msk, &addr_l, &addr_r);
release_sock(sk);net/mptcp/pm_userspace.c +2
-0+if (err) +GENL_SET_ERR_MSG (info,"subflow not found" );
destroy_err:
sock_put(sk);
return err;
}net/mptcp/pm_userspace.c +21
-0+static int userspace_pm_set_flags (struct mptcp_sock *msk, + struct mptcp_pm_addr_entry *local, + struct mptcp_addr_info *remote) +{ +struct mptcp_pm_addr_entry *entry; +u8 bkup =0 ; + +if (local->flags &MPTCP_PM_ADDR_FLAG_BACKUP ) + bkup =1 ; + +spin_lock_bh (&msk->pm.lock); + entry =mptcp_userspace_pm_lookup_addr (msk, &local->addr); +if (entry) { +if (bkup) + entry->flags |=MPTCP_PM_ADDR_FLAG_BACKUP ; +else + entry->flags &= ~MPTCP_PM_ADDR_FLAG_BACKUP ; + } +spin_unlock_bh (&msk->pm.lock); + + return mptcp_pm_nl_mp_prio_send_ack(msk, &local->addr,remote, bkup);
net/mptcp/pm_userspace.c +2
-0+} +int
mptcp_userspace_pm_set_flags(struct mptcp_pm_addr_entry *local, struct genl_info *info){
structmptcp_addr_inforem = { .family =AF_UNSPEC, };net/mptcp/pm_userspace.c +0
-1-struct mptcp_pm_addr_entry *entry;struct nlattr *attr,
*attr_rem;
structmptcp_sock*msk;
int ret =-EINVAL;
struct sock *sk;net/mptcp/pm_userspace.c +0
-1-u8 bkup =0 ;
if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR_REMOTE)) return ret;net/mptcp/pm_userspace.c +0
-0@@ -596,21 +656,8 @@ int mptcp_userspace_pm_set_flags(structmptcp_pm_addr_entry *local, goto set_flags_err; }net/mptcp/pm_userspace.c +0
-13-if (local->flags &MPTCP_PM_ADDR_FLAG_BACKUP ) - bkup =1 ; - -spin_lock_bh (&msk->pm.lock); - entry =mptcp_userspace_pm_lookup_addr (msk, &local->addr); -if (entry) { -if (bkup) - entry->flags |=MPTCP_PM_ADDR_FLAG_BACKUP ; -else - entry->flags &= ~MPTCP_PM_ADDR_FLAG_BACKUP ; - } -spin_unlock_bh (&msk->pm.lock); -
lock_sock(sk);net/mptcp/pm_userspace.c +0
-1- ret = mptcp_pm_nl_mp_prio_send_ack(msk, &local->addr, &rem,bkup);
net/mptcp/pm_userspace.c +1
-0+ ret =userspace_pm_set_flags (msk, local, &rem);
release_sock(sk);
/*mptcp_pm_nl_mp_prio_send_ack()only fails in one case */net/mptcp/pm_userspace.c +0
-0@@ -687,6 +734,18 @@ int mptcp_userspace_pm_get_addr(u8 id, structmptcp_pm_addr_entry *addr, return ret; }net/mptcp/pm_userspace.c +3
-0+static struct mptcp_pm_ops mptcp_userspace_pm = { + .address_announce = userspace_pm_address_announce, + .address_remove =
userspace_pm_address_remove,net/mptcp/pm_userspace.c +1
-0+ .subflow_create =
userspace_pm_subflow_create,net/mptcp/pm_userspace.c +8
-0+ .subflow_destroy = userspace_pm_subflow_destroy, + .get_local_id = userspace_pm_get_local_id, + .get_flags = userspace_pm_get_flags, + .set_flags = userspace_pm_set_flags, + .type = MPTCP_PM_TYPE_USERSPACE, + .owner = THIS_MODULE, +}; +/* Must be called with rcu read lock held */ struct
mptcp_pm_ops*mptcp_pm_find(enummptcp_pm_typetype) {net/mptcp/pm_userspace.c +0
-0@@ -734,7 +793,15 @@ int mptcp_register_path_manager(struct mptcp_pm_ops *pm)
voidmptcp_unregister_path_manager(struct mptcp_pm_ops *pm){net/mptcp/pm_userspace.c +3
-0+if (pm == &mptcp_userspace_pm) +return ; +
spin_lock(&mptcp_pm_list_lock);
list_del_rcu(&pm->list);
spin_unlock(&mptcp_pm_list_lock);
}net/mptcp/pm_userspace.c +5
-0+ +void __init mptcp_userspace_pm_init (void ) +{ +mptcp_register_path_manager (&mptcp_userspace_pm); +}net/mptcp/protocol.h +0
-0@@ -1160,6 +1160,7 @@ static inline u8 subflow_get_local_id(conststruct
mptcp_subflow_context*subflo
}
void__initmptcp_pm_nl_init(void);
+void__initmptcp_userspace_pm_init(void);
voidmptcp_pm_nl_work(struct mptcp_sock *msk); unsigned intmptcp_pm_get_add_addr_signal_max(const struct mptcp_sock *msk);
unsigned intmptcp_pm_get_add_addr_accept_max(const struct mptcp_sock *msk);
Geliang Tang
reviewerPATCH v2 3/3 mptcp: init and release mptcp_pm_ops
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
Add a struct mptcp_pm_ops pointer "ops" in struct mptcp_pm_data, and two functions mptcp_init_pm() and mptcp_release_pm(), to set and release this pointer. mptcp_init_pm() is invoked in mptcp_pm_data_reset(), while mptcp_release_pm() is invoked in __mptcp_destroy_sock().
In this way, different userspace path managers can be initialized through the pm_type sysctl, and then called into their respective interfaces through "ops" of "msk->pm".
--- net/mptcp/pm.c | 7 +++++ net/mptcp/pm_userspace.c | 58 +++++++++++++++++++++++++++++++++++----- net/mptcp/protocol.c | 1 + net/mptcp/protocol.h | 3 +++ 4 files changed, 62 insertions(+), 7 deletions(-)
net/mptcp/pm.c +7 -0
@@ -600,6 +600,7 @@ void mptcp_pm_data_reset(struct mptcp_sock *msk) {u8 pm_type =mptcp_get_pm_type (sock_net ((struct sock *)msk));struct mptcp_pm_data *pm = &msk->pm; +int ret; pm->add_addr_signaled =0 ; pm->add_addr_accepted =0 ;
@@ -627,6 +628,12 @@ void mptcp_pm_data_reset(struct mptcp_sock *msk)WRITE_ONCE (pm->work_pending,0 );WRITE_ONCE (pm->accept_addr,0 );WRITE_ONCE (pm->accept_subflow,0 ); + +rcu_read_lock (); + ret =mptcp_init_pm (msk,mptcp_pm_find (pm_type)); +rcu_read_unlock (); +if (ret) +return ; }WRITE_ONCE (pm->addr_signal,0 );
net/mptcp/pm_userspace.c +51 -7
106 lines not on this page · raw message
net/mptcp/protocol.c +1 -0
@@ -2940,6 +2940,7 @@ static void __mptcp_destroy_sock(struct sock *sk)sk_stop_timer (sk, &sk->sk_timer); msk->pm.status =0 ;mptcp_release_sched (msk); +mptcp_release_pm (msk); sk->sk_prot->destroy (sk);
net/mptcp/protocol.h +3 -0
@@ -221,6 +221,7 @@ struct mptcp_pm_data {struct mptcp_addr_info remote;struct list_head anno_list;struct list_head userspace_pm_local_addr_list; +struct mptcp_pm_ops *ops;spinlock_t lock;/*protects the whole PM data */
@@ -1052,6 +1053,8 @@ struct mptcp_pm_ops *mptcp_pm_find(enum mptcp_pm_type type);int mptcp_validate_path_manager (struct mptcp_pm_ops *pm);int mptcp_register_path_manager (struct mptcp_pm_ops *pm);void mptcp_unregister_path_manager (struct mptcp_pm_ops *pm); +int mptcp_init_pm (struct mptcp_sock *msk,struct mptcp_pm_ops *pm); +void mptcp_release_pm (struct mptcp_sock *msk);void mptcp_free_local_addr_list (struct mptcp_sock *msk);
Signature · 1 line
2.43.0
Hi Geliang,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal: Success! ✅
- KVM Validation: debug: Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Unstable: 1 failed test(s): bpftest_test_progs-cpuv4_mptcp 🔴
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/12786155697
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/70af88472329
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=925640
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-normalFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)