From a83591e47729b0f2dd53189aac771fefa71762a4 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Sat, 16 Jan 2021 12:08:15 +0100 Subject: [PATCH 01/37] tg create t/mptcp-create-the-listening-socket-for-new-port base --- .topdeps | 1 - .topmsg | 8 -------- 2 files changed, 9 deletions(-) delete mode 100644 .topdeps delete mode 100644 .topmsg diff --git a/.topdeps b/.topdeps deleted file mode 100644 index a04be34786ae0..0000000000000 --- a/.topdeps +++ /dev/null @@ -1 +0,0 @@ -t/selftests-mptcp-use-minus-values-for-removing-address-numbers diff --git a/.topmsg b/.topmsg deleted file mode 100644 index 5d7f62ccfbec6..0000000000000 --- a/.topmsg +++ /dev/null @@ -1,8 +0,0 @@ -From: Geliang Tang -Subject: [PATCH] selftests: mptcp: add testcases for newly added addresses - -This patch adds testcases to create subflows or signal addresses for the -newly added IPv4 or IPv6 addresses. - -Reviewed-by: Mat Martineau -Signed-off-by: Geliang Tang From 6cbbab87c36a2c4f7291ea49d238e18e22481df7 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Sat, 16 Jan 2021 12:08:16 +0100 Subject: [PATCH 02/37] tg create t/mptcp-create-the-listening-socket-for-new-port --- .topdeps | 1 + .topmsg | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000000000..c6e7b24882674 --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +t/selftests-mptcp-add-testcases-for-newly-added-addresses diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000000000..8e64f67e2aa46 --- /dev/null +++ b/.topmsg @@ -0,0 +1,4 @@ +From: Matthieu Baerts +Subject: [PATCH] t/mptcp-create-the-listening-socket-for-new-port + +Signed-off-by: Matthieu Baerts From 7e8c2c5b057cb0dcd9c29351aa70aa055b8a49e5 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Sat, 16 Jan 2021 12:08:17 +0100 Subject: [PATCH 03/37] tg import create t/mptcp-create-the-listening-socket-for-new-port --- .topmsg | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.topmsg b/.topmsg index 8e64f67e2aa46..4c9e391dd162b 100644 --- a/.topmsg +++ b/.topmsg @@ -1,4 +1,12 @@ -From: Matthieu Baerts -Subject: [PATCH] t/mptcp-create-the-listening-socket-for-new-port +From: Geliang Tang +Subject: [PATCH] mptcp: create the listening socket for new port -Signed-off-by: Matthieu Baerts +This patch creates a listening socket when an address with a port-number +is added by PM netlink. Then binds the new port to the socket, and +listens for new connections. + +When the address is removed or the addresses are flushed by PM netlink, +release the listening socket. + +Reviewed-by: Mat Martineau +Signed-off-by: Geliang Tang From 4396001600480e2689f9178623a341bf13407e4b Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Thu, 14 Jan 2021 13:24:58 +0800 Subject: [PATCH 04/37] mptcp: create the listening socket for new port This patch creates a listening socket when an address with a port-number is added by PM netlink. Then binds the new port to the socket, and listens for new connections. When the address is removed or the addresses are flushed by PM netlink, release the listening socket. Reviewed-by: Mat Martineau Signed-off-by: Geliang Tang --- net/mptcp/pm_netlink.c | 96 +++++++++++++++++++++++++++++++++++++++++- net/mptcp/protocol.c | 2 +- net/mptcp/protocol.h | 4 ++ net/mptcp/subflow.c | 6 +-- 4 files changed, 102 insertions(+), 6 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 43fb670cababe..2164b016585ac 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -26,6 +26,7 @@ struct mptcp_pm_addr_entry { struct list_head list; struct mptcp_addr_info addr; struct rcu_head rcu; + struct socket *lsk; }; struct mptcp_pm_add_entry { @@ -677,6 +678,53 @@ static int mptcp_pm_nl_append_new_local_addr(struct pm_nl_pernet *pernet, return ret; } +static int mptcp_pm_nl_create_listen_socket(struct sock *sk, + struct mptcp_pm_addr_entry *entry) +{ + struct sockaddr_storage addr; + struct mptcp_sock *msk; + struct socket *ssock; + int backlog = 1024; + int err; + + err = sock_create_kern(sock_net(sk), entry->addr.family, + SOCK_STREAM, IPPROTO_MPTCP, &entry->lsk); + if (err) + return err; + + msk = mptcp_sk(entry->lsk->sk); + if (!msk) { + err = -EINVAL; + goto out; + } + + ssock = __mptcp_nmpc_socket(msk); + if (!ssock) { + err = -EINVAL; + goto out; + } + + mptcp_info2sockaddr(&entry->addr, &addr, entry->addr.family); + err = kernel_bind(ssock, (struct sockaddr *)&addr, + sizeof(struct sockaddr_in)); + if (err) { + pr_warn("kernel_bind error, err=%d", err); + goto out; + } + + err = kernel_listen(ssock, backlog); + if (err) { + pr_warn("kernel_listen error, err=%d", err); + goto out; + } + + return 0; + +out: + sock_release(entry->lsk); + return err; +} + int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct sock_common *skc) { struct mptcp_pm_addr_entry *entry; @@ -721,6 +769,8 @@ int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct sock_common *skc) entry->addr.ifindex = 0; entry->addr.flags = 0; entry->addr.id = 0; + entry->addr.port = 0; + entry->lsk = NULL; ret = mptcp_pm_nl_append_new_local_addr(pernet, entry); if (ret < 0) kfree(entry); @@ -890,9 +940,19 @@ static int mptcp_nl_cmd_add_addr(struct sk_buff *skb, struct genl_info *info) } *entry = addr; + if (entry->addr.port) { + ret = mptcp_pm_nl_create_listen_socket(skb->sk, entry); + if (ret) { + GENL_SET_ERR_MSG(info, "create listen socket error"); + kfree(entry); + return ret; + } + } ret = mptcp_pm_nl_append_new_local_addr(pernet, entry); if (ret < 0) { GENL_SET_ERR_MSG(info, "too many addresses or duplicate one"); + if (entry->lsk) + sock_release(entry->lsk); kfree(entry); return ret; } @@ -976,6 +1036,38 @@ static int mptcp_nl_remove_subflow_and_signal_addr(struct net *net, return 0; } +struct addr_entry_release_work { + struct rcu_work rwork; + struct mptcp_pm_addr_entry *entry; +}; + +static void mptcp_pm_release_addr_entry(struct work_struct *work) +{ + struct addr_entry_release_work *w; + struct mptcp_pm_addr_entry *entry; + + w = container_of(to_rcu_work(work), struct addr_entry_release_work, rwork); + entry = w->entry; + if (entry) { + if (entry->lsk) + sock_release(entry->lsk); + kfree(entry); + } + kfree(w); +} + +static void mptcp_pm_free_addr_entry(struct mptcp_pm_addr_entry *entry) +{ + struct addr_entry_release_work *w; + + w = kmalloc(sizeof(*w), GFP_ATOMIC); + if (w) { + INIT_RCU_WORK(&w->rwork, mptcp_pm_release_addr_entry); + w->entry = entry; + queue_rcu_work(system_wq, &w->rwork); + } +} + static int mptcp_nl_cmd_del_addr(struct sk_buff *skb, struct genl_info *info) { struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR]; @@ -1010,7 +1102,7 @@ static int mptcp_nl_cmd_del_addr(struct sk_buff *skb, struct genl_info *info) spin_unlock_bh(&pernet->lock); mptcp_nl_remove_subflow_and_signal_addr(sock_net(skb->sk), &entry->addr); - kfree_rcu(entry, rcu); + mptcp_pm_free_addr_entry(entry); return ret; } @@ -1024,7 +1116,7 @@ static void __flush_addrs(struct net *net, struct list_head *list) struct mptcp_pm_addr_entry, list); mptcp_nl_remove_subflow_and_signal_addr(net, &cur->addr); list_del_rcu(&cur->list); - kfree_rcu(cur, rcu); + mptcp_pm_free_addr_entry(cur); } } diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 442ad81d4abcf..7e61627c7c405 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -52,7 +52,7 @@ static struct net_device mptcp_napi_dev; * completed yet or has failed, return the subflow socket. * Otherwise return NULL. */ -static struct socket *__mptcp_nmpc_socket(const struct mptcp_sock *msk) +struct socket *__mptcp_nmpc_socket(const struct mptcp_sock *msk) { if (!msk->subflow || READ_ONCE(msk->can_ack)) return NULL; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index b4477420e86b5..9e05092a640d4 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -522,11 +522,15 @@ void __mptcp_close_ssk(struct sock *sk, struct sock *ssk, struct mptcp_subflow_context *subflow); void mptcp_subflow_reset(struct sock *ssk); void mptcp_sock_graft(struct sock *sk, struct socket *parent); +struct socket *__mptcp_nmpc_socket(const struct mptcp_sock *msk); /* called with sk socket lock held */ int __mptcp_subflow_connect(struct sock *sk, const struct mptcp_addr_info *loc, const struct mptcp_addr_info *remote); int mptcp_subflow_create_socket(struct sock *sk, struct socket **new_sock); +void mptcp_info2sockaddr(const struct mptcp_addr_info *info, + struct sockaddr_storage *addr, + unsigned short family); static inline void mptcp_subflow_tcp_fallback(struct sock *sk, struct mptcp_subflow_context *ctx) diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 8405f3ef8fd83..e6337538131a5 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -1088,9 +1088,9 @@ void mptcpv6_handle_mapped(struct sock *sk, bool mapped) } #endif -static void mptcp_info2sockaddr(const struct mptcp_addr_info *info, - struct sockaddr_storage *addr, - unsigned short family) +void mptcp_info2sockaddr(const struct mptcp_addr_info *info, + struct sockaddr_storage *addr, + unsigned short family) { memset(addr, 0, sizeof(*addr)); addr->ss_family = family; From c3991f41ebbc5d9429787f0c733ce238836500b5 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Sat, 16 Jan 2021 12:08:19 +0100 Subject: [PATCH 05/37] tg create t/mptcp-drop-unused-skb-in-subflow_token_join_request base --- .topdeps | 1 - .topmsg | 12 ------------ 2 files changed, 13 deletions(-) delete mode 100644 .topdeps delete mode 100644 .topmsg diff --git a/.topdeps b/.topdeps deleted file mode 100644 index c6e7b24882674..0000000000000 --- a/.topdeps +++ /dev/null @@ -1 +0,0 @@ -t/selftests-mptcp-add-testcases-for-newly-added-addresses diff --git a/.topmsg b/.topmsg deleted file mode 100644 index 4c9e391dd162b..0000000000000 --- a/.topmsg +++ /dev/null @@ -1,12 +0,0 @@ -From: Geliang Tang -Subject: [PATCH] mptcp: create the listening socket for new port - -This patch creates a listening socket when an address with a port-number -is added by PM netlink. Then binds the new port to the socket, and -listens for new connections. - -When the address is removed or the addresses are flushed by PM netlink, -release the listening socket. - -Reviewed-by: Mat Martineau -Signed-off-by: Geliang Tang From 762eadf4f570ff4f19da905b67133d1c3585e684 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Sat, 16 Jan 2021 12:08:20 +0100 Subject: [PATCH 06/37] tg create t/mptcp-drop-unused-skb-in-subflow_token_join_request --- .topdeps | 1 + .topmsg | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000000000..a510485caacf6 --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +t/mptcp-create-the-listening-socket-for-new-port diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000000000..e71af9387b3f4 --- /dev/null +++ b/.topmsg @@ -0,0 +1,4 @@ +From: Matthieu Baerts +Subject: [PATCH] t/mptcp-drop-unused-skb-in-subflow_token_join_request + +Signed-off-by: Matthieu Baerts From 54a98b2e478fb519062614daca4a30719a386360 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Sat, 16 Jan 2021 12:08:20 +0100 Subject: [PATCH 07/37] tg import create t/mptcp-drop-unused-skb-in-subflow_token_join_request --- .topmsg | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.topmsg b/.topmsg index e71af9387b3f4..afdd215704d57 100644 --- a/.topmsg +++ b/.topmsg @@ -1,4 +1,7 @@ -From: Matthieu Baerts -Subject: [PATCH] t/mptcp-drop-unused-skb-in-subflow_token_join_request +From: Geliang Tang +Subject: [PATCH] mptcp: drop unused skb in subflow_token_join_request -Signed-off-by: Matthieu Baerts +This patch drops the unused parameter skb in subflow_token_join_request. + +Reviewed-by: Mat Martineau +Signed-off-by: Geliang Tang From 3122c6542e4fbd564b5ff0ad62a700d21b3cc889 Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Thu, 14 Jan 2021 13:24:59 +0800 Subject: [PATCH 08/37] mptcp: drop unused skb in subflow_token_join_request This patch drops the unused parameter skb in subflow_token_join_request. Reviewed-by: Mat Martineau Signed-off-by: Geliang Tang --- net/mptcp/subflow.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index e6337538131a5..c1cace730e945 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -62,8 +62,7 @@ static bool mptcp_can_accept_new_subflow(const struct mptcp_sock *msk) } /* validate received token and create truncated hmac and nonce for SYN-ACK */ -static struct mptcp_sock *subflow_token_join_request(struct request_sock *req, - const struct sk_buff *skb) +static struct mptcp_sock *subflow_token_join_request(struct request_sock *req) { struct mptcp_subflow_request_sock *subflow_req = mptcp_subflow_rsk(req); u8 hmac[SHA256_DIGEST_SIZE]; @@ -179,7 +178,7 @@ static int subflow_init_req(struct request_sock *req, subflow_req->remote_id = mp_opt.join_id; subflow_req->token = mp_opt.token; subflow_req->remote_nonce = mp_opt.nonce; - subflow_req->msk = subflow_token_join_request(req, skb); + subflow_req->msk = subflow_token_join_request(req); /* Can't fall back to TCP in this case. */ if (!subflow_req->msk) From e30055b17147df22aa580edf3f58583d5b493f2c Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Sat, 16 Jan 2021 12:08:22 +0100 Subject: [PATCH 09/37] tg create t/mptcp-add-a-new-helper-subflow_req_create_thmac base --- .topdeps | 1 - .topmsg | 7 ------- 2 files changed, 8 deletions(-) delete mode 100644 .topdeps delete mode 100644 .topmsg diff --git a/.topdeps b/.topdeps deleted file mode 100644 index a510485caacf6..0000000000000 --- a/.topdeps +++ /dev/null @@ -1 +0,0 @@ -t/mptcp-create-the-listening-socket-for-new-port diff --git a/.topmsg b/.topmsg deleted file mode 100644 index afdd215704d57..0000000000000 --- a/.topmsg +++ /dev/null @@ -1,7 +0,0 @@ -From: Geliang Tang -Subject: [PATCH] mptcp: drop unused skb in subflow_token_join_request - -This patch drops the unused parameter skb in subflow_token_join_request. - -Reviewed-by: Mat Martineau -Signed-off-by: Geliang Tang From 4712306c5989cbbed510d810f4f9ad0401bd2e46 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Sat, 16 Jan 2021 12:08:23 +0100 Subject: [PATCH 10/37] tg create t/mptcp-add-a-new-helper-subflow_req_create_thmac --- .topdeps | 1 + .topmsg | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000000000..308ab54ec8d61 --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +t/mptcp-drop-unused-skb-in-subflow_token_join_request diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000000000..22be5c1356a9d --- /dev/null +++ b/.topmsg @@ -0,0 +1,4 @@ +From: Matthieu Baerts +Subject: [PATCH] t/mptcp-add-a-new-helper-subflow_req_create_thmac + +Signed-off-by: Matthieu Baerts From df52b60c27fca45eca8b30cbb70a1f0334a2385e Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Sat, 16 Jan 2021 12:08:24 +0100 Subject: [PATCH 11/37] tg import create t/mptcp-add-a-new-helper-subflow_req_create_thmac --- .topmsg | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.topmsg b/.topmsg index 22be5c1356a9d..b82c241a70183 100644 --- a/.topmsg +++ b/.topmsg @@ -1,4 +1,9 @@ -From: Matthieu Baerts -Subject: [PATCH] t/mptcp-add-a-new-helper-subflow_req_create_thmac +From: Geliang Tang +Subject: [PATCH] mptcp: add a new helper subflow_req_create_thmac -Signed-off-by: Matthieu Baerts +This patch adds a new helper named subflow_req_create_thmac, which is +extracted from subflow_token_join_request. It initializes subflow_req's +local_nonce and thmac fields, those are the more expensive to populate. + +Reviewed-by: Mat Martineau +Signed-off-by: Geliang Tang From 9dfc9b337d4fb3a7344a4f60d572dd1ed035ba6a Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Thu, 14 Jan 2021 13:25:00 +0800 Subject: [PATCH 12/37] mptcp: add a new helper subflow_req_create_thmac This patch adds a new helper named subflow_req_create_thmac, which is extracted from subflow_token_join_request. It initializes subflow_req's local_nonce and thmac fields, those are the more expensive to populate. Reviewed-by: Mat Martineau Signed-off-by: Geliang Tang --- net/mptcp/subflow.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index c1cace730e945..a0af661fbef6c 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -62,10 +62,23 @@ static bool mptcp_can_accept_new_subflow(const struct mptcp_sock *msk) } /* validate received token and create truncated hmac and nonce for SYN-ACK */ +static void subflow_req_create_thmac(struct mptcp_subflow_request_sock *subflow_req) +{ + struct mptcp_sock *msk = subflow_req->msk; + u8 hmac[SHA256_DIGEST_SIZE]; + + get_random_bytes(&subflow_req->local_nonce, sizeof(u32)); + + subflow_generate_hmac(msk->local_key, msk->remote_key, + subflow_req->local_nonce, + subflow_req->remote_nonce, hmac); + + subflow_req->thmac = get_unaligned_be64(hmac); +} + static struct mptcp_sock *subflow_token_join_request(struct request_sock *req) { struct mptcp_subflow_request_sock *subflow_req = mptcp_subflow_rsk(req); - u8 hmac[SHA256_DIGEST_SIZE]; struct mptcp_sock *msk; int local_id; @@ -82,13 +95,6 @@ static struct mptcp_sock *subflow_token_join_request(struct request_sock *req) } subflow_req->local_id = local_id; - get_random_bytes(&subflow_req->local_nonce, sizeof(u32)); - - subflow_generate_hmac(msk->local_key, msk->remote_key, - subflow_req->local_nonce, - subflow_req->remote_nonce, hmac); - - subflow_req->thmac = get_unaligned_be64(hmac); return msk; } @@ -184,6 +190,8 @@ static int subflow_init_req(struct request_sock *req, if (!subflow_req->msk) return -EPERM; + subflow_req_create_thmac(subflow_req); + if (unlikely(req->syncookie)) { if (mptcp_can_accept_new_subflow(subflow_req->msk)) subflow_init_req_cookie_join_save(subflow_req, skb); From b9e1471b24c00d274471a643cd043fd3f45d0b50 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Sat, 16 Jan 2021 12:08:26 +0100 Subject: [PATCH 13/37] tg create t/mptcp-add-port-number-check-for-MP_JOIN base --- .topdeps | 1 - .topmsg | 9 --------- 2 files changed, 10 deletions(-) delete mode 100644 .topdeps delete mode 100644 .topmsg diff --git a/.topdeps b/.topdeps deleted file mode 100644 index 308ab54ec8d61..0000000000000 --- a/.topdeps +++ /dev/null @@ -1 +0,0 @@ -t/mptcp-drop-unused-skb-in-subflow_token_join_request diff --git a/.topmsg b/.topmsg deleted file mode 100644 index b82c241a70183..0000000000000 --- a/.topmsg +++ /dev/null @@ -1,9 +0,0 @@ -From: Geliang Tang -Subject: [PATCH] mptcp: add a new helper subflow_req_create_thmac - -This patch adds a new helper named subflow_req_create_thmac, which is -extracted from subflow_token_join_request. It initializes subflow_req's -local_nonce and thmac fields, those are the more expensive to populate. - -Reviewed-by: Mat Martineau -Signed-off-by: Geliang Tang From 9c58a838b0cfc1167d6878a8bfced0106da6ead5 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Sat, 16 Jan 2021 12:08:27 +0100 Subject: [PATCH 14/37] tg create t/mptcp-add-port-number-check-for-MP_JOIN --- .topdeps | 1 + .topmsg | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000000000..3bb4fd8483d47 --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +t/mptcp-add-a-new-helper-subflow_req_create_thmac diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000000000..4d63a4d08af73 --- /dev/null +++ b/.topmsg @@ -0,0 +1,4 @@ +From: Matthieu Baerts +Subject: [PATCH] t/mptcp-add-port-number-check-for-MP_JOIN + +Signed-off-by: Matthieu Baerts From 5a225ac5e5f6d2ffd54c9799ec1ed7ee22acd4e4 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Sat, 16 Jan 2021 12:08:27 +0100 Subject: [PATCH 15/37] tg import create t/mptcp-add-port-number-check-for-MP_JOIN --- .topmsg | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/.topmsg b/.topmsg index 4d63a4d08af73..25e711be57df6 100644 --- a/.topmsg +++ b/.topmsg @@ -1,4 +1,18 @@ -From: Matthieu Baerts -Subject: [PATCH] t/mptcp-add-port-number-check-for-MP_JOIN +From: Geliang Tang +Subject: [PATCH] mptcp: add port number check for MP_JOIN -Signed-off-by: Matthieu Baerts +This patch adds two new helpers, subflow_use_different_sport and +subflow_use_different_dport, to check whether the subflow's source or +destination port number is different from the msk's port number. When +receiving the MP_JOIN's SYN/SYNACK/ACK, we do these port number checks +and print out the different port numbers. + +And furthermore, when receiving the MP_JOIN's SYN/ACK, we also use a new +helper mptcp_pm_sport_in_anno_list to check whether this port number is +announced. If it isn't, we need to abort this connection. + +This patch also populates the local address's port field in +local_address. + +Reviewed-by: Mat Martineau +Signed-off-by: Geliang Tang From 551edb8d92ab125c7e2e6b179b03a82344a61f8e Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Thu, 14 Jan 2021 13:25:01 +0800 Subject: [PATCH 16/37] mptcp: add port number check for MP_JOIN This patch adds two new helpers, subflow_use_different_sport and subflow_use_different_dport, to check whether the subflow's source or destination port number is different from the msk's port number. When receiving the MP_JOIN's SYN/SYNACK/ACK, we do these port number checks and print out the different port numbers. And furthermore, when receiving the MP_JOIN's SYN/ACK, we also use a new helper mptcp_pm_sport_in_anno_list to check whether this port number is announced. If it isn't, we need to abort this connection. This patch also populates the local address's port field in local_address. Reviewed-by: Mat Martineau Signed-off-by: Geliang Tang --- net/mptcp/pm_netlink.c | 23 ++++++++++++++++++++++- net/mptcp/protocol.h | 1 + net/mptcp/subflow.c | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 2164b016585ac..e6a8ca4694c02 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -97,8 +97,8 @@ static bool address_zero(const struct mptcp_addr_info *addr) static void local_address(const struct sock_common *skc, struct mptcp_addr_info *addr) { - addr->port = 0; addr->family = skc->skc_family; + addr->port = htons(skc->skc_num); if (addr->family == AF_INET) addr->addr.s_addr = skc->skc_rcv_saddr; #if IS_ENABLED(CONFIG_MPTCP_IPV6) @@ -251,6 +251,27 @@ lookup_anno_list_by_saddr(struct mptcp_sock *msk, return NULL; } +bool mptcp_pm_sport_in_anno_list(struct mptcp_sock *msk, const struct sock *sk) +{ + struct mptcp_pm_add_entry *entry; + struct mptcp_addr_info saddr; + bool ret = false; + + local_address((struct sock_common *)sk, &saddr); + + spin_lock_bh(&msk->pm.lock); + list_for_each_entry(entry, &msk->pm.anno_list, list) { + if (addresses_equal(&entry->addr, &saddr, true)) { + ret = true; + goto out; + } + } + +out: + spin_unlock_bh(&msk->pm.lock); + return ret; +} + static void mptcp_pm_add_timer(struct timer_list *timer) { struct mptcp_pm_add_entry *entry = from_timer(entry, timer, add_timer); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 9e05092a640d4..90f43cd34e8d6 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -634,6 +634,7 @@ int mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk, struct mptcp_addr_info *addr, u8 bkup); void mptcp_pm_free_anno_list(struct mptcp_sock *msk); +bool mptcp_pm_sport_in_anno_list(struct mptcp_sock *msk, const struct sock *sk); struct mptcp_pm_add_entry * mptcp_pm_del_add_timer(struct mptcp_sock *msk, struct mptcp_addr_info *addr); diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index a0af661fbef6c..e7d3d76327bd2 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -118,6 +118,11 @@ static int __subflow_init_req(struct request_sock *req, const struct sock *sk_li return 0; } +static bool subflow_use_different_sport(struct mptcp_sock *msk, const struct sock *sk) +{ + return inet_sk(sk)->inet_sport != inet_sk((struct sock *)msk)->inet_sport; +} + /* Init mptcp request socket. * * Returns an error code if a JOIN has failed and a TCP reset @@ -190,6 +195,20 @@ static int subflow_init_req(struct request_sock *req, if (!subflow_req->msk) return -EPERM; + if (subflow_use_different_sport(subflow_req->msk, sk_listener)) { + pr_debug("syn inet_sport=%d %d", + ntohs(inet_sk(sk_listener)->inet_sport), + ntohs(inet_sk((struct sock *)subflow_req->msk)->inet_sport)); + if (!mptcp_pm_sport_in_anno_list(subflow_req->msk, sk_listener)) { + sock_put((struct sock *)subflow_req->msk); + mptcp_token_destroy_request(req); + tcp_request_sock_ops.destructor(req); + subflow_req->msk = NULL; + subflow_req->mp_join = 0; + return -EPERM; + } + } + subflow_req_create_thmac(subflow_req); if (unlikely(req->syncookie)) { @@ -334,6 +353,11 @@ void mptcp_subflow_reset(struct sock *ssk) sock_put(sk); } +static bool subflow_use_different_dport(struct mptcp_sock *msk, const struct sock *sk) +{ + return inet_sk(sk)->inet_dport != inet_sk((struct sock *)msk)->inet_dport; +} + static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb) { struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk); @@ -400,6 +424,12 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb) subflow->mp_join = 1; MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_JOINSYNACKRX); + + if (subflow_use_different_dport(mptcp_sk(parent), sk)) { + pr_debug("synack inet_dport=%d %d", + ntohs(inet_sk(sk)->inet_dport), + ntohs(inet_sk(parent)->inet_dport)); + } } else if (mptcp_check_fallback(sk)) { fallback: mptcp_rcv_space_init(mptcp_sk(parent), sk); @@ -671,6 +701,14 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk, SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_JOINACKRX); tcp_rsk(req)->drop_req = true; + + if (subflow_use_different_sport(owner, sk)) { + pr_debug("ack inet_sport=%d %d", + ntohs(inet_sk(sk)->inet_sport), + ntohs(inet_sk((struct sock *)owner)->inet_sport)); + if (!mptcp_pm_sport_in_anno_list(owner, sk)) + goto out; + } } } From 8de884922396604a15fb837bea48cda6b55bb785 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Sat, 16 Jan 2021 12:08:30 +0100 Subject: [PATCH 17/37] tg create t/mptcp-enable-use_port-when-invoke-addresses_equal base --- .topdeps | 1 - .topmsg | 18 ------------------ 2 files changed, 19 deletions(-) delete mode 100644 .topdeps delete mode 100644 .topmsg diff --git a/.topdeps b/.topdeps deleted file mode 100644 index 3bb4fd8483d47..0000000000000 --- a/.topdeps +++ /dev/null @@ -1 +0,0 @@ -t/mptcp-add-a-new-helper-subflow_req_create_thmac diff --git a/.topmsg b/.topmsg deleted file mode 100644 index 25e711be57df6..0000000000000 --- a/.topmsg +++ /dev/null @@ -1,18 +0,0 @@ -From: Geliang Tang -Subject: [PATCH] mptcp: add port number check for MP_JOIN - -This patch adds two new helpers, subflow_use_different_sport and -subflow_use_different_dport, to check whether the subflow's source or -destination port number is different from the msk's port number. When -receiving the MP_JOIN's SYN/SYNACK/ACK, we do these port number checks -and print out the different port numbers. - -And furthermore, when receiving the MP_JOIN's SYN/ACK, we also use a new -helper mptcp_pm_sport_in_anno_list to check whether this port number is -announced. If it isn't, we need to abort this connection. - -This patch also populates the local address's port field in -local_address. - -Reviewed-by: Mat Martineau -Signed-off-by: Geliang Tang From e04f74c43630143d16da77fdb30eddf591e6d42c Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Sat, 16 Jan 2021 12:08:31 +0100 Subject: [PATCH 18/37] tg create t/mptcp-enable-use_port-when-invoke-addresses_equal --- .topdeps | 1 + .topmsg | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000000000..cae1df3fa7824 --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +t/mptcp-add-port-number-check-for-MP_JOIN diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000000000..1bc4d4ed22db3 --- /dev/null +++ b/.topmsg @@ -0,0 +1,4 @@ +From: Matthieu Baerts +Subject: [PATCH] t/mptcp-enable-use_port-when-invoke-addresses_equal + +Signed-off-by: Matthieu Baerts From 751e3f65a07b9c33c83a7c9eba0d19b15aa7dc5b Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Sat, 16 Jan 2021 12:08:31 +0100 Subject: [PATCH 19/37] tg import create t/mptcp-enable-use_port-when-invoke-addresses_equal --- .topmsg | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.topmsg b/.topmsg index 1bc4d4ed22db3..ed58a8868f89c 100644 --- a/.topmsg +++ b/.topmsg @@ -1,4 +1,9 @@ -From: Matthieu Baerts -Subject: [PATCH] t/mptcp-enable-use_port-when-invoke-addresses_equal +From: Geliang Tang +Subject: [PATCH] mptcp: enable use_port when invoke addresses_equal -Signed-off-by: Matthieu Baerts +When dealing with the addresses list local_addr_list or anno_list, we +should enable the function addresses_equal's parameter use_port. And +enable it in address_zero too. + +Reviewed-by: Mat Martineau +Signed-off-by: Geliang Tang From 3f96f48fbd199e2e01c9a5168c706c8e33ecac4c Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Thu, 14 Jan 2021 13:25:02 +0800 Subject: [PATCH 20/37] mptcp: enable use_port when invoke addresses_equal When dealing with the addresses list local_addr_list or anno_list, we should enable the function addresses_equal's parameter use_port. And enable it in address_zero too. Reviewed-by: Mat Martineau Signed-off-by: Geliang Tang --- net/mptcp/pm_netlink.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index e6a8ca4694c02..e924204d28e78 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -91,7 +91,7 @@ static bool address_zero(const struct mptcp_addr_info *addr) memset(&zero, 0, sizeof(zero)); zero.family = addr->family; - return addresses_equal(addr, &zero, false); + return addresses_equal(addr, &zero, true); } static void local_address(const struct sock_common *skc, @@ -131,7 +131,7 @@ static bool lookup_subflow_by_saddr(const struct list_head *list, skc = (struct sock_common *)mptcp_subflow_tcp_sock(subflow); local_address(skc, &cur); - if (addresses_equal(&cur, saddr, false)) + if (addresses_equal(&cur, saddr, saddr->port)) return true; } @@ -244,7 +244,7 @@ lookup_anno_list_by_saddr(struct mptcp_sock *msk, struct mptcp_pm_add_entry *entry; list_for_each_entry(entry, &msk->pm.anno_list, list) { - if (addresses_equal(&entry->addr, addr, false)) + if (addresses_equal(&entry->addr, addr, true)) return entry; } @@ -772,7 +772,7 @@ int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct sock_common *skc) rcu_read_lock(); list_for_each_entry_rcu(entry, &pernet->local_addr_list, list) { - if (addresses_equal(&entry->addr, &skc_local, false)) { + if (addresses_equal(&entry->addr, &skc_local, entry->addr.port)) { ret = entry->addr.id; break; } From 4973ae20e4302be68ece6428afc5c0b59943731c Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Sat, 16 Jan 2021 12:08:33 +0100 Subject: [PATCH 21/37] tg create t/mptcp-deal-with-MPTCP_PM_ADDR_ATTR_PORT-in-PM-netlink base --- .topdeps | 1 - .topmsg | 9 --------- 2 files changed, 10 deletions(-) delete mode 100644 .topdeps delete mode 100644 .topmsg diff --git a/.topdeps b/.topdeps deleted file mode 100644 index cae1df3fa7824..0000000000000 --- a/.topdeps +++ /dev/null @@ -1 +0,0 @@ -t/mptcp-add-port-number-check-for-MP_JOIN diff --git a/.topmsg b/.topmsg deleted file mode 100644 index ed58a8868f89c..0000000000000 --- a/.topmsg +++ /dev/null @@ -1,9 +0,0 @@ -From: Geliang Tang -Subject: [PATCH] mptcp: enable use_port when invoke addresses_equal - -When dealing with the addresses list local_addr_list or anno_list, we -should enable the function addresses_equal's parameter use_port. And -enable it in address_zero too. - -Reviewed-by: Mat Martineau -Signed-off-by: Geliang Tang From 8fdd52cdab1d2d24e14a68550f363c6b5bd139d8 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Sat, 16 Jan 2021 12:08:34 +0100 Subject: [PATCH 22/37] tg create t/mptcp-deal-with-MPTCP_PM_ADDR_ATTR_PORT-in-PM-netlink --- .topdeps | 1 + .topmsg | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000000000..5c8e82019b3ad --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +t/mptcp-enable-use_port-when-invoke-addresses_equal diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000000000..de595b27d87a0 --- /dev/null +++ b/.topmsg @@ -0,0 +1,4 @@ +From: Matthieu Baerts +Subject: [PATCH] t/mptcp-deal-with-MPTCP_PM_ADDR_ATTR_PORT-in-PM-netlink + +Signed-off-by: Matthieu Baerts From 00e8d1ae16ff743e7dd40806310178c563498d1f Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Sat, 16 Jan 2021 12:08:35 +0100 Subject: [PATCH 23/37] tg import create t/mptcp-deal-with-MPTCP_PM_ADDR_ATTR_PORT-in-PM-netlink --- .topmsg | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.topmsg b/.topmsg index de595b27d87a0..2c922b9bf3283 100644 --- a/.topmsg +++ b/.topmsg @@ -1,4 +1,8 @@ -From: Matthieu Baerts -Subject: [PATCH] t/mptcp-deal-with-MPTCP_PM_ADDR_ATTR_PORT-in-PM-netlink +From: Geliang Tang +Subject: [PATCH] mptcp: deal with MPTCP_PM_ADDR_ATTR_PORT in PM netlink -Signed-off-by: Matthieu Baerts +This patch adds MPTCP_PM_ADDR_ATTR_PORT filling and parsing in PM +netlink. + +Reviewed-by: Mat Martineau +Signed-off-by: Geliang Tang From 60e993388f4f4efdb22c7c85acf6e4dd21c1d68a Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Thu, 14 Jan 2021 13:25:03 +0800 Subject: [PATCH 24/37] mptcp: deal with MPTCP_PM_ADDR_ATTR_PORT in PM netlink This patch adds MPTCP_PM_ADDR_ATTR_PORT filling and parsing in PM netlink. Reviewed-by: Mat Martineau Signed-off-by: Geliang Tang --- net/mptcp/pm_netlink.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index e924204d28e78..5a6d4753fba8f 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -910,6 +910,9 @@ static int mptcp_pm_parse_addr(struct nlattr *attr, struct genl_info *info, if (tb[MPTCP_PM_ADDR_ATTR_FLAGS]) entry->addr.flags = nla_get_u32(tb[MPTCP_PM_ADDR_ATTR_FLAGS]); + if (tb[MPTCP_PM_ADDR_ATTR_PORT]) + entry->addr.port = htons(nla_get_u16(tb[MPTCP_PM_ADDR_ATTR_PORT])); + return 0; } @@ -1176,6 +1179,8 @@ static int mptcp_nl_fill_addr(struct sk_buff *skb, if (nla_put_u16(skb, MPTCP_PM_ADDR_ATTR_FAMILY, addr->family)) goto nla_put_failure; + if (nla_put_u16(skb, MPTCP_PM_ADDR_ATTR_PORT, ntohs(addr->port))) + goto nla_put_failure; if (nla_put_u8(skb, MPTCP_PM_ADDR_ATTR_ID, addr->id)) goto nla_put_failure; if (nla_put_u32(skb, MPTCP_PM_ADDR_ATTR_FLAGS, entry->addr.flags)) From 8af395f34204f0f65ec345ce82fb81db1ec5a6c5 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Sat, 16 Jan 2021 12:08:37 +0100 Subject: [PATCH 25/37] tg create t/selftests-mptcp-add-port-argument-for-pm_nl_ctl base --- .topdeps | 1 - .topmsg | 8 -------- 2 files changed, 9 deletions(-) delete mode 100644 .topdeps delete mode 100644 .topmsg diff --git a/.topdeps b/.topdeps deleted file mode 100644 index 5c8e82019b3ad..0000000000000 --- a/.topdeps +++ /dev/null @@ -1 +0,0 @@ -t/mptcp-enable-use_port-when-invoke-addresses_equal diff --git a/.topmsg b/.topmsg deleted file mode 100644 index 2c922b9bf3283..0000000000000 --- a/.topmsg +++ /dev/null @@ -1,8 +0,0 @@ -From: Geliang Tang -Subject: [PATCH] mptcp: deal with MPTCP_PM_ADDR_ATTR_PORT in PM netlink - -This patch adds MPTCP_PM_ADDR_ATTR_PORT filling and parsing in PM -netlink. - -Reviewed-by: Mat Martineau -Signed-off-by: Geliang Tang From 88c2c8275b0f1bce827269ef5f5b9ac4c95e1a2b Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Sat, 16 Jan 2021 12:08:38 +0100 Subject: [PATCH 26/37] tg create t/selftests-mptcp-add-port-argument-for-pm_nl_ctl --- .topdeps | 1 + .topmsg | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000000000..a3b3bee5665e7 --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +t/mptcp-deal-with-MPTCP_PM_ADDR_ATTR_PORT-in-PM-netlink diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000000000..bd9ea26ad18ae --- /dev/null +++ b/.topmsg @@ -0,0 +1,4 @@ +From: Matthieu Baerts +Subject: [PATCH] t/selftests-mptcp-add-port-argument-for-pm_nl_ctl + +Signed-off-by: Matthieu Baerts From 181a0a7a100fd531080ced19fc1bf4186fa84024 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Sat, 16 Jan 2021 12:08:39 +0100 Subject: [PATCH 27/37] tg import create t/selftests-mptcp-add-port-argument-for-pm_nl_ctl --- .topmsg | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.topmsg b/.topmsg index bd9ea26ad18ae..64f267aced33b 100644 --- a/.topmsg +++ b/.topmsg @@ -1,4 +1,12 @@ -From: Matthieu Baerts -Subject: [PATCH] t/selftests-mptcp-add-port-argument-for-pm_nl_ctl +From: Geliang Tang +Subject: [PATCH] selftests: mptcp: add port argument for pm_nl_ctl -Signed-off-by: Matthieu Baerts +This patch adds a new argument for pm_nl_ctl tool. We can use it like +this: + + # pm_nl_ctl add 10.0.2.1 flags signal port 10100 + # pm_nl_ctl dump + id 1 flags signal 10.0.2.1 10100 + +Reviewed-by: Mat Martineau +Signed-off-by: Geliang Tang From 7e876f36d1647414e86bde8fa6989f388cdbb346 Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Thu, 14 Jan 2021 13:25:04 +0800 Subject: [PATCH 28/37] selftests: mptcp: add port argument for pm_nl_ctl This patch adds a new argument for pm_nl_ctl tool. We can use it like this: # pm_nl_ctl add 10.0.2.1 flags signal port 10100 # pm_nl_ctl dump id 1 flags signal 10.0.2.1 10100 Reviewed-by: Mat Martineau Signed-off-by: Geliang Tang --- tools/testing/selftests/net/mptcp/pm_nl_ctl.c | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c b/tools/testing/selftests/net/mptcp/pm_nl_ctl.c index abc269e96a07c..7b4167f3f9a2c 100644 --- a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c +++ b/tools/testing/selftests/net/mptcp/pm_nl_ctl.c @@ -177,8 +177,8 @@ int add_addr(int fd, int pm_family, int argc, char *argv[]) 1024]; struct rtattr *rta, *nest; struct nlmsghdr *nh; + u_int32_t flags = 0; u_int16_t family; - u_int32_t flags; int nest_start; u_int8_t id; int off = 0; @@ -224,7 +224,6 @@ int add_addr(int fd, int pm_family, int argc, char *argv[]) char *tok, *str; /* flags */ - flags = 0; if (++arg >= argc) error(1, 0, " missing flags value"); @@ -272,6 +271,20 @@ int add_addr(int fd, int pm_family, int argc, char *argv[]) rta->rta_len = RTA_LENGTH(4); memcpy(RTA_DATA(rta), &ifindex, 4); off += NLMSG_ALIGN(rta->rta_len); + } else if (!strcmp(argv[arg], "port")) { + u_int16_t port; + + if (++arg >= argc) + error(1, 0, " missing port value"); + if (!(flags & MPTCP_PM_ADDR_FLAG_SIGNAL)) + error(1, 0, " flags must be signal when using port"); + + port = atoi(argv[arg]); + rta = (void *)(data + off); + rta->rta_type = MPTCP_PM_ADDR_ATTR_PORT; + rta->rta_len = RTA_LENGTH(2); + memcpy(RTA_DATA(rta), &port, 2); + off += NLMSG_ALIGN(rta->rta_len); } else error(1, 0, "unknown keyword %s", argv[arg]); } @@ -324,6 +337,7 @@ int del_addr(int fd, int pm_family, int argc, char *argv[]) static void print_addr(struct rtattr *attrs, int len) { uint16_t family = 0; + uint16_t port = 0; char str[1024]; uint32_t flags; uint8_t id; @@ -331,12 +345,16 @@ static void print_addr(struct rtattr *attrs, int len) while (RTA_OK(attrs, len)) { if (attrs->rta_type == MPTCP_PM_ADDR_ATTR_FAMILY) memcpy(&family, RTA_DATA(attrs), 2); + if (attrs->rta_type == MPTCP_PM_ADDR_ATTR_PORT) + memcpy(&port, RTA_DATA(attrs), 2); if (attrs->rta_type == MPTCP_PM_ADDR_ATTR_ADDR4) { if (family != AF_INET) error(1, errno, "wrong IP (v4) for family %d", family); inet_ntop(AF_INET, RTA_DATA(attrs), str, sizeof(str)); printf("%s", str); + if (port) + printf(" %d", port); } if (attrs->rta_type == MPTCP_PM_ADDR_ATTR_ADDR6) { if (family != AF_INET6) @@ -344,6 +362,8 @@ static void print_addr(struct rtattr *attrs, int len) family); inet_ntop(AF_INET6, RTA_DATA(attrs), str, sizeof(str)); printf("%s", str); + if (port) + printf(" %d", port); } if (attrs->rta_type == MPTCP_PM_ADDR_ATTR_ID) { memcpy(&id, RTA_DATA(attrs), 1); From 7bbe57122b560df583389335217da9721c96269b Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Sat, 16 Jan 2021 12:08:41 +0100 Subject: [PATCH 29/37] tg create t/mptcp-add-the-mibs-for-ADD_ADDR-with-port base --- .topdeps | 1 - .topmsg | 12 ------------ 2 files changed, 13 deletions(-) delete mode 100644 .topdeps delete mode 100644 .topmsg diff --git a/.topdeps b/.topdeps deleted file mode 100644 index a3b3bee5665e7..0000000000000 --- a/.topdeps +++ /dev/null @@ -1 +0,0 @@ -t/mptcp-deal-with-MPTCP_PM_ADDR_ATTR_PORT-in-PM-netlink diff --git a/.topmsg b/.topmsg deleted file mode 100644 index 64f267aced33b..0000000000000 --- a/.topmsg +++ /dev/null @@ -1,12 +0,0 @@ -From: Geliang Tang -Subject: [PATCH] selftests: mptcp: add port argument for pm_nl_ctl - -This patch adds a new argument for pm_nl_ctl tool. We can use it like -this: - - # pm_nl_ctl add 10.0.2.1 flags signal port 10100 - # pm_nl_ctl dump - id 1 flags signal 10.0.2.1 10100 - -Reviewed-by: Mat Martineau -Signed-off-by: Geliang Tang From 36c1500bf4257aebdf1c0f4ec56e9adb07f4646c Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Sat, 16 Jan 2021 12:08:42 +0100 Subject: [PATCH 30/37] tg create t/mptcp-add-the-mibs-for-ADD_ADDR-with-port --- .topdeps | 1 + .topmsg | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000000000..0ec28935b4361 --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +t/selftests-mptcp-add-port-argument-for-pm_nl_ctl diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000000000..649bde70cdd5f --- /dev/null +++ b/.topmsg @@ -0,0 +1,4 @@ +From: Matthieu Baerts +Subject: [PATCH] t/mptcp-add-the-mibs-for-ADD_ADDR-with-port + +Signed-off-by: Matthieu Baerts From 15f987a69566bb41c2282fa3ee2f84c6d432a642 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Sat, 16 Jan 2021 12:08:43 +0100 Subject: [PATCH 31/37] tg import create t/mptcp-add-the-mibs-for-ADD_ADDR-with-port --- .topmsg | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.topmsg b/.topmsg index 649bde70cdd5f..0fab28588faa9 100644 --- a/.topmsg +++ b/.topmsg @@ -1,4 +1,16 @@ -From: Matthieu Baerts -Subject: [PATCH] t/mptcp-add-the-mibs-for-ADD_ADDR-with-port +From: Geliang Tang +Subject: [PATCH] mptcp: add the mibs for ADD_ADDR with port -Signed-off-by: Matthieu Baerts +This patch adds the mibs for ADD_ADDR with port: + +MPTCP_MIB_PORTADD for received ADD_ADDR suboption with a port number. + +MPTCP_MIB_PORTSYNRX, MPTCP_MIB_PORTSYNACKRX, MPTCP_MIB_PORTACKRX, for +received MP_JOIN's SYN or SYN/ACK or ACK with a port number which is +different from the msk's port number. + +MPTCP_MIB_MISMATCHPORTSYNRX and MPTCP_MIB_MISMATCHPORTACKRX, for +received SYN or ACK MP_JOIN with a mismatched port-number. + +Reviewed-by: Mat Martineau +Signed-off-by: Geliang Tang From e7b4ca22e5fba33d45f63a5d5de75ef45a1bd589 Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Thu, 14 Jan 2021 13:25:05 +0800 Subject: [PATCH 32/37] mptcp: add the mibs for ADD_ADDR with port This patch adds the mibs for ADD_ADDR with port: MPTCP_MIB_PORTADD for received ADD_ADDR suboption with a port number. MPTCP_MIB_PORTSYNRX, MPTCP_MIB_PORTSYNACKRX, MPTCP_MIB_PORTACKRX, for received MP_JOIN's SYN or SYN/ACK or ACK with a port number which is different from the msk's port number. MPTCP_MIB_MISMATCHPORTSYNRX and MPTCP_MIB_MISMATCHPORTACKRX, for received SYN or ACK MP_JOIN with a mismatched port-number. Reviewed-by: Mat Martineau Signed-off-by: Geliang Tang --- net/mptcp/mib.c | 6 ++++++ net/mptcp/mib.h | 6 ++++++ net/mptcp/options.c | 4 ++++ net/mptcp/subflow.c | 8 +++++++- 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/net/mptcp/mib.c b/net/mptcp/mib.c index 8ca196489893f..3780c29c321d1 100644 --- a/net/mptcp/mib.c +++ b/net/mptcp/mib.c @@ -29,6 +29,12 @@ static const struct snmp_mib mptcp_snmp_list[] = { SNMP_MIB_ITEM("DuplicateData", MPTCP_MIB_DUPDATA), SNMP_MIB_ITEM("AddAddr", MPTCP_MIB_ADDADDR), SNMP_MIB_ITEM("EchoAdd", MPTCP_MIB_ECHOADD), + SNMP_MIB_ITEM("PortAdd", MPTCP_MIB_PORTADD), + SNMP_MIB_ITEM("MPJoinPortSynRx", MPTCP_MIB_JOINPORTSYNRX), + SNMP_MIB_ITEM("MPJoinPortSynAckRx", MPTCP_MIB_JOINPORTSYNACKRX), + SNMP_MIB_ITEM("MPJoinPortAckRx", MPTCP_MIB_JOINPORTACKRX), + SNMP_MIB_ITEM("MismatchPortSynRx", MPTCP_MIB_MISMATCHPORTSYNRX), + SNMP_MIB_ITEM("MismatchPortAckRx", MPTCP_MIB_MISMATCHPORTACKRX), SNMP_MIB_ITEM("RmAddr", MPTCP_MIB_RMADDR), SNMP_MIB_ITEM("RmSubflow", MPTCP_MIB_RMSUBFLOW), SNMP_MIB_ITEM("MPPrioTx", MPTCP_MIB_MPPRIOTX), diff --git a/net/mptcp/mib.h b/net/mptcp/mib.h index 63914a5ef6a5d..72afbc135f8e7 100644 --- a/net/mptcp/mib.h +++ b/net/mptcp/mib.h @@ -22,6 +22,12 @@ enum linux_mptcp_mib_field { MPTCP_MIB_DUPDATA, /* Segments discarded due to duplicate DSS */ MPTCP_MIB_ADDADDR, /* Received ADD_ADDR with echo-flag=0 */ MPTCP_MIB_ECHOADD, /* Received ADD_ADDR with echo-flag=1 */ + MPTCP_MIB_PORTADD, /* Received ADD_ADDR with a port-number */ + MPTCP_MIB_JOINPORTSYNRX, /* Received a SYN MP_JOIN with a different port-number */ + MPTCP_MIB_JOINPORTSYNACKRX, /* Received a SYNACK MP_JOIN with a different port-number */ + MPTCP_MIB_JOINPORTACKRX, /* Received an ACK MP_JOIN with a different port-number */ + MPTCP_MIB_MISMATCHPORTSYNRX, /* Received a SYN MP_JOIN with a mismatched port-number */ + MPTCP_MIB_MISMATCHPORTACKRX, /* Received an ACK MP_JOIN with a mismatched port-number */ MPTCP_MIB_RMADDR, /* Received RM_ADDR */ MPTCP_MIB_RMSUBFLOW, /* Remove a subflow */ MPTCP_MIB_MPPRIOTX, /* Transmit a MP_PRIO */ diff --git a/net/mptcp/options.c b/net/mptcp/options.c index c9643344a8d74..331d460d82fa6 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -1024,6 +1024,10 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb) mptcp_pm_del_add_timer(msk, &addr); MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_ECHOADD); } + + if (mp_opt.port) + MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_PORTADD); + mp_opt.add_addr = 0; } diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index e7d3d76327bd2..88a165408b07d 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -205,8 +205,10 @@ static int subflow_init_req(struct request_sock *req, tcp_request_sock_ops.destructor(req); subflow_req->msk = NULL; subflow_req->mp_join = 0; + SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_MISMATCHPORTSYNRX); return -EPERM; } + SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_JOINPORTSYNRX); } subflow_req_create_thmac(subflow_req); @@ -429,6 +431,7 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb) pr_debug("synack inet_dport=%d %d", ntohs(inet_sk(sk)->inet_dport), ntohs(inet_sk(parent)->inet_dport)); + MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_JOINPORTSYNACKRX); } } else if (mptcp_check_fallback(sk)) { fallback: @@ -706,8 +709,11 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk, pr_debug("ack inet_sport=%d %d", ntohs(inet_sk(sk)->inet_sport), ntohs(inet_sk((struct sock *)owner)->inet_sport)); - if (!mptcp_pm_sport_in_anno_list(owner, sk)) + if (!mptcp_pm_sport_in_anno_list(owner, sk)) { + SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_MISMATCHPORTACKRX); goto out; + } + SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_JOINPORTACKRX); } } } From e431c8eb9d9994f2270d14ab552ff45c441b3c39 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Sat, 16 Jan 2021 12:08:45 +0100 Subject: [PATCH 33/37] tg create t/selftests-mptcp-add-testcases-for-ADD_ADDR-with-port base --- .topdeps | 1 - .topmsg | 16 ---------------- 2 files changed, 17 deletions(-) delete mode 100644 .topdeps delete mode 100644 .topmsg diff --git a/.topdeps b/.topdeps deleted file mode 100644 index 0ec28935b4361..0000000000000 --- a/.topdeps +++ /dev/null @@ -1 +0,0 @@ -t/selftests-mptcp-add-port-argument-for-pm_nl_ctl diff --git a/.topmsg b/.topmsg deleted file mode 100644 index 0fab28588faa9..0000000000000 --- a/.topmsg +++ /dev/null @@ -1,16 +0,0 @@ -From: Geliang Tang -Subject: [PATCH] mptcp: add the mibs for ADD_ADDR with port - -This patch adds the mibs for ADD_ADDR with port: - -MPTCP_MIB_PORTADD for received ADD_ADDR suboption with a port number. - -MPTCP_MIB_PORTSYNRX, MPTCP_MIB_PORTSYNACKRX, MPTCP_MIB_PORTACKRX, for -received MP_JOIN's SYN or SYN/ACK or ACK with a port number which is -different from the msk's port number. - -MPTCP_MIB_MISMATCHPORTSYNRX and MPTCP_MIB_MISMATCHPORTACKRX, for -received SYN or ACK MP_JOIN with a mismatched port-number. - -Reviewed-by: Mat Martineau -Signed-off-by: Geliang Tang From e4727c6e11f813b6f5f19a4ae7eaf21d8c2e71cc Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Sat, 16 Jan 2021 12:08:45 +0100 Subject: [PATCH 34/37] tg create t/selftests-mptcp-add-testcases-for-ADD_ADDR-with-port --- .topdeps | 1 + .topmsg | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000000000..23f36ab51512f --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +t/mptcp-add-the-mibs-for-ADD_ADDR-with-port diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000000000..b276ab086b8e4 --- /dev/null +++ b/.topmsg @@ -0,0 +1,4 @@ +From: Matthieu Baerts +Subject: [PATCH] t/selftests-mptcp-add-testcases-for-ADD_ADDR-with-port + +Signed-off-by: Matthieu Baerts From 6258644f1a7a502c9a076e9211282b9af91aaaaf Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Sat, 16 Jan 2021 12:08:46 +0100 Subject: [PATCH 35/37] tg import create t/selftests-mptcp-add-testcases-for-ADD_ADDR-with-port --- .topmsg | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/.topmsg b/.topmsg index b276ab086b8e4..fc3c459bebd88 100644 --- a/.topmsg +++ b/.topmsg @@ -1,4 +1,22 @@ -From: Matthieu Baerts -Subject: [PATCH] t/selftests-mptcp-add-testcases-for-ADD_ADDR-with-port +From: Geliang Tang +Subject: [PATCH] selftests: mptcp: add testcases for ADD_ADDR with port -Signed-off-by: Matthieu Baerts +This patch adds testcases for ADD_ADDR with port and the related MIB +counters check in chk_add_nr. The output looks like this: + + 24 signal address with port syn[ ok ] - synack[ ok ] - ack[ ok ] + add[ ok ] - echo [ ok ] - pt [ ok ] + syn[ ok ] - synack[ ok ] - ack[ ok ] + syn[ ok ] - ack [ ok ] + 25 subflow and signal with port syn[ ok ] - synack[ ok ] - ack[ ok ] + add[ ok ] - echo [ ok ] - pt [ ok ] + syn[ ok ] - synack[ ok ] - ack[ ok ] + syn[ ok ] - ack [ ok ] + 26 remove single address with port syn[ ok ] - synack[ ok ] - ack[ ok ] + add[ ok ] - echo [ ok ] - pt [ ok ] + syn[ ok ] - synack[ ok ] - ack[ ok ] + syn[ ok ] - ack [ ok ] + rm [ ok ] - sf [ ok ] + +Reviewed-by: Mat Martineau +Signed-off-by: Geliang Tang From 4eed522178187951a112abd3d87a394c34a613ba Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Thu, 14 Jan 2021 13:25:06 +0800 Subject: [PATCH 36/37] selftests: mptcp: add testcases for ADD_ADDR with port This patch adds testcases for ADD_ADDR with port and the related MIB counters check in chk_add_nr. The output looks like this: 24 signal address with port syn[ ok ] - synack[ ok ] - ack[ ok ] add[ ok ] - echo [ ok ] - pt [ ok ] syn[ ok ] - synack[ ok ] - ack[ ok ] syn[ ok ] - ack [ ok ] 25 subflow and signal with port syn[ ok ] - synack[ ok ] - ack[ ok ] add[ ok ] - echo [ ok ] - pt [ ok ] syn[ ok ] - synack[ ok ] - ack[ ok ] syn[ ok ] - ack [ ok ] 26 remove single address with port syn[ ok ] - synack[ ok ] - ack[ ok ] add[ ok ] - echo [ ok ] - pt [ ok ] syn[ ok ] - synack[ ok ] - ack[ ok ] syn[ ok ] - ack [ ok ] rm [ ok ] - sf [ ok ] Reviewed-by: Mat Martineau Signed-off-by: Geliang Tang --- .../testing/selftests/net/mptcp/mptcp_join.sh | 160 +++++++++++++++++- 1 file changed, 159 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index b5cd2a48831eb..b8fd924033b1e 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -487,6 +487,12 @@ chk_add_nr() { local add_nr=$1 local echo_nr=$2 + local port_nr=${3:-0} + local syn_nr=${4:-$port_nr} + local syn_ack_nr=${5:-$port_nr} + local ack_nr=${6:-$port_nr} + local mis_syn_nr=${7:-0} + local mis_ack_nr=${8:-0} local count local dump_stats @@ -509,7 +515,87 @@ chk_add_nr() ret=1 dump_stats=1 else - echo "[ ok ]" + echo -n "[ ok ]" + fi + + if [ $port_nr -gt 0 ]; then + echo -n " - pt " + count=`ip netns exec $ns2 nstat -as | grep MPTcpExtPortAdd | awk '{print $2}'` + [ -z "$count" ] && count=0 + if [ "$count" != "$port_nr" ]; then + echo "[fail] got $count ADD_ADDR[s] with a port-number expected $port_nr" + ret=1 + dump_stats=1 + else + echo "[ ok ]" + fi + + printf "%-39s %s" " " "syn" + count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinPortSynRx | + awk '{print $2}'` + [ -z "$count" ] && count=0 + if [ "$count" != "$syn_nr" ]; then + echo "[fail] got $count JOIN[s] syn with a different \ + port-number expected $syn_nr" + ret=1 + dump_stats=1 + else + echo -n "[ ok ]" + fi + + echo -n " - synack" + count=`ip netns exec $ns2 nstat -as | grep MPTcpExtMPJoinPortSynAckRx | + awk '{print $2}'` + [ -z "$count" ] && count=0 + if [ "$count" != "$syn_ack_nr" ]; then + echo "[fail] got $count JOIN[s] synack with a different \ + port-number expected $syn_ack_nr" + ret=1 + dump_stats=1 + else + echo -n "[ ok ]" + fi + + echo -n " - ack" + count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinPortAckRx | + awk '{print $2}'` + [ -z "$count" ] && count=0 + if [ "$count" != "$ack_nr" ]; then + echo "[fail] got $count JOIN[s] ack with a different \ + port-number expected $ack_nr" + ret=1 + dump_stats=1 + else + echo "[ ok ]" + fi + + printf "%-39s %s" " " "syn" + count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMismatchPortSynRx | + awk '{print $2}'` + [ -z "$count" ] && count=0 + if [ "$count" != "$mis_syn_nr" ]; then + echo "[fail] got $count JOIN[s] syn with a mismatched \ + port-number expected $mis_syn_nr" + ret=1 + dump_stats=1 + else + echo -n "[ ok ]" + fi + + echo -n " - ack " + count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMismatchPortAckRx | + awk '{print $2}'` + [ -z "$count" ] && count=0 + if [ "$count" != "$mis_ack_nr" ]; then + echo "[fail] got $count JOIN[s] ack with a mismatched \ + port-number expected $mis_ack_nr" + ret=1 + dump_stats=1 + else + echo "[ ok ]" + fi + else + echo "" fi if [ "${dump_stats}" = 1 ]; then @@ -955,6 +1041,78 @@ chk_join_nr "single address, backup" 1 1 1 chk_add_nr 1 1 chk_prio_nr 1 0 +# signal address with port +reset +ip netns exec $ns1 ./pm_nl_ctl limits 0 1 +ip netns exec $ns2 ./pm_nl_ctl limits 1 1 +ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100 +run_tests $ns1 $ns2 10.0.1.1 +chk_join_nr "signal address with port" 1 1 1 +chk_add_nr 1 1 1 + +# subflow and signal with port +reset +ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100 +ip netns exec $ns1 ./pm_nl_ctl limits 0 2 +ip netns exec $ns2 ./pm_nl_ctl limits 1 2 +ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow +run_tests $ns1 $ns2 10.0.1.1 +chk_join_nr "subflow and signal with port" 2 2 2 +chk_add_nr 1 1 1 + +# single address with port, remove +reset +ip netns exec $ns1 ./pm_nl_ctl limits 0 1 +ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100 +ip netns exec $ns2 ./pm_nl_ctl limits 1 1 +run_tests $ns1 $ns2 10.0.1.1 0 -1 0 slow +chk_join_nr "remove single address with port" 1 1 1 +chk_add_nr 1 1 1 +chk_rm_nr 0 0 + +# subflow and signal with port, remove +reset +ip netns exec $ns1 ./pm_nl_ctl limits 0 2 +ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100 +ip netns exec $ns2 ./pm_nl_ctl limits 1 2 +ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow +run_tests $ns1 $ns2 10.0.1.1 0 -1 -1 slow +chk_join_nr "remove subflow and signal with port" 2 2 2 +chk_add_nr 1 1 1 +chk_rm_nr 1 1 + +# subflows and signal with port, flush +reset +ip netns exec $ns1 ./pm_nl_ctl limits 0 3 +ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100 +ip netns exec $ns2 ./pm_nl_ctl limits 1 3 +ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow +ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow +run_tests $ns1 $ns2 10.0.1.1 0 -8 -8 slow +chk_join_nr "flush subflows and signal with port" 3 3 3 +chk_add_nr 1 1 +chk_rm_nr 2 2 + +# multiple addresses with port +reset +ip netns exec $ns1 ./pm_nl_ctl limits 2 2 +ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100 +ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal port 10100 +ip netns exec $ns2 ./pm_nl_ctl limits 2 2 +run_tests $ns1 $ns2 10.0.1.1 +chk_join_nr "multiple addresses with port" 2 2 2 +chk_add_nr 2 2 2 + +# multiple addresses with ports +reset +ip netns exec $ns1 ./pm_nl_ctl limits 2 2 +ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal port 10100 +ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal port 10101 +ip netns exec $ns2 ./pm_nl_ctl limits 2 2 +run_tests $ns1 $ns2 10.0.1.1 +chk_join_nr "multiple addresses with ports" 2 2 2 +chk_add_nr 2 2 2 + # single subflow, syncookies reset_with_cookies ip netns exec $ns1 ./pm_nl_ctl limits 0 1 From d2d5d019496667a75bd0c1acc6121298610454d4 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Sat, 16 Jan 2021 12:08:48 +0100 Subject: [PATCH 37/37] tg: switch to t/selftests-mptcp-add-testcases-for-ADD_ADDR-with-port Signed-off-by: Matthieu Baerts --- .topdeps | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.topdeps b/.topdeps index c6e7b24882674..983a1d54c6b5c 100644 --- a/.topdeps +++ b/.topdeps @@ -1 +1 @@ -t/selftests-mptcp-add-testcases-for-newly-added-addresses +t/selftests-mptcp-add-testcases-for-ADD_ADDR-with-port