summaryrefslogtreecommitdiffhomepage
path: root/table
diff options
context:
space:
mode:
authorWataru Ishida <ishida.wataru@lab.ntt.co.jp>2016-09-03 07:27:51 +0000
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-09-13 00:49:17 -0700
commit10142c11f9c93e6699d8e65af002cf2eef3a3e5e (patch)
tree45c2ae35a76c980ac8245fc48ac27ad81902467c /table
parenta795d2452ac2c0201dc48ea4608bca46a887b3d4 (diff)
server/table: fix a bug of vrf route injection
regression due to 43dc07d72353fc8bcb79a18a5739ea0a90dda6bb before: $ gobgp vrf add vrf01 rd 100:100 rt both 100:100 $ gobgp vrf vrf01 rib add 10.0.0.0/24 $ gobgp global rib -a ipv4 Network Next Hop AS_PATH Age Attrs *> 10.0.0.0/24 0.0.0.0 00:00:19 [{Origin: ?} {Extcomms: [100:100]}] after: $ gobgp vrf add vrf01 rd 100:100 rt both 100:100 $ gobgp vrf vrf01 rib add 10.0.0.0/24 $ gobgp global rib -a ipv4 Network not in table $ gobgp global rib -a vpnv4 Network Labels Next Hop AS_PATH Age Attrs *> 100:100:10.0.0.0/24 [16000] 0.0.0.0 00:00:19 [{Origin: ?} {Extcomms: [100:100]}] Signed-off-by: Wataru Ishida <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table')
-rw-r--r--table/vrf.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/table/vrf.go b/table/vrf.go
index c8fc2a16..18a5af87 100644
--- a/table/vrf.go
+++ b/table/vrf.go
@@ -16,6 +16,7 @@
package table
import (
+ "fmt"
"github.com/osrg/gobgp/packet/bgp"
)
@@ -27,6 +28,30 @@ type Vrf struct {
LabelMap map[string]uint32
}
+func (v *Vrf) ToGlobalPath(path *Path, label uint32) error {
+ nlri := path.GetNlri()
+ switch rf := path.GetRouteFamily(); rf {
+ case bgp.RF_IPv4_UC:
+ n := nlri.(*bgp.IPAddrPrefix)
+ path.OriginInfo().nlri = bgp.NewLabeledVPNIPAddrPrefix(n.Length, n.Prefix.String(), *bgp.NewMPLSLabelStack(label), v.Rd)
+ case bgp.RF_IPv6_UC:
+ n := nlri.(*bgp.IPv6AddrPrefix)
+ path.OriginInfo().nlri = bgp.NewLabeledVPNIPv6AddrPrefix(n.Length, n.Prefix.String(), *bgp.NewMPLSLabelStack(label), v.Rd)
+ case bgp.RF_EVPN:
+ n := nlri.(*bgp.EVPNNLRI)
+ switch n.RouteType {
+ case bgp.EVPN_ROUTE_TYPE_MAC_IP_ADVERTISEMENT:
+ n.RouteTypeData.(*bgp.EVPNMacIPAdvertisementRoute).RD = v.Rd
+ case bgp.EVPN_INCLUSIVE_MULTICAST_ETHERNET_TAG:
+ n.RouteTypeData.(*bgp.EVPNMulticastEthernetTagRoute).RD = v.Rd
+ }
+ default:
+ return fmt.Errorf("unsupported route family for vrf: %s", rf)
+ }
+ path.SetExtCommunities(v.ExportRt, false)
+ return nil
+}
+
func (v *Vrf) Clone() *Vrf {
f := func(rt []bgp.ExtendedCommunityInterface) []bgp.ExtendedCommunityInterface {
l := make([]bgp.ExtendedCommunityInterface, 0, len(rt))