samples/bpf: fix compilation failure
following commit: commitd58e468b11
("flow_dissector: implements flow dissector BPF hook") added struct bpf_flow_keys which conflicts with the struct with same name in sockex2_kern.c and sockex3_kern.c similar to commit: commit534e0e52bc
("samples/bpf: fix a compilation failure") we tried the rename it "flow_keys" but it also conflicted with struct having same name in include/net/flow_dissector.h. Hence renaming the struct to "flow_key_record". Also, this commit doesn't fix the compilation error completely because the similar struct is present in sockex3_kern.c. Hence renaming it in both files sockex3_user.c and sockex3_kern.c Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp> Acked-by: Song Liu <songliubraving@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
This commit is contained in:
parent
2dfd184abd
commit
32c0097983
@ -14,7 +14,7 @@ struct vlan_hdr {
|
|||||||
__be16 h_vlan_encapsulated_proto;
|
__be16 h_vlan_encapsulated_proto;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct bpf_flow_keys {
|
struct flow_key_record {
|
||||||
__be32 src;
|
__be32 src;
|
||||||
__be32 dst;
|
__be32 dst;
|
||||||
union {
|
union {
|
||||||
@ -59,7 +59,7 @@ static inline __u32 ipv6_addr_hash(struct __sk_buff *ctx, __u64 off)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline __u64 parse_ip(struct __sk_buff *skb, __u64 nhoff, __u64 *ip_proto,
|
static inline __u64 parse_ip(struct __sk_buff *skb, __u64 nhoff, __u64 *ip_proto,
|
||||||
struct bpf_flow_keys *flow)
|
struct flow_key_record *flow)
|
||||||
{
|
{
|
||||||
__u64 verlen;
|
__u64 verlen;
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ static inline __u64 parse_ip(struct __sk_buff *skb, __u64 nhoff, __u64 *ip_proto
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline __u64 parse_ipv6(struct __sk_buff *skb, __u64 nhoff, __u64 *ip_proto,
|
static inline __u64 parse_ipv6(struct __sk_buff *skb, __u64 nhoff, __u64 *ip_proto,
|
||||||
struct bpf_flow_keys *flow)
|
struct flow_key_record *flow)
|
||||||
{
|
{
|
||||||
*ip_proto = load_byte(skb,
|
*ip_proto = load_byte(skb,
|
||||||
nhoff + offsetof(struct ipv6hdr, nexthdr));
|
nhoff + offsetof(struct ipv6hdr, nexthdr));
|
||||||
@ -96,7 +96,8 @@ static inline __u64 parse_ipv6(struct __sk_buff *skb, __u64 nhoff, __u64 *ip_pro
|
|||||||
return nhoff;
|
return nhoff;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool flow_dissector(struct __sk_buff *skb, struct bpf_flow_keys *flow)
|
static inline bool flow_dissector(struct __sk_buff *skb,
|
||||||
|
struct flow_key_record *flow)
|
||||||
{
|
{
|
||||||
__u64 nhoff = ETH_HLEN;
|
__u64 nhoff = ETH_HLEN;
|
||||||
__u64 ip_proto;
|
__u64 ip_proto;
|
||||||
@ -198,7 +199,7 @@ struct bpf_map_def SEC("maps") hash_map = {
|
|||||||
SEC("socket2")
|
SEC("socket2")
|
||||||
int bpf_prog2(struct __sk_buff *skb)
|
int bpf_prog2(struct __sk_buff *skb)
|
||||||
{
|
{
|
||||||
struct bpf_flow_keys flow = {};
|
struct flow_key_record flow = {};
|
||||||
struct pair *value;
|
struct pair *value;
|
||||||
u32 key;
|
u32 key;
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ struct vlan_hdr {
|
|||||||
__be16 h_vlan_encapsulated_proto;
|
__be16 h_vlan_encapsulated_proto;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct bpf_flow_keys {
|
struct flow_key_record {
|
||||||
__be32 src;
|
__be32 src;
|
||||||
__be32 dst;
|
__be32 dst;
|
||||||
union {
|
union {
|
||||||
@ -88,7 +88,7 @@ static inline __u32 ipv6_addr_hash(struct __sk_buff *ctx, __u64 off)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct globals {
|
struct globals {
|
||||||
struct bpf_flow_keys flow;
|
struct flow_key_record flow;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct bpf_map_def SEC("maps") percpu_map = {
|
struct bpf_map_def SEC("maps") percpu_map = {
|
||||||
@ -114,14 +114,14 @@ struct pair {
|
|||||||
|
|
||||||
struct bpf_map_def SEC("maps") hash_map = {
|
struct bpf_map_def SEC("maps") hash_map = {
|
||||||
.type = BPF_MAP_TYPE_HASH,
|
.type = BPF_MAP_TYPE_HASH,
|
||||||
.key_size = sizeof(struct bpf_flow_keys),
|
.key_size = sizeof(struct flow_key_record),
|
||||||
.value_size = sizeof(struct pair),
|
.value_size = sizeof(struct pair),
|
||||||
.max_entries = 1024,
|
.max_entries = 1024,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void update_stats(struct __sk_buff *skb, struct globals *g)
|
static void update_stats(struct __sk_buff *skb, struct globals *g)
|
||||||
{
|
{
|
||||||
struct bpf_flow_keys key = g->flow;
|
struct flow_key_record key = g->flow;
|
||||||
struct pair *value;
|
struct pair *value;
|
||||||
|
|
||||||
value = bpf_map_lookup_elem(&hash_map, &key);
|
value = bpf_map_lookup_elem(&hash_map, &key);
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#define PARSE_IP_PROG_FD (prog_fd[0])
|
#define PARSE_IP_PROG_FD (prog_fd[0])
|
||||||
#define PROG_ARRAY_FD (map_fd[0])
|
#define PROG_ARRAY_FD (map_fd[0])
|
||||||
|
|
||||||
struct flow_keys {
|
struct flow_key_record {
|
||||||
__be32 src;
|
__be32 src;
|
||||||
__be32 dst;
|
__be32 dst;
|
||||||
union {
|
union {
|
||||||
@ -64,7 +64,7 @@ int main(int argc, char **argv)
|
|||||||
(void) f;
|
(void) f;
|
||||||
|
|
||||||
for (i = 0; i < 5; i++) {
|
for (i = 0; i < 5; i++) {
|
||||||
struct flow_keys key = {}, next_key;
|
struct flow_key_record key = {}, next_key;
|
||||||
struct pair value;
|
struct pair value;
|
||||||
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user