From e00bea7a43e8d8edb13cbc217929aea7bdd69edf Mon Sep 17 00:00:00 2001 From: Logan Lamb Date: Tue, 15 Aug 2023 17:56:16 +0000 Subject: [PATCH] bpf_printk test --- src/tango/xdp/build-xdp.sh | 6 ++++++ src/tango/xdp/fd_xdp_redirect_prog.c | 25 ++++++++++++++----------- src/tango/xdp/fd_xdp_redirect_prog.o | Bin 1272 -> 1472 bytes 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/tango/xdp/build-xdp.sh b/src/tango/xdp/build-xdp.sh index 33a7996b7d..501dd7bbf1 100755 --- a/src/tango/xdp/build-xdp.sh +++ b/src/tango/xdp/build-xdp.sh @@ -7,6 +7,12 @@ # which is not supported for the eBPF target -- the kernel verifier # provides such safety features. +# bash strict mode +set -euo pipefail +IFS=$'\n\t' +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +cd "${SCRIPT_DIR}" + clang \ -std=c17 \ -I./opt/include \ diff --git a/src/tango/xdp/fd_xdp_redirect_prog.c b/src/tango/xdp/fd_xdp_redirect_prog.c index fbe5cb8b76..59073bbc06 100644 --- a/src/tango/xdp/fd_xdp_redirect_prog.c +++ b/src/tango/xdp/fd_xdp_redirect_prog.c @@ -21,6 +21,7 @@ #include "fd_xdp_redirect_prog.h" #include +#include /* TODO: Some devices only support one XSK which requires multiplexing @@ -30,20 +31,21 @@ /* Metadata ***********************************************************/ -char __license[] __attribute__(( section("license") )) = "Apache-2.0"; +char LICENSE[] SEC("license") = "GPL"; +//char __license[] __attribute__(( section("license") )) = "GPL"; /* eBPF syscalls ******************************************************/ -static void * -(* bpf_map_lookup_elem)( void * map, - void const * key) - = (void *)1U; - -static long -(* bpf_redirect_map)( void * map, - ulong key, - ulong flags ) - = (void *)51U; +//static void * +//(* bpf_map_lookup_elem)( void * map, +// void const * key) +// = (void *)1U; +// +//static long +//(* bpf_redirect_map)( void * map, +// ulong key, +// ulong flags ) +// = (void *)51U; /* eBPF maps **********************************************************/ @@ -67,6 +69,7 @@ extern uint fd_xdp_udp_dsts __attribute__((section("maps"))); Returns an XDP action code in XDP_{PASS,REDIRECT,DROP}. */ __attribute__(( section("xdp"), used )) int fd_xdp_redirect( struct xdp_md *ctx ) { + bpf_printk("neat\n"); uchar const * data = (uchar const*)(ulong)ctx->data; uchar const * data_end = (uchar const*)(ulong)ctx->data_end; diff --git a/src/tango/xdp/fd_xdp_redirect_prog.o b/src/tango/xdp/fd_xdp_redirect_prog.o index 9371b53d35fae25e5babf6fb738dbdda53ab97b0..9ac0fbba96fe2d63821e6c23d70cee63f548da39 100644 GIT binary patch literal 1472 zcmbtS&5P4e5TCT&&93;>tsjemBI`-mxcG4sEW1<@gI!p}V@R89D7M=+iBj=kFM>xe zg2%;+e?mP7xq9>>_-}Y}Z}B%TZ<_LCy*T8(ncwft%$qlpH!b%;#j;4mqTf^^VTq>I z(rzlVNvrV8E)@K_5j3k1E#v4d7V8-nDDr)5tUEQOvxZV+BmWJUn;RR77&lHT9f3a! zYkclhff2R>t9?g78aFN~L-5nuWvattG4E-3jJ1D+c&_6a^gZY^J1U$qeQtxtN1NBz z)IskSd!yd^6{RD*lj~_;Q;=R?I?CC~J{8!8`%#|fW{v-H06}@0jo&gKbnuXIcC;ef}HSg;CSn->dRw~Oj zIcYdaX+Q8L!N`llpcjYT)bSwugTHw3dja1dNfW`7ZKDm!}T2J;` zeiXkgeJ&|w>2}Ro#=K{tRGMsq=f~D z4WN2K6i78Q3oCvZ*0xAyTBHJec6$b!Lg)X@O