summaryrefslogtreecommitdiffhomepage
path: root/table/policy.go
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2016-01-16 16:40:05 +0900
committerISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2016-01-16 18:25:35 +0900
commit6403c806634491b6cd6c3c90f61badf478fed9aa (patch)
treef557370a5c3ca739d644172140dd42af63cd1b00 /table/policy.go
parent0cf8045e994b653030b721c574614d46c1870cf1 (diff)
server: reduce number of path.Clone() call to reduce memory footprint
the result of memory profile (500 route-server-clients each of them advertises 100 routes) before: (pprof) top5 3913.02MB of 3978.69MB total (98.35%) Dropped 148 nodes (cum <= 19.89MB) Showing top 10 nodes out of 11 (cum >= 21MB) flat flat% sum% cum cum% 2970.30MB 74.66% 74.66% 2975.80MB 74.79% github.com/osrg/gobgp/server.filterpath 810.09MB 20.36% 95.02% 810.59MB 20.37% github.com/osrg/gobgp/table.(*AdjRib).Update 115.60MB 2.91% 97.92% 119.10MB 2.99% github.com/osrg/gobgp/table.createUpdateMsgFromPath 10MB 0.25% 98.17% 1878.02MB 47.20% github.com/osrg/gobgp/server.(*BgpServer).propagateUpdate 4.50MB 0.11% 98.29% 144.60MB 3.63% github.com/osrg/gobgp/table.CreateUpdateMsgFromPaths after: (pprof) top5 1259.49MB of 1284.27MB total (98.07%) Dropped 175 nodes (cum <= 6.42MB) Showing top 10 nodes out of 26 (cum >= 36.51MB) flat flat% sum% cum cum% 975.81MB 75.98% 75.98% 976.31MB 76.02% github.com/osrg/gobgp/table.(*AdjRib).Update 198.67MB 15.47% 91.45% 208.17MB 16.21% github.com/osrg/gobgp/table.createUpdateMsgFromPath 22MB 1.71% 93.16% 22MB 1.71% github.com/osrg/gobgp/packet.(*IPAddrPrefix).Serialize 20MB 1.56% 94.72% 707.19MB 55.07% github.com/osrg/gobgp/server.(*BgpServer).propagateUpdate 13.50MB 1.05% 95.77% 13.50MB 1.05% github.com/osrg/gobgp/table.NewPath Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table/policy.go')
-rw-r--r--table/policy.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/table/policy.go b/table/policy.go
index a8192a58..81010a9d 100644
--- a/table/policy.go
+++ b/table/policy.go
@@ -32,6 +32,7 @@ import (
)
type PolicyOptions struct {
+ Neighbor net.IP
}
type DefinedType int
@@ -1152,19 +1153,24 @@ func (c *NeighborCondition) Option() MatchOption {
// compare neighbor ipaddress of this condition and source address of path
// and, subsequent comparisons are skipped if that matches the conditions.
// If NeighborList's length is zero, return true.
-func (c *NeighborCondition) Evaluate(path *Path, _ *PolicyOptions) bool {
+func (c *NeighborCondition) Evaluate(path *Path, options *PolicyOptions) bool {
if len(c.set.list) == 0 {
log.Debug("NeighborList doesn't have elements")
return true
}
- if path.Owner == nil {
+ neighbor := path.GetSource().Address
+ if options != nil && options.Neighbor != nil {
+ neighbor = options.Neighbor
+ }
+
+ if neighbor == nil {
return false
}
result := false
for _, n := range c.set.list {
- if path.Owner.Equal(n) {
+ if neighbor.Equal(n) {
result = true
break
}
@@ -2094,7 +2100,7 @@ func (s *Statement) Apply(path *Path, options *PolicyOptions) (RouteType, *Path)
if result {
if len(s.ModActions) != 0 {
// apply all modification actions
- path = path.Clone(path.Owner, path.IsWithdraw)
+ path = path.Clone(path.IsWithdraw)
for _, action := range s.ModActions {
path = action.Apply(path)
}