MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ktls_try_toe

Function ktls_try_toe

freebsd/kern/uipc_ktls.c:749–790  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

747
748#ifdef TCP_OFFLOAD
749static int
750ktls_try_toe(struct socket *so, struct ktls_session *tls, int direction)
751{
752 struct inpcb *inp;
753 struct tcpcb *tp;
754 int error;
755
756 inp = so->so_pcb;
757 INP_WLOCK(inp);
758 if (inp->inp_flags2 & INP_FREED) {
759 INP_WUNLOCK(inp);
760 return (ECONNRESET);
761 }
762 if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) {
763 INP_WUNLOCK(inp);
764 return (ECONNRESET);
765 }
766 if (inp->inp_socket == NULL) {
767 INP_WUNLOCK(inp);
768 return (ECONNRESET);
769 }
770 tp = intotcpcb(inp);
771 if (!(tp->t_flags & TF_TOE)) {
772 INP_WUNLOCK(inp);
773 return (EOPNOTSUPP);
774 }
775
776 error = tcp_offload_alloc_tls_session(tp, tls, direction);
777 INP_WUNLOCK(inp);
778 if (error == 0) {
779 tls->mode = TCP_TLS_MODE_TOE;
780 switch (tls->params.cipher_algorithm) {
781 case CRYPTO_AES_CBC:
782 counter_u64_add(ktls_toe_cbc, 1);
783 break;
784 case CRYPTO_AES_NIST_GCM_16:
785 counter_u64_add(ktls_toe_gcm, 1);
786 break;
787 }
788 }
789 return (error);
790}
791#endif
792
793/*

Callers 2

ktls_enable_rxFunction · 0.85
ktls_enable_txFunction · 0.85

Calls 2

counter_u64_addFunction · 0.50

Tested by

no test coverage detected