summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNaoto Hanaue <hanaue.naoto@po.ntts.co.jp>2015-08-05 13:23:12 +0900
committerNaoto Hanaue <hanaue.naoto@po.ntts.co.jp>2015-08-05 15:04:03 +0900
commitb7d8d53c486eff0370e9908e75a97b7d8816725c (patch)
treec47a6749af89f6116ea2a6675727237002e152f1
parent064c8834e94349f611be6e9555ec355bd1aef351 (diff)
config: change the structure of AsPathSet, CommunitySet and ExtCommunitySet as the PrefixSet
-rw-r--r--config/bgp_configs.go32
-rw-r--r--policy/policy.go72
-rw-r--r--policy/policy_test.go165
-rw-r--r--server/server.go42
-rw-r--r--test/scenario_test/policy/policy_generator.go42
-rw-r--r--tools/config/example_toml.go14
6 files changed, 249 insertions, 118 deletions
diff --git a/config/bgp_configs.go b/config/bgp_configs.go
index adb4a1c5..12af5fcb 100644
--- a/config/bgp_configs.go
+++ b/config/bgp_configs.go
@@ -1436,12 +1436,18 @@ type PolicyDefinitions struct {
PolicyDefinitionList []PolicyDefinition
}
+//struct for container bgp-pol:as-path
+type AsPath struct {
+ // original -> bgp-pol:as-path
+ AsPath string
+}
+
//struct for container bgp-pol:as-path-set
type AsPathSet struct {
// original -> bgp-pol:as-path-set-name
AsPathSetName string
- // original -> bgp-pol:as-path-set-member
- AsPathSetMember []string
+ // original -> bgp-pol:as-path
+ AsPathList []AsPath
}
//struct for container bgp-pol:as-path-sets
@@ -1450,13 +1456,18 @@ type AsPathSets struct {
AsPathSetList []AsPathSet
}
+//struct for container bgp-pol:ext-community
+type ExtCommunity struct {
+ // original -> bgp-pol:ext-community
+ ExtCommunity string
+}
+
//struct for container bgp-pol:ext-community-set
type ExtCommunitySet struct {
// original -> bgp-pol:ext-community-set-name
ExtCommunitySetName string
- // original -> bgp-pol:ext-community-member
- //original type is list of union
- ExtCommunityMember []string
+ // original -> bgp-pol:ext-community
+ ExtCommunityList []ExtCommunity
}
//struct for container bgp-pol:ext-community-sets
@@ -1465,13 +1476,18 @@ type ExtCommunitySets struct {
ExtCommunitySetList []ExtCommunitySet
}
+//struct for container bgp-pol:community
+type Community struct {
+ // original -> bgp-pol:community
+ Community string
+}
+
//struct for container bgp-pol:community-set
type CommunitySet struct {
// original -> bgp-pol:community-set-name
CommunitySetName string
- // original -> bgp-pol:community-member
- //original type is list of union
- CommunityMember []string
+ // original -> bgp-pol:community
+ CommunityList []Community
}
//struct for container bgp-pol:community-sets
diff --git a/policy/policy.go b/policy/policy.go
index b0eb3809..2a90f5c6 100644
--- a/policy/policy.go
+++ b/policy/policy.go
@@ -418,10 +418,11 @@ func NewAsPathCondition(matchSet config.MatchAsPathSet, defAsPathSetList []confi
asPathList := make([]*AsPathElement, 0)
for _, asPathSet := range defAsPathSetList {
if asPathSet.AsPathSetName == asPathSetName {
- for _, as := range asPathSet.AsPathSetMember {
- if regAsn.MatchString(as) {
+ for _, aspath := range asPathSet.AsPathList {
+ a := aspath.AsPath
+ if regAsn.MatchString(a) {
- group := regAsn.FindStringSubmatch(as)
+ group := regAsn.FindStringSubmatch(a)
asn, err := strconv.Atoi(group[2])
if err != nil {
log.WithFields(log.Fields{
@@ -583,8 +584,8 @@ func NewCommunityCondition(matchSet config.MatchCommunitySet, defCommunitySetLis
communityList := make([]*CommunityElement, 0)
for _, communitySet := range defCommunitySetList {
if communitySet.CommunitySetName == communitySetName {
- for _, c := range communitySet.CommunityMember {
-
+ for _, community := range communitySet.CommunityList {
+ c := community.Community
e := &CommunityElement{
isRegExp: false,
communityStr: c,
@@ -807,18 +808,19 @@ func NewExtCommunityCondition(matchSet config.MatchExtCommunitySet, defExtComSet
extCommunityElemList := make([]*ExtCommunityElement, 0)
for _, extComSet := range defExtComSetList {
if extComSet.ExtCommunitySetName == extComSetName {
- for _, c := range extComSet.ExtCommunityMember {
+ for _, ecommunity := range extComSet.ExtCommunityList {
matchAll := false
+ ec := ecommunity.ExtCommunity
e := &ExtCommunityElement{
isRegExp: false,
- comStr: c,
+ comStr: ec,
}
- matchType, val := getECommunitySubType(c)
+ matchType, val := getECommunitySubType(ec)
if !matchType {
log.WithFields(log.Fields{
"Topic": "Policy",
"Type": "Extended Community Condition",
- }).Error("failed to parse the sub type %s.", c)
+ }).Error("failed to parse the sub type %s.", ec)
return nil
}
switch val[1] {
@@ -848,7 +850,7 @@ func NewExtCommunityCondition(matchSet config.MatchExtCommunitySet, defExtComSet
}
if !matchAll {
e.isRegExp = true
- reg, err := regexp.Compile(c)
+ reg, err := regexp.Compile(ec)
if err != nil {
log.WithFields(log.Fields{
"Topic": "Policy",
@@ -1545,11 +1547,11 @@ func IndexOfAsPathSet(conAsPathSetList []config.AsPathSet, reqAsPathSet config.A
for i, conAsPathSet := range conAsPathSetList {
if conAsPathSet.AsPathSetName == reqAsPathSet.AsPathSetName {
idxAsPathSet = i
- if len(reqAsPathSet.AsPathSetMember) == 0 {
+ if len(reqAsPathSet.AsPathList) == 0 {
return idxAsPathSet, idxAsPath
}
- for j, conAsPath := range conAsPathSet.AsPathSetMember {
- if conAsPath == reqAsPathSet.AsPathSetMember[0] {
+ for j, conAsPath := range conAsPathSet.AsPathList {
+ if conAsPath == reqAsPathSet.AsPathList[0] {
idxAsPath = j
return idxAsPathSet, idxAsPath
}
@@ -1568,11 +1570,11 @@ func IndexOfCommunitySet(conCommunitySetList []config.CommunitySet, reqCommunity
for i, conCommunitySet := range conCommunitySetList {
if conCommunitySet.CommunitySetName == reqCommunitySet.CommunitySetName {
idxCommunitySet = i
- if len(reqCommunitySet.CommunityMember) == 0 {
+ if len(reqCommunitySet.CommunityList) == 0 {
return idxCommunitySet, idxCommunity
}
- for j, conCommunity := range conCommunitySet.CommunityMember {
- if conCommunity == reqCommunitySet.CommunityMember[0] {
+ for j, conCommunity := range conCommunitySet.CommunityList {
+ if conCommunity == reqCommunitySet.CommunityList[0] {
idxCommunity = j
return idxCommunitySet, idxCommunity
}
@@ -1591,11 +1593,11 @@ func IndexOfExtCommunitySet(conExtCommunitySetList []config.ExtCommunitySet, req
for i, conExtCommunitySet := range conExtCommunitySetList {
if conExtCommunitySet.ExtCommunitySetName == reqExtCommunitySet.ExtCommunitySetName {
idxExtCommunitySet = i
- if len(reqExtCommunitySet.ExtCommunityMember) == 0 {
+ if len(reqExtCommunitySet.ExtCommunityList) == 0 {
return idxExtCommunitySet, idxExtCommunity
}
- for j, conExtCommunity := range conExtCommunitySet.ExtCommunityMember {
- if conExtCommunity == reqExtCommunitySet.ExtCommunityMember[0] {
+ for j, conExtCommunity := range conExtCommunitySet.ExtCommunityList {
+ if conExtCommunity == reqExtCommunitySet.ExtCommunityList[0] {
idxExtCommunity = j
return idxExtCommunitySet, idxExtCommunity
}
@@ -1721,8 +1723,8 @@ func NeighborSetToConfigStruct(reqNeighborSet *api.NeighborSet) (bool, config.Ne
func AsPathSetToApiStruct(as config.AsPathSet) *api.AsPathSet {
resAsPathMembers := make([]string, 0)
- for _, m := range as.AsPathSetMember {
- resAsPathMembers = append(resAsPathMembers, m)
+ for _, a := range as.AsPathList {
+ resAsPathMembers = append(resAsPathMembers, a.AsPath)
}
resAsPathSet := &api.AsPathSet{
AsPathSetName: as.AsPathSetName,
@@ -1736,17 +1738,21 @@ func AsPathSetToConfigStruct(reqAsPathSet *api.AsPathSet) (bool, config.AsPathSe
if len(reqAsPathSet.AsPathMembers) == 0 {
isAsPathSetSet = false
}
+ asPathList := make([]config.AsPath, 0)
+ for _, a := range reqAsPathSet.AsPathMembers {
+ asPathList = append(asPathList, config.AsPath{AsPath: a})
+ }
asPathSet := config.AsPathSet{
- AsPathSetName: reqAsPathSet.AsPathSetName,
- AsPathSetMember: reqAsPathSet.AsPathMembers,
+ AsPathSetName: reqAsPathSet.AsPathSetName,
+ AsPathList: asPathList,
}
return isAsPathSetSet, asPathSet
}
func CommunitySetToApiStruct(cs config.CommunitySet) *api.CommunitySet {
resCommunityMembers := make([]string, 0)
- for _, m := range cs.CommunityMember {
- resCommunityMembers = append(resCommunityMembers, m)
+ for _, c := range cs.CommunityList {
+ resCommunityMembers = append(resCommunityMembers, c.Community)
}
resCommunitySet := &api.CommunitySet{
CommunitySetName: cs.CommunitySetName,
@@ -1760,17 +1766,21 @@ func CommunitySetToConfigStruct(reqCommunitySet *api.CommunitySet) (bool, config
if len(reqCommunitySet.CommunityMembers) == 0 {
isCommunitySet = false
}
+ communityList := make([]config.Community, 0)
+ for _, c := range reqCommunitySet.CommunityMembers {
+ communityList = append(communityList, config.Community{Community: c})
+ }
communitySet := config.CommunitySet{
CommunitySetName: reqCommunitySet.CommunitySetName,
- CommunityMember: reqCommunitySet.CommunityMembers,
+ CommunityList: communityList,
}
return isCommunitySet, communitySet
}
func ExtCommunitySetToApiStruct(es config.ExtCommunitySet) *api.ExtCommunitySet {
resExtCommunityMembers := make([]string, 0)
- for _, m := range es.ExtCommunityMember {
- resExtCommunityMembers = append(resExtCommunityMembers, m)
+ for _, ec := range es.ExtCommunityList {
+ resExtCommunityMembers = append(resExtCommunityMembers, ec.ExtCommunity)
}
resExtCommunitySet := &api.ExtCommunitySet{
ExtCommunitySetName: es.ExtCommunitySetName,
@@ -1784,9 +1794,13 @@ func ExtCommunitySetToConfigStruct(reqExtCommunitySet *api.ExtCommunitySet) (boo
if len(reqExtCommunitySet.ExtCommunityMembers) == 0 {
isExtCommunitySet = false
}
+ extCommunityList := make([]config.ExtCommunity, 0)
+ for _, ec := range reqExtCommunitySet.ExtCommunityMembers {
+ extCommunityList = append(extCommunityList, config.ExtCommunity{ExtCommunity: ec})
+ }
ExtCommunitySet := config.ExtCommunitySet{
ExtCommunitySetName: reqExtCommunitySet.ExtCommunitySetName,
- ExtCommunityMember: reqExtCommunitySet.ExtCommunityMembers,
+ ExtCommunityList: extCommunityList,
}
return isExtCommunitySet, ExtCommunitySet
}
diff --git a/policy/policy_test.go b/policy/policy_test.go
index 7859f747..e184f42d 100644
--- a/policy/policy_test.go
+++ b/policy/policy_test.go
@@ -611,33 +611,46 @@ func TestAsPathConditionEvaluate(t *testing.T) {
// create match condition
asPathSet1 := config.AsPathSet{
- AsPathSetName: "asset1",
- AsPathSetMember: []string{"^65001"},
+ AsPathSetName: "asset1",
+ AsPathList: []config.AsPath{
+ config.AsPath{AsPath: "^65001"},
+ },
}
asPathSet2 := config.AsPathSet{
- AsPathSetName: "asset2",
- AsPathSetMember: []string{"65005$"},
+ AsPathSetName: "asset2",
+ AsPathList: []config.AsPath{
+ config.AsPath{AsPath: "65005$"},
+ },
}
asPathSet3 := config.AsPathSet{
- AsPathSetName: "asset3",
- AsPathSetMember: []string{"65004", "65005$"},
+ AsPathSetName: "asset3",
+ AsPathList: []config.AsPath{
+ config.AsPath{AsPath: "65004"},
+ config.AsPath{AsPath: "65005$"},
+ },
}
asPathSet4 := config.AsPathSet{
- AsPathSetName: "asset4",
- AsPathSetMember: []string{"65000$"},
+ AsPathSetName: "asset4",
+ AsPathList: []config.AsPath{
+ config.AsPath{AsPath: "65000$"},
+ },
}
asPathSet5 := config.AsPathSet{
- AsPathSetName: "asset5",
- AsPathSetMember: []string{"65010"},
+ AsPathSetName: "asset5",
+ AsPathList: []config.AsPath{
+ config.AsPath{AsPath: "65010"},
+ },
}
asPathSet6 := config.AsPathSet{
- AsPathSetName: "asset6",
- AsPathSetMember: []string{"^65010$"},
+ AsPathSetName: "asset6",
+ AsPathList: []config.AsPath{
+ config.AsPath{AsPath: "^65010$"},
+ },
}
asPathSetList := []config.AsPathSet{asPathSet1, asPathSet2, asPathSet3,
@@ -698,8 +711,8 @@ func TestAsPathConditionWithOtherCondition(t *testing.T) {
// create policy
asPathSet := config.AsPathSet{
- AsPathSetName: "asset1",
- AsPathSetMember: []string{"65005$"},
+ AsPathSetName: "asset1",
+ AsPathList: []config.AsPath{config.AsPath{"65005$"}},
}
ps := createPrefixSet("ps1", "10.10.1.0/16", "21..24")
@@ -761,52 +774,78 @@ func TestCommunityConditionEvaluate(t *testing.T) {
// create match condition
comSet1 := config.CommunitySet{
CommunitySetName: "comset1",
- CommunityMember: []string{"65001:10", "65001:50", "65001:100"},
+ CommunityList: []config.Community{
+ config.Community{"65001:10"},
+ config.Community{"65001:50"},
+ config.Community{"65001:100"},
+ },
}
comSet2 := config.CommunitySet{
CommunitySetName: "comset2",
- CommunityMember: []string{"65001:200"},
+ CommunityList: []config.Community{
+ config.Community{"65001:200"},
+ },
}
comSet3 := config.CommunitySet{
CommunitySetName: "comset3",
- CommunityMember: []string{"4259905936"},
+ CommunityList: []config.Community{
+ config.Community{"4259905936"},
+ },
}
comSet4 := config.CommunitySet{
CommunitySetName: "comset4",
- CommunityMember: []string{"^[0-9]*:300$"},
+ CommunityList: []config.Community{
+ config.Community{"^[0-9]*:300$"},
+ },
}
comSet5 := config.CommunitySet{
CommunitySetName: "comset5",
- CommunityMember: []string{"INTERNET"},
+ CommunityList: []config.Community{
+ config.Community{"INTERNET"},
+ },
}
comSet6 := config.CommunitySet{
CommunitySetName: "comset6",
- CommunityMember: []string{"NO_EXPORT"},
+ CommunityList: []config.Community{
+ config.Community{"NO_EXPORT"},
+ },
}
comSet7 := config.CommunitySet{
CommunitySetName: "comset7",
- CommunityMember: []string{"NO_ADVERTISE"},
+ CommunityList: []config.Community{
+ config.Community{"NO_ADVERTISE"},
+ },
}
comSet8 := config.CommunitySet{
CommunitySetName: "comset8",
- CommunityMember: []string{"NO_EXPORT_SUBCONFED"},
+ CommunityList: []config.Community{
+ config.Community{"NO_EXPORT_SUBCONFED"},
+ },
}
comSet9 := config.CommunitySet{
CommunitySetName: "comset9",
- CommunityMember: []string{"65001:100", "65001:200", "65001:300"},
+ CommunityList: []config.Community{
+ config.Community{"65001:100"},
+ config.Community{"65001:200"},
+ config.Community{"65001:300"},
+ },
}
comSet10 := config.CommunitySet{
CommunitySetName: "comset10",
- CommunityMember: []string{"65001:1", "65001:2", "65001:3"},
+ CommunityList: []config.Community{
+ config.Community{"65001:1"},
+ config.Community{"65001:2"},
+ config.Community{"65001:3"},
+ },
}
comSetList := []config.CommunitySet{comSet1, comSet2, comSet3,
@@ -881,18 +920,26 @@ func TestCommunityConditionEvaluateWithOtherCondition(t *testing.T) {
// create policy
asPathSet := config.AsPathSet{
- AsPathSetName: "asset1",
- AsPathSetMember: []string{"65005$"},
+ AsPathSetName: "asset1",
+ AsPathList: []config.AsPath{
+ config.AsPath{"65005$"},
+ },
}
comSet1 := config.CommunitySet{
CommunitySetName: "comset1",
- CommunityMember: []string{"65001:100", "65001:200", "65001:300"},
+ CommunityList: []config.Community{
+ config.Community{"65001:100"},
+ config.Community{"65001:200"},
+ config.Community{"65001:300"},
+ },
}
comSet2 := config.CommunitySet{
CommunitySetName: "comset2",
- CommunityMember: []string{"65050:\\d+"},
+ CommunityList: []config.Community{
+ config.Community{"65050:\\d+"},
+ },
}
ps := createPrefixSet("ps1", "10.10.0.0/16", "21..24")
@@ -1200,48 +1247,74 @@ func TestExtCommunityConditionEvaluate(t *testing.T) {
// create match condition
ecomSet1 := config.ExtCommunitySet{
ExtCommunitySetName: "ecomSet1",
- ExtCommunityMember: []string{"RT:65001:200"},
+ ExtCommunityList: []config.ExtCommunity{
+ config.ExtCommunity{"RT:65001:200"},
+ },
}
ecomSet2 := config.ExtCommunitySet{
ExtCommunitySetName: "ecomSet2",
- ExtCommunityMember: []string{"RT:10.0.0.1:300"},
+ ExtCommunityList: []config.ExtCommunity{
+ config.ExtCommunity{"RT:10.0.0.1:300"},
+ },
}
ecomSet3 := config.ExtCommunitySet{
ExtCommunitySetName: "ecomSet3",
- ExtCommunityMember: []string{fmt.Sprintf("RT:%s:200", convUintStr(65030000))},
+ ExtCommunityList: []config.ExtCommunity{
+ config.ExtCommunity{fmt.Sprintf("RT:%s:200", convUintStr(65030000))},
+ },
}
ecomSet4 := config.ExtCommunitySet{
ExtCommunitySetName: "ecomSet4",
- ExtCommunityMember: []string{"RT:65002:200"},
+ ExtCommunityList: []config.ExtCommunity{
+ config.ExtCommunity{"RT:65002:200"},
+ },
}
ecomSet5 := config.ExtCommunitySet{
ExtCommunitySetName: "ecomSet5",
- ExtCommunityMember: []string{"RT:10.0.0.2:300"},
+ ExtCommunityList: []config.ExtCommunity{
+ config.ExtCommunity{"RT:10.0.0.2:300"},
+ },
}
ecomSet6 := config.ExtCommunitySet{
ExtCommunitySetName: "ecomSet6",
- ExtCommunityMember: []string{fmt.Sprintf("RT:%s:200", convUintStr(65030001))},
+ ExtCommunityList: []config.ExtCommunity{
+ config.ExtCommunity{fmt.Sprintf("RT:%s:200", convUintStr(65030001))},
+ },
}
ecomSet7 := config.ExtCommunitySet{
ExtCommunitySetName: "ecomSet7",
- ExtCommunityMember: []string{"SoO:65010:300"},
+ ExtCommunityList: []config.ExtCommunity{
+ config.ExtCommunity{"SoO:65010:300"},
+ },
}
ecomSet8 := config.ExtCommunitySet{
ExtCommunitySetName: "ecomSet8",
- ExtCommunityMember: []string{"SoO:10.0.10.10:[0-9]+"},
+ ExtCommunityList: []config.ExtCommunity{
+ config.ExtCommunity{"SoO:10.0.10.10:[0-9]+"},
+ },
}
ecomSet9 := config.ExtCommunitySet{
ExtCommunitySetName: "ecomSet9",
- ExtCommunityMember: []string{"RT:[0-9]+:[0-9]+"},
+ ExtCommunityList: []config.ExtCommunity{
+ config.ExtCommunity{"RT:[0-9]+:[0-9]+"},
+ },
}
ecomSet10 := config.ExtCommunitySet{
ExtCommunitySetName: "ecomSet10",
- ExtCommunityMember: []string{"RT:65001:200", "RT:10.0.0.1:300", "SoO:10.0.10.10:[0-9]+"},
+ ExtCommunityList: []config.ExtCommunity{
+ config.ExtCommunity{"RT:65001:200"},
+ config.ExtCommunity{"RT:10.0.0.1:300"},
+ config.ExtCommunity{"SoO:10.0.10.10:[0-9]+"},
+ },
}
ecomSet11 := config.ExtCommunitySet{
ExtCommunitySetName: "ecomSet11",
- ExtCommunityMember: []string{"RT:65001:2", "RT:10.0.0.1:3", "SoO:11.0.10.10:[0-9]+"},
+ ExtCommunityList: []config.ExtCommunity{
+ config.ExtCommunity{"RT:65001:2"},
+ config.ExtCommunity{"RT:10.0.0.1:3"},
+ config.ExtCommunity{"SoO:11.0.10.10:[0-9]+"},
+ },
}
comSetList := []config.ExtCommunitySet{ecomSet1, ecomSet2, ecomSet3, ecomSet4, ecomSet5, ecomSet6, ecomSet7,
@@ -1368,17 +1441,23 @@ func TestExtCommunityConditionEvaluateWithOtherCondition(t *testing.T) {
// create policy
asPathSet := config.AsPathSet{
- AsPathSetName: "asset1",
- AsPathSetMember: []string{"65005$"},
+ AsPathSetName: "asset1",
+ AsPathList: []config.AsPath{
+ config.AsPath{"65005$"},
+ },
}
ecomSet1 := config.ExtCommunitySet{
ExtCommunitySetName: "ecomSet1",
- ExtCommunityMember: []string{"RT:65001:201"},
+ ExtCommunityList: []config.ExtCommunity{
+ config.ExtCommunity{"RT:65001:201"},
+ },
}
ecomSet2 := config.ExtCommunitySet{
ExtCommunitySetName: "ecomSet2",
- ExtCommunityMember: []string{"RT:[0-9]+:[0-9]+"},
+ ExtCommunityList: []config.ExtCommunity{
+ config.ExtCommunity{"RT:[0-9]+:[0-9]+"},
+ },
}
ps := createPrefixSet("ps1", "10.10.1.0/16", "21..24")
diff --git a/server/server.go b/server/server.go
index 0604fded..78d1928e 100644
--- a/server/server.go
+++ b/server/server.go
@@ -1410,8 +1410,8 @@ func (server *BgpServer) handleGrpcAddPolicy(grpcReq *GrpcRequest) {
conAsPathSetList = append(conAsPathSetList, asPathSet)
} else {
if idxAsPath == -1 {
- conAsPathSetList[idxAsPathSet].AsPathSetMember =
- append(conAsPathSetList[idxAsPathSet].AsPathSetMember, asPathSet.AsPathSetMember[0])
+ conAsPathSetList[idxAsPathSet].AsPathList =
+ append(conAsPathSetList[idxAsPathSet].AsPathList, asPathSet.AsPathList[0])
}
}
server.routingPolicy.DefinedSets.BgpDefinedSets.AsPathSets.AsPathSetList = conAsPathSetList
@@ -1431,8 +1431,8 @@ func (server *BgpServer) handleGrpcAddPolicy(grpcReq *GrpcRequest) {
conCommunitySetList = append(conCommunitySetList, communitySet)
} else {
if idxCommunity == -1 {
- conCommunitySetList[idxCommunitySet].CommunityMember =
- append(conCommunitySetList[idxCommunitySet].CommunityMember, communitySet.CommunityMember[0])
+ conCommunitySetList[idxCommunitySet].CommunityList =
+ append(conCommunitySetList[idxCommunitySet].CommunityList, communitySet.CommunityList[0])
}
}
server.routingPolicy.DefinedSets.BgpDefinedSets.CommunitySets.CommunitySetList = conCommunitySetList
@@ -1452,8 +1452,8 @@ func (server *BgpServer) handleGrpcAddPolicy(grpcReq *GrpcRequest) {
conExtCommunitySetList = append(conExtCommunitySetList, extCommunitySet)
} else {
if idxExtCommunity == -1 {
- conExtCommunitySetList[idxExtCommunitySet].ExtCommunityMember =
- append(conExtCommunitySetList[idxExtCommunitySet].ExtCommunityMember, extCommunitySet.ExtCommunityMember[0])
+ conExtCommunitySetList[idxExtCommunitySet].ExtCommunityList =
+ append(conExtCommunitySetList[idxExtCommunitySet].ExtCommunityList, extCommunitySet.ExtCommunityList[0])
}
}
server.routingPolicy.DefinedSets.BgpDefinedSets.ExtCommunitySets.ExtCommunitySetList = conExtCommunitySetList
@@ -1600,15 +1600,15 @@ func (server *BgpServer) handleGrpcDelPolicy(grpcReq *GrpcRequest) {
if isReqAsPathSet {
if idxAsPathSet == -1 {
result.ResponseErr = fmt.Errorf("Policy aspath that has %v %v doesn't exist.", asPathSet.AsPathSetName,
- asPathSet.AsPathSetMember[0])
+ asPathSet.AsPathList[0].AsPath)
} else {
if idxAsPath == -1 {
result.ResponseErr = fmt.Errorf("Policy aspath that has %v %v doesn't exist.", asPathSet.AsPathSetName,
- asPathSet.AsPathSetMember[0])
+ asPathSet.AsPathList[0].AsPath)
} else {
- conAsPathSetList[idxAsPathSet].AsPathSetMember =
- append(conAsPathSetList[idxAsPathSet].AsPathSetMember[:idxAsPath],
- conAsPathSetList[idxAsPathSet].AsPathSetMember[idxAsPath+1:]...)
+ conAsPathSetList[idxAsPathSet].AsPathList =
+ append(conAsPathSetList[idxAsPathSet].AsPathList[:idxAsPath],
+ conAsPathSetList[idxAsPathSet].AsPathList[idxAsPath+1:]...)
}
}
} else {
@@ -1629,15 +1629,15 @@ func (server *BgpServer) handleGrpcDelPolicy(grpcReq *GrpcRequest) {
if isReqCommunitySet {
if idxCommunitySet == -1 {
result.ResponseErr = fmt.Errorf("Policy community that has %v %v doesn't exist.", CommunitySet.CommunitySetName,
- CommunitySet.CommunityMember[0])
+ CommunitySet.CommunityList[0].Community)
} else {
if idxCommunity == -1 {
result.ResponseErr = fmt.Errorf("Policy community that has %v %v doesn't exist.", CommunitySet.CommunitySetName,
- CommunitySet.CommunityMember[0])
+ CommunitySet.CommunityList[0].Community)
} else {
- conCommunitySetList[idxCommunitySet].CommunityMember =
- append(conCommunitySetList[idxCommunitySet].CommunityMember[:idxCommunity],
- conCommunitySetList[idxCommunitySet].CommunityMember[idxCommunity+1:]...)
+ conCommunitySetList[idxCommunitySet].CommunityList =
+ append(conCommunitySetList[idxCommunitySet].CommunityList[:idxCommunity],
+ conCommunitySetList[idxCommunitySet].CommunityList[idxCommunity+1:]...)
}
}
} else {
@@ -1658,15 +1658,15 @@ func (server *BgpServer) handleGrpcDelPolicy(grpcReq *GrpcRequest) {
if isReqExtCommunitySet {
if idxExtCommunitySet == -1 {
result.ResponseErr = fmt.Errorf("Policy extended community that has %v %v doesn't exist.",
- ExtCommunitySet.ExtCommunitySetName, ExtCommunitySet.ExtCommunityMember[0])
+ ExtCommunitySet.ExtCommunitySetName, ExtCommunitySet.ExtCommunityList[0].ExtCommunity)
} else {
if idxExtCommunity == -1 {
result.ResponseErr = fmt.Errorf("Policy extended community that has %v %v doesn't exist.",
- ExtCommunitySet.ExtCommunitySetName, ExtCommunitySet.ExtCommunityMember[0])
+ ExtCommunitySet.ExtCommunitySetName, ExtCommunitySet.ExtCommunityList[0].ExtCommunity)
} else {
- conExtCommunitySetList[idxExtCommunitySet].ExtCommunityMember =
- append(conExtCommunitySetList[idxExtCommunitySet].ExtCommunityMember[:idxExtCommunity],
- conExtCommunitySetList[idxExtCommunitySet].ExtCommunityMember[idxExtCommunity+1:]...)
+ conExtCommunitySetList[idxExtCommunitySet].ExtCommunityList =
+ append(conExtCommunitySetList[idxExtCommunitySet].ExtCommunityList[:idxExtCommunity],
+ conExtCommunitySetList[idxExtCommunitySet].ExtCommunityList[idxExtCommunity+1:]...)
}
}
} else {
diff --git a/test/scenario_test/policy/policy_generator.go b/test/scenario_test/policy/policy_generator.go
index d1a32299..6576c76c 100644
--- a/test/scenario_test/policy/policy_generator.go
+++ b/test/scenario_test/policy/policy_generator.go
@@ -174,41 +174,57 @@ func createPolicyConfig() *config.RoutingPolicy {
}
aspathFrom := config.AsPathSet{
- AsPathSetName: "aspathFrom",
- AsPathSetMember: []string{"^65100"},
+ AsPathSetName: "aspathFrom",
+ AsPathList: []config.AsPath{
+ config.AsPath{"^65100"},
+ },
}
aspathAny := config.AsPathSet{
- AsPathSetName: "aspAny",
- AsPathSetMember: []string{"65098"},
+ AsPathSetName: "aspAny",
+ AsPathList: []config.AsPath{
+ config.AsPath{"65098"},
+ },
}
aspathOrigin := config.AsPathSet{
- AsPathSetName: "aspOrigin",
- AsPathSetMember: []string{"65091$"},
+ AsPathSetName: "aspOrigin",
+ AsPathList: []config.AsPath{
+ config.AsPath{"65091$"},
+ },
}
aspathOnly := config.AsPathSet{
- AsPathSetName: "aspOnly",
- AsPathSetMember: []string{"^65100$"},
+ AsPathSetName: "aspOnly",
+ AsPathList: []config.AsPath{
+ config.AsPath{"^65100$"},
+ },
}
comStr := config.CommunitySet{
CommunitySetName: "comStr",
- CommunityMember: []string{"65100:10"},
+ CommunityList: []config.Community{
+ config.Community{"65100:10"},
+ },
}
comRegExp := config.CommunitySet{
CommunitySetName: "comRegExp",
- CommunityMember: []string{"6[0-9]+:[0-9]+"},
+ CommunityList: []config.Community{
+ config.Community{"6[0-9]+:[0-9]+"},
+ },
}
eComOrigin := config.ExtCommunitySet{
ExtCommunitySetName: "eComOrigin",
- ExtCommunityMember: []string{"SoO:65001.65100:200"},
+ ExtCommunityList: []config.ExtCommunity{
+ config.ExtCommunity{"SoO:65001.65100:200"},
+ },
}
eComTarget := config.ExtCommunitySet{
ExtCommunitySetName: "eComTarget",
- ExtCommunityMember: []string{"RT:6[0-9]+:3[0-9]+"},
+ ExtCommunityList: []config.ExtCommunity{
+ config.ExtCommunity{"RT:6[0-9]+:3[0-9]+"},
+ },
}
createStatement := func(name string, ps, ns string, accept bool) config.Statement {
@@ -639,7 +655,7 @@ func createPolicyConfig() *config.RoutingPolicy {
test_42_only_prefix_condition_accept := config.PolicyDefinition{
Name: "test_42_only_prefix_condition_accept",
- Statements : config.Statements{
+ Statements: config.Statements{
StatementList: []config.Statement{st_only_prefix_condition_accept},
},
}
diff --git a/tools/config/example_toml.go b/tools/config/example_toml.go
index 8a80e540..51ab4ae6 100644
--- a/tools/config/example_toml.go
+++ b/tools/config/example_toml.go
@@ -95,17 +95,23 @@ func policy() config.RoutingPolicy {
cs := config.CommunitySet{
CommunitySetName: "community1",
- CommunityMember: []string{"65100:10"},
+ CommunityList: []config.Community{
+ config.Community{"65100:10"},
+ },
}
ecs := config.ExtCommunitySet{
ExtCommunitySetName: "ecommunity1",
- ExtCommunityMember: []string{"RT:65001:200"},
+ ExtCommunityList: []config.ExtCommunity{
+ config.ExtCommunity{"RT:65001:200"},
+ },
}
as := config.AsPathSet{
- AsPathSetName: "aspath1",
- AsPathSetMember: []string{"^65100"},
+ AsPathSetName: "aspath1",
+ AsPathList: []config.AsPath{
+ config.AsPath{"^65100"},
+ },
}
bds := config.BgpDefinedSets{