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

BGP Labelpool : Releasing the label in labelpool when VPN session gets removed #17580

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

varuntumbe
Copy link

What is the problem ?

When we remove the BGP VPN session which had been configured using ( label vpn export auto ), corresponding label is not getting freed up in the label pool structures.

What is the Impact ?

In higher scale deployment, more we remove sessions and rollback or add new session, earlier assigned labels wont get freed up leading to label pool expansion

What is the fix ?

Fix to release the corresponding label pool using bgp_lp_release in bgp_delete flow and verifying the same using topotest

@varuntumbe varuntumbe marked this pull request as ready for review December 4, 2024 17:45
@github-actions github-actions bot added size/XL and removed size/L labels Dec 4, 2024
@mjstapp
Copy link
Contributor

mjstapp commented Dec 4, 2024

no "fix it" commits, please. to make updates or edits to a commit, please rebase and force-push. note that our CI verifies our development workflow rules about commits; please read the developer doc and update your commit to match our guidelines.

address-family ipv4 vpn
neighbor 192.168.0.2 activate
exit-address-family
!
Copy link
Member

Choose a reason for hiding this comment

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

please reformulate commit log: title + detail

topotets: add test to control release of bgp labels

@varuntumbe varuntumbe force-pushed the dev/label_pool_release_fix branch from 97e7c96 to 42e8fc4 Compare December 5, 2024 13:10
@frrbot frrbot bot added the bgp label Dec 5, 2024
@varuntumbe varuntumbe force-pushed the dev/label_pool_release_fix branch from 42e8fc4 to 1bb51d5 Compare December 5, 2024 14:29
Copy link
Contributor

@mjstapp mjstapp left a comment

Choose a reason for hiding this comment

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

and the two commits are still empty: please include a description of the changes made in each commit.


bgp_lp_release(LP_TYPE_VRF, &bgp->vpn_policy[afi], bgp->vpn_policy[afi].tovpn_label);

if (reset) {
Copy link
Contributor

Choose a reason for hiding this comment

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

don't follow this: why release a label, but leave it in tovpn_label ?

Copy link
Member

Choose a reason for hiding this comment

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

This is to avoid doing unnecessary changes because this function is reused in vty to change the allocation-mode.
This said, I think it can be acceptable to move:

                        bgp->vpn_policy[afi].tovpn_label = MPLS_LABEL_NONE;                                                                 

just after
bgp_lp_release

Copy link
Author

Choose a reason for hiding this comment

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

moved bgp->vpn_policy[afi].tovpn_label = MPLS_LABEL_NONE;

@varuntumbe varuntumbe force-pushed the dev/label_pool_release_fix branch 4 times, most recently from ffaf7ab to 88088d1 Compare December 7, 2024 16:34
tgen = get_topogen()
cmds_list = [
"ip link add vrf{} type vrf table {}",
"echo 100000 > /proc/sys/net/mpls/platform_labels",
Copy link
Contributor

Choose a reason for hiding this comment

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

please check the test lib code - I think this setup is already being done

Copy link
Author

Choose a reason for hiding this comment

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

While reproducing, I did check on couple of existing suite, but I was unable to find it, so added a new topo.

"show bgp labelpool summary json",
expected,
)
_, result = topotest.run_and_expect(test_func, None, count=10, wait=3)
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

Referred one of the new bgp topotest and added the appropriate count and wait time of 30, 1

_populate_iface()

for rname, router in router_list.items():
router.load_config(
Copy link
Contributor

Choose a reason for hiding this comment

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

new tests should use unified config please

Copy link
Author

Choose a reason for hiding this comment

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

Replacing the old cfgs with new unified config

@@ -0,0 +1,27 @@
log stdout
Copy link
Contributor

Choose a reason for hiding this comment

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

please remove this

Copy link
Author

Choose a reason for hiding this comment

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

removed

@@ -0,0 +1,21 @@
log stdout
Copy link
Contributor

Choose a reason for hiding this comment

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

remove all of these statements

Copy link
Author

Choose a reason for hiding this comment

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

removed

@@ -0,0 +1,24 @@
hostname r3
log file ldpd.log
Copy link
Contributor

Choose a reason for hiding this comment

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

remove this

Copy link
Author

Choose a reason for hiding this comment

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

removed

# test_bgp_vpnv4_ebgp.py
# Part of NetDEF Topology Tests
#
# Copyright (c) 2022 by 6WIND
Copy link
Contributor

Choose a reason for hiding this comment

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

is this the correct copyright statement?

Copy link
Author

Choose a reason for hiding this comment

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

Changed the copyright appropriately

@@ -4074,6 +4074,32 @@ void bgp_vpn_leak_export(struct bgp *from_bgp)
}
}

void bgp_vpn_release_label(struct bgp *bgp, afi_t afi, bool reset)
Copy link
Contributor

Choose a reason for hiding this comment

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

please add a comment block explaining the dual uses of this new function

Copy link
Author

Choose a reason for hiding this comment

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

Added the comment

@varuntumbe varuntumbe force-pushed the dev/label_pool_release_fix branch from 88088d1 to 202e252 Compare December 11, 2024 15:51
@github-actions github-actions bot added size/L rebase PR needs rebase and removed size/XL labels Dec 11, 2024
@varuntumbe varuntumbe force-pushed the dev/label_pool_release_fix branch from 202e252 to 3ebb795 Compare December 11, 2024 16:03
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.

Both commits are mixed together (for a topotest), please fix them properly to separate the topotest from the actual bgpd change (without fixup in the middle).


for rname, router in router_list.items():
router.load_config(
TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname))
Copy link
Member

Choose a reason for hiding this comment

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

Please use unified config (frr.conf).

Copy link
Author

Choose a reason for hiding this comment

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

Using unified config

#

"""
test_bgp_vpnv4_ebgp.py: Test the FRR BGP daemon with EBGP direct connection
Copy link
Member

Choose a reason for hiding this comment

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

Wrong

Copy link
Author

Choose a reason for hiding this comment

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

changed the file name and description

output = json.loads(
router.vtysh_cmd("show bgp labelpool summary json")
)
expected = json.loads('{"ledger":5,"inUse":5,"requests":0,"labelChunks":1,"pending":0,"reconnects":1}')
Copy link
Member

Choose a reason for hiding this comment

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

Please use Python dict directly, e.g.:

expected = {
  "ledger":5,"inUse":5,"requests":0,"labelChunks":1,"pending":0,"reconnects":1
}

Copy link
Author

Choose a reason for hiding this comment

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

replaced


# checking the initial label pool chunk's free labels
logger.info("checking the initial label pool chunk's free labels")
expected = json.loads('[{"first":80,"last":207,"size":128,"numberFree":123}]')
Copy link
Member

Choose a reason for hiding this comment

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

Ditto.

Copy link
Author

Choose a reason for hiding this comment

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

fixed

no router bgp 65500 vrf vrf2
"""
)
expected = json.loads('[{"first":80,"last":207,"size":128,"numberFree":125}]')
Copy link
Member

Choose a reason for hiding this comment

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

Ditto.

Copy link
Author

Choose a reason for hiding this comment

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

fixed

@varuntumbe varuntumbe force-pushed the dev/label_pool_release_fix branch from 3ebb795 to 42371da Compare December 12, 2024 12:44
tgen = get_topogen()
cmds_list = [
"ip link add vrf{} type vrf table {}",
"echo 100000 > /proc/sys/net/mpls/platform_labels",
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't this already in lib/topotest.py ?

Copy link
Author

Choose a reason for hiding this comment

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

Yes was able to find that cmd in topotest.py itself and removed from here

Adding the topotest which verifies whether label beloning to corresponding chunk has been released properly or not once
we remove the vpn session

Signed-off-by: Varun Hegde <[email protected]>
Releasing the vpn label from label pool chunk using bgp_lp_release routine whenever vpn session is removed.
bgp_lp_release will clear corresponding bit in the allocated map of the label pool chunk and increases nfree by 1

Signed-off-by: Philippe Guibert <[email protected]>
@varuntumbe varuntumbe force-pushed the dev/label_pool_release_fix branch from 42371da to d5c2f2d Compare December 16, 2024 15:59
Copy link
Contributor

@mjstapp mjstapp 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 to me now

Copy link
Member

@pguibert6WIND pguibert6WIND left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants