summaryrefslogtreecommitdiffhomepage
path: root/table/table_manager.go
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-08-17 17:03:20 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-08-19 13:29:33 +0900
commit2f1e599c75b3954d798d16e6c924bc38fc61dbea (patch)
tree082e9a698e324485fb56c36a5cfbf3f2c103e929 /table/table_manager.go
parent79ed96fdc1a171de4b13108c7ca9c154d6d7fcd4 (diff)
vrf: advertise route-target constraint routes when adding a vrf
partial implementation of RFC4686 Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table/table_manager.go')
-rw-r--r--table/table_manager.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/table/table_manager.go b/table/table_manager.go
index 90a12175..b6295498 100644
--- a/table/table_manager.go
+++ b/table/table_manager.go
@@ -134,9 +134,9 @@ func (manager *TableManager) OwnerName() string {
return manager.owner
}
-func (manager *TableManager) AddVrf(name string, rd bgp.RouteDistinguisherInterface, importRt, exportRt []bgp.ExtendedCommunityInterface) error {
+func (manager *TableManager) AddVrf(name string, rd bgp.RouteDistinguisherInterface, importRt, exportRt []bgp.ExtendedCommunityInterface, info *PeerInfo) ([]*Path, error) {
if _, ok := manager.Vrfs[name]; ok {
- return fmt.Errorf("vrf %s already exists", name)
+ return nil, fmt.Errorf("vrf %s already exists", name)
}
log.WithFields(log.Fields{
"Topic": "Vrf",
@@ -151,8 +151,16 @@ func (manager *TableManager) AddVrf(name string, rd bgp.RouteDistinguisherInterf
ImportRt: importRt,
ExportRt: exportRt,
}
- return nil
-
+ msgs := make([]*Path, 0, len(importRt))
+ nexthop := "0.0.0.0"
+ for _, target := range importRt {
+ nlri := bgp.NewRouteTargetMembershipNLRI(info.AS, target)
+ pattr := make([]bgp.PathAttributeInterface, 0)
+ pattr = append(pattr, bgp.NewPathAttributeOrigin(bgp.BGP_ORIGIN_ATTR_TYPE_IGP))
+ pattr = append(pattr, bgp.NewPathAttributeMpReachNLRI(nexthop, []bgp.AddrPrefixInterface{nlri}))
+ msgs = append(msgs, NewPath(info, nlri, false, pattr, false, time.Now(), false))
+ }
+ return msgs, nil
}
func (manager *TableManager) DeleteVrf(name string) ([]*Path, error) {