Skip to content

Commit 1e5642a

Browse files
matttbeintel-lab-lkp
authored andcommitted
mptcp: pm: move generic helper at the top
In prevision to another change importing all generic PM helpers from pm_netlink.c to there. Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
1 parent a5b792b commit 1e5642a

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

net/mptcp/pm.c

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,33 @@
1212
#include "mib.h"
1313
#include "mptcp_pm_gen.h"
1414

15+
/* path manager helpers */
16+
17+
/* if sk is ipv4 or ipv6_only allows only same-family local and remote addresses,
18+
* otherwise allow any matching local/remote pair
19+
*/
20+
bool mptcp_pm_addr_families_match(const struct sock *sk,
21+
const struct mptcp_addr_info *loc,
22+
const struct mptcp_addr_info *rem)
23+
{
24+
bool mptcp_is_v4 = sk->sk_family == AF_INET;
25+
26+
#if IS_ENABLED(CONFIG_MPTCP_IPV6)
27+
bool loc_is_v4 = loc->family == AF_INET || ipv6_addr_v4mapped(&loc->addr6);
28+
bool rem_is_v4 = rem->family == AF_INET || ipv6_addr_v4mapped(&rem->addr6);
29+
30+
if (mptcp_is_v4)
31+
return loc_is_v4 && rem_is_v4;
32+
33+
if (ipv6_only_sock(sk))
34+
return !loc_is_v4 && !rem_is_v4;
35+
36+
return loc_is_v4 == rem_is_v4;
37+
#else
38+
return mptcp_is_v4 && loc->family == AF_INET && rem->family == AF_INET;
39+
#endif
40+
}
41+
1542
/* path manager command handlers */
1643

1744
int mptcp_pm_announce_addr(struct mptcp_sock *msk,
@@ -325,8 +352,6 @@ void mptcp_pm_mp_fail_received(struct sock *sk, u64 fail_seq)
325352
}
326353
}
327354

328-
/* path manager helpers */
329-
330355
bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, const struct sk_buff *skb,
331356
unsigned int opt_size, unsigned int remaining,
332357
struct mptcp_addr_info *addr, bool *echo,
@@ -574,31 +599,6 @@ void mptcp_pm_subflow_chk_stale(const struct mptcp_sock *msk, struct sock *ssk)
574599
}
575600
}
576601

577-
/* if sk is ipv4 or ipv6_only allows only same-family local and remote addresses,
578-
* otherwise allow any matching local/remote pair
579-
*/
580-
bool mptcp_pm_addr_families_match(const struct sock *sk,
581-
const struct mptcp_addr_info *loc,
582-
const struct mptcp_addr_info *rem)
583-
{
584-
bool mptcp_is_v4 = sk->sk_family == AF_INET;
585-
586-
#if IS_ENABLED(CONFIG_MPTCP_IPV6)
587-
bool loc_is_v4 = loc->family == AF_INET || ipv6_addr_v4mapped(&loc->addr6);
588-
bool rem_is_v4 = rem->family == AF_INET || ipv6_addr_v4mapped(&rem->addr6);
589-
590-
if (mptcp_is_v4)
591-
return loc_is_v4 && rem_is_v4;
592-
593-
if (ipv6_only_sock(sk))
594-
return !loc_is_v4 && !rem_is_v4;
595-
596-
return loc_is_v4 == rem_is_v4;
597-
#else
598-
return mptcp_is_v4 && loc->family == AF_INET && rem->family == AF_INET;
599-
#endif
600-
}
601-
602602
void mptcp_pm_worker(struct mptcp_sock *msk)
603603
{
604604
struct mptcp_pm_data *pm = &msk->pm;

0 commit comments

Comments
 (0)