Skip to content

Conversation

sparkzky
Copy link
Collaborator

此PR为OSPP-DragonOS 桥接网络支持

已实现:

  1. 虚拟网络设备驱动开发
    • 在 DragonOS 中实现 Bridge,支持虚拟网桥创建、MAC 地址学习与二层转发。
    • 实现 veth pair 驱动,支持连接到 Bridge。
  2. 网络隔离与命名空间支持
    • 补充 Network Namespace 功能。
  3. 实现 NAT 功能(SNAT/DNAT)
  4. 补充完善路由子系统功能
    • 增强路由子系统,支持多 Namespace 独立路由表。
    • 实现虚拟接口(veth、Bridge)的路由规则更新与流量转发。
  5. 实现netlink socket框架以及部分协议

待补充:

  • 路由is_my_ip实现有误
  • 将arp查询过程从smotcp中移动出来,由DragonOS记录相关邻居
  • netlink支持创建veth和bridge设备,支持更新命名空间
  • test-router使用多命名空间进行测试
  • 规则路由
  • netlink 支持展示,更新路由信息
  • 文档

Signed-off-by: sparkzky <[email protected]>
- Removed the default_iface parameter.
- Introduced a new NAPI module to manage network polling and scheduling.
- Updated the Iface trait to include a napi_struct method for NAPI support.
- Modified Veth network interfaces to integrate with the new NAPI structure.
- Refactored the Router implementation to remove unnecessary polling threads and wait queues.
- Updated NetNamespace to manage a list of bridge devices.
- Cleaned up various unused methods and comments across network-related files.

Signed-off-by: sparkzky <[email protected]>
@github-actions github-actions bot added the enhancement New feature or request label Sep 22, 2025
@fslongjin
Copy link
Member

bugbot run

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

// 或者需要遍历 reverse_mappings 找到 value 为 key 的条目并删除。
// 为简单起见,这里只清理主表。更健壮的实现需要双向链接或引用计数。
log::info!("Cleaned up expired connection for key: {:?}", key);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Time Travel Bug and Memory Leak

The cleanup_expired method has two issues: duration_since().unwrap() can panic if mapping.last_seen() is in the future relative to now, and it causes a memory leak by only cleaning the mappings table, leaving reverse_mappings with stale entries.

Fix in Cursor Fix in Web


let chunks = unsafe { from_raw_parts(byte_buffer.as_ptr() as *const T, 1) };
let data = &chunks[0];
return Ok(data);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Unsafe Cast and Excessive Logging

The convert_one_from_raw_buf function performs an unsafe cast from a byte slice to &T without verifying proper alignment for type T. This can lead to undefined behavior, crashes, or data corruption. Separately, a log::info! statement in this function will cause excessive logging in production.

Fix in Cursor Fix in Web

.inner
.lock()
.bridge_common_data
.as_ref()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Weak Reference Upgrade Panic

The recv_from_peer method panics if its self_iface_ref weak reference has been dropped. Calling upgrade().unwrap() on a Weak reference can lead to a crash if the underlying VethInterface is no longer alive.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants