Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR - bgp multi-hop support #69

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/loxilb-agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func run(o *Options) error {
klog.Infof("CIDR: %s", o.config.ExternalCIDR)
klog.Infof("SetBGP: %v", o.config.SetBGP)
klog.Infof("ListenBGPPort: %v", o.config.ListenBGPPort)
klog.Infof("eBGPMultiHop: %v", o.config.EBGPMultiHop)
klog.Infof("SetLBMode: %v", o.config.SetLBMode)
klog.Infof("ExclIPAM: %v", o.config.ExclIPAM)
klog.Infof("Monitor: %v", o.config.Monitor)
Expand All @@ -88,6 +89,7 @@ func run(o *Options) error {
ExternalCIDR6: o.config.ExternalCIDR6,
SetBGP: o.config.SetBGP,
ListenBGPPort: o.config.ListenBGPPort,
EBGPMultiHop: o.config.EBGPMultiHop,
SetRoles: o.config.SetRoles,
ExtBGPPeers: o.config.ExtBGPPeers,
SetLBMode: o.config.SetLBMode,
Expand Down
2 changes: 2 additions & 0 deletions cmd/loxilb-agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ type AgentConfig struct {
SetBGP uint16 `yaml:"setBGP,omitempty,default=0"`
// Custom BGP Port
ListenBGPPort uint16 `yaml:"listenBGPPort,omitempty,default=179"`
// Set eBGP multi-hop
EBGPMultiHop bool `yaml:"eBGPMultiHop"`
// loxilb loadbalancer mode
SetLBMode uint16 `yaml:"setLBMode,omitempty"`
// Shared or exclusive IPAM
Expand Down
1 change: 1 addition & 0 deletions cmd/loxilb-agent/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func (o *Options) addFlags(fs *pflag.FlagSet) {
fs.StringVar(&o.config.LoxilbLoadBalancerClass, "loxilbLoadBalancerClass", o.config.LoxilbLoadBalancerClass, "Load-Balancer Class Name")
fs.Uint16Var(&o.config.SetBGP, "setBGP", o.config.SetBGP, "Use BGP routing")
fs.Uint16Var(&o.config.ListenBGPPort, "listenBGPPort", o.config.ListenBGPPort, "Custom BGP listen port")
fs.BoolVar(&o.config.EBGPMultiHop, "eBGPMultiHop", o.config.EBGPMultiHop, "Enable multi-hop eBGP")
fs.StringVar(&extBGPPeers, "extBGPPeers", extBGPPeers, "External BGP Peer(s)")
fs.BoolVar(&o.config.ExclIPAM, "setUniqueIP", false, "Use unique IPAM per service")
fs.Uint16Var(&o.config.SetLBMode, "setLBMode", o.config.SetLBMode, "LB mode to use")
Expand Down
1 change: 1 addition & 0 deletions pkg/agent/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type NetworkConfig struct {
ExternalSecondaryCIDRs6 []string
SetBGP uint16
ListenBGPPort uint16
EBGPMultiHop bool
ExtBGPPeers []string
SetLBMode uint16
Monitor bool
Expand Down
15 changes: 8 additions & 7 deletions pkg/agent/manager/loadbalancer/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1136,17 +1136,18 @@ func (m *Manager) makeLoxiLBBGPGlobalModel(localAS int, selfID string, setNHSelf
}, nil
}

func (m *Manager) makeLoxiLBBGNeighModel(remoteAS int, IPString string, rPort uint16) (api.BGPNeigh, error) {
func (m *Manager) makeLoxiLBBGNeighModel(remoteAS int, IPString string, rPort uint16, mHopEn bool) (api.BGPNeigh, error) {

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

return api.BGPNeigh{
RemoteAs: int64(remoteAS),
IPAddress: IPString,
RemotePort: int64(port),
RemoteAs: int64(remoteAS),
IPAddress: IPString,
RemotePort: int64(port),
SetMultiHop: mHopEn,
}, nil
}

Expand Down Expand Up @@ -1419,7 +1420,7 @@ loop:
}

for _, bgpPeer := range bgpPeers {
bgpNeighCfg, _ := m.makeLoxiLBBGNeighModel(int(m.networkConfig.SetBGP), bgpPeer.Host, m.networkConfig.ListenBGPPort)
bgpNeighCfg, _ := m.makeLoxiLBBGNeighModel(int(m.networkConfig.SetBGP), bgpPeer.Host, m.networkConfig.ListenBGPPort, false)
err := func(bgpNeighCfg *api.BGPNeigh) error {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
Expand All @@ -1432,7 +1433,7 @@ loop:
m.checkHandleBGPCfgErrors(loxiAliveCh, aliveClient, err)
}

bgpNeighCfg1, _ := m.makeLoxiLBBGNeighModel(int(m.networkConfig.SetBGP), aliveClient.Host, m.networkConfig.ListenBGPPort)
bgpNeighCfg1, _ := m.makeLoxiLBBGNeighModel(int(m.networkConfig.SetBGP), aliveClient.Host, m.networkConfig.ListenBGPPort, false)
err = func(bgpNeighCfg1 *api.BGPNeigh) error {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
Expand Down Expand Up @@ -1463,7 +1464,7 @@ loop:
continue
}

bgpNeighCfg, _ := m.makeLoxiLBBGNeighModel(int(asid), bgpRemoteIP.String(), 0)
bgpNeighCfg, _ := m.makeLoxiLBBGNeighModel(int(asid), bgpRemoteIP.String(), 0, m.networkConfig.EBGPMultiHop)
err = func(bgpNeighCfg *api.BGPNeigh) error {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
Expand Down
2 changes: 2 additions & 0 deletions pkg/api/bgp.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ type BGPNeigh struct {
RemoteAs int64 `json:"remoteAs,omitempty"`
// Remote Connect Port (default 179)
RemotePort int64 `json:"remotePort,omitempty"`
// Enable multi-hop peering (if needed)
SetMultiHop bool `json:"setMultiHop,omitempty"`
}

type BGPGlobalConfig struct {
Expand Down
Loading