Skip to content

Commit

Permalink
Re-enable reuseport
Browse files Browse the repository at this point in the history
  • Loading branch information
kanocz committed Aug 31, 2019
1 parent 04c3ca1 commit a7c3c95
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 18 deletions.
7 changes: 4 additions & 3 deletions cmd/cnetflow/cnetflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ var (
buildinfos = ""
AppVersion = "GoFlow NetFlow " + version + " " + buildinfos

Addr = flag.String("addr", "", "NetFlow/IPFIX listening address")
Port = flag.Int("port", 2055, "NetFlow/IPFIX listening port")
Addr = flag.String("addr", "", "NetFlow/IPFIX listening address")
Port = flag.Int("port", 2055, "NetFlow/IPFIX listening port")
Reuse = flag.Bool("reuse", false, "Enable so_reuseport for NetFlow/IPFIX listening port")

Workers = flag.Int("workers", 1, "Number of NetFlow workers")
LogLevel = flag.String("loglevel", "info", "Log level")
Expand Down Expand Up @@ -80,7 +81,7 @@ func main() {
"Type": "NetFlow"}).
Infof("Listening on UDP %v:%v", *Addr, *Port)

err := s.FlowRoutine(*Workers, *Addr, *Port)
err := s.FlowRoutine(*Workers, *Addr, *Port, *Reuse)
if err != nil {
log.Fatalf("Fatal error: could not listen to UDP (%v)", err)
}
Expand Down
7 changes: 4 additions & 3 deletions cmd/cnflegacy/cnflegacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ var (
buildinfos = ""
AppVersion = "GoFlow NetFlowV5 " + version + " " + buildinfos

Addr = flag.String("addr", "", "NetFlow v5 listening address")
Port = flag.Int("port", 2055, "NetFlow v5 listening port")
Addr = flag.String("addr", "", "NetFlow v5 listening address")
Port = flag.Int("port", 2055, "NetFlow v5 listening port")
Reuse = flag.Bool("reuse", false, "Enable so_reuseport for NetFlow v5 listening port")

Workers = flag.Int("workers", 1, "Number of NetFlow v5 workers")
LogLevel = flag.String("loglevel", "info", "Log level")
Expand Down Expand Up @@ -78,7 +79,7 @@ func main() {
"Type": "NetFlowLegacy"}).
Infof("Listening on UDP %v:%v", *Addr, *Port)

err := s.FlowRoutine(*Workers, *Addr, *Port)
err := s.FlowRoutine(*Workers, *Addr, *Port, *Reuse)
if err != nil {
log.Fatalf("Fatal error: could not listen to UDP (%v)", err)
}
Expand Down
7 changes: 4 additions & 3 deletions cmd/csflow/csflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ var (
buildinfos = ""
AppVersion = "GoFlow sFlow " + version + " " + buildinfos

Addr = flag.String("addr", "", "sFlow listening address")
Port = flag.Int("port", 6343, "sFlow listening port")
Addr = flag.String("addr", "", "sFlow listening address")
Port = flag.Int("port", 6343, "sFlow listening port")
Reuse = flag.Bool("reuse", false, "Enable so_reuseport for sFlow listening port")

Workers = flag.Int("workers", 1, "Number of sFlow workers")
LogLevel = flag.String("loglevel", "info", "Log level")
Expand Down Expand Up @@ -78,7 +79,7 @@ func main() {
"Type": "sFlow"}).
Infof("Listening on UDP %v:%v", *Addr, *Port)

err := s.FlowRoutine(*Workers, *Addr, *Port)
err := s.FlowRoutine(*Workers, *Addr, *Port, *Reuse)
if err != nil {
log.Fatalf("Fatal error: could not listen to UDP (%v)", err)
}
Expand Down
9 changes: 6 additions & 3 deletions cmd/goflow/goflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@ var (
SFlowEnable = flag.Bool("sflow", true, "Enable sFlow")
SFlowAddr = flag.String("sflow.addr", "", "sFlow listening address")
SFlowPort = flag.Int("sflow.port", 6343, "sFlow listening port")
SFlowReuse = flag.Bool("sflow.reuserport", false, "Enable so_reuseport for sFlow")

NFLEnable = flag.Bool("nfl", true, "Enable NetFlow v5")
NFLAddr = flag.String("nfl.addr", "", "NetFlow v5 listening address")
NFLPort = flag.Int("nfl.port", 2056, "NetFlow v5 listening port")
NFLReuse = flag.Bool("nfl.reuserport", false, "Enable so_reuseport for NetFlow v5")

NFEnable = flag.Bool("nf", true, "Enable NetFlow/IPFIX")
NFAddr = flag.String("nf.addr", "", "NetFlow/IPFIX listening address")
NFPort = flag.Int("nf.port", 2055, "NetFlow/IPFIX listening port")
NFReuse = flag.Bool("nf.reuserport", false, "Enable so_reuseport for NetFlow/IPFIX")

Workers = flag.Int("workers", 1, "Number of workers per collector")
LogLevel = flag.String("loglevel", "info", "Log level")
Expand Down Expand Up @@ -109,7 +112,7 @@ func main() {
"Type": "sFlow"}).
Infof("Listening on UDP %v:%v", *SFlowAddr, *SFlowPort)

err := sSFlow.FlowRoutine(*Workers, *SFlowAddr, *SFlowPort)
err := sSFlow.FlowRoutine(*Workers, *SFlowAddr, *SFlowPort, *SFlowReuse)
if err != nil {
log.Fatalf("Fatal error: could not listen to UDP (%v)", err)
}
Expand All @@ -123,7 +126,7 @@ func main() {
"Type": "NetFlow"}).
Infof("Listening on UDP %v:%v", *NFAddr, *NFPort)

err := sNF.FlowRoutine(*Workers, *NFAddr, *NFPort)
err := sNF.FlowRoutine(*Workers, *NFAddr, *NFPort, *NFReuse)
if err != nil {
log.Fatalf("Fatal error: could not listen to UDP (%v)", err)
}
Expand All @@ -137,7 +140,7 @@ func main() {
"Type": "NetFlowLegacy"}).
Infof("Listening on UDP %v:%v", *NFLAddr, *NFLPort)

err := sNFL.FlowRoutine(*Workers, *NFLAddr, *NFLPort)
err := sNFL.FlowRoutine(*Workers, *NFLAddr, *NFLPort, *NFLReuse)
if err != nil {
log.Fatalf("Fatal error: could not listen to UDP (%v)", err)
}
Expand Down
4 changes: 2 additions & 2 deletions utils/netflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ func (s *StateNetFlow) InitTemplates() {
s.samplinglock = &sync.RWMutex{}
}

func (s *StateNetFlow) FlowRoutine(workers int, addr string, port int) error {
func (s *StateNetFlow) FlowRoutine(workers int, addr string, port int, reuseport bool) error {
s.InitTemplates()
return UDPRoutine("NetFlow", s.DecodeFlow, workers, addr, port, false, s.Logger)
return UDPRoutine("NetFlow", s.DecodeFlow, workers, addr, port, reuseport, s.Logger)
}
4 changes: 2 additions & 2 deletions utils/nflegacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ func (s *StateNFLegacy) DecodeFlow(msg interface{}) error {
return nil
}

func (s *StateNFLegacy) FlowRoutine(workers int, addr string, port int) error {
return UDPRoutine("NetFlowV5", s.DecodeFlow, workers, addr, port, false, s.Logger)
func (s *StateNFLegacy) FlowRoutine(workers int, addr string, port int, reuseport bool) error {
return UDPRoutine("NetFlowV5", s.DecodeFlow, workers, addr, port, reuseport, s.Logger)
}
4 changes: 2 additions & 2 deletions utils/sflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,6 @@ func (s *StateSFlow) DecodeFlow(msg interface{}) error {
return nil
}

func (s *StateSFlow) FlowRoutine(workers int, addr string, port int) error {
return UDPRoutine("sFlow", s.DecodeFlow, workers, addr, port, false, s.Logger)
func (s *StateSFlow) FlowRoutine(workers int, addr string, port int, reuseport bool) error {
return UDPRoutine("sFlow", s.DecodeFlow, workers, addr, port, reuseport, s.Logger)
}

0 comments on commit a7c3c95

Please sign in to comment.