xdp-tutorial icon indicating copy to clipboard operation
xdp-tutorial copied to clipboard

bpf_fib_lookup write equivalent?

Open PolynomialDivision opened this issue 3 years ago • 6 comments

Is there a way to write into the kernel table? The only option currently that I see is to poll a map from userspace and do a write then, or?

PolynomialDivision avatar Feb 26 '21 21:02 PolynomialDivision

Polynomdivision [email protected] writes:

Is there a way to write into the kernel table?

Not from BPF; you'd need to do that from userspace.

The only option currently that I see is to poll a map and do a write then, or?

To do what? What, exactly, is your use case?

tohojo avatar Feb 26 '21 22:02 tohojo

To do what? What, exactly, is your use case?

We switched in our community wireless mesh network (freifunk) to babeld and I would like to interact with the daemon. :) Typically, you use some proto number and install a redistribute route for that proto. Here, I would like for example just install a "/128" route for a new client, if I see some IP from another prefix on the client interface, so layer 3 roaming works.

PolynomialDivision avatar Feb 26 '21 22:02 PolynomialDivision

So I would probably write into a map and just poll it and use netlink to interace with kernel again... ^^ But this takes unnecessary CPU, or? Or is there some mechanism I can use that just interacts if new data is available in a map?

BTW, I have no idea if this will work but I heard other people do similar things to enable layer 3 roaming. xD

PolynomialDivision avatar Feb 26 '21 22:02 PolynomialDivision

Polynomdivision [email protected] writes:

To do what? What, exactly, is your use case?

We switched in our community wireless mesh network (freifunk) to babeld and I would like to interact with the daemon. :) Typically, you use some proto number and install a redistribute route for that proto. Here, I would like for example just install a "/128" route for a new client, if I see some IP from another prefix on the client interface, so layer 3 raoming works.

Ah, I see. For that I'd suggest using the bpf_perf_event_output() helper to send events to userspace. You can have a userspace process that listens for those events and updates the routing table accordingly.

The pping program does something similar to output its data points. See the sender side in XDP here:

https://github.com/xdp-project/bpf-examples/blob/master/pping/pping_kern_xdp.c#L57

And the userspace reader side here: https://github.com/xdp-project/bpf-examples/blob/master/pping/pping.c#L392

tohojo avatar Feb 26 '21 22:02 tohojo

Polynomdivision [email protected] writes:

BTW, I have no idea if this will work but I heard other people do similar things to enable layer 3 roaming. xD

Are you aware of https://alioth-lists.debian.net/pipermail/babel-users/2020-April/003692.html ?

tohojo avatar Feb 26 '21 22:02 tohojo

I was not aware of that. Wow, thanks! :)

PolynomialDivision avatar Feb 26 '21 23:02 PolynomialDivision