8 Star 0 Fork 6

src-anolis-os/smc-tools

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
1001-smc-tools-1.0.0-anolis-smc-ebpf-fix-issues-in-clearing-ports-and-configurin.patch 1.63 KB
一键复制 编辑 原始数据 按行查看 历史
From a08688a471c93388d2418a68782df5957d440842 Mon Sep 17 00:00:00 2001
From: Wen Gu <guwen@linux.alibaba.com>
Date: Wed, 11 Dec 2024 20:54:10 +0800
Subject: [PATCH] smc-ebpf: fix issues in clearing ports and configuring ipv4
address
This fixes two issues:
- Unable to successfully delete multiple port records. Fix it.
e.g.
smc-ebpf policy clear
Error: expected key or value, got: 0x00
- The variable in ipv4_{add|delete}_map() is used incorrectly,
but this has no real impact on the functionality. Fix it BTW.
Signed-off-by: Wen Gu <guwen@linux.alibaba.com>
---
smc-ebpf | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/smc-ebpf b/smc-ebpf
index 60584ac..ac876ce 100755
--- a/smc-ebpf
+++ b/smc-ebpf
@@ -121,7 +121,7 @@ ipv4_add_map() {
local ipv4_mask="$2"
local mode="$3"
- ipv4_hex=$(ipv4_aton "$ip")
+ ipv4_hex=$(ipv4_aton "$ipv4")
if [[ ${ipv4_hex} == "error" ]]; then
echo "IP format is incorrect. Only IPv4 addresses are accepted"
exit 1
@@ -202,7 +202,7 @@ ipv4_delete_map() {
local ipv4_hex
local ipv4_mask="$2"
- ipv4_hex=$(ipv4_aton "$ip")
+ ipv4_hex=$(ipv4_aton "$ipv4")
if [[ ${ipv4_hex} == "error" ]]; then
echo "IP format is incorrect. Only IPv4 addresses are accepted"
exit 1
@@ -439,8 +439,8 @@ policy_delete() {
# clear all config
policy_clear() {
# clear port policy
- local keys=$(${BPFT} map dump name ${PORT_POLICY} \
- | grep -oP '(?<= "key": )\d+')
+ local keys=($(${BPFT} map dump name ${PORT_POLICY} \
+ | grep -oP '(?<= "key": )\d+'))
for key in "${keys[@]}"; do
${BPFT} map delete name ${PORT_POLICY} key $(endian $key 2)
done
--
2.43.5
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-anolis-os/smc-tools.git
git@gitee.com:src-anolis-os/smc-tools.git
src-anolis-os
smc-tools
smc-tools
a8

搜索帮助