All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Krystad <peter.krystad at linux.intel.com>
To: mptcp at lists.01.org
Subject: [MPTCP] [PATCH v3 09/10] Use pm_get_local_id() to get the real local address id.
Date: Wed, 07 Aug 2019 15:44:33 -0700	[thread overview]
Message-ID: <20190807224434.2829-10-peter.krystad@linux.intel.com> (raw)
In-Reply-To: 20190807224434.2829-1-peter.krystad@linux.intel.com

[-- Attachment #1: Type: text/plain, Size: 1869 bytes --]

Also, take reference to mptcp sock while using it

squashto: Add handling of incoming MP_JOIN requests

Signed-off-by: Peter Krystad <peter.krystad(a)linux.intel.com>
---
 net/mptcp/token.c | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/net/mptcp/token.c b/net/mptcp/token.c
index d7cf40b40beb..80acb6c6657f 100644
--- a/net/mptcp/token.c
+++ b/net/mptcp/token.c
@@ -222,14 +222,22 @@ int token_join_request(struct request_sock *req, const struct sk_buff *skb)
 	pr_debug("subflow_req=%p, token=%u", subflow_req, subflow_req->token);
 	spin_lock_bh(&token_tree_lock);
 	conn = lookup_token(subflow_req->token);
+	if (conn)
+		sock_hold(conn);
 	spin_unlock_bh(&token_tree_lock);
-	if (conn) {
-		// @@ get real local address id for this skb->saddr
-		subflow_req->local_id = 0;
-		new_req_join(req, conn, skb);
-		return 0;
+
+	if (!conn)
+		return -1;
+
+	if (pm_get_local_id(req, conn, skb)) {
+		sock_put(conn);
+		return -1;
 	}
-	return -1;
+
+	new_req_join(req, conn, skb);
+
+	sock_put(conn);
+	return 0;
 }
 
 /* validate received truncated hmac and create hmac for third ACK */
@@ -247,15 +255,20 @@ int token_join_valid(struct request_sock *req,
 {
 	struct subflow_request_sock *subflow_req = subflow_rsk(req);
 	struct sock *conn;
+	int err;
 
 	pr_debug("subflow_req=%p, token=%u", subflow_req, subflow_req->token);
 	spin_lock_bh(&token_tree_lock);
 	conn = lookup_token(subflow_req->token);
-	spin_unlock_bh(&token_tree_lock);
 	if (conn)
-		return new_join_valid(req, conn, rx_opt);
+		sock_hold(conn);
+	spin_unlock_bh(&token_tree_lock);
+	if (!conn)
+		return -1;
 
-	return -1;
+	err = new_join_valid(req, conn, rx_opt);
+	sock_put(conn);
+	return err;
 }
 
 /* create new local key, idsn, and token for subflow */
-- 
2.17.2


             reply	other threads:[~2019-08-07 22:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-07 22:44 Peter Krystad [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-08-12 19:36 [MPTCP] [PATCH v3 09/10] Use pm_get_local_id() to get the real local address id Matthieu Baerts

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=20190807224434.2829-10-peter.krystad@linux.intel.com \
    --to=unknown@example.com \
    /path/to/YOUR_REPLY

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

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