Skip to contentSkip to conversation

scripts/runqemu-ifdown: Don't treat the last iptables command as special

PATCH New Daniel Mueller 1 participant 2 messages Feb 2, 2022 – Feb 8, 2022 2 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 scripts/runqemu-ifdown: Don't treat the last iptables command as special

The runqemu-ifup script performs a bunch of setup steps that runqemu-ifdown attempts to undo later on. While a bunch of said setup operations are considered fatal should they fail, the iptables based NAT setup notably is not.
The tear down procedure in runqemu-ifdown, however, has the iptables based tear down as the last operation, with the status of it determining the overall status of the script. Hence, if this step fails, the script is considered a failure overall. That is arguably inconsistent: If the NAT setup did not succeed, the tear down cannot succeed either. To ensure similarity of the two paths, let's not treat the last iptables tear down operation any special and allow it to fail the runqemu-ifdown script, but just ignore failures.

Background: we have seen a NAT related setup problem on the ifup path (which didn't cause script failure), but then saw an issue bubbled up when this operation was meant to be undone on the ifdown path.

---
 scripts/runqemu-ifdown | 1 +
 1 file changed, 1 insertion(+)
scripts/runqemu-ifdown +1 -0
index a104c3..e0eb53 100755
@@ -64,3 +64,4 @@ n=$[ (`echo $TAP | sed 's/tap//'` * 2) + 1 ]
 dest=$[ (`echo $TAP | sed 's/tap//'` * 2) + 2 ]
 $IPTABLES -D POSTROUTING -t nat -j MASQUERADE -s 192.168.7.$n/32
 $IPTABLES -D POSTROUTING -t nat -j MASQUERADE -s 192.168.7.$dest/32
+true

--
2.34.1

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

Are there any comments on this patch?

Thanks,
Daniel

________________________________________
From: [email protected] <[email protected]> on behalf of Daniel Mueller via lists.openembedded.org <[email protected]>
Sent: Wednesday, February 2, 2022 09:18
To: [email protected]
Subject: [OE-core] [PATCH] scripts/runqemu-ifdown: Don't treat the last iptables command as special

The runqemu-ifup script performs a bunch of setup steps that runqemu-ifdown attempts to undo later on. While a bunch of said setup operations are considered fatal should they fail, the iptables based NAT setup notably is not.
The tear down procedure in runqemu-ifdown, however, has the iptables based tear down as the last operation, with the status of it determining the overall status of the script. Hence, if this step fails, the script is considered a failure overall. That is arguably inconsistent: If the NAT setup did not succeed, the tear down cannot succeed either. To ensure similarity of the two paths, let's not treat the last iptables tear down operation any special and allow it to fail the runqemu-ifdown script, but just ignore failures.

Background: we have seen a NAT related setup problem on the ifup path (which didn't cause script failure), but then saw an issue bubbled up when this operation was meant to be undone on the ifdown path.

---
 scripts/runqemu-ifdown | 1 +
 1 file changed, 1 insertion(+)
scripts/runqemu-ifdown +1 -0
index a104c3..e0eb53 100755
@@ -64,3 +64,4 @@ n=$[ (`echo $TAP | sed 's/tap//'` * 2) + 1 ]
 dest=$[ (`echo $TAP | sed 's/tap//'` * 2) + 2 ]
 $IPTABLES -D POSTROUTING -t nat -j MASQUERADE -s 192.168.7.$n/32
 $IPTABLES -D POSTROUTING -t nat -j MASQUERADE -s 192.168.7.$dest/32
+true

--
2.34.1