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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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.

'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.

Signed-off-by: Alexander Skorichenko <askorichenko@netgate.com>
@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
bgp->as = *as;
if (as_pretty)
bgp->as_pretty = XSTRDUP(MTYPE_BGP_NAME, as_pretty);
else
bgp->as_pretty = XSTRDUP(MTYPE_BGP_NAME, asn_asn2asplain(*as));

if (hidden)
goto peer_init;
Copy link
Member

Choose a reason for hiding this comment

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

Here we don't have bgp->peer allocated, and bgp->peer->cmp = (int (*)(void *, void *))peer_cmp; will segfault after goto peer_init;.

Also, we should respect AS notation...

@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 👍

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