Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/ip_output.c
Show All 30 Lines | |||||
* @(#)ip_output.c 8.3 (Berkeley) 1/21/94 | * @(#)ip_output.c 8.3 (Berkeley) 1/21/94 | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include "opt_inet.h" | #include "opt_inet.h" | ||||
#include "opt_ipsec.h" | #include "opt_ipsec.h" | ||||
#include "opt_kern_tls.h" | |||||
#include "opt_mbuf_stress_test.h" | #include "opt_mbuf_stress_test.h" | ||||
#include "opt_mpath.h" | #include "opt_mpath.h" | ||||
#include "opt_ratelimit.h" | #include "opt_ratelimit.h" | ||||
#include "opt_route.h" | #include "opt_route.h" | ||||
#include "opt_rss.h" | #include "opt_rss.h" | ||||
#include "opt_sctp.h" | #include "opt_sctp.h" | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/ktls.h> | |||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/mbuf.h> | #include <sys/mbuf.h> | ||||
#include <sys/priv.h> | #include <sys/priv.h> | ||||
#include <sys/proc.h> | #include <sys/proc.h> | ||||
#include <sys/protosw.h> | #include <sys/protosw.h> | ||||
#include <sys/rmlock.h> | #include <sys/rmlock.h> | ||||
#include <sys/sdt.h> | #include <sys/sdt.h> | ||||
▲ Show 20 Lines • Show All 150 Lines • ▼ Show 20 Lines | #endif | ||||
return 0; | return 0; | ||||
} | } | ||||
static int | static int | ||||
ip_output_send(struct inpcb *inp, struct ifnet *ifp, struct mbuf *m, | ip_output_send(struct inpcb *inp, struct ifnet *ifp, struct mbuf *m, | ||||
const struct sockaddr_in *gw, struct route *ro) | const struct sockaddr_in *gw, struct route *ro) | ||||
{ | { | ||||
#ifdef KERN_TLS | |||||
struct ktls_session *tls = NULL; | |||||
#endif | |||||
struct m_snd_tag *mst; | struct m_snd_tag *mst; | ||||
int error; | int error; | ||||
MPASS((m->m_pkthdr.csum_flags & CSUM_SND_TAG) == 0); | MPASS((m->m_pkthdr.csum_flags & CSUM_SND_TAG) == 0); | ||||
mst = NULL; | mst = NULL; | ||||
#ifdef KERN_TLS | |||||
/* | |||||
* If this is an unencrypted TLS record, save a reference to | |||||
* the record. This local reference is used to call | |||||
* ktls_output_eagain after the mbuf has been freed (thus | |||||
* dropping the mbuf's reference) in if_output. | |||||
*/ | |||||
if (m->m_next != NULL && mbuf_has_tls_session(m->m_next)) { | |||||
tls = ktls_hold(m->m_next->m_ext.ext_pgs->tls); | |||||
mst = tls->snd_tag; | |||||
/* | |||||
* If a TLS session doesn't have a valid tag, it must | |||||
* have had an earlier ifp mismatch, so drop this | |||||
* packet. | |||||
*/ | |||||
if (mst == NULL) { | |||||
error = EAGAIN; | |||||
goto done; | |||||
} | |||||
} | |||||
#endif | |||||
#ifdef RATELIMIT | #ifdef RATELIMIT | ||||
if (inp != NULL) { | if (inp != NULL && mst == NULL) { | ||||
if ((inp->inp_flags2 & INP_RATE_LIMIT_CHANGED) != 0 || | if ((inp->inp_flags2 & INP_RATE_LIMIT_CHANGED) != 0 || | ||||
(inp->inp_snd_tag != NULL && | (inp->inp_snd_tag != NULL && | ||||
inp->inp_snd_tag->ifp != ifp)) | inp->inp_snd_tag->ifp != ifp)) | ||||
in_pcboutput_txrtlmt(inp, ifp, m); | in_pcboutput_txrtlmt(inp, ifp, m); | ||||
if (inp->inp_snd_tag != NULL) | if (inp->inp_snd_tag != NULL) | ||||
mst = inp->inp_snd_tag; | mst = inp->inp_snd_tag; | ||||
} | } | ||||
Show All 10 Lines | if (mst != NULL) { | ||||
m->m_pkthdr.snd_tag = m_snd_tag_ref(mst); | m->m_pkthdr.snd_tag = m_snd_tag_ref(mst); | ||||
m->m_pkthdr.csum_flags |= CSUM_SND_TAG; | m->m_pkthdr.csum_flags |= CSUM_SND_TAG; | ||||
} | } | ||||
error = (*ifp->if_output)(ifp, m, (const struct sockaddr *)gw, ro); | error = (*ifp->if_output)(ifp, m, (const struct sockaddr *)gw, ro); | ||||
done: | done: | ||||
/* Check for route change invalidating send tags. */ | /* Check for route change invalidating send tags. */ | ||||
#ifdef KERN_TLS | |||||
if (tls != NULL) { | |||||
if (error == EAGAIN) | |||||
error = ktls_output_eagain(inp, tls); | |||||
ktls_free(tls); | |||||
} | |||||
#endif | |||||
#ifdef RATELIMIT | #ifdef RATELIMIT | ||||
if (error == EAGAIN) | if (error == EAGAIN) | ||||
in_pcboutput_eagain(inp); | in_pcboutput_eagain(inp); | ||||
#endif | #endif | ||||
return (error); | return (error); | ||||
} | } | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 1,288 Lines • Show Last 20 Lines |