From 9eaf510391f12a6e70e8cc613437829a4705c39c Mon Sep 17 00:00:00 2001 From: lspgn Date: Sun, 4 Aug 2024 17:25:13 -0700 Subject: [PATCH] rename ipv6eh, layer-size --- pb/flow.pb.go | 72 ++++++++++++++++++------------- pb/flow.proto | 5 ++- producer/proto/custom.go | 15 ++++--- producer/proto/producer_packet.go | 7 ++- 4 files changed, 57 insertions(+), 42 deletions(-) diff --git a/pb/flow.pb.go b/pb/flow.pb.go index e50df94f..8f92f977 100644 --- a/pb/flow.pb.go +++ b/pb/flow.pb.go @@ -221,8 +221,9 @@ type FlowMessage struct { ObservationDomainId uint32 `protobuf:"varint,70,opt,name=observation_domain_id,json=observationDomainId,proto3" json:"observation_domain_id,omitempty"` ObservationPointId uint32 `protobuf:"varint,71,opt,name=observation_point_id,json=observationPointId,proto3" json:"observation_point_id,omitempty"` LayerStack []FlowMessage_LayerStack `protobuf:"varint,103,rep,packed,name=layer_stack,json=layerStack,proto3,enum=flowpb.FlowMessage_LayerStack" json:"layer_stack,omitempty"` - Ipv6RoutingHeaderAddresses [][]byte `protobuf:"bytes,104,rep,name=ipv6_routing_header_addresses,json=ipv6RoutingHeaderAddresses,proto3" json:"ipv6_routing_header_addresses,omitempty"` // SRv6 - Ipv6RoutingHeaderSegLeft uint32 `protobuf:"varint,105,opt,name=ipv6_routing_header_seg_left,json=ipv6RoutingHeaderSegLeft,proto3" json:"ipv6_routing_header_seg_left,omitempty"` // SRv6 + LayerSize []uint32 `protobuf:"varint,104,rep,packed,name=layer_size,json=layerSize,proto3" json:"layer_size,omitempty"` + Ipv6RoutingHeaderAddresses [][]byte `protobuf:"bytes,105,rep,name=ipv6_routing_header_addresses,json=ipv6RoutingHeaderAddresses,proto3" json:"ipv6_routing_header_addresses,omitempty"` // SRv6 + Ipv6RoutingHeaderSegLeft uint32 `protobuf:"varint,106,opt,name=ipv6_routing_header_seg_left,json=ipv6RoutingHeaderSegLeft,proto3" json:"ipv6_routing_header_seg_left,omitempty"` // SRv6 } func (x *FlowMessage) Reset() { @@ -586,6 +587,13 @@ func (x *FlowMessage) GetLayerStack() []FlowMessage_LayerStack { return nil } +func (x *FlowMessage) GetLayerSize() []uint32 { + if x != nil { + return x.LayerSize + } + return nil +} + func (x *FlowMessage) GetIpv6RoutingHeaderAddresses() [][]byte { if x != nil { return x.Ipv6RoutingHeaderAddresses @@ -604,7 +612,7 @@ var File_pb_flow_proto protoreflect.FileDescriptor var file_pb_flow_proto_rawDesc = []byte{ 0x0a, 0x0d, 0x70, 0x62, 0x2f, 0x66, 0x6c, 0x6f, 0x77, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x06, 0x66, 0x6c, 0x6f, 0x77, 0x70, 0x62, 0x22, 0xdb, 0x0e, 0x0a, 0x0b, 0x46, 0x6c, 0x6f, 0x77, + 0x06, 0x66, 0x6c, 0x6f, 0x77, 0x70, 0x62, 0x22, 0xfa, 0x0e, 0x0a, 0x0b, 0x46, 0x6c, 0x6f, 0x77, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1c, 0x2e, 0x66, 0x6c, 0x6f, 0x77, 0x70, 0x62, 0x2e, 0x46, 0x6c, 0x6f, 0x77, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x46, 0x6c, 0x6f, 0x77, 0x54, @@ -698,34 +706,36 @@ var file_pb_flow_proto_rawDesc = []byte{ 0x73, 0x74, 0x61, 0x63, 0x6b, 0x18, 0x67, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x66, 0x6c, 0x6f, 0x77, 0x70, 0x62, 0x2e, 0x46, 0x6c, 0x6f, 0x77, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x52, 0x0a, 0x6c, 0x61, 0x79, - 0x65, 0x72, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x12, 0x41, 0x0a, 0x1d, 0x69, 0x70, 0x76, 0x36, 0x5f, - 0x72, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x5f, 0x61, - 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x18, 0x68, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x1a, - 0x69, 0x70, 0x76, 0x36, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x48, 0x65, 0x61, 0x64, 0x65, - 0x72, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x12, 0x3e, 0x0a, 0x1c, 0x69, 0x70, - 0x76, 0x36, 0x5f, 0x72, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, - 0x72, 0x5f, 0x73, 0x65, 0x67, 0x5f, 0x6c, 0x65, 0x66, 0x74, 0x18, 0x69, 0x20, 0x01, 0x28, 0x0d, - 0x52, 0x18, 0x69, 0x70, 0x76, 0x36, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x48, 0x65, 0x61, - 0x64, 0x65, 0x72, 0x53, 0x65, 0x67, 0x4c, 0x65, 0x66, 0x74, 0x22, 0x53, 0x0a, 0x08, 0x46, 0x6c, - 0x6f, 0x77, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x46, 0x4c, 0x4f, 0x57, 0x55, 0x4e, - 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x46, 0x4c, 0x4f, 0x57, - 0x5f, 0x35, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x4e, 0x45, 0x54, 0x46, 0x4c, 0x4f, 0x57, 0x5f, - 0x56, 0x35, 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x4e, 0x45, 0x54, 0x46, 0x4c, 0x4f, 0x57, 0x5f, - 0x56, 0x39, 0x10, 0x03, 0x12, 0x09, 0x0a, 0x05, 0x49, 0x50, 0x46, 0x49, 0x58, 0x10, 0x04, 0x22, - 0xa3, 0x01, 0x0a, 0x0a, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x12, 0x0c, - 0x0a, 0x08, 0x45, 0x74, 0x68, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, - 0x49, 0x50, 0x76, 0x34, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x49, 0x50, 0x76, 0x36, 0x10, 0x02, - 0x12, 0x07, 0x0a, 0x03, 0x54, 0x43, 0x50, 0x10, 0x03, 0x12, 0x07, 0x0a, 0x03, 0x55, 0x44, 0x50, - 0x10, 0x04, 0x12, 0x08, 0x0a, 0x04, 0x4d, 0x50, 0x4c, 0x53, 0x10, 0x05, 0x12, 0x09, 0x0a, 0x05, - 0x44, 0x6f, 0x74, 0x31, 0x51, 0x10, 0x06, 0x12, 0x08, 0x0a, 0x04, 0x49, 0x43, 0x4d, 0x50, 0x10, - 0x07, 0x12, 0x0a, 0x0a, 0x06, 0x49, 0x43, 0x4d, 0x50, 0x76, 0x36, 0x10, 0x08, 0x12, 0x07, 0x0a, - 0x03, 0x47, 0x52, 0x45, 0x10, 0x09, 0x12, 0x15, 0x0a, 0x11, 0x49, 0x50, 0x76, 0x36, 0x48, 0x65, - 0x61, 0x64, 0x65, 0x72, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x10, 0x0a, 0x12, 0x16, 0x0a, - 0x12, 0x49, 0x50, 0x76, 0x36, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x46, 0x72, 0x61, 0x67, 0x6d, - 0x65, 0x6e, 0x74, 0x10, 0x0b, 0x42, 0x29, 0x5a, 0x27, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x6e, 0x65, 0x74, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x2f, 0x67, - 0x6f, 0x66, 0x6c, 0x6f, 0x77, 0x32, 0x2f, 0x70, 0x62, 0x3b, 0x66, 0x6c, 0x6f, 0x77, 0x70, 0x62, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x72, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x12, 0x1d, 0x0a, 0x0a, 0x6c, 0x61, 0x79, 0x65, 0x72, + 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x68, 0x20, 0x03, 0x28, 0x0d, 0x52, 0x09, 0x6c, 0x61, 0x79, + 0x65, 0x72, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x41, 0x0a, 0x1d, 0x69, 0x70, 0x76, 0x36, 0x5f, 0x72, + 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x5f, 0x61, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x18, 0x69, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x1a, 0x69, + 0x70, 0x76, 0x36, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, + 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x12, 0x3e, 0x0a, 0x1c, 0x69, 0x70, 0x76, + 0x36, 0x5f, 0x72, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, + 0x5f, 0x73, 0x65, 0x67, 0x5f, 0x6c, 0x65, 0x66, 0x74, 0x18, 0x6a, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x18, 0x69, 0x70, 0x76, 0x36, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x48, 0x65, 0x61, 0x64, + 0x65, 0x72, 0x53, 0x65, 0x67, 0x4c, 0x65, 0x66, 0x74, 0x22, 0x53, 0x0a, 0x08, 0x46, 0x6c, 0x6f, + 0x77, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x46, 0x4c, 0x4f, 0x57, 0x55, 0x4e, 0x4b, + 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x46, 0x4c, 0x4f, 0x57, 0x5f, + 0x35, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x4e, 0x45, 0x54, 0x46, 0x4c, 0x4f, 0x57, 0x5f, 0x56, + 0x35, 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x4e, 0x45, 0x54, 0x46, 0x4c, 0x4f, 0x57, 0x5f, 0x56, + 0x39, 0x10, 0x03, 0x12, 0x09, 0x0a, 0x05, 0x49, 0x50, 0x46, 0x49, 0x58, 0x10, 0x04, 0x22, 0xa3, + 0x01, 0x0a, 0x0a, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x12, 0x0c, 0x0a, + 0x08, 0x45, 0x74, 0x68, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x49, + 0x50, 0x76, 0x34, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x49, 0x50, 0x76, 0x36, 0x10, 0x02, 0x12, + 0x07, 0x0a, 0x03, 0x54, 0x43, 0x50, 0x10, 0x03, 0x12, 0x07, 0x0a, 0x03, 0x55, 0x44, 0x50, 0x10, + 0x04, 0x12, 0x08, 0x0a, 0x04, 0x4d, 0x50, 0x4c, 0x53, 0x10, 0x05, 0x12, 0x09, 0x0a, 0x05, 0x44, + 0x6f, 0x74, 0x31, 0x51, 0x10, 0x06, 0x12, 0x08, 0x0a, 0x04, 0x49, 0x43, 0x4d, 0x50, 0x10, 0x07, + 0x12, 0x0a, 0x0a, 0x06, 0x49, 0x43, 0x4d, 0x50, 0x76, 0x36, 0x10, 0x08, 0x12, 0x07, 0x0a, 0x03, + 0x47, 0x52, 0x45, 0x10, 0x09, 0x12, 0x15, 0x0a, 0x11, 0x49, 0x50, 0x76, 0x36, 0x48, 0x65, 0x61, + 0x64, 0x65, 0x72, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x10, 0x0a, 0x12, 0x16, 0x0a, 0x12, + 0x49, 0x50, 0x76, 0x36, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x46, 0x72, 0x61, 0x67, 0x6d, 0x65, + 0x6e, 0x74, 0x10, 0x0b, 0x42, 0x29, 0x5a, 0x27, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x6e, 0x65, 0x74, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x2f, 0x67, 0x6f, + 0x66, 0x6c, 0x6f, 0x77, 0x32, 0x2f, 0x70, 0x62, 0x3b, 0x66, 0x6c, 0x6f, 0x77, 0x70, 0x62, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pb/flow.proto b/pb/flow.proto index c251d2e5..c88a6221 100644 --- a/pb/flow.proto +++ b/pb/flow.proto @@ -112,8 +112,9 @@ message FlowMessage { // todo: add nsh } repeated LayerStack layer_stack = 103; + repeated uint32 layer_size = 104; - repeated bytes ipv6_routing_header_addresses = 104; // SRv6 - uint32 ipv6_routing_header_seg_left = 105; // SRv6 + repeated bytes ipv6_routing_header_addresses = 105; // SRv6 + uint32 ipv6_routing_header_seg_left = 106; // SRv6 } diff --git a/producer/proto/custom.go b/producer/proto/custom.go index 9f594564..ceb07260 100644 --- a/producer/proto/custom.go +++ b/producer/proto/custom.go @@ -124,13 +124,14 @@ func mapFormat(cfg *ProducerConfig) (*FormatterConfigMapper, error) { formatterMapped.render = make(map[string]RenderFunc) formatterMapped.rename = make(map[string]string) formatterMapped.isSlice = map[string]bool{ - "BgpCommunities": true, - "AsPath": true, - "MplsIp": true, - "MplsLabel": true, - "MplsTtl": true, - "LayerStack": true, - "Ipv6RoutingHeaderAddresses": true, + "BgpCommunities": true, + "AsPath": true, + "MplsIp": true, + "MplsLabel": true, + "MplsTtl": true, + "LayerStack": true, + "LayerSize": true, + "Ipv6RoutingHeaderAddresses": true, } // todo: improve this with defaults for k, v := range defaultRenderers { formatterMapped.render[k] = v diff --git a/producer/proto/producer_packet.go b/producer/proto/producer_packet.go index 2f0ed4d6..2beda215 100644 --- a/producer/proto/producer_packet.go +++ b/producer/proto/producer_packet.go @@ -58,14 +58,14 @@ var ( } parserIPv6HeaderRouting = ParserInfo{ nil, //ParseIPv6HeaderRouting2, - []string{"ipv6he_routing", "ipv6he"}, + []string{"ipv6eh_routing", "ipv6eh"}, 35, 7, false, } parserIPv6HeaderFragment = ParserInfo{ nil, //ParseIPv6HeaderFragment2, - []string{"ipv6he_fragment", "ipv6he"}, + []string{"ipv6eh_fragment", "ipv6eh"}, 35, 6, true, @@ -259,6 +259,9 @@ func ParsePacket(flowMessage ProtoProducerMessageIf, data []byte, config PacketM } } + fm := flowMessage.GetFlowMessage() + fm.LayerSize = append(fm.LayerSize, uint32(res.Size)) + // compares the next layer index with current to determine if it's an encapsulation // IP over IP is the equals case // except if layer is skipping comparison (will be compared after). For instance IPv6 Fragment Header, dot1q and MPLS cannot trigger encap