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

[lwtunnel bpf] add support for encap BPF #645

Merged
merged 1 commit into from
Jul 3, 2021

Conversation

bersoare
Copy link
Contributor

@bersoare bersoare commented Apr 21, 2021

this patch adds a new type for encap BPF, allowing FD and NAME to be set for programs, as well as the XMIT headroom.
bpf loading not included in this patch, but the bpf program can be loaded using a 3rd party library

example usage:

	fmt.Printf("prog fd: %d\n", prog.GetFd()) // loaded program, exposing its FD (it is pinned in this case)
	encap := netlink.BPFEncap{}
	err = encap.SetProg(nl.LWT_BPF_XMIT, prog.GetFd(), "mytest123")
	if err != nil {
		panic(err)
	}
	err = encap.SetXmitHeadroom(128)
	if err != nil {
		panic(err)
	}
	_, dst, _ := net.ParseCIDR("192.168.123.12/32")
	newRoute := &netlink.Route{Dst: dst, LinkIndex: link.Attrs().Index, Encap: &encap}
	err = handle.RouteAdd(newRoute)
	if err != nil {
		panic(err)
	}

result of the above code:

# ip ro sh | grep mytest
192.168.123.12  encap bpf xmit mytest123[fd:3] dev bareudp0

@bersoare
Copy link
Contributor Author

Alt Text

@aboch
Copy link
Collaborator

aboch commented May 30, 2021

please squash your commits into one

add bpf program types

add unit tests

don't use strings to determine type

fix camel case
@aboch aboch merged commit 079db23 into vishvananda:master Jul 3, 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.

2 participants