On Thu, Aug 03, 2023 at 03:30:39PM +0800, Geliang Tang wrote:
> Add a hook named update_socket_protocol in __sys_socket(), for bpf
> progs to attach to and update socket protocol. One user case is to
> force legacy TCP apps to create and use MPTCP sockets instead of
> TCP ones.
> 
> Define a mod_ret set named bpf_mptcp_fmodret_ids, add the hook
> update_socket_protocol into this set, and register it in
> bpf_mptcp_kfunc_init().
> 
> Signed-off-by: Geliang Tang <[email protected]>

...

> diff --git a/net/socket.c b/net/socket.c
> index 2b0e54b2405c..586a437d7a5e 100644
> --- a/net/socket.c
> +++ b/net/socket.c
> @@ -1644,11 +1644,36 @@ struct file *__sys_socket_file(int family, int type, 
> int protocol)
>       return sock_alloc_file(sock, flags, NULL);
>  }
>  
> +/**

Hi Geliang Tang,

nit: The format of the text below is not in kernel doc format,
     so it is probably better if the comment begins with '/*'
     rather than '/**'.

> + *   A hook for bpf progs to attach to and update socket protocol.
> + *
> + *   A static noinline declaration here could cause the compiler to
> + *   optimize away the function. A global noinline declaration will
> + *   keep the definition, but may optimize away the callsite.
> + *   Therefore, __weak is needed to ensure that the call is still
> + *   emitted, by telling the compiler that we don't know what the
> + *   function might eventually be.
> + *
> + *   __diag_* below are needed to dismiss the missing prototype warning.
> + */

...

Reply via email to