Sync with latest libbpf repo
authorYonghong Song <yhs@fb.com>
Wed, 17 Nov 2021 23:57:02 +0000 (15:57 -0800)
committeryonghong-song <ys114321@gmail.com>
Thu, 18 Nov 2021 00:31:39 +0000 (16:31 -0800)
Sync with latest libbpf repo upto commit:
   94a49850c5ee Makefile: enforce gnu89 standard

Signed-off-by: Yonghong Song <yhs@fb.com>
docs/kernel-versions.md
introspection/bps.c
src/cc/compat/linux/virtual_bpf.h
src/cc/export/helpers.h
src/cc/libbpf
src/cc/libbpf.c

index f92062730db1b1dfce462f1e343bcb6823cd34f7..1b4334569331feec9056106997e120bae70dde1b 100644 (file)
@@ -218,6 +218,7 @@ Helper | Kernel version | License | Commit |
 `BPF_FUNC_current_task_under_cgroup()` | 4.9 |  | [`60d20f9195b2`](https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=60d20f9195b260bdf0ac10c275ae9f6016f9c069)
 `BPF_FUNC_d_path()` | 5.10 |  | [`6e22ab9da793`](https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit?id=6e22ab9da79343532cd3cde39df25e5a5478c692)
 `BPF_FUNC_fib_lookup()` | 4.18 | GPL | [`87f5fc7e48dd`](https://git.kernel.org/cgit/linux/kernel/git/davem/net-next.git/commit/?id=87f5fc7e48dd3175b30dd03b41564e1a8e136323)
+`BPF_FUNC_find_vma()` | 5.17 | | [`7c7e3d31e785`](https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit?id=7c7e3d31e7856a8260a254f8c71db416f7f9f5a1)
 `BPF_FUNC_for_each_map_elem()` | 5.13 | | [`69c087ba6225`](https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit?id=69c087ba6225b574afb6e505b72cb75242a3d844)
 `BPF_FUNC_get_attach_cookie()` | 5.15 |  | [`7adfc6c9b315`](https://github.com/torvalds/linux/commit/7adfc6c9b315e174cf8743b21b7b691c8766791b)
 `BPF_FUNC_get_branch_snapshot()` | 5.16 | GPL | [`856c02dbce4f`](https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit?id=856c02dbce4f8d6a5644083db22c11750aa11481)
@@ -249,6 +250,7 @@ Helper | Kernel version | License | Commit |
 `BPF_FUNC_inode_storage_delete()` | 5.10 |  | [`8ea636848aca`](https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit?id=8ea636848aca35b9f97c5b5dee30225cf2dd0fe6)
 `BPF_FUNC_inode_storage_get()` | 5.10 |  | [`8ea636848aca`](https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit?id=8ea636848aca35b9f97c5b5dee30225cf2dd0fe6)
 `BPF_FUNC_jiffies64()` | 5.5 |  | [`5576b991e9c1`](https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?id=5576b991e9c1a11d2cc21c4b94fc75ec27603896)
+`BPF_FUNC_kallsyms_lookup_name()` | 5.16 | | [`d6aef08a872b`](https://github.com/torvalds/linux/commit/d6aef08a872b9e23eecc92d0e92393473b13c497)
 `BPF_FUNC_ktime_get_boot_ns()` | 5.7 | GPL | [`71d19214776e`](https://kernel.googlesource.com/pub/scm/linux/kernel/git/bpf/bpf-next/+/71d19214776e61b33da48f7c1b46e522c7f78221)
 `BPF_FUNC_ktime_get_coarse_ns()` | 5.11 | GPL | [`d05512618056`](https://github.com/torvalds/linux/commit/d055126180564a57fe533728a4e93d0cb53d49b3)
 `BPF_FUNC_ktime_get_ns()` | 4.1 | GPL | [`d9847d310ab4`](https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=d9847d310ab4003725e6ed1822682e24bd406908)
index 6ec02e6cbc1593e04859b581dd601e3a742e5c5a..232b23d414f8d026cafc7c42042536f006eda3d0 100644 (file)
@@ -80,6 +80,7 @@ static const char * const map_type_strings[] = {
   [BPF_MAP_TYPE_RINGBUF] = "ringbuf",
   [BPF_MAP_TYPE_INODE_STORAGE] = "inode_storage",
   [BPF_MAP_TYPE_TASK_STORAGE] = "task_storage",
+  [BPF_MAP_TYPE_BLOOM_FILTER] = "bloom_filter",
 };
 
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
index 3193afe23a10c183fb03919c79142ff9f789ddef..92f8da5a462a986d65a8cb057434ecb49d49853d 100644 (file)
@@ -907,6 +907,7 @@ enum bpf_map_type {
        BPF_MAP_TYPE_RINGBUF,
        BPF_MAP_TYPE_INODE_STORAGE,
        BPF_MAP_TYPE_TASK_STORAGE,
+       BPF_MAP_TYPE_BLOOM_FILTER,
 };
 
 /* Note that tracing related programs such as
@@ -1275,6 +1276,13 @@ union bpf_attr {
                                                   * struct stored as the
                                                   * map value
                                                   */
+               /* Any per-map-type extra fields
+                *
+                * BPF_MAP_TYPE_BLOOM_FILTER - the lowest 4 bits indicate the
+                * number of hash functions (if 0, the bloom filter will default
+                * to using 5 hash functions).
+                */
+               __u64   map_extra;
        };
 
        struct { /* anonymous struct used by BPF_MAP_*_ELEM commands */
@@ -1737,7 +1745,7 @@ union bpf_attr {
  *             if the maximum number of tail calls has been reached for this
  *             chain of programs. This limit is defined in the kernel by the
  *             macro **MAX_TAIL_CALL_CNT** (not accessible to user space),
- *             which is currently set to 32.
+ *             which is currently set to 33.
  *     Return
  *             0 on success, or a negative error in case of failure.
  *
@@ -4916,6 +4924,40 @@ union bpf_attr {
  *             Dynamically cast a *sk* pointer to a *unix_sock* pointer.
  *     Return
  *             *sk* if casting is valid, or **NULL** otherwise.
+ *
+ * long bpf_kallsyms_lookup_name(const char *name, int name_sz, int flags, u64 *res)
+ *     Description
+ *             Get the address of a kernel symbol, returned in *res*. *res* is
+ *             set to 0 if the symbol is not found.
+ *     Return
+ *             On success, zero. On error, a negative value.
+ *
+ *             **-EINVAL** if *flags* is not zero.
+ *
+ *             **-EINVAL** if string *name* is not the same size as *name_sz*.
+ *
+ *             **-ENOENT** if symbol is not found.
+ *
+ *             **-EPERM** if caller does not have permission to obtain kernel address.
+ *
+ * long bpf_find_vma(struct task_struct *task, u64 addr, void *callback_fn, void *callback_ctx, u64 flags)
+ *     Description
+ *             Find vma of *task* that contains *addr*, call *callback_fn*
+ *             function with *task*, *vma*, and *callback_ctx*.
+ *             The *callback_fn* should be a static function and
+ *             the *callback_ctx* should be a pointer to the stack.
+ *             The *flags* is used to control certain aspects of the helper.
+ *             Currently, the *flags* must be 0.
+ *
+ *             The expected callback signature is
+ *
+ *             long (\*callback_fn)(struct task_struct \*task, struct vm_area_struct \*vma, void \*callback_ctx);
+ *
+ *     Return
+ *             0 on success.
+ *             **-ENOENT** if *task->mm* is NULL, or no vma contains *addr*.
+ *             **-EBUSY** if failed to try lock mmap_lock.
+ *             **-EINVAL** for invalid **flags**.
  */
 #define __BPF_FUNC_MAPPER(FN)          \
        FN(unspec),                     \
@@ -5097,6 +5139,8 @@ union bpf_attr {
        FN(get_branch_snapshot),        \
        FN(trace_vprintk),              \
        FN(skc_to_unix_sock),           \
+       FN(kallsyms_lookup_name),       \
+       FN(find_vma),                   \
        /* */
 
 /* integer value in 'imm' field of BPF_CALL instruction selects which helper
@@ -5639,6 +5683,8 @@ struct bpf_map_info {
        __u32 btf_id;
        __u32 btf_key_type_id;
        __u32 btf_value_type_id;
+       __u32 :32;      /* alignment pad */
+       __u64 map_extra;
 } __attribute__((aligned(8)));
 
 struct bpf_btf_info {
@@ -6271,6 +6317,7 @@ struct bpf_sk_lookup {
        __u32 local_ip4;        /* Network byte order */
        __u32 local_ip6[4];     /* Network byte order */
        __u32 local_port;       /* Host byte order */
+       __u32 ingress_ifindex;          /* The arriving interface. Determined by inet_iif. */
 };
 
 /*
index 596f4a45c9e3f3e31bd4f53221ae69bf027df47f..f300c1841af6403fb558950f9bef0cd93875524d 100644 (file)
@@ -914,6 +914,12 @@ static long (*bpf_trace_vprintk)(const char *fmt, __u32 fmt_size, const void *da
   (void *)BPF_FUNC_trace_vprintk;
 static struct unix_sock *(*bpf_skc_to_unix_sock)(void *sk) =
   (void *)BPF_FUNC_skc_to_unix_sock;
+static long (*bpf_kallsyms_lookup_name)(const char *name, int name_sz, int flags,
+                               __u64 *res) =
+  (void *)BPF_FUNC_kallsyms_lookup_name;
+static long (*bpf_find_vma)(struct task_struct *task, __u64 addr, void *callback_fn,
+                           void *callback_ctx, __u64 flags) =
+  (void *)BPF_FUNC_find_vma;
 
 /* llvm builtin functions that eBPF C program may use to
  * emit BPF_LD_ABS and BPF_LD_IND instructions
index eaea2bce024fa6ae0db54af1e78b4d477d422791..94a49850c5ee61ea02dfcbabf48013391e8cecdf 160000 (submodule)
@@ -1 +1 @@
-Subproject commit eaea2bce024fa6ae0db54af1e78b4d477d422791
+Subproject commit 94a49850c5ee61ea02dfcbabf48013391e8cecdf
index 6c2faed6ce900b63d34b55d711d955801ecdd481..6434ec486e0f7f7f024dab7a0bd5f4a21893cbf8 100644 (file)
@@ -283,6 +283,8 @@ static struct bpf_helper helpers[] = {
   {"get_branch_snapshot", "5.16"},
   {"trace_vprintk", "5.16"},
   {"skc_to_unix_sock", "5.16"},
+  {"kallsyms_lookup_name", "5.16"},
+  {"find_vma", "5.17"},
 };
 
 static uint64_t ptr_to_u64(void *ptr)