vendorBpfLoader: trivialize getSectionType()
since we only support skfilter/ we can simplify this (support for any future other vendor types should be added to the rust loader) Test: TreeHugger Flag: EXEMPT cleanup Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I72ad38c056728ef768ee70bc38471c3e9d368f60
This commit is contained in:
parent
b3ad463c44
commit
a3ecd74594
1 changed files with 2 additions and 35 deletions
|
|
@ -79,30 +79,6 @@ static string pathToObjName(const string& path) {
|
|||
return name.substr(0, name.find_last_of('@'));
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
const char* name;
|
||||
enum bpf_prog_type type;
|
||||
} sectionType;
|
||||
|
||||
/*
|
||||
* Map section name prefixes to program types, the section name will be:
|
||||
* SECTION(<prefix>/<name-of-program>)
|
||||
* For example:
|
||||
* SECTION("tracepoint/sched_switch_func") where sched_switch_funcs
|
||||
* is the name of the program, and tracepoint is the type.
|
||||
*
|
||||
* However, be aware that you should not be directly using the SECTION() macro.
|
||||
* Instead use the DEFINE_(BPF|XDP)_(PROG|MAP)... & LICENSE/CRITICAL macros.
|
||||
*
|
||||
* see b/162057235. For arbitrary program types, the concern is that due to the lack of
|
||||
* SELinux access controls over BPF program attachpoints, we have no way to control the
|
||||
* attachment of programs to shared resources (or to detect when a shared resource
|
||||
* has one BPF program replace another that is attached there)
|
||||
*/
|
||||
sectionType sectionNameTypes[] = {
|
||||
{"skfilter/", BPF_PROG_TYPE_SOCKET_FILTER},
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
enum bpf_prog_type type;
|
||||
string name;
|
||||
|
|
@ -258,13 +234,6 @@ static int readSymTab(ifstream& elfFile, int sort, vector<Elf64_Sym>& data) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static enum bpf_prog_type getSectionType(string& name) {
|
||||
for (auto& snt : sectionNameTypes)
|
||||
if (StartsWith(name, snt.name)) return snt.type;
|
||||
|
||||
return BPF_PROG_TYPE_UNSPEC;
|
||||
}
|
||||
|
||||
static int readProgDefs(ifstream& elfFile, vector<struct bpf_prog_def>& pd) {
|
||||
vector<char> pdData;
|
||||
int ret = readSectionByName("progs", elfFile, pdData);
|
||||
|
|
@ -350,16 +319,14 @@ static int readCodeSections(ifstream& elfFile, vector<codeSection>& cs) {
|
|||
ret = getSymName(elfFile, shTable[i].sh_name, name);
|
||||
if (ret) return ret;
|
||||
|
||||
enum bpf_prog_type ptype = getSectionType(name);
|
||||
|
||||
if (ptype == BPF_PROG_TYPE_UNSPEC) continue;
|
||||
if (!StartsWith(name, "skfilter/")) continue;
|
||||
|
||||
string oldName = name;
|
||||
|
||||
// convert all slashes to underscores
|
||||
std::replace(name.begin(), name.end(), '/', '_');
|
||||
|
||||
cs_temp.type = ptype;
|
||||
cs_temp.type = BPF_PROG_TYPE_SOCKET_FILTER;
|
||||
cs_temp.name = name;
|
||||
|
||||
ret = readSectionByIdx(elfFile, i, cs_temp.data);
|
||||
|
|
|
|||
Loading…
Reference in a new issue