From 0869c837db364e1254a8962e26cfefe0f5dee718 Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Fri, 14 Oct 2022 14:25:10 +0900 Subject: [PATCH] pkg/packet/bgp: refactor Prefix-SID - Add TLVType contant values. - Add NewPathAttributePrefixSID(). - Add SRv6ServiceTLV to support SRv6 L2 Service TLV. - Move reserved field handling to each type of TLV, because header and reserved field size are different for each type. For more details, see https://www.rfc-editor.org/rfc/rfc8669.html and https://www.rfc-editor.org/rfc/rfc9252.html. --- api/attribute.pb.go | 358 ++++++++++++++++++------------ api/attribute.proto | 11 +- pkg/apiutil/attribute.go | 17 ++ pkg/apiutil/attribute_test.go | 5 +- pkg/packet/bgp/prefix_sid.go | 204 ++++++++++++++--- pkg/packet/bgp/prefix_sid_test.go | 37 +++ 6 files changed, 462 insertions(+), 170 deletions(-) diff --git a/api/attribute.pb.go b/api/attribute.pb.go index 666ee65d3..7fea90853 100644 --- a/api/attribute.pb.go +++ b/api/attribute.pb.go @@ -7531,7 +7531,7 @@ func (x *SRv6InformationSubTLV) GetSubSubTlvs() map[uint32]*SRv6TLV { return nil } -// https://tools.ietf.org/html/draft-dawra-bess-srv6-services-02#section-2 +// https://www.rfc-editor.org/rfc/rfc9252.html#section-2 type SRv6L3ServiceTLV struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -7581,6 +7581,56 @@ func (x *SRv6L3ServiceTLV) GetSubTlvs() map[uint32]*SRv6TLV { return nil } +// https://www.rfc-editor.org/rfc/rfc9252.html#section-2 +type SRv6L2ServiceTLV struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // SRv6TLV is one of: + // - SRv6InformationSubTLV + SubTlvs map[uint32]*SRv6TLV `protobuf:"bytes,1,rep,name=sub_tlvs,json=subTlvs,proto3" json:"sub_tlvs,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *SRv6L2ServiceTLV) Reset() { + *x = SRv6L2ServiceTLV{} + if protoimpl.UnsafeEnabled { + mi := &file_attribute_proto_msgTypes[117] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SRv6L2ServiceTLV) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SRv6L2ServiceTLV) ProtoMessage() {} + +func (x *SRv6L2ServiceTLV) ProtoReflect() protoreflect.Message { + mi := &file_attribute_proto_msgTypes[117] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SRv6L2ServiceTLV.ProtoReflect.Descriptor instead. +func (*SRv6L2ServiceTLV) Descriptor() ([]byte, []int) { + return file_attribute_proto_rawDescGZIP(), []int{117} +} + +func (x *SRv6L2ServiceTLV) GetSubTlvs() map[uint32]*SRv6TLV { + if x != nil { + return x.SubTlvs + } + return nil +} + // https://tools.ietf.org/html/rfc8669 type PrefixSID struct { state protoimpl.MessageState @@ -7591,14 +7641,14 @@ type PrefixSID struct { // - IndexLabelTLV Type 1 (not yet implemented) // - OriginatorSRGBTLV Type 3 (not yet implemented) // - SRv6L3ServiceTLV Type 5 - // - SRv6L2ServiceTLV Type 6 (not yet implemented) + // - SRv6L2ServiceTLV Type 6 Tlvs []*anypb.Any `protobuf:"bytes,1,rep,name=tlvs,proto3" json:"tlvs,omitempty"` } func (x *PrefixSID) Reset() { *x = PrefixSID{} if protoimpl.UnsafeEnabled { - mi := &file_attribute_proto_msgTypes[117] + mi := &file_attribute_proto_msgTypes[118] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -7611,7 +7661,7 @@ func (x *PrefixSID) String() string { func (*PrefixSID) ProtoMessage() {} func (x *PrefixSID) ProtoReflect() protoreflect.Message { - mi := &file_attribute_proto_msgTypes[117] + mi := &file_attribute_proto_msgTypes[118] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -7624,7 +7674,7 @@ func (x *PrefixSID) ProtoReflect() protoreflect.Message { // Deprecated: Use PrefixSID.ProtoReflect.Descriptor instead. func (*PrefixSID) Descriptor() ([]byte, []int) { - return file_attribute_proto_rawDescGZIP(), []int{117} + return file_attribute_proto_rawDescGZIP(), []int{118} } func (x *PrefixSID) GetTlvs() []*anypb.Any { @@ -8442,100 +8492,110 @@ var file_attribute_proto_rawDesc = []byte{ 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x24, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x61, 0x70, 0x69, 0x70, 0x62, 0x2e, 0x53, 0x52, 0x76, 0x36, - 0x54, 0x4c, 0x56, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x35, - 0x0a, 0x09, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x53, 0x49, 0x44, 0x12, 0x28, 0x0a, 0x04, 0x74, - 0x6c, 0x76, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, - 0x04, 0x74, 0x6c, 0x76, 0x73, 0x2a, 0xf7, 0x01, 0x0a, 0x0f, 0x4c, 0x73, 0x4f, 0x73, 0x70, 0x66, - 0x52, 0x6f, 0x75, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x1a, 0x4c, 0x53, 0x5f, - 0x4f, 0x53, 0x50, 0x46, 0x5f, 0x52, 0x4f, 0x55, 0x54, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, - 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x21, 0x0a, 0x1d, 0x4c, 0x53, 0x5f, - 0x4f, 0x53, 0x50, 0x46, 0x5f, 0x52, 0x4f, 0x55, 0x54, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, - 0x49, 0x4e, 0x54, 0x52, 0x41, 0x5f, 0x41, 0x52, 0x45, 0x41, 0x10, 0x01, 0x12, 0x21, 0x0a, 0x1d, - 0x4c, 0x53, 0x5f, 0x4f, 0x53, 0x50, 0x46, 0x5f, 0x52, 0x4f, 0x55, 0x54, 0x45, 0x5f, 0x54, 0x59, - 0x50, 0x45, 0x5f, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x41, 0x52, 0x45, 0x41, 0x10, 0x02, 0x12, - 0x20, 0x0a, 0x1c, 0x4c, 0x53, 0x5f, 0x4f, 0x53, 0x50, 0x46, 0x5f, 0x52, 0x4f, 0x55, 0x54, 0x45, - 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x45, 0x58, 0x54, 0x45, 0x52, 0x4e, 0x41, 0x4c, 0x31, 0x10, - 0x03, 0x12, 0x20, 0x0a, 0x1c, 0x4c, 0x53, 0x5f, 0x4f, 0x53, 0x50, 0x46, 0x5f, 0x52, 0x4f, 0x55, + 0x54, 0x4c, 0x56, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x9f, + 0x01, 0x0a, 0x10, 0x53, 0x52, 0x76, 0x36, 0x4c, 0x32, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x54, 0x4c, 0x56, 0x12, 0x3f, 0x0a, 0x08, 0x73, 0x75, 0x62, 0x5f, 0x74, 0x6c, 0x76, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x61, 0x70, 0x69, 0x70, 0x62, 0x2e, 0x53, 0x52, + 0x76, 0x36, 0x4c, 0x32, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x54, 0x4c, 0x56, 0x2e, 0x53, + 0x75, 0x62, 0x54, 0x6c, 0x76, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x73, 0x75, 0x62, + 0x54, 0x6c, 0x76, 0x73, 0x1a, 0x4a, 0x0a, 0x0c, 0x53, 0x75, 0x62, 0x54, 0x6c, 0x76, 0x73, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0d, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x24, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x61, 0x70, 0x69, 0x70, 0x62, 0x2e, 0x53, 0x52, + 0x76, 0x36, 0x54, 0x4c, 0x56, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, + 0x22, 0x35, 0x0a, 0x09, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x53, 0x49, 0x44, 0x12, 0x28, 0x0a, + 0x04, 0x74, 0x6c, 0x76, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, + 0x79, 0x52, 0x04, 0x74, 0x6c, 0x76, 0x73, 0x2a, 0xf7, 0x01, 0x0a, 0x0f, 0x4c, 0x73, 0x4f, 0x73, + 0x70, 0x66, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x1a, 0x4c, + 0x53, 0x5f, 0x4f, 0x53, 0x50, 0x46, 0x5f, 0x52, 0x4f, 0x55, 0x54, 0x45, 0x5f, 0x54, 0x59, 0x50, + 0x45, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x21, 0x0a, 0x1d, 0x4c, + 0x53, 0x5f, 0x4f, 0x53, 0x50, 0x46, 0x5f, 0x52, 0x4f, 0x55, 0x54, 0x45, 0x5f, 0x54, 0x59, 0x50, + 0x45, 0x5f, 0x49, 0x4e, 0x54, 0x52, 0x41, 0x5f, 0x41, 0x52, 0x45, 0x41, 0x10, 0x01, 0x12, 0x21, + 0x0a, 0x1d, 0x4c, 0x53, 0x5f, 0x4f, 0x53, 0x50, 0x46, 0x5f, 0x52, 0x4f, 0x55, 0x54, 0x45, 0x5f, + 0x54, 0x59, 0x50, 0x45, 0x5f, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x41, 0x52, 0x45, 0x41, 0x10, + 0x02, 0x12, 0x20, 0x0a, 0x1c, 0x4c, 0x53, 0x5f, 0x4f, 0x53, 0x50, 0x46, 0x5f, 0x52, 0x4f, 0x55, 0x54, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x45, 0x58, 0x54, 0x45, 0x52, 0x4e, 0x41, 0x4c, - 0x32, 0x10, 0x04, 0x12, 0x1c, 0x0a, 0x18, 0x4c, 0x53, 0x5f, 0x4f, 0x53, 0x50, 0x46, 0x5f, 0x52, - 0x4f, 0x55, 0x54, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4e, 0x53, 0x53, 0x41, 0x31, 0x10, - 0x05, 0x12, 0x1c, 0x0a, 0x18, 0x4c, 0x53, 0x5f, 0x4f, 0x53, 0x50, 0x46, 0x5f, 0x52, 0x4f, 0x55, - 0x54, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4e, 0x53, 0x53, 0x41, 0x32, 0x10, 0x06, 0x2a, - 0x73, 0x0a, 0x0a, 0x4c, 0x73, 0x4e, 0x4c, 0x52, 0x49, 0x54, 0x79, 0x70, 0x65, 0x12, 0x13, 0x0a, - 0x0f, 0x4c, 0x53, 0x5f, 0x4e, 0x4c, 0x52, 0x49, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, - 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x4c, 0x53, 0x5f, 0x4e, 0x4c, 0x52, 0x49, 0x5f, 0x4e, 0x4f, - 0x44, 0x45, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x4c, 0x53, 0x5f, 0x4e, 0x4c, 0x52, 0x49, 0x5f, - 0x4c, 0x49, 0x4e, 0x4b, 0x10, 0x02, 0x12, 0x15, 0x0a, 0x11, 0x4c, 0x53, 0x5f, 0x4e, 0x4c, 0x52, - 0x49, 0x5f, 0x50, 0x52, 0x45, 0x46, 0x49, 0x58, 0x5f, 0x56, 0x34, 0x10, 0x03, 0x12, 0x15, 0x0a, - 0x11, 0x4c, 0x53, 0x5f, 0x4e, 0x4c, 0x52, 0x49, 0x5f, 0x50, 0x52, 0x45, 0x46, 0x49, 0x58, 0x5f, - 0x56, 0x36, 0x10, 0x04, 0x2a, 0xbb, 0x01, 0x0a, 0x0c, 0x4c, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, - 0x63, 0x6f, 0x6c, 0x49, 0x44, 0x12, 0x17, 0x0a, 0x13, 0x4c, 0x53, 0x5f, 0x50, 0x52, 0x4f, 0x54, - 0x4f, 0x43, 0x4f, 0x4c, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x17, - 0x0a, 0x13, 0x4c, 0x53, 0x5f, 0x50, 0x52, 0x4f, 0x54, 0x4f, 0x43, 0x4f, 0x4c, 0x5f, 0x49, 0x53, - 0x49, 0x53, 0x5f, 0x4c, 0x31, 0x10, 0x01, 0x12, 0x17, 0x0a, 0x13, 0x4c, 0x53, 0x5f, 0x50, 0x52, - 0x4f, 0x54, 0x4f, 0x43, 0x4f, 0x4c, 0x5f, 0x49, 0x53, 0x49, 0x53, 0x5f, 0x4c, 0x32, 0x10, 0x02, + 0x31, 0x10, 0x03, 0x12, 0x20, 0x0a, 0x1c, 0x4c, 0x53, 0x5f, 0x4f, 0x53, 0x50, 0x46, 0x5f, 0x52, + 0x4f, 0x55, 0x54, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x45, 0x58, 0x54, 0x45, 0x52, 0x4e, + 0x41, 0x4c, 0x32, 0x10, 0x04, 0x12, 0x1c, 0x0a, 0x18, 0x4c, 0x53, 0x5f, 0x4f, 0x53, 0x50, 0x46, + 0x5f, 0x52, 0x4f, 0x55, 0x54, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4e, 0x53, 0x53, 0x41, + 0x31, 0x10, 0x05, 0x12, 0x1c, 0x0a, 0x18, 0x4c, 0x53, 0x5f, 0x4f, 0x53, 0x50, 0x46, 0x5f, 0x52, + 0x4f, 0x55, 0x54, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4e, 0x53, 0x53, 0x41, 0x32, 0x10, + 0x06, 0x2a, 0x73, 0x0a, 0x0a, 0x4c, 0x73, 0x4e, 0x4c, 0x52, 0x49, 0x54, 0x79, 0x70, 0x65, 0x12, + 0x13, 0x0a, 0x0f, 0x4c, 0x53, 0x5f, 0x4e, 0x4c, 0x52, 0x49, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, + 0x57, 0x4e, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x4c, 0x53, 0x5f, 0x4e, 0x4c, 0x52, 0x49, 0x5f, + 0x4e, 0x4f, 0x44, 0x45, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x4c, 0x53, 0x5f, 0x4e, 0x4c, 0x52, + 0x49, 0x5f, 0x4c, 0x49, 0x4e, 0x4b, 0x10, 0x02, 0x12, 0x15, 0x0a, 0x11, 0x4c, 0x53, 0x5f, 0x4e, + 0x4c, 0x52, 0x49, 0x5f, 0x50, 0x52, 0x45, 0x46, 0x49, 0x58, 0x5f, 0x56, 0x34, 0x10, 0x03, 0x12, + 0x15, 0x0a, 0x11, 0x4c, 0x53, 0x5f, 0x4e, 0x4c, 0x52, 0x49, 0x5f, 0x50, 0x52, 0x45, 0x46, 0x49, + 0x58, 0x5f, 0x56, 0x36, 0x10, 0x04, 0x2a, 0xbb, 0x01, 0x0a, 0x0c, 0x4c, 0x73, 0x50, 0x72, 0x6f, + 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x49, 0x44, 0x12, 0x17, 0x0a, 0x13, 0x4c, 0x53, 0x5f, 0x50, 0x52, + 0x4f, 0x54, 0x4f, 0x43, 0x4f, 0x4c, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, 0x4c, 0x53, 0x5f, 0x50, 0x52, 0x4f, 0x54, 0x4f, 0x43, 0x4f, 0x4c, 0x5f, - 0x4f, 0x53, 0x50, 0x46, 0x5f, 0x56, 0x32, 0x10, 0x03, 0x12, 0x16, 0x0a, 0x12, 0x4c, 0x53, 0x5f, - 0x50, 0x52, 0x4f, 0x54, 0x4f, 0x43, 0x4f, 0x4c, 0x5f, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x10, - 0x04, 0x12, 0x16, 0x0a, 0x12, 0x4c, 0x53, 0x5f, 0x50, 0x52, 0x4f, 0x54, 0x4f, 0x43, 0x4f, 0x4c, - 0x5f, 0x53, 0x54, 0x41, 0x54, 0x49, 0x43, 0x10, 0x05, 0x12, 0x17, 0x0a, 0x13, 0x4c, 0x53, 0x5f, - 0x50, 0x52, 0x4f, 0x54, 0x4f, 0x43, 0x4f, 0x4c, 0x5f, 0x4f, 0x53, 0x50, 0x46, 0x5f, 0x56, 0x33, - 0x10, 0x06, 0x2a, 0xed, 0x05, 0x0a, 0x0c, 0x53, 0x52, 0x76, 0x36, 0x42, 0x65, 0x68, 0x61, 0x76, - 0x69, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x45, 0x53, 0x45, 0x52, 0x56, 0x45, 0x44, 0x10, - 0x00, 0x12, 0x07, 0x0a, 0x03, 0x45, 0x4e, 0x44, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x45, 0x4e, - 0x44, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x50, 0x53, 0x50, 0x10, 0x02, 0x12, 0x10, 0x0a, 0x0c, - 0x45, 0x4e, 0x44, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x55, 0x53, 0x50, 0x10, 0x03, 0x12, 0x14, - 0x0a, 0x10, 0x45, 0x4e, 0x44, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x50, 0x53, 0x50, 0x5f, 0x55, - 0x53, 0x50, 0x10, 0x04, 0x12, 0x08, 0x0a, 0x04, 0x45, 0x4e, 0x44, 0x58, 0x10, 0x05, 0x12, 0x11, - 0x0a, 0x0d, 0x45, 0x4e, 0x44, 0x58, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x50, 0x53, 0x50, 0x10, - 0x06, 0x12, 0x11, 0x0a, 0x0d, 0x45, 0x4e, 0x44, 0x58, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x55, - 0x53, 0x50, 0x10, 0x07, 0x12, 0x15, 0x0a, 0x11, 0x45, 0x4e, 0x44, 0x58, 0x5f, 0x57, 0x49, 0x54, - 0x48, 0x5f, 0x50, 0x53, 0x50, 0x5f, 0x55, 0x53, 0x50, 0x10, 0x08, 0x12, 0x08, 0x0a, 0x04, 0x45, - 0x4e, 0x44, 0x54, 0x10, 0x09, 0x12, 0x11, 0x0a, 0x0d, 0x45, 0x4e, 0x44, 0x54, 0x5f, 0x57, 0x49, - 0x54, 0x48, 0x5f, 0x50, 0x53, 0x50, 0x10, 0x0a, 0x12, 0x11, 0x0a, 0x0d, 0x45, 0x4e, 0x44, 0x54, - 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x55, 0x53, 0x50, 0x10, 0x0b, 0x12, 0x15, 0x0a, 0x11, 0x45, - 0x4e, 0x44, 0x54, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x50, 0x53, 0x50, 0x5f, 0x55, 0x53, 0x50, - 0x10, 0x0c, 0x12, 0x11, 0x0a, 0x0d, 0x45, 0x4e, 0x44, 0x5f, 0x42, 0x36, 0x5f, 0x45, 0x4e, 0x43, - 0x41, 0x50, 0x53, 0x10, 0x0e, 0x12, 0x0a, 0x0a, 0x06, 0x45, 0x4e, 0x44, 0x5f, 0x42, 0x4d, 0x10, - 0x0f, 0x12, 0x0b, 0x0a, 0x07, 0x45, 0x4e, 0x44, 0x5f, 0x44, 0x58, 0x36, 0x10, 0x10, 0x12, 0x0b, - 0x0a, 0x07, 0x45, 0x4e, 0x44, 0x5f, 0x44, 0x58, 0x34, 0x10, 0x11, 0x12, 0x0b, 0x0a, 0x07, 0x45, - 0x4e, 0x44, 0x5f, 0x44, 0x54, 0x36, 0x10, 0x12, 0x12, 0x0b, 0x0a, 0x07, 0x45, 0x4e, 0x44, 0x5f, - 0x44, 0x54, 0x34, 0x10, 0x13, 0x12, 0x0c, 0x0a, 0x08, 0x45, 0x4e, 0x44, 0x5f, 0x44, 0x54, 0x34, - 0x36, 0x10, 0x14, 0x12, 0x0b, 0x0a, 0x07, 0x45, 0x4e, 0x44, 0x5f, 0x44, 0x58, 0x32, 0x10, 0x15, - 0x12, 0x0c, 0x0a, 0x08, 0x45, 0x4e, 0x44, 0x5f, 0x44, 0x58, 0x32, 0x56, 0x10, 0x16, 0x12, 0x0c, - 0x0a, 0x08, 0x45, 0x4e, 0x44, 0x5f, 0x44, 0x54, 0x32, 0x55, 0x10, 0x17, 0x12, 0x0c, 0x0a, 0x08, - 0x45, 0x4e, 0x44, 0x5f, 0x44, 0x54, 0x32, 0x4d, 0x10, 0x18, 0x12, 0x15, 0x0a, 0x11, 0x45, 0x4e, - 0x44, 0x5f, 0x42, 0x36, 0x5f, 0x45, 0x4e, 0x43, 0x41, 0x50, 0x53, 0x5f, 0x52, 0x65, 0x64, 0x10, - 0x1b, 0x12, 0x10, 0x0a, 0x0c, 0x45, 0x4e, 0x44, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x55, 0x53, - 0x44, 0x10, 0x1c, 0x12, 0x14, 0x0a, 0x10, 0x45, 0x4e, 0x44, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, - 0x50, 0x53, 0x50, 0x5f, 0x55, 0x53, 0x44, 0x10, 0x1d, 0x12, 0x14, 0x0a, 0x10, 0x45, 0x4e, 0x44, - 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x55, 0x53, 0x50, 0x5f, 0x55, 0x53, 0x44, 0x10, 0x1e, 0x12, - 0x18, 0x0a, 0x14, 0x45, 0x4e, 0x44, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x50, 0x53, 0x50, 0x5f, - 0x55, 0x53, 0x50, 0x5f, 0x55, 0x53, 0x44, 0x10, 0x1f, 0x12, 0x11, 0x0a, 0x0d, 0x45, 0x4e, 0x44, - 0x58, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x55, 0x53, 0x44, 0x10, 0x20, 0x12, 0x15, 0x0a, 0x11, + 0x49, 0x53, 0x49, 0x53, 0x5f, 0x4c, 0x31, 0x10, 0x01, 0x12, 0x17, 0x0a, 0x13, 0x4c, 0x53, 0x5f, + 0x50, 0x52, 0x4f, 0x54, 0x4f, 0x43, 0x4f, 0x4c, 0x5f, 0x49, 0x53, 0x49, 0x53, 0x5f, 0x4c, 0x32, + 0x10, 0x02, 0x12, 0x17, 0x0a, 0x13, 0x4c, 0x53, 0x5f, 0x50, 0x52, 0x4f, 0x54, 0x4f, 0x43, 0x4f, + 0x4c, 0x5f, 0x4f, 0x53, 0x50, 0x46, 0x5f, 0x56, 0x32, 0x10, 0x03, 0x12, 0x16, 0x0a, 0x12, 0x4c, + 0x53, 0x5f, 0x50, 0x52, 0x4f, 0x54, 0x4f, 0x43, 0x4f, 0x4c, 0x5f, 0x44, 0x49, 0x52, 0x45, 0x43, + 0x54, 0x10, 0x04, 0x12, 0x16, 0x0a, 0x12, 0x4c, 0x53, 0x5f, 0x50, 0x52, 0x4f, 0x54, 0x4f, 0x43, + 0x4f, 0x4c, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x49, 0x43, 0x10, 0x05, 0x12, 0x17, 0x0a, 0x13, 0x4c, + 0x53, 0x5f, 0x50, 0x52, 0x4f, 0x54, 0x4f, 0x43, 0x4f, 0x4c, 0x5f, 0x4f, 0x53, 0x50, 0x46, 0x5f, + 0x56, 0x33, 0x10, 0x06, 0x2a, 0xed, 0x05, 0x0a, 0x0c, 0x53, 0x52, 0x76, 0x36, 0x42, 0x65, 0x68, + 0x61, 0x76, 0x69, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x45, 0x53, 0x45, 0x52, 0x56, 0x45, + 0x44, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x45, 0x4e, 0x44, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, + 0x45, 0x4e, 0x44, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x50, 0x53, 0x50, 0x10, 0x02, 0x12, 0x10, + 0x0a, 0x0c, 0x45, 0x4e, 0x44, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x55, 0x53, 0x50, 0x10, 0x03, + 0x12, 0x14, 0x0a, 0x10, 0x45, 0x4e, 0x44, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x50, 0x53, 0x50, + 0x5f, 0x55, 0x53, 0x50, 0x10, 0x04, 0x12, 0x08, 0x0a, 0x04, 0x45, 0x4e, 0x44, 0x58, 0x10, 0x05, + 0x12, 0x11, 0x0a, 0x0d, 0x45, 0x4e, 0x44, 0x58, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x50, 0x53, + 0x50, 0x10, 0x06, 0x12, 0x11, 0x0a, 0x0d, 0x45, 0x4e, 0x44, 0x58, 0x5f, 0x57, 0x49, 0x54, 0x48, + 0x5f, 0x55, 0x53, 0x50, 0x10, 0x07, 0x12, 0x15, 0x0a, 0x11, 0x45, 0x4e, 0x44, 0x58, 0x5f, 0x57, + 0x49, 0x54, 0x48, 0x5f, 0x50, 0x53, 0x50, 0x5f, 0x55, 0x53, 0x50, 0x10, 0x08, 0x12, 0x08, 0x0a, + 0x04, 0x45, 0x4e, 0x44, 0x54, 0x10, 0x09, 0x12, 0x11, 0x0a, 0x0d, 0x45, 0x4e, 0x44, 0x54, 0x5f, + 0x57, 0x49, 0x54, 0x48, 0x5f, 0x50, 0x53, 0x50, 0x10, 0x0a, 0x12, 0x11, 0x0a, 0x0d, 0x45, 0x4e, + 0x44, 0x54, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x55, 0x53, 0x50, 0x10, 0x0b, 0x12, 0x15, 0x0a, + 0x11, 0x45, 0x4e, 0x44, 0x54, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x50, 0x53, 0x50, 0x5f, 0x55, + 0x53, 0x50, 0x10, 0x0c, 0x12, 0x11, 0x0a, 0x0d, 0x45, 0x4e, 0x44, 0x5f, 0x42, 0x36, 0x5f, 0x45, + 0x4e, 0x43, 0x41, 0x50, 0x53, 0x10, 0x0e, 0x12, 0x0a, 0x0a, 0x06, 0x45, 0x4e, 0x44, 0x5f, 0x42, + 0x4d, 0x10, 0x0f, 0x12, 0x0b, 0x0a, 0x07, 0x45, 0x4e, 0x44, 0x5f, 0x44, 0x58, 0x36, 0x10, 0x10, + 0x12, 0x0b, 0x0a, 0x07, 0x45, 0x4e, 0x44, 0x5f, 0x44, 0x58, 0x34, 0x10, 0x11, 0x12, 0x0b, 0x0a, + 0x07, 0x45, 0x4e, 0x44, 0x5f, 0x44, 0x54, 0x36, 0x10, 0x12, 0x12, 0x0b, 0x0a, 0x07, 0x45, 0x4e, + 0x44, 0x5f, 0x44, 0x54, 0x34, 0x10, 0x13, 0x12, 0x0c, 0x0a, 0x08, 0x45, 0x4e, 0x44, 0x5f, 0x44, + 0x54, 0x34, 0x36, 0x10, 0x14, 0x12, 0x0b, 0x0a, 0x07, 0x45, 0x4e, 0x44, 0x5f, 0x44, 0x58, 0x32, + 0x10, 0x15, 0x12, 0x0c, 0x0a, 0x08, 0x45, 0x4e, 0x44, 0x5f, 0x44, 0x58, 0x32, 0x56, 0x10, 0x16, + 0x12, 0x0c, 0x0a, 0x08, 0x45, 0x4e, 0x44, 0x5f, 0x44, 0x54, 0x32, 0x55, 0x10, 0x17, 0x12, 0x0c, + 0x0a, 0x08, 0x45, 0x4e, 0x44, 0x5f, 0x44, 0x54, 0x32, 0x4d, 0x10, 0x18, 0x12, 0x15, 0x0a, 0x11, + 0x45, 0x4e, 0x44, 0x5f, 0x42, 0x36, 0x5f, 0x45, 0x4e, 0x43, 0x41, 0x50, 0x53, 0x5f, 0x52, 0x65, + 0x64, 0x10, 0x1b, 0x12, 0x10, 0x0a, 0x0c, 0x45, 0x4e, 0x44, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, + 0x55, 0x53, 0x44, 0x10, 0x1c, 0x12, 0x14, 0x0a, 0x10, 0x45, 0x4e, 0x44, 0x5f, 0x57, 0x49, 0x54, + 0x48, 0x5f, 0x50, 0x53, 0x50, 0x5f, 0x55, 0x53, 0x44, 0x10, 0x1d, 0x12, 0x14, 0x0a, 0x10, 0x45, + 0x4e, 0x44, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x55, 0x53, 0x50, 0x5f, 0x55, 0x53, 0x44, 0x10, + 0x1e, 0x12, 0x18, 0x0a, 0x14, 0x45, 0x4e, 0x44, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x50, 0x53, + 0x50, 0x5f, 0x55, 0x53, 0x50, 0x5f, 0x55, 0x53, 0x44, 0x10, 0x1f, 0x12, 0x11, 0x0a, 0x0d, 0x45, + 0x4e, 0x44, 0x58, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x55, 0x53, 0x44, 0x10, 0x20, 0x12, 0x15, + 0x0a, 0x11, 0x45, 0x4e, 0x44, 0x58, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x50, 0x53, 0x50, 0x5f, + 0x55, 0x53, 0x44, 0x10, 0x21, 0x12, 0x15, 0x0a, 0x11, 0x45, 0x4e, 0x44, 0x58, 0x5f, 0x57, 0x49, + 0x54, 0x48, 0x5f, 0x55, 0x53, 0x50, 0x5f, 0x55, 0x53, 0x44, 0x10, 0x22, 0x12, 0x19, 0x0a, 0x15, 0x45, 0x4e, 0x44, 0x58, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x50, 0x53, 0x50, 0x5f, 0x55, 0x53, - 0x44, 0x10, 0x21, 0x12, 0x15, 0x0a, 0x11, 0x45, 0x4e, 0x44, 0x58, 0x5f, 0x57, 0x49, 0x54, 0x48, - 0x5f, 0x55, 0x53, 0x50, 0x5f, 0x55, 0x53, 0x44, 0x10, 0x22, 0x12, 0x19, 0x0a, 0x15, 0x45, 0x4e, - 0x44, 0x58, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x50, 0x53, 0x50, 0x5f, 0x55, 0x53, 0x50, 0x5f, - 0x55, 0x53, 0x44, 0x10, 0x23, 0x12, 0x11, 0x0a, 0x0d, 0x45, 0x4e, 0x44, 0x54, 0x5f, 0x57, 0x49, - 0x54, 0x48, 0x5f, 0x55, 0x53, 0x44, 0x10, 0x24, 0x12, 0x15, 0x0a, 0x11, 0x45, 0x4e, 0x44, 0x54, - 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x50, 0x53, 0x50, 0x5f, 0x55, 0x53, 0x44, 0x10, 0x25, 0x12, - 0x15, 0x0a, 0x11, 0x45, 0x4e, 0x44, 0x54, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x55, 0x53, 0x50, - 0x5f, 0x55, 0x53, 0x44, 0x10, 0x26, 0x12, 0x19, 0x0a, 0x15, 0x45, 0x4e, 0x44, 0x54, 0x5f, 0x57, - 0x49, 0x54, 0x48, 0x5f, 0x50, 0x53, 0x50, 0x5f, 0x55, 0x53, 0x50, 0x5f, 0x55, 0x53, 0x44, 0x10, - 0x27, 0x12, 0x0e, 0x0a, 0x0a, 0x45, 0x4e, 0x44, 0x4d, 0x5f, 0x47, 0x54, 0x50, 0x36, 0x44, 0x10, - 0x2d, 0x12, 0x0f, 0x0a, 0x0b, 0x45, 0x4e, 0x44, 0x4d, 0x5f, 0x47, 0x54, 0x50, 0x36, 0x44, 0x49, - 0x10, 0x2e, 0x12, 0x0e, 0x0a, 0x0a, 0x45, 0x4e, 0x44, 0x4d, 0x5f, 0x47, 0x54, 0x50, 0x36, 0x45, - 0x10, 0x2f, 0x12, 0x0e, 0x0a, 0x0a, 0x45, 0x4e, 0x44, 0x4d, 0x5f, 0x47, 0x54, 0x50, 0x34, 0x45, - 0x10, 0x30, 0x2a, 0x44, 0x0a, 0x08, 0x45, 0x4e, 0x4c, 0x50, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0c, - 0x0a, 0x08, 0x52, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, - 0x54, 0x79, 0x70, 0x65, 0x31, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x54, 0x79, 0x70, 0x65, 0x32, - 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x54, 0x79, 0x70, 0x65, 0x33, 0x10, 0x03, 0x12, 0x09, 0x0a, - 0x05, 0x54, 0x79, 0x70, 0x65, 0x34, 0x10, 0x04, 0x42, 0x24, 0x5a, 0x22, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x73, 0x72, 0x67, 0x2f, 0x67, 0x6f, 0x62, 0x67, - 0x70, 0x2f, 0x76, 0x33, 0x2f, 0x61, 0x70, 0x69, 0x3b, 0x61, 0x70, 0x69, 0x70, 0x62, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x50, 0x5f, 0x55, 0x53, 0x44, 0x10, 0x23, 0x12, 0x11, 0x0a, 0x0d, 0x45, 0x4e, 0x44, 0x54, 0x5f, + 0x57, 0x49, 0x54, 0x48, 0x5f, 0x55, 0x53, 0x44, 0x10, 0x24, 0x12, 0x15, 0x0a, 0x11, 0x45, 0x4e, + 0x44, 0x54, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x50, 0x53, 0x50, 0x5f, 0x55, 0x53, 0x44, 0x10, + 0x25, 0x12, 0x15, 0x0a, 0x11, 0x45, 0x4e, 0x44, 0x54, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x55, + 0x53, 0x50, 0x5f, 0x55, 0x53, 0x44, 0x10, 0x26, 0x12, 0x19, 0x0a, 0x15, 0x45, 0x4e, 0x44, 0x54, + 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x50, 0x53, 0x50, 0x5f, 0x55, 0x53, 0x50, 0x5f, 0x55, 0x53, + 0x44, 0x10, 0x27, 0x12, 0x0e, 0x0a, 0x0a, 0x45, 0x4e, 0x44, 0x4d, 0x5f, 0x47, 0x54, 0x50, 0x36, + 0x44, 0x10, 0x2d, 0x12, 0x0f, 0x0a, 0x0b, 0x45, 0x4e, 0x44, 0x4d, 0x5f, 0x47, 0x54, 0x50, 0x36, + 0x44, 0x49, 0x10, 0x2e, 0x12, 0x0e, 0x0a, 0x0a, 0x45, 0x4e, 0x44, 0x4d, 0x5f, 0x47, 0x54, 0x50, + 0x36, 0x45, 0x10, 0x2f, 0x12, 0x0e, 0x0a, 0x0a, 0x45, 0x4e, 0x44, 0x4d, 0x5f, 0x47, 0x54, 0x50, + 0x34, 0x45, 0x10, 0x30, 0x2a, 0x44, 0x0a, 0x08, 0x45, 0x4e, 0x4c, 0x50, 0x54, 0x79, 0x70, 0x65, + 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x10, 0x00, 0x12, 0x09, + 0x0a, 0x05, 0x54, 0x79, 0x70, 0x65, 0x31, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x54, 0x79, 0x70, + 0x65, 0x32, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x54, 0x79, 0x70, 0x65, 0x33, 0x10, 0x03, 0x12, + 0x09, 0x0a, 0x05, 0x54, 0x79, 0x70, 0x65, 0x34, 0x10, 0x04, 0x42, 0x24, 0x5a, 0x22, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x73, 0x72, 0x67, 0x2f, 0x67, 0x6f, + 0x62, 0x67, 0x70, 0x2f, 0x76, 0x33, 0x2f, 0x61, 0x70, 0x69, 0x3b, 0x61, 0x70, 0x69, 0x70, 0x62, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -8551,7 +8611,7 @@ func file_attribute_proto_rawDescGZIP() []byte { } var file_attribute_proto_enumTypes = make([]protoimpl.EnumInfo, 6) -var file_attribute_proto_msgTypes = make([]protoimpl.MessageInfo, 120) +var file_attribute_proto_msgTypes = make([]protoimpl.MessageInfo, 122) var file_attribute_proto_goTypes = []interface{}{ (LsOspfRouteType)(0), // 0: apipb.LsOspfRouteType (LsNLRIType)(0), // 1: apipb.LsNLRIType @@ -8676,32 +8736,34 @@ var file_attribute_proto_goTypes = []interface{}{ (*SRv6TLV)(nil), // 120: apipb.SRv6TLV (*SRv6InformationSubTLV)(nil), // 121: apipb.SRv6InformationSubTLV (*SRv6L3ServiceTLV)(nil), // 122: apipb.SRv6L3ServiceTLV - (*PrefixSID)(nil), // 123: apipb.PrefixSID - nil, // 124: apipb.SRv6InformationSubTLV.SubSubTlvsEntry - nil, // 125: apipb.SRv6L3ServiceTLV.SubTlvsEntry - (*anypb.Any)(nil), // 126: google.protobuf.Any - (*Family)(nil), // 127: apipb.Family + (*SRv6L2ServiceTLV)(nil), // 123: apipb.SRv6L2ServiceTLV + (*PrefixSID)(nil), // 124: apipb.PrefixSID + nil, // 125: apipb.SRv6InformationSubTLV.SubSubTlvsEntry + nil, // 126: apipb.SRv6L3ServiceTLV.SubTlvsEntry + nil, // 127: apipb.SRv6L2ServiceTLV.SubTlvsEntry + (*anypb.Any)(nil), // 128: google.protobuf.Any + (*Family)(nil), // 129: apipb.Family } var file_attribute_proto_depIdxs = []int32{ 5, // 0: apipb.AsSegment.type:type_name -> apipb.AsSegment.Type 7, // 1: apipb.AsPathAttribute.segments:type_name -> apipb.AsSegment - 126, // 2: apipb.EVPNEthernetAutoDiscoveryRoute.rd:type_name -> google.protobuf.Any + 128, // 2: apipb.EVPNEthernetAutoDiscoveryRoute.rd:type_name -> google.protobuf.Any 23, // 3: apipb.EVPNEthernetAutoDiscoveryRoute.esi:type_name -> apipb.EthernetSegmentIdentifier - 126, // 4: apipb.EVPNMACIPAdvertisementRoute.rd:type_name -> google.protobuf.Any + 128, // 4: apipb.EVPNMACIPAdvertisementRoute.rd:type_name -> google.protobuf.Any 23, // 5: apipb.EVPNMACIPAdvertisementRoute.esi:type_name -> apipb.EthernetSegmentIdentifier - 126, // 6: apipb.EVPNInclusiveMulticastEthernetTagRoute.rd:type_name -> google.protobuf.Any - 126, // 7: apipb.EVPNEthernetSegmentRoute.rd:type_name -> google.protobuf.Any + 128, // 6: apipb.EVPNInclusiveMulticastEthernetTagRoute.rd:type_name -> google.protobuf.Any + 128, // 7: apipb.EVPNEthernetSegmentRoute.rd:type_name -> google.protobuf.Any 23, // 8: apipb.EVPNEthernetSegmentRoute.esi:type_name -> apipb.EthernetSegmentIdentifier - 126, // 9: apipb.EVPNIPPrefixRoute.rd:type_name -> google.protobuf.Any + 128, // 9: apipb.EVPNIPPrefixRoute.rd:type_name -> google.protobuf.Any 23, // 10: apipb.EVPNIPPrefixRoute.esi:type_name -> apipb.EthernetSegmentIdentifier - 126, // 11: apipb.EVPNIPMSIRoute.rd:type_name -> google.protobuf.Any - 126, // 12: apipb.EVPNIPMSIRoute.rt:type_name -> google.protobuf.Any - 126, // 13: apipb.LabeledVPNIPAddressPrefix.rd:type_name -> google.protobuf.Any - 126, // 14: apipb.RouteTargetMembershipNLRI.rt:type_name -> google.protobuf.Any + 128, // 11: apipb.EVPNIPMSIRoute.rd:type_name -> google.protobuf.Any + 128, // 12: apipb.EVPNIPMSIRoute.rt:type_name -> google.protobuf.Any + 128, // 13: apipb.LabeledVPNIPAddressPrefix.rd:type_name -> google.protobuf.Any + 128, // 14: apipb.RouteTargetMembershipNLRI.rt:type_name -> google.protobuf.Any 35, // 15: apipb.FlowSpecComponent.items:type_name -> apipb.FlowSpecComponentItem - 126, // 16: apipb.FlowSpecNLRI.rules:type_name -> google.protobuf.Any - 126, // 17: apipb.VPNFlowSpecNLRI.rd:type_name -> google.protobuf.Any - 126, // 18: apipb.VPNFlowSpecNLRI.rules:type_name -> google.protobuf.Any + 128, // 16: apipb.FlowSpecNLRI.rules:type_name -> google.protobuf.Any + 128, // 17: apipb.VPNFlowSpecNLRI.rd:type_name -> google.protobuf.Any + 128, // 18: apipb.VPNFlowSpecNLRI.rules:type_name -> google.protobuf.Any 0, // 19: apipb.LsPrefixDescriptor.ospf_route_type:type_name -> apipb.LsOspfRouteType 40, // 20: apipb.LsNodeNLRI.local_node:type_name -> apipb.LsNodeDescriptor 40, // 21: apipb.LsLinkNLRI.local_node:type_name -> apipb.LsNodeDescriptor @@ -8712,19 +8774,19 @@ var file_attribute_proto_depIdxs = []int32{ 40, // 26: apipb.LsPrefixV6NLRI.local_node:type_name -> apipb.LsNodeDescriptor 42, // 27: apipb.LsPrefixV6NLRI.prefix_descriptor:type_name -> apipb.LsPrefixDescriptor 1, // 28: apipb.LsAddrPrefix.type:type_name -> apipb.LsNLRIType - 126, // 29: apipb.LsAddrPrefix.nlri:type_name -> google.protobuf.Any + 128, // 29: apipb.LsAddrPrefix.nlri:type_name -> google.protobuf.Any 2, // 30: apipb.LsAddrPrefix.protocol_id:type_name -> apipb.LsProtocolID - 126, // 31: apipb.MUPInterworkSegmentDiscoveryRoute.rd:type_name -> google.protobuf.Any - 126, // 32: apipb.MUPDirectSegmentDiscoveryRoute.rd:type_name -> google.protobuf.Any - 126, // 33: apipb.MUPType1SessionTransformedRoute.rd:type_name -> google.protobuf.Any - 126, // 34: apipb.MUPType2SessionTransformedRoute.rd:type_name -> google.protobuf.Any - 127, // 35: apipb.MpReachNLRIAttribute.family:type_name -> apipb.Family - 126, // 36: apipb.MpReachNLRIAttribute.nlris:type_name -> google.protobuf.Any - 127, // 37: apipb.MpUnreachNLRIAttribute.family:type_name -> apipb.Family - 126, // 38: apipb.MpUnreachNLRIAttribute.nlris:type_name -> google.protobuf.Any - 126, // 39: apipb.ExtendedCommunitiesAttribute.communities:type_name -> google.protobuf.Any + 128, // 31: apipb.MUPInterworkSegmentDiscoveryRoute.rd:type_name -> google.protobuf.Any + 128, // 32: apipb.MUPDirectSegmentDiscoveryRoute.rd:type_name -> google.protobuf.Any + 128, // 33: apipb.MUPType1SessionTransformedRoute.rd:type_name -> google.protobuf.Any + 128, // 34: apipb.MUPType2SessionTransformedRoute.rd:type_name -> google.protobuf.Any + 129, // 35: apipb.MpReachNLRIAttribute.family:type_name -> apipb.Family + 128, // 36: apipb.MpReachNLRIAttribute.nlris:type_name -> google.protobuf.Any + 129, // 37: apipb.MpUnreachNLRIAttribute.family:type_name -> apipb.Family + 128, // 38: apipb.MpUnreachNLRIAttribute.nlris:type_name -> google.protobuf.Any + 128, // 39: apipb.ExtendedCommunitiesAttribute.communities:type_name -> google.protobuf.Any 7, // 40: apipb.As4PathAttribute.segments:type_name -> apipb.AsSegment - 126, // 41: apipb.TunnelEncapSubTLVSRBindingSID.bsid:type_name -> google.protobuf.Any + 128, // 41: apipb.TunnelEncapSubTLVSRBindingSID.bsid:type_name -> google.protobuf.Any 3, // 42: apipb.SRv6EndPointBehavior.behavior:type_name -> apipb.SRv6Behavior 87, // 43: apipb.SRv6BindingSID.endpoint_behavior_structure:type_name -> apipb.SRv6EndPointBehavior 4, // 44: apipb.TunnelEncapSubTLVSRENLP.enlp:type_name -> apipb.ENLPType @@ -8732,11 +8794,11 @@ var file_attribute_proto_depIdxs = []int32{ 91, // 46: apipb.SegmentTypeB.flags:type_name -> apipb.SegmentFlags 87, // 47: apipb.SegmentTypeB.endpoint_behavior_structure:type_name -> apipb.SRv6EndPointBehavior 90, // 48: apipb.TunnelEncapSubTLVSRSegmentList.weight:type_name -> apipb.SRWeight - 126, // 49: apipb.TunnelEncapSubTLVSRSegmentList.segments:type_name -> google.protobuf.Any - 126, // 50: apipb.TunnelEncapTLV.tlvs:type_name -> google.protobuf.Any + 128, // 49: apipb.TunnelEncapSubTLVSRSegmentList.segments:type_name -> google.protobuf.Any + 128, // 50: apipb.TunnelEncapTLV.tlvs:type_name -> google.protobuf.Any 98, // 51: apipb.TunnelEncapAttribute.tlvs:type_name -> apipb.TunnelEncapTLV - 126, // 52: apipb.IP6ExtendedCommunitiesAttribute.communities:type_name -> google.protobuf.Any - 126, // 53: apipb.AigpAttribute.tlvs:type_name -> google.protobuf.Any + 128, // 52: apipb.IP6ExtendedCommunitiesAttribute.communities:type_name -> google.protobuf.Any + 128, // 53: apipb.AigpAttribute.tlvs:type_name -> google.protobuf.Any 106, // 54: apipb.LargeCommunitiesAttribute.communities:type_name -> apipb.LargeCommunity 110, // 55: apipb.LsSrCapabilities.ranges:type_name -> apipb.LsSrRange 110, // 56: apipb.LsSrLocalBlock.ranges:type_name -> apipb.LsSrRange @@ -8747,18 +8809,20 @@ var file_attribute_proto_depIdxs = []int32{ 113, // 61: apipb.LsAttribute.node:type_name -> apipb.LsAttributeNode 114, // 62: apipb.LsAttribute.link:type_name -> apipb.LsAttributeLink 115, // 63: apipb.LsAttribute.prefix:type_name -> apipb.LsAttributePrefix - 126, // 64: apipb.SRv6TLV.tlv:type_name -> google.protobuf.Any + 128, // 64: apipb.SRv6TLV.tlv:type_name -> google.protobuf.Any 119, // 65: apipb.SRv6InformationSubTLV.flags:type_name -> apipb.SRv6SIDFlags - 124, // 66: apipb.SRv6InformationSubTLV.sub_sub_tlvs:type_name -> apipb.SRv6InformationSubTLV.SubSubTlvsEntry - 125, // 67: apipb.SRv6L3ServiceTLV.sub_tlvs:type_name -> apipb.SRv6L3ServiceTLV.SubTlvsEntry - 126, // 68: apipb.PrefixSID.tlvs:type_name -> google.protobuf.Any - 120, // 69: apipb.SRv6InformationSubTLV.SubSubTlvsEntry.value:type_name -> apipb.SRv6TLV - 120, // 70: apipb.SRv6L3ServiceTLV.SubTlvsEntry.value:type_name -> apipb.SRv6TLV - 71, // [71:71] is the sub-list for method output_type - 71, // [71:71] is the sub-list for method input_type - 71, // [71:71] is the sub-list for extension type_name - 71, // [71:71] is the sub-list for extension extendee - 0, // [0:71] is the sub-list for field type_name + 125, // 66: apipb.SRv6InformationSubTLV.sub_sub_tlvs:type_name -> apipb.SRv6InformationSubTLV.SubSubTlvsEntry + 126, // 67: apipb.SRv6L3ServiceTLV.sub_tlvs:type_name -> apipb.SRv6L3ServiceTLV.SubTlvsEntry + 127, // 68: apipb.SRv6L2ServiceTLV.sub_tlvs:type_name -> apipb.SRv6L2ServiceTLV.SubTlvsEntry + 128, // 69: apipb.PrefixSID.tlvs:type_name -> google.protobuf.Any + 120, // 70: apipb.SRv6InformationSubTLV.SubSubTlvsEntry.value:type_name -> apipb.SRv6TLV + 120, // 71: apipb.SRv6L3ServiceTLV.SubTlvsEntry.value:type_name -> apipb.SRv6TLV + 120, // 72: apipb.SRv6L2ServiceTLV.SubTlvsEntry.value:type_name -> apipb.SRv6TLV + 73, // [73:73] is the sub-list for method output_type + 73, // [73:73] is the sub-list for method input_type + 73, // [73:73] is the sub-list for extension type_name + 73, // [73:73] is the sub-list for extension extendee + 0, // [0:73] is the sub-list for field type_name } func init() { file_attribute_proto_init() } @@ -10173,6 +10237,18 @@ func file_attribute_proto_init() { } } file_attribute_proto_msgTypes[117].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SRv6L2ServiceTLV); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_attribute_proto_msgTypes[118].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*PrefixSID); i { case 0: return &v.state @@ -10191,7 +10267,7 @@ func file_attribute_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_attribute_proto_rawDesc, NumEnums: 6, - NumMessages: 120, + NumMessages: 122, NumExtensions: 0, NumServices: 0, }, diff --git a/api/attribute.proto b/api/attribute.proto index 46d6d5a61..5919c3109 100644 --- a/api/attribute.proto +++ b/api/attribute.proto @@ -868,19 +868,26 @@ message SRv6InformationSubTLV { map sub_sub_tlvs = 4; } -// https://tools.ietf.org/html/draft-dawra-bess-srv6-services-02#section-2 +// https://www.rfc-editor.org/rfc/rfc9252.html#section-2 message SRv6L3ServiceTLV { // SRv6TLV is one of: // - SRv6InformationSubTLV map sub_tlvs = 1; } +// https://www.rfc-editor.org/rfc/rfc9252.html#section-2 +message SRv6L2ServiceTLV { + // SRv6TLV is one of: + // - SRv6InformationSubTLV + map sub_tlvs = 1; +} + // https://tools.ietf.org/html/rfc8669 message PrefixSID { // tlv is one of: // - IndexLabelTLV Type 1 (not yet implemented) // - OriginatorSRGBTLV Type 3 (not yet implemented) // - SRv6L3ServiceTLV Type 5 - // - SRv6L2ServiceTLV Type 6 (not yet implemented) + // - SRv6L2ServiceTLV Type 6 repeated google.protobuf.Any tlvs = 1; } diff --git a/pkg/apiutil/attribute.go b/pkg/apiutil/attribute.go index fc9628b25..ae4fc0746 100644 --- a/pkg/apiutil/attribute.go +++ b/pkg/apiutil/attribute.go @@ -373,6 +373,23 @@ func MarshalSRv6TLVs(tlvs []bgp.PrefixSIDTLVInterface) ([]*apb.Any, error) { return nil, err } r = o + case *bgp.SRv6ServiceTLV: + switch t.TLV.Type { + case bgp.TLVTypeSRv6L3Service: + o := &api.SRv6L3ServiceTLV{} + o.SubTlvs, err = MarshalSRv6SubTLVs(t.SubTLVs) + if err != nil { + return nil, err + } + r = o + case bgp.TLVTypeSRv6L2Service: + o := &api.SRv6L2ServiceTLV{} + o.SubTlvs, err = MarshalSRv6SubTLVs(t.SubTLVs) + if err != nil { + return nil, err + } + r = o + } default: return nil, fmt.Errorf("invalid prefix sid tlv type to marshal %v", t) } diff --git a/pkg/apiutil/attribute_test.go b/pkg/apiutil/attribute_test.go index d9414e585..7953173ac 100644 --- a/pkg/apiutil/attribute_test.go +++ b/pkg/apiutil/attribute_test.go @@ -1790,7 +1790,10 @@ func TestFullCyclePrefixSID(t *testing.T) { t.Fatalf("test failed with error: %+v", err) } // Converting from Native to API - apiPrefixSID, _ := NewPrefixSIDAttributeFromNative(&attribute) + apiPrefixSID, err := NewPrefixSIDAttributeFromNative(&attribute) + if err != nil { + t.Fatalf("test failed with error: %+v", err) + } // Converting back from API to Native recoveredPrefixSID, err := UnmarshalPrefixSID(apiPrefixSID) if err != nil { diff --git a/pkg/packet/bgp/prefix_sid.go b/pkg/packet/bgp/prefix_sid.go index 84366493b..ff4069eaa 100644 --- a/pkg/packet/bgp/prefix_sid.go +++ b/pkg/packet/bgp/prefix_sid.go @@ -6,54 +6,61 @@ import ( "encoding/json" "fmt" "net" + "net/netip" ) const ( prefixSIDtlvHdrLen = 4 ) +// BGP Prefix-SID TLV Types +// https://www.iana.org/assignments/bgp-parameters/bgp-parameters.xhtml#bgp-prefix-sid-tlv-types type TLVType uint8 +const ( + _ TLVType = iota // Reserved + TLVTypeLavelIndex + _ // Deprecated + TLVTypeOriginatorSRGB + _ // Deprecated + TLVTypeSRv6L3Service + TLVTypeSRv6L2Service +) + type TLV struct { Type TLVType Length uint16 } -func (s *TLV) Len() int { - return int(s.Length) + tlvHdrLen - 1 // Extra reserved byte in the header +func (t *TLV) Len() int { + return int(t.Length) + 3 // Type(1) + Length(2) } -func (s *TLV) Serialize(value []byte) ([]byte, error) { - if len(value) != int(s.Length)-1 { +func (t *TLV) Serialize(value []byte) ([]byte, error) { + if len(value) != int(t.Len()) { return nil, malformedAttrListErr("serialization failed: Prefix SID TLV malformed") } - buf := make([]byte, prefixSIDtlvHdrLen+len(value)) p := 0 - buf[p] = byte(s.Type) - p++ - binary.BigEndian.PutUint16(buf[p:p+2], uint16(s.Length)) - p += 2 - // Reserved byte + value[p] = byte(t.Type) p++ - copy(buf[p:], value) - - return buf, nil + binary.BigEndian.PutUint16(value[p:p+2], uint16(t.Length)) + return value, nil } -func (s *TLV) DecodeFromBytes(data []byte) ([]byte, error) { - if len(data) < prefixSIDtlvHdrLen { +func (t *TLV) DecodeFromBytes(data []byte) ([]byte, error) { + if len(data) < 3 { return nil, malformedAttrListErr("decoding failed: Prefix SID TLV malformed") } p := 0 - s.Type = TLVType(data[p]) + t.Type = TLVType(data[p]) p++ - s.Length = binary.BigEndian.Uint16(data[p : p+2]) + t.Length = binary.BigEndian.Uint16(data[p : p+2]) + p += 2 - if s.Len() < prefixSIDtlvHdrLen || len(data) < s.Len() { + if len(data[p:]) < int(t.Length) { return nil, malformedAttrListErr("decoding failed: Prefix SID TLV malformed") } - - return data[prefixSIDtlvHdrLen:s.Len()], nil + return data[p : p+int(t.Length)], nil } // PrefixSIDTLVInterface defines standard set of methods to handle Prefix SID attribute's TLVs @@ -74,6 +81,21 @@ type PathAttributePrefixSID struct { TLVs []PrefixSIDTLVInterface } +func NewPathAttributePrefixSID(values ...PrefixSIDTLVInterface) *PathAttributePrefixSID { + var l int + for _, v := range values { + l += v.Len() + } + return &PathAttributePrefixSID{ + PathAttribute: PathAttribute{ + Flags: getPathAttrFlags(BGP_ATTR_TYPE_PREFIX_SID, l), + Type: BGP_ATTR_TYPE_PREFIX_SID, + Length: uint16(l), + }, + TLVs: values, + } +} + func (p *PathAttributePrefixSID) DecodeFromBytes(data []byte, options ...*MarshallingOption) error { tlvs, err := p.PathAttribute.DecodeFromBytes(data) if err != nil { @@ -89,8 +111,8 @@ func (p *PathAttributePrefixSID) DecodeFromBytes(data []byte, options ...*Marsha var tlv PrefixSIDTLVInterface switch t.Type { - case 5: - tlv = &SRv6L3ServiceAttribute{ + case TLVTypeSRv6L3Service, TLVTypeSRv6L2Service: + tlv = &SRv6ServiceTLV{ SubTLVs: make([]PrefixSIDTLVInterface, 0), } default: @@ -158,6 +180,7 @@ type SRv6L3Service struct { } // SRv6L3ServiceAttribute defines the structure of SRv6 L3 Service attribute +// Deprecated: Use SRv6ServiceTLV instead. type SRv6L3ServiceAttribute struct { TLV SubTLVs []PrefixSIDTLVInterface @@ -168,13 +191,15 @@ func (s *SRv6L3ServiceAttribute) Len() int { } func (s *SRv6L3ServiceAttribute) Serialize() ([]byte, error) { - buf := make([]byte, 0) + buf := make([]byte, s.Length+3) + p := 4 for _, tlv := range s.SubTLVs { s, err := tlv.Serialize() if err != nil { return nil, err } - buf = append(buf, s...) + copy(buf[p:p+len(s)], s) + p += len(s) } return s.TLV.Serialize(buf) } @@ -184,6 +209,7 @@ func (s *SRv6L3ServiceAttribute) DecodeFromBytes(data []byte) error { if err != nil { return err } + stlvs = stlvs[1:] // RESERVED(1) for len(stlvs) >= subTLVHdrLen { t := &SubTLV{} @@ -274,13 +300,13 @@ func (s *SubTLV) Serialize(value []byte) ([]byte, error) { func (s *SubTLV) DecodeFromBytes(data []byte) ([]byte, error) { if len(data) < subTLVHdrLen { - return nil, malformedAttrListErr("decoding failed: Prefix SID TLV malformed") + return nil, malformedAttrListErr("decoding failed: Prefix SID Sub TLV malformed") } s.Type = SubTLVType(data[0]) s.Length = binary.BigEndian.Uint16(data[1:3]) if len(data) < s.Len() { - return nil, malformedAttrListErr("decoding failed: Prefix SID TLV malformed") + return nil, malformedAttrListErr("decoding failed: Prefix SID Sub TLV malformed") } return data[subTLVHdrLen:s.Len()], nil @@ -303,6 +329,23 @@ type SRv6InformationSubTLV struct { SubSubTLVs []PrefixSIDTLVInterface } +func NewSRv6InformationSubTLV(sid netip.Addr, behavior SRBehavior, values ...PrefixSIDTLVInterface) *SRv6InformationSubTLV { + l := 21 // RESERVED1(1) + SID(16) + Flags(1) + Endpoint Behavior(2) + RESERVED2(1) + for _, v := range values { + l += v.Len() + } + return &SRv6InformationSubTLV{ + SubTLV: SubTLV{ + Type: 1, + Length: uint16(l), + }, + SID: sid.AsSlice(), + Flags: 0, + EndpointBehavior: uint16(behavior), + SubSubTLVs: values, + } +} + func (s *SRv6InformationSubTLV) Len() int { return int(s.Length) + subTLVHdrLen } @@ -471,6 +514,21 @@ type SRv6SIDStructureSubSubTLV struct { TranspositionOffset uint8 } +func NewSRv6SIDStructureSubSubTLV(lbl, lnl, fl, al, tl, to uint8) *SRv6SIDStructureSubSubTLV { + return &SRv6SIDStructureSubSubTLV{ + SubSubTLV: SubSubTLV{ + Type: 1, + Length: 6, + }, + LocatorBlockLength: lbl, + LocatorNodeLength: lnl, + FunctionLength: fl, + ArgumentLength: al, + TranspositionLength: tl, + TranspositionOffset: to, + } +} + func (s *SRv6SIDStructureSubSubTLV) Len() int { return int(s.Length) + subSubTLVHdrLen } @@ -540,3 +598,97 @@ func (s *SRv6SIDStructureSubSubTLV) String() string { s.TranspositionOffset, ) } + +// SRv6ServiceTLV represents SRv6 Service TLV. +// https://www.rfc-editor.org/rfc/rfc9252.html#section-2 +type SRv6ServiceTLV struct { + TLV + SubTLVs []PrefixSIDTLVInterface +} + +func NewSRv6ServiceTLV(t TLVType, values ...PrefixSIDTLVInterface) *SRv6ServiceTLV { + l := 1 // RESERVED(1) + for _, v := range values { + l += v.Len() + } + return &SRv6ServiceTLV{ + TLV: TLV{ + Type: t, + Length: uint16(l), + }, + SubTLVs: values, + } +} + +func (s *SRv6ServiceTLV) Len() int { + return int(s.Length) + 3 // Type(1) + Length(2) +} + +func (t *SRv6ServiceTLV) Serialize() ([]byte, error) { + buf := make([]byte, t.Len()) + p := 4 + for _, tlv := range t.SubTLVs { + b, err := tlv.Serialize() + if err != nil { + return nil, err + } + copy(buf[p:p+len(b)], b) + p += len(b) + } + return t.TLV.Serialize(buf) +} + +func (s *SRv6ServiceTLV) DecodeFromBytes(data []byte) error { + stlvs, err := s.TLV.DecodeFromBytes(data) + if err != nil { + return err + } + stlvs = stlvs[1:] // RESERVED(1) + + for len(stlvs) >= subTLVHdrLen { + t := &SubTLV{} + _, err := t.DecodeFromBytes(stlvs) + if err != nil { + return err + } + + var stlv PrefixSIDTLVInterface + switch t.Type { + case 1: + stlv = &SRv6InformationSubTLV{ + SubSubTLVs: make([]PrefixSIDTLVInterface, 0), + } + default: + data = data[t.Len():] + continue + } + + if err := stlv.DecodeFromBytes(stlvs); err != nil { + return err + } + stlvs = stlvs[t.Len():] + s.SubTLVs = append(s.SubTLVs, stlv) + } + + return nil +} + +func (t *SRv6ServiceTLV) MarshalJSON() ([]byte, error) { + return json.Marshal(struct { + Type TLVType `json:"type"` + SubTLVs []PrefixSIDTLVInterface + }{ + t.Type, + t.SubTLVs, + }) +} + +func (t *SRv6ServiceTLV) String() string { + var buf bytes.Buffer + + for _, tlv := range t.SubTLVs { + buf.WriteString(fmt.Sprintf("%s ", tlv.String())) + } + + return fmt.Sprintf("{SRv6 Service TLV: %s}", buf.String()) +} diff --git a/pkg/packet/bgp/prefix_sid_test.go b/pkg/packet/bgp/prefix_sid_test.go index 2df8a3a30..bebf23b00 100644 --- a/pkg/packet/bgp/prefix_sid_test.go +++ b/pkg/packet/bgp/prefix_sid_test.go @@ -2,6 +2,7 @@ package bgp import ( "bytes" + "net/netip" "testing" ) @@ -88,3 +89,39 @@ func TestRoundTripPrefixSID(t *testing.T) { }) } } + +func TestNewPathAttributePrefixSID(t *testing.T) { + prefix := netip.MustParsePrefix("2001:0:5:3::/64") + tests := []struct { + name string + psid *PathAttributePrefixSID + want []byte + }{ + { + name: "srv6 prefix sid", + psid: NewPathAttributePrefixSID( + NewSRv6ServiceTLV( + TLVTypeSRv6L3Service, + NewSRv6InformationSubTLV( + prefix.Addr(), + END_DT4, + NewSRv6SIDStructureSubSubTLV(uint8(prefix.Bits()), 24, 16, 0, 16, 64), + ), + ), + ), + want: []byte{0xc0, 0x28, 0x25, 0x05, 0x00, 0x22, 0x00, 0x01, 0x00, 0x1e, 0x00, 0x20, 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x01, 0x00, 0x06, 0x40, 0x18, 0x10, 0x00, 0x10, 0x40}, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := tt.psid.Serialize() + if err != nil { + t.Fatalf("test failed with error: %+v", err) + } + if !bytes.Equal(got, tt.want) { + t.Logf("psid: %s", tt.psid) + t.Fatalf("got %x want %x", got, tt.want) + } + }) + } +}