-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added new footer.h header where BPF_LICENSE is set if not defined #1840
Conversation
The helpers.h header specifies the BPF program license as 'GPL'. However, other GPL-compatible licenses are possible (e.g., Dual BSD/GPL) or even proprietary licenses (e.g., cachetop can run with a proprietary license). With this commit, the user can specify a BPF_LICENSE macro in the source code: #define BPF_LICENSE Custom license Note it supports multiple words and the absence of quotes. If the BPF doesn't have a GPL-compatible license and it uses any GPL-only helpers, the kernel will reject it with: cannot call GPL only function from proprietary program If no license is specified, it will fall back to GPL (the current behavior before this commit) so that the BCC tools and examples remain usable. Updated the documentation with BPF_LICENSE description, licensing error description, and licenses for each helper. Signed-off-by: Oriol Arcas <[email protected]>
[buildbot, ok to test] |
Look good. But ubuntu 16.04 test failed. ubuntu 16.04 is linux 4.4 which does not have bpf_get_stackid support. I think you can just remove it since bpf_ktime_get_ns also requires gpl and is available on 4.4. |
docs/reference_guide.md
Outdated
|
||
This error happens when a GPL-only helper is called from a non-GPL BPF program. To fix this error, do not use GPL-only helpers from a proprietary BPF program, or relicense the BPF program under a GPL-compatible license. Check which [BPF helpers](https://github.com/iovisor/bcc/blob/master/docs/kernel-versions.md#helpers) are GPL-only, and what licenses are considered GPL-compatible. | ||
|
||
Example calling `bpf_get_stackid()`, a GPL-only BPF helper, from a proprietary program (`cflags=['-DBPF_LICENSE=Proprietary']`): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove the ability to specify the license via flags. I don't think it was ever done by any open source project. The license should only be explicitly set in the source code (either .h or .c)
FYI, the following change
can prevent user defined macro BPF_LICENSE |
Signed-off-by: Oriol Arcas <[email protected]>
Signed-off-by: Oriol Arcas <[email protected]>
Signed-off-by: Oriol Arcas <[email protected]>
src/cc/export/footer.h
Outdated
|
||
#ifndef BPF_LICENSE | ||
/* No license defined, using GPL | ||
* Use cflags to define your own BPF_LICENSE */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this part of comment is obsolete?
Other than this bit the patch looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback, I changed it in 639217f. Any other fixes?
Signed-off-by: Oriol Arcas <[email protected]>
The helpers.h header specifies the BPF program license as 'GPL'.
However, other GPL-compatible licenses are possible (e.g., Dual BSD/GPL)
or even proprietary licenses (e.g., cachetop can run with a proprietary
license).
With this commit, the user can specify a BPF_LICENSE macro in the source
code:
#define BPF_LICENSE Custom license
Note it supports multiple words and the absence of quotes. If the BPF
doesn't have a GPL-compatible license and it uses any GPL-only helpers,
the kernel will reject it with:
cannot call GPL only function from proprietary program
If no license is specified, it will fall back to GPL (the current
behavior before this commit) so that the BCC tools and examples remain
usable.
Updated the documentation with BPF_LICENSE description, licensing error
description, and licenses for each helper.
Signed-off-by: Oriol Arcas [email protected]