From cd58464e0cf89a373598d3f297fe23aa71ed0048 Mon Sep 17 00:00:00 2001 From: haozi007 Date: Sat, 28 Nov 2020 14:51:08 +0800 Subject: [PATCH] sync from openeuler Signed-off-by: haozi007 --- 0001-ignore-proxy-envs.patch | 4 +- ...ignore-http-proxy-env-for-cni-plugin.patch | 177 ++++++++++++++++++ 0003-fix-invalid-ipv6-format.patch | 50 +++++ clibcni.spec | 12 +- 4 files changed, 239 insertions(+), 4 deletions(-) create mode 100644 0002-ignore-http-proxy-env-for-cni-plugin.patch create mode 100644 0003-fix-invalid-ipv6-format.patch diff --git a/0001-ignore-proxy-envs.patch b/0001-ignore-proxy-envs.patch index d33c0cc..67ca849 100644 --- a/0001-ignore-proxy-envs.patch +++ b/0001-ignore-proxy-envs.patch @@ -1,7 +1,7 @@ From 6af19b52f4867cfb722425ab702162af0f81d0ab Mon Sep 17 00:00:00 2001 From: haozi007 Date: Fri, 4 Sep 2020 09:53:37 +0800 -Subject: [PATCH] ignore proxy envs +Subject: [PATCH 1/3] ignore proxy envs do not inherit proxy envs from isulad @@ -37,5 +37,5 @@ index 96f0b81..f95d444 100644 i++; } -- -2.20.1 +2.25.1 diff --git a/0002-ignore-http-proxy-env-for-cni-plugin.patch b/0002-ignore-http-proxy-env-for-cni-plugin.patch new file mode 100644 index 0000000..3f2999f --- /dev/null +++ b/0002-ignore-http-proxy-env-for-cni-plugin.patch @@ -0,0 +1,177 @@ +From 71d2666525ed064f93693ff182cf8a862220a253 Mon Sep 17 00:00:00 2001 +From: haozi007 +Date: Wed, 18 Nov 2020 16:22:42 +0800 +Subject: [PATCH 2/3] ignore http proxy env for cni plugin + +Signed-off-by: haozi007 +--- + 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 + diff --git a/0003-fix-invalid-ipv6-format.patch b/0003-fix-invalid-ipv6-format.patch new file mode 100644 index 0000000..9332ad0 --- /dev/null +++ b/0003-fix-invalid-ipv6-format.patch @@ -0,0 +1,50 @@ +From d194158130c6824fa048c07783f470f83ec9d8ae Mon Sep 17 00:00:00 2001 +From: haozi007 +Date: Thu, 26 Nov 2020 15:11:05 +0800 +Subject: [PATCH 3/3] fix invalid ipv6 format + +Signed-off-by: haozi007 +--- + README.md | 2 +- + src/types/types.c | 12 ++++++++---- + 2 files changed, 9 insertions(+), 5 deletions(-) + +diff --git a/README.md b/README.md +index bcc0368..d52e27e 100644 +--- a/README.md ++++ b/README.md +@@ -1,7 +1,7 @@ + # clibcni + + CNI (Container Network Interface), a Cloud Native Computing Foundation project. +-clibcni is a library used by iSulad to configure network interfaces in containers, following ++clibcni is a library used by [iSulad](https://gitee.com/openeuler/iSulad) to configure network interfaces in containers, following + the specification of CNI (Container Network Interface), a Cloud Native Computing Foundation project. + + ## How to Contribute +diff --git a/src/types/types.c b/src/types/types.c +index 60a63c3..a9a04e7 100644 +--- a/src/types/types.c ++++ b/src/types/types.c +@@ -313,10 +313,14 @@ static void generate_ip_string(const uint8_t *ip, int e0, int e1, char **result) + } else if (i > 0) { + (*result)[j++] = ':'; + } +- int nret = (ip[i] >> 4); +- (*result)[j++] = g_HEX_DICT[nret]; +- nret = (ip[i] & 0x0f); +- (*result)[j++] = g_HEX_DICT[nret]; ++ uint32_t nret = (ip[i] << 8) | ip[i + 1]; ++ if (sprintf((*result) + j, "%x", nret) < 0) { ++ ERROR("sprint ip failed"); ++ free(*result); ++ *result = NULL; ++ return; ++ } ++ j = strlen(*result); + } + return; + } +-- +2.25.1 + diff --git a/clibcni.spec b/clibcni.spec index 3583506..17dfc82 100644 --- a/clibcni.spec +++ b/clibcni.spec @@ -1,5 +1,5 @@ %global _version 2.0.3 -%global _release 20201112.165252.gitc4aadda4 +%global _release 20201128.143240.git6303aa5e Name: clibcni Version: %{_version} Release: %{_release} @@ -10,7 +10,9 @@ URL: https://gitee.com/openeuler/clibcni Source0: https://gitee.com/openeuler/clibcni/repository/archive/v%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version} -Patch9001: 0001-ignore-proxy-envs.patch +Patch9001: 0001-ignore-proxy-envs.patch +Patch9002: 0002-ignore-http-proxy-env-for-cni-plugin.patch +Patch9003: 0003-fix-invalid-ipv6-format.patch BuildRequires: gcc BuildRequires: cmake @@ -87,6 +89,12 @@ rm -rf %{buildroot} %{_libdir}/pkgconfig/%{name}.pc %changelog +* Sat Nov 28 2020 haozi007 - 2.0.3-20201128.143240.git6303aa5e +- Type:bugfix +- ID:NA +- SUG:NA +- DESC: fix parse ipv6 format error + * Thu Nov 12 2020 gaohuatao - 2.0.3-20201112.165252.gitc4aadda4 - Type:enhancement - ID:NA -- Gitee