Skip to content

Commit fc0ecf4

Browse files
committed
TUN-7776: Remove warp-routing flag from cloudflared
1 parent 3495860 commit fc0ecf4

File tree

13 files changed

+23
-126
lines changed

13 files changed

+23
-126
lines changed

CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 2023.9.0
2+
### Notices
3+
- The `warp-routing` `enabled: boolean` flag is no longer supported in the configuration file. Warp Routing traffic (eg TCP, UDP, ICMP) traffic is proxied to cloudflared if routes to the target tunnel are configured. This change does not affect remotely managed tunnels, but for locally managed tunnels, users that might be relying on this feature flag to block traffic should instead guarantee that tunnel has no Private Routes configured for the tunnel.
14
## 2023.7.0
25
### New Features
36
- You can now enable additional diagnostics over the management.argotunnel.com service for your active cloudflared connectors via a new runtime flag `--management-diagnostics` (or env `TUNNEL_MANAGEMENT_DIAGNOSTICS`). This feature is provided as opt-in and requires the flag to enable. Endpoints such as /metrics provides your prometheus metrics endpoint another mechanism to be reached. Additionally /debug/pprof/(goroutine|heap) are also introduced to allow for remotely retrieving active pprof information from a running cloudflared connector.

config/configuration.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ type Configuration struct {
257257
}
258258

259259
type WarpRoutingConfig struct {
260-
Enabled bool `yaml:"enabled" json:"enabled"`
261260
ConnectTimeout *CustomDuration `yaml:"connectTimeout" json:"connectTimeout,omitempty"`
262261
TCPKeepAlive *CustomDuration `yaml:"tcpKeepAlive" json:"tcpKeepAlive,omitempty"`
263262
}

config/configuration_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ func TestConfigFileSettings(t *testing.T) {
2323
Service: "https://localhost:8001",
2424
}
2525
warpRouting = WarpRoutingConfig{
26-
Enabled: true,
2726
ConnectTimeout: &CustomDuration{Duration: 2 * time.Second},
2827
TCPKeepAlive: &CustomDuration{Duration: 10 * time.Second},
2928
}

connection/connection.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ type Orchestrator interface {
4040
UpdateConfig(version int32, config []byte) *pogs.UpdateConfigurationResponse
4141
GetConfigJSON() ([]byte, error)
4242
GetOriginProxy() (OriginProxy, error)
43-
WarpRoutingEnabled() (enabled bool)
4443
}
4544

4645
type NamedTunnelProperties struct {

connection/quic.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func NewQUICConnection(
103103
sessionDemuxChan := make(chan *packet.Session, demuxChanCapacity)
104104
datagramMuxer := quicpogs.NewDatagramMuxerV2(session, logger, sessionDemuxChan)
105105
sessionManager := datagramsession.NewManager(logger, datagramMuxer.SendToSession, sessionDemuxChan)
106-
packetRouter := ingress.NewPacketRouter(packetRouterConfig, datagramMuxer, logger, orchestrator.WarpRoutingEnabled)
106+
packetRouter := ingress.NewPacketRouter(packetRouterConfig, datagramMuxer, logger)
107107

108108
return &QUICConnection{
109109
session: session,

ingress/config.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,12 @@ const (
4444
)
4545

4646
type WarpRoutingConfig struct {
47-
Enabled bool `yaml:"enabled" json:"enabled"`
4847
ConnectTimeout config.CustomDuration `yaml:"connectTimeout" json:"connectTimeout,omitempty"`
4948
TCPKeepAlive config.CustomDuration `yaml:"tcpKeepAlive" json:"tcpKeepAlive,omitempty"`
5049
}
5150

5251
func NewWarpRoutingConfig(raw *config.WarpRoutingConfig) WarpRoutingConfig {
5352
cfg := WarpRoutingConfig{
54-
Enabled: raw.Enabled,
5553
ConnectTimeout: defaultWarpRoutingConnectTimeout,
5654
TCPKeepAlive: defaultTCPKeepAlive,
5755
}
@@ -65,9 +63,7 @@ func NewWarpRoutingConfig(raw *config.WarpRoutingConfig) WarpRoutingConfig {
6563
}
6664

6765
func (c *WarpRoutingConfig) RawConfig() config.WarpRoutingConfig {
68-
raw := config.WarpRoutingConfig{
69-
Enabled: c.Enabled,
70-
}
66+
raw := config.WarpRoutingConfig{}
7167
if c.ConnectTimeout.Duration != defaultWarpRoutingConnectTimeout.Duration {
7268
raw.ConnectTimeout = &c.ConnectTimeout
7369
}

ingress/packet_router.go

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@ type muxer interface {
2323

2424
// PacketRouter routes packets between Upstream and ICMPRouter. Currently it rejects all other type of ICMP packets
2525
type PacketRouter struct {
26-
globalConfig *GlobalRouterConfig
27-
muxer muxer
28-
logger *zerolog.Logger
29-
checkRouterEnabledFunc func() bool
30-
icmpDecoder *packet.ICMPDecoder
31-
encoder *packet.Encoder
26+
globalConfig *GlobalRouterConfig
27+
muxer muxer
28+
logger *zerolog.Logger
29+
icmpDecoder *packet.ICMPDecoder
30+
encoder *packet.Encoder
3231
}
3332

3433
// GlobalRouterConfig is the configuration shared by all instance of Router.
@@ -40,14 +39,13 @@ type GlobalRouterConfig struct {
4039
}
4140

4241
// NewPacketRouter creates a PacketRouter that handles ICMP packets. Packets are read from muxer but dropped if globalConfig is nil.
43-
func NewPacketRouter(globalConfig *GlobalRouterConfig, muxer muxer, logger *zerolog.Logger, checkRouterEnabledFunc func() bool) *PacketRouter {
42+
func NewPacketRouter(globalConfig *GlobalRouterConfig, muxer muxer, logger *zerolog.Logger) *PacketRouter {
4443
return &PacketRouter{
45-
globalConfig: globalConfig,
46-
muxer: muxer,
47-
logger: logger,
48-
checkRouterEnabledFunc: checkRouterEnabledFunc,
49-
icmpDecoder: packet.NewICMPDecoder(),
50-
encoder: packet.NewEncoder(),
44+
globalConfig: globalConfig,
45+
muxer: muxer,
46+
logger: logger,
47+
icmpDecoder: packet.NewICMPDecoder(),
48+
encoder: packet.NewEncoder(),
5149
}
5250
}
5351

@@ -92,10 +90,6 @@ func (r *PacketRouter) handlePacket(ctx context.Context, rawPacket packet.RawPac
9290
return
9391
}
9492

95-
if enabled := r.checkRouterEnabledFunc(); !enabled {
96-
return
97-
}
98-
9993
icmpPacket, err := r.icmpDecoder.Decode(rawPacket)
10094
if err != nil {
10195
r.logger.Err(err).Msg("Failed to decode ICMP packet from quic datagram")

ingress/packet_router_test.go

Lines changed: 1 addition & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"net/netip"
88
"sync/atomic"
99
"testing"
10-
"time"
1110

1211
"github.com/google/gopacket/layers"
1312
"github.com/stretchr/testify/require"
@@ -29,9 +28,7 @@ var (
2928

3029
func TestRouterReturnTTLExceed(t *testing.T) {
3130
muxer := newMockMuxer(0)
32-
routerEnabled := &routerEnabledChecker{}
33-
routerEnabled.set(true)
34-
router := NewPacketRouter(packetConfig, muxer, &noopLogger, routerEnabled.isEnabled)
31+
router := NewPacketRouter(packetConfig, muxer, &noopLogger)
3532
ctx, cancel := context.WithCancel(context.Background())
3633
routerStopped := make(chan struct{})
3734
go func() {
@@ -80,65 +77,6 @@ func TestRouterReturnTTLExceed(t *testing.T) {
8077
<-routerStopped
8178
}
8279

83-
func TestRouterCheckEnabled(t *testing.T) {
84-
muxer := newMockMuxer(0)
85-
routerEnabled := &routerEnabledChecker{}
86-
router := NewPacketRouter(packetConfig, muxer, &noopLogger, routerEnabled.isEnabled)
87-
ctx, cancel := context.WithCancel(context.Background())
88-
routerStopped := make(chan struct{})
89-
go func() {
90-
router.Serve(ctx)
91-
close(routerStopped)
92-
}()
93-
94-
pk := packet.ICMP{
95-
IP: &packet.IP{
96-
Src: netip.MustParseAddr("192.168.1.1"),
97-
Dst: netip.MustParseAddr("10.0.0.1"),
98-
Protocol: layers.IPProtocolICMPv4,
99-
TTL: 1,
100-
},
101-
Message: &icmp.Message{
102-
Type: ipv4.ICMPTypeEcho,
103-
Code: 0,
104-
Body: &icmp.Echo{
105-
ID: 12481,
106-
Seq: 8036,
107-
Data: []byte(t.Name()),
108-
},
109-
},
110-
}
111-
112-
// router is disabled
113-
encoder := packet.NewEncoder()
114-
encodedPacket, err := encoder.Encode(&pk)
115-
require.NoError(t, err)
116-
sendPacket := quicpogs.RawPacket(encodedPacket)
117-
118-
muxer.edgeToCfd <- sendPacket
119-
select {
120-
case <-time.After(time.Millisecond * 10):
121-
case <-muxer.cfdToEdge:
122-
t.Error("Unexpected reply when router is disabled")
123-
}
124-
routerEnabled.set(true)
125-
// router is enabled, expects reply
126-
muxer.edgeToCfd <- sendPacket
127-
<-muxer.cfdToEdge
128-
129-
routerEnabled.set(false)
130-
// router is disabled
131-
muxer.edgeToCfd <- sendPacket
132-
select {
133-
case <-time.After(time.Millisecond * 10):
134-
case <-muxer.cfdToEdge:
135-
t.Error("Unexpected reply when router is disabled")
136-
}
137-
138-
cancel()
139-
<-routerStopped
140-
}
141-
14280
func assertTTLExceed(t *testing.T, originalPacket *packet.ICMP, expectedSrc netip.Addr, muxer *mockMuxer) {
14381
encoder := packet.NewEncoder()
14482
rawPacket, err := encoder.Encode(originalPacket)

orchestration/config_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ func TestNewLocalConfig_MarshalJSON(t *testing.T) {
6060
}
6161
],
6262
"warp-routing": {
63-
"enabled": true,
6463
"connectTimeout": 1
6564
}
6665
}
@@ -83,7 +82,6 @@ func TestNewLocalConfig_MarshalJSON(t *testing.T) {
8382
require.NoError(t, err)
8483

8584
require.Equal(t, remoteConfig.WarpRouting, ingress.WarpRoutingConfig{
86-
Enabled: true,
8785
ConnectTimeout: config.CustomDuration{
8886
Duration: time.Second,
8987
},

orchestration/orchestrator.go

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,10 @@ type Orchestrator struct {
2929
// Underlying value is proxy.Proxy, can be read without the lock, but still needs the lock to update
3030
proxy atomic.Value
3131
// Set of internal ingress rules defined at cloudflared startup (separate from user-defined ingress rules)
32-
internalRules []ingress.Rule
33-
warpRoutingEnabled atomic.Bool
34-
config *Config
35-
tags []tunnelpogs.Tag
36-
log *zerolog.Logger
32+
internalRules []ingress.Rule
33+
config *Config
34+
tags []tunnelpogs.Tag
35+
log *zerolog.Logger
3736

3837
// orchestrator must not handle any more updates after shutdownC is closed
3938
shutdownC <-chan struct{}
@@ -136,11 +135,6 @@ func (o *Orchestrator) updateIngress(ingressRules ingress.Ingress, warpRouting i
136135
o.proxy.Store(proxy)
137136
o.config.Ingress = &ingressRules
138137
o.config.WarpRouting = warpRouting
139-
if warpRouting.Enabled {
140-
o.warpRoutingEnabled.Store(true)
141-
} else {
142-
o.warpRoutingEnabled.Store(false)
143-
}
144138

145139
// If proxyShutdownC is nil, there is no previous running proxy
146140
if o.proxyShutdownC != nil {
@@ -209,10 +203,6 @@ func (o *Orchestrator) GetOriginProxy() (connection.OriginProxy, error) {
209203
return proxy, nil
210204
}
211205

212-
func (o *Orchestrator) WarpRoutingEnabled() bool {
213-
return o.warpRoutingEnabled.Load()
214-
}
215-
216206
func (o *Orchestrator) waitToCloseLastProxy() {
217207
<-o.shutdownC
218208
o.lock.Lock()

0 commit comments

Comments
 (0)