diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/fsm.go | 6 | ||||
-rw-r--r-- | server/peer.go | 12 | ||||
-rw-r--r-- | server/server.go | 32 |
3 files changed, 33 insertions, 17 deletions
diff --git a/server/fsm.go b/server/fsm.go index 58524efc..15299044 100644 --- a/server/fsm.go +++ b/server/fsm.go @@ -516,7 +516,7 @@ func capabilitiesFromConfig(pConf *config.Neighbor) []bgp.ParameterCapabilityInt caps := make([]bgp.ParameterCapabilityInterface, 0, 4) caps = append(caps, bgp.NewCapRouteRefresh()) for _, rf := range pConf.AfiSafis { - family, _ := bgp.GetRouteFamily(string(rf.AfiSafiName)) + family, _ := bgp.GetRouteFamily(string(rf.Config.AfiSafiName)) caps = append(caps, bgp.NewCapMultiProtocol(family)) } caps = append(caps, bgp.NewCapFourOctetASNumber(pConf.Config.LocalAs)) @@ -533,7 +533,7 @@ func capabilitiesFromConfig(pConf *config.Neighbor) []bgp.ParameterCapabilityInt if !c.HelperOnly { for i, rf := range pConf.AfiSafis { if rf.MpGracefulRestart.Config.Enabled { - k, _ := bgp.GetRouteFamily(string(rf.AfiSafiName)) + k, _ := bgp.GetRouteFamily(string(rf.Config.AfiSafiName)) // When restarting, always flag forwaring bit. // This can be a lie, depending on how gobgpd is used. // For a route-server use-case, since a route-server @@ -829,7 +829,7 @@ func (h *FSMHandler) opensent() (bgp.FSMState, FsmStateReason) { for _, t := range cap.Tuples { n := bgp.AddressFamilyNameMap[bgp.AfiSafiToRouteFamily(t.AFI, t.SAFI)] for i, a := range fsm.pConf.AfiSafis { - if string(a.AfiSafiName) == n { + if string(a.Config.AfiSafiName) == n { fsm.pConf.AfiSafis[i].MpGracefulRestart.State.Enabled = true fsm.pConf.AfiSafis[i].MpGracefulRestart.State.Received = true break diff --git a/server/peer.go b/server/peer.go index d5ca5485..0d0eb490 100644 --- a/server/peer.go +++ b/server/peer.go @@ -105,7 +105,7 @@ func (peer *Peer) forwardingPreservedFamilies() ([]bgp.RouteFamily, []bgp.RouteF list := []bgp.RouteFamily{} for _, a := range peer.fsm.pConf.AfiSafis { if s := a.MpGracefulRestart.State; s.Enabled && s.Received { - f, _ := bgp.GetRouteFamily(string(a.AfiSafiName)) + f, _ := bgp.GetRouteFamily(string(a.Config.AfiSafiName)) list = append(list, f) } } @@ -263,7 +263,7 @@ func (peer *Peer) updatePrefixLimitConfig(c []config.AfiSafi) ([]*SenderMsg, err } m := make(map[bgp.RouteFamily]config.PrefixLimitConfig) for _, e := range x { - k, err := bgp.GetRouteFamily(string(e.AfiSafiName)) + k, err := bgp.GetRouteFamily(string(e.Config.AfiSafiName)) if err != nil { return nil, err } @@ -271,7 +271,7 @@ func (peer *Peer) updatePrefixLimitConfig(c []config.AfiSafi) ([]*SenderMsg, err } msgs := make([]*SenderMsg, 0, len(y)) for _, e := range y { - k, err := bgp.GetRouteFamily(string(e.AfiSafiName)) + k, err := bgp.GetRouteFamily(string(e.Config.AfiSafiName)) if err != nil { return nil, err } @@ -281,7 +281,7 @@ func (peer *Peer) updatePrefixLimitConfig(c []config.AfiSafi) ([]*SenderMsg, err log.WithFields(log.Fields{ "Topic": "Peer", "Key": peer.ID(), - "AddressFamily": e.AfiSafiName, + "AddressFamily": e.Config.AfiSafiName, "OldMaxPrefixes": p.MaxPrefixes, "NewMaxPrefixes": e.PrefixLimit.Config.MaxPrefixes, "OldShutdownThresholdPct": p.ShutdownThresholdPct, @@ -308,7 +308,7 @@ func (peer *Peer) handleUpdate(e *FsmMsg) ([]*table.Path, []bgp.RouteFamily, *bg if len(e.PathList) > 0 { peer.adjRibIn.Update(e.PathList) for _, family := range peer.fsm.pConf.AfiSafis { - k, _ := bgp.GetRouteFamily(string(family.AfiSafiName)) + k, _ := bgp.GetRouteFamily(string(family.Config.AfiSafiName)) if msg := peer.doPrefixLimit(k, &family.PrefixLimit.Config); msg != nil { return nil, nil, msg } @@ -382,7 +382,7 @@ func (peer *Peer) ToApiStruct() *api.Peer { prefixLimits := make([]*api.PrefixLimit, 0, len(peer.fsm.pConf.AfiSafis)) for _, family := range peer.fsm.pConf.AfiSafis { if c := family.PrefixLimit.Config; c.MaxPrefixes > 0 { - k, _ := bgp.GetRouteFamily(string(family.AfiSafiName)) + k, _ := bgp.GetRouteFamily(string(family.Config.AfiSafiName)) prefixLimits = append(prefixLimits, &api.PrefixLimit{ Family: uint32(k), MaxPrefixes: c.MaxPrefixes, diff --git a/server/server.go b/server/server.go index 605d9fe4..c13436de 100644 --- a/server/server.go +++ b/server/server.go @@ -912,7 +912,7 @@ func (server *BgpServer) handleFSMMessage(peer *Peer, e *FsmMsg) []*SenderMsg { rtc = true } for i, a := range peer.fsm.pConf.AfiSafis { - if g, _ := bgp.GetRouteFamily(string(a.AfiSafiName)); f == g { + if g, _ := bgp.GetRouteFamily(string(a.Config.AfiSafiName)); f == g { peer.fsm.pConf.AfiSafis[i].MpGracefulRestart.State.EndOfRibReceived = true } } @@ -1594,7 +1594,6 @@ func (server *BgpServer) handleModConfig(grpcReq *GrpcRequest) error { for _, f := range g.Families { name := config.AfiSafiType(bgp.RouteFamily(f).String()) families = append(families, config.AfiSafi{ - AfiSafiName: name, Config: config.AfiSafiConfig{ AfiSafiName: name, Enabled: true, @@ -2346,7 +2345,7 @@ func (server *BgpServer) handleAddNeighbor(c *config.Neighbor) ([]*SenderMsg, er } func (server *BgpServer) handleDelNeighbor(c *config.Neighbor) ([]*SenderMsg, error) { - addr := c.NeighborAddress + addr := c.Config.NeighborAddress n, y := server.neighborMap[addr] if !y { return nil, fmt.Errorf("Can't delete a peer configuration for %s", addr) @@ -2377,7 +2376,6 @@ func (server *BgpServer) handleGrpcModNeighbor(grpcReq *GrpcRequest) ([]*SenderM apitoConfig := func(a *api.Peer) (*config.Neighbor, error) { pconf := &config.Neighbor{} if a.Conf != nil { - pconf.NeighborAddress = a.Conf.NeighborAddress pconf.Config.NeighborAddress = a.Conf.NeighborAddress pconf.Config.PeerAs = a.Conf.PeerAs if a.Conf.LocalAs == 0 { @@ -2443,16 +2441,30 @@ func (server *BgpServer) handleGrpcModNeighbor(grpcReq *GrpcRequest) ([]*SenderM if !ok { return pconf, fmt.Errorf("invalid address family: %d", family) } - cAfiSafi := config.AfiSafi{AfiSafiName: config.AfiSafiType(name)} + cAfiSafi := config.AfiSafi{ + Config: config.AfiSafiConfig{ + AfiSafiName: config.AfiSafiType(name), + }, + } pconf.AfiSafis = append(pconf.AfiSafis, cAfiSafi) } } else { if net.ParseIP(a.Conf.NeighborAddress).To4() != nil { pconf.AfiSafis = []config.AfiSafi{ - config.AfiSafi{AfiSafiName: "ipv4-unicast"}} + config.AfiSafi{ + Config: config.AfiSafiConfig{ + AfiSafiName: "ipv4-unicast", + }, + }, + } } else { pconf.AfiSafis = []config.AfiSafi{ - config.AfiSafi{AfiSafiName: "ipv6-unicast"}} + config.AfiSafi{ + Config: config.AfiSafiConfig{ + AfiSafiName: "ipv6-unicast", + }, + }, + } } } if a.Transport != nil { @@ -2471,7 +2483,11 @@ func (server *BgpServer) handleGrpcModNeighbor(grpcReq *GrpcRequest) ([]*SenderM } return server.handleAddNeighbor(c) case api.Operation_DEL: - return server.handleDelNeighbor(&config.Neighbor{NeighborAddress: arg.Peer.Conf.NeighborAddress}) + return server.handleDelNeighbor(&config.Neighbor{ + Config: config.NeighborConfig{ + NeighborAddress: arg.Peer.Conf.NeighborAddress, + }, + }) default: return nil, fmt.Errorf("unsupported operation %s", arg.Operation) } |