This group is locked. No changes can be made to the group while it is locked.
Date
1 - 6 of 6
Helper functions available for XDP?
Andrew Wang
Hi I am writing a bpf program for packet processing and have loaded my ingress function at BPF.XDP. I'm updating the destination IPv6 address and want to update the TCP checksum, but when I try to call the helper functions "bpf_csum_diff" or "bpf_l4_csum_replace", I get a "unknown func <function name>". Are these functions not available for XDP program types? Is there a way to tell what helper functions are available to what program types? Thanks Andrew |
Paul Chaignon
On Mon, Jul 23, 2018 at 02:21:05PM -0400, Andrew Wang wrote:
HiXDP programs cannot use bpf_l4_csum_replace, but they can use bpf_csum_diff since commit 205c380 ("bpf: add csum_diff helper to xdp as well") which landed in v4.16-rc1. The list of helpers available to XDP programs is defined in function xdp_func_proto in file net/core/filter.c of the Linux source code. You might also want to check out pull request #1881 [1], which will document helpers available to each program type in file kernel-versions.md of bcc [2]. 1 - https://github.com/iovisor/bcc/pull/1881 2 - https://github.com/iovisor/bcc/blob/master/docs/kernel-versions.md
|
François
On Mon, Jul 23, 2018 at 10:08:08PM +0200, Paul Chaignon wrote:
On Mon, Jul 23, 2018 at 02:21:05PM -0400, Andrew Wang wrote:I was thinking maybe those helpers were not available because no skbHiXDP programs cannot use bpf_l4_csum_replace, but they can use was construct. But after checking, the helper you're mentionning is in the tc_cls. Also, the csum_diff helper lies in the same switch statement as l4_csum_replace. Can you elaborate on why one can be used and not the other? Thanks! |
Yonghong Song
On Tue, Jul 24, 2018 at 1:54 AM, François <fser@...> wrote:
On Mon, Jul 23, 2018 at 10:08:08PM +0200, Paul Chaignon wrote:bpf_csum_diff only accesses packet data and can be used in both cls_act and xdp.On Mon, Jul 23, 2018 at 02:21:05PM -0400, Andrew Wang wrote:I was thinking maybe those helpers were not available because no skbHiXDP programs cannot use bpf_l4_csum_replace, but they can use bpf_l4_csum_replace accesses skb data structure, e.g., it needs to replace the csum and hence needs to test whether skb is writable. It also different calculation based on the existing checksum state (skb->ip_summed), so bpf_l4_csum_replace cannot be used in xdp.
|
Andrew Wang
Then in this case is it possible to replace TCP checksum on ingress with XDP? How do I test if the skb is writable? On Tue, Jul 24, 2018 at 12:04 PM, Yonghong Song <ys114321@...> wrote: On Tue, Jul 24, 2018 at 1:54 AM, François <fser@...> wrote: |
Yonghong Song
On Tue, Jul 24, 2018 at 9:19 AM, Andrew Wang <andrw.wng@...> wrote:
Then in this case is it possible to replace TCP checksum on ingress withThere is no skb in XDP. The helper bpf_l4_csum_replace cannot be used. You need to use other csum functions and can directly modify the packet data.
|