From 316ff3f0594a7b403e43c7f738862e8a9b180040 Mon Sep 17 00:00:00 2001 From: wkgcass Date: Sun, 20 Oct 2024 01:02:54 +0800 Subject: [PATCH] [msquic] upgrade to msquic 2.4.5 --- .../vproxy/base/NativeAccessGraalFeature.java | 118 ++---------------- .../io/vproxy/msquic/MsQuicInitializer.java | 14 ++- misc/init.sh | 5 +- submodules/msquic-java | 2 +- 4 files changed, 24 insertions(+), 115 deletions(-) diff --git a/base/src/main/generated-graal/io/vproxy/base/NativeAccessGraalFeature.java b/base/src/main/generated-graal/io/vproxy/base/NativeAccessGraalFeature.java index ff404f8a..64d4e624 100644 --- a/base/src/main/generated-graal/io/vproxy/base/NativeAccessGraalFeature.java +++ b/base/src/main/generated-graal/io/vproxy/base/NativeAccessGraalFeature.java @@ -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 */)); @@ -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 */)); @@ -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 diff --git a/base/src/main/java/io/vproxy/msquic/MsQuicInitializer.java b/base/src/main/java/io/vproxy/msquic/MsQuicInitializer.java index d264a6c1..7e6454e8 100644 --- a/base/src/main/java/io/vproxy/msquic/MsQuicInitializer.java +++ b/base/src/main/java/io/vproxy/msquic/MsQuicInitializer.java @@ -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; @@ -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; diff --git a/misc/init.sh b/misc/init.sh index d34d91e9..a511c554 100755 --- a/misc/init.sh +++ b/misc/init.sh @@ -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 diff --git a/submodules/msquic-java b/submodules/msquic-java index 8403f9c8..863726b1 160000 --- a/submodules/msquic-java +++ b/submodules/msquic-java @@ -1 +1 @@ -Subproject commit 8403f9c8b2e7b8ecc421a34f6c6bc7cc48335e38 +Subproject commit 863726b10a1d016e9a484cab47c51958f31cdae9