Merge changes I74c24016,I3b2b533e into main
* changes: NetBpfLoad: remove foo@1.o support Tweak: Throw exception for oversized BpfMap keys/values
This commit is contained in:
commit
2b9447dcf6
2 changed files with 9 additions and 8 deletions
|
|
@ -127,13 +127,10 @@ void validatePinDir(const char s[BPF_PIN_SUBDIR_CHAR_ARRAY_SIZE]) {
|
|||
}
|
||||
|
||||
static string pathToObjName(const string& path) {
|
||||
// extract everything after the final slash, ie. this is the filename 'foo@1.o' or 'bar.o'
|
||||
// extract everything after the final slash, ie. this is the filename 'foo.o'
|
||||
string filename = Split(path, "/").back();
|
||||
// strip off everything from the final period onwards (strip '.o' suffix), ie. 'foo@1' or 'bar'
|
||||
string name = filename.substr(0, filename.find_last_of('.'));
|
||||
// strip any potential @1 suffix, this will leave us with just 'foo' or 'bar'
|
||||
// this can be used to provide duplicate programs (mux based on the bpfloader version)
|
||||
return name.substr(0, name.find_last_of('@'));
|
||||
// strip off everything from the final period onwards (strip '.o' suffix), ie. 'foo'
|
||||
return filename.substr(0, filename.find_last_of('.'));
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
|
|
|||
|
|
@ -84,8 +84,12 @@ public class BpfMap<K extends Struct, V extends Struct> implements IBpfMap<K, V>
|
|||
throws ErrnoException, NullPointerException {
|
||||
// Supports up to 1023 byte key and 65535 byte values
|
||||
// Creating a BpfMap with larger keys/values seems like a bad idea any way...
|
||||
keySize &= 1023; // 10-bits
|
||||
valueSize &= 65535; // 16-bits
|
||||
if (keySize > 1023) {
|
||||
throw new IllegalArgumentException("Key size " + keySize + " exceeds 1023");
|
||||
}
|
||||
if (valueSize > 65535) {
|
||||
throw new IllegalArgumentException("Value size " + valueSize + " exceeds 65535");
|
||||
}
|
||||
var key = Pair.create(path, (mode << 26) ^ (keySize << 16) ^ valueSize);
|
||||
// unlocked fetch is safe: map is concurrent read capable, and only inserted into
|
||||
ParcelFileDescriptor fd = sFdCache.get(key);
|
||||
|
|
|
|||
Loading…
Reference in a new issue