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

How to query v4 and v6 networks #51

Open
kotronis-te opened this issue Dec 21, 2023 · 3 comments
Open

How to query v4 and v6 networks #51

kotronis-te opened this issue Dec 21, 2023 · 3 comments

Comments

@kotronis-te
Copy link
Contributor

Hi, I have two routes in BIRD's RIB, one for v4 prefix 10.1.1.0/24 and one for v6 prefix 2001:db8:3c4d::/48.
I am using birdwatcher's route_net endpoint, and specifically:

r.GET("/route/net/:net", endpoints.Endpoint(endpoints.RouteNet))

I have two questions:

  • For v4, I can only query without the netmask, like
/route/net/10.1.1.0

Is there a way to query with the netmask?

  • For v6, I cannot get the query to work at all, possibly due to the : format. Do you have a practical example of a working v6 query?
/route/net/2001:db8:3c4d::

Same question about the netmask too, as long as v6 works of course.

@kotronis-te
Copy link
Contributor Author

Btw for the netmask inclusion, it seems that validation is fine

func ValidatePrefixParam(value string) (string, error) {
	return ValidateLengthAndCharset(value, 80, "1234567890abcdef.:/")
}

however I am not sure how to pass the netmask, escaping the / does not seem to work. Maybe due to this underlying issue?
julienschmidt/httprouter#208

Also regarding the v6, it seems that by default the lookup is in the master table

func RouteNet(r *http.Request, ps httprouter.Params, useCache bool) (bird.Parsed, bool) {
	net, err := ValidatePrefixParam(ps.ByName("net"))
	if err != nil {
		return bird.Parsed{"error": fmt.Sprintf("%s", err)}, false
	}

	return bird.RoutesLookupTable(useCache, net, "master")
}

so it actually needs to use the /table/master6 extension for v6.

However, let me know if you have any ideas or working examples w.r.t. the netmask inclusion in the :net param...

@kotronis-te
Copy link
Contributor Author

Btw it seems that there is some v4/v6 distinction for bird and bird6 here:

return cmd + " where net.type = NET_IP" + IPVersion

This should not apply for bird2 right? I.e., the query should detect the version of the network and use that one, and not set everything on the application layer.

@kotronis-te
Copy link
Contributor Author

I issued a PR for the v6 problem when looking up routes (tested locally and works):
#52

However, it can probably be closed if you merge #30

I will issue a separate PR for the netmask endpoint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant