@@ -114,24 +114,20 @@ def check_if_link_up(self,dev):
114114
115115 def process (self ):
116116 route = CsRoute ()
117+ found_defaultroute = False
117118
118119 for dev in self .dbag :
119120 if dev == "id" :
120121 continue
121122 ip = CsIP (dev , self .config )
122123
123124 for address in self .dbag [dev ]:
124- # if(address["nw_type"]!="public"):
125- # continue
126-
127125 #check if link is up
128- if (not self .check_if_link_exists (dev )):
129- logging .info ("link %s does not exist, so not processing" % dev )
130- continue
131126 if not self .check_if_link_up (dev ):
132127 cmd = "ip link set %s up" % dev
133128 CsHelper .execute (cmd )
134129
130+ gateway = str (address ["gateway" ])
135131 network = str (address ["network" ])
136132
137133 ip .setAddress (address )
@@ -147,17 +143,25 @@ def process(self):
147143 "Address %s on device %s not configured" , ip .ip (), dev )
148144 if CsDevice (dev , self .config ).waitfordevice ():
149145 ip .configure ()
146+
150147 route .add_route (dev , network )
151148
149+ # The code looks redundant here, but we actually have to cater for routers and
150+ # VPC routers in a different manner. Please do not remove this block otherwise
151+ # The VPC default route will be broken.
152+ if address ["nw_type" ] == "public" and not found_defaultroute :
153+ if not route .defaultroute_exists ():
154+ if route .add_defaultroute (gateway ):
155+ found_defaultroute = True
156+
152157 # once we start processing public ip's we need to verify there
153158 # is a default route and add if needed
154159 if not route .defaultroute_exists ():
155- cmdline = self .config .get_cmdline_instance ()
160+ cmdline = self .config .cmdline ()
156161 if (cmdline .get_gateway ()):
157162 route .add_defaultroute (cmdline .get_gateway ())
158163
159164
160-
161165class CsInterface :
162166
163167 """ Hold one single ip """
@@ -516,9 +520,10 @@ def fw_vpcrouter(self):
516520 self .fw .append (["" , "" , "-A NETWORK_STATS -i eth2 -o eth0 -p tcp" ])
517521 self .fw .append (["" , "" , "-A NETWORK_STATS ! -i eth0 -o eth2 -p tcp" ])
518522 self .fw .append (["" , "" , "-A NETWORK_STATS -i eth2 ! -o eth0 -p tcp" ])
519-
523+
524+ self .fw .append (["filter" , "" , "-A INPUT -p icmp -j ACCEPT" ])
520525 self .fw .append (["filter" , "" , "-A INPUT -i eth0 -p tcp -m tcp --dport 3922 -m state --state NEW,ESTABLISHED -j ACCEPT" ])
521-
526+
522527 self .fw .append (["filter" , "" , "-P INPUT DROP" ])
523528 self .fw .append (["filter" , "" , "-P FORWARD DROP" ])
524529
0 commit comments