From: Martin KaFai Lau > Sent: 27 July 2022 07:09 > > Most of the codes in bpf_setsockopt(SOL_SOCKET) are duplicated from > the sock_setsockopt(). The number of supported options are > increasing ever and so as the duplicated codes. > > One issue in reusing sock_setsockopt() is that the bpf prog > has already acquired the sk lock. sockptr_t is useful to handle this. > sockptr_t already has a bit 'is_kernel' to handle the kernel-or-user > memory copy. This patch adds a 'is_bpf' bit to tell if sk locking > has already been ensured by the bpf prog. That is a really horrid place to hide an 'is locked' bit. You'd be better off splitting sock_setsockopt() to add a function that is called with sk_lock held and the value read. That would also save the churn of all the callers. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)