RTR server
This commit is contained in:
236
specs/10_slurm.md
Normal file
236
specs/10_slurm.md
Normal file
@@ -0,0 +1,236 @@
|
||||
# 10. SLURM(Simplified Local Internet Number Resource Management with the RPKI)
|
||||
|
||||
## 10.1 对象定位
|
||||
|
||||
SLURM是一个JSON文件,允许 RPKI 依赖方在本地“覆盖/修正/忽略”来自上游RPKI数据的内容,而不需要修改或伪造原始RPKI对象。
|
||||
|
||||
## 10.2 数据格式 (RFC 8416 §3)
|
||||
|
||||
### SLURM
|
||||
|
||||
SLURM是一个只包含一个JSON对象的文件。格式要求如下(RFC 8416 §3.2):
|
||||
|
||||
```text
|
||||
A SLURM file consists of a single JSON object containing the
|
||||
following members:
|
||||
o A "slurmVersion" member that MUST be set to 1, encoded as a number
|
||||
o A "validationOutputFilters" member (Section 3.3), whose value is
|
||||
an object. The object MUST contain exactly two members:
|
||||
* A "prefixFilters" member, whose value is described in
|
||||
Section 3.3.1.
|
||||
* A "bgpsecFilters" member, whose value is described in
|
||||
Section 3.3.2.
|
||||
o A "locallyAddedAssertions" member (Section 3.4), whose value is an
|
||||
object. The object MUST contain exactly two members:
|
||||
* A "prefixAssertions" member, whose value is described in
|
||||
Section 3.4.1.
|
||||
* A "bgpsecAssertions" member, whose value is described in
|
||||
Section 3.4.2.
|
||||
```
|
||||
|
||||
一个空的SLURM json结构体如下:
|
||||
|
||||
```json
|
||||
{
|
||||
"slurmVersion": 1,
|
||||
"validationOutputFilters": {
|
||||
"prefixFilters": [],
|
||||
"bgpsecFilters": []
|
||||
},
|
||||
"locallyAddedAssertions": {
|
||||
"prefixAssertions": [],
|
||||
"bgpsecAssertions": []
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### prefixFilters
|
||||
其中`prefixFilters`格式要求如下(RFC 8416 §3.3.1):
|
||||
|
||||
```text
|
||||
The above is expressed as a value of the "prefixFilters" member, as
|
||||
an array of zero or more objects. Each object MUST contain either 1)
|
||||
one of the following members or 2) one of each of the following
|
||||
members.
|
||||
o A "prefix" member, whose value is a string representing either an
|
||||
IPv4 prefix (see Section 3.1 of [RFC4632]) or an IPv6 prefix (see
|
||||
[RFC5952]).
|
||||
o An "asn" member, whose value is a number.
|
||||
In addition, each object MAY contain one optional "comment" member,
|
||||
whose value is a string.
|
||||
```
|
||||
示例:
|
||||
```json
|
||||
"prefixFilters": [
|
||||
{
|
||||
"prefix": "192.0.2.0/24",
|
||||
"comment": "All VRPs encompassed by prefix"
|
||||
},
|
||||
{
|
||||
"asn": 64496,
|
||||
"comment": "All VRPs matching ASN"
|
||||
},
|
||||
{
|
||||
"prefix": "198.51.100.0/24",
|
||||
"asn": 64497,
|
||||
"comment": "All VRPs encompassed by prefix, matching ASN"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
### bgpsecFilters
|
||||
`bgpsecFilters`格式要求如下(RFC 8416 §3.3.2)
|
||||
|
||||
```text
|
||||
The above is expressed as a value of the "bgpsecFilters" member, as
|
||||
an array of zero or more objects. Each object MUST contain one of
|
||||
either, or one each of both following members:
|
||||
o An "asn" member, whose value is a number
|
||||
o An "SKI" member, whose value is the Base64 encoding without
|
||||
trailing ’=’ (Section 5 of [RFC4648]) of the certificate’s Subject
|
||||
Key Identifier as described in Section 4.8.2 of [RFC6487]. (This
|
||||
is the value of the ASN.1 OCTET STRING without the ASN.1 tag or
|
||||
length fields.)
|
||||
In addition, each object MAY contain one optional "comment" member,
|
||||
whose value is a string.
|
||||
```
|
||||
|
||||
示例:
|
||||
```json
|
||||
"bgpsecFilters": [
|
||||
{
|
||||
"asn": 64496,
|
||||
"comment": "All keys for ASN"
|
||||
},
|
||||
{
|
||||
"SKI": "<Base 64 of some SKI>",
|
||||
"comment": "Key matching Router SKI"
|
||||
},
|
||||
{
|
||||
"asn": 64497,
|
||||
"SKI": "<Base 64 of some SKI>",
|
||||
"comment": "Key for ASN 64497 matching Router SKI"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
### prefixAssertions
|
||||
`prefixAssertions`格式要求如下(RFC 8416 §3.4.1)
|
||||
```text
|
||||
The above is expressed as a value of the "prefixAssertions" member,
|
||||
as an array of zero or more objects. Each object MUST contain one of
|
||||
each of the following members:
|
||||
o A "prefix" member, whose value is a string representing either an
|
||||
IPv4 prefix (see Section 3.1 of [RFC4632]) or an IPv6 prefix (see
|
||||
[RFC5952]).
|
||||
o An "asn" member, whose value is a number.
|
||||
In addition, each object MAY contain one of each of the following
|
||||
members:
|
||||
o A "maxPrefixLength" member, whose value is a number.
|
||||
o A "comment" member, whose value is a string.
|
||||
```
|
||||
|
||||
示例:
|
||||
```json
|
||||
"prefixAssertions": [
|
||||
{
|
||||
"asn": 64496,
|
||||
"prefix": "198.51.100.0/24",
|
||||
"comment": "My other important route"
|
||||
},
|
||||
{
|
||||
"asn": 64496,
|
||||
"prefix": "2001:DB8::/32",
|
||||
"maxPrefixLength": 48,
|
||||
"comment": "My other important de-aggregated routes"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
### bgpsecAssertions
|
||||
`bgpsecAssertions`格式要求如下(RFC 8416 §3.4.2)
|
||||
```text
|
||||
The above is expressed as a value of the "bgpsecAssertions" member,
|
||||
as an array of zero or more objects. Each object MUST contain one
|
||||
each of all of the following members:
|
||||
o An "asn" member, whose value is a number.
|
||||
o An "SKI" member, whose value is the Base64 encoding without
|
||||
trailing ’=’ (Section 5 of [RFC4648]) of the certificate’s Subject
|
||||
Key Identifier as described in Section 4.8.2 of [RFC6487] (This is
|
||||
the value of the ASN.1 OCTET STRING without the ASN.1 tag or
|
||||
length fields.)
|
||||
o A "routerPublicKey" member, whose value is the Base64 encoding
|
||||
without trailing ’=’ (Section 5 of [RFC4648]) of the equivalent to
|
||||
the subjectPublicKeyInfo value of the router certificate’s public
|
||||
key, as described in [RFC8208]. This is the full ASN.1 DER
|
||||
encoding of the subjectPublicKeyInfo, including the ASN.1 tag and
|
||||
length values of the subjectPublicKeyInfo SEQUENCE.
|
||||
```
|
||||
示例:
|
||||
```json
|
||||
"bgpsecAssertions": [
|
||||
{
|
||||
"asn": 64496,
|
||||
"SKI": "<some base64 SKI>",
|
||||
"routerPublicKey": "<some base64 public key>",
|
||||
"comment": "My known key for my important ASN"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## 10.3 抽象数据结构
|
||||
|
||||
### SLURM
|
||||
| 字段 | 类型 | 语义 | 约束/解析规则 | RFC 引用 |
|
||||
|---------------------------|------------------------|---------|---------|---------------|
|
||||
| slurm_version | number | SLURM版本 | 版本必须为1 | RFC 8416 §3.2 |
|
||||
| validation_output_filters | ValidationOutputFilter | 过滤条件 | | |
|
||||
| locally_added_assertions | LocallyAddedAssertions | 本地添加断言 | | |
|
||||
|
||||
### ValidationOutputFilter
|
||||
| 字段 | 类型 | 语义 | 约束/解析规则 | RFC 引用 |
|
||||
|----------------|-------------------|-----------|---------|---------------|
|
||||
| prefix_filters | Vec<PrefixFilter> | 前缀过滤 | 可以为空数组 | RFC 8416 §3.3 |
|
||||
| bgpsec_filters | Vec<BgpsecFilter> | BGPsec过滤 | 可以为空数组 | RFC 8416 §3.3 |
|
||||
|
||||
### LocallyAddedAssertions
|
||||
| 字段 | 类型 | 语义 | 约束/解析规则 | RFC 引用 |
|
||||
|-------------------|----------------------|-----------|---------|---------------|
|
||||
| prefix_assertions | Vec<PrefixAssertion> | 前缀断言 | 可以为空数组 | RFC 8416 §3.4 |
|
||||
| bgpsec_assertions | Vec<BgpsecAssertion> | BGPsec断言 | 可以为空数组 | RFC 8416 §3.4 |
|
||||
|
||||
### PrefixFilter
|
||||
| 字段 | 类型 | 语义 | 约束/解析规则 | RFC 引用 |
|
||||
|---------|--------|------|--------------------------------|-----------------|
|
||||
| prefix | string | 前缀 | IPv4前缀或IPv6前缀,prefix和asn至少存在一个 | RFC 8416 §3.3.1 |
|
||||
| asn | number | ASN | prefix和asn至少存在一个 | RFC 8416 §3.3.1 |
|
||||
| comment | string | 备注说明 | 可选字段 | RFC 8416 §3.3.1 |
|
||||
|
||||
### BgpsecFilter
|
||||
| 字段 | 类型 | 语义 | 约束/解析规则 | RFC 引用 |
|
||||
|---------|--------|------|------------------|------------------|
|
||||
| asn | number | ASN | prefix和asn至少存在一个 | RFC 8416 §3.3.1 |
|
||||
| ski | u8 | | 证书的SKI | RFC 8416 §3.3.1 |
|
||||
| comment | string | 备注说明 | 可选字段 | RFC 8416 §3.3.1 |
|
||||
|
||||
### PrefixAssertion
|
||||
| 字段 | 类型 | 语义 | 约束/解析规则 | RFC 引用 |
|
||||
|-------------------|--------|--------|---------------|-----------------|
|
||||
| prefix | string | 前缀 | IPv4前缀或IPv6前缀 | RFC 8416 §3.4.1 |
|
||||
| asn | number | ASN | | RFC 8416 §3.4.1 |
|
||||
| max_prefix_length | number | 最大前缀长度 | 可选字段 | RFC 8416 §3.4.1 |
|
||||
| comment | string | 备注说明 | 可选字段 | RFC 8416 §3.4.1 |
|
||||
|
||||
|
||||
### BgpsecAssertion
|
||||
| 字段 | 类型 | 语义 | 约束/解析规则 | RFC 引用 |
|
||||
|-------------------|--------|--------|------------------|-----------------|
|
||||
| asn | number | ASN | prefix和asn至少存在一个 | RFC 8416 §3.4.2 |
|
||||
| ski | u8 | | 证书的SKI | RFC 8416 §3.4.2 |
|
||||
| router_public_key | u8 | 证书的SKI | | RFC 8416 §3.4.2 |
|
||||
| comment | string | 备注说明 | 可选字段 | RFC 8416 §3.4.2 |
|
||||
|
||||
> 注:BGPsec部分可以在第一版考虑先留空
|
||||
|
||||
## 10.4 规则
|
||||
|
||||
65
specs/11_rtr.md
Normal file
65
specs/11_rtr.md
Normal file
@@ -0,0 +1,65 @@
|
||||
# 11. RTR (The Resource Public Key Infrastructure (RPKI) to Router Protocol)
|
||||
|
||||
## 11.1 Cache Server
|
||||
|
||||
### 11.1.1 功能需求
|
||||
|
||||
- 支持Full Sync(Reset Query)
|
||||
- 支持Incremental Sync(Serial Query)
|
||||
- 支持多客户端并发
|
||||
- 支持Serial递增
|
||||
- 保留一定数量的delta
|
||||
- 支持原子更新
|
||||
|
||||
### 11.1.2 架构设计
|
||||
采用一级缓存+二级缓存并存的方式。
|
||||
|
||||

|
||||
|
||||
其中,一级缓存为运行时缓存,主要职责:
|
||||
- 存储当前完整的snapshot
|
||||
- 历史Delta队列管理
|
||||
- Serial管理
|
||||
- RTR查询响应
|
||||
|
||||
二级缓存为持久化缓存,主要职责:
|
||||
- snapshot持久化
|
||||
- 缓存重启后的快速恢复(snapshot和serial)
|
||||
- 不参与实时查询
|
||||
- 异步写入
|
||||
|
||||
### 11.1.3 核心数据结构设计
|
||||
|
||||
#### 11.1.3.1 总cache
|
||||
```rust
|
||||
struct RtrCache {
|
||||
serial: AtomicU32,
|
||||
snapshot: ArcSwap<Snapshot>,
|
||||
deltas: RwLock<VecDeque<Arc<Delta>>>,
|
||||
max_delta: usize,
|
||||
}
|
||||
```
|
||||
|
||||
#### 11.1.3.2 Snapshot
|
||||
```rust
|
||||
struct Snapshot {
|
||||
origins: Vec<RouteOrigin>,
|
||||
router_keys: Vec<RouterKey>,
|
||||
aspas: Vec<Aspa>,
|
||||
created_at: Instant,
|
||||
}
|
||||
```
|
||||
|
||||
#### 11.1.3.3 Delta
|
||||
```rust
|
||||
struct Delta {
|
||||
serial: u32,
|
||||
announced: Vec<Payload>,
|
||||
withdrawn: Vec<Payload>,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## 11.2 Transport
|
||||
|
||||
初版实现RTR over TLS(可外网)和RTR over TCP(内网)两种方式。
|
||||
BIN
specs/img/img.png
Normal file
BIN
specs/img/img.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
Reference in New Issue
Block a user