From 04747910f7f563da4c05f7155e6b7e669f1fb7e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Tue, 29 Jul 2025 16:47:45 -0700 Subject: [PATCH 1/2] NetBpfLoad: use objName/mapName less location pre-rename MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The genfscon rules only care about the directory, the precise name is irrelevant and temporary since we immediately rename. Test: TreeHugger Flag: EXEMPT mainline Signed-off-by: Maciej Żenczykowski Change-Id: Ic8cd316df6649b9bfd629694e32130ce7363afea --- bpf/loader/NetBpfLoad.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/bpf/loader/NetBpfLoad.cpp b/bpf/loader/NetBpfLoad.cpp index fa0b6f1fec..06c1087197 100644 --- a/bpf/loader/NetBpfLoad.cpp +++ b/bpf/loader/NetBpfLoad.cpp @@ -798,13 +798,11 @@ static bool isBtfSupported(enum bpf_map_type type) { return type != BPF_MAP_TYPE_DEVMAP_HASH && type != BPF_MAP_TYPE_RINGBUF; } -static int pinMap(const borrowed_fd& fd, const string& mapName, const struct bpf_map_def& mapDef, - const string& objName, const string& mapPinLoc) { +static int pinMap(const borrowed_fd& fd, const struct bpf_map_def& mapDef, const string& mapPinLoc) { int ret; if (mapDef.selinux_context[0]) { validatePinDir(mapDef.selinux_context); - string createLoc = string(BPF_FS_PATH) + mapDef.selinux_context + - "tmp_map_" + objName + "_" + mapName; + string createLoc = string(BPF_FS_PATH) + mapDef.selinux_context + "tmp_map"; ret = bpfFdPin(fd, createLoc.c_str()); if (ret) { const int err = errno; @@ -1040,7 +1038,7 @@ static int createMaps(const char* elfPath, ifstream& elfFile, vector& // We assume failure is due to pinned map mismatch, hence the 'NOT UNIQUE' return code. if (!mapMatchesExpectations(fd, mapNames[i], md[i], type)) return -ENOTUNIQ; - ret = pinMap(fd, mapNames[i], md[i], objName, mapPinLoc); + ret = pinMap(fd, md[i], mapPinLoc); if (ret) return ret; mapFds.push_back(std::move(fd)); @@ -1402,7 +1400,7 @@ static int pinMaps(const char* const elfPath, const struct bpf_object* obj, return -1; } - ret = pinMap(bpf_map__fd(m), mapNames[i], md[i], objName, mapPinLoc); + ret = pinMap(bpf_map__fd(m), md[i], mapPinLoc); if (ret) return ret; } return 0; From f6dfae8d0e9b887095bdd8e6eabea5910b3e360d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Tue, 29 Jul 2025 16:51:37 -0700 Subject: [PATCH 2/2] NetBpfLoad: use objName/progName less location pre-rename MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The genfscon rules only care about the directory, the precise name is irrelevant and temporary since we immediately rename. Test: TreeHugger Flag: EXEMPT mainline Signed-off-by: Maciej Żenczykowski Change-Id: I6307dc2f7f10d78026c3f798cb1d3027619cee4f --- bpf/loader/NetBpfLoad.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/bpf/loader/NetBpfLoad.cpp b/bpf/loader/NetBpfLoad.cpp index 06c1087197..3f117ce719 100644 --- a/bpf/loader/NetBpfLoad.cpp +++ b/bpf/loader/NetBpfLoad.cpp @@ -1100,13 +1100,12 @@ static void applyMapRelo(ifstream& elfFile, vector &mapFds, vector& cs, const if (!fd.ok()) return fd.get(); if (!reuse) { - ret = pinProg(fd, name, cs[i].prog_def.value(), objName, progPinLoc); + ret = pinProg(fd, cs[i].prog_def.value(), progPinLoc); if (ret) return ret; } ret = validateProg(fd, progPinLoc, bpfloader_ver); @@ -1431,7 +1430,7 @@ static int pinProgs(const char* const elfPath, const struct bpf_object * obj, } int fd = bpf_program__fd(prog); - ret = pinProg(fd, name, cs[i].prog_def.value(), objName, progPinLoc); + ret = pinProg(fd, cs[i].prog_def.value(), progPinLoc); if (ret) return ret; ret = validateProg(fd, progPinLoc, bpfloader_ver); if (ret) return ret;