diff options
Diffstat (limited to 'sys/net/raw_usrreq.c')
-rw-r--r-- | sys/net/raw_usrreq.c | 101 |
1 files changed, 30 insertions, 71 deletions
diff --git a/sys/net/raw_usrreq.c b/sys/net/raw_usrreq.c index fb5f429..47afb4f 100644 --- a/sys/net/raw_usrreq.c +++ b/sys/net/raw_usrreq.c @@ -67,8 +67,7 @@ raw_init(void) * Raw protocol interface. */ void -raw_input(struct mbuf *m0, struct sockproto *proto, struct sockaddr *src, - struct sockaddr *dst) +raw_input(struct mbuf *m0, struct sockproto *proto, struct sockaddr *src) { struct rawcb *rp; struct mbuf *m = m0; @@ -82,19 +81,6 @@ raw_input(struct mbuf *m0, struct sockproto *proto, struct sockaddr *src, if (rp->rcb_proto.sp_protocol && rp->rcb_proto.sp_protocol != proto->sp_protocol) continue; - /* - * We assume the lower level routines have placed the address - * in a canonical format suitable for a structure comparison. - * - * Note that if the lengths are not the same the comparison - * will fail at the first byte. - */ -#define equal(a1, a2) \ - (bcmp((caddr_t)(a1), (caddr_t)(a2), a1->sa_len) == 0) - if (rp->rcb_laddr && !equal(rp->rcb_laddr, dst)) - continue; - if (rp->rcb_faddr && !equal(rp->rcb_faddr, src)) - continue; if (last) { struct mbuf *n; n = m_copy(m, 0, (int)M_COPYALL); @@ -133,20 +119,18 @@ raw_ctlinput(int cmd, struct sockaddr *arg, void *dummy) static void raw_uabort(struct socket *so) { - struct rawcb *rp = sotorawcb(so); - KASSERT(rp != NULL, ("raw_uabort: rp == NULL")); - raw_disconnect(rp); + KASSERT(sotorawcb(so) != NULL, ("raw_uabort: rp == NULL")); + soisdisconnected(so); } static void raw_uclose(struct socket *so) { - struct rawcb *rp = sotorawcb(so); - KASSERT(rp != NULL, ("raw_uabort: rp == NULL")); - raw_disconnect(rp); + KASSERT(sotorawcb(so) != NULL, ("raw_uabort: rp == NULL")); + soisdisconnected(so); } @@ -159,16 +143,16 @@ raw_uattach(struct socket *so, int proto, struct thread *td) /* * Implementors of raw sockets will already have allocated the PCB, - * so it must be non-NULL here. + * so it must be non-NULL here. */ KASSERT(sotorawcb(so) != NULL, ("raw_uattach: so_pcb == NULL")); if (td != NULL) { error = priv_check(td, PRIV_NET_RAW); if (error) - return error; + return (error); } - return raw_attach(so, proto); + return (raw_attach(so, proto)); } static int @@ -194,20 +178,17 @@ raw_udetach(struct socket *so) struct rawcb *rp = sotorawcb(so); KASSERT(rp != NULL, ("raw_udetach: rp == NULL")); + raw_detach(rp); } static int raw_udisconnect(struct socket *so) { - struct rawcb *rp = sotorawcb(so); - KASSERT(rp != NULL, ("raw_udisconnect: rp == NULL")); - if (rp->rcb_faddr == 0) - return (ENOTCONN); - raw_disconnect(rp); - soisdisconnected(so); - return (0); + KASSERT(sotorawcb(so) != NULL, ("raw_udisconnect: rp == NULL")); + + return (ENOTCONN); } /* pru_listen is EOPNOTSUPP */ @@ -215,13 +196,10 @@ raw_udisconnect(struct socket *so) static int raw_upeeraddr(struct socket *so, struct sockaddr **nam) { - struct rawcb *rp = sotorawcb(so); - KASSERT(rp != NULL, ("raw_upeeraddr: rp == NULL")); - if (rp->rcb_faddr == 0) - return (ENOTCONN); - *nam = sodupsockaddr(rp->rcb_faddr, M_WAITOK); - return (0); + KASSERT(sotorawcb(so) != NULL, ("raw_upeeraddr: rp == NULL")); + + return (ENOTCONN); } /* pru_rcvd is EOPNOTSUPP */ @@ -231,38 +209,21 @@ static int raw_usend(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, struct mbuf *control, struct thread *td) { - int error; - struct rawcb *rp = sotorawcb(so); - KASSERT(rp != NULL, ("raw_usend: rp == NULL")); + KASSERT(sotorawcb(so) != NULL, ("raw_usend: rp == NULL")); - if (flags & PRUS_OOB) { - error = EOPNOTSUPP; - goto release; + if ((flags & PRUS_OOB) || (control && control->m_len)) { + /* XXXRW: Should control also be freed here? */ + if (m != NULL) + m_freem(m); + return (EOPNOTSUPP); } - if (control && control->m_len) { - error = EOPNOTSUPP; - goto release; - } - if (nam) { - if (rp->rcb_faddr) { - error = EISCONN; - goto release; - } - rp->rcb_faddr = nam; - } else if (rp->rcb_faddr == 0) { - error = ENOTCONN; - goto release; - } - error = (*so->so_proto->pr_output)(m, so); - m = NULL; - if (nam) - rp->rcb_faddr = 0; -release: - if (m != NULL) - m_freem(m); - return (error); + /* + * For historical (bad?) reasons, we effectively ignore the address + * argument to sendto(2). Perhaps we should return an error instead? + */ + return ((*so->so_proto->pr_output)(m, so)); } /* pru_sense is null */ @@ -272,6 +233,7 @@ raw_ushutdown(struct socket *so) { KASSERT(sotorawcb(so) != NULL, ("raw_ushutdown: rp == NULL")); + socantsendmore(so); return (0); } @@ -279,13 +241,10 @@ raw_ushutdown(struct socket *so) static int raw_usockaddr(struct socket *so, struct sockaddr **nam) { - struct rawcb *rp = sotorawcb(so); - KASSERT(rp != NULL, ("raw_usockaddr: rp == NULL")); - if (rp->rcb_laddr == 0) - return (EINVAL); - *nam = sodupsockaddr(rp->rcb_laddr, M_WAITOK); - return (0); + KASSERT(sotorawcb(so) != NULL, ("raw_usockaddr: rp == NULL")); + + return (EINVAL); } struct pr_usrreqs raw_usrreqs = { |