PERFORCE change 16141 for review
Robert Watson
rwatson at freebsd.org
Sat Aug 17 02:51:39 GMT 2002
http://people.freebsd.org/~peter/p4db/chv.cgi?CH=16141
Change 16141 by rwatson at rwatson_tislabs on 2002/08/16 19:51:16
IFC TrustedBSD base to TrustedBSD MAC branch. Trickle back in the
fo_ioctl() commit to the main tree.
Affected files ...
.. //depot/projects/trustedbsd/mac/sys/cam/scsi/scsi_da.c#12 integrate
.. //depot/projects/trustedbsd/mac/sys/compat/linux/linux_file.c#14 integrate
.. //depot/projects/trustedbsd/mac/sys/compat/linux/linux_ioctl.c#10 integrate
.. //depot/projects/trustedbsd/mac/sys/compat/svr4/svr4_fcntl.c#11 integrate
.. //depot/projects/trustedbsd/mac/sys/compat/svr4/svr4_filio.c#6 integrate
.. //depot/projects/trustedbsd/mac/sys/compat/svr4/svr4_sockio.c#4 integrate
.. //depot/projects/trustedbsd/mac/sys/compat/svr4/svr4_stream.c#7 integrate
.. //depot/projects/trustedbsd/mac/sys/compat/svr4/svr4_termios.c#4 integrate
.. //depot/projects/trustedbsd/mac/sys/compat/svr4/svr4_ttold.c#4 integrate
.. //depot/projects/trustedbsd/mac/sys/dev/aac/aac.c#9 integrate
.. //depot/projects/trustedbsd/mac/sys/dev/drm/drm_drv.h#5 integrate
.. //depot/projects/trustedbsd/mac/sys/dev/mii/mii.c#7 integrate
.. //depot/projects/trustedbsd/mac/sys/dev/tdfx/tdfx_pci.c#5 integrate
.. //depot/projects/trustedbsd/mac/sys/fs/fifofs/fifo_vnops.c#13 integrate
.. //depot/projects/trustedbsd/mac/sys/i386/ibcs2/ibcs2_fcntl.c#5 integrate
.. //depot/projects/trustedbsd/mac/sys/i386/ibcs2/ibcs2_ioctl.c#7 integrate
.. //depot/projects/trustedbsd/mac/sys/kern/kern_descrip.c#29 integrate
.. //depot/projects/trustedbsd/mac/sys/kern/kern_event.c#13 integrate
.. //depot/projects/trustedbsd/mac/sys/kern/sys_generic.c#15 integrate
.. //depot/projects/trustedbsd/mac/sys/kern/sys_pipe.c#27 integrate
.. //depot/projects/trustedbsd/mac/sys/kern/sys_socket.c#13 integrate
.. //depot/projects/trustedbsd/mac/sys/kern/vfs_vnops.c#52 integrate
.. //depot/projects/trustedbsd/mac/sys/netinet/tcp_input.c#22 integrate
.. //depot/projects/trustedbsd/mac/sys/pci/if_ste.c#8 integrate
.. //depot/projects/trustedbsd/mac/sys/sys/file.h#13 integrate
.. //depot/projects/trustedbsd/mac/sys/sys/socketvar.h#25 integrate
Differences ...
==== //depot/projects/trustedbsd/mac/sys/cam/scsi/scsi_da.c#12 (text+ko) ====
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/cam/scsi/scsi_da.c,v 1.105 2002/08/15 20:54:02 njl Exp $
+ * $FreeBSD: src/sys/cam/scsi/scsi_da.c,v 1.106 2002/08/16 22:05:19 njl Exp $
*/
#ifdef _KERNEL
@@ -1284,40 +1284,43 @@
struct scsi_rw_6 cmd6;
struct scsi_rw_10 *cmd10;
struct da_softc *softc;
- struct ccb_scsiio *csio;
- u_int8_t opcode;
+ u_int8_t *cdb;
+ int frozen;
- csio = &ccb->csio;
- opcode = ((struct scsi_rw_6 *)csio->cdb_io.cdb_bytes)->opcode;
+ cdb = ccb->csio.cdb_io.cdb_bytes;
- if (opcode != READ_6 && opcode != WRITE_6)
+ /* Translation only possible if CDB is an array and cmd is R/W6 */
+ if ((ccb->ccb_h.flags & CAM_CDB_POINTER) != 0 ||
+ (*cdb != READ_6 && *cdb != WRITE_6))
return 0;
xpt_print_path(ccb->ccb_h.path);
- printf("READ(6)/WRITE(6) failed, "
- "minimum_cmd_size is increased to 10.\n");
+ printf("READ(6)/WRITE(6) not supported, "
+ "increasing minimum_cmd_size to 10.\n");
softc = (struct da_softc *)xpt_path_periph(ccb->ccb_h.path)->softc;
softc->minimum_cmd_size = 10;
- bcopy(&csio->cdb_io.cdb_bytes, &cmd6, sizeof(struct scsi_rw_6));
- cmd10 = (struct scsi_rw_10 *) &csio->cdb_io.cdb_bytes;
+ bcopy(cdb, &cmd6, sizeof(struct scsi_rw_6));
+ cmd10 = (struct scsi_rw_10 *)cdb;
cmd10->opcode = (cmd6.opcode == READ_6) ? READ_10 : WRITE_10;
cmd10->byte2 = 0;
scsi_ulto4b(scsi_3btoul(cmd6.addr), cmd10->addr);
cmd10->reserved = 0;
scsi_ulto2b(cmd6.length, cmd10->length);
cmd10->control = cmd6.control;
- csio->cdb_len = sizeof(*cmd10);
+ ccb->csio.cdb_len = sizeof(*cmd10);
- /* requeue */
+ /* Requeue request, unfreezing queue if necessary */
+ frozen = (ccb->ccb_h.status & CAM_DEV_QFRZN) != 0;
ccb->ccb_h.status = CAM_REQUEUE_REQ;
xpt_action(ccb);
- if ((ccb->ccb_h.status & CAM_DEV_QFRZN) != 0)
+ if (frozen) {
cam_release_devq(ccb->ccb_h.path,
/*relsim_flags*/0,
/*reduction*/0,
/*timeout*/0,
/*getcount_only*/0);
+ }
return (ERESTART);
}
@@ -1595,14 +1598,14 @@
*/
error = 0;
if ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_SCSI_STATUS_ERROR
- && ccb->csio.scsi_status == SCSI_STATUS_CHECK_COND) {
+ && ccb->csio.scsi_status == SCSI_STATUS_CHECK_COND) {
scsi_extract_sense(&ccb->csio.sense_data,
- &error_code, &sense_key, &asc, &ascq);
+ &error_code, &sense_key, &asc, &ascq);
if (sense_key == SSD_KEY_ILLEGAL_REQUEST)
error = cmd6workaround(ccb);
}
if (error == ERESTART)
- return ERESTART;
+ return (ERESTART);
/*
* XXX
==== //depot/projects/trustedbsd/mac/sys/compat/linux/linux_file.c#14 (text+ko) ====
@@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/sys/compat/linux/linux_file.c,v 1.68 2002/08/12 01:18:33 rwatson Exp $
+ * $FreeBSD: src/sys/compat/linux/linux_file.c,v 1.69 2002/08/17 02:36:14 rwatson Exp $
*/
#include "opt_compat.h"
==== //depot/projects/trustedbsd/mac/sys/compat/linux/linux_ioctl.c#10 (text+ko) ====
@@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/sys/compat/linux/linux_ioctl.c,v 1.86 2002/06/26 15:53:11 arr Exp $
+ * $FreeBSD: src/sys/compat/linux/linux_ioctl.c,v 1.87 2002/08/17 02:36:14 rwatson Exp $
*/
#include <sys/param.h>
@@ -1438,7 +1438,8 @@
error = linux_to_bsd_dvd_authinfo(&lda, &bcode, &bda);
if (error)
break;
- error = fo_ioctl(fp, bcode, (caddr_t)&bda, td->td_ucred, td);
+ error = fo_ioctl(fp, bcode, (caddr_t)&bda, td->td_ucred,
+ td);
if (error) {
if (lda.type == LINUX_DVD_HOST_SEND_KEY2) {
lda.type = LINUX_DVD_AUTH_FAILURE;
==== //depot/projects/trustedbsd/mac/sys/compat/svr4/svr4_fcntl.c#11 (text+ko) ====
@@ -28,7 +28,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/sys/compat/svr4/svr4_fcntl.c,v 1.24 2002/08/12 01:42:21 rwatson Exp $
+ * $FreeBSD: src/sys/compat/svr4/svr4_fcntl.c,v 1.25 2002/08/17 02:36:15 rwatson Exp $
*/
#include "opt_mac.h"
==== //depot/projects/trustedbsd/mac/sys/compat/svr4/svr4_filio.c#6 (text+ko) ====
@@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/sys/compat/svr4/svr4_filio.c,v 1.15 2002/05/31 11:52:29 tanimura Exp $
+ * $FreeBSD: src/sys/compat/svr4/svr4_filio.c,v 1.16 2002/08/17 02:36:15 rwatson Exp $
*/
#include <sys/param.h>
==== //depot/projects/trustedbsd/mac/sys/compat/svr4/svr4_sockio.c#4 (text+ko) ====
@@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/sys/compat/svr4/svr4_sockio.c,v 1.11 2002/03/20 05:41:38 alfred Exp $
+ * $FreeBSD: src/sys/compat/svr4/svr4_sockio.c,v 1.12 2002/08/17 02:36:15 rwatson Exp $
*/
#include <sys/param.h>
@@ -149,8 +149,9 @@
sizeof(struct ifreq), sizeof(struct svr4_ifreq),
sc.svr4_ifc_len));
- if ((error = fo_ioctl(fp, OSIOCGIFCONF, (caddr_t) &sc,
- td->td_ucred, td)) != 0)
+ if ((error = fo_ioctl(fp, OSIOCGIFCONF,
+ (caddr_t) &sc, td->td_ucred,
+ td)) != 0)
return error;
DPRINTF(("SIOCGIFCONF\n"));
==== //depot/projects/trustedbsd/mac/sys/compat/svr4/svr4_stream.c#7 (text+ko) ====
@@ -27,7 +27,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/sys/compat/svr4/svr4_stream.c,v 1.30 2002/06/11 21:14:02 alfred Exp $
+ * $FreeBSD: src/sys/compat/svr4/svr4_stream.c,v 1.31 2002/08/17 02:36:15 rwatson Exp $
*/
/*
==== //depot/projects/trustedbsd/mac/sys/compat/svr4/svr4_termios.c#4 (text+ko) ====
@@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/sys/compat/svr4/svr4_termios.c,v 1.9 2002/03/20 05:41:38 alfred Exp $
+ * $FreeBSD: src/sys/compat/svr4/svr4_termios.c,v 1.10 2002/08/17 02:36:15 rwatson Exp $
*/
#include <sys/param.h>
==== //depot/projects/trustedbsd/mac/sys/compat/svr4/svr4_ttold.c#4 (text+ko) ====
@@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/sys/compat/svr4/svr4_ttold.c,v 1.10 2002/03/20 05:41:38 alfred Exp $
+ * $FreeBSD: src/sys/compat/svr4/svr4_ttold.c,v 1.11 2002/08/17 02:36:15 rwatson Exp $
*/
#include <sys/param.h>
@@ -194,7 +194,7 @@
if ((error = fo_ioctl(fp, TIOCGPGRP, (caddr_t) &pid,
td->td_ucred, td)) != 0)
- return error;
+ return error;
DPRINTF(("TIOCGPGRP %d\n", pid));
@@ -264,8 +264,8 @@
print_svr4_sgttyb("SVR4_TIOCSET{P,N}", &ss);
#endif /* DEBUG_SVR4 */
cmd = (cmd == SVR4_TIOCSETP) ? TIOCSETP : TIOCSETN;
- return fo_ioctl(fp, cmd, (caddr_t) &bs, td->td_ucred,
- td);
+ return fo_ioctl(fp, cmd, (caddr_t) &bs,
+ td->td_ucred, td);
}
case SVR4_TIOCGETC:
==== //depot/projects/trustedbsd/mac/sys/dev/aac/aac.c#9 (text+ko) ====
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/dev/aac/aac.c,v 1.39 2002/05/03 00:07:50 scottl Exp $
+ * $FreeBSD: src/sys/dev/aac/aac.c,v 1.40 2002/08/17 02:36:15 rwatson Exp $
*/
/*
==== //depot/projects/trustedbsd/mac/sys/dev/drm/drm_drv.h#5 (text+ko) ====
@@ -28,7 +28,7 @@
* Rickard E. (Rik) Faith <faith at valinux.com>
* Gareth Hughes <gareth at valinux.com>
*
- * $FreeBSD: src/sys/dev/drm/drm_drv.h,v 1.4 2002/05/06 19:31:27 alfred Exp $
+ * $FreeBSD: src/sys/dev/drm/drm_drv.h,v 1.5 2002/08/17 02:36:15 rwatson Exp $
*/
/*
==== //depot/projects/trustedbsd/mac/sys/dev/mii/mii.c#7 (text+ko) ====
@@ -62,7 +62,7 @@
#if !defined(lint)
static const char rcsid[] =
- "$FreeBSD: src/sys/dev/mii/mii.c,v 1.13 2002/08/07 22:18:33 ambrisko Exp $";
+ "$FreeBSD: src/sys/dev/mii/mii.c,v 1.14 2002/08/16 23:19:16 ambrisko Exp $";
#endif
static int miibus_readreg (device_t, int, int);
@@ -110,17 +110,14 @@
{
struct mii_attach_args ma, *args;
struct mii_data *mii;
- device_t child = NULL, parent, *children;
- int bmsr, capmask = 0xFFFFFFFF, nchildren;
+ device_t child = NULL, parent;
+ int bmsr, capmask = 0xFFFFFFFF;
mii = device_get_softc(dev);
parent = device_get_parent(dev);
LIST_INIT(&mii->mii_phys);
for (ma.mii_phyno = 0; ma.mii_phyno < MII_NPHY; ma.mii_phyno++) {
- device_get_children(dev, &children, &nchildren);
- if (nchildren)
- break;
/*
* Check to see if there is a PHY at this address. Note,
* many braindead PHYs report 0/0 in their ID registers,
==== //depot/projects/trustedbsd/mac/sys/dev/tdfx/tdfx_pci.c#5 (text+ko) ====
@@ -28,7 +28,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/sys/dev/tdfx/tdfx_pci.c,v 1.18 2002/04/20 01:35:45 marcel Exp $
+ * $FreeBSD: src/sys/dev/tdfx/tdfx_pci.c,v 1.19 2002/08/17 02:36:15 rwatson Exp $
*/
/* 3dfx driver for FreeBSD 4.x - Finished 11 May 2000, 12:25AM ET
==== //depot/projects/trustedbsd/mac/sys/fs/fifofs/fifo_vnops.c#13 (text+ko) ====
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)fifo_vnops.c 8.10 (Berkeley) 5/27/95
- * $FreeBSD: src/sys/fs/fifofs/fifo_vnops.c,v 1.71 2002/08/16 12:51:55 rwatson Exp $
+ * $FreeBSD: src/sys/fs/fifofs/fifo_vnops.c,v 1.72 2002/08/17 02:36:15 rwatson Exp $
*/
#include <sys/param.h>
==== //depot/projects/trustedbsd/mac/sys/i386/ibcs2/ibcs2_fcntl.c#5 (text+ko) ====
@@ -24,7 +24,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/sys/i386/ibcs2/ibcs2_fcntl.c,v 1.20 2002/03/20 05:45:58 alfred Exp $
+ * $FreeBSD: src/sys/i386/ibcs2/ibcs2_fcntl.c,v 1.21 2002/08/17 02:36:16 rwatson Exp $
*/
#include "opt_spx_hack.h"
==== //depot/projects/trustedbsd/mac/sys/i386/ibcs2/ibcs2_ioctl.c#7 (text+ko) ====
@@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/sys/i386/ibcs2/ibcs2_ioctl.c,v 1.24 2002/03/20 05:45:58 alfred Exp $
+ * $FreeBSD: src/sys/i386/ibcs2/ibcs2_ioctl.c,v 1.25 2002/08/17 02:36:16 rwatson Exp $
*/
#include <sys/param.h>
==== //depot/projects/trustedbsd/mac/sys/kern/kern_descrip.c#29 (text+ko) ====
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_descrip.c 8.6 (Berkeley) 4/19/94
- * $FreeBSD: src/sys/kern/kern_descrip.c,v 1.154 2002/08/16 12:51:57 rwatson Exp $
+ * $FreeBSD: src/sys/kern/kern_descrip.c,v 1.155 2002/08/17 02:36:16 rwatson Exp $
*/
#include "opt_compat.h"
==== //depot/projects/trustedbsd/mac/sys/kern/kern_event.c#13 (text+ko) ====
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/kern/kern_event.c,v 1.44 2002/08/16 14:12:40 rwatson Exp $
+ * $FreeBSD: src/sys/kern/kern_event.c,v 1.45 2002/08/17 02:36:16 rwatson Exp $
*/
#include <sys/param.h>
==== //depot/projects/trustedbsd/mac/sys/kern/sys_generic.c#15 (text+ko) ====
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)sys_generic.c 8.5 (Berkeley) 1/21/94
- * $FreeBSD: src/sys/kern/sys_generic.c,v 1.109 2002/08/16 12:51:57 rwatson Exp $
+ * $FreeBSD: src/sys/kern/sys_generic.c,v 1.110 2002/08/17 02:36:16 rwatson Exp $
*/
#include "opt_ktrace.h"
==== //depot/projects/trustedbsd/mac/sys/kern/sys_pipe.c#27 (text+ko) ====
@@ -16,7 +16,7 @@
* 4. Modifications may be freely made to this file if the above conditions
* are met.
*
- * $FreeBSD: src/sys/kern/sys_pipe.c,v 1.115 2002/08/16 14:12:40 rwatson Exp $
+ * $FreeBSD: src/sys/kern/sys_pipe.c,v 1.116 2002/08/17 02:36:16 rwatson Exp $
*/
/*
==== //depot/projects/trustedbsd/mac/sys/kern/sys_socket.c#13 (text+ko) ====
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)sys_socket.c 8.1 (Berkeley) 6/10/93
- * $FreeBSD: src/sys/kern/sys_socket.c,v 1.43 2002/08/16 12:51:58 rwatson Exp $
+ * $FreeBSD: src/sys/kern/sys_socket.c,v 1.44 2002/08/17 02:36:16 rwatson Exp $
*/
#include <sys/param.h>
==== //depot/projects/trustedbsd/mac/sys/kern/vfs_vnops.c#52 (text+ko) ====
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_vnops.c 8.2 (Berkeley) 1/21/94
- * $FreeBSD: src/sys/kern/vfs_vnops.c,v 1.162 2002/08/16 12:51:58 rwatson Exp $
+ * $FreeBSD: src/sys/kern/vfs_vnops.c,v 1.163 2002/08/17 02:36:16 rwatson Exp $
*/
#include "opt_mac.h"
==== //depot/projects/trustedbsd/mac/sys/netinet/tcp_input.c#22 (text+ko) ====
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)tcp_input.c 8.12 (Berkeley) 5/24/95
- * $FreeBSD: src/sys/netinet/tcp_input.c,v 1.169 2002/08/15 18:51:26 rwatson Exp $
+ * $FreeBSD: src/sys/netinet/tcp_input.c,v 1.170 2002/08/17 02:05:25 hsu Exp $
*/
#include "opt_ipfw.h" /* for ipfw_fwd */
@@ -68,32 +68,25 @@
#include <netinet/ip_icmp.h> /* for ICMP_BANDLIM */
#include <netinet/icmp_var.h> /* for ICMP_BANDLIM */
#include <netinet/ip_var.h>
-#ifdef INET6
#include <netinet/ip6.h>
#include <netinet/icmp6.h>
#include <netinet6/in6_pcb.h>
#include <netinet6/ip6_var.h>
#include <netinet6/nd6.h>
-#endif
#include <netinet/tcp.h>
#include <netinet/tcp_fsm.h>
#include <netinet/tcp_seq.h>
#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
-#ifdef INET6
#include <netinet6/tcp6_var.h>
-#endif
#include <netinet/tcpip.h>
#ifdef TCPDEBUG
#include <netinet/tcp_debug.h>
-
#endif /* TCPDEBUG */
#ifdef IPSEC
#include <netinet6/ipsec.h>
-#ifdef INET6
#include <netinet6/ipsec6.h>
-#endif
#include <netkey/key.h>
#endif /*IPSEC*/
@@ -101,7 +94,7 @@
MALLOC_DEFINE(M_TSEGQ, "tseg_qent", "TCP segment queue entry");
-static int tcprexmtthresh = 3;
+static const int tcprexmtthresh = 3;
tcp_cc tcp_ccgen;
struct tcpstat tcpstat;
@@ -138,7 +131,7 @@
static int tcp_reass(struct tcpcb *, struct tcphdr *, int *,
struct mbuf *);
static void tcp_xmit_timer(struct tcpcb *, int);
-static int tcp_newreno(struct tcpcb *, struct tcphdr *);
+static void tcp_newreno_partial_ack(struct tcpcb *, struct tcphdr *);
/* Neighbor Discovery, Neighbor Unreachability Detection Upper layer hint. */
#ifdef INET6
@@ -350,29 +343,35 @@
struct rmxp_tao *taop; /* pointer to our TAO cache entry */
struct rmxp_tao tao_noncached; /* in case there's no cached entry */
int headlocked = 0;
+ struct sockaddr_in *next_hop = NULL;
+ int rstreason; /* For badport_bandlim accounting purposes */
+
+ struct ip6_hdr *ip6 = NULL;
+#ifdef INET6
+ int isipv6;
+#else
+ const int isipv6 = 0;
+#endif
#ifdef TCPDEBUG
+ /*
+ * The size of tcp_saveipgen must be the size of the max ip header,
+ * now IPv6.
+ */
u_char tcp_saveipgen[40];
- /* the size of the above must be of max ip header, now IPv6 */
struct tcphdr tcp_savetcp;
short ostate = 0;
#endif
-#ifdef INET6
- struct ip6_hdr *ip6 = NULL;
- int isipv6;
-#endif /* INET6 */
- struct sockaddr_in *next_hop = NULL;
+
#ifdef MAC
int error;
#endif
- int rstreason; /* For badport_bandlim accounting purposes */
/* Grab info from MT_TAG mbufs prepended to the chain. */
for (;m && m->m_type == MT_TAG; m = m->m_next) {
if (m->m_tag_id == PACKET_TAG_IPFORWARD)
next_hop = (struct sockaddr_in *)m->m_hdr.mh_data;
}
-
#ifdef INET6
isipv6 = (mtod(m, struct ip *)->ip_v == 6) ? 1 : 0;
#endif
@@ -380,7 +379,6 @@
tcpstat.tcps_rcvtotal++;
-#ifdef INET6
if (isipv6) {
/* IP6_EXTHDR_CHECK() is already done at tcp6_input() */
ip6 = mtod(m, struct ip6_hdr *);
@@ -403,55 +401,55 @@
/* XXX stat */
goto drop;
}
- } else
-#endif /* INET6 */
- {
- /*
- * Get IP and TCP header together in first mbuf.
- * Note: IP leaves IP header in first mbuf.
- */
- if (off0 > sizeof (struct ip)) {
- ip_stripoptions(m, (struct mbuf *)0);
- off0 = sizeof(struct ip);
- }
- if (m->m_len < sizeof (struct tcpiphdr)) {
- if ((m = m_pullup(m, sizeof (struct tcpiphdr))) == 0) {
- tcpstat.tcps_rcvshort++;
- return;
- }
- }
- ip = mtod(m, struct ip *);
- ipov = (struct ipovly *)ip;
- th = (struct tcphdr *)((caddr_t)ip + off0);
- tlen = ip->ip_len;
-
- if (m->m_pkthdr.csum_flags & CSUM_DATA_VALID) {
- if (m->m_pkthdr.csum_flags & CSUM_PSEUDO_HDR)
- th->th_sum = m->m_pkthdr.csum_data;
- else
- th->th_sum = in_pseudo(ip->ip_src.s_addr,
- ip->ip_dst.s_addr, htonl(m->m_pkthdr.csum_data +
- ip->ip_len + IPPROTO_TCP));
- th->th_sum ^= 0xffff;
} else {
/*
- * Checksum extended TCP header and data.
+ * Get IP and TCP header together in first mbuf.
+ * Note: IP leaves IP header in first mbuf.
*/
- len = sizeof (struct ip) + tlen;
- bzero(ipov->ih_x1, sizeof(ipov->ih_x1));
- ipov->ih_len = (u_short)tlen;
- ipov->ih_len = htons(ipov->ih_len);
- th->th_sum = in_cksum(m, len);
- }
- if (th->th_sum) {
- tcpstat.tcps_rcvbadsum++;
- goto drop;
- }
+ if (off0 > sizeof (struct ip)) {
+ ip_stripoptions(m, (struct mbuf *)0);
+ off0 = sizeof(struct ip);
+ }
+ if (m->m_len < sizeof (struct tcpiphdr)) {
+ if ((m = m_pullup(m, sizeof (struct tcpiphdr))) == 0) {
+ tcpstat.tcps_rcvshort++;
+ return;
+ }
+ }
+ ip = mtod(m, struct ip *);
+ ipov = (struct ipovly *)ip;
+ th = (struct tcphdr *)((caddr_t)ip + off0);
+ tlen = ip->ip_len;
+
+ if (m->m_pkthdr.csum_flags & CSUM_DATA_VALID) {
+ if (m->m_pkthdr.csum_flags & CSUM_PSEUDO_HDR)
+ th->th_sum = m->m_pkthdr.csum_data;
+ else
+ th->th_sum = in_pseudo(ip->ip_src.s_addr,
+ ip->ip_dst.s_addr,
+ htonl(m->m_pkthdr.csum_data +
+ ip->ip_len +
+ IPPROTO_TCP));
+ th->th_sum ^= 0xffff;
+ } else {
+ /*
+ * Checksum extended TCP header and data.
+ */
+ len = sizeof (struct ip) + tlen;
+ bzero(ipov->ih_x1, sizeof(ipov->ih_x1));
+ ipov->ih_len = (u_short)tlen;
+ ipov->ih_len = htons(ipov->ih_len);
+ th->th_sum = in_cksum(m, len);
+ }
+ if (th->th_sum) {
+ tcpstat.tcps_rcvbadsum++;
+ goto drop;
+ }
#ifdef INET6
- /* Re-initialization for later version check */
- ip->ip_v = IPVERSION;
+ /* Re-initialization for later version check */
+ ip->ip_v = IPVERSION;
#endif
- }
+ }
/*
* Check that TCP offset makes sense,
@@ -464,24 +462,22 @@
}
tlen -= off; /* tlen is used instead of ti->ti_len */
if (off > sizeof (struct tcphdr)) {
-#ifdef INET6
if (isipv6) {
IP6_EXTHDR_CHECK(m, off0, off, );
ip6 = mtod(m, struct ip6_hdr *);
th = (struct tcphdr *)((caddr_t)ip6 + off0);
- } else
-#endif /* INET6 */
- {
- if (m->m_len < sizeof(struct ip) + off) {
- if ((m = m_pullup(m, sizeof (struct ip) + off)) == 0) {
- tcpstat.tcps_rcvshort++;
- return;
+ } else {
+ if (m->m_len < sizeof(struct ip) + off) {
+ if ((m = m_pullup(m, sizeof (struct ip) + off))
+ == 0) {
+ tcpstat.tcps_rcvshort++;
+ return;
+ }
+ ip = mtod(m, struct ip *);
+ ipov = (struct ipovly *)ip;
+ th = (struct tcphdr *)((caddr_t)ip + off0);
}
- ip = mtod(m, struct ip *);
- ipov = (struct ipovly *)ip;
- th = (struct tcphdr *)((caddr_t)ip + off0);
}
- }
optlen = off - sizeof (struct tcphdr);
optp = (u_char *)(th + 1);
}
@@ -526,60 +522,50 @@
headlocked = 1;
findpcb:
/* IPFIREWALL_FORWARD section */
- if (next_hop != NULL
-#ifdef INET6
- && isipv6 == NULL /* IPv6 support is not yet */
-#endif /* INET6 */
- ) {
+ if (next_hop != NULL && isipv6 == 0) { /* IPv6 support is not yet */
/*
* Transparently forwarded. Pretend to be the destination.
* already got one like this?
*/
inp = in_pcblookup_hash(&tcbinfo, ip->ip_src, th->th_sport,
- ip->ip_dst, th->th_dport, 0, m->m_pkthdr.rcvif);
+ ip->ip_dst, th->th_dport,
+ 0, m->m_pkthdr.rcvif);
if (!inp) {
- /*
- * No, then it's new. Try find the ambushing socket
- */
- if (next_hop->sin_port == 0) {
- inp = in_pcblookup_hash(&tcbinfo, ip->ip_src,
- th->th_sport, next_hop->sin_addr,
- th->th_dport, 1, m->m_pkthdr.rcvif);
- } else {
- inp = in_pcblookup_hash(&tcbinfo,
- ip->ip_src, th->th_sport,
- next_hop->sin_addr,
- ntohs(next_hop->sin_port), 1,
- m->m_pkthdr.rcvif);
- }
+ /* It's new. Try find the ambushing socket. */
+ inp = in_pcblookup_hash(&tcbinfo,
+ ip->ip_src, th->th_sport,
+ next_hop->sin_addr,
+ next_hop->sin_port ?
+ ntohs(next_hop->sin_port) :
+ th->th_dport,
+ 1, m->m_pkthdr.rcvif);
}
- } else
- {
-#ifdef INET6
- if (isipv6)
- inp = in6_pcblookup_hash(&tcbinfo, &ip6->ip6_src, th->th_sport,
- &ip6->ip6_dst, th->th_dport, 1,
- m->m_pkthdr.rcvif);
- else
-#endif /* INET6 */
- inp = in_pcblookup_hash(&tcbinfo, ip->ip_src, th->th_sport,
- ip->ip_dst, th->th_dport, 1, m->m_pkthdr.rcvif);
+ } else {
+ if (isipv6)
+ inp = in6_pcblookup_hash(&tcbinfo,
+ &ip6->ip6_src, th->th_sport,
+ &ip6->ip6_dst, th->th_dport,
+ 1, m->m_pkthdr.rcvif);
+ else
+ inp = in_pcblookup_hash(&tcbinfo,
+ ip->ip_src, th->th_sport,
+ ip->ip_dst, th->th_dport,
+ 1, m->m_pkthdr.rcvif);
}
#ifdef IPSEC
-#ifdef INET6
if (isipv6) {
if (inp != NULL && ipsec6_in_reject_so(m, inp->inp_socket)) {
ipsec6stat.in_polvio++;
goto drop;
}
- } else
-#endif /* INET6 */
- if (inp != NULL && ipsec4_in_reject_so(m, inp->inp_socket)) {
- ipsecstat.in_polvio++;
- goto drop;
+ } else {
+ if (inp != NULL && ipsec4_in_reject_so(m, inp->inp_socket)) {
+ ipsecstat.in_polvio++;
+ goto drop;
+ }
}
-#endif /*IPSEC*/
+#endif
/*
* If the state is CLOSED (i.e., TCB does not exist) then
@@ -591,34 +577,32 @@
if (log_in_vain) {
#ifdef INET6
char dbuf[INET6_ADDRSTRLEN], sbuf[INET6_ADDRSTRLEN];
-#else /* INET6 */
+#else
char dbuf[4*sizeof "123"], sbuf[4*sizeof "123"];
-#endif /* INET6 */
+#endif
-#ifdef INET6
if (isipv6) {
strcpy(dbuf, ip6_sprintf(&ip6->ip6_dst));
strcpy(sbuf, ip6_sprintf(&ip6->ip6_src));
- } else
-#endif
- {
- strcpy(dbuf, inet_ntoa(ip->ip_dst));
- strcpy(sbuf, inet_ntoa(ip->ip_src));
- }
+ } else {
+ strcpy(dbuf, inet_ntoa(ip->ip_dst));
+ strcpy(sbuf, inet_ntoa(ip->ip_src));
+ }
switch (log_in_vain) {
case 1:
- if(thflags & TH_SYN)
+ if (thflags & TH_SYN)
log(LOG_INFO,
- "Connection attempt to TCP %s:%d from %s:%d\n",
- dbuf, ntohs(th->th_dport),
- sbuf,
- ntohs(th->th_sport));
+ "Connection attempt to TCP %s:%d "
+ "from %s:%d\n",
+ dbuf, ntohs(th->th_dport), sbuf,
+ ntohs(th->th_sport));
break;
case 2:
log(LOG_INFO,
- "Connection attempt to TCP %s:%d from %s:%d flags:0x%x\n",
- dbuf, ntohs(th->th_dport), sbuf,
- ntohs(th->th_sport), thflags);
+ "Connection attempt to TCP %s:%d "
+ "from %s:%d flags:0x%x\n",
+ dbuf, ntohs(th->th_dport), sbuf,
+ ntohs(th->th_sport), thflags);
break;
default:
break;
@@ -666,13 +650,12 @@
#ifdef TCPDEBUG
if (so->so_options & SO_DEBUG) {
ostate = tp->t_state;
-#ifdef INET6
if (isipv6)
bcopy((char *)ip6, (char *)tcp_saveipgen,
- sizeof(*ip6));
+ sizeof(*ip6));
else
-#endif /* INET6 */
- bcopy((char *)ip, (char *)tcp_saveipgen, sizeof(*ip));
+ bcopy((char *)ip, (char *)tcp_saveipgen,
+ sizeof(*ip));
tcp_savetcp = *th;
}
#endif
@@ -681,14 +664,12 @@
goto after_listen;
#ifdef INET6
inc.inc_isipv6 = isipv6;
+#endif
if (isipv6) {
inc.inc6_faddr = ip6->ip6_src;
inc.inc6_laddr = ip6->ip6_dst;
inc.inc6_route.ro_rt = NULL; /* XXX */
-
- } else
-#endif /* INET6 */
- {
+ } else {
inc.inc_faddr = ip->ip_src;
inc.inc_laddr = ip->ip_dst;
inc.inc_route.ro_rt = NULL; /* XXX */
@@ -817,15 +798,14 @@
* Don't bother responding if the destination was a broadcast.
*/
if (th->th_dport == th->th_sport) {
-#ifdef INET6
if (isipv6) {
if (IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst,
&ip6->ip6_src))
goto drop;
- } else
-#endif /* INET6 */
- if (ip->ip_dst.s_addr == ip->ip_src.s_addr)
- goto drop;
+ } else {
+ if (ip->ip_dst.s_addr == ip->ip_src.s_addr)
+ goto drop;
+ }
}
/*
* RFC1122 4.2.3.10, p. 104: discard bcast/mcast SYN
@@ -836,18 +816,17 @@
*/
if (m->m_flags & (M_BCAST|M_MCAST))
goto drop;
-#ifdef INET6
if (isipv6) {
if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst) ||
IN6_IS_ADDR_MULTICAST(&ip6->ip6_src))
goto drop;
- } else
-#endif
- if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) ||
- IN_MULTICAST(ntohl(ip->ip_src.s_addr)) ||
- ip->ip_src.s_addr == htonl(INADDR_BROADCAST) ||
- in_broadcast(ip->ip_dst, m->m_pkthdr.rcvif))
- goto drop;
+ } else {
+ if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) ||
+ IN_MULTICAST(ntohl(ip->ip_src.s_addr)) ||
+ ip->ip_src.s_addr == htonl(INADDR_BROADCAST) ||
+ in_broadcast(ip->ip_dst, m->m_pkthdr.rcvif))
+ goto drop;
+ }
/*
* SYN appears to be valid; create compressed TCP state
* for syncache, or perform t/tcp connection.
@@ -884,20 +863,13 @@
* segment. Otherwise must send ACK now in case
* the other side is slow starting.
*/
- if (DELAY_ACK(tp) && ((thflags & TH_FIN) ||
- (tlen != 0 &&
-#ifdef INET6
- ((isipv6 && in6_localaddr(&inp->in6p_faddr))
- ||
- (!isipv6 &&
-#endif
- in_localaddr(inp->inp_faddr)
-#ifdef INET6
- ))
-#endif
- ))) {
- callout_reset(tp->tt_delack, tcp_delacktime,
- tcp_timer_delack, tp);
+ if (DELAY_ACK(tp) &&
+ ((thflags & TH_FIN) ||
+ (tlen != 0 &&
+ ((isipv6 && in6_localaddr(&inp->in6p_faddr)) ||
+ (!isipv6 && in_localaddr(inp->inp_faddr)))))) {
+ callout_reset(tp->tt_delack, tcp_delacktime,
+ tcp_timer_delack, tp);
tp->t_flags |= TF_NEEDSYN;
} else
tp->t_flags |= (TF_ACKNOW | TF_NEEDSYN);
@@ -984,7 +956,7 @@
* proposal of the tcplw at cray.com list (Braden 1993/04/26).
*/
if ((to.to_flags & TOF_TS) != 0 &&
- SEQ_LEQ(th->th_seq, tp->last_ack_sent)) {
+ SEQ_LEQ(th->th_seq, tp->last_ack_sent)) {
tp->ts_recent_age = ticks;
tp->ts_recent = to.to_tsval;
}
@@ -1017,7 +989,8 @@
ticks - to.to_tsecr + 1);
else if (tp->t_rtttime &&
SEQ_GT(th->th_ack, tp->t_rtseq))
- tcp_xmit_timer(tp, ticks - tp->t_rtttime);
+ tcp_xmit_timer(tp,
+ ticks - tp->t_rtttime);
acked = th->th_ack - tp->snd_una;
tcpstat.tcps_rcvackpack++;
tcpstat.tcps_rcvackbyte += acked;
@@ -1223,15 +1196,16 @@
tcp_timer_keep, tp);
}
} else {
- /*
- * Received initial SYN in SYN-SENT[*] state => simul-
- * taneous open. If segment contains CC option and there is
- * a cached CC, apply TAO test; if it succeeds, connection is
- * half-synchronized. Otherwise, do 3-way handshake:
- * SYN-SENT -> SYN-RECEIVED
- * SYN-SENT* -> SYN-RECEIVED*
- * If there was no CC option, clear cached CC value.
- */
+ /*
+ * Received initial SYN in SYN-SENT[*] state =>
+ * simultaneous open. If segment contains CC option
+ * and there is a cached CC, apply TAO test.
+ * If it succeeds, connection is * half-synchronized.
+ * Otherwise, do 3-way handshake:
+ * SYN-SENT -> SYN-RECEIVED
+ * SYN-SENT* -> SYN-RECEIVED*
+ * If there was no CC option, clear cached CC value.
+ */
tp->t_flags |= TF_ACKNOW;
callout_stop(tp->tt_rexmt);
if (to.to_flags & TOF_CC) {
@@ -1282,15 +1256,17 @@
tp->snd_wl1 = th->th_seq - 1;
tp->rcv_up = th->th_seq;
/*
- * Client side of transaction: already sent SYN and data.
- * If the remote host used T/TCP to validate the SYN,
- * our data will be ACK'd; if so, enter normal data segment
- * processing in the middle of step 5, ack processing.
- * Otherwise, goto step 6.
+ * Client side of transaction: already sent SYN and data.
+ * If the remote host used T/TCP to validate the SYN,
+ * our data will be ACK'd; if so, enter normal data segment
+ * processing in the middle of step 5, ack processing.
+ * Otherwise, goto step 6.
*/
if (thflags & TH_ACK)
goto process_ACK;
+
goto step6;
+
/*
* If the state is LAST_ACK or CLOSING or TIME_WAIT:
* if segment contains a SYN and CC [not CC.NEW] option:
>>> TRUNCATED FOR MAIL (1000 lines) <<<
To Unsubscribe: send mail to majordomo at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message
More information about the trustedbsd-cvs
mailing list