summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/server.go6
-rw-r--r--table/table_manager.go16
2 files changed, 17 insertions, 5 deletions
diff --git a/server/server.go b/server/server.go
index db1ce6d7..063431d6 100644
--- a/server/server.go
+++ b/server/server.go
@@ -992,7 +992,11 @@ func (server *BgpServer) handleVrfMod(arg *api.ModVrfArguments) ([]*table.Path,
if err != nil {
return nil, err
}
- err = manager.AddVrf(arg.Vrf.Name, rd, importRt, exportRt)
+ pi := &table.PeerInfo{
+ AS: server.bgpConfig.Global.GlobalConfig.As,
+ LocalID: server.bgpConfig.Global.GlobalConfig.RouterId,
+ }
+ msgs, err = manager.AddVrf(arg.Vrf.Name, rd, importRt, exportRt, pi)
if err != nil {
return nil, err
}
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) {