Skip to content

route: allow IPv6 gateway in IPv4 route #90

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hack3ric
Copy link
Contributor

Linux supports it by using RTA_VIA instead of RTA_GATEWAY. Since it essentially acts as gateway, we extend the current API to allow it.

@cathay4t
Copy link
Member

I don't link breaking API for this corner case. Please add RouteMessageBuilder<Ipv4Addr>::gateway6().

If possible, please also provide example ip command showing it actual working.

@rwestphal
Copy link
Contributor

@hack3ric Hi! I'm also interested in this. Just wondering if you're planning to update this PR? If not, I might go ahead and open one myself. I'll also need the conditional Gateway/Via attributes to support MPLS routes, but I don't want to open a PR which will conflict with this one.

@hack3ric
Copy link
Contributor Author

hack3ric commented Apr 6, 2025

Sure, I'll update the PR after the weekend.

@hack3ric hack3ric force-pushed the extended-next-hop branch from 355ccce to a09ba72 Compare April 7, 2025 05:03
@rwestphal
Copy link
Contributor

@hack3ric I'm sorry, but it looks like there's a merge conflict now that #99 has been merged. Could you rebase this on top of master? (it's a simple conflict in the use declarations).

@hack3ric hack3ric force-pushed the extended-next-hop branch from a09ba72 to c86090f Compare April 25, 2025 23:01
@hack3ric
Copy link
Contributor Author

@rwestphal Done

@@ -168,6 +168,13 @@ impl RouteMessageBuilder<Ipv4Addr> {
.push(RouteAttribute::Gateway(RouteAddress::Inet(addr)));
self
}

pub fn gateway6(mut self, addr: Ipv6Addr) -> Self {
Copy link
Member

@cathay4t cathay4t Apr 30, 2025

Choose a reason for hiding this comment

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

Since we already patched gateway() to support assigning ipv6 gateway to a ipv4 route, we do not need this function anymore.

For precise control, maybe change this function to pub fn via(mut self, via: RouteVia) -> Self.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, anyone who wants an IPv4 route with an IPv6 nexthop should probably be using RouteMessageBuilder<IpAddr>. I think this method could be dropped.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry for the late reply. Changed the function name to via, as IMO it would be less consistent in regards of functionality between the Ipv4Addr and IpAddr builders, if removing this completely.

@cathay4t
Copy link
Member

cathay4t commented May 5, 2025

@hack3ric ping

@hack3ric hack3ric force-pushed the extended-next-hop branch from c86090f to afb6018 Compare May 7, 2025 14:08
Linux supports it by using RTA_VIA instead of RTA_GATEWAY. Since it essentially acts as gateway, we extend the current API to allow it.
@hack3ric hack3ric force-pushed the extended-next-hop branch from afb6018 to ea13ce2 Compare May 7, 2025 14:10
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.

3 participants