You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 5ca5851
Browse filesBrowse the repository at this point in the historyBrowse files
Naredula Janardhana Reddy
committed
Bug 12808:
Summary of changes:
- Mutiple routing table for each public interface is added (previously there is only one routing table ). when the packet is send out of public interface corresponding per-interface routing table will be used. per-interface routing table will modified when ever ip/interface added/deleted.
- New parameter is added to ipassoc command to include the default gateway for every interface/ip. prevously it is using only one public interface to send out, default gateway is obtained at the boot up time.
- In the DNAT case. In the revese path(from guest vm to outside, or when DNAT packet receives from the eth0) the public ip/source ip will not be available till POSTROUTING. to overcome this, DNAT connection are marked with routing table number at the time of connection creation, in the reverse path the routing table# from DNAT connection is used to detect per-interface routing table.
Copy file name to clipboardExpand all lines: patches/systemvm/debian/config/root/ipassoc.sh
+74-2Lines changed: 74 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -134,6 +134,72 @@ convert_primary_to_32() {
134
134
done
135
135
}
136
136
137
+
remove_routing() {
138
+
local pubIp=$1
139
+
local ipNoMask=$(echo $pubIp| awk -F'/''{print $1}')
140
+
local mask=$(echo $pubIp| awk -F'/''{print $2}')
141
+
local tableNo=$(echo $ethDev| awk -F'eth''{print $2}')
142
+
143
+
local tableName="Table_$ethDev"
144
+
local ethMask=$(ip route show | grep $ethDev| grep src | awk '{print $1}')
145
+
if [ "$ethMask"!="" ]
146
+
then
147
+
# rules and routes will be deleted for the last ip of the interface.
148
+
sudo ip route delete throw $ethMask table $tableName proto static
149
+
sudo ip rule delete from $ethMask table $tableName
150
+
sudo ip rule delete fwmark $tableNo table $tableName
151
+
sudo ip route flush cache
152
+
fi
153
+
}
154
+
155
+
# copy eth0,eth1 and the current public interface
156
+
copy_routes_from_main() {
157
+
local tableName=$1
158
+
159
+
#get the network masks from the main table
160
+
local eth0Mask=$(ip route show | grep eth0 | grep src | awk '{print $1}')
161
+
local eth1Mask=$(ip route show | grep eth1 | grep src | awk '{print $1}')
162
+
local ethMask=$(ip route show | grep $ethDev| grep src | awk '{print $1}')
163
+
164
+
# eth0,eth1 and other know routes will be skipped, so as main routing table will decide the route. This will be useful if the interface is down and up.
165
+
sudo ip route add throw $eth0Mask table $tableName proto static
166
+
sudo ip route add throw $eth1Mask table $tableName proto static
167
+
sudo ip route add throw $ethMask table $tableName proto static
168
+
return 0;
169
+
}
170
+
171
+
add_routing() {
172
+
local pubIp=$1
173
+
local ipNoMask=$(echo $1| awk -F'/''{print $1}')
174
+
local mask=$(echo $1| awk -F'/''{print $2}')
175
+
176
+
local tableName="Table_$ethDev"
177
+
local tablePresent=$(grep $tableName /etc/iproute2/rt_tables)
178
+
local tableNo=$(echo $ethDev| awk -F'eth''{print $2}')
# NOTE: this entry will be deleted if the interface is down without knowing to Management server, in that case all the outside traffic will be send through main routing table or it will be the first public NIC.
190
+
sudo ip route add default via $defaultGwIP table $tableName proto static
191
+
sudo ip route flush cache
192
+
193
+
local ethMask=$(ip route show | grep $ethDev| grep src | awk '{print $1}')
194
+
local rulePresent=$(ip rule show | grep $ethMask)
195
+
if [ "$rulePresent"=="" ]
196
+
then
197
+
# rules will be added while adding the first ip of the interface
198
+
sudo ip rule add from $ethMask table $tableName
199
+
sudo ip rule add fwmark $tableNo table $tableName
200
+
fi
201
+
return 0;
202
+
}
137
203
138
204
add_nat_entry() {
139
205
local pubIp=$1
@@ -167,6 +233,7 @@ add_nat_entry() {
167
233
sudo ip link set$ethDev up
168
234
sudo arping -c 3 -I $ethDev -A -U -s $ipNoMask$ipNoMask;
0 commit comments