lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20171124021208.13419-7-jakub.kicinski@netronome.com>
Date:   Thu, 23 Nov 2017 18:12:03 -0800
From:   Jakub Kicinski <jakub.kicinski@...ronome.com>
To:     netdev@...r.kernel.org
Cc:     oss-drivers@...ronome.com, daniel@...earbox.net,
        Jakub Kicinski <jakub.kicinski@...ronome.com>
Subject: [PATCH iproute2/master 06/11] bpf: expose bpf_parse_common() and bpf_load_common()

Expose bpf_parse_common() and bpf_load_common() functions
for those users who may want to modify the parameters to
load after parsing is done.

Signed-off-by: Jakub Kicinski <jakub.kicinski@...ronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@...ronome.com>
Acked-by: Daniel Borkmann <daniel@...earbox.net>
---
 include/bpf_util.h |  3 +++
 lib/bpf.c          | 26 ++++++++++++++++----------
 2 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/include/bpf_util.h b/include/bpf_util.h
index da2dee8bb3aa..f6371994252e 100644
--- a/include/bpf_util.h
+++ b/include/bpf_util.h
@@ -259,6 +259,9 @@ struct bpf_cfg_in {
 		.off   = 0,					\
 		.imm   = 0 })
 
+int bpf_parse_common(struct bpf_cfg_in *cfg, const struct bpf_cfg_ops *ops);
+int bpf_load_common(struct bpf_cfg_in *cfg, const struct bpf_cfg_ops *ops,
+		    void *nl);
 int bpf_parse_and_load_common(struct bpf_cfg_in *cfg,
 			      const struct bpf_cfg_ops *ops, void *nl);
 
diff --git a/lib/bpf.c b/lib/bpf.c
index 9a0867124fc4..f25f7016d10f 100644
--- a/lib/bpf.c
+++ b/lib/bpf.c
@@ -926,17 +926,12 @@ static int bpf_do_load(struct bpf_cfg_in *cfg)
 	return 0;
 }
 
-static int bpf_parse_opt_tbl(struct bpf_cfg_in *cfg,
-			     const struct bpf_cfg_ops *ops, void *nl,
-			     const bool *opt_tbl)
+int bpf_load_common(struct bpf_cfg_in *cfg, const struct bpf_cfg_ops *ops,
+		    void *nl)
 {
 	char annotation[256];
 	int ret;
 
-	ret = bpf_do_parse(cfg, opt_tbl);
-	if (ret < 0)
-		return ret;
-
 	ret = bpf_do_load(cfg);
 	if (ret < 0)
 		return ret;
@@ -953,8 +948,7 @@ static int bpf_parse_opt_tbl(struct bpf_cfg_in *cfg,
 	return 0;
 }
 
-int bpf_parse_and_load_common(struct bpf_cfg_in *cfg,
-			      const struct bpf_cfg_ops *ops, void *nl)
+int bpf_parse_common(struct bpf_cfg_in *cfg, const struct bpf_cfg_ops *ops)
 {
 	bool opt_tbl[BPF_MODE_MAX] = {};
 
@@ -968,7 +962,19 @@ int bpf_parse_and_load_common(struct bpf_cfg_in *cfg,
 		opt_tbl[EBPF_PINNED]   = true;
 	}
 
-	return bpf_parse_opt_tbl(cfg, ops, nl, opt_tbl);
+	return bpf_do_parse(cfg, opt_tbl);
+}
+
+int bpf_parse_and_load_common(struct bpf_cfg_in *cfg,
+			      const struct bpf_cfg_ops *ops, void *nl)
+{
+	int ret;
+
+	ret = bpf_parse_common(cfg, ops);
+	if (ret < 0)
+		return ret;
+
+	return bpf_load_common(cfg, ops, nl);
 }
 
 int bpf_graft_map(const char *map_path, uint32_t *key, int argc, char **argv)
-- 
2.14.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ