mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-29 09:53:24 +00:00
fix(net): 解决dhcp偶尔失败的问题 (#1205)
原因是unified init导致网卡顺序不一样了,原本固定写死id的方式不对.现在改用名称匹配 Signed-off-by: longjin <longjin@DragonOS.org>
This commit is contained in:
@ -45,10 +45,17 @@ pub fn net_init() -> Result<(), SystemError> {
|
|||||||
fn dhcp_query() -> Result<(), SystemError> {
|
fn dhcp_query() -> Result<(), SystemError> {
|
||||||
let binding = NET_DEVICES.write_irqsave();
|
let binding = NET_DEVICES.write_irqsave();
|
||||||
|
|
||||||
//由于现在os未实现在用户态为网卡动态分配内存,而lo网卡的id最先分配且ip固定不能被分配
|
let net_face = binding
|
||||||
//所以特判取用id为1的网卡(也就是virto_net)
|
.iter()
|
||||||
let net_face = binding.get(&1).ok_or(SystemError::ENODEV)?.clone();
|
.find(|(_, iface)| iface.name().starts_with("eth"))
|
||||||
|
.map(|(_, iface)| iface.clone());
|
||||||
|
|
||||||
|
if net_face.is_none() {
|
||||||
|
warn!("dhcp_query: No net device found!");
|
||||||
|
return Err(SystemError::ENODEV);
|
||||||
|
}
|
||||||
|
let net_face = net_face.unwrap();
|
||||||
|
log::debug!("dhcp_query: net_face={}", net_face.name());
|
||||||
drop(binding);
|
drop(binding);
|
||||||
|
|
||||||
// Create sockets
|
// Create sockets
|
||||||
|
Reference in New Issue
Block a user