Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions docs/designs/edge-public-listener.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Galactic Edge public listener

Status: proposed, with its open decisions settled. The Phase 0 lab proof is done (see [Phase 0 results](#phase-0-results)), and Phase 1, the API, is implemented: `EdgeListener`, the `PublicListener` capability and `NetworkService.spec.edgeListenerRef` exist, but nothing serves a listener yet. It extends the [Galactic Edge Foundation](galactic-edge.md) and reuses the [XDP/DSR gateway](../gateway/architecture.md). The [provider contract](../edge/provider-contract.md) remains the reference for behavior that exists today.
Status: proposed, with its open decisions settled. The Phase 0 lab proof is done (see [Phase 0 results](#phase-0-results)), and Phase 1, the API, is implemented: `EdgeListener`, the `PublicListener` capability and `NetworkService.spec.edgeListenerRef` exist, but nothing serves a listener yet. Phase 3's unmatched-egress drop is implemented. It extends the [Galactic Edge Foundation](galactic-edge.md) and reuses the [XDP/DSR gateway](../gateway/architecture.md). The [provider contract](../edge/provider-contract.md) remains the reference for behavior that exists today.

This design follows the [Datum enhancement template](https://github.com/datum-cloud/enhancements/blob/main/enhancements/template/README.md).

Expand Down Expand Up @@ -212,14 +212,18 @@ Every listener service also carries a gateway health check, as a second signal b

Listener attachments use the `PublicService` traffic policy path in both directions, like tenant VIP backends. The ingress VRF has no default route. A packet from a listener attachment that does not match a VIP translation row is dropped and counted under a new reason, `ListenerUnmatchedEgress`.

The node agent marks a listener attachment's host link in `edge_listener_link_table` when the attachment's `EdgeService` grants `PublicListener`, or cannot be found, and clears the mark when the grant goes or the link is removed. A marked link's packet leaves only as a VIP reply through the node's public uplink, or as link-scope traffic such as the link's own Neighbor Discovery. `usid_egress` drops everything else, including Neighbor Discovery to a global address, multicast beyond link scope, a VIP reply on a node whose uplink is not configured, and any packet from a marked link whose datapath rows are missing, and counts it as `galactic_usid_drops_total{reason="listener_unmatched_egress"}`. The drop does not depend on the ingress VRF's routes. A datapath that predates the map leaves a listener attachment unprogrammed rather than unconfined, so the uSID datapath rolls out before `galactic-edge`.

ICMPv6 errors a listener sends about a VIP flow, such as Packet Too Big, match no translation row and are dropped for now. Translating them so they leave from the VIP is [#1519](https://github.com/datum-cloud/galactic/issues/1519).

### Implementation phases

| Phase | Work | Gate |
| --- | --- | --- |
| 0 | On the containerlab gvpc lab, hand-wire a `SocketAccess` attachment as a DSR backend: `/128` advertisement and binding, relying on the existing host link registration. Confirm the VIP reply translation on the edge host link, and qualify local and remote delivery. | Bidirectional UDP and TCP to a pod VRF socket through a gateway VIP, for both families, when the backend is not on the receiving gateway's node; local delivery's outcome recorded. Done, see [Phase 0 results](#phase-0-results). |
| 1 | API: capability enums, `EdgeListener`, `NetworkService.spec.edgeListenerRef` and its rule against `backendSelector` | API review and CRD validation tests |
| 2 | Core: ingress gVPC, listener admission and status, `/128` publication, `NetworkService` writer | envtest coverage of every status reason |
| 3 | Node agent and datapath: unmatched-egress drop. Phase 0 found no gap in VIP reply translation on edge host links. | Lab packet tests, including negative egress |
| 3 | Node agent and datapath: unmatched-egress drop. Phase 0 found no gap in VIP reply translation on edge host links. | Lab packet tests, including negative egress. Done in [#1510](https://github.com/datum-cloud/galactic/issues/1510). |
| 4 | Gateway: backend resolution from listener backends, eligibility, local-delivery exclusion | Lab failover: drain, lease expiry, API outage, gateway loss |
| 5 | MASQUE: listener attachment, sockets bound to the pod VRF, public `--authority`. Remove the Service overlay in deployment. | An independent client passes HTTP/3 and HTTP/2 through the VIP, IPv6 and IPv4 |

Expand Down Expand Up @@ -264,7 +268,7 @@ Roll out to the staging labs first, with the existing overlay left in place on a
- `EdgeListener` conditions `Accepted` and `Programmed`, and per-backend `serving`.
- The gateway's existing per-rule packet, drop and advertisement metrics, labelled with the listener name.
- `galactic_edge_foundation_failures_total` for listener attachment failures.
- A counter for `ListenerUnmatchedEgress`.
- `galactic_usid_drops_total{reason="listener_unmatched_egress"}` for `ListenerUnmatchedEgress`.

### Dependencies

Expand All @@ -288,6 +292,7 @@ Each listener has up to 16 ports and two addresses, and each port is one `Networ
- 2026-11-27: proposed, after a staging test reached MASQUE only through a hand-made `NodePort`.
- 2026-11-28: open decisions settled in [#1506](https://github.com/datum-cloud/galactic/issues/1506), and listener addresses scoped to one cell.
- 2026-11-28: Phase 0 proved remote delivery and the reply path, and showed local delivery failing ([#1507](https://github.com/datum-cloud/galactic/issues/1507)).
- 2026-11-28: Phase 3 added the unmatched-egress drop on listener host links ([#1510](https://github.com/datum-cloud/galactic/issues/1510)).

## Drawbacks

Expand Down
2 changes: 2 additions & 0 deletions docs/edge/provider-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ Core sets `Published` on each `EdgeRoute` from its router's report on the route'
An attachment's host link is a traffic policy subject like a workload's interface (see [Traffic policy on the node](../traffic-policy/node.md#edge-attachments)). The `EdgeService` selects its policy: `spec.trafficPolicy.ingressPolicyRef` for traffic delivered to the provider from the gVPC, and `egressPolicyRef` for traffic the provider sends into it. Each names a `TrafficPolicy` in the service's namespace. A provider controls neither: it cannot write the service, and a policy in its own namespace is never read.

- `galactic-edge` writes the link's policy row, with the attachment's address, and attaches `usid_egress` and `tp_deliver` while the link is still down. On a node that enforces policy but failed the kernel preflight, it reports `DatapathFailed` and leaves the link down.
- When the attachment's `EdgeService` grants `PublicListener`, or cannot be found, `galactic-edge` marks the link as a listener's. `usid_egress` then sends only the link's replies that match a VIP translation row, out the node's public uplink, and drops everything else as `listener_unmatched_egress`. A datapath that predates the mark fails the link with `DatapathFailed`, so roll out the uSID datapath before `galactic-edge`.
- `galactic-router` publishes one snapshot per direction. Until it has, the link denies everything. It publishes nothing, and unbinds what it published, while the attachment is not `Admitted` or its service is gone, being deleted, replaced or granting another provider.
- An omitted reference selects the built-in `default-deny-all`. A reference to a missing policy denies everything as `policy_unavailable`. Neighbor discovery on the link is a link operation outside the rules, so it works under any policy.
- `galactic-router` republishes when the service's references or a referenced policy change, so the change applies to active attachments. A change to the service re-admits its attachments under the new generation without draining them.
Expand Down Expand Up @@ -369,6 +370,7 @@ Foundation-owned host state is what `galactic-edge` creates for an attachment, p
| uSID registration of the host link (`ifindex_vrf_table`, `ifindex_egress_kind_table`) | Host link ifindex | None. |
| Traffic policy interface rows (`tp_iface_table`, `tp_iface_addr_table`) for the host link | Host link ifindex | None. `galactic-router`'s traffic-policy reconciler binds snapshots to the link in `tp_binding_table`, as for a workload. |
| Forwarding gate rows (`edge_link_table`, `edge_gate_table`) | Host link ifindex, and prefix | None. The link row is written before `usid_egress` and `tp_deliver` are attached to the link, and removed after its gates. |
| Listener mark (`edge_listener_link_table`) for a host link whose `EdgeService` grants `PublicListener` | Host link ifindex | None. Written with the link row on every pass and removed before it; the agent's sweep removes a mark left with no link row. |
| Local pass-through entries in `egress_route_table`: each edge link's address, and each prefix of a route its attachment holds | gVPC table and prefix | None. Each entry names its owner, `egressroutemap.PassThroughEdge`, in its value, and `galactic-edge` removes only entries with that owner. `galactic-router`'s withdrawals leave them. |
| Ownership records | Scope (gVPC on the node) | Every fenced writer, through `ownership.Authority`. |

Expand Down
1 change: 1 addition & 0 deletions docs/observability/vpc-dataplane.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ has no name for.
| Egress | `egress_route_encap_failed`, `egress_route_fib_lookup_failed`, `egress_route_redirect_failed`, `public_uplink_redirect_failed` | Tenant traffic leaving the node couldn't be encapsulated or sent |
| Service routes | `service_route_denied`, `service_route_redirect_failed` | A private service route refused the sender, or its redirect to the target failed |
| IPv4 VIP | `vip_xlat_failed`, `vip_ipv4_fragment`, `vip_udp_no_checksum`, `vip_ipv4_backend`, `vip_ttl_exceeded` | An IPv4 VIP packet was untranslatable; `vip_ipv4_backend` means a pre-translation router |
| Edge listener | `listener_unmatched_egress` | An Edge public listener sent traffic other than a VIP reply |

```promql
sum by (node, reason) (rate(galactic_usid_drops_total[5m])) > 0
Expand Down
52 changes: 47 additions & 5 deletions internal/edge/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,13 @@ type Datapath interface {
// addr: it carries nothing else until a gate opens for it, and nothing
// its traffic policy does not allow. The link is gated before any
// program that forwards its traffic is attached. It is called while a
// new link is still down.
Register(vrfTable, ifindex uint32, ifname string, addr netip.Addr) error
// new link is still down. A listener link, an Edge public listener
// attachment's, sends only replies that match a VIP translation row; any
// other link has its listener mark cleared.
Register(vrfTable, ifindex uint32, ifname string, addr netip.Addr, listener bool) error
// Unregister closes ifindex's gates and removes every row Register
// wrote for it except the gate's link row, so the link carries nothing
// beyond its own address until it is gone.
// wrote for it except the gate's link row and listener mark, so the
// link carries nothing beyond its own address until it is gone.
Unregister(ifindex uint32) error
// Forget removes ifindex's gate link row, once the link is deleted.
Forget(ifindex uint32) error
Expand Down Expand Up @@ -153,6 +155,10 @@ type Agent struct {
// held is, for the pass under way, each attachment's prefixes from
// routes still accepted on this node, by attachment UID.
held map[string][]netip.Prefix
// listenerServices is, for the pass under way, whether each EdgeService,
// by UID, grants PublicListener. An attachment against one that does is
// a listener attachment.
listenerServices map[string]bool
// local is, by VPC, each attachment's prefixes beyond its own address
// that the last sync of the VPC's local routes kept, by attachment UID.
local map[string]map[string]map[netip.Prefix]bool
Expand Down Expand Up @@ -186,6 +192,11 @@ func (a *Agent) Reconcile(ctx context.Context) error {
return err
}
a.held = held
listenerServices, err := a.listenerServiceUIDs(ctx)
if err != nil {
return err
}
a.listenerServices = listenerServices
active := map[string][]*galacticv1alpha1.EdgeAttachment{}
releasing := map[string][]*galacticv1alpha1.EdgeAttachment{}
pods := map[string]podNS{}
Expand Down Expand Up @@ -488,6 +499,36 @@ func (a *Agent) heldPrefixes(ctx context.Context) (map[string][]netip.Prefix, er
return held, nil
}

// capabilityPublicListener is the EdgeService capability that makes its
// attachments an Edge public listener's.
const capabilityPublicListener = "PublicListener"

// listenerServiceUIDs returns, by UID, whether each EdgeService grants
// PublicListener. A listener attachment's host link sends only replies that
// match a VIP translation row, so a failure to list fails the pass rather
// than programming a listener as an ordinary attachment.
func (a *Agent) listenerServiceUIDs(ctx context.Context) (map[string]bool, error) {
var services galacticv1alpha1.EdgeServiceList
if err := a.Client.List(ctx, &services); err != nil {
return nil, fmt.Errorf("list EdgeServices: %w", err)
}
uids := map[string]bool{}
for i := range services.Items {
uids[string(services.Items[i].UID)] = slices.Contains(services.Items[i].Spec.Capabilities,
capabilityPublicListener)
}
return uids, nil
}

// listener reports whether att's host link is a listener's. An attachment
// whose EdgeService is not found, deleted or not yet in the cache, is treated
// as one: confining a link for a pass is safe, and unconfining a listener is
// not.
func (a *Agent) listener(att *galacticv1alpha1.EdgeAttachment) bool {
granted, known := a.listenerServices[att.Spec.ServiceRef.UID]
return granted || !known
}

// holds reports whether rt is accepted on node and its holder has not
// released it at the accepted epoch. A revoked route still holds: its
// accepted holder stays until another is accepted or the route is deleted.
Expand Down Expand Up @@ -665,7 +706,8 @@ func (a *Agent) program(att *galacticv1alpha1.EdgeAttachment, ns podNS, link hos
datapathErr = a.Datapath.Unregister(uint32(res.HostIndex))
}
if datapathErr == nil {
datapathErr = a.Datapath.Register(res.HostTable, uint32(res.HostIndex), spec.HostLink, spec.Address)
datapathErr = a.Datapath.Register(res.HostTable, uint32(res.HostIndex), spec.HostLink, spec.Address,
a.listener(att))
}
return datapathErr
}
Expand Down
68 changes: 68 additions & 0 deletions internal/edge/agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"github.com/vishvananda/netlink"
"github.com/vishvananda/netns"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"

galacticv1alpha1 "go.datum.net/galactic/api/v1alpha1"
"go.datum.net/galactic/internal/edge/diag"
Expand Down Expand Up @@ -139,6 +141,72 @@ func TestAttachDetach(t *testing.T) {
f.expectLocal(vpcB, addr+"/128")
}

// TestListenerLinks: an attachment against an EdgeService that grants
// PublicListener registers its host link as a listener's, one against a
// service that does not as not, and one whose service is not found as a
// listener's, failing closed. The mark follows the service's grant from one
// pass to the next.
func TestListenerLinks(t *testing.T) {
const socketAccess = "SocketAccess"
f := newFixture(t)
ctx := context.Background()
service := func(name, uid string, caps ...string) *galacticv1alpha1.EdgeService {
s := &galacticv1alpha1.EdgeService{
ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: edgeNS, UID: types.UID(uid)},
Spec: galacticv1alpha1.EdgeServiceSpec{Capabilities: caps},
}
if err := f.client.Create(ctx, s); err != nil {
t.Fatal(err)
}
return s
}
refer := func(name string, s galacticv1alpha1.EdgeServiceReference) {
att := f.get(name)
att.Spec.ServiceRef = s
if err := f.client.Update(ctx, att); err != nil {
t.Fatal(err)
}
}
svc := service("listener", "33333333-0000-0000-0000-000000000001", socketAccess, capabilityPublicListener)
plain := service("plain", "33333333-0000-0000-0000-000000000002", socketAccess)
a := f.agent()
f.pod(pod1UID)
f.pod(pod2UID)
f.attach("a", attA, pod1UID, vpcA, addr, false)
f.attach("b", attB, pod1UID, vpcB, addr, false)
f.attach("p", attP, pod2UID, vpcA, "fd00:aa::2", false)
refer("a", galacticv1alpha1.EdgeServiceReference{Namespace: edgeNS, Name: svc.Name, UID: string(svc.UID)})
refer("b", galacticv1alpha1.EdgeServiceReference{Namespace: edgeNS, Name: plain.Name, UID: string(plain.UID)})
refer("p", galacticv1alpha1.EdgeServiceReference{Namespace: edgeNS, Name: "gone",
UID: "33333333-0000-0000-0000-000000000009"})
f.reconcile(a)
for _, n := range []string{"a", "b", "p"} {
f.programmed(n)
}
linkA, linkB := uint32(f.hostLink("a").Attrs().Index), uint32(f.hostLink("b").Attrs().Index)
if !f.dp.listener(linkA) {
t.Error("a's host link is not registered as a listener's")
}
if f.dp.listener(linkB) {
t.Error("b's host link is registered as a listener's")
}
if !f.dp.listener(uint32(f.hostLink("p").Attrs().Index)) {
t.Error("p's host link, whose service is not found, is not registered as a listener's")
}

if err := f.client.Get(ctx, client.ObjectKeyFromObject(svc), svc); err != nil {
t.Fatal(err)
}
svc.Spec.Capabilities = []string{socketAccess}
if err := f.client.Update(ctx, svc); err != nil {
t.Fatal(err)
}
f.reconcile(a)
if f.dp.listener(linkA) {
t.Error("a's host link is still a listener's after its service stopped granting PublicListener")
}
}

// TestNewLinkClearsStaleRows: a link the agent creates is registered with no
// rows left on its ifindex by a link a pod's deletion took with it, whatever
// number the kernel gives it, while a link it finds already registered, as
Expand Down
20 changes: 18 additions & 2 deletions internal/edge/agent/fixture_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ func (r *resolver) set(podUID, path string) {
// gated in gates as the pinned datapath does.
type datapath struct {
sync.Mutex
rows map[uint32]uint32
rows map[uint32]uint32
// listeners is the listener flag of each link's last Register.
listeners map[uint32]bool
unregistered []uint32
// failUnregister fails the next Unregister calls.
failUnregister int
Expand All @@ -166,7 +168,7 @@ type datapath struct {
routes map[uint32][]netip.Prefix
}

func (d *datapath) Register(vrfTable, ifindex uint32, _ string, addr netip.Addr) error {
func (d *datapath) Register(vrfTable, ifindex uint32, _ string, addr netip.Addr, listener bool) error {
d.Lock()
defer d.Unlock()
if d.onRegister != nil {
Expand All @@ -176,10 +178,21 @@ func (d *datapath) Register(vrfTable, ifindex uint32, _ string, addr netip.Addr)
return d.failRegister
}
d.rows[ifindex] = vrfTable
if d.listeners == nil {
d.listeners = map[uint32]bool{}
}
d.listeners[ifindex] = listener
d.gates.setLink(ifindex, addr)
return nil
}

// listener reports the listener flag of ifindex's last Register.
func (d *datapath) listener(ifindex uint32) bool {
d.Lock()
defer d.Unlock()
return d.listeners[ifindex]
}

func (d *datapath) Unregister(ifindex uint32) error {
d.Lock()
defer d.Unlock()
Expand Down Expand Up @@ -269,6 +282,9 @@ func (g *gates) DeleteLink(ifindex uint32) error {
return nil
}

// PruneListeners implements GateTable: the fake keeps no listener marks.
func (g *gates) PruneListeners() error { return nil }

func (g *gates) deleteLink(ifindex uint32) {
g.Lock()
defer g.Unlock()
Expand Down
Loading
Loading