Skip to content

Commit b5e9909

Browse files
committed
tgupdate: merge t/DO-NOT-MERGE-mptcp-enabled-by-default into t/upstream base
2 parents f58d7d3 + c1bd2fc commit b5e9909

File tree

4 files changed

+35
-40
lines changed

4 files changed

+35
-40
lines changed

net/mptcp/pm.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,27 @@ int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info)
489489
return ret;
490490
}
491491

492+
int mptcp_pm_genl_fill_addr(struct sk_buff *msg,
493+
struct netlink_callback *cb,
494+
struct mptcp_pm_addr_entry *entry)
495+
{
496+
void *hdr;
497+
498+
hdr = genlmsg_put(msg, NETLINK_CB(cb->skb).portid,
499+
cb->nlh->nlmsg_seq, &mptcp_genl_family,
500+
NLM_F_MULTI, MPTCP_PM_CMD_GET_ADDR);
501+
if (!hdr)
502+
return -EINVAL;
503+
504+
if (mptcp_nl_fill_addr(msg, entry) < 0) {
505+
genlmsg_cancel(msg, hdr);
506+
return -EINVAL;
507+
}
508+
509+
genlmsg_end(msg, hdr);
510+
return 0;
511+
}
512+
492513
static int mptcp_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb)
493514
{
494515
const struct genl_info *info = genl_info_dump(cb);

net/mptcp/pm_netlink.c

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ bool mptcp_addresses_equal(const struct mptcp_addr_info *a,
6464
addr_equals = a->addr.s_addr == b->addr.s_addr;
6565
#if IS_ENABLED(CONFIG_MPTCP_IPV6)
6666
else
67-
addr_equals = !ipv6_addr_cmp(&a->addr6, &b->addr6);
67+
addr_equals = ipv6_addr_equal(&a->addr6, &b->addr6);
6868
} else if (a->family == AF_INET) {
6969
if (ipv6_addr_v4mapped(&b->addr6))
7070
addr_equals = a->addr.s_addr == b->addr6.s6_addr32[3];
@@ -1798,7 +1798,6 @@ int mptcp_pm_nl_dump_addr(struct sk_buff *msg,
17981798
struct mptcp_pm_addr_entry *entry;
17991799
struct pm_nl_pernet *pernet;
18001800
int id = cb->args[0];
1801-
void *hdr;
18021801
int i;
18031802

18041803
pernet = pm_nl_get_pernet(net);
@@ -1813,19 +1812,10 @@ int mptcp_pm_nl_dump_addr(struct sk_buff *msg,
18131812
if (entry->addr.id <= id)
18141813
continue;
18151814

1816-
hdr = genlmsg_put(msg, NETLINK_CB(cb->skb).portid,
1817-
cb->nlh->nlmsg_seq, &mptcp_genl_family,
1818-
NLM_F_MULTI, MPTCP_PM_CMD_GET_ADDR);
1819-
if (!hdr)
1815+
if (mptcp_pm_genl_fill_addr(msg, cb, entry) < 0)
18201816
break;
18211817

1822-
if (mptcp_nl_fill_addr(msg, entry) < 0) {
1823-
genlmsg_cancel(msg, hdr);
1824-
break;
1825-
}
1826-
18271818
id = entry->addr.id;
1828-
genlmsg_end(msg, hdr);
18291819
}
18301820
}
18311821
rcu_read_unlock();
@@ -2032,9 +2022,7 @@ static int mptcp_event_add_subflow(struct sk_buff *skb, const struct sock *ssk)
20322022
break;
20332023
#if IS_ENABLED(CONFIG_MPTCP_IPV6)
20342024
case AF_INET6: {
2035-
const struct ipv6_pinfo *np = inet6_sk(ssk);
2036-
2037-
if (nla_put_in6_addr(skb, MPTCP_ATTR_SADDR6, &np->saddr))
2025+
if (nla_put_in6_addr(skb, MPTCP_ATTR_SADDR6, &issk->pinet6->saddr))
20382026
return -EMSGSIZE;
20392027
if (nla_put_in6_addr(skb, MPTCP_ATTR_DADDR6, &ssk->sk_v6_daddr))
20402028
return -EMSGSIZE;
@@ -2261,9 +2249,7 @@ void mptcp_event_pm_listener(const struct sock *ssk,
22612249
break;
22622250
#if IS_ENABLED(CONFIG_MPTCP_IPV6)
22632251
case AF_INET6: {
2264-
const struct ipv6_pinfo *np = inet6_sk(ssk);
2265-
2266-
if (nla_put_in6_addr(skb, MPTCP_ATTR_SADDR6, &np->saddr))
2252+
if (nla_put_in6_addr(skb, MPTCP_ATTR_SADDR6, &issk->pinet6->saddr))
22672253
goto nla_put_failure;
22682254
break;
22692255
}

net/mptcp/pm_userspace.c

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk,
4848
bool needs_id)
4949
{
5050
DECLARE_BITMAP(id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1);
51-
struct mptcp_pm_addr_entry *match = NULL;
5251
struct sock *sk = (struct sock *)msk;
5352
struct mptcp_pm_addr_entry *e;
5453
bool addr_match = false;
@@ -63,16 +62,12 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk,
6362
if (addr_match && entry->addr.id == 0 && needs_id)
6463
entry->addr.id = e->addr.id;
6564
id_match = (e->addr.id == entry->addr.id);
66-
if (addr_match && id_match) {
67-
match = e;
65+
if (addr_match || id_match)
6866
break;
69-
} else if (addr_match || id_match) {
70-
break;
71-
}
7267
__set_bit(e->addr.id, id_bitmap);
7368
}
7469

75-
if (!match && !addr_match && !id_match) {
70+
if (!addr_match && !id_match) {
7671
/* Memory for the entry is allocated from the
7772
* sock option buffer.
7873
*/
@@ -90,7 +85,7 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk,
9085
list_add_tail_rcu(&e->list, &msk->pm.userspace_pm_local_addr_list);
9186
msk->pm.local_addr_used++;
9287
ret = e->addr.id;
93-
} else if (match) {
88+
} else if (addr_match && id_match) {
9489
ret = entry->addr.id;
9590
}
9691

@@ -465,9 +460,7 @@ static struct sock *mptcp_nl_find_ssk(struct mptcp_sock *msk,
465460
break;
466461
#if IS_ENABLED(CONFIG_MPTCP_IPV6)
467462
case AF_INET6: {
468-
const struct ipv6_pinfo *pinfo = inet6_sk(ssk);
469-
470-
if (!ipv6_addr_equal(&local->addr6, &pinfo->saddr) ||
463+
if (!ipv6_addr_equal(&local->addr6, &issk->pinet6->saddr) ||
471464
!ipv6_addr_equal(&remote->addr6, &ssk->sk_v6_daddr))
472465
continue;
473466
break;
@@ -641,7 +634,8 @@ int mptcp_userspace_pm_dump_addr(struct sk_buff *msg,
641634
struct mptcp_sock *msk;
642635
int ret = -EINVAL;
643636
struct sock *sk;
644-
void *hdr;
637+
638+
BUILD_BUG_ON(sizeof(struct id_bitmap) > sizeof(cb->ctx));
645639

646640
bitmap = (struct id_bitmap *)cb->ctx;
647641

@@ -657,19 +651,10 @@ int mptcp_userspace_pm_dump_addr(struct sk_buff *msg,
657651
if (test_bit(entry->addr.id, bitmap->map))
658652
continue;
659653

660-
hdr = genlmsg_put(msg, NETLINK_CB(cb->skb).portid,
661-
cb->nlh->nlmsg_seq, &mptcp_genl_family,
662-
NLM_F_MULTI, MPTCP_PM_CMD_GET_ADDR);
663-
if (!hdr)
654+
if (mptcp_pm_genl_fill_addr(msg, cb, entry) < 0)
664655
break;
665656

666-
if (mptcp_nl_fill_addr(msg, entry) < 0) {
667-
genlmsg_cancel(msg, hdr);
668-
break;
669-
}
670-
671657
__set_bit(entry->addr.id, bitmap->map);
672-
genlmsg_end(msg, hdr);
673658
}
674659
spin_unlock_bh(&msk->pm.lock);
675660
release_sock(sk);

net/mptcp/protocol.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,9 @@ void mptcp_fastopen_subflow_synack_set_params(struct mptcp_subflow_context *subf
10611061
struct request_sock *req);
10621062
int mptcp_nl_fill_addr(struct sk_buff *skb,
10631063
struct mptcp_pm_addr_entry *entry);
1064+
int mptcp_pm_genl_fill_addr(struct sk_buff *msg,
1065+
struct netlink_callback *cb,
1066+
struct mptcp_pm_addr_entry *entry);
10641067

10651068
static inline bool mptcp_pm_should_add_signal(struct mptcp_sock *msk)
10661069
{

0 commit comments

Comments
 (0)