Skip to content

Commit b0c58a6

Browse files
committed
integration-test: Try using ip commands
1 parent 6270e6a commit b0c58a6

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

test/integration-test/src/utils.rs

+30-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::{
44
ffi::CStr,
55
io,
66
net::Ipv4Addr,
7-
process,
7+
process::{self, Command},
88
sync::atomic::{AtomicU64, Ordering},
99
};
1010

@@ -67,7 +67,35 @@ impl NetNsGuard {
6767
unsafe { netlink_set_link_up(lo_idx as i32) }
6868
.unwrap_or_else(|e| panic!("Failed to set `lo` up in netns {}: {e}", name));
6969

70-
setup_test_veth_pair();
70+
//setup_test_veth_pair();
71+
Command::new("ip")
72+
.args(&[
73+
"link",
74+
"add",
75+
"dev",
76+
IF_NAME_1.to_str().unwrap(),
77+
"type",
78+
"veth",
79+
"peer",
80+
"name",
81+
IF_NAME_2.to_str().unwrap(),
82+
])
83+
.status()
84+
.unwrap_or_else(|e| {
85+
panic!(
86+
"Failed to set up veth pair ({}, {}): {e}",
87+
IF_NAME_1.to_string_lossy(),
88+
IF_NAME_2.to_string_lossy()
89+
)
90+
})
91+
.exit_ok()
92+
.unwrap_or_else(|e| {
93+
panic!(
94+
"Failed to set up veth pair ({}, {}): {e}",
95+
IF_NAME_1.to_string_lossy(),
96+
IF_NAME_2.to_string_lossy()
97+
)
98+
});
7199

72100
let if_idx1 = unsafe { if_nametoindex(IF_NAME_1.as_ptr()) };
73101
if if_idx1 == 0 {

0 commit comments

Comments
 (0)