| 1 |
#!/bin/bash |
| 2 |
# |
| 3 |
# This script will setup network namespaces SVM1 ("service VM1") and SVM2 so that |
| 4 |
# traffic between net1 (to which VM1 is attached) and net2 (to which VM2 is attached) |
| 5 |
# goes through SMV1 and SVM2: |
| 6 |
# |
| 7 |
# VM1-------net1 SVM1 --- SVM2 net2-----VM2 |
| 8 |
# .1 11.0.0. 12.0.0 .1 |
| 9 |
# |
| 10 |
# Route targets.... |
| 11 |
# |
| 12 |
# net1: :1 |
| 13 |
# net2: :2 |
| 14 |
# |
| 15 |
# - chain for traffic from net1 to net2: |
| 16 |
# hop12_0: first hop: net1 to SVM1 |
| 17 |
# hop12_1: second hop: SVM1 to SVM2 |
| 18 |
|
| 19 |
as=64512 |
| 20 |
|
| 21 |
hop12_0=$as:120 |
| 22 |
hop12_1=$as:121 |
| 23 |
|
| 24 |
## |
| 25 |
## - chain for traffic from net2 to net1: |
| 26 |
## hop21_0: first hop: net2 to SVM2 |
| 27 |
## hop21_1: second hop: SVM2 to SVM1 |
| 28 |
|
| 29 |
hop21_0=$as:210 |
| 30 |
hop21_1=$as:211 |
| 31 |
|
| 32 |
|
| 33 |
source $(dirname $0)/generic-functions |
| 34 |
|
| 35 |
clean_start |
| 36 |
|
| 37 |
clean_netns_all net1vm1 svm1 svm2 net2vm2 |
| 38 |
|
| 39 |
|
| 40 |
## |
| 41 |
## VM1: sur A |
| 42 |
## |
| 43 |
|
| 44 |
r_a bagpipe-rest-attach --attach --port netns:to-vm1 --network-type ipvpn --vpn-instance-id net1vm1 --ip 11.0.0.1 --rt $as:1 --import-rt $hop12_0 |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
## SVM1: sur B |
| 49 |
## |
| 50 |
## [vrf:x1][if:to-svm1-x1]---[x1][netns:svm1][h0]---[to-svm1-h0][vrf:h01] |
| 51 |
## |
| 52 |
## |
| 53 |
## x1:100.0.0.0/24 |
| 54 |
## h01:30.0.0.0/24 |
| 55 |
## h02:40.0.0.0/24 |
| 56 |
## x2:200.0.0.0/24 |
| 57 |
|
| 58 |
## attach x1: |
| 59 |
|
| 60 |
r_b bagpipe-rest-attach --attach --port netns:to-svm1-x1 --network-type ipvpn --vpn-instance-id x1 --ip 100.0.0.1/24 --netns svm1 --if2vpn x1 \ |
| 61 |
--import $as:1 \ |
| 62 |
--readv-from-rt $hop12_1 --readv-to-rt $hop12_0 |
| 63 |
|
| 64 |
## attach h0: |
| 65 |
|
| 66 |
r_b bagpipe-rest-attach --attach --port netns:to-svm1-h0 --network-type ipvpn --vpn-instance-id h01 --ip 30.0.0.1/24 --netns svm1 --if2vpn h0 \ |
| 67 |
--import-rt $hop12_1 \ |
| 68 |
--readv-from-rt $as:1 --readv-to-rt $hop21_1 |
| 69 |
|
| 70 |
r_b ./setup-cross-routing svm1 x1 100.0.0.254 h0 30.0.0.254 |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
## SVM2: sur A |
| 75 |
# |
| 76 |
# [vrf:h02][to-svm2-h0]---[h0][netns:svm2][x2]---[if:to-svm2-x2][vrf:x2] |
| 77 |
|
| 78 |
## attach h0: |
| 79 |
|
| 80 |
r_a bagpipe-rest-attach --attach --port netns:to-svm2-h0 --network-type ipvpn --vpn-instance-id h02 --ip 40.0.0.1/24 --netns svm2 --if2vpn h0 \ |
| 81 |
--import-rt $hop21_1 \ |
| 82 |
--readv-from-rt $as:2 --readv-to-rt $hop12_1 |
| 83 |
|
| 84 |
## attach x2: |
| 85 |
r_a bagpipe-rest-attach --attach --port netns:to-svm2-x2 --network-type ipvpn --vpn-instance-id x2 --ip 200.0.0.1/24 --netns svm2 --if2vpn x2 \ |
| 86 |
--import $as:2 \ |
| 87 |
--readv-from-rt $hop21_1 --readv-to-rt $hop21_0 |
| 88 |
|
| 89 |
r_a ./setup-cross-routing svm2 x2 200.0.0.254 h0 40.0.0.254 |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
## VM2: sur B |
| 94 |
## |
| 95 |
|
| 96 |
r_b bagpipe-rest-attach --attach --port netns:to-vm2 --network-type ipvpn --vpn-instance-id net2vm2 --ip 12.0.0.1 --rt $as:2 --import-rt $hop21_0 |
| 97 |
|
| 98 |
# |
| 99 |
# Test |
| 100 |
# |
| 101 |
|
| 102 |
wait_ready |
| 103 |
|
| 104 |
r_a ip netns exec net1vm1 ping 12.0.0.1 -c 3 |
| 105 |
|
| 106 |
|
| 107 |
r_a bagpipe-looking-glass vpns instances net1vm1 dataplane flows |
| 108 |
r_b bagpipe-looking-glass vpns instances x1 dataplane flows |
| 109 |
r_b bagpipe-looking-glass vpns instances h01 dataplane flows |
| 110 |
r_a bagpipe-looking-glass vpns instances h02 dataplane flows |
| 111 |
r_a bagpipe-looking-glass vpns instances x2 dataplane flows |
| 112 |
r_b bagpipe-looking-glass vpns instances net2vm2 dataplane flows |
| 113 |
|
| 114 |
r_both bagpipe-looking-glass logs |
| 115 |
|
| 116 |
clean_stop |
| 117 |
|