@@ -1155,7 +1155,8 @@ struct bpf_link_ops {
void (*release)(struct bpf_link *link);
void (*dealloc)(struct bpf_link *link);
int (*detach)(struct bpf_link *link);
- int (*update_prog)(struct bpf_link *link, struct bpf_prog *new_prog,
+ int (*update_prog)(struct bpf_link *link, const union bpf_attr *attr,
+ struct bpf_prog *new_prog,
struct bpf_prog *old_prog);
void (*show_fdinfo)(const struct bpf_link *link, struct seq_file *seq);
int (*fill_link_info)(const struct bpf_link *link,
@@ -400,6 +400,7 @@ static void bpf_iter_link_dealloc(struct bpf_link *link)
}
static int bpf_iter_link_replace(struct bpf_link *link,
+ const union bpf_attr *attr,
struct bpf_prog *new_prog,
struct bpf_prog *old_prog)
{
@@ -664,7 +664,9 @@ static int __cgroup_bpf_replace(struct cgroup *cgrp,
return 0;
}
-static int cgroup_bpf_replace(struct bpf_link *link, struct bpf_prog *new_prog,
+static int cgroup_bpf_replace(struct bpf_link *link,
+ const union bpf_attr *attr,
+ struct bpf_prog *new_prog,
struct bpf_prog *old_prog)
{
struct bpf_cgroup_link *cg_link;
@@ -162,6 +162,7 @@ static void bpf_netns_link_dealloc(struct bpf_link *link)
}
static int bpf_netns_link_update_prog(struct bpf_link *link,
+ const union bpf_attr *attr,
struct bpf_prog *new_prog,
struct bpf_prog *old_prog)
{
@@ -4614,7 +4614,7 @@ static int link_update(union bpf_attr *attr)
}
if (link->ops->update_prog)
- ret = link->ops->update_prog(link, new_prog, old_prog);
+ ret = link->ops->update_prog(link, attr, new_prog, old_prog);
else
ret = -EINVAL;
@@ -619,7 +619,9 @@ static int bpf_xdp_link_fill_link_info(const struct bpf_link *link,
return 0;
}
-static int bpf_xdp_link_update(struct bpf_link *link, struct bpf_prog *new_prog,
+static int bpf_xdp_link_update(struct bpf_link *link,
+ const union bpf_attr *attr,
+ struct bpf_prog *new_prog,
struct bpf_prog *old_prog)
{
struct bpf_xdp_link *xdp_link = container_of(link, struct bpf_xdp_link, link);
In order to be able to use any arbitrary data from bpf_attr::link_update inside the bpf_link_ops::update_prog() implementations, pass a pointer to the whole attr as a callback argument. @new_prog and @old_prog arguments are still here as ::link_update contains only their FDs. Signed-off-by: Alexander Lobakin <alexandr.lobakin@intel.com> --- include/linux/bpf.h | 3 ++- kernel/bpf/bpf_iter.c | 1 + kernel/bpf/cgroup.c | 4 +++- kernel/bpf/net_namespace.c | 1 + kernel/bpf/syscall.c | 2 +- net/bpf/dev.c | 4 +++- 6 files changed, 11 insertions(+), 4 deletions(-)