tail: -r mem leak with non-regular files

2015-03-26 Thread Tobias Stoeckmann
Hi,

tail -r has two memory leaks when handling non-regular files. You can
easily see memory usage increasing with commands like

$ mknod pipe p
$ tail -r pipe pipe pipe > /dev/null

And then writing a large file into the pipe three times. top shows the
memory usage of tail increasing with each consecutive read.

The obvious memory leak is at the end of reverse(): the doubly linked
list (actually circular list) is never freed. To fix this, I break the
circle and iterate through it, freeing items until I hit NULL.

The less obvious one is in an error path. If tail fails to allocate an
item (tl) or space for its content (tl->l), it won't simply err() out
but tries to recover. Yet, it doesn't free tl if allocation of tl->l
failed.


Tobias

Index: reverse.c
===
RCS file: /cvs/src/usr.bin/tail/reverse.c,v
retrieving revision 1.19
diff -u -p -U4 -r1.19 reverse.c
--- reverse.c   27 Oct 2009 23:59:44 -  1.19
+++ reverse.c   26 Mar 2015 22:31:38 -
@@ -183,8 +183,10 @@ r_buf(FILE *fp)
if (enomem || (tl = malloc(sizeof(BF))) == NULL ||
(tl->l = malloc(BSZ)) == NULL) {
if (!mark)
err(1, NULL);
+   if (!enomem)
+   free(tl);
tl = enomem ? tl->next : mark;
enomem += tl->len;
} else if (mark) {
tl->next = mark;
@@ -258,6 +260,14 @@ r_buf(FILE *fp)
}
while ((tl = tl->next)->len) {
WR(tl->l, tl->len);
tl->len = 0;
+   }
+
+   tl->prev->next = NULL;
+   while (tl != NULL) {
+   tr = tl->next;
+   free(tl->l);
+   free(tl);
+   tl = tr;
}
 }



Small patch to 5.4 OpenSSL patch

2015-03-26 Thread Brad
Hey tech,

This is a patch for:

http://ftp.openbsd.org/pub/OpenBSD/patches/5.4/common/016_openssl.patch

The closing parenthesis was left off.

Thanks,

Brad

rbt@teal:~/Downloads$ cat openbsd_5.4_016_openssl.patch
--- 016_openssl.patch 2015-03-26 13:48:44.776479245 -0400
+++ 016_openssl.patch.rbt 2015-03-26 13:49:38.800480259 -0400
@@ -5,7 +5,7 @@

 Apply patch using:

- cat 016_openssl.patch | (cd /usr/src && patch -p0
+ cat 016_openssl.patch | (cd /usr/src && patch -p0)

 Then build and install libssl
OpenBSD 5.4 errata 16, Oct 20, 2014

Two remotely triggerable memory leaks in OpenSSL can lead to a denial of
service in server applications.

Apply patch using:

	cat 016_openssl.patch | (cd /usr/src && patch -p0

Then build and install libssl

cd /usr/src/lib/libssl/ssl
make obj
make
make install


Index: lib/libssl/src/ssl/d1_srtp.c
===
RCS file: /cvs/src/lib/libssl/src/ssl/d1_srtp.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 d1_srtp.c
--- lib/libssl/src/ssl/d1_srtp.c	13 Oct 2012 21:23:49 -	1.1.1.1
+++ lib/libssl/src/ssl/d1_srtp.c	17 Oct 2014 19:57:51 -
@@ -213,6 +213,7 @@ static int ssl_ctx_make_profiles(const c
 		else
 			{
 			SSLerr(SSL_F_SSL_CTX_MAKE_PROFILES,SSL_R_SRTP_UNKNOWN_PROTECTION_PROFILE);
+			sk_SRTP_PROTECTION_PROFILE_free(profiles);
 			return 1;
 			}
 
Index: lib/libssl/src/ssl/t1_lib.c
===
RCS file: /cvs/src/lib/libssl/src/ssl/t1_lib.c,v
retrieving revision 1.12.8.2
diff -u -p -r1.12.8.2 t1_lib.c
--- lib/libssl/src/ssl/t1_lib.c	9 Aug 2014 16:54:58 -	1.12.8.2
+++ lib/libssl/src/ssl/t1_lib.c	17 Oct 2014 19:56:17 -
@@ -2188,8 +2188,10 @@ static int tls_decrypt_ticket(SSL *s, co
 	HMAC_Update(&hctx, etick, eticklen);
 	HMAC_Final(&hctx, tick_hmac, NULL);
 	HMAC_CTX_cleanup(&hctx);
-	if (timingsafe_bcmp(tick_hmac, etick + eticklen, mlen))
+	if (timingsafe_bcmp(tick_hmac, etick + eticklen, mlen)) {
+		EVP_CIPHER_CTX_cleanup(&ctx);
 		return 2;
+	}
 	/* Attempt to decrypt session data */
 	/* Move p after IV to start of encrypted ticket, update length */
 	p = etick + 16 + EVP_CIPHER_CTX_iv_length(&ctx);


016_openssl.patch.rbt
Description: Binary data
--- 016_openssl.patch	2015-03-26 13:48:44.776479245 -0400
+++ 016_openssl.patch.rbt	2015-03-26 13:49:38.800480259 -0400
@@ -5,7 +5,7 @@
 
 Apply patch using:
 
-	cat 016_openssl.patch | (cd /usr/src && patch -p0
+	cat 016_openssl.patch | (cd /usr/src && patch -p0)
 
 Then build and install libssl
 


Patch to OpenSSL 014 patch

2015-03-26 Thread Brad
Here's one other small error in another patch file. This patch is here:

http://ftp.openbsd.org/pub/OpenBSD/patches/5.4/common/014_openssl.patch

rbt@teal:~/Downloads$ diff -u 014_openssl.patch 014_openssl.patch.rbt
--- 014_openssl.patch 2015-03-26 14:04:15.316496714 -0400
+++ 014_openssl.patch.rbt 2015-03-26 14:05:57.456498632 -0400
@@ -6,7 +6,7 @@

 Apply patch using:

-cat 014_openssl.patch.sig | (cd /usr/src && patch -p0)
+cat 014_openssl.patch | (cd /usr/src && patch -p0)

 Then build and install libcrypto and libssl

Thanks,

Brad
OpenBSD 5.4 errata 14, August 9, 2014:

This patch contains backported fixes for OpenSSL issues.

Refer to https://www.openssl.org/news/secadv_20140806.txt

Apply patch using:

cat 014_openssl.patch.sig | (cd /usr/src && patch -p0)

Then build and install libcrypto and libssl

cd /usr/src/lib/libssl/crypto
make obj
make
make install
cd /usr/src/lib/libssl/ssl
make obj
make
make install

Then restart services which depend on OpenSSL.

Index: lib/libssl/src/crypto/asn1/a_object.c
===
RCS file: /cvs/src/lib/libssl/src/crypto/asn1/a_object.c,v
retrieving revision 1.9
diff -u -p -r1.9 a_object.c
--- lib/libssl/src/crypto/asn1/a_object.c	3 Nov 2011 02:34:32 -	1.9
+++ lib/libssl/src/crypto/asn1/a_object.c	8 Aug 2014 14:02:03 -
@@ -283,17 +283,29 @@ err:
 	ASN1err(ASN1_F_D2I_ASN1_OBJECT,i);
 	return(NULL);
 }
+
 ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
 	 long len)
 	{
 	ASN1_OBJECT *ret=NULL;
 	const unsigned char *p;
 	unsigned char *data;
-	int i;
-	/* Sanity check OID encoding: can't have leading 0x80 in
-	 * subidentifiers, see: X.690 8.19.2
+	int i, length;
+
+	/* Sanity check OID encoding.
+	 * Need at least one content octet.
+	 * MSB must be clear in the last octet.
+	 * can't have leading 0x80 in subidentifiers, see: X.690 8.19.2
 	 */
-	for (i = 0, p = *pp; i < len; i++, p++)
+	if (len <= 0 || len > INT_MAX || pp == NULL || (p = *pp) == NULL ||
+	p[len - 1] & 0x80)
+		{
+		ASN1err(ASN1_F_C2I_ASN1_OBJECT,ASN1_R_INVALID_OBJECT_ENCODING);
+		return NULL;
+		}
+	/* Now 0 < len <= INT_MAX, so the cast is safe. */
+	length = (int)len;
+	for (i = 0; i < length; i++, p++)
 		{
 		if (*p == 0x80 && (!i || !(p[-1] & 0x80)))
 			{
@@ -316,23 +328,23 @@ ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT
 	data = (unsigned char *)ret->data;
 	ret->data = NULL;
 	/* once detached we can change it */
-	if ((data == NULL) || (ret->length < len))
+	if ((data == NULL) || (ret->length < length))
 		{
 		ret->length=0;
 		if (data != NULL) OPENSSL_free(data);
-		data=(unsigned char *)OPENSSL_malloc(len ? (int)len : 1);
+		data=(unsigned char *)OPENSSL_malloc(length);
 		if (data == NULL)
 			{ i=ERR_R_MALLOC_FAILURE; goto err; }
 		ret->flags|=ASN1_OBJECT_FLAG_DYNAMIC_DATA;
 		}
-	memcpy(data,p,(int)len);
+	memcpy(data,p,length);
 	/* reattach data to object, after which it remains const */
 	ret->data  =data;
-	ret->length=(int)len;
+	ret->length=length;
 	ret->sn=NULL;
 	ret->ln=NULL;
 	/* ret->flags=ASN1_OBJECT_FLAG_DYNAMIC; we know it is dynamic */
-	p+=len;
+	p+=length;
 
 	if (a != NULL) (*a)=ret;
 	*pp=p;
Index: lib/libssl/src/crypto/ec/ec_lib.c
===
RCS file: /cvs/src/lib/libssl/src/crypto/ec/ec_lib.c,v
retrieving revision 1.6
diff -u -p -r1.6 ec_lib.c
--- lib/libssl/src/crypto/ec/ec_lib.c	13 Oct 2012 21:25:13 -	1.6
+++ lib/libssl/src/crypto/ec/ec_lib.c	8 Aug 2014 14:02:03 -
@@ -942,7 +942,7 @@ int EC_POINT_dbl(const EC_GROUP *group, 
 
 int EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx)
 	{
-	if (group->meth->dbl == 0)
+	if (group->meth->invert == 0)
 		{
 		ECerr(EC_F_EC_POINT_INVERT, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
 		return 0;
Index: lib/libssl/src/crypto/ec/ecp_smpl.c
===
RCS file: /cvs/src/lib/libssl/src/crypto/ec/ecp_smpl.c,v
retrieving revision 1.5
diff -u -p -r1.5 ecp_smpl.c
--- lib/libssl/src/crypto/ec/ecp_smpl.c	13 Oct 2012 21:25:13 -	1.5
+++ lib/libssl/src/crypto/ec/ecp_smpl.c	8 Aug 2014 14:02:03 -
@@ -1181,9 +1181,8 @@ int ec_GFp_simple_make_affine(const EC_G
 int ec_GFp_simple_points_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], BN_CTX *ctx)
 	{
 	BN_CTX *new_ctx = NULL;
-	BIGNUM *tmp0, *tmp1;
-	size_t pow2 = 0;
-	BIGNUM **heap = NULL;
+	BIGNUM *tmp, *tmp_Z;
+	BIGNUM **prod_Z = NULL;
 	size_t i;
 	int ret = 0;
 
@@ -1198,124 +1197,104 @@ int ec_GFp_simple_points_make_affine(con
 		}
 
 	BN_CTX_start(ctx);
-	tmp0 = BN_CTX_get(ctx);
-	tmp1 = BN_CTX_get(ctx);
-	if (tmp0  == NULL || tmp1 == NULL) goto err;
-
-	/* Before converting the individual points, compute inverses of all Z values.
-	 * Modular inversion is rather slow, but luckily we can do with a single
-	 * explicit inversion, plus about 3 multiplications per input value.
-	 */
-
-	pow2 = 1

Re: Small ifconfig output tweak for inet6?

2015-03-26 Thread Florian Obser
On Thu, Mar 26, 2015 at 06:50:37PM +0100, Martin Pieuchot wrote:
> On 26/03/15(Thu) 17:39, Florian Obser wrote:
> > On Thu, Mar 26, 2015 at 01:48:03PM +0100, Martin Pieuchot wrote:
> > > How do people feel about printing the prefixlen in CIDR notation?  I'm
> > > annoyed about outputs not fitting in 80 chars when using autoconf magic:
> > > 
> > > -inet6 fd00::f2de:f1ff:fe6a:15d1 prefixlen 64 autoconf pltime 3594 vltime 
> > > 7194
> > > +inet6 fd00::f2de:f1ff:fe6a:15d1/64 autoconf pltime 3594 vltime 7194
> > 
> > for "real" prefixes this still doesn't fit:
> > inet6 :BBB::1:5054:ff:fedc:6fcd/64 autoconf pltime 604776 
> > vltime 2591976
> > inet6 :BBB::1:e02b:adec:a4ce:f04d/64 autoconf privacy 
> > pltime 85586 vltime 604173
> 
> What are you suggesting?  To not print 'autoconf'?  Use less left
> margin?  Move the 80char limit to 100?  That the CIDR notation is
> not worth it?
> 

I'm not suggesting anything, I don't know how to solve this. I would
love if it fits on 80 cols.

I don't feel strongly either way, so I'll shut up.

-- 
I'm not entirely sure you are real.



Re: Small ifconfig output tweak for inet6?

2015-03-26 Thread Martin Pieuchot
On 26/03/15(Thu) 17:35, Florian Obser wrote:
> On Thu, Mar 26, 2015 at 05:46:12PM +0100, Henning Brauer wrote:
> > * Mike Belopuhov  [2015-03-26 14:36]:
> > > however I agree that if we do this for ipv6 we should do it for ipv4 as 
> > > well
> > > but then do we care about tons of stuff out there parsing ifconfig output?
> > 
> > that's the prime question. I would love to move to CIDR notation - are
> > we breaking people's scripts with that? The inet side has been the same
> > for, what, decades?
> 
> Of course this breaks stuff :)
>
> Diff at the end (for those interested) shows in which way it breaks
> ansible - which I understand the cool kids use these days...
> Note to self: ansible should care about pltime...
> 
> We could port libxo.
> /me runs away giggling like an idiot

Well just use inet_net_pton(3) and call it a day.  You see, I'm trying
to help people writing parsers ;)



Re: Small ifconfig output tweak for inet6?

2015-03-26 Thread Martin Pieuchot
On 26/03/15(Thu) 17:39, Florian Obser wrote:
> On Thu, Mar 26, 2015 at 01:48:03PM +0100, Martin Pieuchot wrote:
> > How do people feel about printing the prefixlen in CIDR notation?  I'm
> > annoyed about outputs not fitting in 80 chars when using autoconf magic:
> > 
> > -inet6 fd00::f2de:f1ff:fe6a:15d1 prefixlen 64 autoconf pltime 3594 vltime 
> > 7194
> > +inet6 fd00::f2de:f1ff:fe6a:15d1/64 autoconf pltime 3594 vltime 7194
> 
> for "real" prefixes this still doesn't fit:
> inet6 :BBB::1:5054:ff:fedc:6fcd/64 autoconf pltime 604776 
> vltime 2591976
> inet6 :BBB::1:e02b:adec:a4ce:f04d/64 autoconf privacy pltime 
> 85586 vltime 604173

What are you suggesting?  To not print 'autoconf'?  Use less left
margin?  Move the 80char limit to 100?  That the CIDR notation is
not worth it?



Re: Small ifconfig output tweak for inet6?

2015-03-26 Thread Florian Obser
On Thu, Mar 26, 2015 at 01:48:03PM +0100, Martin Pieuchot wrote:
> How do people feel about printing the prefixlen in CIDR notation?  I'm
> annoyed about outputs not fitting in 80 chars when using autoconf magic:
> 
> -inet6 fd00::f2de:f1ff:fe6a:15d1 prefixlen 64 autoconf pltime 3594 vltime 7194
> +inet6 fd00::f2de:f1ff:fe6a:15d1/64 autoconf pltime 3594 vltime 7194

for "real" prefixes this still doesn't fit:
inet6 :BBB::1:5054:ff:fedc:6fcd/64 autoconf pltime 604776 
vltime 2591976
inet6 :BBB::1:e02b:adec:a4ce:f04d/64 autoconf privacy pltime 
85586 vltime 604173

-- 
I'm not entirely sure you are real.



Re: Small ifconfig output tweak for inet6?

2015-03-26 Thread Martin Pieuchot
On 26/03/15(Thu) 17:46, Henning Brauer wrote:
> * Mike Belopuhov  [2015-03-26 14:36]:
> > On 26 March 2015 at 14:27, Stuart Henderson  wrote:
> > > seems reasonable. (I'd quite like that for v4 too, though it wouldn't
> > > cope with non-contiguous netmask ;)
> > non-contiguous netmasks for IPv4 addresses configured on an interface?
> > is that possible?  what's the use case?
> > perhaps you're confusing this with  non-contiguous netmasks in the radix
> > tree that are entered by the ipsec flows containing port numbers?
> 
> I don't think we need to worry about non-contiguous netmasks here.

My plan is to stop supporting them in the routing table first...  Does
that ring any bell? :o)

So let's start simple, CIDR notation for IPv6, ok?

Index: ifconfig.c
===
RCS file: /cvs/src/sbin/ifconfig/ifconfig.c,v
retrieving revision 1.296
diff -u -p -r1.296 ifconfig.c
--- ifconfig.c  5 Feb 2015 10:30:25 -   1.296
+++ ifconfig.c  26 Mar 2015 17:15:54 -
@@ -3192,7 +3192,7 @@ in6_alias(struct in6_ifreq *creq)
warn("SIOCGIFNETMASK_IN6");
} else {
sin6 = (struct sockaddr_in6 *)&ifr6.ifr_addr;
-   printf(" prefixlen %d", prefix(&sin6->sin6_addr,
+   printf("/%d", prefix(&sin6->sin6_addr,
sizeof(struct in6_addr)));
}
 



Re: Small ifconfig output tweak for inet6?

2015-03-26 Thread Florian Obser
On Thu, Mar 26, 2015 at 05:46:12PM +0100, Henning Brauer wrote:
> * Mike Belopuhov  [2015-03-26 14:36]:
> > however I agree that if we do this for ipv6 we should do it for ipv4 as well
> > but then do we care about tons of stuff out there parsing ifconfig output?
> 
> that's the prime question. I would love to move to CIDR notation - are
> we breaking people's scripts with that? The inet side has been the same
> for, what, decades?

Of course this breaks stuff :)

Diff at the end (for those interested) shows in which way it breaks
ansible - which I understand the cool kids use these days...
Note to self: ansible should care about pltime...

We could port libxo.
/me runs away giggling like an idiot

--- setup1.txt  Thu Mar 26 18:21:12 2015
+++ setup2.txt  Thu Mar 26 18:21:24 2015
@@ -4,22 +4,23 @@
 "10.11.12.32"
 ], 
 "ansible_all_ipv6_addresses": [
-"fe80::5054:ff:fedc:6fcd%vio0", 
-":::1:5054:ff:fedc:6fcd", 
-":::1:e02b:adec:a4ce:f04d"
+"fe80::1%lo0/64", 
+"fe80::5054:ff:fedc:6fcd%vio0/64", 
+":::1:5054:ff:fedc:6fcd/64", 
+":::1:e02b:adec:a4ce:f04d/64"
 ], 
 "ansible_architecture": "amd64", 
@@ -49,7 +50,7 @@
 "type": "unknown"
 }, 
 "ansible_default_ipv6": {
-"address": "fe80::5054:ff:fedc:6fcd%vio0", 
+"address": "fe80::5054:ff:fedc:6fcd%vio0/64", 
 "device": "vio0", 
 "flags": [
 "UP", 
@@ -65,8 +66,6 @@
 "media": "Ethernet", 
 "media_select": "autoselect", 
 "mtu": "1500", 
-"prefix": "64", 
-"scope": "0x1", 
 "status": "active", 
 "type": "unknown"
 }, 
@@ -119,13 +118,10 @@
 ], 
 "ipv6": [
 {
-"address": "fe80::1%lo0", 
-"prefix": "64", 
-"scope": "0x3"
+"address": "fe80::1%lo0/64"
 }, 
 {
-"address": "::1", 
-"prefix": "128"
+"address": "::1/128"
 }
 ], 
 "macaddress": "unknown", 
@@ -176,17 +172,13 @@
 ], 
 "ipv6": [
 {
-"address": "fe80::5054:ff:fedc:6fcd%vio0", 
-"prefix": "64", 
-"scope": "0x1"
+"address": "fe80::5054:ff:fedc:6fcd%vio0/64"
 }, 
 {
-"address": ":::1:5054:ff:fedc:6fcd", 
-"prefix": "64"
+"address": ":::1:5054:ff:fedc:6fcd/64"
 }, 
 {
-"address": ":::1:e02b:adec:a4ce:f04d", 
-"prefix": "64"
+"address": ":::1:e02b:adec:a4ce:f04d/64"
 }
 ], 
 "macaddress": "52:54:00:dc:6f:cd", 


-- 
I'm not entirely sure you are real.



Re: Small ifconfig output tweak for inet6?

2015-03-26 Thread Henning Brauer
* Mike Belopuhov  [2015-03-26 14:36]:
> On 26 March 2015 at 14:27, Stuart Henderson  wrote:
> > seems reasonable. (I'd quite like that for v4 too, though it wouldn't
> > cope with non-contiguous netmask ;)
> non-contiguous netmasks for IPv4 addresses configured on an interface?
> is that possible?  what's the use case?
> perhaps you're confusing this with  non-contiguous netmasks in the radix
> tree that are entered by the ipsec flows containing port numbers?

I don't think we need to worry about non-contiguous netmasks here.

> however I agree that if we do this for ipv6 we should do it for ipv4 as well
> but then do we care about tons of stuff out there parsing ifconfig output?

that's the prime question. I would love to move to CIDR notation - are
we breaking people's scripts with that? The inet side has been the same
for, what, decades?

-- 
Henning Brauer, h...@bsws.de, henn...@openbsd.org
BS Web Services GmbH, http://bsws.de, Full-Service ISP
Secure Hosting, Mail and DNS. Virtual & Dedicated Servers, Root to Fully Managed
Henning Brauer Consulting, http://henningbrauer.com/



Re: ef(4), eg(4), el(4), ex(4) and ie(4)

2015-03-26 Thread Ted Unangst
Martin Pieuchot wrote:
> On 26/03/15(Thu) 08:00, Ted Unangst wrote:
> > Martin Pieuchot wrote:
> > > Even our ISA Ethernet drivers can be converted to if_input().  If you
> > > still use some of these, I appreciate test reports.
> > > 
> > > I'm asking here because Miod said everybody can test them... hum hum.
> > > 
> > > Alternatively, if you think some drivers can go away, I'll summon
> > > tedu@.
> > 
> > What, no ec? No ep? Why play favorites???
> 
> You're asking for tricky ones!
> 
> Enjoy :)

You're deleting more lines than you're adding, so I did. :) Not as many
deletions as deleting the driver entirely, but I'll take what I can get.



Re: Small ifconfig output tweak for inet6?

2015-03-26 Thread Theo de Raadt
>On Thu, Mar 26, 2015 at 01:48:03PM +0100, Martin Pieuchot wrote:
>> While here can I convert " autoconfprivacy" to " privacy" or "+privacy"?
>
>Please don't change this. The name of the option was chosen such that
>web searches come up with the proper RFC and related references.

Yes, I agree.  The inet6 semantic space is so messed up and complicated,
so the term was chosen narrow and specific.



Re: Small ifconfig output tweak for inet6?

2015-03-26 Thread Stefan Sperling
On Thu, Mar 26, 2015 at 01:48:03PM +0100, Martin Pieuchot wrote:
> While here can I convert " autoconfprivacy" to " privacy" or "+privacy"?

Please don't change this. The name of the option was chosen such that
web searches come up with the proper RFC and related references.



Re: Small ifconfig output tweak for inet6?

2015-03-26 Thread Mike Belopuhov
On 26 March 2015 at 14:27, Stuart Henderson  wrote:
> seems reasonable. (I'd quite like that for v4 too, though it wouldn't
> cope with non-contiguous netmask ;)
>

non-contiguous netmasks for IPv4 addresses configured on an interface?
is that possible?  what's the use case?
perhaps you're confusing this with  non-contiguous netmasks in the radix
tree that are entered by the ipsec flows containing port numbers?

however I agree that if we do this for ipv6 we should do it for ipv4 as well
but then do we care about tons of stuff out there parsing ifconfig output?



Re: Small ifconfig output tweak for inet6?

2015-03-26 Thread Paul de Weerd
On Thu, Mar 26, 2015 at 01:48:03PM +0100, Martin Pieuchot wrote:
| How do people feel about printing the prefixlen in CIDR notation?  I'm
| annoyed about outputs not fitting in 80 chars when using autoconf magic:
| 
| -inet6 fd00::f2de:f1ff:fe6a:15d1 prefixlen 64 autoconf pltime 3594 vltime 7194
| +inet6 fd00::f2de:f1ff:fe6a:15d1/64 autoconf pltime 3594 vltime 7194

Love this!  And you can still copy/paste from 'inet6' upto '64' into
an ifconfig line to get that address configured on an interface.

| While here can I convert " autoconfprivacy" to " privacy" or "+privacy"?

'autoconfprivacy' seems too long to me too, yeah...

Cheers,

Paul 'WEiRD' de Weerd

| Index: ifconfig.c
| ===
| RCS file: /cvs/src/sbin/ifconfig/ifconfig.c,v
| retrieving revision 1.296
| diff -u -p -r1.296 ifconfig.c
| --- ifconfig.c5 Feb 2015 10:30:25 -   1.296
| +++ ifconfig.c26 Mar 2015 12:15:10 -
| @@ -3192,7 +3192,7 @@ in6_alias(struct in6_ifreq *creq)
|   warn("SIOCGIFNETMASK_IN6");
|   } else {
|   sin6 = (struct sockaddr_in6 *)&ifr6.ifr_addr;
| - printf(" prefixlen %d", prefix(&sin6->sin6_addr,
| + printf("/%d", prefix(&sin6->sin6_addr,
|   sizeof(struct in6_addr)));
|   }
|  
| @@ -3216,7 +3216,7 @@ in6_alias(struct in6_ifreq *creq)
|   if (ifr6.ifr_ifru.ifru_flags6 & IN6_IFF_AUTOCONF)
|   printf(" autoconf");
|   if (ifr6.ifr_ifru.ifru_flags6 & IN6_IFF_PRIVACY)
| - printf(" autoconfprivacy");
| + printf(" privacy");
|   }
|  
|   if (scopeid)
| 

-- 
>[<++>-]<+++.>+++[<-->-]<.>+++[<+
+++>-]<.>++[<>-]<+.--.[-]
 http://www.weirdnet.nl/ 



Re: Small ifconfig output tweak for inet6?

2015-03-26 Thread Stuart Henderson
On 2015/03/26 13:48, Martin Pieuchot wrote:
> How do people feel about printing the prefixlen in CIDR notation?  I'm
> annoyed about outputs not fitting in 80 chars when using autoconf magic:
> 
> -inet6 fd00::f2de:f1ff:fe6a:15d1 prefixlen 64 autoconf pltime 3594 vltime 7194
> +inet6 fd00::f2de:f1ff:fe6a:15d1/64 autoconf pltime 3594 vltime 7194
> 
> While here can I convert " autoconfprivacy" to " privacy" or "+privacy"?
> 
> Index: ifconfig.c
> ===
> RCS file: /cvs/src/sbin/ifconfig/ifconfig.c,v
> retrieving revision 1.296
> diff -u -p -r1.296 ifconfig.c
> --- ifconfig.c5 Feb 2015 10:30:25 -   1.296
> +++ ifconfig.c26 Mar 2015 12:15:10 -
> @@ -3192,7 +3192,7 @@ in6_alias(struct in6_ifreq *creq)
>   warn("SIOCGIFNETMASK_IN6");
>   } else {
>   sin6 = (struct sockaddr_in6 *)&ifr6.ifr_addr;
> - printf(" prefixlen %d", prefix(&sin6->sin6_addr,
> + printf("/%d", prefix(&sin6->sin6_addr,
>   sizeof(struct in6_addr)));
>   }

seems reasonable. (I'd quite like that for v4 too, though it wouldn't
cope with non-contiguous netmask ;)

> @@ -3216,7 +3216,7 @@ in6_alias(struct in6_ifreq *creq)
>   if (ifr6.ifr_ifru.ifru_flags6 & IN6_IFF_AUTOCONF)
>   printf(" autoconf");
>   if (ifr6.ifr_ifru.ifru_flags6 & IN6_IFF_PRIVACY)
> - printf(" autoconfprivacy");
> + printf(" privacy");
>   }
>  
>   if (scopeid)
> 

I do prefer "privacy" here, but generally the printed flags match the
name used to configure them so this would be better if the cmds[] table
and manual changed too. (But then we might want to keep backwards compat
to reduce risk of people locking themselves out of remote machines if
they have a flag in the wrong place on a hostname.if line)...



Re: the libressl wikipedia article is awful.

2015-03-26 Thread Joel Sing
On Sunday 22 March 2015, Jiří Navrátil wrote:
> Good morning Bob,
>
> I did a quick fix
>
> "OpenBSD, FreeBSD[2] and many others"
>
> Where I can get list of supported operating systems, please? I will add
> them.

The current list of platforms supported by LibreSSL portable is available at:

  http://www.libressl.org/releases.html

> I can also add list of removed operating systems in the text, if someone
> will see it valuable there.
>
> In general - I can go through the article and the check the accuracy. I’m
> not sure, if will be able to check all details. Which our documents can be
> used as my inputs?
>
> Thank you,
> Jiri
>
> --
> Jiri Navratil, http://kouc.navratil.cz,  +420 222 767 131
>
> > 22. 3. 2015 v 2:51, Bob Beck :
> >
> > Someone who wikipedias should fix it. It runs on a lot more than
> > OpenBSD and FreeBSD.

-- 

"Action without study is fatal. Study without action is futile."
-- Mary Ritter Beard



Small ifconfig output tweak for inet6?

2015-03-26 Thread Martin Pieuchot
How do people feel about printing the prefixlen in CIDR notation?  I'm
annoyed about outputs not fitting in 80 chars when using autoconf magic:

-inet6 fd00::f2de:f1ff:fe6a:15d1 prefixlen 64 autoconf pltime 3594 vltime 7194
+inet6 fd00::f2de:f1ff:fe6a:15d1/64 autoconf pltime 3594 vltime 7194

While here can I convert " autoconfprivacy" to " privacy" or "+privacy"?

Index: ifconfig.c
===
RCS file: /cvs/src/sbin/ifconfig/ifconfig.c,v
retrieving revision 1.296
diff -u -p -r1.296 ifconfig.c
--- ifconfig.c  5 Feb 2015 10:30:25 -   1.296
+++ ifconfig.c  26 Mar 2015 12:15:10 -
@@ -3192,7 +3192,7 @@ in6_alias(struct in6_ifreq *creq)
warn("SIOCGIFNETMASK_IN6");
} else {
sin6 = (struct sockaddr_in6 *)&ifr6.ifr_addr;
-   printf(" prefixlen %d", prefix(&sin6->sin6_addr,
+   printf("/%d", prefix(&sin6->sin6_addr,
sizeof(struct in6_addr)));
}
 
@@ -3216,7 +3216,7 @@ in6_alias(struct in6_ifreq *creq)
if (ifr6.ifr_ifru.ifru_flags6 & IN6_IFF_AUTOCONF)
printf(" autoconf");
if (ifr6.ifr_ifru.ifru_flags6 & IN6_IFF_PRIVACY)
-   printf(" autoconfprivacy");
+   printf(" privacy");
}
 
if (scopeid)



Re: ef(4), eg(4), el(4), ex(4) and ie(4)

2015-03-26 Thread Martin Pieuchot
On 26/03/15(Thu) 08:00, Ted Unangst wrote:
> Martin Pieuchot wrote:
> > Even our ISA Ethernet drivers can be converted to if_input().  If you
> > still use some of these, I appreciate test reports.
> > 
> > I'm asking here because Miod said everybody can test them... hum hum.
> > 
> > Alternatively, if you think some drivers can go away, I'll summon
> > tedu@.
> 
> What, no ec? No ep? Why play favorites???

You're asking for tricky ones!

Enjoy :)


Index: dev/ic/elink3.c
===
RCS file: /cvs/src/sys/dev/ic/elink3.c,v
retrieving revision 1.83
diff -u -p -r1.83 elink3.c
--- dev/ic/elink3.c 14 Mar 2015 03:38:47 -  1.83
+++ dev/ic/elink3.c 26 Mar 2015 12:26:41 -
@@ -1243,8 +1243,9 @@ epread(struct ep_softc *sc)
bus_space_tag_t iot = sc->sc_iot;
bus_space_handle_t ioh = sc->sc_ioh;
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+   struct mbuf_list ml = MBUF_LIST_INITIALIZER();
struct mbuf *m;
-   int len;
+   int len, error = 0;
 
len = bus_space_read_2(iot, ioh, ep_w1_reg(sc, EP_W1_RX_STATUS));
 
@@ -1275,11 +1276,12 @@ again:
 #endif
 
if (len & ERR_INCOMPLETE)
-   return;
+   goto done;
 
if (len & ERR_RX) {
++ifp->if_ierrors;
-   goto abort;
+   error = 1;
+   goto done;
}
 
len &= RX_BYTES_MASK;   /* Lower 11 bits = RX bytes. */
@@ -1288,21 +1290,13 @@ again:
m = epget(sc, len);
if (m == NULL) {
ifp->if_ierrors++;
-   goto abort;
+   error = 1;
+   goto done;
}
 
++ifp->if_ipackets;
 
-#if NBPFILTER > 0
-   /*
-* Check if there's a BPF listener on this interface.
-* If so, hand off the raw packet to BPF.
-*/
-   if (ifp->if_bpf)
-   bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN);
-#endif
-
-   ether_input_mbuf(ifp, m);
+   ml_enqueue(&ml, m);
 
/*
 * In periods of high traffic we can actually receive enough
@@ -1331,15 +1325,14 @@ again:
sc->sc_dev.dv_xname);
 #endif
epreset(sc);
-   return;
+   goto done;
}
goto again;
}
-
-   return;
-
-abort:
-   ep_discard_rxtop(iot, ioh);
+done:
+   if (error)
+   ep_discard_rxtop(iot, ioh);
+   if_input(ifp, &ml);
 }
 
 struct mbuf *
@@ -1347,7 +1340,6 @@ epget(struct ep_softc *sc, int totlen)
 {
bus_space_tag_t iot = sc->sc_iot;
bus_space_handle_t ioh = sc->sc_ioh;
-   struct ifnet *ifp = &sc->sc_arpcom.ac_if;
struct mbuf *m;
caddr_t data;
int len, pad, off, sh, rxreg;
@@ -1368,7 +1360,6 @@ epget(struct ep_softc *sc, int totlen)
sc->next_mb = (sc->next_mb + 1) % MAX_MBS;
 
len = MCLBYTES;
-   m->m_pkthdr.rcvif = ifp;
m->m_pkthdr.len = totlen;
m->m_len = totlen;
pad = ALIGN(sizeof(struct ether_header)) - sizeof(struct ether_header);
Index: dev/ic/dp8390.c
===
RCS file: /cvs/src/sys/dev/ic/dp8390.c,v
retrieving revision 1.49
diff -u -p -r1.49 dp8390.c
--- dev/ic/dp8390.c 14 Mar 2015 03:38:47 -  1.49
+++ dev/ic/dp8390.c 26 Mar 2015 12:35:46 -
@@ -867,6 +867,7 @@ void
 dp8390_read(struct dp8390_softc *sc, int buf, u_short len)
 {
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+   struct mbuf_list ml = MBUF_LIST_INITIALIZER();
struct mbuf *m;
 
/* Pull packet off interface. */
@@ -877,17 +878,9 @@ dp8390_read(struct dp8390_softc *sc, int
}
 
ifp->if_ipackets++;
+   ml_enqueue(&ml, m);
 
-#if NBPFILTER > 0
-   /*
-* Check if there's a BPF listener on this interface.
-* If so, hand off the raw packet to bpf.
-*/
-   if (ifp->if_bpf)
-   bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN);
-#endif
-
-   ether_input_mbuf(ifp, m);
+   if_input(ifp, &ml);
 }
 
 
@@ -947,14 +940,12 @@ dp8390_getmcaf(struct arpcom *ac, u_int8
 struct mbuf *
 dp8390_get(struct dp8390_softc *sc, int src, u_short total_len)
 {
-   struct ifnet *ifp = &sc->sc_arpcom.ac_if;
struct mbuf *m, *m0, *newm;
u_short len;
 
MGETHDR(m0, M_DONTWAIT, MT_DATA);
if (m0 == NULL)
return (0);
-   m0->m_pkthdr.rcvif = ifp;
m0->m_pkthdr.len = total_len;
len = MHLEN;
m = m0;



Proposed small change for ping(8)

2015-03-26 Thread Gregory Edigarov

Hello,

This makes ping -v really verbose, telling about lost packets as they 
progress.


Index: ping.8
===
RCS file: /cvs/src/sbin/ping/ping.8,v
retrieving revision 1.52
diff -u -p -u -r1.52 ping.8
--- ping.8  24 Mar 2014 11:11:49 -  1.52
+++ ping.8  26 Mar 2015 12:28:44 -
@@ -199,7 +199,7 @@ Set the routing table to be used for out
 Verbose output.
 ICMP packets other than
 .Dv ECHO_REPLY
-that are received are listed.
+that are received are listed. Also reports lost packets as they go.
 .It Fl w Ar maxwait
 Specifies the maximum number of seconds to wait for responses
 after the last request has been sent.

Index: ping.c
===
RCS file: /cvs/src/sbin/ping/ping.c,v
retrieving revision 1.118
diff -u -p -u -r1.118 ping.c
--- ping.c  23 Mar 2015 09:36:25 -  1.118
+++ ping.c  26 Mar 2015 12:28:44 -
@@ -576,6 +576,8 @@ catcher(int signo)
nmissedmax = ntransmitted - nreceived - 1;
if (!(options & F_FLOOD) && (options & F_AUD_MISS))
write(STDERR_FILENO, "\a", 1);
+   if (!(options & F_FLOOD) && (options & F_VERBOSE))
+   write(STDOUT_FILENO, "Lost packet\n",12);
}
errno = save_errno;
 }



Re: ef(4), eg(4), el(4), ex(4) and ie(4)

2015-03-26 Thread Ted Unangst
Martin Pieuchot wrote:
> Even our ISA Ethernet drivers can be converted to if_input().  If you
> still use some of these, I appreciate test reports.
> 
> I'm asking here because Miod said everybody can test them... hum hum.
> 
> Alternatively, if you think some drivers can go away, I'll summon
> tedu@.

What, no ec? No ep? Why play favorites???



ef(4), eg(4), el(4), ex(4) and ie(4)

2015-03-26 Thread Martin Pieuchot
Even our ISA Ethernet drivers can be converted to if_input().  If you
still use some of these, I appreciate test reports.

I'm asking here because Miod said everybody can test them... hum hum.

Alternatively, if you think some drivers can go away, I'll summon
tedu@.

Index: isa/if_ef_isapnp.c
===
RCS file: /cvs/src/sys/dev/isa/if_ef_isapnp.c,v
retrieving revision 1.27
diff -u -p -r1.27 if_ef_isapnp.c
--- isa/if_ef_isapnp.c  22 Dec 2014 02:28:51 -  1.27
+++ isa/if_ef_isapnp.c  26 Mar 2015 11:29:22 -
@@ -671,6 +671,7 @@ efread(sc)
bus_space_tag_t iot = sc->sc_iot;
bus_space_handle_t ioh = sc->sc_ioh;
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+   struct mbuf_list ml = MBUF_LIST_INITIALIZER();
struct mbuf *m;
int len;
 
@@ -719,13 +720,9 @@ efread(sc)
}
 
ifp->if_ipackets++;
+   ml_enqueue(&ml, m);
 
-#if NBPFILTER > 0
-   if (ifp->if_bpf)
-   bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN);
-#endif
-
-   ether_input_mbuf(ifp, m);
+   if_input(ifp, &ml);
 }
 
 struct mbuf *
@@ -735,14 +732,12 @@ efget(sc, totlen)
 {
bus_space_tag_t iot = sc->sc_iot;
bus_space_handle_t ioh = sc->sc_ioh;
-   struct ifnet *ifp = &sc->sc_arpcom.ac_if;
struct mbuf *top, **mp, *m;
int len, pad, s;
 
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == NULL)
return (NULL);
-   m->m_pkthdr.rcvif = ifp;
m->m_pkthdr.len = totlen;
pad = ALIGN(sizeof(struct ether_header)) - sizeof(struct ether_header);
m->m_data += pad;
Index: isa/if_eg.c
===
RCS file: /cvs/src/sys/dev/isa/if_eg.c,v
retrieving revision 1.36
diff -u -p -r1.36 if_eg.c
--- isa/if_eg.c 22 Dec 2014 02:28:51 -  1.36
+++ isa/if_eg.c 26 Mar 2015 11:28:42 -
@@ -670,8 +670,9 @@ void
 egread(struct eg_softc *sc, caddr_t buf, int len)
 {
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+   struct mbuf_list ml = MBUF_LIST_INITIALIZER();
struct mbuf *m;
-   
+
if (len <= sizeof(struct ether_header) ||
len > ETHER_MAX_LEN) {
printf("%s: invalid packet size %d; dropping\n",
@@ -688,17 +689,9 @@ egread(struct eg_softc *sc, caddr_t buf,
}
 
ifp->if_ipackets++;
+   ml_enqueue(&ml, m);
 
-#if NBPFILTER > 0
-   /*
-* Check if there's a BPF listener on this interface.
-* If so, hand off the raw packet to BPF.
-*/
-   if (ifp->if_bpf)
-   bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN);
-#endif
-
-   ether_input_mbuf(ifp, m);
+   if_input(ifp, &ml);
 }
 
 /*
@@ -707,14 +700,12 @@ egread(struct eg_softc *sc, caddr_t buf,
 struct mbuf *
 egget(struct eg_softc *sc, caddr_t buf, int totlen)
 {
-   struct ifnet *ifp = &sc->sc_arpcom.ac_if;
struct mbuf *top, **mp, *m;
int len;
 
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == 0)
return (0);
-   m->m_pkthdr.rcvif = ifp;
m->m_pkthdr.len = totlen;
len = MHLEN;
top = 0;
Index: isa/if_el.c
===
RCS file: /cvs/src/sys/dev/isa/if_el.c,v
retrieving revision 1.24
diff -u -p -r1.24 if_el.c
--- isa/if_el.c 22 Dec 2014 02:28:51 -  1.24
+++ isa/if_el.c 26 Mar 2015 11:28:38 -
@@ -490,6 +490,7 @@ elread(sc, len)
int len;
 {
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+   struct mbuf_list ml = MBUF_LIST_INITIALIZER();
struct mbuf *m;
 
if (len <= sizeof(struct ether_header) ||
@@ -508,17 +509,9 @@ elread(sc, len)
}
 
ifp->if_ipackets++;
+   ml_enqueue(&ml, m);
 
-#if NBPFILTER > 0
-   /*
-* Check if there's a BPF listener on this interface.
-* If so, hand off the raw packet to BPF.
-*/
-   if (ifp->if_bpf)
-   bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN);
-#endif
-
-   ether_input_mbuf(ifp, m);
+   if_input(ifp, &ml);
 }
 
 /*
@@ -531,7 +524,6 @@ elget(sc, totlen)
struct el_softc *sc;
int totlen;
 {
-   struct ifnet *ifp = &sc->sc_arpcom.ac_if;
int iobase = sc->sc_iobase;
struct mbuf *top, **mp, *m;
int len;
@@ -539,7 +531,6 @@ elget(sc, totlen)
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == 0)
return 0;
-   m->m_pkthdr.rcvif = ifp;
m->m_pkthdr.len = totlen;
len = MHLEN;
top = 0;
Index: isa/if_ex.c
===
RCS file: /cvs/src/sys/dev/isa/if_ex.c,v
retrieving revision 1.37
diff -u -p -r1.37 if_ex.c
--- isa/if_ex.c 22 Dec 2014 02:28:51 -  1.37
+++ isa/if_ex.c 26 Mar 2015 11:24:27 -
@@ -639,6 +639,7 @@ void 
 ex_rx_intr(struct ex_softc *sc)
 {
struct ifnet *ifp = &sc->arpcom.ac_if;
+   struct mbuf_list ml = MBU

cdce(4), cue(4), kue(4) and mos(4)

2015-03-26 Thread Martin Pieuchot
This spring the new trend has a name: if_input() !

If you are the owner of one of these USB Ethernet dongle, please do
me a favor a make sure they still work as expected with the diff
below.

Martin

Index: if_cdce.c
===
RCS file: /cvs/src/sys/dev/usb/if_cdce.c,v
retrieving revision 1.63
diff -u -p -r1.63 if_cdce.c
--- if_cdce.c   14 Mar 2015 03:38:49 -  1.63
+++ if_cdce.c   17 Mar 2015 21:45:15 -
@@ -726,6 +726,7 @@ cdce_rxeof(struct usbd_xfer *xfer, void 
struct cdce_softc   *sc = c->cdce_sc;
struct ifnet*ifp = GET_IFP(sc);
struct mbuf *m;
+   struct mbuf_list ml = MBUF_LIST_INITIALIZER();
int  total_len = 0;
int  s;
 
@@ -767,25 +768,16 @@ cdce_rxeof(struct usbd_xfer *xfer, void 
}
 
ifp->if_ipackets++;
-
m->m_pkthdr.len = m->m_len = total_len;
-   m->m_pkthdr.rcvif = ifp;
-
-   s = splnet();
+   ml_enqueue(&ml, m);
 
if (cdce_newbuf(sc, c, NULL) == ENOBUFS) {
ifp->if_ierrors++;
-   goto done1;
+   goto done;
}
 
-#if NBPFILTER > 0
-   if (ifp->if_bpf)
-   bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN);
-#endif
-
-   ether_input_mbuf(ifp, m);
-
-done1:
+   s = splnet();
+   if_input(ifp, &ml);
splx(s);
 
 done:
Index: if_cdcef.c
===
RCS file: /cvs/src/sys/dev/usb/if_cdcef.c,v
retrieving revision 1.35
diff -u -p -r1.35 if_cdcef.c
--- if_cdcef.c  22 Dec 2014 02:28:52 -  1.35
+++ if_cdcef.c  17 Mar 2015 21:43:23 -
@@ -361,6 +361,7 @@ cdcef_rxeof(struct usbf_xfer *xfer, void
struct cdcef_softc  *sc = priv;
int total_len = 0;
struct ifnet*ifp = GET_IFP(sc);
+   struct mbuf_listml = MBUF_LIST_INITIALIZER();
struct mbuf *m = NULL;
 
 
@@ -403,32 +404,24 @@ cdcef_rxeof(struct usbf_xfer *xfer, void
goto done;
}
 
-   s = splnet();
if (ifp->if_flags & IFF_RUNNING) {
m = cdcef_newbuf();
if (m == NULL) {
/* message? */
ifp->if_ierrors++;
-   goto done1;
+   goto done;
}
 
m->m_pkthdr.len = m->m_len = total_len;
bcopy(sc->sc_buffer_out, mtod(m, char *), total_len);
-   m->m_pkthdr.rcvif = ifp;
 
ifp->if_ipackets++;
-
-#if NBPFILTER > 0
-   if (ifp->if_bpf)
-   bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN);
-#endif
-
-   ether_input_mbuf(ifp, m);
+   ml_enqueue(&ml, m);
}
 
-done1:
+   s = splnet();
+   if_input(ifp, &ml);
splx(s);
-
 done:
/* Setup another xfer. */
usbf_setup_xfer(xfer, sc->sc_pipe_out, sc, sc->sc_buffer_out,
Index: if_cue.c
===
RCS file: /cvs/src/sys/dev/usb/if_cue.c,v
retrieving revision 1.69
diff -u -p -r1.69 if_cue.c
--- if_cue.c14 Mar 2015 03:38:49 -  1.69
+++ if_cue.c17 Mar 2015 21:45:06 -
@@ -674,6 +674,7 @@ cue_rxeof(struct usbd_xfer *xfer, void *
struct cue_chain*c = priv;
struct cue_softc*sc = c->cue_sc;
struct ifnet*ifp = GET_IFP(sc);
+   struct mbuf_listml = MBUF_LIST_INITIALIZER();
struct mbuf *m;
int total_len = 0;
u_int16_t   len;
@@ -721,26 +722,15 @@ cue_rxeof(struct usbd_xfer *xfer, void *
ifp->if_ipackets++;
m_adj(m, sizeof(u_int16_t));
m->m_pkthdr.len = m->m_len = total_len;
+   ml_enqueue(&ml, m);
 
-   m->m_pkthdr.rcvif = ifp;
-
-   s = splnet();
-
-   /* XXX ugly */
if (cue_newbuf(sc, c, NULL) == ENOBUFS) {
ifp->if_ierrors++;
-   goto done1;
+   goto done;
}
 
-#if NBPFILTER > 0
-   if (ifp->if_bpf)
-   bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN);
-#endif
-
-   DPRINTFN(10,("%s: %s: deliver %d\n", sc->cue_dev.dv_xname,
-   __func__, m->m_len));
-   ether_input_mbuf(ifp, m);
- done1:
+   s = splnet();
+   if_input(ifp, &ml);
splx(s);
 
 done:
Index: if_kue.c
===
RCS file: /cvs/src/sys/dev/usb/if_kue.c,v
retrieving revision 1.78
diff -u -p -r1.78 if_kue.c
--- if_kue.c14 Mar 2015 03:38:49 -  1.78
+++ if_kue.c17 Mar 2015 21:44:56 -
@@ -676,6 +676,7 @@ kue_rxeof(struct usbd_xfer *xfer, void *
struct kue_chain*c = priv;
struct kue_softc*sc = c->kue_sc;
struct ifnet*ifp = GET_IFP(sc);
+   struct mbuf_list   

wsdisplay.4: document IOCTLs

2015-03-26 Thread dan mclaughlin
there were a number of common IOCTLs that weren't documented. i read the
code pretty thoroughly to make sure everything here is correct. there are
some things i don't know, like what 'stride' is. currently it just mentions
that it should be 1 for VGA. i read into the rasops code as far as i could,
but it's much less straightforward than the vga code, so there are a few
things undocumented there.

first is the diff of the outputs, so that the text is clearer. the patch
comes after.

266a267,325
>  WSDISPLAYIO_LDFONT (struct wsdisplay_font)
>Loads a font specified by the wsdisplay_font structure.
>
>  struct wsdisplay_font {
>  char name[WSFONT_NAME_SIZE];
>  int index;
>  int firstchar, numchars;
>  int encoding;
>  u_int fontwidth, fontheight, stride;
>  int bitorder, byteorder;
>  void *cookie;
>  void *data;
>  };
>
>The name field contains a human readable string used to identify
>the font.  For VGA fonts, data is loaded in to the slot given in
>the index field, or into the next free slot if index is -1.  RASOPS
>ignores the index field.  The firstchar field contains the index of
>the first character in the font (always 0 for VGA.)  The numchars
>field contains the number of characters in the font (always 256 for
>VGA.)  The encoding field contains one of the following:
>
>WSDISPLAY_FONTENC_ISO
>
>WSDISPLAY_FONTENC_IBM
>
>WSDISPLAY_FONTENC_PCVT
>
>WSDISPLAY_FONTENC_ISO7
>
>The fontwidth and fontheight fields specify the dimensions of a
>character cell.  fontwidth must be set to 8 for VGA, but can be
>between 4 and 32 for RASOPS.  The stride field must be 1 for VGA.
>The bitorder and byteorder fields must be one of the following
>values:
>
>WSDISPLAY_FONTORDER_KNOWN
>  indicates no need to convert
>
>WSDISPLAY_FONTORDER_L2R
>  default and only option for VGA
>
>WSDISPLAY_FONTORDER_R2L
>
>The data field contains the font character data to be loaded.  The
>cookie field is reserved for internal purposes.
>
>  WSDISPLAYIO_LSFONT (struct wsdisplay_font)
>Retrieves the data for a loaded font into the wsdisplay_font
>structure.  The font is chosen by the index field. For VGA it is an
>index into an array. For RASOPS, it is the index into the list of
>fonts matching the cell dimensions of the current primary font (in
>ri->ri_font).  For the argument structure, see WSDISPLAYIO_LDFONT.
>
>  WSDISPLAYIO_USEFONT (struct wsdisplay_font)
>Tells an open device to use the font specified in the name field.
>An empty name selects the next matching font.  For the argument
>structure, see WSDISPLAYIO_LDFONT. For RASOPS, data must be null.
>
301a361,401
>
>  WSDISPLAYIO_ADDSCREEN (struct wsdisplay_addscreendata)
>Creates a new screen.
>
>  struct wsdisplay_addscreendata {
>  int idx; /* screen index */
>  char screentype[WSSCREEN_NAME_SIZE];
>  char emul[WSEMUL_NAME_SIZE];
>  };
>
>The idx field is the index of the screen to be configured. The
>screentype field is matched against builtin screen types. See
>vga(4) for valid screen types. The emul field indicates the type of
>emulation.  Valid options are "sun", "vt100", "dumb" or "" to
>select the default.
>
>  WSDISPLAYIO_DELSCREEN (struct wsdisplay_delscreendata)
>Deletes an existing screen.
>
>  struct wsdisplay_delscreendata {
>  int idx; /* screen index */
>  int flags;
>  };
>
>The idx field indicates the index of the screen to be deleted. The
>flags field is a logical OR of zero or more of the following:
>
>WSDISPLAY_DELSCR_FORCE
>  Force deletion of screen even if in use by a userspace
>  program.
>
>WSDISPLAY_DELSCR_QUIET
>  Don't report deletion to console.
>
>  WSDISPLAYIO_GETSCREEN (struct wsdisplay_addscreendata)
>Returns information on the screen indicated by idx or the current
>screen if idx is -1.  The screen and emulation types are returned
>in the same structure (see WSDISPLAYIO_GETPARAM ).
>
>  WSDISPLAYIO_SETSCREEN (u_int)
>Switch to the screen with the given index.


--- share/man/man4/wsdisplay.4  Tue Feb 17 07:36:33 2