diff options
Diffstat (limited to 'table/path.go')
-rw-r--r-- | table/path.go | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/table/path.go b/table/path.go index 846c7e16..4ef9c070 100644 --- a/table/path.go +++ b/table/path.go @@ -39,7 +39,7 @@ type Path interface { getPrefix() net.IP setMedSetByTargetNeighbor(medSetByTargetNeighbor bool) getMedSetByTargetNeighbor() bool - Clone() Path + Clone(IsWithdraw bool) Path } type PathDefault struct { @@ -74,15 +74,18 @@ func NewPathDefault(rf RouteFamily, source *PeerInfo, nlri bgp.AddrPrefixInterfa } // create new PathAttributes -func (pd *PathDefault) Clone() Path { - copiedAttrs := append([]bgp.PathAttributeInterface(nil), pd.pathAttrs...) - for i, attr := range copiedAttrs { - t, v := reflect.TypeOf(attr), reflect.ValueOf(attr) - newAttrObjp := reflect.New(t.Elem()) - newAttrObjp.Elem().Set(v.Elem()) - copiedAttrs[i] = newAttrObjp.Interface().(bgp.PathAttributeInterface) +func (pd *PathDefault) Clone(isWithdraw bool) Path { + copiedAttrs := []bgp.PathAttributeInterface(nil) + if !isWithdraw { + copiedAttrs = append(copiedAttrs, pd.pathAttrs...) + for i, attr := range copiedAttrs { + t, v := reflect.TypeOf(attr), reflect.ValueOf(attr) + newAttrObjp := reflect.New(t.Elem()) + newAttrObjp.Elem().Set(v.Elem()) + copiedAttrs[i] = newAttrObjp.Interface().(bgp.PathAttributeInterface) + } } - return CreatePath(pd.source, pd.nlri, copiedAttrs, pd.withdraw) + return CreatePath(pd.source, pd.nlri, copiedAttrs, isWithdraw) } func (pd *PathDefault) getRouteFamily() RouteFamily { |