* [PATCH iproute2] tc: fix compilation with old gcc (< 4.6) (bis)
@ 2016-01-19 11:01 Nicolas Dichtel
0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Dichtel @ 2016-01-19 11:01 UTC (permalink / raw)
To: shemminger; +Cc: netdev, julien.floret, Nicolas Dichtel, Daniel Borkmann
Commit 8f80d450c3cb ("tc: fix compilation with old gcc (< 4.6)") was reverted
to ease the merge of the net-next branch.
Here is the new version.
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
---
tc/tc_bpf.c | 58 +++++++++++++++++++++++++++++++++-------------------------
1 file changed, 33 insertions(+), 25 deletions(-)
diff --git a/tc/tc_bpf.c b/tc/tc_bpf.c
index 42c8841869f5..219ffa582c1a 100644
--- a/tc/tc_bpf.c
+++ b/tc/tc_bpf.c
@@ -49,6 +49,10 @@
#include "tc_util.h"
#include "tc_bpf.h"
+#ifndef AF_ALG
+#define AF_ALG 38
+#endif
+
#ifdef HAVE_ELF
static int bpf_obj_open(const char *path, enum bpf_prog_type type,
const char *sec, bool verbose);
@@ -81,12 +85,13 @@ static int bpf(int cmd, union bpf_attr *attr, unsigned int size)
static int bpf_map_update(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));
}
@@ -745,12 +750,13 @@ static __check_format_string(1, 2) void bpf_dump_error(const char *format, ...)
static int bpf_map_create(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));
}
@@ -758,15 +764,16 @@ static int bpf_map_create(enum bpf_map_type type, unsigned int size_key,
static int bpf_prog_load(enum bpf_prog_type type, const struct bpf_insn *insns,
size_t size, const char *license)
{
- union bpf_attr attr = {
- .prog_type = type,
- .insns = bpf_ptr_to_u64(insns),
- .insn_cnt = size / 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 = size / 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;
if (getenv(BPF_ENV_NOLOG)) {
attr.log_buf = 0;
@@ -779,10 +786,11 @@ static int bpf_prog_load(enum bpf_prog_type type, const struct bpf_insn *insns,
static int bpf_obj_pin(int fd, const char *pathname)
{
- union bpf_attr attr = {
- .pathname = bpf_ptr_to_u64(pathname),
- .bpf_fd = fd,
- };
+ union bpf_attr attr;
+
+ memset(&attr, 0, sizeof(attr));
+ attr.pathname = bpf_ptr_to_u64(pathname);
+ attr.bpf_fd = fd;
return bpf(BPF_OBJ_PIN, &attr, sizeof(attr));
}
--
2.4.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH iproute2] tc: fix compilation with old gcc (< 4.6) (bis)
2016-02-02 9:08 ` Daniel Borkmann
@ 2016-02-02 10:39 ` Nicolas Dichtel
0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Dichtel @ 2016-02-02 10:39 UTC (permalink / raw)
To: Daniel Borkmann, Stephen Hemminger; +Cc: netdev, julien.floret
Le 02/02/2016 10:08, Daniel Borkmann a écrit :
> On 02/02/2016 05:51 AM, Stephen Hemminger wrote:
>> On Tue, 19 Jan 2016 11:01:45 +0000
>> Nicolas Dichtel <nicolas.dichtel@6wind.com> wrote:
>>
>>> diff --git a/tc/tc_bpf.c b/tc/tc_bpf.c
>>> index 42c8841869f5..219ffa582c1a 100644
>>> --- a/tc/tc_bpf.c
>>> +++ b/tc/tc_bpf.c
>>> @@ -49,6 +49,10 @@
>>> #include "tc_util.h"
>>> #include "tc_bpf.h"
>>>
>>> +#ifndef AF_ALG
>>> +#define AF_ALG 38
>>> +#endif
>>
>> Why is this here? AF_ALG is not used anywhere in this code.
>
> It is used, this patch is fine as-is.
Yes, it's used and not defined with old toolchains:
$ git grep AF_ALG
tc/tc_bpf.c:#ifndef AF_ALG
tc/tc_bpf.c:#define AF_ALG 38
tc/tc_bpf.c: .salg_family = AF_ALG,
tc/tc_bpf.c: cfd = socket(AF_ALG, SOCK_SEQPACKET, 0);
tc/tc_bpf.c: fprintf(stderr, "Cannot get AF_ALG socket: %s\n",
Regards,
Nicolas
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH iproute2] tc: fix compilation with old gcc (< 4.6) (bis)
2016-02-02 4:51 ` Stephen Hemminger
@ 2016-02-02 9:08 ` Daniel Borkmann
2016-02-02 10:39 ` Nicolas Dichtel
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Borkmann @ 2016-02-02 9:08 UTC (permalink / raw)
To: Stephen Hemminger, Nicolas Dichtel; +Cc: netdev, julien.floret
On 02/02/2016 05:51 AM, Stephen Hemminger wrote:
> On Tue, 19 Jan 2016 11:01:45 +0000
> Nicolas Dichtel <nicolas.dichtel@6wind.com> wrote:
>
>> diff --git a/tc/tc_bpf.c b/tc/tc_bpf.c
>> index 42c8841869f5..219ffa582c1a 100644
>> --- a/tc/tc_bpf.c
>> +++ b/tc/tc_bpf.c
>> @@ -49,6 +49,10 @@
>> #include "tc_util.h"
>> #include "tc_bpf.h"
>>
>> +#ifndef AF_ALG
>> +#define AF_ALG 38
>> +#endif
>
> Why is this here? AF_ALG is not used anywhere in this code.
It is used, this patch is fine as-is.
Thanks!
> Please remove it and resubmit
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH iproute2] tc: fix compilation with old gcc (< 4.6) (bis)
[not found] <1f5ba49033cd4c55a0d0005487efde39@HQ1WP-EXMB11.corp.brocade.com>
@ 2016-02-02 4:51 ` Stephen Hemminger
2016-02-02 9:08 ` Daniel Borkmann
0 siblings, 1 reply; 4+ messages in thread
From: Stephen Hemminger @ 2016-02-02 4:51 UTC (permalink / raw)
To: Nicolas Dichtel; +Cc: netdev, julien.floret, Daniel Borkmann
On Tue, 19 Jan 2016 11:01:45 +0000
Nicolas Dichtel <nicolas.dichtel@6wind.com> wrote:
> diff --git a/tc/tc_bpf.c b/tc/tc_bpf.c
> index 42c8841869f5..219ffa582c1a 100644
> --- a/tc/tc_bpf.c
> +++ b/tc/tc_bpf.c
> @@ -49,6 +49,10 @@
> #include "tc_util.h"
> #include "tc_bpf.h"
>
> +#ifndef AF_ALG
> +#define AF_ALG 38
> +#endif
Why is this here? AF_ALG is not used anywhere in this code.
Please remove it and resubmit
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-02-02 10:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-19 11:01 [PATCH iproute2] tc: fix compilation with old gcc (< 4.6) (bis) Nicolas Dichtel
[not found] <1f5ba49033cd4c55a0d0005487efde39@HQ1WP-EXMB11.corp.brocade.com>
2016-02-02 4:51 ` Stephen Hemminger
2016-02-02 9:08 ` Daniel Borkmann
2016-02-02 10:39 ` Nicolas Dichtel
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).