dhcpcd -U6 /var/db/dhcpcd/alc0.lease6 incorrectly returns "dhcpcd is not running"

2021-07-01 Thread Zack Newman
Background:

beta# uname -a
OpenBSD beta.philomathiclife.com 6.9 GENERIC.MP#3 amd64 

beta# dhcpcd --version
dhcpcd 9.4.0
Copyright (c) 2006-2020 Roy Marples
Compiled in features: INET ARP ARPing IPv4LL INET6 DHCPv6 AUTH PRIVSEP

beta# cat /etc/hostname.alc0
dhcp
group egress
!/etc/rc.d/dhcpcd start

beta# rcctl ls on
check_quotas
cron
library_aslr
ntpd
pf
pflogd
rad
smtpd
sshd
syslogd
unbound

beta# rcctl ls started
cron
dhcpcd
ntpd
pflogd
rad
smtpd
sshd
syslogd
unbound

beta# ps -A | grep "dhcpcd"
37918 ??  Sp   0:31.21 dhcpcd: [master] [ip6] (dhcpcd)
64941 ??  S0:26.46 dhcpcd: [privileged actioneer] (dhcpcd)
53344 ??  Sp   0:00.61 dhcpcd: [network proxy] (dhcpcd)
35058 ??  Sp   0:00.32 dhcpcd: [control proxy] (dhcpcd)
90538 p0  S+p  0:01.12 grep dhcpcd

beta# dhcpcd -U6 /var/db/dhcpcd/alc0.lease6
dhcpcd is not running

Problem:

When I start dhcpcd during booting the “normal” way (i.e., rcctl enable 
dhcpcd), I am able to successfully dump the lease information associated with 
the alc0 interface (which is connected directly to my bridge modem); however 
when I start the command inside of /etc/hostname.alc0 during booting, I am 
unable to get lease information after. When the computer boots up, I 
successfully acquire a DHCPv6 lease as well as have a /60 routed to me. My IPv6 
connectivity runs just fine too.

I found a discussion on the blog 
(https://roy.marples.name/archives/dhcpcd-discuss/0003312.html 
) belonging to 
the creator but now former maintainer, Roy Marples, of dhcpcd where a similar 
issue was had by someone running dhcpcd on their ARM32 server running a custom 
Linux 4.9 kernel. After much back-and-forth, it was discovered to be an issue 
with privsep not having the system calls fcntl64, fstat64, and TCGETS 
available. Those calls were added 
(https://github.com/NetworkConfiguration/dhcpcd/blob/master/src/privsep-linux.c 
)
 for Linux, and that fixed the issue. I realize that OpenBSD has pledge, so 
this may not be relevant at all and just a coincidence.

Before I raise an issue upstream, I want to make sure this is actually a bug 
and not intended behavior on OpenBSD. I realize that by starting dhcpcd inside 
of /etc/hostname.alc0, it gets started earlier in the boot process—which is in 
fact why I configured it this way—and that means it gets started a lower secure 
level than when it gets started as a normal packaging daemon.

beta# dmesg
OpenBSD 6.9 (GENERIC.MP) #3: Mon Jun  7 08:21:26 MDT 2021

r...@syspatch-69-amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 17112133632 (16319MB)
avail mem = 16578150400 (15810MB)
random: good seed from bootblocks
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 3.2 @ 0xec921000 (49 entries)
bios0: vendor American Megatrends Inc. version "F50d" date 06/16/2020
bios0: Gigabyte Technology Co., Ltd. AX370-Gaming K7
acpi0 at bios0: ACPI 6.0
acpi0: sleep states S0 S4 S5
acpi0: tables DSDT FACP APIC FPDT FIDT SSDT SSDT SSDT MCFG SSDT HPET SSDT UEFI 
VFCT IVRS SSDT CRAT CDIT SSDT SSDT WSMT SSDT
acpi0: wakeup devices GPP0(S4) GPP1(S4) GPP3(S4) GPP4(S4) GPP5(S4) GPP6(S4) 
GPP7(S4) GPP8(S4) GPP9(S4) GPPA(S4) GPPB(S4) GPPC(S4) GPPD(S4) GPPE(S4) 
GPPF(S4) GP17(S4) [...]
acpitimer0 at acpi0: 3579545 Hz, 32 bits
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: AMD Ryzen 7 1700X Eight-Core Processor, 3400.66 MHz, 17-01-01
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT,SSE3,PCLMUL,MWAIT,SSSE3,FMA3,CX16,SSE4.1,SSE4.2,MOVBE,POPCNT,AES,XSAVE,AVX,F16C,RDRAND,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,SKINIT,TCE,TOPEXT,CPCTR,DBKP,PCTRL3,MWAITX,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,RDSEED,ADX,SMAP,CLFLUSHOPT,SHA,IBPB,XSAVEOPT,XSAVEC,XGETBV1,XSAVES
cpu0: 64KB 64b/line 4-way I-cache, 32KB 64b/line 8-way D-cache, 512KB 64b/line 
8-way L2 cache
cpu0: ITLB 64 4KB entries fully associative, 64 4MB entries fully associative
cpu0: DTLB 64 4KB entries fully associative, 64 4MB entries fully associative
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
cpu0: apic clock running at 100MHz
cpu0: mwait min=64, max=64, IBE
cpu1 at mainbus0: apid 1 (application processor)
cpu1: AMD Ryzen 7 1700X Eight-Core Processor, 3400.10 MHz, 17-01-01
cpu1: 

Re: while do done

2021-07-01 Thread Stuart Longland
On Mon, 28 Jun 2021 22:20:15 +1000
Reuben ua Bríġ  wrote:

> you cant interrupt sh in
> 
>   while do done
> 
> not that it matters.
> 

vk4msl-bne$ cat test.sh 

 
#!/bin/sh

oninterrupt() {
echo "I was interrupted!"
exit 0
}

trap oninterrupt INT
while true; do
# Do something
sleep 10
done
vk4msl-bne$ sh test.sh   
^CI was interrupted!
vk4msl-bne$ uname -a
OpenBSD vk4msl-bne.dmz.longlandclan.id.au 6.9 GENERIC#0 amd64


-- 
Stuart Longland (aka Redhatter, VK4MSL)

I haven't lost my mind...
  ...it's backed up on a tape somewhere.



Re: C style in OpenBSD

2021-07-01 Thread Stuart Longland
On Thu, 1 Jul 2021 19:09:28 +1000
Reuben ua Bríġ  wrote:

> > Date: Thu,  1 Jul 2021 13:51:21 +1000
> > From: Stuart Longland   
> 
> > Even someone who didn't know "C",  
> 
> ... seriously?

Yes seriously, there are people who write software computers, and do
not know C.

> > If you didn't know what a ternary was  
> 
> ... seriously?

If you've never needed to use one, why would you know about them?

Ternaries can look different in different languages too.  In Python,
they're expressed as:

(true expression) if (condition) else (false expression)

Some languages do not have ternaries.

> > search.argmode = (
> > (strcmp(progname, BINM_MAN) == 0)
> > ? ARG_NAME
> > : (
> > (strcmp(progname, BINM_APROPOS) == 0) == 0)
> > ? ARG_EXPR
> > : (  
> 
> ... do you write:
> 
> if
> else
>   if
>   else
>   if
>   else
>   .
>.

`if` and `else` are more easily spotted by the eye than `:` and `?`.
If I wanted to write in meaningless symbols I'd use BrainFuck.

> no?  then why do you write ? : in this style?  it is the SAME logic,
> but the conditional is on the expression, not the statement.

It actually isn't… you can add braces to the if-else, and put
for/while/switch/if statements inside those braces to do more complex
logic if the need arises.  Only mathematical expressions can be used
in ternaries.

So the if/else is infinitely more extensible than a ternary, whilst
_also_ being more readable because the eye will spot words like `if`
and `else` easier than single characters.

> my ? : indentation style is based on that usually used for else if

Go patent it then.  I hear they'll patent anything these days.

> > Now, it should be immediately apparent why nesting this many ternaries
> > is a bad idea.  
> 
> Now,
>   it
>   should
>   be
>   immediately
>   apparent
>   why
> 
> excessive indentation is a bad idea.

Right, I do not disagree there.  I tend to use tabs for indentation and
limit my line length to ~80 characters for that reason: if I'm having
to use too deep-er indentation in a function, this is a hint to me that
maybe the function is getting too complex and should be split up or
re-factored to make it less complex.

Some argue that with wide-screen monitors 80 characters is rooted in
the past, and they have a point, but being able to fit two files
side-by-side on the same 1920×1080 monitor with a readable font size is
a big plus in my book.

> > Yeah, it kinda sucks there's no way to do a `switch` with strings,  
> 
> that is what my code does!

… badly.

> > I prefer to use brackets more than is strictly necessary.  
> 
>   STYLE(9)
> 
>   Don't use parentheses unless they're required for precedence,
>   the statement is confusing without them, or the compiler
>   generates a warning without them.

"the statement is confusing without them" -- a subjective observation.
If you do C and nothing but C for a living, with one compiler on one
platform, then maybe, you know the operator precedence off-by-heart.

Most languages follow very similar precedence rules, so often things
just work anyway.

Occasionally, someone will slip an edge case in that you weren't
expecting, using brackets makes it abundantly clear, even to the
compiler/interpreter, what your intent is, a buggy compiler that
ignores operator precedence is not an issue so long as it processes
bracketed expressions properly, anyone with primary-school level maths
will understand what bits are to be computed first (even if they have
to look up what a particular operator does to its operands).

> > I do hope the coding styles you're showcasing to us aren't what
> > they're teaching at ANU.  
> 
> I AM NOT A COMPUTING STUDENT, TEACHER, STAFFER, etc.

Then stop acting like a first year CS student.
-- 
Stuart Longland (aka Redhatter, VK4MSL)

I haven't lost my mind...
  ...it's backed up on a tape somewhere.



Re: supermicro 5019D-FTN4 server with AMD EPYC 3251 SoC Processor

2021-07-01 Thread EdaSky
Thank you very much for your experience and dmesgs.

I'll buy it



Re: C style in OpenBSD

2021-07-01 Thread andrew fabbro
When you write code by yourself:

On Tue, Jun 29, 2021 at 6:15 AM Reuben ua Bríġ  wrote:
> a style i came up with in imitation of some disgusting haskell code.

When you write code with others:

On Wed, Jun 30, 2021 at 7:34 AM Todd C. Miller  wrote:
> It is because consistency makes the code
> easier to read for anyone familiar with that style.  Part of that
> means using common idioms that are immediately recognizable by
> someone familiar with the style.  This reduces the amount of time
> is takes someone to understand the code.

-- 
andrew fabbro
and...@fabbro.org


For your propaganda needs: The Impending Doom of Your Operating System Going to or Past 11, Versus the Lush Oasis of Open Source Systems

2021-07-01 Thread Peter N. M. Hansteen
For your propaganda needs -

The Impending Doom of Your Operating System Going to or Past 11, Versus
the Lush Oasis of Open Source Systems

Will the uncertainty over forced obsolescence of fairly recent hardware
force Microsoft and Apple users to switch to open source alternatives?

-- TL;DR: Open source, specifically OpenBSD, is good for you. Also
featuring bit players Linux, macOS, Windows 11, Apple, Microsoft.

Full article at
https://bsdly.blogspot.com/2021/07/the-impending-doom-of-your-operating.html


(or if you can't stand the big G,
https://www.bsdly.net/~peter/blog_wild_wild_world_of_windows.html)

Cheers,
Peter

-- 
Peter N. M. Hansteen, member of the first RFC 1149 implementation team
http://bsdly.blogspot.com/ http://www.bsdly.net/ http://www.nuug.no/
"Remember to set the evil bit on all malicious network traffic"
delilah spamd[29949]: 85.152.224.147: disconnected after 42673 seconds.



Re: How to set a HTTP proxy for sysupgrade

2021-07-01 Thread trondd
On Thu, July 1, 2021 4:25 am, Raimo Niskanen wrote:
> On Wed, Jun 30, 2021 at 09:23:15PM -0400, trondd wrote:
>>
>> I simply echo the export statements of the proxy environment variables
>> to
>> /etc/rc.firstime before reboot. The installer will always append to the
>> file so fw_update will be added after the variables are exported.
>
> I will try to remember to do that the next time.
> Thanks for the hint!
>
> Would that be a welcome addition to the installer to do this
> automatically?
>
>

The installer can't do it.  Sysupgrade pulls the sets down and so the
automated installation does not use the network.  It won't know if there
is a proxy configuration to pass to rc.firsttime.

I suppose sysupgrade can check the environment for the variables and write
them out to rc.firsttime if they are set.

I just have a wrapper script because I also have internally hosted site
tarballs that need the proxy disabled to access so it was just easier to
have my own script to enable and disable the proxy as needed for the steps
I need to take.  I suppose that's why I never thought to try modifying
sysupgrade.  In my environment, I would still need the script regardless.

Tim.



Re: How to set a HTTP proxy for sysupgrade

2021-07-01 Thread Raimo Niskanen
On Wed, Jun 30, 2021 at 09:23:15PM -0400, trondd wrote:
> On Wed, June 30, 2021 5:28 am, Raimo Niskanen wrote:
> > Hello list!
> >
> > I just upgraded one of our lab machines from 6.8 to 6.9
> > (amd64), and our lab environment is closed to the Internet,
> > so using an HTTP proxy is required to reach out.
> >
> > I have set http_proxy, ftp_proxy and https_proxy in
> > /etc/login.conf, the default class, but it is apparently
> > not used by rc.firstboot after sysupgrade.
> >
> > With the new installer in 6.9 rc.firstboot seems to be
> > a background process that hangs because of this, so when I
> > logged in as root after remote upgrade I resolved the stalemate
> > by first killing an ftp job serving fw_update, then a similar
> > download job serving syspatch, and waited until the not updated
> > kernel was relinked.
> > Then I could run fw_update and syspatch manually.
> >
> > Is there a better / proper way to set a HTTP/HTTPS proxy
> > for sysupgrade?
> >
> > Cheers
> > --
> >
> > / Raimo Niskanen, Erlang/OTP, Ericsson AB
> >
> 
> I simply echo the export statements of the proxy environment variables to
> /etc/rc.firstime before reboot. The installer will always append to the
> file so fw_update will be added after the variables are exported.

I will try to remember to do that the next time.
Thanks for the hint!

Would that be a welcome addition to the installer to do this automatically?


> 
> The ftp process will timeout in, I think, 5 minutes.  That is a long time,
> but you're not going to be hung there forever.
> 
> Tim.

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



Re: Source of the spin

2021-07-01 Thread Stuart Henderson
On 2021-06-30, Sven F.  wrote:
> On Wed, Jun 30, 2021 at 4:15 AM Stuart Henderson  wrote:
>>
>> On 2021-06-29, Sven F.  wrote:
>> > Dear readers,
>> >
>> > I probably did something silly again,
>> > Could you help with a bit of knowledge around performance ?
>> > My openbsd CPU (6.8) is spinning a lot :
>> >
>> >  0.0%Int  53.1%Spn  25.8%Sys  19.6%Usr   1.4%Idle
>> >
>> >  * Is this bad ?
>> >  * What kind of basic operation ( like basic shell scripting ) could do 
>> > that ? ?
>> >
>> > Thank you,
>> >
>>
>> This means the kernel is spending a lot of time waiting for other CPUs
>> to exit locked sections.
>>
>> First things first, try 6.9, the malloc cache implementation changed
>> and that may help.
>>
>>
>
> Thank you,
>
> Can I use ktrace to check where the lock comes from ( can't really put
> 6.9 easily to test ) ?
> Will try to get 6.9 anyway, but it would be either to know what i need to 
> test.

If it's due to a userland process then possibly, as might ltrace. To use
either of these you will need to already know *what* process is involved,
and it is not particularly easy to figure out from the output which
calls/functions result in high cpu use.

Using dt(4)/btrace and generating a flamegraph gives a view of what's
happening in the kernel (it was not enabled by default until after 6.9
so you will need a kernel built with modified config to use it).

See https://marc.info/?l=openbsd-bugs=158583371404603=2 but also
see mpi's other posts in the thread. But this is a lot of work to do if
it is something that has already been improved in the OS.




Re: C style in OpenBSD

2021-07-01 Thread Stuart Longland
On Tue, 29 Jun 2021 15:17:58 +0959
Reuben ua Bríġ  wrote:

> i found the following:
> 
> if (strcmp(progname, BINM_MAN) == 0)
> search.argmode = ARG_NAME;
> else if (strcmp(progname, BINM_APROPOS) == 0)
> search.argmode = ARG_EXPR;
> else if (strcmp(progname, BINM_WHATIS) == 0)
> search.argmode = ARG_WORD;
> else if (strncmp(progname, "help", 4) == 0)
> search.argmode = ARG_NAME;
> else
> search.argmode = ARG_FILE;
> 
> much more readable as:
> 
> search.argmode =
> strcmp(progname, BINM_MAN) == 0 ?   ARG_NAME :
> strcmp(progname, BINM_APROPOS) == 0 ?   ARG_EXPR :
> strcmp(progname, BINM_WHATIS) == 0 ?ARG_WORD :
> strncmp(progname, "help", 4) == 0 ? ARG_NAME :
> ARG_FILE;

I disagree.

The former uses universally understood `if` statements, with clear
formatting of the condition expression and the true/false branches.
Some might quibble about a lack of braces, but the indentation make
things clear enough.

Even someone who didn't know "C", would be able to more-or-less
understand what is being done.  It's almost pseudo-code like.  About
the only trickiness is understanding `strcmp`/`strncmp`.

The latter uses undelimited nested ternaries, with no clear demarcation
between the ternary expression and its true/false branches.  If you
didn't know what a ternary was, you'd be totally snookered
understanding that blob of code.

Maybe it looks "prettier", but if I wanted to write "pretty" C code,
I'd enter the IOCCC.

If I absolutely *had* to use ternaries (and you'd pretty much have to
do it at gun-point, threatening some innocent bystander):

search.argmode = (
(strcmp(progname, BINM_MAN) == 0)
? ARG_NAME
: (
(strcmp(progname, BINM_APROPOS) == 0) == 0)
? ARG_EXPR
: (
(strcmp(progname, BINM_WHATIS) == 0)
? ARG_WORD
: (
(strncmp(progname, "help", 4) == 0)
? ARG_NAME
: ARG_FILE
)
)
)
);

Now, it should be immediately apparent why nesting this many ternaries
is a bad idea.  The above is a marginal improvement, you can clearly see
a ternary is involved and what bits are what, but it's blindingly
obvious why I wouldn't nest that many ternaries and why `if`/`else` or
`switch` is a better solution.

Yeah, it kinda sucks there's no way to do a `switch` with strings, but
the `if`/`else` solution isn't a bad one, and on some rare occasions
(I've personally observed this on MSP430 with gcc), using `if`/`else`
generates tighter code than `switch` does.

You might argue about "operator precedence", and most languages follow
the same rules, but there's enough subtle differences between them, and
I bounce between 4 of them in my day job, that I prefer to use brackets
more than is strictly necessary.

Neither of the "ternary" examples here would qualify for OpenBSD coding
standards.

I do hope the coding styles you're showcasing to us aren't what they're
teaching at ANU.  I've heard of "Canberra bubble" referring to the
reality distortion field that the politicians down there live in, but I
didn't think it extended to the local uni there!
-- 
Stuart Longland (aka Redhatter, VK4MSL)

I haven't lost my mind...
  ...it's backed up on a tape somewhere.