Skip to content

Commit a1ed624

Browse files
authored
private/appnet: remove SvcResolutionFraction (scionproto#4561)
Clean up unused code paths related to old pre-QUIC-RPC-era service address resolution and the ominous SvcResolutionFraction.
1 parent 6458075 commit a1ed624

File tree

8 files changed

+48
-212
lines changed

8 files changed

+48
-212
lines changed

control/onehop/addr.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ type AddressRewriter struct {
6161
func (r *AddressRewriter) RedirectToQUIC(
6262
ctx context.Context,
6363
address net.Addr,
64-
) (net.Addr, bool, error) {
64+
) (net.Addr, error) {
6565
a, ok := address.(*Addr)
6666
if !ok {
6767
return r.Rewriter.RedirectToQUIC(ctx, address)
6868
}
6969
path, err := r.getPath(a.Egress)
7070
if err != nil {
71-
return nil, false, err
71+
return nil, err
7272
}
7373
svc := &snet.SVCAddr{
7474
IA: a.IA,

gateway/gateway.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,6 @@ func (g *Gateway) Run(ctx context.Context) error {
505505
Network: scionNetwork,
506506
LocalIP: g.ServiceDiscoveryClientIP,
507507
},
508-
SVCResolutionFraction: 1.337,
509508
},
510509
},
511510
},

pkg/grpc/dialer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func (t *TCPDialer) Dial(ctx context.Context, dst net.Addr) (*grpc.ClientConn, e
122122

123123
// AddressRewriter redirects to QUIC endpoints.
124124
type AddressRewriter interface {
125-
RedirectToQUIC(ctx context.Context, address net.Addr) (net.Addr, bool, error)
125+
RedirectToQUIC(ctx context.Context, address net.Addr) (net.Addr, error)
126126
}
127127

128128
// ConnDialer dials a net.Conn.
@@ -143,7 +143,7 @@ func (d *QUICDialer) Dial(ctx context.Context, addr net.Addr) (*grpc.ClientConn,
143143
// resolver+balancer mechanism of gRPC. For now, keep the legacy behavior of
144144
// dialing a connection based on the QUIC redirects.
145145

146-
addr, _, err := d.Rewriter.RedirectToQUIC(ctx, addr)
146+
addr, err := d.Rewriter.RedirectToQUIC(ctx, addr)
147147
if err != nil {
148148
return nil, serrors.WrapStr("resolving SVC address", err)
149149
}

private/app/appnet/addr.go

Lines changed: 15 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ package appnet
1616

1717
import (
1818
"context"
19-
"errors"
2019
"fmt"
2120
"net"
22-
"time"
2321

2422
"github.com/scionproto/scion/pkg/addr"
2523
"github.com/scionproto/scion/pkg/log"
@@ -47,81 +45,41 @@ type AddressRewriter struct {
4745
SVCRouter SVCResolver
4846
// Resolver performs SVC resolution if enabled.
4947
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
6348
}
6449

6550
// RedirectToQUIC takes an address and adds a path (if one does not already
6651
// exist but is required), and replaces SVC destinations with QUIC unicast
6752
// ones, if possible.
6853
//
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-
//
7254
// If the address is already unicast, no redirection to QUIC is attempted.
7355
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) {
8357

8458
switch a := address.(type) {
8559
case *snet.UDPAddr:
86-
return a, false, nil
60+
return a, nil
8761
case *snet.SVCAddr:
8862
fa, err := r.buildFullAddress(ctx, a)
8963
if err != nil {
90-
return nil, false, err
91-
}
92-
if r.SVCResolutionFraction <= 0.0 {
93-
return fa, false, nil
64+
return nil, err
9465
}
9566

9667
path, err := fa.GetPath()
9768
if err != nil {
98-
return nil, false, serrors.WrapStr("bad path", err)
69+
return nil, serrors.WrapStr("bad path", err)
9970
}
10071

10172
// 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)
10374
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
11876
}
11977

12078
ret := &snet.UDPAddr{IA: fa.IA, Path: p.Dataplane(), NextHop: fa.NextHop, Host: u}
121-
return ret, quicRedirect, err
79+
return ret, nil
12280
}
12381

124-
return nil, false, serrors.New("address type not supported",
82+
return nil, serrors.New("address type not supported",
12583
"addr", fmt.Sprintf("%v(%T)", address, address))
12684
}
12785

@@ -167,48 +125,30 @@ func (r AddressRewriter) buildFullAddress(ctx context.Context,
167125
return ret, nil
168126
}
169127

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
173130
// unchanged. If address is not a well-formed application address (all fields
174131
// set, non-nil, supported protocols), the function's behavior is undefined.
175132
// The returned path is the path contained in the reply; the path can be used
176133
// to talk to the remote AS after One-Hop Path construction.
177134
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) {
179136
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-
}
185137

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)
188139

189140
reply, err := r.Resolver.LookupSVC(ctx, p, s)
190141
if err != nil {
191142
logger.Debug("SVC resolution failed", "err", err)
192-
return nil, nil, false, err
143+
return nil, nil, err
193144
}
194145

195146
logger.Debug("SVC resolution successful", "reply", reply)
196147
u, err := parseReply(reply)
197148
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
207150
}
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
212152
}
213153

214154
// parseReply searches for a QUIC server on the remote address. If one is not

0 commit comments

Comments
 (0)