Skip to content

Commit

Permalink
Get BGP-LS information from GoBGP
Browse files Browse the repository at this point in the history
  • Loading branch information
Motok1 committed Sep 13, 2022
1 parent 4b5d8a7 commit c0be074
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
21 changes: 21 additions & 0 deletions cmd/polad/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@ import (
"flag"
"log"
"os"
"time"

"go.uber.org/zap"

"github.com/nttcom/pola/internal/config"
"github.com/nttcom/pola/internal/pkg/gobgp"
"github.com/nttcom/pola/internal/pkg/table"
"github.com/nttcom/pola/pkg/logger"
"github.com/nttcom/pola/pkg/server"
)

const (
TED_UPDATE_INTERVAL = 10 // (min)
)

type Flags struct {
ConfigFile string
}
Expand Down Expand Up @@ -49,6 +55,21 @@ func main() {

tedElemsChan := make(chan []table.TedElem)

// Get BGP-LS NLRI from GoBGP
if c.Global.Gobgp.Port != "" {
go func() {
for {
tedElems, err := gobgp.GetBgplsNlris(c.Global.Gobgp.Address, c.Global.Gobgp.Port)
if err != nil {
logger.Panic("Failed session with GoBGP", zap.Error(err))
}
tedElemsChan <- tedElems
time.Sleep(TED_UPDATE_INTERVAL * time.Minute)
}

}()
}

o := new(server.PceOptions)
o.PcepAddr = c.Global.Pcep.Address
o.PcepPort = c.Global.Pcep.Port
Expand Down
5 changes: 4 additions & 1 deletion configs/polad.yaml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ global:
port: 4189
grpc:
address: "127.0.0.1"
port: 50051
port: 50052
log:
path: "/var/log/pola/"
name: "polad.log"
gobgp:
address: "127.0.0.1"
port: 50051
12 changes: 9 additions & 3 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@ type Log struct {
Name string `yaml:"name"`
}

type Gobgp struct {
Address string `yaml:"address"`
Port string `yaml:"port"`
}

type Global struct {
Pcep Pcep `yaml:"pcep"`
Grpc Grpc `yaml:"grpc"`
Log Log `yaml:"log"`
Pcep Pcep `yaml:"pcep"`
Grpc Grpc `yaml:"grpc"`
Log Log `yaml:"log"`
Gobgp Gobgp `yaml:"gobgp"`
}

type Config struct {
Expand Down

0 comments on commit c0be074

Please sign in to comment.