summaryrefslogtreecommitdiffhomepage
path: root/cmd
diff options
context:
space:
mode:
authorEiichiro Watanabe <a16tochjp@gmail.com>2018-11-13 14:41:52 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2018-11-14 19:32:24 +0900
commitfa387c90650613bceaca6c6c90c8744405988f8c (patch)
treeb41edff67b98094e9a8d85710032849f9d7c5671 /cmd
parent99b272438618c33fecc74ae8514c6a10f3de8f8f (diff)
Fix Statistics Report in BMP
Diffstat (limited to 'cmd')
-rw-r--r--cmd/gobgp/bmp.go17
-rw-r--r--cmd/gobgp/common.go4
-rw-r--r--cmd/gobgpd/main.go7
3 files changed, 22 insertions, 6 deletions
diff --git a/cmd/gobgp/bmp.go b/cmd/gobgp/bmp.go
index 1fbc0ae2..831f6340 100644
--- a/cmd/gobgp/bmp.go
+++ b/cmd/gobgp/bmp.go
@@ -49,6 +49,13 @@ func modBmpServer(cmdType string, args []string) error {
var err error
switch cmdType {
case cmdAdd:
+ statisticsTimeout := 0
+ if bmpOpts.StatisticsTimeout >= 0 && bmpOpts.StatisticsTimeout <= 65535 {
+ statisticsTimeout = bmpOpts.StatisticsTimeout
+ } else {
+ return fmt.Errorf("invalid statistics-timeout value. it must be in the range 0-65535. default value is 0 and means disabled.")
+ }
+
policyType := api.AddBmpRequest_PRE
if len(args) > 1 {
switch args[1] {
@@ -65,9 +72,10 @@ func modBmpServer(cmdType string, args []string) error {
}
}
_, err = client.AddBmp(ctx, &api.AddBmpRequest{
- Address: address,
- Port: port,
- Type: policyType,
+ Address: address,
+ Port: port,
+ Type: policyType,
+ StatisticsTimeout: int32(statisticsTimeout),
})
case cmdDel:
_, err = client.DeleteBmp(ctx, &api.DeleteBmpRequest{
@@ -93,6 +101,9 @@ func newBmpCmd() *cobra.Command {
}
},
}
+ if w == cmdAdd {
+ subcmd.PersistentFlags().IntVarP(&bmpOpts.StatisticsTimeout, "statistics-timeout", "s", 0, "Timeout of statistics report")
+ }
bmpCmd.AddCommand(subcmd)
}
diff --git a/cmd/gobgp/common.go b/cmd/gobgp/common.go
index add3d811..7f582902 100644
--- a/cmd/gobgp/common.go
+++ b/cmd/gobgp/common.go
@@ -104,6 +104,10 @@ var mrtOpts struct {
NextHop net.IP `long:"nexthop" description:"Rewrite nexthop"`
}
+var bmpOpts struct {
+ StatisticsTimeout int `short:s long:"statistics-timeout" description:"Interval for Statistics Report"`
+}
+
func formatTimedelta(d int64) string {
u := uint64(d)
neg := d < 0
diff --git a/cmd/gobgpd/main.go b/cmd/gobgpd/main.go
index c880b4b4..5c8f5ac5 100644
--- a/cmd/gobgpd/main.go
+++ b/cmd/gobgpd/main.go
@@ -216,9 +216,10 @@ func main() {
}
for _, c := range newConfig.BmpServers {
if err := bgpServer.AddBmp(context.Background(), &api.AddBmpRequest{
- Address: c.Config.Address,
- Port: c.Config.Port,
- Type: api.AddBmpRequest_MonitoringPolicy(c.Config.RouteMonitoringPolicy.ToInt()),
+ Address: c.Config.Address,
+ Port: c.Config.Port,
+ Type: api.AddBmpRequest_MonitoringPolicy(c.Config.RouteMonitoringPolicy.ToInt()),
+ StatisticsTimeout: int32(c.Config.StatisticsTimeout),
}); err != nil {
log.Fatalf("failed to set bmp config: %s", err)
}