summaryrefslogtreecommitdiffstats
path: root/sys/netpfil/ipfw/ip_fw_nat.c
diff options
context:
space:
mode:
authorgjb <gjb@FreeBSD.org>2015-05-01 18:07:18 +0000
committergjb <gjb@FreeBSD.org>2015-05-01 18:07:18 +0000
commit55e5b36d38ff95ded004ed97fe9ed303abb36184 (patch)
treeca54c9ba1af0ca2eb29e395b069252993a4e1ada /sys/netpfil/ipfw/ip_fw_nat.c
parentdfb432f9b57e5f768243247ed35fbe38bb9c40f1 (diff)
parentfecee76e5a26a3b0a0cac30b34c660389e57579e (diff)
downloadFreeBSD-src-55e5b36d38ff95ded004ed97fe9ed303abb36184.zip
FreeBSD-src-55e5b36d38ff95ded004ed97fe9ed303abb36184.tar.gz
MFH: r281855-r282312
Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'sys/netpfil/ipfw/ip_fw_nat.c')
-rw-r--r--sys/netpfil/ipfw/ip_fw_nat.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/sys/netpfil/ipfw/ip_fw_nat.c b/sys/netpfil/ipfw/ip_fw_nat.c
index 201be2f..df40398 100644
--- a/sys/netpfil/ipfw/ip_fw_nat.c
+++ b/sys/netpfil/ipfw/ip_fw_nat.c
@@ -242,6 +242,8 @@ add_redir_spool_cfg(char *buf, struct cfg_nat *ptr)
}
if (r->alink[0] == NULL) {
printf("LibAliasRedirect* returned NULL\n");
+ free(r->alink, M_IPFW);
+ free(r, M_IPFW);
return (EINVAL);
}
/* LSNAT handling. */
@@ -263,6 +265,16 @@ add_redir_spool_cfg(char *buf, struct cfg_nat *ptr)
return (0);
}
+static void
+free_nat_instance(struct cfg_nat *ptr)
+{
+
+ del_redir_spool_cfg(ptr, &ptr->redir_chain);
+ LibAliasUninit(ptr->lib);
+ free(ptr, M_IPFW);
+}
+
+
/*
* ipfw_nat - perform mbuf header translation.
*
@@ -536,7 +548,7 @@ nat44_config(struct ip_fw_chain *chain, struct nat44_cfg_nat *ucfg)
IPFW_UH_WUNLOCK(chain);
if (tcfg != NULL)
- free(tcfg, M_IPFW);
+ free_nat_instance(ptr);
}
/*
@@ -626,9 +638,7 @@ nat44_destroy(struct ip_fw_chain *chain, ip_fw3_opheader *op3,
IPFW_WUNLOCK(chain);
IPFW_UH_WUNLOCK(chain);
- del_redir_spool_cfg(ptr, &ptr->redir_chain);
- LibAliasUninit(ptr->lib);
- free(ptr, M_IPFW);
+ free_nat_instance(ptr);
return (0);
}
@@ -994,9 +1004,7 @@ ipfw_nat_del(struct sockopt *sopt)
flush_nat_ptrs(chain, i);
IPFW_WUNLOCK(chain);
IPFW_UH_WUNLOCK(chain);
- del_redir_spool_cfg(ptr, &ptr->redir_chain);
- LibAliasUninit(ptr->lib);
- free(ptr, M_IPFW);
+ free_nat_instance(ptr);
return (0);
}
@@ -1139,9 +1147,7 @@ vnet_ipfw_nat_uninit(const void *arg __unused)
IPFW_WLOCK(chain);
LIST_FOREACH_SAFE(ptr, &chain->nat, _next, ptr_temp) {
LIST_REMOVE(ptr, _next);
- del_redir_spool_cfg(ptr, &ptr->redir_chain);
- LibAliasUninit(ptr->lib);
- free(ptr, M_IPFW);
+ free_nat_instance(ptr);
}
flush_nat_ptrs(chain, -1 /* flush all */);
V_ipfw_nat_ready = 0;
OpenPOWER on IntegriCloud