-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
XDP declarations are moved from ebpf_nethooks.h. (#3793)
* Initial commit * Merge with main * Removed ebpf_xdp_test_hooks.h in net_ebpf_ext.h * Removed header not needed * Addressed PR comments * Addressed PR comments * Addressed PR comments * Keeping the change with SEC(xdp) * Generated sample files * Added the generated tests/bpf2c_tests/expected files * Fixed the output expectation * Generated expected files after main merge * Re-push all the generated file
- Loading branch information
Showing
34 changed files
with
1,744 additions
and
1,724 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
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
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,65 @@ | ||
// Copyright (c) eBPF for Windows contributors | ||
// SPDX-License-Identifier: MIT | ||
#pragma once | ||
#include <stdint.h> | ||
|
||
// This file contains APIs for hooks and helpers that are | ||
// exposed by netebpfext.sys for use by eBPF xdp test programs. | ||
|
||
// XDP_TEST hook. | ||
typedef struct xdp_md_ | ||
{ | ||
void* data; ///< Pointer to start of packet data. | ||
void* data_end; ///< Pointer to end of packet data. | ||
uint64_t data_meta; ///< Packet metadata. | ||
uint32_t ingress_ifindex; ///< Ingress interface index. | ||
|
||
/* size: 26, cachelines: 1, members: 4 */ | ||
/* last cacheline: 26 bytes */ | ||
} xdp_md_t; | ||
|
||
typedef enum _xdp_action | ||
{ | ||
XDP_PASS = 1, ///< Allow the packet to pass. | ||
XDP_DROP, ///< Drop the packet. | ||
XDP_TX ///< Bounce the received packet back out the same NIC it arrived on. | ||
} xdp_action_t; | ||
|
||
/** | ||
* @brief Handle an incoming packet as early as possible. | ||
* | ||
* Program type: \ref EBPF_PROGRAM_TYPE_XDP_TEST | ||
* | ||
* @param[in] context Packet metadata. | ||
* @retval XDP_PASS Allow the packet to pass. | ||
* @retval XDP_DROP Drop the packet. | ||
* @retval XDP_TX Bounce the received packet back out the same NIC it arrived on. | ||
*/ | ||
typedef xdp_action_t | ||
xdp_hook_t(xdp_md_t* context); | ||
|
||
// XDP_TEST helper functions. | ||
#define XDP_EXT_HELPER_FN_BASE 0xFFFF | ||
|
||
#ifndef __doxygen | ||
#define EBPF_HELPER(return_type, name, args) typedef return_type(*const name##_t) args | ||
#endif | ||
|
||
typedef enum | ||
{ | ||
BPF_FUNC_xdp_adjust_head = XDP_EXT_HELPER_FN_BASE + 1, | ||
} ebpf_nethook_helper_id_t; | ||
|
||
/** | ||
* @brief Adjust XDP_TEST context data pointer. | ||
* | ||
* @param[in] ctx XDP_TEST context. | ||
* @param[in] delta Number of bytes to move the data pointer by. | ||
* | ||
* @retval 0 The operation was successful. | ||
* @retval <0 A failure occurred. | ||
*/ | ||
EBPF_HELPER(int, bpf_xdp_adjust_head, (xdp_md_t * ctx, int delta)); | ||
#ifndef __doxygen | ||
#define bpf_xdp_adjust_head ((bpf_xdp_adjust_head_t)BPF_FUNC_xdp_adjust_head) | ||
#endif |
Oops, something went wrong.