Skip to content

eBPF-based security platform

shirudo-build: cut the comments down to why

Daniel Borkmannf2d963b28833
diff --git a/tools/shirudo-build/bpm-build.c b/tools/shirudo-build/bpm-build.c
index 1fca9225..764818bd 100644
--- a/tools/shirudo-build/bpm-build.c
+++ b/tools/shirudo-build/bpm-build.c
@@ -700,7 +700,6 @@ static bool build_ends_with(const char *s, const char *suffix)
return n >= m && !strcmp(s + n - m, suffix);
}
-/* The upatch name shirudo-build derives from an input file name. */
static void build_upatch_name(const char *source, char *out, size_t cap)
{
const char *base = strrchr(source, '/');
@@ -715,9 +714,8 @@ static void build_upatch_name(const char *source, char *out, size_t cap)
}
/*
- * Compile, sign and package every upatch of the spec with the same
- * pipeline as `shirudo build`, then its unload directive bound to the
- * payload digest the load artifact ended up with.
+ * The unload directive is bound to the payload digest the load artifact
+ * ended up with.
*/
static int build_upatches(struct bpm_build_spec *spec, const char *pkey,
const char *cert)
diff --git a/tools/shirudo-build/bpm-publish.c b/tools/shirudo-build/bpm-publish.c
index 92735376..100e2484 100644
--- a/tools/shirudo-build/bpm-publish.c
+++ b/tools/shirudo-build/bpm-publish.c
@@ -99,10 +99,7 @@ static int index_entry_compare(const void *left, const void *right)
return rc ? rc : strcmp(a->version, b->version);
}
-/*
- * Fetch, verify and parse the signed repository index of the registry.
- * A registry without one yields an empty index.
- */
+/* A registry without an index yields an empty one. */
static int fetch_index(struct bpm_oci_client *c, const char *cert,
struct bpm_index_entry *entries, int *n)
{
@@ -578,12 +575,6 @@ static int tree_push_artifact(struct bpm_oci_client *c, const char *repository,
return 0;
}
-/*
- * Append the tree-enabled upatches of a built package to the signed tree
- * at <repository>:<reference>: fetch and verify the current publication,
- * push each artifact, append one operation per entry, sign the new
- * publication through shirudo-build and replace the reference.
- */
static int cmd_bpm_tree_append(int argc, char **argv)
{
const char *package = NULL, *raw_repository = NULL, *keys_dir_arg = NULL;
diff --git a/tools/shirudo-build/bpm.h b/tools/shirudo-build/bpm.h
index 742a9e88..969c49a6 100644
--- a/tools/shirudo-build/bpm.h
+++ b/tools/shirudo-build/bpm.h
@@ -69,20 +69,14 @@ int bpm_build_parse_beefile(const unsigned char *body, size_t len,
struct bpm_build_spec *spec);
void bpm_build_spec_free(struct bpm_build_spec *spec);
-/*
- * `shirudo-build bpm <build|push|tree append> ...`, reached through the
- * core binary's `shirudo bpm` dispatch. argv[0] is the subcommand.
- */
int shirudo_build_bpm(int argc, char **argv);
int shirudo_build_bpm_build(int argc, char **argv);
int shirudo_build_bpm_push(int argc, char **argv);
int shirudo_build_bpm_tree(int argc, char **argv);
bool shirudo_build_is_help(const char *arg);
-/* Readable 0600 private key and readable certificate, else 1 with a diagnostic. */
int shirudo_build_check_keys(const char *pkey, const char *cert);
-/* `shirudo-build keys vouch ...`, argv[0] being "vouch". */
int shirudo_build_keys_vouch(int argc, char **argv);
#endif /* SHIRUDO_BUILD_BPM_H */
diff --git a/tools/shirudo-build/compile.c b/tools/shirudo-build/compile.c
index 563f3142..f02083ec 100644
--- a/tools/shirudo-build/compile.c
+++ b/tools/shirudo-build/compile.c
@@ -38,12 +38,6 @@ static int push(const char **argv, int *n, const char *arg)
return 0;
}
-/*
- * Look for the vendor BPF headers under a few well-known locations.
- * Returns a static "-I<path>" string, or NULL if no candidate exists
- * (in which case the operator must supply --extra-cflags / install
- * libbpf-dev).
- */
static const char *locate_bpf_headers(void)
{
static const char installed[] = "-I" SHIRUDO_BPF_INCDIR;
@@ -85,7 +79,6 @@ int shirudo_build_compile(const char *source, const char *output,
return -ENOENT;
}
- /* -I <dirname(vmlinux_h)> so #include "vmlinux.h" resolves. */
snprintf(vmlinux_dir, sizeof(vmlinux_dir), "%s", vmlinux_h);
{
char *slash = strrchr(vmlinux_dir, '/');
diff --git a/tools/shirudo-build/package.c b/tools/shirudo-build/package.c
index 05ce60bc..7a0e293d 100644
--- a/tools/shirudo-build/package.c
+++ b/tools/shirudo-build/package.c
@@ -121,7 +121,6 @@ static uint32_t rd_le32(const void *p)
return le32toh(v);
}
-/* Read a regular payload (<= 16 MiB) into a malloc'd buffer. 0/-errno. */
static int read_small_file(const char *path, char **out, uint32_t *out_len)
{
struct stat st;
@@ -1081,11 +1080,8 @@ static void unregister_target_attach_types(int handler_ids[2])
}
/*
- * Run gen_loader on an already-opened object, CMS-sign the produced
- * loader bytes, and write the .upatch container. Takes ownership of
- * obj (closes it on every exit path). src_path, if non-NULL, is the C
- * source whose directory anchors relative decoder paths (NULL for a
- * .bpf.o input or an unload directive).
+ * Takes ownership of obj. src_path anchors relative decoder paths;
+ * NULL for a .bpf.o input or an unload directive.
*/
static int finalize_object(struct bpf_object *obj, const char *out_path,
const char *upatch_name, uint32_t flags,
diff --git a/tools/shirudo-build/shirudo-build.c b/tools/shirudo-build/shirudo-build.c
index 2856e41c..0eaf17c7 100644
--- a/tools/shirudo-build/shirudo-build.c
+++ b/tools/shirudo-build/shirudo-build.c
@@ -122,11 +122,7 @@ static int ends_with(const char *s, const char *suf)
return ns >= nf && strcmp(s + ns - nf, suf) == 0;
}
-/*
- * Default output path when -o is omitted: strip a trailing .c or .o
- * and append .upatch, keeping the directory and any .bpf stem, so
- * foo/bar.bpf.c lands at foo/bar.bpf.upatch next to its input.
- */
+/* foo/bar.bpf.c lands at foo/bar.bpf.upatch beside its input. */
static int derive_output(const char *input, char *buf, size_t buf_sz)
{
size_t stem = strlen(input);
@@ -142,12 +138,7 @@ static int derive_output(const char *input, char *buf, size_t buf_sz)
return 0;
}
-/*
- * --emit-artifacts artifact path: the .bpf.o sits beside the .upatch,
- * so strip a trailing .upatch off the (already resolved) output path
- * and append .o, keeping the .bpf stem (foo/bar.bpf.upatch ->
- * foo/bar.bpf.o).
- */
+/* The .bpf.o sits beside the .upatch. */
static int derive_artifact_o(const char *output, char *buf, size_t buf_sz)
{
size_t stem = strlen(output);