Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to latest version of GoBGP. #313

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bgp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ go_library(
"@com_github_openconfig_ygot//ygot",
"@com_github_wenovus_gobgp_v3//api",
"@com_github_wenovus_gobgp_v3//pkg/config",
"@com_github_wenovus_gobgp_v3//pkg/config/gobgp",
"@com_github_wenovus_gobgp_v3//pkg/config/oc",
"@com_github_wenovus_gobgp_v3//pkg/server",
"@com_github_wenovus_gobgp_v3//pkg/zebra",
"@org_golang_x_exp//maps",
Expand All @@ -41,6 +41,6 @@ go_test(
"//gnmi/oc",
"@com_github_google_go_cmp//cmp",
"@com_github_openconfig_ygot//ygot",
"@com_github_wenovus_gobgp_v3//pkg/config/gobgp",
"@com_github_wenovus_gobgp_v3//pkg/config/oc",
],
)
42 changes: 21 additions & 21 deletions bgp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

log "github.com/golang/glog"
"github.com/openconfig/lemming/gnmi/oc"
"github.com/wenovus/gobgp/v3/pkg/config/gobgp"
gobgpoc "github.com/wenovus/gobgp/v3/pkg/config/oc"
"github.com/wenovus/gobgp/v3/pkg/zebra"
)

Expand All @@ -31,8 +31,8 @@ import (
// GoBGP's notion of config vs. state does not conform to OpenConfig (see
// https://github.com/osrg/gobgp/issues/2584)
// Therefore, we need a compatibility layer between the two configs.
func intendedToGoBGP(bgpoc *oc.NetworkInstance_Protocol_Bgp, policyoc *oc.RoutingPolicy, zapiURL string, listenPort uint16) *gobgp.BgpConfigSet {
bgpConfig := &gobgp.BgpConfigSet{}
func intendedToGoBGP(bgpoc *oc.NetworkInstance_Protocol_Bgp, policyoc *oc.RoutingPolicy, zapiURL string, listenPort uint16) *gobgpoc.BgpConfigSet {
bgpConfig := &gobgpoc.BgpConfigSet{}

// Global config
global := bgpoc.GetOrCreateGlobal()
Expand All @@ -49,20 +49,20 @@ func intendedToGoBGP(bgpoc *oc.NetworkInstance_Protocol_Bgp, policyoc *oc.Routin

for neighAddr, neigh := range bgpoc.Neighbor {
// Add neighbour config.
bgpConfig.Neighbors = append(bgpConfig.Neighbors, gobgp.Neighbor{
Config: gobgp.NeighborConfig{
bgpConfig.Neighbors = append(bgpConfig.Neighbors, gobgpoc.Neighbor{
Config: gobgpoc.NeighborConfig{
PeerAs: neigh.GetPeerAs(),
NeighborAddress: neighAddr,
},
// This is needed because GoBGP's configuration diffing
// logic may check the state value instead of the
// config value.
State: gobgp.NeighborState{
State: gobgpoc.NeighborState{
PeerAs: neigh.GetPeerAs(),
NeighborAddress: neighAddr,
},
Transport: gobgp.Transport{
Config: gobgp.TransportConfig{
Transport: gobgpoc.Transport{
Config: gobgpoc.TransportConfig{
LocalAddress: neigh.GetTransport().GetLocalAddress(),
RemotePort: neigh.GetNeighborPort(),
},
Expand All @@ -72,7 +72,7 @@ func intendedToGoBGP(bgpoc *oc.NetworkInstance_Protocol_Bgp, policyoc *oc.Routin

intendedToGoBGPPolicies(bgpoc, policyoc, bgpConfig)

bgpConfig.Zebra.Config = gobgp.ZebraConfig{
bgpConfig.Zebra.Config = gobgpoc.ZebraConfig{
Enabled: true,
Url: zapiURL,
// TODO(wenbli): This should actually be filled with the types
Expand All @@ -88,7 +88,7 @@ func intendedToGoBGP(bgpoc *oc.NetworkInstance_Protocol_Bgp, policyoc *oc.Routin
}

// intendedToGoBGPPolicies populates bgpConfig's policies from the OC configuration.
func intendedToGoBGPPolicies(bgpoc *oc.NetworkInstance_Protocol_Bgp, policyoc *oc.RoutingPolicy, bgpConfig *gobgp.BgpConfigSet) {
func intendedToGoBGPPolicies(bgpoc *oc.NetworkInstance_Protocol_Bgp, policyoc *oc.RoutingPolicy, bgpConfig *gobgpoc.BgpConfigSet) {
var communitySetIndexMap map[string]int
// community sets
bgpConfig.DefinedSets.BgpDefinedSets.CommunitySets, communitySetIndexMap = convertCommunitySet(policyoc.GetOrCreateDefinedSets().GetOrCreateBgpDefinedSets().CommunitySet)
Expand Down Expand Up @@ -118,7 +118,7 @@ func intendedToGoBGPPolicies(bgpoc *oc.NetworkInstance_Protocol_Bgp, policyoc *o
// neigh2polA, neigh2polB, ..., ...
// ...]
// Global ApplyPolicy list: [same as policy-definitions]
bgpConfig.DefinedSets.NeighborSets = append(bgpConfig.DefinedSets.NeighborSets, gobgp.NeighborSet{
bgpConfig.DefinedSets.NeighborSets = append(bgpConfig.DefinedSets.NeighborSets, gobgpoc.NeighborSet{
NeighborSetName: neighAddr,
NeighborInfoList: []string{neighAddr},
})
Expand Down Expand Up @@ -155,31 +155,31 @@ func intendedToGoBGPPolicies(bgpoc *oc.NetworkInstance_Protocol_Bgp, policyoc *o
// Create per-neighbour default policies.
defaultImportPolicyName := "default-import|" + neighAddr
defaultExportPolicyName := "default-export|" + neighAddr
bgpConfig.PolicyDefinitions = append(bgpConfig.PolicyDefinitions, gobgp.PolicyDefinition{
bgpConfig.PolicyDefinitions = append(bgpConfig.PolicyDefinitions, gobgpoc.PolicyDefinition{
Name: defaultImportPolicyName,
Statements: []gobgp.Statement{{
Statements: []gobgpoc.Statement{{
// Use a customized name for the default policies.
Name: defaultImportPolicyName,
Conditions: gobgp.Conditions{
MatchNeighborSet: gobgp.MatchNeighborSet{
Conditions: gobgpoc.Conditions{
MatchNeighborSet: gobgpoc.MatchNeighborSet{
NeighborSet: neighAddr,
},
},
Actions: gobgp.Actions{
Actions: gobgpoc.Actions{
RouteDisposition: defaultPolicyToRouteDisp(applyPolicy.Config.DefaultImportPolicy),
},
}},
}, gobgp.PolicyDefinition{
}, gobgpoc.PolicyDefinition{
Name: defaultExportPolicyName,
Statements: []gobgp.Statement{{
Statements: []gobgpoc.Statement{{
// Use a customized name for the default policies.
Name: defaultExportPolicyName,
Conditions: gobgp.Conditions{
MatchNeighborSet: gobgp.MatchNeighborSet{
Conditions: gobgpoc.Conditions{
MatchNeighborSet: gobgpoc.MatchNeighborSet{
NeighborSet: neighAddr,
},
},
Actions: gobgp.Actions{
Actions: gobgpoc.Actions{
RouteDisposition: defaultPolicyToRouteDisp(applyPolicy.Config.DefaultExportPolicy),
},
}},
Expand Down
Loading