Skip to content

Commit

Permalink
Fix accepted/rejected adj-in commands
Browse files Browse the repository at this point in the history
Original logic for accepted/rejected commands was removed
in 2dbca9e when IN policies
were deprecated.

Then 7e5eb10 added support
for server-side filtering based on IMPORT polcies, but
CLI support wasn't added. Repurposing accepted/rejected
commands for this.
  • Loading branch information
Sergey Klyaus authored and fujita committed Sep 26, 2024
1 parent 42df8b6 commit 8bb8ec6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
31 changes: 17 additions & 14 deletions cmd/gobgp/neighbor.go
Original file line number Diff line number Diff line change
Expand Up @@ -945,13 +945,19 @@ func showNeighborRib(r string, name string, args []string) error {
}
}

var t api.TableType
var (
t api.TableType
enableFiltered bool
)
switch r {
case cmdGlobal:
t = api.TableType_GLOBAL
case cmdLocal:
t = api.TableType_LOCAL
case cmdAdjIn, cmdAccepted, cmdRejected:
case cmdAccepted, cmdRejected:
enableFiltered = true
fallthrough
case cmdAdjIn:
t = api.TableType_ADJ_IN
showIdentifier = bgp.BGP_ADD_PATH_RECEIVE
case cmdAdjOut:
Expand All @@ -962,11 +968,12 @@ func showNeighborRib(r string, name string, args []string) error {
}

stream, err := client.ListPath(ctx, &api.ListPathRequest{
TableType: t,
Family: family,
Name: name,
Prefixes: filter,
SortType: api.ListPathRequest_PREFIX,
TableType: t,
Family: family,
Name: name,
Prefixes: filter,
SortType: api.ListPathRequest_PREFIX,
EnableFiltered: enableFiltered,
})
if err != nil {
return err
Expand Down Expand Up @@ -1060,19 +1067,15 @@ func showNeighborRib(r string, name string, args []string) error {
}

for _, d := range dsts {
switch r {
case cmdAccepted:
if enableFiltered {
showFiltered := r == cmdRejected
l := make([]*api.Path, 0, len(d.Paths))
for _, p := range d.GetPaths() {
if !p.Filtered {
if p.Filtered == showFiltered {
l = append(l, p)
}
}
d.Paths = l
case cmdRejected:
// always nothing
d.Paths = []*api.Path{}
default:
}
}
if len(dsts) > 0 {
Expand Down
2 changes: 2 additions & 0 deletions docs/sources/policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,8 @@ $ gobgp neighbor 10.0.255.3 local
*> 10.33.0.0/16 10.0.255.1 [65001] 00:49:38 [{Origin: 0} {Med: 0}]
```

Routes accepted or rejected by import policy can be checked using `gobgp neighbor 10.0.255.2 accepted|rejected` command.

## Policy and Soft Reset

When you change an import policy and reset the inbound routing table (aka soft reset in), a withdraw for a route rejected by the latest import policies will be sent to peers. However, when you change an export policy and reset the outbound routing table (aka soft reset out), even if a route is rejected by the latest export policies, a withdraw for the route will not be sent.
Expand Down

0 comments on commit 8bb8ec6

Please sign in to comment.