[PATCH mptcp-next 04/10] mptcp: drop addr_match and id_match

Geliang Tang posted 10 patches 2 years, 3 months ago
Only 7 patches received!
There is a newer version of this series
[PATCH mptcp-next 04/10] mptcp: drop addr_match and id_match
Posted by Geliang Tang 2 years, 3 months ago
This patch uses the newly defined helper mptcp_userspace_pm_get_entry()
in mptcp_userspace_pm_append_new_local_addr(), and drop local variables
addr_match and id_match to simplify the code.

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
 net/mptcp/pm_userspace.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
index 6856bde6c74c..b7fa9481e3b3 100644
--- a/net/mptcp/pm_userspace.c
+++ b/net/mptcp/pm_userspace.c
@@ -58,8 +58,6 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk,
 	struct sock *sk = (struct sock *)msk;
 	struct mptcp_pm_addr_entry *e;
 	unsigned long *id_bitmap;
-	bool addr_match = false;
-	bool id_match = false;
 	int ret = -EINVAL;
 
 	spin_lock_bh(&msk->pm.lock);
@@ -67,20 +65,13 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk,
 
 	id_bitmap = mptcp_pm_get_id_bitmap(msk);
 
-	list_for_each_entry(e, &msk->pm.userspace_pm_local_addr_list, list) {
-		addr_match = mptcp_addresses_equal(&e->addr, &entry->addr, true);
-		if (addr_match && entry->addr.id == 0)
-			entry->addr.id = e->addr.id;
-		id_match = (e->addr.id == entry->addr.id);
-		if (addr_match && id_match) {
-			match = e;
-			break;
-		} else if (addr_match || id_match) {
-			break;
-		}
-	}
+	e = mptcp_userspace_pm_get_entry(msk, &entry->addr, true);
+	if (e && entry->addr.id == 0)
+		entry->addr.id = e->addr.id;
+	if (e && e->addr.id == entry->addr.id)
+		match = e;
 
-	if (!match && !addr_match && !id_match) {
+	if (!match) {
 		/* Memory for the entry is allocated from the
 		 * sock option buffer.
 		 */
-- 
2.35.3