NICMx / Jool

SIIT and NAT64 for Linux
GNU General Public License v2.0
326 stars 66 forks source link

iptables save problem #311

Closed fatihusta closed 4 years ago

fatihusta commented 4 years ago
[root@jool ~]# jool instance add --pool6=64:ff9a::/96 --iptables "example"
[root@jool ~]# jool instance display
+--------------------+-----------------+-----------+
|          Namespace |            Name | Framework |
+--------------------+-----------------+-----------+
|   ffffffff80e868c0 |         example |  iptables |
+--------------------+-----------------+-----------+
[root@jool ~]# iptables  -t mangle -A PREROUTING -j JOOL --instance example
[root@jool ~]# iptables-save > iptables.jool.save
[root@jool ~]# iptables-restore < iptables.jool.save 
Bad argument `example'
Error occurred at line: 14
Try `iptables-restore -h' or 'iptables-restore --help' for more information.
[root@jool ~]# cat iptables.jool.save 
# Generated by iptables-save v1.6.0 on Tue Dec 10 09:45:36 2019
....

*mangle
:PREROUTING ACCEPT [171:13511]
:INPUT ACCEPT [161:12914]
:FORWARD ACCEPT [10:597]
:OUTPUT ACCEPT [144:13647]
:POSTROUTING ACCEPT [154:14244]
-A PREROUTING -j JOOL--instance example 
COMMIT
# Completed on Tue Dec 10 09:45:36 2019

....

As you can see. JOOL and instance together.

-A PREROUTING -j JOOL--instance example

When I edit iptables.jool.save file like this.

-A PREROUTING -j JOOL --instance example

There is no problem during the restore.

[root@root ~]# vim iptables.jool.save 
[root@root ~]# iptables-restore < iptables.jool.save 
[root@root ~]# echo $?
0
fatihusta commented 4 years ago

Minor fix.

diff -aur a/src/usr/iptables/common.c b/src/usr/iptables/common.c
--- a/src/usr/iptables/common.c 2019-12-10 10:35:08.000000000 +0200
+++ b/src/usr/iptables/common.c 2019-12-10 10:35:37.000000000 +0200
@@ -88,7 +88,7 @@
 static void jool_tg_save(const void *ip, const struct xt_entry_target *target)
 {
    struct target_info *info = (struct target_info *)target->data;
-   printf("--" OPTNAME_INAME " %s ", info->iname);
+   printf(" --" OPTNAME_INAME " %s ", info->iname);
 }

 static struct xtables_target targets[] = {