Skip to content

IPv6 route remove does not seem to work #38

@AaronKutch

Description

@AaronKutch

Using

net-route = "0.4"
tun = { version = "0.7", features = ["async"] }
netdev = "0.32"
    let addr = "10.0.0.1".parse().unwrap();
    let cidr = 32;
    //let addr = "fd00::1".parse().unwrap();
    //let cidr = 128;

    let tun_name = "test";
    let device = tun::create_as_async(&tun::configure().tun_name(tun_name).up()).unwrap();

    let interfaces = netdev::get_interfaces();
    let ni = {
        if let Some(name) = interfaces.iter().find(|x| x.name == tun_name) {
            name
        } else {
            // in some cases
            interfaces
                .iter()
                .find(|x| x.friendly_name.as_deref() == Some(tun_name))
                .unwrap()
        }
    };
    let ifindex = ni.index;

    let handle = net_route::Handle::new().unwrap();

    handle
        .add(&net_route::Route::new(addr, cidr).with_ifindex(ifindex))
        .await
        .unwrap();

    handle
        .delete(&net_route::Route::new(addr, cidr).with_ifindex(ifindex))
        .await
        .unwrap();

    drop(device);

The version adding and deleting an IPv4 address works fine for me on Linux, but with an IPv6 address the deletion function fails with

called `Result::unwrap()` on an `Err` value: Custom { kind: NotFound, error: "No matching route found to delete" }

I don't know what is happening here, running ip route del ... dev test works for both addresses, something this library is doing with IPv6 is not working. This is happening on more than one kind of Linux distribution for me, so I think it is some common issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions