File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -1846,11 +1846,30 @@ const struct bpf_verifier_ops cg_sysctl_verifier_ops = {
18461846const struct bpf_prog_ops cg_sysctl_prog_ops = {
18471847};
18481848
1849+ #ifdef CONFIG_NET
1850+ BPF_CALL_1 (bpf_get_netns_cookie_sockopt , struct bpf_sockopt_kern * , ctx )
1851+ {
1852+ struct sock * sk = ctx ? ctx -> sk : NULL ;
1853+ const struct net * net = sk ? sock_net (sk ) : & init_net ;
1854+
1855+ return net -> net_cookie ;
1856+ }
1857+
1858+ static const struct bpf_func_proto bpf_get_netns_cookie_sockopt_proto = {
1859+ .func = bpf_get_netns_cookie_sockopt ,
1860+ .gpl_only = false,
1861+ .ret_type = RET_INTEGER ,
1862+ .arg1_type = ARG_PTR_TO_CTX_OR_NULL ,
1863+ };
1864+ #endif
1865+
18491866static const struct bpf_func_proto *
18501867cg_sockopt_func_proto (enum bpf_func_id func_id , const struct bpf_prog * prog )
18511868{
18521869 switch (func_id ) {
18531870#ifdef CONFIG_NET
1871+ case BPF_FUNC_get_netns_cookie :
1872+ return & bpf_get_netns_cookie_sockopt_proto ;
18541873 case BPF_FUNC_sk_storage_get :
18551874 return & bpf_sk_storage_get_proto ;
18561875 case BPF_FUNC_sk_storage_delete :
You can’t perform that action at this time.
0 commit comments