Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mptcp: drop flags and ifindex arguments

This patch added a new helper mptcp_pm_get_flags_and_ifindex_by_id(),
and used it in __mptcp_subflow_connect() to get the flags and ifindex
values.

Then the two arguments flags and ifindex of __mptcp_subflow_connect()
can be dropped.

Signed-off-by: Geliang Tang <geliangtang@xiaomi.com>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Geliang Tang and committed by
David S. Miller
ee285257 3349d362

+31 -7
+23 -3
net/mptcp/pm_netlink.c
··· 462 462 check_work_pending(msk); 463 463 remote_address((struct sock_common *)sk, &remote); 464 464 spin_unlock_bh(&msk->pm.lock); 465 - __mptcp_subflow_connect(sk, &local->addr, &remote, 466 - local->flags, local->ifindex); 465 + __mptcp_subflow_connect(sk, &local->addr, &remote); 467 466 spin_lock_bh(&msk->pm.lock); 468 467 return; 469 468 } ··· 517 518 local.family = remote.family; 518 519 519 520 spin_unlock_bh(&msk->pm.lock); 520 - __mptcp_subflow_connect(sk, &local, &remote, 0, 0); 521 + __mptcp_subflow_connect(sk, &local, &remote); 521 522 spin_lock_bh(&msk->pm.lock); 522 523 523 524 add_addr_echo: ··· 1102 1103 return entry; 1103 1104 } 1104 1105 return NULL; 1106 + } 1107 + 1108 + int mptcp_pm_get_flags_and_ifindex_by_id(struct net *net, unsigned int id, 1109 + u8 *flags, int *ifindex) 1110 + { 1111 + struct mptcp_pm_addr_entry *entry; 1112 + 1113 + *flags = 0; 1114 + *ifindex = 0; 1115 + 1116 + if (id) { 1117 + rcu_read_lock(); 1118 + entry = __lookup_addr_by_id(net_generic(net, pm_nl_pernet_id), id); 1119 + if (entry) { 1120 + *flags = entry->flags; 1121 + *ifindex = entry->ifindex; 1122 + } 1123 + rcu_read_unlock(); 1124 + } 1125 + 1126 + return 0; 1105 1127 } 1106 1128 1107 1129 static bool remove_anno_list_by_saddr(struct mptcp_sock *msk,
+3 -2
net/mptcp/protocol.h
··· 577 577 578 578 /* called with sk socket lock held */ 579 579 int __mptcp_subflow_connect(struct sock *sk, const struct mptcp_addr_info *loc, 580 - const struct mptcp_addr_info *remote, 581 - u8 flags, int ifindex); 580 + const struct mptcp_addr_info *remote); 582 581 int mptcp_subflow_create_socket(struct sock *sk, struct socket **new_sock); 583 582 void mptcp_info2sockaddr(const struct mptcp_addr_info *info, 584 583 struct sockaddr_storage *addr, ··· 732 733 struct mptcp_pm_add_entry * 733 734 mptcp_lookup_anno_list_by_saddr(struct mptcp_sock *msk, 734 735 struct mptcp_addr_info *addr); 736 + int mptcp_pm_get_flags_and_ifindex_by_id(struct net *net, unsigned int id, 737 + u8 *flags, int *ifindex); 735 738 736 739 int mptcp_pm_announce_addr(struct mptcp_sock *msk, 737 740 const struct mptcp_addr_info *addr,
+5 -2
net/mptcp/subflow.c
··· 1355 1355 } 1356 1356 1357 1357 int __mptcp_subflow_connect(struct sock *sk, const struct mptcp_addr_info *loc, 1358 - const struct mptcp_addr_info *remote, 1359 - u8 flags, int ifindex) 1358 + const struct mptcp_addr_info *remote) 1360 1359 { 1361 1360 struct mptcp_sock *msk = mptcp_sk(sk); 1362 1361 struct mptcp_subflow_context *subflow; ··· 1366 1367 struct sock *ssk; 1367 1368 u32 remote_token; 1368 1369 int addrlen; 1370 + int ifindex; 1371 + u8 flags; 1369 1372 int err; 1370 1373 1371 1374 if (!mptcp_is_fully_established(sk)) ··· 1391 1390 local_id = err; 1392 1391 } 1393 1392 1393 + mptcp_pm_get_flags_and_ifindex_by_id(sock_net(sk), local_id, 1394 + &flags, &ifindex); 1394 1395 subflow->remote_key = msk->remote_key; 1395 1396 subflow->local_key = msk->local_key; 1396 1397 subflow->token = msk->token;