summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-08-19 22:14:11 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-08-19 22:14:11 +0900
commitaa9af495182e822b84201e1d708cda7d2d090313 (patch)
tree0a28581f78fa89a6b77036ea518c580f86087001
parentfb91965dd47045339a78f2231169a9d32be52985 (diff)
config file support rpki configuration
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--config/default.go5
-rw-r--r--gobgpd/main.go8
-rw-r--r--packet/rtr.go4
-rw-r--r--server/server.go26
4 files changed, 31 insertions, 12 deletions
diff --git a/config/default.go b/config/default.go
index 283ee629..94f5dc9d 100644
--- a/config/default.go
+++ b/config/default.go
@@ -98,5 +98,10 @@ func SetDefaultConfigValues(md toml.MetaData, bt *Bgp) error {
}
}
}
+ for _, r := range bt.RpkiServers.RpkiServerList {
+ if r.RpkiServerConfig.Port == 0 {
+ r.RpkiServerConfig.Port = bgp.RPKI_DEFAULT_PORT
+ }
+ }
return nil
}
diff --git a/gobgpd/main.go b/gobgpd/main.go
index 307372f1..bc274e6e 100644
--- a/gobgpd/main.go
+++ b/gobgpd/main.go
@@ -46,7 +46,6 @@ func main() {
DisableStdlog bool `long:"disable-stdlog" description:"disable standard logging"`
EnableZapi bool `short:"z" long:"enable-zapi" description:"enable zebra api"`
ZapiURL string `long:"zapi-url" description:"specify zebra api url"`
- RPKIServer string `long:"rpki-server" description:"specify rpki server url"`
}
_, err := flags.Parse(&opts)
if err != nil {
@@ -142,7 +141,7 @@ func main() {
reloadCh := make(chan bool)
go config.ReadConfigfileServe(opts.ConfigFile, configCh, reloadCh)
reloadCh <- true
- bgpServer := server.NewBgpServer(bgp.BGP_PORT, opts.RPKIServer)
+ bgpServer := server.NewBgpServer(bgp.BGP_PORT)
go bgpServer.Serve()
// start grpc Server
@@ -165,13 +164,12 @@ func main() {
for {
select {
case newConfig := <-configCh:
- var added []config.Neighbor
- var deleted []config.Neighbor
- var updated []config.Neighbor
+ var added, deleted, updated []config.Neighbor
if bgpConfig == nil {
bgpServer.SetGlobalType(newConfig.Bgp.Global)
bgpConfig = &newConfig.Bgp
+ bgpServer.SetRpkiConfig(newConfig.Bgp.RpkiServers)
added = newConfig.Bgp.Neighbors.NeighborList
deleted = []config.Neighbor{}
updated = []config.Neighbor{}
diff --git a/packet/rtr.go b/packet/rtr.go
index 8e7ea22a..8eca54f3 100644
--- a/packet/rtr.go
+++ b/packet/rtr.go
@@ -22,6 +22,10 @@ import (
)
const (
+ RPKI_DEFAULT_PORT = 323
+)
+
+const (
RTR_SERIAL_NOTIFY = iota
RTR_SERIAL_QUERY
RTR_RESET_QUERY
diff --git a/server/server.go b/server/server.go
index 6984885f..5f708ea2 100644
--- a/server/server.go
+++ b/server/server.go
@@ -70,11 +70,13 @@ func (m *broadcastGrpcMsg) send() {
}
type BgpServer struct {
- bgpConfig config.Bgp
- globalTypeCh chan config.Global
- addedPeerCh chan config.Neighbor
- deletedPeerCh chan config.Neighbor
- updatedPeerCh chan config.Neighbor
+ bgpConfig config.Bgp
+ globalTypeCh chan config.Global
+ addedPeerCh chan config.Neighbor
+ deletedPeerCh chan config.Neighbor
+ updatedPeerCh chan config.Neighbor
+ rpkiConfigCh chan config.RpkiServers
+
GrpcReqCh chan *GrpcRequest
listenPort int
policyUpdateCh chan config.RoutingPolicy
@@ -88,18 +90,19 @@ type BgpServer struct {
roaClient *roaClient
}
-func NewBgpServer(port int, roaURL string) *BgpServer {
+func NewBgpServer(port int) *BgpServer {
b := BgpServer{}
b.globalTypeCh = make(chan config.Global)
b.addedPeerCh = make(chan config.Neighbor)
b.deletedPeerCh = make(chan config.Neighbor)
b.updatedPeerCh = make(chan config.Neighbor)
+ b.rpkiConfigCh = make(chan config.RpkiServers)
b.GrpcReqCh = make(chan *GrpcRequest, 1)
b.policyUpdateCh = make(chan config.RoutingPolicy)
b.localRibMap = make(map[string]*LocalRib)
b.neighborMap = make(map[string]*Peer)
b.listenPort = port
- b.roaClient, _ = newROAClient(roaURL)
+ b.roaClient, _ = newROAClient("")
return &b
}
@@ -223,6 +226,11 @@ func (server *BgpServer) Serve() {
}
select {
+ case c := <-server.rpkiConfigCh:
+ if len(c.RpkiServerList) > 0 {
+ url := fmt.Sprintf("%s:%d", c.RpkiServerList[0].RpkiServerConfig.Address, c.RpkiServerList[0].RpkiServerConfig.Port)
+ server.roaClient, _ = newROAClient(url)
+ }
case rmsg := <-server.roaClient.recieveROA():
server.roaClient.handleRTRMsg(rmsg)
case zmsg := <-zapiMsgCh:
@@ -707,6 +715,10 @@ func (server *BgpServer) SetGlobalType(g config.Global) {
server.globalTypeCh <- g
}
+func (server *BgpServer) SetRpkiConfig(c config.RpkiServers) {
+ server.rpkiConfigCh <- c
+}
+
func (server *BgpServer) PeerAdd(peer config.Neighbor) {
server.addedPeerCh <- peer
}