forked from quic-go/quic-go
add a QUIC_GO_DISABLE_ECN env to disable ECN support
This commit is contained in:
5
.github/workflows/integration.yml
vendored
5
.github/workflows/integration.yml
vendored
@@ -41,6 +41,11 @@ jobs:
|
||||
env:
|
||||
QUIC_GO_DISABLE_GSO: true
|
||||
run: go run github.com/onsi/ginkgo/v2/ginkgo -r -v -randomize-all -randomize-suites -trace integrationtests/self -- -version=1 ${{ env.QLOGFLAG }}
|
||||
- name: Run self tests, with ECN disabled
|
||||
if: ${{ matrix.os == 'ubuntu' && (success() || failure()) }} # run this step even if the previous one failed
|
||||
env:
|
||||
QUIC_GO_DISABLE_ECN: true
|
||||
run: go run github.com/onsi/ginkgo/v2/ginkgo -r -v -randomize-all -randomize-suites -trace integrationtests/self -- -version=1 ${{ env.QLOGFLAG }}
|
||||
- name: Run tests (32 bit)
|
||||
if: ${{ matrix.os != 'macos' && (success() || failure()) }} # run this step even if the previous one failed
|
||||
env:
|
||||
|
||||
@@ -8,6 +8,8 @@ import (
|
||||
"log"
|
||||
"net"
|
||||
"net/netip"
|
||||
"os"
|
||||
"strconv"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
@@ -57,6 +59,11 @@ func inspectWriteBuffer(c syscall.RawConn) (int, error) {
|
||||
return size, serr
|
||||
}
|
||||
|
||||
func isECNDisabled() bool {
|
||||
disabled, err := strconv.ParseBool(os.Getenv("QUIC_GO_DISABLE_ECN"))
|
||||
return err == nil && disabled
|
||||
}
|
||||
|
||||
type oobConn struct {
|
||||
OOBCapablePacketConn
|
||||
batchConn batchConn
|
||||
@@ -141,7 +148,7 @@ func newConn(c OOBCapablePacketConn, supportsDF bool) (*oobConn, error) {
|
||||
cap: connCapabilities{
|
||||
DF: supportsDF,
|
||||
GSO: isGSOSupported(rawConn),
|
||||
ECN: true,
|
||||
ECN: !isECNDisabled(),
|
||||
},
|
||||
}
|
||||
for i := 0; i < batchSize; i++ {
|
||||
@@ -239,6 +246,9 @@ func (c *oobConn) WritePacket(b []byte, addr net.Addr, packetInfoOOB []byte, gso
|
||||
oob = appendUDPSegmentSizeMsg(oob, gsoSize)
|
||||
}
|
||||
if ecn != protocol.ECNUnsupported {
|
||||
if !c.capabilities().ECN {
|
||||
panic("tried to send a ECN-marked packet although ECN is disabled")
|
||||
}
|
||||
if remoteUDPAddr, ok := addr.(*net.UDPAddr); ok {
|
||||
if remoteUDPAddr.IP.To4() != nil {
|
||||
oob = appendIPv4ECNMsg(oob, ecn)
|
||||
|
||||
Reference in New Issue
Block a user