From e715110ce144c1b7527df74d89381f83b4c4aaec Mon Sep 17 00:00:00 2001
From: Maximilian Wilhelm <max@sdn.clinic>
Date: Sun, 24 Jun 2018 10:55:05 +0200
Subject: [PATCH] Print if route has been learned via eBGP or iBGP.

Signed-off-by: Maximilian Wilhelm <max@sdn.clinic>
---
 route/bgp_path.go | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/route/bgp_path.go b/route/bgp_path.go
index 1f100024..38a5a8c9 100644
--- a/route/bgp_path.go
+++ b/route/bgp_path.go
@@ -163,6 +163,7 @@ func (b *BGPPath) better(c *BGPPath) bool {
 	return false
 }
 
+// Print all known information about a route in human readable form
 func (b *BGPPath) Print() string {
 	origin := ""
 	switch b.Origin {
@@ -173,9 +174,16 @@ func (b *BGPPath) Print() string {
 	case 2:
 		origin = "IGP"
 	}
+
+	bgpType := "iBGP"
+	if b.EBGP {
+		bgpType = "eBGP"
+	}
+
 	ret := fmt.Sprintf("\t\tLocal Pref: %d\n", b.LocalPref)
 	ret += fmt.Sprintf("\t\tOrigin: %s\n", origin)
 	ret += fmt.Sprintf("\t\tAS Path: %v\n", b.ASPath)
+	ret += fmt.Sprintf("\t\tBGP type: %s\n", bgpType)
 	nh := uint32To4Byte(b.NextHop)
 	ret += fmt.Sprintf("\t\tNEXT HOP: %d.%d.%d.%d\n", nh[0], nh[1], nh[2], nh[3])
 	ret += fmt.Sprintf("\t\tMED: %d\n", b.MED)
@@ -187,6 +195,7 @@ func (b *BGPPath) Print() string {
 	return ret
 }
 
+// Prepend the given BGPPath with the given ASN given times
 func (b *BGPPath) Prepend(asn uint32, times uint16) {
 	if times == 0 {
 		return
-- 
GitLab