| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: tp_output.c,v 1.37 2009/03/18 17:06:53 cegger Exp $ */ | | 1 | /* $NetBSD: tp_output.c,v 1.38 2009/04/16 22:22:06 elad Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1991, 1993 | | 4 | * Copyright (c) 1991, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -52,27 +52,27 @@ WHETHER IN AN ACTION OF CONTRACT, NEGLIG | | | @@ -52,27 +52,27 @@ WHETHER IN AN ACTION OF CONTRACT, NEGLIG |
52 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS | | 52 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS |
53 | SOFTWARE. | | 53 | SOFTWARE. |
54 | | | 54 | |
55 | ******************************************************************/ | | 55 | ******************************************************************/ |
56 | | | 56 | |
57 | /* | | 57 | /* |
58 | * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison | | 58 | * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison |
59 | */ | | 59 | */ |
60 | /* | | 60 | /* |
61 | * In here is tp_ctloutput(), the guy called by [sg]etsockopt(), | | 61 | * In here is tp_ctloutput(), the guy called by [sg]etsockopt(), |
62 | */ | | 62 | */ |
63 | | | 63 | |
64 | #include <sys/cdefs.h> | | 64 | #include <sys/cdefs.h> |
65 | __KERNEL_RCSID(0, "$NetBSD: tp_output.c,v 1.37 2009/03/18 17:06:53 cegger Exp $"); | | 65 | __KERNEL_RCSID(0, "$NetBSD: tp_output.c,v 1.38 2009/04/16 22:22:06 elad Exp $"); |
66 | | | 66 | |
67 | #include "opt_inet.h" | | 67 | #include "opt_inet.h" |
68 | #include "opt_iso.h" | | 68 | #include "opt_iso.h" |
69 | | | 69 | |
70 | #include <sys/param.h> | | 70 | #include <sys/param.h> |
71 | #include <sys/mbuf.h> | | 71 | #include <sys/mbuf.h> |
72 | #include <sys/systm.h> | | 72 | #include <sys/systm.h> |
73 | #include <sys/socket.h> | | 73 | #include <sys/socket.h> |
74 | #include <sys/socketvar.h> | | 74 | #include <sys/socketvar.h> |
75 | #include <sys/protosw.h> | | 75 | #include <sys/protosw.h> |
76 | #include <sys/errno.h> | | 76 | #include <sys/errno.h> |
77 | #include <sys/time.h> | | 77 | #include <sys/time.h> |
78 | #include <sys/kernel.h> | | 78 | #include <sys/kernel.h> |
| @@ -492,28 +492,29 @@ tp_ctloutput1(int cmd, struct socket *s | | | @@ -492,28 +492,29 @@ tp_ctloutput1(int cmd, struct socket *s |
492 | goto done; | | 492 | goto done; |
493 | } | | 493 | } |
494 | } | | 494 | } |
495 | value = mtod(*mp, void *); /* it's aligned, don't worry, but | | 495 | value = mtod(*mp, void *); /* it's aligned, don't worry, but |
496 | * lint complains about it */ | | 496 | * lint complains about it */ |
497 | val_len = (*mp)->m_len; | | 497 | val_len = (*mp)->m_len; |
498 | | | 498 | |
499 | switch (optname) { | | 499 | switch (optname) { |
500 | | | 500 | |
501 | case TPOPT_INTERCEPT: | | 501 | case TPOPT_INTERCEPT: |
502 | #define INA(t) (((struct inpcb *)(t->tp_npcb))->inp_laddr.s_addr) | | 502 | #define INA(t) (((struct inpcb *)(t->tp_npcb))->inp_laddr.s_addr) |
503 | #define ISOA(t) (((struct isopcb *)(t->tp_npcb))->isop_laddr->siso_addr) | | 503 | #define ISOA(t) (((struct isopcb *)(t->tp_npcb))->isop_laddr->siso_addr) |
504 | | | 504 | |
505 | if (l == 0 || (error = kauth_authorize_generic(l->l_cred, | | 505 | if (l == NULL || (error = kauth_authorize_network(l->l_cred, |
506 | KAUTH_GENERIC_ISSUSER, NULL))) { | | 506 | KAUTH_NETWORK_SOCKET, KAUTH_REQ_NETWORK_SOCKET_SETPRIV, |
| | | 507 | KAUTH_ARG(optname), NULL, NULL))) { |
507 | error = EPERM; | | 508 | error = EPERM; |
508 | } else if (cmd != PRCO_SETOPT || tpcb->tp_state != TP_CLOSED || | | 509 | } else if (cmd != PRCO_SETOPT || tpcb->tp_state != TP_CLOSED || |
509 | (tpcb->tp_flags & TPF_GENERAL_ADDR) || | | 510 | (tpcb->tp_flags & TPF_GENERAL_ADDR) || |
510 | tpcb->tp_next == 0) | | 511 | tpcb->tp_next == 0) |
511 | error = EINVAL; | | 512 | error = EINVAL; |
512 | else { | | 513 | else { |
513 | struct tp_pcb *t; | | 514 | struct tp_pcb *t; |
514 | error = EADDRINUSE; | | 515 | error = EADDRINUSE; |
515 | for (t = tp_listeners; t; t = t->tp_nextlisten) | | 516 | for (t = tp_listeners; t; t = t->tp_nextlisten) |
516 | if ((t->tp_flags & TPF_GENERAL_ADDR) == 0 && | | 517 | if ((t->tp_flags & TPF_GENERAL_ADDR) == 0 && |
517 | t->tp_domain == tpcb->tp_domain) | | 518 | t->tp_domain == tpcb->tp_domain) |
518 | switch (tpcb->tp_domain) { | | 519 | switch (tpcb->tp_domain) { |
519 | default: | | 520 | default: |