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

pbrd: Fix PBR handling for last rule deletion #15206

Merged
merged 1 commit into from
Jan 25, 2024

Conversation

routingrocks
Copy link
Contributor

Issue:
Previously, the PBR common was updated for every rule update or deletion

example:
let say we have three rule 11, 12, 13 and if we are removing rule 12. in the current code we are making the entire map "valid" to false.

pbr-map MAP1 seq 11
match src-ip 90.1.1.2/32
set nexthop 20.1.1.2 swp1

pbr-map MAP1 seq 12
match src-ip 90.1.1.3/32
set nexthop 20.1.1.2 swp1

pbr-map MAP1 seq 13
match src-ip 90.1.1.4/32
set nexthop 20.1.1.2 swp1

no pbr-map MAP1 seq 12 ==> turns whole map valid to false.

r1(config)# end
r1# show pbr map
pbr-map MAP1 valid: no
Seq: 11 rule: 310
Installed: yes Reason: Valid
SRC IP Match: 90.1.1.2/32
nexthop 20.1.1.2 swp1
Installed: yes Tableid: 10002
Seq: 13 rule: 312
Installed: yes Reason: Valid
SRC IP Match: 90.1.1.4/32
nexthop 20.1.1.2 swp1
Installed: yes Tableid: 10004

Fix:
Now, the PBR common will only be updated when the last rule is being deleted. This change ensures that we only send a delete request to Zebra once, and only set the valid and installed flags to false when the last rule is deleted. This optimizes the handling of PBR rules and reduces unnecessary interactions with Zebra

Testing: UT in MR notes

Ticket: #

Signed-off-by: Rajesh Varatharaj [email protected]

Issue:
Previously, the PBR common was updated for every rule update or deletion

example:
let say we have three rule 11, 12, 13 and if we are removing rule 12. in the current code
we are making the entire map "valid" to false.

pbr-map MAP1 seq 11
match src-ip 90.1.1.2/32
set nexthop 20.1.1.2 swp1

pbr-map MAP1 seq 12
match src-ip 90.1.1.3/32
set nexthop 20.1.1.2 swp1

pbr-map MAP1 seq 13
match src-ip 90.1.1.4/32
set nexthop 20.1.1.2 swp1

no pbr-map MAP1 seq 12 ==> turns whole map valid to false.

r1(config)# end
r1# show pbr map
  pbr-map MAP1 valid: no
    Seq: 11 rule: 310
        Installed: yes Reason: Valid
        SRC IP Match: 90.1.1.2/32
        nexthop 20.1.1.2 swp1
          Installed: yes Tableid: 10002
    Seq: 13 rule: 312
        Installed: yes Reason: Valid
        SRC IP Match: 90.1.1.4/32
        nexthop 20.1.1.2 swp1
          Installed: yes Tableid: 10004

Fix:
Now, the PBR common will only be updated when the last rule is being deleted.
This change ensures that we only send a delete request to Zebra once, and only
set the valid and installed flags to false when the last rule is deleted.
This optimizes the handling of PBR rules and reduces unnecessary interactions with Zebra

Testing: UT in MR notes

Ticket: #
Signed-off-by: Rajesh Varatharaj <[email protected]>
@routingrocks
Copy link
Contributor Author

UT Logs:

r1(config)# pbr-map MAP1 seq 11
r1(config-pbr-map)# match src-ip 90.1.1.2/32
r1(config-pbr-map)# set nexthop 20.1.1.2 swp1
r1(config-pbr-map)# exit
r1(config)# pbr-map MAP1 seq 12
r1(config-pbr-map)# match src-ip 90.1.1.3/32
r1(config-pbr-map)# set nexthop 20.1.1.2 swp1
r1(config-pbr-map)# exit
r1(config)# pbr-map MAP1 seq 13
r1(config-pbr-map)# match src-ip 90.1.1.4/32
r1(config-pbr-map)# set nexthop 20.1.1.2 swp1
r1(config-pbr-map)# exit
r1(config)# no pbr-map MAP1 seq 12
r1(config)# end
r1# show pbr map
  pbr-map MAP1 valid: yes
    Seq: 10 rule: 309
        Installed: yes Reason: Valid
        SRC IP Match: 90.1.1.1/32
        nexthop 20.1.1.2 swp1
          Installed: yes Tableid: 10000
    Seq: 11 rule: 310
        Installed: yes Reason: Valid
        SRC IP Match: 90.1.1.2/32
        nexthop 20.1.1.2 swp1
          Installed: yes Tableid: 10002
    Seq: 13 rule: 312
        Installed: yes Reason: Valid
        SRC IP Match: 90.1.1.4/32
        nexthop 20.1.1.2 swp1
          Installed: yes Tableid: 10004
  pbr-map MAP2 valid: yes
    Seq: 20 rule: 319
        Installed: yes Reason: Valid
        SRC IP Match: 90.1.1.2/32
        nexthop 20.1.1.2 swp1
          Installed: yes Tableid: 10001

@chiragshah6 chiragshah6 self-requested a review January 23, 2024 18:05
Copy link
Member

@chiragshah6 chiragshah6 left a comment

Choose a reason for hiding this comment

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

Good finding!

@ton31337
Copy link
Member

@Mergifyio backport stable/9.1 stable/9.0 stable/8.5

Copy link

mergify bot commented Jan 23, 2024

backport stable/9.1 stable/9.0 stable/8.5

✅ Backports have been created

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

@ton31337 ton31337 merged commit 14c7797 into FRRouting:master Jan 25, 2024
11 checks passed
donaldsharp added a commit that referenced this pull request Jan 25, 2024
pbrd: Fix PBR handling for last rule deletion (backport #15206)
donaldsharp added a commit that referenced this pull request Jan 25, 2024
pbrd: Fix PBR handling for last rule deletion (backport #15206)
donaldsharp added a commit that referenced this pull request Jan 25, 2024
pbrd: Fix PBR handling for last rule deletion (backport #15206)
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