diff --git a/etc/exabgp/api-flow-merge.conf b/etc/exabgp/api-flow-merge.conf new file mode 100644 index 000000000..e62815c2c --- /dev/null +++ b/etc/exabgp/api-flow-merge.conf @@ -0,0 +1,43 @@ +process announce-routes { + run ./run/api-flow-merge.run; + encoder json; +} + +neighbor 127.0.0.1 { + router-id 1.2.3.4; + local-address 127.0.0.1; + local-as 1; + peer-as 1; + group-updates false; + + family { + ipv4 flow; + } + api { + processes [ announce-routes ]; + } + flow { + route one { + match { + source 202.255.238.1/32; + } + scope { + interface-set [ non-transitive:input:3405770241:1 ]; + } + then { + discard; + } + } + route two { + match { + source 202.255.238.1/32; + } + scope { + interface-set [ non-transitive:input:3405770241:1 transitive:output:254:254 ]; + } + then { + discard; + } + } + } +} diff --git a/etc/exabgp/run/api-flow-merge.run b/etc/exabgp/run/api-flow-merge.run new file mode 100755 index 000000000..cdee11eb7 --- /dev/null +++ b/etc/exabgp/run/api-flow-merge.run @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 + +import os +import sys +import time + +time.sleep(2) # let the EOR pass + + +messages = [ + 'announce flow route { match { source 0.0.0.0/32; } then { rate-limit 0; } }', + 'announce flow route { match { source 1.1.1.1/32; } then { discard; } }', + 'announce flow route { match { source 2.2.2.2/32; } scope { interface-set [ non-transitive:input:3405770241:1 ]; } then { discard; } }', + 'announce flow route { match { source 2.2.2.2/32; } scope { interface-set [ non-transitive:input:3405770241:1 transitive:output:254:254 ]; } then { discard; } }', +] + +while messages: + message = messages.pop(0) + try: + sys.stdout.write(message + '\n') + sys.stdout.flush() + except IOError: + sys.stderr.write('IOError - ExaBGP exited ? ') + sys.stderr.write('Could not write message: %s\n' % message) + sys.stderr.flush() + +try: + now = time.time() + while os.getppid() != 1 and time.time() < now + 1: + line = sys.stdin.readline().strip() + if not line or 'shutdown' in line: + break + time.sleep(0.5) +except IOError: + pass diff --git a/qa/encoding/api-flow-merge.ci b/qa/encoding/api-flow-merge.ci new file mode 100644 index 000000000..7c387681e --- /dev/null +++ b/qa/encoding/api-flow-merge.ci @@ -0,0 +1 @@ +api-flow-merge.conf diff --git a/qa/encoding/api-flow-merge.msg b/qa/encoding/api-flow-merge.msg new file mode 100644 index 000000000..fc4bdfb1a --- /dev/null +++ b/qa/encoding/api-flow-merge.msg @@ -0,0 +1,10 @@ + +1:raw:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF:0047:02:000000304001010040020040050400000064C010104702CAFFEE0140018006000000000000800E0C0001850000060220CAFFEE01 +1:raw:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF:004F:02:000000384001010040020040050400000064C010184702CAFFEE0140010702000000FE80FE8006000000000000800E0C0001850000060220CAFFEE01 + +1:raw:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF:001E:02:00000007900F0003000185 + +2:raw:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF:003F:02:000000284001010040020040050400000064C010088006000000000000800E0C000185000006022000000000 +3:raw:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF:003F:02:000000284001010040020040050400000064C010088006000000000000800E0C000185000006022001010101 +4:raw:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF:0047:02:000000304001010040020040050400000064C010104702CAFFEE0140018006000000000000800E0C000185000006022002020202 +5:raw:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF:004F:02:000000384001010040020040050400000064C010184702CAFFEE0140010702000000FE80FE8006000000000000800E0C000185000006022002020202