From 275f20e96e674e3a0b654292f81240744c61665a Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Mon, 22 Dec 2014 02:52:33 -0800 Subject: table: send withdraw when peer is down When a peer becomes down, send withdraw for the best pathes of it. Signed-off-by: FUJITA Tomonori --- table/path.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'table/path.go') diff --git a/table/path.go b/table/path.go index 269f6129..b9362bd9 100644 --- a/table/path.go +++ b/table/path.go @@ -76,7 +76,12 @@ func NewPathDefault(rf RouteFamily, source *PeerInfo, nlri bgp.AddrPrefixInterfa // create new PathAttributes func (pd *PathDefault) Clone(isWithdraw bool) Path { copiedAttrs := []bgp.PathAttributeInterface(nil) - if !isWithdraw { + nlri := pd.nlri + if isWithdraw { + if !pd.IsWithdraw() { + nlri = &bgp.WithdrawnRoute{pd.nlri.(*bgp.NLRInfo).IPAddrPrefix} + } + } else { copiedAttrs = append(copiedAttrs, pd.pathAttrs...) for i, attr := range copiedAttrs { t, v := reflect.TypeOf(attr), reflect.ValueOf(attr) @@ -85,7 +90,7 @@ func (pd *PathDefault) Clone(isWithdraw bool) Path { copiedAttrs[i] = newAttrObjp.Interface().(bgp.PathAttributeInterface) } } - return CreatePath(pd.source, pd.nlri, copiedAttrs, isWithdraw) + return CreatePath(pd.source, nlri, copiedAttrs, isWithdraw) } func (pd *PathDefault) getRouteFamily() RouteFamily { -- cgit v1.2.3