Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
clibcni
提交
34704f69
C
clibcni
项目概览
openeuler
/
clibcni
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
clibcni
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
34704f69
编写于
5月 22, 2020
作者:
O
openeuler-ci-bot
提交者:
Gitee
5月 22, 2020
浏览文件
操作
浏览文件
下载
差异文件
!14 fix error struct name
Merge pull request !14 from haozi007/change
上级
d122cf23
92cde479
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
13 addition
and
13 deletion
+13
-13
src/api.c
src/api.c
+10
-10
src/api.h
src/api.h
+3
-3
未找到文件。
src/api.c
浏览文件 @
34704f69
...
...
@@ -46,7 +46,7 @@ static int del_network(const struct network_config *net, const struct runtime_co
static
int
args
(
const
char
*
action
,
const
struct
runtime_conf
*
rc
,
const
char
*
const
*
paths
,
size_t
paths_len
,
struct
cni_args
**
cargs
,
char
**
err
);
static
int
copy_cni_
cni_portmappings
(
cni_portmappings
*
dst
,
const
struct
cni_cni_portmappings
*
src
)
static
int
copy_cni_
port_mapping
(
cni_inner_port_mapping
*
dst
,
const
struct
cni_port_mapping
*
src
)
{
bool
invalid_arg
=
(
dst
==
NULL
||
src
==
NULL
);
if
(
invalid_arg
)
{
...
...
@@ -64,40 +64,40 @@ static int copy_cni_cni_portmappings(cni_portmappings *dst, const struct cni_cni
return
0
;
}
static
int
inject_cni_port
mappings
(
const
struct
runtime_conf
*
rt
,
cni_net_conf_runtime_config
*
rt_config
,
char
**
err
)
static
int
inject_cni_port
_mapping
(
const
struct
runtime_conf
*
rt
,
cni_net_conf_runtime_config
*
rt_config
,
char
**
err
)
{
size_t
j
=
0
;
if
(
rt_config
->
port_mappings
!=
NULL
)
{
for
(
j
=
0
;
j
<
rt_config
->
port_mappings_len
;
j
++
)
{
free_cni_
portmappings
(
rt_config
->
port_mappings
[
j
]);
free_cni_
inner_port_mapping
(
rt_config
->
port_mappings
[
j
]);
rt_config
->
port_mappings
[
j
]
=
NULL
;
}
free
(
rt_config
->
port_mappings
);
rt_config
->
port_mappings
=
NULL
;
}
if
(
rt
->
p_mapping_len
>
(
SIZE_MAX
/
sizeof
(
cni_
portmappings
*
)))
{
if
(
rt
->
p_mapping_len
>
(
SIZE_MAX
/
sizeof
(
cni_
inner_port_mapping
*
)))
{
*
err
=
clibcni_util_strdup_s
(
"Too many mapping"
);
ERROR
(
"Too many mapping"
);
return
-
1
;
}
rt_config
->
port_mappings
=
clibcni_util_common_calloc_s
(
sizeof
(
cni_
portmappings
*
)
*
(
rt
->
p_mapping_len
));
rt_config
->
port_mappings
=
clibcni_util_common_calloc_s
(
sizeof
(
cni_
inner_port_mapping
*
)
*
(
rt
->
p_mapping_len
));
if
(
rt_config
->
port_mappings
==
NULL
)
{
*
err
=
clibcni_util_strdup_s
(
"Out of memory"
);
ERROR
(
"Out of memory"
);
return
-
1
;
}
for
(
j
=
0
;
j
<
rt
->
p_mapping_len
;
j
++
)
{
rt_config
->
port_mappings
[
j
]
=
clibcni_util_common_calloc_s
(
sizeof
(
cni_
portmappings
));
rt_config
->
port_mappings
[
j
]
=
clibcni_util_common_calloc_s
(
sizeof
(
cni_
inner_port_mapping
));
if
(
rt_config
->
port_mappings
[
j
]
==
NULL
)
{
*
err
=
clibcni_util_strdup_s
(
"Out of memory"
);
ERROR
(
"Out of memory"
);
return
-
1
;
}
(
rt_config
->
port_mappings_len
)
++
;
if
(
copy_cni_
cni_portmappings
(
rt_config
->
port_mappings
[
j
],
rt
->
p_mapping
[
j
])
!=
0
)
{
if
(
copy_cni_
port_mapping
(
rt_config
->
port_mappings
[
j
],
rt
->
p_mapping
[
j
])
!=
0
)
{
*
err
=
clibcni_util_strdup_s
(
"Out of memory"
);
ERROR
(
"Out of memory"
);
return
-
1
;
...
...
@@ -127,7 +127,7 @@ static int inject_runtime_config_items(const struct network_config *orig, const
continue
;
}
if
(
strcmp
(
work
,
"portMappings"
)
==
0
&&
rt
->
p_mapping_len
>
0
)
{
if
(
inject_cni_port
mappings
(
rt
,
*
rt_config
,
err
)
!=
0
)
{
if
(
inject_cni_port
_mapping
(
rt
,
*
rt_config
,
err
)
!=
0
)
{
ERROR
(
"Inject port mappings failed"
);
goto
free_out
;
}
...
...
@@ -613,7 +613,7 @@ free_out:
return
ret
;
}
void
free_cni_
cni_portmappings
(
struct
cni_cni_portmappings
*
val
)
void
free_cni_
port_mapping
(
struct
cni_port_mapping
*
val
)
{
if
(
val
!=
NULL
)
{
free
(
val
->
protocol
);
...
...
@@ -666,7 +666,7 @@ void free_runtime_conf(struct runtime_conf *rc)
rc
->
args
=
NULL
;
for
(
i
=
0
;
i
<
rc
->
p_mapping_len
;
i
++
)
{
free_cni_
cni_portmappings
(
rc
->
p_mapping
[
i
]);
free_cni_
port_mapping
(
rc
->
p_mapping
[
i
]);
}
free
(
rc
->
p_mapping
);
rc
->
p_mapping
=
NULL
;
...
...
src/api.h
浏览文件 @
34704f69
...
...
@@ -23,7 +23,7 @@
extern
"C"
{
#endif
struct
cni_
cni_portmappings
{
struct
cni_
port_mapping
{
int32_t
host_port
;
int32_t
container_port
;
char
*
protocol
;
...
...
@@ -37,7 +37,7 @@ struct runtime_conf {
char
*
(
*
args
)[
2
];
size_t
args_len
;
struct
cni_
cni_portmappings
**
p_mapping
;
struct
cni_
port_mapping
**
p_mapping
;
size_t
p_mapping_len
;
};
...
...
@@ -82,7 +82,7 @@ void free_cni_network_conf(struct cni_network_conf *val);
void
free_cni_network_list_conf
(
struct
cni_network_list_conf
*
val
);
void
free_cni_
cni_portmappings
(
struct
cni_cni_portmappings
*
val
);
void
free_cni_
port_mapping
(
struct
cni_port_mapping
*
val
);
void
free_runtime_conf
(
struct
runtime_conf
*
rc
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录