diff --git a/internal/ateomnet/dns/relay.go b/internal/ateomnet/dns/relay.go index 81e2854399..e7f421342e 100644 --- a/internal/ateomnet/dns/relay.go +++ b/internal/ateomnet/dns/relay.go @@ -20,10 +20,7 @@ import ( "log/slog" "net" "net/netip" - "strconv" "time" - - "github.com/agent-substrate/substrate/internal/ateomnet/netns" ) const ( @@ -99,43 +96,6 @@ func NewRelayForUpstreams(upstreams []string) (*Relay, error) { }, nil } -// Serve serves UDP and TCP DNS in the sandbox's local gateway namespace. -func (r *Relay) Serve(ctx context.Context, ns netns.Handle) (*Server, error) { - // Bind the wildcard because the microVM tap's gateway address is added later. - address := net.JoinHostPort("0.0.0.0", strconv.Itoa(dnsPort)) - - netC := netConn{ - dialer: *r.dialer, - } - - if err := netns.Do(ctx, ns, func(context.Context) error { - pc, err := net.ListenPacket("udp", address) - if err != nil { - return fmt.Errorf("while opening the actor DNS socket: %w", err) - } - netC.udp = pc - l, err := net.Listen("tcp", address) - if err != nil { - _ = pc.Close() - return fmt.Errorf("while opening the actor DNS listener: %w", err) - } - netC.tcpListener = l - return nil - }); err != nil { - return nil, err - } - - egressUDP, err := net.ListenPacket("udp", ":0") - if err != nil { - _ = netC.udp.Close() - _ = netC.tcpListener.Close() - return nil, fmt.Errorf("while opening the worker DNS egress socket: %w", err) - } - netC.egressUDP = egressUDP - - return r.serveOn(ctx, &netC) -} - // serveOn serves DNS on netC's sockets, which the caller has already bound, // and dials upstreams with netC's dialer. func (r *Relay) serveOn(ctx context.Context, netC *netConn) (*Server, error) { diff --git a/internal/ateomnet/dns/relay_linux.go b/internal/ateomnet/dns/relay_linux.go new file mode 100644 index 0000000000..53f0185b3f --- /dev/null +++ b/internal/ateomnet/dns/relay_linux.go @@ -0,0 +1,63 @@ +//go:build linux + +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package dns + +import ( + "context" + "fmt" + "net" + "strconv" + + "github.com/agent-substrate/substrate/internal/ateomnet/netns" +) + +// Serve serves UDP and TCP DNS in the sandbox's local gateway namespace. +func (r *Relay) Serve(ctx context.Context, ns netns.Handle) (*Server, error) { + // Bind the wildcard because the microVM tap's gateway address is added later. + address := net.JoinHostPort("0.0.0.0", strconv.Itoa(dnsPort)) + + netC := netConn{ + dialer: *r.dialer, + } + + if err := netns.Do(ctx, ns, func(context.Context) error { + pc, err := net.ListenPacket("udp", address) + if err != nil { + return fmt.Errorf("while opening the actor DNS socket: %w", err) + } + netC.udp = pc + l, err := net.Listen("tcp", address) + if err != nil { + _ = pc.Close() + return fmt.Errorf("while opening the actor DNS listener: %w", err) + } + netC.tcpListener = l + return nil + }); err != nil { + return nil, err + } + + egressUDP, err := net.ListenPacket("udp", ":0") + if err != nil { + _ = netC.udp.Close() + _ = netC.tcpListener.Close() + return nil, fmt.Errorf("while opening the worker DNS egress socket: %w", err) + } + netC.egressUDP = egressUDP + + return r.serveOn(ctx, &netC) +} diff --git a/pkg/objectstorage/env_test.go b/pkg/objectstorage/env_test.go index 5b9b9e7e4e..ee02d368cc 100644 --- a/pkg/objectstorage/env_test.go +++ b/pkg/objectstorage/env_test.go @@ -41,6 +41,8 @@ func TestNewFromEnv(t *testing.T) { missing := filepath.Join(t.TempDir(), "missing") t.Setenv("AWS_CONFIG_FILE", missing) t.Setenv("AWS_SHARED_CREDENTIALS_FILE", missing) + t.Setenv("AWS_PROFILE", "") + t.Setenv("AWS_DEFAULT_PROFILE", "") t.Setenv("AWS_REGION", "us-east-1") t.Setenv("ATE_STORAGE_BACKEND", tc.backend) t.Setenv("AWS_S3_USE_PATH_STYLE", tc.pathStyle)