Problem
The addr_del function executes without error during testing, but it does not successfully remove the IP address from the network interface. The test reports ok, yet the IP address remains on the interface.
Test Code:
Before test I set up a veth peer
root@tcy-VMware-Virtual-Platform:~# sudo ip link add name vethhost type veth peer name vethhost1
root@tcy-VMware-Virtual-Platform:~# sudo ip link set vethhost up
root@tcy-VMware-Virtual-Platform:~# sudo ip link set vethhost1 up
#[tokio::test]
async fn test_addr_del() {
let link = link::link_by_name("vethhost").await.unwrap();
//let res = addr_del(link.header.index).await;
let res = addr_add(
link.header.index,
IpAddr::V4(Ipv4Addr::new(198, 19, 249, 211)),
16 // prefix_len
).await;
println!("res: {:?}", res);
}
#[tokio::test]
async fn test_addr_del() {
let link = link::link_by_name("vethhost").await.unwrap();
let res = addr_del(link.header.index).await;
println!("res: {:?}", res);
}
Code:
pub fn get_handle() -> anyhow::Result<Option<Handle>>{
let (connection, handle, _) = new_connection().map_err(|e| anyhow!("Failed to create rtnetlink connection: {}", e))?;
tokio::spawn(connection);
Ok(Some(handle))
}
pub async fn addr_add(index: u32, address: IpAddr, prefix_len: u8) -> anyhow::Result<()>{
let handle = get_handle()?.ok_or_else(|| anyhow!("Cannot get handle"))?;
let address_handle = handle.address();
address_handle.add(index, address, prefix_len).execute().await?;
Ok(())
}
pub async fn addr_del(index: u32, address: IpAddr) -> anyhow::Result<()>{
let handle = get_handle()?.ok_or_else(|| anyhow!("Cannot get handle"))?;
let address_handle = handle.address();
let mut req = address_handle.get().set_address_filter(address);
let mut msg = req.message_mut();
msg.header.index=index;
//let mut address_message = AddressMessage::default();
//address_message.header.index = index;
//address_handle.del(address_message).execute().await?;
address_handle.del(msg.clone()).execute().await?;
Ok(())
}
Result:
although can past the test , but actually it can't delete the ip address

I can add the ip ,but can't delete


you can see the ip still here. can you help me to solve this issue?
Problem
The
addr_delfunction executes without error during testing, but it does not successfully remove the IP address from the network interface. The test reportsok, yet the IP address remains on the interface.Test Code:
Before test I set up a veth peer
Code:
Result:
although can past the test , but actually it can't delete the ip address
I can add the ip ,but can't delete
you can see the ip still here. can you help me to solve this issue?