-
Notifications
You must be signed in to change notification settings - Fork 298
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
Implement XDP map types #527
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
ec8293a
aya: Implement XDP Map Types
dave-tucker e90d521
bpf: Implement XDP maps
dave-tucker ede3e91
aya: Update XDP maps implementations
Tuetuopay ad3087d
bpf: Update XDP maps implementation
Tuetuopay 4452364
macros: add 'map' option to xdp macro
Tuetuopay 139f382
aya: add support for map-bound XDP programs
Tuetuopay 0647927
xdp: add support for chained xdp programs in {cpu,dev}map
Tuetuopay f7fbbcd
aya: fix docstring missing trailing period
Tuetuopay db49633
bpf: make xdp maps functions safe
Tuetuopay 9ed1d3d
bpf: add documentation for XDP maps
Tuetuopay c6754c6
maps/xdp: use ProgramFd instead of impl AsRawFd
Tuetuopay 63ce2f0
bpf/devmap: don't expose `bpf_devmap_value`
Tuetuopay 00dc7a5
maps/xdp: make maps work on kernels not supporting ProgIds
Tuetuopay 46551de
xtask: bless public-api
Tuetuopay 579e3ce
aya, bpf: misc fixes following review comments
Tuetuopay 0edc13b
bpf: add a shared try_redirect_map function for XDP maps
Tuetuopay 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 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 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//! XDP programs. | ||
|
||
use crate::generated::bpf_attach_type; | ||
|
||
/// Defines where to attach an `XDP` program. | ||
#[derive(Copy, Clone, Debug)] | ||
pub enum XdpAttachType { | ||
/// Attach to a network interface. | ||
Interface, | ||
/// Attach to a cpumap. Requires kernel 5.9 or later. | ||
CpuMap, | ||
/// Attach to a devmap. Requires kernel 5.8 or later. | ||
DevMap, | ||
} | ||
|
||
impl From<XdpAttachType> for bpf_attach_type { | ||
fn from(value: XdpAttachType) -> Self { | ||
match value { | ||
XdpAttachType::Interface => bpf_attach_type::BPF_XDP, | ||
XdpAttachType::CpuMap => bpf_attach_type::BPF_XDP_CPUMAP, | ||
XdpAttachType::DevMap => bpf_attach_type::BPF_XDP_DEVMAP, | ||
} | ||
} | ||
} |
This file contains 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
Oops, something went wrong.
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.
This comment is confusing. You get jumbo frames even without frags, they're just
always linearised
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.
uuuh no, unless I'm mistaken, you cannot attach an xdp program not marked frags on an interface where the mtu is greater than page size - headroom. I've only managed to do it on mellanox connectx-6 hardware with a vendor-specific flag turned on with ethtool and the frags option. afaik only mlx5 and i40e have support for frags (and i40e was non-functional last time I tried)
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 don't think so? Maybe it depends on the attach mode? On aws I've definitely
worked with 9001 bytes large frames with regular (no frags) xdp programs
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.
AFAIK you can attach a non-frags program to a jumbo frame-enabled interface just fine - where jumbo frames mean MTU set to anything with MTU > 1500. Without frags support, you only get up to a page of data.
I'll double-check this next week though.
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.
you can as long as the jumbo frame + xdp headroom fits in a page (4096 bytes):
ebpf:
then the userspace either one or the other depending on the
--frags
flag:testing on a connectx-6 dx nic:
so yes, with jumbo being "anything above > 1500 bytes", frags are not always required. however, this is the strict definition of jumbo, while the usual definition is mtu 9k, in which case frags are definitely always required. this comes from the fact that, for performance reasons, xdp contexts including payload and head/tailroom is required to fit in a single page. packets thus get fragmented with pointers to other frags if it does not fit in a single page. the kernel requires this opt-in as the packet is not linear anymore, and the program needs some bpf helpers to access the payload further.
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.
ha missed this part. yes skb mode does not have this restriction, and will linearize the data. driver mode however is another beast, and to get the most of your hardware is required. on virtualized stuff it does not really matter, because unless the host does nic vf + pcie passthrough, it's quite likely it already generated a sk_buff for the packet, and passed it directly to the gest because virtio. (dunno about ena tho)