Skip to content

Commit

Permalink
cli: Add local-as attribute in neighbor cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvil committed Sep 2, 2022
1 parent cd4eec6 commit ed0b7f9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion cmd/gobgp/neighbor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,7 @@ func modNeighbor(cmdType string, args []string) error {
}
if cmdType == cmdAdd || cmdType == cmdUpdate {
params["as"] = paramSingle
params["local-as"] = paramSingle
params["family"] = paramSingle
params["vrf"] = paramSingle
params["route-reflector-client"] = paramSingle
Expand All @@ -1193,7 +1194,7 @@ func modNeighbor(cmdType string, args []string) error {
params["remove-private-as"] = paramSingle
params["replace-peer-as"] = paramFlag
params["ebgp-multihop-ttl"] = paramSingle
usage += " [ family <address-families-list> | vrf <vrf-name> | route-reflector-client [<cluster-id>] | route-server-client | allow-own-as <num> | remove-private-as (all|replace) | replace-peer-as | ebgp-multihop-ttl <ttl>]"
usage += " [ local-as <VALUE> | family <address-families-list> | vrf <vrf-name> | route-reflector-client [<cluster-id>] | route-server-client | allow-own-as <num> | remove-private-as (all|replace) | replace-peer-as | ebgp-multihop-ttl <ttl>]"
}

m, err := extractReserved(args, params)
Expand Down Expand Up @@ -1255,6 +1256,13 @@ func modNeighbor(cmdType string, args []string) error {
}
peer.Conf.PeerAsn = uint32(as)
}
if len(m["local-as"]) > 0 {
as, err := strconv.ParseUint(m["local-as"][0], 10, 32)
if err != nil {
return err
}
peer.Conf.LocalAsn = uint32(as)
}
if len(m["family"]) == 1 {
peer.AfiSafis = make([]*api.AfiSafi, 0) // for the case of cmdUpdate
for _, f := range strings.Split(m["family"][0], ",") {
Expand Down
2 changes: 1 addition & 1 deletion docs/sources/cli-command-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ Also, refer to the following for the detail syntax of each address family.

```shell
# add neighbor
% gobgp neighbor add { <neighbor address> | interface <ifname> } as <as number> [ vrf <vrf-name> | route-reflector-client [<cluster-id>] | route-server-client | allow-own-as <num> | remove-private-as (all|replace) | replace-peer-as | ebgp-multihop-ttl <ttl>]
% gobgp neighbor add { <neighbor address> | interface <ifname> } as <as number> [ local-as <as number> | vrf <vrf-name> | route-reflector-client [<cluster-id>] | route-server-client | allow-own-as <num> | remove-private-as (all|replace) | replace-peer-as | ebgp-multihop-ttl <ttl>]
# delete neighbor
% gobgp neighbor del { <neighbor address> | interface <ifname> }
% gobgp neighbor <neighbor address> softreset [-a <address family>]
Expand Down

0 comments on commit ed0b7f9

Please sign in to comment.