Skip to content

Commit

Permalink
Merge pull request #3 from nttcom/update/getting-started
Browse files Browse the repository at this point in the history
Add ingress-interface option to config file / Update getting-started
  • Loading branch information
Motok1 authored Jul 20, 2023
2 parents 3581efc + 3711560 commit 616925f
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 20 deletions.
4 changes: 0 additions & 4 deletions cmd/fluvia/fluvia.yaml

This file was deleted.

13 changes: 9 additions & 4 deletions cmd/fluvia/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
)

type flags struct {
configFile string
ifName string
configFile string
ingressIfName string
}

func main() {
Expand All @@ -32,7 +32,7 @@ func main() {
// Parse flags
f := &flags{}
flag.StringVar(&f.configFile, "f", "fluvia.yaml", "Specify a configuration file")
flag.StringVar(&f.ifName, "i", "", "Specify a configuration file")
flag.StringVar(&f.ingressIfName, "i", "", "Specify a configuration file")
flag.Parse()

// Read configuration file
Expand All @@ -46,5 +46,10 @@ func main() {
log.Panic(err)
}

client.New(f.ifName, raddr)
ingressIfName := f.ingressIfName
if f.ingressIfName == "" {
ingressIfName = c.Ipfix.IngressInterface
}

client.New(ingressIfName, raddr)
}
7 changes: 2 additions & 5 deletions docs/sources/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ Specify the IP address and port number for IPFIX collector
```yaml
---
ipfix:
addr: 192.0.2.1
address: 192.0.2.1
port: 4739
ingress-interface: ens192
```
### Run Fluvia Exporter using the fluvia command
Expand All @@ -28,10 +29,6 @@ Start the fluvia command. Specify the created configuration file with the -f opt
$ sudo fluvia -f fluvia.yaml
```

> **Note**
> TODO: Implement `meter.go` to acquire flow data and send it to `exporter.go` via channel ch.
> Currently, the fluvia command only has an exporter function, and `meter.go` is not implemented yet.

## 2. Fluvia Exporter as a Native IPFIX Exporter Library
### Clone this repository
Expand Down
5 changes: 3 additions & 2 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import (
)

type Ipfix struct {
Address string `yaml:"address"`
Port string `yaml:"port"`
Address string `yaml:"address"`
Port string `yaml:"port"`
IngressInterface string `yaml:"ingress-interface"`
}

type Config struct {
Expand Down
4 changes: 2 additions & 2 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/nttcom/fluvia/pkg/packet/ipfix"
)

func New(ifName string, raddr *net.UDPAddr) ClientError {
func New(ingressIfName string, raddr *net.UDPAddr) ClientError {
ch := make(chan []ipfix.FieldValue)
errChan := make(chan ClientError)

Expand All @@ -25,7 +25,7 @@ func New(ifName string, raddr *net.UDPAddr) ClientError {
}
}
}()
go NewMeter(ifName, ch)
go NewMeter(ingressIfName, ch)

for {
clientError := <-errChan
Expand Down
6 changes: 3 additions & 3 deletions pkg/client/meter.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import (
"github.com/nttcom/fluvia/pkg/packet/ipfix"
)

func NewMeter(ifaceName string, ch chan []ipfix.FieldValue) {
iface, err := net.InterfaceByName(ifaceName)
func NewMeter(ingressIfName string, ch chan []ipfix.FieldValue) {
iface, err := net.InterfaceByName(ingressIfName)
if err != nil {
log.Fatalf("lookup network iface %q: %s", ifaceName, err)
log.Fatalf("lookup network iface %q: %s", ingressIfName, err)
}

// Load the XDP program
Expand Down

0 comments on commit 616925f

Please sign in to comment.