From 03ba176cdd5021191d62c8f1e9e31b35999a9479 Mon Sep 17 00:00:00 2001 From: Dominik Roos Date: Fri, 1 Sep 2023 21:18:56 +0200 Subject: [PATCH] prototype: drop SVC resolution TODO: add more context --- control/beaconing/grpc/creation_server.go | 10 ++---- control/onehop/addr.go | 5 +-- pkg/grpc/BUILD.bazel | 1 - pkg/grpc/dialer.go | 5 --- pkg/snet/squic/net.go | 3 ++ private/app/appnet/addr.go | 37 +---------------------- private/app/appnet/infraenv.go | 4 +-- 7 files changed, 12 insertions(+), 53 deletions(-) diff --git a/control/beaconing/grpc/creation_server.go b/control/beaconing/grpc/creation_server.go index 2dc3df7e28..30a68bb8d7 100644 --- a/control/beaconing/grpc/creation_server.go +++ b/control/beaconing/grpc/creation_server.go @@ -85,13 +85,9 @@ func extractIngressIfID(path snet.DataplanePath) (uint16, error) { if !ok { return 0, serrors.New("unexpected path", "type", common.TypeOf(path)) } - rawScionPath, ok := invertedPath.Path.(*scion.Raw) + rawScionPath, ok := invertedPath.Path.(*scion.Decoded) if !ok { - return 0, serrors.New("unexpected path", "type", common.TypeOf(path)) - } - hf, err := rawScionPath.GetCurrentHopField() - if err != nil { - return 0, serrors.WrapStr("getting current hop field", err) + return 0, serrors.New("unexpected path", "type", common.TypeOf(invertedPath.Path)) } - return hf.ConsIngress, nil + return rawScionPath.HopFields[0].ConsIngress, nil } diff --git a/control/onehop/addr.go b/control/onehop/addr.go index 6202443da5..ccca6715ee 100644 --- a/control/onehop/addr.go +++ b/control/onehop/addr.go @@ -64,7 +64,8 @@ func (r *AddressRewriter) RedirectToQUIC( ) (net.Addr, bool, error) { a, ok := address.(*Addr) if !ok { - return r.Rewriter.RedirectToQUIC(ctx, address) + return address, false, nil + //return r.Rewriter.RedirectToQUIC(ctx, address) } path, err := r.getPath(a.Egress) if err != nil { @@ -76,7 +77,7 @@ func (r *AddressRewriter) RedirectToQUIC( SVC: addr.SvcCS, NextHop: a.NextHop, } - return r.Rewriter.RedirectToQUIC(ctx, svc) + return svc, false, nil } func (r *AddressRewriter) getPath(egress uint16) (path.OneHop, error) { diff --git a/pkg/grpc/BUILD.bazel b/pkg/grpc/BUILD.bazel index e82853d5ff..156083e771 100644 --- a/pkg/grpc/BUILD.bazel +++ b/pkg/grpc/BUILD.bazel @@ -12,7 +12,6 @@ go_library( deps = [ "//pkg/addr:go_default_library", "//pkg/log:go_default_library", - "//pkg/private/common:go_default_library", "//pkg/private/serrors:go_default_library", "//pkg/snet:go_default_library", "@com_github_grpc_ecosystem_go_grpc_middleware//retry:go_default_library", diff --git a/pkg/grpc/dialer.go b/pkg/grpc/dialer.go index 03edee33ad..f8824a2aa1 100644 --- a/pkg/grpc/dialer.go +++ b/pkg/grpc/dialer.go @@ -25,7 +25,6 @@ import ( "google.golang.org/grpc/resolver/manual" "github.com/scionproto/scion/pkg/addr" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/serrors" "github.com/scionproto/scion/pkg/snet" ) @@ -147,10 +146,6 @@ func (d *QUICDialer) Dial(ctx context.Context, addr net.Addr) (*grpc.ClientConn, if err != nil { return nil, serrors.WrapStr("resolving SVC address", err) } - if _, ok := addr.(*snet.UDPAddr); !ok { - return nil, serrors.New("wrong address type after svc resolution", - "type", common.TypeOf(addr)) - } dialer := func(context.Context, string) (net.Conn, error) { return d.Dialer.Dial(ctx, addr) } diff --git a/pkg/snet/squic/net.go b/pkg/snet/squic/net.go index dc0d5f01c5..19b0033701 100644 --- a/pkg/snet/squic/net.go +++ b/pkg/snet/squic/net.go @@ -416,6 +416,9 @@ func computeAddressStr(address net.Addr) string { if v, ok := address.(*snet.UDPAddr); ok { return fmt.Sprintf("[%s,%s]:%d", v.IA, v.Host.IP, v.Host.Port) } + if v, ok := address.(*snet.SVCAddr); ok { + return fmt.Sprintf("[%s,%s]:0", v.IA, v.SVC) + } return address.String() } diff --git a/private/app/appnet/addr.go b/private/app/appnet/addr.go index 2d5514c40b..6a82ff9426 100644 --- a/private/app/appnet/addr.go +++ b/private/app/appnet/addr.go @@ -16,7 +16,6 @@ package appnet import ( "context" - "errors" "fmt" "net" "time" @@ -72,7 +71,6 @@ type AddressRewriter struct { // If the address is already unicast, no redirection to QUIC is attempted. func (r AddressRewriter) RedirectToQUIC(ctx context.Context, address net.Addr) (net.Addr, bool, error) { - logger := log.FromCtx(ctx) // FIXME(scrye): This is not legitimate use. It's only included for // compatibility with older unit tests. See @@ -85,40 +83,7 @@ func (r AddressRewriter) RedirectToQUIC(ctx context.Context, case *snet.UDPAddr: return a, false, nil case *snet.SVCAddr: - fa, err := r.buildFullAddress(ctx, a) - if err != nil { - return nil, false, err - } - if r.SVCResolutionFraction <= 0.0 { - return fa, false, nil - } - - path, err := fa.GetPath() - if err != nil { - return nil, false, serrors.WrapStr("bad path", err) - } - - // During One-Hop Path operation, use SVC resolution to also bootstrap the path. - p, u, quicRedirect, err := r.resolveSVC(ctx, path, fa.SVC) - if err != nil { - // For a revoked path we don't fallback we want to give the option - // to retry with a new path. - isRevokedPath := func(err error) bool { - var opErr *snet.OpError - return errors.As(err, &opErr) && opErr.RevInfo() != nil - } - if r.SVCResolutionFraction < 1.0 && !isRevokedPath(err) { - // SVC resolution failed but we allow legacy behavior and have some - // fraction of the timeout left for data transfers, so return - // address with SVC destination still set - logger.Debug("Falling back to legacy mode, ignore error", "err", err) - return fa, false, nil - } - return a, false, err - } - - ret := &snet.UDPAddr{IA: fa.IA, Path: p.Dataplane(), NextHop: fa.NextHop, Host: u} - return ret, quicRedirect, err + return a, false, nil } return nil, false, serrors.New("address type not supported", diff --git a/private/app/appnet/infraenv.go b/private/app/appnet/infraenv.go index c9fdd7646c..47e1da22f4 100644 --- a/private/app/appnet/infraenv.go +++ b/private/app/appnet/infraenv.go @@ -274,7 +274,7 @@ func (nc *NetworkConfig) initSvcRedirect(quicAddress string) (func(), error) { // address nor the port are needed to address the resolver, but the dispatcher still // requires them and checks unicity. At least a dynamic port is allowed. srAddr := &net.UDPAddr{IP: nc.Public.IP, Port: 0} - conn, err := network.Listen(context.Background(), "udp", srAddr, addr.SvcWildcard) + conn, err := network.Listen(context.Background(), "udp", srAddr, addr.SvcNone) if err != nil { log.Info("Listen failed", "err", err) return nil, serrors.WrapStr("listening on SCION", err, "addr", srAddr) @@ -328,7 +328,7 @@ func (nc *NetworkConfig) initQUICSockets() (net.PacketConn, net.PacketConn, erro if err != nil { return nil, nil, serrors.WrapStr("parsing server QUIC address", err) } - server, err := serverNet.Listen(context.Background(), "udp", serverAddr, addr.SvcNone) + server, err := serverNet.Listen(context.Background(), "udp", serverAddr, addr.SvcWildcard) if err != nil { return nil, nil, serrors.WrapStr("creating server connection", err) }