Skip to content

Management cleanup #441

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

Merged
merged 28 commits into from
May 13, 2025
Merged

Conversation

Fredi-raspall
Copy link
Contributor

@Fredi-raspall Fredi-raspall commented May 6, 2025

This rides on #434
This rides on #427

  • reorganizes code and tidies it up
  • refactors integration to decouple gRPC from database and interface to frr-agent, which simplifies setup of gRPC code, tests and removes the need for a RWLock.
  • handles frr-agent reconnects (WIP).

Assigning this to @daniel-noland since it targets and modifies #434

@Fredi-raspall Fredi-raspall self-assigned this May 6, 2025
@Fredi-raspall Fredi-raspall force-pushed the pr/fredi/mgmt-cleanup branch 2 times, most recently from 6c5b296 to 1d339c7 Compare May 7, 2025 09:07
@Fredi-raspall Fredi-raspall marked this pull request as ready for review May 7, 2025 09:14
@Fredi-raspall Fredi-raspall requested a review from a team as a code owner May 7, 2025 09:14
@Fredi-raspall Fredi-raspall force-pushed the pr/fredi/mgmt-integration branch from 3a77ab1 to 7f5a5e7 Compare May 7, 2025 09:28
@Fredi-raspall Fredi-raspall force-pushed the pr/fredi/mgmt-cleanup branch from 1d339c7 to 3197f90 Compare May 7, 2025 09:28
@Fredi-raspall Fredi-raspall force-pushed the pr/fredi/mgmt-integration branch from 7f5a5e7 to 3183aca Compare May 8, 2025 08:01
@Fredi-raspall Fredi-raspall force-pushed the pr/fredi/mgmt-cleanup branch from 246423e to 0a28eb3 Compare May 8, 2025 08:02
Copy link
Member

@qmonnet qmonnet left a comment

Choose a reason for hiding this comment

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

This batch looks good again, awesome work!

Comment on lines 129 to 130
// check error
req.reply_tx.send(response);
Copy link
Member

Choose a reason for hiding this comment

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

Is this a TODO?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

@Fredi-raspall Fredi-raspall force-pushed the pr/fredi/mgmt-cleanup branch 2 times, most recently from 0cd6638 to b231ceb Compare May 10, 2025 15:09
@Fredi-raspall Fredi-raspall force-pushed the pr/fredi/mgmt-integration branch from 3183aca to ce6247c Compare May 10, 2025 15:40
@Fredi-raspall Fredi-raspall force-pushed the pr/fredi/mgmt-cleanup branch from b231ceb to a2d87d8 Compare May 10, 2025 15:41
@Fredi-raspall Fredi-raspall force-pushed the pr/fredi/mgmt-integration branch from ce6247c to 81b4363 Compare May 10, 2025 15:47
Move config database outside of model definition submodule.

Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
The ConfigProcessor owns the config database, an frrmi and opens
a channel to receive configuration requests. This aims at centra-
lizing the config management outside of the specific RPC.

Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Decouple gRPC from management logic (processor) by spawning a
ConfigProcessor task that listens over a channel requests from
the gRPC server. The configuration processor fully owns the
config database and the frrmi to apply configs in FRR.

This way, the gRPC server:
  - needs only relay requests to the ConfigProcessor and receive
    responses back, to produce answers to the outside.
  - does not need access to the config database nor a lock on it.
  - needs not be aware about how configs are applied.

This decouples the internal logic from the gRPC layer.

Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Let ConfigRequest and ConfigResponse variants that require a config
carry instead a Box<GwConfig> so that both enums keep a small size.

Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
It would be better to validate outside of the gRPC as that way
the validation would be performed regardless of how the config
was learnt.

Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
We need to be able to apply a 'blank' config in order to flush the
system (e.g. to roll back an unsuccesful configuration if no prior
config was there).

This patch adds a builder for a blank config. Such a config has
a reserved generation id of 0 and it cannot be deleted. Since the
config is stored in the config database, where configs are keyed
by generation id, this means that attempting to add a config with
generation id 0 will fail.

Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
A default VrfConfig is called "default" and marked as the default
VRF. This is needed so that a blank config underlay VrfConfig has
those values, which affect how the configs are applied.

Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
These are produced by default due to the gRPC server and provide
very little relevant information for us.

Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Don't log parser errors if packets are captured with kernel driver
on the loopback interface.

Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
When sending a config to frr-agent, include the genId so that the
latter can log it. This helps troubleshooting.

Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
If a config is not successfully applied, don't keep it in the
database.

Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
It was annotated initially as such, but the annotation was droppped.
Add the annotation back again and use the Prefix associated method
try_from_tuple() in gRPC as this was causing a panic when feeding
bad prefixes.

Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Prefix, defined in the routing crate is used by crates mgmt and
dataplane. Add a feature flag 'testing' so that external crates
can use prefix converters that are only available for testing.

Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
@Fredi-raspall Fredi-raspall force-pushed the pr/fredi/mgmt-cleanup branch from a2d87d8 to fac46e6 Compare May 10, 2025 16:08
Base automatically changed from pr/fredi/mgmt-integration to pr/fredi/management-processor May 10, 2025 16:11
Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Replace unix datagram-based frrmi implementation with one that
uses unix stream sockets and handle connection failures and
re-connects.

Over the frrmi, "messages" are expected to be serialized as:
           |length(8)|genid(8)|data(variable)|
in both directions, where:
     length: the number of octets contained in data
     genid:  the generation id the message corredponds to, 0 in
             keepalives.
     data:   string of length octets corresponding to a config or
             to a response.

BREAKING-CHANGE: This will only work with an frr-agent using
stream sockets.

Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Call GwConfigDatabase::remove() instead of the member remove()
method, as the latter does not prevent the initial config from
being deleted.

Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
The previous code required BGP configuration to be present and
would refuse to apply a config otherwise. Relax this by issuing
only a warning as this will allow applying vanilla configs for the
purpose of wiping out the system.

Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Probe the frr-agent before attempting to apply a config because
this is cheap and there's little point in trying to apply a config
if the frr-agent is down or unreachable since the operation will
fail.

Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Partial implementation of Display for some Config objects to
produce friendlier logs for testing, until the cli is integrated.

Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
@Fredi-raspall Fredi-raspall merged commit a023d7b into pr/fredi/management-processor May 13, 2025
31 checks passed
@Fredi-raspall Fredi-raspall deleted the pr/fredi/mgmt-cleanup branch May 13, 2025 16:30
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.

2 participants