From 9d08062cb785fa8aa27f18bdb0468f1a3f0d50ff Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 1 Feb 2026 00:33:21 +0000 Subject: [PATCH] fix: Update struct references from config to dynptr_cfg in README files --- src/features/dynptr/README.md | 9 +++++---- src/features/dynptr/README.zh.md | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/features/dynptr/README.md b/src/features/dynptr/README.md index bc4f843..05a0314 100644 --- a/src/features/dynptr/README.md +++ b/src/features/dynptr/README.md @@ -89,13 +89,13 @@ struct { __uint(type, BPF_MAP_TYPE_ARRAY); __uint(max_entries, 1); __type(key, __u32); - __type(value, struct config); + __type(value, struct dynptr_cfg); } cfg_map SEC(".maps"); SEC("tc") int dynptr_tc_ingress(struct __sk_buff *ctx) { - const struct config *cfg; + const struct dynptr_cfg *cfg; struct bpf_dynptr skb_ptr; /* Temporary buffers for slice (data may be copied here) */ @@ -136,7 +136,8 @@ int dynptr_tc_ingress(struct __sk_buff *ctx) return TC_ACT_OK; __u16 dport = bpf_ntohs(tcp->dest); - __u8 drop = (cfg->blocked_port && dport == cfg->blocked_port); + __u16 sport = bpf_ntohs(tcp->source); + __u8 drop = (cfg->blocked_port && (sport == cfg->blocked_port || dport == cfg->blocked_port)); /* Output variable-length event using ringbuf dynptr */ if (cfg->enable_ringbuf) { @@ -250,7 +251,7 @@ static int handle_event(void *ctx, void *data, size_t data_sz) int main(int argc, char **argv) { const char *ifname = NULL; - struct config cfg = { .blocked_port = 0, .snap_len = 64, .enable_ringbuf = 1 }; + struct dynptr_cfg cfg = { .blocked_port = 0, .snap_len = 64, .enable_ringbuf = 1 }; /* Parse arguments */ for (int i = 1; i < argc; i++) { diff --git a/src/features/dynptr/README.zh.md b/src/features/dynptr/README.zh.md index d068a96..d55f14d 100644 --- a/src/features/dynptr/README.zh.md +++ b/src/features/dynptr/README.zh.md @@ -89,13 +89,13 @@ struct { __uint(type, BPF_MAP_TYPE_ARRAY); __uint(max_entries, 1); __type(key, __u32); - __type(value, struct config); + __type(value, struct dynptr_cfg); } cfg_map SEC(".maps"); SEC("tc") int dynptr_tc_ingress(struct __sk_buff *ctx) { - const struct config *cfg; + const struct dynptr_cfg *cfg; struct bpf_dynptr skb_ptr; /* 用于切片的临时缓冲区(数据可能被复制到这里) */ @@ -136,7 +136,8 @@ int dynptr_tc_ingress(struct __sk_buff *ctx) return TC_ACT_OK; __u16 dport = bpf_ntohs(tcp->dest); - __u8 drop = (cfg->blocked_port && dport == cfg->blocked_port); + __u16 sport = bpf_ntohs(tcp->source); + __u8 drop = (cfg->blocked_port && (sport == cfg->blocked_port || dport == cfg->blocked_port)); /* 使用 ringbuf dynptr 输出可变长度事件 */ if (cfg->enable_ringbuf) { @@ -250,7 +251,7 @@ static int handle_event(void *ctx, void *data, size_t data_sz) int main(int argc, char **argv) { const char *ifname = NULL; - struct config cfg = { .blocked_port = 0, .snap_len = 64, .enable_ringbuf = 1 }; + struct dynptr_cfg cfg = { .blocked_port = 0, .snap_len = 64, .enable_ringbuf = 1 }; /* 解析参数 */ for (int i = 1; i < argc; i++) {