summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorHiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp>2015-04-01 20:25:31 +0900
committerHiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp>2015-04-01 20:25:31 +0900
commit405add832c12ce522f19c956f577d49d61704a01 (patch)
tree880e09be9c837e0c2eb7bb49cfa3a4e7668843d6
parent808e8bd92a9e8607cf70640876d3fe59f06361ef (diff)
peer: make applyPolicies into peer's method
-rw-r--r--server/peer.go20
1 files changed, 12 insertions, 8 deletions
diff --git a/server/peer.go b/server/peer.go
index a96a89fa..6677e0bc 100644
--- a/server/peer.go
+++ b/server/peer.go
@@ -375,12 +375,12 @@ func (peer *Peer) sendUpdateMsgFromPaths(pList []table.Path) {
}
log.Debug("p: ", p)
if len(policies) != 0 {
- applied, newPath := applyPolicies(policies, &p)
+ applied, newPath := peer.applyPolicies(policies, p)
if applied {
if newPath != nil {
log.Debug("path accepted")
- paths = append(paths, *newPath)
+ paths = append(paths, newPath)
} else {
log.Debug("path was rejected: ", p)
}
@@ -439,20 +439,24 @@ func (peer *Peer) sendUpdateMsgFromPaths(pList []table.Path) {
// modified path.
// If action of the policy is 'reject', return nil
//
-func applyPolicies(policies []*policy.Policy, original *table.Path) (bool, *table.Path) {
+func (peer *Peer) applyPolicies(policies []*policy.Policy, original table.Path) (bool, table.Path) {
var applied bool = true
for _, pol := range policies {
- if result, action, newpath := pol.Apply(*original); result {
+ if result, action, newpath := pol.Apply(original); result {
log.Debug("newpath: ", newpath)
if action == policy.ROUTE_TYPE_REJECT {
- log.Debug("path was rejected: ", original)
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ "Key": peer.peerConfig.NeighborAddress,
+ "NRLI": original.GetNlri(),
+ }).Debug("path was rejected")
// return applied, nil, this means path was rejected
return applied, nil
} else {
// return applied, new path
- return applied, &newpath
+ return applied, newpath
}
}
}
@@ -479,12 +483,12 @@ func (peer *Peer) handlePeerMsg(m *peerMsg) {
log.Debug("is not withdraw")
if len(policies) != 0 {
- applied, newPath := applyPolicies(policies, &p)
+ applied, newPath := peer.applyPolicies(policies, p)
if applied {
if newPath != nil {
log.Debug("path accepted")
- paths = append(paths, *newPath)
+ paths = append(paths, newPath)
}
} else {
if peer.defaultImportPolicy == config.DEFAULT_POLICY_TYPE_ACCEPT_ROUTE {