-/* $OpenBSD: ip_ah.c,v 1.120 2016/08/15 11:35:25 dlg Exp $ */
+/* $OpenBSD: ip_ah.c,v 1.121 2016/08/18 06:01:10 dlg Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
struct auth_hash *ahx = (struct auth_hash *) tdb->tdb_authalgxform;
struct cryptodesc *crda;
struct tdb_crypto *tc;
- struct mbuf *mo, *mi;
+ struct mbuf *mi;
struct cryptop *crp;
u_int16_t iplen;
int len, rplen;
/*
* Loop through mbuf chain; if we find a readonly mbuf,
- * replace the rest of the chain.
+ * copy the packet.
*/
- mo = NULL;
mi = m;
- while (mi != NULL && !M_READONLY(mi)) {
- mo = mi;
+ while (mi != NULL && !M_READONLY(mi))
mi = mi->m_next;
- }
if (mi != NULL) {
- /* Replace the rest of the mbuf chain. */
- struct mbuf *n = m_dup_pkt(mi, 0, M_DONTWAIT);
+ struct mbuf *n = m_dup_pkt(m, 0, M_DONTWAIT);
if (n == NULL) {
ahstat.ahs_hdrops++;
return ENOBUFS;
}
- if (mo != NULL)
- mo->m_next = n;
- else
- m = n;
-
- m_freem(mi);
+ m_freem(m);
+ m = n;
}
/* Inject AH header. */
-/* $OpenBSD: ip_esp.c,v 1.138 2016/08/15 11:35:25 dlg Exp $ */
+/* $OpenBSD: ip_esp.c,v 1.139 2016/08/18 06:01:10 dlg Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
/*
* Loop through mbuf chain; if we find a readonly mbuf,
- * replace the rest of the chain.
+ * copy the packet.
*/
- mo = NULL;
mi = m;
- while (mi != NULL && !M_READONLY(mi)) {
- mo = mi;
+ while (mi != NULL && !M_READONLY(mi))
mi = mi->m_next;
- }
if (mi != NULL) {
- /* Replace the rest of the mbuf chain. */
- struct mbuf *n = m_dup_pkt(mi, 0, M_DONTWAIT);
+ struct mbuf *n = m_dup_pkt(m, 0, M_DONTWAIT);
if (n == NULL) {
DPRINTF(("esp_output(): bad mbuf chain, SA %s/%08x\n",
return ENOBUFS;
}
- if (mo != NULL)
- mo->m_next = n;
- else
- m = n;
-
- m_freem(mi);
+ m_freem(m);
+ m = n;
}
/* Inject ESP header. */
-/* $OpenBSD: ip_ipcomp.c,v 1.45 2016/08/15 11:35:25 dlg Exp $ */
+/* $OpenBSD: ip_ipcomp.c,v 1.46 2016/08/18 06:01:10 dlg Exp $ */
/*
* Copyright (c) 2001 Jean-Jacques Bernard-Gundol (jj@wabbitt.org)
struct cryptodesc *crdc = NULL;
struct cryptop *crp;
struct tdb_crypto *tc;
- struct mbuf *mi, *mo;
+ struct mbuf *mi;
#ifdef ENCDEBUG
char buf[INET6_ADDRSTRLEN];
#endif
}
/*
* Loop through mbuf chain; if we find a readonly mbuf,
- * replace the rest of the chain.
+ * copy the packet.
*/
- mo = NULL;
mi = m;
- while (mi != NULL && !M_READONLY(mi)) {
- mo = mi;
+ while (mi != NULL && !M_READONLY(mi))
mi = mi->m_next;
- }
if (mi != NULL) {
- /* Replace the rest of the mbuf chain. */
- struct mbuf *n = m_dup_pkt(mi, 0, M_DONTWAIT);
+ struct mbuf *n = m_dup_pkt(m, 0, M_DONTWAIT);
if (n == NULL) {
DPRINTF(("ipcomp_output(): bad mbuf chain, IPCA %s/%08x\n",
m_freem(m);
return ENOBUFS;
}
- if (mo != NULL)
- mo->m_next = n;
- else
- m = n;
- m_freem(mi);
+ m_freem(m);
+ m = n;
}
/* Ok now, we can pass to the crypto processing */