Perform delete operation on the passed entries.
Since Linux 5.6.
Unlike in delete, an entry isn't found,
ENOENT
will be thrown and no more entries will
be processed.
Note that if an error is thrown, part of the entries
could already have been processed. The thrown error
includes a count
field that, if not undefined,
corresponds to the amount of processed entries.
Entry keys to delete
Iterate through the map entries.
This works like entries but the iteration is performed in the kernel, returning many items at once. The interator yields each batch produced by the kernel, until an error is found or there are no more entries.
batchSize
specifies the requested size, but batches may
be smaller. If the kernel returns a partial batch together
with an error, the partial batch will be yielded before
throwing the error. If the map is empty, nothing is yielded.
Since Linux 5.6.
Amount of entries to request per batch, must be non-zero
Operation flags, see MapLookupFlags
Perform set operation on the passed entries.
Since Linux 5.6.
Note that if an error is thrown, part of the entries
could already have been processed. The thrown error
includes a count
field that, if not undefined,
corresponds to the amount of processed entries.
Entries to set
Operation flags, see MapUpdateFlags
Convenience function. Alias of entries.
Convenience function. Non-atomically iterates over the map's entries, deleting them.
Convenience function. Non-atomically iterates through the map's entries, deleting them while iterating.
Convenience function. Non-atomically iterates through the map's entries. Gets the next key before yielding the current one, making it suitable for deleting entries while iterating.
Convenience function. Tests if the map has an entry.
Entry key
Convenience function. Non-atomically iterates through the map's values.
Delete a single map entry.
Returns true
if an entry was found
and deleted, false
otherwise.
Entry key
Freezes the map, making it non-modifiable from userspace. The map stays writeable from BPF side.
Since Linux 5.2.
Fetch the value for a single key.
Entry key
Operation flags (since Linux 5.1), see MapLookupFlags
Entry value, or undefined
if no such entry exists
Atomically deletes an entry and returns its former value,
or undefined
if no entry was found. This operation is
generally implemented only for stack / queue types.
Since Linux 4.20. Most map types probably won't implement this operation.
Entry key
Non-atomically iterates through the map's keys, starting by the key immediately following the passed one. If no key isn't passed or it doesn't exist, iteration starts by the first key in the map.
Note: Not passing a key is only supported on kernels 4.12 and above.
Because this calls BPF_MAP_GET_NEXT_KEY
repeatedly,
if the map's keys are deleted while it's being iterated
(by this or another program), iteration could restart to
the beginning. However, this method fetches the next key
before yielding the current one, making it safe to delete
the current key (and any past ones).
Keep in mind that the order of keys depends on the type of map, and isn't necessarily guaranteed to be consistent.
Start key (if passed and found, iteration will yield keys after this one, i.e. it's not included in the result)
Add or override a single map entry.
Entry key
Entry value
Operation flags (since Linux 3.19), see MapUpdateFlags
Generated using TypeDoc
Generic interface to manipulate an eBPF map of any type. API-compatible with JavaScript
Map
.In an eBPF map, keys and values are binary strings of a fixed length, defined at map creation (see MapDef). RawMap returns these directly as
Buffer
with no conversion, and ConvMap performs the conversion specified at construction time.Operation semantics
The exact semantics of the operations (whether they're atomic or not, supported flags, etc.) depend on the chosen map type.
If your kernel doesn't implement a map operation, it will generally throw
EINVAL
. If it's implemented, but the map type doesn't have it, it will generally throwENOTSUPP
.Convenience methods
Some methods, such as clear, are implemented using one or more map operations. These are marked as convenience methods in their documentation.
Notably, iterating methods such as entries, consumeEntries, values and also clear are all convenience methods, implemented using a combination of keys and another operation.
Batched operations
These are special map operations that process many entries. setBatch and deleteBatch are mostly equivalent to a repeated set or delete on each of the entries. getBatch iterates through the entries of the map and is mostly equivalent to entries.
The difference is that all this is performed in the kernel through a single syscall, so they perform better than normal operations or iterating methods (especially when syscall overhead is a problem).
However they're much more recent and, like other operations, may not be available on your map type or kernel version.