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

feat: add command to enable mptcp #4014

Merged
merged 2 commits into from
Nov 1, 2024
Merged

feat: add command to enable mptcp #4014

merged 2 commits into from
Nov 1, 2024

Conversation

evan-forbes
Copy link
Member

@evan-forbes evan-forbes commented Oct 30, 2024

Overview

adds a makefile command to enable and disable mptcp over different ports (not interfaces) for linux kernels greater than 5.6

not required, but potentially useful

@evan-forbes evan-forbes added the WS: Maintenance 🔧 includes bugs, refactors, flakes, and tech debt etc label Oct 30, 2024
@evan-forbes evan-forbes requested a review from a team as a code owner October 30, 2024 13:48
@evan-forbes evan-forbes requested review from rootulp and rach-id and removed request for a team October 30, 2024 13:48
@celestia-bot celestia-bot requested a review from a team October 30, 2024 13:48
@evan-forbes evan-forbes added the backport:v2.x PR will be backported automatically to the v2.x branch upon merging label Oct 30, 2024
Copy link
Contributor

coderabbitai bot commented Oct 30, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes introduce two new make targets in the Makefile: enable-mptcp and disable-mptcp. The enable-mptcp target configures the system for MultiPath TCP (MPTCP) by adjusting sysctl parameters and ensuring persistence across reboots. Conversely, the disable-mptcp target disables MPTCP and reverts the settings. Both targets are designated as .PHONY, indicating they do not correspond to actual files.

Changes

File Change Summary
Makefile Added enable-mptcp target to configure MPTCP; added disable-mptcp target to disable MPTCP and revert settings. Both targets are marked as .PHONY.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Makefile
    participant System

    User->>Makefile: invoke enable-mptcp
    Makefile->>System: Set sysctl parameters for MPTCP
    Makefile->>System: Append settings to /etc/sysctl.conf
    User->>Makefile: invoke disable-mptcp
    Makefile->>System: Set MPTCP enabled parameter to 0
    Makefile->>System: Remove settings from /etc/sysctl.conf
Loading

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@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: 2

🧹 Outside diff range and nitpick comments (1)
Makefile (1)

276-302: Document MPTCP implications and provide usage guidelines

The MPTCP configuration affects system-wide network settings, which could impact other applications. Consider adding documentation that:

  1. Explains when and why users should enable MPTCP
  2. Describes the performance implications
  3. Lists potential conflicts with other network configurations
  4. Provides troubleshooting steps

Would you like me to help draft this documentation as a new section in the README?

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between b6a3ed2 and 9787bf0.

📒 Files selected for processing (1)
  • Makefile (1 hunks)

Makefile Outdated
Comment on lines 290 to 301
## disable-mptcp: Disables mptcp over multiple ports. Only works on Linux Kernel 5.6 and above.
disable_mptcp:
@echo "Disabling MPTCP..."
@sudo sysctl -w net.mptcp.enabled=0
@sudo sysctl -w net.mptcp.mptcp_path_manager=default
@echo "Removing MPTCP settings from /etc/sysctl.conf..."
@sudo sed -i '/net.mptcp.enabled=1/d' /etc/sysctl.conf
@sudo sed -i '/net.mptcp.mptcp_path_manager=ndiffports/d' /etc/sysctl.conf
@sudo sed -i '/net.mptcp.mptcp_ndiffports=16/d' /etc/sysctl.conf
@echo "MPTCP configuration reverted!"

.PHONY: disable-mptcp
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix target naming and add safety measures for disable-mptcp target

The current implementation has several issues:

  1. Target name uses underscore (disable_mptcp) while enable-mptcp uses hyphen
  2. Unsafe modification of system files without backup
  3. Missing error handling

Apply these fixes:

 ## disable-mptcp: Disables mptcp over multiple ports. Only works on Linux Kernel 5.6 and above.
-disable_mptcp:
+disable-mptcp:
+	@if [ "$$(uname)" != "Linux" ]; then \
+		echo "Error: MPTCP configuration is only supported on Linux systems"; \
+		exit 1; \
+	fi
+	@if ! command -v sudo >/dev/null 2>&1; then \
+		echo "Error: sudo is required to modify system settings"; \
+		exit 1; \
+	fi
 	@echo "Disabling MPTCP..."
+	@sudo cp /etc/sysctl.conf /etc/sysctl.conf.backup
 	@sudo sysctl -w net.mptcp.enabled=0
 	@sudo sysctl -w net.mptcp.mptcp_path_manager=default
 	@echo "Removing MPTCP settings from /etc/sysctl.conf..."
 	@sudo sed -i '/net.mptcp.enabled=1/d' /etc/sysctl.conf
 	@sudo sed -i '/net.mptcp.mptcp_path_manager=ndiffports/d' /etc/sysctl.conf
 	@sudo sed -i '/net.mptcp.mptcp_ndiffports=16/d' /etc/sysctl.conf
 	@echo "MPTCP configuration reverted!"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
## disable-mptcp: Disables mptcp over multiple ports. Only works on Linux Kernel 5.6 and above.
disable_mptcp:
@echo "Disabling MPTCP..."
@sudo sysctl -w net.mptcp.enabled=0
@sudo sysctl -w net.mptcp.mptcp_path_manager=default
@echo "Removing MPTCP settings from /etc/sysctl.conf..."
@sudo sed -i '/net.mptcp.enabled=1/d' /etc/sysctl.conf
@sudo sed -i '/net.mptcp.mptcp_path_manager=ndiffports/d' /etc/sysctl.conf
@sudo sed -i '/net.mptcp.mptcp_ndiffports=16/d' /etc/sysctl.conf
@echo "MPTCP configuration reverted!"
.PHONY: disable-mptcp
## disable-mptcp: Disables mptcp over multiple ports. Only works on Linux Kernel 5.6 and above.
disable-mptcp:
@if [ "$$(uname)" != "Linux" ]; then \
echo "Error: MPTCP configuration is only supported on Linux systems"; \
exit 1; \
fi
@if ! command -v sudo >/dev/null 2>&1; then \
echo "Error: sudo is required to modify system settings"; \
exit 1; \
fi
@echo "Disabling MPTCP..."
@sudo cp /etc/sysctl.conf /etc/sysctl.conf.backup
@sudo sysctl -w net.mptcp.enabled=0
@sudo sysctl -w net.mptcp.mptcp_path_manager=default
@echo "Removing MPTCP settings from /etc/sysctl.conf..."
@sudo sed -i '/net.mptcp.enabled=1/d' /etc/sysctl.conf
@sudo sed -i '/net.mptcp.mptcp_path_manager=ndiffports/d' /etc/sysctl.conf
@sudo sed -i '/net.mptcp.mptcp_ndiffports=16/d' /etc/sysctl.conf
@echo "MPTCP configuration reverted!"
.PHONY: disable-mptcp

Comment on lines +276 to +288
## enable-mptcp: Enable mptcp over multiple ports (not interfaces). Only works on Linux Kernel 5.6 and above.
enable-mptcp:
@echo "Configuring system to use mptcp..."
@sudo sysctl -w net.mptcp.enabled=1
@sudo sysctl -w net.mptcp.mptcp_path_manager=ndiffports
@sudo sysctl -w net.mptcp.mptcp_ndiffports=16
@echo "Making MPTCP settings persistent across reboots..."
@echo "net.mptcp.enabled=1" | sudo tee -a /etc/sysctl.conf
@echo "net.mptcp.mptcp_path_manager=ndiffports" | sudo tee -a /etc/sysctl.conf
@echo "net.mptcp.mptcp_ndiffports=16" | sudo tee -a /etc/sysctl.conf
@echo "MPTCP configuration complete and persistent!"

.PHONY: enable-mptcp
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add safety checks and improve error handling for enable-mptcp target

The current implementation has several potential issues:

  1. Missing kernel version check despite requiring Linux 5.6+
  2. No error handling for sudo operations
  3. No validation that MPTCP is supported
  4. Direct modification of system files without backup

Consider implementing these safety improvements:

 ## enable-mptcp: Enable mptcp over multiple ports (not interfaces). Only works on Linux Kernel 5.6 and above.
 enable-mptcp:
+	@if [ "$$(uname)" != "Linux" ]; then \
+		echo "Error: MPTCP configuration is only supported on Linux systems"; \
+		exit 1; \
+	fi
+	@if [ "$$(uname -r | cut -d. -f1,2)" \< "5.6" ]; then \
+		echo "Error: MPTCP requires Linux kernel 5.6 or higher"; \
+		exit 1; \
+	fi
+	@if ! command -v sudo >/dev/null 2>&1; then \
+		echo "Error: sudo is required to modify system settings"; \
+		exit 1; \
+	fi
 	@echo "Configuring system to use mptcp..."
+	@sudo cp /etc/sysctl.conf /etc/sysctl.conf.backup
 	@sudo sysctl -w net.mptcp.enabled=1
 	@sudo sysctl -w net.mptcp.mptcp_path_manager=ndiffports
 	@sudo sysctl -w net.mptcp.mptcp_ndiffports=16
 	@echo "Making MPTCP settings persistent across reboots..."
 	@echo "net.mptcp.enabled=1" | sudo tee -a /etc/sysctl.conf
 	@echo "net.mptcp.mptcp_path_manager=ndiffports" | sudo tee -a /etc/sysctl.conf
 	@echo "net.mptcp.mptcp_ndiffports=16" | sudo tee -a /etc/sysctl.conf
 	@echo "MPTCP configuration complete and persistent!"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
## enable-mptcp: Enable mptcp over multiple ports (not interfaces). Only works on Linux Kernel 5.6 and above.
enable-mptcp:
@echo "Configuring system to use mptcp..."
@sudo sysctl -w net.mptcp.enabled=1
@sudo sysctl -w net.mptcp.mptcp_path_manager=ndiffports
@sudo sysctl -w net.mptcp.mptcp_ndiffports=16
@echo "Making MPTCP settings persistent across reboots..."
@echo "net.mptcp.enabled=1" | sudo tee -a /etc/sysctl.conf
@echo "net.mptcp.mptcp_path_manager=ndiffports" | sudo tee -a /etc/sysctl.conf
@echo "net.mptcp.mptcp_ndiffports=16" | sudo tee -a /etc/sysctl.conf
@echo "MPTCP configuration complete and persistent!"
.PHONY: enable-mptcp
## enable-mptcp: Enable mptcp over multiple ports (not interfaces). Only works on Linux Kernel 5.6 and above.
enable-mptcp:
@if [ "$$(uname)" != "Linux" ]; then \
echo "Error: MPTCP configuration is only supported on Linux systems"; \
exit 1; \
fi
@if [ "$$(uname -r | cut -d. -f1,2)" \< "5.6" ]; then \
echo "Error: MPTCP requires Linux kernel 5.6 or higher"; \
exit 1; \
fi
@if ! command -v sudo >/dev/null 2>&1; then \
echo "Error: sudo is required to modify system settings"; \
exit 1; \
fi
@echo "Configuring system to use mptcp..."
@sudo cp /etc/sysctl.conf /etc/sysctl.conf.backup
@sudo sysctl -w net.mptcp.enabled=1
@sudo sysctl -w net.mptcp.mptcp_path_manager=ndiffports
@sudo sysctl -w net.mptcp.mptcp_ndiffports=16
@echo "Making MPTCP settings persistent across reboots..."
@echo "net.mptcp.enabled=1" | sudo tee -a /etc/sysctl.conf
@echo "net.mptcp.mptcp_path_manager=ndiffports" | sudo tee -a /etc/sysctl.conf
@echo "net.mptcp.mptcp_ndiffports=16" | sudo tee -a /etc/sysctl.conf
@echo "MPTCP configuration complete and persistent!"
.PHONY: enable-mptcp

Copy link
Member

Choose a reason for hiding this comment

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

these seem to be interesting suggestions, but optional

Copy link
Contributor

@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

🧹 Outside diff range and nitpick comments (1)
Makefile (1)

276-301: Add documentation about operational impact

Consider adding documentation in the target descriptions about:

  1. Impact on running services
  2. Whether a system restart is required
  3. How to verify MPTCP status after enabling/disabling
  4. Prerequisites (root access, kernel modules, etc.)

Update the target descriptions:

-## enable-mptcp: Enable mptcp over multiple ports (not interfaces). Only works on Linux Kernel 5.6 and above.
+## enable-mptcp: Enable mptcp over multiple ports (not interfaces). Requires Linux Kernel 5.6+, root access, and may require system restart.
+##               Note: This will modify system-wide network settings and may affect running services.
+##               Verify status after enabling: sysctl net.mptcp.enabled

-## disable-mptcp: Disables mptcp over multiple ports. Only works on Linux Kernel 5.6 and above.
+## disable-mptcp: Disable mptcp over multiple ports. Requires Linux Kernel 5.6+ and root access.
+##                Note: This will modify system-wide network settings and may affect running services.
+##                Verify status after disabling: sysctl net.mptcp.enabled
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9787bf0 and 54723ce.

📒 Files selected for processing (1)
  • Makefile (1 hunks)
🔇 Additional comments (2)
Makefile (2)

276-288: ⚠️ Potential issue

Add safety checks and improve error handling

The implementation still needs the following safety measures:

  1. Verify Linux OS and kernel version 5.6+
  2. Check sudo availability
  3. Backup system files before modification
  4. Add error handling for sysctl operations

The previous review comment's suggested fixes are still valid and should be implemented:

 enable-mptcp:
+	@if [ "$$(uname)" != "Linux" ]; then \
+		echo "Error: MPTCP configuration is only supported on Linux systems"; \
+		exit 1; \
+	fi
+	@if [ "$$(uname -r | cut -d. -f1,2)" \< "5.6" ]; then \
+		echo "Error: MPTCP requires Linux kernel 5.6 or higher"; \
+		exit 1; \
+	fi
+	@if ! command -v sudo >/dev/null 2>&1; then \
+		echo "Error: sudo is required to modify system settings"; \
+		exit 1; \
+	fi
 	@echo "Configuring system to use mptcp..."
+	@sudo cp /etc/sysctl.conf /etc/sysctl.conf.backup

290-301: ⚠️ Potential issue

Add safety measures and error handling

The implementation still needs the following safety measures:

  1. Verify Linux OS
  2. Check sudo availability
  3. Backup system files before modification
  4. Add error handling for system operations

The previous review comment's suggested fixes are still valid and should be implemented:

 disable-mptcp:
+	@if [ "$$(uname)" != "Linux" ]; then \
+		echo "Error: MPTCP configuration is only supported on Linux systems"; \
+		exit 1; \
+	fi
+	@if ! command -v sudo >/dev/null 2>&1; then \
+		echo "Error: sudo is required to modify system settings"; \
+		exit 1; \
+	fi
 	@echo "Disabling MPTCP..."
+	@sudo cp /etc/sysctl.conf /etc/sysctl.conf.backup

## debug-version: Print the git tag and version.
debug-version:
@echo "GIT_TAG: $(GIT_TAG)"
@echo "VERSION: $(VERSION)"
.PHONY: debug-version

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change

.PHONY: enable-mptcp

## disable-mptcp: Disables mptcp over multiple ports. Only works on Linux Kernel 5.6 and above.
disable-mptcp:
Copy link
Member

Choose a reason for hiding this comment

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

would be nice to have a disable-bbr too :D

Comment on lines +276 to +288
## enable-mptcp: Enable mptcp over multiple ports (not interfaces). Only works on Linux Kernel 5.6 and above.
enable-mptcp:
@echo "Configuring system to use mptcp..."
@sudo sysctl -w net.mptcp.enabled=1
@sudo sysctl -w net.mptcp.mptcp_path_manager=ndiffports
@sudo sysctl -w net.mptcp.mptcp_ndiffports=16
@echo "Making MPTCP settings persistent across reboots..."
@echo "net.mptcp.enabled=1" | sudo tee -a /etc/sysctl.conf
@echo "net.mptcp.mptcp_path_manager=ndiffports" | sudo tee -a /etc/sysctl.conf
@echo "net.mptcp.mptcp_ndiffports=16" | sudo tee -a /etc/sysctl.conf
@echo "MPTCP configuration complete and persistent!"

.PHONY: enable-mptcp
Copy link
Member

Choose a reason for hiding this comment

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

these seem to be interesting suggestions, but optional

Copy link
Member

@ninabarbakadze ninabarbakadze left a comment

Choose a reason for hiding this comment

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

utAck

@evan-forbes evan-forbes merged commit 808d0f2 into main Nov 1, 2024
31 checks passed
@evan-forbes evan-forbes deleted the evan/make-mptcp branch November 1, 2024 19:40
mergify bot pushed a commit that referenced this pull request Nov 1, 2024
## Overview

adds a makefile command to enable and disable mptcp over different ports
(not interfaces) for linux kernels greater than 5.6

not required, but potentially useful

(cherry picked from commit 808d0f2)

# Conflicts:
#	Makefile
rach-id pushed a commit that referenced this pull request Nov 26, 2024
## Overview

adds a makefile command to enable and disable mptcp over different ports
(not interfaces) for linux kernels greater than 5.6

not required, but potentially useful

(cherry picked from commit 808d0f2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:v2.x PR will be backported automatically to the v2.x branch upon merging WS: Maintenance 🔧 includes bugs, refactors, flakes, and tech debt etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants