Skip to content

Commit 16ea4f9

Browse files
Add neighbor config option to bypass as-path loop detection on local (static) routes
1 parent 2819c56 commit 16ea4f9

10 files changed

+1152
-1113
lines changed

api/attribute.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/capability.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/gobgp.pb.go

+1,106-1,094
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/gobgp.proto

+1
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ message PeerConf {
621621
bool replace_peer_asn = 14;
622622
bool admin_down = 15;
623623
bool send_software_version = 16;
624+
bool allow_aspath_loop_local = 17;
624625
}
625626

626627
message PeerGroupConf {

pkg/config/oc/bgp_configs.go

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/config/oc/default.go

+1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ func setDefaultNeighborConfigValuesWithViper(v *viper.Viper, n *Neighbor, g *Glo
109109

110110
n.State.PeerAs = n.Config.PeerAs
111111
n.AsPathOptions.State.AllowOwnAs = n.AsPathOptions.Config.AllowOwnAs
112+
n.AsPathOptions.State.AllowAsPathLoopLocal = n.AsPathOptions.Config.AllowAsPathLoopLocal
112113

113114
if !v.IsSet("neighbor.error-handling.config.treat-as-withdraw") {
114115
n.ErrorHandling.Config.TreatAsWithdraw = true

pkg/config/oc/util.go

+16-15
Original file line numberDiff line numberDiff line change
@@ -466,21 +466,22 @@ func NewPeerFromConfigStruct(pconf *Neighbor) *api.Peer {
466466
return &api.Peer{
467467
ApplyPolicy: newApplyPolicyFromConfigStruct(&pconf.ApplyPolicy),
468468
Conf: &api.PeerConf{
469-
NeighborAddress: pconf.Config.NeighborAddress,
470-
PeerAsn: pconf.Config.PeerAs,
471-
LocalAsn: pconf.Config.LocalAs,
472-
Type: api.PeerType(pconf.Config.PeerType.ToInt()),
473-
AuthPassword: pconf.Config.AuthPassword,
474-
RouteFlapDamping: pconf.Config.RouteFlapDamping,
475-
Description: pconf.Config.Description,
476-
PeerGroup: pconf.Config.PeerGroup,
477-
NeighborInterface: pconf.Config.NeighborInterface,
478-
Vrf: pconf.Config.Vrf,
479-
AllowOwnAsn: uint32(pconf.AsPathOptions.Config.AllowOwnAs),
480-
RemovePrivate: removePrivate,
481-
ReplacePeerAsn: pconf.AsPathOptions.Config.ReplacePeerAs,
482-
AdminDown: pconf.Config.AdminDown,
483-
SendSoftwareVersion: pconf.Config.SendSoftwareVersion,
469+
NeighborAddress: pconf.Config.NeighborAddress,
470+
PeerAsn: pconf.Config.PeerAs,
471+
LocalAsn: pconf.Config.LocalAs,
472+
Type: api.PeerType(pconf.Config.PeerType.ToInt()),
473+
AuthPassword: pconf.Config.AuthPassword,
474+
RouteFlapDamping: pconf.Config.RouteFlapDamping,
475+
Description: pconf.Config.Description,
476+
PeerGroup: pconf.Config.PeerGroup,
477+
NeighborInterface: pconf.Config.NeighborInterface,
478+
Vrf: pconf.Config.Vrf,
479+
AllowOwnAsn: uint32(pconf.AsPathOptions.Config.AllowOwnAs),
480+
AllowAspathLoopLocal: pconf.AsPathOptions.Config.AllowAsPathLoopLocal,
481+
RemovePrivate: removePrivate,
482+
ReplacePeerAsn: pconf.AsPathOptions.Config.ReplacePeerAs,
483+
AdminDown: pconf.Config.AdminDown,
484+
SendSoftwareVersion: pconf.Config.SendSoftwareVersion,
484485
},
485486
State: &api.PeerState{
486487
SessionState: api.PeerState_SessionState(api.PeerState_SessionState_value[strings.ToUpper(string(s.SessionState))]),

pkg/server/grpc_server.go

+1
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,7 @@ func newNeighborFromAPIStruct(a *api.Peer) (*oc.Neighbor, error) {
691691
pconf.Config.Vrf = a.Conf.Vrf
692692
pconf.AsPathOptions.Config.AllowOwnAs = uint8(a.Conf.AllowOwnAsn)
693693
pconf.AsPathOptions.Config.ReplacePeerAs = a.Conf.ReplacePeerAsn
694+
pconf.AsPathOptions.Config.AllowAsPathLoopLocal = a.Conf.AllowAspathLoopLocal
694695
pconf.Config.SendSoftwareVersion = a.Conf.SendSoftwareVersion
695696

696697
switch a.Conf.RemovePrivate {

pkg/server/peer.go

+6
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ func (peer *peer) TableID() string {
158158
return peer.tableId
159159
}
160160

161+
func (peer *peer) allowAsPathLoopLocal() bool {
162+
peer.fsm.lock.RLock()
163+
defer peer.fsm.lock.RUnlock()
164+
return peer.fsm.pConf.AsPathOptions.Config.AllowAsPathLoopLocal
165+
}
166+
161167
func (peer *peer) isIBGPPeer() bool {
162168
peer.fsm.lock.RLock()
163169
defer peer.fsm.lock.RUnlock()

pkg/server/server.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -691,8 +691,15 @@ func filterpath(peer *peer, path, old *table.Path) *table.Path {
691691
return nil
692692
}
693693

694-
if !peer.isRouteServerClient() && isASLoop(peer, path) && !path.IsLocal() {
695-
return nil
694+
if !peer.isRouteServerClient() && isASLoop(peer, path) {
695+
// Do not filter local (static) routes with as-path loop
696+
// if configured to bypass these checks in the peer
697+
// as-path options config.
698+
if path.IsLocal() && !peer.allowAsPathLoopLocal() {
699+
return nil
700+
} else if !path.IsLocal() {
701+
return nil
702+
}
696703
}
697704
return path
698705
}

0 commit comments

Comments
 (0)