summaryrefslogtreecommitdiffhomepage
path: root/pkg/server/server.go
diff options
context:
space:
mode:
authorHitoshi Irino <irino@sfc.wide.ad.jp>2019-03-02 13:54:38 +0900
committerFUJITA Tomonori <fujita.tomonori@gmail.com>2019-03-14 21:20:31 +0900
commit3a79ad3fdcbb7af0b7911a9c610c6e7af970ad6d (patch)
tree40911a6e5be205a15752aa11ea3b2e4f7335ebfa /pkg/server/server.go
parentdc4d9c6d1b253bc3a381f82941796b6bb8c71384 (diff)
Supporting BGP/MPLS L3VPNs with Frrouting Zebra API 6
- This commit aims to solve reported problem on issues #1611, #1648 and #1912 - Partial changes of this commit duplicate with changes on PR #1587 (not merged) and PR #1766 (not merged and already closed) - This commit is tested with only FRRouting version 6.0.2 (which uses Zebra API 6) - This commit fixes lack of LABEL_MANAGER_CONNECT_ASYNC for ZAPI6. (This bug is introduced on commit 2bdb76f2dcf24b891f2b6327a57c31b26463b2dd "Supporting Zebra API version 6 which is used in FRRouting version 6")
Diffstat (limited to 'pkg/server/server.go')
-rw-r--r--pkg/server/server.go32
1 files changed, 31 insertions, 1 deletions
diff --git a/pkg/server/server.go b/pkg/server/server.go
index ee0498e5..17937fff 100644
--- a/pkg/server/server.go
+++ b/pkg/server/server.go
@@ -958,6 +958,7 @@ func (s *BgpServer) propagateUpdate(peer *peer, pathList []*table.Path) {
peer.fsm.lock.RLock()
peerVrf := peer.fsm.pConf.Config.Vrf
peer.fsm.lock.RUnlock()
+ path.SetReceiveVrfId(rib.Vrfs[peerVrf].Id)
path = path.ToGlobal(rib.Vrfs[peerVrf])
}
@@ -1590,7 +1591,10 @@ func (s *BgpServer) EnableZebra(ctx context.Context, r *api.EnableZebraRequest)
protos = append(protos, string(p))
}
var err error
- s.zclient, err = newZebraClient(s, r.Url, protos, uint8(r.Version), r.NexthopTriggerEnable, uint8(r.NexthopTriggerDelay))
+ s.zclient, err = newZebraClient(s, r.Url, protos, uint8(r.Version), r.NexthopTriggerEnable, uint8(r.NexthopTriggerDelay), r.MplsLabelRangeSize)
+ if err == nil && s.globalRib != nil && s.zclient.client.Version >= 4 && r.MplsLabelRangeSize > 0 {
+ err = s.globalRib.EnableMplsLabelAllocation()
+ }
return err
}, false)
}
@@ -2029,6 +2033,26 @@ func (s *BgpServer) ListVrf(ctx context.Context, _ *api.ListVrfRequest, fn func(
return nil
}
+func assignMplsLabel(s *BgpServer, vrf *table.Vrf) error {
+ var mplsLabel uint32
+ var err error
+ for mplsLabel, err = s.globalRib.AssignMplsLabel(); err != nil; mplsLabel, err = s.globalRib.AssignMplsLabel() {
+ if err = s.zclient.client.SendGetLabelChunk(&zebra.GetLabelChunkBody{ChunkSize: s.zclient.mplsLabelRangeSize}); err != nil {
+ return err
+ }
+ labels := <-s.zclient.mplsLabelRangeCh
+ if err = s.globalRib.AllocateMplsLabelRange(labels[0], labels[1]); err != nil {
+ return err
+ }
+ }
+ vrf.MplsLabel = mplsLabel
+ err = s.zclient.client.SendVrfLabel(vrf.MplsLabel, vrf.Id)
+ if err != nil {
+ return err
+ }
+ return nil
+}
+
func (s *BgpServer) AddVrf(ctx context.Context, r *api.AddVrfRequest) error {
return s.mgmtOperation(func() error {
if r == nil || r.Vrf == nil {
@@ -2055,11 +2079,17 @@ func (s *BgpServer) AddVrf(ctx context.Context, r *api.AddVrfRequest) error {
AS: s.bgpConfig.Global.Config.As,
LocalID: net.ParseIP(s.bgpConfig.Global.Config.RouterId).To4(),
}
+
if pathList, err := s.globalRib.AddVrf(name, id, rd, im, ex, pi); err != nil {
return err
} else if len(pathList) > 0 {
s.propagateUpdate(nil, pathList)
}
+ if vrf, ok := s.globalRib.Vrfs[name]; ok {
+ if s.zclient.mplsLabelRangeSize > 0 {
+ go assignMplsLabel(s, vrf)
+ }
+ }
return nil
}, true)
}