-
Notifications
You must be signed in to change notification settings - Fork 106
Add docs on using pmm (packet manipulation module) bf_pktpy, and option to select pmm by env variable #213
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
Merged
jafingerhut
merged 24 commits into
p4lang:main
from
jafingerhut:add-docs-on-using-bf-pktpy
Mar 14, 2025
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
5e5612e
Add documentation on using packet manipulation module bf_pktpy
jafingerhut dbfb87e
Add more Python packages required when you want to use `bf-pktpy`
jafingerhut 3acec26
Merge branch 'main' of https://github.com/p4lang/ptf into add-docs-on…
jafingerhut 92527b9
Merge branch 'add-docs-on-using-bf-pktpy' of github.com:jafingerhut/p…
jafingerhut 52566d6
Merge remote-tracking branch 'up/main' into add-docs-on-using-bf-pktpy
jafingerhut 42311e3
Implement environment variable as one way to choose packet manip module
jafingerhut 69487c9
Reformat Python code with black
jafingerhut f299e5c
Correct logic in program ptf for selecting pmm
jafingerhut 120b520
Remove unnecessary white space change
jafingerhut 61adee9
Fix CI build
jafingerhut 6fa5d4f
Merge remote-tracking branch 'up/main' into add-docs-on-using-bf-pktpy
jafingerhut 6274b3a
Corrections to README, and mention env var method of configuration
jafingerhut 32ece7e
Make more function names usable via ptf when common in bf-pktpy and s…
jafingerhut 7496fef
Merge branch 'add-docs-on-using-bf-pktpy' of github.com:jafingerhut/p…
jafingerhut 8f529d1
Run black formatter on code.
jafingerhut 9b0db69
More output during CI to help analyze failures
jafingerhut a7c0f92
Try using Python venv when running tests
jafingerhut 7db732d
More debug output
jafingerhut e9f8950
Make each new shell use venv
jafingerhut 9cef279
Eliminate some debug output
jafingerhut 72ca744
Merge remote-tracking branch 'up/main' into add-docs-on-using-bf-pktpy
jafingerhut a8d6eb0
Merge branch 'add-docs-on-using-bf-pktpy' of github.com:jafingerhut/p…
jafingerhut 4622182
Address review comment.
jafingerhut 87e6c62
Fix typo
jafingerhut File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -97,8 +97,6 @@ config_default = { | |
| "test_case_timeout": None, | ||
| # Socket options | ||
| "socket_recv_size": 4096, | ||
| # Packet manipulation provider module | ||
| "packet_manipulation_module": "ptf.packet_scapy", | ||
| # Other configuration | ||
| "port_map": None, | ||
| } | ||
|
|
@@ -435,6 +433,21 @@ be subtracted from the result by prefixing them with the '^' character. """ | |
| config = config_default.copy() | ||
| for key in config.keys(): | ||
| config[key] = getattr(args, key) | ||
| # For selecting the packet manipulation module when running the | ||
| # `ptf` command, the order of precedence is: | ||
| # (1) If the `--packet-manipulation-module` command line option is | ||
| # present, use its value. | ||
| # (2) Otherwise, if the environment variable | ||
| # PTF_PACKET_MANIPULATION_MODULE is defined, use its value. | ||
| # (3) Otherwise, use "ptf.packet_scapy" | ||
| pmm_key = "packet_manipulation_module" | ||
| if getattr(args, pmm_key): | ||
| # Then use the value from the command line option. | ||
| config[pmm_key] = getattr(args, pmm_key) | ||
| elif os.getenv("PTF_PACKET_MANIPULATION_MODULE"): | ||
| config[pmm_key] = os.getenv("PTF_PACKET_MANIPULATION_MODULE") | ||
| else: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. elif? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated in commit 23 |
||
| config[pmm_key] = "ptf.packet_scapy" | ||
|
|
||
| return (config, args) | ||
|
|
||
|
|
||
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
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
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.
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.
We should consider making that module standalone or upstreaming it to PTF.
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.
I have a temporary repo with only the bf_pkpy code by itself here, and it does allow one to pip install it just fine in my testing: https://github.com/jafingerhut/bf-pktpy
I don't have a big opinion on whether open-p4studio should be modified to install it from a new https://github.com/p4lang/bf-pktpy repo, or if we end up with 2 copies of it.
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.
I think it is easiest to vendor it as part of ptf, because it is specially built for this use case.
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.
Are you thinking an arrangement where
pip install ptfinstalls code such that you can then doimport ptfand/orimport bf_pktpy?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.
Yes, partially for convenience. Partially because bf_pktpy is specialized towards PTF and this coupling makes sure its functionality is scoped for PTF-style use cases.