| 1 |
# Even though this template understands the output from |
| 2 |
# - show ip cef [vrf NAME] [PREFIX | INTERFACE] [detail] |
| 3 |
# INDEX file forces you to use 'detail' keyword, or there |
| 4 |
# will be no match. This is done to simplify INDEX file |
| 5 |
# matching logic, otherwise matching regex is too complex. |
| 6 |
# |
| 7 |
# This template is compatible with IOS v12.x and above, |
| 8 |
# including IOS-XE. There are two versions of output |
| 9 |
# with significant differences depending on IOS version. |
| 10 |
# Template is able to recognize both versions and captures |
| 11 |
# same structured data regardless of IOS version. |
| 12 |
# |
| 13 |
Value Required PREFIX ((?:\d{1,3}\.){3}\d{1,3}\/\d{1,2}) |
| 14 |
# Nexthop and Interface are lists to support ECMP |
| 15 |
# Usually these will be single item lists |
| 16 |
# However, if there are multiple paths available |
| 17 |
# these will contain one item per route/path |
| 18 |
Value List NEXTHOP ((?:no\s)?\S+) |
| 19 |
Value List INTERFACE ([A-Za-z][A-Za-z0-9\.\/-]+) |
| 20 |
|
| 21 |
Start |
| 22 |
# >>> Parse EXCEPTIONS |
| 23 |
# CEF is not enabled |
| 24 |
^%IPv4\s+CEF\s+not\s+running$$ -> End |
| 25 |
# Invalid prefix |
| 26 |
^\s+Invalid\s+prefix/mask -> End |
| 27 |
# |
| 28 |
# >>> Parse HEADING |
| 29 |
# Ignore Junk (irrelevant output) |
| 30 |
^IP(?:v4)?\s+CEF |
| 31 |
^VRF|Adjacency |
| 32 |
^\s+\d+\s+(?:routes|instant|leaves|load|prefixes|in-place) |
| 33 |
^\s+(?:Default|Table|Database|Resolution|Non-stop|Switchover) |
| 34 |
^\s+(?:universal|refcounts) |
| 35 |
^.*?CEF\s+resets |
| 36 |
# |
| 37 |
# >>> Parse CEF ENTRIES |
| 38 |
# Entry detected, begin analysis |
| 39 |
^(?:\d{1,3}\.){3}\d{1,3}\/\d{1,2} -> Continue.Record |
| 40 |
# |
| 41 |
# >>>>>> Cisco IOS >v15.x |
| 42 |
# Extract prefix (no flags) |
| 43 |
^${PREFIX},\s+epoch |
| 44 |
# Extract nexthop for recursive entries |
| 45 |
^\s+recursive\s+via\s+${NEXTHOP} -> Recursive |
| 46 |
# Extract nexthop (receive) and interface |
| 47 |
^\s+${NEXTHOP}(?<=receive)\s+for\s+${INTERFACE} |
| 48 |
# Extract nexthop (attached) and interface |
| 49 |
^\s+${NEXTHOP}(?<=attached)\s+to\s+${INTERFACE} |
| 50 |
# Extract nexthop (drop) |
| 51 |
^\s+${NEXTHOP}(?<=drop)$$ |
| 52 |
# Extract nexthop (no route) |
| 53 |
^\s+${NEXTHOP}(?<=no route)$$ |
| 54 |
# Extract nexthop (receive) |
| 55 |
^\s+${NEXTHOP}(?<=receive)$$ |
| 56 |
# Extract nexthop (multicast) |
| 57 |
^\s+${NEXTHOP}(?<=multicast)$$ |
| 58 |
# Extract nexthop and interface |
| 59 |
^\s+nexthop\s+${NEXTHOP}\s+${INTERFACE} |
| 60 |
# |
| 61 |
# >>>>>> Cisco IOS 12.x ISR G1 (legacy CEF formatting) |
| 62 |
# Extract prefix |
| 63 |
^${PREFIX},\s+version -> Continue |
| 64 |
# Extract nexthop (receive and attached) |
| 65 |
^.*?epoch\s+\d+,.+?${NEXTHOP}(?<=receive) |
| 66 |
^.*?epoch\s+\d+,.+?${NEXTHOP}(?<=attached) |
| 67 |
^.*?epoch.*?$$ |
| 68 |
# Extract interface for glean adjacency (attached) |
| 69 |
^\s+via\s+${INTERFACE},\s+\d+\s+depend |
| 70 |
^.*?depend |
| 71 |
# Extract nexthop IP address and interface |
| 72 |
^\s+next\s+hop\s+${NEXTHOP},\s+${INTERFACE} |
| 73 |
^\s+next\s+hop |
| 74 |
# Extract nexthop (drop) |
| 75 |
^\s+valid\s+${NEXTHOP}(?<=drop)\s+adjacency$$ |
| 76 |
^\s+valid.+adjacency |
| 77 |
# |
| 78 |
# >>> Parse OTHER BODY (irrelevant output) |
| 79 |
^\s+Adj\s+source |
| 80 |
^\s+Special\s+source |
| 81 |
^\s+Interface\s+source |
| 82 |
^\s+DefNet\s+source |
| 83 |
^\s+Q[Oo]S |
| 84 |
^\s+Covered\s+dependent |
| 85 |
^\s+need\s+deagg |
| 86 |
^\s+notify\s+cover |
| 87 |
^\s+Dependent\s+covered |
| 88 |
^.*?RR\s+source |
| 89 |
^\s+(?:Net)?Flow: |
| 90 |
^\s+Interest\s+List: |
| 91 |
^\s+-\s+ |
| 92 |
^\s+BFD\s+state |
| 93 |
^\s+\d+\s+IPL\s+source |
| 94 |
^\d+\s+packets |
| 95 |
# |
| 96 |
# >>> Parse SPECIAL |
| 97 |
^\s*$$ |
| 98 |
^. -> Error |
| 99 |
|
| 100 |
Recursive |
| 101 |
# Extract interface for recursive entries |
| 102 |
^\s+attached\s+to\s+${INTERFACE} -> Start |
| 103 |
^\s*$$ |
| 104 |
^. -> Error |