f-41: l3vni: borne à 65535 (RD <VTEP>:<l3vni> sur 16 bits) #41
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
35d6985826
commit
c9d0002041
8 changed files with 25 additions and 23 deletions
|
|
@ -321,11 +321,11 @@ components:
|
|||
type: integer
|
||||
format: int32
|
||||
minimum: 1
|
||||
maximum: 16777215
|
||||
maximum: 65535
|
||||
description: >-
|
||||
Optional. L3VNI of the VPC, used for inter-subnet routing between hypervisors
|
||||
(symmetric IRB). Also the id of the routing table of the VPC VRF, so 253-255 are
|
||||
rejected. Requires the bgp section in the agent configuration, and must not be used
|
||||
rejected, and the number of the route distinguisher <vtep>:<l3vni>, which holds 16 bits. Requires the bgp section in the agent configuration, and must not be used
|
||||
by another VPC of the agent. Absent: the VPC has no L3VNI.
|
||||
example: 4001
|
||||
|
||||
|
|
|
|||
|
|
@ -280,6 +280,7 @@ func TestPostVpc_RejectsAnInvalidL3VNIAsABadRequest(t *testing.T) {
|
|||
for _, body := range []string{
|
||||
`{"name":"vp-1","cidr":"10.0.0.0/16","l3vni":0}`,
|
||||
`{"name":"vp-1","cidr":"10.0.0.0/16","l3vni":255}`,
|
||||
`{"name":"vp-1","cidr":"10.0.0.0/16","l3vni":65536}`,
|
||||
`{"name":"vp-1","cidr":"10.0.0.0/16","l3vni":16777216}`,
|
||||
`{"name":"vp-1","cidr":"10.0.0.0/16","l3vni":-1}`,
|
||||
} {
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@ import (
|
|||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"git.g3e.fr/syonad/two/internal/netif"
|
||||
)
|
||||
|
||||
const MaxL3VNI = 1<<16 - 1
|
||||
|
||||
type Base struct {
|
||||
ASN uint32
|
||||
RouterID net.IP
|
||||
|
|
@ -116,8 +116,8 @@ func (v VRF) validate() error {
|
|||
if err := v.validateName(); err != nil {
|
||||
return err
|
||||
}
|
||||
if v.L3VNI == 0 || v.L3VNI > netif.MaxVNI {
|
||||
return fmt.Errorf("frr: l3vni %d does not fit in 24 bits", v.L3VNI)
|
||||
if v.L3VNI == 0 || v.L3VNI > MaxL3VNI {
|
||||
return fmt.Errorf("frr: l3vni %d out of range 1-%d: the route distinguisher <vtep>:<l3vni> holds 16 bits", v.L3VNI, MaxL3VNI)
|
||||
}
|
||||
if v.VTEP.To4() == nil {
|
||||
return fmt.Errorf("frr: vtep %v is not an IPv4 address", v.VTEP)
|
||||
|
|
|
|||
|
|
@ -117,8 +117,9 @@ func TestVRFValidateRejects(t *testing.T) {
|
|||
}{
|
||||
"asn nul": {func(v *VRF) { v.ASN = 0 }, "asn must not be 0"},
|
||||
"id vide": {func(v *VRF) { v.ID = "" }, "vrf id must not be empty"},
|
||||
"l3vni nul": {func(v *VRF) { v.L3VNI = 0 }, "l3vni 0 does not fit in 24 bits"},
|
||||
"l3vni sur 25 bits": {func(v *VRF) { v.L3VNI = 16777216 }, "l3vni 16777216 does not fit in 24 bits"},
|
||||
"l3vni nul": {func(v *VRF) { v.L3VNI = 0 }, "l3vni 0 out of range 1-65535"},
|
||||
"l3vni sur 17 bits": {func(v *VRF) { v.L3VNI = 65536 }, "l3vni 65536 out of range 1-65535"},
|
||||
"l3vni sur 24 bits": {func(v *VRF) { v.L3VNI = 16777215 }, "l3vni 16777215 out of range 1-65535"},
|
||||
"vtep absent": {func(v *VRF) { v.VTEP = nil }, "vtep <nil> is not an IPv4 address"},
|
||||
"vtep IPv6": {func(v *VRF) { v.VTEP = net.ParseIP("fd00::1") }, "vtep fd00::1 is not an IPv4 address"},
|
||||
"supernet absent": {func(v *VRF) { v.Supernet = nil }, "supernet <nil> is not an IPv4 prefix"},
|
||||
|
|
@ -133,10 +134,10 @@ func TestVRFValidateRejects(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestVRFAcceptsTheLargest24BitVNI(t *testing.T) {
|
||||
func TestVRFAcceptsTheLargest16BitVNI(t *testing.T) {
|
||||
v := labVRF(t)
|
||||
v.L3VNI = 16777215
|
||||
v.L3VNI = 65535
|
||||
if err := v.validate(); err != nil {
|
||||
t.Errorf("l3vni 16777215 refusée : %v", err)
|
||||
t.Errorf("l3vni 65535 refusée : %v", err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@ package l3vni
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"git.g3e.fr/syonad/two/internal/netif"
|
||||
"git.g3e.fr/syonad/two/internal/frr"
|
||||
)
|
||||
|
||||
func Valid(id uint32) error {
|
||||
if id == 0 || id > netif.MaxVNI {
|
||||
return fmt.Errorf("l3vni %d does not fit in 24 bits (1-%d)", id, netif.MaxVNI)
|
||||
if id == 0 || id > frr.MaxL3VNI {
|
||||
return fmt.Errorf("l3vni %d out of range 1-%d: the route distinguisher <vtep>:<l3vni> holds 16 bits", id, frr.MaxL3VNI)
|
||||
}
|
||||
if id >= 253 && id <= 255 {
|
||||
return fmt.Errorf("l3vni %d is reserved: it is also the routing table id, and tables 253-255 belong to the kernel", id)
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ import (
|
|||
"testing"
|
||||
)
|
||||
|
||||
func TestValid_AcceptsEvery24BitValueOutsideTheKernelTables(t *testing.T) {
|
||||
for _, id := range []uint32{1, 252, 256, 4001, 16777215} {
|
||||
func TestValid_AcceptsEvery16BitValueOutsideTheKernelTables(t *testing.T) {
|
||||
for _, id := range []uint32{1, 252, 256, 4001, 65535} {
|
||||
if err := Valid(id); err != nil {
|
||||
t.Errorf("Valid(%d) = %v", id, err)
|
||||
}
|
||||
|
|
@ -15,8 +15,9 @@ func TestValid_AcceptsEvery24BitValueOutsideTheKernelTables(t *testing.T) {
|
|||
|
||||
func TestValid_RejectsOutOfRangeAndReservedTables(t *testing.T) {
|
||||
cases := map[uint32]string{
|
||||
0: "does not fit in 24 bits",
|
||||
16777216: "does not fit in 24 bits",
|
||||
0: "out of range 1-65535",
|
||||
65536: "out of range 1-65535",
|
||||
16777215: "out of range 1-65535",
|
||||
253: "is reserved",
|
||||
254: "is reserved",
|
||||
255: "is reserved",
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@ import (
|
|||
"github.com/vishvananda/netlink"
|
||||
)
|
||||
|
||||
const MaxVNI = 1<<24 - 1
|
||||
|
||||
const (
|
||||
scopeUniverse = 0
|
||||
addressSecondary = 0x01
|
||||
|
|
|
|||
|
|
@ -34,9 +34,10 @@ L3VNI, avec une configuration BGP pilotée par l'agent ; documentation du projet
|
|||
|
||||
**Routage inter-subnet entre hyperviseurs : L3VNI (#41)**
|
||||
|
||||
- Nouveau champ facultatif `l3vni` sur `POST /vpcs` (1 à 16777215, sauf 253-255 : c'est aussi
|
||||
l'identifiant de la table de routage). Absent, le VPC se comporte comme avant. Une L3VNI déjà
|
||||
portée par un VPC de l'agent est refusée (409), comme un `l3vni` demandé sans section `bgp`
|
||||
- Nouveau champ facultatif `l3vni` sur `POST /vpcs` (1 à 65535, sauf 253-255 : c'est aussi
|
||||
l'identifiant de la table de routage, et le numéro du RD `<VTEP>:<l3vni>`, sur 16 bits).
|
||||
Absent, le VPC se comporte comme avant. Une L3VNI déjà portée par un VPC de l'agent est refusée
|
||||
(409), comme un `l3vni` demandé sans section `bgp`
|
||||
- Pour un VPC routé, l'agent pose sur l'hyperviseur une VRF (table = L3VNI), un bridge à la MAC de
|
||||
routeur `02:02:<IPv4 du VTEP>`, le VXLAN de la L3VNI, un lien de transit `169.254.0.1/30` ↔
|
||||
`169.254.0.2/30` vers le netns et la route du `cidr` du VPC dans le netns ; FRR reçoit la VRF,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue