Add remap command for TCP listen port remapping (Closes #169)#190
Open
UtkarshSingh-06 wants to merge 1 commit intocheckpoint-restore:mainfrom
Open
Add remap command for TCP listen port remapping (Closes #169)#190UtkarshSingh-06 wants to merge 1 commit intocheckpoint-restore:mainfrom
UtkarshSingh-06 wants to merge 1 commit intocheckpoint-restore:mainfrom
Conversation
This commit adds a new 'remap' command to checkpointctl that allows remapping TCP listen ports in checkpoint archives. This addresses issue checkpoint-restore#169 by providing functionality similar to --tcp-listen-remap option of criu-image-streamer or edit_files_img.py script. The implementation: - Adds a new 'remap' command that accepts --tcp-listen-remap flag - Extracts files.img from checkpoint archives - Parses files.img to find TCP listen sockets (SOCK_STREAM, TCP_LISTEN state) - Remaps the source port according to the provided mappings - Repacks the modified files.img back into the checkpoint archive Port mappings are specified in the format old_port:new_port, with multiple mappings separated by commas. Closes checkpoint-restore#169 Signed-off-by: UtkarshSingh-06 <[email protected]>
rst0git
reviewed
Jan 18, 2026
| --tcp-listen-remap 8080:80,8443:443 | ||
|
|
||
| Example: | ||
| checkpointctl remap checkpoint.tar --tcp-listen-remap 8080:80`, |
Member
There was a problem hiding this comment.
It would be better to use more generic command name. For example, something like the following:
checkpointctl edit --tcp-listen-remap 8080:80 checkpoint.tarThis will allow us to extend the "edit" functionality with other features in the future.
rst0git
reviewed
Jan 18, 2026
| defer os.RemoveAll(tempDir) | ||
|
|
||
| // Extract entire archive | ||
| if err := extractArchive(archiveFile.Name(), tempDir); err != nil { |
Member
There was a problem hiding this comment.
In some cases, container checkpoints can be very large (>100 GB). Extracting the entire archive then recreating it again is not the best way of implementing this edit operation. Perhaps we can avoid both temporary storage requirements and unnecessary I/O by using a streaming tar reader/writer and replace the modified CRIU image on the fly.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This PR implements the remapping of TCP listen ports in container checkpoint archives, addressing issue #169. This provides functionality similar to the --tcp-listen-remap\ option of \criu-image-streamer\ or the \edit_files_img.py\ script.
Changes
emap\ command to checkpointctl
Usage
The command accepts port mappings in the format \old_port:new_port:
\\�ash
checkpointctl remap checkpoint.tar --tcp-listen-remap 8080:80
\\
Multiple port mappings can be specified by separating them with commas:
\\�ash
checkpointctl remap checkpoint.tar --tcp-listen-remap 8080:80,8443:443
\\
Technical Details
Related Issue
Closes #169
Testing
The implementation:
All code changes are well-documented with comments explaining the functionality.