Skip to content

protoc generated file breaks code #2886

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
usama6naseer opened this issue Feb 27, 2025 · 7 comments
Open

protoc generated file breaks code #2886

usama6naseer opened this issue Feb 27, 2025 · 7 comments

Comments

@usama6naseer
Copy link

usama6naseer commented Feb 27, 2025

I am working on adding color-only steering to GoBGP ColorExtended (Flag field). I plan to make a pull request to merge with upstream, once done.

However, when I try to generate attribute.pb.go, using /tools/grpc/genproto.sh, the generated file is way different than original one (added below). I have also added env info below.

I even tried re-generating from the vanilla attribute.go (i.e., without any modifications) and the output is much different from the ground-truth attribute.pb.go.

`
[gobgp-3.24.0]$ protoc --version

libprotoc 3.19.1

[gobgp-3.24.0]$ go version

go version go1.21.1 linux/amd64

`

@usama6naseer
Copy link
Author

I have added a comparison for sample below.
Image

@fujita
Copy link
Member

fujita commented Feb 28, 2025

The generated protobuf files gives you the information about the used software versions.

// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.1
// protoc v4.25.6
// source: attribute.proto

tools/grpc/genproto.sh is outdated. Can you send a pull request to update it?

@floatingstatic
Copy link
Contributor

@fujita I think this was my fault due to using a new version of protoc and did not run the script in the tools folder. This PR should update the script. I also upgraded protoc-gen-go and re-generated protobuffs while I was at it:

#2889

@usama6naseer
Copy link
Author

@floatingstatic Thanks for the quick fix!

I still see the problem at my end and it seems like I am doing something wrong. Would really appreciate if you can take a look.

I am working with gobgp-3.24.0 and generating from the vanilla attribute.proto is breaking things for me. The versions suggested for 3.24.0 are:

// Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 // protoc v3.20.3 // source: attribute.proto

My env versions seem to be the same but I am seeing weird generated attribute.pb.go (generated file are the same with v25.6). I have added a sample of generated file below.

Image

`
// Code generated by protoc-gen-go.
// source: attribute.proto
// DO NOT EDIT!

/*
Package github_com_osrg_gobgp_v3_api_apipb is a generated protocol buffer package.

It is generated from these files:
attribute.proto
capability.proto
gobgp.proto

It has these top-level messages:
OriginAttribute
AsSegment
AsPathAttribute
NextHopAttribute
MultiExitDiscAttribute
LocalPrefAttribute
AtomicAggregateAttribute
AggregatorAttribute
CommunitiesAttribute
OriginatorIdAttribute
ClusterListAttribute
IPAddressPrefix
LabeledIPAddressPrefix
EncapsulationNLRI
RouteDistinguisherTwoOctetASN
RouteDistinguisherIPAddress
RouteDistinguisherFourOctetASN
EthernetSegmentIdentifier
VPLSNLRI
EVPNEthernetAutoDiscoveryRoute
EVPNMACIPAdvertisementRoute
EVPNInclusiveMulticastEthernetTagRoute
EVPNEthernetSegmentRoute
EVPNIPPrefixRoute
EVPNIPMSIRoute
SRPolicyNLRI
LabeledVPNIPAddressPrefix
RouteTargetMembershipNLRI
FlowSpecIPPrefix
FlowSpecMAC
FlowSpecComponentItem
FlowSpecComponent
FlowSpecNLRI
VPNFlowSpecNLRI
OpaqueNLRI
LsNodeDescriptor
LsLinkDescriptor
LsPrefixDescriptor
LsNodeNLRI
LsLinkNLRI
LsPrefixV4NLRI
LsPrefixV6NLRI
LsAddrPrefix
MUPInterworkSegmentDiscoveryRoute
MUPDirectSegmentDiscoveryRoute
MUPType1SessionTransformedRoute
MUPType2SessionTransformedRoute
MpReachNLRIAttribute
MpUnreachNLRIAttribute
TwoOctetAsSpecificExtended
IPv4AddressSpecificExtended
FourOctetAsSpecificExtended
LinkBandwidthExtended
ValidationExtended
ColorExtended
EncapExtended
DefaultGatewayExtended
OpaqueExtended
ESILabelExtended
ESImportRouteTarget
MacMobilityExtended
RouterMacExtended
TrafficRateExtended
TrafficActionExtended
RedirectTwoOctetAsSpecificExtended
RedirectIPv4AddressSpecificExtended
RedirectFourOctetAsSpecificExtended
TrafficRemarkExtended
MUPExtended
VPLSExtended
UnknownExtended
ExtendedCommunitiesAttribute
As4PathAttribute
As4AggregatorAttribute
PmsiTunnelAttribute
TunnelEncapSubTLVEncapsulation
TunnelEncapSubTLVProtocol
TunnelEncapSubTLVColor
TunnelEncapSubTLVSRPreference
TunnelEncapSubTLVSRCandidatePathName
TunnelEncapSubTLVSRPriority
TunnelEncapSubTLVSRBindingSID
SRBindingSID
SRv6EndPointBehavior
SRv6BindingSID
TunnelEncapSubTLVSRENLP
SRWeight
SegmentFlags
SegmentTypeA
SegmentTypeB
TunnelEncapSubTLVSRSegmentList
TunnelEncapSubTLVEgressEndpoint
TunnelEncapSubTLVUDPDestPort
TunnelEncapSubTLVUnknown
TunnelEncapTLV
TunnelEncapAttribute
IPv6AddressSpecificExtended
RedirectIPv6AddressSpecificExtended
IP6ExtendedCommunitiesAttribute
AigpTLVIGPMetric
AigpTLVUnknown
AigpAttribute
LargeCommunity
LargeCommunitiesAttribute
LsNodeFlags
LsIGPFlags
LsSrRange
LsSrCapabilities
LsSrLocalBlock
LsAttributeNode
LsAttributeLink
LsAttributePrefix
LsBgpPeerSegmentSIDFlags
LsBgpPeerSegmentSID
LsAttributeBgpPeerSegment
LsAttribute
UnknownAttribute
SRv6StructureSubSubTLV
SRv6SIDFlags
SRv6TLV
SRv6InformationSubTLV
SRv6L3ServiceTLV
SRv6L2ServiceTLV
PrefixSID
*/
package github_com_osrg_gobgp_v3_api_apipb

import proto "github.com/golang/protobuf/proto"
import google_protobuf "google/protobuf"

// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal

type LsOspfRouteType int32

const (
LsOspfRouteType_LS_OSPF_ROUTE_TYPE_UNKNOWN LsOspfRouteType = 0
LsOspfRouteType_LS_OSPF_ROUTE_TYPE_INTRA_AREA LsOspfRouteType = 1
LsOspfRouteType_LS_OSPF_ROUTE_TYPE_INTER_AREA LsOspfRouteType = 2
LsOspfRouteType_LS_OSPF_ROUTE_TYPE_EXTERNAL1 LsOspfRouteType = 3
LsOspfRouteType_LS_OSPF_ROUTE_TYPE_EXTERNAL2 LsOspfRouteType = 4
LsOspfRouteType_LS_OSPF_ROUTE_TYPE_NSSA1 LsOspfRouteType = 5
LsOspfRouteType_LS_OSPF_ROUTE_TYPE_NSSA2 LsOspfRouteType = 6
)

var LsOspfRouteType_name = map[int32]string{
0: "LS_OSPF_ROUTE_TYPE_UNKNOWN",
1: "LS_OSPF_ROUTE_TYPE_INTRA_AREA",
2: "LS_OSPF_ROUTE_TYPE_INTER_AREA",
3: "LS_OSPF_ROUTE_TYPE_EXTERNAL1",
4: "LS_OSPF_ROUTE_TYPE_EXTERNAL2",
5: "LS_OSPF_ROUTE_TYPE_NSSA1",
6: "LS_OSPF_ROUTE_TYPE_NSSA2",
}
var LsOspfRouteType_value = map[string]int32{
"LS_OSPF_ROUTE_TYPE_UNKNOWN": 0,
"LS_OSPF_ROUTE_TYPE_INTRA_AREA": 1,
"LS_OSPF_ROUTE_TYPE_INTER_AREA": 2,
"LS_OSPF_ROUTE_TYPE_EXTERNAL1": 3,
"LS_OSPF_ROUTE_TYPE_EXTERNAL2": 4,
"LS_OSPF_ROUTE_TYPE_NSSA1": 5,
"LS_OSPF_ROUTE_TYPE_NSSA2": 6,
}

func (x LsOspfRouteType) String() string {
return proto.EnumName(LsOspfRouteType_name, int32(x))
}

// Based om RFC 7752, Table 1.
type LsNLRIType int32

const (
LsNLRIType_LS_NLRI_UNKNOWN LsNLRIType = 0
LsNLRIType_LS_NLRI_NODE LsNLRIType = 1
LsNLRIType_LS_NLRI_LINK LsNLRIType = 2
LsNLRIType_LS_NLRI_PREFIX_V4 LsNLRIType = 3
LsNLRIType_LS_NLRI_PREFIX_V6 LsNLRIType = 4
)

var LsNLRIType_name = map[int32]string{
0: "LS_NLRI_UNKNOWN",
1: "LS_NLRI_NODE",
2: "LS_NLRI_LINK",
3: "LS_NLRI_PREFIX_V4",
4: "LS_NLRI_PREFIX_V6",
}
var LsNLRIType_value = map[string]int32{
"LS_NLRI_UNKNOWN": 0,
"LS_NLRI_NODE": 1,
"LS_NLRI_LINK": 2,
"LS_NLRI_PREFIX_V4": 3,
"LS_NLRI_PREFIX_V6": 4,
}

func (x LsNLRIType) String() string {
return proto.EnumName(LsNLRIType_name, int32(x))
}

type LsProtocolID int32

const (
LsProtocolID_LS_PROTOCOL_UNKNOWN LsProtocolID = 0
LsProtocolID_LS_PROTOCOL_ISIS_L1 LsProtocolID = 1
LsProtocolID_LS_PROTOCOL_ISIS_L2 LsProtocolID = 2
LsProtocolID_LS_PROTOCOL_OSPF_V2 LsProtocolID = 3
LsProtocolID_LS_PROTOCOL_DIRECT LsProtocolID = 4
LsProtocolID_LS_PROTOCOL_STATIC LsProtocolID = 5
LsProtocolID_LS_PROTOCOL_OSPF_V3 LsProtocolID = 6
)

var LsProtocolID_name = map[int32]string{
0: "LS_PROTOCOL_UNKNOWN",
1: "LS_PROTOCOL_ISIS_L1",
2: "LS_PROTOCOL_ISIS_L2",
3: "LS_PROTOCOL_OSPF_V2",
4: "LS_PROTOCOL_DIRECT",
5: "LS_PROTOCOL_STATIC",
6: "LS_PROTOCOL_OSPF_V3",
}
var LsProtocolID_value = map[string]int32{
"LS_PROTOCOL_UNKNOWN": 0,
"LS_PROTOCOL_ISIS_L1": 1,
"LS_PROTOCOL_ISIS_L2": 2,
"LS_PROTOCOL_OSPF_V2": 3,
"LS_PROTOCOL_DIRECT": 4,
"LS_PROTOCOL_STATIC": 5,
"LS_PROTOCOL_OSPF_V3": 6,
}

func (x LsProtocolID) String() string {
return proto.EnumName(LsProtocolID_name, int32(x))
}

type SRv6Behavior int32

const (
SRv6Behavior_RESERVED SRv6Behavior = 0
SRv6Behavior_END SRv6Behavior = 1
SRv6Behavior_END_WITH_PSP SRv6Behavior = 2
SRv6Behavior_END_WITH_USP SRv6Behavior = 3
SRv6Behavior_END_WITH_PSP_USP SRv6Behavior = 4
SRv6Behavior_ENDX SRv6Behavior = 5
SRv6Behavior_ENDX_WITH_PSP SRv6Behavior = 6
SRv6Behavior_ENDX_WITH_USP SRv6Behavior = 7
SRv6Behavior_ENDX_WITH_PSP_USP SRv6Behavior = 8
SRv6Behavior_ENDT SRv6Behavior = 9
SRv6Behavior_ENDT_WITH_PSP SRv6Behavior = 10
SRv6Behavior_ENDT_WITH_USP SRv6Behavior = 11
SRv6Behavior_ENDT_WITH_PSP_USP SRv6Behavior = 12
SRv6Behavior_END_B6_ENCAPS SRv6Behavior = 14
SRv6Behavior_END_BM SRv6Behavior = 15
SRv6Behavior_END_DX6 SRv6Behavior = 16
SRv6Behavior_END_DX4 SRv6Behavior = 17
SRv6Behavior_END_DT6 SRv6Behavior = 18
SRv6Behavior_END_DT4 SRv6Behavior = 19
SRv6Behavior_END_DT46 SRv6Behavior = 20
SRv6Behavior_END_DX2 SRv6Behavior = 21
SRv6Behavior_END_DX2V SRv6Behavior = 22
SRv6Behavior_END_DT2U SRv6Behavior = 23
SRv6Behavior_END_DT2M SRv6Behavior = 24
SRv6Behavior_END_B6_ENCAPS_Red SRv6Behavior = 27
SRv6Behavior_END_WITH_USD SRv6Behavior = 28
SRv6Behavior_END_WITH_PSP_USD SRv6Behavior = 29
SRv6Behavior_END_WITH_USP_USD SRv6Behavior = 30
SRv6Behavior_END_WITH_PSP_USP_USD SRv6Behavior = 31
SRv6Behavior_ENDX_WITH_USD SRv6Behavior = 32
SRv6Behavior_ENDX_WITH_PSP_USD SRv6Behavior = 33
SRv6Behavior_ENDX_WITH_USP_USD SRv6Behavior = 34
SRv6Behavior_ENDX_WITH_PSP_USP_USD SRv6Behavior = 35
SRv6Behavior_ENDT_WITH_USD SRv6Behavior = 36
SRv6Behavior_ENDT_WITH_PSP_USD SRv6Behavior = 37
SRv6Behavior_ENDT_WITH_USP_USD SRv6Behavior = 38
SRv6Behavior_ENDT_WITH_PSP_USP_USD SRv6Behavior = 39
SRv6Behavior_ENDM_GTP6D SRv6Behavior = 69
SRv6Behavior_ENDM_GTP6DI SRv6Behavior = 70
SRv6Behavior_ENDM_GTP6E SRv6Behavior = 71
SRv6Behavior_ENDM_GTP4E SRv6Behavior = 72
)

var SRv6Behavior_name = map[int32]string{
0: "RESERVED",
1: "END",
2: "END_WITH_PSP",
3: "END_WITH_USP",
4: "END_WITH_PSP_USP",
5: "ENDX",
6: "ENDX_WITH_PSP",
7: "ENDX_WITH_USP",
8: "ENDX_WITH_PSP_USP",
9: "ENDT",
10: "ENDT_WITH_PSP",
11: "ENDT_WITH_USP",
12: "ENDT_WITH_PSP_USP",
14: "END_B6_ENCAPS",
15: "END_BM",
16: "END_DX6",
17: "END_DX4",
18: "END_DT6",
19: "END_DT4",
20: "END_DT46",
21: "END_DX2",
22: "END_DX2V",
23: "END_DT2U",
24: "END_DT2M",
27: "END_B6_ENCAPS_Red",
28: "END_WITH_USD",
29: "END_WITH_PSP_USD",
30: "END_WITH_USP_USD",
31: "END_WITH_PSP_USP_USD",
32: "ENDX_WITH_USD",
33: "ENDX_WITH_PSP_USD",
34: "ENDX_WITH_USP_USD",
35: "ENDX_WITH_PSP_USP_USD",
36: "ENDT_WITH_USD",
37: "ENDT_WITH_PSP_USD",
38: "ENDT_WITH_USP_USD",
39: "ENDT_WITH_PSP_USP_USD",
69: "ENDM_GTP6D",
70: "ENDM_GTP6DI",
71: "ENDM_GTP6E",
72: "ENDM_GTP4E",
}
var SRv6Behavior_value = map[string]int32{
"RESERVED": 0,
"END": 1,
"END_WITH_PSP": 2,
"END_WITH_USP": 3,
"END_WITH_PSP_USP": 4,
"ENDX": 5,
"ENDX_WITH_PSP": 6,
"ENDX_WITH_USP": 7,
"ENDX_WITH_PSP_USP": 8,
"ENDT": 9,
"ENDT_WITH_PSP": 10,
"ENDT_WITH_USP": 11,
"ENDT_WITH_PSP_USP": 12,
"END_B6_ENCAPS": 14,
"END_BM": 15,
"END_DX6": 16,
"END_DX4": 17,
"END_DT6": 18,
"END_DT4": 19,
"END_DT46": 20,
"END_DX2": 21,
"END_DX2V": 22,
"END_DT2U": 23,
"END_DT2M": 24,
"END_B6_ENCAPS_Red": 27,
"END_WITH_USD": 28,
"END_WITH_PSP_USD": 29,
"END_WITH_USP_USD": 30,
"END_WITH_PSP_USP_USD": 31,
"ENDX_WITH_USD": 32,
"ENDX_WITH_PSP_USD": 33,
"ENDX_WITH_USP_USD": 34,
"ENDX_WITH_PSP_USP_USD": 35,
"ENDT_WITH_USD": 36,
"ENDT_WITH_PSP_USD": 37,
"ENDT_WITH_USP_USD": 38,
"ENDT_WITH_PSP_USP_USD": 39,
"ENDM_GTP6D": 69,
"ENDM_GTP6DI": 70,
"ENDM_GTP6E": 71,
"ENDM_GTP4E": 72,
}

func (x SRv6Behavior) String() string {
return proto.EnumName(SRv6Behavior_name, int32(x))
}

type ENLPType int32

const (
ENLPType_Reserved ENLPType = 0
ENLPType_Type1 ENLPType = 1
ENLPType_Type2 ENLPType = 2
ENLPType_Type3 ENLPType = 3
ENLPType_Type4 ENLPType = 4
)

var ENLPType_name = map[int32]string{
0: "Reserved",
1: "Type1",
2: "Type2",
3: "Type3",
4: "Type4",
}
var ENLPType_value = map[string]int32{
"Reserved": 0,
"Type1": 1,
"Type2": 2,
"Type3": 3,
"Type4": 4,
}

func (x ENLPType) String() string {
return proto.EnumName(ENLPType_name, int32(x))
}

type AsSegment_Type int32

const (
AsSegment_UNKNOWN AsSegment_Type = 0
AsSegment_AS_SET AsSegment_Type = 1
AsSegment_AS_SEQUENCE AsSegment_Type = 2
AsSegment_AS_CONFED_SEQUENCE AsSegment_Type = 3
AsSegment_AS_CONFED_SET AsSegment_Type = 4
)
`

@floatingstatic
Copy link
Contributor

floatingstatic commented Feb 28, 2025

@usama6naseer try downloading protoc from here: https://github.com/protocolbuffers/protobuf/releases/tag/v25.6
See under "assets" you can find a pre-compiled binary for whatever operating system you are using.

I would also suggest seeing if you can try genproto.sh from the branch I opened a PR for (see above)

@floatingstatic
Copy link
Contributor

@usama6naseer following up on this. Did installing the correct version of protoc fix your problem?

@usama6naseer
Copy link
Author

@floatingstatic yes, I can confirm that I was able to fix the issues with newer scripts (though I had to specific the protoc-gen-go binary path with --plugin= because my env wasn't picking up protoc-gen-go even with PATH set).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants