rtsock.c (234572) | rtsock.c (241686) |
---|---|
1/*- 2 * Copyright (c) 1988, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)rtsock.c 8.7 (Berkeley) 10/12/95 | 1/*- 2 * Copyright (c) 1988, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)rtsock.c 8.7 (Berkeley) 10/12/95 |
30 * $FreeBSD: head/sys/net/rtsock.c 234572 2012-04-22 16:13:23Z melifaro $ | 30 * $FreeBSD: head/sys/net/rtsock.c 241686 2012-10-18 13:57:24Z andre $ |
31 */ 32#include "opt_compat.h" 33#include "opt_sctp.h" 34#include "opt_mpath.h" 35#include "opt_inet.h" 36#include "opt_inet6.h" 37 38#include <sys/param.h> --- 258 unchanged lines hidden (view full) --- 297} 298 299/* pru_accept is EOPNOTSUPP */ 300 301static int 302rts_attach(struct socket *so, int proto, struct thread *td) 303{ 304 struct rawcb *rp; | 31 */ 32#include "opt_compat.h" 33#include "opt_sctp.h" 34#include "opt_mpath.h" 35#include "opt_inet.h" 36#include "opt_inet6.h" 37 38#include <sys/param.h> --- 258 unchanged lines hidden (view full) --- 297} 298 299/* pru_accept is EOPNOTSUPP */ 300 301static int 302rts_attach(struct socket *so, int proto, struct thread *td) 303{ 304 struct rawcb *rp; |
305 int s, error; | 305 int error; |
306 307 KASSERT(so->so_pcb == NULL, ("rts_attach: so_pcb != NULL")); 308 309 /* XXX */ 310 rp = malloc(sizeof *rp, M_PCB, M_WAITOK | M_ZERO); 311 if (rp == NULL) 312 return ENOBUFS; 313 | 306 307 KASSERT(so->so_pcb == NULL, ("rts_attach: so_pcb != NULL")); 308 309 /* XXX */ 310 rp = malloc(sizeof *rp, M_PCB, M_WAITOK | M_ZERO); 311 if (rp == NULL) 312 return ENOBUFS; 313 |
314 /* 315 * The splnet() is necessary to block protocols from sending 316 * error notifications (like RTM_REDIRECT or RTM_LOSING) while 317 * this PCB is extant but incompletely initialized. 318 * Probably we should try to do more of this work beforehand and 319 * eliminate the spl. 320 */ 321 s = splnet(); | |
322 so->so_pcb = (caddr_t)rp; 323 so->so_fibnum = td->td_proc->p_fibnum; 324 error = raw_attach(so, proto); 325 rp = sotorawcb(so); 326 if (error) { | 314 so->so_pcb = (caddr_t)rp; 315 so->so_fibnum = td->td_proc->p_fibnum; 316 error = raw_attach(so, proto); 317 rp = sotorawcb(so); 318 if (error) { |
327 splx(s); | |
328 so->so_pcb = NULL; 329 free(rp, M_PCB); 330 return error; 331 } 332 RTSOCK_LOCK(); 333 switch(rp->rcb_proto.sp_protocol) { 334 case AF_INET: 335 route_cb.ip_count++; --- 4 unchanged lines hidden (view full) --- 340 case AF_IPX: 341 route_cb.ipx_count++; 342 break; 343 } 344 route_cb.any_count++; 345 RTSOCK_UNLOCK(); 346 soisconnected(so); 347 so->so_options |= SO_USELOOPBACK; | 319 so->so_pcb = NULL; 320 free(rp, M_PCB); 321 return error; 322 } 323 RTSOCK_LOCK(); 324 switch(rp->rcb_proto.sp_protocol) { 325 case AF_INET: 326 route_cb.ip_count++; --- 4 unchanged lines hidden (view full) --- 331 case AF_IPX: 332 route_cb.ipx_count++; 333 break; 334 } 335 route_cb.any_count++; 336 RTSOCK_UNLOCK(); 337 soisconnected(so); 338 so->so_options |= SO_USELOOPBACK; |
348 splx(s); | |
349 return 0; 350} 351 352static int 353rts_bind(struct socket *so, struct sockaddr *nam, struct thread *td) 354{ 355 356 return (raw_usrreqs.pru_bind(so, nam, td)); /* xxx just EINVAL */ --- 1581 unchanged lines hidden --- | 339 return 0; 340} 341 342static int 343rts_bind(struct socket *so, struct sockaddr *nam, struct thread *td) 344{ 345 346 return (raw_usrreqs.pru_bind(so, nam, td)); /* xxx just EINVAL */ --- 1581 unchanged lines hidden --- |