From d7644c81e32c88638d6c2290e1312bd0b4b06749 Mon Sep 17 00:00:00 2001 From: a-thieme <79036111+a-thieme@users.noreply.github.com> Date: Sat, 24 Oct 2026 01:30:33 -0500 Subject: [PATCH 01/52] Modify root prefix strategy in nfd-init.sh.j2 Updated the default strategy for root prefix to include version=5 and retransmission suppression max=1s. --- templates/nfd/nfd-init.sh.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/nfd/nfd-init.sh.j2 b/templates/nfd/nfd-init.sh.j2 index 66fcd23..3168500 100755 --- a/templates/nfd/nfd-init.sh.j2 +++ b/templates/nfd/nfd-init.sh.j2 @@ -13,7 +13,7 @@ nfdc strategy set / /localhost/nfd/strategy/asf/%FD%04/max-timeou nfdc strategy set /ndn/web /localhost/nfd/strategy/asf/%FD%04/max-timeouts~5 nfdc strategy set /ndn/web/stats /localhost/nfd/strategy/best-route {% else %} -nfdc strategy set / /localhost/nfd/strategy/best-route +nfdc strategy set / /localhost/nfd/strategy/best-route/v=5/retx-suppression-max~1000 {% endif %} # Set multicast strategy From c65654eb94d0abdd0d4fca85ca2ba75bea7b6fee Mon Sep 17 00:00:00 2001 From: a-thieme <79036111+a-thieme@users.noreply.github.com> Date: Sat, 24 Oct 2026 01:55:53 -0500 Subject: [PATCH 02/52] Modify multicast strategy settings in nfd-init.sh.j2 Updated multicast strategy to include version and retx suppression. Fixes previous commit that changed the unicast interest limits instead of multicast. --- templates/nfd/nfd-init.sh.j2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/nfd/nfd-init.sh.j2 b/templates/nfd/nfd-init.sh.j2 index 3168500..4393036 100755 --- a/templates/nfd/nfd-init.sh.j2 +++ b/templates/nfd/nfd-init.sh.j2 @@ -13,11 +13,11 @@ nfdc strategy set / /localhost/nfd/strategy/asf/%FD%04/max-timeou nfdc strategy set /ndn/web /localhost/nfd/strategy/asf/%FD%04/max-timeouts~5 nfdc strategy set /ndn/web/stats /localhost/nfd/strategy/best-route {% else %} -nfdc strategy set / /localhost/nfd/strategy/best-route/v=5/retx-suppression-max~1000 +nfdc strategy set / /localhost/nfd/strategy/best-route {% endif %} # Set multicast strategy -nfdc strategy set /ndn/multicast /localhost/nfd/strategy/multicast +nfdc strategy set /ndn/multicast /localhost/nfd/strategy/multicast/v=5/retx-suppression-max~1000 nfdc strategy set /ndn/broadcast /localhost/nfd/strategy/multicast nfdc strategy set /localhost /localhost/nfd/strategy/multicast From 9b64afa54a3ad4fa9e86f5cd47303a563bda4e2a Mon Sep 17 00:00:00 2001 From: Adam Thieme Date: Sat, 24 Oct 2026 00:50:03 -0700 Subject: [PATCH 03/52] update operator emails and names --- host_vars/ARIZONA | 4 ++-- host_vars/AVEIRO | 4 ++-- host_vars/BERN | 4 ++-- host_vars/DELFT | 4 ++-- host_vars/FRANKFURT | 4 ++-- host_vars/HK | 2 +- host_vars/MEMPHIS | 4 ++-- host_vars/NEU | 4 ++-- host_vars/QUB | 4 ++-- host_vars/SINGAPORE | 4 ++-- host_vars/UCLA | 4 ++-- host_vars/UFBA | 4 ++-- host_vars/WU | 4 ++-- 13 files changed, 25 insertions(+), 25 deletions(-) diff --git a/host_vars/ARIZONA b/host_vars/ARIZONA index 3cdf5eb..286f04c 100644 --- a/host_vars/ARIZONA +++ b/host_vars/ARIZONA @@ -1,8 +1,8 @@ site: /edu/arizona site_name: The University of Arizona -operator_name: Teng Liang +operator_name: Beichuan Zhang operator_email: philoliang2011@gmail.com -ansible_host: hobo.cs.arizona.edu +ansible_host: bzhang@cs.arizona.edu host_ip: 128.196.203.36 local_ip: 128.196.203.36 site_email_domain: diff --git a/host_vars/AVEIRO b/host_vars/AVEIRO index 8309148..3bfca8c 100644 --- a/host_vars/AVEIRO +++ b/host_vars/AVEIRO @@ -1,7 +1,7 @@ site: /pt/it/av site_name: University of Aveiro, Portugal -operator_name: Jose Quevedo -operator_email: quevedo@av.it.pt +operator_name: Rui Miguel Morais Silva +operator_email: ruimiguelsilva@av.it.pt ansible_host: selficn.av.it.pt host_ip: 193.136.92.155 local_ip: 10.0.12.127 diff --git a/host_vars/BERN b/host_vars/BERN index efc68ae..7b48801 100644 --- a/host_vars/BERN +++ b/host_vars/BERN @@ -1,7 +1,7 @@ site: /ch/unibe site_name: University of Bern, Switzerland -operator_name: Jonnahtan Saltarin -operator_email: saltarin@inf.unibe.ch +operator_name: hexu xing +operator_email: hexu.xing@unibe.ch ansible_host: os-float159.cnds.unibe.ch host_ip: 130.92.70.159 local_ip: 192.168.111.10 diff --git a/host_vars/DELFT b/host_vars/DELFT index fbf18ee..02a52cf 100644 --- a/host_vars/DELFT +++ b/host_vars/DELFT @@ -1,7 +1,7 @@ site: /nl/delft site_name: Delft University of Technology, Netherlands -operator_name: Chhagan Lal -operator_email: c.lal@tudelft.nl +operator_name: Ruud de Jong +operator_email: R.deJong@tudelft.nl ansible_host: ndn-testbed.ewi.tudelft.nl host_ip: 131.180.178.63 local_ip: 131.180.178.63 diff --git a/host_vars/FRANKFURT b/host_vars/FRANKFURT index 6d830cc..b367e10 100644 --- a/host_vars/FRANKFURT +++ b/host_vars/FRANKFURT @@ -1,7 +1,7 @@ site: /pcl/frankfurt site_name: PCL Frankfurt -operator_name: Teng Liang -operator_email: redact@pcl.ac.cn +operator_name: Jian Yang +operator_email: yangj02@pcl.ac.cn ansible_host: frankfurt.testbed.named-data.net host_ip: 49.51.163.56 local_ip: 49.51.163.56 diff --git a/host_vars/HK b/host_vars/HK index 9978445..e71458b 100644 --- a/host_vars/HK +++ b/host_vars/HK @@ -1,7 +1,7 @@ site: /pcl/hk site_name: Hong Kong operator_name: Jian Yang -operator_email: yangj@stu.hit.edu.cn +operator_email: yangj02@pcl.ac.cn ansible_host: hk.testbed.named-data.net host_ip: 47.238.59.170 local_ip: 47.238.59.170 diff --git a/host_vars/MEMPHIS b/host_vars/MEMPHIS index 1df85c0..0e4e254 100644 --- a/host_vars/MEMPHIS +++ b/host_vars/MEMPHIS @@ -1,7 +1,7 @@ site: /edu/memphis site_name: The University of Memphis -operator_name: Saurab Dulal -operator_email: sdulal@memphis.edu +operator_name: Mark Roberts +operator_email: mgrbrts1@memphis.edu ansible_host: titan.cs.memphis.edu host_ip: 141.225.11.173 local_ip: 141.225.11.173 diff --git a/host_vars/NEU b/host_vars/NEU index 9a69868..93d0803 100644 --- a/host_vars/NEU +++ b/host_vars/NEU @@ -1,7 +1,7 @@ site: /edu/neu site_name: Northeastern University -operator_name: Ran Liu -operator_email: liuranapply@gmail.com +operator_name: Edmund Yeh (PI) +operator_email: eyeh@ece.neu.edu ansible_host: neu.testbed.named-data.net host_ip: 155.33.178.42 local_ip: 155.33.178.42 diff --git a/host_vars/QUB b/host_vars/QUB index 63085b5..8f9c366 100644 --- a/host_vars/QUB +++ b/host_vars/QUB @@ -1,7 +1,7 @@ site: /uk/ac/qub site_name: Queen's University Belfast, UK -operator_name: Paul McAllister -operator_email: P.McAllister@qub.ac.uk +operator_name: James Grant +operator_email: J.Grant@qub.ac.uk ansible_host: ndn.qub.ac.uk host_ip: 51.148.47.242 local_ip: 10.60.60.2 diff --git a/host_vars/SINGAPORE b/host_vars/SINGAPORE index 53d4598..18cd1db 100644 --- a/host_vars/SINGAPORE +++ b/host_vars/SINGAPORE @@ -1,7 +1,7 @@ site: /pcl/singapore site_name: PCL Singapore -operator_name: Teng Liang -operator_email: redact@pcl.ac.cn +operator_name: Jian Yang +operator_email: yangj02@pcl.ac.cn ansible_host: singapore.testbed.named-data.net host_ip: 43.134.56.106 local_ip: 43.134.56.106 diff --git a/host_vars/UCLA b/host_vars/UCLA index ae7d657..cccbe67 100644 --- a/host_vars/UCLA +++ b/host_vars/UCLA @@ -1,7 +1,7 @@ site: /edu/ucla site_name: University of California, Los Angeles -operator_name: Tianyuan Yu -operator_email: royu29@g.ucla.edu +operator_name: Adam Thieme +operator_email: adam@cs.ucla.edu ansible_host: suns.cs.ucla.edu host_ip: 131.179.196.48 local_ip: 131.179.196.48 diff --git a/host_vars/UFBA b/host_vars/UFBA index 276688d..e5325bb 100644 --- a/host_vars/UFBA +++ b/host_vars/UFBA @@ -1,7 +1,7 @@ site: /br/ufba site_name: Federal University of Bahia, Brazil -operator_name: 'Thiago Bomfim ' -operator_email: thiagobomfim@pop-ba.rnp.br +operator_name: Prof. Dr. LEOBINO N SAMPAIO +operator_email: leobino@ufba.br ansible_host: ufba.testbed.named-data.net host_ip: 200.128.51.61 local_ip: 200.128.51.61 diff --git a/host_vars/WU b/host_vars/WU index 20d2d60..244a542 100644 --- a/host_vars/WU +++ b/host_vars/WU @@ -1,7 +1,7 @@ site: /edu/wustl site_name: Washington University in St. Louis -operator_name: John DeHart -operator_email: jdd@wustl.edu +operator_name: Patrick Crowley +operator_email: pcrowley@wustl.edu ansible_host: wu.testbed.named-data.net host_ip: 128.252.185.35 local_ip: 128.252.185.35 From b65d36ebd296e8cfb35339a5841158bb346d5d14 Mon Sep 17 00:00:00 2001 From: Adam Thieme Date: Sat, 24 Oct 2026 00:52:01 -0700 Subject: [PATCH 04/52] fix arizona host and operator email mistake --- host_vars/ARIZONA | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/host_vars/ARIZONA b/host_vars/ARIZONA index 286f04c..1ea4965 100644 --- a/host_vars/ARIZONA +++ b/host_vars/ARIZONA @@ -1,8 +1,8 @@ site: /edu/arizona site_name: The University of Arizona operator_name: Beichuan Zhang -operator_email: philoliang2011@gmail.com -ansible_host: bzhang@cs.arizona.edu +operator_email: bzhang@cs.arizona.edu +ansible_host: hobo.cs.arizona.edu host_ip: 128.196.203.36 local_ip: 128.196.203.36 site_email_domain: From 37021ca252ffb0ab1ef47d4a1d60dcef50d852b1 Mon Sep 17 00:00:00 2001 From: Adam Thieme Date: Sat, 24 Oct 2026 00:54:37 -0700 Subject: [PATCH 05/52] update WASEDA host_vars operator name --- host_vars/WASEDA | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/host_vars/WASEDA b/host_vars/WASEDA index 3392bde..5f402f1 100644 --- a/host_vars/WASEDA +++ b/host_vars/WASEDA @@ -1,6 +1,6 @@ site: /jp/waseda site_name: Waseda University, Tokyo, Japan -operator_name: Xiabo Li +operator_name: Hidenori Nakazato operator_email: lxb385@fuji.waseda.jp ansible_host: ndn-tb.nz.comm.waseda.ac.jp host_ip: 133.9.67.98 From d316f9c7113ceb1e4894d032958e81b2d88f0173 Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Fri, 16 Oct 2026 18:20:11 -0700 Subject: [PATCH 06/52] Add opt-in NDNd with Caddy WebSocket routes --- config.yml | 13 ++++++++++++ docker-compose.yml | 38 ++++++++++++++++++++++++++++++++++++ framework/internal/conf.py | 12 +++++++++++- host_vars/UCLA | 1 + templates/caddy/Caddyfile.j2 | 9 +++++++++ templates/ndnd/yanfd.yml.j2 | 17 ++++++++++++++++ 6 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 templates/ndnd/yanfd.yml.j2 diff --git a/config.yml b/config.yml index 4fc53d5..9af3d14 100644 --- a/config.yml +++ b/config.yml @@ -6,6 +6,17 @@ host_vars_path: host_vars # This must match exactly with the docker-compose.yml file services: + ndnd: + enabled_by: ndnd_enabled + profile: ndnd + template_path: templates/ndnd + render_path: dist/ndnd + + ndnd-http-status-server: + enabled_by: ndnd_enabled + profile: ndnd + pass: on + caddy: template_path: templates/caddy render_path: dist/caddy @@ -74,6 +85,7 @@ globals: # Explicitly select the active root; retain additional roots here during rollover. ndnd_repo_anchors: - anchors/ndn-testbed-root.ndncert.2204.base64 + ndnd_udp_port: 6364 # Declare variables available for each host # You can use lint.py to check variables, their types and @@ -102,3 +114,4 @@ variables: ethernet_device: string is_root_ca: "?boolean" is_status_page: "?boolean" + ndnd_enabled: "?boolean" diff --git a/docker-compose.yml b/docker-compose.yml index 590cc87..86eab4f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -43,6 +43,44 @@ services: logging: driver: local + ndnd: + image: ndnd-dv2:a841cc27 + build: + context: https://github.com/named-data/ndnd.git#a841cc27f6ee90ca4dfefa8d4f3ef4ce91e5da93 + profiles: [ndnd] + init: true + volumes: + - /run/ndnd:/run/ndnd + - ${PWD}/dist/ndnd:/config:ro + environment: + NDN_CLIENT_TRANSPORT: unix:///run/ndnd/ndnd.sock + command: [fw, run, /config/yanfd.yml] + ports: + - 6364:6364/udp + restart: unless-stopped + healthcheck: + test: [CMD, /ndnd, fw, status] + interval: 1m + start_period: 30s + depends_on: + master: { condition: service_healthy } + logging: + driver: local + + ndnd-http-status-server: + image: ghcr.io/named-data/nfd-status-http-server:20260420 + profiles: [ndnd] + init: true + volumes: + - /run/ndnd:/run/ndnd:ro + environment: + NDN_CLIENT_TRANSPORT: unix:///run/ndnd/ndnd.sock + restart: unless-stopped + depends_on: + ndnd: { condition: service_healthy } + logging: + driver: local + nfd: image: ghcr.io/named-data/nfd:20250420 init: true diff --git a/framework/internal/conf.py b/framework/internal/conf.py index 88017c6..b51451f 100644 --- a/framework/internal/conf.py +++ b/framework/internal/conf.py @@ -3,6 +3,7 @@ from dataclasses import dataclass from os import getenv +from pathlib import Path from typing import Any from .utils import read_dotenv @@ -34,7 +35,16 @@ def get() -> Config: def service_enabled(service: dict, node: str) -> bool: - return 'hosts' not in service or node in service['hosts'] + if 'hosts' in service and node not in service['hosts']: + return False + enabled_by = service.get('enabled_by') + if enabled_by is None: + return True + if not node: + return False + with open(Path(get().host_vars_path) / node) as stream: + host_vars = yaml.safe_load(stream) or {} + return bool(host_vars.get(enabled_by, False)) def compose_profiles(node: str = None) -> str: diff --git a/host_vars/UCLA b/host_vars/UCLA index cccbe67..f05dfed 100644 --- a/host_vars/UCLA +++ b/host_vars/UCLA @@ -44,3 +44,4 @@ hr_angle: 2.99911 hr_radius: 16.5866 ethernet_device: eth0 is_root_ca: true +ndnd_enabled: true diff --git a/templates/caddy/Caddyfile.j2 b/templates/caddy/Caddyfile.j2 index bb6973f..2c1997a 100644 --- a/templates/caddy/Caddyfile.j2 +++ b/templates/caddy/Caddyfile.j2 @@ -1,4 +1,13 @@ {{ ansible_host }} { + {% if ndnd_enabled | default(false) %} + handle_path /ndnd-status/* { + reverse_proxy http://ndnd-http-status-server:6380 + } + + @ndndws path /ndnd /ndnd/* + reverse_proxy @ndndws http://ndnd:9696 + {% endif %} + @nfdstatus path / /nfd-status.xsl /xslt-polyfill.min.js /*.css reverse_proxy @nfdstatus http://nfd-http-status-server:6380 diff --git a/templates/ndnd/yanfd.yml.j2 b/templates/ndnd/yanfd.yml.j2 new file mode 100644 index 0000000..e0e47db --- /dev/null +++ b/templates/ndnd/yanfd.yml.j2 @@ -0,0 +1,17 @@ +faces: + udp: + enabled_unicast: true + enabled_multicast: false + port_unicast: {{ ndnd_udp_port }} + tcp: + enabled: false + unix: + enabled: true + socket_path: /run/ndnd/ndnd.sock + websocket: + enabled: true + bind: "" + port: 9696 + tls_enabled: false + http3: + enabled: false \ No newline at end of file From 2ff9b0bbaaaa98047d86625bcb9e9893897a0c0a Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Fri, 16 Oct 2026 18:25:08 -0700 Subject: [PATCH 07/52] Serve NDNd status via its management socket --- docker-compose.yml | 2 ++ framework/ndnd-status-http-server.py | 34 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 framework/ndnd-status-http-server.py diff --git a/docker-compose.yml b/docker-compose.yml index 86eab4f..b220109 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -73,8 +73,10 @@ services: init: true volumes: - /run/ndnd:/run/ndnd:ro + - ${PWD}/framework/ndnd-status-http-server.py:/app/ndnd-status-http-server.py:ro environment: NDN_CLIENT_TRANSPORT: unix:///run/ndnd/ndnd.sock + entrypoint: [python3, /app/ndnd-status-http-server.py] restart: unless-stopped depends_on: ndnd: { condition: service_healthy } diff --git a/framework/ndnd-status-http-server.py b/framework/ndnd-status-http-server.py new file mode 100644 index 0000000..b95750d --- /dev/null +++ b/framework/ndnd-status-http-server.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 + +import html +import subprocess +from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer + + +class Handler(BaseHTTPRequestHandler): + def do_GET(self): + if self.path not in ("/", "/index.html"): + self.send_error(404) + return + + try: + status = subprocess.run( + ["nfdc", "status"], capture_output=True, check=True, text=True, timeout=5 + ).stdout + except (OSError, subprocess.SubprocessError) as error: + self.send_error(502, str(error)) + return + + body = ( + "" + "NDNd status

NDNd status

"
+            f"{html.escape(status)}
" + ).encode() + self.send_response(200) + self.send_header("Content-Type", "text/html; charset=utf-8") + self.send_header("Content-Length", str(len(body))) + self.end_headers() + self.wfile.write(body) + + +ThreadingHTTPServer(("0.0.0.0", 6380), Handler).serve_forever() \ No newline at end of file From 9044db5270a97afab6dff2f7533bc4fec344c9d6 Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Fri, 16 Oct 2026 18:33:37 -0700 Subject: [PATCH 08/52] Enable NDNd canary at Arizona and Memphis --- host_vars/ARIZONA | 1 + host_vars/MEMPHIS | 1 + 2 files changed, 2 insertions(+) diff --git a/host_vars/ARIZONA b/host_vars/ARIZONA index 1ea4965..f6022da 100644 --- a/host_vars/ARIZONA +++ b/host_vars/ARIZONA @@ -35,3 +35,4 @@ position: hr_angle: 2.97033 hr_radius: 16.2305 ethernet_device: eth0 +ndnd_enabled: true diff --git a/host_vars/MEMPHIS b/host_vars/MEMPHIS index 0e4e254..ea46b45 100644 --- a/host_vars/MEMPHIS +++ b/host_vars/MEMPHIS @@ -30,3 +30,4 @@ position: hr_angle: 2.9836 hr_radius: 15.2647 ethernet_device: eth1 +ndnd_enabled: true From 3f44ca27ff0ea659c7fb059ec6f488d6f3f6e823 Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Sat, 17 Oct 2026 14:09:47 -0700 Subject: [PATCH 09/52] Use NDNd XML status server --- docker-compose.yml | 14 ++++++++---- framework/ndnd-status-http-server.py | 34 ---------------------------- 2 files changed, 9 insertions(+), 39 deletions(-) delete mode 100644 framework/ndnd-status-http-server.py diff --git a/docker-compose.yml b/docker-compose.yml index b220109..bcf0da7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,9 +44,9 @@ services: driver: local ndnd: - image: ndnd-dv2:a841cc27 + image: ndnd-dv2:8263081 build: - context: https://github.com/named-data/ndnd.git#a841cc27f6ee90ca4dfefa8d4f3ef4ce91e5da93 + context: https://github.com/markverick/ndnd.git#826308101bd266c5b33c6105b584595674214522 profiles: [ndnd] init: true volumes: @@ -68,15 +68,19 @@ services: driver: local ndnd-http-status-server: - image: ghcr.io/named-data/nfd-status-http-server:20260420 + image: ndnd-dv2:8263081 + build: + context: https://github.com/markverick/ndnd.git#826308101bd266c5b33c6105b584595674214522 profiles: [ndnd] init: true volumes: - /run/ndnd:/run/ndnd:ro - - ${PWD}/framework/ndnd-status-http-server.py:/app/ndnd-status-http-server.py:ro environment: NDN_CLIENT_TRANSPORT: unix:///run/ndnd/ndnd.sock - entrypoint: [python3, /app/ndnd-status-http-server.py] + command: [fw, status-server] + read_only: true + cap_drop: [ALL] + security_opt: [no-new-privileges:true] restart: unless-stopped depends_on: ndnd: { condition: service_healthy } diff --git a/framework/ndnd-status-http-server.py b/framework/ndnd-status-http-server.py deleted file mode 100644 index b95750d..0000000 --- a/framework/ndnd-status-http-server.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python3 - -import html -import subprocess -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer - - -class Handler(BaseHTTPRequestHandler): - def do_GET(self): - if self.path not in ("/", "/index.html"): - self.send_error(404) - return - - try: - status = subprocess.run( - ["nfdc", "status"], capture_output=True, check=True, text=True, timeout=5 - ).stdout - except (OSError, subprocess.SubprocessError) as error: - self.send_error(502, str(error)) - return - - body = ( - "" - "NDNd status

NDNd status

"
-            f"{html.escape(status)}
" - ).encode() - self.send_response(200) - self.send_header("Content-Type", "text/html; charset=utf-8") - self.send_header("Content-Length", str(len(body))) - self.end_headers() - self.wfile.write(body) - - -ThreadingHTTPServer(("0.0.0.0", 6380), Handler).serve_forever() \ No newline at end of file From e75c0ad180b6fd74b6cde6593aca1cc855ff9fa0 Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Sat, 17 Oct 2026 15:22:16 -0700 Subject: [PATCH 10/52] Pin NDNd status service to TLV dataset version --- docker-compose.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index bcf0da7..71d57ac 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,9 +44,9 @@ services: driver: local ndnd: - image: ndnd-dv2:8263081 + image: ndnd-dv2:7ea7f49 build: - context: https://github.com/markverick/ndnd.git#826308101bd266c5b33c6105b584595674214522 + context: https://github.com/markverick/ndnd.git#7ea7f49049818020b7fd79a236b3a8643163ef58 profiles: [ndnd] init: true volumes: @@ -68,9 +68,9 @@ services: driver: local ndnd-http-status-server: - image: ndnd-dv2:8263081 + image: ndnd-dv2:7ea7f49 build: - context: https://github.com/markverick/ndnd.git#826308101bd266c5b33c6105b584595674214522 + context: https://github.com/markverick/ndnd.git#7ea7f49049818020b7fd79a236b3a8643163ef58 profiles: [ndnd] init: true volumes: From 1710320dff1ba1419c59624f87a358713912ee2b Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Sat, 17 Oct 2026 16:32:47 -0700 Subject: [PATCH 11/52] Pin testbed to updated NDNd status build --- docker-compose.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 71d57ac..6985338 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,9 +44,9 @@ services: driver: local ndnd: - image: ndnd-dv2:7ea7f49 + image: ndnd-dv2:924263f build: - context: https://github.com/markverick/ndnd.git#7ea7f49049818020b7fd79a236b3a8643163ef58 + context: https://github.com/markverick/ndnd.git#924263f1a89e8698ee1d4913b331894c1bb16378 profiles: [ndnd] init: true volumes: @@ -68,9 +68,9 @@ services: driver: local ndnd-http-status-server: - image: ndnd-dv2:7ea7f49 + image: ndnd-dv2:924263f build: - context: https://github.com/markverick/ndnd.git#7ea7f49049818020b7fd79a236b3a8643163ef58 + context: https://github.com/markverick/ndnd.git#924263f1a89e8698ee1d4913b331894c1bb16378 profiles: [ndnd] init: true volumes: From a60fbbdc03d22e60f9a769f4caff02ecd34cf47f Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Sat, 17 Oct 2026 17:44:08 -0700 Subject: [PATCH 12/52] Pin testbed to latest NDNd status build --- docker-compose.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 6985338..359a50e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,9 +44,9 @@ services: driver: local ndnd: - image: ndnd-dv2:924263f + image: ndnd-dv2:e9b25bd build: - context: https://github.com/markverick/ndnd.git#924263f1a89e8698ee1d4913b331894c1bb16378 + context: https://github.com/markverick/ndnd.git#e9b25bda4a313727696c99efe2b26c59677740b9 profiles: [ndnd] init: true volumes: @@ -68,9 +68,9 @@ services: driver: local ndnd-http-status-server: - image: ndnd-dv2:924263f + image: ndnd-dv2:e9b25bd build: - context: https://github.com/markverick/ndnd.git#924263f1a89e8698ee1d4913b331894c1bb16378 + context: https://github.com/markverick/ndnd.git#e9b25bda4a313727696c99efe2b26c59677740b9 profiles: [ndnd] init: true volumes: From d68345dc20dbe4edc4d493a503fcfc1a1e35d86a Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Sat, 17 Oct 2026 19:01:05 -0700 Subject: [PATCH 13/52] Run isolated NDNd DV routers --- README.md | 4 ++ config.yml | 7 ++++ docker-compose.yml | 23 ++++++++++++ scripts/cert-renew.sh | 13 +++++++ scripts/ndnd-infra-security.py | 59 +++++++++++++++++++++--------- templates/ndnd-dv/dv-schema.lvs.j2 | 16 ++++++++ templates/ndnd-dv/dv.yml.j2 | 20 ++++++++++ templates/ndnd-dv/renew.sh.j2 | 16 ++++++++ 8 files changed, 140 insertions(+), 18 deletions(-) create mode 100644 templates/ndnd-dv/dv-schema.lvs.j2 create mode 100644 templates/ndnd-dv/dv.yml.j2 create mode 100644 templates/ndnd-dv/renew.sh.j2 diff --git a/README.md b/README.md index 977bff2..2727c1e 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,10 @@ docker compose exec -e HOME=/testbed/root-ca-home master ndnsec list -c Each node runs the pinned `ndnd-repo` container with identity `/ndnd/repo` (e.g. `/ndn/edu/ucla/ndnd/repo`). Master generates a dedicated key, obtains a certificate from the local site CA, and installs the public chain selected by `globals.ndnd_repo_anchors`. The repo can write only its keychain and storage; it has no access to CA private keys or master renewal scripts. +## NDNd Distance Vector + +Nodes with `ndnd_enabled: true` run the NDNd forwarder and a separate `ndnd dv` router. The router connects only to the forwarder's `/run/ndnd/ndnd.sock` and exchanges DV traffic over the forwarder's UDP listener on port 6364; it does not use NFD's socket or NLSR. Router identities are root-signed as `/32=DV`, and each router has permanent UDP neighbor links to the other NDNd-enabled nodes. + ## NDNd Merkle Only UCLA runs the `ndnd-merkle` container, selected by `services.ndnd-merkle.hosts: [UCLA]` in `config.yml`, with identity `/ndn/edu/ucla/ndnd/merkle`. Master automatically provisions and renews its dedicated site-issued certificate using the same testbed anchors as the repo. Its trust schema permits testbed-certified users to append under their own identities and only the log key to sign responses. History persists in `dist/ndnd-merkle/storage`. diff --git a/config.yml b/config.yml index 9af3d14..b92fb99 100644 --- a/config.yml +++ b/config.yml @@ -12,6 +12,12 @@ services: template_path: templates/ndnd render_path: dist/ndnd + ndnd-dv: + enabled_by: ndnd_enabled + profile: ndnd + template_path: templates/ndnd-dv + render_path: dist/ndnd-dv + ndnd-http-status-server: enabled_by: ndnd_enabled profile: ndnd @@ -86,6 +92,7 @@ globals: ndnd_repo_anchors: - anchors/ndn-testbed-root.ndncert.2204.base64 ndnd_udp_port: 6364 + ndnd_dv_network: /ndn/edu # Declare variables available for each host # You can use lint.py to check variables, their types and diff --git a/docker-compose.yml b/docker-compose.yml index 359a50e..1e81c62 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -67,6 +67,29 @@ services: logging: driver: local + ndnd-dv: + image: ndnd-dv2:e9b25bd + build: + context: https://github.com/markverick/ndnd.git#e9b25bda4a313727696c99efe2b26c59677740b9 + profiles: [ndnd] + init: true + volumes: + - /run/ndnd:/run/ndnd:ro + - ${PWD}/dist/ndnd-dv/dv.yml:/config/dv.yml:ro + - ${PWD}/dist/ndnd-dv/dv-schema.tlv:/config/dv-schema.tlv:ro + - ${PWD}/dist/ndnd-dv/keys:/config/keys:ro + environment: + NDN_CLIENT_TRANSPORT: unix:///run/ndnd/ndnd.sock + command: [dv, run, /config/dv.yml] + read_only: true + cap_drop: [ALL] + security_opt: [no-new-privileges:true] + restart: unless-stopped + depends_on: + ndnd: { condition: service_healthy } + logging: + driver: local + ndnd-http-status-server: image: ndnd-dv2:e9b25bd build: diff --git a/scripts/cert-renew.sh b/scripts/cert-renew.sh index dc2f14d..e9c6fa3 100644 --- a/scripts/cert-renew.sh +++ b/scripts/cert-renew.sh @@ -20,6 +20,19 @@ bash "$(pwd)/dist/nlsr/renew.sh" "${FORCE}" || exit $? bash "$(pwd)/dist/ndn-python-repo/renew.sh" "${FORCE}" || exit $? bash "$(pwd)/dist/ndnd-repo/renew.sh" ${FORCE:+"${FORCE}"} || exit $? +DV_ENABLED=$(python3 framework/service-profiles.py --service ndnd-dv) || exit $? +if [[ "${DV_ENABLED}" == 1 ]]; then + DV_DIR=dist/ndnd-dv + bash "${DV_DIR}/renew.sh" ${FORCE:+"${FORCE}"} || exit $? + if [[ -f "${DV_DIR}/.security-changed" ]]; then + RUNNING_DV=$(PWD="${ROOT_DIR:-$PWD}" docker compose ps --status running -q ndnd-dv) || exit $? + if [[ -n "${RUNNING_DV}" ]]; then + PWD="${ROOT_DIR:-$PWD}" docker compose restart ndnd-dv || exit $? + fi + rm -f "${DV_DIR}/.security-changed" + fi +fi + # Restart containers if force if [[ -n "${FORCE}" ]]; then PWD="${ROOT_DIR:-$PWD}" docker compose restart nlsr ndncert serve-certs ndn-python-repo || exit $? diff --git a/scripts/ndnd-infra-security.py b/scripts/ndnd-infra-security.py index 6b77abf..d957f1c 100644 --- a/scripts/ndnd-infra-security.py +++ b/scripts/ndnd-infra-security.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -"""Provision NDNd's directory keychain using the existing ndn-cxx site CA.""" +"""Provision NDNd service keychains using the testbed certificate authorities.""" import argparse import base64 @@ -12,6 +12,7 @@ import subprocess import tempfile import time +from urllib.request import Request, urlopen from Cryptodome.PublicKey import ECC, RSA import yaml @@ -61,6 +62,13 @@ def import_packet(directory, wire, kind): return write_atomic(path, pem(wire, kind)) +def sign_with_root_ca(csr, root_ca_url, secret): + url = f'{root_ca_url.rstrip("/")}/sign?secret={secret}' + request = Request(url, data=base64.encodebytes(csr), method='POST') + with urlopen(request, timeout=30) as response: + return base64.b64decode(b''.join(response.read().split()), validate=True) + + def validity(wire): period = parse_certificate(wire).signature_info.validity_period return tuple(datetime.strptime(bytes(value).decode(), '%Y%m%dT%H%M%S').replace(tzinfo=timezone.utc) @@ -112,23 +120,32 @@ def get_key(directory, identity): return name, key, wire -def provision(directory, site_home, site_prefix, anchors_path, force=False, renew_before_days=30, service='repo'): +def provision(directory, site_home, site_prefix, anchors_path, force=False, renew_before_days=30, + service='repo', root_ca_url=''): # Serialize overlapping cron/manual renewal runs without rotating the key. with (directory / '.security.lock').open('a') as lock: fcntl.flock(lock, fcntl.LOCK_EX) - return provision_locked(directory, site_home, site_prefix, anchors_path, force, renew_before_days, service) + return provision_locked(directory, site_home, site_prefix, anchors_path, force, renew_before_days, + service, root_ca_url) -def provision_locked(directory, site_home, site_prefix, anchors_path, force, renew_before_days, service): - if service not in ('repo', 'merkle'): +def provision_locked(directory, site_home, site_prefix, anchors_path, force, renew_before_days, service, root_ca_url): + if service not in ('repo', 'merkle', 'dv'): raise ValueError('Unsupported NDNd service') if service == 'merkle' and site_prefix != '/ndn/edu/ucla': raise ValueError('Merkle log provisioning is restricted to UCLA') with (directory / f'{service}.yml').open() as stream: config = yaml.safe_load(stream)[service] - identity = Name.normalize(config['name']) - if Name.to_bytes(identity) != Name.to_bytes(Name.normalize(site_prefix + '/ndnd/' + service)): - raise ValueError(f'Identity must be /ndnd/{service}') + if service == 'dv': + identity = Name.normalize(config['router'] + '/32=DV') + expected_identity = Name.normalize(site_prefix + '/32=DV') + if not root_ca_url or not os.environ.get('ROOT_CA_SECRET'): + raise ValueError('DV credential provisioning requires the root CA URL and ROOT_CA_SECRET') + else: + identity = Name.normalize(config['name']) + expected_identity = Name.normalize(site_prefix + '/ndnd/' + service) + if Name.to_bytes(identity) != Name.to_bytes(expected_identity): + raise ValueError(f'Invalid {service} identity {Name.to_str(identity)}') now = datetime.now(timezone.utc) site_wire = decode_certificate(site_home / 'site.ndncert') @@ -145,6 +162,7 @@ def provision_locked(directory, site_home, site_prefix, anchors_path, force, ren issuer = next((wire for wire in anchor_wires if verify_certificate(site_wire, wire)), None) if issuer is None: raise ValueError('Site certificate does not verify against a pinned testbed root') + signing_issuer = issuer if service == 'dv' else site_wire site_before, site_after = validity(site_wire) root_before, root_after = validity(issuer) # ndn-cxx rounds NotBefore up to a whole second when issuing a certificate. @@ -170,7 +188,7 @@ def provision_locked(directory, site_home, site_prefix, anchors_path, force, ren renew |= (not before <= now < after - margin or Name.to_bytes(cert.name[:-2]) != Name.to_bytes(key_name) or bytes(cert.content) != key.public_key().export_key(format='DER') - or not verify_certificate(cert_wire, site_wire) + or not verify_certificate(cert_wire, signing_issuer) or before < max(site_before, root_before) or after > min(site_after, root_after)) @@ -182,16 +200,19 @@ def provision_locked(directory, site_home, site_prefix, anchors_path, force, ren signer = Sha256WithEcdsaSigner(key_name, key.export_key(format='DER', use_pkcs8=False)) _, csr = new_cert(key_name, Component.from_str('self'), key.public_key().export_key(format='DER'), signer, before, after) - command = ['ndnsec', 'cert-gen', '-s', site_prefix, - '-S', before.strftime('%Y%m%d%H%M%S'), '-E', after.strftime('%Y%m%d%H%M%S'), '-'] - result = subprocess.run(command, input=base64.encodebytes(csr), stdout=subprocess.PIPE, - env={**os.environ, 'HOME': str(site_home)}, check=True, timeout=30) - cert_wire = base64.b64decode(b''.join(result.stdout.split()), validate=True) + if service == 'dv': + cert_wire = sign_with_root_ca(csr, root_ca_url, os.environ['ROOT_CA_SECRET']) + else: + command = ['ndnsec', 'cert-gen', '-s', site_prefix, + '-S', before.strftime('%Y%m%d%H%M%S'), '-E', after.strftime('%Y%m%d%H%M%S'), '-'] + result = subprocess.run(command, input=base64.encodebytes(csr), stdout=subprocess.PIPE, + env={**os.environ, 'HOME': str(site_home)}, check=True, timeout=30) + cert_wire = base64.b64decode(b''.join(result.stdout.split()), validate=True) cert = parse_certificate(cert_wire) actual_before, actual_after = validity(cert_wire) if (Name.to_bytes(cert.name[:-2]) != Name.to_bytes(key_name) or bytes(cert.content) != key.public_key().export_key(format='DER') - or not verify_certificate(cert_wire, site_wire) + or not verify_certificate(cert_wire, signing_issuer) or not before <= actual_before <= now < actual_after <= after): raise ValueError('Site CA returned an invalid service certificate') @@ -202,7 +223,7 @@ def provision_locked(directory, site_home, site_prefix, anchors_path, force, ren changed |= write_atomic(cert_path, base64.encodebytes(cert_wire)) if changed: write_atomic(directory / '.security-changed', b'\n') - print(f"NDNd {service} {config['name']}: {'credentials updated' if changed else 'credentials current'}") + print(f"NDNd {service} {Name.to_str(identity)}: {'credentials updated' if changed else 'credentials current'}") return changed @@ -212,7 +233,9 @@ def provision_locked(directory, site_home, site_prefix, anchors_path, force, ren parser.add_argument('--site-home', type=Path, required=True) parser.add_argument('--site-prefix', required=True) parser.add_argument('--anchors', type=Path, required=True) - parser.add_argument('--service', choices=('repo', 'merkle'), default='repo') + parser.add_argument('--service', choices=('repo', 'merkle', 'dv'), default='repo') + parser.add_argument('--root-ca-url', default='') parser.add_argument('--force', action='store_true') args = parser.parse_args() - provision(args.directory, args.site_home, args.site_prefix, args.anchors, args.force, service=args.service) + provision(args.directory, args.site_home, args.site_prefix, args.anchors, args.force, + service=args.service, root_ca_url=args.root_ca_url) diff --git a/templates/ndnd-dv/dv-schema.lvs.j2 b/templates/ndnd-dv/dv-schema.lvs.j2 new file mode 100644 index 0000000..669738f --- /dev/null +++ b/templates/ndnd-dv/dv-schema.lvs.j2 @@ -0,0 +1,16 @@ +// All NDNd routers use the shared /ndn/edu DV network. The testbed root +// directly issues each site router's /32=DV certificate. +#KEY: "KEY"/_/_/_ +#network: {{ ndn_lvs_name(ndnd_dv_network) }} +#network_cert: {{ ndn_lvs_name(ndnNetwork) }}/#KEY +#prefix_state: #network/"32=DV"/"32=PSD" + +{% for host, values in hostvars.items() %} +{% if values.get('ndnd_enabled', false) %} +{% set router = ndn_lvs_name(values.default_prefix) %} +#router_{{ loop.index }}: {{ router }} +#router_cert_{{ loop.index }}: #router_{{ loop.index }}/"32=DV"/#KEY <= #network_cert +#advertisement_data_{{ loop.index }}: /"localhop"/#router_{{ loop.index }}/"32=DV"/"32=ADV"/_ <= #router_cert_{{ loop.index }} +#prefix_state_data_{{ loop.index }}: #prefix_state/#router_{{ loop.index }}/_/_ <= #router_cert_{{ loop.index }} +{% endif %} +{% endfor %} \ No newline at end of file diff --git a/templates/ndnd-dv/dv.yml.j2 b/templates/ndnd-dv/dv.yml.j2 new file mode 100644 index 0000000..ff25552 --- /dev/null +++ b/templates/ndnd-dv/dv.yml.j2 @@ -0,0 +1,20 @@ +dv: + network: {{ ndnd_dv_network | tojson }} + router: {{ default_prefix | tojson }} + keychain: dir:///config/keys + trust_anchors: + {% for anchor in ndnd_repo_anchors %} + - {{ ndn_cert_name(read_file(anchor)) | tojson }} + {% endfor %} + trust_schema: dv-schema.tlv + neighbors: + {% set peers = namespace(count=0) %} + {% for host, values in hostvars.items() %} + {% if host != inventory_hostname and values.get('ndnd_enabled', false) %} + - uri: {{ ("udp4://" + values.host_ip + ":" + str(ndnd_udp_port)) | tojson }} + {% set peers.count = peers.count + 1 %} + {% endif %} + {% endfor %} + {% if peers.count == 0 %} + [] + {% endif %} \ No newline at end of file diff --git a/templates/ndnd-dv/renew.sh.j2 b/templates/ndnd-dv/renew.sh.j2 new file mode 100644 index 0000000..2fcc6f3 --- /dev/null +++ b/templates/ndnd-dv/renew.sh.j2 @@ -0,0 +1,16 @@ +#!/bin/bash + +set -eu + +REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +TESTBED_DIR="$(cd "${REPO_DIR}/../.." && pwd)" +ROOT_CA_SECRET={{ ROOT_CA_SECRET | tojson }} +export ROOT_CA_SECRET + +python3 "${TESTBED_DIR}/scripts/ndnd-infra-security.py" \ + --directory "${REPO_DIR}" \ + --site-home "${TESTBED_DIR}/dist/ndncert" \ + --site-prefix {{ default_prefix | tojson }} \ + --anchors "${TESTBED_DIR}/anchors" \ + --service dv \ + --root-ca-url {{ root_ca_https | tojson }} "$@" \ No newline at end of file From 86d12274ef915c6e2cd83c2903d9170477bf5fda Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Sat, 17 Oct 2026 19:14:27 -0700 Subject: [PATCH 14/52] Secure root-issued DV credentials --- framework/http-ca-server.py | 46 ++++++++++++++++++++++++++++++---- scripts/ndnd-infra-security.py | 14 ++++++++--- templates/ndncert/renew.sh.j2 | 5 ++-- 3 files changed, 54 insertions(+), 11 deletions(-) diff --git a/framework/http-ca-server.py b/framework/http-ca-server.py index f2bff58..05545d9 100755 --- a/framework/http-ca-server.py +++ b/framework/http-ca-server.py @@ -7,6 +7,8 @@ import subprocess import ndn import ipaddress +from datetime import datetime, timedelta +from urllib.parse import parse_qs from dataclasses import dataclass from http.server import BaseHTTPRequestHandler, HTTPServer @@ -30,7 +32,13 @@ def which_host_ip(self, address: str) -> dict|None: def sign(self, path: str, query: str, data: bytes) -> None: # Check if the secret is correct from query parameter - if query != f'secret={config.secret}': + try: + params = parse_qs(query, strict_parsing=True) + except ValueError: + self.send_error(400, "Invalid query parameters") + return + authorization = self.headers.get('Authorization') + if authorization != f'Bearer {config.secret}' and params.get('secret') != [config.secret]: self.send_error(401, "Invalid secret") return @@ -49,8 +57,28 @@ def sign(self, path: str, query: str, data: bytes) -> None: self.send_error(400, f"Invalid name {str_name}, expected prefix {pfx}") return - # Sign a certificate for the name - proc = subprocess.run(['ndnsec', 'cert-gen', '-s', config.global_prefix, '-'], input=data, capture_output=True) + not_before = params.get('not_before', []) + not_after = params.get('not_after', []) + if bool(not_before) != bool(not_after) or len(not_before) > 1 or len(not_after) > 1: + self.send_error(400, "Both validity bounds must be provided once") + return + + command = ['ndnsec', 'cert-gen', '-s', config.global_prefix] + if not_before: + try: + start = datetime.strptime(not_before[0], '%Y%m%d%H%M%S') + end = datetime.strptime(not_after[0], '%Y%m%d%H%M%S') + except ValueError: + self.send_error(400, "Invalid certificate validity bounds") + return + if end <= start or end - start > timedelta(days=90): + self.send_error(400, "Certificate validity must be positive and no longer than 90 days") + return + command.extend(['-S', not_before[0], '-E', not_after[0]]) + command.append('-') + + # Sign a certificate for the name. + proc = subprocess.run(command, input=data, capture_output=True) if proc.returncode != 0: self.send_error(500, f"Failed to sign certificate: {proc.stderr}") @@ -66,8 +94,11 @@ def sign(self, path: str, query: str, data: bytes) -> None: self.end_headers() self.wfile.write(certificate) - # Store the certificate if path provided - if path := host.get('cert_file'): + # This cache is consumed as the host's site certificate, not as a + # general log of every descendant certificate signed for that host. + identity = ndn.encoding.name.Name.to_str(cert_name[:-4]) if len(cert_name) >= 4 else '' + path = host.get('cert_file') + if path and identity == pfx: with open(path, 'wb') as f: f.write(certificate) @@ -99,6 +130,11 @@ def address_string(self) -> str: return self.client_address[0] + def log_request(self, code='-', size='-') -> None: + # Legacy callers put the root CA secret in the query string. + requestline = self.requestline.split('?', 1)[0] + self.log_message('"%s" %s %s', requestline, str(code), str(size)) + if __name__ == '__main__': # Read YAML config with open(sys.argv[1], 'r') as f: diff --git a/scripts/ndnd-infra-security.py b/scripts/ndnd-infra-security.py index d957f1c..c169634 100644 --- a/scripts/ndnd-infra-security.py +++ b/scripts/ndnd-infra-security.py @@ -12,6 +12,7 @@ import subprocess import tempfile import time +from urllib.parse import urlencode from urllib.request import Request, urlopen from Cryptodome.PublicKey import ECC, RSA @@ -62,9 +63,14 @@ def import_packet(directory, wire, kind): return write_atomic(path, pem(wire, kind)) -def sign_with_root_ca(csr, root_ca_url, secret): - url = f'{root_ca_url.rstrip("/")}/sign?secret={secret}' - request = Request(url, data=base64.encodebytes(csr), method='POST') +def sign_with_root_ca(csr, root_ca_url, secret, before, after): + query = urlencode({ + 'not_before': before.strftime('%Y%m%d%H%M%S'), + 'not_after': after.strftime('%Y%m%d%H%M%S'), + }) + url = f'{root_ca_url.rstrip("/")}/sign?{query}' + request = Request(url, data=base64.encodebytes(csr), method='POST', + headers={'Authorization': f'Bearer {secret}'}) with urlopen(request, timeout=30) as response: return base64.b64decode(b''.join(response.read().split()), validate=True) @@ -201,7 +207,7 @@ def provision_locked(directory, site_home, site_prefix, anchors_path, force, ren _, csr = new_cert(key_name, Component.from_str('self'), key.public_key().export_key(format='DER'), signer, before, after) if service == 'dv': - cert_wire = sign_with_root_ca(csr, root_ca_url, os.environ['ROOT_CA_SECRET']) + cert_wire = sign_with_root_ca(csr, root_ca_url, os.environ['ROOT_CA_SECRET'], before, after) else: command = ['ndnsec', 'cert-gen', '-s', site_prefix, '-S', before.strftime('%Y%m%d%H%M%S'), '-E', after.strftime('%Y%m%d%H%M%S'), '-'] diff --git a/templates/ndncert/renew.sh.j2 b/templates/ndncert/renew.sh.j2 index 3ec3849..e85a897 100644 --- a/templates/ndncert/renew.sh.j2 +++ b/templates/ndncert/renew.sh.j2 @@ -22,8 +22,9 @@ if [[ $(needs_renewal "${NDNCERT_CERTFILE}") ]]; then trap 'rm -f "${RENEW_CERTFILE}"' EXIT # Get certificate from root certificate authority - curl -fsSL -X POST --upload-file "${NDNCERT_CERTFILE}.csr" -o "${RENEW_CERTFILE}" \ - "${ROOT_CA_HTTPS}/sign?secret=${ROOT_CA_SECRET}" + curl -fsSL -X POST -H "Authorization: Bearer ${ROOT_CA_SECRET}" \ + --upload-file "${NDNCERT_CERTFILE}.csr" -o "${RENEW_CERTFILE}" \ + "${ROOT_CA_HTTPS}/sign" # Install certificate to keychain ndnsec cert-install -f "${RENEW_CERTFILE}" From 01285f0f71a78addb505fddfd3c08631384e49eb Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Sat, 17 Oct 2026 19:17:12 -0700 Subject: [PATCH 15/52] Allow isolated DV keychain persistence --- docker-compose.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 1e81c62..d8fd8ec 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -77,10 +77,11 @@ services: - /run/ndnd:/run/ndnd:ro - ${PWD}/dist/ndnd-dv/dv.yml:/config/dv.yml:ro - ${PWD}/dist/ndnd-dv/dv-schema.tlv:/config/dv-schema.tlv:ro - - ${PWD}/dist/ndnd-dv/keys:/config/keys:ro + - ${PWD}/dist/ndnd-dv/keys:/config/keys environment: NDN_CLIENT_TRANSPORT: unix:///run/ndnd/ndnd.sock command: [dv, run, /config/dv.yml] + network_mode: none read_only: true cap_drop: [ALL] security_opt: [no-new-privileges:true] From 53f0ef34a2701cee4ce2cfcc3b65c116f0ca507b Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Sat, 17 Oct 2026 20:21:08 -0700 Subject: [PATCH 16/52] Pin NDNd DV sync fix --- docker-compose.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index d8fd8ec..0d8de9a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,9 +44,9 @@ services: driver: local ndnd: - image: ndnd-dv2:e9b25bd + image: ndnd-dv2:c8daa9c build: - context: https://github.com/markverick/ndnd.git#e9b25bda4a313727696c99efe2b26c59677740b9 + context: https://github.com/markverick/ndnd.git#c8daa9ce9f675b7c02ead3e579321bd86fdd9e53 profiles: [ndnd] init: true volumes: @@ -68,9 +68,9 @@ services: driver: local ndnd-dv: - image: ndnd-dv2:e9b25bd + image: ndnd-dv2:c8daa9c build: - context: https://github.com/markverick/ndnd.git#e9b25bda4a313727696c99efe2b26c59677740b9 + context: https://github.com/markverick/ndnd.git#c8daa9ce9f675b7c02ead3e579321bd86fdd9e53 profiles: [ndnd] init: true volumes: @@ -92,9 +92,9 @@ services: driver: local ndnd-http-status-server: - image: ndnd-dv2:e9b25bd + image: ndnd-dv2:c8daa9c build: - context: https://github.com/markverick/ndnd.git#e9b25bda4a313727696c99efe2b26c59677740b9 + context: https://github.com/markverick/ndnd.git#c8daa9ce9f675b7c02ead3e579321bd86fdd9e53 profiles: [ndnd] init: true volumes: From 732b446e02a6c995abc1825be136a2d2e217c279 Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Sat, 17 Oct 2026 20:40:01 -0700 Subject: [PATCH 17/52] Set NDNd router identity for DV forwarding --- templates/ndnd/yanfd.yml.j2 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/templates/ndnd/yanfd.yml.j2 b/templates/ndnd/yanfd.yml.j2 index e0e47db..4033543 100644 --- a/templates/ndnd/yanfd.yml.j2 +++ b/templates/ndnd/yanfd.yml.j2 @@ -14,4 +14,7 @@ faces: port: 9696 tls_enabled: false http3: - enabled: false \ No newline at end of file + enabled: false + +fw: + router_name: {{ default_prefix | tojson }} \ No newline at end of file From a6fc0e9bd818e3d6623f1cab70a5ddad6d625c0e Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Mon, 19 Oct 2026 21:15:53 -0700 Subject: [PATCH 18/52] Deploy combined NDNd XML and CA image --- docker-compose.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 0d8de9a..d519f14 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,9 +44,9 @@ services: driver: local ndnd: - image: ndnd-dv2:c8daa9c + image: ndnd-dv2:integration-62021f4 build: - context: https://github.com/markverick/ndnd.git#c8daa9ce9f675b7c02ead3e579321bd86fdd9e53 + context: https://github.com/markverick/ndnd.git#62021f4eb5a630d677fa909e93e5a07babf1ad48 profiles: [ndnd] init: true volumes: @@ -68,9 +68,9 @@ services: driver: local ndnd-dv: - image: ndnd-dv2:c8daa9c + image: ndnd-dv2:integration-62021f4 build: - context: https://github.com/markverick/ndnd.git#c8daa9ce9f675b7c02ead3e579321bd86fdd9e53 + context: https://github.com/markverick/ndnd.git#62021f4eb5a630d677fa909e93e5a07babf1ad48 profiles: [ndnd] init: true volumes: @@ -92,9 +92,9 @@ services: driver: local ndnd-http-status-server: - image: ndnd-dv2:c8daa9c + image: ndnd-dv2:integration-62021f4 build: - context: https://github.com/markverick/ndnd.git#c8daa9ce9f675b7c02ead3e579321bd86fdd9e53 + context: https://github.com/markverick/ndnd.git#62021f4eb5a630d677fa909e93e5a07babf1ad48 profiles: [ndnd] init: true volumes: From fa9759601d065a4b9927352a3c1cfd4136e0d1ae Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Mon, 19 Oct 2026 22:56:17 -0700 Subject: [PATCH 19/52] Deploy email-capable NDNd CA image --- docker-compose.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index d519f14..c1516e8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,9 +44,9 @@ services: driver: local ndnd: - image: ndnd-dv2:integration-62021f4 + image: ndnd-dv2:integration-a991047 build: - context: https://github.com/markverick/ndnd.git#62021f4eb5a630d677fa909e93e5a07babf1ad48 + context: https://github.com/markverick/ndnd.git#a9910477b5943781428773f2e2cd0dec755224e7 profiles: [ndnd] init: true volumes: @@ -68,9 +68,9 @@ services: driver: local ndnd-dv: - image: ndnd-dv2:integration-62021f4 + image: ndnd-dv2:integration-a991047 build: - context: https://github.com/markverick/ndnd.git#62021f4eb5a630d677fa909e93e5a07babf1ad48 + context: https://github.com/markverick/ndnd.git#a9910477b5943781428773f2e2cd0dec755224e7 profiles: [ndnd] init: true volumes: @@ -92,9 +92,9 @@ services: driver: local ndnd-http-status-server: - image: ndnd-dv2:integration-62021f4 + image: ndnd-dv2:integration-a991047 build: - context: https://github.com/markverick/ndnd.git#62021f4eb5a630d677fa909e93e5a07babf1ad48 + context: https://github.com/markverick/ndnd.git#a9910477b5943781428773f2e2cd0dec755224e7 profiles: [ndnd] init: true volumes: From 8ddecc7c45a8ead9ef4fa475ce71309be99385c2 Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Tue, 20 Oct 2026 00:28:06 -0700 Subject: [PATCH 20/52] Run Go CA for NDNd alongside C++ CA --- .gitignore | 3 +- config.yml | 6 ++ docker-compose.yml | 48 ++++++++++++++++ framework/ndnd_ca_bootstrap.py | 99 +++++++++++++++++++++++++++++++++ templates/ndnd-go-ca/ca.json.j2 | 16 ++++++ 5 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 framework/ndnd_ca_bootstrap.py create mode 100644 templates/ndnd-go-ca/ca.json.j2 diff --git a/.gitignore b/.gitignore index de5742c..81f4748 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ __pycache__/ dist/ secrets.yml .env -root-ca-home/ \ No newline at end of file +root-ca-home/ +ndnd-root-ca-home/ \ No newline at end of file diff --git a/config.yml b/config.yml index b92fb99..a6bfbf5 100644 --- a/config.yml +++ b/config.yml @@ -23,6 +23,12 @@ services: profile: ndnd pass: on + ndnd-go-ca: + hosts: [UCLA] + profile: ndnd-go-ca + template_path: templates/ndnd-go-ca + render_path: dist/ndnd-go-ca + caddy: template_path: templates/caddy render_path: dist/caddy diff --git a/docker-compose.yml b/docker-compose.yml index c1516e8..66cae04 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -111,6 +111,54 @@ services: logging: driver: local + ndnd-go-ca-bootstrap: + image: ghcr.io/named-data/testbed-master:20261012 + profiles: [ndnd-go-ca] + init: true + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - ${PWD}/framework/ndnd_ca_bootstrap.py:/app/ndnd_ca_bootstrap.py:ro + - ${PWD}/dist/ndnd-go-ca/ca.json:/config/ca.json:ro + - ${PWD}/ndnd-root-ca-home:/ca + - ${PWD}/dist/file-server/ndnd:/public + environment: + NDND_CA_IMAGE: ndnd-dv2:integration-a991047 + NDND_CA_HOST_DIR: ${PWD}/ndnd-root-ca-home + NDND_ROOT_CERT_URL: https://suns.cs.ucla.edu/file-server/ndnd/ndnd-root.ndncert + entrypoint: [python3] + command: [/app/ndnd_ca_bootstrap.py] + network_mode: none + restart: "no" + depends_on: + master: { condition: service_healthy } + ndnd: { condition: service_healthy } + logging: + driver: local + + ndnd-go-ca: + image: ndnd-dv2:integration-a991047 + build: + context: https://github.com/markverick/ndnd.git#a9910477b5943781428773f2e2cd0dec755224e7 + profiles: [ndnd-go-ca] + init: true + volumes: + - /run/ndnd:/run/ndnd:ro + - ${PWD}/ndnd-root-ca-home:/ca:ro + - ${PWD}/dist/ndnd-go-ca/ca.json:/config/ca.json:ro + environment: + NDN_CLIENT_TRANSPORT: unix:///run/ndnd/ndnd.sock + NDND_SMTP_PASSWORD: ${VAR_SMTP_PASSWORD:-} + command: [sec, certca, /config/ca.json, /ca/ca.cert.pem, /ca/ca.key.pem] + read_only: true + cap_drop: [ALL] + security_opt: [no-new-privileges:true] + restart: unless-stopped + depends_on: + ndnd: { condition: service_healthy } + ndnd-go-ca-bootstrap: { condition: service_completed_successfully } + logging: + driver: local + nfd: image: ghcr.io/named-data/nfd:20250420 init: true diff --git a/framework/ndnd_ca_bootstrap.py b/framework/ndnd_ca_bootstrap.py new file mode 100644 index 0000000..a611972 --- /dev/null +++ b/framework/ndnd_ca_bootstrap.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python3 +"""Create and publish the persistent Go NDNd root CA identity.""" + +import hashlib +import json +import os +import subprocess +import tempfile +from pathlib import Path + +from ndn.app_support.security_v2 import parse_certificate +from ndn.encoding import Name + + +CA_HOME = Path("/ca") +PUBLIC_DIR = Path("/public") +CA_CONFIG = Path("/config/ca.json") +CA_IMAGE = os.environ["NDND_CA_IMAGE"] +CA_HOME_HOST = os.environ["NDND_CA_HOST_DIR"] +ROOT_CERT_URL = os.environ["NDND_ROOT_CERT_URL"] + + +def run_ndnd(args: list[str], input_data: bytes | None = None, mount_ca: bool = False) -> bytes: + command = ["docker", "run", "--rm"] + if input_data is not None: + command.append("-i") + if mount_ca: + command.extend(["-v", f"{CA_HOME_HOST}:/ca:ro"]) + command.extend([CA_IMAGE, *args]) + result = subprocess.run(command, input=input_data, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if result.returncode != 0: + raise RuntimeError(result.stderr.decode(errors="replace").strip() or "NDNd CLI failed") + return result.stdout + + +def atomic_write(path: Path, data: bytes, mode: int) -> None: + path.parent.mkdir(parents=True, exist_ok=True) + descriptor, temporary = tempfile.mkstemp(dir=path.parent, prefix=f".{path.name}.") + try: + os.fchmod(descriptor, mode) + with os.fdopen(descriptor, "wb") as stream: + stream.write(data) + stream.flush() + os.fsync(stream.fileno()) + os.replace(temporary, path) + finally: + if os.path.exists(temporary): + os.unlink(temporary) + + +def main() -> None: + CA_HOME.mkdir(mode=0o700, parents=True, exist_ok=True) + key_path = CA_HOME / "ca.key.pem" + cert_path = CA_HOME / "ca.cert.pem" + + if not key_path.exists() and not cert_path.exists(): + key = run_ndnd(["sec", "keygen", "/ndn/edu", "ed25519"]) + atomic_write(key_path, key, 0o600) + elif not key_path.exists(): + raise RuntimeError("CA certificate exists without its private key; refusing to rotate the root") + + if not cert_path.exists(): + cert = run_ndnd(["sec", "sign-cert", "/ca/ca.key.pem"], key_path.read_bytes(), mount_ca=True) + atomic_write(cert_path, cert, 0o644) + + cert_wire = run_ndnd(["sec", "pem-decode"], cert_path.read_bytes()) + cert = parse_certificate(cert_wire) + with CA_CONFIG.open() as stream: + config = json.load(stream) + + ca_prefix = Name.normalize(config["ca-prefix"]) + if cert.name[:len(ca_prefix)] != ca_prefix: + raise RuntimeError("CA certificate identity is outside configured CA prefix") + + cert_name = Name.to_str(cert.name) + cert_digest = hashlib.sha256(cert_wire).hexdigest() + atomic_write(PUBLIC_DIR / "ndnd-root.ndncert", cert_wire, 0o644) + + profile = { + "schema_version": 1, + "ca_prefix": config["ca-prefix"], + "ca_info": config.get("ca-info", ""), + "max_validity_period_seconds": int(config["max-validity-period"]), + "probe_parameters": [], + "supported_challenges": [item["challenge"] for item in config["supported-challenges"]], + "root_certificate_url": ROOT_CERT_URL, + "root_certificate_name": cert_name, + "root_certificate_sha256": cert_digest, + } + atomic_write( + PUBLIC_DIR / "ndnd-ca-profile.json", + (json.dumps(profile, indent=2) + "\n").encode(), + 0o644, + ) + print(f"Prepared Go CA identity {cert_name}") + + +if __name__ == "__main__": + main() diff --git a/templates/ndnd-go-ca/ca.json.j2 b/templates/ndnd-go-ca/ca.json.j2 new file mode 100644 index 0000000..20dd61f --- /dev/null +++ b/templates/ndnd-go-ca/ca.json.j2 @@ -0,0 +1,16 @@ +{ + "ca-prefix": {{ ndnd_dv_network | tojson }}, + "ca-info": "NDNd Testbed Go CA", + "max-validity-period": "7776000", + "supported-challenges": [ + { "challenge": "email" } + ], + "email": { + "smtp-server": {{ SMTP_SERVER | tojson }}, + "smtp-port": 587, + "smtp-username": {{ SMTP_USER | tojson }}, + "smtp-password-env": "NDND_SMTP_PASSWORD", + "from": "NDN Certificate Robot ", + "subject": "Your NDNCERT verification code" + } +} From 7a09dd21d600b412708535a89d42cde699c8f46f Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Tue, 20 Oct 2026 03:53:28 -0700 Subject: [PATCH 21/52] Isolate NDNd identities and renewal signer --- anchors/ndnd-go-root.base64 | 1 + config.yml | 22 +++- docker-compose.yml | 56 +++++------ framework/http-ca-server.py | 76 ++++++++++++-- framework/ndnd_ca_bootstrap.py | 112 ++++++++++++++------- host_vars/ARIZONA | 1 + host_vars/MEMPHIS | 1 + host_vars/UCLA | 1 + scripts/cert-renew.sh | 8 +- scripts/cron-master.sh | 3 + scripts/master.sh | 3 + scripts/ndnd-infra-security.py | 82 ++++++++++----- templates/caddy/Caddyfile.j2 | 8 ++ templates/ndnd-dv/dv-schema.lvs.j2 | 6 +- templates/ndnd-dv/dv.yml.j2 | 6 +- templates/ndnd-dv/renew.sh.j2 | 22 +++- templates/ndnd-go-ca/ca.json.j2 | 6 +- templates/ndnd-go-ca/http-ca-server.yml.j2 | 19 ++++ templates/ndnd/yanfd.yml.j2 | 2 +- 19 files changed, 315 insertions(+), 120 deletions(-) create mode 100644 anchors/ndnd-go-root.base64 create mode 100644 templates/ndnd-go-ca/http-ca-server.yml.j2 diff --git a/anchors/ndnd-go-root.base64 b/anchors/ndnd-go-root.base64 new file mode 100644 index 0000000..2e12a12 --- /dev/null +++ b/anchors/ndnd-go-root.base64 @@ -0,0 +1 @@ +BugHIwgEbmRuZAgDS0VZCAiErVznAwK56QgCTkE2CAAAAaFYpS5aFAkYAQIZBAA27oAVLDAqMAUGAytlcAMhAOi1L42QxRzGB/yMvduMM19dM3ukSmyubURXLZG9RvY1FkYbAQUcFwcVCARuZG5kCANLRVkICIStXOcDArnp/QD9Jv0A/g8yMDI2MTAyMFQwOTI5NDL9AP8PMjAyNzEwMjBUMDkyOTQyF0Aj+qOlJSdFN9wGXmnobfYLUmjqNikwnydWB6qUAmp1EGZN5d3q8kcQ5By/6B44uzeVau5TksFdwRZKoB7HtxwE \ No newline at end of file diff --git a/config.yml b/config.yml index a6bfbf5..9c78104 100644 --- a/config.yml +++ b/config.yml @@ -16,7 +16,7 @@ services: enabled_by: ndnd_enabled profile: ndnd template_path: templates/ndnd-dv - render_path: dist/ndnd-dv + render_path: dist/ndnd-dv-independent ndnd-http-status-server: enabled_by: ndnd_enabled @@ -29,6 +29,12 @@ services: template_path: templates/ndnd-go-ca render_path: dist/ndnd-go-ca + ndnd-root-http-ca: + hosts: [UCLA] + profile: ndnd-go-ca + template_path: templates/ndnd-go-ca + render_path: dist/ndnd-go-ca + caddy: template_path: templates/caddy render_path: dist/caddy @@ -98,7 +104,18 @@ globals: ndnd_repo_anchors: - anchors/ndn-testbed-root.ndncert.2204.base64 ndnd_udp_port: 6364 - ndnd_dv_network: /ndn/edu + ndnd_dv_network: /ndnd + ndnd_ca_host: UCLA + ndnd_ca_image: ndnd-dv2:integration-a991047 + ndnd_ca_info: "NDNd Testbed Go CA" + ndnd_ca_max_validity_period: "7776000" + ndnd_ca_supported_challenges: [email] + ndnd_root_certificate_url: https://suns.cs.ucla.edu/file-server/ndnd/ndnd-root.ndncert + ndnd_root_certificate_sha256: c020b0ddf2c82dcbdbb8339bc63d8a63d8fece4be41d3f69097cd3185dd47889 + ndnd_root_http_ca_url: https://suns.cs.ucla.edu/ndnd-ca + ndnd_root_anchor_path: anchors/ndnd-go-root.base64 + ndnd_trust_schema_url: https://suns.cs.ucla.edu/file-server/ndnd/dv-schema.tlv + ndnd_root_http_ca_internal_url: http://ndnd-root-http-ca:8777 # Declare variables available for each host # You can use lint.py to check variables, their types and @@ -128,3 +145,4 @@ variables: is_root_ca: "?boolean" is_status_page: "?boolean" ndnd_enabled: "?boolean" + ndnd_router_prefix: "?string" diff --git a/docker-compose.yml b/docker-compose.yml index 66cae04..f796504 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -75,9 +75,9 @@ services: init: true volumes: - /run/ndnd:/run/ndnd:ro - - ${PWD}/dist/ndnd-dv/dv.yml:/config/dv.yml:ro - - ${PWD}/dist/ndnd-dv/dv-schema.tlv:/config/dv-schema.tlv:ro - - ${PWD}/dist/ndnd-dv/keys:/config/keys + - ${PWD}/dist/ndnd-dv-independent/dv.yml:/config/dv.yml:ro + - ${PWD}/dist/ndnd-dv-independent/dv-schema.tlv:/config/dv-schema.tlv:ro + - ${PWD}/dist/ndnd-dv-independent/keys:/config/keys environment: NDN_CLIENT_TRANSPORT: unix:///run/ndnd/ndnd.sock command: [dv, run, /config/dv.yml] @@ -111,30 +111,6 @@ services: logging: driver: local - ndnd-go-ca-bootstrap: - image: ghcr.io/named-data/testbed-master:20261012 - profiles: [ndnd-go-ca] - init: true - volumes: - - /var/run/docker.sock:/var/run/docker.sock - - ${PWD}/framework/ndnd_ca_bootstrap.py:/app/ndnd_ca_bootstrap.py:ro - - ${PWD}/dist/ndnd-go-ca/ca.json:/config/ca.json:ro - - ${PWD}/ndnd-root-ca-home:/ca - - ${PWD}/dist/file-server/ndnd:/public - environment: - NDND_CA_IMAGE: ndnd-dv2:integration-a991047 - NDND_CA_HOST_DIR: ${PWD}/ndnd-root-ca-home - NDND_ROOT_CERT_URL: https://suns.cs.ucla.edu/file-server/ndnd/ndnd-root.ndncert - entrypoint: [python3] - command: [/app/ndnd_ca_bootstrap.py] - network_mode: none - restart: "no" - depends_on: - master: { condition: service_healthy } - ndnd: { condition: service_healthy } - logging: - driver: local - ndnd-go-ca: image: ndnd-dv2:integration-a991047 build: @@ -143,7 +119,7 @@ services: init: true volumes: - /run/ndnd:/run/ndnd:ro - - ${PWD}/ndnd-root-ca-home:/ca:ro + - ${PWD}/ndnd-root-ca-home/ndnd:/ca:ro - ${PWD}/dist/ndnd-go-ca/ca.json:/config/ca.json:ro environment: NDN_CLIENT_TRANSPORT: unix:///run/ndnd/ndnd.sock @@ -155,7 +131,29 @@ services: restart: unless-stopped depends_on: ndnd: { condition: service_healthy } - ndnd-go-ca-bootstrap: { condition: service_completed_successfully } + logging: + driver: local + + ndnd-root-http-ca: + image: ghcr.io/named-data/testbed-master:20261012 + profiles: [ndnd-go-ca] + init: true + tty: true + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - ${PWD}/framework/http-ca-server.py:/app/http-ca-server.py:ro + - ${PWD}/dist/ndnd-go-ca/http-ca-server.yml:/config/http-ca-server.yml:ro + environment: + NDND_ROOT_CA_SECRET: ${VAR_NDND_ROOT_CA_SECRET:?VAR_NDND_ROOT_CA_SECRET must be set} + NDND_CA_IMAGE: ndnd-dv2:integration-a991047 + NDND_CA_HOST_DIR: ${PWD}/ndnd-root-ca-home/ndnd + entrypoint: [python3, /app/http-ca-server.py] + command: [/config/http-ca-server.yml] + restart: unless-stopped + healthcheck: + test: [CMD-SHELL, "python3 -c \"import urllib.request; urllib.request.urlopen('http://127.0.0.1:8777/health', timeout=2).read()\""] + interval: 1m + start_period: 5s logging: driver: local diff --git a/framework/http-ca-server.py b/framework/http-ca-server.py index 05545d9..7f75a96 100755 --- a/framework/http-ca-server.py +++ b/framework/http-ca-server.py @@ -7,6 +7,7 @@ import subprocess import ndn import ipaddress +import os from datetime import datetime, timedelta from urllib.parse import parse_qs @@ -19,10 +20,33 @@ class Config: secret: str hosts: dict[str, dict] port: int + signer_backend: str = 'ndnsec' + ndnd_ca_image: str = '' + ndnd_ca_host_dir: str = '' config: Config = None + +def is_ndnd_csr_name(prefix: str, name: list[bytes]) -> bool: + prefix_name = ndn.encoding.Name.normalize(prefix) + if len(name) != len(prefix_name) + 4 or name[:len(prefix_name)] != prefix_name: + return False + component = ndn.encoding.Component + return (name[len(prefix_name)] == component.from_str('KEY') + and name[len(prefix_name) + 2] == component.from_str('self') + and component.get_type(name[-1]) == component.TYPE_VERSION) + + class MyHTTPRequestHandler(BaseHTTPRequestHandler): + def do_GET(self): + if self.path == '/health': + self.send_response(200) + self.send_header('Content-Type', 'text/plain; charset=utf-8') + self.end_headers() + self.wfile.write(b'ok\n') + return + self.send_error(404) + def which_host_ip(self, address: str) -> dict|None: for _, host in config.hosts.items(): for subnet in host['subnets']: @@ -52,7 +76,9 @@ def sign(self, path: str, query: str, data: bytes) -> None: # Validate prefix of the CSR pfx = host['prefix'] name = ndn.encoding.ndn_format_0_3.parse_data(base64.b64decode(data))[0] - if not ndn.encoding.name.Name.is_prefix(pfx, name): + valid_name = (is_ndnd_csr_name(pfx, name) if config.signer_backend == 'ndnd-go' + else ndn.encoding.name.Name.is_prefix(pfx, name)) + if not valid_name: str_name = ndn.encoding.name.Name.to_str(name) self.send_error(400, f"Invalid name {str_name}, expected prefix {pfx}") return @@ -63,7 +89,6 @@ def sign(self, path: str, query: str, data: bytes) -> None: self.send_error(400, "Both validity bounds must be provided once") return - command = ['ndnsec', 'cert-gen', '-s', config.global_prefix] if not_before: try: start = datetime.strptime(not_before[0], '%Y%m%d%H%M%S') @@ -74,11 +99,41 @@ def sign(self, path: str, query: str, data: bytes) -> None: if end <= start or end - start > timedelta(days=90): self.send_error(400, "Certificate validity must be positive and no longer than 90 days") return - command.extend(['-S', not_before[0], '-E', not_after[0]]) - command.append('-') - # Sign a certificate for the name. - proc = subprocess.run(command, input=data, capture_output=True) + if config.signer_backend == 'ndnd-go': + if not config.ndnd_ca_image or not config.ndnd_ca_host_dir: + self.send_error(500, "NDNd Go signer is not configured") + return + try: + csr_wire = base64.b64decode(b''.join(data.split()), validate=True) + except ValueError: + self.send_error(400, "Invalid base64 CSR") + return + csr_pem = (b'-----BEGIN NDN CERT-----\n' + base64.encodebytes(csr_wire) + + b'-----END NDN CERT-----\n') + command = ['docker', 'run', '--rm', '-i', '-v', + f'{config.ndnd_ca_host_dir}:/ca:ro', config.ndnd_ca_image, + 'sec', 'sign-cert', '/ca/ca.key.pem'] + if not_before: + command.extend(['--start', not_before[0], '--end', not_after[0]]) + proc = subprocess.run(command, input=csr_pem, capture_output=True, timeout=30) + if proc.returncode == 0: + decoded = subprocess.run( + ['docker', 'run', '--rm', '-i', config.ndnd_ca_image, 'sec', 'pem-decode'], + input=proc.stdout, capture_output=True, timeout=30) + if decoded.returncode != 0: + proc = decoded + else: + proc.stdout = base64.encodebytes(decoded.stdout) + elif config.signer_backend == 'ndnsec': + command = ['ndnsec', 'cert-gen', '-s', config.global_prefix] + if not_before: + command.extend(['-S', not_before[0], '-E', not_after[0]]) + command.append('-') + proc = subprocess.run(command, input=data, capture_output=True, timeout=30) + else: + self.send_error(500, "Unsupported signer backend") + return if proc.returncode != 0: self.send_error(500, f"Failed to sign certificate: {proc.stderr}") @@ -138,7 +193,14 @@ def log_request(self, code='-', size='-') -> None: if __name__ == '__main__': # Read YAML config with open(sys.argv[1], 'r') as f: - config = Config(**yaml.safe_load(f)) + config_data = yaml.safe_load(f) + if os.environ.get('NDND_ROOT_CA_SECRET'): + config_data['secret'] = os.environ['NDND_ROOT_CA_SECRET'] + config_data['ndnd_ca_image'] = os.environ.get('NDND_CA_IMAGE', config_data.get('ndnd_ca_image', '')) + config_data['ndnd_ca_host_dir'] = os.environ.get('NDND_CA_HOST_DIR', config_data.get('ndnd_ca_host_dir', '')) + if not config_data.get('secret'): + raise RuntimeError('HTTP CA secret must be configured') + config = Config(**config_data) # Start server server_address = ('', config.port) diff --git a/framework/ndnd_ca_bootstrap.py b/framework/ndnd_ca_bootstrap.py index a611972..1f0adec 100644 --- a/framework/ndnd_ca_bootstrap.py +++ b/framework/ndnd_ca_bootstrap.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 """Create and publish the persistent Go NDNd root CA identity.""" +import base64 import hashlib import json import os @@ -8,31 +9,45 @@ import tempfile from pathlib import Path +import yaml +from Cryptodome.PublicKey import ECC, RSA from ndn.app_support.security_v2 import parse_certificate -from ndn.encoding import Name +from ndn.encoding import Component, ContentType, Name, SignatureType, parse_data +from ndn.security.validator import verify_ecdsa, verify_ed25519, verify_rsa -CA_HOME = Path("/ca") -PUBLIC_DIR = Path("/public") -CA_CONFIG = Path("/config/ca.json") -CA_IMAGE = os.environ["NDND_CA_IMAGE"] -CA_HOME_HOST = os.environ["NDND_CA_HOST_DIR"] -ROOT_CERT_URL = os.environ["NDND_ROOT_CERT_URL"] - - -def run_ndnd(args: list[str], input_data: bytes | None = None, mount_ca: bool = False) -> bytes: +def run_ndnd(image: str, ca_home_host: Path, args: list[str], input_data: bytes | None = None, + mount_ca: bool = False) -> bytes: command = ["docker", "run", "--rm"] if input_data is not None: command.append("-i") if mount_ca: - command.extend(["-v", f"{CA_HOME_HOST}:/ca:ro"]) - command.extend([CA_IMAGE, *args]) + command.extend(["-v", f"{ca_home_host}:/ca:ro"]) + command.extend([image, *args]) result = subprocess.run(command, input=input_data, stdout=subprocess.PIPE, stderr=subprocess.PIPE) if result.returncode != 0: raise RuntimeError(result.stderr.decode(errors="replace").strip() or "NDNd CLI failed") return result.stdout +def verify_self_signed_root(wire: bytes) -> bool: + cert = parse_certificate(wire) + if cert.meta_info.content_type != ContentType.KEY: + return False + locator = cert.signature_info.key_locator + if locator is None or Name.to_bytes(locator.name) not in ( + Name.to_bytes(cert.name[:-2]), Name.to_bytes(cert.name)): + return False + _, _, _, pointers = parse_data(wire) + if cert.signature_info.signature_type == SignatureType.SHA256_WITH_ECDSA: + return verify_ecdsa(ECC.import_key(bytes(cert.content)), pointers) + if cert.signature_info.signature_type == SignatureType.SHA256_WITH_RSA: + return verify_rsa(RSA.import_key(bytes(cert.content)), pointers) + if cert.signature_info.signature_type == SignatureType.ED25519: + return verify_ed25519(ECC.import_key(bytes(cert.content)), pointers) + return False + + def atomic_write(path: Path, data: bytes, mode: int) -> None: path.parent.mkdir(parents=True, exist_ok=True) descriptor, temporary = tempfile.mkstemp(dir=path.parent, prefix=f".{path.name}.") @@ -49,49 +64,70 @@ def atomic_write(path: Path, data: bytes, mode: int) -> None: def main() -> None: - CA_HOME.mkdir(mode=0o700, parents=True, exist_ok=True) - key_path = CA_HOME / "ca.key.pem" - cert_path = CA_HOME / "ca.cert.pem" + project_dir = Path(__file__).resolve().parent.parent + with (project_dir / "config.yml").open() as stream: + config = yaml.safe_load(stream) + values = config["globals"] + if os.environ.get("MANAGED_HOST") != values["ndnd_ca_host"]: + return + + host_root = Path(os.environ.get("ROOT_DIR", str(project_dir))) + ca_home = project_dir / "ndnd-root-ca-home" / "ndnd" + ca_home_host = host_root / "ndnd-root-ca-home" / "ndnd" + public_dir = project_dir / "dist/file-server/ndnd" + anchor_path = project_dir / values["ndnd_root_anchor_path"] + ca_home.mkdir(mode=0o700, parents=True, exist_ok=True) + ca_home.chmod(0o700) + key_path = ca_home / "ca.key.pem" + cert_path = ca_home / "ca.cert.pem" + image = values["ndnd_ca_image"] + ca_prefix = Name.normalize(values["ndnd_dv_network"]) if not key_path.exists() and not cert_path.exists(): - key = run_ndnd(["sec", "keygen", "/ndn/edu", "ed25519"]) - atomic_write(key_path, key, 0o600) + atomic_write(key_path, run_ndnd(image, ca_home_host, ["sec", "keygen", "/ndnd", "ed25519"]), 0o600) elif not key_path.exists(): - raise RuntimeError("CA certificate exists without its private key; refusing to rotate the root") + raise RuntimeError("NDNd CA certificate exists without its private key; refusing to rotate the root") if not cert_path.exists(): - cert = run_ndnd(["sec", "sign-cert", "/ca/ca.key.pem"], key_path.read_bytes(), mount_ca=True) + cert = run_ndnd(image, ca_home_host, ["sec", "sign-cert", "/ca/ca.key.pem"], + key_path.read_bytes(), mount_ca=True) atomic_write(cert_path, cert, 0o644) - cert_wire = run_ndnd(["sec", "pem-decode"], cert_path.read_bytes()) + cert_wire = run_ndnd(image, ca_home_host, ["sec", "pem-decode"], cert_path.read_bytes()) + pinned_root = base64.b64decode("".join(anchor_path.read_text().split()), validate=True) + if cert_wire != pinned_root: + raise RuntimeError("NDNd CA certificate does not match the committed /ndnd trust anchor") cert = parse_certificate(cert_wire) - with CA_CONFIG.open() as stream: - config = json.load(stream) - - ca_prefix = Name.normalize(config["ca-prefix"]) - if cert.name[:len(ca_prefix)] != ca_prefix: - raise RuntimeError("CA certificate identity is outside configured CA prefix") + root_identity = cert.name[:-4] + if Name.to_bytes(root_identity) != Name.to_bytes(ca_prefix): + raise RuntimeError(f"NDNd CA cert identity must be {values['ndnd_dv_network']}, got {Name.to_str(root_identity)}") + if not verify_self_signed_root(cert_wire): + raise RuntimeError("NDNd CA certificate is not validly self-signed") cert_name = Name.to_str(cert.name) cert_digest = hashlib.sha256(cert_wire).hexdigest() - atomic_write(PUBLIC_DIR / "ndnd-root.ndncert", cert_wire, 0o644) - + if cert_digest != values["ndnd_root_certificate_sha256"]: + raise RuntimeError("NDNd CA certificate does not match the pinned testbed fingerprint") + previous_cert = public_dir / "ndnd-root-previous.ndncert" + published_cert = public_dir / "ndnd-root.ndncert" + if published_cert.exists() and published_cert.read_bytes() != cert_wire: + atomic_write(previous_cert, published_cert.read_bytes(), 0o644) + atomic_write(published_cert, cert_wire, 0o644) profile = { "schema_version": 1, - "ca_prefix": config["ca-prefix"], - "ca_info": config.get("ca-info", ""), - "max_validity_period_seconds": int(config["max-validity-period"]), + "ca_prefix": values["ndnd_dv_network"], + "ca_info": values["ndnd_ca_info"], + "max_validity_period_seconds": int(values["ndnd_ca_max_validity_period"]), "probe_parameters": [], - "supported_challenges": [item["challenge"] for item in config["supported-challenges"]], - "root_certificate_url": ROOT_CERT_URL, + "supported_challenges": values["ndnd_ca_supported_challenges"], + "router_identity_suffix": "/32=DV", + "root_certificate_url": values["ndnd_root_certificate_url"], "root_certificate_name": cert_name, "root_certificate_sha256": cert_digest, + "bootstrap_csr_signing_endpoint": values["ndnd_root_http_ca_url"] + "/sign", + "trust_schema_url": values["ndnd_trust_schema_url"], } - atomic_write( - PUBLIC_DIR / "ndnd-ca-profile.json", - (json.dumps(profile, indent=2) + "\n").encode(), - 0o644, - ) + atomic_write(public_dir / "ndnd-ca-profile.json", (json.dumps(profile, indent=2) + "\n").encode(), 0o644) print(f"Prepared Go CA identity {cert_name}") diff --git a/host_vars/ARIZONA b/host_vars/ARIZONA index f6022da..5f7c2b6 100644 --- a/host_vars/ARIZONA +++ b/host_vars/ARIZONA @@ -36,3 +36,4 @@ hr_angle: 2.97033 hr_radius: 16.2305 ethernet_device: eth0 ndnd_enabled: true +ndnd_router_prefix: /ndnd/arizona diff --git a/host_vars/MEMPHIS b/host_vars/MEMPHIS index ea46b45..2b7adc6 100644 --- a/host_vars/MEMPHIS +++ b/host_vars/MEMPHIS @@ -31,3 +31,4 @@ hr_angle: 2.9836 hr_radius: 15.2647 ethernet_device: eth1 ndnd_enabled: true +ndnd_router_prefix: /ndnd/memphis diff --git a/host_vars/UCLA b/host_vars/UCLA index f05dfed..a0fe14a 100644 --- a/host_vars/UCLA +++ b/host_vars/UCLA @@ -45,3 +45,4 @@ hr_radius: 16.5866 ethernet_device: eth0 is_root_ca: true ndnd_enabled: true +ndnd_router_prefix: /ndnd/ucla diff --git a/scripts/cert-renew.sh b/scripts/cert-renew.sh index e9c6fa3..735c769 100644 --- a/scripts/cert-renew.sh +++ b/scripts/cert-renew.sh @@ -22,7 +22,13 @@ bash "$(pwd)/dist/ndnd-repo/renew.sh" ${FORCE:+"${FORCE}"} || exit $? DV_ENABLED=$(python3 framework/service-profiles.py --service ndnd-dv) || exit $? if [[ "${DV_ENABLED}" == 1 ]]; then - DV_DIR=dist/ndnd-dv + NDND_SIGNER_ENABLED=$(python3 framework/service-profiles.py --service ndnd-root-http-ca) || exit $? + if [[ "${NDND_SIGNER_ENABLED}" == 1 ]]; then + COMPOSE_PROFILES=$(python3 framework/service-profiles.py) || exit $? + export COMPOSE_PROFILES + PWD="${ROOT_DIR:-$PWD}" docker compose up -d --no-deps --wait --wait-timeout 30 ndnd-root-http-ca || exit $? + fi + DV_DIR=dist/ndnd-dv-independent bash "${DV_DIR}/renew.sh" ${FORCE:+"${FORCE}"} || exit $? if [[ -f "${DV_DIR}/.security-changed" ]]; then RUNNING_DV=$(PWD="${ROOT_DIR:-$PWD}" docker compose ps --status running -q ndnd-dv) || exit $? diff --git a/scripts/cron-master.sh b/scripts/cron-master.sh index 5baef03..82b6a61 100755 --- a/scripts/cron-master.sh +++ b/scripts/cron-master.sh @@ -23,6 +23,9 @@ fi rm -f .git/index.lock git pull +# Bootstrap and verify the dedicated NDNd CA root before rendering DV trust. +python3 framework/ndnd_ca_bootstrap.py || exit $? + # Render new service templates before certificate provisioning on an existing node. PWD="${ROOT_DIR}" python3 framework/main.py || exit $? diff --git a/scripts/master.sh b/scripts/master.sh index 815e3df..4b7f8da 100755 --- a/scripts/master.sh +++ b/scripts/master.sh @@ -19,6 +19,9 @@ if [[ -z "$DEBUG" ]]; then git config --global --add safe.directory /testbed git pull + # Bootstrap and verify the dedicated NDNd CA root before rendering DV trust. + python3 framework/ndnd_ca_bootstrap.py + # Bootstrap all configuration files python3 framework/main.py --dry diff --git a/scripts/ndnd-infra-security.py b/scripts/ndnd-infra-security.py index c169634..5d5a8b2 100644 --- a/scripts/ndnd-infra-security.py +++ b/scripts/ndnd-infra-security.py @@ -20,7 +20,7 @@ from ndn.app_support.security_v2 import new_cert, parse_certificate from ndn.encoding import Component, ContentType, MetaInfo, Name, SignatureType, make_data, parse_data from ndn.security import Sha256WithEcdsaSigner -from ndn.security.validator import verify_ecdsa, verify_rsa +from ndn.security.validator import verify_ecdsa, verify_ed25519, verify_rsa def decode_certificate(path): @@ -96,6 +96,8 @@ def verify_certificate(wire, issuer): return verify_ecdsa(ECC.import_key(bytes(parent.content)), pointers) if signature_type == SignatureType.SHA256_WITH_RSA: return verify_rsa(RSA.import_key(bytes(parent.content)), pointers) + if signature_type == SignatureType.ED25519: + return verify_ed25519(ECC.import_key(bytes(parent.content)), pointers) return False @@ -127,15 +129,16 @@ def get_key(directory, identity): def provision(directory, site_home, site_prefix, anchors_path, force=False, renew_before_days=30, - service='repo', root_ca_url=''): + service='repo', root_ca_url='', root_cert_path=None): # Serialize overlapping cron/manual renewal runs without rotating the key. with (directory / '.security.lock').open('a') as lock: fcntl.flock(lock, fcntl.LOCK_EX) return provision_locked(directory, site_home, site_prefix, anchors_path, force, renew_before_days, - service, root_ca_url) + service, root_ca_url, root_cert_path) -def provision_locked(directory, site_home, site_prefix, anchors_path, force, renew_before_days, service, root_ca_url): +def provision_locked(directory, site_home, site_prefix, anchors_path, force, renew_before_days, + service, root_ca_url, root_cert_path): if service not in ('repo', 'merkle', 'dv'): raise ValueError('Unsupported NDNd service') if service == 'merkle' and site_prefix != '/ndn/edu/ucla': @@ -145,8 +148,10 @@ def provision_locked(directory, site_home, site_prefix, anchors_path, force, ren if service == 'dv': identity = Name.normalize(config['router'] + '/32=DV') expected_identity = Name.normalize(site_prefix + '/32=DV') - if not root_ca_url or not os.environ.get('ROOT_CA_SECRET'): - raise ValueError('DV credential provisioning requires the root CA URL and ROOT_CA_SECRET') + if not root_ca_url or not os.environ.get('NDND_ROOT_CA_SECRET'): + raise ValueError('DV credential provisioning requires the NDNd root CA URL and NDND_ROOT_CA_SECRET') + if root_cert_path is None: + raise ValueError('DV credential provisioning requires the NDNd root certificate path') else: identity = Name.normalize(config['name']) expected_identity = Name.normalize(site_prefix + '/ndnd/' + service) @@ -154,23 +159,40 @@ def provision_locked(directory, site_home, site_prefix, anchors_path, force, ren raise ValueError(f'Invalid {service} identity {Name.to_str(identity)}') now = datetime.now(timezone.utc) - site_wire = decode_certificate(site_home / 'site.ndncert') - site = parse_certificate(site_wire) - if Name.to_bytes(site.name[:-4]) != Name.to_bytes(Name.normalize(site_prefix)): - raise ValueError('Site certificate has the wrong identity') - available = {} - for path in anchors_path.glob('*.base64'): - wire = decode_certificate(path) - available[Name.to_str(parse_certificate(wire).name)] = wire - anchor_wires = [available[name] for name in config['trust_anchors']] - if not anchor_wires: - raise ValueError('At least one pinned trust anchor is required') - issuer = next((wire for wire in anchor_wires if verify_certificate(site_wire, wire)), None) - if issuer is None: - raise ValueError('Site certificate does not verify against a pinned testbed root') - signing_issuer = issuer if service == 'dv' else site_wire - site_before, site_after = validity(site_wire) - root_before, root_after = validity(issuer) + if service == 'dv': + issuer = decode_certificate(root_cert_path) + root = parse_certificate(issuer) + root_identity = root.name[:-4] + expected_root = Name.normalize('/ndnd') + if Name.to_bytes(root_identity) != Name.to_bytes(expected_root): + raise ValueError(f'NDNd CA certificate identity must be /ndnd, got {Name.to_str(root_identity)}') + if Name.to_str(root.name) not in config.get('trust_anchors', []): + raise ValueError('DV configuration does not trust the configured NDNd root certificate') + if not verify_certificate(issuer, issuer): + raise ValueError('NDNd root certificate is not self-signed by its own key') + anchor_wires = [issuer] + signing_issuer = issuer + root_before, root_after = validity(issuer) + site_before = root_before + site_after = root_after + else: + site_wire = decode_certificate(site_home / 'site.ndncert') + site = parse_certificate(site_wire) + if Name.to_bytes(site.name[:-4]) != Name.to_bytes(Name.normalize(site_prefix)): + raise ValueError('Site certificate has the wrong identity') + available = {} + for path in anchors_path.glob('*.base64'): + wire = decode_certificate(path) + available[Name.to_str(parse_certificate(wire).name)] = wire + anchor_wires = [available[name] for name in config['trust_anchors']] + if not anchor_wires: + raise ValueError('At least one pinned trust anchor is required') + issuer = next((wire for wire in anchor_wires if verify_certificate(site_wire, wire)), None) + if issuer is None: + raise ValueError('Site certificate does not verify against a pinned testbed root') + signing_issuer = site_wire + site_before, site_after = validity(site_wire) + root_before, root_after = validity(issuer) # ndn-cxx rounds NotBefore up to a whole second when issuing a certificate. # Wait for that boundary rather than accepting a certificate before it is valid. starts = max(site_before, root_before) @@ -201,13 +223,15 @@ def provision_locked(directory, site_home, site_prefix, anchors_path, force, ren if renew: before = max(now - timedelta(minutes=5), site_before, root_before).replace(microsecond=0) after = min(now + timedelta(days=90), site_after, root_after).replace(microsecond=0) + if service == 'dv': + after = min(after, before + timedelta(days=90)) if after <= now + margin: raise ValueError('Renew the site/root certificate before issuing a service certificate') signer = Sha256WithEcdsaSigner(key_name, key.export_key(format='DER', use_pkcs8=False)) _, csr = new_cert(key_name, Component.from_str('self'), key.public_key().export_key(format='DER'), signer, before, after) if service == 'dv': - cert_wire = sign_with_root_ca(csr, root_ca_url, os.environ['ROOT_CA_SECRET'], before, after) + cert_wire = sign_with_root_ca(csr, root_ca_url, os.environ['NDND_ROOT_CA_SECRET'], before, after) else: command = ['ndnsec', 'cert-gen', '-s', site_prefix, '-S', before.strftime('%Y%m%d%H%M%S'), '-E', after.strftime('%Y%m%d%H%M%S'), '-'] @@ -224,7 +248,10 @@ def provision_locked(directory, site_home, site_prefix, anchors_path, force, ren # Prepare every credential before marking it for a service reload. changed = import_packet(keys, key_wire, 'KEY') - for wire in [*anchor_wires, site_wire, cert_wire]: + certificates = [*anchor_wires, cert_wire] + if service != 'dv': + certificates.insert(len(anchor_wires), site_wire) + for wire in certificates: changed |= import_packet(keys, wire, 'CERT') changed |= write_atomic(cert_path, base64.encodebytes(cert_wire)) if changed: @@ -236,12 +263,13 @@ def provision_locked(directory, site_home, site_prefix, anchors_path, force, ren if __name__ == '__main__': parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('--directory', type=Path, required=True) - parser.add_argument('--site-home', type=Path, required=True) + parser.add_argument('--site-home', type=Path) parser.add_argument('--site-prefix', required=True) parser.add_argument('--anchors', type=Path, required=True) parser.add_argument('--service', choices=('repo', 'merkle', 'dv'), default='repo') parser.add_argument('--root-ca-url', default='') + parser.add_argument('--root-cert', type=Path) parser.add_argument('--force', action='store_true') args = parser.parse_args() provision(args.directory, args.site_home, args.site_prefix, args.anchors, args.force, - service=args.service, root_ca_url=args.root_ca_url) + service=args.service, root_ca_url=args.root_ca_url, root_cert_path=args.root_cert) diff --git a/templates/caddy/Caddyfile.j2 b/templates/caddy/Caddyfile.j2 index 2c1997a..b05dc27 100644 --- a/templates/caddy/Caddyfile.j2 +++ b/templates/caddy/Caddyfile.j2 @@ -14,6 +14,14 @@ @ws path /ws /ws/* reverse_proxy @ws http://nfd:9696 + {% if inventory_hostname == ndnd_ca_host %} + handle_path /ndnd-ca/* { + reverse_proxy http://ndnd-root-http-ca:8777 { + header_up X-Forwarded-For {remote_host} + } + } + {% endif %} + root * /srv file_server diff --git a/templates/ndnd-dv/dv-schema.lvs.j2 b/templates/ndnd-dv/dv-schema.lvs.j2 index 669738f..1dc0dbd 100644 --- a/templates/ndnd-dv/dv-schema.lvs.j2 +++ b/templates/ndnd-dv/dv-schema.lvs.j2 @@ -1,13 +1,13 @@ -// All NDNd routers use the shared /ndn/edu DV network. The testbed root +// All NDNd routers use the shared /ndnd DV network. The testbed root // directly issues each site router's /32=DV certificate. #KEY: "KEY"/_/_/_ #network: {{ ndn_lvs_name(ndnd_dv_network) }} -#network_cert: {{ ndn_lvs_name(ndnNetwork) }}/#KEY +#network_cert: {{ ndn_lvs_name(ndnd_dv_network) }}/#KEY #prefix_state: #network/"32=DV"/"32=PSD" {% for host, values in hostvars.items() %} {% if values.get('ndnd_enabled', false) %} -{% set router = ndn_lvs_name(values.default_prefix) %} +{% set router = ndn_lvs_name(values.ndnd_router_prefix) %} #router_{{ loop.index }}: {{ router }} #router_cert_{{ loop.index }}: #router_{{ loop.index }}/"32=DV"/#KEY <= #network_cert #advertisement_data_{{ loop.index }}: /"localhop"/#router_{{ loop.index }}/"32=DV"/"32=ADV"/_ <= #router_cert_{{ loop.index }} diff --git a/templates/ndnd-dv/dv.yml.j2 b/templates/ndnd-dv/dv.yml.j2 index ff25552..b2d6226 100644 --- a/templates/ndnd-dv/dv.yml.j2 +++ b/templates/ndnd-dv/dv.yml.j2 @@ -1,11 +1,9 @@ dv: network: {{ ndnd_dv_network | tojson }} - router: {{ default_prefix | tojson }} + router: {{ ndnd_router_prefix | tojson }} keychain: dir:///config/keys trust_anchors: - {% for anchor in ndnd_repo_anchors %} - - {{ ndn_cert_name(read_file(anchor)) | tojson }} - {% endfor %} + - {{ ndn_cert_name(read_file(ndnd_root_anchor_path)) | tojson }} trust_schema: dv-schema.tlv neighbors: {% set peers = namespace(count=0) %} diff --git a/templates/ndnd-dv/renew.sh.j2 b/templates/ndnd-dv/renew.sh.j2 index 2fcc6f3..932ea16 100644 --- a/templates/ndnd-dv/renew.sh.j2 +++ b/templates/ndnd-dv/renew.sh.j2 @@ -4,13 +4,25 @@ set -eu REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" TESTBED_DIR="$(cd "${REPO_DIR}/../.." && pwd)" -ROOT_CA_SECRET={{ ROOT_CA_SECRET | tojson }} -export ROOT_CA_SECRET +source "${TESTBED_DIR}/.env" +NDND_ROOT_CA_SECRET="${VAR_NDND_ROOT_CA_SECRET:?Set VAR_NDND_ROOT_CA_SECRET in .env}" +export NDND_ROOT_CA_SECRET +{% if inventory_hostname == ndnd_ca_host %} +NDND_ROOT_HTTP_CA_URL={{ ndnd_root_http_ca_internal_url | tojson }} +{% else %} +NDND_ROOT_HTTP_CA_URL={{ ndnd_root_http_ca_url | tojson }} +{% endif %} + +if ! curl -fsS --max-time 5 "${NDND_ROOT_HTTP_CA_URL}/health" >/dev/null; then + echo "NDNd root signer is not ready; deferring DV renewal to the next cron run" >&2 + exit 0 +fi python3 "${TESTBED_DIR}/scripts/ndnd-infra-security.py" \ --directory "${REPO_DIR}" \ - --site-home "${TESTBED_DIR}/dist/ndncert" \ - --site-prefix {{ default_prefix | tojson }} \ + --site-home "${TESTBED_DIR}/dist/ndnd-dv-independent" \ + --site-prefix {{ ndnd_router_prefix | tojson }} \ --anchors "${TESTBED_DIR}/anchors" \ --service dv \ - --root-ca-url {{ root_ca_https | tojson }} "$@" \ No newline at end of file + --root-ca-url "${NDND_ROOT_HTTP_CA_URL}" \ + --root-cert "${TESTBED_DIR}/{{ ndnd_root_anchor_path }}" "$@" \ No newline at end of file diff --git a/templates/ndnd-go-ca/ca.json.j2 b/templates/ndnd-go-ca/ca.json.j2 index 20dd61f..1f717ee 100644 --- a/templates/ndnd-go-ca/ca.json.j2 +++ b/templates/ndnd-go-ca/ca.json.j2 @@ -1,9 +1,9 @@ { "ca-prefix": {{ ndnd_dv_network | tojson }}, - "ca-info": "NDNd Testbed Go CA", - "max-validity-period": "7776000", + "ca-info": {{ ndnd_ca_info | tojson }}, + "max-validity-period": {{ ndnd_ca_max_validity_period | tojson }}, "supported-challenges": [ - { "challenge": "email" } + {% for challenge in ndnd_ca_supported_challenges %}{ "challenge": {{ challenge | tojson }} }{% if not loop.last %},{% endif %}{% endfor %} ], "email": { "smtp-server": {{ SMTP_SERVER | tojson }}, diff --git a/templates/ndnd-go-ca/http-ca-server.yml.j2 b/templates/ndnd-go-ca/http-ca-server.yml.j2 new file mode 100644 index 0000000..0ed8b40 --- /dev/null +++ b/templates/ndnd-go-ca/http-ca-server.yml.j2 @@ -0,0 +1,19 @@ +global_prefix: {{ ndnd_dv_network | tojson }} +port: 8777 +secret: "" +signer_backend: ndnd-go +ndnd_ca_image: {{ ndnd_ca_image | tojson }} + +hosts: + {% for host, values in hostvars.items() %} + {% if values.get('ndnd_enabled', false) %} + {{ host }}: + subnets: + - {{ values.host_ip }}/32 + {% if host == ndnd_ca_host %} + - 172.16.0.0/12 + - 192.168.0.0/16 + {% endif %} + prefix: {{ (values.ndnd_router_prefix + '/32=DV') | tojson }} + {% endif %} + {% endfor %} \ No newline at end of file diff --git a/templates/ndnd/yanfd.yml.j2 b/templates/ndnd/yanfd.yml.j2 index 4033543..88fe71c 100644 --- a/templates/ndnd/yanfd.yml.j2 +++ b/templates/ndnd/yanfd.yml.j2 @@ -17,4 +17,4 @@ faces: enabled: false fw: - router_name: {{ default_prefix | tojson }} \ No newline at end of file + router_name: {{ ndnd_router_prefix | tojson }} \ No newline at end of file From 5d3dd424f126c63ba5941be088363e365a2df3f0 Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Tue, 20 Oct 2026 05:46:18 -0700 Subject: [PATCH 22/52] Run NDNd Go CA with deployed root and site policy --- config.yml | 17 ++++++-- docker-compose.yml | 46 ++++++++++++++++------ framework/http-ca-server.py | 15 +++++-- framework/ndnd_ca_bootstrap.py | 4 +- host_vars/ARIZONA | 1 + host_vars/MEMPHIS | 1 + host_vars/UCLA | 1 + scripts/cert-renew.sh | 12 ++++++ scripts/ndnd-infra-security.py | 43 ++++++++++++++------ templates/ndnd-go-ca/ca.json.j2 | 24 +++++++++++ templates/ndnd-go-ca/http-ca-server.yml.j2 | 4 ++ templates/ndnd-site-ca/ca.json.j2 | 19 +++++++++ templates/ndnd-site-ca/renew.sh.j2 | 28 +++++++++++++ 13 files changed, 183 insertions(+), 32 deletions(-) create mode 100644 templates/ndnd-site-ca/ca.json.j2 create mode 100644 templates/ndnd-site-ca/renew.sh.j2 diff --git a/config.yml b/config.yml index 9c78104..7d0c3a8 100644 --- a/config.yml +++ b/config.yml @@ -24,16 +24,22 @@ services: pass: on ndnd-go-ca: + enabled_by: ndnd_enabled + profile: ndnd-go-ca + template_path: templates/ndnd-site-ca + render_path: dist/ndnd-site-ca + + ndnd-go-root-ca: hosts: [UCLA] profile: ndnd-go-ca template_path: templates/ndnd-go-ca - render_path: dist/ndnd-go-ca + render_path: dist/ndnd-go-root-ca ndnd-root-http-ca: hosts: [UCLA] profile: ndnd-go-ca template_path: templates/ndnd-go-ca - render_path: dist/ndnd-go-ca + render_path: dist/ndnd-go-root-ca caddy: template_path: templates/caddy @@ -106,10 +112,12 @@ globals: ndnd_udp_port: 6364 ndnd_dv_network: /ndnd ndnd_ca_host: UCLA - ndnd_ca_image: ndnd-dv2:integration-a991047 + ndnd_ca_image: ndnd-dv2:integration-a1d6546 ndnd_ca_info: "NDNd Testbed Go CA" ndnd_ca_max_validity_period: "7776000" - ndnd_ca_supported_challenges: [email] + ndnd_ca_max_suffix_length: "5" + ndnd_ca_supported_challenges: [email, dns] + ndnd_site_ca_supported_challenges: [email] ndnd_root_certificate_url: https://suns.cs.ucla.edu/file-server/ndnd/ndnd-root.ndncert ndnd_root_certificate_sha256: c020b0ddf2c82dcbdbb8339bc63d8a63d8fece4be41d3f69097cd3185dd47889 ndnd_root_http_ca_url: https://suns.cs.ucla.edu/ndnd-ca @@ -139,6 +147,7 @@ variables: memsize: number neighbors: dict position: list + ndnd_ca_prefix: "?string" hr_angle: number hr_radius: number ethernet_device: string diff --git a/docker-compose.yml b/docker-compose.yml index f796504..7d0acd6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,9 +44,9 @@ services: driver: local ndnd: - image: ndnd-dv2:integration-a991047 + image: ndnd-dv2:integration-a1d6546 build: - context: https://github.com/markverick/ndnd.git#a9910477b5943781428773f2e2cd0dec755224e7 + context: https://github.com/markverick/ndnd.git#a1d6546b10aa700b3fab340ad82015dc19556b4d profiles: [ndnd] init: true volumes: @@ -68,9 +68,9 @@ services: driver: local ndnd-dv: - image: ndnd-dv2:integration-a991047 + image: ndnd-dv2:integration-a1d6546 build: - context: https://github.com/markverick/ndnd.git#a9910477b5943781428773f2e2cd0dec755224e7 + context: https://github.com/markverick/ndnd.git#a1d6546b10aa700b3fab340ad82015dc19556b4d profiles: [ndnd] init: true volumes: @@ -92,9 +92,9 @@ services: driver: local ndnd-http-status-server: - image: ndnd-dv2:integration-a991047 + image: ndnd-dv2:integration-a1d6546 build: - context: https://github.com/markverick/ndnd.git#a9910477b5943781428773f2e2cd0dec755224e7 + context: https://github.com/markverick/ndnd.git#a1d6546b10aa700b3fab340ad82015dc19556b4d profiles: [ndnd] init: true volumes: @@ -112,15 +112,38 @@ services: driver: local ndnd-go-ca: - image: ndnd-dv2:integration-a991047 + image: ndnd-dv2:integration-a1d6546 build: - context: https://github.com/markverick/ndnd.git#a9910477b5943781428773f2e2cd0dec755224e7 + context: https://github.com/markverick/ndnd.git#a1d6546b10aa700b3fab340ad82015dc19556b4d + profiles: [ndnd-go-ca] + init: true + volumes: + - /run/ndnd:/run/ndnd:ro + - ${PWD}/dist/ndnd-site-ca-independent:/ca:ro + - ${PWD}/dist/ndnd-site-ca/ca.json:/config/ca.json:ro + environment: + NDN_CLIENT_TRANSPORT: unix:///run/ndnd/ndnd.sock + NDND_SMTP_PASSWORD: ${VAR_SMTP_PASSWORD:-} + command: [sec, certca, /config/ca.json, /ca/ca.cert.pem, /ca/ca.key.pem] + read_only: true + cap_drop: [ALL] + security_opt: [no-new-privileges:true] + restart: unless-stopped + depends_on: + ndnd: { condition: service_healthy } + logging: + driver: local + + ndnd-go-root-ca: + image: ndnd-dv2:integration-a1d6546 + build: + context: https://github.com/markverick/ndnd.git#a1d6546b10aa700b3fab340ad82015dc19556b4d profiles: [ndnd-go-ca] init: true volumes: - /run/ndnd:/run/ndnd:ro - ${PWD}/ndnd-root-ca-home/ndnd:/ca:ro - - ${PWD}/dist/ndnd-go-ca/ca.json:/config/ca.json:ro + - ${PWD}/dist/ndnd-go-root-ca/ca.json:/config/ca.json:ro environment: NDN_CLIENT_TRANSPORT: unix:///run/ndnd/ndnd.sock NDND_SMTP_PASSWORD: ${VAR_SMTP_PASSWORD:-} @@ -142,10 +165,11 @@ services: volumes: - /var/run/docker.sock:/var/run/docker.sock - ${PWD}/framework/http-ca-server.py:/app/http-ca-server.py:ro - - ${PWD}/dist/ndnd-go-ca/http-ca-server.yml:/config/http-ca-server.yml:ro + - ${PWD}/dist/ndnd-go-root-ca/http-ca-server.yml:/config/http-ca-server.yml:ro + - ${PWD}/dist/ndnd-go-root-ca/cert-store:/config/cert-store environment: NDND_ROOT_CA_SECRET: ${VAR_NDND_ROOT_CA_SECRET:?VAR_NDND_ROOT_CA_SECRET must be set} - NDND_CA_IMAGE: ndnd-dv2:integration-a991047 + NDND_CA_IMAGE: ndnd-dv2:integration-a1d6546 NDND_CA_HOST_DIR: ${PWD}/ndnd-root-ca-home/ndnd entrypoint: [python3, /app/http-ca-server.py] command: [/config/http-ca-server.yml] diff --git a/framework/http-ca-server.py b/framework/http-ca-server.py index 7f75a96..832c49c 100755 --- a/framework/http-ca-server.py +++ b/framework/http-ca-server.py @@ -76,8 +76,13 @@ def sign(self, path: str, query: str, data: bytes) -> None: # Validate prefix of the CSR pfx = host['prefix'] name = ndn.encoding.ndn_format_0_3.parse_data(base64.b64decode(data))[0] - valid_name = (is_ndnd_csr_name(pfx, name) if config.signer_backend == 'ndnd-go' - else ndn.encoding.name.Name.is_prefix(pfx, name)) + if config.signer_backend == 'ndnd-go': + valid_name = is_ndnd_csr_name(pfx, name) + ca_prefix = host.get('ca_prefix') + if ca_prefix: + valid_name |= is_ndnd_csr_name(ca_prefix, name) + else: + valid_name = ndn.encoding.name.Name.is_prefix(pfx, name) if not valid_name: str_name = ndn.encoding.name.Name.to_str(name) self.send_error(400, f"Invalid name {str_name}, expected prefix {pfx}") @@ -152,8 +157,10 @@ def sign(self, path: str, query: str, data: bytes) -> None: # This cache is consumed as the host's site certificate, not as a # general log of every descendant certificate signed for that host. identity = ndn.encoding.name.Name.to_str(cert_name[:-4]) if len(cert_name) >= 4 else '' - path = host.get('cert_file') - if path and identity == pfx: + ca_prefix = host.get('ca_prefix') + path = host.get('ca_cert_file') if ca_prefix and identity == ca_prefix else host.get('cert_file') + expected_identity = ca_prefix if ca_prefix and identity == ca_prefix else pfx + if path and identity == expected_identity: with open(path, 'wb') as f: f.write(certificate) diff --git a/framework/ndnd_ca_bootstrap.py b/framework/ndnd_ca_bootstrap.py index 1f0adec..0263a65 100644 --- a/framework/ndnd_ca_bootstrap.py +++ b/framework/ndnd_ca_bootstrap.py @@ -118,7 +118,9 @@ def main() -> None: "ca_prefix": values["ndnd_dv_network"], "ca_info": values["ndnd_ca_info"], "max_validity_period_seconds": int(values["ndnd_ca_max_validity_period"]), - "probe_parameters": [], + "probe_parameters": ["email"], + "name_assignment": {"email": "/nonexist"}, + "max_suffix_length": int(values["ndnd_ca_max_suffix_length"]), "supported_challenges": values["ndnd_ca_supported_challenges"], "router_identity_suffix": "/32=DV", "root_certificate_url": values["ndnd_root_certificate_url"], diff --git a/host_vars/ARIZONA b/host_vars/ARIZONA index 5f7c2b6..02328f2 100644 --- a/host_vars/ARIZONA +++ b/host_vars/ARIZONA @@ -32,6 +32,7 @@ neighbors: position: - 32.2289614 - -110.9483226 +ndnd_ca_prefix: /ndnd/arizona hr_angle: 2.97033 hr_radius: 16.2305 ethernet_device: eth0 diff --git a/host_vars/MEMPHIS b/host_vars/MEMPHIS index 2b7adc6..ef6b891 100644 --- a/host_vars/MEMPHIS +++ b/host_vars/MEMPHIS @@ -27,6 +27,7 @@ neighbors: position: - 35.1186099 - -89.93700109999999 +ndnd_ca_prefix: /ndnd/memphis hr_angle: 2.9836 hr_radius: 15.2647 ethernet_device: eth1 diff --git a/host_vars/UCLA b/host_vars/UCLA index a0fe14a..eb15d68 100644 --- a/host_vars/UCLA +++ b/host_vars/UCLA @@ -40,6 +40,7 @@ neighbors: position: - 34.0728225 - -118.4387398 +ndnd_ca_prefix: /ndnd/ucla hr_angle: 2.99911 hr_radius: 16.5866 ethernet_device: eth0 diff --git a/scripts/cert-renew.sh b/scripts/cert-renew.sh index 735c769..f9518f3 100644 --- a/scripts/cert-renew.sh +++ b/scripts/cert-renew.sh @@ -28,6 +28,18 @@ if [[ "${DV_ENABLED}" == 1 ]]; then export COMPOSE_PROFILES PWD="${ROOT_DIR:-$PWD}" docker compose up -d --no-deps --wait --wait-timeout 30 ndnd-root-http-ca || exit $? fi + SITE_CA_ENABLED=$(python3 framework/service-profiles.py --service ndnd-go-ca) || exit $? + if [[ "${SITE_CA_ENABLED}" == 1 ]]; then + SITE_CA_DIR=dist/ndnd-site-ca-independent + bash "${PWD}/${SITE_CA_DIR}/renew.sh" ${FORCE:+"${FORCE}"} || exit $? + if [[ -f "${SITE_CA_DIR}/.security-changed" ]]; then + RUNNING_CA=$(PWD="${ROOT_DIR:-$PWD}" docker compose ps --status running -q ndnd-go-ca) || exit $? + if [[ -n "${RUNNING_CA}" ]]; then + PWD="${ROOT_DIR:-$PWD}" docker compose restart ndnd-go-ca || exit $? + fi + rm -f "${SITE_CA_DIR}/.security-changed" + fi + fi DV_DIR=dist/ndnd-dv-independent bash "${DV_DIR}/renew.sh" ${FORCE:+"${FORCE}"} || exit $? if [[ -f "${DV_DIR}/.security-changed" ]]; then diff --git a/scripts/ndnd-infra-security.py b/scripts/ndnd-infra-security.py index 5d5a8b2..2027923 100644 --- a/scripts/ndnd-infra-security.py +++ b/scripts/ndnd-infra-security.py @@ -129,22 +129,27 @@ def get_key(directory, identity): def provision(directory, site_home, site_prefix, anchors_path, force=False, renew_before_days=30, - service='repo', root_ca_url='', root_cert_path=None): + service='repo', root_ca_url='', root_cert_path=None, identity=None): # Serialize overlapping cron/manual renewal runs without rotating the key. + directory.mkdir(mode=0o700, parents=True, exist_ok=True) + directory.chmod(0o700) with (directory / '.security.lock').open('a') as lock: fcntl.flock(lock, fcntl.LOCK_EX) return provision_locked(directory, site_home, site_prefix, anchors_path, force, renew_before_days, - service, root_ca_url, root_cert_path) + service, root_ca_url, root_cert_path, identity) def provision_locked(directory, site_home, site_prefix, anchors_path, force, renew_before_days, - service, root_ca_url, root_cert_path): - if service not in ('repo', 'merkle', 'dv'): + service, root_ca_url, root_cert_path, identity): + if service not in ('repo', 'merkle', 'dv', 'ca'): raise ValueError('Unsupported NDNd service') if service == 'merkle' and site_prefix != '/ndn/edu/ucla': raise ValueError('Merkle log provisioning is restricted to UCLA') - with (directory / f'{service}.yml').open() as stream: - config = yaml.safe_load(stream)[service] + if service == 'ca': + config = {} + else: + with (directory / f'{service}.yml').open() as stream: + config = yaml.safe_load(stream)[service] if service == 'dv': identity = Name.normalize(config['router'] + '/32=DV') expected_identity = Name.normalize(site_prefix + '/32=DV') @@ -152,6 +157,15 @@ def provision_locked(directory, site_home, site_prefix, anchors_path, force, ren raise ValueError('DV credential provisioning requires the NDNd root CA URL and NDND_ROOT_CA_SECRET') if root_cert_path is None: raise ValueError('DV credential provisioning requires the NDNd root certificate path') + elif service == 'ca': + if not identity: + raise ValueError('Site CA provisioning requires an explicit identity') + identity = Name.normalize(identity) + expected_identity = Name.normalize(site_prefix) + if not root_ca_url or not os.environ.get('NDND_ROOT_CA_SECRET'): + raise ValueError('Site CA provisioning requires the NDNd root CA URL and NDND_ROOT_CA_SECRET') + if root_cert_path is None: + raise ValueError('Site CA provisioning requires the NDNd root certificate path') else: identity = Name.normalize(config['name']) expected_identity = Name.normalize(site_prefix + '/ndnd/' + service) @@ -159,14 +173,14 @@ def provision_locked(directory, site_home, site_prefix, anchors_path, force, ren raise ValueError(f'Invalid {service} identity {Name.to_str(identity)}') now = datetime.now(timezone.utc) - if service == 'dv': + if service in ('dv', 'ca'): issuer = decode_certificate(root_cert_path) root = parse_certificate(issuer) root_identity = root.name[:-4] expected_root = Name.normalize('/ndnd') if Name.to_bytes(root_identity) != Name.to_bytes(expected_root): raise ValueError(f'NDNd CA certificate identity must be /ndnd, got {Name.to_str(root_identity)}') - if Name.to_str(root.name) not in config.get('trust_anchors', []): + if service == 'dv' and Name.to_str(root.name) not in config.get('trust_anchors', []): raise ValueError('DV configuration does not trust the configured NDNd root certificate') if not verify_certificate(issuer, issuer): raise ValueError('NDNd root certificate is not self-signed by its own key') @@ -230,7 +244,7 @@ def provision_locked(directory, site_home, site_prefix, anchors_path, force, ren signer = Sha256WithEcdsaSigner(key_name, key.export_key(format='DER', use_pkcs8=False)) _, csr = new_cert(key_name, Component.from_str('self'), key.public_key().export_key(format='DER'), signer, before, after) - if service == 'dv': + if service in ('dv', 'ca'): cert_wire = sign_with_root_ca(csr, root_ca_url, os.environ['NDND_ROOT_CA_SECRET'], before, after) else: command = ['ndnsec', 'cert-gen', '-s', site_prefix, @@ -249,11 +263,14 @@ def provision_locked(directory, site_home, site_prefix, anchors_path, force, ren # Prepare every credential before marking it for a service reload. changed = import_packet(keys, key_wire, 'KEY') certificates = [*anchor_wires, cert_wire] - if service != 'dv': + if service not in ('dv', 'ca'): certificates.insert(len(anchor_wires), site_wire) for wire in certificates: changed |= import_packet(keys, wire, 'CERT') changed |= write_atomic(cert_path, base64.encodebytes(cert_wire)) + if service == 'ca': + changed |= write_atomic(directory / 'ca.cert.pem', pem(cert_wire, 'CERT')) + changed |= write_atomic(directory / 'ca.key.pem', pem(key_wire, 'KEY')) if changed: write_atomic(directory / '.security-changed', b'\n') print(f"NDNd {service} {Name.to_str(identity)}: {'credentials updated' if changed else 'credentials current'}") @@ -266,10 +283,12 @@ def provision_locked(directory, site_home, site_prefix, anchors_path, force, ren parser.add_argument('--site-home', type=Path) parser.add_argument('--site-prefix', required=True) parser.add_argument('--anchors', type=Path, required=True) - parser.add_argument('--service', choices=('repo', 'merkle', 'dv'), default='repo') + parser.add_argument('--service', choices=('repo', 'merkle', 'dv', 'ca'), default='repo') + parser.add_argument('--identity') parser.add_argument('--root-ca-url', default='') parser.add_argument('--root-cert', type=Path) parser.add_argument('--force', action='store_true') args = parser.parse_args() provision(args.directory, args.site_home, args.site_prefix, args.anchors, args.force, - service=args.service, root_ca_url=args.root_ca_url, root_cert_path=args.root_cert) + service=args.service, root_ca_url=args.root_ca_url, root_cert_path=args.root_cert, + identity=args.identity) diff --git a/templates/ndnd-go-ca/ca.json.j2 b/templates/ndnd-go-ca/ca.json.j2 index 1f717ee..186b2b1 100644 --- a/templates/ndnd-go-ca/ca.json.j2 +++ b/templates/ndnd-go-ca/ca.json.j2 @@ -2,6 +2,30 @@ "ca-prefix": {{ ndnd_dv_network | tojson }}, "ca-info": {{ ndnd_ca_info | tojson }}, "max-validity-period": {{ ndnd_ca_max_validity_period | tojson }}, + "max-suffix-length": {{ ndnd_ca_max_suffix_length | tojson }}, + "probe-parameters": [{ "probe-parameter-key": "email" }], + "name-assignment": { "email": "/nonexist" }, + "redirect-to": [ + {% set redirects = namespace(comma=false) %} + {% for host, values in hostvars.items() %} + {% if values.get('ndnd_enabled', false) %} + {% set cert_path = "./dist/ndnd-go-root-ca/cert-store/site-ca." + host + ".ndncert" %} + {% if path_exists(cert_path) %} + {% set cert_oneline = oneline(read_file(cert_path)) %} + {% for email_domain in values.site_email_domain %} + {% if redirects.comma %},{% endif %} + { + "ca-prefix": {{ values.ndnd_ca_prefix | tojson }}, + "certificate": {{ cert_oneline | tojson }}, + "policy-type": "email", + "policy-param": {{ email_domain | tojson }} + } + {% set redirects.comma = true %} + {% endfor %} + {% endif %} + {% endif %} + {% endfor %} + ], "supported-challenges": [ {% for challenge in ndnd_ca_supported_challenges %}{ "challenge": {{ challenge | tojson }} }{% if not loop.last %},{% endif %}{% endfor %} ], diff --git a/templates/ndnd-go-ca/http-ca-server.yml.j2 b/templates/ndnd-go-ca/http-ca-server.yml.j2 index 0ed8b40..a38d2a2 100644 --- a/templates/ndnd-go-ca/http-ca-server.yml.j2 +++ b/templates/ndnd-go-ca/http-ca-server.yml.j2 @@ -3,6 +3,7 @@ port: 8777 secret: "" signer_backend: ndnd-go ndnd_ca_image: {{ ndnd_ca_image | tojson }} +ndnd_ca_host_dir: {{ ("./ndnd-root-ca-home/ndnd") | tojson }} hosts: {% for host, values in hostvars.items() %} @@ -15,5 +16,8 @@ hosts: - 192.168.0.0/16 {% endif %} prefix: {{ (values.ndnd_router_prefix + '/32=DV') | tojson }} + ca_prefix: {{ values.ndnd_ca_prefix | tojson }} + ca_cert_file: /config/cert-store/site-ca.{{ host }}.ndncert + cert_file: /config/cert-store/router-dv.{{ host }}.ndncert {% endif %} {% endfor %} \ No newline at end of file diff --git a/templates/ndnd-site-ca/ca.json.j2 b/templates/ndnd-site-ca/ca.json.j2 new file mode 100644 index 0000000..b1037d6 --- /dev/null +++ b/templates/ndnd-site-ca/ca.json.j2 @@ -0,0 +1,19 @@ +{ + "ca-prefix": {{ ndnd_ca_prefix | tojson }}, + "ca-info": {{ ("NDN Testbed NDNCERT Site CA for " + inventory_hostname) | tojson }}, + "max-validity-period": {{ ndnd_ca_max_validity_period | tojson }}, + "max-suffix-length": {{ ndnd_ca_max_suffix_length | tojson }}, + "probe-parameters": [{ "probe-parameter-key": "email" }], + "name-assignment": { "email": {{ site | tojson }} }, + "supported-challenges": [ + {% for challenge in ndnd_site_ca_supported_challenges %}{ "challenge": {{ challenge | tojson }} }{% if not loop.last %},{% endif %}{% endfor %} + ], + "email": { + "smtp-server": {{ SMTP_SERVER | tojson }}, + "smtp-port": 587, + "smtp-username": {{ SMTP_USER | tojson }}, + "smtp-password-env": "NDND_SMTP_PASSWORD", + "from": "NDN Certificate Robot ", + "subject": "Your NDNCERT verification code" + } +} \ No newline at end of file diff --git a/templates/ndnd-site-ca/renew.sh.j2 b/templates/ndnd-site-ca/renew.sh.j2 new file mode 100644 index 0000000..9389bea --- /dev/null +++ b/templates/ndnd-site-ca/renew.sh.j2 @@ -0,0 +1,28 @@ +#!/bin/bash + +set -eu + +REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +TESTBED_DIR="$(cd "${REPO_DIR}/../.." && pwd)" +source "${TESTBED_DIR}/.env" +NDND_ROOT_CA_SECRET="${VAR_NDND_ROOT_CA_SECRET:?Set VAR_NDND_ROOT_CA_SECRET in .env}" +export NDND_ROOT_CA_SECRET +{% if inventory_hostname == ndnd_ca_host %} +NDND_ROOT_HTTP_CA_URL={{ ndnd_root_http_ca_internal_url | tojson }} +{% else %} +NDND_ROOT_HTTP_CA_URL={{ ndnd_root_http_ca_url | tojson }} +{% endif %} + +if ! curl -fsS --max-time 5 "${NDND_ROOT_HTTP_CA_URL}/health" >/dev/null; then + echo "NDNd root signer is not ready; deferring site CA renewal to the next cron run" >&2 + exit 0 +fi + +python3 "${TESTBED_DIR}/scripts/ndnd-infra-security.py" \ + --directory "${TESTBED_DIR}/dist/ndnd-site-ca-independent" \ + --site-prefix {{ ndnd_ca_prefix | tojson }} \ + --identity {{ ndnd_ca_prefix | tojson }} \ + --anchors "${TESTBED_DIR}/anchors" \ + --service ca \ + --root-ca-url "${NDND_ROOT_HTTP_CA_URL}" \ + --root-cert "${TESTBED_DIR}/{{ ndnd_root_anchor_path }}" "$@" \ No newline at end of file From 4847af623599b9faff911f3c448fe437c0dd1fbe Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Tue, 20 Oct 2026 07:32:28 -0700 Subject: [PATCH 23/52] Mount Go CA rendered config directories --- config.yml | 6 +++--- docker-compose.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config.yml b/config.yml index 7d0c3a8..f46f3ce 100644 --- a/config.yml +++ b/config.yml @@ -27,19 +27,19 @@ services: enabled_by: ndnd_enabled profile: ndnd-go-ca template_path: templates/ndnd-site-ca - render_path: dist/ndnd-site-ca + render_path: dist/ndnd-site-ca-config ndnd-go-root-ca: hosts: [UCLA] profile: ndnd-go-ca template_path: templates/ndnd-go-ca - render_path: dist/ndnd-go-root-ca + render_path: dist/ndnd-go-root-config ndnd-root-http-ca: hosts: [UCLA] profile: ndnd-go-ca template_path: templates/ndnd-go-ca - render_path: dist/ndnd-go-root-ca + render_path: dist/ndnd-go-root-config caddy: template_path: templates/caddy diff --git a/docker-compose.yml b/docker-compose.yml index 7d0acd6..e80b320 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -120,7 +120,7 @@ services: volumes: - /run/ndnd:/run/ndnd:ro - ${PWD}/dist/ndnd-site-ca-independent:/ca:ro - - ${PWD}/dist/ndnd-site-ca/ca.json:/config/ca.json:ro + - ${PWD}/dist/ndnd-site-ca-config:/config:ro environment: NDN_CLIENT_TRANSPORT: unix:///run/ndnd/ndnd.sock NDND_SMTP_PASSWORD: ${VAR_SMTP_PASSWORD:-} @@ -143,7 +143,7 @@ services: volumes: - /run/ndnd:/run/ndnd:ro - ${PWD}/ndnd-root-ca-home/ndnd:/ca:ro - - ${PWD}/dist/ndnd-go-root-ca/ca.json:/config/ca.json:ro + - ${PWD}/dist/ndnd-go-root-config:/config:ro environment: NDN_CLIENT_TRANSPORT: unix:///run/ndnd/ndnd.sock NDND_SMTP_PASSWORD: ${VAR_SMTP_PASSWORD:-} @@ -165,7 +165,7 @@ services: volumes: - /var/run/docker.sock:/var/run/docker.sock - ${PWD}/framework/http-ca-server.py:/app/http-ca-server.py:ro - - ${PWD}/dist/ndnd-go-root-ca/http-ca-server.yml:/config/http-ca-server.yml:ro + - ${PWD}/dist/ndnd-go-root-config:/config:ro - ${PWD}/dist/ndnd-go-root-ca/cert-store:/config/cert-store environment: NDND_ROOT_CA_SECRET: ${VAR_NDND_ROOT_CA_SECRET:?VAR_NDND_ROOT_CA_SECRET must be set} From d993440834c0234fa28dcf6e8f6fbc24094dc930 Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Tue, 20 Oct 2026 07:39:11 -0700 Subject: [PATCH 24/52] Mount CA certificate cache outside config --- docker-compose.yml | 2 +- templates/ndnd-go-ca/http-ca-server.yml.j2 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index e80b320..e26316e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -166,7 +166,7 @@ services: - /var/run/docker.sock:/var/run/docker.sock - ${PWD}/framework/http-ca-server.py:/app/http-ca-server.py:ro - ${PWD}/dist/ndnd-go-root-config:/config:ro - - ${PWD}/dist/ndnd-go-root-ca/cert-store:/config/cert-store + - ${PWD}/dist/ndnd-go-root-ca/cert-store:/cert-store environment: NDND_ROOT_CA_SECRET: ${VAR_NDND_ROOT_CA_SECRET:?VAR_NDND_ROOT_CA_SECRET must be set} NDND_CA_IMAGE: ndnd-dv2:integration-a1d6546 diff --git a/templates/ndnd-go-ca/http-ca-server.yml.j2 b/templates/ndnd-go-ca/http-ca-server.yml.j2 index a38d2a2..9abfab0 100644 --- a/templates/ndnd-go-ca/http-ca-server.yml.j2 +++ b/templates/ndnd-go-ca/http-ca-server.yml.j2 @@ -17,7 +17,7 @@ hosts: {% endif %} prefix: {{ (values.ndnd_router_prefix + '/32=DV') | tojson }} ca_prefix: {{ values.ndnd_ca_prefix | tojson }} - ca_cert_file: /config/cert-store/site-ca.{{ host }}.ndncert - cert_file: /config/cert-store/router-dv.{{ host }}.ndncert + ca_cert_file: /cert-store/site-ca.{{ host }}.ndncert + cert_file: /cert-store/router-dv.{{ host }}.ndncert {% endif %} {% endfor %} \ No newline at end of file From f260ac39479eb0ce7fab26c2d858f103e0a2e072 Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Tue, 20 Oct 2026 07:44:27 -0700 Subject: [PATCH 25/52] Run site CA renewal from rendered config --- scripts/cert-renew.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/cert-renew.sh b/scripts/cert-renew.sh index f9518f3..78ecdd3 100644 --- a/scripts/cert-renew.sh +++ b/scripts/cert-renew.sh @@ -30,8 +30,9 @@ if [[ "${DV_ENABLED}" == 1 ]]; then fi SITE_CA_ENABLED=$(python3 framework/service-profiles.py --service ndnd-go-ca) || exit $? if [[ "${SITE_CA_ENABLED}" == 1 ]]; then + SITE_CA_CONFIG_DIR=dist/ndnd-site-ca-config SITE_CA_DIR=dist/ndnd-site-ca-independent - bash "${PWD}/${SITE_CA_DIR}/renew.sh" ${FORCE:+"${FORCE}"} || exit $? + bash "${PWD}/${SITE_CA_CONFIG_DIR}/renew.sh" ${FORCE:+"${FORCE}"} || exit $? if [[ -f "${SITE_CA_DIR}/.security-changed" ]]; then RUNNING_CA=$(PWD="${ROOT_DIR:-$PWD}" docker compose ps --status running -q ndnd-go-ca) || exit $? if [[ -n "${RUNNING_CA}" ]]; then From f1851014418ce004cddf91e21bc7f90f9929b203 Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Tue, 20 Oct 2026 07:48:15 -0700 Subject: [PATCH 26/52] Cap site CA validity at signer limit --- scripts/ndnd-infra-security.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ndnd-infra-security.py b/scripts/ndnd-infra-security.py index 2027923..a26d732 100644 --- a/scripts/ndnd-infra-security.py +++ b/scripts/ndnd-infra-security.py @@ -237,7 +237,7 @@ def provision_locked(directory, site_home, site_prefix, anchors_path, force, ren if renew: before = max(now - timedelta(minutes=5), site_before, root_before).replace(microsecond=0) after = min(now + timedelta(days=90), site_after, root_after).replace(microsecond=0) - if service == 'dv': + if service in ('dv', 'ca'): after = min(after, before + timedelta(days=90)) if after <= now + margin: raise ValueError('Renew the site/root certificate before issuing a service certificate') From 4b204174e830c1dd1f3a04765f9f42dc3475e0a0 Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Tue, 20 Oct 2026 08:05:47 -0700 Subject: [PATCH 27/52] Use NDNd image with SMTP trust roots --- config.yml | 2 +- docker-compose.yml | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/config.yml b/config.yml index f46f3ce..de9b777 100644 --- a/config.yml +++ b/config.yml @@ -112,7 +112,7 @@ globals: ndnd_udp_port: 6364 ndnd_dv_network: /ndnd ndnd_ca_host: UCLA - ndnd_ca_image: ndnd-dv2:integration-a1d6546 + ndnd_ca_image: ndnd-dv2:integration-763420d ndnd_ca_info: "NDNd Testbed Go CA" ndnd_ca_max_validity_period: "7776000" ndnd_ca_max_suffix_length: "5" diff --git a/docker-compose.yml b/docker-compose.yml index e26316e..cabbf56 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,9 +44,9 @@ services: driver: local ndnd: - image: ndnd-dv2:integration-a1d6546 + image: ndnd-dv2:integration-763420d build: - context: https://github.com/markverick/ndnd.git#a1d6546b10aa700b3fab340ad82015dc19556b4d + context: https://github.com/markverick/ndnd.git#763420dd4d11b860b97e0cd57169011f3dbfdef5 profiles: [ndnd] init: true volumes: @@ -68,9 +68,9 @@ services: driver: local ndnd-dv: - image: ndnd-dv2:integration-a1d6546 + image: ndnd-dv2:integration-763420d build: - context: https://github.com/markverick/ndnd.git#a1d6546b10aa700b3fab340ad82015dc19556b4d + context: https://github.com/markverick/ndnd.git#763420dd4d11b860b97e0cd57169011f3dbfdef5 profiles: [ndnd] init: true volumes: @@ -92,9 +92,9 @@ services: driver: local ndnd-http-status-server: - image: ndnd-dv2:integration-a1d6546 + image: ndnd-dv2:integration-763420d build: - context: https://github.com/markverick/ndnd.git#a1d6546b10aa700b3fab340ad82015dc19556b4d + context: https://github.com/markverick/ndnd.git#763420dd4d11b860b97e0cd57169011f3dbfdef5 profiles: [ndnd] init: true volumes: @@ -112,9 +112,9 @@ services: driver: local ndnd-go-ca: - image: ndnd-dv2:integration-a1d6546 + image: ndnd-dv2:integration-763420d build: - context: https://github.com/markverick/ndnd.git#a1d6546b10aa700b3fab340ad82015dc19556b4d + context: https://github.com/markverick/ndnd.git#763420dd4d11b860b97e0cd57169011f3dbfdef5 profiles: [ndnd-go-ca] init: true volumes: @@ -135,9 +135,9 @@ services: driver: local ndnd-go-root-ca: - image: ndnd-dv2:integration-a1d6546 + image: ndnd-dv2:integration-763420d build: - context: https://github.com/markverick/ndnd.git#a1d6546b10aa700b3fab340ad82015dc19556b4d + context: https://github.com/markverick/ndnd.git#763420dd4d11b860b97e0cd57169011f3dbfdef5 profiles: [ndnd-go-ca] init: true volumes: @@ -169,7 +169,7 @@ services: - ${PWD}/dist/ndnd-go-root-ca/cert-store:/cert-store environment: NDND_ROOT_CA_SECRET: ${VAR_NDND_ROOT_CA_SECRET:?VAR_NDND_ROOT_CA_SECRET must be set} - NDND_CA_IMAGE: ndnd-dv2:integration-a1d6546 + NDND_CA_IMAGE: ndnd-dv2:integration-763420d NDND_CA_HOST_DIR: ${PWD}/ndnd-root-ca-home/ndnd entrypoint: [python3, /app/http-ca-server.py] command: [/config/http-ca-server.yml] From a31b5b049a9760a8f30d6f1dad1d3d6ad274e2c4 Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Tue, 20 Oct 2026 12:45:08 -0700 Subject: [PATCH 28/52] Use NDNd testbed-staging image --- docker-compose.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index cabbf56..ac8b1a3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -169,7 +169,7 @@ services: - ${PWD}/dist/ndnd-go-root-ca/cert-store:/cert-store environment: NDND_ROOT_CA_SECRET: ${VAR_NDND_ROOT_CA_SECRET:?VAR_NDND_ROOT_CA_SECRET must be set} - NDND_CA_IMAGE: ndnd-dv2:integration-763420d + NDND_CA_IMAGE: ghcr.io/named-data/ndnd:testbed-staging NDND_CA_HOST_DIR: ${PWD}/ndnd-root-ca-home/ndnd entrypoint: [python3, /app/http-ca-server.py] command: [/config/http-ca-server.yml] @@ -292,7 +292,8 @@ services: driver: local ndnd-repo: - image: ghcr.io/named-data/ndnd:20261012 + image: ghcr.io/named-data/ndnd:testbed-staging + pull_policy: always init: true volumes: - /run/nfd:/run/nfd:ro @@ -314,7 +315,7 @@ services: driver: local ndnd-merkle: - image: ghcr.io/named-data/ndnd:20261012 + image: ghcr.io/named-data/ndnd:testbed-staging pull_policy: always profiles: [merkle-log] # selected by config.yml through maintenance init: true From 0d33d968655d283790fb749e1642bd52fa05108e Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Tue, 20 Oct 2026 12:53:07 -0700 Subject: [PATCH 29/52] Deploy staging NDNd across testbed services --- config.yml | 4 ++-- docker-compose.yml | 29 ++++++++++++----------------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/config.yml b/config.yml index de9b777..b16b1f1 100644 --- a/config.yml +++ b/config.yml @@ -31,13 +31,13 @@ services: ndnd-go-root-ca: hosts: [UCLA] - profile: ndnd-go-ca + profile: ndnd-go-root-ca template_path: templates/ndnd-go-ca render_path: dist/ndnd-go-root-config ndnd-root-http-ca: hosts: [UCLA] - profile: ndnd-go-ca + profile: ndnd-go-root-ca template_path: templates/ndnd-go-ca render_path: dist/ndnd-go-root-config diff --git a/docker-compose.yml b/docker-compose.yml index ac8b1a3..487fc5c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,9 +44,8 @@ services: driver: local ndnd: - image: ndnd-dv2:integration-763420d - build: - context: https://github.com/markverick/ndnd.git#763420dd4d11b860b97e0cd57169011f3dbfdef5 + image: ghcr.io/named-data/ndnd:testbed-staging + pull_policy: always profiles: [ndnd] init: true volumes: @@ -68,9 +67,8 @@ services: driver: local ndnd-dv: - image: ndnd-dv2:integration-763420d - build: - context: https://github.com/markverick/ndnd.git#763420dd4d11b860b97e0cd57169011f3dbfdef5 + image: ghcr.io/named-data/ndnd:testbed-staging + pull_policy: always profiles: [ndnd] init: true volumes: @@ -92,9 +90,8 @@ services: driver: local ndnd-http-status-server: - image: ndnd-dv2:integration-763420d - build: - context: https://github.com/markverick/ndnd.git#763420dd4d11b860b97e0cd57169011f3dbfdef5 + image: ghcr.io/named-data/ndnd:testbed-staging + pull_policy: always profiles: [ndnd] init: true volumes: @@ -112,9 +109,8 @@ services: driver: local ndnd-go-ca: - image: ndnd-dv2:integration-763420d - build: - context: https://github.com/markverick/ndnd.git#763420dd4d11b860b97e0cd57169011f3dbfdef5 + image: ghcr.io/named-data/ndnd:testbed-staging + pull_policy: always profiles: [ndnd-go-ca] init: true volumes: @@ -135,10 +131,9 @@ services: driver: local ndnd-go-root-ca: - image: ndnd-dv2:integration-763420d - build: - context: https://github.com/markverick/ndnd.git#763420dd4d11b860b97e0cd57169011f3dbfdef5 - profiles: [ndnd-go-ca] + image: ghcr.io/named-data/ndnd:testbed-staging + pull_policy: always + profiles: [ndnd-go-root-ca] init: true volumes: - /run/ndnd:/run/ndnd:ro @@ -159,7 +154,7 @@ services: ndnd-root-http-ca: image: ghcr.io/named-data/testbed-master:20261012 - profiles: [ndnd-go-ca] + profiles: [ndnd-go-root-ca] init: true tty: true volumes: From b8ca7023799ee8a56f329289abb5a8b8be4ee32f Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Tue, 20 Oct 2026 13:02:24 -0700 Subject: [PATCH 30/52] Remove unsupported NDNd router_name setting --- templates/ndnd/yanfd.yml.j2 | 3 --- 1 file changed, 3 deletions(-) diff --git a/templates/ndnd/yanfd.yml.j2 b/templates/ndnd/yanfd.yml.j2 index 88fe71c..37d6236 100644 --- a/templates/ndnd/yanfd.yml.j2 +++ b/templates/ndnd/yanfd.yml.j2 @@ -15,6 +15,3 @@ faces: tls_enabled: false http3: enabled: false - -fw: - router_name: {{ ndnd_router_prefix | tojson }} \ No newline at end of file From 0f41317fb435808fa6cefa2aa3c929fd6ae6bb72 Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Tue, 20 Oct 2026 13:05:19 -0700 Subject: [PATCH 31/52] Remove unsupported NDNd DV trust_schema setting --- templates/ndnd-dv/dv.yml.j2 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/templates/ndnd-dv/dv.yml.j2 b/templates/ndnd-dv/dv.yml.j2 index b2d6226..34c1f76 100644 --- a/templates/ndnd-dv/dv.yml.j2 +++ b/templates/ndnd-dv/dv.yml.j2 @@ -4,7 +4,6 @@ dv: keychain: dir:///config/keys trust_anchors: - {{ ndn_cert_name(read_file(ndnd_root_anchor_path)) | tojson }} - trust_schema: dv-schema.tlv neighbors: {% set peers = namespace(count=0) %} {% for host, values in hostvars.items() %} @@ -15,4 +14,4 @@ dv: {% endfor %} {% if peers.count == 0 %} [] - {% endif %} \ No newline at end of file + {% endif %} From ca7019c6a4ea04c23488c635b322028a62efca41 Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Tue, 20 Oct 2026 13:07:02 -0700 Subject: [PATCH 32/52] Resolve Compose profiles before certificate restarts --- scripts/cert-renew.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/cert-renew.sh b/scripts/cert-renew.sh index 78ecdd3..8ec62e9 100644 --- a/scripts/cert-renew.sh +++ b/scripts/cert-renew.sh @@ -2,6 +2,9 @@ source "$(pwd)/scripts/utils.sh" +COMPOSE_PROFILES=$(python3 framework/service-profiles.py) || exit $? +export COMPOSE_PROFILES + NDNCERT_CERTFILE="$(pwd)/dist/ndncert/site.ndncert" FORCE="" @@ -24,8 +27,6 @@ DV_ENABLED=$(python3 framework/service-profiles.py --service ndnd-dv) || exit $? if [[ "${DV_ENABLED}" == 1 ]]; then NDND_SIGNER_ENABLED=$(python3 framework/service-profiles.py --service ndnd-root-http-ca) || exit $? if [[ "${NDND_SIGNER_ENABLED}" == 1 ]]; then - COMPOSE_PROFILES=$(python3 framework/service-profiles.py) || exit $? - export COMPOSE_PROFILES PWD="${ROOT_DIR:-$PWD}" docker compose up -d --no-deps --wait --wait-timeout 30 ndnd-root-http-ca || exit $? fi SITE_CA_ENABLED=$(python3 framework/service-profiles.py --service ndnd-go-ca) || exit $? From 69683e444c441b6e094b16082094db254a24452f Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Tue, 20 Oct 2026 19:45:20 -0700 Subject: [PATCH 33/52] Add dedicated repository for the NDNd network --- config.yml | 6 +++++ docker-compose.yml | 23 +++++++++++++++++ scripts/cert-renew.sh | 10 ++++++++ scripts/ndnd-infra-security.py | 18 +++++++++++-- .../management-schema.lvs.j2 | 25 +++++++++++++++++++ templates/ndnd-network-repo/renew.sh.j2 | 13 ++++++++++ templates/ndnd-network-repo/repo.yml.j2 | 8 ++++++ 7 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 templates/ndnd-network-repo/management-schema.lvs.j2 create mode 100644 templates/ndnd-network-repo/renew.sh.j2 create mode 100644 templates/ndnd-network-repo/repo.yml.j2 diff --git a/config.yml b/config.yml index b16b1f1..d493bf0 100644 --- a/config.yml +++ b/config.yml @@ -74,6 +74,12 @@ services: template_path: templates/ndnd-repo render_path: dist/ndnd-repo + ndnd-network-repo: + enabled_by: ndnd_enabled + profile: ndnd + template_path: templates/ndnd-network-repo + render_path: dist/ndnd-network-repo + ndnd-merkle: hosts: [UCLA] profile: merkle-log diff --git a/docker-compose.yml b/docker-compose.yml index 487fc5c..4b352ea 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -309,6 +309,29 @@ services: logging: driver: local + ndnd-network-repo: + image: ghcr.io/named-data/ndnd:testbed-staging + profiles: [ndnd] + init: true + volumes: + - /run/ndnd:/run/ndnd:ro + - ${PWD}/dist/ndnd-network-repo/keys:/config/keys + - ${PWD}/dist/ndnd-network-repo/storage:/config/storage + - ${PWD}/dist/ndnd-network-repo/repo.yml:/config/repo.yml:ro + - ${PWD}/dist/ndnd-network-repo/management-schema.tlv:/config/management-schema.tlv:ro + environment: + NDN_CLIENT_TRANSPORT: unix:///run/ndnd/ndnd.sock + command: [repo, run, /config/repo.yml] + read_only: true + cap_drop: [ALL] + security_opt: [no-new-privileges:true] + restart: unless-stopped + depends_on: + ndnd: { condition: service_healthy } + ndnd-dv: { condition: service_started } + logging: + driver: local + ndnd-merkle: image: ghcr.io/named-data/ndnd:testbed-staging pull_policy: always diff --git a/scripts/cert-renew.sh b/scripts/cert-renew.sh index 8ec62e9..2c4bda2 100644 --- a/scripts/cert-renew.sh +++ b/scripts/cert-renew.sh @@ -51,6 +51,16 @@ if [[ "${DV_ENABLED}" == 1 ]]; then fi rm -f "${DV_DIR}/.security-changed" fi + NETWORK_REPO_DIR=dist/ndnd-network-repo + bash "${NETWORK_REPO_DIR}/renew.sh" ${FORCE:+"${FORCE}"} || exit $? + mkdir -p "${NETWORK_REPO_DIR}/storage" + if [[ -f "${NETWORK_REPO_DIR}/.security-changed" ]]; then + RUNNING_NETWORK_REPO=$(PWD="${ROOT_DIR:-$PWD}" docker compose ps --status running -q ndnd-network-repo) || exit $? + if [[ -n "${RUNNING_NETWORK_REPO}" ]]; then + PWD="${ROOT_DIR:-$PWD}" docker compose restart ndnd-network-repo || exit $? + fi + rm -f "${NETWORK_REPO_DIR}/.security-changed" + fi fi # Restart containers if force diff --git a/scripts/ndnd-infra-security.py b/scripts/ndnd-infra-security.py index a26d732..6014f65 100644 --- a/scripts/ndnd-infra-security.py +++ b/scripts/ndnd-infra-security.py @@ -167,8 +167,10 @@ def provision_locked(directory, site_home, site_prefix, anchors_path, force, ren if root_cert_path is None: raise ValueError('Site CA provisioning requires the NDNd root certificate path') else: + expected_identity = Name.normalize(identity or (site_prefix + '/ndnd/' + service)) identity = Name.normalize(config['name']) - expected_identity = Name.normalize(site_prefix + '/ndnd/' + service) + if not Name.is_prefix(Name.normalize(site_prefix), expected_identity): + raise ValueError('Service identity must be beneath the site prefix') if Name.to_bytes(identity) != Name.to_bytes(expected_identity): raise ValueError(f'Invalid {service} identity {Name.to_str(identity)}') @@ -190,7 +192,10 @@ def provision_locked(directory, site_home, site_prefix, anchors_path, force, ren site_before = root_before site_after = root_after else: - site_wire = decode_certificate(site_home / 'site.ndncert') + site_cert_path = site_home / 'site.ndncert' + if not site_cert_path.exists(): + site_cert_path = site_home / 'ca.ndncert' + site_wire = decode_certificate(site_cert_path) site = parse_certificate(site_wire) if Name.to_bytes(site.name[:-4]) != Name.to_bytes(Name.normalize(site_prefix)): raise ValueError('Site certificate has the wrong identity') @@ -246,6 +251,15 @@ def provision_locked(directory, site_home, site_prefix, anchors_path, force, ren key.public_key().export_key(format='DER'), signer, before, after) if service in ('dv', 'ca'): cert_wire = sign_with_root_ca(csr, root_ca_url, os.environ['NDND_ROOT_CA_SECRET'], before, after) + elif site_cert_path.name == 'ca.ndncert': + site_key_wire = decode_pem((site_home / 'ca.key.pem').read_text(), 'KEY') + _, _, secret, _ = parse_data(site_key_wire) + site_key = ECC.import_key(bytes(secret)) + if site_key.public_key().export_key(format='DER') != bytes(site.content): + raise ValueError('Site CA private key does not match its certificate') + site_signer = Sha256WithEcdsaSigner(site.name[:-2], site_key.export_key(format='DER', use_pkcs8=False)) + _, cert_wire = new_cert(key_name, Component.from_str('site'), + key.public_key().export_key(format='DER'), site_signer, before, after) else: command = ['ndnsec', 'cert-gen', '-s', site_prefix, '-S', before.strftime('%Y%m%d%H%M%S'), '-E', after.strftime('%Y%m%d%H%M%S'), '-'] diff --git a/templates/ndnd-network-repo/management-schema.lvs.j2 b/templates/ndnd-network-repo/management-schema.lvs.j2 new file mode 100644 index 0000000..3a38d30 --- /dev/null +++ b/templates/ndnd-network-repo/management-schema.lvs.j2 @@ -0,0 +1,25 @@ +#key: "KEY"/_/_/_ +#root: {{ ndn_lvs_name(ndnd_dv_network) }}/#key +#flat_user: {{ ndn_lvs_name(ndnd_dv_network) }}/user +#flat_user_key: #flat_user/#key <= #root +#flat_command: #flat_user/"32=repo" <= #flat_user_key +#flat_security: #flat_user/"32=repo-security" <= #flat_user_key +{% for host, values in hostvars.items() %} +{% if values.get('ndnd_enabled', false) %} +{% set site_id = loop.index %} +#site_{{ site_id }}: {{ ndn_lvs_name(values.ndnd_ca_prefix) }}/#key <= #root +#flat_user_key: #flat_user/#key <= #site_{{ site_id }} +{% for depth in range(1, 6) %} +{% set id = site_id ~ '_' ~ depth %} +#user_{{ id }}: {{ ndn_lvs_name(values.ndnd_ca_prefix) }}{% for n in range(depth) %}/user{{ n }}{% endfor %} + +#user_key_{{ id }}: #user_{{ id }}/#key <= #site_{{ site_id }} +#command_{{ id }}: #user_{{ id }}/"32=repo" <= #user_key_{{ id }} +#security_{{ id }}: #user_{{ id }}/"32=repo-security" <= #user_key_{{ id }} +{% endfor %} +{% if host == inventory_hostname %} +#repo_key: {{ ndn_lvs_name(ndnd_router_prefix + '/repo') }}/#key <= #site_{{ site_id }} +{% endif %} +{% endif %} +{% endfor %} +#response: {{ ndn_lvs_name(ndnd_router_prefix + '/repo') }}/"32=cmd"/_ <= #repo_key diff --git a/templates/ndnd-network-repo/renew.sh.j2 b/templates/ndnd-network-repo/renew.sh.j2 new file mode 100644 index 0000000..02b4ea1 --- /dev/null +++ b/templates/ndnd-network-repo/renew.sh.j2 @@ -0,0 +1,13 @@ +#!/bin/bash +set -eu + +REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +TESTBED_DIR="$(cd "${REPO_DIR}/../.." && pwd)" + +python3 "${TESTBED_DIR}/scripts/ndnd-infra-security.py" \ + --directory "${REPO_DIR}" \ + --site-home "${TESTBED_DIR}/dist/ndnd-site-ca-independent" \ + --site-prefix {{ ndnd_ca_prefix | tojson }} \ + --identity {{ (ndnd_router_prefix + '/repo') | tojson }} \ + --anchors "${TESTBED_DIR}/anchors" \ + --service repo "$@" diff --git a/templates/ndnd-network-repo/repo.yml.j2 b/templates/ndnd-network-repo/repo.yml.j2 new file mode 100644 index 0000000..282c3d6 --- /dev/null +++ b/templates/ndnd-network-repo/repo.yml.j2 @@ -0,0 +1,8 @@ +repo: + name: {{ (ndnd_router_prefix + '/repo') | tojson }} + storage_dir: /config/storage + keychain: dir:///config/keys + trust_schema: /config/management-schema.tlv + trust_anchors: + - {{ ndn_cert_name(read_file(ndnd_root_anchor_path)) | tojson }} + ignore_validity: false From 06fd9a45db0723efa8ab2cd6e0718861f2147b76 Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Tue, 20 Oct 2026 20:30:58 -0700 Subject: [PATCH 34/52] Avoid missing repo bind files and authorize NDNd user identities --- docker-compose.yml | 14 ++++++++++++-- .../ndnd-network-repo/management-schema.lvs.j2 | 8 ++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 4b352ea..5690df2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -317,8 +317,18 @@ services: - /run/ndnd:/run/ndnd:ro - ${PWD}/dist/ndnd-network-repo/keys:/config/keys - ${PWD}/dist/ndnd-network-repo/storage:/config/storage - - ${PWD}/dist/ndnd-network-repo/repo.yml:/config/repo.yml:ro - - ${PWD}/dist/ndnd-network-repo/management-schema.tlv:/config/management-schema.tlv:ro + - type: bind + source: ${PWD}/dist/ndnd-network-repo/repo.yml + target: /config/repo.yml + read_only: true + bind: + create_host_path: false + - type: bind + source: ${PWD}/dist/ndnd-network-repo/management-schema.tlv + target: /config/management-schema.tlv + read_only: true + bind: + create_host_path: false environment: NDN_CLIENT_TRANSPORT: unix:///run/ndnd/ndnd.sock command: [repo, run, /config/repo.yml] diff --git a/templates/ndnd-network-repo/management-schema.lvs.j2 b/templates/ndnd-network-repo/management-schema.lvs.j2 index 3a38d30..2b56274 100644 --- a/templates/ndnd-network-repo/management-schema.lvs.j2 +++ b/templates/ndnd-network-repo/management-schema.lvs.j2 @@ -4,6 +4,14 @@ #flat_user_key: #flat_user/#key <= #root #flat_command: #flat_user/"32=repo" <= #flat_user_key #flat_security: #flat_user/"32=repo-security" <= #flat_user_key +{% for depth in range(2, 7) %} +// Root-issued NDNCERT identities may have multiple components (e.g. com/gmail/user). +#root_user_{{ depth }}: {{ ndn_lvs_name(ndnd_dv_network) }}{% for n in range(depth) %}/rootuser{{ n }}{% endfor %} + +#root_user_key_{{ depth }}: #root_user_{{ depth }}/#key <= #root +#root_command_{{ depth }}: #root_user_{{ depth }}/"32=repo" <= #root_user_key_{{ depth }} +#root_security_{{ depth }}: #root_user_{{ depth }}/"32=repo-security" <= #root_user_key_{{ depth }} +{% endfor %} {% for host, values in hostvars.items() %} {% if values.get('ndnd_enabled', false) %} {% set site_id = loop.index %} From e055bc1f8ee9dd5b98dd7073030621a7a58efacb Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Tue, 20 Oct 2026 20:50:31 -0700 Subject: [PATCH 35/52] Add separate Merkle log for the NDNd network --- config.yml | 7 ++++ docker-compose.yml | 38 +++++++++++++++++ scripts/cert-renew.sh | 42 ++++++++++--------- scripts/ndnd-infra-security.py | 2 +- .../management-schema.lvs.j2 | 28 +++++++++++++ templates/ndnd-network-merkle/merkle.yml.j2 | 8 ++++ templates/ndnd-network-merkle/renew.sh.j2 | 14 +++++++ 7 files changed, 118 insertions(+), 21 deletions(-) create mode 100644 templates/ndnd-network-merkle/management-schema.lvs.j2 create mode 100644 templates/ndnd-network-merkle/merkle.yml.j2 create mode 100644 templates/ndnd-network-merkle/renew.sh.j2 diff --git a/config.yml b/config.yml index d493bf0..2aee987 100644 --- a/config.yml +++ b/config.yml @@ -86,6 +86,13 @@ services: template_path: templates/ndnd-merkle render_path: dist/ndnd-merkle + ndnd-network-merkle: + hosts: [UCLA] + enabled_by: ndnd_enabled + profile: ndnd-merkle-log + template_path: templates/ndnd-network-merkle + render_path: dist/ndnd-network-merkle + ndncert: template_path: templates/ndncert render_path: dist/ndncert diff --git a/docker-compose.yml b/docker-compose.yml index 5690df2..cc85680 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -370,6 +370,44 @@ services: logging: driver: local + ndnd-network-merkle: + image: ghcr.io/named-data/ndnd:testbed-staging + pull_policy: always + profiles: [ndnd-merkle-log] + init: true + volumes: + - /run/ndnd:/run/ndnd:ro + - ${PWD}/dist/ndnd-network-merkle/keys:/config/keys + - ${PWD}/dist/ndnd-network-merkle/storage:/config/storage + - type: bind + source: ${PWD}/dist/ndnd-network-merkle/merkle.yml + target: /config/merkle.yml + read_only: true + bind: + create_host_path: false + - type: bind + source: ${PWD}/dist/ndnd-network-merkle/management-schema.tlv + target: /config/management-schema.tlv + read_only: true + bind: + create_host_path: false + environment: + NDN_CLIENT_TRANSPORT: unix:///run/ndnd/ndnd.sock + command: [merkle, run, /config/merkle.yml] + network_mode: none + read_only: true + cap_drop: [ALL] + security_opt: [no-new-privileges:true] + mem_limit: 2g + cpus: 1 + pids_limit: 128 + restart: unless-stopped + depends_on: + ndnd: { condition: service_healthy } + ndnd-dv: { condition: service_started } + logging: + driver: local + ndncert: image: ghcr.io/ucla-irl/ndncert-ca:20250923 init: true diff --git a/scripts/cert-renew.sh b/scripts/cert-renew.sh index 2c4bda2..7474abf 100644 --- a/scripts/cert-renew.sh +++ b/scripts/cert-renew.sh @@ -80,26 +80,28 @@ if [[ -f dist/ndnd-repo/.security-changed ]]; then fi # Optional services run after the core renewals and retain their own retry state. -MERKLE_ENABLED=$(python3 framework/service-profiles.py --service ndnd-merkle) || exit $? -if [[ "${MERKLE_ENABLED}" == 1 ]]; then - MERKLE_DIR=dist/ndnd-merkle - if [[ -n "${FORCE}" ]]; then - touch "${MERKLE_DIR}/.renew-pending" - fi - MERKLE_FORCE="" - if [[ -f "${MERKLE_DIR}/.renew-pending" ]]; then - MERKLE_FORCE="--force" - fi - if bash "${MERKLE_DIR}/renew.sh" ${MERKLE_FORCE:+"${MERKLE_FORCE}"}; then - rm -f "${MERKLE_DIR}/.renew-pending" - if [[ -f "${MERKLE_DIR}/.security-changed" ]]; then - RUNNING_LOG=$(PWD="${ROOT_DIR:-$PWD}" docker compose ps --status running -q ndnd-merkle) || exit $? - if [[ -n "${RUNNING_LOG}" ]]; then - PWD="${ROOT_DIR:-$PWD}" docker compose restart ndnd-merkle || exit $? +for MERKLE_SERVICE in ndnd-merkle ndnd-network-merkle; do + MERKLE_ENABLED=$(python3 framework/service-profiles.py --service "${MERKLE_SERVICE}") || exit $? + if [[ "${MERKLE_ENABLED}" == 1 ]]; then + MERKLE_DIR="dist/${MERKLE_SERVICE}" + if [[ -n "${FORCE}" ]]; then + touch "${MERKLE_DIR}/.renew-pending" + fi + MERKLE_FORCE="" + if [[ -f "${MERKLE_DIR}/.renew-pending" ]]; then + MERKLE_FORCE="--force" + fi + if bash "${MERKLE_DIR}/renew.sh" ${MERKLE_FORCE:+"${MERKLE_FORCE}"}; then + rm -f "${MERKLE_DIR}/.renew-pending" + if [[ -f "${MERKLE_DIR}/.security-changed" ]]; then + RUNNING_LOG=$(PWD="${ROOT_DIR:-$PWD}" docker compose ps --status running -q "${MERKLE_SERVICE}") || exit $? + if [[ -n "${RUNNING_LOG}" ]]; then + PWD="${ROOT_DIR:-$PWD}" docker compose restart "${MERKLE_SERVICE}" || exit $? + fi + rm -f "${MERKLE_DIR}/.security-changed" fi - rm -f "${MERKLE_DIR}/.security-changed" + else + echo "${MERKLE_SERVICE} credential renewal failed; core services renewed, log will retry next poll" >&2 fi - else - echo "NDNd Merkle credential renewal failed; core services renewed, log will retry next poll" >&2 fi -fi +done diff --git a/scripts/ndnd-infra-security.py b/scripts/ndnd-infra-security.py index 6014f65..8f7a641 100644 --- a/scripts/ndnd-infra-security.py +++ b/scripts/ndnd-infra-security.py @@ -143,7 +143,7 @@ def provision_locked(directory, site_home, site_prefix, anchors_path, force, ren service, root_ca_url, root_cert_path, identity): if service not in ('repo', 'merkle', 'dv', 'ca'): raise ValueError('Unsupported NDNd service') - if service == 'merkle' and site_prefix != '/ndn/edu/ucla': + if service == 'merkle' and site_prefix not in ('/ndn/edu/ucla', '/ndnd/ucla'): raise ValueError('Merkle log provisioning is restricted to UCLA') if service == 'ca': config = {} diff --git a/templates/ndnd-network-merkle/management-schema.lvs.j2 b/templates/ndnd-network-merkle/management-schema.lvs.j2 new file mode 100644 index 0000000..ac172f5 --- /dev/null +++ b/templates/ndnd-network-merkle/management-schema.lvs.j2 @@ -0,0 +1,28 @@ +// Root -> user, or root -> site -> user/log; only the local log signs responses. +#key: "KEY"/_/_/_ +#root: {{ ndn_lvs_name(ndnd_dv_network) }}/#key +{% for depth in range(1, 7) %} +#root_user_{{ depth }}: {{ ndn_lvs_name(ndnd_dv_network) }}{% for n in range(depth) %}/rootuser{{ n }}{% endfor %} + +#root_user_key_{{ depth }}: #root_user_{{ depth }}/#key <= #root +#root_append_{{ depth }}: {{ ndn_lvs_name(ndnd_router_prefix + '/merkle') }}/"32=append"/#root_user_{{ depth }}/_ <= #root_user_key_{{ depth }} +{% endfor %} +{% for host, values in hostvars.items() %} +{% if values.get('ndnd_enabled', false) %} +{% set site_id = loop.index %} +#site_{{ site_id }}: {{ ndn_lvs_name(values.ndnd_ca_prefix) }}/#key <= #root +{% for depth in range(1, 6) %} +{% set id = site_id ~ '_' ~ depth %} +#user_{{ id }}: {{ ndn_lvs_name(values.ndnd_ca_prefix) }}{% for n in range(depth) %}/user{{ n }}{% endfor %} + +#user_key_{{ id }}: #user_{{ id }}/#key <= #site_{{ site_id }} +#append_{{ id }}: {{ ndn_lvs_name(ndnd_router_prefix + '/merkle') }}/"32=append"/#user_{{ id }}/_ <= #user_key_{{ id }} +{% endfor %} +{% if host == inventory_hostname %} +#log_key: {{ ndn_lvs_name(ndnd_router_prefix + '/merkle') }}/#key <= #site_{{ site_id }} +{% endif %} +{% endif %} +{% endfor %} +// Object validation removes terminal version and segment components. +#append_response: {{ ndn_lvs_name(ndnd_router_prefix + '/merkle') }}/"32=append"/_ <= #log_key +#check_response: {{ ndn_lvs_name(ndnd_router_prefix + '/merkle') }}/"32=check"/_ <= #log_key diff --git a/templates/ndnd-network-merkle/merkle.yml.j2 b/templates/ndnd-network-merkle/merkle.yml.j2 new file mode 100644 index 0000000..1fbea6a --- /dev/null +++ b/templates/ndnd-network-merkle/merkle.yml.j2 @@ -0,0 +1,8 @@ +merkle: + name: {{ (ndnd_router_prefix + '/merkle') | tojson }} + storage_dir: /config/storage + max_entries: 1000000 + keychain: dir:///config/keys + trust_schema: /config/management-schema.tlv + trust_anchors: + - {{ ndn_cert_name(read_file(ndnd_root_anchor_path)) | tojson }} diff --git a/templates/ndnd-network-merkle/renew.sh.j2 b/templates/ndnd-network-merkle/renew.sh.j2 new file mode 100644 index 0000000..f4a5e29 --- /dev/null +++ b/templates/ndnd-network-merkle/renew.sh.j2 @@ -0,0 +1,14 @@ +#!/bin/bash + +set -eu + +SERVICE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +TESTBED_DIR="$(cd "${SERVICE_DIR}/../.." && pwd)" + +python3 "${TESTBED_DIR}/scripts/ndnd-infra-security.py" \ + --service merkle \ + --directory "${SERVICE_DIR}" \ + --site-home "${TESTBED_DIR}/dist/ndnd-site-ca-independent" \ + --site-prefix {{ ndnd_ca_prefix | tojson }} \ + --identity {{ (ndnd_router_prefix + '/merkle') | tojson }} \ + --anchors "${TESTBED_DIR}/anchors" "$@" From 2d099d730b878e0867fb62c9c9d11967c96c0e6b Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Tue, 20 Oct 2026 23:32:27 -0700 Subject: [PATCH 36/52] Enable the NDNd Merkle log on every NDNd node --- config.yml | 1 - scripts/ndnd-infra-security.py | 2 -- 2 files changed, 3 deletions(-) diff --git a/config.yml b/config.yml index 2aee987..0624400 100644 --- a/config.yml +++ b/config.yml @@ -87,7 +87,6 @@ services: render_path: dist/ndnd-merkle ndnd-network-merkle: - hosts: [UCLA] enabled_by: ndnd_enabled profile: ndnd-merkle-log template_path: templates/ndnd-network-merkle diff --git a/scripts/ndnd-infra-security.py b/scripts/ndnd-infra-security.py index 8f7a641..5ad99aa 100644 --- a/scripts/ndnd-infra-security.py +++ b/scripts/ndnd-infra-security.py @@ -143,8 +143,6 @@ def provision_locked(directory, site_home, site_prefix, anchors_path, force, ren service, root_ca_url, root_cert_path, identity): if service not in ('repo', 'merkle', 'dv', 'ca'): raise ValueError('Unsupported NDNd service') - if service == 'merkle' and site_prefix not in ('/ndn/edu/ucla', '/ndnd/ucla'): - raise ValueError('Merkle log provisioning is restricted to UCLA') if service == 'ca': config = {} else: From e7a44ca7519b36fd998ce5c301972a6991f02d66 Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Tue, 20 Oct 2026 23:34:29 -0700 Subject: [PATCH 37/52] Keep NDNd Merkle deployment UCLA-only like the NFD service --- config.yml | 1 + scripts/ndnd-infra-security.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/config.yml b/config.yml index 0624400..2aee987 100644 --- a/config.yml +++ b/config.yml @@ -87,6 +87,7 @@ services: render_path: dist/ndnd-merkle ndnd-network-merkle: + hosts: [UCLA] enabled_by: ndnd_enabled profile: ndnd-merkle-log template_path: templates/ndnd-network-merkle diff --git a/scripts/ndnd-infra-security.py b/scripts/ndnd-infra-security.py index 5ad99aa..8f7a641 100644 --- a/scripts/ndnd-infra-security.py +++ b/scripts/ndnd-infra-security.py @@ -143,6 +143,8 @@ def provision_locked(directory, site_home, site_prefix, anchors_path, force, ren service, root_ca_url, root_cert_path, identity): if service not in ('repo', 'merkle', 'dv', 'ca'): raise ValueError('Unsupported NDNd service') + if service == 'merkle' and site_prefix not in ('/ndn/edu/ucla', '/ndnd/ucla'): + raise ValueError('Merkle log provisioning is restricted to UCLA') if service == 'ca': config = {} else: From 69482381e42ce5d95bea919897ff3958f0810a41 Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Wed, 21 Oct 2026 14:45:00 -0700 Subject: [PATCH 38/52] Enable local-hop management for NDNd client registration --- templates/ndnd/yanfd.yml.j2 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/templates/ndnd/yanfd.yml.j2 b/templates/ndnd/yanfd.yml.j2 index 37d6236..1bc83ce 100644 --- a/templates/ndnd/yanfd.yml.j2 +++ b/templates/ndnd/yanfd.yml.j2 @@ -1,3 +1,6 @@ +mgmt: + allow_localhop: true + faces: udp: enabled_unicast: true From 26f45c4cfb3f2398e84b6ab74f3d9b91981d327e Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Wed, 21 Oct 2026 19:12:25 -0700 Subject: [PATCH 39/52] Pin all NDNd services and provisioning to workflow run 39708255483 --- config.yml | 2 +- docker-compose.yml | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/config.yml b/config.yml index 2aee987..bfdd39a 100644 --- a/config.yml +++ b/config.yml @@ -125,7 +125,7 @@ globals: ndnd_udp_port: 6364 ndnd_dv_network: /ndnd ndnd_ca_host: UCLA - ndnd_ca_image: ndnd-dv2:integration-763420d + ndnd_ca_image: ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a ndnd_ca_info: "NDNd Testbed Go CA" ndnd_ca_max_validity_period: "7776000" ndnd_ca_max_suffix_length: "5" diff --git a/docker-compose.yml b/docker-compose.yml index cc85680..99f4605 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,7 +44,7 @@ services: driver: local ndnd: - image: ghcr.io/named-data/ndnd:testbed-staging + image: ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a pull_policy: always profiles: [ndnd] init: true @@ -67,7 +67,7 @@ services: driver: local ndnd-dv: - image: ghcr.io/named-data/ndnd:testbed-staging + image: ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a pull_policy: always profiles: [ndnd] init: true @@ -90,7 +90,7 @@ services: driver: local ndnd-http-status-server: - image: ghcr.io/named-data/ndnd:testbed-staging + image: ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a pull_policy: always profiles: [ndnd] init: true @@ -109,7 +109,7 @@ services: driver: local ndnd-go-ca: - image: ghcr.io/named-data/ndnd:testbed-staging + image: ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a pull_policy: always profiles: [ndnd-go-ca] init: true @@ -131,7 +131,7 @@ services: driver: local ndnd-go-root-ca: - image: ghcr.io/named-data/ndnd:testbed-staging + image: ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a pull_policy: always profiles: [ndnd-go-root-ca] init: true @@ -164,7 +164,7 @@ services: - ${PWD}/dist/ndnd-go-root-ca/cert-store:/cert-store environment: NDND_ROOT_CA_SECRET: ${VAR_NDND_ROOT_CA_SECRET:?VAR_NDND_ROOT_CA_SECRET must be set} - NDND_CA_IMAGE: ghcr.io/named-data/ndnd:testbed-staging + NDND_CA_IMAGE: ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a NDND_CA_HOST_DIR: ${PWD}/ndnd-root-ca-home/ndnd entrypoint: [python3, /app/http-ca-server.py] command: [/config/http-ca-server.yml] @@ -287,7 +287,7 @@ services: driver: local ndnd-repo: - image: ghcr.io/named-data/ndnd:testbed-staging + image: ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a pull_policy: always init: true volumes: @@ -310,7 +310,7 @@ services: driver: local ndnd-network-repo: - image: ghcr.io/named-data/ndnd:testbed-staging + image: ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a profiles: [ndnd] init: true volumes: @@ -343,7 +343,7 @@ services: driver: local ndnd-merkle: - image: ghcr.io/named-data/ndnd:testbed-staging + image: ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a pull_policy: always profiles: [merkle-log] # selected by config.yml through maintenance init: true @@ -371,7 +371,7 @@ services: driver: local ndnd-network-merkle: - image: ghcr.io/named-data/ndnd:testbed-staging + image: ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a pull_policy: always profiles: [ndnd-merkle-log] init: true From 23d5c998575904a624e234833c6cb451d841f6cd Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Fri, 23 Oct 2026 10:46:03 -0700 Subject: [PATCH 40/52] Update Python repo to PR 119 image from run 39997406675 --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 99f4605..668c32c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -269,7 +269,7 @@ services: driver: local ndn-python-repo: - image: ghcr.io/ucla-irl/ndn-python-repo:20240508 + image: ghcr.io/ucla-irl/ndn-python-repo:20261023@sha256:781c3db4aad30a91a0672da787b316599ee08957b63961219f09d7c4408cf763 init: true volumes: - /run/nfd:/run/nfd:ro From 3615d1cad453e75d07defed8f82da797827dba41 Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Tue, 27 Oct 2026 02:08:19 -0700 Subject: [PATCH 41/52] Deploy DV2 image with explicit status trust and HTTP reports --- README.md | 30 +++++++ config.yml | 5 +- docker-compose.yml | 23 ++--- framework/test_ndnd_status_trust.py | 86 +++++++++++++++++++ templates/caddy/Caddyfile.j2 | 1 + templates/file-server/ndnd/dv-schema.lvs.j2 | 1 + templates/ndnd-dv/dv-schema.lvs.j2 | 3 +- templates/ndnd-dv/dv.yml.j2 | 1 + .../ndnd-http-status-server/dv-schema.lvs.j2 | 1 + .../ndnd-http-status-server/root.cert.pem.j2 | 3 + templates/ndnd/yanfd.yml.j2 | 3 + 11 files changed, 143 insertions(+), 14 deletions(-) create mode 100644 framework/test_ndnd_status_trust.py create mode 100644 templates/file-server/ndnd/dv-schema.lvs.j2 create mode 100644 templates/ndnd-http-status-server/dv-schema.lvs.j2 create mode 100644 templates/ndnd-http-status-server/root.cert.pem.j2 diff --git a/README.md b/README.md index 2727c1e..46072d4 100644 --- a/README.md +++ b/README.md @@ -148,3 +148,33 @@ sudo systemctl enable unattended-upgrades sudo systemctl start unattended-upgrades sudo unattended-upgrades --debug ``` + +## NDNd status + +NDNd services use the digest-pinned DV2 image from +[workflow run 40476201514](https://github.com/named-data/ndnd/actions/runs/40476201514). +Upgrade the forwarder, DV router, status server, repositories, Merkle logs, and +CA services together; the DV2 BIFT management dataset uses TLV encoding. + +On hosts with `ndnd_enabled: true`, Caddy exposes: + +- `/ndnd-status/`: HTML status page. +- `/ndnd-status/status.xml`: XML status report. +- `/ndnd-status/status.json`: JSON status report. + +For example: `https://suns.cs.ucla.edu/ndnd-status/status.json`. + +The renderer compiles `templates/ndnd-dv/dv-schema.lvs.j2` for both DV and the +status server. It permits only inventoried NDNd router certificates, issued +directly by the `/ndnd` root, to sign their routing and status datasets. DV +explicitly loads this schema; the status server receives the same schema and +the public root certificate in PEM format through a separate read-only mount. +It has no access to router private keys. Changes to either status trust file +cause the existing renderer to restart the status server. +The same compiled schema is published at `/file-server/ndnd/dv-schema.tlv`, +matching the schema URL in the NDNd CA profile. + +The status server validates `//32=DV/32=STATUS` before including the +routing dataset. It does not fall back to an unrestricted schema. The local +DV summary remains available if the signed dataset cannot be validated; check +the status server logs and the report's routing state in that case. diff --git a/config.yml b/config.yml index bfdd39a..f68d986 100644 --- a/config.yml +++ b/config.yml @@ -21,7 +21,8 @@ services: ndnd-http-status-server: enabled_by: ndnd_enabled profile: ndnd - pass: on + template_path: templates/ndnd-http-status-server + render_path: dist/ndnd-http-status-server ndnd-go-ca: enabled_by: ndnd_enabled @@ -125,7 +126,7 @@ globals: ndnd_udp_port: 6364 ndnd_dv_network: /ndnd ndnd_ca_host: UCLA - ndnd_ca_image: ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a + ndnd_ca_image: ghcr.io/named-data/ndnd:20261027@sha256:60032fc87a0c684f7bb7d4579691cb1c9225851e2b9e1445fa84fc4c0d5f5bd3 ndnd_ca_info: "NDNd Testbed Go CA" ndnd_ca_max_validity_period: "7776000" ndnd_ca_max_suffix_length: "5" diff --git a/docker-compose.yml b/docker-compose.yml index 668c32c..79b3a02 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,7 +44,7 @@ services: driver: local ndnd: - image: ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a + image: ghcr.io/named-data/ndnd:20261027@sha256:60032fc87a0c684f7bb7d4579691cb1c9225851e2b9e1445fa84fc4c0d5f5bd3 pull_policy: always profiles: [ndnd] init: true @@ -67,7 +67,7 @@ services: driver: local ndnd-dv: - image: ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a + image: ghcr.io/named-data/ndnd:20261027@sha256:60032fc87a0c684f7bb7d4579691cb1c9225851e2b9e1445fa84fc4c0d5f5bd3 pull_policy: always profiles: [ndnd] init: true @@ -90,15 +90,16 @@ services: driver: local ndnd-http-status-server: - image: ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a + image: ghcr.io/named-data/ndnd:20261027@sha256:60032fc87a0c684f7bb7d4579691cb1c9225851e2b9e1445fa84fc4c0d5f5bd3 pull_policy: always profiles: [ndnd] init: true volumes: - /run/ndnd:/run/ndnd:ro + - ${PWD}/dist/ndnd-http-status-server:/config:ro environment: NDN_CLIENT_TRANSPORT: unix:///run/ndnd/ndnd.sock - command: [fw, status-server] + command: [fw, status-server, --trust-schema, /config/dv-schema.tlv, --trust-anchor, /config/root.cert.pem] read_only: true cap_drop: [ALL] security_opt: [no-new-privileges:true] @@ -109,7 +110,7 @@ services: driver: local ndnd-go-ca: - image: ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a + image: ghcr.io/named-data/ndnd:20261027@sha256:60032fc87a0c684f7bb7d4579691cb1c9225851e2b9e1445fa84fc4c0d5f5bd3 pull_policy: always profiles: [ndnd-go-ca] init: true @@ -131,7 +132,7 @@ services: driver: local ndnd-go-root-ca: - image: ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a + image: ghcr.io/named-data/ndnd:20261027@sha256:60032fc87a0c684f7bb7d4579691cb1c9225851e2b9e1445fa84fc4c0d5f5bd3 pull_policy: always profiles: [ndnd-go-root-ca] init: true @@ -164,7 +165,7 @@ services: - ${PWD}/dist/ndnd-go-root-ca/cert-store:/cert-store environment: NDND_ROOT_CA_SECRET: ${VAR_NDND_ROOT_CA_SECRET:?VAR_NDND_ROOT_CA_SECRET must be set} - NDND_CA_IMAGE: ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a + NDND_CA_IMAGE: ghcr.io/named-data/ndnd:20261027@sha256:60032fc87a0c684f7bb7d4579691cb1c9225851e2b9e1445fa84fc4c0d5f5bd3 NDND_CA_HOST_DIR: ${PWD}/ndnd-root-ca-home/ndnd entrypoint: [python3, /app/http-ca-server.py] command: [/config/http-ca-server.yml] @@ -287,7 +288,7 @@ services: driver: local ndnd-repo: - image: ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a + image: ghcr.io/named-data/ndnd:20261027@sha256:60032fc87a0c684f7bb7d4579691cb1c9225851e2b9e1445fa84fc4c0d5f5bd3 pull_policy: always init: true volumes: @@ -310,7 +311,7 @@ services: driver: local ndnd-network-repo: - image: ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a + image: ghcr.io/named-data/ndnd:20261027@sha256:60032fc87a0c684f7bb7d4579691cb1c9225851e2b9e1445fa84fc4c0d5f5bd3 profiles: [ndnd] init: true volumes: @@ -343,7 +344,7 @@ services: driver: local ndnd-merkle: - image: ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a + image: ghcr.io/named-data/ndnd:20261027@sha256:60032fc87a0c684f7bb7d4579691cb1c9225851e2b9e1445fa84fc4c0d5f5bd3 pull_policy: always profiles: [merkle-log] # selected by config.yml through maintenance init: true @@ -371,7 +372,7 @@ services: driver: local ndnd-network-merkle: - image: ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a + image: ghcr.io/named-data/ndnd:20261027@sha256:60032fc87a0c684f7bb7d4579691cb1c9225851e2b9e1445fa84fc4c0d5f5bd3 pull_policy: always profiles: [ndnd-merkle-log] init: true diff --git a/framework/test_ndnd_status_trust.py b/framework/test_ndnd_status_trust.py new file mode 100644 index 0000000..b898634 --- /dev/null +++ b/framework/test_ndnd_status_trust.py @@ -0,0 +1,86 @@ +import base64 +import hashlib +from pathlib import Path +import unittest + +import jinja2 +import yaml +from ndn.app_support.light_versec import Checker, compile_lvs + +from internal import conf +from internal.render import JINJA_FUNCTIONS + + +class TestNdndStatusTrust(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.config = conf.get() + cls.hostvars = {} + for path in Path(cls.config.host_vars_path).iterdir(): + if path.is_file(): + cls.hostvars[path.name] = { + **yaml.safe_load(path.read_text()), + **cls.config.globals, + 'inventory_hostname': path.name, + } + cls.environment = jinja2.Environment( + loader=jinja2.FileSystemLoader(cls.config.environment_path), + undefined=jinja2.StrictUndefined, + trim_blocks=True, + lstrip_blocks=True, + ) + + def render(self, template, host): + return self.environment.get_template(template).render( + **self.hostvars[host], hostvars=self.hostvars, **JINJA_FUNCTIONS) + + def test_router_and_status_authorization(self): + root = self.config.globals['ndnd_dv_network'] + root_cert = root + '/KEY/root/self/v=1' + for host, values in self.hostvars.items(): + if not values.get('ndnd_enabled'): + continue + with self.subTest(host=host): + routing = self.render('templates/ndnd-dv/dv-schema.lvs.j2', host) + status = self.render('templates/ndnd-http-status-server/dv-schema.lvs.j2', host) + model = compile_lvs(routing) + self.assertEqual(0x00011000, model.version) + self.assertEqual(bytes(model.encode()), bytes(compile_lvs(status).encode())) + published = self.render('templates/file-server/ndnd/dv-schema.lvs.j2', host) + self.assertEqual(bytes(model.encode()), bytes(compile_lvs(published).encode())) + checker = Checker(model, {}) + router = values['ndnd_router_prefix'] + cert = router + '/32=DV/KEY/router/root/v=1' + self.assertTrue(checker.check(cert, root_cert)) + for name in [router + '/32=DV/32=STATUS', + '/localhop' + router + '/32=DV/32=ADV/v=1', + root + '/32=DV/32=PSD' + router + '/t=1/seq=1']: + self.assertTrue(checker.check(name, cert), name) + self.assertFalse(checker.check(name, root_cert), name) + self.assertFalse(checker.check(name, router + '/g/user/KEY/key/site/v=1'), name) + for peer, peer_values in self.hostvars.items(): + if peer != host and peer_values.get('ndnd_enabled'): + peer_cert = peer_values['ndnd_router_prefix'] + '/32=DV/KEY/router/root/v=1' + self.assertFalse(checker.check(name, peer_cert), name) + outsider = root + '/unlisted/32=DV' + self.assertFalse(checker.check(outsider + '/KEY/router/root/v=1', root_cert)) + self.assertFalse(checker.check(outsider + '/32=STATUS', cert)) + + dv = yaml.safe_load(self.render('templates/ndnd-dv/dv.yml.j2', host))['dv'] + self.assertEqual('/config/dv-schema.tlv', dv['trust_schema']) + fw = yaml.safe_load(self.render('templates/ndnd/yanfd.yml.j2', host)) + self.assertEqual(router, fw['fw']['router_name']) + + def test_public_status_anchor_matches_pin(self): + for host, values in self.hostvars.items(): + if values.get('ndnd_enabled'): + with self.subTest(host=host): + pem = self.render('templates/ndnd-http-status-server/root.cert.pem.j2', host) + wire = base64.b64decode(''.join(pem.splitlines()[1:-1]), validate=True) + pinned = base64.b64decode(''.join(Path(values['ndnd_root_anchor_path']).read_text().split()), validate=True) + self.assertEqual(pinned, wire) + self.assertEqual(values['ndnd_root_certificate_sha256'], hashlib.sha256(wire).hexdigest()) + + +if __name__ == '__main__': + unittest.main() diff --git a/templates/caddy/Caddyfile.j2 b/templates/caddy/Caddyfile.j2 index b05dc27..aef754f 100644 --- a/templates/caddy/Caddyfile.j2 +++ b/templates/caddy/Caddyfile.j2 @@ -1,5 +1,6 @@ {{ ansible_host }} { {% if ndnd_enabled | default(false) %} + redir /ndnd-status /ndnd-status/ 308 handle_path /ndnd-status/* { reverse_proxy http://ndnd-http-status-server:6380 } diff --git a/templates/file-server/ndnd/dv-schema.lvs.j2 b/templates/file-server/ndnd/dv-schema.lvs.j2 new file mode 100644 index 0000000..25418dd --- /dev/null +++ b/templates/file-server/ndnd/dv-schema.lvs.j2 @@ -0,0 +1 @@ +{% include "templates/ndnd-dv/dv-schema.lvs.j2" %} diff --git a/templates/ndnd-dv/dv-schema.lvs.j2 b/templates/ndnd-dv/dv-schema.lvs.j2 index 1dc0dbd..0fc1e63 100644 --- a/templates/ndnd-dv/dv-schema.lvs.j2 +++ b/templates/ndnd-dv/dv-schema.lvs.j2 @@ -11,6 +11,7 @@ #router_{{ loop.index }}: {{ router }} #router_cert_{{ loop.index }}: #router_{{ loop.index }}/"32=DV"/#KEY <= #network_cert #advertisement_data_{{ loop.index }}: /"localhop"/#router_{{ loop.index }}/"32=DV"/"32=ADV"/_ <= #router_cert_{{ loop.index }} +#status_data_{{ loop.index }}: #router_{{ loop.index }}/"32=DV"/"32=STATUS" <= #router_cert_{{ loop.index }} #prefix_state_data_{{ loop.index }}: #prefix_state/#router_{{ loop.index }}/_/_ <= #router_cert_{{ loop.index }} {% endif %} -{% endfor %} \ No newline at end of file +{% endfor %} diff --git a/templates/ndnd-dv/dv.yml.j2 b/templates/ndnd-dv/dv.yml.j2 index 34c1f76..02e83ad 100644 --- a/templates/ndnd-dv/dv.yml.j2 +++ b/templates/ndnd-dv/dv.yml.j2 @@ -2,6 +2,7 @@ dv: network: {{ ndnd_dv_network | tojson }} router: {{ ndnd_router_prefix | tojson }} keychain: dir:///config/keys + trust_schema: /config/dv-schema.tlv trust_anchors: - {{ ndn_cert_name(read_file(ndnd_root_anchor_path)) | tojson }} neighbors: diff --git a/templates/ndnd-http-status-server/dv-schema.lvs.j2 b/templates/ndnd-http-status-server/dv-schema.lvs.j2 new file mode 100644 index 0000000..25418dd --- /dev/null +++ b/templates/ndnd-http-status-server/dv-schema.lvs.j2 @@ -0,0 +1 @@ +{% include "templates/ndnd-dv/dv-schema.lvs.j2" %} diff --git a/templates/ndnd-http-status-server/root.cert.pem.j2 b/templates/ndnd-http-status-server/root.cert.pem.j2 new file mode 100644 index 0000000..960f641 --- /dev/null +++ b/templates/ndnd-http-status-server/root.cert.pem.j2 @@ -0,0 +1,3 @@ +-----BEGIN NDN CERT----- +{{ oneline(read_file(ndnd_root_anchor_path)) }} +-----END NDN CERT----- diff --git a/templates/ndnd/yanfd.yml.j2 b/templates/ndnd/yanfd.yml.j2 index 1bc83ce..74b9fc2 100644 --- a/templates/ndnd/yanfd.yml.j2 +++ b/templates/ndnd/yanfd.yml.j2 @@ -1,3 +1,6 @@ +fw: + router_name: {{ ndnd_router_prefix | tojson }} + mgmt: allow_localhop: true From ff3bdd8a6ff9b8b9503bfa2f0254def8f65eceef Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Tue, 27 Oct 2026 02:21:36 -0700 Subject: [PATCH 42/52] Stop deployment when repository updates fail --- scripts/cron-master.sh | 2 +- scripts/master.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/cron-master.sh b/scripts/cron-master.sh index 82b6a61..b462de6 100755 --- a/scripts/cron-master.sh +++ b/scripts/cron-master.sh @@ -21,7 +21,7 @@ fi # Remove git lock file if it exists and pull the latest changes rm -f .git/index.lock -git pull +git pull --ff-only || exit $? # Bootstrap and verify the dedicated NDNd CA root before rendering DV trust. python3 framework/ndnd_ca_bootstrap.py || exit $? diff --git a/scripts/master.sh b/scripts/master.sh index 4b7f8da..b0ded96 100755 --- a/scripts/master.sh +++ b/scripts/master.sh @@ -17,7 +17,7 @@ source .env if [[ -z "$DEBUG" ]]; then # Initial repo pull git config --global --add safe.directory /testbed - git pull + git pull --ff-only # Bootstrap and verify the dedicated NDNd CA root before rendering DV trust. python3 framework/ndnd_ca_bootstrap.py From bbf6666f7affa7df63e0c334d35a74c9c9c59629 Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Tue, 27 Oct 2026 02:26:10 -0700 Subject: [PATCH 43/52] Retain compatible repository and Merkle images --- README.md | 9 ++++++--- docker-compose.yml | 8 ++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 46072d4..d3df2fc 100644 --- a/README.md +++ b/README.md @@ -151,10 +151,13 @@ sudo unattended-upgrades --debug ## NDNd status -NDNd services use the digest-pinned DV2 image from +The NDNd forwarder, DV router, status server, and CA services use the +digest-pinned DV2 image from [workflow run 40476201514](https://github.com/named-data/ndnd/actions/runs/40476201514). -Upgrade the forwarder, DV router, status server, repositories, Merkle logs, and -CA services together; the DV2 BIFT management dataset uses TLV encoding. +Upgrade the forwarder, DV router, and status server together; the DV2 BIFT +management dataset uses TLV encoding. Repositories and Merkle logs retain the +October 22 image: this DV2 build does not support repository management trust +schemas or the Merkle command. On hosts with `ndnd_enabled: true`, Caddy exposes: diff --git a/docker-compose.yml b/docker-compose.yml index 79b3a02..501bd3b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -288,7 +288,7 @@ services: driver: local ndnd-repo: - image: ghcr.io/named-data/ndnd:20261027@sha256:60032fc87a0c684f7bb7d4579691cb1c9225851e2b9e1445fa84fc4c0d5f5bd3 + image: ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a pull_policy: always init: true volumes: @@ -311,7 +311,7 @@ services: driver: local ndnd-network-repo: - image: ghcr.io/named-data/ndnd:20261027@sha256:60032fc87a0c684f7bb7d4579691cb1c9225851e2b9e1445fa84fc4c0d5f5bd3 + image: ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a profiles: [ndnd] init: true volumes: @@ -344,7 +344,7 @@ services: driver: local ndnd-merkle: - image: ghcr.io/named-data/ndnd:20261027@sha256:60032fc87a0c684f7bb7d4579691cb1c9225851e2b9e1445fa84fc4c0d5f5bd3 + image: ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a pull_policy: always profiles: [merkle-log] # selected by config.yml through maintenance init: true @@ -372,7 +372,7 @@ services: driver: local ndnd-network-merkle: - image: ghcr.io/named-data/ndnd:20261027@sha256:60032fc87a0c684f7bb7d4579691cb1c9225851e2b9e1445fa84fc4c0d5f5bd3 + image: ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a pull_policy: always profiles: [ndnd-merkle-log] init: true From 80486270b5d23ca37e9de3c57d53e8201c516800 Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Tue, 27 Oct 2026 03:45:37 -0700 Subject: [PATCH 44/52] Deploy DV2 repository schema image from run 40489426886 --- README.md | 16 ++++++++++------ config.yml | 2 +- docker-compose.yml | 14 +++++++------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index d3df2fc..7f68624 100644 --- a/README.md +++ b/README.md @@ -151,13 +151,17 @@ sudo unattended-upgrades --debug ## NDNd status -The NDNd forwarder, DV router, status server, and CA services use the -digest-pinned DV2 image from -[workflow run 40476201514](https://github.com/named-data/ndnd/actions/runs/40476201514). +The NDNd forwarder, DV router, status server, CA services, and `/ndnd` repository +use the digest-pinned DV2 image from +[workflow run 40489426886](https://github.com/named-data/ndnd/actions/runs/40489426886). Upgrade the forwarder, DV router, and status server together; the DV2 BIFT -management dataset uses TLV encoding. Repositories and Merkle logs retain the -October 22 image: this DV2 build does not support repository management trust -schemas or the Merkle command. +management dataset uses TLV encoding. Both repository configurations explicitly +supply their management trust schema. + +The NFD-connected `ndnd-repo` retains the October 22 image because DV2's local +prefix advertising uses the DV management API instead of NFD RIB registration. +Both Merkle logs also retain that image because this DV2 build lacks the Merkle +command. On hosts with `ndnd_enabled: true`, Caddy exposes: diff --git a/config.yml b/config.yml index f68d986..f69f96f 100644 --- a/config.yml +++ b/config.yml @@ -126,7 +126,7 @@ globals: ndnd_udp_port: 6364 ndnd_dv_network: /ndnd ndnd_ca_host: UCLA - ndnd_ca_image: ghcr.io/named-data/ndnd:20261027@sha256:60032fc87a0c684f7bb7d4579691cb1c9225851e2b9e1445fa84fc4c0d5f5bd3 + ndnd_ca_image: ghcr.io/named-data/ndnd:20261027@sha256:ef2110d2df302bf5131046d7d2406c74591141d7e9b14beee7378ed452faa384 ndnd_ca_info: "NDNd Testbed Go CA" ndnd_ca_max_validity_period: "7776000" ndnd_ca_max_suffix_length: "5" diff --git a/docker-compose.yml b/docker-compose.yml index 501bd3b..fc5aa2c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,7 +44,7 @@ services: driver: local ndnd: - image: ghcr.io/named-data/ndnd:20261027@sha256:60032fc87a0c684f7bb7d4579691cb1c9225851e2b9e1445fa84fc4c0d5f5bd3 + image: ghcr.io/named-data/ndnd:20261027@sha256:ef2110d2df302bf5131046d7d2406c74591141d7e9b14beee7378ed452faa384 pull_policy: always profiles: [ndnd] init: true @@ -67,7 +67,7 @@ services: driver: local ndnd-dv: - image: ghcr.io/named-data/ndnd:20261027@sha256:60032fc87a0c684f7bb7d4579691cb1c9225851e2b9e1445fa84fc4c0d5f5bd3 + image: ghcr.io/named-data/ndnd:20261027@sha256:ef2110d2df302bf5131046d7d2406c74591141d7e9b14beee7378ed452faa384 pull_policy: always profiles: [ndnd] init: true @@ -90,7 +90,7 @@ services: driver: local ndnd-http-status-server: - image: ghcr.io/named-data/ndnd:20261027@sha256:60032fc87a0c684f7bb7d4579691cb1c9225851e2b9e1445fa84fc4c0d5f5bd3 + image: ghcr.io/named-data/ndnd:20261027@sha256:ef2110d2df302bf5131046d7d2406c74591141d7e9b14beee7378ed452faa384 pull_policy: always profiles: [ndnd] init: true @@ -110,7 +110,7 @@ services: driver: local ndnd-go-ca: - image: ghcr.io/named-data/ndnd:20261027@sha256:60032fc87a0c684f7bb7d4579691cb1c9225851e2b9e1445fa84fc4c0d5f5bd3 + image: ghcr.io/named-data/ndnd:20261027@sha256:ef2110d2df302bf5131046d7d2406c74591141d7e9b14beee7378ed452faa384 pull_policy: always profiles: [ndnd-go-ca] init: true @@ -132,7 +132,7 @@ services: driver: local ndnd-go-root-ca: - image: ghcr.io/named-data/ndnd:20261027@sha256:60032fc87a0c684f7bb7d4579691cb1c9225851e2b9e1445fa84fc4c0d5f5bd3 + image: ghcr.io/named-data/ndnd:20261027@sha256:ef2110d2df302bf5131046d7d2406c74591141d7e9b14beee7378ed452faa384 pull_policy: always profiles: [ndnd-go-root-ca] init: true @@ -165,7 +165,7 @@ services: - ${PWD}/dist/ndnd-go-root-ca/cert-store:/cert-store environment: NDND_ROOT_CA_SECRET: ${VAR_NDND_ROOT_CA_SECRET:?VAR_NDND_ROOT_CA_SECRET must be set} - NDND_CA_IMAGE: ghcr.io/named-data/ndnd:20261027@sha256:60032fc87a0c684f7bb7d4579691cb1c9225851e2b9e1445fa84fc4c0d5f5bd3 + NDND_CA_IMAGE: ghcr.io/named-data/ndnd:20261027@sha256:ef2110d2df302bf5131046d7d2406c74591141d7e9b14beee7378ed452faa384 NDND_CA_HOST_DIR: ${PWD}/ndnd-root-ca-home/ndnd entrypoint: [python3, /app/http-ca-server.py] command: [/config/http-ca-server.yml] @@ -311,7 +311,7 @@ services: driver: local ndnd-network-repo: - image: ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a + image: ghcr.io/named-data/ndnd:20261027@sha256:ef2110d2df302bf5131046d7d2406c74591141d7e9b14beee7378ed452faa384 profiles: [ndnd] init: true volumes: From f8ed17517e5497676987876fbf829f3015de6934 Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Tue, 27 Oct 2026 04:12:56 -0700 Subject: [PATCH 45/52] Enable NDNd at HK, Singapore, and Frankfurt --- host_vars/FRANKFURT | 3 +++ host_vars/HK | 3 +++ host_vars/SINGAPORE | 3 +++ 3 files changed, 9 insertions(+) diff --git a/host_vars/FRANKFURT b/host_vars/FRANKFURT index b367e10..9e583e0 100644 --- a/host_vars/FRANKFURT +++ b/host_vars/FRANKFURT @@ -37,3 +37,6 @@ position: hr_angle: 0 hr_radius: 0 ethernet_device: eth0 +ndnd_ca_prefix: /ndnd/frankfurt +ndnd_enabled: true +ndnd_router_prefix: /ndnd/frankfurt diff --git a/host_vars/HK b/host_vars/HK index e71458b..738dd60 100644 --- a/host_vars/HK +++ b/host_vars/HK @@ -27,3 +27,6 @@ position: hr_angle: 0 hr_radius: 0 ethernet_device: eth0 +ndnd_ca_prefix: /ndnd/hk +ndnd_enabled: true +ndnd_router_prefix: /ndnd/hk diff --git a/host_vars/SINGAPORE b/host_vars/SINGAPORE index 18cd1db..e1b86e5 100644 --- a/host_vars/SINGAPORE +++ b/host_vars/SINGAPORE @@ -35,3 +35,6 @@ position: hr_angle: 0 hr_radius: 0 ethernet_device: eth0 +ndnd_ca_prefix: /ndnd/singapore +ndnd_enabled: true +ndnd_router_prefix: /ndnd/singapore From 664f269cbfbf88e298f7f89ba3eae51e1eb894cf Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Fri, 30 Oct 2026 06:08:46 -0700 Subject: [PATCH 46/52] Reload the HTTP signer when host authorization changes Give the HTTP signer its own template directory so the renderer detects its configuration changes and restarts the signer instead of consuming them while rendering the root CA. --- config.yml | 2 +- .../{ndnd-go-ca => ndnd-root-http-ca}/http-ca-server.yml.j2 | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename templates/{ndnd-go-ca => ndnd-root-http-ca}/http-ca-server.yml.j2 (100%) diff --git a/config.yml b/config.yml index f69f96f..a05d3d6 100644 --- a/config.yml +++ b/config.yml @@ -39,7 +39,7 @@ services: ndnd-root-http-ca: hosts: [UCLA] profile: ndnd-go-root-ca - template_path: templates/ndnd-go-ca + template_path: templates/ndnd-root-http-ca render_path: dist/ndnd-go-root-config caddy: diff --git a/templates/ndnd-go-ca/http-ca-server.yml.j2 b/templates/ndnd-root-http-ca/http-ca-server.yml.j2 similarity index 100% rename from templates/ndnd-go-ca/http-ca-server.yml.j2 rename to templates/ndnd-root-http-ca/http-ca-server.yml.j2 From 51a235622131e9837a8c8cf715f7e2376c003921 Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Tue, 27 Oct 2026 04:25:10 -0700 Subject: [PATCH 47/52] Allow preserving an existing NFD repository image --- README.md | 3 +++ docker-compose.yml | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7f68624..99925ea 100644 --- a/README.md +++ b/README.md @@ -162,6 +162,9 @@ The NFD-connected `ndnd-repo` retains the October 22 image because DV2's local prefix advertising uses the DV management API instead of NFD RIB registration. Both Merkle logs also retain that image because this DV2 build lacks the Merkle command. +Nodes can preserve an existing NFD-connected repository image with +`NDND_NFD_REPO_IMAGE` and its pull policy with `NDND_NFD_REPO_PULL_POLICY` in `.env`. +These settings apply only to `ndnd-repo`. On hosts with `ndnd_enabled: true`, Caddy exposes: diff --git a/docker-compose.yml b/docker-compose.yml index fc5aa2c..a6660d1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -288,8 +288,8 @@ services: driver: local ndnd-repo: - image: ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a - pull_policy: always + image: ${NDND_NFD_REPO_IMAGE:-ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a} + pull_policy: ${NDND_NFD_REPO_PULL_POLICY:-always} init: true volumes: - /run/nfd:/run/nfd:ro From 77c6665c0b4dc14e5cb2d29f5a63619aba9c2236 Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Tue, 27 Oct 2026 21:30:41 -0700 Subject: [PATCH 48/52] Deploy NDNd staging image from run 40631720501 Pin the NDNd-network forwarder, DV, status, certificate authorities, repository and Merkle service to staging revision 993a483. Keep the NFD-connected repository and Merkle images unchanged. --- config.yml | 2 +- docker-compose.yml | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/config.yml b/config.yml index a05d3d6..7f321ea 100644 --- a/config.yml +++ b/config.yml @@ -126,7 +126,7 @@ globals: ndnd_udp_port: 6364 ndnd_dv_network: /ndnd ndnd_ca_host: UCLA - ndnd_ca_image: ghcr.io/named-data/ndnd:20261027@sha256:ef2110d2df302bf5131046d7d2406c74591141d7e9b14beee7378ed452faa384 + ndnd_ca_image: ghcr.io/named-data/ndnd:dv2-staging@sha256:cd362167f0d34804ba79cc33ba654e35d666f39c9a729debafe0e93b40348a9c ndnd_ca_info: "NDNd Testbed Go CA" ndnd_ca_max_validity_period: "7776000" ndnd_ca_max_suffix_length: "5" diff --git a/docker-compose.yml b/docker-compose.yml index a6660d1..c50ab99 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,7 +44,7 @@ services: driver: local ndnd: - image: ghcr.io/named-data/ndnd:20261027@sha256:ef2110d2df302bf5131046d7d2406c74591141d7e9b14beee7378ed452faa384 + image: ghcr.io/named-data/ndnd:dv2-staging@sha256:cd362167f0d34804ba79cc33ba654e35d666f39c9a729debafe0e93b40348a9c pull_policy: always profiles: [ndnd] init: true @@ -67,7 +67,7 @@ services: driver: local ndnd-dv: - image: ghcr.io/named-data/ndnd:20261027@sha256:ef2110d2df302bf5131046d7d2406c74591141d7e9b14beee7378ed452faa384 + image: ghcr.io/named-data/ndnd:dv2-staging@sha256:cd362167f0d34804ba79cc33ba654e35d666f39c9a729debafe0e93b40348a9c pull_policy: always profiles: [ndnd] init: true @@ -90,7 +90,7 @@ services: driver: local ndnd-http-status-server: - image: ghcr.io/named-data/ndnd:20261027@sha256:ef2110d2df302bf5131046d7d2406c74591141d7e9b14beee7378ed452faa384 + image: ghcr.io/named-data/ndnd:dv2-staging@sha256:cd362167f0d34804ba79cc33ba654e35d666f39c9a729debafe0e93b40348a9c pull_policy: always profiles: [ndnd] init: true @@ -110,7 +110,7 @@ services: driver: local ndnd-go-ca: - image: ghcr.io/named-data/ndnd:20261027@sha256:ef2110d2df302bf5131046d7d2406c74591141d7e9b14beee7378ed452faa384 + image: ghcr.io/named-data/ndnd:dv2-staging@sha256:cd362167f0d34804ba79cc33ba654e35d666f39c9a729debafe0e93b40348a9c pull_policy: always profiles: [ndnd-go-ca] init: true @@ -132,7 +132,7 @@ services: driver: local ndnd-go-root-ca: - image: ghcr.io/named-data/ndnd:20261027@sha256:ef2110d2df302bf5131046d7d2406c74591141d7e9b14beee7378ed452faa384 + image: ghcr.io/named-data/ndnd:dv2-staging@sha256:cd362167f0d34804ba79cc33ba654e35d666f39c9a729debafe0e93b40348a9c pull_policy: always profiles: [ndnd-go-root-ca] init: true @@ -165,7 +165,7 @@ services: - ${PWD}/dist/ndnd-go-root-ca/cert-store:/cert-store environment: NDND_ROOT_CA_SECRET: ${VAR_NDND_ROOT_CA_SECRET:?VAR_NDND_ROOT_CA_SECRET must be set} - NDND_CA_IMAGE: ghcr.io/named-data/ndnd:20261027@sha256:ef2110d2df302bf5131046d7d2406c74591141d7e9b14beee7378ed452faa384 + NDND_CA_IMAGE: ghcr.io/named-data/ndnd:dv2-staging@sha256:cd362167f0d34804ba79cc33ba654e35d666f39c9a729debafe0e93b40348a9c NDND_CA_HOST_DIR: ${PWD}/ndnd-root-ca-home/ndnd entrypoint: [python3, /app/http-ca-server.py] command: [/config/http-ca-server.yml] @@ -311,7 +311,7 @@ services: driver: local ndnd-network-repo: - image: ghcr.io/named-data/ndnd:20261027@sha256:ef2110d2df302bf5131046d7d2406c74591141d7e9b14beee7378ed452faa384 + image: ghcr.io/named-data/ndnd:dv2-staging@sha256:cd362167f0d34804ba79cc33ba654e35d666f39c9a729debafe0e93b40348a9c profiles: [ndnd] init: true volumes: @@ -372,7 +372,7 @@ services: driver: local ndnd-network-merkle: - image: ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a + image: ghcr.io/named-data/ndnd:dv2-staging@sha256:cd362167f0d34804ba79cc33ba654e35d666f39c9a729debafe0e93b40348a9c pull_policy: always profiles: [ndnd-merkle-log] init: true From 934906c14fa7184ceb363bfb9b7e3a0026997ef0 Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Thu, 29 Oct 2026 17:17:11 -0700 Subject: [PATCH 49/52] Deploy NDNd staging image from run 40977341660 Update the forwarder, DV, status, CA and NDNd-network Merkle image pins to e834064. Preserve both repository images and NFD-connected Merkle. --- config.yml | 2 +- docker-compose.yml | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/config.yml b/config.yml index 7f321ea..5d19e4f 100644 --- a/config.yml +++ b/config.yml @@ -126,7 +126,7 @@ globals: ndnd_udp_port: 6364 ndnd_dv_network: /ndnd ndnd_ca_host: UCLA - ndnd_ca_image: ghcr.io/named-data/ndnd:dv2-staging@sha256:cd362167f0d34804ba79cc33ba654e35d666f39c9a729debafe0e93b40348a9c + ndnd_ca_image: ghcr.io/named-data/ndnd:dv2-staging@sha256:aba4d409d0f3ed2a7b134bd5d0ade0e0c9c37ad55e69254951c306f961b36d5b ndnd_ca_info: "NDNd Testbed Go CA" ndnd_ca_max_validity_period: "7776000" ndnd_ca_max_suffix_length: "5" diff --git a/docker-compose.yml b/docker-compose.yml index c50ab99..f314709 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,7 +44,7 @@ services: driver: local ndnd: - image: ghcr.io/named-data/ndnd:dv2-staging@sha256:cd362167f0d34804ba79cc33ba654e35d666f39c9a729debafe0e93b40348a9c + image: ghcr.io/named-data/ndnd:dv2-staging@sha256:aba4d409d0f3ed2a7b134bd5d0ade0e0c9c37ad55e69254951c306f961b36d5b pull_policy: always profiles: [ndnd] init: true @@ -67,7 +67,7 @@ services: driver: local ndnd-dv: - image: ghcr.io/named-data/ndnd:dv2-staging@sha256:cd362167f0d34804ba79cc33ba654e35d666f39c9a729debafe0e93b40348a9c + image: ghcr.io/named-data/ndnd:dv2-staging@sha256:aba4d409d0f3ed2a7b134bd5d0ade0e0c9c37ad55e69254951c306f961b36d5b pull_policy: always profiles: [ndnd] init: true @@ -90,7 +90,7 @@ services: driver: local ndnd-http-status-server: - image: ghcr.io/named-data/ndnd:dv2-staging@sha256:cd362167f0d34804ba79cc33ba654e35d666f39c9a729debafe0e93b40348a9c + image: ghcr.io/named-data/ndnd:dv2-staging@sha256:aba4d409d0f3ed2a7b134bd5d0ade0e0c9c37ad55e69254951c306f961b36d5b pull_policy: always profiles: [ndnd] init: true @@ -110,7 +110,7 @@ services: driver: local ndnd-go-ca: - image: ghcr.io/named-data/ndnd:dv2-staging@sha256:cd362167f0d34804ba79cc33ba654e35d666f39c9a729debafe0e93b40348a9c + image: ghcr.io/named-data/ndnd:dv2-staging@sha256:aba4d409d0f3ed2a7b134bd5d0ade0e0c9c37ad55e69254951c306f961b36d5b pull_policy: always profiles: [ndnd-go-ca] init: true @@ -132,7 +132,7 @@ services: driver: local ndnd-go-root-ca: - image: ghcr.io/named-data/ndnd:dv2-staging@sha256:cd362167f0d34804ba79cc33ba654e35d666f39c9a729debafe0e93b40348a9c + image: ghcr.io/named-data/ndnd:dv2-staging@sha256:aba4d409d0f3ed2a7b134bd5d0ade0e0c9c37ad55e69254951c306f961b36d5b pull_policy: always profiles: [ndnd-go-root-ca] init: true @@ -165,7 +165,7 @@ services: - ${PWD}/dist/ndnd-go-root-ca/cert-store:/cert-store environment: NDND_ROOT_CA_SECRET: ${VAR_NDND_ROOT_CA_SECRET:?VAR_NDND_ROOT_CA_SECRET must be set} - NDND_CA_IMAGE: ghcr.io/named-data/ndnd:dv2-staging@sha256:cd362167f0d34804ba79cc33ba654e35d666f39c9a729debafe0e93b40348a9c + NDND_CA_IMAGE: ghcr.io/named-data/ndnd:dv2-staging@sha256:aba4d409d0f3ed2a7b134bd5d0ade0e0c9c37ad55e69254951c306f961b36d5b NDND_CA_HOST_DIR: ${PWD}/ndnd-root-ca-home/ndnd entrypoint: [python3, /app/http-ca-server.py] command: [/config/http-ca-server.yml] @@ -372,7 +372,7 @@ services: driver: local ndnd-network-merkle: - image: ghcr.io/named-data/ndnd:dv2-staging@sha256:cd362167f0d34804ba79cc33ba654e35d666f39c9a729debafe0e93b40348a9c + image: ghcr.io/named-data/ndnd:dv2-staging@sha256:aba4d409d0f3ed2a7b134bd5d0ade0e0c9c37ad55e69254951c306f961b36d5b pull_policy: always profiles: [ndnd-merkle-log] init: true From 55e071b56db6421785ab53fe1f4778a1ab63642f Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Thu, 29 Oct 2026 17:57:48 -0700 Subject: [PATCH 50/52] Use NLSR neighbor topology for NDNd routing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Select peers from each host’s existing neighbors list and retain only NDNd-enabled sites. Keep NDNd UDP transport and hop-count routing unchanged. --- templates/ndnd-dv/dv.yml.j2 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/ndnd-dv/dv.yml.j2 b/templates/ndnd-dv/dv.yml.j2 index 02e83ad..7a25c92 100644 --- a/templates/ndnd-dv/dv.yml.j2 +++ b/templates/ndnd-dv/dv.yml.j2 @@ -7,7 +7,8 @@ dv: - {{ ndn_cert_name(read_file(ndnd_root_anchor_path)) | tojson }} neighbors: {% set peers = namespace(count=0) %} - {% for host, values in hostvars.items() %} + {% for host in neighbors %} + {% set values = hostvars[host] %} {% if host != inventory_hostname and values.get('ndnd_enabled', false) %} - uri: {{ ("udp4://" + values.host_ip + ":" + str(ndnd_udp_port)) | tojson }} {% set peers.count = peers.count + 1 %} From e40fc34c730dd5215c5282a09b1517525328a559 Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Fri, 30 Oct 2026 06:08:56 -0700 Subject: [PATCH 51/52] Bridge NFD and NDNd networks with symmetric gateway routes Advertise /ndnd through NLSR and /ndn through DV using persistent local UDP faces. Initialize BIER mappings and restore runtime entries after forwarder restarts. Use capture on the NFD gateway route to exclude inherited parent routes, and mount only the NDNd socket directory in the temporary management helper. --- README.md | 28 ++++++ config.yml | 1 + framework/internal/ndnd_network.py | 138 +++++++++++++++++++++++++++++ framework/ndnd-network-init.py | 18 ++++ framework/test_ndnd_network.py | 112 +++++++++++++++++++++++ host_vars/ARIZONA | 1 + host_vars/FRANKFURT | 1 + host_vars/HK | 1 + host_vars/MEMPHIS | 1 + host_vars/SINGAPORE | 1 + host_vars/UCLA | 1 + scripts/cron-host.sh | 5 +- scripts/cron-master.sh | 3 + templates/ndnd/yanfd.yml.j2 | 1 + templates/nlsr/nlsr.conf.j2 | 3 + 15 files changed, 314 insertions(+), 1 deletion(-) create mode 100644 framework/internal/ndnd_network.py create mode 100644 framework/ndnd-network-init.py create mode 100644 framework/test_ndnd_network.py diff --git a/README.md b/README.md index 99925ea..077661b 100644 --- a/README.md +++ b/README.md @@ -188,3 +188,31 @@ The status server validates `//32=DV/32=STATUS` before including the routing dataset. It does not fall back to an unrestricted schema. The local DV summary remains available if the signed dataset cannot be validated; check the status server logs and the report's routing state in that case. + + +## NDNd network bridge + +NDNd-enabled sites bridge the two forwarders locally over UDP. NFD sends `/ndnd` +Interests to NDNd through a capture route, excluding inherited root routes, and +advertises `/ndnd` through NLSR. NDNd installs a `/ndn` PET +next hop toward NFD and advertises it through DV. Producers still register on +the network matching their top-level prefix; the bridge does not redistribute +producer registrations or change application trust policies. + +Each enabled host needs a unique, stable `ndnd_bier_index`. The forwarder loads +that index at startup, and `framework/ndnd-network-init.py` registers the same +router-to-index inventory on every node and rebuilds the BIFT. Both cron scripts +run this initializer after service updates. It binds announcements to permanent +UDP faces, restores entries after restarts, and reloads NDNd-connected producers +when their forwarder's startup time changes. The NFD-connected repository and +Merkle service are outside that restart group. + +To reconcile a running node manually from its checkout: + +```bash +docker compose exec -T -e PWD="$PWD" master python3 framework/ndnd-network-init.py +``` + +The bridge has static routes. An abrupt peer failure does not automatically +withdraw its gateway advertisement; alternative gateway advertisements alone do +not guarantee immediate failover. Gateway health tracking is not implemented here. diff --git a/config.yml b/config.yml index 5d19e4f..1f567f9 100644 --- a/config.yml +++ b/config.yml @@ -169,3 +169,4 @@ variables: is_status_page: "?boolean" ndnd_enabled: "?boolean" ndnd_router_prefix: "?string" + ndnd_bier_index: "?number" diff --git a/framework/internal/ndnd_network.py b/framework/internal/ndnd_network.py new file mode 100644 index 0000000..83d47a2 --- /dev/null +++ b/framework/internal/ndnd_network.py @@ -0,0 +1,138 @@ +"""Initialize BIER and the local NFD–NDNd gateway after service startup.""" + +import json +import os +from pathlib import Path +import re +import subprocess +import time + +import yaml + +from . import conf + + +def router_indices(hosts): + routers = {} + for name, host in hosts.items(): + if not host.get('ndnd_enabled', False): + continue + index = host.get('ndnd_bier_index') + if type(index) is not int or index < 0: + raise ValueError(f'{name}: ndnd_bier_index must be a non-negative integer') + prefix = host['ndnd_router_prefix'] + if index in routers or prefix in routers.values(): + raise ValueError(f'{name}: duplicate NDNd router prefix or BIER index') + routers[index] = prefix + return routers + + +def run(args, check=True, timeout=30): + result = subprocess.run(args, capture_output=True, text=True, timeout=timeout) + if check and result.returncode: + raise RuntimeError(f'{args}: {result.stderr.strip()}') + return result + + +def wait_ready(command): + for _ in range(20): + result = run(command, check=False) + if result.returncode == 0: + return + time.sleep(1) + raise RuntimeError(f'Service not ready: {command}: {result.stderr.strip()}') + + +def face_id(output, uri): + for match in re.finditer(r'^faceid=(\d+) remote=(\S+)', output, re.MULTILINE): + if match[2] == uri: + return match[1] + return None + + +def configure(containers, routers, network, port, previous): + nfd, fw = containers['nfd'], containers['ndnd'] + networks = nfd['NetworkSettings']['Networks'].keys() & fw['NetworkSettings']['Networks'].keys() + if len(networks) != 1: + raise RuntimeError('NFD and NDNd must share exactly one Docker network') + docker_network = next(iter(networks)) + to_nfd = 'udp4://' + nfd['NetworkSettings']['Networks'][docker_network]['IPAddress'] + ':6363' + to_ndnd = 'udp4://' + fw['NetworkSettings']['Networks'][docker_network]['IPAddress'] + ':' + str(port) + nfd_cmd = ['docker', 'exec', nfd['Id'], 'nfdc'] + ndnd_cmd = ['docker', 'exec', fw['Id'], '/ndnd'] + changed = previous.get('forwarder_started') != fw['State']['StartedAt'] + + wait_ready(ndnd_cmd + ['fw', 'status']) + wait_ready(nfd_cmd + ['status']) + for index, prefix in sorted(routers.items()): + run(ndnd_cmd + ['fw', 'bift-register', 'prefix=' + prefix, 'index=' + str(index)]) + run(ndnd_cmd + ['fw', 'bift-rebuild']) + if changed or not containers['ndnd-dv']['State']['Running']: + run(['docker', 'restart', containers['ndnd-dv']['Id']]) + wait_ready(ndnd_cmd + ['dv', 'status']) + + # Remove our previous bridge entries if Docker assigned a new peer address. + if previous.get('to_nfd') not in (None, to_nfd) and not changed: + old_face = face_id(run(ndnd_cmd + ['fw', 'face-list']).stdout, previous['to_nfd']) + if old_face: + run(ndnd_cmd + ['dv', 'prefix-withdraw', 'prefix=/ndn', 'face=' + old_face]) + run(ndnd_cmd + ['fw', 'pet-remove-nexthop', 'prefix=/ndn', 'face=' + old_face]) + if previous.get('to_ndnd') not in (None, to_ndnd): + # A missing old face means NFD already removed its routes. + if face_id(run(nfd_cmd + ['face', 'list']).stdout, previous['to_ndnd']): + run(nfd_cmd + ['route', 'remove', network, previous['to_ndnd']]) + + # nfdc updates existing on-demand faces too; NDNd's create-only CLI returns 409. + # Mount only the socket directory; nfdc needs its own writable client keychain. + socket_dir = next(m['Source'] for m in fw['Mounts'] if m['Destination'] == '/run/ndnd') + run(['docker', 'run', '--rm', '--network', 'none', + '--mount', 'type=bind,src=' + socket_dir + ',dst=/run/ndnd,readonly', + '-e', 'NDN_CLIENT_TRANSPORT=unix:///run/ndnd/ndnd.sock', + '--entrypoint', '/usr/bin/nfdc', nfd['Image'], + 'face', 'create', to_nfd, 'persistency', 'permanent']) + run(nfd_cmd + ['face', 'create', to_ndnd, 'persistency', 'permanent']) + # Exclude inherited application/default routes from the foreign namespace. + run(nfd_cmd + ['route', 'add', network, to_ndnd, 'capture']) + bridge_face = face_id(run(ndnd_cmd + ['fw', 'face-list']).stdout, to_nfd) + if bridge_face is None: + raise RuntimeError('NDNd bridge face was not created') + run(ndnd_cmd + ['fw', 'pet-add-nexthop', 'prefix=/ndn', 'face=' + bridge_face]) + # Bind the announcement to the UDP face, not this short-lived CLI connection. + run(ndnd_cmd + ['dv', 'prefix-announce', 'prefix=/ndn', 'face=' + bridge_face]) + run(ndnd_cmd + ['fw', 'bift-rebuild']) + + if changed: + # These services keep registrations on the forwarder's Unix socket. + dependents = ['ndnd-http-status-server', 'ndnd-go-ca', 'ndnd-go-root-ca', + 'ndnd-network-repo', 'ndnd-network-merkle'] + restart = [containers[s]['Id'] for s in dependents + if s in containers and containers[s]['State']['Running']] + if restart: + run(['docker', 'restart', *restart], timeout=120) + return {'forwarder_started': fw['State']['StartedAt'], 'to_nfd': to_nfd, 'to_ndnd': to_ndnd} + + +def reconcile(node): + config = conf.get() + hosts = {path.name: yaml.safe_load(path.read_text()) + for path in Path(config.host_vars_path).iterdir() if path.is_file()} + if not hosts[node].get('ndnd_enabled', False): + return + routers = router_indices(hosts) + os.environ['COMPOSE_PROFILES'] = conf.compose_profiles(node) + ids = run(['docker', 'compose', 'ps', '-aq']).stdout.split() + containers = {c['Config']['Labels']['com.docker.compose.service']: c + for c in json.loads(run(['docker', 'inspect', *ids]).stdout)} if ids else {} + if 'ndnd-dv' not in containers: + raise RuntimeError('ndnd-dv must be created before NDNd network initialization') + for service in ['nfd', 'ndnd']: + if service not in containers or not containers[service]['State']['Running']: + raise RuntimeError(f'{service} must be running before NDNd network initialization') + state_file = Path('dist/.ndnd-network-state.json') + previous = json.loads(state_file.read_text()) if state_file.exists() else {} + state = configure(containers, routers, config.globals['ndnd_dv_network'], + config.globals['ndnd_udp_port'], previous) + temporary = state_file.with_suffix('.tmp') + temporary.write_text(json.dumps(state)) + temporary.replace(state_file) + print('NDNd BIER and symmetric NFD gateway initialized') diff --git a/framework/ndnd-network-init.py b/framework/ndnd-network-init.py new file mode 100644 index 0000000..d64ddb6 --- /dev/null +++ b/framework/ndnd-network-init.py @@ -0,0 +1,18 @@ +"""Reconcile the local NDNd network after Compose or certificate updates.""" + +import fcntl +import os +from pathlib import Path + +from internal.ndnd_network import reconcile + + +if __name__ == '__main__': + Path('dist').mkdir(exist_ok=True) + with open('dist/.ndnd-network.lock', 'w') as lock: + try: + fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB) + except BlockingIOError: + print('NDNd network initialization already running') + else: + reconcile(os.environ['MANAGED_HOST']) diff --git a/framework/test_ndnd_network.py b/framework/test_ndnd_network.py new file mode 100644 index 0000000..b5582b4 --- /dev/null +++ b/framework/test_ndnd_network.py @@ -0,0 +1,112 @@ +import subprocess +import unittest +from unittest.mock import patch + +import jinja2 +import yaml + +from internal import ndnd_network +from internal import conf + + +class NetworkInitTest(unittest.TestCase): + def setUp(self): + self.commands = [] + self.containers = {} + for service, ip in [('nfd', '172.20.0.2'), ('ndnd', '172.20.0.3'), + ('ndnd-dv', ''), ('ndnd-network-repo', ''), + ('ndnd-go-ca', ''), ('ndnd-repo', ''), ('nlsr', '')]: + self.containers[service] = { + 'Id': service, 'Image': 'nfd-image', + 'Mounts': [{'Source': '/run/ndnd', 'Destination': '/run/ndnd'}, + {'Source': '/read-only/config', 'Destination': '/config'}], + 'State': {'Running': True, 'StartedAt': 'start-1'}, + 'NetworkSettings': {'Networks': {'default': {'IPAddress': ip}}}, + } + self.previous = {'forwarder_started': 'start-1', + 'to_nfd': 'udp4://172.20.0.2:6363', + 'to_ndnd': 'udp4://172.20.0.3:6364'} + + def run_command(self, args, check=True, **kwargs): + self.commands.append(args) + output = '' + if args[-2:] == ['fw', 'face-list']: + output = 'faceid=42 remote=udp4://172.20.0.2:6363\nfaceid=43 remote=udp4://172.20.0.9:6363\n' + elif args[-2:] == ['face', 'list']: + output = 'faceid=70 remote=udp4://172.20.0.8:6364\n' + return subprocess.CompletedProcess(args, 0, output, '') + + def configure(self, previous=None): + with patch.object(ndnd_network, 'run', side_effect=self.run_command): + return ndnd_network.configure(self.containers, {0: '/ndnd/a', 1: '/ndnd/b'}, + '/ndnd', 6364, self.previous if previous is None else previous) + + def test_announcement_uses_persistent_udp_face(self): + state = self.configure() + self.assertIn(['docker', 'exec', 'ndnd', '/ndnd', 'dv', 'prefix-announce', + 'prefix=/ndn', 'face=42'], self.commands) + self.assertEqual(state, self.previous) + self.assertIn(['docker', 'exec', 'nfd', 'nfdc', 'route', 'add', + '/ndnd', self.previous['to_ndnd'], 'capture'], self.commands) + self.assertTrue(any(c[:3] == ['docker', 'run', '--rm'] and + 'type=bind,src=/run/ndnd,dst=/run/ndnd,readonly' in c and + '--volumes-from' not in c and c[-4:] == ['create', self.previous['to_nfd'], + 'persistency', 'permanent'] + for c in self.commands)) + + def test_repeated_initialization_does_not_restart_services(self): + self.configure() + self.assertFalse(any(command[1] == 'restart' for command in self.commands)) + + def test_forwarder_restart_restores_only_its_dependents(self): + self.configure({}) + restarted = [command[2:] for command in self.commands if command[1] == 'restart'] + self.assertEqual(restarted, [['ndnd-dv'], ['ndnd-go-ca', 'ndnd-network-repo']]) + self.assertEqual(sum('bift-register' in command for command in self.commands), 2) + + def test_peer_address_change_removes_old_bridge_routes(self): + previous = dict(self.previous, to_nfd='udp4://172.20.0.9:6363', + to_ndnd='udp4://172.20.0.8:6364') + self.configure(previous) + self.assertIn(['docker', 'exec', 'ndnd', '/ndnd', 'dv', 'prefix-withdraw', + 'prefix=/ndn', 'face=43'], self.commands) + self.assertIn(['docker', 'exec', 'nfd', 'nfdc', 'route', 'remove', + '/ndnd', previous['to_ndnd']], self.commands) + + def test_stopped_dv_restarts_without_restarting_producers(self): + self.containers['ndnd-dv']['State']['Running'] = False + self.configure() + self.assertEqual([c[2:] for c in self.commands if c[1] == 'restart'], [['ndnd-dv']]) + + def test_duplicate_indices_rejected(self): + hosts = {'A': {'ndnd_enabled': True, 'ndnd_bier_index': 0, 'ndnd_router_prefix': '/ndnd/a'}, + 'B': {'ndnd_enabled': True, 'ndnd_bier_index': 0, 'ndnd_router_prefix': '/ndnd/b'}} + with self.assertRaises(ValueError): + ndnd_network.router_indices(hosts) + + def test_invalid_index_rejected(self): + for index in [None, -1, True, 1.5]: + with self.subTest(index=index), self.assertRaises(ValueError): + ndnd_network.router_indices({'A': {'ndnd_enabled': True, 'ndnd_bier_index': index}}) + + def test_enabled_hosts_have_stable_unique_indices_and_bridge_advertisements(self): + from pathlib import Path + config = conf.get() + hosts = {p.name: yaml.safe_load(p.read_text()) + for p in Path(config.host_vars_path).iterdir() if p.is_file()} + indices = ndnd_network.router_indices(hosts) + self.assertEqual(len(indices), 6) + env = jinja2.Environment(loader=jinja2.FileSystemLoader('.'), undefined=jinja2.StrictUndefined) + for name, host in hosts.items(): + context = dict(host, **config.globals) + context['hostvars'] = {n: dict(h, **config.globals) for n, h in hosts.items()} + rendered = env.get_template('templates/nlsr/nlsr.conf.j2').render(**context) + advertising = rendered.split('advertising\n{', 1)[1].split('}', 1)[0] + self.assertEqual('/ndnd 0' in advertising, bool(host.get('ndnd_enabled'))) + if host.get('ndnd_enabled'): + fw = yaml.safe_load(env.get_template('templates/ndnd/yanfd.yml.j2').render(**context)) + self.assertEqual(indices[fw['fw']['bier_index']], host['ndnd_router_prefix']) + + +if __name__ == '__main__': + unittest.main() diff --git a/host_vars/ARIZONA b/host_vars/ARIZONA index 02328f2..138ddc0 100644 --- a/host_vars/ARIZONA +++ b/host_vars/ARIZONA @@ -38,3 +38,4 @@ hr_radius: 16.2305 ethernet_device: eth0 ndnd_enabled: true ndnd_router_prefix: /ndnd/arizona +ndnd_bier_index: 2 diff --git a/host_vars/FRANKFURT b/host_vars/FRANKFURT index 9e583e0..b1a7055 100644 --- a/host_vars/FRANKFURT +++ b/host_vars/FRANKFURT @@ -40,3 +40,4 @@ ethernet_device: eth0 ndnd_ca_prefix: /ndnd/frankfurt ndnd_enabled: true ndnd_router_prefix: /ndnd/frankfurt +ndnd_bier_index: 5 diff --git a/host_vars/HK b/host_vars/HK index 738dd60..4e86092 100644 --- a/host_vars/HK +++ b/host_vars/HK @@ -30,3 +30,4 @@ ethernet_device: eth0 ndnd_ca_prefix: /ndnd/hk ndnd_enabled: true ndnd_router_prefix: /ndnd/hk +ndnd_bier_index: 3 diff --git a/host_vars/MEMPHIS b/host_vars/MEMPHIS index ef6b891..6b53709 100644 --- a/host_vars/MEMPHIS +++ b/host_vars/MEMPHIS @@ -33,3 +33,4 @@ hr_radius: 15.2647 ethernet_device: eth1 ndnd_enabled: true ndnd_router_prefix: /ndnd/memphis +ndnd_bier_index: 1 diff --git a/host_vars/SINGAPORE b/host_vars/SINGAPORE index e1b86e5..dc48247 100644 --- a/host_vars/SINGAPORE +++ b/host_vars/SINGAPORE @@ -38,3 +38,4 @@ ethernet_device: eth0 ndnd_ca_prefix: /ndnd/singapore ndnd_enabled: true ndnd_router_prefix: /ndnd/singapore +ndnd_bier_index: 4 diff --git a/host_vars/UCLA b/host_vars/UCLA index eb15d68..05e4d79 100644 --- a/host_vars/UCLA +++ b/host_vars/UCLA @@ -47,3 +47,4 @@ ethernet_device: eth0 is_root_ca: true ndnd_enabled: true ndnd_router_prefix: /ndnd/ucla +ndnd_bier_index: 0 diff --git a/scripts/cron-host.sh b/scripts/cron-host.sh index a09bd3f..74ae02a 100755 --- a/scripts/cron-host.sh +++ b/scripts/cron-host.sh @@ -29,6 +29,9 @@ COMPOSE_PROFILES=$(docker compose exec -T master python3 framework/service-profi export COMPOSE_PROFILES # Ensure services are running -docker compose up -d --remove-orphans +docker compose up -d --remove-orphans || exit $? + +# Services must be running before their management commands can install routes. +docker compose exec -T -e PWD="$PWD" master python3 framework/ndnd-network-init.py || exit $? echo -e "Finished cron-host at $(date)" >&2 diff --git a/scripts/cron-master.sh b/scripts/cron-master.sh index b462de6..e36e0ae 100755 --- a/scripts/cron-master.sh +++ b/scripts/cron-master.sh @@ -32,4 +32,7 @@ PWD="${ROOT_DIR}" python3 framework/main.py || exit $? # Renew certificates if needed bash $(pwd)/scripts/cert-renew.sh || exit $? +# Restore runtime forwarding entries after rendered services or credentials changed. +PWD="${ROOT_DIR:-$PWD}" python3 framework/ndnd-network-init.py || exit $? + echo -e "Finished cron-master at $(date)" >&2 diff --git a/templates/ndnd/yanfd.yml.j2 b/templates/ndnd/yanfd.yml.j2 index 74b9fc2..cb1a929 100644 --- a/templates/ndnd/yanfd.yml.j2 +++ b/templates/ndnd/yanfd.yml.j2 @@ -1,4 +1,5 @@ fw: + bier_index: {{ ndnd_bier_index }} router_name: {{ ndnd_router_prefix | tojson }} mgmt: diff --git a/templates/nlsr/nlsr.conf.j2 b/templates/nlsr/nlsr.conf.j2 index 4ca01c0..a8d0cb2 100644 --- a/templates/nlsr/nlsr.conf.j2 +++ b/templates/nlsr/nlsr.conf.j2 @@ -53,6 +53,9 @@ fib advertising { + {% if ndnd_enabled | default(false) and ndnd_dv_network not in advertised_prefixes %} + {{ ndnd_dv_network }} 0 + {% endif %} {% for prefix in advertised_prefixes %} {{ prefix }} 0 {% endfor %} From f4fe35a14d463b95bfd75e970be7a0f4f29f1186 Mon Sep 17 00:00:00 2001 From: Sirapop Theeranantachai Date: Fri, 30 Oct 2026 06:15:25 -0700 Subject: [PATCH 52/52] Limit the testbed patch to NDNd integration Remove per-node repository image overrides and restore upstream Git update and C++ NDNCERT renewal behavior. Correct stale image documentation and document the hop-count routing limitation. --- README.md | 15 +++++++-------- docker-compose.yml | 4 ++-- scripts/cron-master.sh | 2 +- scripts/master.sh | 2 +- templates/ndncert/renew.sh.j2 | 5 ++--- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 077661b..35bbf10 100644 --- a/README.md +++ b/README.md @@ -151,20 +151,16 @@ sudo unattended-upgrades --debug ## NDNd status -The NDNd forwarder, DV router, status server, CA services, and `/ndnd` repository -use the digest-pinned DV2 image from -[workflow run 40489426886](https://github.com/named-data/ndnd/actions/runs/40489426886). +The NDNd forwarder, DV router, status server, CA services, and `/ndnd` Merkle log +use the digest-pinned DV2 staging image configured in Compose. The `/ndnd` +repository retains its separately pinned DV2 image. Upgrade the forwarder, DV router, and status server together; the DV2 BIFT management dataset uses TLV encoding. Both repository configurations explicitly supply their management trust schema. The NFD-connected `ndnd-repo` retains the October 22 image because DV2's local prefix advertising uses the DV management API instead of NFD RIB registration. -Both Merkle logs also retain that image because this DV2 build lacks the Merkle -command. -Nodes can preserve an existing NFD-connected repository image with -`NDND_NFD_REPO_IMAGE` and its pull policy with `NDND_NFD_REPO_PULL_POLICY` in `.env`. -These settings apply only to `ndnd-repo`. +The NFD-connected Merkle log also retains the October 22 image. On hosts with `ndnd_enabled: true`, Caddy exposes: @@ -207,6 +203,9 @@ UDP faces, restores entries after restarts, and reloads NDNd-connected producers when their forwarder's startup time changes. The NFD-connected repository and Merkle service are outside that restart group. +NDNd uses the NLSR neighbor connections between enabled sites. DV2 currently +uses a fixed cost of 1 per link; it does not use NLSR's configured link costs. + To reconcile a running node manually from its checkout: ```bash diff --git a/docker-compose.yml b/docker-compose.yml index f314709..d801542 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -288,8 +288,8 @@ services: driver: local ndnd-repo: - image: ${NDND_NFD_REPO_IMAGE:-ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a} - pull_policy: ${NDND_NFD_REPO_PULL_POLICY:-always} + image: ghcr.io/named-data/ndnd:20261022@sha256:1816103c4fec8ea04253ed3d5f9e5c53c6657067a2cbc4d3c1fbb6be7ed28c3a + pull_policy: always init: true volumes: - /run/nfd:/run/nfd:ro diff --git a/scripts/cron-master.sh b/scripts/cron-master.sh index e36e0ae..dbc4d63 100755 --- a/scripts/cron-master.sh +++ b/scripts/cron-master.sh @@ -21,7 +21,7 @@ fi # Remove git lock file if it exists and pull the latest changes rm -f .git/index.lock -git pull --ff-only || exit $? +git pull # Bootstrap and verify the dedicated NDNd CA root before rendering DV trust. python3 framework/ndnd_ca_bootstrap.py || exit $? diff --git a/scripts/master.sh b/scripts/master.sh index b0ded96..4b7f8da 100755 --- a/scripts/master.sh +++ b/scripts/master.sh @@ -17,7 +17,7 @@ source .env if [[ -z "$DEBUG" ]]; then # Initial repo pull git config --global --add safe.directory /testbed - git pull --ff-only + git pull # Bootstrap and verify the dedicated NDNd CA root before rendering DV trust. python3 framework/ndnd_ca_bootstrap.py diff --git a/templates/ndncert/renew.sh.j2 b/templates/ndncert/renew.sh.j2 index e85a897..3ec3849 100644 --- a/templates/ndncert/renew.sh.j2 +++ b/templates/ndncert/renew.sh.j2 @@ -22,9 +22,8 @@ if [[ $(needs_renewal "${NDNCERT_CERTFILE}") ]]; then trap 'rm -f "${RENEW_CERTFILE}"' EXIT # Get certificate from root certificate authority - curl -fsSL -X POST -H "Authorization: Bearer ${ROOT_CA_SECRET}" \ - --upload-file "${NDNCERT_CERTFILE}.csr" -o "${RENEW_CERTFILE}" \ - "${ROOT_CA_HTTPS}/sign" + curl -fsSL -X POST --upload-file "${NDNCERT_CERTFILE}.csr" -o "${RENEW_CERTFILE}" \ + "${ROOT_CA_HTTPS}/sign?secret=${ROOT_CA_SECRET}" # Install certificate to keychain ndnsec cert-install -f "${RENEW_CERTFILE}"