Skip to content
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

Merged
merged 1 commit into from
Dec 3, 2020

Conversation

srikartati
Copy link
Contributor

@srikartati srikartati commented Nov 29, 2020

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.

@codecov
Copy link

codecov bot commented Nov 29, 2020

Codecov Report

Merging #92 (d2a8d83) into master (499c7d9) will decrease coverage by 0.15%.
The diff coverage is 86.66%.

Impacted file tree graph

@@            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     
Flag Coverage Δ
integration-tests 67.20% <63.63%> (-0.68%) ⬇️
unit-tests 80.68% <86.66%> (+0.25%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/entities/message.go 100.00% <ø> (ø)
pkg/entities/set.go 89.18% <50.00%> (-5.10%) ⬇️
pkg/exporter/process.go 72.17% <100.00%> (+5.50%) ⬆️
pkg/intermediate/aggregate.go 75.56% <0.00%> (-3.41%) ⬇️

@srikartati srikartati changed the title Message size check for UDP size Message size check for UDP transport Nov 30, 2020
@srikartati srikartati force-pushed the udp_check branch 2 times, most recently from 887a1c0 to c95b4a6 Compare December 2, 2020 16:49
@srikartati srikartati requested a review from zyiou December 2, 2020 19:45
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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: s/set/message

}
} else {
if msgLen > ep.pathMTU {
return 0, fmt.Errorf("UDP transport: set size exceeds max pathMTU (set as %v)", ep.pathMTU)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above.

zyiou
zyiou previously approved these changes Dec 2, 2020
Copy link
Contributor

@zyiou zyiou left a 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)
Copy link
Contributor

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

Copy link
Contributor Author

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.

// 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

incomplete comment here.

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).
Copy link
Contributor

@zyiou zyiou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@srikartati srikartati merged commit 150f98e into vmware:master Dec 3, 2020
@srikartati srikartati deleted the udp_check branch December 3, 2020 17:40
zyiou pushed a commit to zyiou/go-ipfix that referenced this pull request Feb 5, 2021
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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants