summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gobgp/cmd/common.go2
-rw-r--r--gobgp/cmd/monitor.go55
2 files changed, 57 insertions, 0 deletions
diff --git a/gobgp/cmd/common.go b/gobgp/cmd/common.go
index 84925d0b..44de301e 100644
--- a/gobgp/cmd/common.go
+++ b/gobgp/cmd/common.go
@@ -163,6 +163,7 @@ type Path struct {
IsWithdraw bool `json:"isWithdraw"`
Validation int32 `json:"validation"`
Filtered bool `json:"filtered"`
+ SourceId string `json:"source-id"`
}
func ApiStruct2Path(p *gobgpapi.Path) ([]*Path, error) {
@@ -208,6 +209,7 @@ func ApiStruct2Path(p *gobgpapi.Path) ([]*Path, error) {
Best: p.Best,
IsWithdraw: p.IsWithdraw,
Validation: p.Validation,
+ SourceId: p.SourceId,
Filtered: p.Filtered,
})
}
diff --git a/gobgp/cmd/monitor.go b/gobgp/cmd/monitor.go
index 95f5af2a..88142866 100644
--- a/gobgp/cmd/monitor.go
+++ b/gobgp/cmd/monitor.go
@@ -164,12 +164,67 @@ func NewMonitorCmd() *cobra.Command {
},
}
+ adjInCmd := &cobra.Command{
+ Use: CMD_ADJ_IN,
+ Run: func(cmd *cobra.Command, args []string) {
+ name := ""
+ if len(args) > 0 {
+ remoteIP := net.ParseIP(args[0])
+ if remoteIP == nil {
+ fmt.Println("invalid ip address: %s", args[0])
+ os.Exit(1)
+ }
+ name = args[0]
+ }
+ family, err := checkAddressFamily(bgp.RouteFamily(0))
+ if err != nil {
+ fmt.Println(err)
+ os.Exit(1)
+ }
+ arg := &gobgpapi.Table{
+ Type: gobgpapi.Resource_ADJ_IN,
+ Family: uint32(family),
+ Name: name,
+ }
+
+ stream, err := client.MonitorRib(context.Background(), arg)
+ if err != nil {
+ fmt.Println(err)
+ os.Exit(1)
+ }
+ for {
+ d, err := stream.Recv()
+ if err == io.EOF {
+ break
+ } else if err != nil {
+ fmt.Println(err)
+ os.Exit(1)
+ }
+ p, err := ApiStruct2Path(d.Paths[0])
+ if err != nil {
+ fmt.Println(err)
+ os.Exit(1)
+ }
+
+ if globalOpts.Json {
+ j, _ := json.Marshal(p)
+ fmt.Println(string(j))
+ } else {
+ ShowRoute(p, false, false, false, true, false)
+ }
+ }
+
+ },
+ }
+ adjInCmd.PersistentFlags().StringVarP(&subOpts.AddressFamily, "address-family", "a", "", "address family")
+
monitorCmd := &cobra.Command{
Use: CMD_MONITOR,
}
monitorCmd.AddCommand(globalCmd)
monitorCmd.AddCommand(neighborCmd)
monitorCmd.AddCommand(rpkiCmd)
+ monitorCmd.AddCommand(adjInCmd)
return monitorCmd
}