diff options
Diffstat (limited to 'pkg/server')
-rw-r--r-- | pkg/server/grpc_server.go | 74 | ||||
-rw-r--r-- | pkg/server/server.go | 80 | ||||
-rw-r--r-- | pkg/server/server_test.go | 48 |
3 files changed, 101 insertions, 101 deletions
diff --git a/pkg/server/grpc_server.go b/pkg/server/grpc_server.go index fdbcb3d6..ccdaa51c 100644 --- a/pkg/server/grpc_server.go +++ b/pkg/server/grpc_server.go @@ -239,7 +239,7 @@ func newRoutingPolicyFromApiStruct(arg *api.SetPoliciesRequest) (*config.Routing }, nil } -func api2Path(resource api.Resource, path *api.Path, isWithdraw bool) (*table.Path, error) { +func api2Path(resource api.TableType, path *api.Path, isWithdraw bool) (*table.Path, error) { var pi *table.PeerInfo var nlri bgp.AddrPrefixInterface var nexthop string @@ -289,7 +289,7 @@ func api2Path(resource api.Resource, path *api.Path, isWithdraw bool) (*table.Pa return nil, fmt.Errorf("nexthop not found") } rf := bgp.AfiSafiToRouteFamily(uint16(path.Family.Afi), uint8(path.Family.Safi)) - if resource != api.Resource_VRF && rf == bgp.RF_IPv4_UC && net.ParseIP(nexthop).To4() != nil { + if resource != api.TableType_VRF && rf == bgp.RF_IPv4_UC && net.ParseIP(nexthop).To4() != nil { pattrs = append(pattrs, bgp.NewPathAttributeNextHop(nexthop)) } else { pattrs = append(pattrs, bgp.NewPathAttributeMpReachNLRI(nexthop, []bgp.AddrPrefixInterface{nlri})) @@ -337,12 +337,12 @@ func (s *server) AddPathStream(stream api.GobgpApi_AddPathStreamServer) error { return err } - if arg.Resource != api.Resource_GLOBAL && arg.Resource != api.Resource_VRF { - return fmt.Errorf("unsupported resource: %s", arg.Resource) + if arg.TableType != api.TableType_GLOBAL && arg.TableType != api.TableType_VRF { + return fmt.Errorf("unsupported resource: %s", arg.TableType) } pathList := make([]*table.Path, 0, len(arg.Paths)) for _, apiPath := range arg.Paths { - if path, err := api2Path(arg.Resource, apiPath, apiPath.IsWithdraw); err != nil { + if path, err := api2Path(arg.TableType, apiPath, apiPath.IsWithdraw); err != nil { return err } else { pathList = append(pathList, path) @@ -826,7 +826,7 @@ func newConfigDefinedSetsFromApiStruct(a []*api.DefinedSet) (*config.DefinedSets if ds.Name == "" { return nil, fmt.Errorf("empty neighbor set name") } - switch table.DefinedType(ds.Type) { + switch table.DefinedType(ds.DefinedType) { case table.DEFINED_TYPE_PREFIX: prefixes := make([]config.Prefix, 0, len(ds.Prefixes)) for _, p := range ds.Prefixes { @@ -886,7 +886,7 @@ func newDefinedSetFromApiStruct(a *api.DefinedSet) (table.DefinedSet, error) { if a.Name == "" { return nil, fmt.Errorf("empty neighbor set name") } - switch table.DefinedType(a.Type) { + switch table.DefinedType(a.DefinedType) { case table.DEFINED_TYPE_PREFIX: prefixes := make([]*table.Prefix, 0, len(a.Prefixes)) for _, p := range a.Prefixes { @@ -970,44 +970,44 @@ func toStatementApi(s *config.Statement) *api.Statement { cs := &api.Conditions{} if s.Conditions.MatchPrefixSet.PrefixSet != "" { cs.PrefixSet = &api.MatchSet{ - Type: matchSetOptionsRestrictedTypeToAPI(s.Conditions.MatchPrefixSet.MatchSetOptions), - Name: s.Conditions.MatchPrefixSet.PrefixSet, + MatchType: matchSetOptionsRestrictedTypeToAPI(s.Conditions.MatchPrefixSet.MatchSetOptions), + Name: s.Conditions.MatchPrefixSet.PrefixSet, } } if s.Conditions.MatchNeighborSet.NeighborSet != "" { cs.NeighborSet = &api.MatchSet{ - Type: matchSetOptionsRestrictedTypeToAPI(s.Conditions.MatchNeighborSet.MatchSetOptions), - Name: s.Conditions.MatchNeighborSet.NeighborSet, + MatchType: matchSetOptionsRestrictedTypeToAPI(s.Conditions.MatchNeighborSet.MatchSetOptions), + Name: s.Conditions.MatchNeighborSet.NeighborSet, } } if s.Conditions.BgpConditions.AsPathLength.Operator != "" { cs.AsPathLength = &api.AsPathLength{ - Length: s.Conditions.BgpConditions.AsPathLength.Value, - Type: api.AsPathLengthType(s.Conditions.BgpConditions.AsPathLength.Operator.ToInt()), + Length: s.Conditions.BgpConditions.AsPathLength.Value, + LengthType: api.AsPathLengthType(s.Conditions.BgpConditions.AsPathLength.Operator.ToInt()), } } if s.Conditions.BgpConditions.MatchAsPathSet.AsPathSet != "" { cs.AsPathSet = &api.MatchSet{ - Type: api.MatchType(s.Conditions.BgpConditions.MatchAsPathSet.MatchSetOptions.ToInt()), - Name: s.Conditions.BgpConditions.MatchAsPathSet.AsPathSet, + MatchType: api.MatchType(s.Conditions.BgpConditions.MatchAsPathSet.MatchSetOptions.ToInt()), + Name: s.Conditions.BgpConditions.MatchAsPathSet.AsPathSet, } } if s.Conditions.BgpConditions.MatchCommunitySet.CommunitySet != "" { cs.CommunitySet = &api.MatchSet{ - Type: api.MatchType(s.Conditions.BgpConditions.MatchCommunitySet.MatchSetOptions.ToInt()), - Name: s.Conditions.BgpConditions.MatchCommunitySet.CommunitySet, + MatchType: api.MatchType(s.Conditions.BgpConditions.MatchCommunitySet.MatchSetOptions.ToInt()), + Name: s.Conditions.BgpConditions.MatchCommunitySet.CommunitySet, } } if s.Conditions.BgpConditions.MatchExtCommunitySet.ExtCommunitySet != "" { cs.ExtCommunitySet = &api.MatchSet{ - Type: api.MatchType(s.Conditions.BgpConditions.MatchExtCommunitySet.MatchSetOptions.ToInt()), - Name: s.Conditions.BgpConditions.MatchExtCommunitySet.ExtCommunitySet, + MatchType: api.MatchType(s.Conditions.BgpConditions.MatchExtCommunitySet.MatchSetOptions.ToInt()), + Name: s.Conditions.BgpConditions.MatchExtCommunitySet.ExtCommunitySet, } } if s.Conditions.BgpConditions.MatchLargeCommunitySet.LargeCommunitySet != "" { cs.LargeCommunitySet = &api.MatchSet{ - Type: api.MatchType(s.Conditions.BgpConditions.MatchLargeCommunitySet.MatchSetOptions.ToInt()), - Name: s.Conditions.BgpConditions.MatchLargeCommunitySet.LargeCommunitySet, + MatchType: api.MatchType(s.Conditions.BgpConditions.MatchLargeCommunitySet.MatchSetOptions.ToInt()), + Name: s.Conditions.BgpConditions.MatchLargeCommunitySet.LargeCommunitySet, } } if s.Conditions.BgpConditions.RouteType != "" { @@ -1042,7 +1042,7 @@ func toStatementApi(s *config.Statement) *api.Statement { return nil } return &api.CommunityAction{ - Type: api.CommunityActionType(config.BgpSetCommunityOptionTypeToIntMap[config.BgpSetCommunityOptionType(s.Actions.BgpActions.SetCommunity.Options)]), + ActionType: api.CommunityActionType(config.BgpSetCommunityOptionTypeToIntMap[config.BgpSetCommunityOptionType(s.Actions.BgpActions.SetCommunity.Options)]), Communities: s.Actions.BgpActions.SetCommunity.SetCommunityMethod.CommunitiesList} }(), Med: func() *api.MedAction { @@ -1064,8 +1064,8 @@ func toStatementApi(s *config.Statement) *api.Statement { return nil } return &api.MedAction{ - Value: value, - Type: action, + Value: value, + ActionType: action, } }(), AsPrepend: func() *api.AsPrependAction { @@ -1090,7 +1090,7 @@ func toStatementApi(s *config.Statement) *api.Statement { return nil } return &api.CommunityAction{ - Type: api.CommunityActionType(config.BgpSetCommunityOptionTypeToIntMap[config.BgpSetCommunityOptionType(s.Actions.BgpActions.SetExtCommunity.Options)]), + ActionType: api.CommunityActionType(config.BgpSetCommunityOptionTypeToIntMap[config.BgpSetCommunityOptionType(s.Actions.BgpActions.SetExtCommunity.Options)]), Communities: s.Actions.BgpActions.SetExtCommunity.SetExtCommunityMethod.CommunitiesList, } }(), @@ -1099,7 +1099,7 @@ func toStatementApi(s *config.Statement) *api.Statement { return nil } return &api.CommunityAction{ - Type: api.CommunityActionType(config.BgpSetCommunityOptionTypeToIntMap[config.BgpSetCommunityOptionType(s.Actions.BgpActions.SetLargeCommunity.Options)]), + ActionType: api.CommunityActionType(config.BgpSetCommunityOptionTypeToIntMap[config.BgpSetCommunityOptionType(s.Actions.BgpActions.SetLargeCommunity.Options)]), Communities: s.Actions.BgpActions.SetLargeCommunity.SetLargeCommunityMethod.CommunitiesList, } }(), @@ -1163,7 +1163,7 @@ func newPrefixConditionFromApiStruct(a *api.MatchSet) (*table.PrefixCondition, e if a == nil { return nil, nil } - typ, err := toConfigMatchSetOptionRestricted(a.Type) + typ, err := toConfigMatchSetOptionRestricted(a.MatchType) if err != nil { return nil, err } @@ -1178,7 +1178,7 @@ func newNeighborConditionFromApiStruct(a *api.MatchSet) (*table.NeighborConditio if a == nil { return nil, nil } - typ, err := toConfigMatchSetOptionRestricted(a.Type) + typ, err := toConfigMatchSetOptionRestricted(a.MatchType) if err != nil { return nil, err } @@ -1194,7 +1194,7 @@ func newAsPathLengthConditionFromApiStruct(a *api.AsPathLength) (*table.AsPathLe return nil, nil } return table.NewAsPathLengthCondition(config.AsPathLength{ - Operator: config.IntToAttributeComparisonMap[int(a.Type)], + Operator: config.IntToAttributeComparisonMap[int(a.LengthType)], Value: a.Length, }) } @@ -1203,7 +1203,7 @@ func newAsPathConditionFromApiStruct(a *api.MatchSet) (*table.AsPathCondition, e if a == nil { return nil, nil } - typ, err := toConfigMatchSetOption(a.Type) + typ, err := toConfigMatchSetOption(a.MatchType) if err != nil { return nil, err } @@ -1236,7 +1236,7 @@ func newCommunityConditionFromApiStruct(a *api.MatchSet) (*table.CommunityCondit if a == nil { return nil, nil } - typ, err := toConfigMatchSetOption(a.Type) + typ, err := toConfigMatchSetOption(a.MatchType) if err != nil { return nil, err } @@ -1251,7 +1251,7 @@ func newExtCommunityConditionFromApiStruct(a *api.MatchSet) (*table.ExtCommunity if a == nil { return nil, nil } - typ, err := toConfigMatchSetOption(a.Type) + typ, err := toConfigMatchSetOption(a.MatchType) if err != nil { return nil, err } @@ -1266,7 +1266,7 @@ func newLargeCommunityConditionFromApiStruct(a *api.MatchSet) (*table.LargeCommu if a == nil { return nil, nil } - typ, err := toConfigMatchSetOption(a.Type) + typ, err := toConfigMatchSetOption(a.MatchType) if err != nil { return nil, err } @@ -1319,7 +1319,7 @@ func newCommunityActionFromApiStruct(a *api.CommunityAction) (*table.CommunityAc return nil, nil } return table.NewCommunityAction(config.SetCommunity{ - Options: string(config.IntToBgpSetCommunityOptionTypeMap[int(a.Type)]), + Options: string(config.IntToBgpSetCommunityOptionTypeMap[int(a.ActionType)]), SetCommunityMethod: config.SetCommunityMethod{ CommunitiesList: a.Communities, }, @@ -1331,7 +1331,7 @@ func newExtCommunityActionFromApiStruct(a *api.CommunityAction) (*table.ExtCommu return nil, nil } return table.NewExtCommunityAction(config.SetExtCommunity{ - Options: string(config.IntToBgpSetCommunityOptionTypeMap[int(a.Type)]), + Options: string(config.IntToBgpSetCommunityOptionTypeMap[int(a.ActionType)]), SetExtCommunityMethod: config.SetExtCommunityMethod{ CommunitiesList: a.Communities, }, @@ -1343,7 +1343,7 @@ func newLargeCommunityActionFromApiStruct(a *api.CommunityAction) (*table.LargeC return nil, nil } return table.NewLargeCommunityAction(config.SetLargeCommunity{ - Options: config.IntToBgpSetCommunityOptionTypeMap[int(a.Type)], + Options: config.IntToBgpSetCommunityOptionTypeMap[int(a.ActionType)], SetLargeCommunityMethod: config.SetLargeCommunityMethod{ CommunitiesList: a.Communities, }, @@ -1354,7 +1354,7 @@ func newMedActionFromApiStruct(a *api.MedAction) (*table.MedAction, error) { if a == nil { return nil, nil } - return table.NewMedActionFromApiStruct(table.MedActionType(a.Type), a.Value), nil + return table.NewMedActionFromApiStruct(table.MedActionType(a.ActionType), a.Value), nil } func newLocalPrefActionFromApiStruct(a *api.LocalPrefAction) (*table.LocalPrefAction, error) { diff --git a/pkg/server/server.go b/pkg/server/server.go index 9269bbd4..728214f5 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -1584,14 +1584,14 @@ func (s *BgpServer) EnableZebra(ctx context.Context, r *api.EnableZebraRequest) func (s *BgpServer) AddBmp(ctx context.Context, r *api.AddBmpRequest) error { return s.mgmtOperation(func() error { - _, ok := api.AddBmpRequest_MonitoringPolicy_name[int32(r.Type)] + _, ok := api.AddBmpRequest_MonitoringPolicy_name[int32(r.Policy)] if !ok { - return fmt.Errorf("invalid bmp route monitoring policy: %v", r.Type) + return fmt.Errorf("invalid bmp route monitoring policy: %v", r.Policy) } return s.bmpManager.addServer(&config.BmpServerConfig{ Address: r.Address, Port: r.Port, - RouteMonitoringPolicy: config.IntToBmpRouteMonitoringPolicyTypeMap[int(r.Type)], + RouteMonitoringPolicy: config.IntToBmpRouteMonitoringPolicyTypeMap[int(r.Policy)], StatisticsTimeout: uint16(r.StatisticsTimeout), }) }, true) @@ -1845,7 +1845,7 @@ func (s *BgpServer) addPathList(vrfId string, pathList []*table.Path) error { func (s *BgpServer) AddPath(ctx context.Context, r *api.AddPathRequest) (*api.AddPathResponse, error) { var uuidBytes []byte err := s.mgmtOperation(func() error { - path, err := api2Path(r.Resource, r.Path, false) + path, err := api2Path(r.TableType, r.Path, false) if err != nil { return err } @@ -1867,7 +1867,7 @@ func (s *BgpServer) DeletePath(ctx context.Context, r *api.DeletePathRequest) er pathList, err := func() ([]*table.Path, error) { if r.Path != nil { - path, err := api2Path(r.Resource, r.Path, true) + path, err := api2Path(r.TableType, r.Path, true) return []*table.Path{path}, err } return []*table.Path{}, nil @@ -2330,18 +2330,18 @@ func (s *BgpServer) ListPath(ctx context.Context, r *api.ListPathRequest, fn fun family = bgp.AfiSafiToRouteFamily(uint16(r.Family.Afi), uint8(r.Family.Safi)) } var err error - switch r.Type { - case api.Resource_LOCAL, api.Resource_GLOBAL: + switch r.TableType { + case api.TableType_LOCAL, api.TableType_GLOBAL: tbl, v, err = s.getRib(r.Name, family, f()) - case api.Resource_ADJ_IN: + case api.TableType_ADJ_IN: in = true fallthrough - case api.Resource_ADJ_OUT: + case api.TableType_ADJ_OUT: tbl, v, err = s.getAdjRib(r.Name, family, in, f()) - case api.Resource_VRF: + case api.TableType_VRF: tbl, err = s.getVrfRib(r.Name, family, []*table.LookupPrefix{}) default: - return fmt.Errorf("unsupported resource type: %v", r.Type) + return fmt.Errorf("unsupported resource type: %v", r.TableType) } if err != nil { @@ -2359,8 +2359,8 @@ func (s *BgpServer) ListPath(ctx context.Context, r *api.ListPathRequest, fn fun p := toPathApi(path, getValidation(v, idx)) idx++ if i == 0 && !table.SelectionOptions.DisableBestPathSelection { - switch r.Type { - case api.Resource_LOCAL, api.Resource_GLOBAL: + switch r.TableType { + case api.TableType_LOCAL, api.TableType_GLOBAL: p.Best = true } } @@ -2433,16 +2433,16 @@ func (s *BgpServer) GetTable(ctx context.Context, r *api.GetTableRequest) (*api. var in bool var err error var info *table.TableInfo - switch r.Type { - case api.Resource_GLOBAL, api.Resource_LOCAL: + switch r.TableType { + case api.TableType_GLOBAL, api.TableType_LOCAL: info, err = s.getRibInfo(r.Name, family) - case api.Resource_ADJ_IN: + case api.TableType_ADJ_IN: in = true fallthrough - case api.Resource_ADJ_OUT: + case api.TableType_ADJ_OUT: info, err = s.getAdjRibInfo(r.Name, family, in) default: - return nil, fmt.Errorf("unsupported resource type: %s", r.Type) + return nil, fmt.Errorf("unsupported resource type: %s", r.TableType) } if err != nil { @@ -3014,7 +3014,7 @@ func (s *BgpServer) ListDefinedSet(ctx context.Context, r *api.ListDefinedSetReq var cd *config.DefinedSets var err error err = s.mgmtOperation(func() error { - cd, err = s.policy.GetDefinedSet(table.DefinedType(r.Type), r.Name) + cd, err = s.policy.GetDefinedSet(table.DefinedType(r.DefinedType), r.Name) return err }, false) @@ -3033,8 +3033,8 @@ func (s *BgpServer) ListDefinedSet(ctx context.Context, r *api.ListDefinedSetReq for _, cs := range cd.PrefixSets { ad := &api.DefinedSet{ - Type: api.DefinedType_PREFIX, - Name: cs.PrefixSetName, + DefinedType: api.DefinedType_PREFIX, + Name: cs.PrefixSetName, Prefixes: func() []*api.Prefix { l := make([]*api.Prefix, 0, len(cs.PrefixList)) for _, p := range cs.PrefixList { @@ -3053,9 +3053,9 @@ func (s *BgpServer) ListDefinedSet(ctx context.Context, r *api.ListDefinedSetReq } for _, cs := range cd.NeighborSets { ad := &api.DefinedSet{ - Type: api.DefinedType_NEIGHBOR, - Name: cs.NeighborSetName, - List: cs.NeighborInfoList, + DefinedType: api.DefinedType_NEIGHBOR, + Name: cs.NeighborSetName, + List: cs.NeighborInfoList, } if exec(ad) { return nil @@ -3063,9 +3063,9 @@ func (s *BgpServer) ListDefinedSet(ctx context.Context, r *api.ListDefinedSetReq } for _, cs := range cd.BgpDefinedSets.CommunitySets { ad := &api.DefinedSet{ - Type: api.DefinedType_COMMUNITY, - Name: cs.CommunitySetName, - List: cs.CommunityList, + DefinedType: api.DefinedType_COMMUNITY, + Name: cs.CommunitySetName, + List: cs.CommunityList, } if exec(ad) { return nil @@ -3073,9 +3073,9 @@ func (s *BgpServer) ListDefinedSet(ctx context.Context, r *api.ListDefinedSetReq } for _, cs := range cd.BgpDefinedSets.ExtCommunitySets { ad := &api.DefinedSet{ - Type: api.DefinedType_EXT_COMMUNITY, - Name: cs.ExtCommunitySetName, - List: cs.ExtCommunityList, + DefinedType: api.DefinedType_EXT_COMMUNITY, + Name: cs.ExtCommunitySetName, + List: cs.ExtCommunityList, } if exec(ad) { return nil @@ -3083,9 +3083,9 @@ func (s *BgpServer) ListDefinedSet(ctx context.Context, r *api.ListDefinedSetReq } for _, cs := range cd.BgpDefinedSets.LargeCommunitySets { ad := &api.DefinedSet{ - Type: api.DefinedType_LARGE_COMMUNITY, - Name: cs.LargeCommunitySetName, - List: cs.LargeCommunityList, + DefinedType: api.DefinedType_LARGE_COMMUNITY, + Name: cs.LargeCommunitySetName, + List: cs.LargeCommunityList, } if exec(ad) { return nil @@ -3093,9 +3093,9 @@ func (s *BgpServer) ListDefinedSet(ctx context.Context, r *api.ListDefinedSetReq } for _, cs := range cd.BgpDefinedSets.AsPathSets { ad := &api.DefinedSet{ - Type: api.DefinedType_AS_PATH, - Name: cs.AsPathSetName, - List: cs.AsPathList, + DefinedType: api.DefinedType_AS_PATH, + Name: cs.AsPathSetName, + List: cs.AsPathList, } if exec(ad) { return nil @@ -3486,16 +3486,16 @@ func (s *BgpServer) MonitorTable(ctx context.Context, r *api.MonitorTableRequest return fmt.Errorf("nil request") } w, err := func() (*watcher, error) { - switch r.Type { - case api.Resource_GLOBAL: + switch r.TableType { + case api.TableType_GLOBAL: return s.watch(watchBestPath(r.Current)), nil - case api.Resource_ADJ_IN: + case api.TableType_ADJ_IN: if r.PostPolicy { return s.watch(watchPostUpdate(r.Current)), nil } return s.watch(watchUpdate(r.Current)), nil default: - return nil, fmt.Errorf("unsupported resource type: %v", r.Type) + return nil, fmt.Errorf("unsupported resource type: %v", r.TableType) } }() if err != nil { diff --git a/pkg/server/server_test.go b/pkg/server/server_test.go index 984cf53a..14124c79 100644 --- a/pkg/server/server_test.go +++ b/pkg/server/server_test.go @@ -978,9 +978,9 @@ func TestDoNotReactToDuplicateRTCMemberships(t *testing.T) { path := apiutil.NewPath(prefix, false, attrs, time.Now()) if _, err := s2.AddPath(ctx, &api.AddPathRequest{ - Resource: api.Resource_VRF, - VrfId: "vrf1", - Path: path, + TableType: api.TableType_VRF, + VrfId: "vrf1", + Path: path, }); err != nil { t.Fatal(err) } @@ -1077,7 +1077,7 @@ func TestAddDeletePath(t *testing.T) { listRib := func() []*api.Destination { l := make([]*api.Destination, 0) - s.ListPath(ctx, &api.ListPathRequest{Type: api.Resource_GLOBAL, Family: family}, func(d *api.Destination) { l = append(l, d) }) + s.ListPath(ctx, &api.ListPathRequest{TableType: api.TableType_GLOBAL, Family: family}, func(d *api.Destination) { l = append(l, d) }) return l } @@ -1093,29 +1093,29 @@ func TestAddDeletePath(t *testing.T) { p1 := getPath() _, err = s.AddPath(ctx, &api.AddPathRequest{ - Resource: api.Resource_GLOBAL, - Path: p1, + TableType: api.TableType_GLOBAL, + Path: p1, }) assert.Nil(t, err) assert.Equal(t, len(listRib()), 1) err = s.DeletePath(ctx, &api.DeletePathRequest{ - Resource: api.Resource_GLOBAL, - Path: p1, + TableType: api.TableType_GLOBAL, + Path: p1, }) assert.Nil(t, err) assert.Equal(t, len(listRib()), 0) // DeletePath(ListPath()) without PeerInfo _, err = s.AddPath(ctx, &api.AddPathRequest{ - Resource: api.Resource_GLOBAL, - Path: p1, + TableType: api.TableType_GLOBAL, + Path: p1, }) assert.Nil(t, err) l := listRib() assert.Equal(t, len(l), 1) err = s.DeletePath(ctx, &api.DeletePathRequest{ - Resource: api.Resource_GLOBAL, - Path: l[0].Paths[0], + TableType: api.TableType_GLOBAL, + Path: l[0].Paths[0], }) assert.Nil(t, err) assert.Equal(t, len(listRib()), 0) @@ -1126,37 +1126,37 @@ func TestAddDeletePath(t *testing.T) { // DeletePath(AddPath()) with PeerInfo _, err = s.AddPath(ctx, &api.AddPathRequest{ - Resource: api.Resource_GLOBAL, - Path: p2, + TableType: api.TableType_GLOBAL, + Path: p2, }) assert.Nil(t, err) assert.Equal(t, len(listRib()), 1) err = s.DeletePath(ctx, &api.DeletePathRequest{ - Resource: api.Resource_GLOBAL, - Path: p2, + TableType: api.TableType_GLOBAL, + Path: p2, }) assert.Nil(t, err) assert.Equal(t, len(listRib()), 0) // DeletePath(ListPath()) with PeerInfo _, err = s.AddPath(ctx, &api.AddPathRequest{ - Resource: api.Resource_GLOBAL, - Path: p2, + TableType: api.TableType_GLOBAL, + Path: p2, }) assert.Nil(t, err) l = listRib() assert.Equal(t, len(l), 1) err = s.DeletePath(ctx, &api.DeletePathRequest{ - Resource: api.Resource_GLOBAL, - Path: l[0].Paths[0], + TableType: api.TableType_GLOBAL, + Path: l[0].Paths[0], }) assert.Nil(t, err) assert.Equal(t, len(listRib()), 0) // DeletePath(AddPath()) with different PeerInfo _, err = s.AddPath(ctx, &api.AddPathRequest{ - Resource: api.Resource_GLOBAL, - Path: p2, + TableType: api.TableType_GLOBAL, + Path: p2, }) assert.Nil(t, err) assert.Equal(t, len(listRib()), 1) @@ -1164,8 +1164,8 @@ func TestAddDeletePath(t *testing.T) { p3.SourceAsn = 2 p3.SourceId = "1.1.1.2" err = s.DeletePath(ctx, &api.DeletePathRequest{ - Resource: api.Resource_GLOBAL, - Path: p3, + TableType: api.TableType_GLOBAL, + Path: p3, }) assert.Nil(t, err) assert.Equal(t, len(listRib()), 1) |