From 0db1cd4af26a2c5025517ae30c9c16b11d5bb8d6 Mon Sep 17 00:00:00 2001 From: Wataru Ishida Date: Thu, 15 Sep 2016 08:17:22 +0000 Subject: 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 --- packet/bgp/bgp_test.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'packet/bgp/bgp_test.go') 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)) + } + +} -- cgit v1.2.3