Skip to content

Commit

Permalink
move go-ipfix to v0.4.3 and fix destinationServicePort warnings
Browse files Browse the repository at this point in the history
The commit is for bumping go-ipfix to v0.4.3, with fixes on issue #1747 and changes for
exporting process and collecting process input. It also fixes issue #1820, which is about
unexpected number of warnings for destinationServicePort mismatch.
  • Loading branch information
zyiou authored and Yongming Ding committed Feb 8, 2021
1 parent bce7799 commit 5e087f8
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 32 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ require (
github.com/stretchr/testify v1.6.1
github.com/ti-mo/conntrack v0.3.0
github.com/vishvananda/netlink v1.1.0
github.com/vmware/go-ipfix v0.4.2
github.com/vmware/go-ipfix v0.4.3
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a
golang.org/x/exp v0.0.0-20190312203227-4b39c73a6495
golang.org/x/mod v0.4.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,8 @@ github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYp
github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc/go.mod h1:ZjcWmFBXmLKZu9Nxj3WKYEafiSqer2rnvPr0en9UNpI=
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df h1:OviZH7qLw/7ZovXvuNyL3XQl8UFofeikI1NW1Gypu7k=
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU=
github.com/vmware/go-ipfix v0.4.2 h1:KfIYSxC2D4Rdez9KojXYKYyPnU2dkCawtjfbXaTdbpk=
github.com/vmware/go-ipfix v0.4.2/go.mod h1:lQz3f4r2pZWo0q8s8BtZ0xo5fPSOYsYteqJgBASP69o=
github.com/vmware/go-ipfix v0.4.3 h1:6fzvm15xBxbyqIRLOr0nmhyoODLFJp3FBlXqScJG7kI=
github.com/vmware/go-ipfix v0.4.3/go.mod h1:lQz3f4r2pZWo0q8s8BtZ0xo5fPSOYsYteqJgBASP69o=
github.com/wenyingd/ofnet v0.0.0-20201109024835-6fd225d8c8d1 h1:jBQJP2829C09r07Rc5EWS0+LefZhY51BJG0v3pLlGGA=
github.com/wenyingd/ofnet v0.0.0-20201109024835-6fd225d8c8d1/go.mod h1:8mMMWAYBNUeTGXYKizOLETfN3WIbu3P5DgvS2jiXKdI=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8=
Expand Down
22 changes: 9 additions & 13 deletions pkg/agent/flowexporter/exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,32 +184,24 @@ func (exp *flowExporter) initFlowExporter(collectorAddr string, collectorProto s
collectorAddr = net.JoinHostPort(hostIPs[0].String(), defaultIPFIXPort)
}

// TODO: This code can be further simplified by changing the go-ipfix API to accept
// collectorAddr and collectorProto instead of net.Addr input.
var expInput exporter.ExporterInput
if collectorProto == "tcp" {
collector, err := net.ResolveTCPAddr("tcp", collectorAddr)
if err != nil {
return err
}
// TCP transport does not need any tempRefTimeout, so sending 0.
// tempRefTimeout is the template refresh timeout, which specifies how often
// the exporting process should send the template again.
expInput = exporter.ExporterInput{
CollectorAddr: collector,
CollectorAddress: collectorAddr,
CollectorProtocol: collectorProto,
ObservationDomainID: obsID,
TempRefTimeout: 0,
PathMTU: 0,
IsEncrypted: false,
}
} else {
collector, err := net.ResolveUDPAddr("udp", collectorAddr)
if err != nil {
return err
}
// For UDP transport, hardcoding tempRefTimeout value as 1800s.
expInput = exporter.ExporterInput{
CollectorAddr: collector,
CollectorAddress: collectorAddr,
CollectorProtocol: collectorProto,
ObservationDomainID: obsID,
TempRefTimeout: 1800,
PathMTU: 0,
Expand Down Expand Up @@ -446,7 +438,11 @@ func (exp *flowExporter) addRecordToSet(dataSet ipfix.IPFIXSet, record flowexpor
ie.Value = net.ParseIP("::")
}
case "destinationServicePort":
ie.Value = record.Conn.TupleOrig.DestinationPort
if record.Conn.DestinationServicePortName != "" {
ie.Value = record.Conn.TupleOrig.DestinationPort
} else {
ie.Value = uint16(0)
}
case "destinationServicePortName":
if record.Conn.DestinationServicePortName != "" {
ie.Value = record.Conn.DestinationServicePortName
Expand Down
26 changes: 11 additions & 15 deletions pkg/flowaggregator/flowaggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ var (

const (
aggregationWorkerNum = 2
udpTransport = "udp"
tcpTransport = "tcp"
collectorAddress = "0.0.0.0:4739"
)

type AggregatorTransportProtocol string
Expand Down Expand Up @@ -181,21 +184,20 @@ func genObservationID() (uint32, error) {
}

func (fa *flowAggregator) InitCollectingProcess() error {
var collectAddr net.Addr
var err error
var cpInput collector.CollectorInput
if fa.aggregatorTransportProtocol == AggregatorTransportProtocolTCP {
collectAddr, _ = net.ResolveTCPAddr("tcp", "0.0.0.0:4739")
cpInput = collector.CollectorInput{
Address: collectAddr,
Address: collectorAddress,
Protocol: tcpTransport,
MaxBufferSize: 65535,
TemplateTTL: 0,
IsEncrypted: false,
}
} else {
collectAddr, _ = net.ResolveUDPAddr("udp", "0.0.0.0:4739")
cpInput = collector.CollectorInput{
Address: collectAddr,
Address: collectorAddress,
Protocol: udpTransport,
MaxBufferSize: 1024,
TemplateTTL: 0,
IsEncrypted: false,
Expand Down Expand Up @@ -226,26 +228,20 @@ func (fa *flowAggregator) initExportingProcess() error {
// externalFlowCollectorAddr and externalFlowCollectorProto instead of net.Addr input.
var expInput exporter.ExporterInput
if fa.externalFlowCollectorProto == "tcp" {
collector, err := net.ResolveTCPAddr("tcp", fa.externalFlowCollectorAddr)
if err != nil {
return err
}
// TCP transport does not need any tempRefTimeout, so sending 0.
expInput = exporter.ExporterInput{
CollectorAddr: collector,
CollectorAddress: fa.externalFlowCollectorAddr,
CollectorProtocol: fa.externalFlowCollectorProto,
ObservationDomainID: obsID,
TempRefTimeout: 0,
PathMTU: 0,
IsEncrypted: false,
}
} else {
collector, err := net.ResolveUDPAddr("udp", fa.externalFlowCollectorAddr)
if err != nil {
return err
}
// For UDP transport, hardcoding tempRefTimeout value as 1800s. So we will send out template every 30 minutes.
expInput = exporter.ExporterInput{
CollectorAddr: collector,
CollectorAddress: fa.externalFlowCollectorAddr,
CollectorProtocol: fa.externalFlowCollectorProto,
ObservationDomainID: obsID,
TempRefTimeout: 1800,
PathMTU: 0,
Expand Down
2 changes: 1 addition & 1 deletion plugins/octant/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc/go.mod h1:ZjcWmF
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU=
github.com/vmware-tanzu/octant v0.16.1 h1:fkofB9oZ4yTqOaKf0JEhdibnIGBEOJ4OYOZL4Kli74A=
github.com/vmware-tanzu/octant v0.16.1/go.mod h1:FhWXp2v0bgOQEwuOMOE49DXUu+uwWt8lXh7aOHtrA8A=
github.com/vmware/go-ipfix v0.4.2/go.mod h1:lQz3f4r2pZWo0q8s8BtZ0xo5fPSOYsYteqJgBASP69o=
github.com/vmware/go-ipfix v0.4.3/go.mod h1:lQz3f4r2pZWo0q8s8BtZ0xo5fPSOYsYteqJgBASP69o=
github.com/wenyingd/ofnet v0.0.0-20201109024835-6fd225d8c8d1/go.mod h1:8mMMWAYBNUeTGXYKizOLETfN3WIbu3P5DgvS2jiXKdI=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xlab/handysort v0.0.0-20150421192137-fb3537ed64a1/go.mod h1:QcJo0QPSfTONNIgpN5RA8prR7fF8nkF6cTWTcNerRO8=
Expand Down

0 comments on commit 5e087f8

Please sign in to comment.