Re: More 'extern' love: net proto

2013-04-15 Thread Martin Pieuchot
On 12/04/13(Fri) 12:26, Martin Pieuchot wrote:
 Simple diff to move all the redundant extern declaration into their 
 corresponding header.

I just realized that this diff is missing the sys/ part, here's the
full diff, everything goes under #ifdef _KERNEL anyway. ok?

Index: netinet/in_proto.c
===
RCS file: /home/ncvs/src/sys/netinet/in_proto.c,v
retrieving revision 1.58
diff -u -p -r1.58 in_proto.c
--- netinet/in_proto.c  17 Jan 2013 16:30:10 -  1.58
+++ netinet/in_proto.c  15 Apr 2013 09:55:41 -
@@ -176,7 +176,7 @@
 #include netinet/ip_divert.h
 #endif
 
-extern struct domain inetdomain;
+u_char ip_protox[IPPROTO_MAX];
 
 struct protosw inetsw[] = {
 { 0,   inetdomain,0,  0,
Index: netinet/ip_icmp.c
===
RCS file: /home/ncvs/src/sys/netinet/ip_icmp.c,v
retrieving revision 1.97
diff -u -p -r1.97 ip_icmp.c
--- netinet/ip_icmp.c   10 Apr 2013 08:50:59 -  1.97
+++ netinet/ip_icmp.c   15 Apr 2013 09:55:41 -
@@ -125,11 +125,6 @@ void icmp_mtudisc_timeout(struct rtentry
 int icmp_ratelimit(const struct in_addr *, const int, const int);
 void icmp_redirect_timeout(struct rtentry *, struct rttimer *);
 
-/* from ip_input.c */
-extern u_char ip_protox[];
-
-extern struct protosw inetsw[];
-
 void
 icmp_init(void)
 {
Index: netinet/ip_input.c
===
RCS file: /home/ncvs/src/sys/netinet/ip_input.c,v
retrieving revision 1.208
diff -u -p -r1.208 ip_input.c
--- netinet/ip_input.c  10 Apr 2013 08:50:59 -  1.208
+++ netinet/ip_input.c  15 Apr 2013 09:55:41 -
@@ -121,9 +121,6 @@ extern struct baddynamicports baddynamic
 
 int *ipctl_vars[IPCTL_MAXID] = IPCTL_VARS;
 
-extern struct domain inetdomain;
-extern struct protosw inetsw[];
-u_char ip_protox[IPPROTO_MAX];
 struct in_ifaddrhead in_ifaddr;
 struct ifqueue ipintrq;
 
Index: netinet/ipsec_input.c
===
RCS file: /home/ncvs/src/sys/netinet/ipsec_input.c,v
retrieving revision 1.113
diff -u -p -r1.113 ipsec_input.c
--- netinet/ipsec_input.c   11 Apr 2013 12:06:25 -  1.113
+++ netinet/ipsec_input.c   15 Apr 2013 09:55:41 -
@@ -110,11 +110,6 @@ int *espctl_vars[ESPCTL_MAXID] = ESPCTL_
 int *ahctl_vars[AHCTL_MAXID] = AHCTL_VARS;
 int *ipcompctl_vars[IPCOMPCTL_MAXID] = IPCOMPCTL_VARS;
 
-#ifdef INET6
-extern struct ip6protosw inet6sw[];
-extern u_char ip6_protox[];
-#endif
-
 /*
  * ipsec_common_input() gets called when we receive an IPsec-protected packet
  * in IPv4 or IPv6. All it does is find the right TDB and call the appropriate
Index: netinet6/icmp6.c
===
RCS file: /home/ncvs/src/sys/netinet6/icmp6.c,v
retrieving revision 1.125
diff -u -p -r1.125 icmp6.c
--- netinet6/icmp6.c10 Apr 2013 01:35:55 -  1.125
+++ netinet6/icmp6.c15 Apr 2013 09:55:41 -
@@ -129,10 +129,6 @@
  */
 #define in6p_ip6_nxt   inp_ipv6.ip6_nxt
 
-extern struct domain inet6domain;
-extern struct ip6protosw inet6sw[];
-extern u_char ip6_protox[];
-
 struct icmp6stat icmp6stat;
 
 extern struct inpcbtable rawin6pcbtable;
Index: netinet6/in6_proto.c
===
RCS file: /home/ncvs/src/sys/netinet6/in6_proto.c,v
retrieving revision 1.66
diff -u -p -r1.66 in6_proto.c
--- netinet6/in6_proto.c1 Apr 2013 22:58:29 -   1.66
+++ netinet6/in6_proto.c15 Apr 2013 09:55:41 -
@@ -122,8 +122,7 @@
 /*
  * TCP/IP protocol family: IP6, ICMP6, UDP, TCP.
  */
-
-extern struct domain inet6domain;
+u_char ip6_protox[IPPROTO_MAX];
 
 struct ip6protosw inet6sw[] = {
 { 0,   inet6domain,   IPPROTO_IPV6,   0,
Index: netinet6/ip6_input.c
===
RCS file: /home/ncvs/src/sys/netinet6/ip6_input.c,v
retrieving revision 1.111
diff -u -p -r1.111 ip6_input.c
--- netinet6/ip6_input.c28 Mar 2013 23:10:06 -  1.111
+++ netinet6/ip6_input.c15 Apr 2013 09:55:41 -
@@ -117,10 +117,6 @@
 #include netinet/ip_carp.h
 #endif
 
-extern struct domain inet6domain;
-extern struct ip6protosw inet6sw[];
-
-u_char ip6_protox[IPPROTO_MAX];
 struct in6_ifaddrhead in6_ifaddr;
 struct ifqueue ip6intrq;
 
Index: netinet6/ip6protosw.h
===
RCS file: /home/ncvs/src/sys/netinet6/ip6protosw.h,v
retrieving revision 1.7
diff -u -p -r1.7 ip6protosw.h
--- netinet6/ip6protosw.h   2 Jun 2003 23:28:16 -   1.7
+++ netinet6/ip6protosw.h   15 Apr 2013 09:55:41 -
@@ -142,4 +142,9 @@ struct ip6protosw {
int (*pr_sysctl)(int *, u_int, void *, size_t *, void *, size_t);
 };
 
+#ifdef _KERNEL
+extern u_char ip6_protox[];
+extern struct ip6protosw inet6sw[];
+#endif
+
 #endif /* 

Re: tmpfs

2013-04-15 Thread Marc Espie
On Thu, Apr 11, 2013 at 10:16:48AM +0100, Pedro Martelletto wrote:
 Speaking of, I see a lot of int64_max sprinkled throughout, which doesn't
 seem right for 32 bit platforms.
 
 Hi Ted,
 
 In tmpfs3.diff there are three uses of INT64_MAX:
 
 The first, in tmpfs_mount(), concerns the maximum amount of memory (in
 bytes) that tmpfs will contemplate. This value is bounded by the numbers
 in UVM's uvmexp and by the parameters specified upon mount, if any.

I won't pretend to understand this code all that much, but I'm now running
it... and I fully intend to try to run it into the ground, as I've started
a full bulk build with /tmp  using tmpfs... 
which means both object files and small work directories go to it.

I hope to avoid the mfs issues where once you've hit swap, you never go back.

I'll let you know if I see any panics.

(amd64, btw).



Re: tmpfs

2013-04-15 Thread Marc Espie
However, both fs indirection structures will need fixing,
as they use C99 field assignments:

you know stuff like:
+struct vops tmpfs_fifovops = {
+   .vop_lookup = tmpfs_fifo_lookup,
+   .vop_create = tmpfs_fifo_create,

and

+struct vops tmpfs_specvops = {
+   .vop_lookup = tmpfs_spec_lookup,
+   .vop_create = tmpfs_spec_create,



Re: tmpfs

2013-04-15 Thread Marc Espie
On Mon, Apr 15, 2013 at 12:20:13PM +0200, Marc Espie wrote:
 On Thu, Apr 11, 2013 at 10:16:48AM +0100, Pedro Martelletto wrote:
  Speaking of, I see a lot of int64_max sprinkled throughout, which doesn't
  seem right for 32 bit platforms.
  
  Hi Ted,
  
  In tmpfs3.diff there are three uses of INT64_MAX:
  
  The first, in tmpfs_mount(), concerns the maximum amount of memory (in
  bytes) that tmpfs will contemplate. This value is bounded by the numbers
  in UVM's uvmexp and by the parameters specified upon mount, if any.
 
 I won't pretend to understand this code all that much, but I'm now running
 it... and I fully intend to try to run it into the ground, as I've started
 a full bulk build with /tmp  using tmpfs... 
 which means both object files and small work directories go to it.
 
 I hope to avoid the mfs issues where once you've hit swap, you never go back.
 
 I'll let you know if I see any panics.
 
 (amd64, btw).

So, it's not working.

After about 5 mn of succesful build, my tmpfs is full
touch /tmp/a
touch: /tmp/a: No space left on device
whereas:
df -khi /tmp
tmpfs 10.5G 600M 9.9G   6% 45728 41386496  0% /tmp

so, something put it into a no space left configuration internally ?



Re: tmpfs

2013-04-15 Thread Pedro Martelletto

So, it's not working.

After about 5 mn of succesful build, my tmpfs is full
touch /tmp/a
touch: /tmp/a: No space left on device
whereas:
df -khi /tmp
tmpfs 10.5G 600M 9.9G   6% 45728 41386496  0% /tmp

so, something put it into a no space left configuration internally ?


My guess is that you are reaching the UVM aobj limit. Try a 'vmstat -m'
to check that.

-p.



Re: Removing -Wno-format from kernel makefiles

2013-04-15 Thread Stefan Fritsch

On Sun, 14 Apr 2013, Theo de Raadt wrote:

That wasn't clear from Miod's response. So the policy is to assume
that char/short/int/long long are 8/16/32/64 bits and that intptr_t
is  long?


We only run on C8S16I32L32P32 and C8S16I32L64P64 architectures.  Short
names ILP32 and I32LP64.  The addition of any other sizing would
require us to fix thousands of subtle bugs, and crank the ABI on every
architecture.


Should that be added to style(9), then?
I assume that the lack of a response means yes.


Perhaps.  Thing is, we don't want people to worsen the current
situation for decades down the line in case someone tries to create
a 'popular' architecture with I64.


Or LL128 ...
But if such architectures come around, all kinds of things will need to be 
changed. This should not prevent anyone from documenting the current best 
practices.



Since the kernel's printf does not support %td for ptrdiff_t, I have
used %ld instead. %zd would also work. Is there a preferred way?


Or try to add %td support to kernel printf?


That would also require gcc to be taught that %td is now allowed. I don't 
know how difficult that is, but I will take a look when I have some time.




unix semantics fuck up

2013-04-15 Thread Marc Espie
$ cat goodfilename
coincoin

$ perl -pi -e 's/toto/tutu/' goodfilename
works

$ cp goodfilename /tmp
$ perl -pi -e 's/toto/tutu/' /tmp/goodfilename
Can't do inplace edit on goodfilename: File exists.
$ cat /tmp/goodfilename
cat: /tmp/goodfilename: No such file or directory.

ktrace shows a disturbing lack of Unix semantics:
 
 15350 perl CALL  open(0x1850b9e863f0,0O_RDONLY)
 15350 perl NAMI  goodfilename
 15350 perl RET   open 3
 ...
 15350 perl CALL  unlink(0x1850b9e86a00)
 15350 perl NAMI  goodfilename
 15350 perl RET   unlink 0
 15350 perl CALL  
open(0x1850b9e868e0,0xa01O_WRONLY|O_CREAT|O_EXCL,0x180S_IRUSR|S_IWUSR)
 15350 perl NAMI  goodfilename
 15350 perl RET   open -1 errno 17 File exists


err...

simply put:

#include fcntl.h
#include unistd.h
#include stdio.h

int 
main()
{
if (open(fucked_up, O_RDWR|O_CREAT|O_TRUNC, 0666) == -1)
perror(open);
if (unlink(fucked_up) != 0)
perror(unlink);
if (open(fucked_up, O_WRONLY|O_CREAT|O_EXCL, 0666) == -1)
perror(reopen);
return 0;
}



Re: tmpfs

2013-04-15 Thread Pedro Martelletto

$ cat goodfilename
coincoin

$ perl -pi -e 's/toto/tutu/' goodfilename
works

$ cp goodfilename /tmp
$ perl -pi -e 's/toto/tutu/' /tmp/goodfilename
Can't do inplace edit on goodfilename: File exists.
$ cat /tmp/goodfilename
cat: /tmp/goodfilename: No such file or directory.

ktrace shows a disturbing lack of Unix semantics:

15350 perl CALL  open(0x1850b9e863f0,0O_RDONLY)
15350 perl NAMI  goodfilename
15350 perl RET   open 3
...
15350 perl CALL  unlink(0x1850b9e86a00)
15350 perl NAMI  goodfilename
15350 perl RET   unlink 0
15350 perl CALL  
open(0x1850b9e868e0,0xa01O_WRONLY|O_CREAT|O_EXCL,0x180S_IRUSR|S_IWUSR)
15350 perl NAMI  goodfilename
15350 perl RET   open -1 errno 17 File exists


err...

simply put:

#include fcntl.h
#include unistd.h
#include stdio.h

int
main()
{
if (open(fucked_up, O_RDWR|O_CREAT|O_TRUNC, 0666) == -1)
perror(open);
if (unlink(fucked_up) != 0)
perror(unlink);
if (open(fucked_up, O_WRONLY|O_CREAT|O_EXCL, 0666) == -1)
perror(reopen);
return 0;
}


Thank you very much for spotting this. The problem was a missing check
when calling cache_enter() from tmpfs_lookup(). I have fixed the glitch
in version 4 of the diff:

http://block.io/tmpfs/tmpfs4.diff

Alternatively, you might want to ammend the source code directly, since
it is a one-line change. In tmpfs_vnops.c, replace the following check
in line 289

if (cnp-cn_nameiop != CREATE) {
cache_enter(dvp, *vpp, cnp);
}

with

if ((cnp-cn_flags  MAKEENTRY)  cnp-cn_nameiop != CREATE) {
cache_enter(dvp, *vpp, cnp);
}

-p.



Re: tmpfs

2013-04-15 Thread Pedro Martelletto

http://block.io/tmpfs/tmpfs4.diff


My bad, the correct URL is:

http://block.io/tmp/tmpfs4.diff

-p.



Re: tmpfs

2013-04-15 Thread Pedro Martelletto

However, both fs indirection structures will need fixing,
as they use C99 field assignments:

you know stuff like:
+struct vops tmpfs_fifovops = {
+   .vop_lookup = tmpfs_fifo_lookup,
+   .vop_create = tmpfs_fifo_create,

and

+struct vops tmpfs_specvops = {
+   .vop_lookup = tmpfs_spec_lookup,
+   .vop_create = tmpfs_spec_create,


This is the same kind of field assignment used by all other file systems
in the tree for 2 years now.

-p.



Re: unix semantics fuck up

2013-04-15 Thread sven falempin
*-i*[*extension*]

-i\.sed

but wow, nice way to destroy file.


On Mon, Apr 15, 2013 at 8:12 AM, Marc Espie es...@nerim.net wrote:

 $ cat goodfilename
 coincoin

 $ perl -pi -e 's/toto/tutu/' goodfilename
 works

 $ cp goodfilename /tmp
 $ perl -pi -e 's/toto/tutu/' /tmp/goodfilename
 Can't do inplace edit on goodfilename: File exists.
 $ cat /tmp/goodfilename
 cat: /tmp/goodfilename: No such file or directory.

 ktrace shows a disturbing lack of Unix semantics:
  
  15350 perl CALL  open(0x1850b9e863f0,0O_RDONLY)
  15350 perl NAMI  goodfilename
  15350 perl RET   open 3
  ...
  15350 perl CALL  unlink(0x1850b9e86a00)
  15350 perl NAMI  goodfilename
  15350 perl RET   unlink 0
  15350 perl CALL
  open(0x1850b9e868e0,0xa01O_WRONLY|O_CREAT|O_EXCL,0x180S_IRUSR|S_IWUSR)
  15350 perl NAMI  goodfilename
  15350 perl RET   open -1 errno 17 File exists


 err...

 simply put:

 #include fcntl.h
 #include unistd.h
 #include stdio.h

 int
 main()
 {
 if (open(fucked_up, O_RDWR|O_CREAT|O_TRUNC, 0666) == -1)
 perror(open);
 if (unlink(fucked_up) != 0)
 perror(unlink);
 if (open(fucked_up, O_WRONLY|O_CREAT|O_EXCL, 0666) == -1)
 perror(reopen);
 return 0;
 }




-- 
-
() ascii ribbon campaign - against html e-mail
/\


Re: unix semantics fuck up

2013-04-15 Thread sven falempin
On Mon, Apr 15, 2013 at 10:44 AM, sven falempin sven.falem...@gmail.comwrote:

 *-i*[*extension*]

 -i\.sed

 but wow, nice way to destroy file.

 oh , it is tmpfs related :-)



 On Mon, Apr 15, 2013 at 8:12 AM, Marc Espie es...@nerim.net wrote:

 $ cat goodfilename
 coincoin

 $ perl -pi -e 's/toto/tutu/' goodfilename
 works

 $ cp goodfilename /tmp
 $ perl -pi -e 's/toto/tutu/' /tmp/goodfilename
 Can't do inplace edit on goodfilename: File exists.
 $ cat /tmp/goodfilename
 cat: /tmp/goodfilename: No such file or directory.

 ktrace shows a disturbing lack of Unix semantics:
  
  15350 perl CALL  open(0x1850b9e863f0,0O_RDONLY)
  15350 perl NAMI  goodfilename
  15350 perl RET   open 3
  ...
  15350 perl CALL  unlink(0x1850b9e86a00)
  15350 perl NAMI  goodfilename
  15350 perl RET   unlink 0
  15350 perl CALL
  open(0x1850b9e868e0,0xa01O_WRONLY|O_CREAT|O_EXCL,0x180S_IRUSR|S_IWUSR)
  15350 perl NAMI  goodfilename
  15350 perl RET   open -1 errno 17 File exists


 err...

 simply put:

 #include fcntl.h
 #include unistd.h
 #include stdio.h

 int
 main()
 {
 if (open(fucked_up, O_RDWR|O_CREAT|O_TRUNC, 0666) == -1)
 perror(open);
 if (unlink(fucked_up) != 0)
 perror(unlink);
 if (open(fucked_up, O_WRONLY|O_CREAT|O_EXCL, 0666) == -1)
 perror(reopen);
 return 0;
 }




 --

 -
 () ascii ribbon campaign - against html e-mail
 /\




-- 
-
() ascii ribbon campaign - against html e-mail
/\


Re: pppd-invoked scripts to run as root or not?

2013-04-15 Thread Jason McIntyre
On Sun, Mar 24, 2013 at 12:15:55AM +, Creamy wrote:
 From the pppd man page:
 
 1163:.Sh SCRIPTS
 1164-.Nm
 1165-invokes scripts at various stages in its processing which can be
 1166-used to perform site-specific ancillary processing.
 1167-These scripts are usually shell scripts, but could be executable code 
 files
 1168-instead.
 1169-.Nm
 1170-does not wait for the scripts to finish.
 1171-The scripts are executed as root (with the real and effective user ID 
 set to 0),
  
 
 No, they are not.  Which is wrong, the man page, or the behavior of pppd?
 

my understanding is the behaviour is wrong (as already pointed out
in this thread). stuart henderson has asked for some feedback on a
diff but seemingly received none. so until this issue is cleared
up, i've amended the man page.

jmc



Re: Removing -Wno-format from kernel makefiles

2013-04-15 Thread Theo de Raadt
 Or LL128 ...
 But if such architectures come around, all kinds of things will need to be 
 changed. This should not prevent anyone from documenting the current best 
 practices.

All kinds of things will need to be changed?  Quite the understatement.



Re: Active PS/2 Multiplexing

2013-04-15 Thread mike
On Sun, 14 Apr 2013 10:57:04 +
Miod Vallat m...@online.fr wrote:

  Did you get any other feedback or test report? What was the previous
  issues preventing this for going in? I don't remember. 
 
 It used to not behave correctly after suspend, but that was fixed
 eventually. The main reason why this has never been commited was that
 none of the systems this diff had been tried on had a multiplexed
 device, except for Tobias' machine...
 

Hello,

This diff just solved my suspend/resume problem:
http://comments.gmane.org/gmane.os.openbsd.misc/203943

Is this going to eventually make it in the tree ?

Best regards,
Mike



Re: Active PS/2 Multiplexing

2013-04-15 Thread Tobias Stoeckmann
Hello mike, and hello list,

this is the first feedback I have received as of now, and nice to hear
that the diff helps someone else, too.  Having no negative feedback, I
would say it didn't hurt anyone out there (yet).

So if there are no further objections or feedback, I would go for the
diff and commit it soon.


Tobias

On Mon, Apr 15, 2013 at 09:51:33PM +0200, mike wrote:
 On Sun, 14 Apr 2013 10:57:04 +
 Miod Vallat m...@online.fr wrote:
 
   Did you get any other feedback or test report? What was the previous
   issues preventing this for going in? I don't remember. 
  
  It used to not behave correctly after suspend, but that was fixed
  eventually. The main reason why this has never been commited was that
  none of the systems this diff had been tried on had a multiplexed
  device, except for Tobias' machine...
  
 
 Hello,
 
 This diff just solved my suspend/resume problem:
 http://comments.gmane.org/gmane.os.openbsd.misc/203943
 
 Is this going to eventually make it in the tree ?
 
 Best regards,
 Mike



Important: following -current update!

2013-04-15 Thread Philip Guenther
While it's often the case that you can leave our steps when building
-current from source, it is sometimes ABSOLUTELY REQUIRED that you
followed the steps precisely.

This is one of those times.

If you build a -current kernel without running config(8) and make
clean, then the resulting kernel WILL NOT RUN YOUR INSTALLED
USERLAND.  If that happens, you will have to boot from the old kernel
(do you know how?) or boot from an alternate device like a CD.

If you are not 100% comfortable with doing that recovery, then you
should wait and install the next snapshot instead.


Philip Guenther

-- Forwarded message --
From: Philip Guenther guent...@cvs.openbsd.org
Date: Mon, Apr 15, 2013 at 8:56 PM
Subject: CVS: cvs.openbsd.org: www
To: source-chan...@cvs.openbsd.org
...
Modified files:
faq: current.html

Log message:
statfs change requires strict following of the build steps, or you'll
end up with a userland that can't mount (or remount!) critical filesystems