UPSTREAM: bpf: Allow to change skb mark in test_run

allow to pass skb's mark field into bpf_prog_test_run ctx
for BPF_PROG_TYPE_SCHED_CLS prog type. that would allow
to test bpf programs which are doing decision based on this
field

Change-Id: Id05ce69ad66d1635c4c839e28d389d7c80b38a02
Signed-off-by: Nikita V. Shirokov <[email protected]>
Signed-off-by: Alexei Starovoitov <[email protected]>
This commit is contained in:
Nikita V. Shirokov 2019-12-18 12:57:47 -08:00 • committed by basamaryan
commit b8909f104c
No known key found for this signature in database
GPG key ID: 210D5384FB2A5885
3 changed files with 15 additions and 1 deletions

View file

@ -13,6 +13,7 @@ void test_skb_ctx(void)
.tstamp = 7,
.wire_len = 100,
.gso_segs = 8,
.mark = 9,
};
struct bpf_prog_test_run_attr tattr = {
.data_in = &pkt_v4,
@ -93,4 +94,8 @@ void test_skb_ctx(void)
"ctx_out_tstamp",
"skb->tstamp == %lld, expected %d\n",
skb.tstamp, 8);
CHECK_ATTR(skb.mark != 10,
"ctx_out_mark",
"skb->mark == %u, expected %d\n",
skb.mark, 10);
}

View file

@ -17,6 +17,7 @@ int process(struct __sk_buff *skb)
}
skb->priority++;
skb->tstamp++;
skb->mark++;
if (skb->wire_len != 100)
return 1;