RE: [PATCH net V3 2/2] tuntap: synchronize through tfiles array instead of tun->numqueues

From: weiyongjun (A)
Date: Thu May 09 2019 - 07:43:59 EST


> -----Original Message-----
> From: Jason Wang [mailto:jasowang@xxxxxxxxxx]
> Sent: Thursday, May 09, 2019 11:20 AM
> To: netdev@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx
> Cc: yuehaibing <yuehaibing@xxxxxxxxxx>; xiyou.wangcong@xxxxxxxxx;
> weiyongjun (A) <weiyongjun1@xxxxxxxxxx>; eric.dumazet@xxxxxxxxx;
> Jason Wang <jasowang@xxxxxxxxxx>
> Subject: [PATCH net V3 2/2] tuntap: synchronize through tfiles array instead
> of tun->numqueues
>
> When a queue(tfile) is detached through __tun_detach(), we move the
> last enabled tfile to the position where detached one sit but don't
> NULL out last position. We expect to synchronize the datapath through
> tun->numqueues. Unfortunately, this won't work since we're lacking
> sufficient mechanism to order or synchronize the access to
> tun->numqueues.
>
> To fix this, NULL out the last position during detaching and check
> RCU protected tfile against NULL instead of checking tun->numqueues in
> datapath.
>
> Cc: YueHaibing <yuehaibing@xxxxxxxxxx>
> Cc: Cong Wang <xiyou.wangcong@xxxxxxxxx>
> Cc: weiyongjun (A) <weiyongjun1@xxxxxxxxxx>
> Cc: Eric Dumazet <eric.dumazet@xxxxxxxxx>
> Fixes: c8d68e6be1c3b ("tuntap: multiqueue support")
> Signed-off-by: Jason Wang <jasowang@xxxxxxxxxx>
> ---
> Changes from V2:
> - resample during detach in tun_xdp_xmit()
> Changes from V1:
> - keep the check in tun_xdp_xmit()
> ---

Reviewed-by: Wei Yongjun <weiyongjun1@xxxxxxxxxx>

Thanks