-
Notifications
You must be signed in to change notification settings - Fork 27
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
Message size check for UDP transport #92
Conversation
Codecov Report
@@ Coverage Diff @@
## master #92 +/- ##
==========================================
- Coverage 81.30% 81.14% -0.16%
==========================================
Files 13 13
Lines 1487 1496 +9
==========================================
+ Hits 1209 1214 +5
- Misses 186 191 +5
+ Partials 92 91 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
887a1c0
to
c95b4a6
Compare
pkg/exporter/process.go
Outdated
return 0, fmt.Errorf("set size exceeds max socket size") | ||
if ep.connToCollector.LocalAddr().Network() == "tcp" { | ||
if msgLen > entities.MaxTcpSocketMsgSize { | ||
return 0, fmt.Errorf("TCP transport: set size exceeds max socket buffer size") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: s/set/message
pkg/exporter/process.go
Outdated
} | ||
} else { | ||
if msgLen > ep.pathMTU { | ||
return 0, fmt.Errorf("UDP transport: set size exceeds max pathMTU (set as %v)", ep.pathMTU) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
dataSet.AddRecord(elements, templateID) | ||
} | ||
bytesSent, err = exporter.SendSet(dataSet) | ||
assert.Error(t, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to log the error here. the error message is could not send the complete message on the connection
instead of exceeding maximum size. Not sure whether we can test it here since 65535 is rather large and current msgLen for 10000 records is only 14484
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch with the error. Each data record is around ~8 bytes, so the number of data records added is fine but uint16 casting in set.GetBufferLen
is causing the issue. Fixed it.
pkg/exporter/process_test.go
Outdated
// 28 is the size of the IPFIX message including all headers (20 bytes) | ||
assert.Equal(t, 28, bytesSent) | ||
assert.Equal(t, dataRecBytes, <-buffCh) | ||
assert.Equal(t, uint32(1), exporter.seqNumber) | ||
|
||
// Create data set with multiple data records to test invalid message length | ||
// logic for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
incomplete comment here.
b63d712
to
db1b396
Compare
Added a path MTU config parameter for InitExportingProcess function. For UDP transport, based on path MTU parameter, we make a decision on the message size. This is optional parameter for TCP transport; TCP supports max socket buffer size (65535).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Added a path MTU config parameter for InitExportingProcess function. For UDP transport, based on path MTU parameter, we make a decision on the message size. This is optional parameter for TCP transport; TCP supports max socket buffer size (65535).
Added a path MTU config parameter for InitExportingProcess function.
For UDP transport, based on path MTU parameter, we make a decision on
the message size. This is optional parameter for TCP transport; TCP
supports max socket buffer size (65535).
Cleaned up AddSetAndSendMsg function a bit as well.
This PR is on top of PR #91. It will be checked in after that PR. Please look for separate commit when reviewing.