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

bgpd: update AS value of a hidden bgp instance #17861

Closed

Conversation

askorichenko
Copy link
Contributor

'import vrf CUSTOM' could define a hidden bgp instance with the default AS_UNSPECIFIED (i.e. = 1) value.
When a
router bgp AS vrf CUSTOM
gets configured later on, replace this AS_UNSPECIFIED setting with a requested value.

@askorichenko
Copy link
Contributor Author

Let config have

  • a custom "vrf D" defined and
  • a bgp router in that vrf that imports default vrf
frr# show run
Current configuration:
...
!
vrf D
exit-vrf
!
router bgp 65001 vrf D
 !
 address-family ipv4 unicast
  import vrf default
 exit-address-family
exit
!

This operation defines a 'hidden bgp' in the default vrf

  • it has bgp->as = AS_UNSPECIFIED (i.e = 1)
  • a flag (bgp->flags & BGP_FLAG_INSTANCE_HIDDEN) == BGP_FLAG_INSTANCE_HIDDEN

To define a real bgp router in the default vrf now, this hidden structure would be selected for update.
But bgp_create() function would miss to update "bgp->as, bgp->as_pretty" values.
The router would remain in AS = 1.

frr# conf
frr(config)# router bgp 65001 
frr(config-router)# exit
frr(config)# exit
frr#
frr#
frr# show run 
Current configuration:
...
!
vrf D
exit-vrf
!
router bgp 65001 vrf D
 !
 address-family ipv4 unicast
  import vrf default
 exit-address-family
exit
!
router bgp 1
exit

This patch of bgp_create() adds an overwrite of as, as_pretty values for a hidden bgp instance.

@github-actions github-actions bot added size/S and removed size/XS labels Jan 16, 2025
@askorichenko askorichenko marked this pull request as ready for review January 16, 2025 15:50
bgpd/bgpd.c Outdated Show resolved Hide resolved
@donaldsharp
Copy link
Member

I'd like to see a topotest for this situation... Unless @ton31337 doesn't think we need it.

@ton31337
Copy link
Member

Agree, a topotest would be great 👍

@askorichenko
Copy link
Contributor Author

Hi,
Submitted the topotest
tests: bgp routers with vrf cross import #17907

@github-actions github-actions bot added size/L and removed size/S labels Jan 23, 2025
@askorichenko askorichenko marked this pull request as ready for review February 1, 2025 01:55
@askorichenko askorichenko requested a review from ton31337 February 3, 2025 12:18
@askorichenko
Copy link
Contributor Author

The current code has

if (hidden) {
  bgp = bgp_old;
  goto peer_init;
}

The logic of this change adds setting 3 values from the function arguments

if (hidden) {
  bgp = bgp_old;
  bgp->as = *as;
  bgp->as_pretty = as_pretty;
  bgp->asnotation = asnotation;
  goto peer_init;
}

It's only written slightly different to utilize identical code for the '! hidden' case.

Please review

@askorichenko
Copy link
Contributor Author

Hello,
If the change was approved, could it get merged, please?
Thank you!

Copy link

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

@ton31337
Copy link
Member

@askorichenko could you rebase please?

'import vrf VRF' could define a hidden bgp instance with
the default AS_UNSPECIFIED (i.e. = 1) value.
When a
	router bgp AS vrf VRF
gets configured later on, replace this AS_UNSPECIFIED setting
with a requested value.

Signed-off-by: Alexander Skorichenko <[email protected]>
@askorichenko
Copy link
Contributor Author

Done

else
bgp = XCALLOC(MTYPE_BGP, sizeof(struct bgp));

bgp->as = *as;
Copy link
Contributor

Choose a reason for hiding this comment

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

You are duplicating code that are just after the peer_init label

4358f12#diff-2a485107bd513dd693e99b63de03350c46f55affadfda5082728e7060a0ce021R3479

Duplication is incorrect and it creates some memory leaks.

I have found the same issue and here is my fix. I am doing the same thing without duplicating code.
4ea376f

Copy link
Member

Choose a reason for hiding this comment

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

So, can you both combine two PRs in a single one, but have a topotest which is here?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Commit collides with

commit 2ff08af78e315c69795417d150cd23649f68c655
Author: Chirag Shah <[email protected]>
Date:   Mon Feb 10 18:56:15 2025 -0800

    bgpd: fix bgp vrf instance creation from implicit

merged 3 days ago

Here is the above patch by @chiragshah6
https://github.com/FRRouting/frr/pull/18081/files,
And that patch's code obviously zlog_debugs a null string in line 3425 of the new version of the file bgpd/bgpd.c.

Reverting to the previous version of my patch (this preserves log messaging order)

Copy link
Contributor

Choose a reason for hiding this comment

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

Feel free to provide your own patch. But use a working topotest. For example: 0b2b477

Copy link
Contributor

Choose a reason for hiding this comment

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

And that patch's code obviously zlog_debugs a null string in line 3425 of the new version of the file bgpd/bgpd.c.

the null pointer issue is fixed in #18119

@louis-6wind
Copy link
Contributor

Continuing in #18119

The pull-request fix is incorrect and the topotest even passes without the fix.

The fixes for the described issue:
9680831
9e343e3
and its topotest:

0b2b477

@louis-6wind
Copy link
Contributor

Your fix was obviously wrong and the test was not testing anything.

I am fixing your issue in #18119

If it is not fixing your issue, please open a new pull-request and we will look at it.

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.

4 participants