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

[IPv6] Support flow exporter #1541

Merged
merged 1 commit into from
Dec 8, 2020
Merged

Conversation

lzhecheng
Copy link
Contributor

@lzhecheng lzhecheng commented Nov 12, 2020

No description provided.

@antrea-bot
Copy link
Collaborator

Thanks for your PR.
Unit tests and code linters are run automatically every time the PR is updated.
E2e, conformance and network policy tests can only be triggered by a member of the vmware-tanzu organization. Regular contributors to the project should join the org.

The following commands are available:

  • /test-e2e: to trigger e2e tests.
  • /skip-e2e: to skip e2e tests.
  • /test-conformance: to trigger conformance tests.
  • /skip-conformance: to skip conformance tests.
  • /test-all-features-conformance: to trigger conformance tests with all alpha features enabled.
  • /skip-all-features-conformance: to skip conformance tests with all alpha features enabled.
  • /test-whole-conformance: to trigger all conformance tests on linux.
  • /skip-whole-conformance: to skip all conformance tests on linux.
  • /test-networkpolicy: to trigger networkpolicy tests.
  • /skip-networkpolicy: to skip networkpolicy tests.
  • /test-windows-conformance: to trigger windows conformance tests.
  • /skip-windows-conformance: to skip windows conformance tests.
  • /test-windows-networkpolicy: to trigger windows networkpolicy tests.
  • /skip-windows-networkpolicy: to skip windows networkpolicy tests.
  • /test-hw-offload: to trigger ovs hardware offload test.
  • /skip-hw-offload: to skip ovs hardware offload test.
  • /test-all: to trigger all tests (except whole conformance).
  • /skip-all: to skip all tests (except whole conformance).

@codecov-io
Copy link

codecov-io commented Nov 12, 2020

Codecov Report

Merging #1541 (7dea211) into master (9d3d10b) will increase coverage by 0.99%.
The diff coverage is 58.73%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1541      +/-   ##
==========================================
+ Coverage   63.31%   64.30%   +0.99%     
==========================================
  Files         170      181      +11     
  Lines       14250    15427    +1177     
==========================================
+ Hits         9023     9921     +898     
- Misses       4292     4472     +180     
- Partials      935     1034      +99     
Flag Coverage Δ
e2e-tests 47.77% <38.24%> (?)
kind-e2e-tests 52.60% <51.84%> (-2.79%) ⬇️
unit-tests 40.46% <21.37%> (-0.81%) ⬇️

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

Impacted Files Coverage Δ
cmd/antrea-agent/agent.go 0.00% <0.00%> (ø)
.../agent/apiserver/handlers/networkpolicy/handler.go 58.33% <ø> (ø)
...gent/controller/noderoute/node_route_controller.go 61.04% <ø> (+14.58%) ⬆️
pkg/agent/stats/collector.go 97.72% <ø> (ø)
pkg/antctl/antctl.go 100.00% <ø> (ø)
pkg/antctl/transform/controllerinfo/transform.go 0.00% <ø> (ø)
pkg/antctl/transform/version/transform.go 44.82% <ø> (ø)
pkg/controller/networkpolicy/tier.go 90.00% <ø> (ø)
pkg/features/antrea_features.go 16.66% <ø> (ø)
pkg/ovs/openflow/ofctrl_builder.go 60.94% <0.00%> (-1.23%) ⬇️
... and 91 more

@lxiaopei
Copy link
Contributor

/test-e2e /test-conformance /test-networkpolicy

Copy link
Member

@srikartati srikartati left a comment

Choose a reason for hiding this comment

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

My main comment is about destinationClusterIPv6. Otherwise, it looks good to me.

build/yamls/antrea-aks.yml Outdated Show resolved Hide resolved
pkg/agent/flowexporter/exporter/exporter.go Outdated Show resolved Hide resolved
@lzhecheng lzhecheng force-pushed the ipv6-fx branch 2 times, most recently from ebc6fbf to 6ed7a7c Compare November 13, 2020 07:40
Copy link
Member

@srikartati srikartati left a comment

Choose a reason for hiding this comment

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

@lzhecheng Currently we consider only the connections in Antrea connection zone of conntrack table and ignore connections in the default zone.

There is a separate connection zone for IPv6. Don't we need to consider that connection zone if the stack is IPv6? Wondering if the flow exporter e2e test is passing with IPv6 stack or not.

@lzhecheng
Copy link
Contributor Author

@lzhecheng Currently we consider only the connections in Antrea connection zone of conntrack table and ignore connections in the default zone.

There is a separate connection zone for IPv6. Don't we need to consider that connection zone if the stack is IPv6? Wondering if the flow exporter e2e test is passing with IPv6 stack or not.

I think I have it?
https://github.com/vmware-tanzu/antrea/pull/1541/files#diff-
fa3c4bf704e90acceacb369eed2fe23b739bd365e8d41ff087becab848371924R244

@lzhecheng
Copy link
Contributor Author

/test-windows-conformance
/test-windows-networkpolicy

srikartati
srikartati previously approved these changes Nov 13, 2020
Copy link
Member

@srikartati srikartati left a comment

Choose a reason for hiding this comment

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

Thanks for making the changes.
LGTM.

@srikartati
Copy link
Member

/test-ipv6-all
/test-ipv6-only-all

@srikartati
Copy link
Member

/test-e2e
/test-conformance
/test-networkpolicy

@lzhecheng
Copy link
Contributor Author

/test-ipv6-e2e
/test-windows-networkpolicy

@lzhecheng lzhecheng force-pushed the ipv6-fx branch 2 times, most recently from 09d082e to 6a50de8 Compare December 4, 2020 10:21
@lzhecheng
Copy link
Contributor Author

/test-e2e
/test-ipv6-e2e
/test-ipv6-only-e2e

@lzhecheng
Copy link
Contributor Author

/test-all
/test-ipv6-all
/test-ipv6-only-all

@lzhecheng
Copy link
Contributor Author

/test-conformance
/test-ipv6-e2e
/test-ipv6-networkpolicy


return sentBytes, nil
}

func (exp *flowExporter) sendDataSet(dataSet ipfix.IPFIXSet, record flowexporter.FlowRecord, templateID uint16) error {
func (exp *flowExporter) sendDataSet(dataSet ipfix.IPFIXSet, record flowexporter.FlowRecord, templateID uint16, isIPv6 bool) error {
Copy link
Member

Choose a reason for hiding this comment

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

Do we need the args templateID and isIPv6? I thinkrecord flowexporter.FlowRecord and exp *flowExporter should have these already.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Removed.

@@ -195,9 +227,15 @@ func (exp *flowExporter) sendFlowRecords() error {
return nil
}

func (exp *flowExporter) sendTemplateSet(templateSet ipfix.IPFIXSet, templateID uint16) (int, error) {
func (exp *flowExporter) sendTemplateSet(templateSet ipfix.IPFIXSet, templateID uint16, isIPv6 bool) (int, error) {
Copy link
Member

Choose a reason for hiding this comment

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

templateID is not needed as we assign the templateID to exp *flowExporter in L179 and L189 and can use that inside the function based on isIPv6. Is my understanding correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right. Updated.

ie.Value = record.Conn.TupleOrig.DestinationAddress
} else {
// Same as destinationClusterIPv4.
ie.Value = net.IP{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
Copy link
Member

Choose a reason for hiding this comment

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

nit: simplified version net.IP.Parse("::0")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems "::" works as well. Updated.

@@ -70,4 +70,6 @@ type FlowRecord struct {
PrevBytes uint64
PrevReversePackets uint64
PrevReverseBytes uint64
V4Enabled bool
Copy link
Member

Choose a reason for hiding this comment

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

Just need one field isIPv6 as one flow record corresponds to either v4 or v6.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@@ -35,9 +35,32 @@ func NewFlowRecords(connStore *connections.ConnectionStore) *FlowRecords {
}

// BuildFlowRecords builds the flow record map from connection map in connection store
func (fr *FlowRecords) BuildFlowRecords() error {
func (fr *FlowRecords) BuildFlowRecords(v4Enabled bool, v6Enabled bool) error {
Copy link
Member

Choose a reason for hiding this comment

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

We do not need the args. From IP in key, we can say if it is v4 or v6.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@lzhecheng lzhecheng force-pushed the ipv6-fx branch 3 times, most recently from d4de2f4 to a579a20 Compare December 7, 2020 04:57
@lzhecheng
Copy link
Contributor Author

/test-e2e
/test-ipv6-e2e
/test-ipv6-only-e2e

@lzhecheng
Copy link
Contributor Author

/test-all
/test-ipv6-all
/test-ipv6-only-all

fr.recordsMap[key] = record
return nil
}

// fr.addOrUpdateFlowRecord method does not return any error, hence no error handling required.
Copy link
Member

@srikartati srikartati Dec 7, 2020

Choose a reason for hiding this comment

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

We could change the comment that still says the method name of flow record rather than function name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed. fr.addOrUpdateFlowRecord -> addOrUpdateFlowRecord

srikartati
srikartati previously approved these changes Dec 7, 2020
Copy link
Member

@srikartati srikartati left a comment

Choose a reason for hiding this comment

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

Thanks for addressing comments.
LGTM.

@lzhecheng
Copy link
Contributor Author

/test-all
/test-ipv6-all
/test-ipv6-only-all

@lzhecheng
Copy link
Contributor Author

/test-conformance

@lzhecheng
Copy link
Contributor Author

/test-e2e

@lzhecheng
Copy link
Contributor Author

/test-ipv6-only-conformance

1 similar comment
@lzhecheng
Copy link
Contributor Author

/test-ipv6-only-conformance

Copy link
Contributor

@antoninbas antoninbas left a comment

Choose a reason for hiding this comment

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

couple nits, otherwise LGTM

Comment on lines 228 to 229
// Poll calls into conntrackDumper interface to dump conntrack flows. In a dual-stack setup, there will be two connsLens
// get returned.
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Poll calls into conntrackDumper interface to dump conntrack flows. It returns the number of connections for each address family, as a slice. In dual-stack clusters, the slice will contain 2 values (number of IPv4 connections first, then number of IPv6 connections).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

IANAReverseInfoElements = []string{
"reversePacketTotalCount",
"reverseOctetTotalCount",
"reversePacketDeltaCount",
"reverseOctetDeltaCount",
}
AntreaInfoElements = []string{
AntreaInfoElementsCommon = []string{
Copy link
Contributor

Choose a reason for hiding this comment

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

does not need to be exported I think... could be antreaInfoElementsCommon

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed. Updated.


func getElemList(ianaIE []string, antreaIE []string) []*ipfixentities.InfoElementWithValue {
// Following consists of all elements that are in IANAInfoElements and AntreaInfoElements (globals)
// Need only element name and other are dummys
Copy link
Contributor

Choose a reason for hiding this comment

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

s/other are dummys/other fields are set to dummy values

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

Co-authored-by: Antonin Bas <antonin.bas@gmail.com>
Co-authored-by: srikartati <stati@vmware.com>
@lzhecheng
Copy link
Contributor Author

/test-all
/test-ipv6-all
/test-ipv6-only-all

@lzhecheng
Copy link
Contributor Author

/test-conformance
/test-networkpolicy

@lzhecheng
Copy link
Contributor Author

Thank you a lot for the effort to review! @antoninbas @srikartati
Merging this PR.

@lzhecheng lzhecheng merged commit 501bd0b into antrea-io:master Dec 8, 2020
@lzhecheng lzhecheng deleted the ipv6-fx branch December 8, 2020 07:06
antoninbas added a commit that referenced this pull request Dec 23, 2020
Co-authored-by: Antonin Bas <antonin.bas@gmail.com>
Co-authored-by: srikartati <stati@vmware.com>
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

Successfully merging this pull request may close these issues.

7 participants