mirror of
https://github.com/osrg/gobgp.git
synced 2024-05-11 05:55:10 +00:00
cli: support monitoring specific route family
// monitor only ipv6 best path changes $ gobgp monitor global rib -a ipv6 Signed-off-by: ISHIDA Wataru <[email protected]>
This commit is contained in:
+3
-1
@@ -465,7 +465,9 @@ func checkAddressFamily(ip net.IP) (bgp.RouteFamily, error) {
|
||||
case "ipv6-flowspec", "ipv6-flow", "flow6":
|
||||
rf = bgp.RF_FS_IPv6_UC
|
||||
case "":
|
||||
if len(ip) == 0 || ip.To4() != nil {
|
||||
if ip == nil {
|
||||
return rf, nil
|
||||
} else if len(ip) == 0 || ip.To4() != nil {
|
||||
rf = bgp.RF_IPv4_UC
|
||||
} else {
|
||||
rf = bgp.RF_IPv6_UC
|
||||
|
||||
@@ -22,7 +22,6 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
"golang.org/x/net/context"
|
||||
"io"
|
||||
"net"
|
||||
"os"
|
||||
)
|
||||
|
||||
@@ -30,7 +29,7 @@ func NewMonitorCmd() *cobra.Command {
|
||||
ribCmd := &cobra.Command{
|
||||
Use: CMD_RIB,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
rf, err := checkAddressFamily(net.IP{})
|
||||
rf, err := checkAddressFamily(nil)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
@@ -69,6 +68,7 @@ func NewMonitorCmd() *cobra.Command {
|
||||
|
||||
},
|
||||
}
|
||||
ribCmd.PersistentFlags().StringVarP(&subOpts.AddressFamily, "address-family", "a", "", "address family")
|
||||
|
||||
globalCmd := &cobra.Command{
|
||||
Use: CMD_GLOBAL,
|
||||
|
||||
+8
-4
@@ -608,6 +608,8 @@ func (server *BgpServer) broadcastBests(bests []*table.Path) {
|
||||
}
|
||||
}
|
||||
|
||||
rf := path.GetRouteFamily()
|
||||
|
||||
result := &GrpcResponse{
|
||||
Data: &api.Destination{
|
||||
Prefix: path.GetNlri().String(),
|
||||
@@ -625,11 +627,13 @@ func (server *BgpServer) broadcastBests(bests []*table.Path) {
|
||||
remainReqs = append(remainReqs, req)
|
||||
continue
|
||||
}
|
||||
m := &broadcastGrpcMsg{
|
||||
req: req,
|
||||
result: result,
|
||||
if req.RouteFamily == bgp.RouteFamily(0) || req.RouteFamily == rf {
|
||||
m := &broadcastGrpcMsg{
|
||||
req: req,
|
||||
result: result,
|
||||
}
|
||||
server.broadcastMsgs = append(server.broadcastMsgs, m)
|
||||
}
|
||||
server.broadcastMsgs = append(server.broadcastMsgs, m)
|
||||
remainReqs = append(remainReqs, req)
|
||||
}
|
||||
server.broadcastReqs = remainReqs
|
||||
|
||||
Reference in New Issue
Block a user