Skip to content

Helper function bpf_map_delete_elem

v3.19

The delete map element helper call is used to delete values from maps.

Definition

Copyright (c) 2015 The Libbpf Authors. All rights reserved.

Delete entry with key from map.

Returns

0 on success, or a negative error in case of failure.

static long (* const bpf_map_delete_elem)(void *map, const void *key) = (void *) 3;

Usage

The map argument must be a pointer to a map definition and key must be a pointer to the key you wish to delete.

The return value will be 0 on success or a negative valued error number indicating a failure.

Program types

This helper call can be used in the following program types:

Map types

This helper call can be used with the following map types:

Example

int key, result;
key = 1;
result = bpf_map_delete_element(&my_map, &key);
if (result == 0)
    bpf_printk("Element deleted from the map\n");
else
    bpf_printk("Failed to delete element from the map: %d\n",result);