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

Function sopeeloff

freebsd/kern/uipc_socket.c:801–852  ·  view source on GitHub ↗

* Socket part of sctp_peeloff(). Detach a new socket from an * association. The new socket is returned with a reference. */

Source from the content-addressed store, hash-verified

799 * association. The new socket is returned with a reference.
800 */
801struct socket *
802sopeeloff(struct socket *head)
803{
804 struct socket *so;
805
806 VNET_ASSERT(head->so_vnet != NULL, ("%s:%d so_vnet is NULL, head=%p",
807 __func__, __LINE__, head));
808 so = soalloc(head->so_vnet);
809 if (so == NULL) {
810 log(LOG_DEBUG, "%s: pcb %p: New socket allocation failure: "
811 "limit reached or out of memory\n",
812 __func__, head->so_pcb);
813 return (NULL);
814 }
815 so->so_type = head->so_type;
816 so->so_options = head->so_options;
817 so->so_linger = head->so_linger;
818 so->so_state = (head->so_state & SS_NBIO) | SS_ISCONNECTED;
819 so->so_fibnum = head->so_fibnum;
820 so->so_proto = head->so_proto;
821 so->so_cred = crhold(head->so_cred);
822#ifdef MAC
823 mac_socket_newconn(head, so);
824#endif
825 knlist_init(&so->so_rdsel.si_note, so, so_rdknl_lock, so_rdknl_unlock,
826 so_rdknl_assert_lock);
827 knlist_init(&so->so_wrsel.si_note, so, so_wrknl_lock, so_wrknl_unlock,
828 so_wrknl_assert_lock);
829 VNET_SO_ASSERT(head);
830 if (soreserve(so, head->so_snd.sb_hiwat, head->so_rcv.sb_hiwat)) {
831 sodealloc(so);
832 log(LOG_DEBUG, "%s: pcb %p: soreserve() failed\n",
833 __func__, head->so_pcb);
834 return (NULL);
835 }
836 if ((*so->so_proto->pr_usrreqs->pru_attach)(so, 0, NULL)) {
837 sodealloc(so);
838 log(LOG_DEBUG, "%s: pcb %p: pru_attach() failed\n",
839 __func__, head->so_pcb);
840 return (NULL);
841 }
842 so->so_rcv.sb_lowat = head->so_rcv.sb_lowat;
843 so->so_snd.sb_lowat = head->so_snd.sb_lowat;
844 so->so_rcv.sb_timeo = head->so_rcv.sb_timeo;
845 so->so_snd.sb_timeo = head->so_snd.sb_timeo;
846 so->so_rcv.sb_flags |= head->so_rcv.sb_flags & SB_AUTOSIZE;
847 so->so_snd.sb_flags |= head->so_snd.sb_flags & SB_AUTOSIZE;
848
849 soref(so);
850
851 return (so);
852}
853#endif /* SCTP */
854
855int

Callers 1

sys_sctp_peeloffFunction · 0.85

Calls 7

soallocFunction · 0.85
mac_socket_newconnFunction · 0.85
knlist_initFunction · 0.85
soreserveFunction · 0.85
sodeallocFunction · 0.85
logFunction · 0.70
crholdFunction · 0.70

Tested by

no test coverage detected