summaryrefslogtreecommitdiffhomepage
path: root/pkg/server/server.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@gmail.com>2018-12-22 16:33:37 +0900
committerFUJITA Tomonori <fujita.tomonori@gmail.com>2018-12-23 19:29:23 +0900
commitababf3068c48d665e2d9d7816cbb521c74fc47c5 (patch)
tree2fc2f54823294768e88ca94eb7bdc4fb74da9259 /pkg/server/server.go
parent5d008d7b7c22cab84d974cfb7a90a002b391538a (diff)
make Add/Delete/ListPath APIs symmetric
- AddPath() with an api.Path object then DeletePath() works with the same api.Path object. - ListPath() returns an api.Path object then DeletePath() works with the same api.Path object. The above is guaranteed with and without PeerInfo (SourceAsn and SourceId). Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Diffstat (limited to 'pkg/server/server.go')
-rw-r--r--pkg/server/server.go18
1 files changed, 4 insertions, 14 deletions
diff --git a/pkg/server/server.go b/pkg/server/server.go
index f7a09daf..9269bbd4 100644
--- a/pkg/server/server.go
+++ b/pkg/server/server.go
@@ -1769,11 +1769,6 @@ func getMacMobilityExtendedCommunity(etag uint32, mac net.HardwareAddr, evpnPath
}
func (s *BgpServer) fixupApiPath(vrfId string, pathList []*table.Path) error {
- pi := &table.PeerInfo{
- AS: s.bgpConfig.Global.Config.As,
- LocalID: net.ParseIP(s.bgpConfig.Global.Config.RouterId).To4(),
- }
-
for _, path := range pathList {
if !path.IsWithdraw {
if _, err := path.GetOrigin(); err != nil {
@@ -1781,10 +1776,6 @@ func (s *BgpServer) fixupApiPath(vrfId string, pathList []*table.Path) error {
}
}
- if path.GetSource() == nil {
- path.SetSource(pi)
- }
-
if vrfId != "" {
vrf := s.globalRib.Vrfs[vrfId]
if vrf == nil {
@@ -1854,15 +1845,14 @@ 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 {
- pathList, err := api2PathList(r.Resource, []*api.Path{r.Path})
+ path, err := api2Path(r.Resource, r.Path, false)
if err != nil {
return err
}
- err = s.addPathList(r.VrfId, pathList)
+ err = s.addPathList(r.VrfId, []*table.Path{path})
if err != nil {
return err
}
- path := pathList[0]
id, _ := uuid.NewV4()
s.uuidMap[id] = pathTokey(path)
uuidBytes = id.Bytes()
@@ -1877,8 +1867,8 @@ func (s *BgpServer) DeletePath(ctx context.Context, r *api.DeletePathRequest) er
pathList, err := func() ([]*table.Path, error) {
if r.Path != nil {
- r.Path.IsWithdraw = true
- return api2PathList(r.Resource, []*api.Path{r.Path})
+ path, err := api2Path(r.Resource, r.Path, true)
+ return []*table.Path{path}, err
}
return []*table.Path{}, nil
}()