Allow to retrieve uds path from the environment, facilitates
also dealing with export a bit.

Signed-off-by: Daniel Borkmann <dan...@iogearbox.net>
---
 tc/f_bpf.c  | 6 ++++--
 tc/m_bpf.c  | 6 ++++--
 tc/tc_bpf.h | 2 ++
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/tc/f_bpf.c b/tc/f_bpf.c
index 597ef60..c21bf33 100644
--- a/tc/f_bpf.c
+++ b/tc/f_bpf.c
@@ -122,6 +122,7 @@ opt_bpf:
 
                        NEXT_ARG();
                        if (ebpf) {
+                               bpf_uds_name = secure_getenv(BPF_ENV_UDS);
                                bpf_obj = *argv;
                                NEXT_ARG();
 
@@ -131,8 +132,9 @@ opt_bpf:
                                        bpf_sec_name = *argv;
                                        NEXT_ARG();
                                }
-                               if (strcmp(*argv, "export") == 0 ||
-                                   strcmp(*argv, "exp") == 0) {
+                               if (!bpf_uds_name &&
+                                   (strcmp(*argv, "export") == 0 ||
+                                    strcmp(*argv, "exp") == 0)) {
                                        NEXT_ARG();
                                        bpf_uds_name = *argv;
                                        NEXT_ARG();
diff --git a/tc/m_bpf.c b/tc/m_bpf.c
index 0621157..9ddb667 100644
--- a/tc/m_bpf.c
+++ b/tc/m_bpf.c
@@ -105,6 +105,7 @@ opt_bpf:
 
                        NEXT_ARG();
                        if (ebpf) {
+                               bpf_uds_name = secure_getenv(BPF_ENV_UDS);
                                bpf_obj = *argv;
                                NEXT_ARG();
 
@@ -114,8 +115,9 @@ opt_bpf:
                                        bpf_sec_name = *argv;
                                        NEXT_ARG();
                                }
-                               if (strcmp(*argv, "export") == 0 ||
-                                   strcmp(*argv, "exp") == 0) {
+                               if (!bpf_uds_name &&
+                                   (strcmp(*argv, "export") == 0 ||
+                                    strcmp(*argv, "exp") == 0)) {
                                        NEXT_ARG();
                                        bpf_uds_name = *argv;
                                        NEXT_ARG();
diff --git a/tc/tc_bpf.h b/tc/tc_bpf.h
index 5a697e5..2ad8812 100644
--- a/tc/tc_bpf.h
+++ b/tc/tc_bpf.h
@@ -25,6 +25,8 @@
 #include "utils.h"
 #include "bpf_scm.h"
 
+#define BPF_ENV_UDS    "TC_BPF_UDS"
+
 int bpf_parse_string(char *arg, bool from_file, __u16 *bpf_len,
                     char **bpf_string, bool *need_release,
                     const char separator);
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to