diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-10-09 19:39:03 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-10-09 19:39:03 +0900 |
commit | dd6140c6a28eb6e2dc41b47611240647e2b938fd (patch) | |
tree | ec40225abe267982913580c3c654f45422a32766 | |
parent | eb67afbdad499466e9407b4b30e9854664dd0486 (diff) |
table: merge policy package into table
-rw-r--r-- | gobgp/cmd/neighbor.go | 4 | ||||
-rw-r--r-- | gobgp/cmd/policy.go | 18 | ||||
-rw-r--r-- | server/peer.go | 55 | ||||
-rw-r--r-- | server/server.go | 123 | ||||
-rw-r--r-- | table/policy.go (renamed from policy/policy.go) | 80 | ||||
-rw-r--r-- | table/policy_test.go (renamed from policy/policy_test.go) | 193 |
6 files changed, 239 insertions, 234 deletions
diff --git a/gobgp/cmd/neighbor.go b/gobgp/cmd/neighbor.go index ba3ca03b..4c1663e8 100644 --- a/gobgp/cmd/neighbor.go +++ b/gobgp/cmd/neighbor.go @@ -22,7 +22,7 @@ import ( api "github.com/osrg/gobgp/api" "github.com/osrg/gobgp/config" "github.com/osrg/gobgp/packet" - "github.com/osrg/gobgp/policy" + "github.com/osrg/gobgp/table" "github.com/spf13/cobra" "golang.org/x/net/context" "io" @@ -668,7 +668,7 @@ func modNeighborPolicy(remoteIP net.IP, cmdType string, eArg []string) error { switch cmdType { case CMD_ADD: if len(eArg) < 4 { - return fmt.Errorf("Usage: gobgp neighbor <ipaddr> policy %s {%s|%s|%s} <policies> {%s|%s}", cmdType, CMD_IMPORT, CMD_EXPORT, CMD_IN, policy.ROUTE_TYPE_ACCEPT, policy.ROUTE_TYPE_REJECT) + return fmt.Errorf("Usage: gobgp neighbor <ipaddr> policy %s {%s|%s|%s} <policies> {%s|%s}", cmdType, CMD_IMPORT, CMD_EXPORT, CMD_IN, table.ROUTE_TYPE_ACCEPT, table.ROUTE_TYPE_REJECT) } policies := parsePolicy(eArg[1]) defaultPolicy, err := parseRouteAction(eArg[2]) diff --git a/gobgp/cmd/policy.go b/gobgp/cmd/policy.go index 6bb710dc..6445b9d6 100644 --- a/gobgp/cmd/policy.go +++ b/gobgp/cmd/policy.go @@ -20,7 +20,7 @@ import ( "encoding/json" "fmt" api "github.com/osrg/gobgp/api" - "github.com/osrg/gobgp/policy" + "github.com/osrg/gobgp/table" "github.com/spf13/cobra" "golang.org/x/net/context" "io" @@ -731,10 +731,10 @@ func checkCommunityFormat(comStr string) bool { regUint, _ := regexp.Compile("^([0-9]+)$") regString, _ := regexp.Compile("([0-9]+):([0-9]+)") regWellKnown, _ := regexp.Compile("^(" + - policy.COMMUNITY_INTERNET + "|" + - policy.COMMUNITY_NO_EXPORT + "|" + - policy.COMMUNITY_NO_ADVERTISE + "|" + - policy.COMMUNITY_NO_EXPORT_SUBCONFED + ")$") + table.COMMUNITY_INTERNET + "|" + + table.COMMUNITY_NO_EXPORT + "|" + + table.COMMUNITY_NO_ADVERTISE + "|" + + table.COMMUNITY_NO_EXPORT_SUBCONFED + ")$") if regUint.MatchString(comStr) || regString.MatchString(comStr) || regWellKnown.MatchString(comStr) { return true } @@ -1254,10 +1254,10 @@ func parseCommunityAction(communityStr string) (*api.CommunityAction, error) { communities = group[2] // check options - communityActionTypes := policy.COMMUNITY_ACTION_ADD + "|" + - policy.COMMUNITY_ACTION_REPLACE + "|" + - policy.COMMUNITY_ACTION_REMOVE + "|" + - policy.COMMUNITY_ACTION_NULL + communityActionTypes := table.COMMUNITY_ACTION_ADD + "|" + + table.COMMUNITY_ACTION_REPLACE + "|" + + table.COMMUNITY_ACTION_REMOVE + "|" + + table.COMMUNITY_ACTION_NULL regOption, _ := regexp.Compile(fmt.Sprintf("^(%s)$", communityActionTypes)) if !regOption.MatchString(option) { e := fmt.Sprintf("invalid Option: %s\n", option) diff --git a/server/peer.go b/server/peer.go index 90c73469..4a602675 100644 --- a/server/peer.go +++ b/server/peer.go @@ -21,7 +21,6 @@ import ( api "github.com/osrg/gobgp/api" "github.com/osrg/gobgp/config" "github.com/osrg/gobgp/packet" - "github.com/osrg/gobgp/policy" "github.com/osrg/gobgp/table" "net" "time" @@ -41,13 +40,13 @@ type Peer struct { adjRib *table.AdjRib peerInfo *table.PeerInfo outgoing chan *bgp.BGPMessage - inPolicies []*policy.Policy + inPolicies []*table.Policy defaultInPolicy config.DefaultPolicyType accepted uint32 staleAccepted bool - importPolicies []*policy.Policy + importPolicies []*table.Policy defaultImportPolicy config.DefaultPolicyType - exportPolicies []*policy.Policy + exportPolicies []*table.Policy defaultExportPolicy config.DefaultPolicyType isConfederationMember bool recvOpen *bgp.BGPMessage @@ -358,10 +357,9 @@ func (peer *Peer) ToApiStruct() *api.Peer { } } -func (peer *Peer) setPolicy(policyMap map[string]*policy.Policy) { - // configure in-policy +func (peer *Peer) setPolicy(policyMap map[string]*table.Policy) { policyConf := peer.conf.ApplyPolicy - inPolicies := make([]*policy.Policy, 0) + inPolicies := make([]*table.Policy, 0) for _, policyName := range policyConf.ApplyPolicyConfig.InPolicy { log.WithFields(log.Fields{ "Topic": "Peer", @@ -376,13 +374,13 @@ func (peer *Peer) setPolicy(policyMap map[string]*policy.Policy) { peer.inPolicies = inPolicies peer.defaultInPolicy = policyConf.ApplyPolicyConfig.DefaultInPolicy - importPolicies := make([]*policy.Policy, 0) + importPolicies := make([]*table.Policy, 0) for _, policyName := range policyConf.ApplyPolicyConfig.ImportPolicy { log.WithFields(log.Fields{ "Topic": "Peer", "Key": peer.conf.NeighborConfig.NeighborAddress, "PolicyName": policyName, - }).Info("import policy installed") + }).Info("import-policy installed") if pol, ok := policyMap[policyName]; ok { log.Debug("import policy : ", pol) importPolicies = append(importPolicies, pol) @@ -391,14 +389,13 @@ func (peer *Peer) setPolicy(policyMap map[string]*policy.Policy) { peer.importPolicies = importPolicies peer.defaultImportPolicy = policyConf.ApplyPolicyConfig.DefaultImportPolicy - // configure export policy - exportPolicies := make([]*policy.Policy, 0) + exportPolicies := make([]*table.Policy, 0) for _, policyName := range policyConf.ApplyPolicyConfig.ExportPolicy { log.WithFields(log.Fields{ "Topic": "Peer", "Key": peer.conf.NeighborConfig.NeighborAddress, "PolicyName": policyName, - }).Info("export policy installed") + }).Info("export-policy installed") if pol, ok := policyMap[policyName]; ok { log.Debug("export policy : ", pol) exportPolicies = append(exportPolicies, pol) @@ -408,60 +405,60 @@ func (peer *Peer) setPolicy(policyMap map[string]*policy.Policy) { peer.defaultExportPolicy = policyConf.ApplyPolicyConfig.DefaultExportPolicy } -func (peer *Peer) GetPolicy(d PolicyDirection) []*policy.Policy { +func (peer *Peer) GetPolicy(d table.PolicyDirection) []*table.Policy { switch d { - case POLICY_DIRECTION_IN: + case table.POLICY_DIRECTION_IN: return peer.inPolicies - case POLICY_DIRECTION_IMPORT: + case table.POLICY_DIRECTION_IMPORT: return peer.importPolicies - case POLICY_DIRECTION_EXPORT: + case table.POLICY_DIRECTION_EXPORT: return peer.exportPolicies } return nil } -func (peer *Peer) GetDefaultPolicy(d PolicyDirection) policy.RouteType { +func (peer *Peer) GetDefaultPolicy(d table.PolicyDirection) table.RouteType { var def config.DefaultPolicyType switch d { - case POLICY_DIRECTION_IN: + case table.POLICY_DIRECTION_IN: def = peer.defaultInPolicy - case POLICY_DIRECTION_IMPORT: + case table.POLICY_DIRECTION_IMPORT: def = peer.defaultImportPolicy - case POLICY_DIRECTION_EXPORT: + case table.POLICY_DIRECTION_EXPORT: def = peer.defaultExportPolicy } if def == config.DEFAULT_POLICY_TYPE_ACCEPT_ROUTE { - return policy.ROUTE_TYPE_ACCEPT + return table.ROUTE_TYPE_ACCEPT } - return policy.ROUTE_TYPE_REJECT + return table.ROUTE_TYPE_REJECT } -func (peer *Peer) ApplyPolicy(d PolicyDirection, paths []*table.Path) ([]*table.Path, []*table.Path) { - if d == POLICY_DIRECTION_IN { +func (peer *Peer) ApplyPolicy(d table.PolicyDirection, paths []*table.Path) ([]*table.Path, []*table.Path) { + if d == table.POLICY_DIRECTION_IN { peer.staleAccepted = true } newpaths := make([]*table.Path, 0, len(paths)) filteredPaths := make([]*table.Path, 0) for _, path := range paths { - result := policy.ROUTE_TYPE_NONE + result := table.ROUTE_TYPE_NONE newpath := path for _, p := range peer.GetPolicy(d) { result, newpath = p.Apply(path) - if result != policy.ROUTE_TYPE_NONE { + if result != table.ROUTE_TYPE_NONE { break } } - if result == policy.ROUTE_TYPE_NONE { + if result == table.ROUTE_TYPE_NONE { result = peer.GetDefaultPolicy(d) } switch result { - case policy.ROUTE_TYPE_ACCEPT: + case table.ROUTE_TYPE_ACCEPT: path.Filtered = false newpaths = append(newpaths, newpath) - case policy.ROUTE_TYPE_REJECT: + case table.ROUTE_TYPE_REJECT: path.Filtered = true filteredPaths = append(filteredPaths, path) log.WithFields(log.Fields{ diff --git a/server/server.go b/server/server.go index d65fbace..de0dabc3 100644 --- a/server/server.go +++ b/server/server.go @@ -23,7 +23,6 @@ import ( api "github.com/osrg/gobgp/api" "github.com/osrg/gobgp/config" "github.com/osrg/gobgp/packet" - "github.com/osrg/gobgp/policy" "github.com/osrg/gobgp/table" "github.com/osrg/gobgp/zebra" "net" @@ -37,14 +36,6 @@ const ( GLOBAL_RIB_NAME = "global" ) -type PolicyDirection int - -const ( - POLICY_DIRECTION_IMPORT PolicyDirection = iota - POLICY_DIRECTION_EXPORT - POLICY_DIRECTION_IN -) - type SenderMsg struct { messages []*bgp.BGPMessage sendCh chan *bgp.BGPMessage @@ -96,7 +87,7 @@ type BgpServer struct { GrpcReqCh chan *GrpcRequest listenPort int policyUpdateCh chan config.RoutingPolicy - policyMap map[string]*policy.Policy + policyMap map[string]*table.Policy routingPolicy config.RoutingPolicy broadcastReqs []*GrpcRequest broadcastMsgs []broadcastMsg @@ -383,7 +374,7 @@ func (server *BgpServer) Serve() { pathList = append(pathList, p.adjRib.GetInPathList(rf)...) } } - pathList, _ = peer.ApplyPolicy(POLICY_DIRECTION_IMPORT, pathList) + pathList, _ = peer.ApplyPolicy(table.POLICY_DIRECTION_IMPORT, pathList) if len(pathList) > 0 { rib.ProcessPaths(pathList) } @@ -670,19 +661,19 @@ func (server *BgpServer) broadcastPeerState(peer *Peer) { func (server *BgpServer) propagateUpdate(peer *Peer, pathList []*table.Path) []*SenderMsg { msgs := make([]*SenderMsg, 0) if peer != nil && peer.isRouteServerClient() { - pathList, _ = peer.ApplyPolicy(POLICY_DIRECTION_IN, pathList) + pathList, _ = peer.ApplyPolicy(table.POLICY_DIRECTION_IN, pathList) for _, rib := range server.localRibMap { targetPeer := server.neighborMap[rib.OwnerName()] neighborAddress := peer.conf.NeighborConfig.NeighborAddress.String() if rib.OwnerName() == GLOBAL_RIB_NAME || rib.OwnerName() == neighborAddress { continue } - sendPathList, _ := targetPeer.ApplyPolicy(POLICY_DIRECTION_IMPORT, pathList) + sendPathList, _ := targetPeer.ApplyPolicy(table.POLICY_DIRECTION_IMPORT, pathList) sendPathList, _ = rib.ProcessPaths(sendPathList) if targetPeer.fsm.state != bgp.BGP_FSM_ESTABLISHED || len(sendPathList) == 0 { continue } - sendPathList, _ = targetPeer.ApplyPolicy(POLICY_DIRECTION_EXPORT, filterpath(targetPeer, sendPathList)) + sendPathList, _ = targetPeer.ApplyPolicy(table.POLICY_DIRECTION_EXPORT, filterpath(targetPeer, sendPathList)) if len(sendPathList) == 0 { continue } @@ -881,10 +872,10 @@ func (server *BgpServer) UpdatePolicy(policy config.RoutingPolicy) { } func (server *BgpServer) SetPolicy(pl config.RoutingPolicy) { - pMap := make(map[string]*policy.Policy) + pMap := make(map[string]*table.Policy) df := pl.DefinedSets for _, p := range pl.PolicyDefinitions.PolicyDefinitionList { - pMap[p.Name] = policy.NewPolicy(p, df) + pMap[p.Name] = table.NewPolicy(p, df) } server.policyMap = pMap server.routingPolicy = pl @@ -1217,7 +1208,7 @@ func (server *BgpServer) handleVrfRequest(req *GrpcRequest) []*table.Path { break } for _, path := range rib.GetPathList(rf) { - ok := policy.CanImportToVrf(vrfs[name], path) + ok := table.CanImportToVrf(vrfs[name], path) if !ok { continue } @@ -1266,7 +1257,7 @@ func (server *BgpServer) getBestFromLocal(peer *Peer) ([]*table.Path, []*table.P filtered := make([]*table.Path, 0) if peer.isRouteServerClient() { rib := server.localRibMap[peer.conf.NeighborConfig.NeighborAddress.String()] - pathList, filtered = peer.ApplyPolicy(POLICY_DIRECTION_EXPORT, filterpath(peer, peer.getBests(rib))) + pathList, filtered = peer.ApplyPolicy(table.POLICY_DIRECTION_EXPORT, filterpath(peer, peer.getBests(rib))) } else { rib := server.localRibMap[GLOBAL_RIB_NAME] l, _ := peer.fsm.LocalHostPort() @@ -1580,7 +1571,7 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg { for _, pd := range pdList { if policyName == pd.Name { match = true - extracted = append(extracted, policy.PolicyDefinitionToApiStruct(pd, df)) + extracted = append(extracted, table.PolicyDefinitionToApiStruct(pd, df)) break } } @@ -1604,18 +1595,10 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg { inPolicyNames := peer.conf.ApplyPolicy.ApplyPolicyConfig.InPolicy resInPolicies := extract(inPolicyNames) - defaultImportPolicy := api.RouteAction_REJECT - defaultExportPolicy := api.RouteAction_REJECT - defaultInPolicy := api.RouteAction_REJECT - if peer.defaultImportPolicy == config.DEFAULT_POLICY_TYPE_ACCEPT_ROUTE { - defaultImportPolicy = api.RouteAction_ACCEPT - } - if peer.defaultExportPolicy == config.DEFAULT_POLICY_TYPE_ACCEPT_ROUTE { - defaultExportPolicy = api.RouteAction_ACCEPT - } - if peer.defaultInPolicy == config.DEFAULT_POLICY_TYPE_ACCEPT_ROUTE { - defaultInPolicy = api.RouteAction_ACCEPT - } + defaultImportPolicy := peer.GetDefaultPolicy(table.POLICY_DIRECTION_IMPORT).ToApiStruct() + defaultExportPolicy := peer.GetDefaultPolicy(table.POLICY_DIRECTION_EXPORT).ToApiStruct() + defaultInPolicy := peer.GetDefaultPolicy(table.POLICY_DIRECTION_IN).ToApiStruct() + result := &GrpcResponse{ Data: &api.ApplyPolicy{ DefaultImportPolicy: defaultImportPolicy, @@ -1645,19 +1628,19 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg { defInPolicy = config.DEFAULT_POLICY_TYPE_REJECT_ROUTE } applyPolicy.DefaultImportPolicy = defInPolicy - applyPolicy.ImportPolicy = policy.PoliciesToString(reqApplyPolicy.ImportPolicies) + applyPolicy.ImportPolicy = table.PoliciesToString(reqApplyPolicy.ImportPolicies) } else if grpcReq.RequestType == REQ_NEIGHBOR_POLICY_ADD_EXPORT { if reqApplyPolicy.DefaultExportPolicy != api.RouteAction_ACCEPT { defOutPolicy = config.DEFAULT_POLICY_TYPE_REJECT_ROUTE } applyPolicy.DefaultExportPolicy = defOutPolicy - applyPolicy.ExportPolicy = policy.PoliciesToString(reqApplyPolicy.ExportPolicies) + applyPolicy.ExportPolicy = table.PoliciesToString(reqApplyPolicy.ExportPolicies) } else if grpcReq.RequestType == REQ_NEIGHBOR_POLICY_ADD_IN { if reqApplyPolicy.DefaultInPolicy != api.RouteAction_ACCEPT { defDistPolicy = config.DEFAULT_POLICY_TYPE_REJECT_ROUTE } applyPolicy.DefaultInPolicy = defDistPolicy - applyPolicy.InPolicy = policy.PoliciesToString(reqApplyPolicy.InPolicies) + applyPolicy.InPolicy = table.PoliciesToString(reqApplyPolicy.InPolicies) } else if grpcReq.RequestType == REQ_NEIGHBOR_POLICY_DEL_IMPORT { applyPolicy.DefaultImportPolicy = config.DEFAULT_POLICY_TYPE_ACCEPT_ROUTE applyPolicy.ImportPolicy = make([]string, 0) @@ -1718,7 +1701,7 @@ func (server *BgpServer) handleGrpcShowPolicies(grpcReq *GrpcRequest) { info := server.routingPolicy.DefinedSets.PrefixSets.PrefixSetList if len(info) > 0 { for _, ps := range info { - resPrefixSet := policy.PrefixSetToApiStruct(ps) + resPrefixSet := table.PrefixSetToApiStruct(ps) pd := &api.PolicyDefinition{} pd.StatementList = []*api.Statement{{Conditions: &api.Conditions{MatchPrefixSet: resPrefixSet}}} result = &GrpcResponse{ @@ -1734,7 +1717,7 @@ func (server *BgpServer) handleGrpcShowPolicies(grpcReq *GrpcRequest) { info := server.routingPolicy.DefinedSets.NeighborSets.NeighborSetList if len(info) > 0 { for _, ns := range info { - resNeighborSet := policy.NeighborSetToApiStruct(ns) + resNeighborSet := table.NeighborSetToApiStruct(ns) pd := &api.PolicyDefinition{} pd.StatementList = []*api.Statement{{Conditions: &api.Conditions{MatchNeighborSet: resNeighborSet}}} result = &GrpcResponse{ @@ -1750,7 +1733,7 @@ func (server *BgpServer) handleGrpcShowPolicies(grpcReq *GrpcRequest) { info := server.routingPolicy.DefinedSets.BgpDefinedSets.AsPathSets.AsPathSetList if len(info) > 0 { for _, as := range info { - resAsPathSet := policy.AsPathSetToApiStruct(as) + resAsPathSet := table.AsPathSetToApiStruct(as) pd := &api.PolicyDefinition{} pd.StatementList = []*api.Statement{{Conditions: &api.Conditions{MatchAsPathSet: resAsPathSet}}} result = &GrpcResponse{ @@ -1766,7 +1749,7 @@ func (server *BgpServer) handleGrpcShowPolicies(grpcReq *GrpcRequest) { info := server.routingPolicy.DefinedSets.BgpDefinedSets.CommunitySets.CommunitySetList if len(info) > 0 { for _, cs := range info { - resCommunitySet := policy.CommunitySetToApiStruct(cs) + resCommunitySet := table.CommunitySetToApiStruct(cs) pd := &api.PolicyDefinition{} pd.StatementList = []*api.Statement{{Conditions: &api.Conditions{MatchCommunitySet: resCommunitySet}}} result = &GrpcResponse{ @@ -1782,7 +1765,7 @@ func (server *BgpServer) handleGrpcShowPolicies(grpcReq *GrpcRequest) { info := server.routingPolicy.DefinedSets.BgpDefinedSets.ExtCommunitySets.ExtCommunitySetList if len(info) > 0 { for _, es := range info { - resExtcommunitySet := policy.ExtCommunitySetToApiStruct(es) + resExtcommunitySet := table.ExtCommunitySetToApiStruct(es) pd := &api.PolicyDefinition{} pd.StatementList = []*api.Statement{{Conditions: &api.Conditions{MatchExtCommunitySet: resExtcommunitySet}}} result = &GrpcResponse{ @@ -1800,7 +1783,7 @@ func (server *BgpServer) handleGrpcShowPolicies(grpcReq *GrpcRequest) { result := &GrpcResponse{} if len(info) > 0 { for _, pd := range info { - resPolicyDefinition := policy.PolicyDefinitionToApiStruct(pd, df) + resPolicyDefinition := table.PolicyDefinitionToApiStruct(pd, df) result = &GrpcResponse{ Data: resPolicyDefinition, } @@ -1822,7 +1805,7 @@ func (server *BgpServer) handleGrpcShowPolicy(grpcReq *GrpcRequest) { resPrefixSet := &api.PrefixSet{} for _, ps := range info { if ps.PrefixSetName == name { - resPrefixSet = policy.PrefixSetToApiStruct(ps) + resPrefixSet = table.PrefixSetToApiStruct(ps) break } } @@ -1840,7 +1823,7 @@ func (server *BgpServer) handleGrpcShowPolicy(grpcReq *GrpcRequest) { resNeighborSet := &api.NeighborSet{} for _, ns := range info { if ns.NeighborSetName == name { - resNeighborSet = policy.NeighborSetToApiStruct(ns) + resNeighborSet = table.NeighborSetToApiStruct(ns) break } } @@ -1858,7 +1841,7 @@ func (server *BgpServer) handleGrpcShowPolicy(grpcReq *GrpcRequest) { resAsPathSet := &api.AsPathSet{} for _, as := range info { if as.AsPathSetName == name { - resAsPathSet = policy.AsPathSetToApiStruct(as) + resAsPathSet = table.AsPathSetToApiStruct(as) break } } @@ -1876,7 +1859,7 @@ func (server *BgpServer) handleGrpcShowPolicy(grpcReq *GrpcRequest) { resCommunitySet := &api.CommunitySet{} for _, cs := range info { if cs.CommunitySetName == name { - resCommunitySet = policy.CommunitySetToApiStruct(cs) + resCommunitySet = table.CommunitySetToApiStruct(cs) break } } @@ -1894,7 +1877,7 @@ func (server *BgpServer) handleGrpcShowPolicy(grpcReq *GrpcRequest) { resExtCommunitySet := &api.ExtCommunitySet{} for _, es := range info { if es.ExtCommunitySetName == name { - resExtCommunitySet = policy.ExtCommunitySetToApiStruct(es) + resExtCommunitySet = table.ExtCommunitySetToApiStruct(es) break } } @@ -1913,7 +1896,7 @@ func (server *BgpServer) handleGrpcShowPolicy(grpcReq *GrpcRequest) { resPolicyDefinition := &api.PolicyDefinition{} for _, pd := range info { if pd.Name == name { - resPolicyDefinition = policy.PolicyDefinitionToApiStruct(pd, df) + resPolicyDefinition = table.PolicyDefinitionToApiStruct(pd, df) break } } @@ -1935,7 +1918,7 @@ func (server *BgpServer) handleGrpcAddPolicy(grpcReq *GrpcRequest) { case REQ_POLICY_PREFIX_ADD: reqPrefixSet := grpcReq.Data.(*api.PolicyDefinition).StatementList[0].Conditions.MatchPrefixSet conPrefixSetList := server.routingPolicy.DefinedSets.PrefixSets.PrefixSetList - isReqPrefixSet, prefixSet := policy.PrefixSetToConfigStruct(reqPrefixSet) + isReqPrefixSet, prefixSet := table.PrefixSetToConfigStruct(reqPrefixSet) if !isReqPrefixSet { result.ResponseErr = fmt.Errorf("doesn't reqest of policy prefix.") grpcReq.ResponseCh <- result @@ -1943,7 +1926,7 @@ func (server *BgpServer) handleGrpcAddPolicy(grpcReq *GrpcRequest) { } // If the same PrefixSet is not set, add PrefixSet of request to the end. // If only name of the PrefixSet is same, overwrite with PrefixSet of request - idxPrefixSet, idxPrefix := policy.IndexOfPrefixSet(conPrefixSetList, prefixSet) + idxPrefixSet, idxPrefix := table.IndexOfPrefixSet(conPrefixSetList, prefixSet) if idxPrefixSet == -1 { conPrefixSetList = append(conPrefixSetList, prefixSet) } else { @@ -1956,7 +1939,7 @@ func (server *BgpServer) handleGrpcAddPolicy(grpcReq *GrpcRequest) { case REQ_POLICY_NEIGHBOR_ADD: reqNeighborSet := grpcReq.Data.(*api.PolicyDefinition).StatementList[0].Conditions.MatchNeighborSet conNeighborSetList := server.routingPolicy.DefinedSets.NeighborSets.NeighborSetList - isReqNeighborSet, neighborSet := policy.NeighborSetToConfigStruct(reqNeighborSet) + isReqNeighborSet, neighborSet := table.NeighborSetToConfigStruct(reqNeighborSet) if !isReqNeighborSet { result.ResponseErr = fmt.Errorf("doesn't reqest of policy neighbor.") grpcReq.ResponseCh <- result @@ -1964,7 +1947,7 @@ func (server *BgpServer) handleGrpcAddPolicy(grpcReq *GrpcRequest) { } // If the same NeighborSet is not set, add NeighborSet of request to the end. // If only name of the NeighborSet is same, overwrite with NeighborSet of request - idxNeighborSet, idxNeighbor := policy.IndexOfNeighborSet(conNeighborSetList, neighborSet) + idxNeighborSet, idxNeighbor := table.IndexOfNeighborSet(conNeighborSetList, neighborSet) if idxNeighborSet == -1 { conNeighborSetList = append(conNeighborSetList, neighborSet) } else { @@ -1977,7 +1960,7 @@ func (server *BgpServer) handleGrpcAddPolicy(grpcReq *GrpcRequest) { case REQ_POLICY_ASPATH_ADD: reqAsPathSet := grpcReq.Data.(*api.PolicyDefinition).StatementList[0].Conditions.MatchAsPathSet conAsPathSetList := server.routingPolicy.DefinedSets.BgpDefinedSets.AsPathSets.AsPathSetList - isReqAsPathSet, asPathSet := policy.AsPathSetToConfigStruct(reqAsPathSet) + isReqAsPathSet, asPathSet := table.AsPathSetToConfigStruct(reqAsPathSet) if !isReqAsPathSet { result.ResponseErr = fmt.Errorf("doesn't reqest of policy aspath.") grpcReq.ResponseCh <- result @@ -1985,7 +1968,7 @@ func (server *BgpServer) handleGrpcAddPolicy(grpcReq *GrpcRequest) { } // If the same AsPathSet is not set, add AsPathSet of request to the end. // If only name of the AsPathSet is same, overwrite with AsPathSet of request - idxAsPathSet, idxAsPath := policy.IndexOfAsPathSet(conAsPathSetList, asPathSet) + idxAsPathSet, idxAsPath := table.IndexOfAsPathSet(conAsPathSetList, asPathSet) if idxAsPathSet == -1 { conAsPathSetList = append(conAsPathSetList, asPathSet) } else { @@ -1998,7 +1981,7 @@ func (server *BgpServer) handleGrpcAddPolicy(grpcReq *GrpcRequest) { case REQ_POLICY_COMMUNITY_ADD: reqCommunitySet := grpcReq.Data.(*api.PolicyDefinition).StatementList[0].Conditions.MatchCommunitySet conCommunitySetList := server.routingPolicy.DefinedSets.BgpDefinedSets.CommunitySets.CommunitySetList - isReqCommunitySet, communitySet := policy.CommunitySetToConfigStruct(reqCommunitySet) + isReqCommunitySet, communitySet := table.CommunitySetToConfigStruct(reqCommunitySet) if !isReqCommunitySet { result.ResponseErr = fmt.Errorf("doesn't reqest of policy community.") grpcReq.ResponseCh <- result @@ -2006,7 +1989,7 @@ func (server *BgpServer) handleGrpcAddPolicy(grpcReq *GrpcRequest) { } // If the same CommunitySet is not set, add CommunitySet of request to the end. // If only name of the CommunitySet is same, overwrite with CommunitySet of request - idxCommunitySet, idxCommunity := policy.IndexOfCommunitySet(conCommunitySetList, communitySet) + idxCommunitySet, idxCommunity := table.IndexOfCommunitySet(conCommunitySetList, communitySet) if idxCommunitySet == -1 { conCommunitySetList = append(conCommunitySetList, communitySet) } else { @@ -2019,7 +2002,7 @@ func (server *BgpServer) handleGrpcAddPolicy(grpcReq *GrpcRequest) { case REQ_POLICY_EXTCOMMUNITY_ADD: reqExtCommunitySet := grpcReq.Data.(*api.PolicyDefinition).StatementList[0].Conditions.MatchExtCommunitySet conExtCommunitySetList := server.routingPolicy.DefinedSets.BgpDefinedSets.ExtCommunitySets.ExtCommunitySetList - isReqExtCommunitySet, extCommunitySet := policy.ExtCommunitySetToConfigStruct(reqExtCommunitySet) + isReqExtCommunitySet, extCommunitySet := table.ExtCommunitySetToConfigStruct(reqExtCommunitySet) if !isReqExtCommunitySet { result.ResponseErr = fmt.Errorf("doesn't reqest of policy extended community.") grpcReq.ResponseCh <- result @@ -2027,7 +2010,7 @@ func (server *BgpServer) handleGrpcAddPolicy(grpcReq *GrpcRequest) { } // If the same ExtCommunitySet is not set, add ExtCommunitySet of request to the end. // If only name of the ExtCommunitySet is same, overwrite with ExtCommunitySet of request - idxExtCommunitySet, idxExtCommunity := policy.IndexOfExtCommunitySet(conExtCommunitySetList, extCommunitySet) + idxExtCommunitySet, idxExtCommunity := table.IndexOfExtCommunitySet(conExtCommunitySetList, extCommunitySet) if idxExtCommunitySet == -1 { conExtCommunitySetList = append(conExtCommunitySetList, extCommunitySet) } else { @@ -2042,8 +2025,8 @@ func (server *BgpServer) handleGrpcAddPolicy(grpcReq *GrpcRequest) { reqConditions := reqPolicy.StatementList[0].Conditions reqActions := reqPolicy.StatementList[0].Actions conPolicyList := server.routingPolicy.PolicyDefinitions.PolicyDefinitionList - _, policyDef := policy.PolicyDefinitionToConfigStruct(reqPolicy) - idxPolicy, idxStatement := policy.IndexOfPolicyDefinition(conPolicyList, policyDef) + _, policyDef := table.PolicyDefinitionToConfigStruct(reqPolicy) + idxPolicy, idxStatement := table.IndexOfPolicyDefinition(conPolicyList, policyDef) if idxPolicy == -1 { conPolicyList = append(conPolicyList, policyDef) } else { @@ -2100,11 +2083,11 @@ func (server *BgpServer) handleGrpcDelPolicy(grpcReq *GrpcRequest) { case REQ_POLICY_PREFIX_DELETE: reqPrefixSet := grpcReq.Data.(*api.PolicyDefinition).StatementList[0].Conditions.MatchPrefixSet conPrefixSetList := server.routingPolicy.DefinedSets.PrefixSets.PrefixSetList - isReqPrefixSet, prefixSet := policy.PrefixSetToConfigStruct(reqPrefixSet) + isReqPrefixSet, prefixSet := table.PrefixSetToConfigStruct(reqPrefixSet) if isReqPrefixSet { // If only name of the PrefixSet is same, delete all of the elements of the PrefixSet. // If the same element PrefixSet, delete the it's element from PrefixSet. - idxPrefixSet, idxPrefix := policy.IndexOfPrefixSet(conPrefixSetList, prefixSet) + idxPrefixSet, idxPrefix := table.IndexOfPrefixSet(conPrefixSetList, prefixSet) prefix := prefixSet.PrefixList[0] if idxPrefixSet == -1 { result.ResponseErr = fmt.Errorf("Policy prefix that has %v %v %v doesn't exist.", prefixSet.PrefixSetName, @@ -2136,11 +2119,11 @@ func (server *BgpServer) handleGrpcDelPolicy(grpcReq *GrpcRequest) { case REQ_POLICY_NEIGHBOR_DELETE: reqNeighborSet := grpcReq.Data.(*api.PolicyDefinition).StatementList[0].Conditions.MatchNeighborSet conNeighborSetList := server.routingPolicy.DefinedSets.NeighborSets.NeighborSetList - isReqNeighborSet, neighborSet := policy.NeighborSetToConfigStruct(reqNeighborSet) + isReqNeighborSet, neighborSet := table.NeighborSetToConfigStruct(reqNeighborSet) if isReqNeighborSet { // If only name of the NeighborSet is same, delete all of the elements of the NeighborSet. // If the same element NeighborSet, delete the it's element from NeighborSet. - idxNeighborSet, idxNeighbor := policy.IndexOfNeighborSet(conNeighborSetList, neighborSet) + idxNeighborSet, idxNeighbor := table.IndexOfNeighborSet(conNeighborSetList, neighborSet) if idxNeighborSet == -1 { result.ResponseErr = fmt.Errorf("Policy neighbor that has %v %v doesn't exist.", neighborSet.NeighborSetName, neighborSet.NeighborInfoList[0].Address) @@ -2173,10 +2156,10 @@ func (server *BgpServer) handleGrpcDelPolicy(grpcReq *GrpcRequest) { reqAsPathSet := grpcReq.Data.(*api.PolicyDefinition).StatementList[0].Conditions.MatchAsPathSet conAsPathSetList := server.routingPolicy.DefinedSets.BgpDefinedSets.AsPathSets.AsPathSetList result := &GrpcResponse{} - isReqAsPathSet, asPathSet := policy.AsPathSetToConfigStruct(reqAsPathSet) + isReqAsPathSet, asPathSet := table.AsPathSetToConfigStruct(reqAsPathSet) // If only name of the AsPathSet is same, delete all of the elements of the AsPathSet. // If the same element AsPathSet, delete the it's element from AsPathSet. - idxAsPathSet, idxAsPath := policy.IndexOfAsPathSet(conAsPathSetList, asPathSet) + idxAsPathSet, idxAsPath := table.IndexOfAsPathSet(conAsPathSetList, asPathSet) if isReqAsPathSet { if idxAsPathSet == -1 { result.ResponseErr = fmt.Errorf("Policy aspath that has %v %v doesn't exist.", asPathSet.AsPathSetName, @@ -2202,10 +2185,10 @@ func (server *BgpServer) handleGrpcDelPolicy(grpcReq *GrpcRequest) { case REQ_POLICY_COMMUNITY_DELETE: reqCommunitySet := grpcReq.Data.(*api.PolicyDefinition).StatementList[0].Conditions.MatchCommunitySet conCommunitySetList := server.routingPolicy.DefinedSets.BgpDefinedSets.CommunitySets.CommunitySetList - isReqCommunitySet, CommunitySet := policy.CommunitySetToConfigStruct(reqCommunitySet) + isReqCommunitySet, CommunitySet := table.CommunitySetToConfigStruct(reqCommunitySet) // If only name of the CommunitySet is same, delete all of the elements of the CommunitySet. // If the same element CommunitySet, delete the it's element from CommunitySet. - idxCommunitySet, idxCommunity := policy.IndexOfCommunitySet(conCommunitySetList, CommunitySet) + idxCommunitySet, idxCommunity := table.IndexOfCommunitySet(conCommunitySetList, CommunitySet) if isReqCommunitySet { if idxCommunitySet == -1 { result.ResponseErr = fmt.Errorf("Policy community that has %v %v doesn't exist.", CommunitySet.CommunitySetName, @@ -2231,10 +2214,10 @@ func (server *BgpServer) handleGrpcDelPolicy(grpcReq *GrpcRequest) { case REQ_POLICY_EXTCOMMUNITY_DELETE: reqExtCommunitySet := grpcReq.Data.(*api.PolicyDefinition).StatementList[0].Conditions.MatchExtCommunitySet conExtCommunitySetList := server.routingPolicy.DefinedSets.BgpDefinedSets.ExtCommunitySets.ExtCommunitySetList - isReqExtCommunitySet, ExtCommunitySet := policy.ExtCommunitySetToConfigStruct(reqExtCommunitySet) + isReqExtCommunitySet, ExtCommunitySet := table.ExtCommunitySetToConfigStruct(reqExtCommunitySet) // If only name of the ExtCommunitySet is same, delete all of the elements of the ExtCommunitySet. // If the same element ExtCommunitySet, delete the it's element from ExtCommunitySet. - idxExtCommunitySet, idxExtCommunity := policy.IndexOfExtCommunitySet(conExtCommunitySetList, ExtCommunitySet) + idxExtCommunitySet, idxExtCommunity := table.IndexOfExtCommunitySet(conExtCommunitySetList, ExtCommunitySet) if isReqExtCommunitySet { if idxExtCommunitySet == -1 { result.ResponseErr = fmt.Errorf("Policy extended community that has %v %v doesn't exist.", @@ -2262,8 +2245,8 @@ func (server *BgpServer) handleGrpcDelPolicy(grpcReq *GrpcRequest) { case REQ_POLICY_ROUTEPOLICY_DELETE: reqPolicy := grpcReq.Data.(*api.PolicyDefinition) conPolicyList := server.routingPolicy.PolicyDefinitions.PolicyDefinitionList - isStatement, policyDef := policy.PolicyDefinitionToConfigStruct(reqPolicy) - idxPolicy, idxStatement := policy.IndexOfPolicyDefinition(conPolicyList, policyDef) + isStatement, policyDef := table.PolicyDefinitionToConfigStruct(reqPolicy) + idxPolicy, idxStatement := table.IndexOfPolicyDefinition(conPolicyList, policyDef) if isStatement { if idxPolicy == -1 { result.ResponseErr = fmt.Errorf("Policy that has %v doesn't exist.", policyDef.Name) diff --git a/policy/policy.go b/table/policy.go index e04d56a3..bec56e07 100644 --- a/policy/policy.go +++ b/table/policy.go @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package policy +package table import ( "fmt" @@ -27,7 +27,6 @@ import ( "github.com/osrg/gobgp/api" "github.com/osrg/gobgp/config" "github.com/osrg/gobgp/packet" - "github.com/osrg/gobgp/table" ) type RouteType int @@ -38,6 +37,38 @@ const ( ROUTE_TYPE_REJECT ) +func (t RouteType) String() string { + switch t { + case ROUTE_TYPE_NONE: + return "NONE" + case ROUTE_TYPE_ACCEPT: + return "ACCEPT" + case ROUTE_TYPE_REJECT: + return "REJECT" + default: + return fmt.Sprintf("Unknown(%d)", t) + } +} + +func (t RouteType) ToApiStruct() gobgpapi.RouteAction { + switch t { + case ROUTE_TYPE_ACCEPT: + return gobgpapi.RouteAction_ACCEPT + case ROUTE_TYPE_REJECT: + return gobgpapi.RouteAction_REJECT + default: + return gobgpapi.RouteAction_NONE + } +} + +type PolicyDirection int + +const ( + POLICY_DIRECTION_IN = iota + POLICY_DIRECTION_IMPORT = iota + POLICY_DIRECTION_EXPORT +) + type AttributeComparison int const ( @@ -155,7 +186,7 @@ type Statement struct { } // evaluate each condition in the statement according to MatchSetOptions -func (s *Statement) evaluate(p *table.Path) bool { +func (s *Statement) evaluate(p *Path) bool { for _, condition := range s.Conditions { r := condition.evaluate(p) @@ -167,14 +198,14 @@ func (s *Statement) evaluate(p *table.Path) bool { } type Condition interface { - evaluate(*table.Path) bool + evaluate(*Path) bool } type DefaultCondition struct { CallPolicy string } -func (c *DefaultCondition) evaluate(path *table.Path) bool { +func (c *DefaultCondition) evaluate(path *Path) bool { return false } @@ -224,7 +255,7 @@ func NewPrefixCondition(matchPref config.MatchPrefixSet, defPrefixList []config. // compare prefixes in this condition and nlri of path and // subsequent comparison is skipped if that matches the conditions. // If PrefixList's length is zero, return true. -func (c *PrefixCondition) evaluate(path *table.Path) bool { +func (c *PrefixCondition) evaluate(path *Path) bool { if len(c.PrefixList) == 0 { log.Debug("PrefixList doesn't have elements") @@ -289,7 +320,7 @@ func NewNeighborCondition(matchNeighborSet config.MatchNeighborSet, defNeighborS // compare neighbor ipaddress of this condition and source address of path // and, subsequent comparisons are skipped if that matches the conditions. // If NeighborList's length is zero, return true. -func (c *NeighborCondition) evaluate(path *table.Path) bool { +func (c *NeighborCondition) evaluate(path *Path) bool { if len(c.NeighborList) == 0 { log.Debug("NeighborList doesn't have elements") @@ -356,7 +387,7 @@ func NewAsPathLengthCondition(defAsPathLength config.AsPathLength) *AsPathLength // compare AS_PATH length in the message's AS_PATH attribute with // the one in condition. -func (c *AsPathLengthCondition) evaluate(path *table.Path) bool { +func (c *AsPathLengthCondition) evaluate(path *Path) bool { length := uint32(path.GetAsPathLen()) result := false @@ -458,7 +489,7 @@ func (c *AsPathCondition) checkMembers(aspathStr string, checkAll bool) bool { // compare AS_PATH in the message's AS_PATH attribute with // the one in condition. -func (c *AsPathCondition) evaluate(path *table.Path) bool { +func (c *AsPathCondition) evaluate(path *Path) bool { aspathStr := path.GetAsString() @@ -687,7 +718,7 @@ func (c *CommunityCondition) checkMembers(communities []uint32, checkAll bool) b // compare community in the message's attribute with // the one in the condition. -func (c *CommunityCondition) evaluate(path *table.Path) bool { +func (c *CommunityCondition) evaluate(path *Path) bool { communities := path.GetCommunities() @@ -942,7 +973,7 @@ func (c *ExtCommunityCondition) checkMembers(eCommunities []bgp.ExtendedCommunit // compare extended community in the message's attribute with // the one in the condition. -func (c *ExtCommunityCondition) evaluate(path *table.Path) bool { +func (c *ExtCommunityCondition) evaluate(path *Path) bool { eCommunities := path.GetExtCommunities() if len(eCommunities) == 0 { @@ -985,12 +1016,12 @@ func NewRPKIValidationCondition(result config.RpkiValidationResultType) *RPKIVal } } -func (c *RPKIValidationCondition) evaluate(path *table.Path) bool { +func (c *RPKIValidationCondition) evaluate(path *Path) bool { return c.result == path.Validation } type Action interface { - apply(*table.Path) *table.Path + apply(*Path) *Path } type RoutingAction struct { @@ -1003,7 +1034,7 @@ func NewRoutingAction(action config.Actions) *RoutingAction { } } -func (r *RoutingAction) apply(path *table.Path) *table.Path { +func (r *RoutingAction) apply(path *Path) *Path { if r.AcceptRoute { return path } @@ -1086,7 +1117,7 @@ func NewCommunityAction(action config.SetCommunity) *CommunityAction { return m } -func RegexpRemoveCommunities(path *table.Path, exps []*regexp.Regexp) { +func RegexpRemoveCommunities(path *Path, exps []*regexp.Regexp) { comms := path.GetCommunities() newComms := make([]uint32, 0, len(comms)) for _, comm := range comms { @@ -1105,7 +1136,7 @@ func RegexpRemoveCommunities(path *table.Path, exps []*regexp.Regexp) { path.SetCommunities(newComms, true) } -func (a *CommunityAction) apply(path *table.Path) *table.Path { +func (a *CommunityAction) apply(path *Path) *Path { if len(a.ext) > 0 { return a.extApply(path) } @@ -1132,7 +1163,7 @@ func (a *CommunityAction) apply(path *table.Path) *table.Path { return path } -func (a *CommunityAction) extApply(path *table.Path) *table.Path { +func (a *CommunityAction) extApply(path *Path) *Path { path.SetExtCommunities(a.ext, false) log.WithFields(log.Fields{ @@ -1238,7 +1269,7 @@ func getMedValue(medStr string) (bool, int64, ActionType) { } return false, int64(0), MED_ACTION_NONE } -func (a *MedAction) apply(path *table.Path) *table.Path { +func (a *MedAction) apply(path *Path) *Path { var err error switch a.action { @@ -1301,7 +1332,7 @@ func NewAsPathPrependAction(action config.SetAsPathPrepend) *AsPathPrependAction return a } -func (a *AsPathPrependAction) apply(path *table.Path) *table.Path { +func (a *AsPathPrependAction) apply(path *Path) *Path { var asn uint32 if a.useLeftMost { @@ -1388,7 +1419,7 @@ func NewPrefix(prefixStr string, maskRange string) (Prefix, error) { // Compare path with a policy's condition in stored order in the policy. // If a condition match, then this function stops evaluation and // subsequent conditions are skipped. -func (p *Policy) Apply(path *table.Path) (RouteType, *table.Path) { +func (p *Policy) Apply(path *Path) (RouteType, *Path) { for _, statement := range p.Statements { result := statement.evaluate(path) @@ -1418,7 +1449,7 @@ func (p *Policy) Apply(path *table.Path) (RouteType, *table.Path) { return ROUTE_TYPE_NONE, path } -func ipPrefixCalculate(path *table.Path, cPrefix Prefix) bool { +func ipPrefixCalculate(path *Path, cPrefix Prefix) bool { rf := path.GetRouteFamily() log.Debug("path routefamily : ", rf.String()) var pAddr net.IP @@ -1443,11 +1474,6 @@ func ipPrefixCalculate(path *table.Path, cPrefix Prefix) bool { } const ( - ROUTE_ACCEPT string = "ACCEPT" - ROUTE_REJECT = "REJECT" -) - -const ( OPTIONS_ANY string = "ANY" OPTIONS_ALL = "ALL" OPTIONS_INVERT = "INVERT" @@ -2017,7 +2043,7 @@ func PoliciesToString(reqPolicies []*gobgpapi.PolicyDefinition) []string { return policies } -func CanImportToVrf(v *table.Vrf, path *table.Path) bool { +func CanImportToVrf(v *Vrf, path *Path) bool { f := func(arg []bgp.ExtendedCommunityInterface) []config.ExtCommunity { ret := make([]config.ExtCommunity, 0, len(arg)) for _, a := range arg { diff --git a/policy/policy_test.go b/table/policy_test.go index de8d4691..588a769b 100644 --- a/policy/policy_test.go +++ b/table/policy_test.go @@ -13,14 +13,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -package policy +package table import ( "fmt" log "github.com/Sirupsen/logrus" "github.com/osrg/gobgp/config" "github.com/osrg/gobgp/packet" - "github.com/osrg/gobgp/table" "github.com/stretchr/testify/assert" "math" "net" @@ -38,7 +37,7 @@ func init() { func TestPrefixCalcurateNoRange(t *testing.T) { log.SetLevel(log.DebugLevel) // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65001})} aspath := bgp.NewPathAttributeAsPath(aspathParam) @@ -47,7 +46,7 @@ func TestPrefixCalcurateNoRange(t *testing.T) { pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med} nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.0.0")} updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - path := table.ProcessMessage(updateMsg, peer)[0] + path := ProcessMessage(updateMsg, peer)[0] // test pl1, _ := NewPrefix("10.10.0.0/24", "") match1 := ipPrefixCalculate(path, pl1) @@ -62,7 +61,7 @@ func TestPrefixCalcurateNoRange(t *testing.T) { func TestPrefixCalcurateAddress(t *testing.T) { // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65001})} aspath := bgp.NewPathAttributeAsPath(aspathParam) @@ -71,7 +70,7 @@ func TestPrefixCalcurateAddress(t *testing.T) { pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med} nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.0.101")} updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - path := table.ProcessMessage(updateMsg, peer)[0] + path := ProcessMessage(updateMsg, peer)[0] // test pl1, _ := NewPrefix("10.11.0.0/16", "21..24") match1 := ipPrefixCalculate(path, pl1) @@ -83,7 +82,7 @@ func TestPrefixCalcurateAddress(t *testing.T) { func TestPrefixCalcurateLength(t *testing.T) { // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65001})} aspath := bgp.NewPathAttributeAsPath(aspathParam) @@ -92,7 +91,7 @@ func TestPrefixCalcurateLength(t *testing.T) { pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med} nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.0.101")} updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - path := table.ProcessMessage(updateMsg, peer)[0] + path := ProcessMessage(updateMsg, peer)[0] // test pl1, _ := NewPrefix("10.10.64.0/24", "21..24") match1 := ipPrefixCalculate(path, pl1) @@ -104,7 +103,7 @@ func TestPrefixCalcurateLength(t *testing.T) { func TestPrefixCalcurateLengthRange(t *testing.T) { // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65001})} aspath := bgp.NewPathAttributeAsPath(aspathParam) @@ -113,7 +112,7 @@ func TestPrefixCalcurateLengthRange(t *testing.T) { pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med} nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.0.101")} updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - path := table.ProcessMessage(updateMsg, peer)[0] + path := ProcessMessage(updateMsg, peer)[0] // test pl1, _ := NewPrefix("10.10.0.0/16", "21..23") match1 := ipPrefixCalculate(path, pl1) @@ -129,7 +128,7 @@ func TestPrefixCalcurateLengthRange(t *testing.T) { func TestPrefixCalcurateNoRangeIPv6(t *testing.T) { log.SetLevel(log.DebugLevel) // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("2001::192:168:50:1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("2001::192:168:50:1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65001})} aspath := bgp.NewPathAttributeAsPath(aspathParam) @@ -138,7 +137,7 @@ func TestPrefixCalcurateNoRangeIPv6(t *testing.T) { med := bgp.NewPathAttributeMultiExitDisc(0) pathAttributes := []bgp.PathAttributeInterface{mpreach, origin, aspath, med} updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nil) - path := table.ProcessMessage(updateMsg, peer)[0] + path := ProcessMessage(updateMsg, peer)[0] // test pl1, _ := NewPrefix("2001:123:123::/48", "") match1 := ipPrefixCalculate(path, pl1) @@ -153,7 +152,7 @@ func TestPrefixCalcurateNoRangeIPv6(t *testing.T) { func TestPrefixCalcurateAddressIPv6(t *testing.T) { // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("2001::192:168:50:1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("2001::192:168:50:1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65001})} aspath := bgp.NewPathAttributeAsPath(aspathParam) @@ -162,7 +161,7 @@ func TestPrefixCalcurateAddressIPv6(t *testing.T) { med := bgp.NewPathAttributeMultiExitDisc(0) pathAttributes := []bgp.PathAttributeInterface{mpreach, origin, aspath, med} updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nil) - path := table.ProcessMessage(updateMsg, peer)[0] + path := ProcessMessage(updateMsg, peer)[0] // test pl1, _ := NewPrefix("2001:123:128::/48", "64..80") match1 := ipPrefixCalculate(path, pl1) @@ -174,7 +173,7 @@ func TestPrefixCalcurateAddressIPv6(t *testing.T) { func TestPrefixCalcurateLengthIPv6(t *testing.T) { // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("2001::192:168:50:1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("2001::192:168:50:1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65001})} aspath := bgp.NewPathAttributeAsPath(aspathParam) @@ -183,7 +182,7 @@ func TestPrefixCalcurateLengthIPv6(t *testing.T) { med := bgp.NewPathAttributeMultiExitDisc(0) pathAttributes := []bgp.PathAttributeInterface{mpreach, origin, aspath, med} updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nil) - path := table.ProcessMessage(updateMsg, peer)[0] + path := ProcessMessage(updateMsg, peer)[0] // test pl1, _ := NewPrefix("2001:123:123:64::/64", "64..80") match1 := ipPrefixCalculate(path, pl1) @@ -195,7 +194,7 @@ func TestPrefixCalcurateLengthIPv6(t *testing.T) { func TestPrefixCalcurateLengthRangeIPv6(t *testing.T) { // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("2001::192:168:50:1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("2001::192:168:50:1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65001})} aspath := bgp.NewPathAttributeAsPath(aspathParam) @@ -204,7 +203,7 @@ func TestPrefixCalcurateLengthRangeIPv6(t *testing.T) { med := bgp.NewPathAttributeMultiExitDisc(0) pathAttributes := []bgp.PathAttributeInterface{mpreach, origin, aspath, med} updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nil) - path := table.ProcessMessage(updateMsg, peer)[0] + path := ProcessMessage(updateMsg, peer)[0] // test pl1, _ := NewPrefix("2001:123:123::/48", "62..63") match1 := ipPrefixCalculate(path, pl1) @@ -219,7 +218,7 @@ func TestPrefixCalcurateLengthRangeIPv6(t *testing.T) { func TestPolicyNotMatch(t *testing.T) { // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65001})} aspath := bgp.NewPathAttributeAsPath(aspathParam) @@ -228,7 +227,7 @@ func TestPolicyNotMatch(t *testing.T) { pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med} nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.0.101")} updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - path := table.ProcessMessage(updateMsg, peer)[0] + path := ProcessMessage(updateMsg, peer)[0] // create policy ps := createPrefixSet("ps1", "10.3.0.0/16", "21..24") @@ -250,7 +249,7 @@ func TestPolicyNotMatch(t *testing.T) { func TestPolicyMatchAndReject(t *testing.T) { // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65001})} aspath := bgp.NewPathAttributeAsPath(aspathParam) @@ -259,7 +258,7 @@ func TestPolicyMatchAndReject(t *testing.T) { pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med} nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.0.101")} updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - path := table.ProcessMessage(updateMsg, peer)[0] + path := ProcessMessage(updateMsg, peer)[0] // create policy ps := createPrefixSet("ps1", "10.10.0.0/16", "21..24") ns := createNeighborSet("ns1", "10.0.0.1") @@ -281,7 +280,7 @@ func TestPolicyMatchAndReject(t *testing.T) { func TestPolicyMatchAndAccept(t *testing.T) { // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65001})} aspath := bgp.NewPathAttributeAsPath(aspathParam) @@ -290,7 +289,7 @@ func TestPolicyMatchAndAccept(t *testing.T) { pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med} nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.0.101")} updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - path := table.ProcessMessage(updateMsg, peer)[0] + path := ProcessMessage(updateMsg, peer)[0] // create policy ps := createPrefixSet("ps1", "10.10.0.0/16", "21..24") ns := createNeighborSet("ns1", "10.0.0.1") @@ -312,7 +311,7 @@ func TestPolicyMatchAndAccept(t *testing.T) { func TestPolicyRejectOnlyPrefixSet(t *testing.T) { // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.1.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.1.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65001})} aspath := bgp.NewPathAttributeAsPath(aspathParam) @@ -321,9 +320,9 @@ func TestPolicyRejectOnlyPrefixSet(t *testing.T) { pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med} nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.1.101")} updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - path1 := table.ProcessMessage(updateMsg, peer)[0] + path1 := ProcessMessage(updateMsg, peer)[0] - peer = &table.PeerInfo{AS: 65002, Address: net.ParseIP("10.0.2.2")} + peer = &PeerInfo{AS: 65002, Address: net.ParseIP("10.0.2.2")} origin = bgp.NewPathAttributeOrigin(0) aspathParam = []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65002})} aspath = bgp.NewPathAttributeAsPath(aspathParam) @@ -332,7 +331,7 @@ func TestPolicyRejectOnlyPrefixSet(t *testing.T) { pathAttributes = []bgp.PathAttributeInterface{origin, aspath, nexthop, med} nlri = []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.9.2.102")} updateMsg = bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - path2 := table.ProcessMessage(updateMsg, peer)[0] + path2 := ProcessMessage(updateMsg, peer)[0] // create policy ps := createPrefixSet("ps1", "10.10.1.0/16", "21..24") @@ -357,7 +356,7 @@ func TestPolicyRejectOnlyPrefixSet(t *testing.T) { func TestPolicyRejectOnlyNeighborSet(t *testing.T) { // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.1.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.1.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65001})} aspath := bgp.NewPathAttributeAsPath(aspathParam) @@ -366,9 +365,9 @@ func TestPolicyRejectOnlyNeighborSet(t *testing.T) { pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med} nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.1.101")} updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - path1 := table.ProcessMessage(updateMsg, peer)[0] + path1 := ProcessMessage(updateMsg, peer)[0] - peer = &table.PeerInfo{AS: 65002, Address: net.ParseIP("10.0.2.2")} + peer = &PeerInfo{AS: 65002, Address: net.ParseIP("10.0.2.2")} origin = bgp.NewPathAttributeOrigin(0) aspathParam = []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65002})} aspath = bgp.NewPathAttributeAsPath(aspathParam) @@ -377,7 +376,7 @@ func TestPolicyRejectOnlyNeighborSet(t *testing.T) { pathAttributes = []bgp.PathAttributeInterface{origin, aspath, nexthop, med} nlri = []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.2.102")} updateMsg = bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - path2 := table.ProcessMessage(updateMsg, peer)[0] + path2 := ProcessMessage(updateMsg, peer)[0] // create policy ns := createNeighborSet("ns1", "10.0.1.1") @@ -402,7 +401,7 @@ func TestPolicyRejectOnlyNeighborSet(t *testing.T) { func TestPolicyDifferentRoutefamilyOfPathAndPolicy(t *testing.T) { // create path ipv4 - peerIPv4 := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} + peerIPv4 := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} originIPv4 := bgp.NewPathAttributeOrigin(0) aspathParamIPv4 := []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65001})} aspathIPv4 := bgp.NewPathAttributeAsPath(aspathParamIPv4) @@ -411,9 +410,9 @@ func TestPolicyDifferentRoutefamilyOfPathAndPolicy(t *testing.T) { pathAttributesIPv4 := []bgp.PathAttributeInterface{originIPv4, aspathIPv4, nexthopIPv4, medIPv4} nlriIPv4 := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.0.101")} updateMsgIPv4 := bgp.NewBGPUpdateMessage(nil, pathAttributesIPv4, nlriIPv4) - pathIPv4 := table.ProcessMessage(updateMsgIPv4, peerIPv4)[0] + pathIPv4 := ProcessMessage(updateMsgIPv4, peerIPv4)[0] // create path ipv6 - peerIPv6 := &table.PeerInfo{AS: 65001, Address: net.ParseIP("2001::192:168:50:1")} + peerIPv6 := &PeerInfo{AS: 65001, Address: net.ParseIP("2001::192:168:50:1")} originIPv6 := bgp.NewPathAttributeOrigin(0) aspathParamIPv6 := []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65001})} aspathIPv6 := bgp.NewPathAttributeAsPath(aspathParamIPv6) @@ -422,7 +421,7 @@ func TestPolicyDifferentRoutefamilyOfPathAndPolicy(t *testing.T) { medIPv6 := bgp.NewPathAttributeMultiExitDisc(0) pathAttributesIPv6 := []bgp.PathAttributeInterface{mpreachIPv6, originIPv6, aspathIPv6, medIPv6} updateMsgIPv6 := bgp.NewBGPUpdateMessage(nil, pathAttributesIPv6, nil) - pathIPv6 := table.ProcessMessage(updateMsgIPv6, peerIPv6)[0] + pathIPv6 := ProcessMessage(updateMsgIPv6, peerIPv6)[0] // create policy psIPv4 := createPrefixSet("psIPv4", "10.10.0.0/16", "21..24") nsIPv4 := createNeighborSet("nsIPv4", "10.0.0.1") @@ -455,7 +454,7 @@ func TestPolicyDifferentRoutefamilyOfPathAndPolicy(t *testing.T) { func TestAsPathLengthConditionEvaluate(t *testing.T) { // setup // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{ bgp.NewAsPathParam(2, []uint16{65001, 65000, 65004, 65005}), @@ -467,8 +466,8 @@ func TestAsPathLengthConditionEvaluate(t *testing.T) { pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med} nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.0.101")} updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - table.UpdatePathAttrs4ByteAs(updateMsg.Body.(*bgp.BGPUpdate)) - path := table.ProcessMessage(updateMsg, peer)[0] + UpdatePathAttrs4ByteAs(updateMsg.Body.(*bgp.BGPUpdate)) + path := ProcessMessage(updateMsg, peer)[0] // create match condition asPathLength := config.AsPathLength{ @@ -504,7 +503,7 @@ func TestAsPathLengthConditionEvaluate(t *testing.T) { func TestAsPathLengthConditionWithOtherCondition(t *testing.T) { // setup // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{ bgp.NewAsPathParam(2, []uint16{65001, 65000, 65004, 65004, 65005}), @@ -516,8 +515,8 @@ func TestAsPathLengthConditionWithOtherCondition(t *testing.T) { pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med} nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.0.101")} updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - table.UpdatePathAttrs4ByteAs(updateMsg.Body.(*bgp.BGPUpdate)) - path := table.ProcessMessage(updateMsg, peer)[0] + UpdatePathAttrs4ByteAs(updateMsg.Body.(*bgp.BGPUpdate)) + path := ProcessMessage(updateMsg, peer)[0] // create policy ps := createPrefixSet("ps1", "10.10.1.0/16", "21..24") @@ -551,7 +550,7 @@ func TestAsPathConditionEvaluate(t *testing.T) { // setup // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam1 := []bgp.AsPathParamInterface{ bgp.NewAsPathParam(2, []uint16{65001, 65000, 65010, 65004, 65005}), @@ -562,8 +561,8 @@ func TestAsPathConditionEvaluate(t *testing.T) { pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med} nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.0.101")} updateMsg1 := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - table.UpdatePathAttrs4ByteAs(updateMsg1.Body.(*bgp.BGPUpdate)) - path1 := table.ProcessMessage(updateMsg1, peer)[0] + UpdatePathAttrs4ByteAs(updateMsg1.Body.(*bgp.BGPUpdate)) + path1 := ProcessMessage(updateMsg1, peer)[0] aspathParam2 := []bgp.AsPathParamInterface{ bgp.NewAsPathParam(2, []uint16{65010}), @@ -571,8 +570,8 @@ func TestAsPathConditionEvaluate(t *testing.T) { aspath2 := bgp.NewPathAttributeAsPath(aspathParam2) pathAttributes = []bgp.PathAttributeInterface{origin, aspath2, nexthop, med} updateMsg2 := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - table.UpdatePathAttrs4ByteAs(updateMsg2.Body.(*bgp.BGPUpdate)) - path2 := table.ProcessMessage(updateMsg2, peer)[0] + UpdatePathAttrs4ByteAs(updateMsg2.Body.(*bgp.BGPUpdate)) + path2 := ProcessMessage(updateMsg2, peer)[0] // create match condition asPathSet1 := config.AsPathSet{ @@ -657,7 +656,7 @@ func TestMultipleAsPathConditionEvaluate(t *testing.T) { // setup // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam1 := []bgp.AsPathParamInterface{ bgp.NewAsPathParam(2, []uint16{65001, 65000, 54000, 65004, 65005}), @@ -668,8 +667,8 @@ func TestMultipleAsPathConditionEvaluate(t *testing.T) { pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med} nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.0.101")} updateMsg1 := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - table.UpdatePathAttrs4ByteAs(updateMsg1.Body.(*bgp.BGPUpdate)) - path1 := table.ProcessMessage(updateMsg1, peer)[0] + UpdatePathAttrs4ByteAs(updateMsg1.Body.(*bgp.BGPUpdate)) + path1 := ProcessMessage(updateMsg1, peer)[0] // create match condition asPathSet1 := config.AsPathSet{ @@ -770,7 +769,7 @@ func TestMultipleAsPathConditionEvaluate(t *testing.T) { func TestAsPathCondition(t *testing.T) { type astest struct { - path *table.Path + path *Path result bool } @@ -779,7 +778,7 @@ func TestAsPathCondition(t *testing.T) { bgp.NewAs4PathParam(asPathAttrType, ases), } pathAttributes := []bgp.PathAttributeInterface{bgp.NewPathAttributeAsPath(aspathParam)} - p := table.NewPath(nil, nil, false, pathAttributes, false, time.Time{}, false) + p := NewPath(nil, nil, false, pathAttributes, false, time.Time{}, false) return astest{ path: p, result: result, @@ -839,7 +838,7 @@ func TestAsPathConditionWithOtherCondition(t *testing.T) { // setup // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{ bgp.NewAsPathParam(1, []uint16{65001, 65000, 65004, 65005}), @@ -851,8 +850,8 @@ func TestAsPathConditionWithOtherCondition(t *testing.T) { pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med} nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.0.101")} updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - table.UpdatePathAttrs4ByteAs(updateMsg.Body.(*bgp.BGPUpdate)) - path := table.ProcessMessage(updateMsg, peer)[0] + UpdatePathAttrs4ByteAs(updateMsg.Body.(*bgp.BGPUpdate)) + path := ProcessMessage(updateMsg, peer)[0] // create policy asPathSet := config.AsPathSet{ @@ -889,7 +888,7 @@ func TestCommunityConditionEvaluate(t *testing.T) { // setup // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam1 := []bgp.AsPathParamInterface{ bgp.NewAsPathParam(2, []uint16{65001, 65000, 65004, 65005}), @@ -911,8 +910,8 @@ func TestCommunityConditionEvaluate(t *testing.T) { pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med, communities} nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.0.101")} updateMsg1 := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - table.UpdatePathAttrs4ByteAs(updateMsg1.Body.(*bgp.BGPUpdate)) - path1 := table.ProcessMessage(updateMsg1, peer)[0] + UpdatePathAttrs4ByteAs(updateMsg1.Body.(*bgp.BGPUpdate)) + path1 := ProcessMessage(updateMsg1, peer)[0] // create match condition comSet1 := config.CommunitySet{ @@ -1036,7 +1035,7 @@ func TestCommunityConditionEvaluateWithOtherCondition(t *testing.T) { // setup // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{ bgp.NewAsPathParam(1, []uint16{65001, 65000, 65004, 65005}), @@ -1057,8 +1056,8 @@ func TestCommunityConditionEvaluateWithOtherCondition(t *testing.T) { pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med, communities} nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.0.101")} updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - table.UpdatePathAttrs4ByteAs(updateMsg.Body.(*bgp.BGPUpdate)) - path := table.ProcessMessage(updateMsg, peer)[0] + UpdatePathAttrs4ByteAs(updateMsg.Body.(*bgp.BGPUpdate)) + path := ProcessMessage(updateMsg, peer)[0] // create policy asPathSet := config.AsPathSet{ @@ -1123,7 +1122,7 @@ func TestCommunityConditionEvaluateWithOtherCondition(t *testing.T) { func TestPolicyMatchAndAddCommunities(t *testing.T) { // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65001})} aspath := bgp.NewPathAttributeAsPath(aspathParam) @@ -1132,7 +1131,7 @@ func TestPolicyMatchAndAddCommunities(t *testing.T) { pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med} nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.0.101")} updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - path := table.ProcessMessage(updateMsg, peer)[0] + path := ProcessMessage(updateMsg, peer)[0] // create policy ps := createPrefixSet("ps1", "10.10.0.0/16", "21..24") ns := createNeighborSet("ns1", "10.0.0.1") @@ -1163,7 +1162,7 @@ func TestPolicyMatchAndAddCommunities(t *testing.T) { func TestPolicyMatchAndReplaceCommunities(t *testing.T) { // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65001})} aspath := bgp.NewPathAttributeAsPath(aspathParam) @@ -1175,7 +1174,7 @@ func TestPolicyMatchAndReplaceCommunities(t *testing.T) { pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med, communities} nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.0.101")} updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - path := table.ProcessMessage(updateMsg, peer)[0] + path := ProcessMessage(updateMsg, peer)[0] // create policy ps := createPrefixSet("ps1", "10.10.0.0/16", "21..24") ns := createNeighborSet("ns1", "10.0.0.1") @@ -1207,7 +1206,7 @@ func TestPolicyMatchAndRemoveCommunities(t *testing.T) { // create path community1 := "65000:100" community2 := "65000:200" - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65001})} aspath := bgp.NewPathAttributeAsPath(aspathParam) @@ -1220,7 +1219,7 @@ func TestPolicyMatchAndRemoveCommunities(t *testing.T) { pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med, communities} nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.0.101")} updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - path := table.ProcessMessage(updateMsg, peer)[0] + path := ProcessMessage(updateMsg, peer)[0] // create policy ps := createPrefixSet("ps1", "10.10.0.0/16", "21..24") ns := createNeighborSet("ns1", "10.0.0.1") @@ -1250,7 +1249,7 @@ func TestPolicyMatchAndRemoveCommunitiesRegexp(t *testing.T) { community1 := "65000:100" community2 := "65000:200" community3 := "65100:100" - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65001})} aspath := bgp.NewPathAttributeAsPath(aspathParam) @@ -1264,7 +1263,7 @@ func TestPolicyMatchAndRemoveCommunitiesRegexp(t *testing.T) { pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med, communities} nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.0.101")} updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - path := table.ProcessMessage(updateMsg, peer)[0] + path := ProcessMessage(updateMsg, peer)[0] // create policy ps := createPrefixSet("ps1", "10.10.0.0/16", "21..24") ns := createNeighborSet("ns1", "10.0.0.1") @@ -1294,7 +1293,7 @@ func TestPolicyMatchAndRemoveCommunitiesRegexp2(t *testing.T) { community1 := "0:1" community2 := "10:1" community3 := "45686:2" - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65001})} aspath := bgp.NewPathAttributeAsPath(aspathParam) @@ -1308,7 +1307,7 @@ func TestPolicyMatchAndRemoveCommunitiesRegexp2(t *testing.T) { pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med, communities} nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.0.101")} updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - path := table.ProcessMessage(updateMsg, peer)[0] + path := ProcessMessage(updateMsg, peer)[0] // create policy ps := createPrefixSet("ps1", "10.10.0.0/16", "21..24") ns := createNeighborSet("ns1", "10.0.0.1") @@ -1337,7 +1336,7 @@ func TestPolicyMatchAndClearCommunities(t *testing.T) { // create path community1 := "65000:100" community2 := "65000:200" - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65001})} aspath := bgp.NewPathAttributeAsPath(aspathParam) @@ -1350,7 +1349,7 @@ func TestPolicyMatchAndClearCommunities(t *testing.T) { pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med, communities} nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.0.101")} updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - path := table.ProcessMessage(updateMsg, peer)[0] + path := ProcessMessage(updateMsg, peer)[0] // create policy ps := createPrefixSet("ps1", "10.10.0.0/16", "21..24") ns := createNeighborSet("ns1", "10.0.0.1") @@ -1383,7 +1382,7 @@ func TestExtCommunityConditionEvaluate(t *testing.T) { // setup // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam1 := []bgp.AsPathParamInterface{ bgp.NewAsPathParam(2, []uint16{65001, 65000, 65004, 65005}), @@ -1453,8 +1452,8 @@ func TestExtCommunityConditionEvaluate(t *testing.T) { pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med, extCommunities} nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.0.101")} updateMsg1 := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - table.UpdatePathAttrs4ByteAs(updateMsg1.Body.(*bgp.BGPUpdate)) - path1 := table.ProcessMessage(updateMsg1, peer)[0] + UpdatePathAttrs4ByteAs(updateMsg1.Body.(*bgp.BGPUpdate)) + path1 := ProcessMessage(updateMsg1, peer)[0] convUintStr := func(as uint32) string { upper := strconv.FormatUint(uint64(as&0xFFFF0000>>16), 10) @@ -1584,7 +1583,7 @@ func TestExtCommunityConditionEvaluateWithOtherCondition(t *testing.T) { // setup // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.2.1.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.2.1.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{ bgp.NewAsPathParam(1, []uint16{65001, 65000, 65004, 65005}), @@ -1654,8 +1653,8 @@ func TestExtCommunityConditionEvaluateWithOtherCondition(t *testing.T) { pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med, extCommunities} nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.0.101")} updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - table.UpdatePathAttrs4ByteAs(updateMsg.Body.(*bgp.BGPUpdate)) - path := table.ProcessMessage(updateMsg, peer)[0] + UpdatePathAttrs4ByteAs(updateMsg.Body.(*bgp.BGPUpdate)) + path := ProcessMessage(updateMsg, peer)[0] // create policy asPathSet := config.AsPathSet{ @@ -1715,7 +1714,7 @@ func TestExtCommunityConditionEvaluateWithOtherCondition(t *testing.T) { func TestPolicyMatchAndReplaceMed(t *testing.T) { // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65001})} aspath := bgp.NewPathAttributeAsPath(aspathParam) @@ -1725,7 +1724,7 @@ func TestPolicyMatchAndReplaceMed(t *testing.T) { pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med} nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.0.101")} updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - path := table.ProcessMessage(updateMsg, peer)[0] + path := ProcessMessage(updateMsg, peer)[0] // create policy ps := createPrefixSet("ps1", "10.10.0.0/16", "21..24") ns := createNeighborSet("ns1", "10.0.0.1") @@ -1757,7 +1756,7 @@ func TestPolicyMatchAndReplaceMed(t *testing.T) { func TestPolicyMatchAndAddingMed(t *testing.T) { // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65001})} aspath := bgp.NewPathAttributeAsPath(aspathParam) @@ -1767,7 +1766,7 @@ func TestPolicyMatchAndAddingMed(t *testing.T) { pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med} nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.0.101")} updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - path := table.ProcessMessage(updateMsg, peer)[0] + path := ProcessMessage(updateMsg, peer)[0] // create policy ps := createPrefixSet("ps1", "10.10.0.0/16", "21..24") ns := createNeighborSet("ns1", "10.0.0.1") @@ -1799,7 +1798,7 @@ func TestPolicyMatchAndAddingMed(t *testing.T) { func TestPolicyMatchAndAddingMedOverFlow(t *testing.T) { // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65001})} aspath := bgp.NewPathAttributeAsPath(aspathParam) @@ -1809,7 +1808,7 @@ func TestPolicyMatchAndAddingMedOverFlow(t *testing.T) { pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med} nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.0.101")} updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - path := table.ProcessMessage(updateMsg, peer)[0] + path := ProcessMessage(updateMsg, peer)[0] // create policy ps := createPrefixSet("ps1", "10.10.0.0/16", "21..24") ns := createNeighborSet("ns1", "10.0.0.1") @@ -1843,7 +1842,7 @@ func TestPolicyMatchAndAddingMedOverFlow(t *testing.T) { func TestPolicyMatchAndSubtractMed(t *testing.T) { // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65001})} aspath := bgp.NewPathAttributeAsPath(aspathParam) @@ -1853,7 +1852,7 @@ func TestPolicyMatchAndSubtractMed(t *testing.T) { pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med} nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.0.101")} updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - path := table.ProcessMessage(updateMsg, peer)[0] + path := ProcessMessage(updateMsg, peer)[0] // create policy ps := createPrefixSet("ps1", "10.10.0.0/16", "21..24") ns := createNeighborSet("ns1", "10.0.0.1") @@ -1887,7 +1886,7 @@ func TestPolicyMatchAndSubtractMed(t *testing.T) { func TestPolicyMatchAndSubtractMedUnderFlow(t *testing.T) { // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65001})} aspath := bgp.NewPathAttributeAsPath(aspathParam) @@ -1897,7 +1896,7 @@ func TestPolicyMatchAndSubtractMedUnderFlow(t *testing.T) { pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med} nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.0.101")} updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - path := table.ProcessMessage(updateMsg, peer)[0] + path := ProcessMessage(updateMsg, peer)[0] // create policy ps := createPrefixSet("ps1", "10.10.0.0/16", "21..24") ns := createNeighborSet("ns1", "10.0.0.1") @@ -1931,7 +1930,7 @@ func TestPolicyMatchAndSubtractMedUnderFlow(t *testing.T) { func TestPolicyMatchWhenPathHaveNotMed(t *testing.T) { // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65001})} aspath := bgp.NewPathAttributeAsPath(aspathParam) @@ -1940,7 +1939,7 @@ func TestPolicyMatchWhenPathHaveNotMed(t *testing.T) { pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop} nlri := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.10.0.101")} updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) - path := table.ProcessMessage(updateMsg, peer)[0] + path := ProcessMessage(updateMsg, peer)[0] // create policy ps := createPrefixSet("ps1", "10.10.0.0/16", "21..24") ns := createNeighborSet("ns1", "10.0.0.1") @@ -1972,7 +1971,7 @@ func TestPolicyAsPathPrepend(t *testing.T) { assert := assert.New(t) // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65001, 65000})} aspath := bgp.NewPathAttributeAsPath(aspathParam) @@ -1984,8 +1983,8 @@ func TestPolicyAsPathPrepend(t *testing.T) { updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) body := updateMsg.Body.(*bgp.BGPUpdate) - table.UpdatePathAttrs4ByteAs(body) - path := table.ProcessMessage(updateMsg, peer)[0] + UpdatePathAttrs4ByteAs(body) + path := ProcessMessage(updateMsg, peer)[0] // create policy ps := createPrefixSet("ps1", "10.10.0.0/16", "21..24") @@ -2015,7 +2014,7 @@ func TestPolicyAsPathPrependLastAs(t *testing.T) { assert := assert.New(t) // create path - peer := &table.PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} + peer := &PeerInfo{AS: 65001, Address: net.ParseIP("10.0.0.1")} origin := bgp.NewPathAttributeOrigin(0) aspathParam := []bgp.AsPathParamInterface{bgp.NewAsPathParam(2, []uint16{65002, 65001, 65000})} aspath := bgp.NewPathAttributeAsPath(aspathParam) @@ -2027,8 +2026,8 @@ func TestPolicyAsPathPrependLastAs(t *testing.T) { updateMsg := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri) body := updateMsg.Body.(*bgp.BGPUpdate) - table.UpdatePathAttrs4ByteAs(body) - path := table.ProcessMessage(updateMsg, peer)[0] + UpdatePathAttrs4ByteAs(body) + path := ProcessMessage(updateMsg, peer)[0] // create policy ps := createPrefixSet("ps1", "10.10.0.0/16", "21..24") |