Lines Matching refs:net

21 	struct net *net;  member
55 static void netns_bpf_run_array_detach(struct net *net, in netns_bpf_run_array_detach() argument
60 run_array = rcu_replace_pointer(net->bpf.run_array[type], NULL, in netns_bpf_run_array_detach()
65 static int link_index(struct net *net, enum netns_bpf_attach_type type, in link_index() argument
71 list_for_each_entry(pos, &net->bpf.links[type], node) { in link_index()
79 static int link_count(struct net *net, enum netns_bpf_attach_type type) in link_count() argument
84 list_for_each(pos, &net->bpf.links[type]) in link_count()
89 static void fill_prog_array(struct net *net, enum netns_bpf_attach_type type, in fill_prog_array() argument
95 list_for_each_entry(pos, &net->bpf.links[type], node) { in fill_prog_array()
107 struct net *net; in bpf_netns_link_release() local
116 net = net_link->net; in bpf_netns_link_release()
117 if (!net) in bpf_netns_link_release()
124 idx = link_index(net, type, net_link); in bpf_netns_link_release()
127 cnt = link_count(net, type); in bpf_netns_link_release()
129 netns_bpf_run_array_detach(net, type); in bpf_netns_link_release()
133 old_array = rcu_dereference_protected(net->bpf.run_array[type], in bpf_netns_link_release()
140 fill_prog_array(net, type, new_array); in bpf_netns_link_release()
141 rcu_assign_pointer(net->bpf.run_array[type], new_array); in bpf_netns_link_release()
145 net_link->net = NULL; in bpf_netns_link_release()
171 struct net *net; in bpf_netns_link_update_prog() local
181 net = net_link->net; in bpf_netns_link_update_prog()
182 if (!net || !check_net(net)) { in bpf_netns_link_update_prog()
188 run_array = rcu_dereference_protected(net->bpf.run_array[type], in bpf_netns_link_update_prog()
190 idx = link_index(net, type, net_link); in bpf_netns_link_update_prog()
209 struct net *net; in bpf_netns_link_fill_info() local
212 net = net_link->net; in bpf_netns_link_fill_info()
213 if (net && check_net(net)) in bpf_netns_link_fill_info()
214 inum = net->ns.inum; in bpf_netns_link_fill_info()
247 struct net *net, in __netns_bpf_prog_query() argument
254 run_array = rcu_dereference_protected(net->bpf.run_array[type], in __netns_bpf_prog_query()
274 struct net *net; in netns_bpf_prog_query() local
284 net = get_net_ns_by_fd(attr->query.target_fd); in netns_bpf_prog_query()
285 if (IS_ERR(net)) in netns_bpf_prog_query()
286 return PTR_ERR(net); in netns_bpf_prog_query()
289 ret = __netns_bpf_prog_query(attr, uattr, net, type); in netns_bpf_prog_query()
292 put_net(net); in netns_bpf_prog_query()
301 struct net *net; in netns_bpf_prog_attach() local
311 net = current->nsproxy->net_ns; in netns_bpf_prog_attach()
315 if (!list_empty(&net->bpf.links[type])) { in netns_bpf_prog_attach()
322 ret = flow_dissector_bpf_prog_attach_check(net, prog); in netns_bpf_prog_attach()
331 attached = net->bpf.progs[type]; in netns_bpf_prog_attach()
338 run_array = rcu_dereference_protected(net->bpf.run_array[type], in netns_bpf_prog_attach()
349 rcu_assign_pointer(net->bpf.run_array[type], run_array); in netns_bpf_prog_attach()
352 net->bpf.progs[type] = prog; in netns_bpf_prog_attach()
363 static int __netns_bpf_prog_detach(struct net *net, in __netns_bpf_prog_detach() argument
370 if (!list_empty(&net->bpf.links[type])) in __netns_bpf_prog_detach()
373 attached = net->bpf.progs[type]; in __netns_bpf_prog_detach()
376 netns_bpf_run_array_detach(net, type); in __netns_bpf_prog_detach()
377 net->bpf.progs[type] = NULL; in __netns_bpf_prog_detach()
420 static int netns_bpf_link_attach(struct net *net, struct bpf_link *link, in netns_bpf_link_attach() argument
430 cnt = link_count(net, type); in netns_bpf_link_attach()
436 if (net->bpf.progs[type]) { in netns_bpf_link_attach()
443 err = flow_dissector_bpf_prog_attach_check(net, link->prog); in netns_bpf_link_attach()
461 list_add_tail(&net_link->node, &net->bpf.links[type]); in netns_bpf_link_attach()
463 fill_prog_array(net, type, run_array); in netns_bpf_link_attach()
464 run_array = rcu_replace_pointer(net->bpf.run_array[type], run_array, in netns_bpf_link_attach()
482 struct net *net; in netns_bpf_link_create() local
493 net = get_net_ns_by_fd(attr->link_create.target_fd); in netns_bpf_link_create()
494 if (IS_ERR(net)) in netns_bpf_link_create()
495 return PTR_ERR(net); in netns_bpf_link_create()
504 net_link->net = net; in netns_bpf_link_create()
514 err = netns_bpf_link_attach(net, &net_link->link, netns_type); in netns_bpf_link_create()
520 put_net(net); in netns_bpf_link_create()
524 put_net(net); in netns_bpf_link_create()
528 static int __net_init netns_bpf_pernet_init(struct net *net) in netns_bpf_pernet_init() argument
533 INIT_LIST_HEAD(&net->bpf.links[type]); in netns_bpf_pernet_init()
538 static void __net_exit netns_bpf_pernet_pre_exit(struct net *net) in netns_bpf_pernet_pre_exit() argument
545 netns_bpf_run_array_detach(net, type); in netns_bpf_pernet_pre_exit()
546 list_for_each_entry(net_link, &net->bpf.links[type], node) { in netns_bpf_pernet_pre_exit()
547 net_link->net = NULL; /* auto-detach link */ in netns_bpf_pernet_pre_exit()
550 if (net->bpf.progs[type]) in netns_bpf_pernet_pre_exit()
551 bpf_prog_put(net->bpf.progs[type]); in netns_bpf_pernet_pre_exit()