svn commit: r218010 - head/usr.sbin/usbdump

2011-01-28 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Jan 28 08:00:57 2011
New Revision: 218010
URL: http://svn.freebsd.org/changeset/base/218010

Log:
  - Remove double semicolon.
  - Remove reference to sprintf. Use printf directly. This part of
  the code should be optimised further to avoid many small printouts.
  Setting a sensible line buffer length could help aswell when printing
  out megabytes of data per second.
  
  Approved by:  thompsa (mentor)

Modified:
  head/usr.sbin/usbdump/usbdump.c

Modified: head/usr.sbin/usbdump/usbdump.c
==
--- head/usr.sbin/usbdump/usbdump.c Fri Jan 28 07:04:01 2011
(r218009)
+++ head/usr.sbin/usbdump/usbdump.c Fri Jan 28 08:00:57 2011
(r218010)
@@ -72,7 +72,7 @@ struct usbcap_filehdr {
 static int doexit = 0;
 static int pkt_captured = 0;
 static int verbose = 0;
-static const char *i_arg = "usbus0";;
+static const char *i_arg = "usbus0";
 static const char *r_arg = NULL;
 static const char *w_arg = NULL;
 static const char *errstr_table[USB_ERR_MAX] = {
@@ -185,11 +185,10 @@ static void
 hexdump(const char *region, size_t len)
 {
const char *line;
-   int x, c;
-   char lbuf[80];
-#define EMIT(fmt, args...) do {\
-   sprintf(lbuf, fmt , ## args);   \
-   printf("%s", lbuf); \
+   int x;
+   int c;
+#define EMIT(fmt, ...) do {\
+   printf(fmt,## __VA_ARGS__); \
 } while (0)
 
for (line = region; line < (region + len); line += 16) {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218011 - head/sys/dev/ath/ath_hal

2011-01-28 Thread Adrian Chadd
Author: adrian
Date: Fri Jan 28 08:35:55 2011
New Revision: 218011
URL: http://svn.freebsd.org/changeset/base/218011

Log:
  Bring in some 802.11n packet duration calculation functions from a mix of 
Sam/Rui and linux ath9k .
  
  This will eventually be used by rate control modules and by the TX
  code for calculating packet duration when handling rts/cts protection.
  
  Obtained from:sam@, rpaulo@, linux ath9k

Modified:
  head/sys/dev/ath/ath_hal/ah.c
  head/sys/dev/ath/ath_hal/ah.h

Modified: head/sys/dev/ath/ath_hal/ah.c
==
--- head/sys/dev/ath/ath_hal/ah.c   Fri Jan 28 08:00:57 2011
(r218010)
+++ head/sys/dev/ath/ath_hal/ah.c   Fri Jan 28 08:35:55 2011
(r218011)
@@ -234,6 +234,78 @@ ath_hal_reverseBits(uint32_t val, uint32
return retval;
 }
 
+/* 802.11n related timing definitions */
+
+#defineOFDM_PLCP_BITS  22
+#defineHT_L_STF8
+#defineHT_L_LTF8
+#defineHT_L_SIG4
+#defineHT_SIG  8
+#defineHT_STF  4
+#defineHT_LTF(n)   ((n) * 4)
+
+#defineHT_RC_2_MCS(_rc)((_rc) & 0xf)
+#defineHT_RC_2_STREAMS(_rc)_rc) & 0x78) >> 3) + 1)
+#defineIS_HT_RATE(_rc) ( (_rc) & IEEE80211_RATE_MCS)
+
+/*
+ * Calculate the duration of a packet whether it is 11n or legacy.
+ */
+uint32_t
+ath_hal_pkt_txtime(struct ath_hal *ah, const HAL_RATE_TABLE *rates, uint32_t 
frameLen,
+uint16_t rateix, HAL_BOOL isht40, HAL_BOOL shortPreamble)
+{
+   uint8_t rc;
+   int numStreams;
+
+   rc = rates->info[rateix].rateCode;
+
+   /* Legacy rate? Return the old way */
+   if (! IS_HT_RATE(rc))
+   return ath_hal_computetxtime(ah, rates, frameLen, rateix, 
shortPreamble);
+
+   /* 11n frame - extract out the number of spatial streams */
+   numStreams = HT_RC_2_STREAMS(rc);
+   KASSERT(numStreams == 1 || numStreams == 2, ("number of spatial streams 
needs to be 1 or 2: MCS rate 0x%x!", rateix));
+
+   return ath_computedur_ht(frameLen, rc, numStreams, isht40, 
shortPreamble);
+}
+
+/*
+ * Calculate the transmit duration of an 11n frame.
+ * This only works for MCS0->MCS15.
+ */
+uint32_t
+ath_computedur_ht(uint32_t frameLen, uint16_t rate, int streams, HAL_BOOL 
isht40,
+HAL_BOOL isShortGI)
+{
+   static const uint16_t ht20_bps[16] = {
+   26, 52, 78, 104, 156, 208, 234, 260,
+   52, 104, 156, 208, 312, 416, 468, 520
+   };
+   static const uint16_t ht40_bps[16] = {
+   54, 108, 162, 216, 324, 432, 486, 540,
+   108, 216, 324, 432, 648, 864, 972, 1080,
+   };
+   uint32_t bitsPerSymbol, numBits, numSymbols, txTime;
+
+   KASSERT(rate & IEEE80211_RATE_MCS, ("not mcs %d", rate));
+   KASSERT((rate &~ IEEE80211_RATE_MCS) < 16, ("bad mcs 0x%x", rate));
+
+   if (isht40)
+   bitsPerSymbol = ht40_bps[rate & 0xf];
+   else
+   bitsPerSymbol = ht20_bps[rate & 0xf];
+   numBits = OFDM_PLCP_BITS + (frameLen << 3);
+   numSymbols = howmany(numBits, bitsPerSymbol);
+   if (isShortGI)
+   txTime = ((numSymbols * 18) + 4) / 5;   /* 3.6us */
+   else
+   txTime = numSymbols * 4;/* 4us */
+   return txTime + HT_L_STF + HT_L_LTF +
+   HT_L_SIG + HT_SIG + HT_STF + HT_LTF(streams);
+}
+
 /*
  * Compute the time to transmit a frame of length frameLen bytes
  * using the specified rate, phy, and short preamble setting.

Modified: head/sys/dev/ath/ath_hal/ah.h
==
--- head/sys/dev/ath/ath_hal/ah.h   Fri Jan 28 08:00:57 2011
(r218010)
+++ head/sys/dev/ath/ath_hal/ah.h   Fri Jan 28 08:35:55 2011
(r218011)
@@ -882,7 +882,20 @@ extern void __ahdecl ath_hal_process_noi
 extern u_int __ahdecl ath_hal_getwirelessmodes(struct ath_hal*);
 
 /*
- * Calculate the transmit duration of a frame.
+ * Calculate the packet TX time for a legacy or 11n frame
+ */
+extern uint32_t __ahdecl ath_hal_pkt_txtime(struct ath_hal *ah,
+const HAL_RATE_TABLE *rates, uint32_t frameLen,
+uint16_t rateix, HAL_BOOL isht40, HAL_BOOL shortPreamble);
+
+/*
+ * Calculate the duration of an 11n frame.
+ */
+extern uint32_t __ahdecl ath_computedur_ht(uint32_t frameLen, uint16_t rate,
+int streams, HAL_BOOL isht40, HAL_BOOL isShortGI);
+
+/*
+ * Calculate the transmit duration of a legacy frame.
  */
 extern uint16_t __ahdecl ath_hal_computetxtime(struct ath_hal *,
const HAL_RATE_TABLE *rates, uint32_t frameLen,
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218012 - head/sys/dev/ath/ath_hal/ar5212

2011-01-28 Thread Adrian Chadd
Author: adrian
Date: Fri Jan 28 08:45:19 2011
New Revision: 218012
URL: http://svn.freebsd.org/changeset/base/218012

Log:
  Make space for the extended 802.11n MCS rate tables.

Modified:
  head/sys/dev/ath/ath_hal/ar5212/ar5212.h

Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212.h
==
--- head/sys/dev/ath/ath_hal/ar5212/ar5212.hFri Jan 28 08:35:55 2011
(r218011)
+++ head/sys/dev/ath/ath_hal/ar5212/ar5212.hFri Jan 28 08:45:19 2011
(r218012)
@@ -326,7 +326,7 @@ struct ath_hal_5212 {
 */
uint16_t*ah_pcdacTable;
u_int   ah_pcdacTableSize;
-   uint16_tah_ratesArray[16];
+   uint16_tah_ratesArray[37];
 
uint8_t ah_txTrigLev;   /* current Tx trigger level */
uint8_t ah_maxTxTrigLev;/* max tx trigger level */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218013 - head/sys/dev/ath/ath_rate/sample

2011-01-28 Thread Adrian Chadd
Author: adrian
Date: Fri Jan 28 08:57:58 2011
New Revision: 218013
URL: http://svn.freebsd.org/changeset/base/218013

Log:
  (Mostly) teach ath_rate_sample about MCS rates.
  
  This is just the bare minimum needed to teach ath_rate_sample to try
  and handle MCS rates. It doesn't at all attempt to find the best
  rate by any means - it doesn't know anything about the MCS rate
  relations, TX aggregation or any of the much sexier 11n stuff
  that's out there.
  
  It's just enough to transmit 11n frames and handle TX completion.
  
  It shouldn't affect legacy (11abg) behaviour.
  
  Obtained from:rpaulo@

Added:
  head/sys/dev/ath/ath_rate/sample/tx_schedules.h   (contents, props changed)
Modified:
  head/sys/dev/ath/ath_rate/sample/sample.c

Modified: head/sys/dev/ath/ath_rate/sample/sample.c
==
--- head/sys/dev/ath/ath_rate/sample/sample.c   Fri Jan 28 08:45:19 2011
(r218012)
+++ head/sys/dev/ath/ath_rate/sample/sample.c   Fri Jan 28 08:57:58 2011
(r218013)
@@ -75,6 +75,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 /*
  * This file is an implementation of the SampleRate algorithm
@@ -142,6 +143,13 @@ ath_rate_node_cleanup(struct ath_softc *
 {
 }
 
+static int
+dot11rate(const HAL_RATE_TABLE *rt, int rix)
+{
+   return rt->info[rix].phy == IEEE80211_T_HT ?
+   rt->info[rix].dot11Rate : (rt->info[rix].dot11Rate & 
IEEE80211_RATE_VAL) / 2;
+}
+
 /*
  * Return the rix with the lowest average_tx_time,
  * or -1 if all the average_tx_times are 0.
@@ -186,6 +194,7 @@ pick_sample_rate(struct sample_softc *ss
 const HAL_RATE_TABLE *rt, int size_bin)
 {
 #defineDOT11RATE(ix)   (rt->info[ix].dot11Rate & IEEE80211_RATE_VAL)
+#defineMCS(ix) (rt->info[ix].dot11Rate | IEEE80211_RATE_MCS)
int current_rix, rix;
unsigned current_tt;
uint32_t mask;
@@ -232,6 +241,7 @@ pick_sample_rate(struct sample_softc *ss
}
return current_rix;
 #undef DOT11RATE
+#undef MCS
 }
 
 void
@@ -240,6 +250,7 @@ ath_rate_findrate(struct ath_softc *sc, 
  u_int8_t *rix0, int *try0, u_int8_t *txrate)
 {
 #defineDOT11RATE(ix)   (rt->info[ix].dot11Rate & IEEE80211_RATE_VAL)
+#defineMCS(ix) (rt->info[ix].dot11Rate | IEEE80211_RATE_MCS)
 #defineRATE(ix)(DOT11RATE(ix) / 2)
struct sample_node *sn = ATH_NODE_SAMPLE(an);
struct sample_softc *ssc = ATH_SOFTC_SAMPLE(sc);
@@ -334,7 +345,7 @@ ath_rate_findrate(struct ath_softc *sc, 
/* 
 * Set the visible txrate for this node.
 */
-   an->an_node.ni_txrate = DOT11RATE(best_rix);
+   an->an_node.ni_txrate = (rt->info[best_rix].phy == 
IEEE80211_T_HT) ?  MCS(best_rix) : DOT11RATE(best_rix);
}
rix = sn->current_rix[size_bin];
sn->packets_since_switch[size_bin]++;
@@ -348,81 +359,10 @@ done:
| (shortPreamble ? rt->info[rix].shortPreamble : 0);
sn->packets_sent[size_bin]++;
 #undef DOT11RATE
+#undef MCS
 #undef RATE
 }
 
-#define A(_r) \
-(((_r) == 6)   ? 0 : (((_r) == 9)   ? 1 : (((_r) == 12)  ? 2 : \
-(((_r) == 18)  ? 3 : (((_r) == 24)  ? 4 : (((_r) == 36)  ? 5 : \
-(((_r) == 48)  ? 6 : (((_r) == 54)  ? 7 : 0
-static const struct txschedule series_11a[] = {
-   { 3,A( 6), 3,A(  6), 0,A(  6), 0,A( 6) },   /*   6Mb/s */
-   { 4,A( 9), 3,A(  6), 4,A(  6), 0,A( 6) },   /*   9Mb/s */
-   { 4,A(12), 3,A(  6), 4,A(  6), 0,A( 6) },   /*  12Mb/s */
-   { 4,A(18), 3,A( 12), 4,A(  6), 2,A( 6) },   /*  18Mb/s */
-   { 4,A(24), 3,A( 18), 4,A( 12), 2,A( 6) },   /*  24Mb/s */
-   { 4,A(36), 3,A( 24), 4,A( 18), 2,A( 6) },   /*  36Mb/s */
-   { 4,A(48), 3,A( 36), 4,A( 24), 2,A(12) },   /*  48Mb/s */
-   { 4,A(54), 3,A( 48), 4,A( 36), 2,A(24) }/*  54Mb/s */
-};
-#undef A
-
-#define G(_r) \
-(((_r) == 1)   ? 0 : (((_r) == 2)   ? 1 : (((_r) == 5.5) ? 2 : \
-(((_r) == 11)  ? 3 : (((_r) == 6)   ? 4 : (((_r) == 9)   ? 5 : \
-(((_r) == 12)  ? 6 : (((_r) == 18)  ? 7 : (((_r) == 24)  ? 8 : \
-(((_r) == 36)  ? 9 : (((_r) == 48)  ? 10 : (((_r) == 54)  ? 11 : 
0
-static const struct txschedule series_11g[] = {
-   { 3,G( 1), 3,G(  1), 0,G(  1), 0,G( 1) },   /*   1Mb/s */
-   { 4,G( 2), 3,G(  1), 4,G(  1), 0,G( 1) },   /*   2Mb/s */
-   { 4,G(5.5),3,G(  2), 4,G(  1), 2,G( 1) },   /* 5.5Mb/s */
-   { 4,G(11), 3,G(5.5), 4,G(  2), 2,G( 1) },   /*  11Mb/s */
-   { 4,G( 6), 3,G(5.5), 4,G(  2), 2,G( 1) },   /*   6Mb/s */
-   { 4,G( 9), 3,G(  6), 4,G(5.5), 2,G( 1) },   /*   9Mb/s */
-   { 4,G(12), 3,G( 11), 4,G(5.5), 2,G( 1) },   /*  12Mb/s */
-   { 4,G(18), 3,G( 12), 4,G( 11), 2,G( 1) },   /*  18Mb/s */
-   {

Re: svn commit: r217871 - head/sbin/mount

2011-01-28 Thread Bruce Evans

On Thu, 27 Jan 2011, Doug Barton wrote:


On 01/26/2011 21:24, Bruce Evans wrote:

On Wed, 26 Jan 2011, Doug Barton wrote:



My concern was that the man page says that we don't support the option
at all, but with a FreeBSD client and a solaris server it has a
demonstrable effect. If someone wants to improve the wording then by
all means, either make a suggestion or just do it. :)


What is the effect?


Um, the expected one? :)

If I use a FreeBSD client to nfs mount something on a solaris system with the 
noatime option then the access time does not change no matter how many times 
I access the file. If I then unmount and remount without the noatime option 
the access time will be modified. If I do the same thing but with a FreeBSD 
nfs server the access time is modified, with or without the noatime option.


The solaris server behaviour can't happen, except accidentally due to
races :-).  Since the FreeBSD client doesn't support the noatime flag
except to ignore it, it can't tell any server about it.  The FreeBSD
server behaviour is as expected -- unmounting flushes the client's cache,
so the first read after remounting goes to the server and the server
must mark the atime for update (unless the server filesystem is mounted
with noatime); then a later stat() on the client should somehow see an
updated atime (but I wonder if caching defeats this too -- stat() on the
server must change any mark for update to an update, but the client has
an attribute cache which should be used to prevent most stat()s going to
the server).

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


Re: svn commit: r218010 - head/usr.sbin/usbdump

2011-01-28 Thread Pawel Jakub Dawidek
On Fri, Jan 28, 2011 at 08:00:57AM +, Hans Petter Selasky wrote:
> Author: hselasky
> Date: Fri Jan 28 08:00:57 2011
> New Revision: 218010
> URL: http://svn.freebsd.org/changeset/base/218010
> 
> Log:
>   - Remove double semicolon.
>   - Remove reference to sprintf. Use printf directly. This part of
>   the code should be optimised further to avoid many small printouts.
>   Setting a sensible line buffer length could help aswell when printing
>   out megabytes of data per second.
>   
>   Approved by:thompsa (mentor)
[...]
> +#define EMIT(fmt, ...)   do {\
> + printf(fmt,## __VA_ARGS__); \
>  } while (0)

Or:

#define EMIT(...)   printf(__VA_ARGS__)

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
p...@freebsd.org   http://www.FreeBSD.org
FreeBSD committer Am I Evil? Yes, I Am!


pgpVTbnMXHceg.pgp
Description: PGP signature


svn commit: r218014 - in head/sys: geom/part sys

2011-01-28 Thread Andrey V. Elsukov
Author: ae
Date: Fri Jan 28 11:13:01 2011
New Revision: 218014
URL: http://svn.freebsd.org/changeset/base/218014

Log:
  Add new user-friendly aliases for partition types for the MBR and
  EBR schemes: fat32, ebr, linux-data, linux-raid, linux-swap and
  linux-lvm. Add bios-boot GUID and alias for the GPT scheme. It used by
  GRUB 2 loader. Also do sorting definitions of types in diskmbr.h
  and in g_part.c.
  
  PR:   bin/120990, kern/147664
  MFC after:2 weeks

Modified:
  head/sys/geom/part/g_part.c
  head/sys/geom/part/g_part.h
  head/sys/geom/part/g_part_ebr.c
  head/sys/geom/part/g_part_gpt.c
  head/sys/geom/part/g_part_mbr.c
  head/sys/sys/diskmbr.h
  head/sys/sys/gpt.h

Modified: head/sys/geom/part/g_part.c
==
--- head/sys/geom/part/g_part.c Fri Jan 28 08:57:58 2011(r218013)
+++ head/sys/geom/part/g_part.c Fri Jan 28 11:13:01 2011(r218014)
@@ -76,7 +76,10 @@ struct g_part_alias_list {
{ "apple-raid-offline", G_PART_ALIAS_APPLE_RAID_OFFLINE },
{ "apple-tv-recovery", G_PART_ALIAS_APPLE_TV_RECOVERY },
{ "apple-ufs", G_PART_ALIAS_APPLE_UFS },
+   { "bios-boot", G_PART_ALIAS_BIOS_BOOT },
+   { "ebr", G_PART_ALIAS_EBR },
{ "efi", G_PART_ALIAS_EFI },
+   { "fat32", G_PART_ALIAS_MS_FAT32 },
{ "freebsd", G_PART_ALIAS_FREEBSD },
{ "freebsd-boot", G_PART_ALIAS_FREEBSD_BOOT },
{ "freebsd-swap", G_PART_ALIAS_FREEBSD_SWAP },
@@ -87,6 +90,7 @@ struct g_part_alias_list {
{ "linux-lvm", G_PART_ALIAS_LINUX_LVM },
{ "linux-raid", G_PART_ALIAS_LINUX_RAID },
{ "linux-swap", G_PART_ALIAS_LINUX_SWAP },
+   { "mbr", G_PART_ALIAS_MBR },
{ "ms-basic-data", G_PART_ALIAS_MS_BASIC_DATA },
{ "ms-ldm-data", G_PART_ALIAS_MS_LDM_DATA },
{ "ms-ldm-metadata", G_PART_ALIAS_MS_LDM_METADATA },
@@ -98,7 +102,6 @@ struct g_part_alias_list {
{ "netbsd-lfs", G_PART_ALIAS_NETBSD_LFS },
{ "netbsd-raid", G_PART_ALIAS_NETBSD_RAID },
{ "netbsd-swap", G_PART_ALIAS_NETBSD_SWAP },
-   { "mbr", G_PART_ALIAS_MBR }
 };
 
 /*

Modified: head/sys/geom/part/g_part.h
==
--- head/sys/geom/part/g_part.h Fri Jan 28 08:57:58 2011(r218013)
+++ head/sys/geom/part/g_part.h Fri Jan 28 11:13:01 2011(r218014)
@@ -66,6 +66,9 @@ enum g_part_alias {
G_PART_ALIAS_NETBSD_RAID,   /* A NetBSD RAID partition entry. */
G_PART_ALIAS_NETBSD_SWAP,   /* A NetBSD swap partition entry. */
G_PART_ALIAS_NETBSD_LFS,/* A NetBSD LFS partition entry. */
+   G_PART_ALIAS_EBR,   /* A EBR partition entry. */
+   G_PART_ALIAS_MS_FAT32,  /* A Microsoft FAT32 partition entry. */
+   G_PART_ALIAS_BIOS_BOOT, /* A GRUB 2 boot partition entry. */
/* Keep the following last */
G_PART_ALIAS_COUNT
 };

Modified: head/sys/geom/part/g_part_ebr.c
==
--- head/sys/geom/part/g_part_ebr.c Fri Jan 28 08:57:58 2011
(r218013)
+++ head/sys/geom/part/g_part_ebr.c Fri Jan 28 11:13:01 2011
(r218014)
@@ -113,6 +113,19 @@ static struct g_part_scheme g_part_ebr_s
 };
 G_PART_SCHEME_DECLARE(g_part_ebr);
 
+static struct g_part_ebr_alias {
+   u_char  typ;
+   int alias;
+} ebr_alias_match[] = {
+   { DOSPTYP_386BSD,   G_PART_ALIAS_FREEBSD },
+   { DOSPTYP_NTFS, G_PART_ALIAS_MS_NTFS },
+   { DOSPTYP_FAT32,G_PART_ALIAS_MS_FAT32 },
+   { DOSPTYP_LINSWP,   G_PART_ALIAS_LINUX_SWAP },
+   { DOSPTYP_LINUX,G_PART_ALIAS_LINUX_DATA },
+   { DOSPTYP_LINLVM,   G_PART_ALIAS_LINUX_LVM },
+   { DOSPTYP_LINRAID,  G_PART_ALIAS_LINUX_RAID },
+};
+
 static void ebr_set_chs(struct g_part_table *, uint32_t, u_char *, u_char *,
 u_char *);
 
@@ -152,6 +165,7 @@ ebr_parse_type(const char *type, u_char 
const char *alias;
char *endp;
long lt;
+   int i;
 
if (type[0] == '!') {
lt = strtol(type + 1, &endp, 0);
@@ -160,14 +174,18 @@ ebr_parse_type(const char *type, u_char 
*dp_typ = (u_char)lt;
return (0);
}
-   alias = g_part_alias_name(G_PART_ALIAS_FREEBSD);
-   if (!strcasecmp(type, alias)) {
-   *dp_typ = DOSPTYP_386BSD;
-   return (0);
+   for (i = 0;
+   i < sizeof(ebr_alias_match) / sizeof(ebr_alias_match[0]); i++) {
+   alias = g_part_alias_name(ebr_alias_match[i].alias);
+   if (strcasecmp(type, alias) == 0) {
+   *dp_typ = ebr_alias_match[i].typ;
+   return (0);
+   }
}
return (EINVAL);
 }
 
+
 static void
 ebr_set_chs(struct g_part_table *table, uint32_t lba, u_char *cylp, u_cha

svn commit: r218015 - head/sbin/geom/class/part

2011-01-28 Thread Andrey V. Elsukov
Author: ae
Date: Fri Jan 28 11:56:14 2011
New Revision: 218015
URL: http://svn.freebsd.org/changeset/base/218015

Log:
  Document the "bios-boot" partition type.
  
  MFC after:2 weeks

Modified:
  head/sbin/geom/class/part/gpart.8

Modified: head/sbin/geom/class/part/gpart.8
==
--- head/sbin/geom/class/part/gpart.8   Fri Jan 28 11:13:01 2011
(r218014)
+++ head/sbin/geom/class/part/gpart.8   Fri Jan 28 11:56:14 2011
(r218015)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd January 12, 2011
+.Dd January 28, 2011
 .Dt GPART 8
 .Os
 .Sh NAME
@@ -509,6 +509,11 @@ utility also allows the user to specify 
 for partition types that do not have symbol names.
 The symbolic names currently understood are:
 .Bl -tag -width ".Cm freebsd-vinum"
+.It Cm bios-boot
+The system partition dedicated to second stage of the boot loader program.
+Usually it used by GRUB 2 loader when the partition table is GPT.
+The scheme-specific type is
+.Qq Li "!21686148-6449-6E6F-744E-656564454649" .
 .It Cm efi
 The system partition for computers that use the Extensible Firmware
 Interface (EFI).
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218019 - head/sys/kern

2011-01-28 Thread Jilles Tjoelker
Author: jilles
Date: Fri Jan 28 15:29:35 2011
New Revision: 218019
URL: http://svn.freebsd.org/changeset/base/218019

Log:
  Do not trip a KASSERT if /dev/null cannot be opened for a setuid program.
  
  The fdcheckstd() function makes sure fds 0, 1 and 2 are open by opening
  /dev/null. If this fails (e.g. missing devfs or wrong permissions),
  fdcheckstd() will return failure and the process will exit as if it received
  SIGABRT. The KASSERT is only to check that kern_open() returns the expected
  fd, given that it succeeded.
  
  Tripping the KASSERT is most likely if fd 0 is open but fd 1 or 2 are not.
  
  MFC after:2 weeks

Modified:
  head/sys/kern/kern_descrip.c

Modified: head/sys/kern/kern_descrip.c
==
--- head/sys/kern/kern_descrip.cFri Jan 28 15:25:46 2011
(r218018)
+++ head/sys/kern/kern_descrip.cFri Jan 28 15:29:35 2011
(r218019)
@@ -2024,10 +2024,10 @@ fdcheckstd(struct thread *td)
error = kern_open(td, "/dev/null", UIO_SYSSPACE,
O_RDWR, 0);
devnull = td->td_retval[0];
-   KASSERT(devnull == i, ("oof, we didn't get our fd"));
td->td_retval[0] = save;
if (error)
break;
+   KASSERT(devnull == i, ("oof, we didn't get our fd"));
} else {
error = do_dup(td, DUP_FIXED, devnull, i, &retval);
if (error != 0)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218025 - head/libexec/rtld-elf

2011-01-28 Thread Sergey Kandaurov
Author: pluknet
Date: Fri Jan 28 17:30:24 2011
New Revision: 218025
URL: http://svn.freebsd.org/changeset/base/218025

Log:
  Remove SuperH architecture from a comment as we do not support it.
  Presumably it was leaked from NetBSD together with rtld-elf mips support.
  
  Approved by:  kib (mentor)
  MFC after:3 days

Modified:
  head/libexec/rtld-elf/rtld.c

Modified: head/libexec/rtld-elf/rtld.c
==
--- head/libexec/rtld-elf/rtld.cFri Jan 28 17:10:37 2011
(r218024)
+++ head/libexec/rtld-elf/rtld.cFri Jan 28 17:30:24 2011
(r218025)
@@ -1385,7 +1385,7 @@ init_rtld(caddr_t mapbase, Elf_Auxinfo *
digest_dynamic1(&objtmp, 1, &dyn_rpath, &dyn_soname);
assert(objtmp.needed == NULL);
 #if !defined(__mips__)
-   /* MIPS and SH{3,5} have a bogus DT_TEXTREL. */
+   /* MIPS has a bogus DT_TEXTREL. */
assert(!objtmp.textrel);
 #endif
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218026 - head/sys/kern

2011-01-28 Thread Konstantin Belousov
Author: kib
Date: Fri Jan 28 17:37:09 2011
New Revision: 218026
URL: http://svn.freebsd.org/changeset/base/218026

Log:
  If more than one thread allocated sf buffers for sendfile(2), and
  each of the threads needs more while current pool of the buffers is
  exhausted, then neither thread can make progress.
  
  Switch to nowait allocations after we got first buffer already.
  
  Reported by:  az
  Reviewed by:  alc (previous version)
  Tested by:pho
  MFC after:1 week

Modified:
  head/sys/kern/uipc_syscalls.c

Modified: head/sys/kern/uipc_syscalls.c
==
--- head/sys/kern/uipc_syscalls.c   Fri Jan 28 17:30:24 2011
(r218025)
+++ head/sys/kern/uipc_syscalls.c   Fri Jan 28 17:37:09 2011
(r218026)
@@ -2126,18 +2126,25 @@ retry_space:
}
 
/*
-* Get a sendfile buf.  We usually wait as long
-* as necessary, but this wait can be interrupted.
+* Get a sendfile buf.  When allocating the
+* first buffer for mbuf chain, we usually
+* wait as long as necessary, but this wait
+* can be interrupted.  For consequent
+* buffers, do not sleep, since several
+* threads might exhaust the buffers and then
+* deadlock.
 */
-   if ((sf = sf_buf_alloc(pg,
-   (mnw ? SFB_NOWAIT : SFB_CATCH))) == NULL) {
+   sf = sf_buf_alloc(pg, (mnw || m != NULL) ? SFB_NOWAIT :
+   SFB_CATCH);
+   if (sf == NULL) {
mbstat.sf_allocfail++;
vm_page_lock(pg);
vm_page_unwire(pg, 0);
KASSERT(pg->object != NULL,
("kern_sendfile: object disappeared"));
vm_page_unlock(pg);
-   error = (mnw ? EAGAIN : EINTR);
+   if (m == NULL)
+   error = (mnw ? EAGAIN : EINTR);
break;
}
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218028 - head/sys/amd64/linux32

2011-01-28 Thread Dmitry Chagin
Author: dchagin
Date: Fri Jan 28 18:28:06 2011
New Revision: 218028
URL: http://svn.freebsd.org/changeset/base/218028

Log:
  To avoid excessive code duplication move struct rusage translation
  to a separate function.
  
  MFC after:1 Month.

Modified:
  head/sys/amd64/linux32/linux32_machdep.c

Modified: head/sys/amd64/linux32/linux32_machdep.c
==
--- head/sys/amd64/linux32/linux32_machdep.cFri Jan 28 18:25:51 2011
(r218027)
+++ head/sys/amd64/linux32/linux32_machdep.cFri Jan 28 18:28:06 2011
(r218028)
@@ -106,6 +106,28 @@ bsd_to_linux_sigaltstack(int bsa)
return (lsa);
 }
 
+static void bsd_to_linux_rusage(struct rusage *ru, struct l_rusage *lru)
+{
+   lru->ru_utime.tv_sec = ru->ru_utime.tv_sec;
+   lru->ru_utime.tv_usec = ru->ru_utime.tv_usec;
+   lru->ru_stime.tv_sec = ru->ru_stime.tv_sec;
+   lru->ru_stime.tv_usec = ru->ru_stime.tv_usec;
+   lru->ru_maxrss = ru->ru_maxrss;
+   lru->ru_ixrss = ru->ru_ixrss;
+   lru->ru_idrss = ru->ru_idrss;
+   lru->ru_isrss = ru->ru_isrss;
+   lru->ru_minflt = ru->ru_minflt;
+   lru->ru_majflt = ru->ru_majflt;
+   lru->ru_nswap = ru->ru_nswap;
+   lru->ru_inblock = ru->ru_inblock;
+   lru->ru_oublock = ru->ru_oublock;
+   lru->ru_msgsnd = ru->ru_msgsnd;
+   lru->ru_msgrcv = ru->ru_msgrcv;
+   lru->ru_nsignals = ru->ru_nsignals;
+   lru->ru_nvcsw = ru->ru_nvcsw;
+   lru->ru_nivcsw = ru->ru_nivcsw;
+}
+
 int
 linux_execve(struct thread *td, struct linux_execve_args *args)
 {
@@ -1126,24 +1148,7 @@ linux_getrusage(struct thread *td, struc
if (error != 0)
return (error);
if (uap->rusage != NULL) {
-   s32.ru_utime.tv_sec = s.ru_utime.tv_sec;
-   s32.ru_utime.tv_usec = s.ru_utime.tv_usec;
-   s32.ru_stime.tv_sec = s.ru_stime.tv_sec;
-   s32.ru_stime.tv_usec = s.ru_stime.tv_usec;
-   s32.ru_maxrss = s.ru_maxrss;
-   s32.ru_ixrss = s.ru_ixrss;
-   s32.ru_idrss = s.ru_idrss;
-   s32.ru_isrss = s.ru_isrss;
-   s32.ru_minflt = s.ru_minflt;
-   s32.ru_majflt = s.ru_majflt;
-   s32.ru_nswap = s.ru_nswap;
-   s32.ru_inblock = s.ru_inblock;
-   s32.ru_oublock = s.ru_oublock;
-   s32.ru_msgsnd = s.ru_msgsnd;
-   s32.ru_msgrcv = s.ru_msgrcv;
-   s32.ru_nsignals = s.ru_nsignals;
-   s32.ru_nvcsw = s.ru_nvcsw;
-   s32.ru_nivcsw = s.ru_nivcsw;
+   bsd_to_linux_rusage(&s, &s32);
error = copyout(&s32, uap->rusage, sizeof(s32));
}
return (error);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218030 - in head/sys: amd64/linux32 compat/linux i386/linux

2011-01-28 Thread Dmitry Chagin
Author: dchagin
Date: Fri Jan 28 18:47:07 2011
New Revision: 218030
URL: http://svn.freebsd.org/changeset/base/218030

Log:
  Implement a variation of the linux_common_wait() which should
  be used by linuxolator itself.
  
  Move linux_wait4() to MD path as it requires native struct
  rusage translation to struct l_rusage on linux32/amd64.
  
  MFC after:1 Month.

Modified:
  head/sys/amd64/linux32/linux32_machdep.c
  head/sys/compat/linux/linux_misc.c
  head/sys/compat/linux/linux_misc.h
  head/sys/i386/linux/linux_machdep.c

Modified: head/sys/amd64/linux32/linux32_machdep.c
==
--- head/sys/amd64/linux32/linux32_machdep.cFri Jan 28 18:42:17 2011
(r218029)
+++ head/sys/amd64/linux32/linux32_machdep.cFri Jan 28 18:47:07 2011
(r218030)
@@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -66,6 +67,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1272,3 +1274,44 @@ linux_set_thread_area(struct thread *td,
 
return (0);
 }
+
+int
+linux_wait4(struct thread *td, struct linux_wait4_args *args)
+{
+   int error, options;
+   struct rusage ru, *rup;
+   struct l_rusage lru;
+   struct proc *p;
+
+#ifdef DEBUG
+   if (ldebug(wait4))
+   printf(ARGS(wait4, "%d, %p, %d, %p"),
+   args->pid, (void *)args->status, args->options,
+   (void *)args->rusage);
+#endif
+
+   options = (args->options & (WNOHANG | WUNTRACED));
+   /* WLINUXCLONE should be equal to __WCLONE, but we make sure */
+   if (args->options & __WCLONE)
+   options |= WLINUXCLONE;
+
+   if (args->rusage != NULL)
+   rup = &ru;
+   else
+   rup = NULL;
+   error = linux_common_wait(td, args->pid, args->status, options, rup);
+   if (error)
+   return (error);
+
+   p = td->td_proc;
+   PROC_LOCK(p);
+   sigqueue_delete(&p->p_sigqueue, SIGCHLD);
+   PROC_UNLOCK(p);
+
+   if (args->rusage != NULL) {
+   bsd_to_linux_rusage(rup, &lru);
+   error = copyout(&lru, args->rusage, sizeof(lru));
+   }
+
+   return (error);
+}

Modified: head/sys/compat/linux/linux_misc.c
==
--- head/sys/compat/linux/linux_misc.c  Fri Jan 28 18:42:17 2011
(r218029)
+++ head/sys/compat/linux/linux_misc.c  Fri Jan 28 18:47:07 2011
(r218030)
@@ -847,35 +847,17 @@ linux_futimesat(struct thread *td, struc
 }
 #endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */
 
-#define __WCLONE 0x8000
-
 int
-linux_waitpid(struct thread *td, struct linux_waitpid_args *args)
+linux_common_wait(struct thread *td, int pid, int *status,
+int options, struct rusage *ru)
 {
-   int error, options, tmpstat;
-
-#ifdef DEBUG
-   if (ldebug(waitpid))
-   printf(ARGS(waitpid, "%d, %p, %d"),
-   args->pid, (void *)args->status, args->options);
-#endif
-   /*
-* this is necessary because the test in kern_wait doesn't work
-* because we mess with the options here
-*/
-   if (args->options & ~(WUNTRACED | WNOHANG | WCONTINUED | __WCLONE))
-   return (EINVAL);
+   int error, tmpstat;
 
-   options = (args->options & (WNOHANG | WUNTRACED));
-   /* WLINUXCLONE should be equal to __WCLONE, but we make sure */
-   if (args->options & __WCLONE)
-   options |= WLINUXCLONE;
-
-   error = kern_wait(td, args->pid, &tmpstat, options, NULL);
+   error = kern_wait(td, pid, &tmpstat, options, ru);
if (error)
-   return error;
+   return (error);
 
-   if (args->status) {
+   if (status) {
tmpstat &= 0x;
if (WIFSIGNALED(tmpstat))
tmpstat = (tmpstat & 0xff80) |
@@ -883,60 +865,38 @@ linux_waitpid(struct thread *td, struct 
else if (WIFSTOPPED(tmpstat))
tmpstat = (tmpstat & 0x00ff) |
(BSD_TO_LINUX_SIGNAL(WSTOPSIG(tmpstat)) << 8);
-   return copyout(&tmpstat, args->status, sizeof(int));
+   error = copyout(&tmpstat, status, sizeof(int));
}
 
-   return (0);
+   return (error);
 }
 
 int
-linux_wait4(struct thread *td, struct linux_wait4_args *args)
+linux_waitpid(struct thread *td, struct linux_waitpid_args *args)
 {
-   int error, options, tmpstat;
-   struct rusage ru, *rup;
-   struct proc *p;
-
+   int options;
+ 
 #ifdef DEBUG
-   if (ldebug(wait4))
-   printf(ARGS(wait4, "%d, %p, %d, %p"),
-   args->pid, (void *)args->status, args->options,
-   (void *)args->rusage);
+   if (ldebug(waitpid))
+   printf(ARG

svn commit: r218031 - head/sys/compat/linux

2011-01-28 Thread Dmitry Chagin
Author: dchagin
Date: Fri Jan 28 19:04:15 2011
New Revision: 218031
URL: http://svn.freebsd.org/changeset/base/218031

Log:
  Style(9) fixes.
  
  MFC after:1 Month.

Modified:
  head/sys/compat/linux/linux_misc.c

Modified: head/sys/compat/linux/linux_misc.c
==
--- head/sys/compat/linux/linux_misc.c  Fri Jan 28 18:47:07 2011
(r218030)
+++ head/sys/compat/linux/linux_misc.c  Fri Jan 28 19:04:15 2011
(r218031)
@@ -160,7 +160,7 @@ linux_sysinfo(struct thread *td, struct 
sysinfo.freebig = 0;
sysinfo.mem_unit = 1;
 
-   return copyout(&sysinfo, args->info, sizeof(sysinfo));
+   return (copyout(&sysinfo, args->info, sizeof(sysinfo)));
 }
 
 int
@@ -216,7 +216,7 @@ linux_brk(struct thread *td, struct linu
else
td->td_retval[0] = (long)old;
 
-   return 0;
+   return (0);
 }
 
 #if defined(__i386__)
@@ -468,7 +468,7 @@ cleanup:
vm_map_remove(kernel_map, (vm_offset_t)a_out,
(vm_offset_t)a_out + PAGE_SIZE);
 
-   return error;
+   return (error);
 }
 
 #endif /* __i386__ */
@@ -562,7 +562,7 @@ select_out:
if (ldebug(select))
printf(LMSG("select_out -> %d"), error);
 #endif
-   return error;
+   return (error);
 }
 
 int
@@ -602,7 +602,7 @@ linux_mremap(struct thread *td, struct l
 
if (args->new_len > args->old_len) {
td->td_retval[0] = 0;
-   return ENOMEM;
+   return (ENOMEM);
}
 
if (args->new_len < args->old_len) {
@@ -613,7 +613,7 @@ linux_mremap(struct thread *td, struct l
}
 
td->td_retval[0] = error ? 0 : (uintptr_t)args->addr;
-   return error;
+   return (error);
 }
 
 #define LINUX_MS_ASYNC   0x0001
@@ -629,7 +629,7 @@ linux_msync(struct thread *td, struct li
bsd_args.len = (uintptr_t)args->len;
bsd_args.flags = args->fl & ~LINUX_MS_SYNC;
 
-   return msync(td, &bsd_args);
+   return (msync(td, &bsd_args));
 }
 
 int
@@ -647,9 +647,9 @@ linux_time(struct thread *td, struct lin
microtime(&tv);
tm = tv.tv_sec;
if (args->tm && (error = copyout(&tm, args->tm, sizeof(tm
-   return error;
+   return (error);
td->td_retval[0] = tm;
-   return 0;
+   return (0);
 }
 
 struct l_times_argv {
@@ -702,12 +702,12 @@ linux_times(struct thread *td, struct li
tms.tms_cstime = CONVTCK(cstime);
 
if ((error = copyout(&tms, args->buf, sizeof(tms
-   return error;
+   return (error);
}
 
microuptime(&tv);
td->td_retval[0] = (int)CONVTCK(tv);
-   return 0;
+   return (0);
 }
 
 int
@@ -766,7 +766,7 @@ linux_utime(struct thread *td, struct li
if (args->times) {
if ((error = copyin(args->times, &lut, sizeof lut))) {
LFREEPATH(fname);
-   return error;
+   return (error);
}
tv[0].tv_sec = lut.l_actime;
tv[0].tv_usec = 0;
@@ -1003,11 +1003,11 @@ linux_personality(struct thread *td, str
printf(ARGS(personality, "%lu"), (unsigned long)args->per);
 #endif
if (args->per != 0)
-   return EINVAL;
+   return (EINVAL);
 
/* Yes Jim, it's still a Linux... */
td->td_retval[0] = 0;
-   return 0;
+   return (0);
 }
 
 struct l_itimerval {
@@ -1085,7 +1085,7 @@ linux_nice(struct thread *td, struct lin
bsd_args.which = PRIO_PROCESS;
bsd_args.who = 0;   /* current process */
bsd_args.prio = args->inc;
-   return setpriority(td, &bsd_args);
+   return (setpriority(td, &bsd_args));
 }
 
 int
@@ -1312,12 +1312,12 @@ linux_sched_setscheduler(struct thread *
bsd.policy = SCHED_RR;
break;
default:
-   return EINVAL;
+   return (EINVAL);
}
 
bsd.pid = args->pid;
bsd.param = (struct sched_param *)args->param;
-   return sched_setscheduler(td, &bsd);
+   return (sched_setscheduler(td, &bsd));
 }
 
 int
@@ -1347,7 +1347,7 @@ linux_sched_getscheduler(struct thread *
break;
}
 
-   return error;
+   return (error);
 }
 
 int
@@ -1372,9 +1372,9 @@ linux_sched_get_priority_max(struct thre
bsd.policy = SCHED_RR;
break;
default:
-   return EINVAL;
+   return (EINVAL);
}
-   return sched_get_priority_max(td, &bsd);
+   return (sched_get_priority_max(td, &bsd));
 }
 
 int
@@ -1399,9 +1399,9 @@ linux_sched_get_priority_min(struct thre
bsd.policy = SCHED_RR;
break;
default:
-   return EINVAL;
+   return (EINVAL);
}
-   return 

svn commit: r218037 - head/sys/netinet

2011-01-28 Thread Randall Stewart
Author: rrs
Date: Fri Jan 28 20:49:15 2011
New Revision: 218037
URL: http://svn.freebsd.org/changeset/base/218037

Log:
  Fix a bug in the way ECN-Echo chunk
  sends were being accounted for. The
  counting was such that we counted only
  when we queued a chunk, not when we sent it.
  Now keep an additional counter for queuing and
  one for sending.
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_output.c
  head/sys/netinet/sctp_uio.h

Modified: head/sys/netinet/sctp_output.c
==
--- head/sys/netinet/sctp_output.c  Fri Jan 28 20:22:03 2011
(r218036)
+++ head/sys/netinet/sctp_output.c  Fri Jan 28 20:49:15 2011
(r218037)
@@ -7809,6 +7809,20 @@ again_one_more_time:
if (chk->rec.chunk_id.id == 
SCTP_COOKIE_ECHO) {
cookie = 1;
no_out_cnt = 1;
+   } else if (chk->rec.chunk_id.id == 
SCTP_ECN_ECHO) {
+   /*
+* Increment ecne send count
+* here this means we may be
+* over-zealous in our
+* counting if the send
+* fails, but its the best
+* place to do it (we used
+* to do it in the queue of
+* the chunk, but that did
+* not tell how many times
+* it was sent.
+*/
+   SCTP_STAT_INCR(sctps_sendecne);
}
chk->sent = SCTP_DATAGRAM_SENT;
chk->snd_count++;
@@ -10751,6 +10765,7 @@ sctp_send_ecn_echo(struct sctp_tcb *stcb
/* found a previous ECN_ECHO update it if needed */
ecne = mtod(chk->data, struct sctp_ecne_chunk *);
ecne->tsn = htonl(high_tsn);
+   SCTP_STAT_INCR(sctps_queue_upd_ecne);
return;
}
}
@@ -10760,7 +10775,7 @@ sctp_send_ecn_echo(struct sctp_tcb *stcb
return;
}
chk->copy_by_ref = 0;
-   SCTP_STAT_INCR(sctps_sendecne);
+   SCTP_STAT_INCR(sctps_queue_upd_ecne);
chk->rec.chunk_id.id = SCTP_ECN_ECHO;
chk->rec.chunk_id.can_take_data = 0;
chk->asoc = &stcb->asoc;

Modified: head/sys/netinet/sctp_uio.h
==
--- head/sys/netinet/sctp_uio.h Fri Jan 28 20:22:03 2011(r218036)
+++ head/sys/netinet/sctp_uio.h Fri Jan 28 20:49:15 2011(r218037)
@@ -946,8 +946,9 @@ struct sctpstat {
 * max burst inflight to net */
uint32_t sctps_fwdtsn_map_over; /* number of map array over-runs via
 * fwd-tsn's */
-
-   uint32_t sctps_reserved[32];/* Future ABI compat - remove int's
+   uint32_t sctps_queue_upd_ecne;  /* Number of times we queued or
+* updated an ECN chunk on send queue */
+   uint32_t sctps_reserved[31];/* Future ABI compat - remove int's
 * from here when adding new */
 };
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218038 - head/sys/dev/alc

2011-01-28 Thread Pyun YongHyeon
Author: yongari
Date: Fri Jan 28 21:03:32 2011
New Revision: 218038
URL: http://svn.freebsd.org/changeset/base/218038

Log:
  Fix logic error. Due to the bug, it incorrectly checked TXQ status
  which in turn can leave TXQ active.
  
  Submitted by: Brad ( brad <> comstyle dot com )
  MFC after:3 days

Modified:
  head/sys/dev/alc/if_alc.c

Modified: head/sys/dev/alc/if_alc.c
==
--- head/sys/dev/alc/if_alc.c   Fri Jan 28 20:49:15 2011(r218037)
+++ head/sys/dev/alc/if_alc.c   Fri Jan 28 21:03:32 2011(r218038)
@@ -3556,7 +3556,7 @@ alc_stop_queue(struct alc_softc *sc)
}
/* Disable TxQ. */
reg = CSR_READ_4(sc, ALC_TXQ_CFG);
-   if ((reg & TXQ_CFG_ENB) == 0) {
+   if ((reg & TXQ_CFG_ENB) != 0) {
reg &= ~TXQ_CFG_ENB;
CSR_WRITE_4(sc, ALC_TXQ_CFG, reg);
}
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218039 - head/sys/netinet

2011-01-28 Thread Randall Stewart
Author: rrs
Date: Fri Jan 28 21:05:21 2011
New Revision: 218039
URL: http://svn.freebsd.org/changeset/base/218039

Log:
  Keep track of the real last RTT on each net.
  This will be used for Data Center congestion
  control, we won't want to engage it in the
  ECN code unless we KNOW that the RTT is less
  than 500us.
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_structs.h
  head/sys/netinet/sctputil.c

Modified: head/sys/netinet/sctp_structs.h
==
--- head/sys/netinet/sctp_structs.h Fri Jan 28 21:03:32 2011
(r218038)
+++ head/sys/netinet/sctp_structs.h Fri Jan 28 21:05:21 2011
(r218039)
@@ -266,7 +266,7 @@ struct sctp_nets {
uint32_t tos_flowlabel;
 
struct timeval start_time;  /* time when this net was created */
-
+   struct timeval last_measured_rtt;
uint32_t marked_retrans;/* number or DATA chunks marked for timer
 * based retransmissions */
uint32_t marked_fastretrans;

Modified: head/sys/netinet/sctputil.c
==
--- head/sys/netinet/sctputil.c Fri Jan 28 21:03:32 2011(r218038)
+++ head/sys/netinet/sctputil.c Fri Jan 28 21:05:21 2011(r218039)
@@ -2500,6 +2500,13 @@ sctp_calculate_rto(struct sctp_tcb *stcb
//
/* get the current time */
(void)SCTP_GETTIME_TIMEVAL(&now);
+
+   /*
+* Record the real time of the last RTT for use in DC-CC.
+*/
+   net->last_measured_rtt = now;
+   timevalsub(&net->last_measured_rtt, old);
+
/* compute the RTT value */
if ((u_long)now.tv_sec > (u_long)old->tv_sec) {
calc_time = ((u_long)now.tv_sec - (u_long)old->tv_sec) * 1000;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218040 - head/sbin/hastd

2011-01-28 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Jan 28 21:36:01 2011
New Revision: 218040
URL: http://svn.freebsd.org/changeset/base/218040

Log:
  Initialize all global variables on pjdlog_init().
  
  MFC after:1 week

Modified:
  head/sbin/hastd/pjdlog.c

Modified: head/sbin/hastd/pjdlog.c
==
--- head/sbin/hastd/pjdlog.cFri Jan 28 21:05:21 2011(r218039)
+++ head/sbin/hastd/pjdlog.cFri Jan 28 21:36:01 2011(r218040)
@@ -43,8 +43,7 @@ __FBSDID("$FreeBSD$");
 #include "pjdlog.h"
 
 static bool pjdlog_initialized = false;
-static int pjdlog_mode = PJDLOG_MODE_STD;
-static int pjdlog_debug_level = 0;
+static int pjdlog_mode, pjdlog_debug_level;
 static char pjdlog_prefix[128];
 
 void
@@ -57,6 +56,8 @@ pjdlog_init(int mode)
if (mode == PJDLOG_MODE_SYSLOG)
openlog(NULL, LOG_PID | LOG_NDELAY, LOG_DAEMON);
pjdlog_mode = mode;
+   pjdlog_debug_level = 0;
+   bzero(pjdlog_prefix, sizeof(pjdlog_prefix));
 
pjdlog_initialized = true;
 }
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218041 - head/sbin/hastd

2011-01-28 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Jan 28 21:48:15 2011
New Revision: 218041
URL: http://svn.freebsd.org/changeset/base/218041

Log:
  Add function to close all unneeded descriptors after fork(2).
  
  MFC after:1 week

Modified:
  head/sbin/hastd/hastd.c
  head/sbin/hastd/hastd.h

Modified: head/sbin/hastd/hastd.c
==
--- head/sbin/hastd/hastd.c Fri Jan 28 21:36:01 2011(r218040)
+++ head/sbin/hastd/hastd.c Fri Jan 28 21:48:15 2011(r218041)
@@ -1,6 +1,6 @@
 /*-
  * Copyright (c) 2009-2010 The FreeBSD Foundation
- * Copyright (c) 2010 Pawel Jakub Dawidek 
+ * Copyright (c) 2010-2011 Pawel Jakub Dawidek 
  * All rights reserved.
  *
  * This software was developed by Pawel Jakub Dawidek under sponsorship from
@@ -93,6 +93,32 @@ g_gate_load(void)
}
 }
 
+void
+descriptors_cleanup(struct hast_resource *res)
+{
+   struct hast_resource *tres;
+
+   TAILQ_FOREACH(tres, &cfg->hc_resources, hr_next) {
+   if (tres == res) {
+   PJDLOG_VERIFY(res->hr_role == HAST_ROLE_SECONDARY ||
+   (res->hr_remotein == NULL &&
+res->hr_remoteout == NULL));
+   continue;
+   }
+   if (tres->hr_remotein != NULL)
+   proto_close(tres->hr_remotein);
+   if (tres->hr_remoteout != NULL)
+   proto_close(tres->hr_remoteout);
+   }
+   if (cfg->hc_controlin != NULL)
+   proto_close(cfg->hc_controlin);
+   proto_close(cfg->hc_controlconn);
+   proto_close(cfg->hc_listenconn);
+   (void)pidfile_close(pfh);
+   hook_fini();
+   pjdlog_fini();
+}
+
 static void
 child_exit_log(unsigned int pid, int status)
 {

Modified: head/sbin/hastd/hastd.h
==
--- head/sbin/hastd/hastd.h Fri Jan 28 21:36:01 2011(r218040)
+++ head/sbin/hastd/hastd.h Fri Jan 28 21:48:15 2011(r218041)
@@ -43,6 +43,8 @@ extern const char *cfgpath;
 extern bool sigexit_received;
 extern struct pidfh *pfh;
 
+void descriptors_cleanup(struct hast_resource *res);
+
 void hastd_primary(struct hast_resource *res);
 void hastd_secondary(struct hast_resource *res, struct nv *nvin);
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218042 - head/sbin/hastd

2011-01-28 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Jan 28 21:51:40 2011
New Revision: 218042
URL: http://svn.freebsd.org/changeset/base/218042

Log:
  Add comments to places where we treat errors as ciritical, but it is possible
  to handle them more gracefully.
  
  MFC after:1 week

Modified:
  head/sbin/hastd/primary.c

Modified: head/sbin/hastd/primary.c
==
--- head/sbin/hastd/primary.c   Fri Jan 28 21:48:15 2011(r218041)
+++ head/sbin/hastd/primary.c   Fri Jan 28 21:51:40 2011(r218042)
@@ -796,6 +796,7 @@ hastd_primary(struct hast_resource *res)
 * Create communication channel between parent and child.
 */
if (proto_client("socketpair://", &res->hr_ctrl) < 0) {
+   /* TODO: There's no need for this to be fatal error. */
KEEP_ERRNO((void)pidfile_remove(pfh));
pjdlog_exit(EX_OSERR,
"Unable to create control sockets between parent and 
child");
@@ -804,6 +805,7 @@ hastd_primary(struct hast_resource *res)
 * Create communication channel between child and parent.
 */
if (proto_client("socketpair://", &res->hr_event) < 0) {
+   /* TODO: There's no need for this to be fatal error. */
KEEP_ERRNO((void)pidfile_remove(pfh));
pjdlog_exit(EX_OSERR,
"Unable to create event sockets between child and parent");
@@ -811,6 +813,7 @@ hastd_primary(struct hast_resource *res)
 
pid = fork();
if (pid < 0) {
+   /* TODO: There's no need for this to be fatal error. */
KEEP_ERRNO((void)pidfile_remove(pfh));
pjdlog_exit(EX_TEMPFAIL, "Unable to fork");
}
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218043 - head/sbin/hastd

2011-01-28 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Jan 28 21:52:37 2011
New Revision: 218043
URL: http://svn.freebsd.org/changeset/base/218043

Log:
  Close all unneeded descriptors after fork(2).
  
  MFC after:1 week

Modified:
  head/sbin/hastd/primary.c
  head/sbin/hastd/secondary.c

Modified: head/sbin/hastd/primary.c
==
--- head/sbin/hastd/primary.c   Fri Jan 28 21:51:40 2011(r218042)
+++ head/sbin/hastd/primary.c   Fri Jan 28 21:52:37 2011(r218043)
@@ -790,7 +790,7 @@ hastd_primary(struct hast_resource *res)
 {
pthread_t td;
pid_t pid;
-   int error;
+   int error, mode;
 
/*
 * Create communication channel between parent and child.
@@ -822,19 +822,24 @@ hastd_primary(struct hast_resource *res)
/* This is parent. */
/* Declare that we are receiver. */
proto_recv(res->hr_event, NULL, 0);
+   /* Declare that we are sender. */
+   proto_send(res->hr_ctrl, NULL, 0);
res->hr_workerpid = pid;
return;
}
 
gres = res;
-
-   (void)pidfile_close(pfh);
-   hook_fini();
-
-   setproctitle("%s (primary)", res->hr_name);
+   mode = pjdlog_mode_get();
 
/* Declare that we are sender. */
proto_send(res->hr_event, NULL, 0);
+   /* Declare that we are receiver. */
+   proto_recv(res->hr_ctrl, NULL, 0);
+   descriptors_cleanup(res);
+
+   pjdlog_init(mode);
+   pjdlog_prefix_set("[%s] (%s) ", res->hr_name, role2str(res->hr_role));
+   setproctitle("%s (primary)", res->hr_name);
 
init_local(res);
init_ggate(res);

Modified: head/sbin/hastd/secondary.c
==
--- head/sbin/hastd/secondary.c Fri Jan 28 21:51:40 2011(r218042)
+++ head/sbin/hastd/secondary.c Fri Jan 28 21:52:37 2011(r218043)
@@ -347,7 +347,7 @@ hastd_secondary(struct hast_resource *re
sigset_t mask;
pthread_t td;
pid_t pid;
-   int error;
+   int error, mode;
 
/*
 * Create communication channel between parent and child.
@@ -380,23 +380,28 @@ hastd_secondary(struct hast_resource *re
res->hr_remoteout = NULL;
/* Declare that we are receiver. */
proto_recv(res->hr_event, NULL, 0);
+   /* Declare that we are sender. */
+   proto_send(res->hr_ctrl, NULL, 0);
res->hr_workerpid = pid;
return;
}
 
gres = res;
+   mode = pjdlog_mode_get();
 
-   (void)pidfile_close(pfh);
-   hook_fini();
+   /* Declare that we are sender. */
+   proto_send(res->hr_event, NULL, 0);
+   /* Declare that we are receiver. */
+   proto_recv(res->hr_ctrl, NULL, 0);
+   descriptors_cleanup(res);
 
+   pjdlog_init(mode);
+   pjdlog_prefix_set("[%s] (%s) ", res->hr_name, role2str(res->hr_role));
setproctitle("%s (secondary)", res->hr_name);
 
PJDLOG_VERIFY(sigemptyset(&mask) == 0);
PJDLOG_VERIFY(sigprocmask(SIG_SETMASK, &mask, NULL) == 0);
 
-   /* Declare that we are sender. */
-   proto_send(res->hr_event, NULL, 0);
-
/* Error in setting timeout is not critical, but why should it fail? */
if (proto_timeout(res->hr_remotein, 0) < 0)
pjdlog_errno(LOG_WARNING, "Unable to set connection timeout");
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218044 - head/sbin/hastd

2011-01-28 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Jan 28 21:56:47 2011
New Revision: 218044
URL: http://svn.freebsd.org/changeset/base/218044

Log:
  Add function to assert that the only descriptors we have open are the ones
  we expect to be open. Also assert that they point at expected type.
  
  Because openlog(3) API is unable to tell us descriptor number it is using, we
  have to close syslog socket, remember assert message in local buffer and if we
  fail on assertion, reopen syslog socket and log the message.
  
  MFC after:1 week

Modified:
  head/sbin/hastd/hastd.c
  head/sbin/hastd/hastd.h

Modified: head/sbin/hastd/hastd.c
==
--- head/sbin/hastd/hastd.c Fri Jan 28 21:52:37 2011(r218043)
+++ head/sbin/hastd/hastd.c Fri Jan 28 21:56:47 2011(r218044)
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -119,6 +120,146 @@ descriptors_cleanup(struct hast_resource
pjdlog_fini();
 }
 
+static const char *
+dtype2str(mode_t mode)
+{
+
+   if (S_ISBLK(mode))
+   return ("block device");
+   else if (S_ISCHR(mode)) 
+   return ("character device");
+   else if (S_ISDIR(mode)) 
+   return ("directory");
+   else if (S_ISFIFO(mode))
+   return ("pipe or FIFO");
+   else if (S_ISLNK(mode)) 
+   return ("symbolic link");
+   else if (S_ISREG(mode)) 
+   return ("regular file");
+   else if (S_ISSOCK(mode))
+   return ("socket");
+   else if (S_ISWHT(mode)) 
+   return ("whiteout");
+   else
+   return ("unknown");
+}
+
+void
+descriptors_assert(const struct hast_resource *res, int pjdlogmode)
+{
+   char msg[256];
+   struct stat sb;
+   long maxfd;
+   bool isopen;
+   mode_t mode;
+   int fd;
+
+   /*
+* At this point descriptor to syslog socket is closed, so if we want
+* to log assertion message, we have to first store it in 'msg' local
+* buffer and then open syslog socket and log it.
+*/
+   msg[0] = '\0';
+
+   maxfd = sysconf(_SC_OPEN_MAX);
+   if (maxfd < 0) {
+   pjdlog_errno(LOG_WARNING, "sysconf(_SC_OPEN_MAX) failed");
+   maxfd = 16384;
+   }
+   for (fd = 0; fd <= maxfd; fd++) {
+   if (fstat(fd, &sb) == 0) {
+   isopen = true;
+   mode = sb.st_mode;
+   } else if (errno == EBADF) {
+   isopen = false;
+   mode = 0;
+   } else {
+   isopen = true;  /* silence gcc */
+   mode = 0;   /* silence gcc */
+   snprintf(msg, sizeof(msg),
+   "Unable to fstat descriptor %d: %s", fd,
+   strerror(errno));
+   }
+   if (fd == STDIN_FILENO || fd == STDOUT_FILENO ||
+   fd == STDERR_FILENO) {
+   if (!isopen) {
+   snprintf(msg, sizeof(msg),
+   "Descriptor %d (%s) is closed, but should 
be open.",
+   fd, (fd == STDIN_FILENO ? "stdin" :
+   (fd == STDOUT_FILENO ? "stdout" : 
"stderr")));
+   break;
+   }
+   } else if (fd == proto_descriptor(res->hr_event)) {
+   if (!isopen) {
+   snprintf(msg, sizeof(msg),
+   "Descriptor %d (event) is closed, but 
should be open.",
+   fd);
+   break;
+   }
+   if (!S_ISSOCK(mode)) {
+   snprintf(msg, sizeof(msg),
+   "Descriptor %d (event) is %s, but should be 
%s.",
+   fd, dtype2str(mode), dtype2str(S_IFSOCK));
+   break;
+   }
+   } else if (fd == proto_descriptor(res->hr_ctrl)) {
+   if (!isopen) {
+   snprintf(msg, sizeof(msg),
+   "Descriptor %d (ctrl) is closed, but should 
be open.",
+   fd);
+   break;
+   }
+   if (!S_ISSOCK(mode)) {
+   snprintf(msg, sizeof(msg),
+   "Descriptor %d (ctrl) is %s, but should be 
%s.",
+   fd, dtype2str(mode), dtype2str(S_IFSOCK));
+   break;
+   }
+   } else if (res->hr_role == HAST_ROLE_SECONDARY &&
+   fd == prot

svn commit: r218045 - head/sbin/hastd

2011-01-28 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Jan 28 21:57:42 2011
New Revision: 218045
URL: http://svn.freebsd.org/changeset/base/218045

Log:
  Use newly added descriptors_assert() function to ensure only expected
  descriptors are open.
  
  MFC after:1 week

Modified:
  head/sbin/hastd/primary.c
  head/sbin/hastd/secondary.c

Modified: head/sbin/hastd/primary.c
==
--- head/sbin/hastd/primary.c   Fri Jan 28 21:56:47 2011(r218044)
+++ head/sbin/hastd/primary.c   Fri Jan 28 21:57:42 2011(r218045)
@@ -837,6 +837,8 @@ hastd_primary(struct hast_resource *res)
proto_recv(res->hr_ctrl, NULL, 0);
descriptors_cleanup(res);
 
+   descriptors_assert(res, mode);
+
pjdlog_init(mode);
pjdlog_prefix_set("[%s] (%s) ", res->hr_name, role2str(res->hr_role));
setproctitle("%s (primary)", res->hr_name);

Modified: head/sbin/hastd/secondary.c
==
--- head/sbin/hastd/secondary.c Fri Jan 28 21:56:47 2011(r218044)
+++ head/sbin/hastd/secondary.c Fri Jan 28 21:57:42 2011(r218045)
@@ -395,6 +395,8 @@ hastd_secondary(struct hast_resource *re
proto_recv(res->hr_ctrl, NULL, 0);
descriptors_cleanup(res);
 
+   descriptors_assert(res, mode);
+
pjdlog_init(mode);
pjdlog_prefix_set("[%s] (%s) ", res->hr_name, role2str(res->hr_role));
setproctitle("%s (secondary)", res->hr_name);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218046 - head/etc

2011-01-28 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Jan 28 22:28:12 2011
New Revision: 218046
URL: http://svn.freebsd.org/changeset/base/218046

Log:
  Add 'hast' user and 'hast' group that will be used by hastd (and maybe 
hastctl)
  to drop privileges.
  
  MFC after:1 week

Modified:
  head/etc/group
  head/etc/master.passwd

Modified: head/etc/group
==
--- head/etc/group  Fri Jan 28 21:57:42 2011(r218045)
+++ head/etc/group  Fri Jan 28 22:28:12 2011(r218046)
@@ -27,5 +27,6 @@ dialer:*:68:
 network:*:69:
 audit:*:77:
 www:*:80:
+hast:*:845:
 nogroup:*:65533:
 nobody:*:65534:

Modified: head/etc/master.passwd
==
--- head/etc/master.passwd  Fri Jan 28 21:57:42 2011(r218045)
+++ head/etc/master.passwd  Fri Jan 28 22:28:12 2011(r218046)
@@ -20,4 +20,5 @@ _dhcp:*:65:65::0:0:dhcp programs:/var/em
 uucp:*:66:66::0:0:UUCP 
pseudo-user:/var/spool/uucppublic:/usr/local/libexec/uucp/uucico
 pop:*:68:6::0:0:Post Office Owner:/nonexistent:/usr/sbin/nologin
 www:*:80:80::0:0:World Wide Web Owner:/nonexistent:/usr/sbin/nologin
+hast:*:845:845::0:0:HAST unprivileged user:/nonexistent:/usr/sbin/nologin
 nobody:*:65534:65534::0:0:Unprivileged user:/nonexistent:/usr/sbin/nologin
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218047 - head/etc

2011-01-28 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Jan 28 22:29:38 2011
New Revision: 218047
URL: http://svn.freebsd.org/changeset/base/218047

Log:
  Change hast user home directory to /var/empty.
  
  MFC after:1 week

Modified:
  head/etc/master.passwd

Modified: head/etc/master.passwd
==
--- head/etc/master.passwd  Fri Jan 28 22:28:12 2011(r218046)
+++ head/etc/master.passwd  Fri Jan 28 22:29:38 2011(r218047)
@@ -20,5 +20,5 @@ _dhcp:*:65:65::0:0:dhcp programs:/var/em
 uucp:*:66:66::0:0:UUCP 
pseudo-user:/var/spool/uucppublic:/usr/local/libexec/uucp/uucico
 pop:*:68:6::0:0:Post Office Owner:/nonexistent:/usr/sbin/nologin
 www:*:80:80::0:0:World Wide Web Owner:/nonexistent:/usr/sbin/nologin
-hast:*:845:845::0:0:HAST unprivileged user:/nonexistent:/usr/sbin/nologin
+hast:*:845:845::0:0:HAST unprivileged user:/var/empty:/usr/sbin/nologin
 nobody:*:65534:65534::0:0:Unprivileged user:/nonexistent:/usr/sbin/nologin
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218048 - head/sbin/hastd

2011-01-28 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Jan 28 22:33:47 2011
New Revision: 218048
URL: http://svn.freebsd.org/changeset/base/218048

Log:
  Implement function that drops privileges by:
  - chrooting to /var/empty (user hast home directory),
  - setting groups to 'hast' (user hast primary group),
  - setting real group id, effective group id and saved group id to 'hast',
  - setting real user id, effective user id and saved user id to 'hast'.
  At the end verify that those operations where successfull.
  
  MFC after:1 week

Modified:
  head/sbin/hastd/hast.h
  head/sbin/hastd/subr.c
  head/sbin/hastd/subr.h

Modified: head/sbin/hastd/hast.h
==
--- head/sbin/hastd/hast.h  Fri Jan 28 22:29:38 2011(r218047)
+++ head/sbin/hastd/hast.h  Fri Jan 28 22:33:47 2011(r218048)
@@ -81,6 +81,7 @@
 #defineHIO_FLUSH   4
 #defineHIO_KEEPALIVE   5
 
+#defineHAST_USER   "hast"
 #defineHAST_TIMEOUT5
 #defineHAST_CONFIG "/etc/hast.conf"
 #defineHAST_CONTROL"/var/run/hastctl"

Modified: head/sbin/hastd/subr.c
==
--- head/sbin/hastd/subr.c  Fri Jan 28 22:29:38 2011(r218047)
+++ head/sbin/hastd/subr.c  Fri Jan 28 22:33:47 2011(r218048)
@@ -38,6 +38,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 
@@ -116,3 +118,73 @@ role2str(int role)
}
return ("unknown");
 }
+
+int
+drop_privs(void)
+{
+   struct passwd *pw;
+   uid_t ruid, euid, suid;
+   gid_t rgid, egid, sgid;
+   gid_t gidset[1];
+
+   /*
+* According to getpwnam(3) we have to clear errno before calling the
+* function to be able to distinguish between an error and missing
+* entry (with is not treated as error by getpwnam(3)).
+*/
+   errno = 0;
+   pw = getpwnam(HAST_USER);
+   if (pw == NULL) {
+   if (errno != 0) {
+   KEEP_ERRNO(pjdlog_errno(LOG_ERR,
+   "Unable to find info about '%s' user", HAST_USER));
+   return (-1);
+   } else {
+   pjdlog_error("'%s' user doesn't exist.", HAST_USER);
+   errno = ENOENT;
+   return (-1);
+   }
+   }
+   if (chroot(pw->pw_dir) == -1) {
+   KEEP_ERRNO(pjdlog_errno(LOG_ERR,
+   "Unable to change root directory to %s", pw->pw_dir));
+   return (-1);
+   }
+   PJDLOG_VERIFY(chdir("/") == 0);
+   gidset[0] = pw->pw_gid;
+   if (setgroups(1, gidset) == -1) {
+   KEEP_ERRNO(pjdlog_errno(LOG_ERR,
+   "Unable to set groups to gid %u",
+   (unsigned int)pw->pw_gid));
+   return (-1);
+   }
+   if (setgid(pw->pw_gid) == -1) {
+   KEEP_ERRNO(pjdlog_errno(LOG_ERR, "Unable to set gid to %u",
+   (unsigned int)pw->pw_gid));
+   return (-1);
+   }
+   if (setuid(pw->pw_uid) == -1) {
+   KEEP_ERRNO(pjdlog_errno(LOG_ERR, "Unable to set uid to %u",
+   (unsigned int)pw->pw_uid));
+   return (-1);
+   }
+
+   /*
+* Better be sure that everything succeeded.
+*/
+   PJDLOG_VERIFY(getresuid(&ruid, &euid, &suid) == 0);
+   PJDLOG_VERIFY(ruid == pw->pw_uid);
+   PJDLOG_VERIFY(euid == pw->pw_uid);
+   PJDLOG_VERIFY(suid == pw->pw_uid);
+   PJDLOG_VERIFY(getresgid(&rgid, &egid, &sgid) == 0);
+   PJDLOG_VERIFY(rgid == pw->pw_gid);
+   PJDLOG_VERIFY(egid == pw->pw_gid);
+   PJDLOG_VERIFY(sgid == pw->pw_gid);
+   PJDLOG_VERIFY(getgroups(0, NULL) == 1);
+   PJDLOG_VERIFY(getgroups(1, gidset) == 1);
+   PJDLOG_VERIFY(gidset[0] == pw->pw_gid);
+
+   pjdlog_info("Privileges successfully dropped.");
+
+   return (0);
+}

Modified: head/sbin/hastd/subr.h
==
--- head/sbin/hastd/subr.h  Fri Jan 28 22:29:38 2011(r218047)
+++ head/sbin/hastd/subr.h  Fri Jan 28 22:33:47 2011(r218048)
@@ -47,5 +47,6 @@
 
 int provinfo(struct hast_resource *res, bool dowrite);
 const char *role2str(int role);
+int drop_privs(void);
 
 #endif /* !_SUBR_H_ */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218049 - head/sbin/hastd

2011-01-28 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Jan 28 22:35:46 2011
New Revision: 218049
URL: http://svn.freebsd.org/changeset/base/218049

Log:
  Drop privileges in worker processes.
  
  Accepting connections and handshaking in secondary is still done before
  dropping privileges. It should be implemented by only accepting connections in
  privileged main process and passing connection descriptors to the worker, but
  is not implemented yet.
  
  MFC after:1 week

Modified:
  head/sbin/hastd/primary.c
  head/sbin/hastd/secondary.c

Modified: head/sbin/hastd/primary.c
==
--- head/sbin/hastd/primary.c   Fri Jan 28 22:33:47 2011(r218048)
+++ head/sbin/hastd/primary.c   Fri Jan 28 22:35:46 2011(r218049)
@@ -847,6 +847,11 @@ hastd_primary(struct hast_resource *res)
init_ggate(res);
init_environment(res);
 
+   if (drop_privs() != 0) {
+   cleanup(res);
+   exit(EX_CONFIG);
+   }
+
/*
 * Create the guard thread first, so we can handle signals from the
 * very begining.

Modified: head/sbin/hastd/secondary.c
==
--- head/sbin/hastd/secondary.c Fri Jan 28 22:33:47 2011(r218048)
+++ head/sbin/hastd/secondary.c Fri Jan 28 22:35:46 2011(r218049)
@@ -413,6 +413,9 @@ hastd_secondary(struct hast_resource *re
init_local(res);
init_environment();
 
+   if (drop_privs() != 0)
+   exit(EX_CONFIG);
+
/*
 * Create the control thread before sending any event to the parent,
 * as we can deadlock when parent sends control request to worker,
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218050 - head/sys/dev/tsec

2011-01-28 Thread Marcel Moolenaar
Author: marcel
Date: Fri Jan 28 23:40:13 2011
New Revision: 218050
URL: http://svn.freebsd.org/changeset/base/218050

Log:
  Don't use the MAC address in the device tree if it's all zeroes
  (i.e. 00-00-00-00-00-00). Use the currently programmed address
  instead.
  
  While here, simplify the function.

Modified:
  head/sys/dev/tsec/if_tsec_fdt.c

Modified: head/sys/dev/tsec/if_tsec_fdt.c
==
--- head/sys/dev/tsec/if_tsec_fdt.c Fri Jan 28 22:35:46 2011
(r218049)
+++ head/sys/dev/tsec/if_tsec_fdt.c Fri Jan 28 23:40:13 2011
(r218050)
@@ -320,17 +320,15 @@ tsec_get_hwaddr(struct tsec_softc *sc, u
union {
uint32_t reg[2];
uint8_t addr[6];
-   } curmac;
-   uint32_t a[6];
-   uint8_t lma[6];
+   } hw;
int i;
 
-   /*
-* Retrieve hw address from the device tree.
-*/
-   i = OF_getprop(sc->node, "local-mac-address", (void *)lma, 6);
-   if (i == 6) {
-   bcopy(lma, addr, 6);
+   hw.reg[0] = hw.reg[1] = 0;
+
+   /* Retrieve the hardware address from the device tree. */
+   i = OF_getprop(sc->node, "local-mac-address", (void *)hw.addr, 6);
+   if (i == 6 && (hw.reg[0] != 0 || hw.reg[1] != 0)) {
+   bcopy(hw.addr, addr, 6);
return;
}
 
@@ -338,15 +336,8 @@ tsec_get_hwaddr(struct tsec_softc *sc, u
 * Fall back -- use the currently programmed address in the hope that
 * it was set be firmware...
 */
-   curmac.reg[0] = TSEC_READ(sc, TSEC_REG_MACSTNADDR1);
-   curmac.reg[1] = TSEC_READ(sc, TSEC_REG_MACSTNADDR2);
+   hw.reg[0] = TSEC_READ(sc, TSEC_REG_MACSTNADDR1);
+   hw.reg[1] = TSEC_READ(sc, TSEC_REG_MACSTNADDR2);
for (i = 0; i < 6; i++)
-   a[5-i] = curmac.addr[i];
-
-   addr[0] = a[0];
-   addr[1] = a[1];
-   addr[2] = a[2];
-   addr[3] = a[3];
-   addr[4] = a[4];
-   addr[5] = a[5];
+   addr[5-i] = hw.addr[i];
 }
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218051 - head/libexec/rtld-elf

2011-01-28 Thread Alexander Kabaev
Author: kan
Date: Fri Jan 28 23:44:57 2011
New Revision: 218051
URL: http://svn.freebsd.org/changeset/base/218051

Log:
  Eliminate the use of symlook_needed function in favor of DAGS.
  
  Place elements on DAG lists in breadth-first order. This allows us to
  walk pre-built list in all cases where breadth-first dependency chain
  enumeration is required.
  
  Fix dlsym on special handle obtained by dlopen(NULL, ...) to do what
  comment claims it does. Take advantage of recently added symlook_global
  function to iterate over main objects and global DAGs lists properly in
  search of a symbol. Since rtld itself provides part of the global
  namespace, search rtld_obj too.
  
  Remove recursion from init_dag and symlook_needed functions. Use
  symlook_needed for ELF filtee processing only and change lookup order
  used in the function to match the order used by Solaris runtime linker
  under same circumstances. While there, fix weak symbol handling in the
  loop so that we return the first weak symbol definition if no strong one
  was found, instead of the last one.
  
  Reviewed by: kib
  MFC after:   1 month

Modified:
  head/libexec/rtld-elf/rtld.c

Modified: head/libexec/rtld-elf/rtld.c
==
--- head/libexec/rtld-elf/rtld.cFri Jan 28 23:40:13 2011
(r218050)
+++ head/libexec/rtld-elf/rtld.cFri Jan 28 23:44:57 2011
(r218051)
@@ -93,7 +93,6 @@ static void *fill_search_info(const char
 static char *find_library(const char *, const Obj_Entry *);
 static const char *gethints(void);
 static void init_dag(Obj_Entry *);
-static void init_dag1(Obj_Entry *, Obj_Entry *, DoneList *);
 static void init_rtld(caddr_t, Elf_Auxinfo **);
 static void initlist_add_neededs(Needed_Entry *, Objlist *);
 static void initlist_add_objects(Obj_Entry *, Obj_Entry **, Objlist *);
@@ -1331,28 +1330,33 @@ gethints(void)
 static void
 init_dag(Obj_Entry *root)
 {
+const Needed_Entry *needed;
+const Objlist_Entry *elm;
 DoneList donelist;
 
 if (root->dag_inited)
return;
 donelist_init(&donelist);
-init_dag1(root, root, &donelist);
-root->dag_inited = true;
-}
 
-static void
-init_dag1(Obj_Entry *root, Obj_Entry *obj, DoneList *dlp)
-{
-const Needed_Entry *needed;
-
-if (donelist_check(dlp, obj))
-   return;
+/* Root object belongs to own DAG. */
+objlist_push_tail(&root->dldags, root);
+objlist_push_tail(&root->dagmembers, root);
+donelist_check(&donelist, root);
 
-objlist_push_tail(&obj->dldags, root);
-objlist_push_tail(&root->dagmembers, obj);
-for (needed = obj->needed;  needed != NULL;  needed = needed->next)
-   if (needed->obj != NULL)
-   init_dag1(root, needed->obj, dlp);
+/*
+ * Add dependencies of root object to DAG in breadth order
+ * by exploiting the fact that each new object get added
+ * to the tail of the dagmembers list.
+ */
+STAILQ_FOREACH(elm, &root->dagmembers, link) {
+   for (needed = elm->obj->needed; needed != NULL; needed = needed->next) {
+   if (needed->obj == NULL || donelist_check(&donelist, needed->obj))
+   continue;
+   objlist_push_tail(&needed->obj->dldags, root);
+   objlist_push_tail(&root->dagmembers, needed->obj);
+   }
+}
+root->dag_inited = true;
 }
 
 /*
@@ -2320,32 +2324,28 @@ do_dlsym(void *handle, const char *name,
 
donelist_init(&donelist);
if (obj->mainprog) {
-   /* Search main program and all libraries loaded by it. */
-   res = symlook_list(&req, &list_main, &donelist);
+/* Handle obtained by dlopen(NULL, ...) implies global scope. */
+   res = symlook_global(&req, &donelist);
if (res == 0) {
def = req.sym_out;
defobj = req.defobj_out;
-   } else {
-   /*
-* We do not distinguish between 'main' object and
-* global scope.  If symbol is not defined by objects
-* loaded at startup, continue search among
-* dynamically loaded objects with RTLD_GLOBAL scope.
-*/
-   res = symlook_list(&req, &list_global, &donelist);
+   }
+   /*
+* Search the dynamic linker itself, and possibly resolve the
+* symbol from there.  This is how the application links to
+* dynamic linker services such as dlopen.
+*/
+   if (def == NULL || ELF_ST_BIND(def->st_info) == STB_WEAK) {
+   res = symlook_obj(&req, &obj_rtld);
if (res == 0) {
def = req.sym_out;
defobj = req.defobj_out;
}
}
-   } else {
-   Needed_Entry fake;
-
+   }
+   else {
/* Search the whole DAG rooted at the given object. */
-   fake.next = NULL;
-   fake.obj 

Re: svn commit: r218046 - head/etc

2011-01-28 Thread Bjoern A. Zeeb

On Fri, 28 Jan 2011, Pawel Jakub Dawidek wrote:


Author: pjd
Date: Fri Jan 28 22:28:12 2011
New Revision: 218046
URL: http://svn.freebsd.org/changeset/base/218046

Log:
 Add 'hast' user and 'hast' group that will be used by hastd (and maybe hastctl)
 to drop privileges.


Does it really have to be a high number in the 50-1000 range tracked
by ports/UIDs ports/GIDs?  I am worried that we'll soon end up in a
problem with that anyway:(



 MFC after: 1 week

Modified:
 head/etc/group
 head/etc/master.passwd

Modified: head/etc/group
==
--- head/etc/group  Fri Jan 28 21:57:42 2011(r218045)
+++ head/etc/group  Fri Jan 28 22:28:12 2011(r218046)
@@ -27,5 +27,6 @@ dialer:*:68:
network:*:69:
audit:*:77:
www:*:80:
+hast:*:845:
nogroup:*:65533:
nobody:*:65534:

Modified: head/etc/master.passwd
==
--- head/etc/master.passwd  Fri Jan 28 21:57:42 2011(r218045)
+++ head/etc/master.passwd  Fri Jan 28 22:28:12 2011(r218046)
@@ -20,4 +20,5 @@ _dhcp:*:65:65::0:0:dhcp programs:/var/em
uucp:*:66:66::0:0:UUCP 
pseudo-user:/var/spool/uucppublic:/usr/local/libexec/uucp/uucico
pop:*:68:6::0:0:Post Office Owner:/nonexistent:/usr/sbin/nologin
www:*:80:80::0:0:World Wide Web Owner:/nonexistent:/usr/sbin/nologin
+hast:*:845:845::0:0:HAST unprivileged user:/nonexistent:/usr/sbin/nologin
nobody:*:65534:65534::0:0:Unprivileged user:/nonexistent:/usr/sbin/nologin



--
Bjoern A. Zeeb You have to have visions!
 Going to jail sucks --  All my daemons like it!
  http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/jails.html
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r218046 - head/etc

2011-01-28 Thread Andrew Thompson
On 29 January 2011 13:10, Bjoern A. Zeeb  wrote:
> On Fri, 28 Jan 2011, Pawel Jakub Dawidek wrote:
>
>> Author: pjd
>> Date: Fri Jan 28 22:28:12 2011
>> New Revision: 218046
>> URL: http://svn.freebsd.org/changeset/base/218046
>>
>> Log:
>>  Add 'hast' user and 'hast' group that will be used by hastd (and maybe
>> hastctl)
>>  to drop privileges.
>
> Does it really have to be a high number in the 50-1000 range tracked
> by ports/UIDs ports/GIDs?  I am worried that we'll soon end up in a
> problem with that anyway:(

It could be also noted in /usr/ports/UIDS
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218054 - head/sys/arm/s3c2xx0

2011-01-28 Thread Andrew Turner
Author: andrew
Date: Sat Jan 29 00:46:11 2011
New Revision: 218054
URL: http://svn.freebsd.org/changeset/base/218054

Log:
  Move the load address of the kernel to the start of KVA as the
  s3c24x0 copy of initarm expects the kernel to be loaded there.
  
  Approved by:  imp (mentor)

Modified:
  head/sys/arm/s3c2xx0/std.ln2410sbc

Modified: head/sys/arm/s3c2xx0/std.ln2410sbc
==
--- head/sys/arm/s3c2xx0/std.ln2410sbc  Sat Jan 29 00:33:04 2011
(r218053)
+++ head/sys/arm/s3c2xx0/std.ln2410sbc  Sat Jan 29 00:46:11 2011
(r218054)
@@ -1,10 +1,10 @@
 #$FreeBSD$
 include "../s3c2xx0/std.s3c2410"
 
-makeoptionsKERNPHYSADDR=0x30408000
-makeoptionsKERNVIRTADDR=0xc0408000
-optionsKERNPHYSADDR=0x30408000 
-optionsKERNVIRTADDR=0xc0408000
+makeoptionsKERNPHYSADDR=0x3000
+makeoptionsKERNVIRTADDR=0xc000
+optionsKERNPHYSADDR=0x3000 
+optionsKERNVIRTADDR=0xc000
 optionsPHYSADDR=0x3000
 optionsSTARTUP_PAGETABLE_ADDR=0x3080
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218055 - head/sys/dev/cs

2011-01-28 Thread Andrew Turner
Author: andrew
Date: Sat Jan 29 00:53:58 2011
New Revision: 218055
URL: http://svn.freebsd.org/changeset/base/218055

Log:
  Use bus space functions rather than inw/outw
  to help a future port of the driver to ARM.
  
  Approved by:  imp (mentor)

Modified:
  head/sys/dev/cs/if_cs.c
  head/sys/dev/cs/if_csreg.h
  head/sys/dev/cs/if_csvar.h

Modified: head/sys/dev/cs/if_cs.c
==
--- head/sys/dev/cs/if_cs.c Sat Jan 29 00:46:11 2011(r218054)
+++ head/sys/dev/cs/if_cs.c Sat Jan 29 00:53:58 2011(r218055)
@@ -272,8 +272,6 @@ cs_cs89x0_probe(device_t dev)
if (error)
return (error);
 
-   sc->nic_addr = rman_get_start(sc->port_res);
-
if ((cs_inw(sc, ADD_PORT) & ADD_MASK) != ADD_SIG) {
/* Chip not detected. Let's try to reset it */
if (bootverbose)
@@ -704,7 +702,7 @@ static int
 cs_get_packet(struct cs_softc *sc)
 {
struct ifnet *ifp = sc->ifp;
-   int iobase = sc->nic_addr, status, length;
+   int status, length;
struct ether_header *eh;
struct mbuf *m;
 
@@ -746,7 +744,8 @@ cs_get_packet(struct cs_softc *sc)
m->m_len = length;
 
/* Get the data */
-   insw(iobase + RX_FRAME_PORT, m->m_data, (length+1)>>1);
+   bus_read_multi_2(sc->port_res, RX_FRAME_PORT, mtod(m, uint16_t *),
+   (length + 1) >> 1);
 
eh = mtod(m, struct ether_header *);
 
@@ -869,7 +868,8 @@ cs_write_mbufs( struct cs_softc *sc, str
 static void
 cs_xmit_buf( struct cs_softc *sc )
 {
-   outsw(sc->nic_addr+TX_FRAME_PORT, sc->buffer, (sc->buf_len+1)>>1);
+   bus_write_multi_2(sc->port_res, TX_FRAME_PORT, (uint16_t *)sc->buffer,
+   (sc->buf_len + 1) >> 1);
sc->buf_len = 0;
 }
 

Modified: head/sys/dev/cs/if_csreg.h
==
--- head/sys/dev/cs/if_csreg.h  Sat Jan 29 00:46:11 2011(r218054)
+++ head/sys/dev/cs/if_csreg.h  Sat Jan 29 00:53:58 2011(r218055)
@@ -30,6 +30,8 @@
  * $FreeBSD$
  */
 
+#include 
+
 #define CS_89x0_IO_PORTS   0x0020
 
 #define PP_ChipID 0x   /* offset   0h -> Corp -ID  */
@@ -541,21 +543,21 @@ cs_inw(struct cs_softc *sc, int off)
 {
if (off & 1)
device_printf(sc->dev, "BUG: inw to an odd address.\n");
-   return ((inb(sc->nic_addr + off) & 0xff) |
-   (inb(sc->nic_addr + off + 1) << 8));
+   return ((bus_read_1(sc->port_res, off)) |
+   (bus_read_1(sc->port_res, off + 1) << 8));
 }
 #else
 static __inline uint16_t
 cs_inw(struct cs_softc *sc, int off)
 {
-   return (inw(sc->nic_addr + off));
+   return (bus_read_2(sc->port_res, off));
 }
 #endif
 
 static __inline void
 cs_outw(struct cs_softc *sc, int off, uint16_t val)
 {
-   outw(sc->nic_addr + off, val);
+   bus_write_2(sc->port_res, off, val);
 }
 
 static __inline uint16_t

Modified: head/sys/dev/cs/if_csvar.h
==
--- head/sys/dev/cs/if_csvar.h  Sat Jan 29 00:46:11 2011(r218054)
+++ head/sys/dev/cs/if_csvar.h  Sat Jan 29 00:53:58 2011(r218055)
@@ -57,7 +57,6 @@ struct cs_softc {
 
int flags;
 #defineCS_NO_IRQ   0x1
-   int nic_addr;   /* Base IO address of card */
int send_cmd;
int line_ctl;   /* */
int send_underrun;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218056 - head/sys/dev/xen/netfront

2011-01-28 Thread Justin T. Gibbs
Author: gibbs
Date: Sat Jan 29 02:36:45 2011
New Revision: 218056
URL: http://svn.freebsd.org/changeset/base/218056

Log:
  Fix bug in the netfront driver that caused excessive packet drops during
  receive processing.
  
  Remove unnecessary restrictions on the mbuf chain length built during an
  LRO receive.  This restriction was copied from the Linux netfront driver
  where the LRO implementation cannot handle more than 18 discontinuities.
  The FreeBSD implementation has no such restriction.
  
  MFC after: 1 week

Modified:
  head/sys/dev/xen/netfront/netfront.c

Modified: head/sys/dev/xen/netfront/netfront.c
==
--- head/sys/dev/xen/netfront/netfront.cSat Jan 29 00:53:58 2011
(r218055)
+++ head/sys/dev/xen/netfront/netfront.cSat Jan 29 02:36:45 2011
(r218056)
@@ -1273,7 +1273,6 @@ xennet_get_responses(struct netfront_inf
struct mbuf *m, *m0, *m_prev;
grant_ref_t ref = xennet_get_rx_ref(np, *cons);
RING_IDX ref_cons = *cons;
-   int max = 5 /* MAX_TX_REQ_FRAGS + (rx->status <= RX_COPY_THRESHOLD) */;
int frags = 1;
int err = 0;
u_long ret;
@@ -1416,20 +1415,10 @@ next_skip_queue:
frags++;
}
*list = m0;
-
-   if (unlikely(frags > max)) {
-   if (net_ratelimit())
-   WPRINTK("Too many frags\n");
-   printf("%s: too many frags %d > max %d\n", __func__, frags,
-  max);
-   err = E2BIG;
-   }
-
*cons += frags;
-
*pages_flipped_p = pages_flipped;
 
-   return err;
+   return (err);
 }
 
 static void
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218057 - head/tools/tools/ath/athpow

2011-01-28 Thread Adrian Chadd
Author: adrian
Date: Sat Jan 29 04:34:30 2011
New Revision: 218057
URL: http://svn.freebsd.org/changeset/base/218057

Log:
  Keep this in sync with the ar5212 power rate table size.
  This doesn't yet know about the 802.11n radios or rates.

Modified:
  head/tools/tools/ath/athpow/athpow.c

Modified: head/tools/tools/ath/athpow/athpow.c
==
--- head/tools/tools/ath/athpow/athpow.cSat Jan 29 02:36:45 2011
(r218056)
+++ head/tools/tools/ath/athpow/athpow.cSat Jan 29 04:34:30 2011
(r218057)
@@ -78,7 +78,7 @@ main(int argc, char *argv[])
const char *ifname;
HAL_REVS revs;
u_int16_t pcdacTable[MAX(PWR_TABLE_SIZE,PWR_TABLE_SIZE_2413)];
-   u_int16_t ratesArray[16];
+   u_int16_t ratesArray[37];
u_int nrates, npcdac;
 
s = socket(AF_INET, SOCK_DGRAM, 0);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218058 - in head/sys: conf dev/ath modules/ath

2011-01-28 Thread Adrian Chadd
Author: adrian
Date: Sat Jan 29 05:08:21 2011
New Revision: 218058
URL: http://svn.freebsd.org/changeset/base/218058

Log:
  Break out the debug macros from if_ath.c into if_ath_debug.[ch] .
  
  This is prep work for breaking out the TX path into a separate
  set of source files.

Added:
  head/sys/dev/ath/if_ath_debug.c   (contents, props changed)
  head/sys/dev/ath/if_ath_debug.h   (contents, props changed)
Modified:
  head/sys/conf/files
  head/sys/dev/ath/if_ath.c
  head/sys/modules/ath/Makefile

Modified: head/sys/conf/files
==
--- head/sys/conf/files Sat Jan 29 04:34:30 2011(r218057)
+++ head/sys/conf/files Sat Jan 29 05:08:21 2011(r218058)
@@ -566,6 +566,8 @@ dev/ata/atapi-cam.c optional atapicam
 #
 dev/ath/if_ath.c   optional ath \
compile-with "${NORMAL_C} -I$S/dev/ath"
+dev/ath/if_ath_debug.c optional ath \
+   compile-with "${NORMAL_C} -I$S/dev/ath"
 dev/ath/if_ath_pci.c   optional ath pci \
compile-with "${NORMAL_C} -I$S/dev/ath"
 dev/ath/ah_osdep.c optional ath \

Modified: head/sys/dev/ath/if_ath.c
==
--- head/sys/dev/ath/if_ath.c   Sat Jan 29 04:34:30 2011(r218057)
+++ head/sys/dev/ath/if_ath.c   Sat Jan 29 05:08:21 2011(r218058)
@@ -89,6 +89,8 @@ __FBSDID("$FreeBSD$");
 #include   /* XXX for softled */
 #include 
 
+#include 
+
 #ifdef ATH_TX99_DIAG
 #include 
 #endif
@@ -291,65 +293,6 @@ static int ath_bstuck_threshold = 4;   /*
 SYSCTL_INT(_hw_ath, OID_AUTO, bstuck, CTLFLAG_RW, &ath_bstuck_threshold,
0, "max missed beacon xmits before chip reset");
 
-#ifdef ATH_DEBUG
-enum {
-   ATH_DEBUG_XMIT  = 0x0001,   /* basic xmit operation */
-   ATH_DEBUG_XMIT_DESC = 0x0002,   /* xmit descriptors */
-   ATH_DEBUG_RECV  = 0x0004,   /* basic recv operation */
-   ATH_DEBUG_RECV_DESC = 0x0008,   /* recv descriptors */
-   ATH_DEBUG_RATE  = 0x0010,   /* rate control */
-   ATH_DEBUG_RESET = 0x0020,   /* reset processing */
-   ATH_DEBUG_MODE  = 0x0040,   /* mode init/setup */
-   ATH_DEBUG_BEACON= 0x0080,   /* beacon handling */
-   ATH_DEBUG_WATCHDOG  = 0x0100,   /* watchdog timeout */
-   ATH_DEBUG_INTR  = 0x1000,   /* ISR */
-   ATH_DEBUG_TX_PROC   = 0x2000,   /* tx ISR proc */
-   ATH_DEBUG_RX_PROC   = 0x4000,   /* rx ISR proc */
-   ATH_DEBUG_BEACON_PROC   = 0x8000,   /* beacon ISR proc */
-   ATH_DEBUG_CALIBRATE = 0x0001,   /* periodic calibration */
-   ATH_DEBUG_KEYCACHE  = 0x0002,   /* key cache management */
-   ATH_DEBUG_STATE = 0x0004,   /* 802.11 state transitions */
-   ATH_DEBUG_NODE  = 0x0008,   /* node management */
-   ATH_DEBUG_LED   = 0x0010,   /* led management */
-   ATH_DEBUG_FF= 0x0020,   /* fast frames */
-   ATH_DEBUG_DFS   = 0x0040,   /* DFS processing */
-   ATH_DEBUG_TDMA  = 0x0080,   /* TDMA processing */
-   ATH_DEBUG_TDMA_TIMER= 0x0100,   /* TDMA timer processing */
-   ATH_DEBUG_REGDOMAIN = 0x0200,   /* regulatory processing */
-   ATH_DEBUG_FATAL = 0x8000,   /* fatal errors */
-   ATH_DEBUG_ANY   = 0x
-};
-static int ath_debug = 0;
-SYSCTL_INT(_hw_ath, OID_AUTO, debug, CTLFLAG_RW, &ath_debug,
-   0, "control debugging printfs");
-TUNABLE_INT("hw.ath.debug", &ath_debug);
-
-#defineIFF_DUMPPKTS(sc, m) \
-   ((sc->sc_debug & (m)) || \
-   (sc->sc_ifp->if_flags & (IFF_DEBUG|IFF_LINK2)) == 
(IFF_DEBUG|IFF_LINK2))
-#defineDPRINTF(sc, m, fmt, ...) do {   \
-   if (sc->sc_debug & (m)) \
-   device_printf(sc->sc_dev, fmt, __VA_ARGS__);\
-} while (0)
-#defineKEYPRINTF(sc, ix, hk, mac) do { \
-   if (sc->sc_debug & ATH_DEBUG_KEYCACHE)  \
-   ath_keyprint(sc, __func__, ix, hk, mac);\
-} while (0)
-static void ath_printrxbuf(struct ath_softc *, const struct ath_buf *bf,
-   u_int ix, int);
-static void ath_printtxbuf(struct ath_softc *, const struct ath_buf *bf,
-   u_int qnum, u_int ix, int done);
-#else
-#defineIFF_DUMPPKTS(sc, m) \
-   ((sc->sc_ifp->if_flags & (IFF_DEBUG|IFF_LINK2)) == 
(IFF_DEBUG|IFF_LINK2))
-#defineDPRINTF(sc, m, fmt, ...) do {   \
-   (void) sc;  \
-} while (0)
-#defineKEYPRINTF(sc, k, ix, mac) do {  \
-   (void) sc;  \
-} while (0)
-#endif
-
 MALLOC_DEFI

svn commit: r218059 - head/sys/amd64/linux32

2011-01-28 Thread Dmitry Chagin
Author: dchagin
Date: Sat Jan 29 07:22:33 2011
New Revision: 218059
URL: http://svn.freebsd.org/changeset/base/218059

Log:
  My style(9) bug.
  
  Pointed out by:   kib
  
  MFC after:1 Month.

Modified:
  head/sys/amd64/linux32/linux32_machdep.c

Modified: head/sys/amd64/linux32/linux32_machdep.c
==
--- head/sys/amd64/linux32/linux32_machdep.cSat Jan 29 05:08:21 2011
(r218058)
+++ head/sys/amd64/linux32/linux32_machdep.cSat Jan 29 07:22:33 2011
(r218059)
@@ -108,8 +108,10 @@ bsd_to_linux_sigaltstack(int bsa)
return (lsa);
 }
 
-static void bsd_to_linux_rusage(struct rusage *ru, struct l_rusage *lru)
+static void
+bsd_to_linux_rusage(struct rusage *ru, struct l_rusage *lru)
 {
+
lru->ru_utime.tv_sec = ru->ru_utime.tv_sec;
lru->ru_utime.tv_usec = ru->ru_utime.tv_usec;
lru->ru_stime.tv_sec = ru->ru_stime.tv_sec;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"