2020-11-18 16:46:25 +08:00
|
|
|
From 71d2666525ed064f93693ff182cf8a862220a253 Mon Sep 17 00:00:00 2001
|
|
|
|
|
From: haozi007 <liuhao27@huawei.com>
|
|
|
|
|
Date: Wed, 18 Nov 2020 16:22:42 +0800
|
2020-11-28 14:22:02 +08:00
|
|
|
Subject: [PATCH 2/3] ignore http proxy env for cni plugin
|
2020-11-18 16:46:25 +08:00
|
|
|
|
|
|
|
|
Signed-off-by: haozi007 <liuhao27@huawei.com>
|
|
|
|
|
---
|
|
|
|
|
src/api.c | 3 ++-
|
|
|
|
|
src/api.h | 6 ++++--
|
|
|
|
|
src/invoke/args.c | 5 +++--
|
|
|
|
|
src/invoke/exec.c | 3 ++-
|
|
|
|
|
src/types/current.c | 35 ++++++++++++++++++-----------------
|
|
|
|
|
src/types/types.h | 8 ++++----
|
|
|
|
|
src/utils.c | 3 ++-
|
|
|
|
|
7 files changed, 35 insertions(+), 28 deletions(-)
|
|
|
|
|
|
|
|
|
|
diff --git a/src/api.c b/src/api.c
|
|
|
|
|
index abb3791..97d166d 100644
|
|
|
|
|
--- a/src/api.c
|
|
|
|
|
+++ b/src/api.c
|
|
|
|
|
@@ -704,7 +704,8 @@ int cni_add_network_list(const char *net_list_conf_str, const struct runtime_con
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-int cni_add_network(const char *cni_net_conf_str, const struct runtime_conf *rc, char **paths, struct result **add_result,
|
|
|
|
|
+int cni_add_network(const char *cni_net_conf_str, const struct runtime_conf *rc, char **paths,
|
|
|
|
|
+ struct result **add_result,
|
|
|
|
|
char **err)
|
|
|
|
|
{
|
|
|
|
|
struct network_config *net = NULL;
|
|
|
|
|
diff --git a/src/api.h b/src/api.h
|
|
|
|
|
index 392133a..61e56bb 100644
|
|
|
|
|
--- a/src/api.h
|
|
|
|
|
+++ b/src/api.h
|
|
|
|
|
@@ -58,7 +58,8 @@ struct cni_network_list_conf {
|
|
|
|
|
int cni_add_network_list(const char *net_list_conf_str, const struct runtime_conf *rc, char **paths,
|
|
|
|
|
struct result **pret, char **err);
|
|
|
|
|
|
|
|
|
|
-int cni_add_network(const char *cni_net_conf_str, const struct runtime_conf *rc, char **paths, struct result **add_result,
|
|
|
|
|
+int cni_add_network(const char *cni_net_conf_str, const struct runtime_conf *rc, char **paths,
|
|
|
|
|
+ struct result **add_result,
|
|
|
|
|
char **err);
|
|
|
|
|
|
|
|
|
|
int cni_del_network_list(const char *net_list_conf_str, const struct runtime_conf *rc, char **paths, char **err);
|
|
|
|
|
@@ -75,7 +76,8 @@ int cni_conflist_from_bytes(const char *bytes, struct cni_network_list_conf **li
|
|
|
|
|
|
|
|
|
|
int cni_conflist_from_file(const char *filename, struct cni_network_list_conf **list, char **err);
|
|
|
|
|
|
|
|
|
|
-int cni_conflist_from_conf(const struct cni_network_conf *cni_net_conf, struct cni_network_list_conf **cni_net_conf_list,
|
|
|
|
|
+int cni_conflist_from_conf(const struct cni_network_conf *cni_net_conf,
|
|
|
|
|
+ struct cni_network_list_conf **cni_net_conf_list,
|
|
|
|
|
char **err);
|
|
|
|
|
|
|
|
|
|
void free_cni_network_conf(struct cni_network_conf *val);
|
|
|
|
|
diff --git a/src/invoke/args.c b/src/invoke/args.c
|
|
|
|
|
index f95d444..dae484e 100644
|
|
|
|
|
--- a/src/invoke/args.c
|
|
|
|
|
+++ b/src/invoke/args.c
|
|
|
|
|
@@ -192,8 +192,9 @@ char **as_env(const struct cni_args *cniargs)
|
|
|
|
|
/* inherit environs of parent */
|
|
|
|
|
for (pos = envir; pos != NULL && *pos != NULL && i < len; pos++) {
|
|
|
|
|
// ignore proxy environs
|
|
|
|
|
- if (strcasecmp(*pos, NO_PROXY_KEY) == 0 || strcasecmp(*pos, HTTP_PROXY_KEY) == 0 ||
|
|
|
|
|
- strcasecmp(*pos, HTTPS_PROXY_KEY) == 0) {
|
|
|
|
|
+ if (strncasecmp(*pos, NO_PROXY_KEY, strlen(NO_PROXY_KEY)) == 0 ||
|
|
|
|
|
+ strncasecmp(*pos, HTTP_PROXY_KEY, strlen(HTTP_PROXY_KEY)) == 0 ||
|
|
|
|
|
+ strncasecmp(*pos, HTTPS_PROXY_KEY, strlen(HTTPS_PROXY_KEY)) == 0) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
result[i] = clibcni_util_strdup_s(*pos);
|
|
|
|
|
diff --git a/src/invoke/exec.c b/src/invoke/exec.c
|
|
|
|
|
index 3ad91b5..becba55 100644
|
|
|
|
|
--- a/src/invoke/exec.c
|
|
|
|
|
+++ b/src/invoke/exec.c
|
|
|
|
|
@@ -159,7 +159,8 @@ out:
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-static int do_parse_get_version_errmsg(int exec_ret, const cni_exec_error *e_err, struct plugin_info **result, char **err)
|
|
|
|
|
+static int do_parse_get_version_errmsg(int exec_ret, const cni_exec_error *e_err, struct plugin_info **result,
|
|
|
|
|
+ char **err)
|
|
|
|
|
{
|
|
|
|
|
char *str_err = NULL;
|
|
|
|
|
|
|
|
|
|
diff --git a/src/types/current.c b/src/types/current.c
|
|
|
|
|
index aa04f4d..da6c750 100644
|
|
|
|
|
--- a/src/types/current.c
|
|
|
|
|
+++ b/src/types/current.c
|
|
|
|
|
@@ -94,26 +94,26 @@ struct result *new_curr_result(const char *json_data, char **err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct interface *convert_curr_interface(const cni_network_interface *curr_interface)
|
|
|
|
|
- {
|
|
|
|
|
- struct interface *result = NULL;
|
|
|
|
|
-
|
|
|
|
|
- if (curr_interface == NULL) {
|
|
|
|
|
- ERROR("Invalid argument");
|
|
|
|
|
- return NULL;
|
|
|
|
|
- }
|
|
|
|
|
+{
|
|
|
|
|
+ struct interface *result = NULL;
|
|
|
|
|
|
|
|
|
|
- result = clibcni_util_common_calloc_s(sizeof(struct interface));
|
|
|
|
|
- if (result == NULL) {
|
|
|
|
|
- ERROR("Out of memory");
|
|
|
|
|
- return NULL;
|
|
|
|
|
- }
|
|
|
|
|
+ if (curr_interface == NULL) {
|
|
|
|
|
+ ERROR("Invalid argument");
|
|
|
|
|
+ return NULL;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
- result->name = clibcni_util_strdup_s(curr_interface->name);
|
|
|
|
|
- result->mac = clibcni_util_strdup_s(curr_interface->mac);
|
|
|
|
|
- result->sandbox = clibcni_util_strdup_s(curr_interface->sandbox);
|
|
|
|
|
- return result;
|
|
|
|
|
+ result = clibcni_util_common_calloc_s(sizeof(struct interface));
|
|
|
|
|
+ if (result == NULL) {
|
|
|
|
|
+ ERROR("Out of memory");
|
|
|
|
|
+ return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+ result->name = clibcni_util_strdup_s(curr_interface->name);
|
|
|
|
|
+ result->mac = clibcni_util_strdup_s(curr_interface->mac);
|
|
|
|
|
+ result->sandbox = clibcni_util_strdup_s(curr_interface->sandbox);
|
|
|
|
|
+ return result;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
static int do_parse_ipnet(const char *cidr_str, const char *ip_str, uint8_t **ip, size_t *ip_len,
|
|
|
|
|
struct ipnet **ipnet_val, char **err)
|
|
|
|
|
{
|
|
|
|
|
@@ -611,7 +611,8 @@ static bool copy_interfaces_from_result_to_json(const struct result *src, cni_re
|
|
|
|
|
|
|
|
|
|
res->interfaces_len = 0;
|
|
|
|
|
|
|
|
|
|
- res->interfaces = (cni_network_interface **)clibcni_util_smart_calloc_s(src->interfaces_len, sizeof(cni_network_interface *));
|
|
|
|
|
+ res->interfaces = (cni_network_interface **)clibcni_util_smart_calloc_s(src->interfaces_len,
|
|
|
|
|
+ sizeof(cni_network_interface *));
|
|
|
|
|
if (res->interfaces == NULL) {
|
|
|
|
|
*err = clibcni_util_strdup_s("Out of memory");
|
|
|
|
|
ERROR("Out of memory");
|
|
|
|
|
diff --git a/src/types/types.h b/src/types/types.h
|
|
|
|
|
index 68d074a..ccf2121 100644
|
|
|
|
|
--- a/src/types/types.h
|
|
|
|
|
+++ b/src/types/types.h
|
|
|
|
|
@@ -28,10 +28,10 @@ extern "C" {
|
|
|
|
|
|
|
|
|
|
/* define types for version */
|
|
|
|
|
struct interface {
|
|
|
|
|
- char *name;
|
|
|
|
|
- char *mac;
|
|
|
|
|
- char *sandbox;
|
|
|
|
|
- };
|
|
|
|
|
+ char *name;
|
|
|
|
|
+ char *mac;
|
|
|
|
|
+ char *sandbox;
|
|
|
|
|
+};
|
|
|
|
|
|
|
|
|
|
struct ipnet {
|
|
|
|
|
uint8_t *ip;
|
|
|
|
|
diff --git a/src/utils.c b/src/utils.c
|
|
|
|
|
index b64b8bd..4308b62 100644
|
|
|
|
|
--- a/src/utils.c
|
|
|
|
|
+++ b/src/utils.c
|
|
|
|
|
@@ -397,7 +397,8 @@ static inline bool check_do_clibcni_util_safe_uint_args(const char *numstr, cons
|
|
|
|
|
return (err_str == NULL || err_str == numstr || *err_str != '\0');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-static int do_clibcni_util_safe_uint(const char *numstr, const char *err_str, unsigned long long ull, unsigned int *converted)
|
|
|
|
|
+static int do_clibcni_util_safe_uint(const char *numstr, const char *err_str, unsigned long long ull,
|
|
|
|
|
+ unsigned int *converted)
|
|
|
|
|
{
|
|
|
|
|
if (check_do_clibcni_util_safe_uint_args(numstr, err_str)) {
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
--
|
|
|
|
|
2.25.1
|
|
|
|
|
|