From 0b97e810645eb51cdddd3890e620325a562b04c1 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Tue, 28 Nov 2023 13:22:46 +0100 Subject: [PATCH] Adjust API usage to match latest quiche code (#624) Motivation: A API was changed in quiche to address a bug. We need to adjust our code as well Modifications: Pass in a pointer for the sequence number Result: Compiles against latest quiche code --- .../src/main/java/io/netty/incubator/codec/quic/Quiche.java | 2 +- .../io/netty/incubator/codec/quic/QuicheQuicChannel.java | 5 ++++- codec-native-quic/pom.xml | 2 +- codec-native-quic/src/main/c/netty_quic_quiche.c | 6 +++--- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/codec-classes-quic/src/main/java/io/netty/incubator/codec/quic/Quiche.java b/codec-classes-quic/src/main/java/io/netty/incubator/codec/quic/Quiche.java index d5aaf9dfc..b15e71a45 100644 --- a/codec-classes-quic/src/main/java/io/netty/incubator/codec/quic/Quiche.java +++ b/codec-classes-quic/src/main/java/io/netty/incubator/codec/quic/Quiche.java @@ -557,7 +557,7 @@ static native int quiche_conn_stream_priority( static native int quiche_conn_scids_left(long connAddr); - static native long quiche_conn_new_scid(long connAddr, long scidAddr, int scidLen, byte[] resetToken, boolean retire_if_needed); + static native long quiche_conn_new_scid(long connAddr, long scidAddr, int scidLen, byte[] resetToken, boolean retire_if_needed, long seq); static native byte[] quiche_conn_retired_scid_next(long connAddr); diff --git a/codec-classes-quic/src/main/java/io/netty/incubator/codec/quic/QuicheQuicChannel.java b/codec-classes-quic/src/main/java/io/netty/incubator/codec/quic/QuicheQuicChannel.java index 247df144a..5fa2a578a 100644 --- a/codec-classes-quic/src/main/java/io/netty/incubator/codec/quic/QuicheQuicChannel.java +++ b/codec-classes-quic/src/main/java/io/netty/incubator/codec/quic/QuicheQuicChannel.java @@ -916,9 +916,11 @@ List newSourceConnectionIds( boolean sendAndFlush = false; ByteBuffer key = localIdAdrr.connId.duplicate(); ByteBuf connIdBuffer = alloc().directBuffer(key.remaining()); + ByteBuf seqBuffer = alloc().directBuffer(Long.BYTES); byte[] resetTokenArray = new byte[Quic.RESET_TOKEN_LEN]; try { + long seqAddress = Quiche.memoryAddress(seqBuffer, 0, seqBuffer.capacity()); do { ByteBuffer srcId = connectionIdGenerator.newId(key, key.remaining()); connIdBuffer.clear(); @@ -927,7 +929,7 @@ List newSourceConnectionIds( resetToken.get(resetTokenArray); long result = Quiche.quiche_conn_new_scid( connAddr, Quiche.memoryAddress(connIdBuffer, 0, connIdBuffer.readableBytes()), - connIdBuffer.readableBytes(), resetTokenArray, false); + connIdBuffer.readableBytes(), resetTokenArray, false, seqAddress); if (result < 0) { break; } @@ -937,6 +939,7 @@ List newSourceConnectionIds( } while (--left > 0); } finally { connIdBuffer.release(); + seqBuffer.release(); } if (sendAndFlush) { diff --git a/codec-native-quic/pom.xml b/codec-native-quic/pom.xml index 730b38ba8..38e855aae 100644 --- a/codec-native-quic/pom.xml +++ b/codec-native-quic/pom.xml @@ -56,7 +56,7 @@ ${quicheHomeDir}/quiche/include https://github.com/cloudflare/quiche master - 5796adc0a06044e9e4f2020ad51f680bd0d071bc + b0944d88882e412685554446e6209c317b6f912b ${project.build.directory}/generated-sources ${project.build.directory}/template diff --git a/codec-native-quic/src/main/c/netty_quic_quiche.c b/codec-native-quic/src/main/c/netty_quic_quiche.c index 0ede0612d..8f870e0b2 100644 --- a/codec-native-quic/src/main/c/netty_quic_quiche.c +++ b/codec-native-quic/src/main/c/netty_quic_quiche.c @@ -664,9 +664,9 @@ static jint netty_quiche_conn_scids_left(JNIEnv* env, jclass clazz, jlong conn) return (jint) quiche_conn_scids_left((quiche_conn *) conn); } -static jlong netty_quiche_conn_new_scid(JNIEnv* env, jclass clazz, jlong conn, jlong scid, jint scid_len, jbyteArray reset_token, jboolean retire_if_needed) { +static jlong netty_quiche_conn_new_scid(JNIEnv* env, jclass clazz, jlong conn, jlong scid, jint scid_len, jbyteArray reset_token, jboolean retire_if_needed, jlong seq) { uint8_t* buf = (uint8_t*) (*env)->GetByteArrayElements(env, reset_token, 0); - jlong ret = quiche_conn_new_scid((quiche_conn *) conn, (const uint8_t *) scid, scid_len, buf, retire_if_needed == JNI_TRUE ? true : false); + jlong ret = quiche_conn_new_scid((quiche_conn *) conn, (const uint8_t *) scid, scid_len, buf, retire_if_needed == JNI_TRUE ? true : false, (uint64_t*) seq); (*env)->ReleaseByteArrayElements(env, reset_token, (jbyte*)buf, JNI_ABORT); return ret; } @@ -1134,7 +1134,7 @@ static const JNINativeMethod fixed_method_table[] = { { "quiche_conn_set_session", "(J[B)I", (void* ) netty_quiche_conn_set_session }, { "quiche_conn_max_send_udp_payload_size", "(J)I", (void* ) netty_quiche_conn_max_send_udp_payload_size }, { "quiche_conn_scids_left", "(J)I", (void* ) netty_quiche_conn_scids_left }, - { "quiche_conn_new_scid", "(JJI[BZ)J", (void* ) netty_quiche_conn_new_scid }, + { "quiche_conn_new_scid", "(JJI[BZJ)J", (void* ) netty_quiche_conn_new_scid }, { "quiche_conn_retired_scid_next", "(J)[B", (void* ) netty_quiche_conn_retired_scid_next }, { "quiche_config_new", "(I)J", (void *) netty_quiche_config_new }, { "quiche_config_enable_dgram", "(JZII)V", (void *) netty_quiche_config_enable_dgram },