Skip to content

Commit 2a76a80

Browse files
Tao Chenanakryiko
authored andcommitted
bpf: Remove attach_type in bpf_netns_link
Use attach_type in bpf_link, and remove it in bpf_netns_link. And move netns_type field to the end to fill the byte hole. Signed-off-by: Tao Chen <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Reviewed-by: Jakub Sitnicki <[email protected]> Acked-by: Jiri Olsa <[email protected]> Acked-by: John Fastabend <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 6e816e1 commit 2a76a80

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

kernel/bpf/net_namespace.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
struct bpf_netns_link {
1313
struct bpf_link link;
14-
enum bpf_attach_type type;
15-
enum netns_bpf_attach_type netns_type;
1614

1715
/* We don't hold a ref to net in order to auto-detach the link
1816
* when netns is going away. Instead we rely on pernet
@@ -21,6 +19,7 @@ struct bpf_netns_link {
2119
*/
2220
struct net *net;
2321
struct list_head node; /* node in list of links attached to net */
22+
enum netns_bpf_attach_type netns_type;
2423
};
2524

2625
/* Protects updates to netns_bpf */
@@ -216,7 +215,7 @@ static int bpf_netns_link_fill_info(const struct bpf_link *link,
216215
mutex_unlock(&netns_bpf_mutex);
217216

218217
info->netns.netns_ino = inum;
219-
info->netns.attach_type = net_link->type;
218+
info->netns.attach_type = link->attach_type;
220219
return 0;
221220
}
222221

@@ -230,7 +229,7 @@ static void bpf_netns_link_show_fdinfo(const struct bpf_link *link,
230229
"netns_ino:\t%u\n"
231230
"attach_type:\t%u\n",
232231
info.netns.netns_ino,
233-
info.netns.attach_type);
232+
link->attach_type);
234233
}
235234

236235
static const struct bpf_link_ops bpf_netns_link_ops = {
@@ -503,7 +502,6 @@ int netns_bpf_link_create(const union bpf_attr *attr, struct bpf_prog *prog)
503502
bpf_link_init(&net_link->link, BPF_LINK_TYPE_NETNS,
504503
&bpf_netns_link_ops, prog, type);
505504
net_link->net = net;
506-
net_link->type = type;
507505
net_link->netns_type = netns_type;
508506

509507
err = bpf_link_prime(&net_link->link, &link_primer);

0 commit comments

Comments
 (0)