summaryrefslogtreecommitdiffhomepage
path: root/packet
diff options
context:
space:
mode:
Diffstat (limited to 'packet')
-rw-r--r--packet/bgp/bgp.go14
-rw-r--r--packet/bgp/bgp_test.go6
-rw-r--r--packet/bgp/helper.go8
3 files changed, 16 insertions, 12 deletions
diff --git a/packet/bgp/bgp.go b/packet/bgp/bgp.go
index 61cd4a54..21788549 100644
--- a/packet/bgp/bgp.go
+++ b/packet/bgp/bgp.go
@@ -2855,11 +2855,15 @@ func (n *EVPNNLRI) RD() RouteDistinguisherInterface {
return n.RouteTypeData.rd()
}
-func NewEVPNNLRI(routetype uint8, length uint8, routetypedata EVPNRouteTypeInterface) *EVPNNLRI {
+func NewEVPNNLRI(routeType uint8, routeTypeData EVPNRouteTypeInterface) *EVPNNLRI {
+ var l uint8
+ if routeTypeData != nil {
+ l = uint8(routeTypeData.Len())
+ }
return &EVPNNLRI{
- RouteType: routetype,
- Length: length,
- RouteTypeData: routetypedata,
+ RouteType: routeType,
+ Length: l,
+ RouteTypeData: routeTypeData,
}
}
@@ -4681,7 +4685,7 @@ func NewPrefixFromRouteFamily(afi uint16, safi uint8) (prefix AddrPrefixInterfac
case RF_IPv6_MPLS:
prefix = NewLabeledIPv6AddrPrefix(0, "", *NewMPLSLabelStack())
case RF_EVPN:
- prefix = NewEVPNNLRI(0, 0, nil)
+ prefix = NewEVPNNLRI(0, nil)
case RF_RTC_UC:
prefix = &RouteTargetMembershipNLRI{}
case RF_IPv4_ENCAP:
diff --git a/packet/bgp/bgp_test.go b/packet/bgp/bgp_test.go
index 248fb346..65847b55 100644
--- a/packet/bgp/bgp_test.go
+++ b/packet/bgp/bgp_test.go
@@ -585,7 +585,7 @@ func Test_EVPNIPPrefixRoute(t *testing.T) {
GWIPAddress: net.IP{10, 10, 10, 10},
Label: 1000,
}
- n1 := NewEVPNNLRI(EVPN_IP_PREFIX, 0, r)
+ n1 := NewEVPNNLRI(EVPN_IP_PREFIX, r)
buf1, err := n1.Serialize()
assert.Nil(err)
n2, err := NewPrefixFromRouteFamily(RouteFamilyToAfiSafi(RF_EVPN))
@@ -722,13 +722,13 @@ func Test_AddPath(t *testing.T) {
}
opt = &MarshallingOption{AddPath: map[RouteFamily]BGPAddPathMode{RF_EVPN: BGP_ADD_PATH_BOTH}}
{
- n1 := NewEVPNNLRI(EVPN_ROUTE_TYPE_ETHERNET_AUTO_DISCOVERY, 0,
+ n1 := NewEVPNNLRI(EVPN_ROUTE_TYPE_ETHERNET_AUTO_DISCOVERY,
&EVPNEthernetAutoDiscoveryRoute{NewRouteDistinguisherFourOctetAS(5, 6),
EthernetSegmentIdentifier{ESI_ARBITRARY, make([]byte, 9)}, 2, 2})
n1.SetPathLocalIdentifier(40)
bits, err := n1.Serialize(opt)
assert.Nil(err)
- n2 := NewEVPNNLRI(0, 0, nil)
+ n2 := NewEVPNNLRI(0, nil)
err = n2.DecodeFromBytes(bits, opt)
assert.Nil(err)
assert.Equal(n2.PathIdentifier(), uint32(40))
diff --git a/packet/bgp/helper.go b/packet/bgp/helper.go
index ecae6bdd..c816c9d6 100644
--- a/packet/bgp/helper.go
+++ b/packet/bgp/helper.go
@@ -92,17 +92,17 @@ func NewTestBGPUpdateMessage() *BGPMessage {
mac, _ := net.ParseMAC("01:23:45:67:89:ab")
prefixes5 := []AddrPrefixInterface{
- NewEVPNNLRI(EVPN_ROUTE_TYPE_ETHERNET_AUTO_DISCOVERY, 0,
+ NewEVPNNLRI(EVPN_ROUTE_TYPE_ETHERNET_AUTO_DISCOVERY,
&EVPNEthernetAutoDiscoveryRoute{NewRouteDistinguisherFourOctetAS(5, 6),
EthernetSegmentIdentifier{ESI_ARBITRARY, make([]byte, 9)}, 2, 2}),
- NewEVPNNLRI(EVPN_ROUTE_TYPE_MAC_IP_ADVERTISEMENT, 0,
+ NewEVPNNLRI(EVPN_ROUTE_TYPE_MAC_IP_ADVERTISEMENT,
&EVPNMacIPAdvertisementRoute{NewRouteDistinguisherFourOctetAS(5, 6),
EthernetSegmentIdentifier{ESI_ARBITRARY, make([]byte, 9)}, 3, 48,
mac, 32, net.ParseIP("192.2.1.2"),
[]uint32{3, 4}}),
- NewEVPNNLRI(EVPN_INCLUSIVE_MULTICAST_ETHERNET_TAG, 0,
+ NewEVPNNLRI(EVPN_INCLUSIVE_MULTICAST_ETHERNET_TAG,
&EVPNMulticastEthernetTagRoute{NewRouteDistinguisherFourOctetAS(5, 6), 3, 32, net.ParseIP("192.2.1.2")}),
- NewEVPNNLRI(EVPN_ETHERNET_SEGMENT_ROUTE, 0,
+ NewEVPNNLRI(EVPN_ETHERNET_SEGMENT_ROUTE,
&EVPNEthernetSegmentRoute{NewRouteDistinguisherFourOctetAS(5, 6),
EthernetSegmentIdentifier{ESI_ARBITRARY, make([]byte, 9)},
32, net.ParseIP("192.2.1.1")}),