-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support neighbor PrefixesWithCommunity
Signed-off-by: Ori Braunshtein <[email protected]>
- Loading branch information
Showing
4 changed files
with
247 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
package controller | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/google/go-cmp/cmp" | ||
|
@@ -420,6 +421,180 @@ func TestConversion(t *testing.T) { | |
}, | ||
err: nil, | ||
}, | ||
{ | ||
name: "Two Neighbor with ToAdvertise, one advertise all, both with communities", | ||
fromK8s: []v1beta1.FRRConfiguration{ | ||
{ | ||
Spec: v1beta1.FRRConfigurationSpec{ | ||
BGP: v1beta1.BGPConfig{ | ||
Routers: []v1beta1.Router{ | ||
{ | ||
ASN: 65040, | ||
ID: "192.0.2.20", | ||
Neighbors: []v1beta1.Neighbor{ | ||
{ | ||
ASN: 65041, | ||
Address: "192.0.2.21", | ||
Port: 179, | ||
ToAdvertise: v1beta1.Advertise{ | ||
Allowed: v1beta1.AllowedPrefixes{ | ||
Prefixes: []string{"192.0.2.0/24", "192.0.4.0/24"}, | ||
Mode: v1beta1.AllowRestricted, | ||
}, | ||
PrefixesWithCommunity: []v1beta1.CommunityPrefixes{ | ||
{ | ||
Prefixes: []string{"192.0.2.0/24", "192.0.4.0/24"}, | ||
Community: "10:100", | ||
}, | ||
{ | ||
Prefixes: []string{"192.0.2.0/24"}, | ||
Community: "10:102", | ||
}, { | ||
Prefixes: []string{"192.0.4.0/24"}, | ||
Community: "10:104", | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
ASN: 65041, | ||
Address: "192.0.2.22", | ||
Port: 179, | ||
ToAdvertise: v1beta1.Advertise{ | ||
Allowed: v1beta1.AllowedPrefixes{ | ||
Mode: v1beta1.AllowAll, | ||
}, | ||
PrefixesWithCommunity: []v1beta1.CommunityPrefixes{ | ||
{ | ||
Prefixes: []string{"192.0.2.0/24", "192.0.4.0/24"}, | ||
Community: "10:100", | ||
}, | ||
{ | ||
Prefixes: []string{"192.0.2.0/24"}, | ||
Community: "10:102", | ||
}, | ||
{ | ||
Prefixes: []string{"192.0.2.0/24", "2001:db8::/64"}, | ||
Community: "10:108", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
Prefixes: []string{"192.0.2.0/24", "192.0.3.0/24", "192.0.4.0/24", "2001:db8::/64"}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
expected: &frr.Config{ | ||
Routers: []*frr.RouterConfig{ | ||
{ | ||
MyASN: 65040, | ||
RouterID: "192.0.2.20", | ||
Neighbors: []*frr.NeighborConfig{ | ||
{ | ||
IPFamily: ipfamily.IPv4, | ||
Name: "[email protected]", | ||
ASN: 65041, | ||
Addr: "192.0.2.21", | ||
Port: 179, | ||
Advertisements: []*frr.AdvertisementConfig{ | ||
{ | ||
IPFamily: ipfamily.IPv4, | ||
Prefix: "192.0.2.0/24", | ||
Communities: []string{"10:100", "10:102"}, | ||
}, | ||
{ | ||
IPFamily: ipfamily.IPv4, | ||
Prefix: "192.0.4.0/24", | ||
Communities: []string{"10:100", "10:104"}, | ||
}, | ||
}, | ||
HasV4Advertisements: true, | ||
}, | ||
{ | ||
IPFamily: ipfamily.IPv4, | ||
Name: "[email protected]", | ||
ASN: 65041, | ||
Addr: "192.0.2.22", | ||
Port: 179, | ||
Advertisements: []*frr.AdvertisementConfig{ | ||
{ | ||
IPFamily: ipfamily.IPv4, | ||
Prefix: "192.0.2.0/24", | ||
Communities: []string{"10:100", "10:102", "10:108"}, | ||
}, | ||
{ | ||
IPFamily: ipfamily.IPv4, | ||
Prefix: "192.0.3.0/24", | ||
}, | ||
{ | ||
IPFamily: ipfamily.IPv4, | ||
Prefix: "192.0.4.0/24", | ||
Communities: []string{"10:100"}, | ||
}, | ||
{ | ||
IPFamily: ipfamily.IPv6, | ||
Prefix: "2001:db8::/64", | ||
Communities: []string{"10:108"}, | ||
}, | ||
}, | ||
HasV4Advertisements: true, | ||
HasV6Advertisements: true, | ||
}, | ||
}, | ||
IPV4Prefixes: []string{"192.0.2.0/24", "192.0.3.0/24", "192.0.4.0/24"}, | ||
IPV6Prefixes: []string{"2001:db8::/64"}, | ||
}, | ||
}, | ||
}, | ||
err: nil, | ||
}, | ||
{ | ||
name: "One neighbor, trying to set community on an unallowed prefix", | ||
fromK8s: []v1beta1.FRRConfiguration{ | ||
{ | ||
Spec: v1beta1.FRRConfigurationSpec{ | ||
BGP: v1beta1.BGPConfig{ | ||
Routers: []v1beta1.Router{ | ||
{ | ||
ASN: 65040, | ||
ID: "192.0.2.20", | ||
Neighbors: []v1beta1.Neighbor{ | ||
{ | ||
ASN: 65041, | ||
Address: "192.0.2.21", | ||
Port: 179, | ||
ToAdvertise: v1beta1.Advertise{ | ||
Allowed: v1beta1.AllowedPrefixes{ | ||
Prefixes: []string{"192.0.2.0/24", "192.0.4.0/24"}, | ||
Mode: v1beta1.AllowRestricted, | ||
}, | ||
PrefixesWithCommunity: []v1beta1.CommunityPrefixes{ | ||
{ | ||
Prefixes: []string{"192.0.2.0/24", "192.0.4.0/24"}, | ||
Community: "10:100", | ||
}, | ||
{ | ||
Prefixes: []string{"192.0.10.10/32"}, // not allowed | ||
Community: "10:100", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
Prefixes: []string{"192.0.2.0/24", "192.0.3.0/24", "192.0.4.0/24", "2001:db8::/64"}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
expected: nil, | ||
err: fmt.Errorf("prefix %s with community %s not in allowed list for neighbor %s", "192.0.10.10/32", "10:100", "192.0.2.21"), | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters