-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
runtime: add network related helpers and maps (#297)
* add bpf_get_smp_processor_id * add xdp related functions * add helpers and map in maps
- Loading branch information
Showing
4 changed files
with
203 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef BPFTIME_EXTENSION_USERSPACE_XDP_HPP | ||
#define BPFTIME_EXTENSION_USERSPACE_XDP_HPP | ||
|
||
#include <cstdint> | ||
|
||
struct xdp_md_userspace | ||
{ | ||
uint64_t data; | ||
uint64_t data_end; | ||
uint32_t data_meta; | ||
uint32_t ingress_ifindex; | ||
uint32_t rx_queue_index; | ||
uint32_t egress_ifindex; | ||
// additional fields | ||
uint64_t buffer_start; // record the start of the available buffer | ||
uint64_t buffer_end; // record the end of the available buffer | ||
}; | ||
|
||
#endif // BPFTIME_EXTENSION_USERSPACE_XDP_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* SPDX-License-Identifier: MIT | ||
* | ||
* Copyright (c) 2022, eunomia-bpf org | ||
* All rights reserved. | ||
*/ | ||
#ifndef _MAP_IN_MAP_HPP | ||
#define _MAP_IN_MAP_HPP | ||
|
||
#include <bpf_map/map_common_def.hpp> | ||
#include "array_map.hpp" | ||
|
||
namespace bpftime | ||
{ | ||
|
||
// implementation of array map | ||
class array_map_of_maps_impl : public array_map_impl { | ||
public: | ||
array_map_of_maps_impl(boost::interprocess::managed_shared_memory &memory, uint32_t max_entries) : array_map_impl(memory, sizeof(int), max_entries){ | ||
} | ||
// TODO: add verify the correctness of the key | ||
void *elem_lookup(const void *key) { | ||
auto key_val = array_map_impl::elem_lookup(key); | ||
int map_id = *(int *)key_val; | ||
return (void*)((u_int64_t)map_id << 32); | ||
} | ||
}; | ||
|
||
} // namespace bpftime | ||
|
||
#endif // _MAP_IN_MAP_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters