Commit Graph

33 Commits

Author SHA1 Message Date
Quentin Monnet
eaea2bce02 sync: remove redundant test on $BPF_BRANCH
The sync-kernel.sh script has two consecutive tests for $BPF_BRANCH
being provided by the user (and so the second one can currently never
fail). Looking at the error message displayed in each case, we want to
keep the second one. Let's remove the first check.

Signed-off-by: Quentin Monnet <quentin@isovalent.com>
2021-10-26 14:39:07 -07:00
Quentin Monnet
f05791d8cf sync: fix comment for commit_signature() (subject instead of hash)
The commit_signature() function does not use the hash of the commit,
which typically differs between the kernel repo and the mirrored
version, but the subject for this commit. Fix the comment accordingly.

Signed-off-by: Quentin Monnet <quentin@isovalent.com>
2021-10-25 13:29:16 -07:00
Andrii Nakryiko
827963ffb3 sync: fix up docs sync path mapping
Kernel docs from Documentation/bpf/libbpf go straight to docs/ under libbpf.
Also ignore libbpf-only parts of docs subdir.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2021-08-16 22:37:57 -07:00
grantseltzer
b2a63c974d docs: reconfigure libbpf documentation syncing
This adds documentation files, including ones for autogenerating API
documentation based on code comments in the source code that's pulled
in via the mirror.

Signed-off-by: Grant Seltzer <grantseltzer@gmail.com>
2021-08-16 22:30:23 -07:00
Yonghong Song
8bf016110e sync uapi headers linux/pkt_cls.h and linux/pkt_sched.h
Let us sync linux/{pkt_cls.h,pkt_sched.h} to libbpf repo.
Otherwise, on ubuntu 16.04, system headers will be picked up
and this will result in compilation error like:
  .../netlink.c:416:23: error: ‘TC_H_CLSACT’ undeclared (first use in this function)
     *parent = TC_H_MAKE(TC_H_CLSACT,
                         ^
  .../netlink.c:418:9: error: ‘TC_H_MIN_INGRESS’ undeclared (first use in this function)
           TC_H_MIN_INGRESS : TC_H_MIN_EGRESS);
           ^
  .../netlink.c:418:28: error: ‘TC_H_MIN_EGRESS’ undeclared (first use in this function)
           TC_H_MIN_INGRESS : TC_H_MIN_EGRESS);
                              ^
  .../netlink.c: In function ‘__get_tc_info’:
  .../netlink.c:522:11: error: ‘TCA_BPF_ID’ undeclared (first use in this function)
    if (!tbb[TCA_BPF_ID])
             ^

Signed-off-by: Yonghong Song <yhs@fb.com>
2021-07-12 14:01:21 -07:00
Ilya Leoshkevich
8c2c7e5bcf sync: use bpf_doc.py
In the latest bpf-next bpf_helpers_doc.py has been renamed to
bpf_doc.py.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
2021-03-25 23:31:23 -07:00
Andrii Nakryiko
8205f37a56 sync: ignore libc_compat.h
Libbpf doesn't rely on libc_compat.h anymore, so ignore it for the purposes of
syncing libbpf sources into Github.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
2020-10-12 12:18:53 -07:00
Vladimír Čunát
5a10cd2060 remove internal reallocarray()
... as it's covered by libbpf_reallocarray() since commit dc70da9c70.
2020-09-30 12:55:50 -07:00
Andrii Nakryiko
829e50fc15 sync: improve sync script to handle common issues
Few recurring issues are fixed.
1. When there are patches in bpf tree that hasn't been synced yet, but bpf was
   already merged into bpf-next, merged patches would be applied twice,
   causing failures, requiring manual resolution. Now this is handled smarter
   and shouldn't happen.
2. When synced libbpf repo contains fixes from bpf that weren't yet merged
   into bpf-next, those bpf tree changes would cause inconsistency against
   bpf-next tree state. That's expected and usually is pretty easy for human
   to discard during consistency check, but is hard for automation. So instead
   of failing at the very end, ask human whether discrepancies look good.
3. If sync script detected no new patches needed syncing, it previously didn't
   restore linux repo state back. Fixed.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
2020-09-03 20:14:51 -07:00
Andrii Nakryiko
bbe442da7a sync: allow 3-way merge for patching to simplify manual conflict resolution
Allowing --3way leaves conflicts in the local files, which makes manual
conflict resolution so much easier.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
2020-08-25 00:53:18 -07:00
Andrii Nakryiko
46c272f9b4 sync: don't check and warn about non-empty merges anymore
Initial versions of sync script couldn't handle non-empty merges. But since
then, script became smarter, more interactive and thus more powerful and can
handle some complicated situations easily on its own, while falling back to
human intervention for even more complicated situations. This non-empty merge
check has outlived its purpose and is just an annoying bump in sync process.
Drop it.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
2020-06-10 13:59:07 -07:00
Andrii Nakryiko
cf3fc46ea8 sync: squelch annoying warning from filter-branch git command
Newer git started emitting warning about dangerousness of filter-branch.
Squelch it with FILTER_BRANCH_SQUELCH_WARNING=1 envvar.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
2020-04-29 23:01:56 -07:00
Andrii Nakryiko
fa8cb316fb sync: fix commit signature determination in sync script
Commit signature, used to determine already synced commits, includes a short
stats per each file relevant. Fix this script to include only files that are
actually synced (i.e., exclude Makefile, Build file, etc).

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
2020-02-20 11:12:59 -08:00
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