Skip to content

Conversation

@amastbaum
Copy link
Contributor

@amastbaum amastbaum commented Oct 30, 2025

What?

Added UCX_TCP_REACHABILITY_MODE config (default: route) to optionally allow all addresses without route checking when set to all.
Solving bug: https://redmine.mellanox.com/issues/4659780

Summary by CodeRabbit

  • New Features
    • Added a TCP "reachability mode" configuration with three options: route (default), all, and last.
    • Selecting "all" treats all network addresses as reachable; the chosen mode is exposed in configuration and applied at runtime to influence reachability checks.

@amastbaum amastbaum added the WIP-DNM Work in progress / Do not review label Oct 30, 2025
@gleon99 gleon99 requested a review from shasson5 November 4, 2025 14:01
@gleon99
Copy link
Contributor

gleon99 commented Nov 4, 2025

@shasson5 please look

@coderabbitai
Copy link

coderabbitai bot commented Nov 5, 2025

Walkthrough

Adds a configurable TCP interface reachability mode enum and wires it through the public config, initialization, and the reachability check so the iface can treat addresses as routability-checked or universally reachable.

Changes

Cohort / File(s) Change Summary
Header: public types & config
src/uct/tcp/tcp.h
Added typedef enum uct_tcp_reachability_mode_t { UCT_TCP_REACHABILITY_ROUTE, UCT_TCP_REACHABILITY_ALL, UCT_TCP_REACHABILITY_LAST }; added reachability_mode field to the iface config area and to uct_tcp_iface_config_t.
Implementation & config table
src/uct/tcp/tcp_iface.c
Added const char *uct_tcp_reachability_modes[] string mapping and REACHABILITY_MODE config entry (default "route"); propagated reachability_mode from TL config into self->config; modified uct_tcp_iface_is_reachable_v2 to use uct_iface_scope_is_reachable when mode==ALL and to perform routability checks when mode==ROUTE.

Sequence Diagram(s)

sequenceDiagram
    participant Caller as reachability caller
    participant IFACE as TCP_IFACE\n(config.reachability_mode)
    participant SCOPE as ScopeChecker
    participant ROUTE as RoutabilityChecker

    Caller->>IFACE: uct_tcp_iface_is_reachable_v2(addr)
    alt config == ALL
        IFACE->>SCOPE: uct_iface_scope_is_reachable(addr)
        SCOPE-->>IFACE: reachable / not reachable
        IFACE-->>Caller: return result
    else config == ROUTE
        IFACE->>ROUTE: check address routability (if_nametoindex / name-index)
        ROUTE-->>IFACE: routable / not routable
        IFACE-->>Caller: return result
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Pay attention to:
    • Correct enum ↔ string mapping and NUL termination of uct_tcp_reachability_modes[].
    • Config table entry syntax, default value, and how the enum is parsed.
    • Proper propagation of reachability_mode into self->config during init.
    • The conditional logic in uct_tcp_iface_is_reachable_v2 to ensure no regressions in routability checks.

Poem

🐰 I nibble configs, choose route or all,
A hop of enum, a tiny call,
From table into runtime I bound,
Scope or route — I check the ground,
TCP carrots scattered round.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately summarizes the main change: adding a reachability mode configuration variable to tcp_iface, which is directly reflected in the code additions across tcp.h and tcp_iface.c.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/uct/tcp/tcp.h (1)

232-240: Consider naming consistency with other TCP iface types.

The enum is named uct_tcp_reachability_mode_t, but given that this is specific to the TCP interface configuration and following the pattern of other types like uct_tcp_iface_config_t and uct_tcp_iface_addr_t, the name uct_tcp_iface_reachability_mode_t would be more consistent with the codebase conventions.

Apply this diff to align with naming conventions:

-typedef enum {
+typedef enum uct_tcp_iface_reachability_mode {
     UCT_TCP_REACHABILITY_MODE_ROUTE = 0,
     UCT_TCP_REACHABILITY_MODE_ALL   = 1,
     UCT_TCP_REACHABILITY_MODE_LAST
-} uct_tcp_reachability_mode_t;
+} uct_tcp_iface_reachability_mode_t;

Also update the corresponding field declarations on lines 435-436 and 474, and the array declaration in src/uct/tcp/tcp_iface.c.

src/uct/tcp/tcp_iface.c (1)

257-265: Add comment explaining the reachability bypass logic.

The conditional logic on lines 257-260 is somewhat complex. When reachability_mode is set to ALL, the function delegates to uct_iface_scope_is_reachable, which returns 1 for NETWORK scope (the default). This effectively treats all addresses as reachable without performing route verification. The assertion on lines 264-265 is good defensive programming to ensure only ROUTE mode reaches the route checking code.

Consider adding a clarifying comment before the conditional:

+    /* For DEVICE scope or ALL reachability mode, delegate to base function
+     * which bypasses route checking and treats all addresses as reachable */
     if (((params->field_mask & UCT_IFACE_IS_REACHABLE_FIELD_SCOPE) &&
          (params->scope == UCT_IFACE_REACHABILITY_SCOPE_DEVICE)) ||
         (iface->config.reachability_mode == UCT_TCP_REACHABILITY_MODE_ALL)) {
         return uct_iface_scope_is_reachable(tl_iface, params);
     }
 
     /* Check if the remote address is routable */
     ucs_assert(iface->config.reachability_mode ==
                UCT_TCP_REACHABILITY_MODE_ROUTE);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 78115a7 and 9f96287.

📒 Files selected for processing (2)
  • src/uct/tcp/tcp.h (3 hunks)
  • src/uct/tcp/tcp_iface.c (4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/uct/tcp/tcp_iface.c (1)
src/uct/base/uct_iface.c (1)
  • uct_iface_scope_is_reachable (303-322)
⏰ 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). (8)
  • GitHub Check: UCX PR (Codestyle ctags check)
  • GitHub Check: UCX PR (Codestyle commit title)
  • GitHub Check: UCX PR (Codestyle format code)
  • GitHub Check: UCX PR (Codestyle codespell check)
  • GitHub Check: UCX PR (Codestyle AUTHORS file update check)
  • GitHub Check: UCX release DRP (Prepare CheckRelease)
  • GitHub Check: UCX release (Prepare CheckRelease)
  • GitHub Check: UCX snapshot (Prepare Check)
🔇 Additional comments (5)
src/uct/tcp/tcp.h (2)

435-436: Verify external declaration for the modes array.

The reachability_mode field is correctly added to the config structure. However, I don't see an extern declaration for the uct_tcp_reachability_modes[] array that is defined in src/uct/tcp/tcp_iface.c. This array is referenced in the config table via UCS_CONFIG_TYPE_ENUM() macro.

Please verify whether an extern declaration should be added near the other external declarations (around line 518-522) like:

extern const char *uct_tcp_reachability_modes[];

This would make the array properly visible to code that includes this header file.


474-474: Configuration field looks good.

The reachability_mode field is correctly added to the configuration structure, maintaining consistency with the runtime config structure.

src/uct/tcp/tcp_iface.c (3)

25-29: Array definition is correct.

The reachability modes array is properly defined with correct enum indices and NULL terminator for the LAST element.


127-132: Configuration entry documentation is clear.

The configuration entry properly documents both modes and their behavior. The default value "route" maintains backward compatibility.


782-782: Configuration propagation is correct.

The reachability_mode value is properly propagated from the config to the runtime iface structure.

@shasson5
Copy link
Contributor

shasson5 commented Nov 6, 2025

BTW why is WIP label set?

@amastbaum amastbaum removed the WIP-DNM Work in progress / Do not review label Nov 6, 2025
@amastbaum
Copy link
Contributor Author

amastbaum commented Nov 6, 2025

BTW why is WIP label set?
By mistake

@amastbaum amastbaum closed this Nov 6, 2025
@amastbaum amastbaum reopened this Nov 6, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
src/uct/tcp/tcp.h (3)

232-240: Add documentation for the enum and its values.

The enum lacks documentation comments explaining what each reachability mode does. Based on the PR objectives, ROUTE performs route checking (default behavior), while ALL allows all addresses without route checking.

Apply this diff to add documentation:

+/**
+ * TCP Reachability mode.
+ * Determines how reachability checks are performed for TCP interfaces.
+ */
 typedef enum {
+    UCT_TCP_REACHABILITY_MODE_ROUTE = 0, /* Check reachability via routing table (default) */
+    UCT_TCP_REACHABILITY_MODE_ALL   = 1, /* Allow all addresses without route checking */
-    UCT_TCP_REACHABILITY_MODE_ROUTE = 0,
-    UCT_TCP_REACHABILITY_MODE_ALL   = 1,
     UCT_TCP_REACHABILITY_MODE_LAST
 } uct_tcp_reachability_mode_t;

435-435: Add documentation for the reachability_mode field.

The reachability_mode field lacks a comment explaining its purpose. Consider adding an inline comment similar to other fields in the config struct.

Apply this diff:

-        uct_tcp_reachability_mode_t reachability_mode; /* Mode used for performing reachability check */
+        uct_tcp_reachability_mode_t reachability_mode; /* Reachability checking mode: ROUTE (default, via routing table) or ALL (skip route checks) */

473-473: Consider adding documentation for the reachability_mode field.

Similar to other config fields, consider adding a brief comment for clarity, though the type name is self-documenting.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9f96287 and 1ad0201.

📒 Files selected for processing (1)
  • src/uct/tcp/tcp.h (3 hunks)
⏰ 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). (11)
  • GitHub Check: UCX PR (Codestyle ctags check)
  • GitHub Check: UCX PR (Codestyle codespell check)
  • GitHub Check: UCX PR (Codestyle commit title)
  • GitHub Check: UCX PR (Codestyle format code)
  • GitHub Check: UCX PR (Codestyle AUTHORS file update check)
  • GitHub Check: UCX release DRP (Prepare CheckRelease)
  • GitHub Check: UCX release DRP (Prepare CheckRelease)
  • GitHub Check: UCX release (Prepare CheckRelease)
  • GitHub Check: UCX release (Prepare CheckRelease)
  • GitHub Check: UCX snapshot (Prepare Check)
  • GitHub Check: UCX snapshot (Prepare Check)
🔇 Additional comments (2)
src/uct/tcp/tcp.h (2)

378-443: LGTM: Struct alignment addresses previous review feedback.

The alignment changes to uct_tcp_iface_t address the clang false positive issue mentioned in the previous review comments. The substantive change is the addition of the reachability_mode field at line 435.

Based on learnings.


516-520: The review comment appears to be based on an incorrect assumption about the intended scope of the array.

Based on verification, the array uct_tcp_reachability_modes[] is defined and used exclusively within src/uct/tcp/tcp_iface.c (defined at line 25, used at line 132). The script found zero references to this array outside of that file. For internal-only usage within a single compilation unit, an extern declaration in the header is not required. The similar pattern with other declared arrays in the header (like uct_tcp_address_type_names[]) reflects those being part of the public TCP component API, whereas this reachability modes array appears to be intentionally scoped to internal configuration handling.

Likely an incorrect or invalid review comment.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/uct/tcp/tcp.h (2)

232-240: Consider documenting the enum values.

The enum values UCT_TCP_REACHABILITY_MODE_ROUTE and UCT_TCP_REACHABILITY_MODE_ALL would benefit from inline documentation explaining their behavior. Based on the PR objectives, ROUTE performs route checking (default) while ALL skips route checking and allows all addresses.

Consider applying this documentation:

 /**
- * TCP Reachability mode.
+ * TCP Reachability mode for determining interface reachability.
  */
 typedef enum {
-    UCT_TCP_REACHABILITY_MODE_ROUTE = 0,
-    UCT_TCP_REACHABILITY_MODE_ALL   = 1,
+    UCT_TCP_REACHABILITY_MODE_ROUTE = 0, /* Perform route checking (default) */
+    UCT_TCP_REACHABILITY_MODE_ALL   = 1, /* Skip route checking, allow all addresses */
     UCT_TCP_REACHABILITY_MODE_LAST
 } uct_tcp_reachability_mode_t;

473-473: Consider adding an inline comment for consistency.

The corresponding field in uct_tcp_iface_t (line 435) has an inline comment explaining its purpose. Adding a similar comment here would improve consistency.

-    uct_tcp_reachability_mode_t     reachability_mode;
+    uct_tcp_reachability_mode_t     reachability_mode; /* Mode used for performing reachability check */
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1ad0201 and e7aa4df.

📒 Files selected for processing (1)
  • src/uct/tcp/tcp.h (4 hunks)
⏰ 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). (9)
  • GitHub Check: UCX PR (Static_check Static checks)
  • GitHub Check: UCX PR (Codestyle codespell check)
  • GitHub Check: UCX PR (Codestyle format code)
  • GitHub Check: UCX PR (Codestyle AUTHORS file update check)
  • GitHub Check: UCX PR (Codestyle ctags check)
  • GitHub Check: UCX PR (Codestyle commit title)
  • GitHub Check: UCX release DRP (Prepare CheckRelease)
  • GitHub Check: UCX release (Prepare CheckRelease)
  • GitHub Check: UCX snapshot (Prepare Check)
🔇 Additional comments (2)
src/uct/tcp/tcp.h (2)

435-435: LGTM!

The reachability_mode field is correctly added to the interface config structure with appropriate typing and documentation.


346-368: Alignment changes address previous review feedback.

The extensive alignment changes across the struct definitions appropriately address the concerns raised in previous reviews about clang false positives with struct definitions.

Also applies to: 377-443, 449-474

@amastbaum amastbaum force-pushed the configure_reachability_mode_in_tcp_iface branch from e7aa4df to 1ad0201 Compare November 6, 2025 15:48
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.

3 participants