-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: API versioning for user/kernel boundary
This allows reusing eBPF probes across different consumers (and consumer versions) as long as the API is compatible. It also adds validation of API versions in the non-eBPF kernel probes, which was a long-standing omission. Since the actual interface evolved slowly, it generally worked fine, but in some rare cases it could easily end up with a kernel panic. Signed-off-by: Grzegorz Nosek <grzegorz.nosek@sysdig.com>
- Loading branch information
Showing
14 changed files
with
347 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# API version number | ||
|
||
The file API_VERSION must contain a semver-like version number of the userspace<->kernel API. All other lines are ignored. | ||
|
||
## When to increment | ||
|
||
**major version**: increment when the probe API becomes incompatible with previous userspace versions | ||
|
||
**minor version**: increment when new features are added but existing features remain compatible | ||
|
||
**patch version**: increment when code changes don't break compatibility (e.g. bug fixes) | ||
|
||
Do *not* increment for patches that only add support for new kernels, without affecting already supported ones. | ||
|
||
# Schema version number | ||
|
||
The file SCHEMA_VERSION must contain a semver-like version number of the event schema. All other lines are ignored. | ||
|
||
## When to increment | ||
|
||
**major version**: increment when the schema becomes incompatible with previous userspace versions | ||
|
||
**minor version**: increment when new features are added but existing features remain compatible (e.g. new event fields or new events) | ||
|
||
**patch version**: increment when code changes don't break compatibility (e.g. bug fixes in filler code) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#ifndef PPM_API_VERSION_H | ||
#define PPM_API_VERSION_H | ||
|
||
/* | ||
* API version component macros | ||
* | ||
* The version is a single uint64_t, structured as follows: | ||
* bit 63: unused (so the version number is always positive) | ||
* bits 44-62: major version | ||
* bits 24-43: minor version | ||
* bits 0-23: patch version | ||
*/ | ||
|
||
/* extract components from an API version number */ | ||
#define PPM_API_VERSION_MAJOR(ver) ((((ver) >> 44)) & (((1 << 19) - 1))) | ||
#define PPM_API_VERSION_MINOR(ver) (((ver) >> 24) & (((1 << 20) - 1))) | ||
#define PPM_API_VERSION_PATCH(ver) (((ver) & ((1 << 24) - 1))) | ||
|
||
/* build an API version number from components */ | ||
#define PPM_API_VERSION(major, minor, patch) \ | ||
(((major) & (((1ULL << 19) - 1) << 44)) | \ | ||
((minor) & (((1ULL << 20) - 1) << 24)) | \ | ||
((major) & (((1ULL << 24) - 1)))) | ||
|
||
#define PPM_API_CURRENT_VERSION PPM_API_VERSION( \ | ||
PPM_API_CURRENT_VERSION_MAJOR, \ | ||
PPM_API_CURRENT_VERSION_MINOR, \ | ||
PPM_API_CURRENT_VERSION_PATCH) | ||
|
||
#define PPM_SCHEMA_CURRENT_VERSION PPM_API_VERSION( \ | ||
PPM_SCHEMA_CURRENT_VERSION_MAJOR, \ | ||
PPM_SCHEMA_CURRENT_VERSION_MINOR, \ | ||
PPM_SCHEMA_CURRENT_VERSION_PATCH) | ||
|
||
#define __PPM_STRINGIFY1(x) #x | ||
#define __PPM_STRINGIFY(x) __PPM_STRINGIFY1(x) | ||
|
||
#define PPM_API_CURRENT_VERSION_STRING \ | ||
__PPM_STRINGIFY(PPM_API_CURRENT_VERSION_MAJOR) "." \ | ||
__PPM_STRINGIFY(PPM_API_CURRENT_VERSION_MINOR) "." \ | ||
__PPM_STRINGIFY(PPM_API_CURRENT_VERSION_PATCH) | ||
|
||
#define PPM_SCHEMA_CURRENT_VERSION_STRING \ | ||
__PPM_STRINGIFY(PPM_SCHEMA_CURRENT_VERSION_MAJOR) "." \ | ||
__PPM_STRINGIFY(PPM_SCHEMA_CURRENT_VERSION_MINOR) "." \ | ||
__PPM_STRINGIFY(PPM_SCHEMA_CURRENT_VERSION_PATCH) | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.