samples/bpf: xdp2skb_meta comment explain why pkt-data pointers are invalidated
Improve the 'unknown reason' comment, with an actual explaination of why
the ctx pkt-data pointers need to be loaded after the helper function
bpf_xdp_adjust_meta(). Based on the explaination Daniel gave.
Fixes: 36e04a2d78
("samples/bpf: xdp2skb_meta shows transferring info from XDP to SKB")
Reported-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
This commit is contained in:
parent
cda18e9726
commit
e2e3224122
@ -35,15 +35,17 @@ int _xdp_mark(struct xdp_md *ctx)
|
|||||||
void *data, *data_end;
|
void *data, *data_end;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Reserve space in-front data pointer for our meta info.
|
/* Reserve space in-front of data pointer for our meta info.
|
||||||
* (Notice drivers not supporting data_meta will fail here!)
|
* (Notice drivers not supporting data_meta will fail here!)
|
||||||
*/
|
*/
|
||||||
ret = bpf_xdp_adjust_meta(ctx, -(int)sizeof(*meta));
|
ret = bpf_xdp_adjust_meta(ctx, -(int)sizeof(*meta));
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return XDP_ABORTED;
|
return XDP_ABORTED;
|
||||||
|
|
||||||
/* For some unknown reason, these ctx pointers must be read
|
/* Notice: Kernel-side verifier requires that loading of
|
||||||
* after bpf_xdp_adjust_meta, else verifier will reject prog.
|
* ctx->data MUST happen _after_ helper bpf_xdp_adjust_meta(),
|
||||||
|
* as pkt-data pointers are invalidated. Helpers that require
|
||||||
|
* this are determined/marked by bpf_helper_changes_pkt_data()
|
||||||
*/
|
*/
|
||||||
data = (void *)(unsigned long)ctx->data;
|
data = (void *)(unsigned long)ctx->data;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user