summaryrefslogtreecommitdiffhomepage
path: root/table
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-10-01 21:30:04 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-10-02 03:30:29 +0900
commit94836fe9a9e247361eb80d16e095c736732a7c61 (patch)
tree92e32b1986688f2f8ea7ce96f021b21a8e87cf29 /table
parent94b9f27c89d050c80183514986edebc9f6c8361f (diff)
cli: add command to show accepted/rejected routes
$ gobgp neighbor <remote addr> accepted $ gobgp neighbor <remote addr> rejected Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table')
-rw-r--r--table/path.go4
-rw-r--r--table/table_manager.go46
2 files changed, 18 insertions, 32 deletions
diff --git a/table/path.go b/table/path.go
index 8997af67..02b24416 100644
--- a/table/path.go
+++ b/table/path.go
@@ -38,6 +38,7 @@ type Path struct {
NoImplicitWithdraw bool
Validation config.RpkiValidationResultType
IsFromZebra bool
+ Filtered bool
}
func NewPath(source *PeerInfo, nlri bgp.AddrPrefixInterface, isWithdraw bool, pattrs []bgp.PathAttributeInterface, medSetByTargetNeighbor bool, timestamp time.Time, noImplicitWithdraw bool) *Path {
@@ -190,6 +191,7 @@ func (path *Path) ToApiStruct() *api.Path {
Age: int64(time.Now().Sub(path.timestamp).Seconds()),
IsWithdraw: path.IsWithdraw,
Validation: int32(path.Validation),
+ Filtered: path.Filtered,
Rf: rf,
}
}
@@ -200,11 +202,13 @@ func (path *Path) MarshalJSON() ([]byte, error) {
IsWithdraw bool `json:"is_withdraw"`
Nlri bgp.AddrPrefixInterface `json:"nlri"`
Pathattrs []bgp.PathAttributeInterface `json:"pattrs"`
+ Filtered bool `json:"filtered"`
}{
Source: path.source,
IsWithdraw: path.IsWithdraw,
Nlri: path.nlri,
Pathattrs: path.pathAttrs,
+ Filtered: path.Filtered,
})
}
diff --git a/table/table_manager.go b/table/table_manager.go
index 01651e1c..25807566 100644
--- a/table/table_manager.go
+++ b/table/table_manager.go
@@ -412,23 +412,23 @@ func (manager *TableManager) ProcessUpdate(fromPeer *PeerInfo, message *bgp.BGPM
}
type AdjRib struct {
- adjRibIn map[bgp.RouteFamily]map[string]*ReceivedRoute
- adjRibOut map[bgp.RouteFamily]map[string]*ReceivedRoute
+ adjRibIn map[bgp.RouteFamily]map[string]*Path
+ adjRibOut map[bgp.RouteFamily]map[string]*Path
}
func NewAdjRib(rfList []bgp.RouteFamily) *AdjRib {
r := &AdjRib{
- adjRibIn: make(map[bgp.RouteFamily]map[string]*ReceivedRoute),
- adjRibOut: make(map[bgp.RouteFamily]map[string]*ReceivedRoute),
+ adjRibIn: make(map[bgp.RouteFamily]map[string]*Path),
+ adjRibOut: make(map[bgp.RouteFamily]map[string]*Path),
}
for _, rf := range rfList {
- r.adjRibIn[rf] = make(map[string]*ReceivedRoute)
- r.adjRibOut[rf] = make(map[string]*ReceivedRoute)
+ r.adjRibIn[rf] = make(map[string]*Path)
+ r.adjRibOut[rf] = make(map[string]*Path)
}
return r
}
-func (adj *AdjRib) update(rib map[bgp.RouteFamily]map[string]*ReceivedRoute, pathList []*Path) {
+func (adj *AdjRib) update(rib map[bgp.RouteFamily]map[string]*Path, pathList []*Path) {
for _, path := range pathList {
rf := path.GetRouteFamily()
key := path.getPrefix()
@@ -438,10 +438,10 @@ func (adj *AdjRib) update(rib map[bgp.RouteFamily]map[string]*ReceivedRoute, pat
delete(rib[rf], key)
}
} else {
- if found && reflect.DeepEqual(old.path.GetPathAttrs(), path.GetPathAttrs()) {
- path.setTimestamp(old.path.GetTimestamp())
+ if found && reflect.DeepEqual(old.GetPathAttrs(), path.GetPathAttrs()) {
+ path.setTimestamp(old.GetTimestamp())
}
- rib[rf][key] = NewReceivedRoute(path, false)
+ rib[rf][key] = path
}
}
}
@@ -454,10 +454,10 @@ func (adj *AdjRib) UpdateOut(pathList []*Path) {
adj.update(adj.adjRibOut, pathList)
}
-func (adj *AdjRib) getPathList(rib map[string]*ReceivedRoute) []*Path {
+func (adj *AdjRib) getPathList(rib map[string]*Path) []*Path {
pathList := make([]*Path, 0, len(rib))
for _, rr := range rib {
- pathList = append(pathList, rr.path)
+ pathList = append(pathList, rr)
}
return pathList
}
@@ -493,25 +493,7 @@ func (adj *AdjRib) GetOutCount(rf bgp.RouteFamily) int {
func (adj *AdjRib) DropAll(rf bgp.RouteFamily) {
if _, ok := adj.adjRibIn[rf]; ok {
// replace old one
- adj.adjRibIn[rf] = make(map[string]*ReceivedRoute)
- adj.adjRibOut[rf] = make(map[string]*ReceivedRoute)
+ adj.adjRibIn[rf] = make(map[string]*Path)
+ adj.adjRibOut[rf] = make(map[string]*Path)
}
}
-
-type ReceivedRoute struct {
- path *Path
- filtered bool
-}
-
-func (rr *ReceivedRoute) String() string {
- return rr.path.getPrefix()
-}
-
-func NewReceivedRoute(path *Path, filtered bool) *ReceivedRoute {
-
- rroute := &ReceivedRoute{
- path: path,
- filtered: filtered,
- }
- return rroute
-}