diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-07-31 18:51:05 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-08-08 20:56:46 +0900 |
commit | bf9e135ba85cad641c3812abace9221cbf5a2615 (patch) | |
tree | 435728bd72e93ddfea7a3c02d78cfb1a9c65f16f /table | |
parent | ecd079e318e1c5d5aa2d2f1348a4ad1a37daec37 (diff) |
server: support vrf
to add/delete vrf
$ gobgp vrf [add|del] <vrf-name> rd <rd> rt [import|export|both] <rt>...
show vrf
$ gobgp vrf
to add/delete a path to a specific vrf
$ gobgp vrf <vrf-name> rib [add|del] <prefix> -a <address-family>
show paths contained in a specific vrf
$ gobgp vrf <vrf-name> rib -a <address-family>
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table')
-rw-r--r-- | table/table_manager.go | 9 | ||||
-rw-r--r-- | table/vrf.go | 46 |
2 files changed, 52 insertions, 3 deletions
diff --git a/table/table_manager.go b/table/table_manager.go index 2b34f2c6..41630246 100644 --- a/table/table_manager.go +++ b/table/table_manager.go @@ -113,17 +113,20 @@ func ProcessMessage(m *bgp.BGPMessage, peerInfo *PeerInfo) []*Path { type TableManager struct { Tables map[bgp.RouteFamily]*Table + Vrfs map[string]*Vrf localAsn uint32 owner string } func NewTableManager(owner string, rfList []bgp.RouteFamily) *TableManager { - t := &TableManager{} - t.Tables = make(map[bgp.RouteFamily]*Table) + t := &TableManager{ + Tables: make(map[bgp.RouteFamily]*Table), + Vrfs: make(map[string]*Vrf), + owner: owner, + } for _, rf := range rfList { t.Tables[rf] = NewTable(rf) } - t.owner = owner return t } diff --git a/table/vrf.go b/table/vrf.go new file mode 100644 index 00000000..3833ecac --- /dev/null +++ b/table/vrf.go @@ -0,0 +1,46 @@ +// Copyright (C) 2014 Nippon Telegraph and Telephone Corporation. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +// implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package table + +import ( + "github.com/osrg/gobgp/api" + "github.com/osrg/gobgp/packet" +) + +type Vrf struct { + Name string + Rd bgp.RouteDistinguisherInterface + ImportRt []bgp.ExtendedCommunityInterface + ExportRt []bgp.ExtendedCommunityInterface +} + +func (v *Vrf) ToApiStruct() *api.Vrf { + f := func(rts []bgp.ExtendedCommunityInterface) [][]byte { + ret := make([][]byte, 0, len(rts)) + for _, rt := range rts { + b, _ := rt.Serialize() + ret = append(ret, b) + } + return ret + } + rd, _ := v.Rd.Serialize() + return &api.Vrf{ + Name: v.Name, + Rd: rd, + ImportRt: f(v.ImportRt), + ExportRt: f(v.ExportRt), + } +} |