batfish / batfish

Batfish is a network configuration analysis tool that can find bugs and guarantee the correctness of (planned or current) network configurations. It enables network engineers to rapidly and safely evolve their network, without fear of outages or security breaches.

Home Page:http://www.batfish.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Community List Regex : space vs underscore

rsingha108 opened this issue · comments

Describe the bug and expected behavior
I am trying to test some route-maps using the "Analyzing Routing Policies" Notebook. If we use the regex ^[0-1]:[1]+ [0-1]:[1-2]+$, it doesn't match with the community "0:1 0:12" but if we use the regex ^[0-1]:[1]+_[0-1]:[1-2]+$ (' ' replaced by '_'), it matches. Ideally the regex with ' ' should also match.

Runnable example

Configuration file in networks/route-analysis/configs/border3.cfg

!
hostname border3
!
ip community-list 100 permit ^[0-1]:[1]+ [0-1]:[1-2]+$
!
route-map Rmap permit 10
	match community 100
!
end

python code in notebooks/Analyzing Routing Policies

%run startup.py
from pybatfish.datamodel.route import BgpRouteConstraints
bf = Session(host="localhost")

# Initialize a network and snapshot
NETWORK_NAME = "example_network"
SNAPSHOT_NAME = "example_snapshot"

SNAPSHOT_PATH = "networks/route-analysis"

bf.set_network(NETWORK_NAME)
bf.init_snapshot(SNAPSHOT_PATH, name=SNAPSHOT_NAME, overwrite=True)

# Create an example route to use for testing
inRoute1 = BgpRoute(network="10.0.0.0/24", 
                    originatorIp="4.4.4.4", 
                    originType="egp", 
                    protocol="bgp",
                    communities=["0:1","0:12"])

# Test how our policy treats this route
result = bf.q.testRoutePolicies(policies="Rmap", 
                             direction="in", 
                             inputRoutes=[inRoute1]).answer().frame()
# Pretty print the result
show(result)

Additional context
The expected output is PERMIT but the output is DENY. If we change the ' ' in regex to '_' the the output is PERMIT (as expected)