代码拉取完成,页面将自动刷新
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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。