Skip to content

Commit

Permalink
Support for custom bgp listen port
Browse files Browse the repository at this point in the history
  • Loading branch information
TrekkieCoder committed Jul 30, 2023
1 parent e7aab92 commit c6014d4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions pkg/agent/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type NetworkConfig struct {
ExternalCIDR6 string
ExternalSecondaryCIDRs6 []string
SetBGP uint16
ListenBGPPort uint16
ExtBGPPeers []string
SetLBMode uint16
Monitor bool
Expand Down
18 changes: 12 additions & 6 deletions pkg/agent/manager/loadbalancer/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1056,12 +1056,18 @@ func (m *Manager) makeLoxiLBCIStatusModel(instance string, client *api.LoxiClien
}, nil
}

func (m *Manager) makeLoxiLBBGPGlobalModel(localAS int, selfID string, setNHSelf bool) (api.BGPGlobalConfig, error) {
func (m *Manager) makeLoxiLBBGPGlobalModel(localAS int, selfID string, setNHSelf bool, lPort uint16) (api.BGPGlobalConfig, error) {

port := lPort
if lPort == 0 {
port = 179
}

return api.BGPGlobalConfig{
LocalAs: int64(localAS),
RouterID: selfID,
SetNHSelf: setNHSelf,
LocalAs: int64(localAS),
RouterID: selfID,
SetNHSelf: setNHSelf,
ListenPort: port,
}, nil
}

Expand Down Expand Up @@ -1274,9 +1280,9 @@ loop:
}
var bgpGlobalCfg api.BGPGlobalConfig
if aliveClient.PeeringOnly {
bgpGlobalCfg, _ = m.makeLoxiLBBGPGlobalModel(int(m.networkConfig.SetBGP), aliveClient.Host, false)
bgpGlobalCfg, _ = m.makeLoxiLBBGPGlobalModel(int(m.networkConfig.SetBGP), aliveClient.Host, false, m.networkConfig.ListenBGPPort)
} else {
bgpGlobalCfg, _ = m.makeLoxiLBBGPGlobalModel(int(m.networkConfig.SetBGP), aliveClient.Host, true)
bgpGlobalCfg, _ = m.makeLoxiLBBGPGlobalModel(int(m.networkConfig.SetBGP), aliveClient.Host, true, m.networkConfig.ListenBGPPort)
}
if err := aliveClient.BGP().CreateGlobalConfig(context.Background(), &bgpGlobalCfg); err == nil {
klog.Infof("set-bgp-global success")
Expand Down
2 changes: 2 additions & 0 deletions pkg/api/bgp.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ type BGPGlobalConfig struct {
RouterID string `json:"routerId,omitempty"`
// Set Next hop self option
SetNHSelf bool `json:"setNextHopSelf,omitempty"`
// Listen Port
ListenPort uint16 `json:"listenPort,omitempty"`
}

type BGPAPI struct {
Expand Down

0 comments on commit c6014d4

Please sign in to comment.