From 00860b2676d760ce06c2ff2f3d926fa80eee7a10 Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Tue, 6 Oct 2015 13:50:34 +0900 Subject: [PATCH] policy: fix removing community wich multiple regexp conditions Signed-off-by: FUJITA Tomonori --- policy/policy.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/policy/policy.go b/policy/policy.go index 06921eab..2a1524af 100644 --- a/policy/policy.go +++ b/policy/policy.go @@ -1089,12 +1089,16 @@ func RegexpRemoveCommunities(path *table.Path, exps []*regexp.Regexp) { newComms := make([]uint32, 0, len(comms)) for _, comm := range comms { c := fmt.Sprintf("%d:%d", comm>>16, comm&0x0000ffff) + match := false for _, exp := range exps { - if !exp.MatchString(c) { - newComms = append(newComms, comm) + if exp.MatchString(c) { + match = true break } } + if match == false { + newComms = append(newComms, comm) + } } path.SetCommunities(newComms, true) }