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

More found connection conversion issues #17385

Merged

Conversation

donaldsharp
Copy link
Member

I have started another round of converting the struct peer doppelganger away and found some more functions that should properly be connection oriented. Move them over. I also made some code changes to make the coding pattern in bgp to be a bit better.

bgpd/bgpd.c Outdated Show resolved Hide resolved
Copy link
Member

@riw777 riw777 left a comment

Choose a reason for hiding this comment

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

looks good

Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@donaldsharp donaldsharp force-pushed the more_found_connection_conversion_issues branch from f99d54e to e3f24e5 Compare November 19, 2024 14:37
bgpd/bgpd.c Outdated
void peer_notify_unconfig(struct peer_connection *connection)
{
if (BGP_IS_VALID_STATE_FOR_NOTIF(connection->status))
bgp_notify_send(connection, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE);
Copy link
Member

Choose a reason for hiding this comment

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

This should be BGP_NOTIFY_CEASE_PEER_UNCONFIG, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes I got it backwards, fixed

bgpd/bgpd.c Outdated
bgp_notify_send(peer->connection, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_PEER_UNCONFIG);
if (BGP_IS_VALID_STATE_FOR_NOTIF(connection->status)) {
bgp_notify_send(connection, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_PEER_UNCONFIG);
Copy link
Member

Choose a reason for hiding this comment

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

Here it should be BGP_NOTIFY_CEASE_CONFIG_CHANGE, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@donaldsharp donaldsharp force-pushed the more_found_connection_conversion_issues branch from e3f24e5 to d1772d6 Compare November 25, 2024 18:10
Copy link
Member

@ton31337 ton31337 left a comment

Choose a reason for hiding this comment

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

I see still lots of places where BGP_IS_VALID_STATE_FOR_NOTIF() is called, but it's actually called also in peer_notify_config_change(), correct?

bgpd/bgpd.c Outdated
@@ -7057,8 +7006,7 @@ int peer_password_unset(struct peer *peer)

/* Send notification or reset peer depending on state. */
if (BGP_IS_VALID_STATE_FOR_NOTIF(member->connection->status))
Copy link
Member

Choose a reason for hiding this comment

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

peer_notify_config_change() already do this check, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed them all

bgpd/bgpd.c Outdated
@@ -7030,8 +6980,7 @@ int peer_password_unset(struct peer *peer)
if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
/* Send notification or reset peer depending on state. */
if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status))
Copy link
Member

Choose a reason for hiding this comment

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

peer_notify_config_change() already do this check, right?

bgpd/bgpd.c Outdated
@@ -6984,8 +6935,7 @@ int peer_password_set(struct peer *peer, const char *password)
member->last_reset = PEER_DOWN_PASSWORD_CHANGE;
/* Send notification or reset peer depending on state. */
if (BGP_IS_VALID_STATE_FOR_NOTIF(member->connection->status))
Copy link
Member

Choose a reason for hiding this comment

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

peer_notify_config_change() already do this check, right?

bgpd/bgpd.c Outdated
@@ -6946,8 +6898,7 @@ int peer_password_set(struct peer *peer, const char *password)
peer->last_reset = PEER_DOWN_PASSWORD_CHANGE;
/* Send notification or reset peer depending on state. */
if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status))
Copy link
Member

Choose a reason for hiding this comment

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

peer_notify_config_change() already do this check, right?

bgpd/bgpd.c Outdated
@@ -6914,8 +6867,7 @@ int peer_local_as_unset(struct peer *peer)

/* Send notification or stop peer depending on state. */
if (BGP_IS_VALID_STATE_FOR_NOTIF(member->connection->status))
Copy link
Member

Choose a reason for hiding this comment

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

Ditto.

bgpd/bgpd.c Outdated
@@ -5852,8 +5807,7 @@ void peer_update_source_unset(struct peer *peer)

/* Send notification or reset peer depending on state. */
if (BGP_IS_VALID_STATE_FOR_NOTIF(member->connection->status))
Copy link
Member

Choose a reason for hiding this comment

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

Ditto.

bgpd/bgpd.c Outdated
@@ -5816,8 +5772,7 @@ void peer_update_source_unset(struct peer *peer)
peer->last_reset = PEER_DOWN_UPDATE_SOURCE_CHANGE;
/* Send notification or reset peer depending on state. */
if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status))
Copy link
Member

Choose a reason for hiding this comment

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

Ditto.

bgpd/bgpd.c Outdated
@@ -5765,8 +5722,7 @@ void peer_update_source_addr_set(struct peer *peer, const union sockunion *su)

/* Send notification or reset peer depending on state. */
if (BGP_IS_VALID_STATE_FOR_NOTIF(member->connection->status))
Copy link
Member

Choose a reason for hiding this comment

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

Ditto.

bgpd/bgpd.c Outdated
@@ -5427,9 +5392,7 @@ int peer_ebgp_multihop_set(struct peer *peer, int ttl)
if (peer->sort != BGP_PEER_IBGP) {
if (BGP_IS_VALID_STATE_FOR_NOTIF(
Copy link
Member

Choose a reason for hiding this comment

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

Ditto.

@donaldsharp donaldsharp force-pushed the more_found_connection_conversion_issues branch from d1772d6 to 1bdce30 Compare November 26, 2024 14:24
bgpd/bgpd.c Outdated
bgp_notify_send(member->connection, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONFIG_CHANGE);
else
if (peer_notify_config_change(peer->connection))
Copy link
Member

Choose a reason for hiding this comment

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

!peer_notify_config_change() :)

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@donaldsharp donaldsharp force-pushed the more_found_connection_conversion_issues branch from 1bdce30 to 90f78f6 Compare November 26, 2024 14:40
Copy link
Member

@ton31337 ton31337 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Convert this function to being connection based.

Signed-off-by: Donald Sharp <[email protected]>
We have about a bajillion tests of if we can
notify the peer and then we send a config change
notification.  Let's just make a function that
does this.

Signed-off-by: Donald Sharp <[email protected]>
if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status))
        peer_notify_config_change(peer->connection);
else
        bgp_session_reset_safe(peer, &nnode);

Let's add a bool return to peer_notify_config_change of whether or
not it should call the peer session reset.  This simplifies
the code a bunch.

Signed-off-by: Donald Sharp <[email protected]>
Let's use the connection associated with the peer
instead.

Signed-off-by: Donald Sharp <[email protected]>
@donaldsharp donaldsharp force-pushed the more_found_connection_conversion_issues branch from 90f78f6 to 7bf3f53 Compare November 26, 2024 16:59
@ton31337 ton31337 merged commit 4c2f5c7 into FRRouting:master Nov 26, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants