pointer is passed to the function, it will return a refcounted TDB.
The ref happens when ipsp_spd_inp() copies the pointer from
ipo->ipo_tdb. The caller of ipsp_spd_lookup() has to unref after
using it.
tested by Hrvoje Popovski; OK mvs@ tobhe@
-/* $OpenBSD: if_bridge.c,v 1.360 2021/12/01 12:51:09 bluhm Exp $ */
+/* $OpenBSD: if_bridge.c,v 1.361 2021/12/03 17:18:34 bluhm Exp $ */
/*
* Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net)
tdb->tdb_tap)) == NULL ||
pf_test(af, dir, encif, &m) != PF_PASS) {
m_freem(m);
+ tdb_unref(tdb);
return (1);
}
- if (m == NULL)
+ if (m == NULL) {
+ tdb_unref(tdb);
return (1);
- else if (af == AF_INET)
+ }
+ if (af == AF_INET)
in_proto_cksum_out(m, encif);
#ifdef INET6
else if (af == AF_INET6)
ICMP_UNREACH, ICMP_UNREACH_NEEDFRAG);
else
error = ipsp_process_packet(m, tdb, af, 0);
+ tdb_unref(tdb);
return (1);
} else
return (0);
-/* $OpenBSD: ip_output.c,v 1.376 2021/12/01 12:51:09 bluhm Exp $ */
+/* $OpenBSD: ip_output.c,v 1.377 2021/12/03 17:18:34 bluhm Exp $ */
/* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */
/*
if (ro == &iproute && ro->ro_rt)
rtfree(ro->ro_rt);
if_put(ifp);
+#ifdef IPSEC
+ tdb_unref(tdb);
+#endif /* IPSEC */
return (error);
bad:
!memcmp(&tdbi->dst, &tdb->tdb_dst,
sizeof(union sockaddr_union))) {
/* no IPsec needed */
+ tdb_unref(tdb);
*tdbout = NULL;
return 0;
}
-/* $OpenBSD: ip_spd.c,v 1.107 2021/12/01 12:51:09 bluhm Exp $ */
+/* $OpenBSD: ip_spd.c,v 1.108 2021/12/03 17:18:34 bluhm Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu)
*
justreturn:
if (tdbout != NULL) {
- if (ipo != NULL)
+ if (ipo != NULL) {
+ tdb_ref(ipo->ipo_tdb);
*tdbout = ipo->ipo_tdb;
- else
+ } else
*tdbout = NULL;
}
return 0;
-/* $OpenBSD: ip6_forward.c,v 1.103 2021/12/01 12:51:09 bluhm Exp $ */
+/* $OpenBSD: ip6_forward.c,v 1.104 2021/12/03 17:18:34 bluhm Exp $ */
/* $KAME: ip6_forward.c,v 1.75 2001/06/29 12:42:13 jinmei Exp $ */
/*
out:
rtfree(rt);
if_put(ifp);
+#ifdef IPSEC
+ tdb_unref(tdb);
+#endif /* IPSEC */
}
-/* $OpenBSD: ip6_output.c,v 1.262 2021/12/01 12:51:09 bluhm Exp $ */
+/* $OpenBSD: ip6_output.c,v 1.263 2021/12/03 17:18:34 bluhm Exp $ */
/* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */
/*
}
#ifdef IPSEC
- if (ipsec_in_use || inp) {
+ if (ipsec_in_use || inp != NULL) {
error = ip6_output_ipsec_lookup(m, inp, &tdb);
if (error) {
/*
}
#ifdef IPSEC
- if (tdb) {
+ if (tdb != NULL) {
/*
* XXX what should we do if ip6_hlim == 0 and the
* packet gets tunneled?
ip6stat_inc(ip6s_fragmented);
done:
- if_put(ifp);
if (ro == &ip6route && ro->ro_rt) {
rtfree(ro->ro_rt);
} else if (ro_pmtu == &ip6route && ro_pmtu->ro_rt) {
rtfree(ro_pmtu->ro_rt);
}
+ if_put(ifp);
+#ifdef IPSEC
+ tdb_unref(tdb);
+#endif /* IPSEC */
return (error);
freehdrs:
!memcmp(&tdbi->dst, &tdb->tdb_dst,
sizeof(union sockaddr_union))) {
/* no IPsec needed */
+ tdb_unref(tdb);
*tdbout = NULL;
return 0;
}