2424//! `attach` is atomic from the caller's perspective: it establishes and binds
2525//! the boundary, returns `Bound`, or fails closed. It never binds a resource
2626//! already bound to an active boundary. Binary identity travels on every
27- //! [`PendingNetworkOpen `], resolved for that exact socket and process
27+ //! [`PendingTcpOpen `], resolved for that exact socket and process
2828//! generation; an unresolved identity denies the open.
2929//!
3030//! The contract is transport-neutral. Concrete topology implementations keep
@@ -352,17 +352,12 @@ pub trait IsolationBackend: Send + Sync {
352352/// code is running.
353353#[ async_trait]
354354pub trait BoundBoundary : Send {
355- /// The mediation service's backend-neutral source of workload connections.
355+ /// The mediation service's backend-neutral source of workload network
356+ /// requests. TCP and DNS remain typed operations so consumers cannot mix
357+ /// their framing, decisions, or response semantics.
356358 /// Retained by the supervisor before consuming `Bound`.
357359 fn network_mediation_source ( & self ) -> Arc < dyn NetworkMediationSource > ;
358360
359- /// Optional transport for workload DNS exchanges. Backends that expose
360- /// this source keep DNS inside the supervisor-owned policy path rather
361- /// than granting the workload access to a resolver socket.
362- fn dns_mediation_source ( & self ) -> Option < Arc < dyn DnsMediationSource > > {
363- None
364- }
365-
366361 /// Trusted host-side dial target for the well-known host-gateway aliases.
367362 ///
368363 /// Backends return this when the mediation service runs outside the
@@ -703,7 +698,7 @@ pub trait BoundaryLoopbackConnector: Send + Sync {
703698// ============================================================================
704699
705700/// Executable identity for one accepted connection, resolved by the backend and
706- /// delivered on [`PendingNetworkOpen `] before the mediation service evaluates
701+ /// delivered on [`PendingTcpOpen `] before the mediation service evaluates
707702/// policy.
708703///
709704/// A missing digest is `None`, never an empty value; policy that requires an
@@ -777,21 +772,36 @@ pub struct NetworkSocketMetadata {
777772
778773/// Typed supervisor decision for one pending TCP open.
779774#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
780- pub enum NetworkOpenResult {
775+ pub enum TcpOpenDecision {
781776 /// L4 authorization and a bounded relay handler are ready. L7 policy still
782777 /// applies to bytes after the local connection commits.
783778 RelayReady ,
784779 /// The socket remains unchanged and connect returns this positive errno.
785- Denied { errno : i32 } ,
780+ Denied ( TcpOpenDenial ) ,
781+ }
782+
783+ /// Placement-neutral reason why a staged TCP open was not committed.
784+ #[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
785+ pub enum TcpOpenDenial {
786+ /// The admitted network policy rejected the request.
787+ PolicyDenied ,
788+ /// The backend could not resolve authoritative executable identity.
789+ IdentityUnavailable ,
790+ /// The requested destination could not be validated.
791+ InvalidDestination ,
792+ /// A bounded mediation resource was exhausted.
793+ ResourceExhausted ,
794+ /// The mediation path became unavailable before commit.
795+ MediationUnavailable ,
786796}
787797
788798/// A staged workload TCP open delivered before its local relay is committed.
789799///
790800/// An `Err` identity must be denied and audited. The supervisor owns
791801/// `result`; dropping it cancels the open without changing the workload socket.
792- pub struct PendingNetworkOpen {
802+ pub struct PendingTcpOpen {
793803 /// Staged byte stream whose workload side is committed only after
794- /// [`NetworkOpenResult ::RelayReady`].
804+ /// [`TcpOpenDecision ::RelayReady`].
795805 pub stream : BoundaryDuplexStream ,
796806 /// Executable identity, resolved by the backend for this connection.
797807 pub binary_identity : Result < BinaryIdentity , ResolveError > ,
@@ -802,7 +812,7 @@ pub struct PendingNetworkOpen {
802812 /// Policy generation under which the request was created.
803813 pub policy_generation : u64 ,
804814 /// Single-use completion channel back to the sandbox broker.
805- pub result : oneshot:: Sender < NetworkOpenResult > ,
815+ pub decision : oneshot:: Sender < TcpOpenDecision > ,
806816}
807817
808818/// A logical per-boundary stream of workload connections, consumed by the
@@ -811,28 +821,33 @@ pub struct PendingNetworkOpen {
811821/// It may wrap a dedicated listener or a demultiplexed view over shared
812822/// transport; how it reaches a co-located proxy, a sidecar, or a shared
813823/// mediation service is backend-private. A trusted backend component associates
814- /// every returned connection with its active boundary without relying solely on
815- /// a transport tuple or workload-provided identifier. An `Err` from `accept`
816- /// means the source itself is unusable and fails the boundary closed.
824+ /// every returned request with its active boundary without relying solely on a
825+ /// transport tuple or workload-provided identifier. TCP and DNS use separate
826+ /// accepts so they can be consumed concurrently with independent backpressure.
827+ /// An `Err` means that mediation lane is unusable and fails closed.
817828#[ async_trait]
818829pub trait NetworkMediationSource : Send + Sync {
819830 /// Await the next staged workload TCP open.
820- async fn accept ( & self ) -> Result < PendingNetworkOpen , BackendError > ;
831+ async fn accept_tcp ( & self ) -> Result < PendingTcpOpen , BackendError > ;
832+
833+ /// Await the next workload DNS query.
834+ async fn accept_dns ( & self ) -> Result < PendingDnsQuery , BackendError > ;
821835}
822836
823837/// DNS transport used by one workload exchange.
824838#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
825839pub enum DnsTransport {
826840 /// One DNS wire datagram without a TCP length prefix.
827841 Udp ,
828- /// One two-byte-length-prefixed DNS message.
842+ /// One DNS message received over a TCP resolver connection .
829843 Tcp ,
830844}
831845
832846/// One workload DNS request and its fail-closed response channel.
833- pub struct MediatedDnsQuery {
834- /// DNS request bytes in the framing selected by [`Self::transport`].
835- pub request : Vec < u8 > ,
847+ pub struct PendingDnsQuery {
848+ /// Exactly one DNS wire message, without a DNS-over-TCP length prefix.
849+ /// The backend removes and restores transport framing.
850+ pub message : Vec < u8 > ,
836851 /// Workload DNS transport.
837852 pub transport : DnsTransport ,
838853 /// Identity of the process that issued the DNS request when the backend
@@ -844,11 +859,3 @@ pub struct MediatedDnsQuery {
844859 /// Single-use response channel owned by the backend adapter.
845860 pub response : oneshot:: Sender < Result < Vec < u8 > , BackendError > > ,
846861}
847-
848- /// Logical per-boundary stream of DNS exchanges. The backend handles syscall,
849- /// packet, or guest-agent transport details; the supervisor owns policy DNS.
850- #[ async_trait]
851- pub trait DnsMediationSource : Send + Sync {
852- /// Await the next DNS query from this boundary.
853- async fn accept ( & self ) -> Result < MediatedDnsQuery , BackendError > ;
854- }
0 commit comments