Skip to content

Get Route by Destination Address #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

ryansmick
Copy link

Get a route by its destination address. This PR updates the RouteGetRequest to add a generic type for the IP address, and adds two new functions to accept IPv4 and IPv6 addresses for the destination address. It also updates the RouteHandle's get function to remove the IP family, as it's now specified by the v4 and v6 functions on the RouteGetRequest. The implemented functionality matches the functionality of the ip route get cli command.

ryansmick added 2 commits May 31, 2023 21:53
Get a route by its destination address. This PR updates the RouteGetRequest to add a generic type for the IP address, and adds two new functions to accept IPv4 and IPv6 destination addresses for the destination address. It also updates the RouteHandle's get function to remove the IP family, as it's now specified by the v4 and v6 functions on the RouteGetRequest. The implemented functionality matches the functionality of the `ip route get` cli command.
Change usages of Vec::from() to .to_vec() to match style of other code in this project.
Copy link
Member

@cathay4t cathay4t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes too many public API while you can avoid it by using

    pub fn destination_address(&mut self) -> &mut self {
        self.destination_address = Some(destination_address);
        let octets = destination_address.octets().to_vec();
        self.message.header.destination_prefix_length =
            (octets.len() * 8) as u8;
        self.message.nlas.push(Nla::Destination(octets));

        self
    }

When patching a library, we should try our best to maintain API stability.

@cathay4t
Copy link
Member

Meanwhile, have you test your patch? My old code indicate NETLINK_GET_STRICT_CHK via libc::setsockopt() is required to enable kernel space filtering.

@cathay4t
Copy link
Member

It has been a while with a lot code changed in this crate. Please rebase your code and open new pull request if you still want to work on this.

@cathay4t cathay4t closed this Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants