Skip to content

Commit

Permalink
[msquic] upgrade to msquic 2.4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
wkgcass committed Oct 19, 2024
1 parent 9342eea commit 316ff3f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ public void duringSetup(DuringSetupAccess access) {
/* JavaCritical_io_vproxy_msquic_QuicApiTable_openRegistration */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildCriticalFunctionDescriptor(MemoryLayout.class /* io.vproxy.msquic.QuicRegistration.LAYOUT.getClass() */, MemorySegment.class /* self */, MemoryLayout.class /* io.vproxy.msquic.QuicRegistrationConfig.LAYOUT.getClass() */ /* Config */, MemorySegment.class /* returnStatus */, MemorySegment.class /* return */));

/* JavaCritical_io_vproxy_msquic_QuicApiTable_setParam */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildCriticalFunctionDescriptor(int.class, MemorySegment.class /* self */, int.class /* Param */, int.class /* BufferLength */, MemorySegment.class /* Buffer */));

/* JavaCritical_io_vproxy_msquic_QuicApiTable_getParam */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildCriticalFunctionDescriptor(int.class, MemorySegment.class /* self */, int.class /* Param */, MemorySegment.class /* BufferLength */, MemorySegment.class /* Buffer */));

/* JavaCritical_io_vproxy_msquic_QuicConfiguration_close */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildCriticalFunctionDescriptor(void.class, MemorySegment.class /* self */));

Expand Down Expand Up @@ -154,9 +160,6 @@ public void duringSetup(DuringSetupAccess access) {
/* JavaCritical_io_vproxy_msquic_QuicConnection_certificateValidationComplete */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildCriticalFunctionDescriptor(int.class, MemorySegment.class /* self */, boolean.class /* Result */, int.class /* TlsAlert */));

/* JavaCritical_io_vproxy_msquic_QuicExtraApiTable_ThreadCountLimitSet */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildCriticalFunctionDescriptor(void.class, MemorySegment.class /* self */, int.class /* limit */));

/* JavaCritical_io_vproxy_msquic_QuicExtraApiTable_EventLoopThreadDispatcherSet */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildCriticalFunctionDescriptor(int.class, MemorySegment.class /* self */, MemorySegment.class /* dispatcher */));

Expand Down Expand Up @@ -679,114 +682,7 @@ public void duringSetup(DuringSetupAccess access) {
for (var CONS : java.io.IOException.class.getConstructors()) {
RuntimeReflection.register(CONS);
}

/* Java_io_vproxy_xdp_XDPNative_loadAndAttachBPFProgramToNic */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildFunctionDescriptor(String.class /* filepath */, String.class /* programName */, String.class /* nicName */, int.class /* mode */, boolean.class /* forceAttach */), PanamaHack.getCriticalOption());
RuntimeReflection.registerAllConstructors(java.io.IOException.class);
for (var CONS : java.io.IOException.class.getConstructors()) {
RuntimeReflection.register(CONS);
}

/* Java_io_vproxy_xdp_XDPNative_detachBPFProgramFromNic */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildFunctionDescriptor(String.class /* nicName */), PanamaHack.getCriticalOption());
RuntimeReflection.registerAllConstructors(java.io.IOException.class);
for (var CONS : java.io.IOException.class.getConstructors()) {
RuntimeReflection.register(CONS);
}

/* Java_io_vproxy_xdp_XDPNative_findMapByNameInBPF */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildFunctionDescriptor(long.class /* bpfobj */, String.class /* mapName */), PanamaHack.getCriticalOption());
RuntimeReflection.registerAllConstructors(java.io.IOException.class);
for (var CONS : java.io.IOException.class.getConstructors()) {
RuntimeReflection.register(CONS);
}

/* Java_io_vproxy_xdp_XDPNative_createUMem */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildFunctionDescriptor(int.class /* chunksSize */, int.class /* fillRingSize */, int.class /* compRingSize */, int.class /* frameSize */, int.class /* headroom */), PanamaHack.getCriticalOption());
RuntimeReflection.registerAllConstructors(java.io.IOException.class);
for (var CONS : java.io.IOException.class.getConstructors()) {
RuntimeReflection.register(CONS);
}

/* Java_io_vproxy_xdp_XDPNative_shareUMem */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildFunctionDescriptor(long.class /* umem */), PanamaHack.getCriticalOption());

/* Java_io_vproxy_xdp_XDPNative_getBufferFromUMem */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildFunctionDescriptor(long.class /* umem */), PanamaHack.getCriticalOption());

/* Java_io_vproxy_xdp_XDPNative_getBufferAddressFromUMem */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildFunctionDescriptor(long.class /* umem */), PanamaHack.getCriticalOption());

/* Java_io_vproxy_xdp_XDPNative_createXSK */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildFunctionDescriptor(String.class /* nicName */, int.class /* queueId */, long.class /* umem */, int.class /* rxRingSize */, int.class /* txRingSize */, int.class /* mode */, boolean.class /* zeroCopy */, int.class /* busyPollBudget */, boolean.class /* rxGenChecksum */), PanamaHack.getCriticalOption());
RuntimeReflection.registerAllConstructors(java.io.IOException.class);
for (var CONS : java.io.IOException.class.getConstructors()) {
RuntimeReflection.register(CONS);
}

/* Java_io_vproxy_xdp_XDPNative_addXSKIntoMap */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildFunctionDescriptor(long.class /* map */, int.class /* key */, long.class /* xsk */), PanamaHack.getCriticalOption());
RuntimeReflection.registerAllConstructors(java.io.IOException.class);
for (var CONS : java.io.IOException.class.getConstructors()) {
RuntimeReflection.register(CONS);
}

/* Java_io_vproxy_xdp_XDPNative_addMacIntoMap */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildFunctionDescriptor(long.class /* map */, MemorySegment.class /* mac */, long.class /* xsk */), PanamaHack.getCriticalOption());
RuntimeReflection.registerAllConstructors(java.io.IOException.class);
for (var CONS : java.io.IOException.class.getConstructors()) {
RuntimeReflection.register(CONS);
}

/* Java_io_vproxy_xdp_XDPNative_removeMacFromMap */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildFunctionDescriptor(long.class /* map */, MemorySegment.class /* mac */), PanamaHack.getCriticalOption());
RuntimeReflection.registerAllConstructors(java.io.IOException.class);
for (var CONS : java.io.IOException.class.getConstructors()) {
RuntimeReflection.register(CONS);
}

/* Java_io_vproxy_xdp_XDPNative_getFDFromXSK */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildFunctionDescriptor(long.class /* xsk */), PanamaHack.getCriticalOption());

/* Java_io_vproxy_xdp_XDPNative_fillUpFillRing */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildFunctionDescriptor(long.class /* umem */), PanamaHack.getCriticalOption());

/* Java_io_vproxy_xdp_XDPNative_fetchPackets0 */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildFunctionDescriptor(long.class /* xsk */, int.class /* capacity */, MemorySegment.class /* umem */, MemorySegment.class /* chunk */, MemorySegment.class /* ref */, MemorySegment.class /* addr */, MemorySegment.class /* endaddr */, MemorySegment.class /* pktaddr */, MemorySegment.class /* pktlen */), PanamaHack.getCriticalOption());

/* Java_io_vproxy_xdp_XDPNative_rxRelease */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildFunctionDescriptor(long.class /* xsk */, int.class /* cnt */), PanamaHack.getCriticalOption());

/* Java_io_vproxy_xdp_XDPNative_writePacket */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildFunctionDescriptor(long.class /* xsk */, long.class /* chunk */), PanamaHack.getCriticalOption());

/* Java_io_vproxy_xdp_XDPNative_writePackets */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildFunctionDescriptor(long.class /* xsk */, int.class /* size */, MemorySegment.class /* chunkPtrs */), PanamaHack.getCriticalOption());

/* Java_io_vproxy_xdp_XDPNative_completeTx */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildFunctionDescriptor(long.class /* xsk */), PanamaHack.getCriticalOption());

/* Java_io_vproxy_xdp_XDPNative_fetchChunk0 */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildFunctionDescriptor(long.class /* umemPtr */, MemorySegment.class /* umem */, MemorySegment.class /* chunk */, MemorySegment.class /* ref */, MemorySegment.class /* addr */, MemorySegment.class /* endaddr */, MemorySegment.class /* pktaddr */, MemorySegment.class /* pktlen */), PanamaHack.getCriticalOption());

/* Java_io_vproxy_xdp_XDPNative_setChunk */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildFunctionDescriptor(long.class /* chunk */, int.class /* pktaddr */, int.class /* pktlen */, int.class /* csumFlags */), PanamaHack.getCriticalOption());

/* Java_io_vproxy_xdp_XDPNative_releaseChunk */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildFunctionDescriptor(long.class /* umem */, long.class /* chunk */), PanamaHack.getCriticalOption());

/* Java_io_vproxy_xdp_XDPNative_addChunkRefCnt */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildFunctionDescriptor(long.class /* chunk */), PanamaHack.getCriticalOption());

/* Java_io_vproxy_xdp_XDPNative_releaseXSK */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildFunctionDescriptor(long.class /* xsk */), PanamaHack.getCriticalOption());

/* Java_io_vproxy_xdp_XDPNative_releaseUMem */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildFunctionDescriptor(long.class /* umem */, boolean.class /* releaseBuffer */), PanamaHack.getCriticalOption());

/* Java_io_vproxy_xdp_XDPNative_releaseBPFObject */
RuntimeForeignAccess.registerForDowncall(PanamaUtils.buildFunctionDescriptor(long.class /* bpfobj */), PanamaHack.getCriticalOption());
}
}
// metadata.generator-version: pni 22.0.0.20
// sha256:38a120bc4306f368794637a078c0c9afb54d1618acdba5a8e1f86295204ec27f
// sha256:a3f45507001a8b424ea5961244d78065cd208ed0d5b6b86a0a429d79f4809e02
14 changes: 13 additions & 1 deletion base/src/main/java/io/vproxy/msquic/MsQuicInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
import io.vproxy.base.util.Logger;
import io.vproxy.base.util.Utils;
import io.vproxy.msquic.wrap.ApiExtraTables;
import io.vproxy.msquic.wrap.ApiTables;
import io.vproxy.pni.Allocator;

import java.util.NoSuchElementException;

import static io.vproxy.msquic.MsQuicConsts.QUIC_PARAM_GLOBAL_EXECUTION_CONFIG;

public class MsQuicInitializer {
private static boolean initialized = false;
private static boolean supported = false;
Expand All @@ -25,11 +29,19 @@ public static boolean isSupported() {
return false;
}

ApiExtraTables.V2EXTRA.ThreadCountLimitSet(1); // FIXME: need to implement event loop migration
MsQuicUpcall.setImpl(MsQuicUpcallImpl.get());
MsQuicModUpcall.setImpl(MsQuicModUpcallImpl.get());
ApiExtraTables.V2EXTRA.EventLoopThreadDispatcherSet(MsQuicModUpcall.dispatch);

// FIXME: need to implement event loop migration
try (var allocator = Allocator.ofConfined()) {
int cpucnt = 1;
var config = new QuicExecutionConfig(allocator.allocate(QuicExecutionConfig.LAYOUT.byteSize()));
config.setProcessorCount(cpucnt);
config.getProcessorList().set(0, (short) 0);
ApiTables.V2.opts.apiTableQ.setParam(QUIC_PARAM_GLOBAL_EXECUTION_CONFIG, (int) config.MEMORY.byteSize(), config.MEMORY);
}

supported = true;
initialized = true;
return true;
Expand Down
5 changes: 3 additions & 2 deletions misc/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ git submodule update --init --recursive

cd submodules/

MSQUIC_VERSION="2.2.4"
MSQUIC_COMMIT="2a34f44107298d1e8723825b65dac4761ca6cafa"
MSQUIC_VERSION="2.4.5"
if [[ ! -d ./msquic ]]; then
git clone https://github.com/wkgcass/msquic --branch=$MSQUIC_VERSION-modified --depth=1
else
refs=`cat msquic/.git/HEAD | awk '{print $2}'`
commit=`cat "msquic/.git/$refs"`
if [[ "$commit" != "56cafbd0c26e1cb4e169b1233fe6d620218f6f61" ]]; then
if [[ "$commit" != "$MSQUIC_COMMIT" ]]; then
rm -rf ./msquic
git clone https://github.com/wkgcass/msquic --branch=$MSQUIC_VERSION-modified --depth=1
fi
Expand Down
2 changes: 1 addition & 1 deletion submodules/msquic-java
Submodule msquic-java updated 23 files
+3 −1 core/src/main/c-generated-graal/io_vproxy_msquic_QuicApiTable.h
+19 −1 core/src/main/c-generated-graal/io_vproxy_msquic_QuicApiTable.impl.h
+29 −0 core/src/main/c-generated-graal/io_vproxy_msquic_QuicExecutionConfig.h
+1 −2 core/src/main/c-generated-graal/io_vproxy_msquic_QuicExtraApiTable.h
+1 −5 core/src/main/c-generated-graal/io_vproxy_msquic_QuicExtraApiTable.impl.h
+3 −1 core/src/main/c-generated/io_vproxy_msquic_QuicApiTable.h
+19 −1 core/src/main/c-generated/io_vproxy_msquic_QuicApiTable.impl.h
+29 −0 core/src/main/c-generated/io_vproxy_msquic_QuicExecutionConfig.h
+1 −2 core/src/main/c-generated/io_vproxy_msquic_QuicExtraApiTable.h
+1 −5 core/src/main/c-generated/io_vproxy_msquic_QuicExtraApiTable.impl.h
+1 −0 core/src/main/c/io_vproxy_msquic_MsQuic.c
+7 −4 core/src/main/generated-graal/io/vproxy/msquic/Feature.java
+25 −1 core/src/main/generated-graal/io/vproxy/msquic/QuicApiTable.java
+195 −0 core/src/main/generated-graal/io/vproxy/msquic/QuicExecutionConfig.java
+1 −11 core/src/main/generated-graal/io/vproxy/msquic/QuicExtraApiTable.java
+33 −6 core/src/main/generated/io/vproxy/msquic/QuicApiTable.java
+190 −0 core/src/main/generated/io/vproxy/msquic/QuicExecutionConfig.java
+1 −11 core/src/main/generated/io/vproxy/msquic/QuicExtraApiTable.java
+1 −0 core/src/main/java/io/vproxy/msquic/MsQuicConsts.java
+11 −1 sample/src/main/java/io/vproxy/msquic/sample/Client.java
+12 −1 sample/src/main/java/io/vproxy/msquic/sample/Server.java
+0 −8 template/src/main/java/io/vproxy/msquic/Extension.java
+39 −0 template/src/main/java/io/vproxy/msquic/PNIQuicApiTable.java

0 comments on commit 316ff3f

Please sign in to comment.