Skip to content

Commit

Permalink
cli,mup: fix prefix and route type handling
Browse files Browse the repository at this point in the history
  • Loading branch information
higebu committed Mar 26, 2023
1 parent cbd1d66 commit b1ed1f1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions cmd/gobgp/neighbor.go
Original file line number Diff line number Diff line change
Expand Up @@ -854,8 +854,6 @@ func showNeighborRib(r string, name string, args []string) error {
switch rf {
case bgp.RF_IPv4_MPLS, bgp.RF_IPv6_MPLS, bgp.RF_IPv4_VPN, bgp.RF_IPv6_VPN, bgp.RF_EVPN:
showLabel = true
case bgp.RF_MUP_IPv4, bgp.RF_MUP_IPv6:
showMUP = true
}

var filter []*api.TableLookupPrefix
Expand All @@ -865,7 +863,11 @@ func showNeighborRib(r string, name string, args []string) error {
case bgp.RF_EVPN:
// Uses target as EVPN Route Type string
case bgp.RF_MUP_IPv4, bgp.RF_MUP_IPv6:
// Uses target as MUP Route Type string
// Uses target as MUP Route Type string or route key
// Only t1st has MUP specific columns
if target == "t1st" {
showMUP = true
}
default:
if _, _, err = parseCIDRorIP(target); err != nil {
return err
Expand Down
8 changes: 5 additions & 3 deletions internal/pkg/table/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,9 @@ func (t *Table) GetEvpnDestinationsWithRouteType(typ string) ([]*Destination, er
return results, nil
}

func (t *Table) GetMUPDestinationsWithRouteType(typ string) ([]*Destination, error) {
func (t *Table) GetMUPDestinationsWithRouteType(p string) ([]*Destination, error) {
var routeType uint16
switch strings.ToLower(typ) {
switch strings.ToLower(p) {
case "isd":
routeType = bgp.MUP_ROUTE_TYPE_INTERWORK_SEGMENT_DISCOVERY
case "dsd":
Expand All @@ -300,7 +300,7 @@ func (t *Table) GetMUPDestinationsWithRouteType(typ string) ([]*Destination, err
case "t2st":
routeType = bgp.MUP_ROUTE_TYPE_TYPE_2_SESSION_TRANSFORMED
default:
return nil, fmt.Errorf("unsupported mup route type: %s", typ)
// use prefix as route key
}
destinations := t.GetDestinations()
results := make([]*Destination, 0, len(destinations))
Expand All @@ -311,6 +311,8 @@ func (t *Table) GetMUPDestinationsWithRouteType(typ string) ([]*Destination, err
return nil, fmt.Errorf("invalid mup nlri type detected: %T", dst.nlri)
} else if nlri.RouteType == routeType {
results = append(results, dst)
} else if nlri.String() == p {
results = append(results, dst)
}
}
default:
Expand Down

0 comments on commit b1ed1f1

Please sign in to comment.