From 2b3a355b972f27eebb34c5c2e271e67f369dfd1f Mon Sep 17 00:00:00 2001
From: Christoph Petrausch <christoph.petrausch@inovex.de>
Date: Mon, 28 May 2018 12:33:35 +0200
Subject: [PATCH] Return early if route is not present. We do not need to
 update any clients or select new best paths

---
 routingtable/locRIB/loc_rib.go      |  2 ++
 routingtable/locRIB/loc_rib_test.go | 11 +++++++++++
 2 files changed, 13 insertions(+)

diff --git a/routingtable/locRIB/loc_rib.go b/routingtable/locRIB/loc_rib.go
index 584954a9..a1701743 100644
--- a/routingtable/locRIB/loc_rib.go
+++ b/routingtable/locRIB/loc_rib.go
@@ -74,6 +74,8 @@ func (a *LocRIB) RemovePath(pfx net.Prefix, p *route.Path) bool {
 	r := a.rt.Get(pfx)
 	if r != nil {
 		oldRoute = r.Copy()
+	} else {
+		return true
 	}
 
 	a.rt.RemovePath(pfx, p)
diff --git a/routingtable/locRIB/loc_rib_test.go b/routingtable/locRIB/loc_rib_test.go
index 6493991c..ea4d9c6c 100644
--- a/routingtable/locRIB/loc_rib_test.go
+++ b/routingtable/locRIB/loc_rib_test.go
@@ -84,3 +84,14 @@ func TestContainsPfxPath(t *testing.T) {
 		assert.Equal(t, tc.expected, contains, "mismatch in testcase %v", i)
 	}
 }
+
+func TestLocRIB_RemovePathUnknown(t *testing.T) {
+	rib := New()
+	assert.True(t, rib.RemovePath(net.NewPfx(1, 32),
+		&route.Path{
+			Type: route.StaticPathType,
+			StaticPath: &route.StaticPath{
+				NextHop: 2,
+			},
+		}))
+}
-- 
GitLab