File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -264,6 +264,20 @@ void NatMgr::cleanupPoolIpTable(void)
264264 }
265265}
266266
267+ /* This is ideally called on docker stop */
268+ void NatMgr::cleanupMangleIpTables (void )
269+ {
270+ SWSS_LOG_INFO (" Cleaning the Mangle IpTables" );
271+ for (auto it = m_natZoneInterfaceInfo.begin (); it != m_natZoneInterfaceInfo.end (); it++)
272+ {
273+ /* Delete the mangle iptables rules for non-loopback interface */
274+ if (strncmp ((*it).first .c_str (), LOOPBACK_PREFIX, strlen (LOOPBACK_PREFIX)))
275+ {
276+ setMangleIptablesRules (DELETE, (*it).first , (*it).second );
277+ }
278+ }
279+ }
280+
267281/* To Add/Delete NAPT pool ip table to APPL_DB */
268282void NatMgr::setNaptPoolIpTable (const string &opCmd, const string &ip_range, const string &port_range)
269283{
Original file line number Diff line number Diff line change @@ -231,7 +231,8 @@ class NatMgr : public Orch
231231 using Orch::doTask;
232232
233233 /* Function to be called from signal handler on nat docker stop */
234- void cleanupPoolIpTable (void );
234+ void cleanupPoolIpTable ();
235+ void cleanupMangleIpTables ();
235236 bool isPortInitDone (DBConnector *app_db);
236237
237238private:
Original file line number Diff line number Diff line change @@ -62,7 +62,6 @@ void sigterm_handler(int signo)
6262 int ret = 0 ;
6363 std::string res;
6464 const std::string iptablesFlushNat = " iptables -t nat -F" ;
65- const std::string iptablesFlushMangle = " iptables -t mangle -F" ;
6665 const std::string conntrackFlush = " conntrack -F" ;
6766
6867 SWSS_LOG_NOTICE (" Got SIGTERM" );
@@ -73,11 +72,6 @@ void sigterm_handler(int signo)
7372 {
7473 SWSS_LOG_ERROR (" Command '%s' failed with rc %d" , iptablesFlushNat.c_str (), ret);
7574 }
76- ret = swss::exec (iptablesFlushMangle, res);
77- if (ret)
78- {
79- SWSS_LOG_ERROR (" Command '%s' failed with rc %d" , iptablesFlushMangle.c_str (), ret);
80- }
8175 ret = swss::exec (conntrackFlush, res);
8276 if (ret)
8377 {
@@ -96,6 +90,7 @@ void sigterm_handler(int signo)
9690
9791 if (natmgr)
9892 {
93+ natmgr->cleanupMangleIpTables ();
9994 natmgr->cleanupPoolIpTable ();
10095 }
10196}
You can’t perform that action at this time.
0 commit comments