2021-03-05 20:05:09 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) Microsoft Corporation
|
|
|
|
* SPDX-License-Identifier: MIT
|
2021-03-10 01:54:03 +03:00
|
|
|
*/
|
2021-03-05 20:05:09 +03:00
|
|
|
|
2021-05-06 23:47:09 +03:00
|
|
|
// All of this file is cross-platform except the following
|
|
|
|
// two includes. TODO: make the include filename(s) also be
|
|
|
|
// cross-platform for eBPF program portability.
|
|
|
|
#include "ebpf_helpers.h"
|
|
|
|
#include "ebpf_nethooks.h"
|
2021-03-05 20:05:09 +03:00
|
|
|
|
2021-05-06 23:47:09 +03:00
|
|
|
__attribute__((section("maps"), used)) struct bpf_map map = {sizeof(struct bpf_map), BPF_MAP_TYPE_ARRAY, 2, 4, 512};
|
2021-02-08 00:07:50 +03:00
|
|
|
|
2021-05-06 23:47:09 +03:00
|
|
|
__attribute__((section("xdp_prog"), used)) int
|
|
|
|
func(struct xdp_md* ctx)
|
2021-05-05 18:39:38 +03:00
|
|
|
{
|
2021-05-06 23:47:09 +03:00
|
|
|
uint32_t key = 0;
|
|
|
|
uint32_t value = 42;
|
|
|
|
int result = bpf_map_update_elem(&map, &key, &value, 0);
|
|
|
|
return result;
|
2021-05-05 18:39:38 +03:00
|
|
|
}
|