MP_PRIO support
Subsystems (3)
Geliang Tang
cover MP_PRIO support
v1:
- add MP_PRIO PM netlink support
Geliang Tang (5):
mptcp: add the outgoing MP_PRIO support
mptcp: add the incoming MP_PRIO support
mptcp: deal with MPTCP_PM_ADDR_FLAG_BACKUP in PM netlink
mptcp: add the mibs for MP_PRIO
selftests: mptcp: add the MP_PRIO testcases
net/mptcp/mib.c | 2 + net/mptcp/mib.h | 2 + net/mptcp/options.c | 56 +++++++++++++ net/mptcp/pm.c | 19 +++++ net/mptcp/pm_netlink.c | 81 +++++++++++++++++++ net/mptcp/protocol.h | 11 +++ .../testing/selftests/net/mptcp/mptcp_join.sh | 81 ++++++++++++++++++- 7 files changed, 251 insertions(+), 1 deletion(-)
Signature · 1 line
2.26.2
Geliang Tang
PATCH 1/5 mptcp: add the outgoing MP_PRIO support
This patch added the outgoing MP_PRIO logic:
In mptcp_pm_mp_prio_send_ack, find the related subflow and subsocket according to the input parameter addr. Save the input priority value to suflow's backup, and reschedule mptcp_worker. Then set subflow's send_mp_prio flag to true, and save the input priority value to suflow's request_bkup. Finally, send out a pure ACK on the related subsocket.
In mptcp_established_options_mp_prio, check whether the subflow's send_mp_prio is set. If it is, this is the packet for send MP_PRIO. So save subflow->request_bkup value to mptcp_out_options's backup, and change the option type to OPTION_MPTCP_PRIO.
In mptcp_write_options, sent out the MP_PRIO suboption with mptcp_out_options's backup value.
--- net/mptcp/options.c | 40 ++++++++++++++++++++++++++++++++++++++++ net/mptcp/pm_netlink.c | 39 +++++++++++++++++++++++++++++++++++++++ net/mptcp/protocol.h | 6 ++++++ 3 files changed, 85 insertions(+)
net/mptcp/options.c +40 -0
@@ -666,6 +666,28 @@ static bool mptcp_established_options_rm_addr(struct sock *sk,return true; } +static bool mptcp_established_options_mp_prio (struct sock *sk, +unsigned int *size, +unsigned int remaining, +struct mptcp_out_options *opts) +{ +struct mptcp_subflow_context *subflow =mptcp_subflow_ctx (sk); + +if (!subflow->send_mp_prio) +return false; + +if (remaining <TCPOLEN_MPTCP_PRIO ) +return false; + + *size =TCPOLEN_MPTCP_PRIO ; + opts->suboptions |=OPTION_MPTCP_PRIO ; + opts->backup = subflow->request_bkup; + +pr_debug ("prio=%d" , opts->backup); + +return true; +} +bool mptcp_established_options (struct sock *sk,struct sk_buff *skb,unsigned int *size,unsigned int remaining,struct mptcp_out_options *opts)
@@ -708,6 +730,12 @@ bool mptcp_established_options(struct sock *sk, struct sk_buff *skb, ret = true; } +if (mptcp_established_options_mp_prio (sk, &opt_size, remaining, opts)) { + *size += opt_size; + remaining -= opt_size; + ret = true; + } +return ret; }
@@ -1145,6 +1173,18 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp, 0, opts->rm_id); } +if (OPTION_MPTCP_PRIO & opts->suboptions) { +const struct sock *ssk = (const struct sock *)tp; +struct mptcp_subflow_context *subflow; + + subflow =mptcp_subflow_ctx (ssk); + subflow->send_mp_prio =0 ; + + *ptr++ =mptcp_option (MPTCPOPT_MP_PRIO , +TCPOLEN_MPTCP_PRIO , + opts->backup,TCPOPT_NOP ); + } +if (OPTION_MPTCP_MPJ_SYN & opts->suboptions) { *ptr++ = mptcp_option(MPTCPOPT_MP_JOIN, TCPOLEN_MPTCP_MPJ_SYN,
net/mptcp/pm_netlink.c +39 -0
@@ -513,6 +513,45 @@ void mptcp_pm_nl_add_addr_send_ack(struct mptcp_sock *msk) } } +void mptcp_pm_nl_mp_prio_send_ack (struct mptcp_sock *msk, +struct mptcp_addr_info *addr, +u8 bkup) +{ +struct mptcp_subflow_context *subflow; + +pr_debug ("bkup=%d" , bkup); + +mptcp_for_each_subflow (msk, subflow) { +struct sock *ssk =mptcp_subflow_tcp_sock (subflow); +struct sock *sk = (struct sock *)msk; +struct mptcp_addr_info local; + +local_address ((struct sock_common *)ssk, &local); +if (!addresses_equal (&local, addr, false)) +continue ; + +if (subflow->backup == bkup) { +pr_warn ("backup error" ); +return ; + } + + subflow->backup = bkup; +mptcp_schedule_work (sk); + + subflow->send_mp_prio =1 ; + subflow->request_bkup = bkup; + +spin_unlock_bh (&msk->pm.lock); +pr_debug ("send ack for mp_prio" ); +lock_sock (ssk); +tcp_send_ack (ssk); +release_sock (ssk); +spin_lock_bh (&msk->pm.lock); + +break ; + } +} +void mptcp_pm_nl_rm_addr_received (struct mptcp_sock *msk) {struct mptcp_subflow_context *subflow, *tmp;
net/mptcp/protocol.h +6 -0
@@ -23,6 +23,7 @@#define OPTION_MPTCP_ADD_ADDR BIT(6)#define OPTION_MPTCP_ADD_ADDR6 BIT(7)#define OPTION_MPTCP_RM_ADDR BIT(8) +#define OPTION_MPTCP_PRIO BIT(9)/* MPTCP option subtypes */ #define MPTCPOPT_MP_CAPABLE 0
@@ -59,6 +60,7 @@#define TCPOLEN_MPTCP_PORT_LEN 4#define TCPOLEN_MPTCP_ADD_ADDR_HMAC 8#define TCPOLEN_MPTCP_RM_ADDR_BASE 4 +#define TCPOLEN_MPTCP_PRIO 4/* MPTCP MP_JOIN flags */ #define MPTCPOPT_BACKUP BIT(0)
@@ -394,6 +396,7 @@ struct mptcp_subflow_context { map_valid : 1, mpc_map : 1, backup : 1, + send_mp_prio : 1, rx_eof : 1, can_ack : 1, /* only after processing the remote a key */ disposable : 1, /* ctx can be free at ulp release time */
@@ -552,6 +555,9 @@ void mptcp_pm_add_addr_received(struct mptcp_sock *msk, const struct mptcp_addr_info *addr);void mptcp_pm_add_addr_send_ack (struct mptcp_sock *msk);void mptcp_pm_rm_addr_received (struct mptcp_sock *msk,u8 rm_id); +void mptcp_pm_nl_mp_prio_send_ack (struct mptcp_sock *msk, +struct mptcp_addr_info *addr, +u8 bkup);void mptcp_pm_free_anno_list (struct mptcp_sock *msk);bool mptcp_pm_sport_in_anno_list (struct mptcp_sock *msk,const struct sock *sk); struct mptcp_pm_add_entry *
Signature · 1 line
2.26.2
Geliang Tang
PATCH 2/5 mptcp: add the incoming MP_PRIO support
This patch added the incoming MP_PRIO logic:
Added a flag named mp_prio in struct mptcp_options_received, to mark the MP_PRIO is received, and save the priority value to struct mptcp_options_received's backup member. Then invoke mptcp_pm_mp_prio_received with the receiving subsocket and the backup value.
In mptcp_pm_mp_prio_received, get the subflow context according the input subsocket, and change the subflow's backup as the incoming priority value and reschedule mptcp_worker.
--- net/mptcp/options.c | 15 +++++++++++++++ net/mptcp/pm.c | 19 +++++++++++++++++++ net/mptcp/protocol.h | 5 +++++ 3 files changed, 39 insertions(+)
net/mptcp/options.c +15 -0
@@ -282,6 +282,15 @@ static void mptcp_parse_option(const struct sk_buff *skb,pr_debug ("RM_ADDR: id=%d" , mp_opt->rm_id);break ; +case MPTCPOPT_MP_PRIO : +if (opsize !=TCPOLEN_MPTCP_PRIO ) +break ; + + mp_opt->mp_prio =1 ; + mp_opt->backup = *ptr++ &MPTCP_PRIO_BKUP ; +pr_debug ("MP_PRIO: prio=%d" , mp_opt->backup); +break ; +default :break ; }
@@ -302,6 +311,7 @@ void mptcp_get_options(const struct sk_buff *skb, mp_opt->port =0 ; mp_opt->rm_addr =0 ; mp_opt->dss =0 ; + mp_opt->mp_prio =0 ; length = (th->doff *4 ) -sizeof (struct tcphdr ); ptr = (const unsigned char *)(th +1 );
@@ -999,6 +1009,11 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb) mp_opt.rm_addr =0 ; } +if (mp_opt.mp_prio) { +mptcp_pm_mp_prio_received (sk, mp_opt.backup); + mp_opt.mp_prio =0 ; + } +if (!mp_opt.dss)return ;
net/mptcp/pm.c +19 -0
@@ -201,6 +201,25 @@ void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id)spin_unlock_bh (&pm->lock); } +void mptcp_pm_mp_prio_received (struct sock *sk,u8 bkup) +{ +struct mptcp_subflow_context *subflow =mptcp_subflow_ctx (sk); +struct mptcp_sock *msk =mptcp_sk (subflow->conn); + +pr_debug ("bkup=%d" , bkup); + +if (subflow->backup == bkup) { +pr_warn ("backup error." ); +return ; + } + + subflow->backup = bkup; + +spin_lock_bh (&msk->pm.lock); +mptcp_schedule_work ((struct sock *)msk); +spin_unlock_bh (&msk->pm.lock); +} +/* path manager helpers */ bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
net/mptcp/protocol.h +5 -0
@@ -87,6 +87,9 @@#define MPTCP_ADDR_IPVERSION_4 4#define MPTCP_ADDR_IPVERSION_6 6 +/* MPTCP MP_PRIO flags */ +#define MPTCP_PRIO_BKUP BIT(0) +/* MPTCP socket flags */ #define MPTCP_DATA_READY 0#define MPTCP_NOSPACE 1
@@ -116,6 +119,7 @@ struct mptcp_options_received { dss : 1, add_addr : 1, rm_addr : 1, + mp_prio : 1, family : 4, echo : 1, backup : 1;
@@ -555,6 +559,7 @@ void mptcp_pm_add_addr_received(struct mptcp_sock *msk, const struct mptcp_addr_info *addr);void mptcp_pm_add_addr_send_ack (struct mptcp_sock *msk);void mptcp_pm_rm_addr_received (struct mptcp_sock *msk,u8 rm_id); +void mptcp_pm_mp_prio_received (struct sock *sk,u8 bkup);void mptcp_pm_nl_mp_prio_send_ack (struct mptcp_sock *msk,struct mptcp_addr_info *addr,u8 bkup);
Signature · 1 line
2.26.2
Geliang Tang
PATCH 3/5 mptcp: deal with MPTCP_PM_ADDR_FLAG_BACKUP in PM netlink
This patch added the MP_PRIO support for PM netlink:
When PM netlink adds an address, check whether the MPTCP_PM_ADDR_FLAG_BACKUP flag is set. If it is, check whether this address had been added in the local address list. If it had been, then call mptcp_nl_addr_backup to deal with this address.
In mptcp_nl_addr_backup, we traverse all the existing msk sockets to find the relevant sockets, and get the backup value according to whether the MPTCP_PM_ADDR_FLAG_BACKUP flag is set, then call mptcp_pm_nl_mp_prio_send_ack to send out a MP_PRIO ACK packet.
In mptcp_pm_nl_mp_prio_send_ack, we set or clear the MPTCP_PM_ADDR_FLAG_BACKUP flag.
--- net/mptcp/pm_netlink.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
net/mptcp/pm_netlink.c +41 -0
@@ -535,6 +535,11 @@ void mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk,return ; } +if (addr->flags &MPTCP_PM_ADDR_FLAG_BACKUP ) + addr->flags &= ~MPTCP_PM_ADDR_FLAG_BACKUP ; +else + addr->flags |=MPTCP_PM_ADDR_FLAG_BACKUP ; + subflow->backup = bkup;mptcp_schedule_work (sk);
@@ -847,17 +852,53 @@ static struct pm_nl_pernet *genl_info_pm_nl(struct genl_info *info)return net_generic (genl_info_net (info), pm_nl_pernet_id); } +static int mptcp_nl_addr_backup (struct net *net, +struct mptcp_addr_info *addr) +{ +long s_slot =0 , s_num =0 ; +struct mptcp_sock *msk; + +while ((msk =mptcp_token_iter_next (net, &s_slot, &s_num)) !=NULL ) { +u8 bkup = !(addr->flags &MPTCP_PM_ADDR_FLAG_BACKUP ); +struct sock *sk = (struct sock *)msk; + +if (list_empty (&msk->conn_list)) + goto next; + +lock_sock (sk); +spin_lock_bh (&msk->pm.lock); +mptcp_pm_nl_mp_prio_send_ack (msk, addr, bkup); +spin_unlock_bh (&msk->pm.lock); +release_sock (sk); + +next: +sock_put (sk); +cond_resched (); + } + +return 0 ; +} +static int mptcp_nl_cmd_add_addr (struct sk_buff *skb,struct genl_info *info) {struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR ];struct pm_nl_pernet *pernet =genl_info_pm_nl (info);struct mptcp_pm_addr_entry addr, *entry; +struct net *net =sock_net (skb->sk);int ret; ret =mptcp_pm_parse_addr (attr, info, true, &addr);if (ret <0 )return ret; +if (addr.addr.flags &MPTCP_PM_ADDR_FLAG_BACKUP ) { +list_for_each_entry (entry, &pernet->local_addr_list, list) { +if (addresses_equal (&entry->addr, &addr.addr, false)) +mptcp_nl_addr_backup (net, &entry->addr); + } +return 0 ; + } + entry =kmalloc (sizeof (*entry),GFP_KERNEL );if (!entry) {GENL_SET_ERR_MSG (info,"can't allocate addr" );
Signature · 1 line
2.26.2
Geliang Tang
PATCH 4/5 mptcp: add the mibs for MP_PRIO
This patch added the mibs for MP_PRIO, MPTCP_MIB_MPPRIOTX for transmitting of the MP_PRIO suboption, and MPTCP_MIB_MPPRIORX for receiving of it.
--- net/mptcp/mib.c | 2 ++ net/mptcp/mib.h | 2 ++ net/mptcp/options.c | 1 + net/mptcp/pm_netlink.c | 1 + 4 files changed, 6 insertions(+)
net/mptcp/mib.c +2 -0
@@ -35,6 +35,8 @@ static const struct snmp_mib mptcp_snmp_list[] = {SNMP_MIB_ITEM ("PortAckRx" ,MPTCP_MIB_PORTACKRX ),SNMP_MIB_ITEM ("RmAddr" ,MPTCP_MIB_RMADDR ),SNMP_MIB_ITEM ("RmSubflow" ,MPTCP_MIB_RMSUBFLOW ), +SNMP_MIB_ITEM ("MPPrioTx" ,MPTCP_MIB_MPPRIOTX ), +SNMP_MIB_ITEM ("MPPrioRx" ,MPTCP_MIB_MPPRIORX ), SNMP_MIB_SENTINEL };
net/mptcp/mib.h +2 -0
@@ -28,6 +28,8 @@ enum linux_mptcp_mib_field {MPTCP_MIB_PORTACKRX ,/* Received an ACK + MP_JOIN with port */ MPTCP_MIB_RMADDR ,/* Received RM_ADDR */ MPTCP_MIB_RMSUBFLOW ,/* Remove a subflow */ +MPTCP_MIB_MPPRIOTX ,/* Transmit a MP_PRIO */ +MPTCP_MIB_MPPRIORX ,/* Received a MP_PRIO */ __MPTCP_MIB_MAX };
net/mptcp/options.c +1 -0
@@ -1011,6 +1011,7 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)if (mp_opt.mp_prio) {mptcp_pm_mp_prio_received (sk, mp_opt.backup); +MPTCP_INC_STATS (sock_net (sk),MPTCP_MIB_MPPRIORX ); mp_opt.mp_prio =0 ; }
net/mptcp/pm_netlink.c +1 -0
@@ -545,6 +545,7 @@ void mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk, subflow->send_mp_prio =1 ; subflow->request_bkup = bkup; +__MPTCP_INC_STATS (sock_net (sk),MPTCP_MIB_MPPRIOTX );spin_unlock_bh (&msk->pm.lock);pr_debug ("send ack for mp_prio" );
Signature · 1 line
2.26.2
Geliang Tang
PATCH 5/5 selftests: mptcp: add the MP_PRIO testcases
This patch added the MP_PRIO testcases:
Add a new argument bkup for run_tests and do_transfer to mark how many times we want to execute the 'pm_nl_ctl flags backup' command.
Add a new function chk_prio_nr to check the MP_PRIO related MIB counters.
The output looks like this:
29 single subflow, backup syn[ ok ] - synack[ ok ] - ack[ ok ]
ptx[ ok ] - prx [ ok ]
30 single address, backup syn[ ok ] - synack[ ok ] - ack[ ok ]
add[ ok ] - echo [ ok ]
ptx[ ok ] - prx [ ok ]
--- .../testing/selftests/net/mptcp/mptcp_join.sh | 81 ++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +80 -1
@@ -213,6 +213,7 @@ do_transfer() rm_nr_ns2="$8" speed="$9" with_port="${10}" + bkup="${11}" port=$((10000+$TEST_COUNT)) TEST_COUNT=$((TEST_COUNT+1))
@@ -294,6 +295,27 @@ do_transfer() done fi + if [ $bkup -gt 0 ]; then + counter=1 + + while [ $counter -le $bkup ] + do + sleep 1 + for netns in "$ns1" "$ns2";do + dump=(`ip netns exec $netns ./pm_nl_ctl dump`) + num=${#dump[@]} + while [ $num -gt 0 ] + do + backup="ip netns exec $netns \ + ./pm_nl_ctl add ${dump[$num - 1]} flags backup" + $backup + num=$(($num - 5)) + done + done + let counter+=1 + done + fi + wait $cpid retc=$? wait $spid
@@ -361,6 +383,7 @@ run_tests() rm_nr_ns2="${6:-0}" speed="${7:-fast}" with_port="${8:-0}" + bkup=${9:-0} lret=0 oldin=""
@@ -375,7 +398,7 @@ run_tests() fi do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} \ - ${test_linkfail} ${rm_nr_ns1} ${rm_nr_ns2} ${speed} ${with_port} + ${test_linkfail} ${rm_nr_ns1} ${rm_nr_ns2} ${speed} ${with_port} ${bkup} lret=$? if [ "$test_linkfail" -eq 1 ];then
@@ -564,6 +587,43 @@ chk_rm_nr() fi } +chk_prio_nr() +{ + local mp_prio_nr_tx=$1 + local mp_prio_nr_rx=$2 + local count + local dump_stats + + printf "%-39s %s" " " "ptx" + count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPPrioTx | awk '{print $2}'` + [ -z "$count" ] && count=0 + if [ "$count" != "$mp_prio_nr_tx" ]; then + echo "[fail] got $count MP_PRIO[s] TX expected $mp_prio_nr_tx" + ret=1 + dump_stats=1 + else + echo -n "[ ok ]" + fi + + echo -n " - prx " + count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPPrioRx | awk '{print $2}'` + [ -z "$count" ] && count=0 + if [ "$count" != "$mp_prio_nr_rx" ]; then + echo "[fail] got $count MP_PRIO[s] RX expected $mp_prio_nr_rx" + ret=1 + dump_stats=1 + else + echo "[ ok ]" + fi + + if [ "${dump_stats}" = 1 ]; then + echo Server ns stats + ip netns exec $ns1 nstat -as | grep MPTcp + echo Client ns stats + ip netns exec $ns2 nstat -as | grep MPTcp + fi +} + sin=$(mktemp) sout=$(mktemp) cin=$(mktemp)
@@ -831,6 +891,25 @@ run_tests $ns1 $ns2 10.0.1.1 0 0 0 fast 10100 chk_join_nr "signal address with port, userspace" 1 0 0 chk_add_nr 1 1 1 0 0 0 +# single subflow, backup +reset +ip netns exec $ns1 ./pm_nl_ctl limits 0 1 +ip netns exec $ns2 ./pm_nl_ctl limits 0 1 +ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow +run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow 0 1 +chk_join_nr "single subflow, backup" 1 1 1 +chk_prio_nr 0 1 + +# single address, backup +reset +ip netns exec $ns1 ./pm_nl_ctl limits 0 1 +ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal +ip netns exec $ns2 ./pm_nl_ctl limits 1 1 +run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow 0 2 +chk_join_nr "single address, backup" 1 1 1 +chk_add_nr 1 1 +chk_prio_nr 2 0 + # single subflow, syncookies reset_with_cookies ip netns exec $ns1 ./pm_nl_ctl limits 0 1
Signature · 1 line
2.26.2
Mat Martineau
[MPTCP] Re: [MPTCP][PATCH mptcp-next 2/5] mptcp: add the incoming MP_PRIO support
In reply to Geliang TangQuoted 24 lines · Geliang Tang
This patch added the incoming
MP_PRIOlogic:Added a flag named
mp_prioin structmptcp_options_received, to mark theMP_PRIOis received, and save the priority value to struct mptcp_options_received's backup member. Then invokemptcp_pm_mp_prio_receivedwith the receiving subsocket and the backup value.In
mptcp_pm_mp_prio_received, get the subflow context according the input subsocket, and change the subflow's backup as the incoming priority value and reschedulemptcp_worker.Signed-off-by Geliang Tang <geliangtang(a)gmail.com>---
net/mptcp/options.c | 15 +++++++++++++++ net/mptcp/pm.c | 19 +++++++++++++++++++ net/mptcp/protocol.h | 5 +++++ 3 files changed, 39 insertions(+)net/mptcp/options.c +0
-0
net/mptcp/options.c static void mptcp_parse_option(const struct sk_buff *skb, · line 290
Quoted 9 lines
net/mptcp/options.c +6
-0@@ -282,6 +282,15 @@ static void mptcp_parse_option(const struct sk_buff *skb,pr_debug ("RM_ADDR: id=%d" , mp_opt->rm_id);break ; +case MPTCPOPT_MP_PRIO : +if (opsize !=TCPOLEN_MPTCP_PRIO ) +break ; + + mp_opt->mp_prio =1 ; + mp_opt->backup = *ptr++ &MPTCP_PRIO_BKUP ;
Hi Geliang. Thank you for the updated patch set.
Why are both mp_opt->mp_prio and mp_opt->backup needed? Why not use only mp_opt->backup?
Regards,
Mat
Quoted 88 lines
net/mptcp/options.c +9
-0+pr_debug ("MP_PRIO: prio=%d" , mp_opt->backup); +break ; +default :break ; }@@ -302,6 +311,7 @@ void mptcp_get_options(const struct sk_buff *skb, mp_opt->port =0 ; mp_opt->rm_addr =0 ; mp_opt->dss =0 ; + mp_opt->mp_prio =0 ; length = (th->doff *4 ) -sizeof (struct tcphdr ); ptr = (const unsigned char *)(th +1 );@@ -999,6 +1009,11 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb) mp_opt.rm_addr =0 ; } +if (mp_opt.mp_prio) { +mptcp_pm_mp_prio_received (sk, mp_opt.backup); + mp_opt.mp_prio =0 ; + } +if (!mp_opt.dss)return ;net/mptcp/pm.c +19
-0@@ -201,6 +201,25 @@ void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id)spin_unlock_bh (&pm->lock); } +void mptcp_pm_mp_prio_received (struct sock *sk,u8 bkup) +{ +struct mptcp_subflow_context *subflow =mptcp_subflow_ctx (sk); +struct mptcp_sock *msk =mptcp_sk (subflow->conn); + +pr_debug ("bkup=%d" , bkup); + +if (subflow->backup == bkup) { +pr_warn ("backup error." ); +return ; + } + + subflow->backup = bkup; + +spin_lock_bh (&msk->pm.lock); +mptcp_schedule_work ((struct sock *)msk); +spin_unlock_bh (&msk->pm.lock); +} +/* path manager helpers */ bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining,net/mptcp/protocol.h +5
-0@@ -87,6 +87,9 @@#define MPTCP_ADDR_IPVERSION_4 4#define MPTCP_ADDR_IPVERSION_6 6 +/* MPTCP MP_PRIO flags */ +#define MPTCP_PRIO_BKUP BIT(0) +/* MPTCP socket flags */ #define MPTCP_DATA_READY 0#define MPTCP_NOSPACE 1@@ -116,6 +119,7 @@ struct mptcp_options_received { dss : 1, add_addr : 1, rm_addr : 1, + mp_prio : 1, family : 4, echo : 1, backup : 1;@@ -555,6 +559,7 @@ void mptcp_pm_add_addr_received(struct mptcp_sock *msk, const struct mptcp_addr_info *addr);void mptcp_pm_add_addr_send_ack (struct mptcp_sock *msk);void mptcp_pm_rm_addr_received (struct mptcp_sock *msk,u8 rm_id); +void mptcp_pm_mp_prio_received (struct sock *sk,u8 bkup);void mptcp_pm_nl_mp_prio_send_ack (struct mptcp_sock *msk,struct mptcp_addr_info *addr,u8 bkup);Signature · 1 line
2.26.2
--
Mat Martineau
Intel
Mat Martineau
[MPTCP] Re: [MPTCP][PATCH mptcp-next 3/5] mptcp: deal with MPTCP_PM_ADDR_FLAG_BACKUP in PM netlink
In reply to Geliang TangQuoted 25 lines · Geliang Tang
This patch added the
MP_PRIOsupport for PM netlink:When PM netlink adds an address, check whether the
MPTCP_PM_ADDR_FLAG_BACKUPflag is set. If it is, check whether this address had been added in the local address list. If it had been, then callmptcp_nl_addr_backupto deal with this address.In
mptcp_nl_addr_backup, we traverse all the existing msk sockets to find the relevant sockets, and get the backup value according to whether theMPTCP_PM_ADDR_FLAG_BACKUPflag is set, then callmptcp_pm_nl_mp_prio_send_ackto send out aMP_PRIOACK packet.In
mptcp_pm_nl_mp_prio_send_ack, we set or clear theMPTCP_PM_ADDR_FLAG_BACKUPflag.Signed-off-by Geliang Tang <geliangtang(a)gmail.com>---
net/mptcp/pm_netlink.c| 41 +++++++++++++++++++++++++++++++++++++++++1 file changed, 41 insertions(+)net/mptcp/pm_netlink.c +0
-0
net/mptcp/pm_netlink.c void mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk, · line 542
Quoted 8 lines
net/mptcp/pm_netlink.c +5
-0@@ -535,6 +535,11 @@ void mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk,return ; } +if (addr->flags &MPTCP_PM_ADDR_FLAG_BACKUP ) + addr->flags &= ~MPTCP_PM_ADDR_FLAG_BACKUP ; +else + addr->flags |=MPTCP_PM_ADDR_FLAG_BACKUP ; +
Why is the backup bit inverted here? It's not clear why it's changed, and why bkup is passed in based on the value of the bit when read by the calling function.
Quoted 40 lines
net/mptcp/pm_netlink.c +28
-0subflow->backup = bkup;mptcp_schedule_work (sk);@@ -847,17 +852,53 @@ static struct pm_nl_pernet *genl_info_pm_nl(struct genl_info *info)return net_generic (genl_info_net (info), pm_nl_pernet_id); } +static int mptcp_nl_addr_backup (struct net *net, +struct mptcp_addr_info *addr) +{ +long s_slot =0 , s_num =0 ; +struct mptcp_sock *msk; + +while ((msk =mptcp_token_iter_next (net, &s_slot, &s_num)) !=NULL ) { +u8 bkup = !(addr->flags &MPTCP_PM_ADDR_FLAG_BACKUP ); +struct sock *sk = (struct sock *)msk; + +if (list_empty (&msk->conn_list)) + goto next; + +lock_sock (sk); +spin_lock_bh (&msk->pm.lock); +mptcp_pm_nl_mp_prio_send_ack (msk, addr, bkup); +spin_unlock_bh (&msk->pm.lock); +release_sock (sk); + +next: +sock_put (sk); +cond_resched (); + } + +return 0 ; +} +static int mptcp_nl_cmd_add_addr (struct sk_buff *skb,struct genl_info *info) {struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR ];struct pm_nl_pernet *pernet =genl_info_pm_nl (info);struct mptcp_pm_addr_entry addr, *entry; +struct net *net =sock_net (skb->sk);
net/mptcp/pm_netlink.c static struct pm_nl_pernet *genl_info_pm_nl(struct genl_info *info) · line 897
Quoted 10 lines
net/mptcp/pm_netlink.c +4
-0int ret; ret =mptcp_pm_parse_addr (attr, info, true, &addr);if (ret <0 )return ret; +if (addr.addr.flags &MPTCP_PM_ADDR_FLAG_BACKUP ) { +list_for_each_entry (entry, &pernet->local_addr_list, list) { +if (addresses_equal (&entry->addr, &addr.addr, false)) +mptcp_nl_addr_backup (net, &entry->addr);
I think a more strict match should be required here that includes the 'id' as well. There may be multiple endpoints with the same address but different port numbers.
Quoted 9 lines
net/mptcp/pm_netlink.c +4
-0+ } +return 0 ; + } + entry =kmalloc (sizeof (*entry),GFP_KERNEL );if (!entry) {GENL_SET_ERR_MSG (info,"can't allocate addr" );Signature · 1 line
2.26.2
--
Mat Martineau
Intel
Mat Martineau
[MPTCP] Re: [MPTCP][PATCH mptcp-next 4/5] mptcp: add the mibs for MP_PRIO
In reply to Geliang TangQuoted 16 lines · Geliang Tang
This patch added the mibs for
MP_PRIO,MPTCP_MIB_MPPRIOTXfor transmitting of theMP_PRIOsuboption, andMPTCP_MIB_MPPRIORXfor receiving of it.Signed-off-by Geliang Tang <geliangtang(a)gmail.com>---
net/mptcp/mib.c | 2 ++ net/mptcp/mib.h | 2 ++ net/mptcp/options.c | 1 + net/mptcp/pm_netlink.c | 1 + 4 files changed, 6 insertions(+)net/mptcp/mib.c +0
-0
net/mptcp/mib.c static const struct snmp_mib mptcp_snmp_list[] = { · line 38
Quoted 4 lines
net/mptcp/mib.c +1
-0@@ -35,6 +35,8 @@ static const struct snmp_mib mptcp_snmp_list[] = {SNMP_MIB_ITEM ("PortAckRx" ,MPTCP_MIB_PORTACKRX ),SNMP_MIB_ITEM ("RmAddr" ,MPTCP_MIB_RMADDR ),SNMP_MIB_ITEM ("RmSubflow" ,MPTCP_MIB_RMSUBFLOW ), + SNMP_MIB_ITEM("MPPrioTx", MPTCP_MIB_MPPRIOTX),
Thanks for adding the Tx MIB. Patch looks good to me.
Quoted 43 lines
net/mptcp/mib.c +1
-0+SNMP_MIB_ITEM ("MPPrioRx" ,MPTCP_MIB_MPPRIORX ), SNMP_MIB_SENTINEL };net/mptcp/mib.h +2
-0@@ -28,6 +28,8 @@ enum linux_mptcp_mib_field {MPTCP_MIB_PORTACKRX ,/* Received an ACK + MP_JOIN with port */ MPTCP_MIB_RMADDR ,/* Received RM_ADDR */ MPTCP_MIB_RMSUBFLOW ,/* Remove a subflow */ +MPTCP_MIB_MPPRIOTX ,/* Transmit a MP_PRIO */ +MPTCP_MIB_MPPRIORX ,/* Received a MP_PRIO */ __MPTCP_MIB_MAX };net/mptcp/options.c +1
-0@@ -1011,6 +1011,7 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)if (mp_opt.mp_prio) {mptcp_pm_mp_prio_received (sk, mp_opt.backup); +MPTCP_INC_STATS (sock_net (sk),MPTCP_MIB_MPPRIORX ); mp_opt.mp_prio =0 ; }net/mptcp/pm_netlink.c +1
-0@@ -545,6 +545,7 @@ void mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk, subflow->send_mp_prio =1 ; subflow->request_bkup = bkup; +__MPTCP_INC_STATS (sock_net (sk),MPTCP_MIB_MPPRIOTX );spin_unlock_bh (&msk->pm.lock);pr_debug ("send ack for mp_prio" );Signature · 1 line
2.26.2
--
Mat Martineau
Intel
Geliang Tang
[MPTCP] Re: [MPTCP][PATCH mptcp-next 2/5] mptcp: add the incoming MP_PRIO support
In reply to Mat MartineauHi Mat,
Thanks for your review.
Quoted 39 lines · Mat Martineau <mathew.j.martineau(a)linux.intel.com> 于2020年11月21日周六 上午9:06写道:
Quoted 24 lines · Geliang Tang
This patch added the incoming
MP_PRIOlogic:Added a flag named
mp_prioin structmptcp_options_received, to mark theMP_PRIOis received, and save the priority value to struct mptcp_options_received's backup member. Then invokemptcp_pm_mp_prio_receivedwith the receiving subsocket and the backup value.In
mptcp_pm_mp_prio_received, get the subflow context according the input subsocket, and change the subflow's backup as the incoming priority value and reschedulemptcp_worker.Signed-off-by Geliang Tang <geliangtang(a)gmail.com>---
net/mptcp/options.c | 15 +++++++++++++++ net/mptcp/pm.c | 19 +++++++++++++++++++ net/mptcp/protocol.h | 5 +++++ 3 files changed, 39 insertions(+)net/mptcp/options.c +0
-0net/mptcp/options.c static void mptcp_parse_option(const struct sk_buff *skb, · line 290
Quoted 9 lines
net/mptcp/options.c +6
-0@@ -282,6 +282,15 @@ static void mptcp_parse_option(const struct sk_buff *skb,pr_debug ("RM_ADDR: id=%d" , mp_opt->rm_id);break ; +case MPTCPOPT_MP_PRIO : +if (opsize !=TCPOLEN_MPTCP_PRIO ) +break ; + + mp_opt->mp_prio =1 ; + mp_opt->backup = *ptr++ &MPTCP_PRIO_BKUP ;Hi Geliang. Thank you for the updated patch set.
Quoted 2 lines
Why are both
mp_opt->mp_prioandmp_opt->backupneeded? Why not use onlymp_opt->backup?
I think mp_opt->backup could be 0 when we want to change the subflow's backup value from 1 to 0. So I added another flag mp_prio to mark we get an MP_PRIO packet.
-Geliang
Quoted 98 lines
Regards,
Mat
Quoted 87 lines
net/mptcp/options.c +9
-0+pr_debug ("MP_PRIO: prio=%d" , mp_opt->backup); +break ; +default :break ; }@@ -302,6 +311,7 @@ void mptcp_get_options(const struct sk_buff *skb, mp_opt->port =0 ; mp_opt->rm_addr =0 ; mp_opt->dss =0 ; + mp_opt->mp_prio =0 ; length = (th->doff *4 ) -sizeof (struct tcphdr ); ptr = (const unsigned char *)(th +1 );@@ -999,6 +1009,11 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb) mp_opt.rm_addr =0 ; } +if (mp_opt.mp_prio) { +mptcp_pm_mp_prio_received (sk, mp_opt.backup); + mp_opt.mp_prio =0 ; + } +if (!mp_opt.dss)return ;net/mptcp/pm.c +19
-0@@ -201,6 +201,25 @@ void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id)spin_unlock_bh (&pm->lock); } +void mptcp_pm_mp_prio_received (struct sock *sk,u8 bkup) +{ +struct mptcp_subflow_context *subflow =mptcp_subflow_ctx (sk); +struct mptcp_sock *msk =mptcp_sk (subflow->conn); + +pr_debug ("bkup=%d" , bkup); + +if (subflow->backup == bkup) { +pr_warn ("backup error." ); +return ; + } + + subflow->backup = bkup; + +spin_lock_bh (&msk->pm.lock); +mptcp_schedule_work ((struct sock *)msk); +spin_unlock_bh (&msk->pm.lock); +} +/* path manager helpers */ bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining,net/mptcp/protocol.h +5
-1@@ -87,6 +87,9 @@#define MPTCP_ADDR_IPVERSION_4 4#define MPTCP_ADDR_IPVERSION_6 6 +/* MPTCP MP_PRIO flags */ +#define MPTCP_PRIO_BKUP BIT(0) +/* MPTCP socket flags */ #define MPTCP_DATA_READY 0#define MPTCP_NOSPACE 1@@ -116,6 +119,7 @@ struct mptcp_options_received { dss : 1, add_addr : 1, rm_addr : 1, + mp_prio : 1, family : 4, echo : 1, backup : 1;@@ -555,6 +559,7 @@ void mptcp_pm_add_addr_received(struct mptcp_sock *msk, const struct mptcp_addr_info *addr);void mptcp_pm_add_addr_send_ack (struct mptcp_sock *msk);void mptcp_pm_rm_addr_received (struct mptcp_sock *msk,u8 rm_id); +void mptcp_pm_mp_prio_received (struct sock *sk,u8 bkup);void mptcp_pm_nl_mp_prio_send_ack (struct mptcp_sock *msk,struct mptcp_addr_info *addr,u8 bkup); --Quoted 1 line
2.26.2
--
Mat Martineau
Intel
Geliang Tang
[MPTCP] Re: [MPTCP][PATCH mptcp-next 3/5] mptcp: deal with MPTCP_PM_ADDR_FLAG_BACKUP in PM netlink
In reply to Mat MartineauHi Mat,
Thanks for your review.
Quoted 31 lines · Mat Martineau <mathew.j.martineau(a)linux.intel.com> 于2020年11月21日周六 上午9:17写道:
Quoted 28 lines · Geliang Tang
This patch added the
MP_PRIOsupport for PM netlink:When PM netlink adds an address, check whether the
MPTCP_PM_ADDR_FLAG_BACKUPflag is set. If it is, check whether this address had been added in the local address list. If it had been, then callmptcp_nl_addr_backupto deal with this address.In
mptcp_nl_addr_backup, we traverse all the existing msk sockets to find the relevant sockets, and get the backup value according to whether theMPTCP_PM_ADDR_FLAG_BACKUPflag is set, then callmptcp_pm_nl_mp_prio_send_ackto send out aMP_PRIOACK packet.In
mptcp_pm_nl_mp_prio_send_ack, we set or clear theMPTCP_PM_ADDR_FLAG_BACKUPflag.Signed-off-by Geliang Tang <geliangtang(a)gmail.com>---
net/mptcp/pm_netlink.c| 41 +++++++++++++++++++++++++++++++++++++++++1 file changed, 41 insertions(+)net/mptcp/pm_netlink.c +0
-0@@ -535,6 +535,11 @@ void mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk,return ; }
Quoted 10 lines
net/mptcp/pm_netlink.c void mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk, · line 542
Quoted 5 lines
net/mptcp/pm_netlink.c +5
-0+if (addr->flags &MPTCP_PM_ADDR_FLAG_BACKUP ) + addr->flags &= ~MPTCP_PM_ADDR_FLAG_BACKUP ; +else + addr->flags |=MPTCP_PM_ADDR_FLAG_BACKUP ; +Why is the backup bit inverted here? It's not clear why it's changed, and why bkup is passed in based on the value of the bit when read by the calling function.
I think we can use backup command not only to 'turn on' a subflow's backup bit, but also to 'turn off' a subflow's backup bit. So the pm_nl_ctl backup command will work like this:
# pm_nl_ctl add 10.0.2.1 flags signal; pm_nl_ctl dump id 1 flags signal 10.0.2.1 # pm_nl_ctl add 10.0.2.1 flags backup; pm_nl_ctl dump id 1 flags signal,backup 10.0.2.1 # pm_nl_ctl add 10.0.2.1 flags backup; pm_nl_ctl dump id 1 flags signal 10.0.2.1
Quoted 46 lines
Quoted 46 lines
net/mptcp/pm_netlink.c +28
-0subflow->backup = bkup;mptcp_schedule_work (sk);@@ -847,17 +852,53 @@ static struct pm_nl_pernet *genl_info_pm_nl(struct genl_info *info)return net_generic (genl_info_net (info), pm_nl_pernet_id); } +static int mptcp_nl_addr_backup (struct net *net, +struct mptcp_addr_info *addr) +{ +long s_slot =0 , s_num =0 ; +struct mptcp_sock *msk; + +while ((msk =mptcp_token_iter_next (net, &s_slot, &s_num)) !=NULL ) { +u8 bkup = !(addr->flags &MPTCP_PM_ADDR_FLAG_BACKUP ); +struct sock *sk = (struct sock *)msk; + +if (list_empty (&msk->conn_list)) + goto next; + +lock_sock (sk); +spin_lock_bh (&msk->pm.lock); +mptcp_pm_nl_mp_prio_send_ack (msk, addr, bkup); +spin_unlock_bh (&msk->pm.lock); +release_sock (sk); + +next: +sock_put (sk); +cond_resched (); + } + +return 0 ; +} +static int mptcp_nl_cmd_add_addr (struct sk_buff *skb,struct genl_info *info) {struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR ];struct pm_nl_pernet *pernet =genl_info_pm_nl (info);struct mptcp_pm_addr_entry addr, *entry; +struct net *net =sock_net (skb->sk);int ret; ret =mptcp_pm_parse_addr (attr, info, true, &addr);if (ret <0 )return ret;
Quoted 9 lines
net/mptcp/pm_netlink.c static struct pm_nl_pernet *genl_info_pm_nl(struct genl_info *info) · line 897
Quoted 4 lines
net/mptcp/pm_netlink.c +4
-0+if (addr.addr.flags &MPTCP_PM_ADDR_FLAG_BACKUP ) { +list_for_each_entry (entry, &pernet->local_addr_list, list) { +if (addresses_equal (&entry->addr, &addr.addr, false)) +mptcp_nl_addr_backup (net, &entry->addr);I think a more strict match should be required here that includes the 'id' as well. There may be multiple endpoints with the same address but different port numbers.
Adding 'id' match doesn't work, since addr.addr's id is always 0 here.
I think we can use addresses_equal(&entry->addr, &addr.addr, true) here, it's enough to cover the same address with different port numbers case.
-Geliang
Quoted 13 lines
Quoted 9 lines
net/mptcp/pm_netlink.c +4
-1+ } +return 0 ; + } + entry =kmalloc (sizeof (*entry),GFP_KERNEL );if (!entry) {GENL_SET_ERR_MSG (info,"can't allocate addr" ); --2.26.2
--
Mat Martineau
Intel
Mat Martineau
[MPTCP] Re: [MPTCP][PATCH mptcp-next 2/5] mptcp: add the incoming MP_PRIO support
In reply to Geliang TangQuoted 44 lines · Geliang Tang
Hi Mat,
Thanks for your review.
Quoted 39 lines · Mat Martineau <mathew.j.martineau(a)linux.intel.com> 于2020年11月21日周六 上午9:06写道:
Quoted 24 lines · Geliang Tang
This patch added the incoming
MP_PRIOlogic:Added a flag named
mp_prioin structmptcp_options_received, to mark theMP_PRIOis received, and save the priority value to struct mptcp_options_received's backup member. Then invokemptcp_pm_mp_prio_receivedwith the receiving subsocket and the backup value.In
mptcp_pm_mp_prio_received, get the subflow context according the input subsocket, and change the subflow's backup as the incoming priority value and reschedulemptcp_worker.Signed-off-by Geliang Tang <geliangtang(a)gmail.com>---
net/mptcp/options.c | 15 +++++++++++++++ net/mptcp/pm.c | 19 +++++++++++++++++++ net/mptcp/protocol.h | 5 +++++ 3 files changed, 39 insertions(+)net/mptcp/options.c +0
-0net/mptcp/options.c static void mptcp_parse_option(const struct sk_buff *skb, · line 290
Quoted 9 lines
net/mptcp/options.c +6
-0@@ -282,6 +282,15 @@ static void mptcp_parse_option(const struct sk_buff *skb,pr_debug ("RM_ADDR: id=%d" , mp_opt->rm_id);break ; +case MPTCPOPT_MP_PRIO : +if (opsize !=TCPOLEN_MPTCP_PRIO ) +break ; + + mp_opt->mp_prio =1 ; + mp_opt->backup = *ptr++ &MPTCP_PRIO_BKUP ;Hi Geliang. Thank you for the updated patch set.
Quoted 6 lines
Quoted 2 lines
Why are both
mp_opt->mp_prioandmp_opt->backupneeded? Why not use onlymp_opt->backup?I think
mp_opt->backupcould be 0 when we want to change the subflow's backup value from 1 to 0. So I added another flagmp_prioto mark we get anMP_PRIOpacket.
Thanks for explaining, I had missed that.
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
net/mptcp/options.c +9
-0+pr_debug ("MP_PRIO: prio=%d" , mp_opt->backup); +break ; +default :break ; }@@ -302,6 +311,7 @@ void mptcp_get_options(const struct sk_buff *skb, mp_opt->port =0 ; mp_opt->rm_addr =0 ; mp_opt->dss =0 ; + mp_opt->mp_prio =0 ; length = (th->doff *4 ) -sizeof (struct tcphdr ); ptr = (const unsigned char *)(th +1 );@@ -999,6 +1009,11 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb) mp_opt.rm_addr =0 ; } +if (mp_opt.mp_prio) { +mptcp_pm_mp_prio_received (sk, mp_opt.backup); + mp_opt.mp_prio =0 ; + } +if (!mp_opt.dss)return ;net/mptcp/pm.c +0
-0@@ -201,6 +201,25 @@ void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id)spin_unlock_bh (&pm->lock); }
Quoted 11 lines
Quoted 11 lines
net/mptcp/pm.c void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id) · line 214
Quoted 11 lines
net/mptcp/pm.c +11
-0+void mptcp_pm_mp_prio_received (struct sock *sk,u8 bkup) +{ +struct mptcp_subflow_context *subflow =mptcp_subflow_ctx (sk); +struct mptcp_sock *msk =mptcp_sk (subflow->conn); + +pr_debug ("bkup=%d" , bkup); + +if (subflow->backup == bkup) { +pr_warn ("backup error." ); +return ; + }
It's not a problem if a duplicate mp_prio is received, no need to do the comparison or print a warning. Let it assign the identical value.
Quoted 6 lines
Quoted 6 lines
net/mptcp/pm.c void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id) · line 220
Quoted 6 lines
net/mptcp/pm.c +6
-0+ + subflow->backup = bkup; + +spin_lock_bh (&msk->pm.lock); +mptcp_schedule_work ((struct sock *)msk); +spin_unlock_bh (&msk->pm.lock);
No need to schedule the worker here, there's nothing else to do after subflow->backup is set.
Thanks,
Mat
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
net/mptcp/pm.c +2
-0+} +/* path manager helpers */ bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining,net/mptcp/protocol.h +4
-0@@ -87,6 +87,9 @@#define MPTCP_ADDR_IPVERSION_4 4#define MPTCP_ADDR_IPVERSION_6 6 +/* MPTCP MP_PRIO flags */ +#define MPTCP_PRIO_BKUP BIT(0) +/* MPTCP socket flags */ #define MPTCP_DATA_READY 0#define MPTCP_NOSPACE 1@@ -116,6 +119,7 @@ struct mptcp_options_received { dss : 1, add_addr : 1, rm_addr : 1, + mp_prio : 1, family : 4, echo : 1, backup : 1;@@ -555,6 +559,7 @@ void mptcp_pm_add_addr_received(struct mptcp_sock *msk, const struct mptcp_addr_info *addr);
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
net/mptcp/protocol.h +1
-1void mptcp_pm_add_addr_send_ack (struct mptcp_sock *msk);void mptcp_pm_rm_addr_received (struct mptcp_sock *msk,u8 rm_id); +void mptcp_pm_mp_prio_received (struct sock *sk,u8 bkup);void mptcp_pm_nl_mp_prio_send_ack (struct mptcp_sock *msk,struct mptcp_addr_info *addr,u8 bkup); --2.26.2
--
Mat Martineau
Intel
Mat Martineau
[MPTCP] Re: [MPTCP][PATCH mptcp-next 3/5] mptcp: deal with MPTCP_PM_ADDR_FLAG_BACKUP in PM netlink
In reply to Geliang TangQuoted 51 lines · Geliang Tang
Hi Mat,
Thanks for your review.
Quoted 31 lines · Mat Martineau <mathew.j.martineau(a)linux.intel.com> 于2020年11月21日周六 上午9:17写道:
Quoted 28 lines · Geliang Tang
This patch added the
MP_PRIOsupport for PM netlink:When PM netlink adds an address, check whether the
MPTCP_PM_ADDR_FLAG_BACKUPflag is set. If it is, check whether this address had been added in the local address list. If it had been, then callmptcp_nl_addr_backupto deal with this address.In
mptcp_nl_addr_backup, we traverse all the existing msk sockets to find the relevant sockets, and get the backup value according to whether theMPTCP_PM_ADDR_FLAG_BACKUPflag is set, then callmptcp_pm_nl_mp_prio_send_ackto send out aMP_PRIOACK packet.In
mptcp_pm_nl_mp_prio_send_ack, we set or clear theMPTCP_PM_ADDR_FLAG_BACKUPflag.Signed-off-by Geliang Tang <geliangtang(a)gmail.com>---
net/mptcp/pm_netlink.c| 41 +++++++++++++++++++++++++++++++++++++++++1 file changed, 41 insertions(+)net/mptcp/pm_netlink.c +0
-0@@ -535,6 +535,11 @@ void mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk,return ; }Quoted 10 lines
net/mptcp/pm_netlink.c void mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk, · line 542
Quoted 5 lines
net/mptcp/pm_netlink.c +5
-0+if (addr->flags &MPTCP_PM_ADDR_FLAG_BACKUP ) + addr->flags &= ‾MPTCP_PM_ADDR_FLAG_BACKUP; +else + addr->flags |=MPTCP_PM_ADDR_FLAG_BACKUP ; +Why is the backup bit inverted here? It's not clear why it's changed, and why bkup is passed in based on the value of the bit when read by the calling function.
I think we can use backup command not only to 'turn on' a subflow's backup bit, but also to 'turn off' a subflow's backup bit. So the
pm_nl_ctlbackup command will work like this:
Quoted 6 lines
# pm_nl_ctl add 10.0.2.1 flags signal; pm_nl_ctl dump id 1 flags signal 10.0.2.1 # pm_nl_ctl add 10.0.2.1 flags backup; pm_nl_ctl dump id 1 flags signal,backup 10.0.2.1 # pm_nl_ctl add 10.0.2.1 flags backup; pm_nl_ctl dump id 1 flags signal 10.0.2.1
I would prefer to have the 'backup' bit in the netlink flags set the backup bit directly - if the backup flag is 0 the subflow backup bit gets set to 0, and if the netlink backup flag is 1 the subflow backup bit gets set to 1. Paolo, does that interpretation of the backup flag match what you were thinking too?
Quoted 57 lines
Quoted 47 lines
Quoted 47 lines
net/mptcp/pm_netlink.c +28
-0subflow->backup = bkup;mptcp_schedule_work (sk);@@ -847,17 +852,53 @@ static struct pm_nl_pernet *genl_info_pm_nl(struct genl_info *info)return net_generic (genl_info_net (info), pm_nl_pernet_id); } +static int mptcp_nl_addr_backup (struct net *net, +struct mptcp_addr_info *addr) +{ +long s_slot =0 , s_num =0 ; +struct mptcp_sock *msk; + +while ((msk =mptcp_token_iter_next (net, &s_slot, &s_num)) !=NULL ) { +u8 bkup = !(addr->flags &MPTCP_PM_ADDR_FLAG_BACKUP ); +struct sock *sk = (struct sock *)msk; + +if (list_empty (&msk->conn_list)) + goto next; + +lock_sock (sk); +spin_lock_bh (&msk->pm.lock); +mptcp_pm_nl_mp_prio_send_ack (msk, addr, bkup); +spin_unlock_bh (&msk->pm.lock); +release_sock (sk); + +next: +sock_put (sk); +cond_resched (); + } + +return 0 ; +} +static int mptcp_nl_cmd_add_addr (struct sk_buff *skb,struct genl_info *info) {struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR ];struct pm_nl_pernet *pernet =genl_info_pm_nl (info);struct mptcp_pm_addr_entry addr, *entry; +struct net *net =sock_net (skb->sk);int ret; ret =mptcp_pm_parse_addr (attr, info, true, &addr);if (ret <0 )return ret;Quoted 9 lines
net/mptcp/pm_netlink.c static struct pm_nl_pernet *genl_info_pm_nl(struct genl_info *info) · line 897
Quoted 4 lines
net/mptcp/pm_netlink.c +4
-0+if (addr.addr.flags &MPTCP_PM_ADDR_FLAG_BACKUP ) { +list_for_each_entry (entry, &pernet->local_addr_list, list) { +if (addresses_equal (&entry->addr, &addr.addr, false)) +mptcp_nl_addr_backup (net, &entry->addr);I think a more strict match should be required here that includes the 'id' as well. There may be multiple endpoints with the same address but different port numbers.
Quoted 4 lines
Adding 'id' match doesn't work, since addr.addr's id is always 0 here.
I think we can use
addresses_equal(&entry->addr, &addr.addr, true)here, it's enough to cover the same address with different port numbers case.
Ok, yes, addresses_equal() does compare port numbers so that should help.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
net/mptcp/pm_netlink.c +4
-1+ } +return 0 ; + } + entry =kmalloc (sizeof (*entry),GFP_KERNEL );if (!entry) {GENL_SET_ERR_MSG (info,"can't allocate addr" ); --2.26.2
--
Mat Martineau
Intel
Geliang Tang
[MPTCP] Re: [MPTCP][PATCH mptcp-next 3/5] mptcp: deal with MPTCP_PM_ADDR_FLAG_BACKUP in PM netlink
Hi Mat,
Quoted 61 lines · Mat Martineau <mathew.j.martineau(a)linux.intel.com> 于2020年12月2日周三 上午8:40写道:
Quoted 51 lines · Geliang Tang
Hi Mat,
Thanks for your review.
Quoted 31 lines · Mat Martineau <mathew.j.martineau(a)linux.intel.com> 于2020年11月21日周六 上午9:17写道:
Quoted 28 lines · Geliang Tang
This patch added the
MP_PRIOsupport for PM netlink:When PM netlink adds an address, check whether the
MPTCP_PM_ADDR_FLAG_BACKUPflag is set. If it is, check whether this address had been added in the local address list. If it had been, then callmptcp_nl_addr_backupto deal with this address.In
mptcp_nl_addr_backup, we traverse all the existing msk sockets to find the relevant sockets, and get the backup value according to whether theMPTCP_PM_ADDR_FLAG_BACKUPflag is set, then callmptcp_pm_nl_mp_prio_send_ackto send out aMP_PRIOACK packet.In
mptcp_pm_nl_mp_prio_send_ack, we set or clear theMPTCP_PM_ADDR_FLAG_BACKUPflag.Signed-off-by Geliang Tang <geliangtang(a)gmail.com>---
net/mptcp/pm_netlink.c| 41 +++++++++++++++++++++++++++++++++++++++++1 file changed, 41 insertions(+)net/mptcp/pm_netlink.c +0
-0@@ -535,6 +535,11 @@ void mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk,return ; }Quoted 10 lines
net/mptcp/pm_netlink.c void mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk, · line 542
Quoted 5 lines
net/mptcp/pm_netlink.c +5
-0+if (addr->flags &MPTCP_PM_ADDR_FLAG_BACKUP ) + addr->flags &= ‾MPTCP_PM_ADDR_FLAG_BACKUP; +else + addr->flags |=MPTCP_PM_ADDR_FLAG_BACKUP ; +Why is the backup bit inverted here? It's not clear why it's changed, and why bkup is passed in based on the value of the bit when read by the calling function.
I think we can use backup command not only to 'turn on' a subflow's backup bit, but also to 'turn off' a subflow's backup bit. So the
pm_nl_ctlbackup command will work like this:Quoted 6 lines
# pm_nl_ctl add 10.0.2.1 flags signal; pm_nl_ctl dump id 1 flags signal 10.0.2.1 # pm_nl_ctl add 10.0.2.1 flags backup; pm_nl_ctl dump id 1 flags signal,backup 10.0.2.1 # pm_nl_ctl add 10.0.2.1 flags backup; pm_nl_ctl dump id 1 flags signal 10.0.2.1
Quoted 5 lines
I would prefer to have the 'backup' bit in the netlink flags set the backup bit directly - if the backup flag is 0 the subflow backup bit gets set to 0, and if the netlink backup flag is 1 the subflow backup bit gets set to 1. Paolo, does that interpretation of the backup flag match what you were thinking too?
Should we add an argument behind backup for the pm_nl_ctl tool? Then we can use pm_nl_ctl to set backup flag like this:
pm_nl_ctl add 10.0.2.1 flags backup 1
pm_nl_ctl add 10.0.2.1 flags backup 0
Or add a new argument 'set' instead of using 'add' when changing the backup flag:
pm_nl_ctl set 10.0.2.1 flags backup 1
pm_nl_ctl set 10.0.2.1 flags backup 0
-Geliang
Quoted 79 lines
Quoted 59 lines
Quoted 49 lines
Quoted 49 lines
net/mptcp/pm_netlink.c +28
-0subflow->backup = bkup;mptcp_schedule_work (sk);@@ -847,17 +852,53 @@ static struct pm_nl_pernet *genl_info_pm_nl(struct genl_info *info)return net_generic (genl_info_net (info), pm_nl_pernet_id); } +static int mptcp_nl_addr_backup (struct net *net, +struct mptcp_addr_info *addr) +{ +long s_slot =0 , s_num =0 ; +struct mptcp_sock *msk; + +while ((msk =mptcp_token_iter_next (net, &s_slot, &s_num)) !=NULL ) { +u8 bkup = !(addr->flags &MPTCP_PM_ADDR_FLAG_BACKUP ); +struct sock *sk = (struct sock *)msk; + +if (list_empty (&msk->conn_list)) + goto next; + +lock_sock (sk); +spin_lock_bh (&msk->pm.lock); +mptcp_pm_nl_mp_prio_send_ack (msk, addr, bkup); +spin_unlock_bh (&msk->pm.lock); +release_sock (sk); + +next: +sock_put (sk); +cond_resched (); + } + +return 0 ; +} +static int mptcp_nl_cmd_add_addr (struct sk_buff *skb,struct genl_info *info) {struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR ];struct pm_nl_pernet *pernet =genl_info_pm_nl (info);struct mptcp_pm_addr_entry addr, *entry; +struct net *net =sock_net (skb->sk);int ret; ret =mptcp_pm_parse_addr (attr, info, true, &addr);if (ret <0 )return ret;Quoted 9 lines
net/mptcp/pm_netlink.c static struct pm_nl_pernet *genl_info_pm_nl(struct genl_info *info) · line 897
Quoted 4 lines
net/mptcp/pm_netlink.c +4
-0+if (addr.addr.flags &MPTCP_PM_ADDR_FLAG_BACKUP ) { +list_for_each_entry (entry, &pernet->local_addr_list, list) { +if (addresses_equal (&entry->addr, &addr.addr, false)) +mptcp_nl_addr_backup (net, &entry->addr);I think a more strict match should be required here that includes the 'id' as well. There may be multiple endpoints with the same address but different port numbers.
Quoted 4 lines
Adding 'id' match doesn't work, since addr.addr's id is always 0 here.
I think we can use
addresses_equal(&entry->addr, &addr.addr, true)here, it's enough to cover the same address with different port numbers case.Ok, yes,
addresses_equal()does compare port numbers so that should help.Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
net/mptcp/pm_netlink.c +4
-1+ } +return 0 ; + } + entry =kmalloc (sizeof (*entry),GFP_KERNEL );if (!entry) {GENL_SET_ERR_MSG (info,"can't allocate addr" ); --2.26.2
--
Mat Martineau
Intel
Paolo Abeni
[MPTCP] Re: [MPTCP][PATCH mptcp-next 3/5] mptcp: deal with MPTCP_PM_ADDR_FLAG_BACKUP in PM netlink
Quoted 71 lines · Geliang Tang
Hi Mat,
Quoted 59 lines · Mat Martineau <mathew.j.martineau(a)linux.intel.com> 于2020年12月2日周三 上午8:40写道:
Quoted 50 lines · Geliang Tang
Hi Mat,
Thanks for your review.
Quoted 30 lines · Mat Martineau <mathew.j.martineau(a)linux.intel.com> 于2020年11月21日周六 上午9:17写道:
Quoted 28 lines · Geliang Tang
This patch added the
MP_PRIOsupport for PM netlink:When PM netlink adds an address, check whether the
MPTCP_PM_ADDR_FLAG_BACKUPflag is set. If it is, check whether this address had been added in the local address list. If it had been, then callmptcp_nl_addr_backupto deal with this address.In
mptcp_nl_addr_backup, we traverse all the existing msk sockets to find the relevant sockets, and get the backup value according to whether theMPTCP_PM_ADDR_FLAG_BACKUPflag is set, then callmptcp_pm_nl_mp_prio_send_ackto send out aMP_PRIOACK packet.In
mptcp_pm_nl_mp_prio_send_ack, we set or clear theMPTCP_PM_ADDR_FLAG_BACKUPflag.Signed-off-by Geliang Tang <geliangtang(a)gmail.com>---
net/mptcp/pm_netlink.c| 41 +++++++++++++++++++++++++++++++++++++++++1 file changed, 41 insertions(+)net/mptcp/pm_netlink.c +0
-0@@ -535,6 +535,11 @@ void mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk,return ; }Quoted 10 lines
net/mptcp/pm_netlink.c void mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk, · line 542
Quoted 5 lines
net/mptcp/pm_netlink.c +5
-0+if (addr->flags &MPTCP_PM_ADDR_FLAG_BACKUP ) + addr->flags &= ‾MPTCP_PM_ADDR_FLAG_BACKUP; +else + addr->flags |=MPTCP_PM_ADDR_FLAG_BACKUP ; +Why is the backup bit inverted here? It's not clear why it's changed, and why bkup is passed in based on the value of the bit when read by the calling function.
I think we can use backup command not only to 'turn on' a subflow's backup bit, but also to 'turn off' a subflow's backup bit. So the
pm_nl_ctlbackup command will work like this:Quoted 6 lines
# pm_nl_ctl add 10.0.2.1 flags signal; pm_nl_ctl dump id 1 flags signal 10.0.2.1 # pm_nl_ctl add 10.0.2.1 flags backup; pm_nl_ctl dump id 1 flags signal,backup 10.0.2.1 # pm_nl_ctl add 10.0.2.1 flags backup; pm_nl_ctl dump id 1 flags signal 10.0.2.1Quoted 5 lines
I would prefer to have the 'backup' bit in the netlink flags set the backup bit directly - if the backup flag is 0 the subflow backup bit gets set to 0, and if the netlink backup flag is 1 the subflow backup bit gets set to 1. Paolo, does that interpretation of the backup flag match what you were thinking too?
Should we add an argument behind backup for the
pm_nl_ctltool? Then we can usepm_nl_ctlto set backup flag like this:
Quoted 8 lines
pm_nl_ctladd 10.0.2.1 flags backup 1
pm_nl_ctladd 10.0.2.1 flags backup 0Or add a new argument 'set' instead of using 'add' when changing the backup flag:
pm_nl_ctlset 10.0.2.1 flags backup 1
pm_nl_ctlset 10.0.2.1 flags backup 0
This patch changes the semantic of the MPTCP_PM_CMD_ADD_ADDR netlink command depending on the presence of the backup flag.
I think is quite confusing.
The backup flag should be the only attribute we are allowed to change on an existing endpoint, but that may change in the future - e.g. if we will ever allow setting setsockopt() on the listening socket for port- based endpoint.
I think it would be better add another NL command to update the existing address. It may still use the same parsing helper as MPTCP_PM_CMD_ADD_ADDR, than it will lookup the address by ID and will set the address backup flag according to the value provided by the user.
The pm_nl_ctl syntax is not extremely important IMHO, but the ip route syntax will be much more interesting.
Something alike:
ip mptcp endpoint set id <nr> flags backup # the endpoint become a backup one
ip mptcp endpoint set id <nr> flags nobackup # the endpoint become a non backup one
ip mptcp endpoint set id <nr> flags "" # the endpoint become a non backup one
ip mptcp endpoint set id <nr> flags signal # the endpoint become a non backup one, 'signal' is ignored ip mptcp endpoint set id <nr> flags signal,backup # the endpoint become a backup one, 'signal' is ignored
pm_nl_ctl could opt for something similar, e.g.:
pm_nl_ctl set 10.0.2.1 flags backuppm_nl_ctl set 10.0.2.1 flags nobackuppm_nl_ctl set 10.0.2.1 flags signal,backuppm_nl_ctl set 10.0.2.1 flags signal
etc...
The only special thing will ne the 'nobackup' keyword, just to be more expressive than leaving the flag list empty.
WDYT?
Thanks,
Paolo