@@ -16,10 +16,8 @@ package appnet
16
16
17
17
import (
18
18
"context"
19
- "errors"
20
19
"fmt"
21
20
"net"
22
- "time"
23
21
24
22
"github.com/scionproto/scion/pkg/addr"
25
23
"github.com/scionproto/scion/pkg/log"
@@ -47,81 +45,41 @@ type AddressRewriter struct {
47
45
SVCRouter SVCResolver
48
46
// Resolver performs SVC resolution if enabled.
49
47
Resolver Resolver
50
- // SVCResolutionFraction enables SVC resolution for traffic to SVC
51
- // destinations in a way that is also compatible with control plane servers
52
- // that do not implement the SVC Resolution Mechanism. The value represents
53
- // the percentage of time, out of the total available context timeout,
54
- // spent attempting to perform SVC resolution. If SVCResolutionFraction is
55
- // 0 or less, SVC resolution is never attempted. If it is between 0 and 1,
56
- // the remaining context timeout is multiplied by the value, and that
57
- // amount of time is spent waiting for an SVC resolution reply from the
58
- // server. If this times out, the data packet is sent with an SVC
59
- // destination. If the value is 1 or more, then legacy behavior is
60
- // disabled, and data packets are never sent to SVC destinations unless the
61
- // resolution step is successful.
62
- SVCResolutionFraction float64
63
48
}
64
49
65
50
// RedirectToQUIC takes an address and adds a path (if one does not already
66
51
// exist but is required), and replaces SVC destinations with QUIC unicast
67
52
// ones, if possible.
68
53
//
69
- // The returned boolean value is set to true if the remote server is
70
- // QUIC-compatible and we have successfully discovered its address.
71
- //
72
54
// If the address is already unicast, no redirection to QUIC is attempted.
73
55
func (r AddressRewriter ) RedirectToQUIC (ctx context.Context ,
74
- address net.Addr ) (net.Addr , bool , error ) {
75
- logger := log .FromCtx (ctx )
76
-
77
- // FIXME(scrye): This is not legitimate use. It's only included for
78
- // compatibility with older unit tests. See
79
- // https://github.com/scionproto/scion/issues/2611.
80
- if address == nil {
81
- return address , false , nil
82
- }
56
+ address net.Addr ) (net.Addr , error ) {
83
57
84
58
switch a := address .(type ) {
85
59
case * snet.UDPAddr :
86
- return a , false , nil
60
+ return a , nil
87
61
case * snet.SVCAddr :
88
62
fa , err := r .buildFullAddress (ctx , a )
89
63
if err != nil {
90
- return nil , false , err
91
- }
92
- if r .SVCResolutionFraction <= 0.0 {
93
- return fa , false , nil
64
+ return nil , err
94
65
}
95
66
96
67
path , err := fa .GetPath ()
97
68
if err != nil {
98
- return nil , false , serrors .WrapStr ("bad path" , err )
69
+ return nil , serrors .WrapStr ("bad path" , err )
99
70
}
100
71
101
72
// During One-Hop Path operation, use SVC resolution to also bootstrap the path.
102
- p , u , quicRedirect , err := r .resolveSVC (ctx , path , fa .SVC )
73
+ p , u , err := r .resolveSVC (ctx , path , fa .SVC )
103
74
if err != nil {
104
- // For a revoked path we don't fallback we want to give the option
105
- // to retry with a new path.
106
- isRevokedPath := func (err error ) bool {
107
- var opErr * snet.OpError
108
- return errors .As (err , & opErr ) && opErr .RevInfo () != nil
109
- }
110
- if r .SVCResolutionFraction < 1.0 && ! isRevokedPath (err ) {
111
- // SVC resolution failed but we allow legacy behavior and have some
112
- // fraction of the timeout left for data transfers, so return
113
- // address with SVC destination still set
114
- logger .Debug ("Falling back to legacy mode, ignore error" , "err" , err )
115
- return fa , false , nil
116
- }
117
- return a , false , err
75
+ return a , err
118
76
}
119
77
120
78
ret := & snet.UDPAddr {IA : fa .IA , Path : p .Dataplane (), NextHop : fa .NextHop , Host : u }
121
- return ret , quicRedirect , err
79
+ return ret , nil
122
80
}
123
81
124
- return nil , false , serrors .New ("address type not supported" ,
82
+ return nil , serrors .New ("address type not supported" ,
125
83
"addr" , fmt .Sprintf ("%v(%T)" , address , address ))
126
84
}
127
85
@@ -167,48 +125,30 @@ func (r AddressRewriter) buildFullAddress(ctx context.Context,
167
125
return ret , nil
168
126
}
169
127
170
- // resolveSVC performs SVC resolution and returns an UDP/IP address. If the UDP/IP
171
- // address is for a QUIC-compatible server, the returned boolean value is set
172
- // to true. If the address does not have an SVC destination, it is returned
128
+ // resolveSVC performs SVC resolution and returns an UDP/IP address.
129
+ // If the address does not have an SVC destination, it is returned
173
130
// unchanged. If address is not a well-formed application address (all fields
174
131
// set, non-nil, supported protocols), the function's behavior is undefined.
175
132
// The returned path is the path contained in the reply; the path can be used
176
133
// to talk to the remote AS after One-Hop Path construction.
177
134
func (r AddressRewriter ) resolveSVC (ctx context.Context , p snet.Path ,
178
- s addr.SVC ) (snet.Path , * net.UDPAddr , bool , error ) {
135
+ s addr.SVC ) (snet.Path , * net.UDPAddr , error ) {
179
136
logger := log .FromCtx (ctx )
180
- if r .SVCResolutionFraction < 1.0 {
181
- var cancelF context.CancelFunc
182
- ctx , cancelF = r .resolutionCtx (ctx )
183
- defer cancelF ()
184
- }
185
137
186
- logger .Debug ("Sending SVC resolution request" , "isd_as" , p .Destination (), "svc" , s ,
187
- "svcResFraction" , r .SVCResolutionFraction )
138
+ logger .Debug ("Sending SVC resolution request" , "isd_as" , p .Destination (), "svc" , s )
188
139
189
140
reply , err := r .Resolver .LookupSVC (ctx , p , s )
190
141
if err != nil {
191
142
logger .Debug ("SVC resolution failed" , "err" , err )
192
- return nil , nil , false , err
143
+ return nil , nil , err
193
144
}
194
145
195
146
logger .Debug ("SVC resolution successful" , "reply" , reply )
196
147
u , err := parseReply (reply )
197
148
if err != nil {
198
- return nil , nil , false , err
199
- }
200
- return reply .ReturnPath , u , true , nil
201
- }
202
-
203
- func (r AddressRewriter ) resolutionCtx (ctx context.Context ) (context.Context , context.CancelFunc ) {
204
- deadline , ok := ctx .Deadline ()
205
- if ! ok {
206
- return context .WithCancel (ctx )
149
+ return nil , nil , err
207
150
}
208
-
209
- timeout := time .Until (deadline )
210
- timeout = time .Duration (float64 (timeout ) * r .SVCResolutionFraction )
211
- return context .WithTimeout (ctx , timeout )
151
+ return reply .ReturnPath , u , nil
212
152
}
213
153
214
154
// parseReply searches for a QUIC server on the remote address. If one is not
0 commit comments