From 925b8c00e068abf2c1af0fee2dc9058f947493e5 Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Sun, 30 Jul 2023 17:05:25 +0900 Subject: [PATCH] support for gobgp to run on custom ports --- api/models/b_g_p_global_config.go | 3 +++ api/models/firewall_entry.go | 10 -------- api/models/loadbalance_entry.go | 15 ----------- api/models/mirror_entry.go | 10 -------- api/models/mirror_get_entry.go | 10 -------- api/models/policy_entry.go | 10 -------- api/models/port_entry.go | 25 ------------------- api/models/route_get_entry.go | 5 ---- api/models/session_entry.go | 10 -------- api/models/session_ul_cl_entry.go | 5 ---- api/models/vlan_get_entry.go | 10 -------- api/restapi/embedded_spec.go | 8 ++++++ api/restapi/handler/gobgp.go | 6 +++++ .../operations/get_config_cistate_all.go | 5 ---- .../operations/get_config_conntrack_all.go | 5 ---- .../operations/get_config_endpoint_all.go | 5 ---- api/restapi/operations/get_config_fdb_all.go | 5 ---- .../operations/get_config_firewall_all.go | 5 ---- .../operations/get_config_ipv4address_all.go | 5 ---- .../operations/get_config_loadbalancer_all.go | 5 ---- .../operations/get_config_mirror_all.go | 5 ---- .../operations/get_config_neighbor_all.go | 5 ---- .../operations/get_config_policy_all.go | 5 ---- api/restapi/operations/get_config_port_all.go | 5 ---- .../operations/get_config_route_all.go | 5 ---- .../operations/get_config_session_all.go | 5 ---- .../operations/get_config_sessionulcl_all.go | 5 ---- .../operations/get_config_tunnel_vxlan_all.go | 5 ---- api/restapi/operations/get_config_vlan_all.go | 5 ---- .../operations/get_status_filesystem.go | 5 ---- api/restapi/operations/get_status_process.go | 5 ---- api/restapi/operations/loxilb_rest_api_api.go | 2 +- api/swagger.yml | 3 +++ common/common.go | 5 ++-- loxinet/gobgpclient.go | 1 + 35 files changed, 25 insertions(+), 203 deletions(-) diff --git a/api/models/b_g_p_global_config.go b/api/models/b_g_p_global_config.go index 4892b02bb..cbb2a15b9 100644 --- a/api/models/b_g_p_global_config.go +++ b/api/models/b_g_p_global_config.go @@ -20,6 +20,9 @@ type BGPGlobalConfig struct { // Adds policy to set next hop as self, if enabled SetNextHopSelf bool `json:"SetNextHopSelf,omitempty"` + // Listen port (default 179) + ListenPort int64 `json:"listenPort,omitempty"` + // Local AS number LocalAs int64 `json:"localAs,omitempty"` diff --git a/api/models/firewall_entry.go b/api/models/firewall_entry.go index 571d5bc13..7de5c8fb9 100644 --- a/api/models/firewall_entry.go +++ b/api/models/firewall_entry.go @@ -102,11 +102,6 @@ func (m *FirewallEntry) ContextValidate(ctx context.Context, formats strfmt.Regi func (m *FirewallEntry) contextValidateOpts(ctx context.Context, formats strfmt.Registry) error { if m.Opts != nil { - - if swag.IsZero(m.Opts) { // not required - return nil - } - if err := m.Opts.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("opts") @@ -123,11 +118,6 @@ func (m *FirewallEntry) contextValidateOpts(ctx context.Context, formats strfmt. func (m *FirewallEntry) contextValidateRuleArguments(ctx context.Context, formats strfmt.Registry) error { if m.RuleArguments != nil { - - if swag.IsZero(m.RuleArguments) { // not required - return nil - } - if err := m.RuleArguments.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("ruleArguments") diff --git a/api/models/loadbalance_entry.go b/api/models/loadbalance_entry.go index 587a4fcb1..5cd573bae 100644 --- a/api/models/loadbalance_entry.go +++ b/api/models/loadbalance_entry.go @@ -149,11 +149,6 @@ func (m *LoadbalanceEntry) contextValidateEndpoints(ctx context.Context, formats for i := 0; i < len(m.Endpoints); i++ { if m.Endpoints[i] != nil { - - if swag.IsZero(m.Endpoints[i]) { // not required - return nil - } - if err := m.Endpoints[i].ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("endpoints" + "." + strconv.Itoa(i)) @@ -174,11 +169,6 @@ func (m *LoadbalanceEntry) contextValidateSecondaryIPs(ctx context.Context, form for i := 0; i < len(m.SecondaryIPs); i++ { if m.SecondaryIPs[i] != nil { - - if swag.IsZero(m.SecondaryIPs[i]) { // not required - return nil - } - if err := m.SecondaryIPs[i].ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("secondaryIPs" + "." + strconv.Itoa(i)) @@ -197,11 +187,6 @@ func (m *LoadbalanceEntry) contextValidateSecondaryIPs(ctx context.Context, form func (m *LoadbalanceEntry) contextValidateServiceArguments(ctx context.Context, formats strfmt.Registry) error { if m.ServiceArguments != nil { - - if swag.IsZero(m.ServiceArguments) { // not required - return nil - } - if err := m.ServiceArguments.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("serviceArguments") diff --git a/api/models/mirror_entry.go b/api/models/mirror_entry.go index 1e75de1e0..062dd2b1f 100644 --- a/api/models/mirror_entry.go +++ b/api/models/mirror_entry.go @@ -105,11 +105,6 @@ func (m *MirrorEntry) ContextValidate(ctx context.Context, formats strfmt.Regist func (m *MirrorEntry) contextValidateMirrorInfo(ctx context.Context, formats strfmt.Registry) error { if m.MirrorInfo != nil { - - if swag.IsZero(m.MirrorInfo) { // not required - return nil - } - if err := m.MirrorInfo.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("mirrorInfo") @@ -126,11 +121,6 @@ func (m *MirrorEntry) contextValidateMirrorInfo(ctx context.Context, formats str func (m *MirrorEntry) contextValidateTargetObject(ctx context.Context, formats strfmt.Registry) error { if m.TargetObject != nil { - - if swag.IsZero(m.TargetObject) { // not required - return nil - } - if err := m.TargetObject.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("targetObject") diff --git a/api/models/mirror_get_entry.go b/api/models/mirror_get_entry.go index f9a7cb0b1..62910e701 100644 --- a/api/models/mirror_get_entry.go +++ b/api/models/mirror_get_entry.go @@ -123,11 +123,6 @@ func (m *MirrorGetEntry) ContextValidate(ctx context.Context, formats strfmt.Reg func (m *MirrorGetEntry) contextValidateMirrorInfo(ctx context.Context, formats strfmt.Registry) error { if m.MirrorInfo != nil { - - if swag.IsZero(m.MirrorInfo) { // not required - return nil - } - if err := m.MirrorInfo.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("mirrorInfo") @@ -144,11 +139,6 @@ func (m *MirrorGetEntry) contextValidateMirrorInfo(ctx context.Context, formats func (m *MirrorGetEntry) contextValidateTargetObject(ctx context.Context, formats strfmt.Registry) error { if m.TargetObject != nil { - - if swag.IsZero(m.TargetObject) { // not required - return nil - } - if err := m.TargetObject.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("targetObject") diff --git a/api/models/policy_entry.go b/api/models/policy_entry.go index f1b62d4d1..b9935512d 100644 --- a/api/models/policy_entry.go +++ b/api/models/policy_entry.go @@ -105,11 +105,6 @@ func (m *PolicyEntry) ContextValidate(ctx context.Context, formats strfmt.Regist func (m *PolicyEntry) contextValidatePolicyInfo(ctx context.Context, formats strfmt.Registry) error { if m.PolicyInfo != nil { - - if swag.IsZero(m.PolicyInfo) { // not required - return nil - } - if err := m.PolicyInfo.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("policyInfo") @@ -126,11 +121,6 @@ func (m *PolicyEntry) contextValidatePolicyInfo(ctx context.Context, formats str func (m *PolicyEntry) contextValidateTargetObject(ctx context.Context, formats strfmt.Registry) error { if m.TargetObject != nil { - - if swag.IsZero(m.TargetObject) { // not required - return nil - } - if err := m.TargetObject.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("targetObject") diff --git a/api/models/port_entry.go b/api/models/port_entry.go index d6273add4..09fde0403 100644 --- a/api/models/port_entry.go +++ b/api/models/port_entry.go @@ -204,11 +204,6 @@ func (m *PortEntry) ContextValidate(ctx context.Context, formats strfmt.Registry func (m *PortEntry) contextValidatePortHardwareInformation(ctx context.Context, formats strfmt.Registry) error { if m.PortHardwareInformation != nil { - - if swag.IsZero(m.PortHardwareInformation) { // not required - return nil - } - if err := m.PortHardwareInformation.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("portHardwareInformation") @@ -225,11 +220,6 @@ func (m *PortEntry) contextValidatePortHardwareInformation(ctx context.Context, func (m *PortEntry) contextValidatePortL2Information(ctx context.Context, formats strfmt.Registry) error { if m.PortL2Information != nil { - - if swag.IsZero(m.PortL2Information) { // not required - return nil - } - if err := m.PortL2Information.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("portL2Information") @@ -246,11 +236,6 @@ func (m *PortEntry) contextValidatePortL2Information(ctx context.Context, format func (m *PortEntry) contextValidatePortL3Information(ctx context.Context, formats strfmt.Registry) error { if m.PortL3Information != nil { - - if swag.IsZero(m.PortL3Information) { // not required - return nil - } - if err := m.PortL3Information.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("portL3Information") @@ -267,11 +252,6 @@ func (m *PortEntry) contextValidatePortL3Information(ctx context.Context, format func (m *PortEntry) contextValidatePortSoftwareInformation(ctx context.Context, formats strfmt.Registry) error { if m.PortSoftwareInformation != nil { - - if swag.IsZero(m.PortSoftwareInformation) { // not required - return nil - } - if err := m.PortSoftwareInformation.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("portSoftwareInformation") @@ -288,11 +268,6 @@ func (m *PortEntry) contextValidatePortSoftwareInformation(ctx context.Context, func (m *PortEntry) contextValidatePortStatisticInformation(ctx context.Context, formats strfmt.Registry) error { if m.PortStatisticInformation != nil { - - if swag.IsZero(m.PortStatisticInformation) { // not required - return nil - } - if err := m.PortStatisticInformation.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("portStatisticInformation") diff --git a/api/models/route_get_entry.go b/api/models/route_get_entry.go index fbb3da5e3..f83534b4e 100644 --- a/api/models/route_get_entry.go +++ b/api/models/route_get_entry.go @@ -91,11 +91,6 @@ func (m *RouteGetEntry) ContextValidate(ctx context.Context, formats strfmt.Regi func (m *RouteGetEntry) contextValidateStatistic(ctx context.Context, formats strfmt.Registry) error { if m.Statistic != nil { - - if swag.IsZero(m.Statistic) { // not required - return nil - } - if err := m.Statistic.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("statistic") diff --git a/api/models/session_entry.go b/api/models/session_entry.go index 6926eb34d..1bfb83af6 100644 --- a/api/models/session_entry.go +++ b/api/models/session_entry.go @@ -108,11 +108,6 @@ func (m *SessionEntry) ContextValidate(ctx context.Context, formats strfmt.Regis func (m *SessionEntry) contextValidateAccessNetworkTunnel(ctx context.Context, formats strfmt.Registry) error { if m.AccessNetworkTunnel != nil { - - if swag.IsZero(m.AccessNetworkTunnel) { // not required - return nil - } - if err := m.AccessNetworkTunnel.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("accessNetworkTunnel") @@ -129,11 +124,6 @@ func (m *SessionEntry) contextValidateAccessNetworkTunnel(ctx context.Context, f func (m *SessionEntry) contextValidateCoreNetworkTunnel(ctx context.Context, formats strfmt.Registry) error { if m.CoreNetworkTunnel != nil { - - if swag.IsZero(m.CoreNetworkTunnel) { // not required - return nil - } - if err := m.CoreNetworkTunnel.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("coreNetworkTunnel") diff --git a/api/models/session_ul_cl_entry.go b/api/models/session_ul_cl_entry.go index b60c9069b..1d0a8500e 100644 --- a/api/models/session_ul_cl_entry.go +++ b/api/models/session_ul_cl_entry.go @@ -75,11 +75,6 @@ func (m *SessionUlClEntry) ContextValidate(ctx context.Context, formats strfmt.R func (m *SessionUlClEntry) contextValidateUlclArgument(ctx context.Context, formats strfmt.Registry) error { if m.UlclArgument != nil { - - if swag.IsZero(m.UlclArgument) { // not required - return nil - } - if err := m.UlclArgument.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("ulclArgument") diff --git a/api/models/vlan_get_entry.go b/api/models/vlan_get_entry.go index e20cdb092..b7d28b37e 100644 --- a/api/models/vlan_get_entry.go +++ b/api/models/vlan_get_entry.go @@ -118,11 +118,6 @@ func (m *VlanGetEntry) contextValidateMember(ctx context.Context, formats strfmt for i := 0; i < len(m.Member); i++ { if m.Member[i] != nil { - - if swag.IsZero(m.Member[i]) { // not required - return nil - } - if err := m.Member[i].ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("member" + "." + strconv.Itoa(i)) @@ -141,11 +136,6 @@ func (m *VlanGetEntry) contextValidateMember(ctx context.Context, formats strfmt func (m *VlanGetEntry) contextValidateVlanStatistic(ctx context.Context, formats strfmt.Registry) error { if m.VlanStatistic != nil { - - if swag.IsZero(m.VlanStatistic) { // not required - return nil - } - if err := m.VlanStatistic.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("vlanStatistic") diff --git a/api/restapi/embedded_spec.go b/api/restapi/embedded_spec.go index 134b51aaa..210244bcf 100644 --- a/api/restapi/embedded_spec.go +++ b/api/restapi/embedded_spec.go @@ -3236,6 +3236,10 @@ func init() { "description": "Adds policy to set next hop as self, if enabled", "type": "boolean" }, + "listenPort": { + "description": "Listen port (default 179)", + "type": "integer" + }, "localAs": { "description": "Local AS number", "type": "integer" @@ -7599,6 +7603,10 @@ func init() { "description": "Adds policy to set next hop as self, if enabled", "type": "boolean" }, + "listenPort": { + "description": "Listen port (default 179)", + "type": "integer" + }, "localAs": { "description": "Local AS number", "type": "integer" diff --git a/api/restapi/handler/gobgp.go b/api/restapi/handler/gobgp.go index f7af8f50d..1829e762f 100644 --- a/api/restapi/handler/gobgp.go +++ b/api/restapi/handler/gobgp.go @@ -74,6 +74,12 @@ func ConfigPostBGPGlobal(params operations.PostConfigBgpGlobalParams) middleware // Export policy list bgpG.SetNHSelf = params.Attr.SetNextHopSelf + // Listen Port + bgpG.ListenPort = uint16(params.Attr.ListenPort) + if bgpG.ListenPort == 0 { + bgpG.ListenPort = 179 + } + tk.LogIt(tk.LogDebug, "[API] GoBGP GCAdd : %v\n", bgpG) _, err := ApiHooks.NetGoBGPGCAdd(&bgpG) if err != nil { diff --git a/api/restapi/operations/get_config_cistate_all.go b/api/restapi/operations/get_config_cistate_all.go index 005aef2a9..7c792381e 100644 --- a/api/restapi/operations/get_config_cistate_all.go +++ b/api/restapi/operations/get_config_cistate_all.go @@ -132,11 +132,6 @@ func (o *GetConfigCistateAllOKBody) contextValidateAttr(ctx context.Context, for for i := 0; i < len(o.Attr); i++ { if o.Attr[i] != nil { - - if swag.IsZero(o.Attr[i]) { // not required - return nil - } - if err := o.Attr[i].ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getConfigCistateAllOK" + "." + "Attr" + "." + strconv.Itoa(i)) diff --git a/api/restapi/operations/get_config_conntrack_all.go b/api/restapi/operations/get_config_conntrack_all.go index fdd98f30f..b6e73fcae 100644 --- a/api/restapi/operations/get_config_conntrack_all.go +++ b/api/restapi/operations/get_config_conntrack_all.go @@ -132,11 +132,6 @@ func (o *GetConfigConntrackAllOKBody) contextValidateCtAttr(ctx context.Context, for i := 0; i < len(o.CtAttr); i++ { if o.CtAttr[i] != nil { - - if swag.IsZero(o.CtAttr[i]) { // not required - return nil - } - if err := o.CtAttr[i].ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getConfigConntrackAllOK" + "." + "ctAttr" + "." + strconv.Itoa(i)) diff --git a/api/restapi/operations/get_config_endpoint_all.go b/api/restapi/operations/get_config_endpoint_all.go index dc7cb6475..014afbde5 100644 --- a/api/restapi/operations/get_config_endpoint_all.go +++ b/api/restapi/operations/get_config_endpoint_all.go @@ -132,11 +132,6 @@ func (o *GetConfigEndpointAllOKBody) contextValidateAttr(ctx context.Context, fo for i := 0; i < len(o.Attr); i++ { if o.Attr[i] != nil { - - if swag.IsZero(o.Attr[i]) { // not required - return nil - } - if err := o.Attr[i].ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getConfigEndpointAllOK" + "." + "Attr" + "." + strconv.Itoa(i)) diff --git a/api/restapi/operations/get_config_fdb_all.go b/api/restapi/operations/get_config_fdb_all.go index c5181c171..64ea648b8 100644 --- a/api/restapi/operations/get_config_fdb_all.go +++ b/api/restapi/operations/get_config_fdb_all.go @@ -132,11 +132,6 @@ func (o *GetConfigFdbAllOKBody) contextValidateFdbAttr(ctx context.Context, form for i := 0; i < len(o.FdbAttr); i++ { if o.FdbAttr[i] != nil { - - if swag.IsZero(o.FdbAttr[i]) { // not required - return nil - } - if err := o.FdbAttr[i].ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getConfigFdbAllOK" + "." + "fdbAttr" + "." + strconv.Itoa(i)) diff --git a/api/restapi/operations/get_config_firewall_all.go b/api/restapi/operations/get_config_firewall_all.go index 79031bfbd..de42ddaf8 100644 --- a/api/restapi/operations/get_config_firewall_all.go +++ b/api/restapi/operations/get_config_firewall_all.go @@ -132,11 +132,6 @@ func (o *GetConfigFirewallAllOKBody) contextValidateFwAttr(ctx context.Context, for i := 0; i < len(o.FwAttr); i++ { if o.FwAttr[i] != nil { - - if swag.IsZero(o.FwAttr[i]) { // not required - return nil - } - if err := o.FwAttr[i].ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getConfigFirewallAllOK" + "." + "fwAttr" + "." + strconv.Itoa(i)) diff --git a/api/restapi/operations/get_config_ipv4address_all.go b/api/restapi/operations/get_config_ipv4address_all.go index 29e3b484b..4b5c94e83 100644 --- a/api/restapi/operations/get_config_ipv4address_all.go +++ b/api/restapi/operations/get_config_ipv4address_all.go @@ -132,11 +132,6 @@ func (o *GetConfigIpv4addressAllOKBody) contextValidateIPAttr(ctx context.Contex for i := 0; i < len(o.IPAttr); i++ { if o.IPAttr[i] != nil { - - if swag.IsZero(o.IPAttr[i]) { // not required - return nil - } - if err := o.IPAttr[i].ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getConfigIpv4addressAllOK" + "." + "ipAttr" + "." + strconv.Itoa(i)) diff --git a/api/restapi/operations/get_config_loadbalancer_all.go b/api/restapi/operations/get_config_loadbalancer_all.go index c7c5146a0..2f460083e 100644 --- a/api/restapi/operations/get_config_loadbalancer_all.go +++ b/api/restapi/operations/get_config_loadbalancer_all.go @@ -132,11 +132,6 @@ func (o *GetConfigLoadbalancerAllOKBody) contextValidateLbAttr(ctx context.Conte for i := 0; i < len(o.LbAttr); i++ { if o.LbAttr[i] != nil { - - if swag.IsZero(o.LbAttr[i]) { // not required - return nil - } - if err := o.LbAttr[i].ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getConfigLoadbalancerAllOK" + "." + "lbAttr" + "." + strconv.Itoa(i)) diff --git a/api/restapi/operations/get_config_mirror_all.go b/api/restapi/operations/get_config_mirror_all.go index abc19dc96..469edc0fa 100644 --- a/api/restapi/operations/get_config_mirror_all.go +++ b/api/restapi/operations/get_config_mirror_all.go @@ -132,11 +132,6 @@ func (o *GetConfigMirrorAllOKBody) contextValidateMirrAttr(ctx context.Context, for i := 0; i < len(o.MirrAttr); i++ { if o.MirrAttr[i] != nil { - - if swag.IsZero(o.MirrAttr[i]) { // not required - return nil - } - if err := o.MirrAttr[i].ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getConfigMirrorAllOK" + "." + "mirrAttr" + "." + strconv.Itoa(i)) diff --git a/api/restapi/operations/get_config_neighbor_all.go b/api/restapi/operations/get_config_neighbor_all.go index 71424804f..6898458a8 100644 --- a/api/restapi/operations/get_config_neighbor_all.go +++ b/api/restapi/operations/get_config_neighbor_all.go @@ -132,11 +132,6 @@ func (o *GetConfigNeighborAllOKBody) contextValidateNeighborAttr(ctx context.Con for i := 0; i < len(o.NeighborAttr); i++ { if o.NeighborAttr[i] != nil { - - if swag.IsZero(o.NeighborAttr[i]) { // not required - return nil - } - if err := o.NeighborAttr[i].ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getConfigNeighborAllOK" + "." + "neighborAttr" + "." + strconv.Itoa(i)) diff --git a/api/restapi/operations/get_config_policy_all.go b/api/restapi/operations/get_config_policy_all.go index 73835733a..189bcdc52 100644 --- a/api/restapi/operations/get_config_policy_all.go +++ b/api/restapi/operations/get_config_policy_all.go @@ -132,11 +132,6 @@ func (o *GetConfigPolicyAllOKBody) contextValidatePolAttr(ctx context.Context, f for i := 0; i < len(o.PolAttr); i++ { if o.PolAttr[i] != nil { - - if swag.IsZero(o.PolAttr[i]) { // not required - return nil - } - if err := o.PolAttr[i].ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getConfigPolicyAllOK" + "." + "polAttr" + "." + strconv.Itoa(i)) diff --git a/api/restapi/operations/get_config_port_all.go b/api/restapi/operations/get_config_port_all.go index b2c35dfc7..b7e645928 100644 --- a/api/restapi/operations/get_config_port_all.go +++ b/api/restapi/operations/get_config_port_all.go @@ -132,11 +132,6 @@ func (o *GetConfigPortAllOKBody) contextValidatePortAttr(ctx context.Context, fo for i := 0; i < len(o.PortAttr); i++ { if o.PortAttr[i] != nil { - - if swag.IsZero(o.PortAttr[i]) { // not required - return nil - } - if err := o.PortAttr[i].ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getConfigPortAllOK" + "." + "portAttr" + "." + strconv.Itoa(i)) diff --git a/api/restapi/operations/get_config_route_all.go b/api/restapi/operations/get_config_route_all.go index 715bd4483..f4430d264 100644 --- a/api/restapi/operations/get_config_route_all.go +++ b/api/restapi/operations/get_config_route_all.go @@ -132,11 +132,6 @@ func (o *GetConfigRouteAllOKBody) contextValidateRouteAttr(ctx context.Context, for i := 0; i < len(o.RouteAttr); i++ { if o.RouteAttr[i] != nil { - - if swag.IsZero(o.RouteAttr[i]) { // not required - return nil - } - if err := o.RouteAttr[i].ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getConfigRouteAllOK" + "." + "routeAttr" + "." + strconv.Itoa(i)) diff --git a/api/restapi/operations/get_config_session_all.go b/api/restapi/operations/get_config_session_all.go index e51e2c2f0..3e30ac8e8 100644 --- a/api/restapi/operations/get_config_session_all.go +++ b/api/restapi/operations/get_config_session_all.go @@ -132,11 +132,6 @@ func (o *GetConfigSessionAllOKBody) contextValidateSessionAttr(ctx context.Conte for i := 0; i < len(o.SessionAttr); i++ { if o.SessionAttr[i] != nil { - - if swag.IsZero(o.SessionAttr[i]) { // not required - return nil - } - if err := o.SessionAttr[i].ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getConfigSessionAllOK" + "." + "sessionAttr" + "." + strconv.Itoa(i)) diff --git a/api/restapi/operations/get_config_sessionulcl_all.go b/api/restapi/operations/get_config_sessionulcl_all.go index 756518852..76db8c587 100644 --- a/api/restapi/operations/get_config_sessionulcl_all.go +++ b/api/restapi/operations/get_config_sessionulcl_all.go @@ -132,11 +132,6 @@ func (o *GetConfigSessionulclAllOKBody) contextValidateUlclAttr(ctx context.Cont for i := 0; i < len(o.UlclAttr); i++ { if o.UlclAttr[i] != nil { - - if swag.IsZero(o.UlclAttr[i]) { // not required - return nil - } - if err := o.UlclAttr[i].ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getConfigSessionulclAllOK" + "." + "ulclAttr" + "." + strconv.Itoa(i)) diff --git a/api/restapi/operations/get_config_tunnel_vxlan_all.go b/api/restapi/operations/get_config_tunnel_vxlan_all.go index 06be74888..d79cfe1a8 100644 --- a/api/restapi/operations/get_config_tunnel_vxlan_all.go +++ b/api/restapi/operations/get_config_tunnel_vxlan_all.go @@ -132,11 +132,6 @@ func (o *GetConfigTunnelVxlanAllOKBody) contextValidateVxlanAttr(ctx context.Con for i := 0; i < len(o.VxlanAttr); i++ { if o.VxlanAttr[i] != nil { - - if swag.IsZero(o.VxlanAttr[i]) { // not required - return nil - } - if err := o.VxlanAttr[i].ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getConfigTunnelVxlanAllOK" + "." + "vxlanAttr" + "." + strconv.Itoa(i)) diff --git a/api/restapi/operations/get_config_vlan_all.go b/api/restapi/operations/get_config_vlan_all.go index f52141cd9..e38e217be 100644 --- a/api/restapi/operations/get_config_vlan_all.go +++ b/api/restapi/operations/get_config_vlan_all.go @@ -132,11 +132,6 @@ func (o *GetConfigVlanAllOKBody) contextValidateVlanAttr(ctx context.Context, fo for i := 0; i < len(o.VlanAttr); i++ { if o.VlanAttr[i] != nil { - - if swag.IsZero(o.VlanAttr[i]) { // not required - return nil - } - if err := o.VlanAttr[i].ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getConfigVlanAllOK" + "." + "vlanAttr" + "." + strconv.Itoa(i)) diff --git a/api/restapi/operations/get_status_filesystem.go b/api/restapi/operations/get_status_filesystem.go index 54e463690..817708add 100644 --- a/api/restapi/operations/get_status_filesystem.go +++ b/api/restapi/operations/get_status_filesystem.go @@ -132,11 +132,6 @@ func (o *GetStatusFilesystemOKBody) contextValidateFilesystemAttr(ctx context.Co for i := 0; i < len(o.FilesystemAttr); i++ { if o.FilesystemAttr[i] != nil { - - if swag.IsZero(o.FilesystemAttr[i]) { // not required - return nil - } - if err := o.FilesystemAttr[i].ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getStatusFilesystemOK" + "." + "filesystemAttr" + "." + strconv.Itoa(i)) diff --git a/api/restapi/operations/get_status_process.go b/api/restapi/operations/get_status_process.go index 4d25fd726..b4fc54b10 100644 --- a/api/restapi/operations/get_status_process.go +++ b/api/restapi/operations/get_status_process.go @@ -132,11 +132,6 @@ func (o *GetStatusProcessOKBody) contextValidateProcessAttr(ctx context.Context, for i := 0; i < len(o.ProcessAttr); i++ { if o.ProcessAttr[i] != nil { - - if swag.IsZero(o.ProcessAttr[i]) { // not required - return nil - } - if err := o.ProcessAttr[i].ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("getStatusProcessOK" + "." + "processAttr" + "." + strconv.Itoa(i)) diff --git a/api/restapi/operations/loxilb_rest_api_api.go b/api/restapi/operations/loxilb_rest_api_api.go index 68444baf6..8546eb18d 100644 --- a/api/restapi/operations/loxilb_rest_api_api.go +++ b/api/restapi/operations/loxilb_rest_api_api.go @@ -968,6 +968,6 @@ func (o *LoxilbRestAPIAPI) AddMiddlewareFor(method, path string, builder middlew } o.Init() if h, ok := o.handlers[um][path]; ok { - o.handlers[um][path] = builder(h) + o.handlers[method][path] = builder(h) } } diff --git a/api/swagger.yml b/api/swagger.yml index 551aa43d4..c774f2e9a 100644 --- a/api/swagger.yml +++ b/api/swagger.yml @@ -3107,3 +3107,6 @@ definitions: SetNextHopSelf: type: boolean description: Adds policy to set next hop as self, if enabled + listenPort: + type: integer + description: Listen port (default 179) diff --git a/common/common.go b/common/common.go index dbc2d5e4b..d6e028a00 100644 --- a/common/common.go +++ b/common/common.go @@ -589,8 +589,9 @@ type GoBGPGlobalConfig struct { // Local AS number LocalAs int64 `json:"localAs,omitempty"` // BGP Router ID - RouterID string `json:"routerId,omitempty"` - SetNHSelf bool `json:"setNextHopSelf,omitempty"` + RouterID string `json:"routerId,omitempty"` + SetNHSelf bool `json:"setNextHopSelf,omitempty"` + ListenPort uint16 `json:"listenPort,omitempty"` } // GoBGPNeighMod - Info related to goBGP neigh diff --git a/loxinet/gobgpclient.go b/loxinet/gobgpclient.go index 5e7932f65..71863533f 100644 --- a/loxinet/gobgpclient.go +++ b/loxinet/gobgpclient.go @@ -827,6 +827,7 @@ func (gbh *GoBgpH) BGPGlobalConfigAdd(config cmn.GoBGPGlobalConfig) (int, error) Global: &api.Global{ Asn: uint32(config.LocalAs), RouterId: config.RouterID, + ListenPort: int32(config.ListenPort), ListenAddresses: lalist, }, })