-
Notifications
You must be signed in to change notification settings - Fork 652
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
Link: add XDP support #484
Conversation
link/xdp.go
Outdated
// Interface is the interface index to attach program to. | ||
Interface int | ||
|
||
// Flags must match the attach flag of XDP. |
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.
Is that correct? I think you can load XDP without any flags and still force XDPDriverMode when attaching (at least that's possible via netlink).
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.
It explained more right after this line:
// Only one XDP mode should be set, without flag defaults
// to driver/generic mode (best effort).
but I just rephrased it line#29 please let me know if you want it something else.
link/xdp_test.go
Outdated
const IfIndexLO = 1 | ||
|
||
func TestAttachXDP(t *testing.T) { | ||
testutils.SkipOnOldKernel(t, "5.7", "BPF_LINK_TYPE_XDP") |
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 appeared in 5.9 I think torvalds/linux@aa8d3a7
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.
Updated.
|
||
l, err := AttachXDP(XDPOptions{ | ||
Program: prog, | ||
Interface: IfIndexLO, |
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.
net.InterfaceByName
?
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 don't need: https://github.com/torvalds/linux/blob/master/tools/testing/selftests/bpf/prog_tests/xdp_link.c#L7
But if you want I can add this instead.
link/xdp_test.go
Outdated
}, | ||
}) | ||
|
||
err = l.Close() |
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.
Not necessary, testLink closes the link I think.
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.
Removed.
Thanks! |
This new API: AttachXDP links an XDP program to an interface through BPF_LINK_CREATE.