Skip to content

FRR: Implementation of BGP interface for FRR - #958

Merged
fedepaol merged 6 commits into
metallb:mainfrom
markdgray:feat/frr_integration
Oct 30, 2021
Merged

fedepaol merged 6 commits into
metallb:mainfrom
markdgray:feat/frr_integration

Conversation

@markdgray

Copy link
Copy Markdown
Contributor

This pull request is an initial attempt at implementing the MetalLB BGP interface for FRR.

It is not complete as:

@markdgray
markdgray force-pushed the feat/frr_integration branch 2 times, most recently from 5ae0b4c to 7385507 Compare September 17, 2021 17:20
Comment thread speaker/bgp_controller.go Resolved
Comment thread internal/bgp/bgpfrr/config.go Resolved
Comment thread internal/bgp/bgpfrr/config.go Resolved
Comment thread internal/bgp/bgpfrr/frr.go Resolved
Comment thread internal/bgp/bgpfrr/frr.go Resolved
Comment thread internal/bgp/bgpfrr/config.go Resolved
Comment thread internal/bgp/bgpfrr/config.go Resolved
Comment thread internal/bgp/bgpfrr/config.go Resolved
Comment thread internal/bgp/bgpfrr/config.go Resolved
Comment thread internal/bgp/bgpfrr/frr.go Resolved
Comment thread internal/bgp/bgpfrr/frr.go Resolved
Comment thread internal/bgp/bgpfrr/frr.go Resolved
Comment thread internal/bgp/bgpfrr/frr.go Resolved
Comment thread internal/bgp/bgpfrr/frr.go Resolved
Comment thread internal/bgp/bgpfrr/frr.go Resolved
Comment thread internal/bgp/bgpfrr/frr.go Resolved
Comment thread internal/bgp/bgpfrr/frr_test.go Resolved
Comment thread internal/bgp/bgpfrr/frr_test.go Resolved
Comment thread internal/bgp/bgpfrr/frr_test.go Resolved
Comment thread internal/bgp/bgp.go Resolved
Comment thread speaker/bgp_controller.go Resolved
Comment thread internal/bgp/bgpfrr/frr.go Resolved
Comment thread internal/bgp/bgpfrr/config.go Resolved
Comment thread internal/bgp/bgpfrr/frr.go Resolved
Comment thread internal/bgp/bgpfrr/config.go Resolved
Comment thread internal/bgp/bgpfrr/config.go Resolved
Comment thread internal/bgp/bgpfrr/config.go Resolved
@fedepaol fedepaol mentioned this pull request Sep 28, 2021
@markdgray
markdgray force-pushed the feat/frr_integration branch 5 times, most recently from 614ff92 to 6d6d161 Compare October 1, 2021 08:16
@cgoncalves

Copy link
Copy Markdown
Contributor

LGTM. This PR provides a good foundation. PR #935 will add the FRR reloader part and PR #969 will integrate the two by signaling the FRR reloader that an updated configuration has been generated and should be applied.

Thank you very much for considering my review comments and cherry-picking suggested commits into this PR!

@markdgray

Copy link
Copy Markdown
Contributor Author

Thanks a lot for this effort @markdgray.

I am not done reviewing, however I already have some important feedback so submitting the current state since there is a chance it's going to affect some major things in the implementation.

Thanks for the review so far @johananl !

@markdgray
markdgray force-pushed the feat/frr_integration branch 2 times, most recently from 9315b42 to a1945ea Compare October 6, 2021 14:18
Comment thread internal/bgp/frr/frr_test.go Resolved
@fedepaol

Copy link
Copy Markdown
Member

You may want to add this too: fedepaol@2ba9195
We need it for ensuring the connection with peers is established even if no announcement is set yet

@cgoncalves

Copy link
Copy Markdown
Contributor

You may want to add this too: fedepaol@2ba9195 We need it for ensuring the connection with peers is established even if no announcement is set yet

Why is it so necessary to have an established BGP peering when there is no address family activated?
If your commit is incorporated, what happens if the cluster is IPv6-only and/or the remote BGP neighbor is not IPv4 activated?

@fedepaol

Copy link
Copy Markdown
Member

You may want to add this too: fedepaol@2ba9195 We need it for ensuring the connection with peers is established even if no announcement is set yet

Why is it so necessary to have an established BGP peering when there is no address family activated? If your commit is incorporated, what happens if the cluster is IPv6-only and/or the remote BGP neighbor is not IPv4 activated?

It's not so necessary but would maintain parity with the current behaviour. Good point about v6 only, will change hte original commit to reflect that.

@markdgray

Copy link
Copy Markdown
Contributor Author

You may want to add this too: fedepaol@2ba9195 We need it for ensuring the connection with peers is established even if no announcement is set yet

Why is it so necessary to have an established BGP peering when there is no address family activated? If your commit is incorporated, what happens if the cluster is IPv6-only and/or the remote BGP neighbor is not IPv4 activated?

It's not so necessary but would maintain parity with the current behaviour. Good point about v6 only, will change hte original commit to reflect that.

Let's leave this as a follow-up commit.

In preparation for introduction of FRR, reorganise the bgp directory
structure.

The "bgp" package will now consist of a sub-package containing
the "native" BGP implementation. Code that is common to all
implementations is pulled out into the "bgp" package.

Signed-off-by: Mark Gray <mark.d.gray@redhat.com>
In order to configure the speaker application to use different
BGP implementation types, add an option to allow the user to specify
the implementation type on speaker startup.

This option is set using an environment variable. It is set to "native"
by default. As there are currently no other BGP implementations, setting
this to another value will cause the speaker to not start.

Signed-off-by: Mark Gray <mark.d.gray@redhat.com>
This adds a Commit() method to the Session interface. The purpose
of this method is to allow clients to defer Set() operations
until Commit() is called. As the native implementation of BGP does
not support Commit(), its implementation is NOOP.

Signed-off-by: Mark Gray <mark.d.gray@redhat.com>
As the ConfigMap defines MyASN as the local ASN and ASN
as the remote ASN, use the same convention for BGP sessions.

Signed-off-by: Mark Gray <mark.d.gray@redhat.com>
@markdgray
markdgray force-pushed the feat/frr_integration branch from a1945ea to b395ab5 Compare October 28, 2021 15:39
This commit implements the MetalLB BGP interface by generating
an FRR configuration file. It does this by maintaining an
in-memory representation of the MetalLB BGP configuration that
can be used to template the FRR configuration file. At each call
of the MetalLB BGP interface, the in-memory state is
regenerated and the config file is (re)created.

Signed-off-by: Mark Gray <mark.d.gray@redhat.com>
Signed-off-by: Carlos Goncalves <cgoncalves@redhat.com>
@markdgray
markdgray force-pushed the feat/frr_integration branch 2 times, most recently from e1686b5 to 8c764c2 Compare October 30, 2021 09:57
Comment thread internal/bgp/frr/frr.go Outdated

// As the MetalLB controller should handle messages synchronously, there should
// no need to lock this data structure. TODO: confirm this.
type FRRSessionManager struct {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be just SessionManager I think

Comment thread internal/bgp/native/native.go Outdated
}

// The 'Native' implementation does not require a session manager .
type NativeSessionManager struct {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd put this on top as it's the external interface

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this can just be SessionManager I think

Comment thread internal/bgp/native/native.go Resolved
Comment thread internal/bgp/native/native.go Resolved
@fedepaol

Copy link
Copy Markdown
Member

Looks great! Left a few comments, not really blocking.

@markdgray

Copy link
Copy Markdown
Contributor Author

Great, I'll update

@markdgray
markdgray force-pushed the feat/frr_integration branch from 8c764c2 to 821b295 Compare October 30, 2021 12:38
In order to remove some package-scoped variables from the BGP FRR
implementation, this commit adds a SessionManager. The SessionManager
can be used to manage multiple BGP Sessions. The SessionManager is
created on creation of the BGP controller and is specific to the
BGP implementation. Currently, only the FRR BGP implementation
uses the SessionManager. In order for the BGP controller to create
BGP sessions, it must do so through the SessionManager.

The interface looks something like this:

sessionManager := newBgp("frr")
session := sessionManager.NewSession(...)
session.Set()
session.Close()

Signed-off-by: Mark Gray <mark.d.gray@redhat.com>
@markdgray
markdgray force-pushed the feat/frr_integration branch from 821b295 to 296ef0c Compare October 30, 2021 13:01
@fedepaol

Copy link
Copy Markdown
Member

LGTM

@fedepaol
fedepaol merged commit 9cb1653 into metallb:main Oct 30, 2021
@markdgray

Copy link
Copy Markdown
Contributor Author

Thanks

sabinaaledort pushed a commit to sabinaaledort/metallb that referenced this pull request Nov 24, 2021
* bgp: Reorganise bgp directory structure

In preparation for introduction of FRR, reorganise the bgp directory
structure.

The "bgp" package will now consist of a sub-package containing
the "native" BGP implementation. Code that is common to all
implementations is pulled out into the "bgp" package.

Signed-off-by: Mark Gray <mark.d.gray@redhat.com>

* bgp: Add option to configure BGP speaker implementation type

In order to configure the speaker application to use different
BGP implementation types, add an option to allow the user to specify
the implementation type on speaker startup.

This option is set using an environment variable. It is set to "native"
by default. As there are currently no other BGP implementations, setting
this to another value will cause the speaker to not start.

Signed-off-by: Mark Gray <mark.d.gray@redhat.com>

* bgp: Extend Session interface with Commit() method

This adds a Commit() method to the Session interface. The purpose
of this method is to allow clients to defer Set() operations
until Commit() is called. As the native implementation of BGP does
not support Commit(), its implementation is NOOP.

Signed-off-by: Mark Gray <mark.d.gray@redhat.com>

* bgp: Change name convention for sessions

As the ConfigMap defines MyASN as the local ASN and ASN
as the remote ASN, use the same convention for BGP sessions.

Signed-off-by: Mark Gray <mark.d.gray@redhat.com>

* frr: Add initial FRR configuration templating engine

This commit implements the MetalLB BGP interface by generating
an FRR configuration file. It does this by maintaining an
in-memory representation of the MetalLB BGP configuration that
can be used to template the FRR configuration file. At each call
of the MetalLB BGP interface, the in-memory state is
regenerated and the config file is (re)created.

Signed-off-by: Mark Gray <mark.d.gray@redhat.com>
Signed-off-by: Carlos Goncalves <cgoncalves@redhat.com>

* bpg: Introduce SessionManager

In order to remove some package-scoped variables from the BGP FRR
implementation, this commit adds a SessionManager. The SessionManager
can be used to manage multiple BGP Sessions. The SessionManager is
created on creation of the BGP controller and is specific to the
BGP implementation. Currently, only the FRR BGP implementation
uses the SessionManager. In order for the BGP controller to create
BGP sessions, it must do so through the SessionManager.

The interface looks something like this:

sessionManager := newBgp("frr")
session := sessionManager.NewSession(...)
session.Set()
session.Close()

Signed-off-by: Mark Gray <mark.d.gray@redhat.com>
rata pushed a commit to kinvolk/metallb that referenced this pull request Feb 17, 2022
* bgp: Reorganise bgp directory structure

In preparation for introduction of FRR, reorganise the bgp directory
structure.

The "bgp" package will now consist of a sub-package containing
the "native" BGP implementation. Code that is common to all
implementations is pulled out into the "bgp" package.

Signed-off-by: Mark Gray <mark.d.gray@redhat.com>

* bgp: Add option to configure BGP speaker implementation type

In order to configure the speaker application to use different
BGP implementation types, add an option to allow the user to specify
the implementation type on speaker startup.

This option is set using an environment variable. It is set to "native"
by default. As there are currently no other BGP implementations, setting
this to another value will cause the speaker to not start.

Signed-off-by: Mark Gray <mark.d.gray@redhat.com>

* bgp: Extend Session interface with Commit() method

This adds a Commit() method to the Session interface. The purpose
of this method is to allow clients to defer Set() operations
until Commit() is called. As the native implementation of BGP does
not support Commit(), its implementation is NOOP.

Signed-off-by: Mark Gray <mark.d.gray@redhat.com>

* bgp: Change name convention for sessions

As the ConfigMap defines MyASN as the local ASN and ASN
as the remote ASN, use the same convention for BGP sessions.

Signed-off-by: Mark Gray <mark.d.gray@redhat.com>

* frr: Add initial FRR configuration templating engine

This commit implements the MetalLB BGP interface by generating
an FRR configuration file. It does this by maintaining an
in-memory representation of the MetalLB BGP configuration that
can be used to template the FRR configuration file. At each call
of the MetalLB BGP interface, the in-memory state is
regenerated and the config file is (re)created.

Signed-off-by: Mark Gray <mark.d.gray@redhat.com>
Signed-off-by: Carlos Goncalves <cgoncalves@redhat.com>

* bpg: Introduce SessionManager

In order to remove some package-scoped variables from the BGP FRR
implementation, this commit adds a SessionManager. The SessionManager
can be used to manage multiple BGP Sessions. The SessionManager is
created on creation of the BGP controller and is specific to the
BGP implementation. Currently, only the FRR BGP implementation
uses the SessionManager. In order for the BGP controller to create
BGP sessions, it must do so through the SessionManager.

The interface looks something like this:

sessionManager := newBgp("frr")
session := sessionManager.NewSession(...)
session.Set()
session.Close()

Signed-off-by: Mark Gray <mark.d.gray@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants