|
@@ -42,6 +42,7 @@
|
|
#include <stdio.h>
|
|
#include <stdio.h>
|
|
#include <linux/bpf.h>
|
|
#include <linux/bpf.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/kernel.h>
|
|
|
|
+#include <linux/hashtable.h>
|
|
|
|
|
|
#include "json_writer.h"
|
|
#include "json_writer.h"
|
|
|
|
|
|
@@ -58,7 +59,7 @@
|
|
#define HELP_SPEC_PROGRAM \
|
|
#define HELP_SPEC_PROGRAM \
|
|
"PROG := { id PROG_ID | pinned FILE | tag PROG_TAG }"
|
|
"PROG := { id PROG_ID | pinned FILE | tag PROG_TAG }"
|
|
#define HELP_SPEC_OPTIONS \
|
|
#define HELP_SPEC_OPTIONS \
|
|
- "OPTIONS := { {-j|--json} [{-p|--pretty}] }"
|
|
|
|
|
|
+ "OPTIONS := { {-j|--json} [{-p|--pretty}] | {-f|--bpffs} }"
|
|
|
|
|
|
enum bpf_obj_type {
|
|
enum bpf_obj_type {
|
|
BPF_OBJ_UNKNOWN,
|
|
BPF_OBJ_UNKNOWN,
|
|
@@ -70,6 +71,9 @@ extern const char *bin_name;
|
|
|
|
|
|
extern json_writer_t *json_wtr;
|
|
extern json_writer_t *json_wtr;
|
|
extern bool json_output;
|
|
extern bool json_output;
|
|
|
|
+extern bool show_pinned;
|
|
|
|
+extern struct pinned_obj_table prog_table;
|
|
|
|
+extern struct pinned_obj_table map_table;
|
|
|
|
|
|
void p_err(const char *fmt, ...);
|
|
void p_err(const char *fmt, ...);
|
|
void p_info(const char *fmt, ...);
|
|
void p_info(const char *fmt, ...);
|
|
@@ -78,6 +82,20 @@ bool is_prefix(const char *pfx, const char *str);
|
|
void fprint_hex(FILE *f, void *arg, unsigned int n, const char *sep);
|
|
void fprint_hex(FILE *f, void *arg, unsigned int n, const char *sep);
|
|
void usage(void) __attribute__((noreturn));
|
|
void usage(void) __attribute__((noreturn));
|
|
|
|
|
|
|
|
+struct pinned_obj_table {
|
|
|
|
+ DECLARE_HASHTABLE(table, 16);
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+struct pinned_obj {
|
|
|
|
+ __u32 id;
|
|
|
|
+ char *path;
|
|
|
|
+ struct hlist_node hash;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+int build_pinned_obj_table(struct pinned_obj_table *table,
|
|
|
|
+ enum bpf_obj_type type);
|
|
|
|
+void delete_pinned_obj_table(struct pinned_obj_table *tab);
|
|
|
|
+
|
|
struct cmd {
|
|
struct cmd {
|
|
const char *cmd;
|
|
const char *cmd;
|
|
int (*func)(int argc, char **argv);
|
|
int (*func)(int argc, char **argv);
|
|
@@ -89,6 +107,7 @@ int cmd_select(const struct cmd *cmds, int argc, char **argv,
|
|
int get_fd_type(int fd);
|
|
int get_fd_type(int fd);
|
|
const char *get_fd_type_name(enum bpf_obj_type type);
|
|
const char *get_fd_type_name(enum bpf_obj_type type);
|
|
char *get_fdinfo(int fd, const char *key);
|
|
char *get_fdinfo(int fd, const char *key);
|
|
|
|
+int open_obj_pinned(char *path);
|
|
int open_obj_pinned_any(char *path, enum bpf_obj_type exp_type);
|
|
int open_obj_pinned_any(char *path, enum bpf_obj_type exp_type);
|
|
int do_pin_any(int argc, char **argv, int (*get_fd_by_id)(__u32));
|
|
int do_pin_any(int argc, char **argv, int (*get_fd_by_id)(__u32));
|
|
|
|
|