-
Notifications
You must be signed in to change notification settings - Fork 225
Initial inet_diag test suite #4176
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
base: main
Are you sure you want to change the base?
Conversation
|
|
||
| time.sleep(poll_interval) | ||
|
|
||
| node.log.warning( |
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.
don't use warning level log
| ) | ||
| def verify_inet_diag_destroy(self, node: Node) -> None: | ||
| kernel_config = node.tools[KernelConfig] | ||
| ss = node.tools[Ss] |
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.
move it into line 200
| # Example output from ss -tn: | ||
| # State Recv-Q Send-Q Local Address:Port Peer Address:Port | ||
| # ESTAB 0 0 127.0.0.1:34567 127.0.0.1:45678 | ||
| _connection_pattern = re.compile( |
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.
remove unused code
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.
Pull request overview
This PR introduces a new test suite for validating the Linux kernel's INET_DIAG_DESTROY feature, which enables administrative termination of TCP connections via netlink socket interface. The implementation includes a new ss tool wrapper and comprehensive test cases to verify socket diagnostic capabilities.
Key Changes:
- New
Sstool class with methods for checking connection state, killing connections, and detecting kernel feature support - Two test cases:
verify_inet_diag_destroy(P2) validates connection termination functionality, andverify_inet_diag_enabled(P3) verifies basic INET_DIAG support - Helper Python script that creates and maintains TCP connections for testing purposes
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
lisa/tools/ss.py |
Implements the Ss tool wrapper with methods for connection management, kill support detection, and BSD compatibility |
lisa/tools/__init__.py |
Adds Ss import and exports it in the public API |
lisa/microsoft/testsuites/network/inet_diag.py |
Comprehensive test suite with helper methods for port discovery, connection state verification, and cleanup |
lisa/microsoft/testsuites/network/TestScripts/lisa_tcp_test.py |
Python script that creates persistent TCP server-client connections on specified ports for testing |
| if connection_process: | ||
| node.execute( | ||
| f"pkill -f {script_path}", | ||
| sudo=True, | ||
| ) | ||
| # Remove temporary script | ||
| node.execute(f"rm -f {script_path}", sudo=True) |
Copilot
AI
Jan 4, 2026
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.
The cleanup in the finally block may fail silently if the process was never created or if pkill fails. The pkill command should be run with expected_exit_code_failure_message or at minimum log whether cleanup succeeded. Additionally, consider checking if connection_process is not None before attempting cleanup operations that depend on it having been created.
| if connection_process: | |
| node.execute( | |
| f"pkill -f {script_path}", | |
| sudo=True, | |
| ) | |
| # Remove temporary script | |
| node.execute(f"rm -f {script_path}", sudo=True) | |
| if connection_process is not None: | |
| node.execute( | |
| f"pkill -f {script_path}", | |
| sudo=True, | |
| expected_exit_code=0, | |
| expected_exit_code_failure_message=( | |
| f"Failed to clean up TCP test process using pkill for script " | |
| f"{script_path}" | |
| ), | |
| ) | |
| # Remove temporary script | |
| node.execute( | |
| f"rm -f {script_path}", | |
| sudo=True, | |
| expected_exit_code=0, | |
| expected_exit_code_failure_message=( | |
| f"Failed to remove temporary script {script_path} during cleanup" | |
| ), | |
| ) |
Add INET_DIAG_DESTROY Test Suite
Adds tests for CONFIG_INET_DIAG_DESTROY kernel feature - validates administrative TCP connection termination via ss -K.
INET_DIAG_DESTROY
"Provides a SOCK_DESTROY operation that allows privileged processes (e.g., a connection manager or a network administration tool such as ss) to close sockets opened by other processes. Closing a socket in this way interrupts any blocking read/write/connect operations on the socket and causes future socket calls to behave as if the socket had been disconnected. If unsure, say N."
Tests
verify_inet_diag_destroy (P2): Creates TCP connection, destroys with ss -K, verifies removal
verify_inet_diag_enabled (P3): Validates CONFIG_INET_DIAG and ss functionality
Validation
Tested on Fedora 43 and Ubuntu