Giter Club home page Giter Club logo

onos-lib-go's Introduction

onos-lib-go

Library of utilities and conveniences for development of µONOS components.

onos-lib-go's People

Contributors

adibrastegarnia avatar agarwal-shivansh avatar dependabot[bot] avatar eroshiva avatar jing1228 avatar kuujo avatar onos-builder avatar raphaelvrosa avatar ray-milkey avatar seancondon avatar tomikazi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

onos-lib-go's Issues

Why does this code ignore the data length returned

dataCount, oobCount, flags, _, err = syscall.Recvmsg(fd, b, oobBuffer, 0)

why dose this code ignore the dataCount from syscall.Recvmsg here, since the ORAN standard some messages have the indefinite length?

Is it OK that it discards the dataCount and creates a fixed length buffer in onos-e2t at the same time ?

https://github.com/onosproject/onos-e2t/blob/9ef17c884e94786226d4004ca0f7325b9cf11fc1/pkg/protocols/e2ap/conn.go#L20

https://github.com/onosproject/onos-e2t/blob/9ef17c884e94786226d4004ca0f7325b9cf11fc1/pkg/protocols/e2ap/conn.go#L155

Index Out-of-Range Errors in ASN1 APER Decoding and Encoding Functions

Hello, during my testing, I two potential index out-of-range issues in the ASN1 APER decoding and encoding implementation. Specifically, the issues are related to unchecked array index access in two functions:

The parseAlignBits function, and the putBitString function.
These issues can potentially cause the E2T, which uses this code to decode messages, to crash. I have tested this on version 0.10.24, but it appears that the latest version still contains the same problem.

For the decoding issue in parseAlignBits, please see the attached logs:

2023-12-19T11:21:52.511-0400 DEBUG asn1/aper aper/aper.go:828 Decoding
2023-12-19T11:21:52.511-0400 DEBUG asn1/aper aper/aper.go:828 Decoding Rsrp
2023-12-19T11:21:52.511-0400 DEBUG asn1/aper aper/aper.go:897 not a built in field type e2smmho.Rsrp
2023-12-19T11:21:52.511-0400 DEBUG asn1/aper aper/aper.go:941 struct Rsrp ignoring unexported field : state
2023-12-19T11:21:52.511-0400 DEBUG asn1/aper aper/aper.go:941 struct Rsrp ignoring unexported field : sizeCache
2023-12-19T11:21:52.511-0400 DEBUG asn1/aper aper/aper.go:941 struct Rsrp ignoring unexported field : unknownFields
2023-12-19T11:21:52.511-0400 DEBUG asn1/aper aper/aper.go:949 SEQUENCE int32 can be extended
2023-12-19T11:21:52.511-0400 DEBUG asn1/aper aper/aper.go:959 optionalCount is 0
2023-12-19T11:21:52.511-0400 DEBUG asn1/aper aper/aper.go:972 struct Rsrp ignoring unexported field : state
2023-12-19T11:21:52.511-0400 DEBUG asn1/aper aper/aper.go:972 struct Rsrp ignoring unexported field : sizeCache
2023-12-19T11:21:52.511-0400 DEBUG asn1/aper aper/aper.go:972 struct Rsrp ignoring unexported field : unknownFields
2023-12-19T11:21:52.511-0400 DEBUG asn1/aper aper/aper.go:828 Decoding int32
2023-12-19T11:21:52.511-0400 DEBUG asn1/aper aper/aper.go:128 [PER got 1 bits, byteOffset(after): 31, bitsOffset(after): 5, value: 0x1]
2023-12-19T11:21:52.511-0400 DEBUG asn1/aper aper/aper.go:859 Decoded Value Extensive Bit: true
2023-12-19T11:21:52.511-0400 DEBUG asn1/aper aper/aper.go:862 Indicating Value Extensive Bit: true
2023-12-19T11:21:52.511-0400 DEBUG asn1/aper aper/aper.go:897 not a built in field type int32
2023-12-19T11:21:52.511-0400 DEBUG asn1/aper aper/aper.go:565 Decoding INTEGER with Extensive Value
2023-12-19T11:21:52.511-0400 DEBUG asn1/aper aper/aper.go:136 Aligning 3 bits
2023-12-19T11:21:52.511-0400 DEBUG asn1/aper aper/aper.go:128 [PER got 3 bits, byteOffset(after): 32, bitsOffset(after): 0, value: 0x2]
panic: runtime error: slice bounds out of range [:33] with capacity 32

goroutine 1 [running]:
github.com/onosproject/onos-lib-go/pkg/asn1/aper.(*perBitData).parseAlignBits(0xc000139c80)
/home/tianchang/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/aper.go:140 +0x179
github.com/onosproject/onos-lib-go/pkg/asn1/aper.(*perBitData).parseInteger(0xc000139c80, 0xec?, 0x1c?, 0xc000305390?)
/home/tianchang/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/aper.go:572 +0x2b5
github.com/onosproject/onos-lib-go/pkg/asn1/aper.parseField({0xd02b60?, 0xc00027dee8?, 0x400?}, 0xc000139c80, {0x0, 0x0, 0x1, 0x0, 0x0, 0xc0002f3300, ...})
/home/tianchang/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/aper.go:908 +0x6c5
github.com/onosproject/onos-lib-go/pkg/asn1/aper.parseField({0xddef60?, 0xc00027dec0?, 0x400?}, 0xc000139c80, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...})
/home/tianchang/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/aper.go:1056 +0x2d07
github.com/onosproject/onos-lib-go/pkg/asn1/aper.parseField({0xdee900?, 0xc0002f60b0?, 0x400?}, 0xc000139c80, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...})
/home/tianchang/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/aper.go:838 +0x18e5
github.com/onosproject/onos-lib-go/pkg/asn1/aper.parseField({0xe044e0?, 0xc0002f6080?, 0x400?}, 0xc000139c80, {0x0, 0x0, 0x1, 0x0, 0x0, 0x0, ...})
/home/tianchang/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/aper.go:1056 +0x2d07
github.com/onosproject/onos-lib-go/pkg/asn1/aper.parseField({0xe0ccc0?, 0xc00027dd50?, 0xfa8f78?}, 0xc000139c80, {0x0, 0x0, 0x1, 0x0, 0x0, 0x0, ...})
/home/tianchang/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/aper.go:838 +0x18e5
github.com/onosproject/onos-lib-go/pkg/asn1/aper.(*perBitData).parseSequenceOf(0xc000139c80, 0x40?, {0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, ...}, ...)
/home/tianchang/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/aper.go:700 +0x605
github.com/onosproject/onos-lib-go/pkg/asn1/aper.parseField({0xce7ea0?, 0xc000288760?, 0x400?}, 0xc000139c80, {0x0, 0x0, 0x1, 0xc0002c2a38, 0xc0002c2a40, 0x0, ...})
/home/tianchang/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/aper.go:1065 +0x11de
github.com/onosproject/onos-lib-go/pkg/asn1/aper.parseField({0xdf5e40?, 0xc000288730?, 0x400?}, 0xc000139c80, {0x0, 0x0, 0x1, 0x0, 0x0, 0x0, ...})
/home/tianchang/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/aper.go:1056 +0x2d07
github.com/onosproject/onos-lib-go/pkg/asn1/aper.parseField({0xdfebe0?, 0xc000014f10?, 0x400?}, 0xc000139c80, {0x0, 0x0, 0x1, 0x0, 0x0, 0x0, ...})
/home/tianchang/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/aper.go:838 +0x18e5
github.com/onosproject/onos-lib-go/pkg/asn1/aper.parseField({0xd76280?, 0xc000014f10?, 0x400?}, 0xc000139c80, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...})
/home/tianchang/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/aper.go:1056 +0x2d07
github.com/onosproject/onos-lib-go/pkg/asn1/aper.parseField({0xd5ad40?, 0xc000255ce8?, 0xc4503e?}, 0xc000139c80, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...})
/home/tianchang/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/aper.go:1200 +0x3305
github.com/onosproject/onos-lib-go/pkg/asn1/aper.parseField({0xddea20?, 0xc000255cc0?, 0xc0000012c0?}, 0xc000139c80, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...})
/home/tianchang/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/aper.go:1056 +0x2d07
github.com/onosproject/onos-lib-go/pkg/asn1/aper.UnmarshalWithParams({0xc0002b2aa0, 0x20, 0x20}, {0xe081e0?, 0xc000255cc0?}, {0xe72a80, 0x9}, 0xc0001d8420, 0x0)
/home/tianchang/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/aper.go:1263 +0x218
github.com/onosproject/onos-e2-sm/servicemodels/e2sm_mho_go/encoder.PerDecodeE2SmMhoIndicationMessage({0xc0002b2aa0, 0x20, 0x20})
/home/tianchang/go/pkg/mod/github.com/onosproject/onos-e2-sm/servicemodels/[email protected]/encoder/E2SM-MHO-IndicationMessage.go:35 +0x108
github.com/onosproject/onos-e2-sm/servicemodels/e2sm_mho_go/servicemodel.MhoServiceModel.IndicationMessageASN1toProto({0xfa4b80?, 0xc000014018?}, {0xc0002b2aa0, 0x20, 0x20})

And for the encoding issue in putBitString, the log is as follows:

panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/onosproject/onos-lib-go/pkg/asn1/aper.(*perRawBitData).putBitString(0xc0006c5af0, {0x0, 0x1b?, 0xc0000c0ea0?}, 0x0)
/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/marshal.go:57 +0x5c5
github.com/onosproject/onos-lib-go/pkg/asn1/aper.(*perRawBitData).appendBitString(0xc0006c5af0, {0x0, 0x0, 0x0}, 0x0, 0x2?, 0x1acbc68?, 0xe3fab7?)
/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/marshal.go:202 +0x6ea
github.com/onosproject/onos-lib-go/pkg/asn1/aper.(*perRawBitData).makeField(0xc0006c5af0, {0x1021de0?, 0xc0005f6ff0?, 0x5?}, {0x0, 0x0, 0x0, 0xc0004ce060, 0xc0004ce068, 0x0, ...})
/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/marshal.go:960 +0x1072
github.com/onosproject/onos-lib-go/pkg/asn1/aper.(*perRawBitData).makeField(0xc0006c5af0, {0x1021ec0?, 0xc00039a718?, 0xeb2b80?}, {0x0, 0x0, 0x0, 0xc0004ce060, 0xc0004ce068, 0x0, ...})
/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/marshal.go:937 +0x1189
github.com/onosproject/onos-lib-go/pkg/asn1/aper.(*perRawBitData).makeField(0xc0006c5af0, {0xf67be0?, 0xc00039a718?, 0xc0000b3780?}, {0x0, 0x0, 0x0, 0xc000469f88, 0xc000469f90, 0x0, ...})
/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/marshal.go:1245 +0x3345
github.com/onosproject/onos-lib-go/pkg/asn1/aper.(*perRawBitData).makeField(0xc0006c5af0, {0xeff660?, 0xc00039a718?, 0xc0004d9db0?}, {0x0, 0x0, 0x0, 0xc000469f88, 0xc000469f90, 0x0, ...})
/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/marshal.go:937 +0x1189
github.com/onosproject/onos-lib-go/pkg/asn1/aper.(*perRawBitData).makeField(0xc0006c5af0, {0xffe3c0?, 0xc0004c83c0?, 0x1acbc58?}, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...})
/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/marshal.go:1174 +0x3a89
github.com/onosproject/onos-lib-go/pkg/asn1/aper.(*perRawBitData).makeField(0xc0006c5af0, {0x1059620?, 0xc0004c8370?, 0xeb2b40?}, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...})
/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/marshal.go:937 +0x1189
github.com/onosproject/onos-lib-go/pkg/asn1/aper.(*perRawBitData).makeField(0xc0006c5af0, {0x10242a0?, 0xc0004c8340?, 0xc000393440?}, {0x1, 0x0, 0x1, 0x0, 0x0, 0x0, ...})
/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/marshal.go:1245 +0x3345
github.com/onosproject/onos-lib-go/pkg/asn1/aper.(*perRawBitData).makeField(0xc0006c5af0, {0x1038180?, 0xc0005f6ef8?, 0x0?}, {0x1, 0x0, 0x1, 0x0, 0x0, 0x0, ...})
/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/marshal.go:937 +0x1189
github.com/onosproject/onos-lib-go/pkg/asn1/aper.(*perRawBitData).makeField(0xc0006c5af0, {0x10742c0?, 0xc0005f6eb0?, 0x412025?}, {0x0, 0x0, 0x1, 0x0, 0x0, 0x0, ...})
/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/marshal.go:1245 +0x3345
github.com/onosproject/onos-lib-go/pkg/asn1/aper.(*perRawBitData).makeField(0xc0006c5af0, {0x1059740?, 0xc00039a700?, 0x28?}, {0x0, 0x0, 0x1, 0x0, 0x0, 0x0, ...})
/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/marshal.go:937 +0x1189
github.com/onosproject/onos-lib-go/pkg/asn1/aper.(*perRawBitData).makeField(0xc0006c5af0, {0xf66fe0?, 0xc00039a700?, 0x0?}, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...})
/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/marshal.go:1245 +0x3345
github.com/onosproject/onos-lib-go/pkg/asn1/aper.(*perRawBitData).makeField(0xc0006c5af0, {0xefed60?, 0xc00039a700?, 0x0?}, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...})
/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/marshal.go:937 +0x1189
github.com/onosproject/onos-lib-go/pkg/asn1/aper.(*perRawBitData).makeField(0xc0006c5af0, {0xffe6c0?, 0xc0004c8200?, 0x0?}, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...})
/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/marshal.go:1174 +0x3a89
github.com/onosproject/onos-lib-go/pkg/asn1/aper.(*perRawBitData).makeField(0xc0006c5af0, {0x1093400?, 0xc0004c81e8?, 0x62202c31203a2972?}, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...})
/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/marshal.go:937 +0x1189
github.com/onosproject/onos-lib-go/pkg/asn1/aper.(*perRawBitData).makeField(0xc0006c5af0, {0x10170a0?, 0xc0004c81c0?, 0xc0006c35f0?}, {0x0, 0x0, 0x1, 0x0, 0x0, 0x0, ...})
/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/marshal.go:1245 +0x3345
github.com/onosproject/onos-lib-go/pkg/asn1/aper.(*perRawBitData).makeField(0xc0006c5af0, {0x1034e80?, 0xc00039a6f0?, 0x426685?}, {0x0, 0x0, 0x1, 0x0, 0x0, 0x0, ...})
/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/marshal.go:937 +0x1189
github.com/onosproject/onos-lib-go/pkg/asn1/aper.(*perRawBitData).makeField(0xc0006c5af0, {0xf5c4e0?, 0xc00039a6f0?, 0xc0006c45b0?}, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...})
/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/marshal.go:1245 +0x3345
github.com/onosproject/onos-lib-go/pkg/asn1/aper.(*perRawBitData).makeField(0xc0006c5af0, {0xefa680?, 0xc00039a6f0?, 0x718e0?}, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...})
/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/marshal.go:937 +0x1189
github.com/onosproject/onos-lib-go/pkg/asn1/aper.(*perRawBitData).makeField(0xc0006c5af0, {0xff2f00?, 0xc0004c8180?, 0x0?}, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...})
/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/marshal.go:1174 +0x3a89
github.com/onosproject/onos-lib-go/pkg/asn1/aper.(*perRawBitData).makeField(0xc0006c5af0, {0x1044c00?, 0xc0004c8180?, 0x123f230?}, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...})
/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/marshal.go:937 +0x1189
github.com/onosproject/onos-lib-go/pkg/asn1/aper.MarshalWithParams({0x1044c00?, 0xc0004c8180?}, {0x10d8ef2?, 0xc0001106b0?}, 0x1?, 0x1?)
/go/pkg/mod/github.com/onosproject/[email protected]/pkg/asn1/aper/marshal.go:1284 +0x15f
github.com/onosproject/onos-e2-sm/servicemodels/e2sm_mho_go/encoder.PerEncodeE2SmMhoIndicationMessage(0xc0004c8180)
/go/pkg/mod/github.com/onosproject/onos-e2-sm/servicemodels/[email protected]/encoder/E2SM-MHO-IndicationMessage.go:21 +0xc8
github.com/onosproject/onos-e2-sm/servicemodels/e2sm_mho_go/servicemodel.MhoServiceModel.IndicationMessageProtoToASN1({0x12201a0?, 0xc00045ff00?}, {0xc0006a40c0, 0x36, 0x36})
/go/pkg/mod/github.com/onosproject/onos-e2-sm/servicemodels/[email protected]/servicemodel/servicemodel.go:83 +0xa6

new ZAP hierarchical logger does not give filename or line number in output

The new ZAP hierarchial logger does not give the file name or line number that the logging took place on in its output:

ran-simulator_1  | {"level":"INFO","ts":"2020-02-20T12:56:02.403Z","northbound/e2":"northbound/e2","msg":"RadioMeasReport 0000009 Ue-000D cqi:15(0000009),15(0000008),15(0000006)"}

Compare this to logging from the k8s.io/klog logger

onos-ran_1       | I0220 12:56:02.403792       1 manager.go:121] RadioMeasReport plmnid:001001 ecid:0000002 crnti:0019 cqis:15(ecid:0000001),15(ecid:0000002),15(ecid:0000004)

Delay in logging through the ZAP Hierarchial logger causes the order of logs to be mixed up

Observe the log below - onos-ran is using the k8s logger, where as ran-simulator is using the
common ZAP Hierarchial logger, while both are running on docker-compose.

Line 1 is the message being received by onos-ran, and Line 11 is the sending of this message by the ran-simulator. The time stamp for the sending looks right 602ms, and the receiving is at 603ms, but the order in which they are put to Standard Out is wrong because of a delay in processing (with the Sugared logger I expect)

onos-ran_1       | I0221 13:00:21.603046       1 e2.go:136] Got messageType 2
onos-ran_1       | I0221 13:00:21.603068       1 e2.go:158] plmnid:001001, ecid:0000001
onos-ran_1       | I0221 13:00:21.603090       1 e2.go:136] Got messageType 2
ran-simulator_1  | {"level":"INFO","ts":"2020-02-21T13:00:21.602Z","northbound/e2":"northbound/e2","msg":"handleCellConfigReport eci: 0000007"}
onos-ran_1       | I0221 13:00:21.603099       1 e2.go:158] plmnid:001001, ecid:0000003
ran-simulator_1  | {"level":"INFO","ts":"2020-02-21T13:00:21.602Z","northbound/e2":"northbound/e2","msg":"handleCellConfigReport eci: 0000002"}
onos-ran_1       | I0221 13:00:21.603111       1 manager.go:77] Got messageType 2
onos-ran_1       | I0221 13:00:21.603118       1 manager.go:80] plmnid:001001, ecid:0000001
onos-ran_1       | I0221 13:00:21.603126       1 manager.go:77] Got messageType 2
onos-ran_1       | I0221 13:00:21.603132       1 manager.go:80] plmnid:001001, ecid:0000003
ran-simulator_1  | {"level":"INFO","ts":"2020-02-21T13:00:21.602Z","northbound/e2":"northbound/e2","msg":"Sending control message CELL_CONFIG_REPORT"}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.