pm_netlink.c (5e9cfa71af79ac210d6274a17ca693fb48df1768) | pm_netlink.c (ff5a0b421cb23bf6b2898939ffef5b683045d9d3) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* Multipath TCP 3 * 4 * Copyright (c) 2020, Red Hat, Inc. 5 */ 6 7#define pr_fmt(fmt) "MPTCP: " fmt 8 --- 32 unchanged lines hidden (view full) --- 41#define MAX_ADDR_ID 255 42#define BITMAP_SZ DIV_ROUND_UP(MAX_ADDR_ID + 1, BITS_PER_LONG) 43 44struct pm_nl_pernet { 45 /* protects pernet updates */ 46 spinlock_t lock; 47 struct list_head local_addr_list; 48 unsigned int addrs; | 1// SPDX-License-Identifier: GPL-2.0 2/* Multipath TCP 3 * 4 * Copyright (c) 2020, Red Hat, Inc. 5 */ 6 7#define pr_fmt(fmt) "MPTCP: " fmt 8 --- 32 unchanged lines hidden (view full) --- 41#define MAX_ADDR_ID 255 42#define BITMAP_SZ DIV_ROUND_UP(MAX_ADDR_ID + 1, BITS_PER_LONG) 43 44struct pm_nl_pernet { 45 /* protects pernet updates */ 46 spinlock_t lock; 47 struct list_head local_addr_list; 48 unsigned int addrs; |
49 unsigned int stale_loss_cnt; |
|
49 unsigned int add_addr_signal_max; 50 unsigned int add_addr_accept_max; 51 unsigned int local_addr_max; 52 unsigned int subflows_max; 53 unsigned int next_id; 54 unsigned long id_bitmap[BITMAP_SZ]; 55}; 56 --- 837 unchanged lines hidden (view full) --- 894 895static const struct nla_policy mptcp_pm_policy[MPTCP_PM_ATTR_MAX + 1] = { 896 [MPTCP_PM_ATTR_ADDR] = 897 NLA_POLICY_NESTED(mptcp_pm_addr_policy), 898 [MPTCP_PM_ATTR_RCV_ADD_ADDRS] = { .type = NLA_U32, }, 899 [MPTCP_PM_ATTR_SUBFLOWS] = { .type = NLA_U32, }, 900}; 901 | 50 unsigned int add_addr_signal_max; 51 unsigned int add_addr_accept_max; 52 unsigned int local_addr_max; 53 unsigned int subflows_max; 54 unsigned int next_id; 55 unsigned long id_bitmap[BITMAP_SZ]; 56}; 57 --- 837 unchanged lines hidden (view full) --- 895 896static const struct nla_policy mptcp_pm_policy[MPTCP_PM_ATTR_MAX + 1] = { 897 [MPTCP_PM_ATTR_ADDR] = 898 NLA_POLICY_NESTED(mptcp_pm_addr_policy), 899 [MPTCP_PM_ATTR_RCV_ADD_ADDRS] = { .type = NLA_U32, }, 900 [MPTCP_PM_ATTR_SUBFLOWS] = { .type = NLA_U32, }, 901}; 902 |
903void mptcp_pm_nl_subflow_chk_stale(const struct mptcp_sock *msk, struct sock *ssk) 904{ 905 struct mptcp_subflow_context *iter, *subflow = mptcp_subflow_ctx(ssk); 906 struct sock *sk = (struct sock *)msk; 907 unsigned int active_max_loss_cnt; 908 struct net *net = sock_net(sk); 909 unsigned int stale_loss_cnt; 910 bool slow; 911 912 stale_loss_cnt = mptcp_stale_loss_cnt(net); 913 if (subflow->stale || !stale_loss_cnt || subflow->stale_count <= stale_loss_cnt) 914 return; 915 916 /* look for another available subflow not in loss state */ 917 active_max_loss_cnt = max_t(int, stale_loss_cnt - 1, 1); 918 mptcp_for_each_subflow(msk, iter) { 919 if (iter != subflow && mptcp_subflow_active(iter) && 920 iter->stale_count < active_max_loss_cnt) { 921 /* we have some alternatives, try to mark this subflow as idle ...*/ 922 slow = lock_sock_fast(ssk); 923 if (!tcp_rtx_and_write_queues_empty(ssk)) { 924 subflow->stale = 1; 925 __mptcp_retransmit_pending_data(sk); 926 } 927 unlock_sock_fast(ssk, slow); 928 929 /* always try to push the pending data regarless of re-injections: 930 * we can possibly use backup subflows now, and subflow selection 931 * is cheap under the msk socket lock 932 */ 933 __mptcp_push_pending(sk, 0); 934 return; 935 } 936 } 937} 938 |
|
902static int mptcp_pm_family_to_addr(int family) 903{ 904#if IS_ENABLED(CONFIG_MPTCP_IPV6) 905 if (family == AF_INET6) 906 return MPTCP_PM_ADDR_ATTR_ADDR6; 907#endif 908 return MPTCP_PM_ADDR_ATTR_ADDR4; 909} --- 1007 unchanged lines hidden (view full) --- 1917}; 1918 1919static int __net_init pm_nl_init_net(struct net *net) 1920{ 1921 struct pm_nl_pernet *pernet = net_generic(net, pm_nl_pernet_id); 1922 1923 INIT_LIST_HEAD_RCU(&pernet->local_addr_list); 1924 pernet->next_id = 1; | 939static int mptcp_pm_family_to_addr(int family) 940{ 941#if IS_ENABLED(CONFIG_MPTCP_IPV6) 942 if (family == AF_INET6) 943 return MPTCP_PM_ADDR_ATTR_ADDR6; 944#endif 945 return MPTCP_PM_ADDR_ATTR_ADDR4; 946} --- 1007 unchanged lines hidden (view full) --- 1954}; 1955 1956static int __net_init pm_nl_init_net(struct net *net) 1957{ 1958 struct pm_nl_pernet *pernet = net_generic(net, pm_nl_pernet_id); 1959 1960 INIT_LIST_HEAD_RCU(&pernet->local_addr_list); 1961 pernet->next_id = 1; |
1962 pernet->stale_loss_cnt = 4; |
|
1925 spin_lock_init(&pernet->lock); 1926 1927 /* No need to initialize other pernet fields, the struct is zeroed at 1928 * allocation time. 1929 */ 1930 1931 return 0; 1932} --- 30 unchanged lines hidden --- | 1963 spin_lock_init(&pernet->lock); 1964 1965 /* No need to initialize other pernet fields, the struct is zeroed at 1966 * allocation time. 1967 */ 1968 1969 return 0; 1970} --- 30 unchanged lines hidden --- |