-
Notifications
You must be signed in to change notification settings - Fork 23
ctlplane: handle interface renaming #450
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
Conversation
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughAdds a new netlink API 📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
modules/infra/control/ctlplane.c(1 hunks)modules/infra/control/gr_netlink.h(1 hunks)modules/infra/control/netlink.c(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{c,h}
⚙️ CodeRabbit configuration file
**/*.{c,h}: -gr_vec_*()functions cannot fail. No need to check their return value.
gr_vec_free(x)always setsx = NULL. There is no risk of double free.ec_node_*()functions consume theirec_nodearguments. No leaks on error.rte_node->ctxis an uint8_t array of size 16, not a pointer.- Never suggest to replace
assert()with graceful error checking.- We compile with
-std=gnu2x. Unnamed parameters in function definitions are valid.
Files:
modules/infra/control/gr_netlink.hmodules/infra/control/ctlplane.cmodules/infra/control/netlink.c
🧬 Code graph analysis (2)
modules/infra/control/gr_netlink.h (1)
modules/infra/control/netlink.c (1)
netlink_link_set_name(331-348)
modules/infra/control/ctlplane.c (2)
modules/infra/control/gr_iface.h (1)
iface(16-25)modules/infra/control/netlink.c (1)
netlink_link_set_name(331-348)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: build-and-tests (clang-18, none, debugoptimized, ubuntu-24.04, false)
- GitHub Check: build-and-tests (clang-15, none, debugoptimized, ubuntu-22.04, false)
- GitHub Check: build-and-tests (gcc-14, address, debug, ubuntu-24.04, -Dfrr=enabled, true)
- GitHub Check: build-and-tests (clang-16, none, debugoptimized, ubuntu-24.04, false)
- GitHub Check: build-and-tests (gcc-13, none, debugoptimized, ubuntu-24.04, -Dfrr=enabled, false)
- GitHub Check: rpm
- GitHub Check: deb
🔇 Additional comments (2)
modules/infra/control/gr_netlink.h (1)
12-12: LGTM!The function declaration is consistent with the existing API style and correctly exposes the new interface renaming capability.
modules/infra/control/netlink.c (1)
331-348: LGTM!The implementation correctly constructs a RTM_SETLINK netlink message with IFLA_IFNAME to rename the interface. The buffer sizing is appropriate, and the function follows the established pattern used by other netlink operations in this file.
| if (iface->cp_id > 0) { | ||
| if (if_indextoname(iface->cp_id, current_name) != NULL | ||
| && strcmp(current_name, iface->name) != 0) { | ||
| netlink_link_set_name(iface->cp_id, iface->name); | ||
| } |
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.
Handle rename failure.
The return value from netlink_link_set_name is not checked. If the rename fails, the code continues silently, potentially causing a mismatch between iface->name and the actual kernel interface name. This could lead to subsequent ioctl operations failing or operating on the wrong interface.
Apply this diff to add error handling:
if (iface->cp_id > 0) {
if (if_indextoname(iface->cp_id, current_name) != NULL
&& strcmp(current_name, iface->name) != 0) {
- netlink_link_set_name(iface->cp_id, iface->name);
+ if (netlink_link_set_name(iface->cp_id, iface->name) < 0) {
+ LOG(ERR, "netlink_link_set_name(%u, %s): %s",
+ iface->cp_id, iface->name, strerror(errno));
+ }
}
}🤖 Prompt for AI Agents
In modules/infra/control/ctlplane.c around lines 391-395, the call to
netlink_link_set_name lacks error handling; check its return value and if it
indicates failure, log the error (include errno/strerror(errno) or the
function's error string) and prevent further operations on the wrong interface —
for example, clear iface->cp_id or return an error from the enclosing function
so subsequent ioctl calls are not made against a mismatched kernel name. Ensure
the log message includes iface->cp_id and iface->name for context.
|
Open question: should we allow interface renaming ? |
Interface renaming was supported since the beginning. Why would it be a problem? |
|
I'm not saying it is a problem, but asking if we ever needed that feature once since the beginning. |
When a grout interface is renamed, rename its control plane counterpart. Signed-off-by: Robin Jarry <[email protected]> Reviewed-by: Christophe Fontaine <[email protected]>
736ea16 to
05d5f82
Compare
Oh, I must admit I never questioned the need. I just implemented renaming since the beginning since it was so trivial to do. Before CP interfaces were a thing, renaming was just informative and just an update of the name field. |
When a grout interface is renamed, rename its control plane counterpart.