Revert "tc: fix compilation with old gcc (< 4.6)"

This reverts commit 8f80d450c3.
This commit is contained in:
Stephen Hemminger 2016-01-18 09:37:38 -08:00
parent 92a0236a3c
commit bc223ab861
1 changed files with 21 additions and 27 deletions

View File

@ -257,14 +257,12 @@ static bool bpf_may_skip_map_creation(int file_fd)
static int bpf_create_map(enum bpf_map_type type, unsigned int size_key, static int bpf_create_map(enum bpf_map_type type, unsigned int size_key,
unsigned int size_value, unsigned int max_elem) unsigned int size_value, unsigned int max_elem)
{ {
union bpf_attr attr; union bpf_attr attr = {
.map_type = type,
memset(&attr, 0, sizeof(attr)); .key_size = size_key,
.value_size = size_value,
attr.map_type = type; .max_entries = max_elem,
attr.key_size = size_key; };
attr.value_size = size_value;
attr.max_entries = max_elem;
return bpf(BPF_MAP_CREATE, &attr, sizeof(attr)); return bpf(BPF_MAP_CREATE, &attr, sizeof(attr));
} }
@ -272,14 +270,12 @@ static int bpf_create_map(enum bpf_map_type type, unsigned int size_key,
static int bpf_update_map(int fd, const void *key, const void *value, static int bpf_update_map(int fd, const void *key, const void *value,
uint64_t flags) uint64_t flags)
{ {
union bpf_attr attr; union bpf_attr attr = {
.map_fd = fd,
memset(&attr, 0, sizeof(attr)); .key = bpf_ptr_to_u64(key),
.value = bpf_ptr_to_u64(value),
attr.map_fd = fd; .flags = flags,
attr.key = bpf_ptr_to_u64(key); };
attr.value = bpf_ptr_to_u64(value);
attr.flags = flags;
return bpf(BPF_MAP_UPDATE_ELEM, &attr, sizeof(attr)); return bpf(BPF_MAP_UPDATE_ELEM, &attr, sizeof(attr));
} }
@ -287,17 +283,15 @@ static int bpf_update_map(int fd, const void *key, const void *value,
static int bpf_prog_load(enum bpf_prog_type type, const struct bpf_insn *insns, static int bpf_prog_load(enum bpf_prog_type type, const struct bpf_insn *insns,
unsigned int len, const char *license) unsigned int len, const char *license)
{ {
union bpf_attr attr; union bpf_attr attr = {
.prog_type = type,
memset(&attr, 0, sizeof(attr)); .insns = bpf_ptr_to_u64(insns),
.insn_cnt = len / sizeof(struct bpf_insn),
attr.prog_type = type; .license = bpf_ptr_to_u64(license),
attr.insns = bpf_ptr_to_u64(insns); .log_buf = bpf_ptr_to_u64(bpf_log_buf),
attr.insn_cnt = len / sizeof(struct bpf_insn); .log_size = sizeof(bpf_log_buf),
attr.license = bpf_ptr_to_u64(license); .log_level = 1,
attr.log_buf = bpf_ptr_to_u64(bpf_log_buf); };
attr.log_size = sizeof(bpf_log_buf);
attr.log_level = 1;
return bpf(BPF_PROG_LOAD, &attr, sizeof(attr)); return bpf(BPF_PROG_LOAD, &attr, sizeof(attr));
} }