summaryrefslogtreecommitdiffhomepage
path: root/table
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-05-01 10:06:42 +0000
committerISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-05-01 10:16:09 +0000
commit232b30117c8eafc5cae7aec81ce9fafe742bdd4b (patch)
tree235342a7345b6034f02a1864485a4c96e25d3ea2 /table
parentcea5941db2dd9268ad35b5f494480350d747d404 (diff)
table: add support for route target constraint nlri
add rtc route $ gobgp global rib add 65000 77 -a rtc check it $ gobgp global rib -a rtc Network Next Hop AS_PATH Age Attrs *> 65001:65000:75 0.0.0.0 [65001] 00:15:35 [{Origin: IGP}] Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table')
-rw-r--r--table/destination.go12
-rw-r--r--table/message.go2
-rw-r--r--table/path.go20
-rw-r--r--table/table.go19
-rw-r--r--table/table_manager.go2
5 files changed, 54 insertions, 1 deletions
diff --git a/table/destination.go b/table/destination.go
index bf4afe63..a01c6e04 100644
--- a/table/destination.go
+++ b/table/destination.go
@@ -1043,3 +1043,15 @@ func NewEncapDestination(nlri bgp.AddrPrefixInterface) *EncapDestination {
DestinationDefault: d,
}
}
+
+type RouteTargetDestination struct {
+ *DestinationDefault
+}
+
+func NewRouteTargetDestination(nlri bgp.AddrPrefixInterface) *RouteTargetDestination {
+ d := NewDestinationDefault(nlri)
+ d.ROUTE_FAMILY = bgp.RF_RTC_UC
+ return &RouteTargetDestination{
+ DestinationDefault: d,
+ }
+}
diff --git a/table/message.go b/table/message.go
index 70e2ffcd..5b444ce0 100644
--- a/table/message.go
+++ b/table/message.go
@@ -155,7 +155,7 @@ func createUpdateMsgFromPath(path Path, msg *bgp.BGPMessage) *bgp.BGPMessage {
return bgp.NewBGPUpdateMessage([]bgp.WithdrawnRoute{}, pathAttrs, []bgp.NLRInfo{*nlri})
}
}
- } else if rf == bgp.RF_IPv6_UC || rf == bgp.RF_EVPN || rf == bgp.RF_ENCAP {
+ } else if rf == bgp.RF_IPv6_UC || rf == bgp.RF_EVPN || rf == bgp.RF_ENCAP || rf == bgp.RF_RTC_UC {
if path.IsWithdraw() {
if msg != nil {
idx, _ := path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_UNREACH_NLRI)
diff --git a/table/path.go b/table/path.go
index 88765d44..0d52d343 100644
--- a/table/path.go
+++ b/table/path.go
@@ -384,6 +384,9 @@ func CreatePath(source *PeerInfo, nlri bgp.AddrPrefixInterface, attrs []bgp.Path
case bgp.RF_ENCAP:
log.Debugf("CreatePath RouteFamily : %s", bgp.RF_ENCAP.String())
path = NewEncapPath(source, nlri, isWithdraw, attrs, false, now)
+ case bgp.RF_RTC_UC:
+ log.Debugf("CreatePath RouteFamily : %s", bgp.RF_RTC_UC)
+ path = NewRouteTargetPath(source, nlri, isWithdraw, attrs, false, now)
default:
return path, fmt.Errorf("Unsupported RouteFamily: %s", rf)
}
@@ -538,3 +541,20 @@ func (p *EncapPath) setPathDefault(pd *PathDefault) {
func (p *EncapPath) getPathDefault() *PathDefault {
return p.PathDefault
}
+
+type RouteTargetPath struct {
+ *PathDefault
+}
+
+func NewRouteTargetPath(source *PeerInfo, nlri bgp.AddrPrefixInterface, isWithdraw bool, attrs []bgp.PathAttributeInterface, medSetByTargetNeighbor bool, now time.Time) *RouteTargetPath {
+ return &RouteTargetPath{
+ PathDefault: NewPathDefault(bgp.RF_RTC_UC, source, nlri, isWithdraw, attrs, medSetByTargetNeighbor, now),
+ }
+}
+
+func (p *RouteTargetPath) setPathDefault(pd *PathDefault) {
+ p.PathDefault = pd
+}
+func (p *RouteTargetPath) getPathDefault() *PathDefault {
+ return p.PathDefault
+}
diff --git a/table/table.go b/table/table.go
index b1434732..22499f5a 100644
--- a/table/table.go
+++ b/table/table.go
@@ -353,3 +353,22 @@ func (t *EncapTable) createDest(nlri bgp.AddrPrefixInterface) Destination {
func (t *EncapTable) tableKey(nlri bgp.AddrPrefixInterface) string {
return nlri.String()
}
+
+type RouteTargetTable struct {
+ *TableDefault
+}
+
+func NewRouteTargetTable() *RouteTargetTable {
+ routeTargetTable := &RouteTargetTable{}
+ routeTargetTable.TableDefault = NewTableDefault(0)
+ routeTargetTable.TableDefault.ROUTE_FAMILY = bgp.RF_RTC_UC
+ return routeTargetTable
+}
+
+func (t *RouteTargetTable) createDest(nlri bgp.AddrPrefixInterface) Destination {
+ return Destination(NewRouteTargetDestination(nlri))
+}
+
+func (t *RouteTargetTable) tableKey(nlri bgp.AddrPrefixInterface) string {
+ return nlri.String()
+}
diff --git a/table/table_manager.go b/table/table_manager.go
index d4da1735..8d3b18ca 100644
--- a/table/table_manager.go
+++ b/table/table_manager.go
@@ -131,6 +131,8 @@ func NewTableManager(owner string, rfList []bgp.RouteFamily) *TableManager {
t.Tables[bgp.RF_EVPN] = NewEVPNTable(0)
case bgp.RF_ENCAP:
t.Tables[bgp.RF_ENCAP] = NewEncapTable()
+ case bgp.RF_RTC_UC:
+ t.Tables[bgp.RF_RTC_UC] = NewRouteTargetTable()
}
}
t.owner = owner