Skip to contentSkip to conversation

Add prefix to path management routines

PATCH New Peter Krystad 1 participant 3 messages Sep 27, 2019

Subsystems (2)
lore
Share & tools
lore

Peter Krystad

author
#0 lore raw

cover Add prefix to path management routines

Make minor changes as proposed in Interim Path Manager patchset, and then add mptcp_ prefix to all path management api routines.

squashto: Implement path manager interface commands

Peter Krystad (2):
mptcp: Minor changes to path manager interface
mptcp: Prefix path management routines with mptcp_

 net/mptcp/options.c  | 10 ++++---
 net/mptcp/pm.c       | 63 ++++++++++++++++++++++++++------------------
 net/mptcp/protocol.c |  5 ++--
 net/mptcp/protocol.h | 35 +++++++++++++++---------
 net/mptcp/subflow.c  |  2 +-
 5 files changed, 69 insertions(+), 46 deletions(-)
Signature · 1 line
2.17.2
author
#1 lore raw

PATCH 1/2 mptcp: Minor changes to path manager interface

Needed preparations so basic path manager can be in it's own file

squashto: Add path manager interface

Signed-off-by Peter Krystad <peter.krystad(a)linux.intel.com>
---
 net/mptcp/pm.c       | 31 +++++++++++++++++++++----------
 net/mptcp/protocol.c |  1 -
 net/mptcp/protocol.h |  9 ++++++++-
 3 files changed, 29 insertions(+), 12 deletions(-)
net/mptcp/pm.c +21 -10
index c8d6341c9683..20bea1303342 100644
@@ -10,7 +10,7 @@
 
 /* path manager command handlers */
 
-int pm_announce_addr(u32 token, sa_family_t family, u8 local_id,
+int pm_announce_addr(u32 token, u8 local_id, sa_family_t family,
 		     struct in_addr *addr)
 {
 	struct mptcp_sock *msk = mptcp_token_get_sock(token);
@@ -50,7 +50,8 @@ int pm_remove_addr(u32 token, u8 local_id)
 	return 0;
 }
 
-int pm_create_subflow(u32 token, u8 remote_id)
+int pm_create_subflow(u32 token, u8 remote_id, sa_family_t family,
+		      struct in_addr *addr)
 {
 	struct mptcp_sock *msk = mptcp_token_get_sock(token);
 	struct sockaddr_in remote;
@@ -69,7 +70,10 @@ int pm_create_subflow(u32 token, u8 remote_id)
 
 	local.sin_family = AF_INET;
 	local.sin_port = 0;
-	local.sin_addr.s_addr = htonl(INADDR_ANY);
+	if (family == AF_INET)
+		local.sin_addr.s_addr = addr->s_addr;
+	else
+		local.sin_addr.s_addr = htonl(INADDR_ANY);
 
 	remote.sin_family = msk->pm.remote_family;
 	remote.sin_port = htons(msk->dport);
@@ -91,16 +95,21 @@ int pm_remove_subflow(u32 token, u8 remote_id)
 
 void pm_new_connection(struct mptcp_sock *msk, int server_side)
 {
-	pr_debug("msk=%p", msk);
+	struct mptcp_pm_data *pm = &msk->pm;
+
+	pr_debug("msk=%p, token=%u", msk, msk->token);
 
-	msk->pm.server_side = server_side;
+	pm->server_side = server_side;
+	pm->token = msk->token;
 }
 
 void pm_fully_established(struct mptcp_sock *msk)
 {
+	struct mptcp_pm_data *pm = &msk->pm;
+
 	pr_debug("msk=%p", msk);
 
-	msk->pm.fully_established = 1;
+	pm->fully_established = 1;
 }
 
 void pm_connection_closed(struct mptcp_sock *msk)
@@ -120,12 +129,14 @@ void pm_subflow_closed(struct mptcp_sock *msk, u8 id)
 
 void pm_add_addr(struct mptcp_sock *msk, const struct in_addr *addr, u8 id)
 {
+	struct mptcp_pm_data *pm = &msk->pm;
+
 	pr_debug("msk=%p, addr=%x, remote_id=%d", msk, addr->s_addr, id);
 
-	msk->pm.remote_addr.s_addr = addr->s_addr;
-	msk->pm.remote_id = id;
-	msk->pm.remote_family = AF_INET;
-	msk->pm.remote_valid = 1;
+	pm->remote_addr.s_addr = addr->s_addr;
+	pm->remote_id = id;
+	pm->remote_family = AF_INET;
+	pm->remote_valid = 1;
 }
 
 void pm_add_addr6(struct mptcp_sock *msk, const struct in6_addr *addr, u8 id)
net/mptcp/protocol.c +0 -1
index e0ae0a2542d1..45dbfe83b08f 100644
@@ -1440,7 +1440,6 @@ void mptcp_proto_init(void)
 		panic("Failed to allocate MPTCP pcpu counter\n");
 
 	subflow_init();
-	pm_init();
 
 	if (proto_register(&mptcp_prot, 1) != 0)
 		panic("Failed to register MPTCP proto.\n");
net/mptcp/protocol.h +8 -1
index f3f293c82058..6518c7f1c232 100644
@@ -288,7 +288,6 @@ static inline void crypto_key_gen_sha1(u64 *key, u32 *token, u64 *idsn)
 void crypto_hmac_sha1(u64 key1, u64 key2, u32 nonce1, u32 nonce2,
 		      u32 *hash_out);
 
-void pm_init(void);
 void pm_new_connection(struct mptcp_sock *msk, int server_side);
 void pm_fully_established(struct mptcp_sock *msk);
 void pm_connection_closed(struct mptcp_sock *msk);
@@ -297,6 +296,14 @@ void pm_subflow_closed(struct mptcp_sock *msk, u8 id);
 void pm_add_addr(struct mptcp_sock *msk, const struct in_addr *addr, u8 id);
 void pm_add_addr6(struct mptcp_sock *msk, const struct in6_addr *addr, u8 id);
 void pm_rm_addr(struct mptcp_sock *msk, u8 id);
+
+int pm_announce_addr(u32 token, u8 local_id, sa_family_t family,
+		     struct in_addr *addr);
+int pm_create_subflow(u32 token, u8 remote_id, sa_family_t family,
+		      struct in_addr *addr);
+int pm_remove_addr(u32 token, u8 local_id);
+int pm_remove_subflow(u32 token, u8 remote_id);
+
 int pm_addr_signal(struct mptcp_sock *msk, u8 *id,
 		   struct sockaddr_storage *saddr);
 int pm_get_local_id(struct request_sock *req, struct sock *sk,
Signature · 1 line
2.17.2
author
#2 lore raw

PATCH 2/2 mptcp: Prefix path management routines with mptcp_

In reply to Peter Krystad

Do not pollute pm namespace.

Signed-off-by Peter Krystad <peter.krystad(a)linux.intel.com>
---
 net/mptcp/options.c  | 10 ++++++----
 net/mptcp/pm.c       | 38 ++++++++++++++++++++------------------
 net/mptcp/protocol.c |  4 ++--
 net/mptcp/protocol.h | 42 ++++++++++++++++++++++--------------------
 net/mptcp/subflow.c  |  2 +-
 5 files changed, 51 insertions(+), 45 deletions(-)
net/mptcp/options.c +6 -4
index 42f8b9beaa41..c4111480a3f4 100644
@@ -465,7 +465,7 @@ static bool mptcp_established_options_addr(struct sock *sk,
 	if (!msk->pm.fully_established || !msk->addr_signal)
 		return false;
 
-	if (pm_addr_signal(msk, &id, &saddr))
+	if (mptcp_pm_addr_signal(msk, &id, &saddr))
 		return false;
 
 	if (saddr.ss_family == AF_INET && remaining < TCPOLEN_MPTCP_ADD_ADDR)
@@ -587,10 +587,12 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb,
 
 	if (msk && mp_opt->add_addr) {
 		if (mp_opt->family == MPTCP_ADDR_IPVERSION_4)
-			pm_add_addr(msk, &mp_opt->addr, mp_opt->addr_id);
+			mptcp_pm_add_addr(msk, &mp_opt->addr,
+					  mp_opt->addr_id);
 #if IS_ENABLED(CONFIG_IPV6)
 		else if (mp_opt->family == MPTCP_ADDR_IPVERSION_6)
-			pm_add_addr6(msk, &mp_opt->addr6, mp_opt->addr_id);
+			mptcp_pm_add_addr6(msk, &mp_opt->addr6,
+					   mp_opt->addr_id);
 #endif
 		mp_opt->add_addr = 0;
 	}
@@ -623,7 +625,7 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb,
 	mpext->data_fin = mp_opt->data_fin;
 
 	if (msk)
-		pm_fully_established(msk);
+		mptcp_pm_fully_established(msk);
 }
 
 void mptcp_write_options(__be32 *ptr, struct mptcp_out_options *opts)
net/mptcp/pm.c +20 -18
index 20bea1303342..0c0eddc3f18e 100644
@@ -10,8 +10,8 @@
 
 /* path manager command handlers */
 
-int pm_announce_addr(u32 token, u8 local_id, sa_family_t family,
-		     struct in_addr *addr)
+int mptcp_pm_announce_addr(u32 token, u8 local_id, sa_family_t family,
+			   struct in_addr *addr)
 {
 	struct mptcp_sock *msk = mptcp_token_get_sock(token);
 	int err = 0;
@@ -36,7 +36,7 @@ int pm_announce_addr(u32 token, u8 local_id, sa_family_t family,
 	return err;
 }
 
-int pm_remove_addr(u32 token, u8 local_id)
+int mptcp_pm_remove_addr(u32 token, u8 local_id)
 {
 	struct mptcp_sock *msk = mptcp_token_get_sock(token);
 
@@ -50,8 +50,8 @@ int pm_remove_addr(u32 token, u8 local_id)
 	return 0;
 }
 
-int pm_create_subflow(u32 token, u8 remote_id, sa_family_t family,
-		      struct in_addr *addr)
+int mptcp_pm_create_subflow(u32 token, u8 remote_id, sa_family_t family,
+			    struct in_addr *addr)
 {
 	struct mptcp_sock *msk = mptcp_token_get_sock(token);
 	struct sockaddr_in remote;
@@ -86,14 +86,14 @@ int pm_create_subflow(u32 token, u8 remote_id, sa_family_t family,
 	return err;
 }
 
-int pm_remove_subflow(u32 token, u8 remote_id)
+int mptcp_pm_remove_subflow(u32 token, u8 remote_id)
 {
 	return -ENOTSUPP;
 }
 
 /* path manager event handlers */
 
-void pm_new_connection(struct mptcp_sock *msk, int server_side)
+void mptcp_pm_new_connection(struct mptcp_sock *msk, int server_side)
 {
 	struct mptcp_pm_data *pm = &msk->pm;
 
@@ -103,7 +103,7 @@ void pm_new_connection(struct mptcp_sock *msk, int server_side)
 	pm->token = msk->token;
 }
 
-void pm_fully_established(struct mptcp_sock *msk)
+void mptcp_pm_fully_established(struct mptcp_sock *msk)
 {
 	struct mptcp_pm_data *pm = &msk->pm;
 
@@ -112,22 +112,23 @@ void pm_fully_established(struct mptcp_sock *msk)
 	pm->fully_established = 1;
 }
 
-void pm_connection_closed(struct mptcp_sock *msk)
+void mptcp_pm_connection_closed(struct mptcp_sock *msk)
 {
 	pr_debug("msk=%p", msk);
 }
 
-void pm_subflow_established(struct mptcp_sock *msk, u8 id)
+void mptcp_pm_subflow_established(struct mptcp_sock *msk, u8 id)
 {
 	pr_debug("msk=%p", msk);
 }
 
-void pm_subflow_closed(struct mptcp_sock *msk, u8 id)
+void mptcp_pm_subflow_closed(struct mptcp_sock *msk, u8 id)
 {
 	pr_debug("msk=%p", msk);
 }
 
-void pm_add_addr(struct mptcp_sock *msk, const struct in_addr *addr, u8 id)
+void mptcp_pm_add_addr(struct mptcp_sock *msk, const struct in_addr *addr,
+		       u8 id)
 {
 	struct mptcp_pm_data *pm = &msk->pm;
 
@@ -139,20 +140,21 @@ void pm_add_addr(struct mptcp_sock *msk, const struct in_addr *addr, u8 id)
 	pm->remote_valid = 1;
 }
 
-void pm_add_addr6(struct mptcp_sock *msk, const struct in6_addr *addr, u8 id)
+void mptcp_pm_add_addr6(struct mptcp_sock *msk, const struct in6_addr *addr,
+			u8 id)
 {
 	pr_debug("msk=%p", msk);
 }
 
-void pm_rm_addr(struct mptcp_sock *msk, u8 id)
+void mptcp_pm_rm_addr(struct mptcp_sock *msk, u8 id)
 {
 	pr_debug("msk=%p", msk);
 }
 
 /* path manager helpers */
 
-int pm_addr_signal(struct mptcp_sock *msk, u8 *id,
-		   struct sockaddr_storage *saddr)
+int mptcp_pm_addr_signal(struct mptcp_sock *msk, u8 *id,
+			 struct sockaddr_storage *saddr)
 {
 	struct sockaddr_in *addr = (struct sockaddr_in *)saddr;
 
@@ -169,8 +171,8 @@ int pm_addr_signal(struct mptcp_sock *msk, u8 *id,
 	return 0;
 }
 
-int pm_get_local_id(struct request_sock *req, struct sock *sk,
-		    const struct sk_buff *skb)
+int mptcp_pm_get_local_id(struct request_sock *req, struct sock *sk,
+			  const struct sk_buff *skb)
 {
 	struct subflow_request_sock *subflow_req = subflow_rsk(req);
 	struct mptcp_sock *msk = mptcp_sk(sk);
net/mptcp/protocol.c +2 -2
index 45dbfe83b08f..4aac1eda09b3 100644
@@ -981,7 +981,7 @@ static struct sock *mptcp_accept(struct sock *sk, int flags, int *err,
 		mptcp_token_update_accept(new_sock->sk, new_mptcp_sock);
 		msk->subflow = NULL;
 
-		pm_new_connection(msk, 1);
+		mptcp_pm_new_connection(msk, 1);
 
 		crypto_key_sha1(msk->remote_key, NULL, &ack_seq);
 		msk->write_seq = subflow->idsn + 1;
@@ -1138,7 +1138,7 @@ void mptcp_finish_connect(struct sock *sk, int mp_capable)
 		pr_debug("msk=%p, token=%u", msk, msk->token);
 		msk->dport = ntohs(inet_sk(msk->subflow->sk)->inet_dport);
 
-		pm_new_connection(msk, 0);
+		mptcp_pm_new_connection(msk, 0);
 
 		crypto_key_sha1(msk->remote_key, NULL, &ack_seq);
 		msk->write_seq = subflow->idsn + 1;
net/mptcp/protocol.h +22 -20

48 lines not on this page · raw message

net/mptcp/subflow.c +1 -1
index 80d297ce11d2..8a542d4d6277 100644
@@ -67,7 +67,7 @@ static bool subflow_token_join_request(struct request_sock *req,
 		return false;
 	}
 
-	if (pm_get_local_id(req, (struct sock *)msk, skb)) {
+	if (mptcp_pm_get_local_id(req, (struct sock *)msk, skb)) {
 		sock_put((struct sock *)msk);
 		return false;
 	}
Signature · 1 line
2.17.2