]>
git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - tools/testing/selftests/bpf/test_pkt_md_access.c
1 /* Copyright (c) 2017 Facebook
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of version 2 of the GNU General Public
5 * License as published by the Free Software Foundation.
10 #include <linux/pkt_cls.h>
11 #include "bpf_helpers.h"
13 int _version
SEC("version") = 1;
15 #define TEST_FIELD(TYPE, FIELD, MASK) \
17 TYPE tmp = *(volatile TYPE *)&skb->FIELD; \
18 if (tmp != ((*(volatile __u32 *)&skb->FIELD) & MASK)) \
23 int process(struct __sk_buff
*skb
)
25 TEST_FIELD(__u8
, len
, 0xFF);
26 TEST_FIELD(__u16
, len
, 0xFFFF);
27 TEST_FIELD(__u32
, len
, 0xFFFFFFFF);
28 TEST_FIELD(__u16
, protocol
, 0xFFFF);
29 TEST_FIELD(__u32
, protocol
, 0xFFFFFFFF);
30 TEST_FIELD(__u8
, hash
, 0xFF);
31 TEST_FIELD(__u16
, hash
, 0xFFFF);
32 TEST_FIELD(__u32
, hash
, 0xFFFFFFFF);