diff options
author | Hiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp> | 2015-01-27 13:51:27 +0900 |
---|---|---|
committer | Hiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp> | 2015-01-28 14:53:24 +0900 |
commit | e53a0b535298758300f1db2bffa6611fea54a9e1 (patch) | |
tree | cb5a49a84193899f2a751ec8d8900a98b3674545 /table/path.go | |
parent | a8cf76d39c46546376756416991d7583970beec1 (diff) |
table: revise table logs
Diffstat (limited to 'table/path.go')
-rw-r--r-- | table/path.go | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/table/path.go b/table/path.go index f6ecf05c..10374aa7 100644 --- a/table/path.go +++ b/table/path.go @@ -58,9 +58,13 @@ type PathDefault struct { } func NewPathDefault(rf bgp.RouteFamily, source *PeerInfo, nlri bgp.AddrPrefixInterface, nexthop net.IP, isWithdraw bool, pattrs []bgp.PathAttributeInterface, medSetByTargetNeighbor bool, now time.Time) *PathDefault { - if !isWithdraw && pattrs == nil { - log.Error("Need to provide nexthop and patattrs for path that is not a withdraw.") + log.WithFields(log.Fields{ + "Topic": "Table", + "Key": nlri.String(), + "Peer": source.Address.String(), + "Nexthop": nexthop.String(), + }).Error("Need to provide nexthop and patattrs for the path that is not withdraw.") return nil } @@ -103,7 +107,11 @@ func (pd *PathDefault) clone(isWithdraw bool) Path { nlri := pd.nlri if isWithdraw { if pd.IsWithdraw() { - log.Fatal("Withdraw path is not supposed to be cloned") + log.WithFields(log.Fields{ + "Topic": "Table", + "Key": pd.getNlri().String(), + "Peer": pd.getSource().Address.String(), + }).Fatal("Withdraw path is not supposed to be cloned") } else { nlri = &bgp.WithdrawnRoute{pd.nlri.(*bgp.NLRInfo).IPAddrPrefix} } @@ -206,15 +214,15 @@ func (pi *PathDefault) getPrefix() string { func CreatePath(source *PeerInfo, nlri bgp.AddrPrefixInterface, attrs []bgp.PathAttributeInterface, isWithdraw bool, now time.Time) Path { rf := bgp.RouteFamily(int(nlri.AFI())<<16 | int(nlri.SAFI())) - log.Debugf("afi: %d, safi: %d ", int(nlri.AFI()), nlri.SAFI()) + log.Debugf("CreatePath afi: %d, safi: %d ", int(nlri.AFI()), nlri.SAFI()) var path Path switch rf { case bgp.RF_IPv4_UC: - log.Debugf("RouteFamily : %s", bgp.RF_IPv4_UC.String()) + log.Debugf("CreatePath RouteFamily : %s", bgp.RF_IPv4_UC.String()) path = NewIPv4Path(source, nlri, isWithdraw, attrs, false, now) case bgp.RF_IPv6_UC: - log.Debugf("RouteFamily : %s", bgp.RF_IPv6_UC.String()) + log.Debugf("CreatePath RouteFamily : %s", bgp.RF_IPv6_UC.String()) path = NewIPv6Path(source, nlri, isWithdraw, attrs, false, now) } return path @@ -262,7 +270,11 @@ func (ipv6p *IPv6Path) clone(isWithdraw bool) Path { nlri := ipv6p.nlri if isWithdraw { if ipv6p.IsWithdraw() { - log.Fatal("Withdraw path is not supposed to be cloned") + log.WithFields(log.Fields{ + "Topic": "Table", + "Key": ipv6p.getNlri().String(), + "Peer": ipv6p.getSource().Address.String(), + }).Fatal("Withdraw path is not supposed to be cloned") } } return CreatePath(ipv6p.source, nlri, ipv6p.pathAttrs, isWithdraw, ipv6p.PathDefault.timestamp) |