* [PATCH iproute2] tc: fix compilation with old gcc (< 4.6)
@ 2016-01-07 13:03 Nicolas Dichtel
2016-01-07 13:31 ` Daniel Borkmann
2016-01-11 16:28 ` Stephen Hemminger
0 siblings, 2 replies; 5+ messages in thread
From: Nicolas Dichtel @ 2016-01-07 13:03 UTC (permalink / raw)
To: shemminger; +Cc: netdev, daniel, Julien Floret, Nicolas Dichtel
From: Julien Floret <julien.floret@6wind.com>
gcc < 4.6 does not handle C11 syntax for the static initialization of
anonymous struct/union, hence the following error:
tc_bpf.c:260: error: unknown field map_type specified in initializer
Signed-off-by: Julien Floret <julien.floret@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
tc/tc_bpf.c | 48 +++++++++++++++++++++++++++---------------------
1 file changed, 27 insertions(+), 21 deletions(-)
diff --git a/tc/tc_bpf.c b/tc/tc_bpf.c
index 276871a5c0a5..47993bad81ca 100644
--- a/tc/tc_bpf.c
+++ b/tc/tc_bpf.c
@@ -257,12 +257,14 @@ static bool bpf_may_skip_map_creation(int file_fd)
static int bpf_create_map(enum bpf_map_type type, unsigned int size_key,
unsigned int size_value, unsigned int max_elem)
{
- union bpf_attr attr = {
- .map_type = type,
- .key_size = size_key,
- .value_size = size_value,
- .max_entries = max_elem,
- };
+ union bpf_attr attr;
+
+ memset(&attr, 0, sizeof(attr));
+
+ attr.map_type = type;
+ attr.key_size = size_key;
+ attr.value_size = size_value;
+ attr.max_entries = max_elem;
return bpf(BPF_MAP_CREATE, &attr, sizeof(attr));
}
@@ -270,12 +272,14 @@ 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,
uint64_t flags)
{
- union bpf_attr attr = {
- .map_fd = fd,
- .key = bpf_ptr_to_u64(key),
- .value = bpf_ptr_to_u64(value),
- .flags = flags,
- };
+ union bpf_attr attr;
+
+ memset(&attr, 0, sizeof(attr));
+
+ attr.map_fd = fd;
+ 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));
}
@@ -283,15 +287,17 @@ 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,
unsigned int len, const char *license)
{
- union bpf_attr attr = {
- .prog_type = type,
- .insns = bpf_ptr_to_u64(insns),
- .insn_cnt = len / sizeof(struct bpf_insn),
- .license = bpf_ptr_to_u64(license),
- .log_buf = bpf_ptr_to_u64(bpf_log_buf),
- .log_size = sizeof(bpf_log_buf),
- .log_level = 1,
- };
+ union bpf_attr attr;
+
+ memset(&attr, 0, sizeof(attr));
+
+ attr.prog_type = type;
+ attr.insns = bpf_ptr_to_u64(insns);
+ attr.insn_cnt = len / sizeof(struct bpf_insn);
+ attr.license = bpf_ptr_to_u64(license);
+ 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));
}
--
2.4.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH iproute2] tc: fix compilation with old gcc (< 4.6)
2016-01-07 13:03 [PATCH iproute2] tc: fix compilation with old gcc (< 4.6) Nicolas Dichtel
@ 2016-01-07 13:31 ` Daniel Borkmann
2016-01-07 13:56 ` Daniel Borkmann
2016-01-11 16:28 ` Stephen Hemminger
1 sibling, 1 reply; 5+ messages in thread
From: Daniel Borkmann @ 2016-01-07 13:31 UTC (permalink / raw)
To: Nicolas Dichtel, shemminger; +Cc: netdev, Julien Floret
On 01/07/2016 02:03 PM, Nicolas Dichtel wrote:
> From: Julien Floret <julien.floret@6wind.com>
>
> gcc < 4.6 does not handle C11 syntax for the static initialization of
> anonymous struct/union, hence the following error:
>
> tc_bpf.c:260: error: unknown field map_type specified in initializer
>
> Signed-off-by: Julien Floret <julien.floret@6wind.com>
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Thanks!
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH iproute2] tc: fix compilation with old gcc (< 4.6)
2016-01-07 13:31 ` Daniel Borkmann
@ 2016-01-07 13:56 ` Daniel Borkmann
2016-01-07 16:21 ` Nicolas Dichtel
0 siblings, 1 reply; 5+ messages in thread
From: Daniel Borkmann @ 2016-01-07 13:56 UTC (permalink / raw)
To: Nicolas Dichtel, shemminger; +Cc: netdev, Julien Floret
On 01/07/2016 02:31 PM, Daniel Borkmann wrote:
> On 01/07/2016 02:03 PM, Nicolas Dichtel wrote:
>> From: Julien Floret <julien.floret@6wind.com>
>>
>> gcc < 4.6 does not handle C11 syntax for the static initialization of
>> anonymous struct/union, hence the following error:
>>
>> tc_bpf.c:260: error: unknown field map_type specified in initializer
>>
>> Signed-off-by: Julien Floret <julien.floret@6wind.com>
>> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
>
> Thanks!
>
> Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Btw, for iproute2's net-next branch there're couple of other occasions
as well. Stephen, how do you prefer to handle this? Should a separate
patch be done against net-next branch to reduce merge conflicts?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH iproute2] tc: fix compilation with old gcc (< 4.6)
2016-01-07 13:56 ` Daniel Borkmann
@ 2016-01-07 16:21 ` Nicolas Dichtel
0 siblings, 0 replies; 5+ messages in thread
From: Nicolas Dichtel @ 2016-01-07 16:21 UTC (permalink / raw)
To: Daniel Borkmann, shemminger; +Cc: netdev, Julien Floret
Le 07/01/2016 14:56, Daniel Borkmann a écrit :
> Btw, for iproute2's net-next branch there're couple of other occasions
> as well. Stephen, how do you prefer to handle this? Should a separate
> patch be done against net-next branch to reduce merge conflicts?
Thank you Daniel for noticing it.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH iproute2] tc: fix compilation with old gcc (< 4.6)
2016-01-07 13:03 [PATCH iproute2] tc: fix compilation with old gcc (< 4.6) Nicolas Dichtel
2016-01-07 13:31 ` Daniel Borkmann
@ 2016-01-11 16:28 ` Stephen Hemminger
1 sibling, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2016-01-11 16:28 UTC (permalink / raw)
To: Nicolas Dichtel; +Cc: shemminger, netdev, daniel, Julien Floret
On Thu, 7 Jan 2016 14:03:13 +0100
Nicolas Dichtel <nicolas.dichtel@6wind.com> wrote:
> From: Julien Floret <julien.floret@6wind.com>
>
> gcc < 4.6 does not handle C11 syntax for the static initialization of
> anonymous struct/union, hence the following error:
>
> tc_bpf.c:260: error: unknown field map_type specified in initializer
>
> Signed-off-by: Julien Floret <julien.floret@6wind.com>
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-01-11 16:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-07 13:03 [PATCH iproute2] tc: fix compilation with old gcc (< 4.6) Nicolas Dichtel
2016-01-07 13:31 ` Daniel Borkmann
2016-01-07 13:56 ` Daniel Borkmann
2016-01-07 16:21 ` Nicolas Dichtel
2016-01-11 16:28 ` Stephen Hemminger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).