summaryrefslogtreecommitdiffhomepage
path: root/packet/bgp/bgp_test.go
diff options
context:
space:
mode:
authorWataru Ishida <ishida.wataru@lab.ntt.co.jp>2016-09-15 08:17:22 +0000
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-09-15 14:32:34 -0700
commit0db1cd4af26a2c5025517ae30c9c16b11d5bb8d6 (patch)
treeb06750b6047064a598fad3eef1997a7423c97daa /packet/bgp/bgp_test.go
parent035b129966b5e91e50a96027e375df577e09194a (diff)
bgp/cli: support evpn route type 5 (ip prefix advertisement)
see draft-ietf-bess-evpn-prefix-advertisement-03 $ gobgp g ri -a evpn add prefix 10.0.0.0/24 etag 20 rd 100:100 rt 100:100 gw 10.10.10.10 label 100 $ gobgp g ri -a evpn add prefix 200::/64 etag 20 rd 100:100 rt 100:100 gw 200::1 label 10000 close #1082 Signed-off-by: Wataru Ishida <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'packet/bgp/bgp_test.go')
-rw-r--r--packet/bgp/bgp_test.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/packet/bgp/bgp_test.go b/packet/bgp/bgp_test.go
index 80dcc5af..0fcef12d 100644
--- a/packet/bgp/bgp_test.go
+++ b/packet/bgp/bgp_test.go
@@ -480,3 +480,39 @@ func Test_FlowSpecNlriVPN(t *testing.T) {
t.Log(bytes.Equal(buf1, buf2))
}
}
+
+func Test_EVPNIPPrefixRoute(t *testing.T) {
+ assert := assert.New(t)
+ rd, _ := ParseRouteDistinguisher("100:100")
+ r := &EVPNIPPrefixRoute{
+ RD: rd,
+ ESI: EthernetSegmentIdentifier{
+ Type: ESI_ARBITRARY,
+ Value: make([]byte, 9),
+ },
+ ETag: 10,
+ IPPrefixLength: 24,
+ IPPrefix: net.IP{10, 10, 10, 0},
+ GWIPAddress: net.IP{10, 10, 10, 10},
+ Label: 1000,
+ }
+ n1 := NewEVPNNLRI(EVPN_IP_PREFIX, 0, r)
+ buf1, err := n1.Serialize()
+ assert.Nil(err)
+ n2, err := NewPrefixFromRouteFamily(RouteFamilyToAfiSafi(RF_EVPN))
+ assert.Nil(err)
+ err = n2.DecodeFromBytes(buf1)
+ assert.Nil(err)
+ buf2, _ := n2.Serialize()
+ t.Log(n1.RouteTypeData.(*EVPNIPPrefixRoute).ESI.Value, n2.(*EVPNNLRI).RouteTypeData.(*EVPNIPPrefixRoute).ESI.Value)
+ t.Log(reflect.DeepEqual(n1.RouteTypeData.(*EVPNIPPrefixRoute).ESI.Value, n2.(*EVPNNLRI).RouteTypeData.(*EVPNIPPrefixRoute).ESI.Value))
+ if reflect.DeepEqual(n1, n2) {
+ t.Log("OK")
+ } else {
+ t.Error("Something wrong")
+ t.Error(len(buf1), n1, buf1)
+ t.Error(len(buf2), n2, buf2)
+ t.Log(bytes.Equal(buf1, buf2))
+ }
+
+}