Skip to content

Commit

Permalink
bgp multihop support
Browse files Browse the repository at this point in the history
  • Loading branch information
TrekkieCoder committed Oct 25, 2023
1 parent 9e2edc1 commit 3e695cf
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 3 deletions.
3 changes: 3 additions & 0 deletions api/models/b_g_p_neigh.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions api/restapi/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions api/restapi/handler/gobgp.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ func ConfigPostBGPNeigh(params operations.PostConfigBgpNeighParams) middleware.R
// Remote Port
bgpNeighMod.RemotePort = uint16(params.Attr.RemotePort)

// Multi-hop or not
bgpNeighMod.MultiHop = params.Attr.SetMultiHop

tk.LogIt(tk.LogDebug, "[API] GoBGP neighAdd : %v\n", bgpNeighMod)
_, err := ApiHooks.NetGoBGPNeighAdd(&bgpNeighMod)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions api/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3100,6 +3100,9 @@ definitions:
remotePort:
type: integer
description: Remote Connect Port (default 179)
setMultiHop:
type: boolean
description: Enable multi-hop peering (if needed)

BGPGlobalConfig:
type: object
Expand Down
1 change: 1 addition & 0 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ type GoBGPNeighMod struct {
Addr net.IP `json:"neighIP"`
RemoteAS uint32 `json:"remoteAS"`
RemotePort uint16 `json:"remotePort"`
MultiHop bool `json:"multiHop"`
}

// Equal - check if two session tunnel entries are equal
Expand Down
4 changes: 2 additions & 2 deletions loxinet/apiclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, uint32(param.RemotePort))
return mh.bgp.BGPNeighMod(true, param.Addr, param.RemoteAS, uint32(param.RemotePort), param.MultiHop)
}
tk.LogIt(tk.LogDebug, "loxilb BGP mode is disabled \n")
return 0, errors.New("loxilb BGP mode is disabled")
Expand All @@ -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, uint32(param.RemotePort))
return mh.bgp.BGPNeighMod(false, param.Addr, param.RemoteAS, uint32(param.RemotePort), param.MultiHop)
}
tk.LogIt(tk.LogDebug, "loxilb BGP mode is disabled \n")
return 0, errors.New("loxilb BGP mode is disabled")
Expand Down
9 changes: 8 additions & 1 deletion loxinet/gobgpclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ func (gbh *GoBgpH) resetBGPMed(toLow bool) error {
}

// BGPNeighMod - Routine to add BGP neigh to goBGP server
func (gbh *GoBgpH) BGPNeighMod(add bool, neigh net.IP, ras uint32, rPort uint32) (int, error) {
func (gbh *GoBgpH) BGPNeighMod(add bool, neigh net.IP, ras uint32, rPort uint32, mhop bool) (int, error) {
var peer *api.Peer
var err error

Expand All @@ -930,6 +930,13 @@ func (gbh *GoBgpH) BGPNeighMod(add bool, neigh net.IP, ras uint32, rPort uint32)
peer.Transport.RemotePort = 179
}

if mhop {
peer.EbgpMultihop = &api.EbgpMultihop{
Enabled: true,
MultihopTtl: uint32(8),
}
}

ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()

Expand Down

0 comments on commit 3e695cf

Please sign in to comment.