diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-04-27 09:41:29 +0000 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-04-27 10:07:02 +0000 |
commit | f6c70e980d41066df51ce8cf63f2351911391e47 (patch) | |
tree | bb774d3b6e6f4792937154da4362e5e047e22876 | |
parent | 21938add9f67de5bea1ac7ccb4b21b24a996437b (diff) |
config: make route-target config struct aligned with open-config model
have config/state container
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
-rw-r--r-- | config/bgp_configs.go | 43 | ||||
-rw-r--r-- | server/server.go | 6 | ||||
-rw-r--r-- | test/lib/gobgp.py | 2 | ||||
-rw-r--r-- | tools/pyang_plugins/gobgp.yang | 15 |
4 files changed, 56 insertions, 10 deletions
diff --git a/config/bgp_configs.go b/config/bgp_configs.go index 7beaeec9..d69995d1 100644 --- a/config/bgp_configs.go +++ b/config/bgp_configs.go @@ -2561,13 +2561,29 @@ func (lhs *Zebra) Equal(rhs *Zebra) bool { return true } -//struct for container gobgp:route-target-membership -type RouteTargetMembership struct { +//struct for container gobgp:state +type RouteTargetMembershipState struct { // original -> gobgp:deferral-time DeferralTime uint16 `mapstructure:"deferral-time"` } -func (lhs *RouteTargetMembership) Equal(rhs *RouteTargetMembership) bool { +func (lhs *RouteTargetMembershipState) Equal(rhs *RouteTargetMembershipState) bool { + if lhs == nil || rhs == nil { + return false + } + if lhs.DeferralTime != rhs.DeferralTime { + return false + } + return true +} + +//struct for container gobgp:config +type RouteTargetMembershipConfig struct { + // original -> gobgp:deferral-time + DeferralTime uint16 `mapstructure:"deferral-time"` +} + +func (lhs *RouteTargetMembershipConfig) Equal(rhs *RouteTargetMembershipConfig) bool { if lhs == nil || rhs == nil { return false } @@ -2577,6 +2593,27 @@ func (lhs *RouteTargetMembership) Equal(rhs *RouteTargetMembership) bool { return true } +//struct for container gobgp:route-target-membership +type RouteTargetMembership struct { + // original -> gobgp:route-target-membership-config + Config RouteTargetMembershipConfig `mapstructure:"config"` + // original -> gobgp:route-target-membership-state + State RouteTargetMembershipState `mapstructure:"state"` +} + +func (lhs *RouteTargetMembership) Equal(rhs *RouteTargetMembership) bool { + if lhs == nil || rhs == nil { + return false + } + if !lhs.Config.Equal(&(rhs.Config)) { + return false + } + if !lhs.State.Equal(&(rhs.State)) { + return false + } + return true +} + //struct for container bgp-mp:l2vpn-evpn type L2vpnEvpn struct { // original -> bgp-mp:prefix-limit diff --git a/server/server.go b/server/server.go index 37c43447..bed5029f 100644 --- a/server/server.go +++ b/server/server.go @@ -766,9 +766,9 @@ func (server *BgpServer) handleFSMMessage(peer *Peer, e *FsmMsg) []*SenderMsg { // waiting sending non-route-target NLRIs since the peer won't send // any routes (and EORs) before we send ours (or deferral-timer expires). var pathList []*table.Path - if c := config.GetAfiSafi(peer.fsm.pConf, bgp.RF_RTC_UC); !peer.fsm.pConf.GracefulRestart.State.PeerRestarting && peer.fsm.rfMap[bgp.RF_RTC_UC] && c.RouteTargetMembership.DeferralTime > 0 { + if c := config.GetAfiSafi(peer.fsm.pConf, bgp.RF_RTC_UC); !peer.fsm.pConf.GracefulRestart.State.PeerRestarting && peer.fsm.rfMap[bgp.RF_RTC_UC] && c.RouteTargetMembership.Config.DeferralTime > 0 { pathList, _ = peer.getBestFromLocal([]bgp.RouteFamily{bgp.RF_RTC_UC}) - t := c.RouteTargetMembership.DeferralTime + t := c.RouteTargetMembership.Config.DeferralTime for _, f := range peer.configuredRFlist() { if f != bgp.RF_RTC_UC { time.AfterFunc(time.Second*time.Duration(t), deferralExpiredFunc(f)) @@ -944,7 +944,7 @@ func (server *BgpServer) handleFSMMessage(peer *Peer, e *FsmMsg) []*SenderMsg { // received EOR of route-target address family // outbound filter is now ready, let's flash non-route-target NLRIs - if c := config.GetAfiSafi(peer.fsm.pConf, bgp.RF_RTC_UC); rtc && c != nil && c.RouteTargetMembership.DeferralTime > 0 { + if c := config.GetAfiSafi(peer.fsm.pConf, bgp.RF_RTC_UC); rtc && c != nil && c.RouteTargetMembership.Config.DeferralTime > 0 { log.WithFields(log.Fields{ "Topic": "Peer", "Key": peer.ID(), diff --git a/test/lib/gobgp.py b/test/lib/gobgp.py index 5b7a847e..12846749 100644 --- a/test/lib/gobgp.py +++ b/test/lib/gobgp.py @@ -237,7 +237,7 @@ class GoBGPContainer(BGPContainer): afi_safi_list.append({'config': {'afi-safi-name': 'l3vpn-ipv4-unicast'}}) afi_safi_list.append({'config': {'afi-safi-name': 'l3vpn-ipv6-unicast'}}) afi_safi_list.append({'config': {'afi-safi-name': 'l2vpn-evpn'}}) - afi_safi_list.append({'config': {'afi-safi-name': 'rtc'}, 'route-target-membership': {'deferral-time': 10}}) + afi_safi_list.append({'config': {'afi-safi-name': 'rtc'}, 'route-target-membership': {'config': {'deferral-time': 10}}}) if info['flowspec']: afi_safi_list.append({'config': {'afi-safi-name': 'ipv4-flowspec'}}) diff --git a/tools/pyang_plugins/gobgp.yang b/tools/pyang_plugins/gobgp.yang index 6650711d..9ca5f78d 100644 --- a/tools/pyang_plugins/gobgp.yang +++ b/tools/pyang_plugins/gobgp.yang @@ -816,11 +816,20 @@ module gobgp { uses bgp-mp:all-afi-safi-common; } + grouping route-target-membership-config { + leaf deferral-time { + type uint16; + } + } + augment "/bgp:bgp/bgp:global/bgp:afi-safis/bgp:afi-safi" { container route-target-membership { - leaf deferral-time { - type uint16; - } + container config { + uses route-target-membership-config; + } + container state { + uses route-target-membership-config; + } } } } |