Page MenuHomeFreeBSD

D58922.id.diff
No OneTemporary

D58922.id.diff

diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c
--- a/sys/netpfil/pf/pf.c
+++ b/sys/netpfil/pf/pf.c
@@ -1988,14 +1988,14 @@
(*sk)->proto = pd->proto;
(*sk)->af = pd->af;
- *nk = pf_state_key_clone(*sk);
- if (*nk == NULL) {
- uma_zfree(V_pf_state_key_z, *sk);
- *sk = NULL;
- return (ENOMEM);
- }
-
if (pd->af != pd->naf) {
+ *nk = pf_state_key_clone(*sk);
+ if (*nk == NULL) {
+ uma_zfree(V_pf_state_key_z, *sk);
+ *sk = NULL;
+ return (ENOMEM);
+ }
+
(*sk)->port[pd->sidx] = pd->osport;
(*sk)->port[pd->didx] = pd->odport;
@@ -2033,6 +2033,8 @@
default:
(*nk)->proto = pd->proto;
}
+ } else {
+ *nk = *sk;
}
return (0);
@@ -6595,7 +6597,8 @@
}
} else {
uma_zfree(V_pf_state_key_z, ctx.sk);
- uma_zfree(V_pf_state_key_z, ctx.nk);
+ if (ctx.sk != ctx.nk)
+ uma_zfree(V_pf_state_key_z, ctx.nk);
ctx.sk = ctx.nk = NULL;
pf_udp_mapping_release(ctx.udp_mapping);
}
@@ -6622,7 +6625,8 @@
cleanup:
uma_zfree(V_pf_state_key_z, ctx.sk);
- uma_zfree(V_pf_state_key_z, ctx.nk);
+ if (ctx.sk != ctx.nk)
+ uma_zfree(V_pf_state_key_z, ctx.nk);
pf_udp_mapping_release(ctx.udp_mapping);
*reason = ctx.reason;
@@ -6958,7 +6962,8 @@
csfailed:
uma_zfree(V_pf_state_key_z, ctx->sk);
- uma_zfree(V_pf_state_key_z, ctx->nk);
+ if (ctx->sk != ctx->nk)
+ uma_zfree(V_pf_state_key_z, ctx->nk);
for (pf_sn_types_t sn_type=0; sn_type<PF_SN_MAX; sn_type++) {
if (pf_src_node_exists(&sns[sn_type], snhs[sn_type])) {
diff --git a/sys/netpfil/pf/pf_lb.c b/sys/netpfil/pf/pf_lb.c
--- a/sys/netpfil/pf/pf_lb.c
+++ b/sys/netpfil/pf/pf_lb.c
@@ -1107,6 +1107,14 @@
if (pf_state_key_setup(pd, pd->nsport, pd->ndport, &ctx->sk,
&ctx->nk))
return (PFRES_MEMORY);
+ if (ctx->sk == ctx->nk) {
+ ctx->nk = pf_state_key_clone(ctx->sk);
+ if (ctx->nk == NULL) {
+ uma_zfree(V_pf_state_key_z, ctx->sk);
+ ctx->sk = NULL;
+ return (PFRES_MEMORY);
+ }
+ }
}
switch (nat_action) {
@@ -1339,7 +1347,8 @@
reason = PFRES_MAX;
notrans:
uma_zfree(V_pf_state_key_z, ctx->nk);
- uma_zfree(V_pf_state_key_z, ctx->sk);
+ if (ctx->nk != ctx->sk)
+ uma_zfree(V_pf_state_key_z, ctx->sk);
ctx->sk = ctx->nk = NULL;
return (reason);

File Metadata

Mime Type
text/plain
Expires
Sun, Aug 23, 12:33 AM (14 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37115611
Default Alt Text
D58922.id.diff (2 KB)

Event Timeline