Last active
March 11, 2024 12:48
-
-
Save zigelboim-misha/5ab773db45d90304e88d1ab3a0150e0a to your computer and use it in GitHub Desktop.
Changing the default MTU on a MacOS Docker Desktop to allow Linking XDP eBPF programs
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
| { | |
| "mtu": 1500 | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Could not attach XDP program: create link: numerical result out of range
The error from the title occurred while trying to link an
ebpfprogram to the kernelsXDPon my MacOS from inside a docker container.Here is the source code - https://github.com/cilium/ebpf/blob/main/examples/xdp/main.go
It's from ciliums example repository.
Running The eBPF Program
I have this
clangfile this I want to link onto my kernel:This should count how many packets each protocol had up to this moment. To compile it we use
go generate. It then generates some.oand.gofiles that ourGolangprogram can use.The following
Golangfile loads theclangonto the kernel:By running
go buildwe create the executable, that we will run to run ourebpfprogram.The Problem
When I tried running the executable with the network interface
eth0I received the following error:Me and my co-founders thought it's connected to the network interface
eth0but did not have a clue on how to check it.Maybe MacOS has problems with
eth0anden0or something similar as usingloinstead ofeth0worked as planned.Fix
After chatting with 2 nice guys on
ebpfs slack - here is a link to the full discussion https://cilium.slack.com/archives/C4XCTGYEM/p1710150479896969We understood that's the problem is the
MTUon my host machine (my new MacBook 14 Pro M2 Pro), the MacOSs defaultMTUvalue is too big:I had to change the default value for
com.docker.network.driver.mtufrom65535to1500:Now it looks like this:
And I can count the packets:
References