Commit Graph

22 Commits

Author SHA1 Message Date
Andrii Nakryiko
9a5adecc62 sync: ignore test_libbpf.c
Adjust sync script to ignore test_libbpf.c, not test_libbpf.cpp.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
2019-10-29 09:25:36 -07:00
Andrii Nakryiko
33b374395f sync: adjust sync script for test_libbpf.c rename and bpf_helper_defs.h
Accomodate changes:
- test_libbpf.cpp was renamed to test_libbpf.c;
- bpf_helper_defs.h should be ignored for consistency check at the end,
  as it's not checked in on linux side;

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
2019-10-15 19:43:48 -07:00
Andrii Nakryiko
e776bf7ec7 sync: teach sync script to generate bpf_helper_defs.h
Linux repo doesn't commit bpf_helper_defs.h, as it's re-generated on
build every time. For Github projection, though, it's much nicer to have
this header be pre-generated during sync and commited. This makes
integration story easier for all the users that use libbpf as
a submodule.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
2019-10-09 14:42:45 -07:00
Andrii Nakryiko
ede18f80d8 scripts: fix empty cherry-pick handling, fix IGNORE_CONSISTENCY check
Fix two issues I've encountered during latest bpf/bpf-next sync.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
2019-09-30 15:02:52 -07:00
Andrii Nakryiko
e78a36f4b0 sync: fix non-empty merge detection/handling
Fix how non-empty merge detection is done. Allow to proceed despite
non-empty merges (they will typically will cause conflicts during
applying patches, but if conflicts were handled already, it should be ok
to ignore this problem).

Also ensure that diff's output is in unified diff format.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
2019-08-14 09:53:04 -07:00
Andrii Nakryiko
def5576b37 sync: pull patches from bpf tree as well
Add patches sync from both bpf and bpf-next trees at the same time.
Baseline checkpoint commits are tracked independently for both.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
2019-08-09 08:41:26 -07:00
Andrii Nakryiko
3e45a16621 sync: make patch applying interactive, allow to ignore consistency
Give more control over patching process to allow manual intervention and
fix up, after which process will continue. Also allow an option to
ignore consistency check results (when having both bpf and bpf-next
changes).

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
2019-08-09 08:41:26 -07:00
Andrii Nakryiko
2c0e53cb08 sync: attempt to auto-resolve non-libbpf conflicts
If cherry-picked commit contains non-libbpf files, chances are high that
this will result in conflict, because we are generally skipping commits
that didn't touch libbpf files, which means that our working copy will
not be up-to-date for non-libbpf files. This change checks if conflicts
are only in non-libbpf files and marks them as resolved. This will work
fine as long as we don't cherry-pick some more non-libbpf changes to
same set of files that happen to conflict with not-so-resolved version
of non-libbpf files. But anyways, this should help in a lot of cases.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
2019-08-09 08:41:26 -07:00
Andrii Nakryiko
6227c6f8dd sync: add manual cherry-picking mode
This is sometimes necessary when we did ad-hoc urgent bug fixes, which
are not identical to the ones in kernel.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
2019-08-09 08:41:26 -07:00
Andrii Nakryiko
00ad180d07 sync: extract cherry-picking logic for reuse
Extract non-empty merge validation and cherry-picking logic so that it
can be re-used for bpf and bpf-next commits.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
2019-08-09 08:41:26 -07:00
Andrii Nakryiko
715a58d593 sync: improve and automate already synced patches detection
Make detection more precise and automate skip/sync decision, if
everything looks sane.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
2019-08-09 08:41:26 -07:00
Andrii Nakryiko
11052fc1be sync: add commit_desc() function and move things around a bit
Just cleaning up a bunch of stuff before the next refactoring.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
2019-08-09 08:41:26 -07:00
Andrii Nakryiko
97ecda3b25 sync: extract directory changing function
Extract the logic of handling relative paths within the script into
go_to() function.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
2019-08-09 08:41:26 -07:00
Andrii Nakryiko
342bcfa319 sync: centralize kernel-to-github paths mapping
Use associative array (requires at least bash 4) to centralize mapping
of paths between kernel's libbpf layout and the one on Github. This
minimizes the chance of all those mappings getting out of sync (which
happened twice before).

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
2019-08-09 08:41:26 -07:00
Andrii Nakryiko
e61f4b8269 scripts/sync-kernel.sh: add missing if_xdp.h in one of file lists
if_xdp.h wasn't added to one of few file lists, causing sync content
verification failure.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
2019-07-19 15:12:56 -07:00
Andrii Nakryiko
61419aae26 sync-kernel.sh: detect synced commits, interactively resolve conflicts
1. There is one commit ("libbpf: fix btf_dedup equivalence check
   handling of different kinds"), which was originally committed into bpf
   tree and manually synced into libbpf (it was a critical bug fix). Now
   that bpf and bpf-next trees were merged, this causes duplicate commits in
   libbpf. To address this, check is added to see if libbpf repo already has
   a commit with the same subject and allow to skip it.
2. Just checking by subject is not good enough, as we currently have few
   different commits with the same subject "bpf: Sync bpf.h to tools/".
   To address this, script now will ask user whether to skip or cherry-pick
   commit. This allows for human to double-check the commit and make
   informed devision.
3. There is a commit ('bfb35c27c65f bpf: fix whitespace for ENCAP_L2
   defines in bpf.h'), which modifies both include/uapi/linux/bpf.h and
   tools/include/uapi/linux/bpf.h in the same commit. This break the
   sync script, as it doesn't cherry-pick commits that hasn't modified
   libbpf files. So at the time that commit bfb35c27c65f is applied, linux
   repo is missing some preceding changes to include/uapi/linux/bpf.h. They
   would normally be ignored later during repo filtering, but to do
   cherry-pick they are necessary. It's hard to fix it automatically, so
   script will wait for user to resolve the issue and continue.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
2019-04-18 17:00:48 -07:00
Andrii Nakryiko
7c15babf40 scripts/sync_kernel.sh: skip empty merges, preventing cherry-picking
Merges are common. `git cherry-pick` can't cherry-pick merge commit and
requires specifying which of the parents should be cherry-picked, so
it's a pain. But merges are also commonly empty, so it's safe to skip them.

This change goes through all merges touching libbpf files, checks that
they don't have any conflict resolution diffs. If there are any, abort,
if not, proceed as usual, ignoring merges.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
2019-03-28 19:51:11 -07:00
Andrii Nakryiko
74efbe5b91 scripts: update sync script to do if_xdp.h syncing
With xsk.{o,h} changes we started including Linux UAPI's if_xdp.h
header. We need to sync it along the other UAPI headers.

Also updated README to reflect this.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
2019-03-19 12:16:59 -07:00
Andrii Nakryiko
947e40e1fd sync_kernel.sh: revamp sync script to work in the presence of merges (#15)
Previous version of script relied on squashing baseline commit and
rebasing rest of commits on top of it. This doesn't work well with git
histories containing merges. This patch changes approach by cherry-picking
commits that have libbpf-related changes and then rewriting history since
last checkpoint.

This still might fail if there were manually resolved merge conflicts for
libbpf, but it's the best we can get as far as I can tell.

Script now also verifies that state of libbpf in Linux's repository exactly
matches the state of libbpf in github repo.

If everything goes smoothing (including verification step), we clean up after
ourselves and only leave libbpf-sync-XXX branch in github's libbpf repo to
push to remote.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
2019-03-02 21:19:17 -08:00
Andrii Nakryiko
8e42f42533 scripts: add script to sync kernel changes (#13)
This script automates the process of applying libbpf-relevant changes
from kernel repository on top of current state of libbpf repository.

It uses CHECKPOINT-COMMIT file to keep track of last commit in kernel
repo up to which libbpf is in sync with. If there are any new libbpf
changes in kernel repository, script extracts them, preserving original
commit metadata. It also creates a "sync commit" using cover letter as
a template, which nicely summarizes changes since last sync with kernel.

Usage: ./scripts/sync-kernel.sh <linux-repo> <libbpf-repo>

If it succeeds, script will create a bunch of local commits in
<libbpf-repo> in separate branch, which can be easily pushed into github
to create a pull request.

Script tries to clean up after itself, except in case of failure. But it
doesn't clean up timestamped branches it creates in both kernel and
libbpf repositories for now. We can add that later.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
2019-02-16 22:22:30 -08:00
David Ahern
29eca541b8 Fix redirect in check-reallocarray (#7)
Builds on debian stretch are failing due to:

../scripts/check-reallocarray.sh: 17: ../scripts/check-reallocarray.sh: Syntax error: Bad fd number

Fix the redirect of stdout and stderr.

Signed-off-by: David Ahern <dsahern@gmail.com>
2019-01-07 20:34:42 -08:00
Yonghong Song
8acf2635c3 add a simple Makefile to build and clean up
add missing macros, static inline functions, etc.
add README to illustrate the purpose of this repo.

Signed-off-by: Yonghong Song <yhs@fb.com>
2018-10-10 09:40:15 -07:00