-
Notifications
You must be signed in to change notification settings - Fork 9
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
christophefontaine
wants to merge
5
commits into
DPDK:main
Choose a base branch
from
christophefontaine:router_advertisement
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1c3abbc
ip6: send icmp router advertisement
christophefontaine c07cd54
ip6: fix iface output for multicast destination
christophefontaine 17d4a11
ip6: answer to router sollicit message
christophefontaine 627392d
ip6: router advertisement configuration
christophefontaine 61f1307
ip6: always register to multicast addresses
christophefontaine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ cli_src += files( | |
'address.c', | ||
'nexthop.c', | ||
'route.c', | ||
'router_advert.c', | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// Copyright (c) 2025 Christophe Fontaine | ||
|
||
#include "ip.h" | ||
|
||
#include <gr_api.h> | ||
#include <gr_cli.h> | ||
#include <gr_cli_iface.h> | ||
#include <gr_ip6.h> | ||
#include <gr_net_types.h> | ||
#include <gr_table.h> | ||
|
||
#include <ecoli.h> | ||
#include <libsmartcols.h> | ||
|
||
#include <errno.h> | ||
|
||
static cmd_status_t ra_show(const struct gr_api_client *c, const struct ec_pnode *p) { | ||
struct libscols_table *table = scols_new_table(); | ||
struct gr_ip6_ra_show_resp *resp; | ||
struct gr_ip6_ra_show_req req; | ||
struct gr_iface iface; | ||
void *resp_ptr = NULL; | ||
|
||
if (!iface_from_name(c, arg_str(p, "IFACE"), &iface)) | ||
req.iface_id = iface.id; | ||
else | ||
req.iface_id = 0; | ||
|
||
if (gr_api_client_send_recv(c, GR_IP6_IFACE_RA_SHOW, sizeof(req), &req, &resp_ptr) < 0) | ||
return CMD_ERROR; | ||
resp = resp_ptr; | ||
|
||
scols_table_new_column(table, "IFACE", 0, 0); | ||
scols_table_new_column(table, "RA", 0, 0); | ||
scols_table_new_column(table, "interval", 0, 0); | ||
scols_table_new_column(table, "lifetime", 0, 0); | ||
scols_table_set_column_separator(table, " "); | ||
|
||
for (uint16_t i = 0; i < resp->n_ras; i++) { | ||
struct libscols_line *line = scols_table_new_line(table, NULL); | ||
if (iface_from_id(c, resp->ras[i].iface_id, &iface) == 0) | ||
scols_line_sprintf(line, 0, "%s", iface.name); | ||
else | ||
scols_line_sprintf(line, 0, "%u", resp->ras[i].iface_id); | ||
scols_line_sprintf(line, 1, "%u", resp->ras[i].enabled); | ||
scols_line_sprintf(line, 2, "%u", resp->ras[i].interval); | ||
scols_line_sprintf(line, 3, "%u", resp->ras[i].lifetime); | ||
} | ||
|
||
scols_print_table(table); | ||
scols_unref_table(table); | ||
free(resp_ptr); | ||
return CMD_SUCCESS; | ||
} | ||
|
||
static cmd_status_t ra_set(const struct gr_api_client *c, const struct ec_pnode *p) { | ||
struct gr_ip6_ra_set_req req = {0}; | ||
struct gr_iface iface; | ||
|
||
if (iface_from_name(c, arg_str(p, "IFACE"), &iface) < 0) | ||
return CMD_ERROR; | ||
|
||
req.iface_id = iface.id; | ||
if (!arg_u16(p, "IT", &req.interval)) | ||
req.set_interval = 1; | ||
|
||
if (!arg_u16(p, "LT", &req.lifetime)) | ||
req.set_lifetime = 1; | ||
|
||
if (gr_api_client_send_recv(c, GR_IP6_IFACE_RA_SET, sizeof(req), &req, NULL) < 0) | ||
return CMD_ERROR; | ||
return CMD_SUCCESS; | ||
} | ||
|
||
static cmd_status_t ra_clear(const struct gr_api_client *c, const struct ec_pnode *p) { | ||
struct gr_ip6_ra_clear_req req; | ||
struct gr_iface iface; | ||
|
||
if (iface_from_name(c, arg_str(p, "IFACE"), &iface) < 0) | ||
return CMD_ERROR; | ||
|
||
req.iface_id = iface.id; | ||
if (gr_api_client_send_recv(c, GR_IP6_IFACE_RA_CLEAR, sizeof(req), &req, NULL) < 0) | ||
return CMD_ERROR; | ||
return CMD_SUCCESS; | ||
} | ||
|
||
static int ctx_init(struct ec_node *root) { | ||
int ret; | ||
|
||
ret = CLI_COMMAND( | ||
IP6_SHOW_CTX(root), | ||
"router-advert [IFACE]", | ||
ra_show, | ||
"Show router advertisement configuration", | ||
with_help("Interface name.", ec_node_dyn("IFACE", complete_iface_names, NULL)) | ||
); | ||
if (ret < 0) | ||
return ret; | ||
|
||
ret = CLI_COMMAND( | ||
IP6_SET_CTX(root), | ||
"router-advert IFACE [interval IT] [lifetime LT]", | ||
ra_set, | ||
"Set router advertisement parameters", | ||
with_help("Interface name.", ec_node_dyn("IFACE", complete_iface_names, NULL)), | ||
with_help("Interval", ec_node_uint("IT", 0, UINT16_MAX - 1, 10)), | ||
with_help("Life time", ec_node_uint("LT", 0, UINT16_MAX - 1, 10)) | ||
); | ||
if (ret < 0) | ||
return ret; | ||
|
||
ret = CLI_COMMAND( | ||
IP6_CLEAR_CTX(root), | ||
"router-advert IFACE", | ||
ra_clear, | ||
"Disable router advertisement and reset parameters", | ||
with_help("Interface name.", ec_node_dyn("IFACE", complete_iface_names, NULL)) | ||
); | ||
if (ret < 0) | ||
return ret; | ||
|
||
return 0; | ||
} | ||
|
||
static struct gr_cli_context ctx = { | ||
.name = "ipv6 router-advert", | ||
.init = ctx_init, | ||
}; | ||
|
||
static void __attribute__((constructor, used)) init(void) { | ||
register_context(&ctx); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,6 @@ src += files( | |
'address.c', | ||
'nexthop.c', | ||
'route.c', | ||
'router_advert.c', | ||
) | ||
inc += include_directories('.') |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This deserves a separate commit for readability.