mirror of
https://mirror.suhoan.cn/https://github.com/EasyTier/EasyTier.git
synced 2025-12-14 05:37:23 +08:00
netlink shoud remove route only when ifidx is same
This commit is contained in:
@@ -377,16 +377,18 @@ impl IfConfiguerTrait for NetlinkIfConfiger {
|
|||||||
|
|
||||||
async fn remove_ipv4_route(
|
async fn remove_ipv4_route(
|
||||||
&self,
|
&self,
|
||||||
_name: &str,
|
name: &str,
|
||||||
address: Ipv4Addr,
|
address: Ipv4Addr,
|
||||||
cidr_prefix: u8,
|
cidr_prefix: u8,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let routes = Self::list_routes()?;
|
let routes = Self::list_routes()?;
|
||||||
|
let ifidx = NetlinkIfConfiger::get_interface_index(name)?;
|
||||||
|
|
||||||
for msg in routes {
|
for msg in routes {
|
||||||
let other_route: Route = msg.clone().into();
|
let other_route: Route = msg.clone().into();
|
||||||
if other_route.destination == std::net::IpAddr::V4(address)
|
if other_route.destination == std::net::IpAddr::V4(address)
|
||||||
&& other_route.prefix == cidr_prefix
|
&& other_route.prefix == cidr_prefix
|
||||||
|
&& other_route.ifindex == Some(ifidx)
|
||||||
{
|
{
|
||||||
send_netlink_req_and_wait_one_resp(RouteNetlinkMessage::DelRoute(msg), true)?;
|
send_netlink_req_and_wait_one_resp(RouteNetlinkMessage::DelRoute(msg), true)?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
|||||||
Reference in New Issue
Block a user