已合并
sync openEuler-24.03-LTS-SP4 to openEuler-26.09-DevStation #51
sync openEuler-24.03-LTS-SP4 to openEuler-26.09-DevStation #51
已合并
weli1创建于 8月19日
共 8 个文件变更+1018-36
@@ -1,26 +0,0 @@
1-From f75438dd75c2991f396d4d5c7f8fc4d11410bd5d Mon Sep 17 00:00:00 2001
2-From: weli-l <1289113577@qq.com>
3-Date: Thu, 11 Jul 2024 16:35:22 +0800
4-Subject: [PATCH] fix pod management cannot be canceld
5- 
6----
7- pkg/controller/manage/kmesh_manage.go | 3 ---
8- 1 file changed, 3 deletions(-)
9- 
10-diff --git a/pkg/controller/manage/kmesh_manage.go b/pkg/controller/manage/kmesh_manage.go
11-index f79dee4..f273083 100644
12---- a/pkg/controller/manage/kmesh_manage.go
13-+++ b/pkg/controller/manage/kmesh_manage.go
14-@@ -210,9 +210,6 @@ func shouldEnroll(client kubernetes.Interface, pod *corev1.Pod) bool {
15- if strings.EqualFold(pod.Labels[constants.DataPlaneModeLabel], constants.DataPlaneModeKmesh) {
16- return true
17- }
18-- if pod.Annotations[constants.KmeshRedirectionAnnotation] == "enabled" {
19-- return true
20-- }
21-
22- ns, err := client.CoreV1().Namespaces().Get(context.TODO(), pod.Namespace, metav1.GetOptions{})
23- if err != nil {
24---
25-2.34.1
26- 
MKmesh.spec+25-10
@@ -1,11 +1,11 @@
1%global codepath kmesh1%global codepath kmesh
2Name: Kmesh2Name: Kmesh
3-Version: 0.4.03+Version: 0.4.1
4-Release: 24+Release: 5
5Summary: %{name} is a eBPF-based service mesh kernel solution5Summary: %{name} is a eBPF-based service mesh kernel solution
6License: ASL 2.0 and GPL-2.06License: ASL 2.0 and GPL-2.0
7URL: https://github.com/kmesh-net7URL: https://github.com/kmesh-net
8-Source0: https://github.com/kmesh-net/kmesh/releases/tag/v%{version}.tar.gz8+Source0: https://github.com/kmesh-net/kmesh/archive/refs/tags/v%{version}.tar.gz
9 9 
10BuildRequires: cmake make pkgconf dracut10BuildRequires: cmake make pkgconf dracut
11BuildRequires: protobuf protobuf-c protobuf-c-devel11BuildRequires: protobuf protobuf-c protobuf-c-devel
@@ -21,8 +21,12 @@ Requires: libboundscheck
21 21 
22Patch0001: Downgrade-go-version-to-v1.21.4.patch22Patch0001: Downgrade-go-version-to-v1.21.4.patch
23Patch0002: Remove-useless-tag-in-Makefile.patch23Patch0002: Remove-useless-tag-in-Makefile.patch
24-Patch0003: Fix-pod-management-cannot-be-canceled.patch24+Patch0003: Support-uid-gid.patch
25-Patch0004: Support-uid-gid.patch25+Patch0004: fix-oncn-mda-don-t-support-use-ipv6-family-in-sockop.patch
26+Patch0005: remove-libboundscheck-dependency.patch
27+Patch0006: The-FN-get_netns_cookie-in-the-6.x-kernel-is-changed.patch
28+Patch0007: add-sockmap-dump-function.patch
29+Patch0008: Remove-cgroup-connect6-ebpf-prog.patch
26 30 
27%description31%description
28%{name} is a eBPF-based service mesh kernel solution.32%{name} is a eBPF-based service mesh kernel solution.
@@ -43,7 +47,7 @@ go mod tidy
43%install47%install
44mkdir -p %{buildroot}%{_bindir}48mkdir -p %{buildroot}%{_bindir}
45install %{_builddir}/%{codepath}-%{version}/kmesh-daemon %{buildroot}%{_bindir}49install %{_builddir}/%{codepath}-%{version}/kmesh-daemon %{buildroot}%{_bindir}
46-install -Dpm 0600 %{_builddir}/%{codepath}-%{version}/kmesh-cni %{buildroot}%{_bindir}50+install -Dpm 0600 %{_builddir}/%{codepath}-%{version}/kmesh-cni %{buildroot}%{_bindir}
47install %{_builddir}/%{codepath}-%{version}/build/kmesh-start-pre.sh %{buildroot}%{_bindir}51install %{_builddir}/%{codepath}-%{version}/build/kmesh-start-pre.sh %{buildroot}%{_bindir}
48install %{_builddir}/%{codepath}-%{version}/build/kmesh-stop-post.sh %{buildroot}%{_bindir}52install %{_builddir}/%{codepath}-%{version}/build/kmesh-stop-post.sh %{buildroot}%{_bindir}
49install %{_builddir}/%{codepath}-%{version}/oncn-mda/deploy/mdacore %{buildroot}%{_bindir}53install %{_builddir}/%{codepath}-%{version}/oncn-mda/deploy/mdacore %{buildroot}%{_bindir}
@@ -122,11 +126,21 @@ rm -rf %{buildroot}
122%attr(0500,root,root) /kmesh/start_kmesh.sh126%attr(0500,root,root) /kmesh/start_kmesh.sh
123 127 
124%changelog128%changelog
125-* Wed Feb 19 2025 weli-l<1289113577@qq.com> - 0.4.0-2129+* Wed Aug 26 2026 weli-l<1289113577@qq.com> - 0.4.1-5
126-- modify ebpf prog premissions130+- modify ebpf prog permissions
127 131 
128-* Mon Jul 29 2024 weli-l<1289113577@qq.com> - 0.4.0-1132+* Fri Dec 12 2025 weli-l<1289113577@qq.com> - 0.4.1-4
129-- init Kmesh 0.4.0133+- remove cgroup/connect6 ebpf prog
134+ 
135+* Fri Mar 21 2025 weli-l<1289113577@qq.com> - 0.4.1-3
136+- 1. fix oncn-mda don't support ipv4 mapped ipv6
137+ 2. remove libboundscheck dependence
138+ 
139+* Tue Dec 17 2024 weli-l<1289113577@qq.com> - 0.4.1-2
140+- modify ebpf prog permissions
141+ 
142+* Mon Sep 02 2024 weli-l<1289113577@qq.com> - 0.4.1-1
143+- init Kmesh 0.4.1
130 144 
131* Fri Aug 18 2023 JofDiamonds <kwb0523@163.com> - 0.3.0-3145* Fri Aug 18 2023 JofDiamonds <kwb0523@163.com> - 0.3.0-3
132- update spec146- update spec
@@ -136,3 +150,4 @@ rm -rf %{buildroot}
136 150 
137* Mon Jul 31 2023 JofDiamonds <kwb0523@163.com> - 0.3.0-1151* Mon Jul 31 2023 JofDiamonds <kwb0523@163.com> - 0.3.0-1
138- init package152- init package
153+ 
@@ -0,0 +1,121 @@
1+From 6473badd55a825f817d3e6a1b34cd3004af01864 Mon Sep 17 00:00:00 2001
2+From: weli-l <1289113577@qq.com>
3+Date: Fri, 12 Dec 2025 15:46:21 +0800
4+Subject: [PATCH] remove cgroup/connect6 ebpf prog
5+ 
6+Signed-off-by: weli-l <1289113577@qq.com>
7+---
8+ bpf/kmesh/workload/cgroup_sock.c | 40 --------------------------------
9+ pkg/bpf/bpf_kmesh_workload.go | 25 --------------------
10+ 2 files changed, 65 deletions(-)
11+ 
12+diff --git a/bpf/kmesh/workload/cgroup_sock.c b/bpf/kmesh/workload/cgroup_sock.c
13+index ca592f3e..407a738a 100644
14+--- a/bpf/kmesh/workload/cgroup_sock.c
15++++ b/bpf/kmesh/workload/cgroup_sock.c
16+@@ -100,45 +100,5 @@ int cgroup_connect4_prog(struct bpf_sock_addr *ctx)
17+ return CGROUP_SOCK_OK;
18+ }
19+
20+-SEC("cgroup/connect6")
21+-int cgroup_connect6_prog(struct bpf_sock_addr *ctx)
22+-{
23+- struct kmesh_context kmesh_ctx = {0};
24+- kmesh_ctx.ctx = ctx;
25+- IP6_COPY(kmesh_ctx.orig_dst_addr.ip6, ctx->user_ip6);
26+- IP6_COPY(kmesh_ctx.dnat_ip.ip6, kmesh_ctx.orig_dst_addr.ip6);
27+- kmesh_ctx.dnat_port = ctx->user_port;
28+-
29+- if (handle_kmesh_manage_process(&kmesh_ctx) || !is_kmesh_enabled(ctx)) {
30+- return CGROUP_SOCK_OK;
31+- }
32+-
33+- if (handle_bypass_process(&kmesh_ctx) || is_bypass_enabled(ctx)) {
34+- return CGROUP_SOCK_OK;
35+- }
36+-
37+- BPF_LOG(DEBUG, KMESH, "enter cgroup/connect6\n");
38+-
39+- int ret = sock_traffic_control(&kmesh_ctx);
40+- if (ret) {
41+- BPF_LOG(ERR, KMESH, "sock_traffic_control failed: %d\n", ret);
42+- return CGROUP_SOCK_OK;
43+- }
44+-
45+- if (is_ipv4_mapped_addr(ctx->user_ip6) && !is_ipv4_mapped_addr(kmesh_ctx.dnat_ip.ip6))
46+- V4_MAPPED_TO_V6(kmesh_ctx.dnat_ip.ip4, kmesh_ctx.dnat_ip.ip6);
47+- SET_CTX_ADDRESS6(ctx, &kmesh_ctx.dnat_ip, kmesh_ctx.dnat_port);
48+-
49+- if (kmesh_ctx.via_waypoint) {
50+- kmesh_workload_tail_call(ctx, TAIL_CALL_CONNECT6_INDEX);
51+-
52+- // if tail call failed will run this code
53+- BPF_LOG(ERR, KMESH, "workload tail call6 failed, err is %d\n", ret);
54+- }
55+-
56+- observe_on_pre_connect(ctx->sk);
57+- return CGROUP_SOCK_OK;
58+-}
59+-
60+ char _license[] SEC("license") = "Dual BSD/GPL";
61+ int _version SEC("version") = 1;
62+diff --git a/pkg/bpf/bpf_kmesh_workload.go b/pkg/bpf/bpf_kmesh_workload.go
63+index 5c508408..b2ab94f0 100644
64+--- a/pkg/bpf/bpf_kmesh_workload.go
65++++ b/pkg/bpf/bpf_kmesh_workload.go
66+@@ -46,7 +46,6 @@ func (sc *BpfSockConnWorkload) NewBpf(cfg *options.BpfConfig) error {
67+ sc.Info.BpfFsPath = cfg.BpfFsPath + "/bpf_kmesh_workload/sockconn/"
68+ sc.Info.BpfVerifyLogSize = cfg.BpfVerifyLogSize
69+ sc.Info.Cgroup2Path = cfg.Cgroup2Path
70+- sc.Info6 = sc.Info
71+
72+ if err := os.MkdirAll(sc.Info.MapPath,
73+ syscall.S_IRUSR|syscall.S_IWUSR|syscall.S_IXUSR|
74+@@ -109,16 +108,6 @@ func (sc *BpfSockConnWorkload) LoadSockConn() error {
75+ return err
76+ }
77+
78+- prog = spec.Programs["cgroup_connect6_prog"]
79+- sc.Info6.Type = prog.Type
80+- sc.Info6.AttachType = prog.AttachType
81+-
82+- if err = sc.MapOfTailCallProg.Update(
83+- uint32(constants.TailCallConnect6Index),
84+- uint32(sc.CgroupConnect6Prog.FD()),
85+- ebpf.UpdateAny); err != nil {
86+- return err
87+- }
88+ return nil
89+ }
90+
91+@@ -142,13 +131,6 @@ func (sc *BpfSockConnWorkload) Attach() error {
92+ return err
93+ }
94+
95+- cgopt = link.CgroupOptions{
96+- Path: sc.Info6.Cgroup2Path,
97+- Attach: sc.Info6.AttachType,
98+- Program: sc.KmeshCgroupSockWorkloadObjects.CgroupConnect6Prog,
99+- }
100+-
101+- sc.Link6, err = link.AttachCgroup(cgopt)
102+ return err
103+ }
104+
105+@@ -176,13 +158,6 @@ func (sc *BpfSockConnWorkload) Detach() error {
106+ return sc.Link.Close()
107+ }
108+
109+- if err := os.RemoveAll(sc.Info6.BpfFsPath); err != nil && !os.IsNotExist(err) {
110+- return err
111+- }
112+-
113+- if sc.Link6 != nil {
114+- return sc.Link6.Close()
115+- }
116+ return nil
117+ }
118+
119+--
120+2.43.0
121+ 
@@ -0,0 +1,545 @@
1+From 7a892ba8c584ab4535b2749611ef498f5289ce3e Mon Sep 17 00:00:00 2001
2+From: bitcoffee <liuxin350@huawei.com>
3+Date: Tue, 24 Dec 2024 22:54:46 +0800
4+Subject: [PATCH 1/4] add sockmap dump function
5+ 
6+---
7+ oncn-mda/cli_src/CMakeLists.txt | 3 +
8+ oncn-mda/cli_src/func/dump.c | 214 ++++++++++++++++++++++++++++++
9+ oncn-mda/cli_src/func/global.c | 2 +-
10+ oncn-mda/cli_src/mdadump.c | 7 +
11+ oncn-mda/ebpf_src/sock_redirect.c | 96 +++++++++++++-
12+ oncn-mda/include/data.h | 3 +
13+ oncn-mda/include/dump.h | 6 +
14+ oncn-mda/include/macli.h | 12 ++
15+ oncn-mda/include/writecap.h | 80 +++++++++++
16+ 9 files changed, 421 insertions(+), 2 deletions(-)
17+ create mode 100644 oncn-mda/cli_src/func/dump.c
18+ create mode 100644 oncn-mda/cli_src/mdadump.c
19+ create mode 100644 oncn-mda/include/dump.h
20+ create mode 100644 oncn-mda/include/writecap.h
21+ 
22+diff --git a/oncn-mda/cli_src/CMakeLists.txt b/oncn-mda/cli_src/CMakeLists.txt
23+index 5bf849f..7c710b3 100644
24+--- a/oncn-mda/cli_src/CMakeLists.txt
25++++ b/oncn-mda/cli_src/CMakeLists.txt
26+@@ -16,4 +16,7 @@ endif($ENV{HS_COVERAGE_ENABLE})
27+ add_executable(mdacore mdacore.c ${SRC_LIST})
28+ target_link_libraries(mdacore -lbpf -lelf -lz -lm)
29+
30++add_executable(mdadump mdadump.c ${SRC_LIST})
31++target_link_libraries(mdadump -lbpf -lelf -lz -lm)
32++
33+ MESSAGE("======================Leave cli folder=======================")
34+diff --git a/oncn-mda/cli_src/func/dump.c b/oncn-mda/cli_src/func/dump.c
35+new file mode 100644
36+index 0000000..72a4916
37+--- /dev/null
38++++ b/oncn-mda/cli_src/func/dump.c
39+@@ -0,0 +1,214 @@
40++// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
41++/* Copyright Authors of Kmesh */
42++
43++#include <signal.h>
44++#include "macli.h"
45++#include "writecap.h"
46++volatile sig_atomic_t g_keep_running = TRUE;
47++
48++static void init_filter_rule(struct sock_param *input)
49++{
50++ (void)memset(input, 0x0, sizeof(struct sock_param));
51++}
52++
53++void dump_usage(void)
54++{
55++ printf("Usage: dump {OPTIONS}\n");
56++ printf(" OPTIONS: -i|--ip: filter ip,eg:1.1.1.1/24\n");
57++ printf(" OPTIONS: -p|--ports: filter ports,eg:15001~15006\n");
58++ printf(" OPTIONS: -w|--write: output file\n");
59++}
60++
61++static const struct option g_dump_optionsp[] = {
62++ {"ip", required_argument, NULL, 'i'},
63++ {"ports", required_argument, NULL, 'p'},
64++ {"writes", required_argument, NULL, 'w'},
65++ {NULL}
66++};
67++
68++int get_input_dump_ip(const char* src, struct sock_param* filter_rules)
69++{
70++ if (filter_rules->dump_params.current_cidr_num >= MAX_PARAM_LENGTH) {
71++ printf("over the max cidrs set num, max is %d\n", MAX_PARAM_LENGTH);
72++ return FAILED;
73++ }
74++ char tmp_arg[MAX_CIDR_LENGTH] = {0};
75++ (void)strncpy(tmp_arg, src, MAX_IP_LENGTH);
76++ (void)strncat(tmp_arg, "/32", sizeof(tmp_arg) - strlen(tmp_arg));
77++ __u32 ip;
78++ __u32 mask;
79++ if (check_cidr(tmp_arg, &ip, &mask) != SUCCESS)
80++ return FAILED;
81++ int current_param_num = filter_rules->dump_params.current_cidr_num++;
82++ filter_rules->dump_params.dump_cidr[current_param_num].ip4 = ip;
83++ filter_rules->dump_params.dump_cidr[current_param_num].mask = mask;
84++ return SUCCESS;
85++}
86++
87++int get_input_dump_port(const char* src, struct sock_param *filter_rules)
88++{
89++ if (strlen(src) > MAX_PORT_RANGE_LENGTH - 1) {
90++ printf("input ports is too long! your input: %s\n", src);
91++ return FAILED;
92++ }
93++ if (filter_rules->dump_params.current_port_num >= MAX_PARAM_LENGTH) {
94++ printf("over the max ports set num, max is %d\n", MAX_PARAM_LENGTH);
95++ return FAILED;
96++ }
97++ __u32 begin_port;
98++ __u32 end_port;
99++ if (check_port(src, &begin_port, &end_port) != SUCCESS) {
100++ return FAILED;
@@ -0,0 +1,26 @@
1+From 3ec7e0af60ea52a1db143a5cb001c0cf171da064 Mon Sep 17 00:00:00 2001
2+From: bitcoffee <liuxin350@huawei.com>
3+Date: Thu, 12 Dec 2024 19:13:53 +0800
4+Subject: [PATCH] fix oncn-mda don't support use ipv6 family in sockops
5+ 
6+Signed-off-by: bitcoffee <liuxin350@huawei.com>
7+---
8+ oncn-mda/ebpf_src/sock_ops.c | 2 +-
9+ 1 file changed, 1 insertion(+), 1 deletion(-)
10+ 
11+diff --git a/oncn-mda/ebpf_src/sock_ops.c b/oncn-mda/ebpf_src/sock_ops.c
12+index f5ab001..92840cc 100644
13+--- a/oncn-mda/ebpf_src/sock_ops.c
14++++ b/oncn-mda/ebpf_src/sock_ops.c
15+@@ -397,7 +397,7 @@ static void clean_ops_map(struct bpf_sock_ops *const skops)
16+ SEC("sockops")
17+ int SOCK_OPS_NAME(struct bpf_sock_ops *const skops)
18+ {
19+- if (skops->family != AF_INET)
20++ if ((skops->family != AF_INET) && (skops->family != AF_INET6))
21+ return 0;
22+
23+ switch (skops->op) {
24+--
25+2.33.0
26+ 
@@ -0,0 +1,269 @@
1+From 66c6cd8aa818fc1b31f0d646817b7577c11396fc Mon Sep 17 00:00:00 2001
2+From: bitcoffee <liuxin350@huawei.com>
3+Date: Thu, 12 Dec 2024 19:41:12 +0800
4+Subject: [PATCH] remove libboundscheck dependency
5+ 
6+Signed-off-by: bitcoffee <liuxin350@huawei.com>
7+---
8+ oncn-mda/cli_src/CMakeLists.txt | 2 +-
9+ oncn-mda/cli_src/func/chain.c | 23 ++++----------
10+ oncn-mda/cli_src/func/global.c | 53 +++++++++------------------------
11+ oncn-mda/cli_src/func/log.c | 2 +-
12+ oncn-mda/cli_src/func/switch.c | 16 ++++------
13+ oncn-mda/include/log.h | 1 -
14+ oncn-mda/include/macli.h | 1 -
15+ 7 files changed, 28 insertions(+), 70 deletions(-)
16+ 
17+diff --git a/oncn-mda/cli_src/CMakeLists.txt b/oncn-mda/cli_src/CMakeLists.txt
18+index 471da73..5bf849f 100644
19+--- a/oncn-mda/cli_src/CMakeLists.txt
20++++ b/oncn-mda/cli_src/CMakeLists.txt
21+@@ -14,6 +14,6 @@ if($ENV{HS_COVERAGE_ENABLE})
22+ endif($ENV{HS_COVERAGE_ENABLE})
23+
24+ add_executable(mdacore mdacore.c ${SRC_LIST})
25+-target_link_libraries(mdacore -lbpf -lboundscheck -lelf -lz -lm)
26++target_link_libraries(mdacore -lbpf -lelf -lz -lm)
27+
28+ MESSAGE("======================Leave cli folder=======================")
29+diff --git a/oncn-mda/cli_src/func/chain.c b/oncn-mda/cli_src/func/chain.c
30+index 3890606..4cf2988 100644
31+--- a/oncn-mda/cli_src/func/chain.c
32++++ b/oncn-mda/cli_src/func/chain.c
33+@@ -32,14 +32,9 @@ static int get_input_ip(const char *const src, struct input_filter_rule *const i
34+ macli_log(ERR, "over the max cidrs set num, max is %d\n", MAX_PARAM_LENGTH);
35+ return FAILED;
36+ }
37+- int ret = strcpy_s(input_filter_rules->input_ip[(input_filter_rules->input_ip_num)++], MAX_CIDR_LENGTH, src);
38+- if (ret == ERANGE_AND_RESET) {
39+- macli_log(ERR, "input cidr string too long!\n");
40+- return FAILED;
41+- } else if (ret != EOK) {
42+- macli_log(ERR, "get filter rules failed! errno:%d\n", ret);
43+- return FAILED;
44+- }
45++ (void)memset(input_filter_rules->input_ip[(input_filter_rules->input_ip_num)], 0x0, MAX_CIDR_LENGTH);
46++ (void)strncpy(input_filter_rules->input_ip[(input_filter_rules->input_ip_num)++], src, MAX_CIDR_LENGTH - 1);
47++
48+ return SUCCESS;
49+ }
50+
51+@@ -49,15 +44,9 @@ static int get_input_port(const char *const src, struct input_filter_rule *const
52+ macli_log(ERR, "over the max ports set num, max is %d\n", MAX_PARAM_LENGTH);
53+ return FAILED;
54+ }
55+- int ret =
56+- strcpy_s(input_filter_rules->input_port[(input_filter_rules->input_port_num)++], MAX_PORT_RANGE_LENGTH, src);
57+- if (ret == ERANGE_AND_RESET) {
58+- macli_log(ERR, "input port string is too long!\n");
59+- return FAILED;
60+- } else if (ret != EOK) {
61+- macli_log(ERR, "get filter rules failed! errno:%d\n", ret);
62+- return FAILED;
63+- }
64++ (void)memset(input_filter_rules->input_port[(input_filter_rules->input_port_num)], 0x0, MAX_PORT_RANGE_LENGTH);
65++ (void)strncpy(input_filter_rules->input_port[(input_filter_rules->input_port_num)++], src, MAX_PORT_RANGE_LENGTH - 1);
66++
67+ return SUCCESS;
68+ }
69+
70+diff --git a/oncn-mda/cli_src/func/global.c b/oncn-mda/cli_src/func/global.c
71+index 2579078..a0f17ab 100644
72+--- a/oncn-mda/cli_src/func/global.c
73++++ b/oncn-mda/cli_src/func/global.c
74+@@ -113,10 +113,8 @@ static int get_prog_fd(const char *const prog_name, int *const fd)
75+ __u32 obj_id = 0;
76+ __u32 info_length = sizeof(struct bpf_prog_info);
77+ while (true) {
78+- if (memset_s(&prog_info, info_length, 0x0, info_length) != EOK) {
79+- macli_log(ERR, "system memset failed!\n");
80+- return FAILED;
81+- }
82++ (void)memset(&prog_info, 0x0, info_length);
83++
84+ if (bpf_prog_get_next_id(obj_id, &obj_id)) {
85+ if (errno == ENOENT)
86+ break;
87+@@ -151,10 +149,7 @@ static int get_map_fd(const char *const map_name, int *const fd)
88+ __u32 obj_id = 0;
89+ __u32 info_length = sizeof(struct bpf_map_info);
90+ while (true) {
91+- if (memset_s(&map_info, info_length, 0x0, info_length) != EOK) {
92+- macli_log(ERR, "system memset failed!\n");
93+- return FAILED;
94+- }
95++ (void)memset(&map_info, 0x0, info_length);
96+ if (bpf_map_get_next_id(obj_id, &obj_id)) {
97+ if (errno == ENOENT)
98+ break;
99+@@ -192,13 +187,10 @@ static int init_mesh_map(
100+ struct bpf_create_map_attr *const map_attr)
101+ #endif
102+ {
103+- int ret = EOK;
104+- ret += strcpy_s(fds_map->name, BPF_OBJ_NAME_LEN, map_name);
105+- ret += strcpy_s(fds_map->pin_file_path, PATH_MAX, pin_file_path);
106+- if (ret != EOK) {
107+- macli_log(ERR, "system copy string failed!");
108+- return FAILED;
109+- }
110++ (void)memset(fds_map->name, 0x0, BPF_OBJ_NAME_LEN);
111++ (void)strncpy(fds_map->name, map_name, BPF_OBJ_NAME_LEN - 1);
112++ (void)memset(fds_map->pin_file_path, 0x0, PATH_MAX);
113++ (void)strncpy(fds_map->pin_file_path, pin_file_path, PATH_MAX - 1);
114+ if (get_map_fd(fds_map->name, &(fds_map->fd)) != SUCCESS)
115+ return FAILED;
116+ fds_map->xattr = map_attr;
117+@@ -212,12 +204,8 @@ static int init_mesh_prog(
118+ enum bpf_attach_type attach_type,
119+ int attach_fd)
120+ {
121+- int ret = EOK;
122+- ret = strcpy_s(fds_prog->name, BPF_OBJ_NAME_LEN, prog_name);
123+- if (ret != EOK) {
124+- macli_log(ERR, "system copy string failed!");
125+- return FAILED;
126+- }
127++ (void)memset(fds_prog->name, 0x0, BPF_OBJ_NAME_LEN);
128++ (void)strncpy(fds_prog->name, prog_name, BPF_OBJ_NAME_LEN - 1);
129+ if (get_prog_fd(fds_prog->name, &(fds_prog->fd)) != SUCCESS)
130+ return FAILED;
131+ fds_prog->attach_type = attach_type;
132+@@ -228,13 +216,8 @@ static int init_mesh_prog(
133+
134+ static int init_mesh_prog_pin_file(struct mesh_prog_info *const fds_prog, const char *const pin_file_path)
135+ {
136+- int ret = EOK;
137+- ret = strcpy_s(fds_prog->pin_file_path, PATH_MAX, pin_file_path);
138+- if (ret != EOK) {
139+- macli_log(ERR, "system copy string failed!");
140+- return FAILED;
141+- }
142+-
143++ (void)memset(fds_prog->pin_file_path, 0x0, PATH_MAX);
144++ (void)strncpy(fds_prog->pin_file_path, pin_file_path, PATH_MAX - 1);
145+ return SUCCESS;
146+ }
147+
148+@@ -318,7 +301,7 @@ int get_u32_num(const char *const src, __u32 *const ret)
149+ const int convert_base = 10;
150+ char tmp_buff[TMP_BUF_SIZE] = {0};
151+ unsigned long tmp = strtoul(src, NULL, convert_base);
152+- if (sprintf_s(tmp_buff, sizeof(tmp_buff), "%lu", tmp) < 0) {
153++ if (snprintf(tmp_buff, sizeof(tmp_buff), "%lu", tmp) < 0) {
154+ macli_log(ERR, "system sprintf string failed!\n");
155+ return FAILED;
156+ }
157+@@ -332,12 +315,8 @@ int get_u32_num(const char *const src, __u32 *const ret)
158+
159+ int check_cidr(const char *const src, __u32 *const ip, __u32 *const mask)
160+ {
161+- int ret = EOK;
162+ char tmp_buff[MAX_CIDR_LENGTH] = {0};
163+- if ((ret = strcpy_s(tmp_buff, sizeof(tmp_buff), src)) != EOK) {
164+- macli_log(ERR, "system copy string failed! errno:%d\n", ret);
165+- return FAILED;
166+- }
167++ (void)strncpy(tmp_buff, src, sizeof(tmp_buff) - 1);
168+ char *ip_part = tmp_buff;
169+ char *p = strrchr(tmp_buff, '/');
170+ if (p == NULL)
171+@@ -358,12 +337,8 @@ int check_cidr(const char *const src, __u32 *const ip, __u32 *const mask)
172+
173+ int check_port(const char *const src, __u32 *const begin_port, __u32 *const end_port)
174+ {
175+- int ret = EOK;
176+ char tmp_buff[MAX_PORT_RANGE_LENGTH] = {0};
177+- if ((ret = strcpy_s(tmp_buff, sizeof(tmp_buff), src)) != EOK) {
178+- macli_log(ERR, "system copy string failed! errno:%d\n", ret);
179+- return FAILED;
180+- }
181++ (void)strncpy(tmp_buff, src, sizeof(tmp_buff) - 1);
182+ // support 80-90
183+ // support 80
184+ char *num1 = tmp_buff;
185+diff --git a/oncn-mda/cli_src/func/log.c b/oncn-mda/cli_src/func/log.c
186+index 9381c7e..b7b8287 100644
187+--- a/oncn-mda/cli_src/func/log.c
188++++ b/oncn-mda/cli_src/func/log.c
189+@@ -20,7 +20,7 @@ void ma_log(enum LOG_LEVEL level, const char *format, ...)
190+ va_list ap;
191+ va_start(ap, format);
192+ char fmt_str[MAX_FMT_STR_LENGTH] = {0};
193+- if (vsnprintf_s(fmt_str, sizeof(fmt_str), sizeof(fmt_str) - 1, format, ap) == -1) {
194++ if (vsnprintf(fmt_str, sizeof(fmt_str), format, ap) < 0) {
195+ va_end(ap);
196+ return;
197+ }
198+diff --git a/oncn-mda/cli_src/func/switch.c b/oncn-mda/cli_src/func/switch.c
199+index 416f00e..3974ba8 100644
200+--- a/oncn-mda/cli_src/func/switch.c
201++++ b/oncn-mda/cli_src/func/switch.c
202+@@ -365,7 +365,6 @@ static int check_file_access(const char *const config_path)
203+
204+ static int read_chain_config(const char *const config_path, struct sock_param *const filter_rules)
205+ {
206+- int ret;
207+ if (check_file_access(config_path) != SUCCESS)
208+ return FAILED;
209+ FILE *config_file = fopen(config_path, "r");
210+@@ -384,10 +383,10 @@ static int read_chain_config(const char *const config_path, struct sock_param *c
211+ if (*p == '#' || *p == '\0')
212+ continue;
213+
214+- if ((ret = strcpy_s(buf_save, sizeof(buf_save), buf)) != EOK) {
215+- macli_log(ERR, "system copy string failed! errno:%d\n", ret);
216+- continue;
217+- }
218++ (void)memset(buf_save, 0x0, sizeof(buf_save));
219++ (void)strncpy(buf_save, buf, sizeof(buf_save));
220++ buf_save[MAX_BUFSIZE - 1] = 0;
221++
222+ char *chain_argv[MAX_INPUT] = {0};
223+ int chain_argc = 0;
224+ if (parser_arg(buf, (int)strlen(buf), &chain_argc, chain_argv) != SUCCESS)
225+@@ -519,15 +518,12 @@ int do_enable(int argc, char *const *argv)
226+ char config_path[PATH_MAX] = {0};
227+ struct sock_param filter_rules = {0};
228+ struct mesh_service_info fds = {0};
229+- int ret;
230+
231+ if (set_rlimit() != SUCCESS)
232+ return FAILED;
233+
234+- if ((ret = strcpy_s(config_path, PATH_MAX, CONFIGFILE_PATH)) != EOK) {
235+- macli_log(ERR, "system copy string failed! errno:%d\n", ret);
236+- return FAILED;
237+- }
238++ (void)memset(config_path, 0x0, PATH_MAX);
239++ (void)strncpy(config_path, CONFIGFILE_PATH, PATH_MAX - 1);
240+
241+ if (enable_get_opt(argc, argv, config_path, &is_help) != SUCCESS)
242+ return FAILED;
243+diff --git a/oncn-mda/include/log.h b/oncn-mda/include/log.h
244+index bfc026f..86162e0 100644
245+--- a/oncn-mda/include/log.h
246++++ b/oncn-mda/include/log.h
247+@@ -8,7 +8,6 @@
248+ #include <stdlib.h>
249+ #include <time.h>
250+ #include <stdarg.h>
251+-#include "securec.h"
252+
253+ enum LOG_LEVEL { FATAL = 0, ERR, WARN, INFO, DEBUG };
254+
255+diff --git a/oncn-mda/include/macli.h b/oncn-mda/include/macli.h
256+index ebe8f69..1db7e7a 100644
257+--- a/oncn-mda/include/macli.h
258++++ b/oncn-mda/include/macli.h
259+@@ -20,7 +20,6 @@
260+ #include <netinet/in.h>
261+ #include <arpa/inet.h>
262+ #include <sys/stat.h>
263+-#include "securec.h"
264+ #include "data.h"
265+ #include "log.h"
266+
267+--
268+2.33.0
269+ 
Rv0.4.0.tar.gz→v0.4.1.tar.gz+0-0
Binary files do not support preview