Skip to content

Commit

Permalink
refine code
Browse files Browse the repository at this point in the history
  • Loading branch information
ssrlive committed Oct 12, 2023
1 parent 1cc06c8 commit bd7ce07
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/platform/linux/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,12 @@ impl Device {
return Err(Error::InvalidQueuesNumber);
}

let iff_no_pi = IFF_NO_PI as c_short;
let iff_multi_queue = IFF_MULTI_QUEUE as c_short;
let packet_information = config.platform.packet_information;
req.ifr_ifru.ifru_flags = device_type
| if config.platform.packet_information {
0_i16
} else {
IFF_NO_PI as c_short
}
| if queues_num > 1 {
IFF_MULTI_QUEUE as c_short
} else {
0_i16
};
| if packet_information { 0 } else { iff_no_pi }
| if queues_num > 1 { iff_multi_queue } else { 0 };

for _ in 0..queues_num {
let tun = Fd::new(libc::open(b"/dev/net/tun\0".as_ptr() as *const _, O_RDWR))
Expand Down

0 comments on commit bd7ce07

Please sign in to comment.