diff mbox series

[bpf-next,6/8] bpf: change func bpf_iter_unreg_target() signature

Message ID 20200512155238.1080615-1-yhs@fb.com
State Changes Requested
Delegated to: BPF Maintainers
Headers show
Series misc fixes for bpf_iter | expand

Commit Message

Yonghong Song May 12, 2020, 3:52 p.m. UTC
Change func bpf_iter_unreg_target() parameter from target
name to target reg_info, similar to bpf_iter_reg_target().

Signed-off-by: Yonghong Song <yhs@fb.com>
---
 include/linux/bpf.h   | 2 +-
 kernel/bpf/bpf_iter.c | 4 ++--
 net/ipv6/route.c      | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

Comments

Andrii Nakryiko May 12, 2020, 10:24 p.m. UTC | #1
On Tue, May 12, 2020 at 8:53 AM Yonghong Song <yhs@fb.com> wrote:
>
> Change func bpf_iter_unreg_target() parameter from target
> name to target reg_info, similar to bpf_iter_reg_target().
>
> Signed-off-by: Yonghong Song <yhs@fb.com>
> ---
>  include/linux/bpf.h   | 2 +-
>  kernel/bpf/bpf_iter.c | 4 ++--
>  net/ipv6/route.c      | 2 +-
>  3 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/include/linux/bpf.h b/include/linux/bpf.h
> index ab94dfd8826f..ad1bd13cd34c 100644
> --- a/include/linux/bpf.h
> +++ b/include/linux/bpf.h
> @@ -1154,7 +1154,7 @@ struct bpf_iter_meta {
>  };
>
>  int bpf_iter_reg_target(struct bpf_iter_reg *reg_info);
> -void bpf_iter_unreg_target(const char *target);
> +void bpf_iter_unreg_target(struct bpf_iter_reg *reg_info);
>  bool bpf_iter_prog_supported(struct bpf_prog *prog);
>  int bpf_iter_link_attach(const union bpf_attr *attr, struct bpf_prog *prog);
>  int bpf_iter_new_fd(struct bpf_link *link);
> diff --git a/kernel/bpf/bpf_iter.c b/kernel/bpf/bpf_iter.c
> index 1d203dc7afe2..041f97dcec39 100644
> --- a/kernel/bpf/bpf_iter.c
> +++ b/kernel/bpf/bpf_iter.c
> @@ -254,14 +254,14 @@ int bpf_iter_reg_target(struct bpf_iter_reg *reg_info)
>         return 0;
>  }
>
> -void bpf_iter_unreg_target(const char *target)
> +void bpf_iter_unreg_target(struct bpf_iter_reg *reg_info)

const, otherwise LGTM:

Acked-by: Andrii Nakryiko <andriin@fb.com>

>  {
>         struct bpf_iter_target_info *tinfo;
>         bool found = false;
>
>         mutex_lock(&targets_mutex);
>         list_for_each_entry(tinfo, &targets, list) {
> -               if (!strcmp(target, tinfo->reg_info->target)) {
> +               if (reg_info == tinfo->reg_info) {
>                         list_del(&tinfo->list);
>                         kfree(tinfo);
>                         found = true;
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index 48e8752d9ad9..bb8581f9b448 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -6412,7 +6412,7 @@ static int __init bpf_iter_register(void)
>
>  static void bpf_iter_unregister(void)
>  {
> -       bpf_iter_unreg_target("ipv6_route");
> +       bpf_iter_unreg_target(&ipv6_route_reg_info);
>  }
>  #endif
>  #endif
> --
> 2.24.1
>
diff mbox series

Patch

diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index ab94dfd8826f..ad1bd13cd34c 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -1154,7 +1154,7 @@  struct bpf_iter_meta {
 };
 
 int bpf_iter_reg_target(struct bpf_iter_reg *reg_info);
-void bpf_iter_unreg_target(const char *target);
+void bpf_iter_unreg_target(struct bpf_iter_reg *reg_info);
 bool bpf_iter_prog_supported(struct bpf_prog *prog);
 int bpf_iter_link_attach(const union bpf_attr *attr, struct bpf_prog *prog);
 int bpf_iter_new_fd(struct bpf_link *link);
diff --git a/kernel/bpf/bpf_iter.c b/kernel/bpf/bpf_iter.c
index 1d203dc7afe2..041f97dcec39 100644
--- a/kernel/bpf/bpf_iter.c
+++ b/kernel/bpf/bpf_iter.c
@@ -254,14 +254,14 @@  int bpf_iter_reg_target(struct bpf_iter_reg *reg_info)
 	return 0;
 }
 
-void bpf_iter_unreg_target(const char *target)
+void bpf_iter_unreg_target(struct bpf_iter_reg *reg_info)
 {
 	struct bpf_iter_target_info *tinfo;
 	bool found = false;
 
 	mutex_lock(&targets_mutex);
 	list_for_each_entry(tinfo, &targets, list) {
-		if (!strcmp(target, tinfo->reg_info->target)) {
+		if (reg_info == tinfo->reg_info) {
 			list_del(&tinfo->list);
 			kfree(tinfo);
 			found = true;
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 48e8752d9ad9..bb8581f9b448 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -6412,7 +6412,7 @@  static int __init bpf_iter_register(void)
 
 static void bpf_iter_unregister(void)
 {
-	bpf_iter_unreg_target("ipv6_route");
+	bpf_iter_unreg_target(&ipv6_route_reg_info);
 }
 #endif
 #endif