Skip to content

Commit 6e816e1

Browse files
Tao Chenanakryiko
authored andcommitted
bpf: Remove location field in tcx_link
Use attach_type in bpf_link to replace the location filed, and remove location field in tcx_link. Signed-off-by: Tao Chen <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Acked-by: Daniel Borkmann <[email protected]> Acked-by: Jiri Olsa <[email protected]> Acked-by: John Fastabend <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 33f69f7 commit 6e816e1

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

include/net/tcx.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ struct tcx_entry {
2020
struct tcx_link {
2121
struct bpf_link link;
2222
struct net_device *dev;
23-
u32 location;
2423
};
2524

2625
static inline void tcx_set_ingress(struct sk_buff *skb, bool ingress)

kernel/bpf/tcx.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ static int tcx_link_prog_attach(struct bpf_link *link, u32 flags, u32 id_or_fd,
142142
u64 revision)
143143
{
144144
struct tcx_link *tcx = tcx_link(link);
145-
bool created, ingress = tcx->location == BPF_TCX_INGRESS;
145+
bool created, ingress = link->attach_type == BPF_TCX_INGRESS;
146146
struct bpf_mprog_entry *entry, *entry_new;
147147
struct net_device *dev = tcx->dev;
148148
int ret;
@@ -169,7 +169,7 @@ static int tcx_link_prog_attach(struct bpf_link *link, u32 flags, u32 id_or_fd,
169169
static void tcx_link_release(struct bpf_link *link)
170170
{
171171
struct tcx_link *tcx = tcx_link(link);
172-
bool ingress = tcx->location == BPF_TCX_INGRESS;
172+
bool ingress = link->attach_type == BPF_TCX_INGRESS;
173173
struct bpf_mprog_entry *entry, *entry_new;
174174
struct net_device *dev;
175175
int ret = 0;
@@ -204,7 +204,7 @@ static int tcx_link_update(struct bpf_link *link, struct bpf_prog *nprog,
204204
struct bpf_prog *oprog)
205205
{
206206
struct tcx_link *tcx = tcx_link(link);
207-
bool ingress = tcx->location == BPF_TCX_INGRESS;
207+
bool ingress = link->attach_type == BPF_TCX_INGRESS;
208208
struct bpf_mprog_entry *entry, *entry_new;
209209
struct net_device *dev;
210210
int ret = 0;
@@ -260,8 +260,8 @@ static void tcx_link_fdinfo(const struct bpf_link *link, struct seq_file *seq)
260260

261261
seq_printf(seq, "ifindex:\t%u\n", ifindex);
262262
seq_printf(seq, "attach_type:\t%u (%s)\n",
263-
tcx->location,
264-
tcx->location == BPF_TCX_INGRESS ? "ingress" : "egress");
263+
link->attach_type,
264+
link->attach_type == BPF_TCX_INGRESS ? "ingress" : "egress");
265265
}
266266

267267
static int tcx_link_fill_info(const struct bpf_link *link,
@@ -276,7 +276,7 @@ static int tcx_link_fill_info(const struct bpf_link *link,
276276
rtnl_unlock();
277277

278278
info->tcx.ifindex = ifindex;
279-
info->tcx.attach_type = tcx->location;
279+
info->tcx.attach_type = link->attach_type;
280280
return 0;
281281
}
282282

@@ -303,7 +303,6 @@ static int tcx_link_init(struct tcx_link *tcx,
303303
{
304304
bpf_link_init(&tcx->link, BPF_LINK_TYPE_TCX, &tcx_link_lops, prog,
305305
attr->link_create.attach_type);
306-
tcx->location = attr->link_create.attach_type;
307306
tcx->dev = dev;
308307
return bpf_link_prime(&tcx->link, link_primer);
309308
}

0 commit comments

Comments
 (0)