Deleted Added
full compact
rtsock.c (157366) rtsock.c (157370)
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 157366 2006-04-01 15:15:05Z rwatson $
30 * $FreeBSD: head/sys/net/rtsock.c 157370 2006-04-01 15:42:02Z rwatson $
31 */
32
33#include <sys/param.h>
34#include <sys/domain.h>
35#include <sys/kernel.h>
36#include <sys/jail.h>
37#include <sys/malloc.h>
38#include <sys/mbuf.h>

--- 108 unchanged lines hidden (view full) ---

147/* pru_accept is EOPNOTSUPP */
148
149static int
150rts_attach(struct socket *so, int proto, struct thread *td)
151{
152 struct rawcb *rp;
153 int s, error;
154
31 */
32
33#include <sys/param.h>
34#include <sys/domain.h>
35#include <sys/kernel.h>
36#include <sys/jail.h>
37#include <sys/malloc.h>
38#include <sys/mbuf.h>

--- 108 unchanged lines hidden (view full) ---

147/* pru_accept is EOPNOTSUPP */
148
149static int
150rts_attach(struct socket *so, int proto, struct thread *td)
151{
152 struct rawcb *rp;
153 int s, error;
154
155 if (sotorawcb(so) != NULL)
156 return EISCONN; /* XXX panic? */
155 KASSERT(so->so_pcb == NULL, ("rts_attach: so_pcb != NULL"));
156
157 /* XXX */
158 MALLOC(rp, struct rawcb *, sizeof *rp, M_PCB, M_WAITOK | M_ZERO);
159 if (rp == NULL)
160 return ENOBUFS;
161
162 /*
163 * The splnet() is necessary to block protocols from sending
164 * error notifications (like RTM_REDIRECT or RTM_LOSING) while

--- 44 unchanged lines hidden (view full) ---

209{
210
211 return (raw_usrreqs.pru_connect(so, nam, td)); /* XXX just EINVAL */
212}
213
214/* pru_connect2 is EOPNOTSUPP */
215/* pru_control is EOPNOTSUPP */
216
157 /* XXX */
158 MALLOC(rp, struct rawcb *, sizeof *rp, M_PCB, M_WAITOK | M_ZERO);
159 if (rp == NULL)
160 return ENOBUFS;
161
162 /*
163 * The splnet() is necessary to block protocols from sending
164 * error notifications (like RTM_REDIRECT or RTM_LOSING) while

--- 44 unchanged lines hidden (view full) ---

209{
210
211 return (raw_usrreqs.pru_connect(so, nam, td)); /* XXX just EINVAL */
212}
213
214/* pru_connect2 is EOPNOTSUPP */
215/* pru_control is EOPNOTSUPP */
216
217static int
217static void
218rts_detach(struct socket *so)
219{
220 struct rawcb *rp = sotorawcb(so);
218rts_detach(struct socket *so)
219{
220 struct rawcb *rp = sotorawcb(so);
221 int s, error;
222
221
223 s = splnet();
224 if (rp != NULL) {
225 RTSOCK_LOCK();
226 switch(rp->rcb_proto.sp_protocol) {
227 case AF_INET:
228 route_cb.ip_count--;
229 break;
230 case AF_INET6:
231 route_cb.ip6_count--;
232 break;
233 case AF_IPX:
234 route_cb.ipx_count--;
235 break;
236 }
237 route_cb.any_count--;
238 RTSOCK_UNLOCK();
222 KASSERT(rp != NULL, ("rts_detach: rp == NULL"));
223
224 RTSOCK_LOCK();
225 switch(rp->rcb_proto.sp_protocol) {
226 case AF_INET:
227 route_cb.ip_count--;
228 break;
229 case AF_INET6:
230 route_cb.ip6_count--;
231 break;
232 case AF_IPX:
233 route_cb.ipx_count--;
234 break;
239 }
235 }
240 error = raw_usrreqs.pru_detach(so);
241 splx(s);
242 return error;
236 route_cb.any_count--;
237 RTSOCK_UNLOCK();
238 raw_usrreqs.pru_detach(so);
243}
244
245static int
246rts_disconnect(struct socket *so)
247{
248
249 return (raw_usrreqs.pru_disconnect(so));
250}

--- 1033 unchanged lines hidden ---
239}
240
241static int
242rts_disconnect(struct socket *so)
243{
244
245 return (raw_usrreqs.pru_disconnect(so));
246}

--- 1033 unchanged lines hidden ---