Skip to content

Prefix Insertion Support in dv - #150

Merged
tianyuan129 merged 39 commits into
named-data:dv2from
jaczhi:jaczhi/prefix-inject
Jan 29, 2026
Merged

tianyuan129 merged 39 commits into
named-data:dv2from
jaczhi:jaczhi/prefix-inject

Conversation

@jaczhi

@jaczhi jaczhi commented May 4, 2025 •

Copy link
Copy Markdown

@zjkmxy
zjkmxy requested a review from Copilot May 4, 2025 18:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for Prefix Injection in dv by extending the protocol handling and configuration across multiple modules. Key changes include:

  • Updating client trust validation to support a default fetch function for certificate retrieval.
  • Introducing new constants, types, and API endpoints for handling prefix injection.
  • Integrating prefix injection logic into the DV router and adding corresponding configuration options.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
std/object/client_trust.go Updated trust validation to use a default fetch function.
std/ndn/mgmt_2022/route.go Added a new route origin constant for prefix injection.
std/ndn/mgmt_2022/definitions.go Introduced new types for Prefix Injection message formatting.
std/ndn/constants.go Added a constant for the new content type Prefix Injection.
std/ndn/client.go Extended ValidateExtArgs to include a fetch function for certificate retrieval.
dv/dv/router.go Integrated prefix injection handler registration and configuration.
dv/dv/injection.go Implemented the core logic for processing Prefix Injection requests.
dv/dv.sample.yml Updated sample configuration with prefix injection options.
dv/config/config.go Added new configuration fields for prefix injection support.

Comment thread dv/dv/injection.go Resolved
Comment thread dv/dv/injection.go Resolved
Comment thread dv/dv/injection.go Resolved
Comment thread std/ndn/mgmt_2022/definitions.go Resolved
overrideName = args.OverrideName
}

// Default fetch function

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we fetch certificates by default?
The current Object client does not have a deadline system, which means it may be vulnerable to infinite fetching loop. Need to look into this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My old design in NTSchema is that the lifetime of a certificate fetching Interest is the original Interest's lifetime minus time elapsed till the send time, so that the validation will fail when the lifetime of original Interest for the Data packet is reached.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, unsure what you mean? Currently this API is used by other code and thus I wanted to maintain the backwards compatibility, just added a new functionality of being able to override the fetch function. (Currently that other code expects ValidateExt to fetch recursively I believe)

Comment thread std/ndn/mgmt_2022/definitions.go Resolved
@Pesa

Pesa commented May 4, 2025

Copy link
Copy Markdown
Member

I thought we still had a couple of open questions on the protocol. Have those been resolved?

@jaczhi

jaczhi commented May 4, 2025

Copy link
Copy Markdown
Author

@Pesa I believe we informally stabilized on a few conclusions for the questions brought up:

how does a data producer know if there is a "routing entity" running locally? -> no easy way to do this, recommend implementers or users to also send a rib/register to the connected forwarder

do not use keyword components unecessarily in interest -> removed from the protocol

how to staple certs -> followed Junxiao's suggestion to move stapling outside of the Data TLV

reuse the existing Prefix Announcement object -> prefix announcement does not have cost as its semantics are different, thus use a similar object but not the same.

how do /routing/inject interests reach the routing entity? what if there are 2+ routing entities connected to the same producer? -> currently this question does not block the implementation we have so far (which is in the routing module), as that would be logic added to forwarders to treat that name as a keyword in a special way

negative connotation for the word "inject" -> this is the one i'm most unsure about. we can rename, but did not want the naming process to block the implementation.

@jaczhi
jaczhi requested review from Pesa and zjkmxy May 4, 2025 23:44
@pulsejet

pulsejet commented May 9, 2025

Copy link
Copy Markdown
Collaborator

Pls hold off on the merge button, I'll get to this shortly

@zjkmxy zjkmxy assigned zjkmxy and pulsejet and unassigned zjkmxy May 16, 2025
@jaczhi jaczhi changed the title Prefix Injection Support in dv Prefix Insertion Support in dv Jun 2, 2025
@jaczhi

jaczhi commented Jun 2, 2025

Copy link
Copy Markdown
Author

Renamed "prefix injection" to "prefix insertion".

@zjkmxy zjkmxy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread dv/dv/insertion.go Resolved
Comment thread dv/tlv/zz_generated.go
buf[pos] = 253
binary.BigEndian.PutUint16(buf[pos+1:], uint16(534))
pos += 3
pos += uint(enc.TLNum(len(value.StapledCertificates)).EncodeInto(buf[pos:]))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spec requires all Certificates to be nested in the TLV-VALUE of a single StapledCertificates.
This code would emit a separate StapledCertificates TLV for each Certificate.

Comment thread dv/tlv/definitions.go Resolved
Comment thread dv/dv/router.go Resolved
Comment thread std/ndn/client.go
UseDataNameFwHint optional.Optional[bool]
// Fetch function to use for fetching certificates.
// The fetcher MUST check the store for the certificate before fetching.
Fetch optional.Optional[func(enc.Name, *InterestConfig, ExpressCallbackFunc)]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fake fetch approach can result in overly complex application code.
It should be further abstracted to directly support "preloaded certificates" use cases, which include both stapled certificates in prefix insertion protocol and the certificate bundle format.
The abstraction can include the mandatory checking of the store, so that application code does not need to do so.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which include both stapled certificates in prefix insertion protocol and the certificate bundle format.

Hm I see. What would be a sufficiently general type(s) for the idea you had in mind?

@yoursunny yoursunny Jun 16, 2025 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type CertSource interface {
  func(KeyLocator) (Certificate, error)
}
  • The function can obtain certificate from multiple sources: the network, the local KeyChain, the preloaded certificates from a bundle / stapled list, etc.
  • It's unnecessary to use Optional wrapper on any function or interface type, because the nil value can naturally indicate the absence of a function object.
  • The Go convention is to use a blocking function that returns the result and an error, instead of callbacks. This allows better readability, and prevents the mistake of forgetting to invoke the callback.

The library can then provide several functions for use as the above parameter:

func NewNetworkCertSource(engine) CertSource
func NewListCertSource(certs []Certificate) CertSource
func NewKeyChainCertSource(keyChain) CertSource
func NewMultiCertSource(sources ...CertSource) CertSource

To suppose both network fetching and stapled certificates:

certSource := NewMultiCertSource(
  NewListCertSource(certs),
  NewNetworkCertSource(engine),
)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yoursunny how deep should this change go? Should I drill this new interface down to the Validate method in trust_config.go as well?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't decide for you.

Comment thread dv/dv.sample.yml
# [optional] Trust schema for prefix insertion
# - If "insecure" is specified, security is disabled
# - If "deny" is specified, the prefix insertion handler will be turned off
# - Example: /absolute/path/to/schema.tlv

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A concrete example of the trust schema should be included as part of the repository.

Comment thread dv/dv/insertion.go Resolved
Comment thread dv/dv/insertion.go Resolved
@zjkmxy

zjkmxy commented Dec 29, 2025

Copy link
Copy Markdown
Member

What's the status for this?

@tianyuan129
tianyuan129 changed the base branch from main to dv2 January 29, 2026 09:12
@tianyuan129

tianyuan129 commented Jan 29, 2026 •

Copy link
Copy Markdown
Collaborator

What's the status for this?

We are pushing for a new version of ndn-dv (and forwarding pipeline) that

1/ The prefix-router mapping is managed by a separate daemon which focuses on dealing with client advertisement. The forwarder will keep a replicated mapping table. The replication is done by the new daemon sending management commands.

2/ FIB only contains router prefix entries.

3/ The forwarder explicitly does the two-step lookup: look up the new table to find the exit router for an app prefix, lookup FIB to find the next hop for the exit router.

The work would be the initial commit in this effort (yes we need to draft some documents first) and we will carry over the comments in this PR. We will fix problems and refactor as we go...

@tianyuan129
tianyuan129 merged commit 316fb7e into named-data:dv2 Jan 29, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants