Skip to content
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

Merged
merged 1 commit into from
Nov 17, 2021
Merged

Link: add XDP support #484

merged 1 commit into from
Nov 17, 2021

Conversation

mehrdadrad
Copy link
Contributor

This new API: AttachXDP links an XDP program to an interface through BPF_LINK_CREATE.

@mehrdadrad mehrdadrad changed the title Add XDP support Link: add XDP support Nov 12, 2021
link/xdp.go Outdated Show resolved Hide resolved
link/xdp.go Outdated Show resolved Hide resolved
link/xdp.go Outdated Show resolved Hide resolved
link/xdp.go Outdated Show resolved Hide resolved
link/xdp.go Outdated Show resolved Hide resolved
link/xdp_test.go Outdated Show resolved Hide resolved
@mehrdadrad mehrdadrad requested a review from lmb November 15, 2021 04:22
link/xdp_test.go Outdated Show resolved Hide resolved
link/xdp.go Outdated Show resolved Hide resolved
link/xdp_test.go Show resolved Hide resolved
@mehrdadrad mehrdadrad requested a review from lmb November 15, 2021 16:39
link/xdp.go Outdated
// Interface is the interface index to attach program to.
Interface int

// Flags must match the attach flag of XDP.
Copy link
Collaborator

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).

Copy link
Contributor Author

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")
Copy link
Collaborator

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

Copy link
Contributor Author

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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

net.InterfaceByName?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

link/xdp_test.go Outdated
},
})

err = l.Close()
Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

@mehrdadrad mehrdadrad requested a review from lmb November 17, 2021 16:35
@lmb
Copy link
Collaborator

lmb commented Nov 17, 2021

Thanks!

@lmb lmb merged commit 03191fa into cilium:master Nov 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants