summaryrefslogtreecommitdiffhomepage
path: root/table
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2016-01-02 02:13:30 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-01-09 05:17:57 -0800
commitcc8d0fd748f83d774ec59e680586421cd9d9a6d2 (patch)
tree393a564c3d6389084f098732528b3b4206cd60de /table
parent0c1c373e498db1023e4f307f362598a096e36df0 (diff)
config: refactor config structure
- change config variable name to chaincase from camelcase - remove unnecessary wrapper structs which only contain one slice field Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table')
-rw-r--r--table/policy.go91
-rw-r--r--table/policy_test.go282
2 files changed, 192 insertions, 181 deletions
diff --git a/table/policy.go b/table/policy.go
index 263002c3..158d359e 100644
--- a/table/policy.go
+++ b/table/policy.go
@@ -510,13 +510,13 @@ func NewNeighborSetFromApiStruct(a *api.DefinedSet) (*NeighborSet, error) {
func NewNeighborSet(c config.NeighborSet) (*NeighborSet, error) {
name := c.NeighborSetName
if name == "" {
- if len(c.NeighborInfo) == 0 {
+ if len(c.NeighborInfoList) == 0 {
return nil, nil
}
return nil, fmt.Errorf("empty neighbor set name")
}
- list := make([]net.IP, 0, len(c.NeighborInfo))
- for _, x := range c.NeighborInfo {
+ list := make([]net.IP, 0, len(c.NeighborInfoList))
+ for _, x := range c.NeighborInfoList {
addr := net.ParseIP(x)
if addr == nil {
return nil, fmt.Errorf("invalid address: %s", x)
@@ -697,7 +697,7 @@ func (s *AsPathSet) ToApiStruct() *api.DefinedSet {
func NewAsPathSetFromApiStruct(a *api.DefinedSet) (*AsPathSet, error) {
c := config.AsPathSet{
AsPathSetName: a.Name,
- AsPath: a.List,
+ AsPathList: a.List,
}
return NewAsPathSet(c)
}
@@ -705,14 +705,14 @@ func NewAsPathSetFromApiStruct(a *api.DefinedSet) (*AsPathSet, error) {
func NewAsPathSet(c config.AsPathSet) (*AsPathSet, error) {
name := c.AsPathSetName
if name == "" {
- if len(c.AsPath) == 0 {
+ if len(c.AsPathList) == 0 {
return nil, nil
}
return nil, fmt.Errorf("empty as-path set name")
}
- list := make([]*regexp.Regexp, 0, len(c.AsPath))
- singleList := make([]*singleAsPathMatch, 0, len(c.AsPath))
- for _, x := range c.AsPath {
+ list := make([]*regexp.Regexp, 0, len(c.AsPathList))
+ singleList := make([]*singleAsPathMatch, 0, len(c.AsPathList))
+ for _, x := range c.AsPathList {
if s := NewSingleAsPathMatch(x); s != nil {
singleList = append(singleList, s)
} else {
@@ -899,7 +899,7 @@ func ParseExtCommunityRegexp(arg string) (bgp.ExtendedCommunityAttrSubType, *reg
func NewCommunitySetFromApiStruct(a *api.DefinedSet) (*CommunitySet, error) {
c := config.CommunitySet{
CommunitySetName: a.Name,
- Community: a.List,
+ CommunityList: a.List,
}
return NewCommunitySet(c)
}
@@ -907,13 +907,13 @@ func NewCommunitySetFromApiStruct(a *api.DefinedSet) (*CommunitySet, error) {
func NewCommunitySet(c config.CommunitySet) (*CommunitySet, error) {
name := c.CommunitySetName
if name == "" {
- if len(c.Community) == 0 {
+ if len(c.CommunityList) == 0 {
return nil, nil
}
return nil, fmt.Errorf("empty community set name")
}
- list := make([]*regexp.Regexp, 0, len(c.Community))
- for _, x := range c.Community {
+ list := make([]*regexp.Regexp, 0, len(c.CommunityList))
+ for _, x := range c.CommunityList {
exp, err := ParseCommunityRegexp(x)
if err != nil {
return nil, err
@@ -959,7 +959,7 @@ func (s *ExtCommunitySet) ToApiStruct() *api.DefinedSet {
func NewExtCommunitySetFromApiStruct(a *api.DefinedSet) (*ExtCommunitySet, error) {
c := config.ExtCommunitySet{
ExtCommunitySetName: a.Name,
- ExtCommunity: a.List,
+ ExtCommunityList: a.List,
}
return NewExtCommunitySet(c)
}
@@ -967,14 +967,14 @@ func NewExtCommunitySetFromApiStruct(a *api.DefinedSet) (*ExtCommunitySet, error
func NewExtCommunitySet(c config.ExtCommunitySet) (*ExtCommunitySet, error) {
name := c.ExtCommunitySetName
if name == "" {
- if len(c.ExtCommunity) == 0 {
+ if len(c.ExtCommunityList) == 0 {
return nil, nil
}
return nil, fmt.Errorf("empty ext-community set name")
}
- list := make([]*regexp.Regexp, 0, len(c.ExtCommunity))
- subtypeList := make([]bgp.ExtendedCommunityAttrSubType, 0, len(c.ExtCommunity))
- for _, x := range c.ExtCommunity {
+ list := make([]*regexp.Regexp, 0, len(c.ExtCommunityList))
+ subtypeList := make([]bgp.ExtendedCommunityAttrSubType, 0, len(c.ExtCommunityList))
+ for _, x := range c.ExtCommunityList {
subtype, exp, err := ParseExtCommunityRegexp(x)
if err != nil {
return nil, err
@@ -1741,7 +1741,7 @@ func NewCommunityActionFromApiStruct(a *api.CommunityAction) (*CommunityAction,
func NewCommunityAction(c config.SetCommunity) (*CommunityAction, error) {
a, ok := CommunityOptionValueMap[strings.ToLower(c.Options)]
if !ok {
- if len(c.SetCommunityMethod.Communities) == 0 {
+ if len(c.SetCommunityMethod.CommunitiesList) == 0 {
return nil, nil
}
return nil, fmt.Errorf("invalid option name: %s", c.Options)
@@ -1749,11 +1749,11 @@ func NewCommunityAction(c config.SetCommunity) (*CommunityAction, error) {
var list []uint32
var removeList []*regexp.Regexp
if a == config.BGP_SET_COMMUNITY_OPTION_TYPE_REMOVE {
- removeList = make([]*regexp.Regexp, 0, len(c.SetCommunityMethod.Communities))
+ removeList = make([]*regexp.Regexp, 0, len(c.SetCommunityMethod.CommunitiesList))
} else {
- list = make([]uint32, 0, len(c.SetCommunityMethod.Communities))
+ list = make([]uint32, 0, len(c.SetCommunityMethod.CommunitiesList))
}
- for _, x := range c.SetCommunityMethod.Communities {
+ for _, x := range c.SetCommunityMethod.CommunitiesList {
if a == config.BGP_SET_COMMUNITY_OPTION_TYPE_REMOVE {
exp, err := ParseCommunityRegexp(x)
if err != nil {
@@ -1865,20 +1865,20 @@ func NewExtCommunityActionFromApiStruct(a *api.CommunityAction) (*ExtCommunityAc
func NewExtCommunityAction(c config.SetExtCommunity) (*ExtCommunityAction, error) {
a, ok := CommunityOptionValueMap[strings.ToLower(c.Options)]
if !ok {
- if len(c.SetExtCommunityMethod.Communities) == 0 {
+ if len(c.SetExtCommunityMethod.CommunitiesList) == 0 {
return nil, nil
}
return nil, fmt.Errorf("invalid option name: %s", c.Options)
}
var list []bgp.ExtendedCommunityInterface
var removeList []*regexp.Regexp
- subtypeList := make([]bgp.ExtendedCommunityAttrSubType, 0, len(c.SetExtCommunityMethod.Communities))
+ subtypeList := make([]bgp.ExtendedCommunityAttrSubType, 0, len(c.SetExtCommunityMethod.CommunitiesList))
if a == config.BGP_SET_COMMUNITY_OPTION_TYPE_REMOVE {
- removeList = make([]*regexp.Regexp, 0, len(c.SetExtCommunityMethod.Communities))
+ removeList = make([]*regexp.Regexp, 0, len(c.SetExtCommunityMethod.CommunitiesList))
} else {
- list = make([]bgp.ExtendedCommunityInterface, 0, len(c.SetExtCommunityMethod.Communities))
+ list = make([]bgp.ExtendedCommunityInterface, 0, len(c.SetExtCommunityMethod.CommunitiesList))
}
- for _, x := range c.SetExtCommunityMethod.Communities {
+ for _, x := range c.SetExtCommunityMethod.CommunitiesList {
if a == config.BGP_SET_COMMUNITY_OPTION_TYPE_REMOVE {
subtype, exp, err := ParseExtCommunityRegexp(x)
if err != nil {
@@ -2516,7 +2516,7 @@ func NewPolicy(c config.PolicyDefinition, dmap DefinedSetMap) (*Policy, error) {
return nil, fmt.Errorf("empty policy name")
}
var st []*Statement
- stmts := c.Statements.StatementList
+ stmts := c.Statements
if len(stmts) != 0 {
st = make([]*Statement, 0, len(stmts))
for idx, stmt := range stmts {
@@ -2654,13 +2654,13 @@ func (r *RoutingPolicy) GetAssignmentFromConfig(dir PolicyDirection, a config.Ap
c := a.Config
switch dir {
case POLICY_DIRECTION_IN:
- names = c.InPolicy
+ names = c.InPolicyList
cdef = c.DefaultInPolicy
case POLICY_DIRECTION_IMPORT:
- names = c.ImportPolicy
+ names = c.ImportPolicyList
cdef = c.DefaultImportPolicy
case POLICY_DIRECTION_EXPORT:
- names = c.ExportPolicy
+ names = c.ExportPolicyList
cdef = c.DefaultExportPolicy
default:
return nil, def, fmt.Errorf("invalid policy direction")
@@ -2708,23 +2708,29 @@ func (r *RoutingPolicy) Reload(c config.RoutingPolicy) error {
dmap := make(map[DefinedType]map[string]DefinedSet)
dmap[DEFINED_TYPE_PREFIX] = make(map[string]DefinedSet)
d := c.DefinedSets
- for _, x := range d.PrefixSets.PrefixSetList {
+ for _, x := range d.PrefixSets {
y, err := NewPrefixSet(x)
if err != nil {
return err
}
+ if y == nil {
+ return fmt.Errorf("empty prefix set")
+ }
dmap[DEFINED_TYPE_PREFIX][y.Name()] = y
}
dmap[DEFINED_TYPE_NEIGHBOR] = make(map[string]DefinedSet)
- for _, x := range d.NeighborSets.NeighborSetList {
+ for _, x := range d.NeighborSets {
y, err := NewNeighborSet(x)
if err != nil {
return err
}
+ if y == nil {
+ return fmt.Errorf("empty neighbor set")
+ }
dmap[DEFINED_TYPE_NEIGHBOR][y.Name()] = y
}
// dmap[DEFINED_TYPE_TAG] = make(map[string]DefinedSet)
- // for _, x := range c.DefinedSets.TagSets.TagSetList {
+ // for _, x := range c.DefinedSets.TagSets{
// y, err := NewTagSet(x)
// if err != nil {
// return nil, err
@@ -2733,32 +2739,41 @@ func (r *RoutingPolicy) Reload(c config.RoutingPolicy) error {
// }
bd := c.DefinedSets.BgpDefinedSets
dmap[DEFINED_TYPE_AS_PATH] = make(map[string]DefinedSet)
- for _, x := range bd.AsPathSets.AsPathSetList {
+ for _, x := range bd.AsPathSets {
y, err := NewAsPathSet(x)
if err != nil {
return err
}
+ if y == nil {
+ return fmt.Errorf("empty as path set")
+ }
dmap[DEFINED_TYPE_AS_PATH][y.Name()] = y
}
dmap[DEFINED_TYPE_COMMUNITY] = make(map[string]DefinedSet)
- for _, x := range bd.CommunitySets.CommunitySetList {
+ for _, x := range bd.CommunitySets {
y, err := NewCommunitySet(x)
if err != nil {
return err
}
+ if y == nil {
+ return fmt.Errorf("empty community set")
+ }
dmap[DEFINED_TYPE_COMMUNITY][y.Name()] = y
}
dmap[DEFINED_TYPE_EXT_COMMUNITY] = make(map[string]DefinedSet)
- for _, x := range bd.ExtCommunitySets.ExtCommunitySetList {
+ for _, x := range bd.ExtCommunitySets {
y, err := NewExtCommunitySet(x)
if err != nil {
return err
}
+ if y == nil {
+ return fmt.Errorf("empty ext-community set")
+ }
dmap[DEFINED_TYPE_EXT_COMMUNITY][y.Name()] = y
}
pmap := make(map[string]*Policy)
smap := make(map[string]*Statement)
- for _, x := range c.PolicyDefinitions.PolicyDefinitionList {
+ for _, x := range c.PolicyDefinitions {
y, err := NewPolicy(x, dmap)
if err != nil {
return err
@@ -2798,7 +2813,7 @@ func CanImportToVrf(v *Vrf, path *Path) bool {
}
set, _ := NewExtCommunitySet(config.ExtCommunitySet{
ExtCommunitySetName: v.Name,
- ExtCommunity: f(v.ImportRt),
+ ExtCommunityList: f(v.ImportRt),
})
matchSet := config.MatchExtCommunitySet{
ExtCommunitySet: v.Name,
diff --git a/table/policy_test.go b/table/policy_test.go
index 099804d7..4df99f86 100644
--- a/table/policy_test.go
+++ b/table/policy_test.go
@@ -232,8 +232,8 @@ func TestPolicyNotMatch(t *testing.T) {
ps := createPrefixSet("ps1", "10.3.0.0/16", "21..24")
ns := createNeighborSet("ns1", "10.0.0.1")
ds := config.DefinedSets{}
- ds.PrefixSets.PrefixSetList = []config.PrefixSet{ps}
- ds.NeighborSets.NeighborSetList = []config.NeighborSet{ns}
+ ds.PrefixSets = []config.PrefixSet{ps}
+ ds.NeighborSets = []config.NeighborSet{ns}
s := createStatement("statement1", "ps1", "ns1", false)
pd := createPolicyDefinition("pd1", s)
pl := createRoutingPolicy(ds, pd)
@@ -262,8 +262,8 @@ func TestPolicyMatchAndReject(t *testing.T) {
ps := createPrefixSet("ps1", "10.10.0.0/16", "21..24")
ns := createNeighborSet("ns1", "10.0.0.1")
ds := config.DefinedSets{}
- ds.PrefixSets.PrefixSetList = []config.PrefixSet{ps}
- ds.NeighborSets.NeighborSetList = []config.NeighborSet{ns}
+ ds.PrefixSets = []config.PrefixSet{ps}
+ ds.NeighborSets = []config.NeighborSet{ns}
s := createStatement("statement1", "ps1", "ns1", false)
pd := createPolicyDefinition("pd1", s)
@@ -293,8 +293,8 @@ func TestPolicyMatchAndAccept(t *testing.T) {
ps := createPrefixSet("ps1", "10.10.0.0/16", "21..24")
ns := createNeighborSet("ns1", "10.0.0.1")
ds := config.DefinedSets{}
- ds.PrefixSets.PrefixSetList = []config.PrefixSet{ps}
- ds.NeighborSets.NeighborSetList = []config.NeighborSet{ns}
+ ds.PrefixSets = []config.PrefixSet{ps}
+ ds.NeighborSets = []config.NeighborSet{ns}
s := createStatement("statement1", "ps1", "ns1", true)
pd := createPolicyDefinition("pd1", s)
@@ -336,7 +336,7 @@ func TestPolicyRejectOnlyPrefixSet(t *testing.T) {
// create policy
ps := createPrefixSet("ps1", "10.10.1.0/16", "21..24")
ds := config.DefinedSets{}
- ds.PrefixSets.PrefixSetList = []config.PrefixSet{ps}
+ ds.PrefixSets = []config.PrefixSet{ps}
s := createStatement("statement1", "ps1", "", false)
pd := createPolicyDefinition("pd1", s)
@@ -383,7 +383,7 @@ func TestPolicyRejectOnlyNeighborSet(t *testing.T) {
// create policy
ns := createNeighborSet("ns1", "10.0.1.1")
ds := config.DefinedSets{}
- ds.NeighborSets.NeighborSetList = []config.NeighborSet{ns}
+ ds.NeighborSets = []config.NeighborSet{ns}
s := createStatement("statement1", "", "ns1", false)
pd := createPolicyDefinition("pd1", s)
@@ -433,8 +433,8 @@ func TestPolicyDifferentRoutefamilyOfPathAndPolicy(t *testing.T) {
nsIPv6 := createNeighborSet("nsIPv6", "2001::192:168:50:1")
ds := config.DefinedSets{}
- ds.PrefixSets.PrefixSetList = []config.PrefixSet{psIPv4, psIPv6}
- ds.NeighborSets.NeighborSetList = []config.NeighborSet{nsIPv4, nsIPv6}
+ ds.PrefixSets = []config.PrefixSet{psIPv4, psIPv6}
+ ds.NeighborSets = []config.NeighborSet{nsIPv4, nsIPv6}
stIPv4 := createStatement("statement1", "psIPv4", "nsIPv4", false)
stIPv6 := createStatement("statement2", "psIPv6", "nsIPv6", false)
@@ -528,8 +528,8 @@ func TestAsPathLengthConditionWithOtherCondition(t *testing.T) {
ns := createNeighborSet("ns1", "10.0.0.1")
ds := config.DefinedSets{}
- ds.PrefixSets.PrefixSetList = []config.PrefixSet{ps}
- ds.NeighborSets.NeighborSetList = []config.NeighborSet{ns}
+ ds.PrefixSets = []config.PrefixSet{ps}
+ ds.NeighborSets = []config.NeighborSet{ns}
// create match condition
asPathLength := config.AsPathLength{
@@ -646,8 +646,8 @@ func TestAs4PathLengthConditionWithOtherCondition(t *testing.T) {
ns := createNeighborSet("ns1", "10.0.0.1")
ds := config.DefinedSets{}
- ds.PrefixSets.PrefixSetList = []config.PrefixSet{ps}
- ds.NeighborSets.NeighborSetList = []config.NeighborSet{ns}
+ ds.PrefixSets = []config.PrefixSet{ps}
+ ds.NeighborSets = []config.NeighborSet{ns}
// create match condition
asPathLength := config.AsPathLength{
@@ -663,7 +663,7 @@ func TestAs4PathLengthConditionWithOtherCondition(t *testing.T) {
//test
r := NewRoutingPolicy()
r.Reload(pl)
- p, _ := NewPolicy(pl.PolicyDefinitions.PolicyDefinitionList[0], r.DefinedSetMap)
+ p, _ := NewPolicy(pl.PolicyDefinitions[0], r.DefinedSetMap)
pType, newPath := p.Apply(path)
assert.Equal(t, ROUTE_TYPE_REJECT, pType)
assert.Equal(t, newPath, path)
@@ -700,32 +700,32 @@ func TestAsPathConditionEvaluate(t *testing.T) {
// create match condition
asPathSet1 := config.AsPathSet{
AsPathSetName: "asset1",
- AsPath: []string{"^65001"},
+ AsPathList: []string{"^65001"},
}
asPathSet2 := config.AsPathSet{
AsPathSetName: "asset2",
- AsPath: []string{"65005$"},
+ AsPathList: []string{"65005$"},
}
asPathSet3 := config.AsPathSet{
AsPathSetName: "asset3",
- AsPath: []string{"65004", "65005$"},
+ AsPathList: []string{"65004", "65005$"},
}
asPathSet4 := config.AsPathSet{
AsPathSetName: "asset4",
- AsPath: []string{"65000$"},
+ AsPathList: []string{"65000$"},
}
asPathSet5 := config.AsPathSet{
AsPathSetName: "asset5",
- AsPath: []string{"65010"},
+ AsPathList: []string{"65010"},
}
asPathSet6 := config.AsPathSet{
AsPathSetName: "asset6",
- AsPath: []string{"^65010$"},
+ AsPathList: []string{"^65010$"},
}
m := make(map[string]DefinedSet)
@@ -785,47 +785,47 @@ func TestMultipleAsPathConditionEvaluate(t *testing.T) {
// create match condition
asPathSet1 := config.AsPathSet{
AsPathSetName: "asset1",
- AsPath: []string{"^65001_65000"},
+ AsPathList: []string{"^65001_65000"},
}
asPathSet2 := config.AsPathSet{
AsPathSetName: "asset2",
- AsPath: []string{"65004_65005$"},
+ AsPathList: []string{"65004_65005$"},
}
asPathSet3 := config.AsPathSet{
AsPathSetName: "asset3",
- AsPath: []string{"65001_65000_54000"},
+ AsPathList: []string{"65001_65000_54000"},
}
asPathSet4 := config.AsPathSet{
AsPathSetName: "asset4",
- AsPath: []string{"54000_65004_65005"},
+ AsPathList: []string{"54000_65004_65005"},
}
asPathSet5 := config.AsPathSet{
AsPathSetName: "asset5",
- AsPath: []string{"^65001 65000 54000 65004 65005$"},
+ AsPathList: []string{"^65001 65000 54000 65004 65005$"},
}
asPathSet6 := config.AsPathSet{
AsPathSetName: "asset6",
- AsPath: []string{".*_[0-9]+_65005"},
+ AsPathList: []string{".*_[0-9]+_65005"},
}
asPathSet7 := config.AsPathSet{
AsPathSetName: "asset7",
- AsPath: []string{".*_5[0-9]+_[0-9]+"},
+ AsPathList: []string{".*_5[0-9]+_[0-9]+"},
}
asPathSet8 := config.AsPathSet{
AsPathSetName: "asset8",
- AsPath: []string{"6[0-9]+_6[0-9]+_5[0-9]+"},
+ AsPathList: []string{"6[0-9]+_6[0-9]+_5[0-9]+"},
}
asPathSet9 := config.AsPathSet{
AsPathSetName: "asset9",
- AsPath: []string{"6[0-9]+__6[0-9]+"},
+ AsPathList: []string{"6[0-9]+__6[0-9]+"},
}
m := make(map[string]DefinedSet)
@@ -914,7 +914,7 @@ func TestAsPathCondition(t *testing.T) {
for k, v := range tests {
s, _ := NewAsPathSet(config.AsPathSet{
AsPathSetName: k,
- AsPath: []string{k},
+ AsPathList: []string{k},
})
c, _ := NewAsPathCondition(config.MatchAsPathSet{
AsPathSet: k,
@@ -956,16 +956,16 @@ func TestAsPathConditionWithOtherCondition(t *testing.T) {
// create policy
asPathSet := config.AsPathSet{
AsPathSetName: "asset1",
- AsPath: []string{"65005$"},
+ AsPathList: []string{"65005$"},
}
ps := createPrefixSet("ps1", "10.10.1.0/16", "21..24")
ns := createNeighborSet("ns1", "10.0.0.1")
ds := config.DefinedSets{}
- ds.PrefixSets.PrefixSetList = []config.PrefixSet{ps}
- ds.NeighborSets.NeighborSetList = []config.NeighborSet{ns}
- ds.BgpDefinedSets.AsPathSets.AsPathSetList = []config.AsPathSet{asPathSet}
+ ds.PrefixSets = []config.PrefixSet{ps}
+ ds.NeighborSets = []config.NeighborSet{ns}
+ ds.BgpDefinedSets.AsPathSets = []config.AsPathSet{asPathSet}
s := createStatement("statement1", "ps1", "ns1", false)
s.Conditions.BgpConditions.MatchAsPathSet.AsPathSet = "asset1"
@@ -1022,17 +1022,17 @@ func TestAs4PathConditionEvaluate(t *testing.T) {
// create match condition
asPathSet1 := config.AsPathSet{
AsPathSetName: "asset1",
- AsPath: []string{fmt.Sprintf("^%d", createAs4Value("65001.1"))},
+ AsPathList: []string{fmt.Sprintf("^%d", createAs4Value("65001.1"))},
}
asPathSet2 := config.AsPathSet{
AsPathSetName: "asset2",
- AsPath: []string{fmt.Sprintf("%d$", createAs4Value("65005.1"))},
+ AsPathList: []string{fmt.Sprintf("%d$", createAs4Value("65005.1"))},
}
asPathSet3 := config.AsPathSet{
AsPathSetName: "asset3",
- AsPath: []string{
+ AsPathList: []string{
fmt.Sprintf("%d", createAs4Value("65004.1")),
fmt.Sprintf("%d$", createAs4Value("65005.1")),
},
@@ -1040,21 +1040,21 @@ func TestAs4PathConditionEvaluate(t *testing.T) {
asPathSet4 := config.AsPathSet{
AsPathSetName: "asset4",
- AsPath: []string{
+ AsPathList: []string{
fmt.Sprintf("%d$", createAs4Value("65000.1")),
},
}
asPathSet5 := config.AsPathSet{
AsPathSetName: "asset5",
- AsPath: []string{
+ AsPathList: []string{
fmt.Sprintf("%d", createAs4Value("65010.1")),
},
}
asPathSet6 := config.AsPathSet{
AsPathSetName: "asset6",
- AsPath: []string{
+ AsPathList: []string{
fmt.Sprintf("%d$", createAs4Value("65010.1")),
},
}
@@ -1125,59 +1125,59 @@ func TestMultipleAs4PathConditionEvaluate(t *testing.T) {
// create match condition
asPathSet1 := config.AsPathSet{
AsPathSetName: "asset1",
- AsPath: []string{
+ AsPathList: []string{
fmt.Sprintf("^%d_%d", createAs4Value("65001.1"), createAs4Value("65000.1")),
},
}
asPathSet2 := config.AsPathSet{
AsPathSetName: "asset2",
- AsPath: []string{
+ AsPathList: []string{
fmt.Sprintf("%d_%d$", createAs4Value("65004.1"), createAs4Value("65005.1")),
},
}
asPathSet3 := config.AsPathSet{
AsPathSetName: "asset3",
- AsPath: []string{
+ AsPathList: []string{
fmt.Sprintf("%d_%d_%d", createAs4Value("65001.1"), createAs4Value("65000.1"), createAs4Value("54000.1")),
},
}
asPathSet4 := config.AsPathSet{
AsPathSetName: "asset4",
- AsPath: []string{
+ AsPathList: []string{
fmt.Sprintf("%d_%d_%d", createAs4Value("54000.1"), createAs4Value("65004.1"), createAs4Value("65005.1")),
},
}
asPathSet5 := config.AsPathSet{
AsPathSetName: "asset5",
- AsPath: []string{
+ AsPathList: []string{
fmt.Sprintf("^%d %d %d %d %d$", createAs4Value("65001.1"), createAs4Value("65000.1"), createAs4Value("54000.1"), createAs4Value("65004.1"), createAs4Value("65005.1")),
},
}
asPathSet6 := config.AsPathSet{
AsPathSetName: "asset6",
- AsPath: []string{
+ AsPathList: []string{
fmt.Sprintf(".*_[0-9]+_%d", createAs4Value("65005.1")),
},
}
asPathSet7 := config.AsPathSet{
AsPathSetName: "asset7",
- AsPath: []string{".*_3[0-9]+_[0-9]+"},
+ AsPathList: []string{".*_3[0-9]+_[0-9]+"},
}
asPathSet8 := config.AsPathSet{
AsPathSetName: "asset8",
- AsPath: []string{"4[0-9]+_4[0-9]+_3[0-9]+"},
+ AsPathList: []string{"4[0-9]+_4[0-9]+_3[0-9]+"},
}
asPathSet9 := config.AsPathSet{
AsPathSetName: "asset9",
- AsPath: []string{"4[0-9]+__4[0-9]+"},
+ AsPathList: []string{"4[0-9]+__4[0-9]+"},
}
m := make(map[string]DefinedSet)
@@ -1250,16 +1250,16 @@ func TestAs4PathConditionWithOtherCondition(t *testing.T) {
// create policy
asPathSet := config.AsPathSet{
AsPathSetName: "asset1",
- AsPath: []string{fmt.Sprintf("%d$", createAs4Value("65005.1"))},
+ AsPathList: []string{fmt.Sprintf("%d$", createAs4Value("65005.1"))},
}
ps := createPrefixSet("ps1", "10.10.1.0/16", "21..24")
ns := createNeighborSet("ns1", "10.0.0.1")
ds := config.DefinedSets{}
- ds.PrefixSets.PrefixSetList = []config.PrefixSet{ps}
- ds.NeighborSets.NeighborSetList = []config.NeighborSet{ns}
- ds.BgpDefinedSets.AsPathSets.AsPathSetList = []config.AsPathSet{asPathSet}
+ ds.PrefixSets = []config.PrefixSet{ps}
+ ds.NeighborSets = []config.NeighborSet{ns}
+ ds.BgpDefinedSets.AsPathSets = []config.AsPathSet{asPathSet}
s := createStatement("statement1", "ps1", "ns1", false)
s.Conditions.BgpConditions.MatchAsPathSet.AsPathSet = "asset1"
@@ -1270,7 +1270,7 @@ func TestAs4PathConditionWithOtherCondition(t *testing.T) {
//test
r := NewRoutingPolicy()
r.Reload(pl)
- p, _ := NewPolicy(pl.PolicyDefinitions.PolicyDefinitionList[0], r.DefinedSetMap)
+ p, _ := NewPolicy(pl.PolicyDefinitions[0], r.DefinedSetMap)
pType, newPath := p.Apply(path)
assert.Equal(t, ROUTE_TYPE_REJECT, pType)
assert.Equal(t, newPath, path)
@@ -1308,37 +1308,37 @@ func TestAs4PathConditionEvaluateMixedWith2byteAS(t *testing.T) {
// create match condition
asPathSet1 := config.AsPathSet{
AsPathSetName: "asset1",
- AsPath: []string{fmt.Sprintf("^%d", createAs4Value("65001.1"))},
+ AsPathList: []string{fmt.Sprintf("^%d", createAs4Value("65001.1"))},
}
asPathSet2 := config.AsPathSet{
AsPathSetName: "asset2",
- AsPath: []string{"4000$"},
+ AsPathList: []string{"4000$"},
}
asPathSet3 := config.AsPathSet{
AsPathSetName: "asset3",
- AsPath: []string{fmt.Sprintf("%d", createAs4Value("65004.1")), "4000$"},
+ AsPathList: []string{fmt.Sprintf("%d", createAs4Value("65004.1")), "4000$"},
}
asPathSet4 := config.AsPathSet{
AsPathSetName: "asset4",
- AsPath: []string{fmt.Sprintf("%d_%d_%d", createAs4Value("54000.1"), 100, 5000)},
+ AsPathList: []string{fmt.Sprintf("%d_%d_%d", createAs4Value("54000.1"), 100, 5000)},
}
asPathSet5 := config.AsPathSet{
AsPathSetName: "asset5",
- AsPath: []string{".*_[0-9]+_100"},
+ AsPathList: []string{".*_[0-9]+_100"},
}
asPathSet6 := config.AsPathSet{
AsPathSetName: "asset6",
- AsPath: []string{".*_3[0-9]+_[0]+"},
+ AsPathList: []string{".*_3[0-9]+_[0]+"},
}
asPathSet7 := config.AsPathSet{
AsPathSetName: "asset7",
- AsPath: []string{".*_3[0-9]+_[1]+"},
+ AsPathList: []string{".*_3[0-9]+_[1]+"},
}
m := make(map[string]DefinedSet)
@@ -1420,47 +1420,47 @@ func TestCommunityConditionEvaluate(t *testing.T) {
// create match condition
comSet1 := config.CommunitySet{
CommunitySetName: "comset1",
- Community: []string{"65001:10", "65001:50", "65001:100"},
+ CommunityList: []string{"65001:10", "65001:50", "65001:100"},
}
comSet2 := config.CommunitySet{
CommunitySetName: "comset2",
- Community: []string{"65001:200"},
+ CommunityList: []string{"65001:200"},
}
comSet3 := config.CommunitySet{
CommunitySetName: "comset3",
- Community: []string{"4259905936"},
+ CommunityList: []string{"4259905936"},
}
comSet4 := config.CommunitySet{
CommunitySetName: "comset4",
- Community: []string{"^[0-9]*:300$"},
+ CommunityList: []string{"^[0-9]*:300$"},
}
comSet5 := config.CommunitySet{
CommunitySetName: "comset5",
- Community: []string{"INTERNET"},
+ CommunityList: []string{"INTERNET"},
}
comSet6 := config.CommunitySet{
CommunitySetName: "comset6",
- Community: []string{"NO_EXPORT"},
+ CommunityList: []string{"NO_EXPORT"},
}
comSet7 := config.CommunitySet{
CommunitySetName: "comset7",
- Community: []string{"NO_ADVERTISE"},
+ CommunityList: []string{"NO_ADVERTISE"},
}
comSet8 := config.CommunitySet{
CommunitySetName: "comset8",
- Community: []string{"NO_EXPORT_SUBCONFED"},
+ CommunityList: []string{"NO_EXPORT_SUBCONFED"},
}
comSet9 := config.CommunitySet{
CommunitySetName: "comset9",
- Community: []string{
+ CommunityList: []string{
"65001:\\d+",
"\\d+:\\d00",
},
@@ -1468,7 +1468,7 @@ func TestCommunityConditionEvaluate(t *testing.T) {
comSet10 := config.CommunitySet{
CommunitySetName: "comset10",
- Community: []string{
+ CommunityList: []string{
"65001:1",
"65001:2",
"65001:3",
@@ -1552,27 +1552,27 @@ func TestCommunityConditionEvaluateWithOtherCondition(t *testing.T) {
// create policy
asPathSet := config.AsPathSet{
AsPathSetName: "asset1",
- AsPath: []string{"65005$"},
+ AsPathList: []string{"65005$"},
}
comSet1 := config.CommunitySet{
CommunitySetName: "comset1",
- Community: []string{"65001:100", "65001:200", "65001:300"},
+ CommunityList: []string{"65001:100", "65001:200", "65001:300"},
}
comSet2 := config.CommunitySet{
CommunitySetName: "comset2",
- Community: []string{"65050:\\d+"},
+ CommunityList: []string{"65050:\\d+"},
}
ps := createPrefixSet("ps1", "10.10.0.0/16", "21..24")
ns := createNeighborSet("ns1", "10.0.0.1")
ds := config.DefinedSets{}
- ds.PrefixSets.PrefixSetList = []config.PrefixSet{ps}
- ds.NeighborSets.NeighborSetList = []config.NeighborSet{ns}
- ds.BgpDefinedSets.AsPathSets.AsPathSetList = []config.AsPathSet{asPathSet}
- ds.BgpDefinedSets.CommunitySets.CommunitySetList = []config.CommunitySet{comSet1, comSet2}
+ ds.PrefixSets = []config.PrefixSet{ps}
+ ds.NeighborSets = []config.NeighborSet{ns}
+ ds.BgpDefinedSets.AsPathSets = []config.AsPathSet{asPathSet}
+ ds.BgpDefinedSets.CommunitySets = []config.CommunitySet{comSet1, comSet2}
s1 := createStatement("statement1", "ps1", "ns1", false)
s1.Conditions.BgpConditions.MatchAsPathSet.AsPathSet = "asset1"
@@ -1620,8 +1620,8 @@ func TestPolicyMatchAndAddCommunities(t *testing.T) {
ns := createNeighborSet("ns1", "10.0.0.1")
ds := config.DefinedSets{}
- ds.PrefixSets.PrefixSetList = []config.PrefixSet{ps}
- ds.NeighborSets.NeighborSetList = []config.NeighborSet{ns}
+ ds.PrefixSets = []config.PrefixSet{ps}
+ ds.NeighborSets = []config.NeighborSet{ns}
community := "65000:100"
@@ -1665,8 +1665,8 @@ func TestPolicyMatchAndReplaceCommunities(t *testing.T) {
ns := createNeighborSet("ns1", "10.0.0.1")
ds := config.DefinedSets{}
- ds.PrefixSets.PrefixSetList = []config.PrefixSet{ps}
- ds.NeighborSets.NeighborSetList = []config.NeighborSet{ns}
+ ds.PrefixSets = []config.PrefixSet{ps}
+ ds.NeighborSets = []config.NeighborSet{ns}
community := "65000:100"
@@ -1712,8 +1712,8 @@ func TestPolicyMatchAndRemoveCommunities(t *testing.T) {
ns := createNeighborSet("ns1", "10.0.0.1")
ds := config.DefinedSets{}
- ds.PrefixSets.PrefixSetList = []config.PrefixSet{ps}
- ds.NeighborSets.NeighborSetList = []config.NeighborSet{ns}
+ ds.PrefixSets = []config.PrefixSet{ps}
+ ds.NeighborSets = []config.NeighborSet{ns}
s := createStatement("statement1", "ps1", "ns1", true)
s.Actions.BgpActions.SetCommunity = createSetCommunity("REMOVE", community1)
@@ -1758,8 +1758,8 @@ func TestPolicyMatchAndRemoveCommunitiesRegexp(t *testing.T) {
ns := createNeighborSet("ns1", "10.0.0.1")
ds := config.DefinedSets{}
- ds.PrefixSets.PrefixSetList = []config.PrefixSet{ps}
- ds.NeighborSets.NeighborSetList = []config.NeighborSet{ns}
+ ds.PrefixSets = []config.PrefixSet{ps}
+ ds.NeighborSets = []config.NeighborSet{ns}
s := createStatement("statement1", "ps1", "ns1", true)
s.Actions.BgpActions.SetCommunity = createSetCommunity("REMOVE", ".*:100")
@@ -1804,8 +1804,8 @@ func TestPolicyMatchAndRemoveCommunitiesRegexp2(t *testing.T) {
ns := createNeighborSet("ns1", "10.0.0.1")
ds := config.DefinedSets{}
- ds.PrefixSets.PrefixSetList = []config.PrefixSet{ps}
- ds.NeighborSets.NeighborSetList = []config.NeighborSet{ns}
+ ds.PrefixSets = []config.PrefixSet{ps}
+ ds.NeighborSets = []config.NeighborSet{ns}
s := createStatement("statement1", "ps1", "ns1", true)
s.Actions.BgpActions.SetCommunity = createSetCommunity("REMOVE", "^(0|45686):[0-9]+")
@@ -1848,13 +1848,13 @@ func TestPolicyMatchAndClearCommunities(t *testing.T) {
ns := createNeighborSet("ns1", "10.0.0.1")
ds := config.DefinedSets{}
- ds.PrefixSets.PrefixSetList = []config.PrefixSet{ps}
- ds.NeighborSets.NeighborSetList = []config.NeighborSet{ns}
+ ds.PrefixSets = []config.PrefixSet{ps}
+ ds.NeighborSets = []config.NeighborSet{ns}
s := createStatement("statement1", "ps1", "ns1", true)
// action NULL is obsolate
s.Actions.BgpActions.SetCommunity.Options = "REPLACE"
- s.Actions.BgpActions.SetCommunity.SetCommunityMethod.Communities = nil
+ s.Actions.BgpActions.SetCommunity.SetCommunityMethod.CommunitiesList = nil
pd := createPolicyDefinition("pd1", s)
pl := createRoutingPolicy(ds, pd)
@@ -1960,48 +1960,48 @@ func TestExtCommunityConditionEvaluate(t *testing.T) {
// create match condition
ecomSet1 := config.ExtCommunitySet{
ExtCommunitySetName: "ecomSet1",
- ExtCommunity: []string{"RT:65001:200"},
+ ExtCommunityList: []string{"RT:65001:200"},
}
ecomSet2 := config.ExtCommunitySet{
ExtCommunitySetName: "ecomSet2",
- ExtCommunity: []string{"RT:10.0.0.1:300"},
+ ExtCommunityList: []string{"RT:10.0.0.1:300"},
}
ecomSet3 := config.ExtCommunitySet{
ExtCommunitySetName: "ecomSet3",
- ExtCommunity: []string{fmt.Sprintf("RT:%s:200", convUintStr(65030000))},
+ ExtCommunityList: []string{fmt.Sprintf("RT:%s:200", convUintStr(65030000))},
}
ecomSet4 := config.ExtCommunitySet{
ExtCommunitySetName: "ecomSet4",
- ExtCommunity: []string{"RT:65002:200"},
+ ExtCommunityList: []string{"RT:65002:200"},
}
ecomSet5 := config.ExtCommunitySet{
ExtCommunitySetName: "ecomSet5",
- ExtCommunity: []string{"RT:10.0.0.2:300"},
+ ExtCommunityList: []string{"RT:10.0.0.2:300"},
}
ecomSet6 := config.ExtCommunitySet{
ExtCommunitySetName: "ecomSet6",
- ExtCommunity: []string{fmt.Sprintf("RT:%s:200", convUintStr(65030001))},
+ ExtCommunityList: []string{fmt.Sprintf("RT:%s:200", convUintStr(65030001))},
}
ecomSet7 := config.ExtCommunitySet{
ExtCommunitySetName: "ecomSet7",
- ExtCommunity: []string{"SoO:65010:300"},
+ ExtCommunityList: []string{"SoO:65010:300"},
}
ecomSet8 := config.ExtCommunitySet{
ExtCommunitySetName: "ecomSet8",
- ExtCommunity: []string{"SoO:10.0.10.10:[0-9]+"},
+ ExtCommunityList: []string{"SoO:10.0.10.10:[0-9]+"},
}
ecomSet9 := config.ExtCommunitySet{
ExtCommunitySetName: "ecomSet9",
- ExtCommunity: []string{"RT:[0-9]+:[0-9]+"},
+ ExtCommunityList: []string{"RT:[0-9]+:[0-9]+"},
}
ecomSet10 := config.ExtCommunitySet{
ExtCommunitySetName: "ecomSet10",
- ExtCommunity: []string{"RT:.+:\\d00", "SoO:.+:\\d00"},
+ ExtCommunityList: []string{"RT:.+:\\d00", "SoO:.+:\\d00"},
}
ecomSet11 := config.ExtCommunitySet{
ExtCommunitySetName: "ecomSet11",
- ExtCommunity: []string{"RT:65001:2", "SoO:11.0.10.10:[0-9]+"},
+ ExtCommunityList: []string{"RT:65001:2", "SoO:11.0.10.10:[0-9]+"},
}
m := make(map[string]DefinedSet)
@@ -2132,26 +2132,26 @@ func TestExtCommunityConditionEvaluateWithOtherCondition(t *testing.T) {
// create policy
asPathSet := config.AsPathSet{
AsPathSetName: "asset1",
- AsPath: []string{"65005$"},
+ AsPathList: []string{"65005$"},
}
ecomSet1 := config.ExtCommunitySet{
ExtCommunitySetName: "ecomSet1",
- ExtCommunity: []string{"RT:65001:201"},
+ ExtCommunityList: []string{"RT:65001:201"},
}
ecomSet2 := config.ExtCommunitySet{
ExtCommunitySetName: "ecomSet2",
- ExtCommunity: []string{"RT:[0-9]+:[0-9]+"},
+ ExtCommunityList: []string{"RT:[0-9]+:[0-9]+"},
}
ps := createPrefixSet("ps1", "10.10.1.0/16", "21..24")
ns := createNeighborSet("ns1", "10.2.1.1")
ds := config.DefinedSets{}
- ds.PrefixSets.PrefixSetList = []config.PrefixSet{ps}
- ds.NeighborSets.NeighborSetList = []config.NeighborSet{ns}
- ds.BgpDefinedSets.AsPathSets.AsPathSetList = []config.AsPathSet{asPathSet}
- ds.BgpDefinedSets.ExtCommunitySets.ExtCommunitySetList = []config.ExtCommunitySet{ecomSet1, ecomSet2}
+ ds.PrefixSets = []config.PrefixSet{ps}
+ ds.NeighborSets = []config.NeighborSet{ns}
+ ds.BgpDefinedSets.AsPathSets = []config.AsPathSet{asPathSet}
+ ds.BgpDefinedSets.ExtCommunitySets = []config.ExtCommunitySet{ecomSet1, ecomSet2}
s1 := createStatement("statement1", "ps1", "ns1", false)
s1.Conditions.BgpConditions.MatchAsPathSet.AsPathSet = "asset1"
@@ -2199,8 +2199,8 @@ func TestPolicyMatchAndReplaceMed(t *testing.T) {
ns := createNeighborSet("ns1", "10.0.0.1")
ds := config.DefinedSets{}
- ds.PrefixSets.PrefixSetList = []config.PrefixSet{ps}
- ds.NeighborSets.NeighborSetList = []config.NeighborSet{ns}
+ ds.PrefixSets = []config.PrefixSet{ps}
+ ds.NeighborSets = []config.NeighborSet{ns}
m := "200"
s := createStatement("statement1", "ps1", "ns1", true)
@@ -2243,8 +2243,8 @@ func TestPolicyMatchAndAddingMed(t *testing.T) {
ns := createNeighborSet("ns1", "10.0.0.1")
ds := config.DefinedSets{}
- ds.PrefixSets.PrefixSetList = []config.PrefixSet{ps}
- ds.NeighborSets.NeighborSetList = []config.NeighborSet{ns}
+ ds.PrefixSets = []config.PrefixSet{ps}
+ ds.NeighborSets = []config.NeighborSet{ns}
m := "+200"
ma := "300"
@@ -2287,8 +2287,8 @@ func TestPolicyMatchAndAddingMedOverFlow(t *testing.T) {
ns := createNeighborSet("ns1", "10.0.0.1")
ds := config.DefinedSets{}
- ds.PrefixSets.PrefixSetList = []config.PrefixSet{ps}
- ds.NeighborSets.NeighborSetList = []config.NeighborSet{ns}
+ ds.PrefixSets = []config.PrefixSet{ps}
+ ds.NeighborSets = []config.NeighborSet{ns}
m := fmt.Sprintf("+%d", math.MaxUint32)
ma := "1"
@@ -2333,8 +2333,8 @@ func TestPolicyMatchAndSubtractMed(t *testing.T) {
ns := createNeighborSet("ns1", "10.0.0.1")
ds := config.DefinedSets{}
- ds.PrefixSets.PrefixSetList = []config.PrefixSet{ps}
- ds.NeighborSets.NeighborSetList = []config.NeighborSet{ns}
+ ds.PrefixSets = []config.PrefixSet{ps}
+ ds.NeighborSets = []config.NeighborSet{ns}
m := "-50"
ma := "50"
@@ -2379,8 +2379,8 @@ func TestPolicyMatchAndSubtractMedUnderFlow(t *testing.T) {
ns := createNeighborSet("ns1", "10.0.0.1")
ds := config.DefinedSets{}
- ds.PrefixSets.PrefixSetList = []config.PrefixSet{ps}
- ds.NeighborSets.NeighborSetList = []config.NeighborSet{ns}
+ ds.PrefixSets = []config.PrefixSet{ps}
+ ds.NeighborSets = []config.NeighborSet{ns}
m := "-101"
ma := "100"
@@ -2424,8 +2424,8 @@ func TestPolicyMatchWhenPathHaveNotMed(t *testing.T) {
ns := createNeighborSet("ns1", "10.0.0.1")
ds := config.DefinedSets{}
- ds.PrefixSets.PrefixSetList = []config.PrefixSet{ps}
- ds.NeighborSets.NeighborSetList = []config.NeighborSet{ns}
+ ds.PrefixSets = []config.PrefixSet{ps}
+ ds.NeighborSets = []config.NeighborSet{ns}
m := "-50"
s := createStatement("statement1", "ps1", "ns1", true)
@@ -2472,8 +2472,8 @@ func TestPolicyAsPathPrepend(t *testing.T) {
ns := createNeighborSet("ns1", "10.0.0.1")
ds := config.DefinedSets{}
- ds.PrefixSets.PrefixSetList = []config.PrefixSet{ps}
- ds.NeighborSets.NeighborSetList = []config.NeighborSet{ns}
+ ds.PrefixSets = []config.PrefixSet{ps}
+ ds.NeighborSets = []config.NeighborSet{ns}
s := createStatement("statement1", "ps1", "ns1", true)
s.Actions.BgpActions.SetAsPathPrepend.As = "65002"
@@ -2516,8 +2516,8 @@ func TestPolicyAsPathPrependLastAs(t *testing.T) {
ns := createNeighborSet("ns1", "10.0.0.1")
ds := config.DefinedSets{}
- ds.PrefixSets.PrefixSetList = []config.PrefixSet{ps}
- ds.NeighborSets.NeighborSetList = []config.NeighborSet{ns}
+ ds.PrefixSets = []config.PrefixSet{ps}
+ ds.NeighborSets = []config.NeighborSet{ns}
s := createStatement("statement1", "ps1", "ns1", true)
s.Actions.BgpActions.SetAsPathPrepend.As = "last-as"
@@ -2566,8 +2566,8 @@ func TestPolicyAs4PathPrepend(t *testing.T) {
ns := createNeighborSet("ns1", "10.0.0.1")
ds := config.DefinedSets{}
- ds.PrefixSets.PrefixSetList = []config.PrefixSet{ps}
- ds.NeighborSets.NeighborSetList = []config.NeighborSet{ns}
+ ds.PrefixSets = []config.PrefixSet{ps}
+ ds.NeighborSets = []config.NeighborSet{ns}
s := createStatement("statement1", "ps1", "ns1", true)
s.Actions.BgpActions.SetAsPathPrepend.As = fmt.Sprintf("%d", createAs4Value("65002.1"))
@@ -2578,7 +2578,7 @@ func TestPolicyAs4PathPrepend(t *testing.T) {
//test
r := NewRoutingPolicy()
r.Reload(pl)
- p, _ := NewPolicy(pl.PolicyDefinitions.PolicyDefinitionList[0], r.DefinedSetMap)
+ p, _ := NewPolicy(pl.PolicyDefinitions[0], r.DefinedSetMap)
pType, newPath := p.Apply(path)
assert.Equal(ROUTE_TYPE_ACCEPT, pType)
@@ -2621,8 +2621,8 @@ func TestPolicyAs4PathPrependLastAs(t *testing.T) {
ns := createNeighborSet("ns1", "10.0.0.1")
ds := config.DefinedSets{}
- ds.PrefixSets.PrefixSetList = []config.PrefixSet{ps}
- ds.NeighborSets.NeighborSetList = []config.NeighborSet{ns}
+ ds.PrefixSets = []config.PrefixSet{ps}
+ ds.NeighborSets = []config.NeighborSet{ns}
s := createStatement("statement1", "ps1", "ns1", true)
s.Actions.BgpActions.SetAsPathPrepend.As = "last-as"
@@ -2633,7 +2633,7 @@ func TestPolicyAs4PathPrependLastAs(t *testing.T) {
//test
r := NewRoutingPolicy()
r.Reload(pl)
- p, _ := NewPolicy(pl.PolicyDefinitions.PolicyDefinitionList[0], r.DefinedSetMap)
+ p, _ := NewPolicy(pl.PolicyDefinitions[0], r.DefinedSetMap)
pType, newPath := p.Apply(path)
assert.Equal(ROUTE_TYPE_ACCEPT, pType)
@@ -2674,7 +2674,7 @@ func createSetCommunity(operation string, community ...string) config.SetCommuni
s := config.SetCommunity{
SetCommunityMethod: config.SetCommunityMethod{
- Communities: community,
+ CommunitiesList: community,
},
Options: operation,
}
@@ -2690,20 +2690,16 @@ func stringToCommunityValue(comStr string) uint32 {
func createPolicyDefinition(defName string, stmt ...config.Statement) config.PolicyDefinition {
pd := config.PolicyDefinition{
- Name: defName,
- Statements: config.Statements{
- StatementList: stmt,
- },
+ Name: defName,
+ Statements: []config.Statement(stmt),
}
return pd
}
func createRoutingPolicy(ds config.DefinedSets, pd ...config.PolicyDefinition) config.RoutingPolicy {
pl := config.RoutingPolicy{
- DefinedSets: ds,
- PolicyDefinitions: config.PolicyDefinitions{
- PolicyDefinitionList: pd,
- },
+ DefinedSets: ds,
+ PolicyDefinitions: []config.PolicyDefinition(pd),
}
return pl
}
@@ -2722,8 +2718,8 @@ func createPrefixSet(name string, prefix string, maskLength string) config.Prefi
func createNeighborSet(name string, addr string) config.NeighborSet {
ns := config.NeighborSet{
- NeighborSetName: name,
- NeighborInfo: []string{addr},
+ NeighborSetName: name,
+ NeighborInfoList: []string{addr},
}
return ns
}