From 2f5a4d59cb8d494bcf1a64d45d84bcd8fd4a7f06 Mon Sep 17 00:00:00 2001 From: Hitoshi Irino Date: Mon, 24 Jun 2019 00:39:22 +0900 Subject: BGP connection on a speecified interface (including which is associated VRF) using syscall SO_BINDTODEVICE --- internal/pkg/config/bgp_configs.go | 11 +++++++++++ internal/pkg/config/util.go | 7 ++++--- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'internal/pkg/config') diff --git a/internal/pkg/config/bgp_configs.go b/internal/pkg/config/bgp_configs.go index 37fe1b39..0e375619 100644 --- a/internal/pkg/config/bgp_configs.go +++ b/internal/pkg/config/bgp_configs.go @@ -2548,6 +2548,10 @@ type TransportState struct { // Remote port being used by the peer for the TCP session // supporting the BGP session. RemotePort uint16 `mapstructure:"remote-port" json:"remote-port,omitempty"` + // original -> bgp:bind-interface + // bgp:bind-interface's original type is union. + // Interface name for binding. + BindInterface string `mapstructure:"bind-interface" json:"bind-interface,omitempty"` } // struct for container bgp:config. @@ -2580,6 +2584,10 @@ type TransportConfig struct { // original -> gobgp:ttl // TTL value for BGP packets. Ttl uint8 `mapstructure:"ttl" json:"ttl,omitempty"` + // original -> bgp:bind-interface + // bgp:bind-interface's original type is union. + // Interface name for binding. + BindInterface string `mapstructure:"bind-interface" json:"bind-interface,omitempty"` } func (lhs *TransportConfig) Equal(rhs *TransportConfig) bool { @@ -2604,6 +2612,9 @@ func (lhs *TransportConfig) Equal(rhs *TransportConfig) bool { if lhs.Ttl != rhs.Ttl { return false } + if lhs.BindInterface != rhs.BindInterface { + return false + } return true } diff --git a/internal/pkg/config/util.go b/internal/pkg/config/util.go index 78a0e713..f85e9376 100644 --- a/internal/pkg/config/util.go +++ b/internal/pkg/config/util.go @@ -534,9 +534,10 @@ func NewPeerFromConfigStruct(pconf *Neighbor) *api.Peer { LocalRestarting: pconf.GracefulRestart.State.LocalRestarting, }, Transport: &api.Transport{ - RemotePort: uint32(pconf.Transport.Config.RemotePort), - LocalAddress: localAddress, - PassiveMode: pconf.Transport.Config.PassiveMode, + RemotePort: uint32(pconf.Transport.Config.RemotePort), + LocalAddress: localAddress, + PassiveMode: pconf.Transport.Config.PassiveMode, + BindInterface: pconf.Transport.Config.BindInterface, }, AfiSafis: afiSafis, } -- cgit v1.2.3