summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2018-01-24 14:31:52 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2018-01-26 16:52:35 +0900
commit38223f2f512cce3d05c9ae8f29ade983aa723cef (patch)
tree0aad4f9f35561cae93b29b5f49377786e2133a9c
parente36879ff7b8d9f42491766951cdff91b7f3812fd (diff)
server: Avoid to delete received paths with DeletePath API
"cli-command-syntax.md" describes "rib del all" command should delete all locally generated paths, but currently this command deletes all paths including received path from neighbors unexpectedly. This patch fixes the DeletePath API to delete only locally generated paths and solves this problem. Current: $ gobgp global rib -a ipv4 Network Next Hop AS_PATH Age Attrs *> 10.12.1.0/24 0.0.0.0 00:00:00 [{Origin: ?}] * 10.12.1.0/24 10.0.0.1 65001 00:00:00 [{Origin: ?}] $ gobgp global rib -a ipv4 del all $ gobgp global rib -a ipv4 Network not in table With this patch: $ gobgp global rib -a ipv4 Network Next Hop AS_PATH Age Attrs *> 10.12.1.0/24 0.0.0.0 00:00:00 [{Origin: ?}] * 10.12.1.0/24 10.0.0.1 65001 00:00:00 [{Origin: ?}] $ gobgp global rib -a ipv4 del all $ gobgp global rib -a ipv4 Network Next Hop AS_PATH Age Attrs *> 10.12.1.0/24 10.0.0.1 65001 00:00:10 [{Origin: ?}] Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
-rw-r--r--server/server.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/server/server.go b/server/server.go
index 2b32e1ce..0a39674d 100644
--- a/server/server.go
+++ b/server/server.go
@@ -1344,27 +1344,29 @@ func (s *BgpServer) DeletePath(uuid []byte, f bgp.RouteFamily, vrfId string, pat
return s.mgmtOperation(func() error {
deletePathList := make([]*table.Path, 0)
if len(uuid) > 0 {
+ // Delete locally generated path which has the given UUID
path := func() *table.Path {
for _, path := range s.globalRib.GetPathList(table.GLOBAL_RIB_NAME, s.globalRib.GetRFlist()) {
- if len(path.UUID()) > 0 && bytes.Equal(path.UUID().Bytes(), uuid) {
+ if path.IsLocal() && len(path.UUID()) > 0 && bytes.Equal(path.UUID().Bytes(), uuid) {
return path
}
}
return nil
}()
- if path != nil {
- deletePathList = append(deletePathList, path.Clone(true))
- } else {
+ if path == nil {
return fmt.Errorf("Can't find a specified path")
}
+ deletePathList = append(deletePathList, path.Clone(true))
} else if len(pathList) == 0 {
- // delete all paths
+ // Delete all locally generated paths
families := s.globalRib.GetRFlist()
if f != 0 {
families = []bgp.RouteFamily{f}
}
for _, path := range s.globalRib.GetPathList(table.GLOBAL_RIB_NAME, families) {
- deletePathList = append(deletePathList, path.Clone(true))
+ if path.IsLocal() {
+ deletePathList = append(deletePathList, path.Clone(true))
+ }
}
} else {
if err := s.fixupApiPath(vrfId, pathList); err != nil {