diff --git a/api/models/b_g_p_neigh.go b/api/models/b_g_p_neigh.go index 75c53cb69..2671eab50 100644 --- a/api/models/b_g_p_neigh.go +++ b/api/models/b_g_p_neigh.go @@ -17,11 +17,14 @@ import ( // swagger:model BGPNeigh type BGPNeigh struct { - // BGP Nieghbor IP address + // BGP Neighbor IP address IPAddress string `json:"ipAddress,omitempty"` // Remote AS number RemoteAs int64 `json:"remoteAs,omitempty"` + + // Remote Connect Port (default 179) + RemotePort int64 `json:"remotePort,omitempty"` } // Validate validates this b g p neigh diff --git a/api/restapi/embedded_spec.go b/api/restapi/embedded_spec.go index 210244bcf..625e3730c 100644 --- a/api/restapi/embedded_spec.go +++ b/api/restapi/embedded_spec.go @@ -3254,12 +3254,16 @@ func init() { "type": "object", "properties": { "ipAddress": { - "description": "BGP Nieghbor IP address", + "description": "BGP Neighbor IP address", "type": "string" }, "remoteAs": { "description": "Remote AS number", "type": "integer" + }, + "remotePort": { + "description": "Remote Connect Port (default 179)", + "type": "integer" } } }, @@ -7621,12 +7625,16 @@ func init() { "type": "object", "properties": { "ipAddress": { - "description": "BGP Nieghbor IP address", + "description": "BGP Neighbor IP address", "type": "string" }, "remoteAs": { "description": "Remote AS number", "type": "integer" + }, + "remotePort": { + "description": "Remote Connect Port (default 179)", + "type": "integer" } } }, diff --git a/api/restapi/handler/gobgp.go b/api/restapi/handler/gobgp.go index 1829e762f..b1b4d2040 100644 --- a/api/restapi/handler/gobgp.go +++ b/api/restapi/handler/gobgp.go @@ -33,6 +33,9 @@ func ConfigPostBGPNeigh(params operations.PostConfigBgpNeighParams) middleware.R // Remote AS bgpNeighMod.RemoteAS = uint32(params.Attr.RemoteAs) + // Remote Port + bgpNeighMod.RemotePort = uint16(params.Attr.RemotePort) + tk.LogIt(tk.LogDebug, "[API] GoBGP neighAdd : %v\n", bgpNeighMod) _, err := ApiHooks.NetGoBGPNeighAdd(&bgpNeighMod) if err != nil { diff --git a/api/swagger.yml b/api/swagger.yml index c774f2e9a..54ed9e0e6 100644 --- a/api/swagger.yml +++ b/api/swagger.yml @@ -3090,10 +3090,13 @@ definitions: properties: ipAddress: type: string - description: BGP Nieghbor IP address + description: BGP Neighbor IP address remoteAs: type: integer description: Remote AS number + remotePort: + type: integer + description: Remote Connect Port (default 179) BGPGlobalConfig: type: object diff --git a/common/common.go b/common/common.go index d6e028a00..2d5b812ad 100644 --- a/common/common.go +++ b/common/common.go @@ -596,8 +596,9 @@ type GoBGPGlobalConfig struct { // GoBGPNeighMod - Info related to goBGP neigh type GoBGPNeighMod struct { - Addr net.IP `json:"neighIP"` - RemoteAS uint32 `json:"remoteAS"` + Addr net.IP `json:"neighIP"` + RemoteAS uint32 `json:"remoteAS"` + RemotePort uint16 `json:"remotePort"` } // Equal - check if two session tunnel entries are equal diff --git a/loxinet/apiclient.go b/loxinet/apiclient.go index 2c3b8c277..921fedae1 100644 --- a/loxinet/apiclient.go +++ b/loxinet/apiclient.go @@ -590,7 +590,7 @@ func (na *NetAPIStruct) NetParamGet(param *cmn.ParamMod) (int, error) { // NetGoBGPNeighAdd - Add bgp neigh to gobgp func (na *NetAPIStruct) NetGoBGPNeighAdd(param *cmn.GoBGPNeighMod) (int, error) { if mh.bgp != nil { - return mh.bgp.BGPNeighMod(true, param.Addr, param.RemoteAS) + return mh.bgp.BGPNeighMod(true, param.Addr, param.RemoteAS, uint32(param.RemotePort)) } tk.LogIt(tk.LogDebug, "loxilb BGP mode is disabled \n") return 0, errors.New("loxilb BGP mode is disabled") @@ -600,7 +600,7 @@ func (na *NetAPIStruct) NetGoBGPNeighAdd(param *cmn.GoBGPNeighMod) (int, error) // NetGoBGPNeighDel - Del bgp neigh from gobgp func (na *NetAPIStruct) NetGoBGPNeighDel(param *cmn.GoBGPNeighMod) (int, error) { if mh.bgp != nil { - return mh.bgp.BGPNeighMod(false, param.Addr, param.RemoteAS) + return mh.bgp.BGPNeighMod(false, param.Addr, param.RemoteAS, uint32(param.RemotePort)) } tk.LogIt(tk.LogDebug, "loxilb BGP mode is disabled \n") return 0, errors.New("loxilb BGP mode is disabled") diff --git a/loxinet/gobgpclient.go b/loxinet/gobgpclient.go index 71863533f..4003184e2 100644 --- a/loxinet/gobgpclient.go +++ b/loxinet/gobgpclient.go @@ -739,7 +739,7 @@ func (gbh *GoBgpH) UpdateCIState(instance string, state int, vip net.IP) { } // BGPNeighMod - Routine to add BGP neigh to goBGP server -func (gbh *GoBgpH) BGPNeighMod(add bool, neigh net.IP, ras uint32) (int, error) { +func (gbh *GoBgpH) BGPNeighMod(add bool, neigh net.IP, ras uint32, rPort uint32) (int, error) { var peer *api.Peer var err error @@ -748,10 +748,17 @@ func (gbh *GoBgpH) BGPNeighMod(add bool, neigh net.IP, ras uint32) (int, error) State: &api.PeerState{}, RouteServer: &api.RouteServer{}, RouteReflector: &api.RouteReflector{}, + Transport: &api.Transport{}, } peer.Conf.NeighborAddress = neigh.String() peer.State.NeighborAddress = neigh.String() peer.Conf.PeerAsn = ras + if rPort != 0 { + peer.Transport.RemotePort = rPort + } else { + peer.Transport.RemotePort = 179 + } + if add { _, err = gbh.client.AddPeer(context.Background(), &api.AddPeerRequest{