Re: svn commit: r214224 - in head/sys/fs: nfs nfsserver

2010-10-23 Thread Gleb Kurtsou
On (22/10/2010 21:38), Rick Macklem wrote:
> Author: rmacklem
> Date: Fri Oct 22 21:38:56 2010
> New Revision: 214224
> URL: http://svn.freebsd.org/changeset/base/214224
> 
> Log:
>   Modify the file handle hash function in the experimental NFS
>   server so that it will work better for non-UFS file systems.
>   The new function simply sums the bytes of the fh_fid field
>   of fhandle_t.
>   
>   MFC after:  10 days
> 
> Modified:
>   head/sys/fs/nfs/nfs_var.h
>   head/sys/fs/nfs/nfsdport.h
>   head/sys/fs/nfsserver/nfs_nfsdport.c
> 
> Modified: head/sys/fs/nfs/nfs_var.h
> ==
> --- head/sys/fs/nfs/nfs_var.h Fri Oct 22 20:46:08 2010(r214223)
> +++ head/sys/fs/nfs/nfs_var.h Fri Oct 22 21:38:56 2010(r214224)
> @@ -576,6 +576,7 @@ void nfsvno_unlockvfs(mount_t);
>  int nfsvno_lockvfs(mount_t);
>  int nfsrv_v4rootexport(void *, struct ucred *, NFSPROC_T *);
>  int nfsvno_testexp(struct nfsrv_descript *, struct nfsexstuff *);
> +int nfsrv_hashfh(fhandle_t *);
>  
>  /* nfs_commonkrpc.c */
>  int newnfs_nmcancelreqs(struct nfsmount *);
> 
> Modified: head/sys/fs/nfs/nfsdport.h
> ==
> --- head/sys/fs/nfs/nfsdport.hFri Oct 22 20:46:08 2010
> (r214223)
> +++ head/sys/fs/nfs/nfsdport.hFri Oct 22 21:38:56 2010
> (r214224)
> @@ -73,7 +73,7 @@ struct nfsexstuff {
>   bcmp(&(f1)->fh_fid, &(f2)->fh_fid, sizeof(struct fid)) == 0)
>  
>  #define  NFSLOCKHASH(f)  
> \
> - (&nfslockhash[(*((u_int32_t *)((f)->fh_fid.fid_data))) % 
> NFSLOCKHASHSIZE])
> + (&nfslockhash[nfsrv_hashfh(f) % NFSLOCKHASHSIZE])
>  
>  #define  NFSFPVNODE(f)   ((struct vnode *)((f)->f_data))
>  #define  NFSFPCRED(f)((f)->f_cred)
> 
> Modified: head/sys/fs/nfsserver/nfs_nfsdport.c
> ==
> --- head/sys/fs/nfsserver/nfs_nfsdport.c  Fri Oct 22 20:46:08 2010
> (r214223)
> +++ head/sys/fs/nfsserver/nfs_nfsdport.c  Fri Oct 22 21:38:56 2010
> (r214224)
> @@ -3087,6 +3087,21 @@ nfsvno_testexp(struct nfsrv_descript *nd
>   return (1);
>  }
>  
> +/*
> + * Calculate a hash value for the fid in a file handle.
> + */
> +int
> +nfsrv_hashfh(fhandle_t *fhp)
> +{
> + int hashval = 0, i;
> + uint8_t *cp;
> +
> + cp = (uint8_t *)&fhp->fh_fid;
> + for (i = 0; i < sizeof(struct fid); i++)
> + hashval += *cp++;
> + return (hashval);
> +}
> +
Is there a reason not to use fnv_32_buf() from sys/fnv_hash.h or
hash32_buf() from sys/hash.h?

Just summing up bytes for hash is not generally helpful.

Thanks,
Gleb.

>  extern int (*nfsd_call_nfsd)(struct thread *, struct nfssvc_args *);
>  
>  /*
> ___
> svn-src-all@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/svn-src-all
> To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r214199 - stable/8

2010-10-23 Thread Robert Watson


On Fri, 22 Oct 2010, Andriy Gapon wrote:


+20101022:
+   A workaround for a fixed ld bug has been removed in kernel code,
+   so make sure that your system ld is built from sources after
+   revision 211583 (r210245 if building stable/8 kernel on head,
+   r211584 for stable/7).  A symptom of incorrect ld version is
+   different addresses for set_pcpu section and __start_set_pcpu
+   symbol in kernel and/or modules.


Since many of our users still rely on cvsup to update FreeBSD source, it might 
be useful to provide rough date thresholds for the branches in addition to the 
Subversion changeset numbers (which are less easy to deal with when checking 
out with cvsup/cvs).


Thanks!

Robert
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214236 - head/sys/dev/iwi

2010-10-23 Thread Bernhard Schmidt
Author: bschmidt
Date: Sat Oct 23 11:26:22 2010
New Revision: 214236
URL: http://svn.freebsd.org/changeset/base/214236

Log:
  The firmware does pad notifications to an even number of bytes (at least
  the association notification), the included information though always
  contains an elem block with an odd number of bytes. We handle the last
  byte as if it might contain a whole elem block, this of course is not
  true as one byte is not enough to hold a block, we therefore discard the
  complete frame. The solution here is to subtract one from the actual
  notification length, this is also what the Linux driver does. With this
  change the frames ends exactly where the last elem block ends.
  
  This commit also reverts r214160 which is no longer required and now even
  wrong.
  
  MFC after:1 week

Modified:
  head/sys/dev/iwi/if_iwi.c

Modified: head/sys/dev/iwi/if_iwi.c
==
--- head/sys/dev/iwi/if_iwi.c   Sat Oct 23 10:46:11 2010(r214235)
+++ head/sys/dev/iwi/if_iwi.c   Sat Oct 23 11:26:22 2010(r214236)
@@ -1356,7 +1356,7 @@ iwi_checkforqos(struct ieee80211vap *vap
 
wme = NULL;
while (frm < efrm) {
-   IEEE80211_VERIFY_LENGTH(efrm - frm, frm[1], break);
+   IEEE80211_VERIFY_LENGTH(efrm - frm, frm[1], return);
switch (*frm) {
case IEEE80211_ELEMID_VENDOR:
if (iswmeoui(frm))
@@ -1483,7 +1483,7 @@ iwi_notification_intr(struct iwi_softc *
IWI_STATE_END(sc, IWI_FW_ASSOCIATING);
iwi_checkforqos(vap,
(const struct ieee80211_frame *)(assoc+1),
-   le16toh(notif->len) - sizeof(*assoc));
+   le16toh(notif->len) - sizeof(*assoc) - 1);
ieee80211_new_state(vap, IEEE80211_S_RUN, -1);
break;
case IWI_ASSOC_INIT:
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214237 - head/contrib/bsnmp/snmpd

2010-10-23 Thread Ulrich Spoerlein
Author: uqs
Date: Sat Oct 23 12:27:39 2010
New Revision: 214237
URL: http://svn.freebsd.org/changeset/base/214237

Log:
  Remove mention of non-existant -o flag for debugging options.
  
  MFC after:3 days

Modified:
  head/contrib/bsnmp/snmpd/bsnmpd.1

Modified: head/contrib/bsnmp/snmpd/bsnmpd.1
==
--- head/contrib/bsnmp/snmpd/bsnmpd.1   Sat Oct 23 11:26:22 2010
(r214236)
+++ head/contrib/bsnmp/snmpd/bsnmpd.1   Sat Oct 23 12:27:39 2010
(r214237)
@@ -31,7 +31,7 @@
 .\"
 .\" $Begemot: bsnmp/snmpd/bsnmpd.1,v 1.12 2006/02/27 09:50:03 brandt_h Exp $
 .\"
-.Dd August 16, 2010
+.Dd October 23, 2010
 .Dt BSNMPD 1
 .Os
 .Sh NAME
@@ -68,11 +68,9 @@ Use
 .Ar file
 as configuration file instead of the standard one.
 .It Fl D Ar options
-Debugging options are specified with a
-.Fl o
-flag followed by a comma separated string of options.
+Debugging options are specified as a comma separated string.
 The following options are available.
-.Bl -tag -width ".It Cm trace Ns Cm = Ns Cm level"
+.Bl -tag -width "trace=level"
 .It Cm dump
 Dump all sent and received PDUs to the terminal.
 .It Cm events
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r212803 - head/sys/netinet

2010-10-23 Thread Bjoern A. Zeeb

On Fri, 17 Sep 2010, Andre Oppermann wrote:


Author: andre
Date: Fri Sep 17 22:05:27 2010
New Revision: 212803
URL: http://svn.freebsd.org/changeset/base/212803

Log:
 Rearrange the TSO code to make it more readable and to clearly
 separate the decision logic, of whether we can do TSO, and the
 calculation of the burst length into two distinct parts.

 Change the way the TSO burst length calculation is done. While
 TSO could do bursts of 65535 bytes that can't be represented in
 ip_len together with the IP and TCP header. Account for that and
 use IP_MAXPACKET instead of TCP_MAXWIN as base constant (both
 have the same value of 64K). When more data is available prevent
 less than MSS sized segments from being sent during the current
 TSO burst.

 Add two more KASSERTs to ensure the integrity of the packets.

 Tested by: Ben Wilber 
 MFC after: 10 days


As this hasn't happned yet, please do not do.  It breaks things.  I'll
follow-up later as soon as I have more details.



Modified:
 head/sys/netinet/tcp_output.c

Modified: head/sys/netinet/tcp_output.c
==
--- head/sys/netinet/tcp_output.c   Fri Sep 17 21:53:56 2010
(r212802)
+++ head/sys/netinet/tcp_output.c   Fri Sep 17 22:05:27 2010
(r212803)
@@ -465,9 +465,8 @@ after_sack_rexmit:
}

/*
-* Truncate to the maximum segment length or enable TCP Segmentation
-* Offloading (if supported by hardware) and ensure that FIN is removed
-* if the length no longer contains the last data byte.
+* Decide if we can use TCP Segmentation Offloading (if supported by
+* hardware).
 *
 * TSO may only be used if we are in a pure bulk sending state.  The
 * presence of TCP-MD5, SACK retransmits, SACK advertizements and
@@ -475,10 +474,6 @@ after_sack_rexmit:
 * (except for the sequence number) for all generated packets.  This
 * makes it impossible to transmit any options which vary per generated
 * segment or packet.
-*
-* The length of TSO bursts is limited to TCP_MAXWIN.  That limit and
-* removal of FIN (if not already catched here) are handled later after
-* the exact length of the TCP options are known.
 */
#ifdef IPSEC
/*
@@ -487,22 +482,15 @@ after_sack_rexmit:
 */
ipsec_optlen = ipsec_hdrsiz_tcp(tp);
#endif
-   if (len > tp->t_maxseg) {
-   if ((tp->t_flags & TF_TSO) && V_tcp_do_tso &&
-   ((tp->t_flags & TF_SIGNATURE) == 0) &&
-   tp->rcv_numsacks == 0 && sack_rxmit == 0 &&
-   tp->t_inpcb->inp_options == NULL &&
-   tp->t_inpcb->in6p_options == NULL
+   if ((tp->t_flags & TF_TSO) && V_tcp_do_tso && len > tp->t_maxseg &&
+   ((tp->t_flags & TF_SIGNATURE) == 0) &&
+   tp->rcv_numsacks == 0 && sack_rxmit == 0 &&
#ifdef IPSEC
-   && ipsec_optlen == 0
+   ipsec_optlen == 0 &&
#endif
-   ) {
-   tso = 1;
-   } else {
-   len = tp->t_maxseg;
-   sendalot = 1;
-   }
-   }
+   tp->t_inpcb->inp_options == NULL &&
+   tp->t_inpcb->in6p_options == NULL)
+   tso = 1;

if (sack_rxmit) {
if (SEQ_LT(p->rxmit + len, tp->snd_una + so->so_snd.sb_cc))
@@ -732,28 +720,53 @@ send:
 * bump the packet length beyond the t_maxopd length.
 * Clear the FIN bit because we cut off the tail of
 * the segment.
-*
-* When doing TSO limit a burst to TCP_MAXWIN minus the
-* IP, TCP and Options length to keep ip->ip_len from
-* overflowing.  Prevent the last segment from being
-* fractional thus making them all equal sized and set
-* the flag to continue sending.  TSO is disabled when
-* IP options or IPSEC are present.
 */
if (len + optlen + ipoptlen > tp->t_maxopd) {
flags &= ~TH_FIN;
+
if (tso) {
-   if (len > TCP_MAXWIN - hdrlen - optlen) {
-   len = TCP_MAXWIN - hdrlen - optlen;
-   len = len - (len % (tp->t_maxopd - optlen));
+   KASSERT(ipoptlen == 0,
+   ("%s: TSO can't do IP options", __func__));
+
+   /*
+* Limit a burst to IP_MAXPACKET minus IP,
+* TCP and options length to keep ip->ip_len
+* from overflowing.
+*/
+   if (len > IP_MAXPACKET - hdrlen) {
+   len = IP_MAXPACKET - hdrlen;
+   sendalot = 1;
+   }
+
+   /*
+* Prevent the last segment fro

svn commit: r214238 - head/sys/kern

2010-10-23 Thread David Xu
Author: davidxu
Date: Sat Oct 23 13:16:39 2010
New Revision: 214238
URL: http://svn.freebsd.org/changeset/base/214238

Log:
  In thr_exit() and kthread_exit(), only remove thread from
  hash if it can directly exit, otherwise let exit1() do it.
  The change should be in r213950, but for unknown reason,
  it was lost.

Modified:
  head/sys/kern/kern_kthread.c
  head/sys/kern/kern_thr.c

Modified: head/sys/kern/kern_kthread.c
==
--- head/sys/kern/kern_kthread.cSat Oct 23 12:27:39 2010
(r214237)
+++ head/sys/kern/kern_kthread.cSat Oct 23 13:16:39 2010
(r214238)
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -315,17 +316,20 @@ kthread_exit(void)
 
p = curthread->td_proc;
 
-   tidhash_remove(curthread);
 
/* A module may be waiting for us to exit. */
wakeup(curthread);
+   rw_wlock(&tidhash_lock);
PROC_LOCK(p);
if (p->p_numthreads == 1) {
PROC_UNLOCK(p);
+   rw_wunlock(&tidhash_lock);
kproc_exit(0);
 
/* NOTREACHED. */
}
+   LIST_REMOVE(curthread, td_hash);
+   rw_wunlock(&tidhash_lock);
PROC_SLOCK(p);
thread_exit();
 }

Modified: head/sys/kern/kern_thr.c
==
--- head/sys/kern/kern_thr.cSat Oct 23 12:27:39 2010(r214237)
+++ head/sys/kern/kern_thr.cSat Oct 23 13:16:39 2010(r214238)
@@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -284,23 +285,23 @@ thr_exit(struct thread *td, struct thr_e
kern_umtx_wake(td, uap->state, INT_MAX, 0);
}
 
-   tidhash_remove(td);
-
+   rw_wlock(&tidhash_lock);
PROC_LOCK(p);
-   tdsigcleanup(td);
-   PROC_SLOCK(p);
-
/*
 * Shutting down last thread in the proc.  This will actually
 * call exit() in the trampoline when it returns.
 */
if (p->p_numthreads != 1) {
+   LIST_REMOVE(td, td_hash);
+   rw_wunlock(&tidhash_lock);
+   tdsigcleanup(td);
+   PROC_SLOCK(p);
thread_stopped(p);
thread_exit();
/* NOTREACHED */
}
-   PROC_SUNLOCK(p);
PROC_UNLOCK(p);
+   rw_wunlock(&tidhash_lock);
return (0);
 }
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214239 - stable/8/bin/sh

2010-10-23 Thread Jilles Tjoelker
Author: jilles
Date: Sat Oct 23 13:36:09 2010
New Revision: 214239
URL: http://svn.freebsd.org/changeset/base/214239

Log:
  MFC r213926: sh(1): Clarify subshells/processes for pipelines.
  
  For multi-command pipelines,
  1. all commands are direct children of the shell (unlike the original
 Bourne shell)
  2. all commands are executed in a subshell (unlike the real Korn shell)

Modified:
  stable/8/bin/sh/sh.1
Directory Properties:
  stable/8/bin/sh/   (props changed)

Modified: stable/8/bin/sh/sh.1
==
--- stable/8/bin/sh/sh.1Sat Oct 23 13:16:39 2010(r214238)
+++ stable/8/bin/sh/sh.1Sat Oct 23 13:36:09 2010(r214239)
@@ -32,7 +32,7 @@
 .\"from: @(#)sh.1  8.6 (Berkeley) 5/4/95
 .\" $FreeBSD$
 .\"
-.Dd September 10, 2010
+.Dd October 16, 2010
 .Dt SH 1
 .Os
 .Sh NAME
@@ -732,6 +732,13 @@ both of a command is considered to be as
 pipeline before any redirection specified by redirection
 operators that are part of the command.
 .Pp
+Note that unlike some other shells,
+.Nm
+executes each process in a pipeline with more than one command
+in a subshell environment and as a child of the
+.Nm
+process.
+.Pp
 If the pipeline is not in the background (discussed later),
 the shell waits for all commands to complete.
 .Pp
@@ -769,15 +776,6 @@ to be executed sequentially;
 an
 .Ql &
 causes asynchronous execution of the preceding AND-OR-list.
-.Pp
-Note that unlike some other shells,
-.Nm
-executes each process in the pipeline as a child of the
-.Nm
-process.
-Shell built-in commands are the exception to this rule.
-They are executed in the current shell, although they do not affect its
-environment when used in pipelines.
 .Ss Background Commands (&)
 If a command is terminated by the control operator ampersand
 .Pq Ql & ,
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214240 - stable/7/bin/sh

2010-10-23 Thread Jilles Tjoelker
Author: jilles
Date: Sat Oct 23 13:57:26 2010
New Revision: 214240
URL: http://svn.freebsd.org/changeset/base/214240

Log:
  MFC r197848: Clarify quoting of word in ${v=word} in sh(1).

Modified:
  stable/7/bin/sh/sh.1
Directory Properties:
  stable/7/bin/sh/   (props changed)

Modified: stable/7/bin/sh/sh.1
==
--- stable/7/bin/sh/sh.1Sat Oct 23 13:36:09 2010(r214239)
+++ stable/7/bin/sh/sh.1Sat Oct 23 13:57:26 2010(r214240)
@@ -1221,6 +1221,9 @@ In all cases, the
 final value of
 .Ar parameter
 is substituted.
+Quoting inside
+.Ar word
+does not prevent field splitting or pathname expansion.
 Only variables, not positional
 parameters or special parameters, can be
 assigned in this way.
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214241 - stable/7/bin/sh

2010-10-23 Thread Jilles Tjoelker
Author: jilles
Date: Sat Oct 23 14:00:31 2010
New Revision: 214241
URL: http://svn.freebsd.org/changeset/base/214241

Log:
  MFC r212417: sh(1): Remove xrefs for expr(1) and getopt(1).
  
  expr(1) should usually not be used as various forms of parameter expansion
  and arithmetic expansion replicate most of its functionality in an easier
  way.
  
  getopt(1) should not be used at all in new code. Instead, getopts(1) or
  entirely manual parsing should be used.

Modified:
  stable/7/bin/sh/sh.1
Directory Properties:
  stable/7/bin/sh/   (props changed)

Modified: stable/7/bin/sh/sh.1
==
--- stable/7/bin/sh/sh.1Sat Oct 23 13:57:26 2010(r214240)
+++ stable/7/bin/sh/sh.1Sat Oct 23 14:00:31 2010(r214241)
@@ -32,7 +32,7 @@
 .\"from: @(#)sh.1  8.6 (Berkeley) 5/4/95
 .\" $FreeBSD$
 .\"
-.Dd October 7, 2006
+.Dd September 10, 2010
 .Dt SH 1
 .Os
 .Sh NAME
@@ -2355,8 +2355,6 @@ will return the argument.
 .Xr echo 1 ,
 .Xr ed 1 ,
 .Xr emacs 1 ,
-.Xr expr 1 ,
-.Xr getopt 1 ,
 .Xr pwd 1 ,
 .Xr test 1 ,
 .Xr vi 1 ,
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214242 - stable/7/bin/sh

2010-10-23 Thread Jilles Tjoelker
Author: jilles
Date: Sat Oct 23 14:04:04 2010
New Revision: 214242
URL: http://svn.freebsd.org/changeset/base/214242

Log:
  MFC r211621: sh(1): Add a brief summary of arithmetic expressions.

Modified:
  stable/7/bin/sh/sh.1
Directory Properties:
  stable/7/bin/sh/   (props changed)

Modified: stable/7/bin/sh/sh.1
==
--- stable/7/bin/sh/sh.1Sat Oct 23 14:00:31 2010(r214241)
+++ stable/7/bin/sh/sh.1Sat Oct 23 14:04:04 2010(r214242)
@@ -1142,7 +1142,7 @@ Quote Removal.
 The
 .Ql $
 character is used to introduce parameter expansion, command
-substitution, or arithmetic evaluation.
+substitution, or arithmetic expansion.
 .Ss Tilde Expansion (substituting a user's home directory)
 A word beginning with an unquoted tilde character
 .Pq Ql ~
@@ -1357,10 +1357,41 @@ The
 shell expands all tokens in the
 .Ar expression
 for parameter expansion,
-command substitution, and quote removal.
+command substitution,
+arithmetic expansion
+and quote removal.
+.Pp
+The allowed expressions are a subset of C expressions,
+summarized below.
+.Bl -tag -width "Variables" -offset indent
+.It Values
+All values are of type
+.Ft intmax_t .
+.It Constants
+Decimal, octal (starting with
+.Li 0 )
+and hexadecimal (starting with 
+.Li 0x )
+integer constants.
+.It Variables
+Shell variables can be read and written
+and contain integer constants.
+.It Unary operators
+.Li "! ~ + -"
+.It Binary operators
+.Li "* / % + - << >> < <= > >= == != & ^ | && ||"
+.It Assignment operators
+.Li "= += -= *= /= %= <<= >>= &= ^= |="
+.It Short-circuit evaluation
+The
+.Li &&
+and
+.Li ||
+operators always evaluate both sides.
+This is a bug.
+.El
 .Pp
-Next, the shell treats this as an arithmetic expression and
-substitutes the value of the expression.
+The result of the expression is substituted in decimal.
 .Ss White Space Splitting (Field Splitting)
 After parameter expansion, command substitution, and
 arithmetic expansion the shell scans the results of
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214243 - stable/7/bin/sh

2010-10-23 Thread Jilles Tjoelker
Author: jilles
Date: Sat Oct 23 14:15:10 2010
New Revision: 214243
URL: http://svn.freebsd.org/changeset/base/214243

Log:
  MFC r207831: sh(1): Fix "reserved word" vs "keyword" inconsistency.
  Use "keyword" everywhere, like the output of the 'type' builtin, and only
  mention "reserved word" once to say it is the same thing.

Modified:
  stable/7/bin/sh/sh.1
Directory Properties:
  stable/7/bin/sh/   (props changed)

Modified: stable/7/bin/sh/sh.1
==
--- stable/7/bin/sh/sh.1Sat Oct 23 14:04:04 2010(r214242)
+++ stable/7/bin/sh/sh.1Sat Oct 23 14:15:10 2010(r214243)
@@ -411,11 +411,11 @@ character, with the exception of the new
 .Pq Ql \en .
 A backslash preceding a newline is treated as a line continuation.
 .El
-.Ss Reserved Words
-Reserved words are words that have special meaning to the
+.Ss Keywords
+Keywords or reserved words are words that have special meaning to the
 shell and are recognized at the beginning of a line and
 after a control operator.
-The following are reserved words:
+The following are keywords:
 .Bl -column "doneXX" "elifXX" "elseXX" "untilXX" "whileX" -offset center
 .It Li \&! Ta { Ta } Ta Ic case Ta Ic do
 .It Ic done Ta Ic elif Ta Ic else Ta Ic esac Ta Ic fi
@@ -425,8 +425,8 @@ The following are reserved words:
 An alias is a name and corresponding value set using the
 .Ic alias
 built-in command.
-Whenever a reserved word may occur (see above),
-and after checking for reserved words, the shell
+Whenever a keyword may occur (see above),
+and after checking for keywords, the shell
 checks the word to see if it matches an alias.
 If it does, it replaces it in the input stream with its value.
 For example, if there is an alias called
@@ -465,7 +465,7 @@ of this man page (refer to the BNF in th
 document).
 Essentially though, a line is read and if
 the first word of the line (or after a control operator)
-is not a reserved word, then the shell has recognized a
+is not a keyword, then the shell has recognized a
 simple command.
 Otherwise, a complex command or some
 other special construct may have been recognized.
@@ -685,7 +685,7 @@ Signal numbers are defined in the header
 .In sys/signal.h .
 .Ss Complex Commands
 Complex commands are combinations of simple commands
-with control operators or reserved words, together creating a larger complex
+with control operators or keywords, together creating a larger complex
 command.
 More generally, a command is one of the following:
 .Bl -item -offset indent
@@ -729,7 +729,7 @@ operators that are part of the command.
 If the pipeline is not in the background (discussed later),
 the shell waits for all commands to complete.
 .Pp
-If the reserved word
+If the keyword
 .Ic !\&
 does not precede the pipeline, the
 exit status is the exit status of the last command specified
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214244 - stable/7/bin/sh

2010-10-23 Thread Jilles Tjoelker
Author: jilles
Date: Sat Oct 23 14:16:33 2010
New Revision: 214244
URL: http://svn.freebsd.org/changeset/base/214244

Log:
  MFC r213926: sh(1): Clarify subshells/processes for pipelines.
  
  For multi-command pipelines,
  1. all commands are direct children of the shell (unlike the original
 Bourne shell)
  2. all commands are executed in a subshell (unlike the real Korn shell)

Modified:
  stable/7/bin/sh/sh.1
Directory Properties:
  stable/7/bin/sh/   (props changed)

Modified: stable/7/bin/sh/sh.1
==
--- stable/7/bin/sh/sh.1Sat Oct 23 14:15:10 2010(r214243)
+++ stable/7/bin/sh/sh.1Sat Oct 23 14:16:33 2010(r214244)
@@ -32,7 +32,7 @@
 .\"from: @(#)sh.1  8.6 (Berkeley) 5/4/95
 .\" $FreeBSD$
 .\"
-.Dd September 10, 2010
+.Dd October 16, 2010
 .Dt SH 1
 .Os
 .Sh NAME
@@ -726,6 +726,13 @@ both of a command is considered to be as
 pipeline before any redirection specified by redirection
 operators that are part of the command.
 .Pp
+Note that unlike some other shells,
+.Nm
+executes each process in a pipeline with more than one command
+in a subshell environment and as a child of the
+.Nm
+process.
+.Pp
 If the pipeline is not in the background (discussed later),
 the shell waits for all commands to complete.
 .Pp
@@ -763,15 +770,6 @@ to be executed sequentially;
 an
 .Ql &
 causes asynchronous execution of the preceding AND-OR-list.
-.Pp
-Note that unlike some other shells,
-.Nm
-executes each process in the pipeline as a child of the
-.Nm
-process.
-Shell built-in commands are the exception to this rule.
-They are executed in the current shell, although they do not affect its
-environment when used in pipelines.
 .Ss Background Commands (&)
 If a command is terminated by the control operator ampersand
 .Pq Ql & ,
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214245 - head/sys/kern

2010-10-23 Thread Edward Tomasz Napierala
Author: trasz
Date: Sat Oct 23 14:22:50 2010
New Revision: 214245
URL: http://svn.freebsd.org/changeset/base/214245

Log:
  Remove workaround for ZFS bug; fix was committed to the 
//depot/user/pjd/zfs/...
  branch some time ago.
  
  MFC after:two weeks

Modified:
  head/sys/kern/subr_acl_nfs4.c

Modified: head/sys/kern/subr_acl_nfs4.c
==
--- head/sys/kern/subr_acl_nfs4.c   Sat Oct 23 14:16:33 2010
(r214244)
+++ head/sys/kern/subr_acl_nfs4.c   Sat Oct 23 14:22:50 2010
(r214245)
@@ -393,28 +393,6 @@ acl_nfs4_trivial_from_mode(struct acl *a
group_deny = everyone_allow & ~group_allow;
user_allow_first = group_deny & ~user_deny;
 
-#if 1
-   /*
-* This is a workaround for what looks like a bug in ZFS - trivial
-* ACL for mode 0077 should look like this:
-*
-*owner@:rwxp--:--:deny
-*owner@:--aARWcCos:--:allow
-*group@:rwxp--a-R-c--s:--:allow
-* everyone@:rwxp--a-R-c--s:--:allow
-*
-* Instead, ZFS makes it like this:
-*
-*owner@:rwx---:--:deny
-*owner@:--aARWcCos:--:allow
-*group@:rwxp--a-R-c--s:--:allow
-* everyone@:rwxp--a-R-c--s:--:allow
-*/
-   user_allow_first &= ~ACL_APPEND_DATA;
-   user_deny &= ~ACL_APPEND_DATA;
-   group_deny &= ~ACL_APPEND_DATA;
-#endif
-
if (user_allow_first != 0)
_acl_append(aclp, ACL_USER_OBJ, user_allow_first, 
ACL_ENTRY_TYPE_ALLOW);
if (user_deny != 0)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214249 - head/sys/security/mac

2010-10-23 Thread Robert Watson
Author: rwatson
Date: Sat Oct 23 16:59:39 2010
New Revision: 214249
URL: http://svn.freebsd.org/changeset/base/214249

Log:
  Add missing DTrace probe invocation to mac_vnode_check_open; the probe
  was declared, but never used.
  
  MFC after:3 days
  Sponsored by: Google, Inc.

Modified:
  head/sys/security/mac/mac_vfs.c

Modified: head/sys/security/mac/mac_vfs.c
==
--- head/sys/security/mac/mac_vfs.c Sat Oct 23 14:30:27 2010
(r214248)
+++ head/sys/security/mac/mac_vfs.c Sat Oct 23 16:59:39 2010
(r214249)
@@ -637,6 +637,8 @@ mac_vnode_check_open(struct ucred *cred,
ASSERT_VOP_LOCKED(vp, "mac_vnode_check_open");
 
MAC_POLICY_CHECK(vnode_check_open, cred, vp, vp->v_label, accmode);
+   MAC_CHECK_PROBE3(vnode_check_open, error, cred, vp, accmode);
+
return (error);
 }
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214250 - in head/sys: netinet netinet6 netipsec

2010-10-23 Thread Bjoern A. Zeeb
Author: bz
Date: Sat Oct 23 20:35:40 2010
New Revision: 214250
URL: http://svn.freebsd.org/changeset/base/214250

Log:
  Make the IPsec SADB embedded route cache a union to be able to hold both the
  legacy and IPv6 route destination address.
  Previously in case of IPv6, there was a memory overwrite due to not enough
  space for the IPv6 address.
  
  PR:   kern/122565
  MFC After:2 weeks

Modified:
  head/sys/netinet/ip_ipsec.c
  head/sys/netinet6/ip6_ipsec.c
  head/sys/netipsec/ipsec_output.c
  head/sys/netipsec/key.c
  head/sys/netipsec/keydb.h

Modified: head/sys/netinet/ip_ipsec.c
==
--- head/sys/netinet/ip_ipsec.c Sat Oct 23 16:59:39 2010(r214249)
+++ head/sys/netinet/ip_ipsec.c Sat Oct 23 20:35:40 2010(r214250)
@@ -239,7 +239,7 @@ ip_ipsec_mtu(struct mbuf *m, int mtu)
if (sp->req != NULL &&
sp->req->sav != NULL &&
sp->req->sav->sah != NULL) {
-   ro = &sp->req->sav->sah->sa_route;
+   ro = &sp->req->sav->sah->route_cache.sa_route;
if (ro->ro_rt && ro->ro_rt->rt_ifp) {
mtu =
ro->ro_rt->rt_rmx.rmx_mtu ?

Modified: head/sys/netinet6/ip6_ipsec.c
==
--- head/sys/netinet6/ip6_ipsec.c   Sat Oct 23 16:59:39 2010
(r214249)
+++ head/sys/netinet6/ip6_ipsec.c   Sat Oct 23 20:35:40 2010
(r214250)
@@ -366,7 +366,7 @@ ip6_ipsec_mtu(struct mbuf *m)
if (sp->req != NULL &&
sp->req->sav != NULL &&
sp->req->sav->sah != NULL) {
-   ro = &sp->req->sav->sah->sa_route;
+   ro = &sp->req->sav->sah->route_cache.sa_route;
if (ro->ro_rt && ro->ro_rt->rt_ifp) {
mtu =
ro->ro_rt->rt_rmx.rmx_mtu ?

Modified: head/sys/netipsec/ipsec_output.c
==
--- head/sys/netipsec/ipsec_output.cSat Oct 23 16:59:39 2010
(r214249)
+++ head/sys/netipsec/ipsec_output.cSat Oct 23 20:35:40 2010
(r214250)
@@ -829,7 +829,8 @@ ipsec6_output_tunnel(struct ipsec_output
}
ip6 = mtod(m, struct ip6_hdr *);
 
-   state->ro = &isr->sav->sah->sa_route;
+   state->ro =
+   (struct route *)&isr->sav->sah->route_cache.sin6_route;
state->dst = (struct sockaddr *)&state->ro->ro_dst;
dst6 = (struct sockaddr_in6 *)state->dst;
if (state->ro->ro_rt

Modified: head/sys/netipsec/key.c
==
--- head/sys/netipsec/key.c Sat Oct 23 16:59:39 2010(r214249)
+++ head/sys/netipsec/key.c Sat Oct 23 20:35:40 2010(r214250)
@@ -2758,9 +2758,9 @@ key_delsah(sah)
/* remove from tree of SA index */
if (__LIST_CHAINED(sah))
LIST_REMOVE(sah, chain);
-   if (sah->sa_route.ro_rt) {
-   RTFREE(sah->sa_route.ro_rt);
-   sah->sa_route.ro_rt = (struct rtentry *)NULL;
+   if (sah->route_cache.sa_route.ro_rt) {
+   RTFREE(sah->route_cache.sa_route.ro_rt);
+   sah->route_cache.sa_route.ro_rt = (struct rtentry 
*)NULL;
}
free(sah, M_IPSEC_SAH);
}
@@ -7925,7 +7925,7 @@ key_sa_routechange(dst)
 
SAHTREE_LOCK();
LIST_FOREACH(sah, &V_sahtree, chain) {
-   ro = &sah->sa_route;
+   ro = &sah->route_cache.sa_route;
if (ro->ro_rt && dst->sa_len == ro->ro_dst.sa_len
 && bcmp(dst, &ro->ro_dst, dst->sa_len) == 0) {
RTFREE(ro->ro_rt);

Modified: head/sys/netipsec/keydb.h
==
--- head/sys/netipsec/keydb.h   Sat Oct 23 16:59:39 2010(r214249)
+++ head/sys/netipsec/keydb.h   Sat Oct 23 20:35:40 2010(r214250)
@@ -85,6 +85,12 @@ struct seclifetime {
u_int64_t usetime;
 };
 
+union sa_route_union {
+   struct routesa_route;
+   struct routesin_route;  /* Duplicate for consistency. */
+   struct route_in6sin6_route;
+};
+
 /* Security Association Data Base */
 struct secashead {
LIST_ENTRY(secashead) chain;
@@ -100,7 +106,7 @@ struct secashead {
/* SA chain */
/* The first of this list is newer SA */
 
-   struct route sa_route;  /* route cache */
+   union sa_route_union route_cache;
 };
 
 struct xfor

Re: svn commit: r214045 - in stable/8/tools/regression/bin/sh: builtins errors execution expansion set-e

2010-10-23 Thread Jilles Tjoelker
On Mon, Oct 18, 2010 at 11:10:32PM +, David E. O'Brien wrote:
> Author: obrien
> Date: Mon Oct 18 23:10:32 2010
> New Revision: 214045
> URL: http://svn.freebsd.org/changeset/base/214045
> 
> Log:
>   MFC:
> r204801: make sure to popredir() even if a special builtin caused an error
> r204802: make sure to popredir() even if a function caused an error

> Copied: stable/8/tools/regression/bin/sh/builtins/command10.0 (from r204802, 
> head/tools/regression/bin/sh/builtins/command10.0)
> ==
> --- /dev/null 00:00:00 1970   (empty, because file is newly added)
> +++ stable/8/tools/regression/bin/sh/builtins/command10.0 Mon Oct 18 
> 23:10:32 2010(r214045, copy of r204802, 
> head/tools/regression/bin/sh/builtins/command10.0)
> @@ -0,0 +1,14 @@
> +# $FreeBSD$
> +
> +failures=0
> +
> +check() {
> + if ! eval "[ $* ]"; then
> + echo "Failed: $*"
> + : $((failures += 1))
> + fi
> +}
> +
> +check '"$(f() { shift x; }; { command eval f 2>/dev/null; } >/dev/null; echo 
> hi)" = hi'
> +
> +exit $((failures > 0))

> Copied: stable/8/tools/regression/bin/sh/builtins/command9.0 (from r204801, 
> head/tools/regression/bin/sh/builtins/command9.0)
> ==
> --- /dev/null 00:00:00 1970   (empty, because file is newly added)
> +++ stable/8/tools/regression/bin/sh/builtins/command9.0  Mon Oct 18 
> 23:10:32 2010(r214045, copy of r204801, 
> head/tools/regression/bin/sh/builtins/command9.0)
> @@ -0,0 +1,14 @@
> +# $FreeBSD$
> +
> +failures=0
> +
> +check() {
> + if ! eval "[ $* ]"; then
> + echo "Failed: $*"
> + : $((failures += 1))
> + fi
> +}
> +
> +check '"$({ command eval shift x 2>/dev/null; } >/dev/null; echo hi)" = hi'
> +
> +exit $((failures > 0))

These work on stable/8, but for the wrong reason. In stable/8, 'command'
does not allow executing builtin utilities, and therefore 'eval' cannot
be found. This is a different error than the expected passing of a
non-number to 'shift', and does not allow testing for the bug this is
supposed to check for.

Some of the other tests for these kinds of bugs use fifos and 'fc',
which also work in older sh (from the point when POSIX-style special
builtins were implemented; before that, 'fc' errors were fatal, probably
for this reason). However, when I allowed 'command' to execute builtin
utilities, I started to use 'command eval' because it makes the tests
more readable and easier to write.

Demonstration of the bug in stable/8:
$ sh
$ shift x
shift: Illegal number: x
$ echo $( { fc -e :; } >/dev/null; echo hi)
shift: Illegal number: x

$

"hi" should be printed, and is printed correctly if the procedure is
repeated without the >/dev/null redirection.

Because this does not cause any extra failures, I don't think it is
necessary to revert it. However, it seems unusual to MFC a test for a
bugfix without also MFCing the bugfix.

-- 
Jilles Tjoelker
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214251 - head/sys/dev/bge

2010-10-23 Thread Pyun YongHyeon
Author: yongari
Date: Sat Oct 23 21:25:50 2010
New Revision: 214251
URL: http://svn.freebsd.org/changeset/base/214251

Log:
  Apply the same workaround for SDI flow control used on BCM5906 A1
  to BCM6906 A0/A2. This should fix a long standing BCM5906 A2 lockup
  issues. Data sheet explicitly mentions BCM5906 A0, A1 and A2 use
  de-pipelined mode on these revisions.
  Special thanks to Buganini who tried all combinations of
  experimental patches for more than 10 days.
  
  Tested by:Buganini  gmail dot com >

Modified:
  head/sys/dev/bge/if_bge.c
  head/sys/dev/bge/if_bgereg.h

Modified: head/sys/dev/bge/if_bge.c
==
--- head/sys/dev/bge/if_bge.c   Sat Oct 23 20:35:40 2010(r214250)
+++ head/sys/dev/bge/if_bge.c   Sat Oct 23 21:25:50 2010(r214251)
@@ -1693,11 +1693,14 @@ bge_blockinit(struct bge_softc *sc)
bge_writembx(sc, BGE_MBX_RX_MINI_PROD_LO, 0);
}
 
-   /* Choose de-pipeline mode for BCM5906 A1. */
-   if (sc->bge_asicrev == BGE_ASICREV_BCM5906 &&
-   sc->bge_chiprev == BGE_CHIPID_BCM5906_A1)
-   CSR_WRITE_4(sc, BGE_ISO_PKT_TX,
-   (CSR_READ_4(sc, BGE_ISO_PKT_TX) & ~3) | 2);
+   /* Choose de-pipeline mode for BCM5906 A0, A1 and A2. */
+   if (sc->bge_asicrev == BGE_ASICREV_BCM5906) {
+   if (sc->bge_chiprev == BGE_CHIPID_BCM5906_A0 ||
+   sc->bge_chiprev == BGE_CHIPID_BCM5906_A1 ||
+   sc->bge_chiprev == BGE_CHIPID_BCM5906_A2)
+   CSR_WRITE_4(sc, BGE_ISO_PKT_TX,
+   (CSR_READ_4(sc, BGE_ISO_PKT_TX) & ~3) | 2);
+   }
/*
 * The BD ring replenish thresholds control how often the
 * hardware fetches new BD's from the producer rings in host

Modified: head/sys/dev/bge/if_bgereg.h
==
--- head/sys/dev/bge/if_bgereg.hSat Oct 23 20:35:40 2010
(r214250)
+++ head/sys/dev/bge/if_bgereg.hSat Oct 23 21:25:50 2010
(r214251)
@@ -306,6 +306,7 @@
 #defineBGE_CHIPID_BCM5787_A0   0xb000
 #defineBGE_CHIPID_BCM5787_A1   0xb001
 #defineBGE_CHIPID_BCM5787_A2   0xb002
+#defineBGE_CHIPID_BCM5906_A0   0xc000
 #defineBGE_CHIPID_BCM5906_A1   0xc001
 #defineBGE_CHIPID_BCM5906_A2   0xc002
 #defineBGE_CHIPID_BCM57780_A0  0x5778
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214252 - stable/8/sbin/geom/core

2010-10-23 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sat Oct 23 21:56:50 2010
New Revision: 214252
URL: http://svn.freebsd.org/changeset/base/214252

Log:
  Implement G_TYPE_MULTI and G_VAL_OPTIONAL for stable/8.
  
  This should have been MFC, but I've no green light from marcel to remove
  G_TYPE_ASCNUM and gc_argname and to modify geom_part in stable/8, so this is
  reimplementation that doesn't touch gpart and hopefully doesn't break 
anything.

Modified:
  stable/8/sbin/geom/core/geom.c
  stable/8/sbin/geom/core/geom.h

Modified: stable/8/sbin/geom/core/geom.c
==
--- stable/8/sbin/geom/core/geom.c  Sat Oct 23 21:25:50 2010
(r214251)
+++ stable/8/sbin/geom/core/geom.c  Sat Oct 23 21:56:50 2010
(r214252)
@@ -224,33 +224,61 @@ find_option(struct g_command *cmd, char 
  * Add given option to gctl_req.
  */
 static void
-set_option(struct gctl_req *req, struct g_option *opt, const char *val)
+set_option(struct g_command *cmd, struct gctl_req *req, struct g_option *opt,
+const char *val)
 {
-   char *s;
-   intmax_t number;
+   const char *optname;
+   uint64_t number;
+   void *ptr;
 
-   if (G_OPT_TYPE(opt) == G_TYPE_NUMBER ||
-   G_OPT_TYPE(opt) == G_TYPE_ASCNUM) {
+   if (G_OPT_ISMULTI(opt)) {
+   size_t optnamesize;
+
+   if (G_OPT_NUM(opt) == UCHAR_MAX)
+   errx(EXIT_FAILURE, "Too many -%c options.", 
opt->go_char);
+
+   /*
+* Base option name length plus 3 bytes for option number
+* (max. 255 options) plus 1 byte for terminating '\0'.
+*/
+   optnamesize = strlen(opt->go_name) + 3 + 1;
+   ptr = malloc(optnamesize);
+   if (ptr == NULL)
+   errx(EXIT_FAILURE, "No memory.");
+   snprintf(ptr, optnamesize, "%s%u", opt->go_name, 
G_OPT_NUM(opt));
+   G_OPT_NUMINC(opt);
+   optname = ptr;
+   } else {
+   optname = opt->go_name;
+   }
+
+   if (G_OPT_TYPE(opt) == G_TYPE_NUMBER) {
if (expand_number(val, &number) == -1) {
-   err(EXIT_FAILURE, "Invalid value for '%c' argument.",
+   err(EXIT_FAILURE, "Invalid value for '%c' argument",
opt->go_char);
}
-   if (G_OPT_TYPE(opt) == G_TYPE_NUMBER)
-   opt->go_val = malloc(sizeof(intmax_t));
-   else {
-   asprintf(&s, "%jd", number);
-   opt->go_val = s;
-   }
+   opt->go_val = malloc(sizeof(intmax_t));
if (opt->go_val == NULL)
errx(EXIT_FAILURE, "No memory.");
-   if (G_OPT_TYPE(opt) == G_TYPE_NUMBER) {
-   *(intmax_t *)opt->go_val = number;
-   gctl_ro_param(req, opt->go_name, sizeof(intmax_t),
-   opt->go_val);
-   } else
+   *(intmax_t *)opt->go_val = number;
+   gctl_ro_param(req, opt->go_name, sizeof(intmax_t), opt->go_val);
+   } else if (G_OPT_TYPE(opt) == G_TYPE_ASCNUM) {
+   if (cmd->gc_argname == NULL || *val != '\0') {
+   char *s;
+
+   if (expand_number(val, &number) == -1) {
+   err(EXIT_FAILURE, "Invalid value for '%c' 
argument",
+   opt->go_char);
+   }
+   asprintf(&s, "%jd", number);
+   if (s == NULL)
+   errx(EXIT_FAILURE, "No memory.");
+   opt->go_val = s;
gctl_ro_param(req, opt->go_name, -1, opt->go_val);
+   }
} else if (G_OPT_TYPE(opt) == G_TYPE_STRING) {
-   gctl_ro_param(req, opt->go_name, -1, val);
+   if (cmd->gc_argname == NULL || *val != '\0')
+   gctl_ro_param(req, opt->go_name, -1, val);
} else if (G_OPT_TYPE(opt) == G_TYPE_BOOL) {
opt->go_val = malloc(sizeof(int));
if (opt->go_val == NULL)
@@ -260,6 +288,9 @@ set_option(struct gctl_req *req, struct 
} else {
assert(!"Invalid type");
}
+
+   if (G_OPT_ISMULTI(opt))
+   free(__DECONST(char *, optname));
 }
 
 /*
@@ -284,7 +315,10 @@ parse_arguments(struct g_command *cmd, s
if (opt->go_name == NULL)
break;
assert(G_OPT_TYPE(opt) != 0);
-   assert((opt->go_type & ~G_TYPE_MASK) == 0);
+   assert((opt->go_type & ~(G_TYPE_MASK | G_TYPE_MULTI)) == 0);
+   /* Multiple bool arguments makes no sense. */
+   assert(G_OPT_TYPE(opt) != G_TYPE_BOOL ||
+   (opt->go_type & G_TYPE_MULTI) == 0);

svn commit: r214253 - stable/8/sbin/geom/core

2010-10-23 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sat Oct 23 22:04:37 2010
New Revision: 214253
URL: http://svn.freebsd.org/changeset/base/214253

Log:
  Constify go_val field.
  
  (Should've been MFC of r212547.)

Modified:
  stable/8/sbin/geom/core/geom.c
  stable/8/sbin/geom/core/geom.h

Modified: stable/8/sbin/geom/core/geom.c
==
--- stable/8/sbin/geom/core/geom.c  Sat Oct 23 21:56:50 2010
(r214252)
+++ stable/8/sbin/geom/core/geom.c  Sat Oct 23 22:04:37 2010
(r214253)
@@ -257,10 +257,11 @@ set_option(struct g_command *cmd, struct
err(EXIT_FAILURE, "Invalid value for '%c' argument",
opt->go_char);
}
-   opt->go_val = malloc(sizeof(intmax_t));
-   if (opt->go_val == NULL)
+   ptr = malloc(sizeof(intmax_t));
+   if (ptr == NULL)
errx(EXIT_FAILURE, "No memory.");
-   *(intmax_t *)opt->go_val = number;
+   *(intmax_t *)ptr = number;
+   opt->go_val = ptr;
gctl_ro_param(req, opt->go_name, sizeof(intmax_t), opt->go_val);
} else if (G_OPT_TYPE(opt) == G_TYPE_ASCNUM) {
if (cmd->gc_argname == NULL || *val != '\0') {
@@ -280,10 +281,11 @@ set_option(struct g_command *cmd, struct
if (cmd->gc_argname == NULL || *val != '\0')
gctl_ro_param(req, opt->go_name, -1, val);
} else if (G_OPT_TYPE(opt) == G_TYPE_BOOL) {
-   opt->go_val = malloc(sizeof(int));
-   if (opt->go_val == NULL)
+   ptr = malloc(sizeof(int));
+   if (ptr == NULL)
errx(EXIT_FAILURE, "No memory.");
-   *(int *)opt->go_val = *val - '0';
+   *(int *)ptr = *val - '0';
+   opt->go_val = ptr;
gctl_ro_param(req, opt->go_name, sizeof(int), opt->go_val);
} else {
assert(!"Invalid type");
@@ -378,7 +380,7 @@ parse_arguments(struct g_command *cmd, s
char val[64];
 
snprintf(val, sizeof(val), "%jd",
-   *(intmax_t *)opt->go_val);
+   *(const intmax_t *)opt->go_val);
set_option(cmd, req, opt, val);
}
}

Modified: stable/8/sbin/geom/core/geom.h
==
--- stable/8/sbin/geom/core/geom.h  Sat Oct 23 21:56:50 2010
(r214252)
+++ stable/8/sbin/geom/core/geom.h  Sat Oct 23 22:04:37 2010
(r214253)
@@ -62,7 +62,7 @@
 struct g_option {
char go_char;
const char  *go_name;
-   void*go_val;
+   const void  *go_val;
unsigned go_type;
 };
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214254 - stable/8/sys/opencrypto

2010-10-23 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sat Oct 23 22:11:30 2010
New Revision: 214254
URL: http://svn.freebsd.org/changeset/base/214254

Log:
  MFC r213065,r213068:
  
  r213065:
  
  Remove redundant space.
  
  r213068:
  
  Add support for AES-XTS.
  
  Obtained from:OpenBSD

Modified:
  stable/8/sys/opencrypto/cryptodev.c
  stable/8/sys/opencrypto/cryptodev.h
  stable/8/sys/opencrypto/cryptosoft.c
  stable/8/sys/opencrypto/xform.c
  stable/8/sys/opencrypto/xform.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/opencrypto/cryptodev.c
==
--- stable/8/sys/opencrypto/cryptodev.c Sat Oct 23 22:04:37 2010
(r214253)
+++ stable/8/sys/opencrypto/cryptodev.c Sat Oct 23 22:11:30 2010
(r214254)
@@ -419,6 +419,9 @@ cryptof_ioctl(
case CRYPTO_AES_CBC:
txform = &enc_xform_rijndael128;
break;
+   case CRYPTO_AES_XTS:
+   txform = &enc_xform_aes_xts;
+   break;
case CRYPTO_NULL_CBC:
txform = &enc_xform_null;
break;

Modified: stable/8/sys/opencrypto/cryptodev.h
==
--- stable/8/sys/opencrypto/cryptodev.h Sat Oct 23 22:04:37 2010
(r214253)
+++ stable/8/sys/opencrypto/cryptodev.h Sat Oct 23 22:11:30 2010
(r214254)
@@ -123,7 +123,8 @@
 #defineCRYPTO_SHA2_384_HMAC19
 #defineCRYPTO_SHA2_512_HMAC20
 #define CRYPTO_CAMELLIA_CBC21
-#defineCRYPTO_ALGORITHM_MAX21 /* Keep updated - see below */
+#defineCRYPTO_AES_XTS  22
+#defineCRYPTO_ALGORITHM_MAX22 /* Keep updated - see below */
 
 /* Algorithm flags */
 #defineCRYPTO_ALG_FLAG_SUPPORTED   0x01 /* Algorithm is supported 
*/

Modified: stable/8/sys/opencrypto/cryptosoft.c
==
--- stable/8/sys/opencrypto/cryptosoft.cSat Oct 23 22:04:37 2010
(r214253)
+++ stable/8/sys/opencrypto/cryptosoft.cSat Oct 23 22:11:30 2010
(r214254)
@@ -114,8 +114,16 @@ swcr_encdec(struct cryptodesc *crd, stru
if (error)
return (error);
}
+
ivp = iv;
 
+   /*
+* xforms that provide a reinit method perform all IV
+* handling themselves.
+*/
+   if (exf->reinit)
+   exf->reinit(sw->sw_kschedule, iv);
+
if (flags & CRYPTO_F_IMBUF) {
struct mbuf *m = (struct mbuf *) buf;
 
@@ -135,7 +143,15 @@ swcr_encdec(struct cryptodesc *crd, stru
m_copydata(m, k, blks, blk);
 
/* Actual encryption/decryption */
-   if (crd->crd_flags & CRD_F_ENCRYPT) {
+   if (exf->reinit) {
+   if (crd->crd_flags & CRD_F_ENCRYPT) {
+   exf->encrypt(sw->sw_kschedule,
+   blk);
+   } else {
+   exf->decrypt(sw->sw_kschedule,
+   blk);
+   }
+   } else if (crd->crd_flags & CRD_F_ENCRYPT) {
/* XOR with previous block */
for (j = 0; j < blks; j++)
blk[j] ^= ivp[j];
@@ -205,7 +221,15 @@ swcr_encdec(struct cryptodesc *crd, stru
idat = mtod(m, unsigned char *) + k;
 
while (m->m_len >= k + blks && i > 0) {
-   if (crd->crd_flags & CRD_F_ENCRYPT) {
+   if (exf->reinit) {
+   if (crd->crd_flags & CRD_F_ENCRYPT) {
+   exf->encrypt(sw->sw_kschedule,
+   idat);
+   } else {
+   exf->decrypt(sw->sw_kschedule,
+   idat);
+   }
+   } else if (crd->crd_flags & CRD_F_ENCRYPT) {
/* XOR with previous block/IV */
for (j = 0; j < blks; j++)
   

svn commit: r214255 - in head/sys/fs: nfs nfsserver

2010-10-23 Thread Rick Macklem
Author: rmacklem
Date: Sat Oct 23 22:28:29 2010
New Revision: 214255
URL: http://svn.freebsd.org/changeset/base/214255

Log:
  Modify the experimental NFSv4 server's file handle hash function
  to use the generic hash32_buf() function. Although adding the
  bytes seemed sufficient for UFS and ZFS, since most of the bytes
  are the same for file handles on the same volume, this might not
  be sufficient for other file systems. Use of a generic function
  also seems preferable to one specific to NFSv4.
  
  Suggested by: gleb.kurtsou at gmail.com
  MFC after:10 days

Modified:
  head/sys/fs/nfs/nfs_var.h
  head/sys/fs/nfsserver/nfs_nfsdport.c

Modified: head/sys/fs/nfs/nfs_var.h
==
--- head/sys/fs/nfs/nfs_var.h   Sat Oct 23 22:11:30 2010(r214254)
+++ head/sys/fs/nfs/nfs_var.h   Sat Oct 23 22:28:29 2010(r214255)
@@ -576,7 +576,7 @@ void nfsvno_unlockvfs(mount_t);
 int nfsvno_lockvfs(mount_t);
 int nfsrv_v4rootexport(void *, struct ucred *, NFSPROC_T *);
 int nfsvno_testexp(struct nfsrv_descript *, struct nfsexstuff *);
-int nfsrv_hashfh(fhandle_t *);
+uint32_t nfsrv_hashfh(fhandle_t *);
 
 /* nfs_commonkrpc.c */
 int newnfs_nmcancelreqs(struct nfsmount *);

Modified: head/sys/fs/nfsserver/nfs_nfsdport.c
==
--- head/sys/fs/nfsserver/nfs_nfsdport.cSat Oct 23 22:11:30 2010
(r214254)
+++ head/sys/fs/nfsserver/nfs_nfsdport.cSat Oct 23 22:28:29 2010
(r214255)
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -3090,15 +3091,12 @@ nfsvno_testexp(struct nfsrv_descript *nd
 /*
  * Calculate a hash value for the fid in a file handle.
  */
-int
+uint32_t
 nfsrv_hashfh(fhandle_t *fhp)
 {
-   int hashval = 0, i;
-   uint8_t *cp;
+   uint32_t hashval;
 
-   cp = (uint8_t *)&fhp->fh_fid;
-   for (i = 0; i < sizeof(struct fid); i++)
-   hashval += *cp++;
+   hashval = hash32_buf(&fhp->fh_fid, sizeof(struct fid), 0);
return (hashval);
 }
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214256 - head/lib/libfetch

2010-10-23 Thread Ed Maste
Author: emaste
Date: Sun Oct 24 01:05:10 2010
New Revision: 214256
URL: http://svn.freebsd.org/changeset/base/214256

Log:
  Move variable declarations into the conditional block where they are
  used, to fix warning if WITH_SSL is not set.
  
  Submitted by: Sean Bruno
  MFC after:1 week

Modified:
  head/lib/libfetch/common.c

Modified: head/lib/libfetch/common.c
==
--- head/lib/libfetch/common.c  Sat Oct 23 22:28:29 2010(r214255)
+++ head/lib/libfetch/common.c  Sun Oct 24 01:05:10 2010(r214256)
@@ -321,9 +321,9 @@ fetch_connect(const char *host, int port
 int
 fetch_ssl(conn_t *conn, int verbose)
 {
+#ifdef WITH_SSL
int ret, ssl_err;
 
-#ifdef WITH_SSL
/* Init the SSL library and context */
if (!SSL_library_init()){
fprintf(stderr, "SSL library init failed\n");
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214257 - head/sys/boot/pc98/boot2

2010-10-23 Thread Takahashi Yoshihiro
Author: nyan
Date: Sun Oct 24 02:59:02 2010
New Revision: 214257
URL: http://svn.freebsd.org/changeset/base/214257

Log:
  MFi386: revision 214210
  
Avoid using memcpy() for copying 32bit chunks. This shrinks
the resulting code a little.

Modified:
  head/sys/boot/pc98/boot2/boot2.c

Modified: head/sys/boot/pc98/boot2/boot2.c
==
--- head/sys/boot/pc98/boot2/boot2.cSun Oct 24 01:05:10 2010
(r214256)
+++ head/sys/boot/pc98/boot2/boot2.cSun Oct 24 02:59:02 2010
(r214257)
@@ -485,7 +485,7 @@ load(void)
return;
p += hdr.ex.a_data + roundup2(hdr.ex.a_bss, PAGE_SIZE);
bootinfo.bi_symtab = VTOP(p);
-   memcpy(p, &hdr.ex.a_syms, sizeof(hdr.ex.a_syms));
+   *(uint32_t*)p = hdr.ex.a_syms;
p += sizeof(hdr.ex.a_syms);
if (hdr.ex.a_syms) {
if (xfsread(ino, p, hdr.ex.a_syms))
@@ -522,7 +522,7 @@ load(void)
if (xfsread(ino, &es, sizeof(es)))
return;
for (i = 0; i < 2; i++) {
-   memcpy(p, &es[i].sh_size, sizeof(es[i].sh_size));
+   *(Elf32_Word *)p = es[i].sh_size;
p += sizeof(es[i].sh_size);
fs_off = es[i].sh_offset;
if (xfsread(ino, p, es[i].sh_size))
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214258 - head/sys/pc98/pc98

2010-10-23 Thread Takahashi Yoshihiro
Author: nyan
Date: Sun Oct 24 03:20:54 2010
New Revision: 214258
URL: http://svn.freebsd.org/changeset/base/214258

Log:
  MFi386: the part of revision 213226.
  
Rewrite the i386 memory probe:
- Move the base memory setup into a new basemem_setup() routine.
  
  MFC after:1 week

Modified:
  head/sys/pc98/pc98/machdep.c

Modified: head/sys/pc98/pc98/machdep.c
==
--- head/sys/pc98/pc98/machdep.cSun Oct 24 02:59:02 2010
(r214257)
+++ head/sys/pc98/pc98/machdep.cSun Oct 24 03:20:54 2010
(r214258)
@@ -1776,52 +1776,13 @@ sdtossd(sd, ssd)
ssd->ssd_gran  = sd->sd_gran;
 }
 
-/*
- * Populate the (physmap) array with base/bound pairs describing the
- * available physical memory in the system, then test this memory and
- * build the phys_avail array describing the actually-available memory.
- *
- * If we cannot accurately determine the physical memory map, then use
- * value from the 0xE801 call, and failing that, the RTC.
- *
- * Total memory size may be set by the kernel environment variable
- * hw.physmem or the compile-time define MAXMEM.
- *
- * XXX first should be vm_paddr_t.
- */
 static void
-getmemsize(int first)
+basemem_setup(void)
 {
-   int i, off, physmap_idx, pa_indx, da_indx;
-   int pg_n;
-   u_long physmem_tunable;
-   u_int extmem;
-   u_int under16;
-   vm_paddr_t pa, physmap[PHYSMAP_SIZE];
+   vm_paddr_t pa;
pt_entry_t *pte;
-   quad_t dcons_addr, dcons_size;
-
-   bzero(physmap, sizeof(physmap));
-
-   /* XXX - some of EPSON machines can't use PG_N */
-   pg_n = PG_N;
-   if (pc98_machine_type & M_EPSON_PC98) {
-   switch (epson_machine_id) {
-#ifdef WB_CACHE
-   default:
-#endif
-   case EPSON_PC486_HX:
-   case EPSON_PC486_HG:
-   case EPSON_PC486_HA:
-   pg_n = 0;
-   break;
-   }
-   }
+   int i;
 
-   /*
-* Perform "base memory" related probes & setup
-*/
-   under16 = pc98_getmemsize(&basemem, &extmem);
if (basemem > 640) {
printf("Preposterous BIOS basemem of %uK, truncating to 640K\n",
basemem);
@@ -1853,12 +1814,62 @@ getmemsize(int first)
pmap_kenter(KERNBASE + pa, pa);
 
/*
-* if basemem != 640, map pages r/w into vm86 page table so 
-* that the bios can scribble on it.
+* Map pages between basemem and ISA_HOLE_START, if any, r/w into
+* the vm86 page table so that vm86 can scribble on them using
+* the vm86 map too.  XXX: why 2 ways for this and only 1 way for
+* page 0, at least as initialized here?
 */
pte = (pt_entry_t *)vm86paddr;
for (i = basemem / 4; i < 160; i++)
pte[i] = (i << PAGE_SHIFT) | PG_V | PG_RW | PG_U;
+}
+
+/*
+ * Populate the (physmap) array with base/bound pairs describing the
+ * available physical memory in the system, then test this memory and
+ * build the phys_avail array describing the actually-available memory.
+ *
+ * If we cannot accurately determine the physical memory map, then use
+ * value from the 0xE801 call, and failing that, the RTC.
+ *
+ * Total memory size may be set by the kernel environment variable
+ * hw.physmem or the compile-time define MAXMEM.
+ *
+ * XXX first should be vm_paddr_t.
+ */
+static void
+getmemsize(int first)
+{
+   int off, physmap_idx, pa_indx, da_indx;
+   u_long physmem_tunable;
+   vm_paddr_t physmap[PHYSMAP_SIZE];
+   pt_entry_t *pte;
+   quad_t dcons_addr, dcons_size;
+   int i;
+   int pg_n;
+   u_int extmem;
+   u_int under16;
+   vm_paddr_t pa;
+
+   bzero(physmap, sizeof(physmap));
+
+   /* XXX - some of EPSON machines can't use PG_N */
+   pg_n = PG_N;
+   if (pc98_machine_type & M_EPSON_PC98) {
+   switch (epson_machine_id) {
+#ifdef WB_CACHE
+   default:
+#endif
+   case EPSON_PC486_HX:
+   case EPSON_PC486_HG:
+   case EPSON_PC486_HA:
+   pg_n = 0;
+   break;
+   }
+   }
+
+   under16 = pc98_getmemsize(&basemem, &extmem);
+   basemem_setup();
 
physmap[0] = 0;
physmap[1] = basemem * 1024;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214260 - head/lib/libc/mips

2010-10-23 Thread Jayachandran C.
Author: jchandra
Date: Sun Oct 24 05:22:07 2010
New Revision: 214260
URL: http://svn.freebsd.org/changeset/base/214260

Log:
  Fix PIC_RETURN when abicalls are not defined.
  
  Submitted by: Artem Belevich (artemb at gmail dot com)

Modified:
  head/lib/libc/mips/SYS.h

Modified: head/lib/libc/mips/SYS.h
==
--- head/lib/libc/mips/SYS.hSun Oct 24 04:38:56 2010(r214259)
+++ head/lib/libc/mips/SYS.hSun Oct 24 05:22:07 2010(r214260)
@@ -91,7 +91,7 @@
 #else
 # define PIC_PROLOGUE(x)
 # define PIC_TAILCALL(l)   j  _C_LABEL(l)
-# define PIC_RETURN()
+# define PIC_RETURN()  j ra
 #endif /* __ABICALLS__ */
 
 # define SYSTRAP(x)li v0,SYS_ ## x; syscall;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r212803 - head/sys/netinet

2010-10-23 Thread Andre Oppermann

On 23.10.2010 15:10, Bjoern A. Zeeb wrote:

On Fri, 17 Sep 2010, Andre Oppermann wrote:


Author: andre
Date: Fri Sep 17 22:05:27 2010
New Revision: 212803
URL: http://svn.freebsd.org/changeset/base/212803

Log:
Rearrange the TSO code to make it more readable and to clearly
separate the decision logic, of whether we can do TSO, and the
calculation of the burst length into two distinct parts.

Change the way the TSO burst length calculation is done. While
TSO could do bursts of 65535 bytes that can't be represented in
ip_len together with the IP and TCP header. Account for that and
use IP_MAXPACKET instead of TCP_MAXWIN as base constant (both
have the same value of 64K). When more data is available prevent
less than MSS sized segments from being sent during the current
TSO burst.

Add two more KASSERTs to ensure the integrity of the packets.

Tested by: Ben Wilber 
MFC after: 10 days


As this hasn't happned yet, please do not do. It breaks things. I'll
follow-up later as soon as I have more details.


I was busied out after the EuroBSDCon DevSummit and didn't have have
time to MFC.  Incidentially I was planning on doing it today, but will
hold off based on your request.

The version currently in 8 certainly has a bug.  For the one in head
you are the first report.  Others reported their all their issues to be
fixed with this patch.

Can you give an high level description of the problem you are seeing?
A detailed description is not required to take a first look on whatever
issue you may have.

--
Andre




Modified:
head/sys/netinet/tcp_output.c

Modified: head/sys/netinet/tcp_output.c
==
--- head/sys/netinet/tcp_output.c Fri Sep 17 21:53:56 2010 (r212802)
+++ head/sys/netinet/tcp_output.c Fri Sep 17 22:05:27 2010 (r212803)
@@ -465,9 +465,8 @@ after_sack_rexmit:
}

/*
- * Truncate to the maximum segment length or enable TCP Segmentation
- * Offloading (if supported by hardware) and ensure that FIN is removed
- * if the length no longer contains the last data byte.
+ * Decide if we can use TCP Segmentation Offloading (if supported by
+ * hardware).
*
* TSO may only be used if we are in a pure bulk sending state. The
* presence of TCP-MD5, SACK retransmits, SACK advertizements and
@@ -475,10 +474,6 @@ after_sack_rexmit:
* (except for the sequence number) for all generated packets. This
* makes it impossible to transmit any options which vary per generated
* segment or packet.
- *
- * The length of TSO bursts is limited to TCP_MAXWIN. That limit and
- * removal of FIN (if not already catched here) are handled later after
- * the exact length of the TCP options are known.
*/
#ifdef IPSEC
/*
@@ -487,22 +482,15 @@ after_sack_rexmit:
*/
ipsec_optlen = ipsec_hdrsiz_tcp(tp);
#endif
- if (len > tp->t_maxseg) {
- if ((tp->t_flags & TF_TSO) && V_tcp_do_tso &&
- ((tp->t_flags & TF_SIGNATURE) == 0) &&
- tp->rcv_numsacks == 0 && sack_rxmit == 0 &&
- tp->t_inpcb->inp_options == NULL &&
- tp->t_inpcb->in6p_options == NULL
+ if ((tp->t_flags & TF_TSO) && V_tcp_do_tso && len > tp->t_maxseg &&
+ ((tp->t_flags & TF_SIGNATURE) == 0) &&
+ tp->rcv_numsacks == 0 && sack_rxmit == 0 &&
#ifdef IPSEC
- && ipsec_optlen == 0
+ ipsec_optlen == 0 &&
#endif
- ) {
- tso = 1;
- } else {
- len = tp->t_maxseg;
- sendalot = 1;
- }
- }
+ tp->t_inpcb->inp_options == NULL &&
+ tp->t_inpcb->in6p_options == NULL)
+ tso = 1;

if (sack_rxmit) {
if (SEQ_LT(p->rxmit + len, tp->snd_una + so->so_snd.sb_cc))
@@ -732,28 +720,53 @@ send:
* bump the packet length beyond the t_maxopd length.
* Clear the FIN bit because we cut off the tail of
* the segment.
- *
- * When doing TSO limit a burst to TCP_MAXWIN minus the
- * IP, TCP and Options length to keep ip->ip_len from
- * overflowing. Prevent the last segment from being
- * fractional thus making them all equal sized and set
- * the flag to continue sending. TSO is disabled when
- * IP options or IPSEC are present.
*/
if (len + optlen + ipoptlen > tp->t_maxopd) {
flags &= ~TH_FIN;
+
if (tso) {
- if (len > TCP_MAXWIN - hdrlen - optlen) {
- len = TCP_MAXWIN - hdrlen - optlen;
- len = len - (len % (tp->t_maxopd - optlen));
+ KASSERT(ipoptlen == 0,
+ ("%s: TSO can't do IP options", __func__));
+
+ /*
+ * Limit a burst to IP_MAXPACKET minus IP,
+ * TCP and options length to keep ip->ip_len
+ * from overflowing.
+ */
+ if (len > IP_MAXPACKET - hdrlen) {
+ len = IP_MAXPACKET - hdrlen;
+ sendalot = 1;
+ }
+
+ /*
+ * Prevent the last segment from being
+ * fractional unless the send sockbuf can
+ * be emptied.
+ */
+ if (sendalot && off + len < so->so_snd.sb_cc) {
+ len -= len % (tp->t_maxopd - optlen);
sendalot = 1;
- } else if (tp->t_flags & TF_NEEDFIN)
+ }
+
+ /*
+ * Send the FIN in a separate segment
+ * after the bulk sending is done.
+ * We don't trust the TSO implementations
+ * to clear the FIN flag on all but the
+ * last segment.
+ */
+ if (tp->t_flags & TF_NEEDFIN)
sendalot = 1;
+
} else {
len = tp->t_maxopd - optlen - ipoptlen;
se