Skip to content
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

Libp2p fails to determine default route on FreeBSD #973

Closed
Stebalien opened this issue Jul 2, 2020 · 7 comments
Closed

Libp2p fails to determine default route on FreeBSD #973

Stebalien opened this issue Jul 2, 2020 · 7 comments
Labels
good first issue Good issue for new contributors help wanted Seeking public contribution on this issue kind/bug A bug in existing code (including security flaws) status/ready Ready to be worked

Comments

@Stebalien
Copy link
Member

On FreeBSD, netroute.Router.Route('0.0.0.0') returns an error instead of returning the default route. We need some other way to determine the default route. We could just try looking up a well known IP address.

if r, err := netroute.New(); err != nil {
log.Debugw("failed to build Router for kernel's routing table", "err", err)
} else {
if _, _, localIPv4, err := r.Route(net.IPv4zero); err != nil {
log.Debugw("failed to fetch local IPv4 address", "err", err)
} else {
maddr, err := manet.FromIP(localIPv4)
if err == nil {
h.localIPv4Addr = maddr
}
}
if _, _, localIpv6, err := r.Route(net.IPv6unspecified); err != nil {
log.Debugw("failed to fetch local IPv6 address", "err", err)
} else {
maddr, err := manet.FromIP(localIpv6)
if err == nil {
h.localIPv6Addr = maddr
}
}
}

@Stebalien Stebalien added the kind/bug A bug in existing code (including security flaws) label Jul 2, 2020
@willscott
Copy link
Contributor

what error do you get? I'm guessing you're able to load the routing table, but asking for the route is failing?

@Stebalien
Copy link
Member Author

"no route found for 0.0.0.0"

@willscott
Copy link
Contributor

just to confirm, you're specifically referring to FreeBSD, and not macs, right?

@Stebalien
Copy link
Member Author

I am. I haven't tested on MacOS.

@jacobheun jacobheun added help wanted Seeking public contribution on this issue status/ready Ready to be worked labels Jul 10, 2020
@willscott
Copy link
Contributor

spun up a FreeBSD VM and can't reproduce:

FreeBSD 12.1-RELEASE r354233 GENERIC  amd64

The RIB's returned by the system call are:

rtNFO: &{10.0.2.15/0 0.0.0.0/0 10.0.2.2 10.0.2.15 0 1 0}
rtNFO: &{10.0.2.15/32 10.0.2.0/24 <nil> 10.0.2.15 0 1 0}
rtNFO: &{127.0.0.1/32 10.0.2.15/32 <nil> 127.0.0.1 0 2 0}
rtNFO: &{127.0.0.1/32 127.0.0.1/32 <nil> 127.0.0.1 0 2 0}
rtNFO: &{::1/128 ::1/128 <nil> ::1 0 2 0}
rtNFO: &{fe80::1/128 fe80::/64 <nil> fe80::1 0 2 0}
rtNFO: &{fe80::1/128 fe80::1/128 <nil> fe80::1 0 2 0}

(em0 network interface 10.0.2.15/24 with gw 10.0.2.2)
default route works as expected in this case.

I think to debug / reproduce, the most useful thing to do would be to modify here to insert the line fmt.Printf("rtNFO: %v", routeInfo)
so that we can try to understand what's happening with regards to the parsed routing table.

@MarcoPolo MarcoPolo added the good first issue Good issue for new contributors label Jun 19, 2023
@gammazero
Copy link
Contributor

Cannot reproduce
FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64

Printing route info here shows results similary to above. Default route is found.

Maybe this issue was reported on a host that only has IPv6 addresses and no default route was found for 0.0.0.0?

In either case, this does not seem to be a defect (or has not been for a long time), so suggest closing this issue.

@Stebalien
Copy link
Member Author

It had an IPv4 address. But this was a long time ago on a machine that no longer exists (and was probably in a FreeBSD jail). Given that nobody can reproduce, I'm just going to close this.

@Stebalien Stebalien closed this as not planned Won't fix, can't repro, duplicate, stale Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good issue for new contributors help wanted Seeking public contribution on this issue kind/bug A bug in existing code (including security flaws) status/ready Ready to be worked
Projects
None yet
Development

No branches or pull requests

5 participants