已合并
knet合并kbdtoe api #185
penghd创建于 6月12日
knet合并kbdtoe api #185
已合并
penghd创建于 6月12日
penghd
penghd
6月12日

当前PR是否有AI参与:

[x] 否

[ ] 是
__1. AI Agent 平台:
__2. AI 模型:
__3. Prompt上下文 :

PR功能描述 / 为什么需要这个合入**:

 kbdtoe合并knet,源码放置src/knet/api目录下,新增kbdtoe的编译,生成libkbdtoe.so,编译命令:python3 build.py Release kbdtoe rpm

该PR关联的issue

(格式为fixes #<issue号>, 或者resolves #<issue号>): fixes #

希望检视人员了解:

likedislike
Pull Request已成功合入, 合并人@openeuler-ci-bot
(感谢 penghd 的贡献)
penghdpenghd
6月12日 创建了 pull request,commit c42c4f17
openeuler-ci-botopeneuler-ci-bot成员
6月12日 将hlinbo,shw030915,Gao_Victor,qmyyxtl,caowaterman设为审查人
openeuler-ci-botopeneuler-ci-bot成员
6月12日 添加了label:sig/sig-UB-ServiceCore
openeuler-ci-bot
openeuler-ci-bot成员
6月12日 评论:

Welcome To openEuler Community

Hey @penghd , thanks for your contribution to the community.

Bot Usage Manual

I'm the Bot here serving you. You can find the instructions on how to interact with me at Here . That means you can comment below every pull request or issue to trigger Bot Commands.

Contact Guide

If you have any questions, please contact the SIG: sig-UB-ServiceCore ,
and any of the maintainers: @Gao_Victor, @caowaterman, @hlinbo, @qmyyxtl, @shw030915 ,
and any of the committers: @Zhao_Py, @lijie_printk, @xhpintell .

likedislike
openeuler-ci-botopeneuler-ci-bot成员
6月12日 添加了label:openeuler-cla/yes
openeuler-ci-botopeneuler-ci-bot成员
6月12日 添加了label:stat/needs-squash
openeuler-ci-botopeneuler-ci-bot成员
6月12日 添加了label:ci_processing
openeuler-ci-botopeneuler-ci-bot成员
6月12日 添加了label:docs_ci_running
openeuler-ci-bot
openeuler-ci-bot成员
6月12日 评论:

门禁正在运行, 您可以通过以下链接查看实时门禁检查结果.
若您对门禁结果含义不清晰或者遇到问题不知如何解决,可参考门禁指导手册
门禁入口及编码规范检查: multiarch/openeuler/trigger/knet/606/console

likedislike
openeuler-ci-bot
openeuler-ci-bot成员
6月12日 评论:

✅ 跳过 docs ci 检查,没有需要检查的文档文件

likedislike
openeuler-ci-botopeneuler-ci-bot成员
6月12日 删除了label:docs_ci_running
openeuler-ci-botopeneuler-ci-bot成员
6月12日 添加了label:docs_ci_successful
xhpintell
xhpintell成员
6月12日 评论:

/ai review

likedislike
atomgit-bot
atomgit-bot
6月12日 评论:

代码审查

本次 PR 涉及 kbdtoe 模块的多项功能改动,整体代码质量存在较多问题。亮点方面,代码结构清晰,部分模块(如 libdtoe_send.c)有正确的 NULL 检查和错误处理可作为参考模板。但严重问题集中:3 个 critical 级别缺陷(logrotate BOM 导致日志轮转失效、重复解锁 mutex 触发未定义行为、空指针解引用导致崩溃)必须在上线前修复,否则将直接影响生产环境稳定性;2 个 high 级别问题(连接槽位泄漏和内存池初始化未检查)会导致长时间运行后的资源耗尽。建议在修复所有 critical 和 high 问题后重新提交 review,并对错误处理路径进行系统性排查。

类型 数量
🔴 阻塞 5 处
🟡 建议 1 处

⛔ 需要修改

likedislike
不准确?
atomgit-bot
atomgit-bot6月12日进行代码检视2
conf/logrotate/kbdtoe
已过期
@@ -0,0 +1,0 @@
1+/var/log/kbdtoe/kbdtoe.log
atomgit-bot
atomgit-bot6月12日评论:

🔴 Critical

文件开头存在 UTF-8 BOM 字符(U+FEFF),logrotate 会将其视为路径的一部分,将 /var/log/kbdtoe/kbdtoe.log 错误解析为 /var/log/kbdtoe/kbdtoe.log,文件路径无效,logrotate 将找不到目标日志文件,轮转完全不生效。

改动建议
1
- /var/log/kbdtoe/kbdtoe.log
1
+ /var/log/kbdtoe/kbdtoe.log
应用建议
likedislike
不准确?
System
系统消息系统
6月12日 评论:

changed this line on 8f5dea76 view diff detail

atomgit-bot
atomgit-bot6月12日进行代码检视1
src/knet/api/kbdtoe_api/src/kbdtoe.c
@@ -0,0 +486,4 @@
486+ ret = flexda_dtoe_start_conn_offload(sockfd, &in, &out);
487+ if (ret != 0) {
488+ KBDTOE_ERR("kbdtoe start offload failed, sockfd:%d, ret:%d", sockfd, ret);
489+ return DTOE_FAIL;
atomgit-bot
atomgit-bot6月12日评论:

🟠 High Priority

conn 已在 line 470 从 free_conns 中移除,但 flexda_dtoe_start_conn_offload 失败后直接 return DTOE_FAIL,未将 conn 插回 free_conns,导致该连接槽位永久丢失。长时间运行会耗尽连接池,新连接无法卸载。

likedislike
不准确?
atomgit-bot
atomgit-bot6月12日进行代码检视1
src/knet/api/kbdtoe_api/src/kbdtoe_mempool_mr.c
@@ -0,0 +212,4 @@
212+ BuddyBlock* bb = (BuddyBlock*)addr;
213+ bb->next = g_free_lists[level];
214+ g_free_lists[level] = bb;
215+ g_buddy_total_alloc -= size ;
atomgit-bot
atomgit-bot6月12日评论:

🟡 Medium Priority

buddy_free 第 184-211 行合并 buddy 块后,size 已倍增为合并后的大小(如 2S、4S),但第 215 行 g_buddy_total_alloc -= size 减去的是合并后的大小。被合并的 buddy 块此前释放时已将其 size 从 g_buddy_total_alloc 中减去,导致重复扣减,g_buddy_total_alloc(size_t 无符号)下溢为一个极大值,kbdtoe_mempool_stats 输出的统计数据将完全错误。

likedislike
不准确?
atomgit-bot
atomgit-bot6月12日进行代码检视1
src/knet/api/kbdtoe_api/src/kbdtoe_mempool_mr.c
@@ -0,0 +353,4 @@
353+ for (int i = 0; i < NUM_SLAB_CACHES; ++i) {
354+ g_slab_caches[i].obj_size = SLAB_OBJ_SIZES[i];
355+ g_slab_caches[i].slabs = NULL;
356+ pthread_mutex_init(&g_slab_caches[i].lock, NULL);
atomgit-bot
atomgit-bot6月12日评论:

🟠 High Priority

第 356 行 pthread_mutex_init(&g_slab_caches[i].lock, NULL) 的返回值未被检查。若 mutex 初始化失败(如系统资源不足),函数仍返回 SUCCESS(0),调用方会认为内存池初始化成功。此后对该 mutex 的 lock/unlock 操作行为未定义,可能导致死锁或崩溃。对比 buddy_init(第 114 行)对 g_buddy_lock 的 pthread_mutex_init 做了完整的错误检查和回滚处理。

likedislike
不准确?
atomgit-bot
atomgit-bot6月12日进行代码检视1
src/knet/api/kbdtoe_api/src/kbdtoe_log.c
@@ -0,0 +154,4 @@
154+ 
155+ ret = pthread_setcanceltype(orig_cancel_type, NULL);
156+ if (ret != 0) {
157+ PRINT_ERR("Pthread restore cancelstate failed, ret %d", ret);
atomgit-bot
atomgit-bot6月12日评论:

🔴 Critical

第 147 行已调用 pthread_mutex_unlock 释放 g_log_mutex,第 153 行 pthread_cleanup_pop(1) 会执行清理函数 kbdtoe_log_lock_unlock,该函数再次调用 pthread_mutex_unlock。对于 PTHREAD_MUTEX_INITIALIZER 初始化的默认互斥锁,重复解锁属于未定义行为,可能导致死锁、崩溃或数据损坏。正常路径应使用 pthread_cleanup_pop(0) 不执行清理函数,清理函数仅为线程取消场景保留。

同一段代码其他问题

likedislike
不准确?
atomgit-bot
atomgit-bot6月12日进行代码检视1
src/knet/api/kbdtoe_api/src/libdtoe_recv.c
@@ -0,0 +27,4 @@
27+ libdtoe_conn_s *conn = (libdtoe_conn_s *)get_conn_by_fd(fd);
28+ libdtoe_recv_desc_s *recv_desc = NULL;
29+ recv_desc = &conn->recv_desc;
30+ if (conn->offload_status == DTOE_OFFLOAD_START) {
atomgit-bot
atomgit-bot6月12日评论:

🔴 Critical

第 27 行 get_conn_by_fd(fd) 返回值直接强转为 libdtoe_conn_s *,第 29 行立即解引用 &amp;conn-&gt;recv_desc,第 30 行访问 conn-&gt;offload_status,均未检查 NULL。若 fd 无效或连接不存在,必将触发段错误崩溃。对比同批 libdtoe_send.c 第 40-46 行,kbdtoe_write/kbdtoe_writev 均有正确的 NULL 检查。

改动建议
30
- if (conn->offload_status == DTOE_OFFLOAD_START) {
30
+ libdtoe_conn_s *conn = (libdtoe_conn_s *)get_conn_by_fd(fd);
31
+ if (conn == NULL) {
32
+ KBDTOE_ERR("kbdtoe read, conn is null for fd %d", fd);
33
+ errno = EINVAL;
34
+ return -1;
35
+ }
36
+ libdtoe_recv_desc_s *recv_desc = NULL;
37
+ recv_desc = &conn->recv_desc;
应用建议
likedislike
不准确?
penghdpenghd
6月12日 update merge request[project id: 8744874, iid: 185, commit_id: 4079e42867f643fe61aa8eebd71f8dacab32c99a] virtual merging success
penghdpenghd
6月12日 强制推送  1 个提交:8f5dea76-compile kbdtoe
penghdpenghd
6月12日 update merge request[project id: 8744874, iid: 185, commit_id: b78eefa8a666cc0df66e9628c6ad186eadc365c0] virtual merging success
openeuler-ci-bot
openeuler-ci-bot成员
6月12日 评论:

CLA Signature Pass

penghd, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
openeuler-ci-botopeneuler-ci-bot成员
6月12日 删除了label:docs_ci_successful
openeuler-ci-botopeneuler-ci-bot成员
6月12日 添加了label:docs_ci_running
openeuler-ci-bot
openeuler-ci-bot成员
6月12日 评论:

✅ 跳过 docs ci 检查,没有需要检查的文档文件

likedislike
openeuler-ci-botopeneuler-ci-bot成员
6月12日 删除了label:docs_ci_running
openeuler-ci-botopeneuler-ci-bot成员
6月12日 添加了label:docs_ci_successful
openeuler-ci-bot
openeuler-ci-bot成员
6月12日 评论:

门禁正在运行, 您可以通过以下链接查看实时门禁检查结果.
若您对门禁结果含义不清晰或者遇到问题不知如何解决,可参考门禁指导手册
门禁入口及编码规范检查: multiarch/openeuler/trigger/knet/607/console

likedislike
openeuler-ci-botopeneuler-ci-bot成员
6月12日 删除了label:ci_processing
openeuler-ci-bot
openeuler-ci-bot成员
6月12日 评论:
Check Name Build Result Build Details
check_sca SUCCESS #606
check_code SUCCESS
check_package_license WARNING
x86_64 check_build SUCCESS #594
aarch64 check_build FAILED #586
likedislike
openeuler-ci-botopeneuler-ci-bot成员
6月12日 添加了label:ci_processing
openeuler-ci-botopeneuler-ci-bot成员
6月12日 添加了label:ci_failed
openeuler-ci-bot
openeuler-ci-bot成员
6月12日 评论:
likedislike
xhpintell
xhpintell成员
6月12日 评论:

/lgtm
/approve

likedislike
openeuler-ci-botopeneuler-ci-bot成员
6月12日 添加了label:approvedlgtm
openeuler-ci-bot
openeuler-ci-bot成员
6月12日 评论:

Review Code Feedback

  • The label lgtm, approved was added to this pull request. It means that xhpintell reviewed the code changes. 👋
Tips
  • If this pull request is not merged while all conditions are met, comment /check-pr to try again. 😄
likedislike
openeuler-ci-botopeneuler-ci-bot成员
6月12日 合入了pull request,合并节点 SHA:f76ebafa79d79299bc592e66d68845c463baebca