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 <chen.dylane@linux.dev>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20250710032038.888700-5-chen.dylane@linux.dev
pull/1309/head
Tao Chen 2025-07-10 11:20:35 +08:00 committed by Andrii Nakryiko
parent 33f69f7365
commit 6e816e1c05
2 changed files with 6 additions and 8 deletions

View File

@ -20,7 +20,6 @@ struct tcx_entry {
struct tcx_link { struct tcx_link {
struct bpf_link link; struct bpf_link link;
struct net_device *dev; struct net_device *dev;
u32 location;
}; };
static inline void tcx_set_ingress(struct sk_buff *skb, bool ingress) static inline void tcx_set_ingress(struct sk_buff *skb, bool ingress)

View File

@ -142,7 +142,7 @@ static int tcx_link_prog_attach(struct bpf_link *link, u32 flags, u32 id_or_fd,
u64 revision) u64 revision)
{ {
struct tcx_link *tcx = tcx_link(link); struct tcx_link *tcx = tcx_link(link);
bool created, ingress = tcx->location == BPF_TCX_INGRESS; bool created, ingress = link->attach_type == BPF_TCX_INGRESS;
struct bpf_mprog_entry *entry, *entry_new; struct bpf_mprog_entry *entry, *entry_new;
struct net_device *dev = tcx->dev; struct net_device *dev = tcx->dev;
int ret; int ret;
@ -169,7 +169,7 @@ static int tcx_link_prog_attach(struct bpf_link *link, u32 flags, u32 id_or_fd,
static void tcx_link_release(struct bpf_link *link) static void tcx_link_release(struct bpf_link *link)
{ {
struct tcx_link *tcx = tcx_link(link); struct tcx_link *tcx = tcx_link(link);
bool ingress = tcx->location == BPF_TCX_INGRESS; bool ingress = link->attach_type == BPF_TCX_INGRESS;
struct bpf_mprog_entry *entry, *entry_new; struct bpf_mprog_entry *entry, *entry_new;
struct net_device *dev; struct net_device *dev;
int ret = 0; int ret = 0;
@ -204,7 +204,7 @@ static int tcx_link_update(struct bpf_link *link, struct bpf_prog *nprog,
struct bpf_prog *oprog) struct bpf_prog *oprog)
{ {
struct tcx_link *tcx = tcx_link(link); struct tcx_link *tcx = tcx_link(link);
bool ingress = tcx->location == BPF_TCX_INGRESS; bool ingress = link->attach_type == BPF_TCX_INGRESS;
struct bpf_mprog_entry *entry, *entry_new; struct bpf_mprog_entry *entry, *entry_new;
struct net_device *dev; struct net_device *dev;
int ret = 0; int ret = 0;
@ -260,8 +260,8 @@ static void tcx_link_fdinfo(const struct bpf_link *link, struct seq_file *seq)
seq_printf(seq, "ifindex:\t%u\n", ifindex); seq_printf(seq, "ifindex:\t%u\n", ifindex);
seq_printf(seq, "attach_type:\t%u (%s)\n", seq_printf(seq, "attach_type:\t%u (%s)\n",
tcx->location, link->attach_type,
tcx->location == BPF_TCX_INGRESS ? "ingress" : "egress"); link->attach_type == BPF_TCX_INGRESS ? "ingress" : "egress");
} }
static int tcx_link_fill_info(const struct bpf_link *link, 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,
rtnl_unlock(); rtnl_unlock();
info->tcx.ifindex = ifindex; info->tcx.ifindex = ifindex;
info->tcx.attach_type = tcx->location; info->tcx.attach_type = link->attach_type;
return 0; return 0;
} }
@ -303,7 +303,6 @@ static int tcx_link_init(struct tcx_link *tcx,
{ {
bpf_link_init(&tcx->link, BPF_LINK_TYPE_TCX, &tcx_link_lops, prog, bpf_link_init(&tcx->link, BPF_LINK_TYPE_TCX, &tcx_link_lops, prog,
attr->link_create.attach_type); attr->link_create.attach_type);
tcx->location = attr->link_create.attach_type;
tcx->dev = dev; tcx->dev = dev;
return bpf_link_prime(&tcx->link, link_primer); return bpf_link_prime(&tcx->link, link_primer);
} }