sk2/autonetkit — Issue #181: communities get messed up when using library.txt 
Author: coaj
Created: 2012-01-23 07:10:16+00:00
State: open

my library.txt:

"""
define gao_rexford ( me, custs , peers , upstream ):
custs ->ingress me: (addTag mytagcust)
peers ->ingress me: (addTag mytagpeers)
upstream ->ingress me: (addTag mytagup)
me egress-> peers: ( if tag = mytagpeers then reject route)
me egress-> peers: ( if tag = mytagup then reject route)
me egress-> upstream: ( if tag = mytagup then reject route)
me egress-> upstream: ( if tag = mytagpeers then reject route)

"""

my policy.txt:

"""
importLibrary library.txt
me = {AS1}
peers = {AS2}
custs = {AS4}
upstream = {AS3}
apply gao_rexford(me,peers,custs,upstream)

"""

resulting policies of router "me" (AS1):

"""

ip bgp-community new-format
ip community-list standard fn_gao_rexford_mytagcust permit 1234:30
ip community-list standard fn_gao_rexford_mytagpeers permit 1234:10
ip community-list standard fn_gao_rexford_mytagup permit 1234:20
!
!
route-map rm_2_AS2_in permit 10
set community 1234:30 additive <<<--------this should be 1234:10 since it's peer (fn_gao_rexford_mytagpeers)
add route-map rm_2_AS2_in permit 20
!
route-map rm_3_AS3_in permit 10
set community 1234:20 additive
add route-map rm_3_AS3_in permit 20
!
route-map rm_3_AS3_out deny 10
match community fn_gao_rexford_mytagup
continue
route-map rm_3_AS3_out deny 20
match community fn_gao_rexford_mytagpeers
add route-map rm_3_AS3_out permit 30
!
route-map rm_4_AS4_in permit 10
set community 1234:10 additive <<<----------------- should be 1234:30 (fn_gao_rexford_mytagcust)
add route-map rm_4_AS4_in permit 20
!
route-map rm_4_AS4_out deny 10 <<<--------------this is peer policy, applied to the customer
match community fn_gao_rexford_mytagpeers
continue
route-map rm_4_AS4_out deny 20
match community fn_gao_rexford_mytagup
add route-map rm_4_AS4_out permit 30
!

"""

summary - peers and customers policies switched in places.