diff mbox series

[net-next] samples/bpf: Fix compilation issue in redirect dummy program

Message ID 1504178199-12410-1-git-send-email-tariqt@mellanox.com
State Accepted, archived
Delegated to: David Miller
Headers show
Series [net-next] samples/bpf: Fix compilation issue in redirect dummy program | expand

Commit Message

Tariq Toukan Aug. 31, 2017, 11:16 a.m. UTC
Fix compilation error below:

$ make samples/bpf/

LLVM ERROR: 'xdp_redirect_dummy' label emitted multiple times to
assembly file
make[1]: *** [samples/bpf/xdp_redirect_kern.o] Error 1
make: *** [samples/bpf/] Error 2

Fixes: 306da4e685b4 ("samples/bpf: xdp_redirect load XDP dummy prog on TX device")
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
---
 samples/bpf/xdp_redirect_kern.c     | 2 +-
 samples/bpf/xdp_redirect_map_kern.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Jesper Dangaard Brouer Aug. 31, 2017, 11:27 a.m. UTC | #1
On Thu, 31 Aug 2017 14:16:39 +0300
Tariq Toukan <tariqt@mellanox.com> wrote:

> Fix compilation error below:
> 
> $ make samples/bpf/
> 
> LLVM ERROR: 'xdp_redirect_dummy' label emitted multiple times to
> assembly file
> make[1]: *** [samples/bpf/xdp_redirect_kern.o] Error 1
> make: *** [samples/bpf/] Error 2
> 
> Fixes: 306da4e685b4 ("samples/bpf: xdp_redirect load XDP dummy prog on TX device")
> Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
> ---

Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>

What LLVM/clang version do you use?

I don't see this compile error, and I have:
 $ clang --version
 clang version 3.9.1 (tags/RELEA
Daniel Borkmann Aug. 31, 2017, 11:43 a.m. UTC | #2
On 08/31/2017 01:27 PM, Jesper Dangaard Brouer wrote:
> On Thu, 31 Aug 2017 14:16:39 +0300
> Tariq Toukan <tariqt@mellanox.com> wrote:
>
>> Fix compilation error below:
>>
>> $ make samples/bpf/
>>
>> LLVM ERROR: 'xdp_redirect_dummy' label emitted multiple times to
>> assembly file
>> make[1]: *** [samples/bpf/xdp_redirect_kern.o] Error 1
>> make: *** [samples/bpf/] Error 2
>>
>> Fixes: 306da4e685b4 ("samples/bpf: xdp_redirect load XDP dummy prog on TX device")
>> Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
>> ---
>
> Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>

Acked-by: Daniel Borkmann <daniel@iogearbox.net>

> What LLVM/clang version do you use?
>
> I don't see this compile error, and I have:
>   $ clang --version
>   clang version 3.9.1 (tags/RELEA

I'm seeing the error as well with a fairly recent LLVM from git
tree (6.0.0git-2d810c2).

Looks like the llvm error is triggered when section name and
the function name for XDP prog is the same. Changing either the
function or the section name right above resolves the issue. If
such error didn't trigger on older versions, people could be
using such naming scheme as done here, so seems to me like a
regression on LLVM side we might need to look at ...

In any case, patch here is fine, thanks!
Tariq Toukan Aug. 31, 2017, 12:29 p.m. UTC | #3
On 31/08/2017 2:43 PM, Daniel Borkmann wrote:
> On 08/31/2017 01:27 PM, Jesper Dangaard Brouer wrote:
>> On Thu, 31 Aug 2017 14:16:39 +0300
>> Tariq Toukan <tariqt@mellanox.com> wrote:
>>
>>> Fix compilation error below:
>>>
>>> $ make samples/bpf/
>>>
>>> LLVM ERROR: 'xdp_redirect_dummy' label emitted multiple times to
>>> assembly file
>>> make[1]: *** [samples/bpf/xdp_redirect_kern.o] Error 1
>>> make: *** [samples/bpf/] Error 2
>>>
>>> Fixes: 306da4e685b4 ("samples/bpf: xdp_redirect load XDP dummy prog 
>>> on TX device")
>>> Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
>>> ---
>>
>> Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>
> 
> Acked-by: Daniel Borkmann <daniel@iogearbox.net>
> 
>> What LLVM/clang version do you use?

clang version 3.8.0 (tags/RELEASE_380/final)

>>
>> I don't see this compile error, and I have:
>>   $ clang --version
>>   clang version 3.9.1 (tags/RELEA
> 
> I'm seeing the error as well with a fairly recent LLVM from git
> tree (6.0.0git-2d810c2).
> 
> Looks like the llvm error is triggered when section name and
> the function name for XDP prog is the same. Changing either the
> function or the section name right above resolves the issue. If
> such error didn't trigger on older versions, people could be
> using such naming scheme as done here, so seems to me like a
> regression on LLVM side we might need to look at ...
Agreed.
> 
> In any case, patch here is fine, thanks!

Thank you.
Y Song Aug. 31, 2017, 3:54 p.m. UTC | #4
On Thu, Aug 31, 2017 at 4:43 AM, Daniel Borkmann <daniel@iogearbox.net> wrote:
> On 08/31/2017 01:27 PM, Jesper Dangaard Brouer wrote:
>>
>> On Thu, 31 Aug 2017 14:16:39 +0300
>> Tariq Toukan <tariqt@mellanox.com> wrote:
>>
>>> Fix compilation error below:
>>>
>>> $ make samples/bpf/
>>>
>>> LLVM ERROR: 'xdp_redirect_dummy' label emitted multiple times to
>>> assembly file
>>> make[1]: *** [samples/bpf/xdp_redirect_kern.o] Error 1
>>> make: *** [samples/bpf/] Error 2
>>>
>>> Fixes: 306da4e685b4 ("samples/bpf: xdp_redirect load XDP dummy prog on TX
>>> device")
>>> Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
>>> ---
>>
>>
>> Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>
>
>
> Acked-by: Daniel Borkmann <daniel@iogearbox.net>
>
>> What LLVM/clang version do you use?
>>
>> I don't see this compile error, and I have:
>>   $ clang --version
>>   clang version 3.9.1 (tags/RELEA
>
>
> I'm seeing the error as well with a fairly recent LLVM from git
> tree (6.0.0git-2d810c2).
>
> Looks like the llvm error is triggered when section name and
> the function name for XDP prog is the same. Changing either the
> function or the section name right above resolves the issue. If
> such error didn't trigger on older versions, people could be
> using such naming scheme as done here, so seems to me like a
> regression on LLVM side we might need to look at ...

Martin fixed a similar bug earlier:
=====
commit a2e8bbd2ef5457485f00b6b947bbbfa2778e5b1e
Author: Martin KaFai Lau <kafai@fb.com>
Date:   Thu Jun 8 22:30:17 2017 -0700

    bpf: Fix test_obj_id.c for llvm 5.0

    llvm 5.0 does not like the section name and the function name
    to be the same:
...
=====

gcc also has this behavior. Section name is treated as global
and hence cannot collide with a function name...
Daniel Borkmann Aug. 31, 2017, 4:20 p.m. UTC | #5
On 08/31/2017 05:54 PM, Y Song wrote:
> On Thu, Aug 31, 2017 at 4:43 AM, Daniel Borkmann <daniel@iogearbox.net> wrote:
>> On 08/31/2017 01:27 PM, Jesper Dangaard Brouer wrote:
>>> On Thu, 31 Aug 2017 14:16:39 +0300
>>> Tariq Toukan <tariqt@mellanox.com> wrote:
>>>
>>>> Fix compilation error below:
>>>>
>>>> $ make samples/bpf/
>>>>
>>>> LLVM ERROR: 'xdp_redirect_dummy' label emitted multiple times to
>>>> assembly file
>>>> make[1]: *** [samples/bpf/xdp_redirect_kern.o] Error 1
>>>> make: *** [samples/bpf/] Error 2
>>>>
>>>> Fixes: 306da4e685b4 ("samples/bpf: xdp_redirect load XDP dummy prog on TX
>>>> device")
>>>> Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
>>>> ---
>>>
>>> Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>
>>
>> Acked-by: Daniel Borkmann <daniel@iogearbox.net>
>>
>>> What LLVM/clang version do you use?
>>>
>>> I don't see this compile error, and I have:
>>>    $ clang --version
>>>    clang version 3.9.1 (tags/RELEA
>>
>> I'm seeing the error as well with a fairly recent LLVM from git
>> tree (6.0.0git-2d810c2).
>>
>> Looks like the llvm error is triggered when section name and
>> the function name for XDP prog is the same. Changing either the
>> function or the section name right above resolves the issue. If
>> such error didn't trigger on older versions, people could be
>> using such naming scheme as done here, so seems to me like a
>> regression on LLVM side we might need to look at ...
>
> Martin fixed a similar bug earlier:
> =====
> commit a2e8bbd2ef5457485f00b6b947bbbfa2778e5b1e
> Author: Martin KaFai Lau <kafai@fb.com>
> Date:   Thu Jun 8 22:30:17 2017 -0700
>
>      bpf: Fix test_obj_id.c for llvm 5.0
>
>      llvm 5.0 does not like the section name and the function name
>      to be the same:
> ...
> =====

Yeah indeed.

> gcc also has this behavior. Section name is treated as global
> and hence cannot collide with a function name...

Okay, so seems at least 3.9.1 treated this slightly different then
where it didn't cause a collision.
David Miller Aug. 31, 2017, 6:58 p.m. UTC | #6
From: Tariq Toukan <tariqt@mellanox.com>
Date: Thu, 31 Aug 2017 14:16:39 +0300

> Fix compilation error below:
> 
> $ make samples/bpf/
> 
> LLVM ERROR: 'xdp_redirect_dummy' label emitted multiple times to
> assembly file
> make[1]: *** [samples/bpf/xdp_redirect_kern.o] Error 1
> make: *** [samples/bpf/] Error 2
> 
> Fixes: 306da4e685b4 ("samples/bpf: xdp_redirect load XDP dummy prog on TX device")
> Signed-off-by: Tariq Toukan <tariqt@mellanox.com>

Applied.
diff mbox series

Patch

diff --git a/samples/bpf/xdp_redirect_kern.c b/samples/bpf/xdp_redirect_kern.c
index 1c90288d0203..8abb151e385f 100644
--- a/samples/bpf/xdp_redirect_kern.c
+++ b/samples/bpf/xdp_redirect_kern.c
@@ -82,7 +82,7 @@  int xdp_redirect_prog(struct xdp_md *ctx)
 
 /* Redirect require an XDP bpf_prog loaded on the TX device */
 SEC("xdp_redirect_dummy")
-int xdp_redirect_dummy(struct xdp_md *ctx)
+int xdp_redirect_dummy_prog(struct xdp_md *ctx)
 {
 	return XDP_PASS;
 }
diff --git a/samples/bpf/xdp_redirect_map_kern.c b/samples/bpf/xdp_redirect_map_kern.c
index 79795d41ad0d..740a529ba84f 100644
--- a/samples/bpf/xdp_redirect_map_kern.c
+++ b/samples/bpf/xdp_redirect_map_kern.c
@@ -84,7 +84,7 @@  int xdp_redirect_map_prog(struct xdp_md *ctx)
 
 /* Redirect require an XDP bpf_prog loaded on the TX device */
 SEC("xdp_redirect_dummy")
-int xdp_redirect_dummy(struct xdp_md *ctx)
+int xdp_redirect_dummy_prog(struct xdp_md *ctx)
 {
 	return XDP_PASS;
 }