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

Router advertisement & Router sollicitation #126

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

christophefontaine
Copy link
Contributor

@christophefontaine christophefontaine commented Jan 14, 2025

Add router advertisement support, with basic configuration (lifetime, priority, interval, but no DNS, etc.).
Also answer to router sollicitation messages.

Depends on PR #112

@christophefontaine christophefontaine marked this pull request as ready for review January 14, 2025 16:38
@@ -5,4 +5,5 @@ cli_src += files(
'address.c',
'nexthop.c',
'route.c',
'router_advertisement.c',
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe s/router_advertisement.c/ra.c/ or at least router_advert.c?


ret = CLI_COMMAND(
IP6_SHOW_CTX(root),
"router-advertisment [IFACE]",
Copy link
Collaborator

Choose a reason for hiding this comment

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

s/advertisment/advertisement/

But I think I prefer router-advert. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

even shorter ra ? Do you think it may be possible to have "short commands" in the CLI ?
So we could use both ra and router-advertisement ? (or to even accept partial commands ?)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes you can have token alternatives separated by pipes (without spaces)

"ra|router-advert|... [IFACE]"

No partial marching though. You need to explicitly list all alternatives to allow libecoli to build a token graph.

Comment on lines +125 to +126
}
void ndp_router_sollicit_input_cb(struct rte_mbuf *m) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

missing empty line

@@ -89,6 +96,7 @@ static struct rte_node_register icmp6_input_node = {
[ICMP6_OUTPUT] = "icmp6_output",
[NEIGH_SOLICIT] = "ndp_ns_input",
[NEIGH_ADVERT] = "ndp_na_input",
[ROUTER_SOLICIT] = "control_output",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there no point in having an ndp_rs_input node for consistency with the other ndp types? You could perform sanity checks before sending the packet to slow path.

ev_base, -1, EV_PERSIST | EV_FINALIZE, send_ra_cb, iface
);
} else if (event == IFACE_EVENT_PRE_REMOVE) {
event_free(ra_conf[iface->id].timer);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure about that but should you call event_free_finalize?

Comment on lines +245 to +247
ra_conf[iface->id].timer = event_new(
ev_base, -1, EV_PERSIST | EV_FINALIZE, send_ra_cb, iface
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I never recall this libevent api... Is this adding a 1s timer or do you need to "enable" it afterwards?

ra->cur_hoplim = IP6_DEFAULT_HOP_LIMIT; // Default TTL for this network
ra->managed_addr = 0; // DHCPv6 is available
ra->other_config = 0; // DNS available, ...
ra->lifetime = rte_cpu_to_be_16(5); // Not a default router
Copy link
Collaborator

Choose a reason for hiding this comment

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

is that in seconds? maybe worth a #define

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, while the lifetime is in seconds, the other parameters below are in milliseconds...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The defines are created in the next commit, when the configuration is settable by the user.

	ra_conf[req->iface_id].interval = RA_DEFAULT_INTERVAL;
	ra_conf[req->iface_id].lifetime = RA_DEFAULT_LIFETIME;
	ra_conf[req->iface_id].preference = RA_DEFAULT_PREFERENCE;

I'll use them in this commit.

Comment on lines +157 to +158
ra->reachable_time = rte_cpu_to_be_32(0);
ra->retrans_timer = rte_cpu_to_be_32(0);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not essential, but RTE_BE32(0) would be better for constants.

return api_out(0, len);
}
void ndp_router_sollicit_input_cb(struct rte_mbuf *m) {
uint16_t iface_id = mbuf_data(m)->iface->id;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we're missing some RFC checks for router solicitations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll double check that.

@christophefontaine christophefontaine marked this pull request as draft January 14, 2025 20:56
We wrongly assumed that the data was still present when prepending
an ip header.
Rewrite the ip/ip6 header instead.

Fixes: e27fab5 ("ip/ip6: post tcp/udp packets to loopback interface")
Signed-off-by: Christophe Fontaine <[email protected]>
For VxLan tunnels, we need to register a specific destination udp port.

Add a new node and api, and push all non-handled packets back
to the management (loopback) interface, as done today.

Signed-off-by: Christophe Fontaine <[email protected]>
BGP unnumbered relies on RA message to discover
the local routers.

Broadcast the simplest router advertisement message
on ipv6 enabled interfaces.
Additional options (DNS, ... ) may be added in the future.

Signed-off-by: Christophe Fontaine <[email protected]>
Upon reception of a router sollicit message, trigger the existing
timer to send immediately a router advertismement packet.

Signed-off-by: Christophe Fontaine <[email protected]>
Add configuration knobs for RA messages.
Instead of a hardcoded perdiodic message, allow a per-interface
configuration.

Signed-off-by: Christophe Fontaine <[email protected]>
The returned nexthop for a multicast route lookup doesn't have
a defined iface.
Yet, this nexthop is valid, and we can rely on the iface defined
by the parent node to select the output iface.

Signed-off-by: Christophe Fontaine <[email protected]>
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

Successfully merging this pull request may close these issues.

2 participants