summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/peer.go12
-rw-r--r--table/path.go10
-rw-r--r--table/path_test.go4
-rw-r--r--table/table_manager.go6
-rw-r--r--table/table_manager_test.go48
5 files changed, 45 insertions, 35 deletions
diff --git a/server/peer.go b/server/peer.go
index 4160ba6e..d76dd088 100644
--- a/server/peer.go
+++ b/server/peer.go
@@ -320,7 +320,17 @@ func (peer *Peer) sendUpdateMsgFromPaths(pList []table.Path) {
peer.adjRib.UpdateOut(pList)
sendpathList := []table.Path{}
for _, p := range pList {
- if _, ok := peer.rfMap[p.GetRouteFamily()]; ok {
+ _, ok := peer.rfMap[p.GetRouteFamily()]
+
+ if peer.peerConfig.NeighborAddress.Equal(p.GetNexthop()) {
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ "Key": peer.peerConfig.NeighborAddress,
+ }).Debugf("From me. Ignore: %s", p)
+ ok = false
+ }
+
+ if ok {
sendpathList = append(sendpathList, p)
}
}
diff --git a/table/path.go b/table/path.go
index 634eda39..5ff4ca2a 100644
--- a/table/path.go
+++ b/table/path.go
@@ -35,7 +35,7 @@ type Path interface {
setSource(source *PeerInfo)
getSource() *PeerInfo
setNexthop(nexthop net.IP)
- getNexthop() net.IP
+ GetNexthop() net.IP
setWithdraw(withdraw bool)
IsWithdraw() bool
getNlri() bgp.AddrPrefixInterface
@@ -225,7 +225,7 @@ func (pd *PathDefault) setNexthop(nexthop net.IP) {
pd.nexthop = nexthop
}
-func (pd *PathDefault) getNexthop() net.IP {
+func (pd *PathDefault) GetNexthop() net.IP {
return pd.nexthop
}
@@ -284,7 +284,7 @@ func (pd *PathDefault) getPathAttr(pattrType bgp.BGPAttrType) (int, bgp.PathAttr
func (pi *PathDefault) String() string {
str := fmt.Sprintf("IPv4Path Source: %v, ", pi.getSource())
str = str + fmt.Sprintf(" NLRI: %s, ", pi.getPrefix())
- str = str + fmt.Sprintf(" nexthop: %s, ", pi.getNexthop().String())
+ str = str + fmt.Sprintf(" nexthop: %s, ", pi.GetNexthop().String())
str = str + fmt.Sprintf(" withdraw: %s, ", pi.IsWithdraw())
//str = str + fmt.Sprintf(" path attributes: %s, ", pi.getPathAttributeMap())
return str
@@ -382,7 +382,7 @@ func (ipv6p *IPv6Path) getPrefix() string {
func (ipv6p *IPv6Path) String() string {
str := fmt.Sprintf("IPv6Path Source: %v, ", ipv6p.getSource())
str = str + fmt.Sprintf(" NLRI: %s, ", ipv6p.getPrefix())
- str = str + fmt.Sprintf(" nexthop: %s, ", ipv6p.getNexthop().String())
+ str = str + fmt.Sprintf(" nexthop: %s, ", ipv6p.GetNexthop().String())
str = str + fmt.Sprintf(" withdraw: %s, ", ipv6p.IsWithdraw())
//str = str + fmt.Sprintf(" path attributes: %s, ", ipv6p.getPathAttributeMap())
return str
@@ -447,7 +447,7 @@ func (ipv4vpnp *IPv4VPNPath) getPrefix() string {
func (ipv4vpnp *IPv4VPNPath) String() string {
str := fmt.Sprintf("IPv4VPNPath Source: %v, ", ipv4vpnp.getSource())
str = str + fmt.Sprintf(" NLRI: %s, ", ipv4vpnp.getPrefix())
- str = str + fmt.Sprintf(" nexthop: %s, ", ipv4vpnp.getNexthop().String())
+ str = str + fmt.Sprintf(" nexthop: %s, ", ipv4vpnp.GetNexthop().String())
str = str + fmt.Sprintf(" withdraw: %s, ", ipv4vpnp.IsWithdraw())
//str = str + fmt.Sprintf(" path attributes: %s, ", ipv4vpnp.getPathAttributeMap())
return str
diff --git a/table/path_test.go b/table/path_test.go
index fe80b3d7..2dc0c3de 100644
--- a/table/path_test.go
+++ b/table/path_test.go
@@ -83,7 +83,7 @@ func TestPathSetNexthop(t *testing.T) {
pd := &PathDefault{}
ip := net.ParseIP("192.168.0.1")
pd.setNexthop(ip)
- nh := pd.getNexthop()
+ nh := pd.GetNexthop()
assert.Equal(t, nh, ip)
}
@@ -91,7 +91,7 @@ func TestPathgetNexthop(t *testing.T) {
pd := &PathDefault{}
ip := net.ParseIP("192.168.0.2")
pd.setNexthop(ip)
- nh := pd.getNexthop()
+ nh := pd.GetNexthop()
assert.Equal(t, nh, ip)
}
diff --git a/table/table_manager.go b/table/table_manager.go
index d34e3780..23c233b1 100644
--- a/table/table_manager.go
+++ b/table/table_manager.go
@@ -175,7 +175,7 @@ func (manager *TableManager) calculate(destinationList []Destination) ([]Path, e
"Owner": manager.owner,
"Key": destination.getNlri().String(),
"peer": newBestPath.getSource().Address,
- "next_hop": newBestPath.getNexthop().String(),
+ "next_hop": newBestPath.GetNexthop().String(),
"reason": reason,
}).Debug("best path is not changed")
continue
@@ -196,7 +196,7 @@ func (manager *TableManager) calculate(destinationList []Destination) ([]Path, e
"Owner": manager.owner,
"Key": destination.getNlri().String(),
"peer": currentBestPath.getSource().Address,
- "next_hop": currentBestPath.getNexthop().String(),
+ "next_hop": currentBestPath.GetNexthop().String(),
}).Debug("best path is lost")
p := destination.getBestPath()
@@ -218,7 +218,7 @@ func (manager *TableManager) calculate(destinationList []Destination) ([]Path, e
"Owner": manager.owner,
"Key": newBestPath.getNlri().String(),
"peer": newBestPath.getSource().Address,
- "next_hop": newBestPath.getNexthop(),
+ "next_hop": newBestPath.GetNexthop(),
"reason": reason,
}).Debug("new best path")
diff --git a/table/table_manager_test.go b/table/table_manager_test.go
index 5d3ed1b8..8e800c8c 100644
--- a/table/table_manager_test.go
+++ b/table/table_manager_test.go
@@ -111,7 +111,7 @@ func TestProcessBGPUpdate_0_select_onlypath_ipv4(t *testing.T) {
assert.Equal(t, expectedPrefix, path.getPrefix())
// check nexthop
expectedNexthop := "192.168.50.1"
- assert.Equal(t, expectedNexthop, path.getNexthop().String())
+ assert.Equal(t, expectedNexthop, path.GetNexthop().String())
}
@@ -163,7 +163,7 @@ func TestProcessBGPUpdate_0_select_onlypath_ipv6(t *testing.T) {
assert.Equal(t, expectedPrefix, path.getPrefix())
// check nexthop
expectedNexthop := "2001::192:168:50:1"
- assert.Equal(t, expectedNexthop, path.getNexthop().String())
+ assert.Equal(t, expectedNexthop, path.GetNexthop().String())
}
@@ -248,7 +248,7 @@ func TestProcessBGPUpdate_1_select_high_localpref_ipv4(t *testing.T) {
assert.Equal(t, expectedPrefix, path.getPrefix())
// check nexthop
expectedNexthop := "192.168.50.1"
- assert.Equal(t, expectedNexthop, path.getNexthop().String())
+ assert.Equal(t, expectedNexthop, path.GetNexthop().String())
}
@@ -335,7 +335,7 @@ func TestProcessBGPUpdate_1_select_high_localpref_ipv6(t *testing.T) {
assert.Equal(t, expectedPrefix, path.getPrefix())
// check nexthop
expectedNexthop := "2001::192:168:100:1"
- assert.Equal(t, expectedNexthop, path.getNexthop().String())
+ assert.Equal(t, expectedNexthop, path.GetNexthop().String())
}
@@ -422,7 +422,7 @@ func TestProcessBGPUpdate_2_select_local_origin_ipv4(t *testing.T) {
assert.Equal(t, expectedPrefix, path.getPrefix())
// check nexthop
expectedNexthop := "0.0.0.0"
- assert.Equal(t, expectedNexthop, path.getNexthop().String())
+ assert.Equal(t, expectedNexthop, path.GetNexthop().String())
}
@@ -512,7 +512,7 @@ func TestProcessBGPUpdate_2_select_local_origin_ipv6(t *testing.T) {
assert.Equal(t, expectedPrefix, path.getPrefix())
// check nexthop
expectedNexthop := "::"
- assert.Equal(t, expectedNexthop, path.getNexthop().String())
+ assert.Equal(t, expectedNexthop, path.GetNexthop().String())
}
@@ -570,7 +570,7 @@ func TestProcessBGPUpdate_3_select_aspath_ipv4(t *testing.T) {
assert.Equal(t, expectedPrefix, path.getPrefix())
// check nexthop
expectedNexthop := "192.168.100.1"
- assert.Equal(t, expectedNexthop, path.getNexthop().String())
+ assert.Equal(t, expectedNexthop, path.GetNexthop().String())
}
@@ -628,7 +628,7 @@ func TestProcessBGPUpdate_3_select_aspath_ipv6(t *testing.T) {
assert.Equal(t, expectedPrefix, path.getPrefix())
// check nexthop
expectedNexthop := "2001::192:168:100:1"
- assert.Equal(t, expectedNexthop, path.getNexthop().String())
+ assert.Equal(t, expectedNexthop, path.GetNexthop().String())
}
@@ -713,7 +713,7 @@ func TestProcessBGPUpdate_4_select_low_origin_ipv4(t *testing.T) {
assert.Equal(t, expectedPrefix, path.getPrefix())
// check nexthop
expectedNexthop := "192.168.100.1"
- assert.Equal(t, expectedNexthop, path.getNexthop().String())
+ assert.Equal(t, expectedNexthop, path.GetNexthop().String())
}
@@ -800,7 +800,7 @@ func TestProcessBGPUpdate_4_select_low_origin_ipv6(t *testing.T) {
assert.Equal(t, expectedPrefix, path.getPrefix())
// check nexthop
expectedNexthop := "2001::192:168:100:1"
- assert.Equal(t, expectedNexthop, path.getNexthop().String())
+ assert.Equal(t, expectedNexthop, path.GetNexthop().String())
}
@@ -885,7 +885,7 @@ func TestProcessBGPUpdate_5_select_low_med_ipv4(t *testing.T) {
assert.Equal(t, expectedPrefix, path.getPrefix())
// check nexthop
expectedNexthop := "192.168.100.1"
- assert.Equal(t, expectedNexthop, path.getNexthop().String())
+ assert.Equal(t, expectedNexthop, path.GetNexthop().String())
}
@@ -972,7 +972,7 @@ func TestProcessBGPUpdate_5_select_low_med_ipv6(t *testing.T) {
assert.Equal(t, expectedPrefix, path.getPrefix())
// check nexthop
expectedNexthop := "2001::192:168:100:1"
- assert.Equal(t, expectedNexthop, path.getNexthop().String())
+ assert.Equal(t, expectedNexthop, path.GetNexthop().String())
}
@@ -1059,7 +1059,7 @@ func TestProcessBGPUpdate_6_select_ebgp_path_ipv4(t *testing.T) {
assert.Equal(t, expectedPrefix, path.getPrefix())
// check nexthop
expectedNexthop := "192.168.100.1"
- assert.Equal(t, expectedNexthop, path.getNexthop().String())
+ assert.Equal(t, expectedNexthop, path.GetNexthop().String())
}
@@ -1147,7 +1147,7 @@ func TestProcessBGPUpdate_6_select_ebgp_path_ipv6(t *testing.T) {
assert.Equal(t, expectedPrefix, path.getPrefix())
// check nexthop
expectedNexthop := "2001::192:168:100:1"
- assert.Equal(t, expectedNexthop, path.getNexthop().String())
+ assert.Equal(t, expectedNexthop, path.GetNexthop().String())
}
@@ -1236,7 +1236,7 @@ func TestProcessBGPUpdate_7_select_low_routerid_path_ipv4(t *testing.T) {
assert.Equal(t, expectedPrefix, path.getPrefix())
// check nexthop
expectedNexthop := "192.168.100.1"
- assert.Equal(t, expectedNexthop, path.getNexthop().String())
+ assert.Equal(t, expectedNexthop, path.GetNexthop().String())
}
@@ -1324,7 +1324,7 @@ func TestProcessBGPUpdate_7_select_low_routerid_path_ipv6(t *testing.T) {
assert.Equal(t, expectedPrefix, path.getPrefix())
// check nexthop
expectedNexthop := "2001::192:168:100:1"
- assert.Equal(t, expectedNexthop, path.getNexthop().String())
+ assert.Equal(t, expectedNexthop, path.GetNexthop().String())
}
@@ -1412,7 +1412,7 @@ func TestProcessBGPUpdate_8_withdraw_path_ipv4(t *testing.T) {
assert.Equal(t, expectedPrefix, path.getPrefix())
// check nexthop
expectedNexthop := "192.168.100.1"
- assert.Equal(t, expectedNexthop, path.getNexthop().String())
+ assert.Equal(t, expectedNexthop, path.GetNexthop().String())
//withdraw path
w1 := bgp.WithdrawnRoute{*bgp.NewIPAddrPrefix(24, "10.10.10.0")}
@@ -1434,7 +1434,7 @@ func TestProcessBGPUpdate_8_withdraw_path_ipv4(t *testing.T) {
assert.Equal(t, expectedPrefix, path.getPrefix())
// check nexthop
expectedNexthop = "192.168.50.1"
- assert.Equal(t, expectedNexthop, path.getNexthop().String())
+ assert.Equal(t, expectedNexthop, path.GetNexthop().String())
}
// TODO MP_UNREACH
@@ -1547,7 +1547,7 @@ func TestProcessBGPUpdate_8_mpunreach_path_ipv6(t *testing.T) {
assert.Equal(t, expectedPrefix, path.getPrefix())
// check nexthop
expectedNexthop := "2001::192:168:100:1"
- assert.Equal(t, expectedNexthop, path.getNexthop().String())
+ assert.Equal(t, expectedNexthop, path.GetNexthop().String())
//mpunreach path
mp_unreach := createMpUNReach("2001:123:123:1::", 64)
@@ -1569,7 +1569,7 @@ func TestProcessBGPUpdate_8_mpunreach_path_ipv6(t *testing.T) {
assert.Equal(t, expectedPrefix, path.getPrefix())
// check nexthop
expectedNexthop = "2001::192:168:50:1"
- assert.Equal(t, expectedNexthop, path.getNexthop().String())
+ assert.Equal(t, expectedNexthop, path.GetNexthop().String())
}
@@ -1805,7 +1805,7 @@ func TestProcessBGPUpdate_implicit_withdrwal_ipv4(t *testing.T) {
assert.Equal(t, expectedPrefix, path.getPrefix())
// check nexthop
expectedNexthop := "192.168.50.1"
- assert.Equal(t, expectedNexthop, path.getNexthop().String())
+ assert.Equal(t, expectedNexthop, path.GetNexthop().String())
}
@@ -1917,7 +1917,7 @@ func TestProcessBGPUpdate_implicit_withdrwal_ipv6(t *testing.T) {
assert.Equal(t, expectedPrefix, path.getPrefix())
// check nexthop
expectedNexthop := "2001::192:168:50:1"
- assert.Equal(t, expectedNexthop, path.getNexthop().String())
+ assert.Equal(t, expectedNexthop, path.GetNexthop().String())
}
@@ -1974,7 +1974,7 @@ func TestProcessBGPUpdate_multiple_nlri_ipv4(t *testing.T) {
// check destination
assert.Equal(t, prefix, p.getPrefix())
// check nexthop
- assert.Equal(t, nexthop, p.getNexthop().String())
+ assert.Equal(t, nexthop, p.GetNexthop().String())
}
// path1
@@ -2115,7 +2115,7 @@ func TestProcessBGPUpdate_multiple_nlri_ipv6(t *testing.T) {
// check destination
assert.Equal(t, prefix, p.getPrefix())
// check nexthop
- assert.Equal(t, nexthop, p.getNexthop().String())
+ assert.Equal(t, nexthop, p.GetNexthop().String())
}
// path1