Hello,
We don't have a command which has the same function. However, we can use other methods to achieve the same result.
The length of as-path <= 3 , it equals to the length of as-path is 0, 1, 2 or 3. So, we can use the as-path-filter to achieve it.
According to the format of as-path, there is a space character between every AS number.
So, we can use the number of spaces to judge the length of the as-path. Following is the as-path-filter example.
ip as-path-filter test permit ^$ // ^$ means the length of as-path is 0.
ip as-path-filter test permit ^[^ ]+$ // [^ ] means the string without space character, ^[^ ]+$ means there is one AS number in as-path.
ip as-path-filter test permit ^[^ ]+_[^ ]+$ // "_" can match space character, ^[^ ]+_[^ ]+$ means one space character between 2 AS number.
ip as-path-filter test permit ^[^ ]+_[^ ]+_[^ ]+$ // similar to above sentence, it means 3 AS number.
If you worry about there could be an invalid character among as-path string in exception condition and want to restrict the character strictly, you can add only valid character in the regular expression.
4 bytes as-path could have "." character in AS number. AS_Set uses {}, AS_Confed_Set uses [], AS_Confed_Sequence use (). In a regular expression, it needs to use "\" to express the bracket's character.
Then, update the as-path like the following sentences.
ip as-path-filter test2 permit ^$
ip as-path-filter test2 permit ^[0-9\.\{\}\[\]\(\)]*$
ip as-path-filter test2 permit ^[0-9\.\{\}\[\]\(\)]*_[0-9\.\{\}\[\]\(\)]*$
ip as-path-filter test2 permit ^[0-9\.\{\}\[\]\(\)]*_[0-9\.\{\}\[\]\(\)]*_[0-9\.\{\}\[\]\(\)]*$
Note:
1. For the Metacharacters supported by BGP AS_Path regular expressions, please refer to Product Document. This case will not describe them.
2. There are other methods to calculate the length of the as-path. If calculate the length of AS_Set is 1, calculate the length of AS_Confed_Set and AS_Confed_Sequence as 0, the regular expression will be very complicated, it's difficult to achieve it. So, in this case, I just calculate the quantity of AS number, do not care about another complicated method.