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

IOS XR: policy map parsing #6432

Merged
merged 7 commits into from Nov 19, 2020
Merged

IOS XR: policy map parsing #6432

merged 7 commits into from Nov 19, 2020

Conversation

ratulm
Copy link
Member

@ratulm ratulm commented Nov 17, 2020

Fixes #6348

Looks like we had copied over qos parsing from uber-cisco-parser to the xr-parser. The syntax in the two worlds appear quite different (and there were no tests for qos parsing in XR). This PR 1) adds parsing for the policy-map syntax in the issue and fleshes out the neighborhood, and 2) removes the s_policy_map_ios_inspect which doesn't appear valid for XR.

@batfish-bot
Copy link

This change is Reviewable

@codecov
Copy link

codecov bot commented Nov 17, 2020

Codecov Report

Merging #6432 (eb25d43) into master (6f5d65a) will increase coverage by 0.04%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##             master    #6432      +/-   ##
============================================
+ Coverage     73.11%   73.15%   +0.04%     
- Complexity    35305    35348      +43     
============================================
  Files          2819     2820       +1     
  Lines        142941   143066     +125     
  Branches      17214    17228      +14     
============================================
+ Hits         104509   104665     +156     
+ Misses        30168    30117      -51     
- Partials       8264     8284      +20     
Impacted Files Coverage Δ Complexity Δ
...representation/cisco_xr/CiscoXrStructureUsage.java 100.00% <ø> (ø) 3.00 <0.00> (ø)
...grammar/cisco_xr/CiscoXrControlPlaneExtractor.java 20.11% <100.00%> (+0.81%) 341.00 <7.00> (+11.00)
.../representation/cisco_xr/CiscoXrConfiguration.java 52.79% <100.00%> (+1.75%) 109.00 <0.00> (-1.00) ⬆️
.../representation/cisco_xr/CiscoXrStructureType.java 100.00% <100.00%> (ø) 3.00 <0.00> (ø)
.../representation/cisco_xr/PolicyMapClassAction.java 0.00% <0.00%> (-100.00%) 0.00% <0.00%> (-1.00%)
...g/batfish/datamodel/flow/IncomingSessionScope.java 84.61% <0.00%> (-15.39%) 7.00% <0.00%> (-1.00%)
...datamodel/routing_policy/expr/MatchProcessAsn.java 60.00% <0.00%> (-6.67%) 6.00% <0.00%> (-1.00%)
...rg/batfish/identifiers/StorageBasedIdResolver.java 85.29% <0.00%> (-5.89%) 22.00% <0.00%> (ø%)
.../org/batfish/dataplane/rib/RouteAdvertisement.java 83.67% <0.00%> (-4.09%) 18.00% <0.00%> (-1.00%)
...rc/main/java/org/batfish/datamodel/flow/Trace.java 80.64% <0.00%> (-3.23%) 13.00% <0.00%> (-1.00%)
... and 29 more

@ratulm ratulm requested a review from arifogel November 17, 2020 23:19
@ratulm ratulm marked this pull request as ready for review November 17, 2020 23:23
Copy link
Member

@arifogel arifogel left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 5 files at r1, 1 of 2 files at r2, 4 of 4 files at r3.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @ratulm)


projects/batfish/src/main/antlr4/org/batfish/grammar/cisco_xr/CiscoXr_qos.g4, line 772 at r3 (raw file):

  DEC
  (
     ACTIVATE DYNAMIC_TEMPLATE dtname = variable

These alternatives should be separate rules. The ones you ignore and/or don't flesh out can go in a null rule.
The dynamic-template one certainly should not be succeeded by null_rest_of_line based on your unit test. Separating that one out will also make the extractor cleaner, i.e. it won't have if-else-if chain based on alternative here.


projects/batfish/src/main/antlr4/org/batfish/grammar/cisco_xr/CiscoXr_qos.g4, line 871 at r3 (raw file):

   POLICY_MAP
   (
      mapname = variable NEWLINE pm_tail*

I suspect when you don't say the type there is a default type among those below.
I'd strongly prefer you make a rule for that default type that can either have or not have the declared type.
Then the rest of the ignored types can go in a much cleaner rule that doesn't have the option of no declared type.
Please split rules at first token at which decision is made.


projects/batfish/src/main/antlr4/org/batfish/grammar/cisco_xr/CiscoXr_qos.g4, line 884 at r3 (raw file):

              | REDIRECT
              | TRAFFIC
          ) mapname = variable NEWLINE pm_tail*

I am really not a fan of having a pm_tail here that aggregates the ignored lines of all the different types. This stuff is far more maintainable if you spend a little time now making separate rules for each policy-map type, each of which has its own pm_xxx_null_tail tail rules (or whatever you want to call it). Also personally i usually inline the tail rules, but I am not sure whether that is currently better or worse for recovery. I'm sure @dhalperi has an opinion on this that also hedges on legibility.


projects/batfish/src/main/antlr4/org/batfish/grammar/cisco_xr/CiscoXr_qos.g4, line 887 at r3 (raw file):

      )
   )
   pm_end_policy_map?

Is this actually optional for XR? Sure it isn't always present/absent?


projects/batfish/src/main/java/org/batfish/representation/cisco_xr/CiscoXrStructureType.java, line 24 at r3 (raw file):

  ICMP_TYPE_OBJECT_GROUP("object-group icmp-type"),
  INSPECT_CLASS_MAP("class-map type inspect"),
  INSPECT_POLICY_MAP("policy-map type inspect"),

Can you remove all the deleted structure types?


projects/batfish/src/test/resources/org/batfish/grammar/cisco_xr/testconfigs/policy-map, line 14 at r3 (raw file):

  !
  class class-default
  class type control subscriber CM do-all

No def/ref tests for this?

Copy link
Member Author

@ratulm ratulm left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @arifogel and @dhalperi)


projects/batfish/src/main/antlr4/org/batfish/grammar/cisco_xr/CiscoXr_qos.g4, line 884 at r3 (raw file):

Previously, arifogel (Ari Fogel) wrote…

I am really not a fan of having a pm_tail here that aggregates the ignored lines of all the different types. This stuff is far more maintainable if you spend a little time now making separate rules for each policy-map type, each of which has its own pm_xxx_null_tail tail rules (or whatever you want to call it). Also personally i usually inline the tail rules, but I am not sure whether that is currently better or worse for recovery. I'm sure @dhalperi has an opinion on this that also hedges on legibility.

as far as i could tell the null tail is shared. so, i left it like that but the pointer to it goes via separate types.


projects/batfish/src/main/antlr4/org/batfish/grammar/cisco_xr/CiscoXr_qos.g4, line 887 at r3 (raw file):

Previously, arifogel (Ari Fogel) wrote…

Is this actually optional for XR? Sure it isn't always present/absent?

Yes, it is optional.

Copy link
Member

@arifogel arifogel left a comment

Choose a reason for hiding this comment

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

Reviewed 7 of 7 files at r4.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

Copy link
Member

@arifogel arifogel left a comment

Choose a reason for hiding this comment

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

Lots of cruft gone. I'm sure there will be follow-on work, but :lgtm: for now.

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

Copy link
Member

@arifogel arifogel left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ratulm)


projects/batfish/src/test/resources/org/batfish/grammar/cisco_xr/testconfigs/policy-map, line 17 at r4 (raw file):

  class type control subscriber PPP do-until-success
 !
! end-policy-map

Since the end-block is omitted for the maps below, may as well not omit it here.

@ratulm ratulm merged commit 01aa593 into master Nov 19, 2020
@ratulm ratulm deleted the xr-pm branch November 19, 2020 00:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IOS-XR - policy-map not recognized properly
3 participants