-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
3,944 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include "vproxy_xdp.h" | ||
|
||
void _vp_dummy(void) {} | ||
#pragma GCC diagnostic ignored "-Wpragmas" | ||
#pragma redefine_extname _vp_dummy vp_dummy | ||
#pragma GCC diagnostic error "-Wpragmas" | ||
|
||
struct vp_chunk_info* _vp_chunk_seek(struct vp_chunk_array* chunks, uint64_t addroff) { | ||
return vp_chunk_seek(chunks, addroff); | ||
} | ||
#pragma redefine_extname _vp_chunk_seek vp_chunk_seek | ||
|
||
struct vp_chunk_info* _vp_chunk_fetch(struct vp_chunk_array* chunks) { | ||
return vp_chunk_fetch(chunks); | ||
} | ||
#pragma redefine_extname _vp_chunk_fetch vp_chunk_fetch | ||
|
||
void _vp_chunk_release(struct vp_chunk_array* chunks, struct vp_chunk_info* chunk) { | ||
vp_chunk_release(chunks, chunk); | ||
} | ||
#pragma redefine_extname _vp_chunk_release vp_chunk_release |
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,43 @@ | ||
.gradle | ||
build/ | ||
!gradle/wrapper/gradle-wrapper.jar | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### IntelliJ IDEA ### | ||
.idea/ | ||
*.iws | ||
*.iml | ||
*.ipr | ||
out/ | ||
!**/src/main/**/out/ | ||
!**/src/test/**/out/ | ||
|
||
### Eclipse ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
bin/ | ||
!**/src/main/**/bin/ | ||
!**/src/test/**/bin/ | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
### Mac OS ### | ||
.DS_Store | ||
|
||
# pni | ||
core/src/main/c-generated/* | ||
!core/src/main/c-generated/.gitkeep |
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 @@ | ||
22 |
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,97 @@ | ||
import io.vproxy.pni.exec.CompilationFlag | ||
|
||
buildscript { | ||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
} | ||
def PNI_VERSION = '22.0.0.21' | ||
ext.set("PNI_VERSION", PNI_VERSION) | ||
dependencies { | ||
classpath group: 'io.vproxy', name: 'pni-exec-jdk22', version: PNI_VERSION | ||
} | ||
} | ||
|
||
plugins { | ||
id 'java' | ||
} | ||
|
||
group = 'io.vproxy' | ||
version = '1.0-SNAPSHOT' | ||
|
||
subprojects { | ||
apply plugin: 'java-library' | ||
|
||
java { | ||
sourceCompatibility = '22' | ||
targetCompatibility = '22' | ||
} | ||
|
||
tasks.withType(JavaCompile) { | ||
options.encoding = "UTF-8" | ||
options.incremental = false | ||
} | ||
tasks.withType(JavaExec) { | ||
jvmArgs += '--enable-native-access=ALL-UNNAMED' | ||
javaLauncher.set(javaToolchains.launcherFor(java.toolchain)) | ||
} | ||
|
||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
api 'io.vproxy:pni-api-jdk22:' + PNI_VERSION | ||
} | ||
} | ||
|
||
project(":pni-template") { | ||
compileJava { | ||
options.compilerArgs += '-parameters' | ||
} | ||
|
||
task pniGenerate() { | ||
dependsOn compileJava | ||
|
||
def workingDir = project.rootProject.rootDir.getAbsolutePath() | ||
def opts = new io.vproxy.pni.exec.CompilerOptions() | ||
.setClasspath(List.of(workingDir + '/pni-template/build/classes/java/main')) | ||
.setJavaOutputBaseDirectory(workingDir + '/core/src/main/generated') | ||
.setCOutputDirectory(workingDir + '/core/src/main/c-generated') | ||
.setCompilationFlag(CompilationFlag.TYPE_NAME_PREFIX, "PNI") | ||
.setCompilationFlag(CompilationFlag.ALWAYS_ALIGNED) | ||
|
||
def gen = new io.vproxy.pni.exec.Generator(opts) | ||
|
||
doLast { | ||
gen.generate() | ||
} | ||
} | ||
} | ||
|
||
project(":core") { | ||
sourceSets { | ||
main { | ||
java { | ||
srcDirs = ['src/main/java', 'src/main/generated'] | ||
} | ||
} | ||
} | ||
} | ||
|
||
project(":test") { | ||
dependencies { | ||
implementation project(":core") | ||
implementation "io.vproxy:commons:1.4.0" | ||
} | ||
|
||
task runSample(type: JavaExec) { | ||
classpath = sourceSets.test.runtimeClasspath | ||
workingDir = project.rootProject.rootDir.getParentFile().getAbsolutePath() | ||
systemProperty("java.library.path", | ||
"./" + File.pathSeparator + "./submodules/xdp-tools/lib/libxdp/" + | ||
File.pathSeparator + "/usr/lib/" + "uname -m".execute().text.trim() + "-linux-gnu") | ||
main = "io.vproxy.vpxdp.SampleUser" | ||
} | ||
} |
Empty file.
Empty file.
148 changes: 148 additions & 0 deletions
148
vpxdp-java/core/src/main/generated/io/vproxy/vpxdp/BPFMap.java
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,148 @@ | ||
package io.vproxy.vpxdp; | ||
|
||
import io.vproxy.pni.*; | ||
import io.vproxy.pni.hack.*; | ||
import io.vproxy.pni.array.*; | ||
import java.lang.foreign.*; | ||
import java.lang.invoke.*; | ||
import java.nio.ByteBuffer; | ||
|
||
public class BPFMap extends AbstractNativeObject implements NativeObject { | ||
public static final MemoryLayout LAYOUT = MemoryLayout.structLayout( | ||
|
||
); | ||
public final MemorySegment MEMORY; | ||
|
||
@Override | ||
public MemorySegment MEMORY() { | ||
return MEMORY; | ||
} | ||
|
||
public BPFMap(MemorySegment MEMORY) { | ||
MEMORY = MEMORY.reinterpret(LAYOUT.byteSize()); | ||
this.MEMORY = MEMORY; | ||
long OFFSET = 0; | ||
} | ||
|
||
public BPFMap(Allocator ALLOCATOR) { | ||
this(ALLOCATOR.allocate(LAYOUT)); | ||
} | ||
|
||
private static final MethodHandle addXskMH = PanamaUtils.lookupPNICriticalFunction(new PNILinkOptions().setCritical(true), int.class, "vp_xsk_add_into_map", MemorySegment.class /* self */, int.class /* key */, io.vproxy.vpxdp.XskInfo.LAYOUT.getClass() /* xsk */); | ||
|
||
public int addXsk(int key, io.vproxy.vpxdp.XskInfo xsk) { | ||
int RESULT; | ||
try { | ||
RESULT = (int) addXskMH.invokeExact(MEMORY, key, (MemorySegment) (xsk == null ? MemorySegment.NULL : xsk.MEMORY)); | ||
} catch (Throwable THROWABLE) { | ||
throw PanamaUtils.convertInvokeExactException(THROWABLE); | ||
} | ||
return RESULT; | ||
} | ||
|
||
private static final MethodHandle addMacMH = PanamaUtils.lookupPNICriticalFunction(new PNILinkOptions().setCritical(true), int.class, "vp_mac_add_into_map", MemorySegment.class /* self */, MemorySegment.class /* mac */, String.class /* ifname */); | ||
|
||
public int addMac(MemorySegment mac, PNIString ifname) { | ||
int RESULT; | ||
try { | ||
RESULT = (int) addMacMH.invokeExact(MEMORY, (MemorySegment) (mac == null ? MemorySegment.NULL : mac), (MemorySegment) (ifname == null ? MemorySegment.NULL : ifname.MEMORY)); | ||
} catch (Throwable THROWABLE) { | ||
throw PanamaUtils.convertInvokeExactException(THROWABLE); | ||
} | ||
return RESULT; | ||
} | ||
|
||
private static final MethodHandle removeMacMH = PanamaUtils.lookupPNICriticalFunction(new PNILinkOptions().setCritical(true), int.class, "vp_mac_remove_from_map", MemorySegment.class /* self */, MemorySegment.class /* mac */); | ||
|
||
public int removeMac(MemorySegment mac) { | ||
int RESULT; | ||
try { | ||
RESULT = (int) removeMacMH.invokeExact(MEMORY, (MemorySegment) (mac == null ? MemorySegment.NULL : mac)); | ||
} catch (Throwable THROWABLE) { | ||
throw PanamaUtils.convertInvokeExactException(THROWABLE); | ||
} | ||
return RESULT; | ||
} | ||
|
||
@Override | ||
public void toString(StringBuilder SB, int INDENT, java.util.Set<NativeObjectTuple> VISITED, boolean CORRUPTED_MEMORY) { | ||
if (!VISITED.add(new NativeObjectTuple(this))) { | ||
SB.append("<...>@").append(Long.toString(MEMORY.address(), 16)); | ||
return; | ||
} | ||
SB.append("BPFMap{\n"); | ||
SB.append(" ".repeat(INDENT)).append("}@").append(Long.toString(MEMORY.address(), 16)); | ||
} | ||
|
||
public static class Array extends RefArray<BPFMap> { | ||
public Array(MemorySegment buf) { | ||
super(buf, BPFMap.LAYOUT); | ||
} | ||
|
||
public Array(Allocator allocator, long len) { | ||
super(allocator, BPFMap.LAYOUT, len); | ||
} | ||
|
||
public Array(PNIBuf buf) { | ||
super(buf, BPFMap.LAYOUT); | ||
} | ||
|
||
@Override | ||
protected void elementToString(io.vproxy.vpxdp.BPFMap ELEM, StringBuilder SB, int INDENT, java.util.Set<NativeObjectTuple> VISITED, boolean CORRUPTED_MEMORY) { | ||
ELEM.toString(SB, INDENT, VISITED, CORRUPTED_MEMORY); | ||
} | ||
|
||
@Override | ||
protected String toStringTypeName() { | ||
return "BPFMap.Array"; | ||
} | ||
|
||
@Override | ||
protected BPFMap construct(MemorySegment seg) { | ||
return new BPFMap(seg); | ||
} | ||
|
||
@Override | ||
protected MemorySegment getSegment(BPFMap value) { | ||
return value.MEMORY; | ||
} | ||
} | ||
|
||
public static class Func extends PNIFunc<BPFMap> { | ||
private Func(io.vproxy.pni.CallSite<BPFMap> func) { | ||
super(func); | ||
} | ||
|
||
private Func(io.vproxy.pni.CallSite<BPFMap> func, Options opts) { | ||
super(func, opts); | ||
} | ||
|
||
private Func(MemorySegment MEMORY) { | ||
super(MEMORY); | ||
} | ||
|
||
public static Func of(io.vproxy.pni.CallSite<BPFMap> func) { | ||
return new Func(func); | ||
} | ||
|
||
public static Func of(io.vproxy.pni.CallSite<BPFMap> func, Options opts) { | ||
return new Func(func, opts); | ||
} | ||
|
||
public static Func of(MemorySegment MEMORY) { | ||
return new Func(MEMORY); | ||
} | ||
|
||
@Override | ||
protected String toStringTypeName() { | ||
return "BPFMap.Func"; | ||
} | ||
|
||
@Override | ||
protected BPFMap construct(MemorySegment seg) { | ||
return new BPFMap(seg); | ||
} | ||
} | ||
} | ||
// metadata.generator-version: pni 21.0.0.20 | ||
// sha256:19a844af4853c26c65bfb7e29fe5590c1e0ba5383438b965842fadb603a045bd |
Oops, something went wrong.