PCI IDs for Ivy Bridge board

2012-07-08 Thread Seth Wright
The patch below adds PCI IDs for the five (previously) "unknown"
devices on my Panther Point / Z77-chipset motherboard.  dmesg follows
diff.

Seth


Index: pcidevs
===
RCS file: /cvsroot/OpenBSD/src/sys/dev/pci/pcidevs,v
retrieving revision 1.1651
diff -u -p -r1.1651 pcidevs
--- pcidevs 8 Jul 2012 09:48:38 -   1.1651
+++ pcidevs 8 Jul 2012 21:30:15 -
@@ -2370,6 +2370,7 @@ product INTEL CORE2G_GT2  0x0112  HD Graph
 product INTEL CORE2G_M_GT2 0x0116  HD Graphics 3000
 product INTEL CORE2G_GT2_PLUS  0x0122  HD Graphics 3000
 product INTEL CORE2G_M_GT2_PLUS0x0126  HD Graphics 3000
+productINTEL XEONE3_1200_HB_1  0x0150  Xeon E3-1200 2G/3G Host
 product INTEL CORE3G_D_GT1 0x0152  HD Graphics 2500
 productINTEL CORE3G_M_HB   0x0154  Core 3G Host
 product INTEL CORE3G_M_GT1 0x0156  HD Graphics 2500
@@ -2697,7 +2698,8 @@ product INTEL C600_MEI_1  0x1d3a  C600 MEI
 product INTEL C600_MEI_2   0x1d3b  C600 MEI
 product INTEL C600_VPCIE   0x1d3e  C600 Virtual PCIE
 product INTEL C600_LPC 0x1d41  C600 LPC
-productINTEL 7SERIES_AHCI  0x1e03  7 Series AHCI
+productINTEL 7SERIES_AHCI  0x1e02  7 Series AHCI
+productINTEL 7SERIES_AHCI_10x1e03  7 Series AHCI
 productINTEL 7SERIES_PCIE_10x1e10  7 Series PCIE
 productINTEL 7SERIES_PCIE_20x1e12  7 Series PCIE
 productINTEL 7SERIES_PCIE_30x1e14  7 Series PCIE
@@ -2712,6 +2714,7 @@ product   INTEL 7SERIES_EHCI_10x1e26  7 Se
 productINTEL 7SERIES_EHCI_20x1e2d  7 Series USB
 productINTEL 7SERIES_MEI_1 0x1e3a  7 Series MEI
 productINTEL 7SERIES_MEI_2 0x1e3b  7 Series MEI
+productINTEL 7SERIES_LPC   0x1e44  Z77 Express LPC
 productINTEL QM77_LPC  0x1e55  QM77 LPC
 product INTEL 82801AA_LPC  0x2410  82801AA LPC
 product INTEL 82801AA_IDE  0x2411  82801AA IDE
@@ -3586,6 +3589,7 @@ product ITEXPRESS IT8212F 0x8212  IT8212F
 product ITEXPRESS IT8213F  0x8213  IT8213F
 product ITEXPRESS IT8330G  0x8330  IT8330G
 product ITEXPRESS ITF_ISA  0x  ITF ISA
+product ITEXPRESS IT8892E_ISA  0x8892  IT8892E ISA

 /* JMicron */
 product JMICRON JMC250 0x0250  JMC250
@@ -3788,6 +3792,7 @@ product MARVELL 88SE6141  0x6141  88SE6141
 product MARVELL 88SE6145   0x6145  88SE6145 SATA
 product MARVELL 88SX7042   0x7042  88SX7042 SATA
 product MARVELL2 88SE9123  0x9123  88SE9123 SATA
+product MARVELL2 88SE9172  0x9172  88SE9172 SATA

 /* Matrox products */
 product MATROX ATLAS   0x0518  MGA PX2085 (Atlas)



--

dmesg:

OpenBSD 5.2-beta (GENERIC.MP) #5: Sun Jul  8 17:20:04 EDT 2012
s...@ivy.crosse.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 17072521216 (16281MB)
avail mem = 16595693568 (15826MB)
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.7 @ 0xeb5c0 (57 entries)
bios0: vendor Intel Corp. version "BHZ7710H.86A.0057.2012.0208.1904"
date 02/08/2012
bios0: Intel Corporation DZ77BH-55K
acpi0 at bios0: rev 2
acpi0: sleep states S0 S1 S3 S4 S5
acpi0: tables DSDT FACP APIC MCFG HPET SSDT SSDT SSDT
acpi0: wakeup devices PS2K(S3) PS2M(S3) CIRP(S3) P0P1(S4) USB1(S3)
USB2(S3) USB3(S3) USB4(S3) USB5(S3) USB6(S3) USB7(S3) PXSX(S4)
RP01(S4) PXSX(S4) RP02(S4) PXSX(S4) ITEE(S3) SLT1(S3) SLT2(S3)
RP03(S4) PXSX(S4) RP04(S4) PXSX(S4) RP05(S4) PXSX(S4) RP06(S4)
PXSX(S4) RP07(S4) PXSX(S4) RP08(S4) PEGP(S4) PEG0(S4) PEG1(S4)
PEG2(S4) PEG3(S4) GLAN(S4) EHC1(S3) EHC2(S3) XHC_(S4) HDEF(S4)
PWRB(S3)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz, 3392.84 MHz
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,SBF,SSE3,PCLMUL,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,SSE4.1,SSE4.2,POPCNT,AES,XSAVE,AVX,NXE,LONG,LAHF
cpu0: 256KB 64b/line 8-way L2 cache
cpu0: apic clock running at 99MHz
cpu1 at mainbus0: apid 2 (application processor)
cpu1: Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz, 3392.30 MHz
cpu1: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,SBF,SSE3,PCLMUL,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,SSE4.1,SSE4.2,POPCNT,AES,XSAVE,AVX,NXE,LONG,LAHF
cpu1: 256KB 64b/line 8-way L2 cache
cpu2 at mainbus0: apid 4 (application processor)
cpu2: Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz, 3392.30 MHz
cpu2: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,SBF,SSE3,PCLMUL,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,SSE4.1,SSE4.2,POPCNT,AES,XSAVE,AVX,NXE,LONG,LAHF
cpu2: 256KB 64b/line 8-way L2 cache
cpu3 at mainbus0: apid 6 (application processor)
cpu3: Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz, 3392.30 MHz
cpu3: 
FPU,VME,DE,PSE,TS

Re: Support for UCD-SNMP-MIB in snmpd

2012-07-07 Thread Seth Wright
I'd like to bring this diff up again.  Is there any interest in it at
all?  Anything I need to correct and then resubmit?

Thanks,

--
Seth


On Sun, Jun 24, 2012 at 1:32 AM, Seth Wright  wrote:
> The diff below is the next rev of my earlier UCD-SNMP-MIB diff.  It
> fixes some mistakes in the MIB declaration/naming, implements laConfig
> as a read-write value, and adds the systemState section of the MIB.
> It does not implement the "cooked" 1-minute-average values in
> systemState, just the ss*Raw* values, since the cooked values are all
> marked as being deprecated in the MIB anyway.
>
> I wasn't quite sure of how to implement laConfig's state.  If my
> approach below was wrong, please let me know a better way and I'll fix
> it.
>
>
> Thanks,
> Seth
>
>
>
> Index: mib.c
> ===
> RCS file: /home/seth/code/obsd/cvsync/src/usr.sbin/snmpd/mib.c,v
> retrieving revision 1.55
> diff -u -p -r1.55 mib.c
> --- mib.c   19 Jun 2012 18:43:27 -  1.55
> +++ mib.c   24 Jun 2012 05:25:31 -
> @@ -3364,6 +3364,361 @@ mib_ipfroute(struct oid *oid, struct ber
>  }
>
>  /*
> + * Defined in UCD-SNMP-MIB.txt
> + */
> +
> +intmib_ucdmemory(struct oid *oid, struct ber_oid *o, struct
> ber_element **elm);
> +intmib_ucdloadTable(struct oid *oid, struct ber_oid *o, struct
> ber_element **elm);
> +intmib_setlaconfig(struct oid *oid, struct ber_oid *o, struct
> ber_element **elm);
> +intmib_ucdsystemStats(struct oid *oid, struct ber_oid *o, struct
> ber_element **elm);
> +
> +static struct oid ucdsnmp_mib[] = {
> +   { MIB(ucDavis), OID_MIB },
> +   { MIB(memIndex),OID_RD, mib_ucdmemory },
> +   { MIB(memErrorName),OID_RD, mib_ucdmemory },
> +   { MIB(memTotalSwap),OID_RD, mib_ucdmemory },
> +   { MIB(memAvailSwap),OID_RD, mib_ucdmemory },
> +   { MIB(memTotalReal),OID_RD, mib_ucdmemory },
> +   { MIB(memAvailReal),OID_RD, mib_ucdmemory },
> +   { MIB(memTotalFree),OID_RD, mib_ucdmemory },
> +   { MIB(memMinimumSwap),  OID_RD, mib_ucdmemory },
> +   { MIB(memShared),   OID_RD, mib_ucdmemory },
> +   { MIB(memBuffer),   OID_RD, mib_ucdmemory },
> +   { MIB(memCached),   OID_RD, mib_ucdmemory },
> +   { MIB(memSwapError),OID_RD, mib_ucdmemory },
> +   { MIB(memSwapErrorMsg), OID_RD, mib_ucdmemory },
> +   { MIB(laIndex), OID_TRD, mib_ucdloadTable },
> +   { MIB(laNames), OID_TRD, mib_ucdloadTable },
> +   { MIB(laLoad),  OID_TRD, mib_ucdloadTable },
> +   { MIB(laConfig),OID_TRW, mib_ucdloadTable,
> +   mib_setlaconfig },
> +   { MIB(laLoadInt),   OID_TRD, mib_ucdloadTable },
> +   { MIB(laErrorFlag), OID_TRD, mib_ucdloadTable },
> +   { MIB(laErrMessage),OID_TRD, mib_ucdloadTable },
> +   { MIB(ssIndex), OID_RD, mib_ucdsystemStats },
> +   { MIB(ssErrorName), OID_RD, mib_ucdsystemStats },
> +   { MIB(ssCpuRawUser),OID_RD, mib_ucdsystemStats },
> +   { MIB(ssCpuRawNice),OID_RD, mib_ucdsystemStats },
> +   { MIB(ssCpuRawSystem),  OID_RD, mib_ucdsystemStats },
> +   { MIB(ssCpuRawIdle),OID_RD, mib_ucdsystemStats },
> +   { MIB(ssCpuRawKernel),  OID_RD, mib_ucdsystemStats },
> +   { MIB(ssCpuRawInterrupt),   OID_RD, mib_ucdsystemStats },
> +   { MIB(ssIORawSent), OID_RD, mib_ucdsystemStats },
> +   { MIB(ssIORawReceived), OID_RD, mib_ucdsystemStats },
> +   { MIB(ssRawInterrupts), OID_RD, mib_ucdsystemStats },
> +   { MIB(ssRawContexts),   OID_RD, mib_ucdsystemStats },
> +   { MIB(ssRawSwapIn), OID_RD, mib_ucdsystemStats },
> +   { MIB(ssRawSwapOut),OID_RD, mib_ucdsystemStats },
> +   { MIBEND }
> +};
> +
> +/* Taken from net-snmp */
> +#define DEFAULTMINIMUMSWAP  16000
> +#define ptok(p) ((p) * (uvm.pagesize >> 10))
> +
> +int
> +mib_ucdmemory(struct oid *oid, struct ber_oid *o, struct ber_element **elm)
> +{
> +   struct ber_element  *ber = *elm;
> +   struct bcachestats   bcstats;
>

Fix comment in usr.bin/w/w.c

2012-06-23 Thread Seth Wright
Looks like someone wasn't sure which verb to use, so they went ahead
and used both.



Index: w.c
===
RCS file: /home/seth/code/obsd/cvsync/src/usr.bin/w/w.c,v
retrieving revision 1.50
diff -u -p -r1.50 w.c
--- w.c 28 Jul 2011 10:14:00 -  1.50
+++ w.c 23 Jun 2012 00:55:19 -
@@ -385,7 +385,7 @@ pr_header(time_t *nowp, int nusers)

/*
 * Print how long system has been up.
-* (Found by looking getting "boottime" from the kernel)
+* (Found by getting "boottime" from the kernel)
 */
mib[0] = CTL_KERN;
mib[1] = KERN_BOOTTIME;



Support for UCD-SNMP-MIB in snmpd

2012-06-23 Thread Seth Wright
The diff below is the next rev of my earlier UCD-SNMP-MIB diff.  It
fixes some mistakes in the MIB declaration/naming, implements laConfig
as a read-write value, and adds the systemState section of the MIB.
It does not implement the "cooked" 1-minute-average values in
systemState, just the ss*Raw* values, since the cooked values are all
marked as being deprecated in the MIB anyway.

I wasn't quite sure of how to implement laConfig's state.  If my
approach below was wrong, please let me know a better way and I'll fix
it.


Thanks,
Seth



Index: mib.c
===
RCS file: /home/seth/code/obsd/cvsync/src/usr.sbin/snmpd/mib.c,v
retrieving revision 1.55
diff -u -p -r1.55 mib.c
--- mib.c   19 Jun 2012 18:43:27 -  1.55
+++ mib.c   24 Jun 2012 05:25:31 -
@@ -3364,6 +3364,361 @@ mib_ipfroute(struct oid *oid, struct ber
 }

 /*
+ * Defined in UCD-SNMP-MIB.txt
+ */
+
+intmib_ucdmemory(struct oid *oid, struct ber_oid *o, struct
ber_element **elm);
+intmib_ucdloadTable(struct oid *oid, struct ber_oid *o, struct
ber_element **elm);
+intmib_setlaconfig(struct oid *oid, struct ber_oid *o, struct
ber_element **elm);
+intmib_ucdsystemStats(struct oid *oid, struct ber_oid *o, struct
ber_element **elm);
+
+static struct oid ucdsnmp_mib[] = {
+   { MIB(ucDavis), OID_MIB },
+   { MIB(memIndex),OID_RD, mib_ucdmemory },
+   { MIB(memErrorName),OID_RD, mib_ucdmemory },
+   { MIB(memTotalSwap),OID_RD, mib_ucdmemory },
+   { MIB(memAvailSwap),OID_RD, mib_ucdmemory },
+   { MIB(memTotalReal),OID_RD, mib_ucdmemory },
+   { MIB(memAvailReal),OID_RD, mib_ucdmemory },
+   { MIB(memTotalFree),OID_RD, mib_ucdmemory },
+   { MIB(memMinimumSwap),  OID_RD, mib_ucdmemory },
+   { MIB(memShared),   OID_RD, mib_ucdmemory },
+   { MIB(memBuffer),   OID_RD, mib_ucdmemory },
+   { MIB(memCached),   OID_RD, mib_ucdmemory },
+   { MIB(memSwapError),OID_RD, mib_ucdmemory },
+   { MIB(memSwapErrorMsg), OID_RD, mib_ucdmemory },
+   { MIB(laIndex), OID_TRD, mib_ucdloadTable },
+   { MIB(laNames), OID_TRD, mib_ucdloadTable },
+   { MIB(laLoad),  OID_TRD, mib_ucdloadTable },
+   { MIB(laConfig),OID_TRW, mib_ucdloadTable,
+   mib_setlaconfig },
+   { MIB(laLoadInt),   OID_TRD, mib_ucdloadTable },
+   { MIB(laErrorFlag), OID_TRD, mib_ucdloadTable },
+   { MIB(laErrMessage),OID_TRD, mib_ucdloadTable },
+   { MIB(ssIndex), OID_RD, mib_ucdsystemStats },
+   { MIB(ssErrorName), OID_RD, mib_ucdsystemStats },
+   { MIB(ssCpuRawUser),OID_RD, mib_ucdsystemStats },
+   { MIB(ssCpuRawNice),OID_RD, mib_ucdsystemStats },
+   { MIB(ssCpuRawSystem),  OID_RD, mib_ucdsystemStats },
+   { MIB(ssCpuRawIdle),OID_RD, mib_ucdsystemStats },
+   { MIB(ssCpuRawKernel),  OID_RD, mib_ucdsystemStats },
+   { MIB(ssCpuRawInterrupt),   OID_RD, mib_ucdsystemStats },
+   { MIB(ssIORawSent), OID_RD, mib_ucdsystemStats },
+   { MIB(ssIORawReceived), OID_RD, mib_ucdsystemStats },
+   { MIB(ssRawInterrupts), OID_RD, mib_ucdsystemStats },
+   { MIB(ssRawContexts),   OID_RD, mib_ucdsystemStats },
+   { MIB(ssRawSwapIn), OID_RD, mib_ucdsystemStats },
+   { MIB(ssRawSwapOut),OID_RD, mib_ucdsystemStats },
+   { MIBEND }
+};
+
+/* Taken from net-snmp */
+#define DEFAULTMINIMUMSWAP  16000
+#define ptok(p) ((p) * (uvm.pagesize >> 10))
+
+int
+mib_ucdmemory(struct oid *oid, struct ber_oid *o, struct ber_element **elm)
+{
+   struct ber_element  *ber = *elm;
+   struct bcachestats   bcstats;
+   struct uvmexpuvm;
+   struct vmtotal   vmmeter;
+   u_int64_tphysmem;
+   size_t   len;
+   int  mib[] = { CTL_VM, VM_UVMEXP };
+   int  bcstats_mib[] = { CTL_VFS, VFS_GENERIC, 
VFS_BCACHESTAT };
+   int  size, inuse, total;
+
+   len = sizeof(uvm);
+   if (sysctl(mib, sizeofa(mib), &uvm, &len, NULL, 0) == -1)
+   return (-1);
+
+   mib[1] = VM_METER;
+   len = sizeof(vmmeter);
+   if (sysctl(mib, sizeofa(mib), &vmmeter, &len, NULL, 0) == -1)
+   return (-1);
+
+   mib[0] = CTL_HW;
+

Re: Support for UCD-SNMP-MIB in snmpd (part one)

2012-06-20 Thread Seth Wright
On Tue, Jun 19, 2012 at 5:53 PM, Matthew Dempsky  wrote:
> [+joel]
>
> On Tue, Jun 19, 2012 at 2:11 PM, Seth Wright  wrote:
>> I kind of thought the UCD-SNMP-MIB was fairly standard and/or
>> widespread, but perhaps not?
>
> HOST-RESOURCES-MIB is an RFC standard, which I assume gives it more
> stature than UCD-SNMP-MIB, but I honestly haven't used SNMP much in
> the last few years, so I'm not the best person to make a decision
> here.

So I trekked out to the land of Wikipedia last night.  I didn't
realize that Net-SNMP was actually called UCD-SNMP before being
renamed to what it is now.  I think that explains why I thought the
UCD-SNMP-MIB was so prevalent; any system that runs or implements
Net-SNMP will (should?) implement the UC-Davis MIBs.  And since snmpd
isn't Net-SNMP, I can see how adding UCD-*-MIB to it may not be
wanted.  (I do still think it'd be useful to have, mainly because of
just how widespread Net-SNMP's usage is.)

>> * HR-MIB includes hrProcessorLoad which is a percentage-based value
>> for each CPU (if I'm reading the MIB right) for the one-minute
>> timeframe.  UCD-SNMP presents 1-, 5-, and 15-minute aggregate values,
>> which may be more useful.
>
> I think you're referring to how UCD-SNMP-MIB exposes 1, 5, and 15
> minute load averages, which are different from CPU utilization.  In
> particular, it tends to be a common source of confusion among users
> because OpenBSD calculates load averages very differently than other
> operating systems (e.g.,
>
http://www.undeadly.org/cgi?action=article&sid=20090715034920&mode=expanded).

Yes, you're correct, that was my mistake in trying to rush the email
out.  And yeah, I'm familiar with the many threads about how OpenBSD's
load average numbers are different from other OSes, but I guess what I
was thinking was that even if it is different, the values should still
be useful for trending a particular system.  For instance, if I have
historical data that suggests that a server's 5-minute load average
usually hovers between 0.45 and 1.0, and then I see that server's
numbers jump to 13.5 for a sustained period, then it might be a good
idea to see what's going on.

> You should be able to calculate 5 and 15 minute rolling averages in
> your SNMP monitoring software too.
>
>> * HR-MIB, under the hrStorage* attributes, includes free and used
>> values for memory, but doesn't get any more granular than that.
>> UCD-SNMP tries to break it down a bit further.
>
> That's valid, though I believe we could expose much more fine grained
> memory via HOST-RESOURCES-MIB too.  E.g., buffer cache, kernel pool(9)
> and malloc(9) buckets, and so on.

To be honest, I haven't matched up what's in HOST-RESOURCES-MIB with
what snmpd implements to know how it would compare to UCD-SNMP-MIB.  I
should do that.

> I'm not sure off hand if the memory groups in UCD-SNMP-MIB maps well
> to our VM system either, but I guess they all say they can be left out
> if the OS doesn't support the category.

Other than all the *TXT values, it *seems* to map fairly well, but
then I don't know all I need to know about that (hence the request for
someone who knows memory/uvm to look it over).  For a few of those
attributes I perused Net-SNMP to see how they handled it, and then
figured it out from there.  I think the only one that's really
different from Net-SNMP's Free/NetBSD implementation is memCached;
they don't implement that on NetBSD.  I took a stab that it would be
the same value as what is reported as "Cache:" by top(1).

>> * UCD-SNMP includes a bunch of CPU stats that I'm only starting to
>> look at (the third "blank graph" in my monitoring templates) that I
>> can't find in a walk against base snmpd.  Those were going to be in
>> diff number next.
>
> These might be interesting, and it's data not exposed otherwise
> currently.  The closest HOST-RESOURCES-MIB has is hrSWRunPerfCPU and
> hrSWRunPerfMem, but those don't track interrupt CPU usage.
>
>> So yes, I think it does provide some value over what's already in
>> there, but that's just the opinion of a guy scratching a proverbial
>> itch.
>
> Understood, I'm just trying to make sure the diff makes sense to be
committed.

For what it's worth, that last diff was mangled and won't apply by
copy/paste.  I need to resend it, but before I do I need to fix a few
things--for instance, the renaming I did in the second diff was wrong.
 I'll resend when I get the nitpicks fixed.

Thanks for looking!

Seth



Re: Support for UCD-SNMP-MIB in snmpd (part one)

2012-06-19 Thread Seth Wright
On Tue, Jun 19, 2012 at 4:49 PM, Matthew Dempsky  wrote:
> On Tue, Jun 19, 2012 at 1:35 PM, Vincent Bernat  wrote:
>> Maybe it would be better to implement standard MIB like
>> HOST-RESOURCES-MIB.
>
> snmpd already supports HOST-RESOURCES-MIB.
>
> Seth, does your diff expose any new information that's not already
> available via snmpd?  If not, I think we'd prefer to stick with
> standard MIBs where possible.  I implemented UCD-DISKIO-MIB only
> because I couldn't find any existing MIB that was a good fit for disk
> IO stats.  (Arguably it might go under the interface statistics since
> you can think of SCSI as just a specialized network protocol, but I
> wasn't sure if that would fly and UCD-DISKIO-MIB was less work.)

I kind of thought the UCD-SNMP-MIB was fairly standard and/or
widespread, but perhaps not?  At any rate, it does add some value, I
think.

* HR-MIB includes hrProcessorLoad which is a percentage-based value
for each CPU (if I'm reading the MIB right) for the one-minute
timeframe.  UCD-SNMP presents 1-, 5-, and 15-minute aggregate values,
which may be more useful.

* HR-MIB, under the hrStorage* attributes, includes free and used
values for memory, but doesn't get any more granular than that.
UCD-SNMP tries to break it down a bit further.

* UCD-SNMP includes a bunch of CPU stats that I'm only starting to
look at (the third "blank graph" in my monitoring templates) that I
can't find in a walk against base snmpd.  Those were going to be in
diff number next.

So yes, I think it does provide some value over what's already in
there, but that's just the opinion of a guy scratching a proverbial
itch.



Re: Support for UCD-SNMP-MIB in snmpd (part one)

2012-06-19 Thread Seth Wright
On Tue, Jun 19, 2012 at 4:35 PM, Vincent Bernat  wrote:
>  ❦ 16 juin 2012 22:32 CEST, Seth Wright  :
>
>> Matthew's UCD-DISKIO-MIB patch got me interested in adding support for
>> the UCD-SNMP-MIB in snmpd.
>
> Maybe it would be better to implement standard MIB like
> HOST-RESOURCES-MIB.

A lot of that MIB is already implemented, actually--maybe all?  I
haven't checked.  This was more because the pretty graphs in Zenoss
were blank for my two OpenBSD servers, and rather than change the data
we polled for hundreds of machines (and "lose" all that historical
data by changing graph points), I thought that instead I'd just
implement the bits that we use.

--
Seth



Re: Support for UCD-SNMP-MIB in snmpd (part one)

2012-06-16 Thread Seth Wright
On Sat, Jun 16, 2012 at 4:32 PM, Seth Wright  wrote:
> Matthew's UCD-DISKIO-MIB patch got me interested in adding support for
> the UCD-SNMP-MIB in snmpd.  This is a first pass and only covers the
> mem* objects.  I'd appreciate it if someone who knows more than me
> about the uvm sysctls could check it over; specifically, the
> memShared, memBuffers, and memCached objects.  Net-SNMP doesn't define
> those objects for NetBSD, but I wanted to take a stab and implementing
> them if possible, so I did some research (and yes, a little guesswork)
> and came up with something that seems to work.  (Actually, the
> memShared code came from the net-snmp code for FreeBSD.)
>
> I've got this running on a Zenoss-monitored server right now and the
> stats look right, but I'd appreciate it if other SNMP users could test
> it out, too.
>
> $ snmpwalk -v2c -c[...] it-mirror1 .1.3.6.1.4.1.2021.4
> UCD-SNMP-MIB::memIndex.0 = INTEGER: 0
> UCD-SNMP-MIB::memErrorName.0 = STRING: swap
> UCD-SNMP-MIB::memTotalSwap.0 = INTEGER: 6851384
> UCD-SNMP-MIB::memAvailSwap.0 = INTEGER: 6851384
> UCD-SNMP-MIB::memTotalReal.0 = INTEGER: 20965696
> UCD-SNMP-MIB::memAvailReal.0 = INTEGER: 16962728
> UCD-SNMP-MIB::memTotalFree.0 = INTEGER: 23814112
> UCD-SNMP-MIB::memMinimumSwap.0 = INTEGER: 16000
> UCD-SNMP-MIB::memShared.0 = INTEGER: 0
> UCD-SNMP-MIB::memBuffer.0 = INTEGER: 0
> UCD-SNMP-MIB::memCached.0 = INTEGER: 2593976
> UCD-SNMP-MIB::memSwapError.0 = INTEGER: 0
> UCD-SNMP-MIB::memSwapErrorMsg.0 = STRING:
>
>
> ok?


So, here's an updated diff.  I was a bit shortsighted when it came to
naming some things the first go-round, so I fixed that.  I also
implemented the laLoad table--minus laLoadFloat--for what that's
worth:

$ walk it-mirror1 .1.3.6.1.4.1.2021.10
UCD-SNMP-MIB::laIndex.1 = INTEGER: 1
UCD-SNMP-MIB::laIndex.2 = INTEGER: 2
UCD-SNMP-MIB::laIndex.3 = INTEGER: 3
UCD-SNMP-MIB::laNames.1 = STRING: Load-1
UCD-SNMP-MIB::laNames.2 = STRING: Load-5
UCD-SNMP-MIB::laNames.3 = STRING: Load-15
UCD-SNMP-MIB::laLoad.1 = STRING: 0.68
UCD-SNMP-MIB::laLoad.2 = STRING: 0.59
UCD-SNMP-MIB::laLoad.3 = STRING: 0.51
UCD-SNMP-MIB::laConfig.1 = STRING: 12.00
UCD-SNMP-MIB::laConfig.2 = STRING: 12.00
UCD-SNMP-MIB::laConfig.3 = STRING: 12.00
UCD-SNMP-MIB::laLoadInt.1 = INTEGER: 67
UCD-SNMP-MIB::laLoadInt.2 = INTEGER: 58
UCD-SNMP-MIB::laLoadInt.3 = INTEGER: 50
UCD-SNMP-MIB::laErrorFlag.1 = INTEGER: 0
UCD-SNMP-MIB::laErrorFlag.2 = INTEGER: 0
UCD-SNMP-MIB::laErrorFlag.3 = INTEGER: 0
UCD-SNMP-MIB::laErrMessage.1 = STRING:
UCD-SNMP-MIB::laErrMessage.2 = STRING:
UCD-SNMP-MIB::laErrMessage.3 = STRING:

Thanks for looking / testing / feedback.


Index: mib.c
===
RCS file: /cvs/src/usr.sbin/snmpd/mib.c,v
retrieving revision 1.54
diff -u -p -r1.54 mib.c
--- mib.c   14 Jun 2012 17:31:32 -  1.54
+++ mib.c   17 Jun 2012 03:11:12 -
@@ -3364,6 +3364,212 @@ mib_ipfroute(struct oid *oid, struct ber
}

/*
+ * Defined in UCD-SNMP-MIB.txt
+ */
+
+intmib_ucdmemory(struct oid *oid, struct ber_oid *o, struct
ber_element **elm);
+intmib_ucdloadavg(struct oid *oid, struct ber_oid *o, struct
ber_element **elm);
+
+static struct oid ucdsnmp_mib[] = {
+   { MIB(ucdSNMPMIB),  OID_MIB },
+   { MIB(memIndex),OID_RD, mib_ucdmemory },
+   { MIB(memErrorName),OID_RD, mib_ucdmemory },
+   { MIB(memTotalSwap),OID_RD, mib_ucdmemory },
+   { MIB(memAvailSwap),OID_RD, mib_ucdmemory },
+   { MIB(memTotalReal),OID_RD, mib_ucdmemory },
+   { MIB(memAvailReal),OID_RD, mib_ucdmemory },
+   { MIB(memTotalFree),OID_RD, mib_ucdmemory },
+   { MIB(memMinimumSwap),  OID_RD, mib_ucdmemory },
+   { MIB(memShared),   OID_RD, mib_ucdmemory },
+   { MIB(memBuffer),   OID_RD, mib_ucdmemory },
+   { MIB(memCached),   OID_RD, mib_ucdmemory },
+   { MIB(memSwapError),OID_RD, mib_ucdmemory },
+   { MIB(memSwapErrorMsg), OID_RD, mib_ucdmemory },
+   { MIB(laIndex), OID_TRD, mib_ucdloadavg },
+   { MIB(laNames), OID_TRD, mib_ucdloadavg },
+   { MIB(laLoad),  OID_TRD, mib_ucdloadavg },
+   { MIB(laConfig),OID_TRD, mib_ucdloadavg },
+   { MIB(laLoadInt),   OID_TRD, mib_ucdloadavg },
+   { MIB(laErrorFlag), OID_TRD, mib_ucdloadavg },
+   { MIB(laErrMessage),OID_TRD, mib_ucdloadavg },
+   { MIBEND }
+};
+
+/* Taken from net-snmp */
+#define DEFAULTMINIMUMSWAP  16000
+
+int
+mib_ucdmem

Support for UCD-SNMP-MIB in snmpd (part one)

2012-06-16 Thread Seth Wright
Matthew's UCD-DISKIO-MIB patch got me interested in adding support for
the UCD-SNMP-MIB in snmpd.  This is a first pass and only covers the
mem* objects.  I'd appreciate it if someone who knows more than me
about the uvm sysctls could check it over; specifically, the
memShared, memBuffers, and memCached objects.  Net-SNMP doesn't define
those objects for NetBSD, but I wanted to take a stab and implementing
them if possible, so I did some research (and yes, a little guesswork)
and came up with something that seems to work.  (Actually, the
memShared code came from the net-snmp code for FreeBSD.)

I've got this running on a Zenoss-monitored server right now and the
stats look right, but I'd appreciate it if other SNMP users could test
it out, too.

$ snmpwalk -v2c -c[...] it-mirror1 .1.3.6.1.4.1.2021.4
UCD-SNMP-MIB::memIndex.0 = INTEGER: 0
UCD-SNMP-MIB::memErrorName.0 = STRING: swap
UCD-SNMP-MIB::memTotalSwap.0 = INTEGER: 6851384
UCD-SNMP-MIB::memAvailSwap.0 = INTEGER: 6851384
UCD-SNMP-MIB::memTotalReal.0 = INTEGER: 20965696
UCD-SNMP-MIB::memAvailReal.0 = INTEGER: 16962728
UCD-SNMP-MIB::memTotalFree.0 = INTEGER: 23814112
UCD-SNMP-MIB::memMinimumSwap.0 = INTEGER: 16000
UCD-SNMP-MIB::memShared.0 = INTEGER: 0
UCD-SNMP-MIB::memBuffer.0 = INTEGER: 0
UCD-SNMP-MIB::memCached.0 = INTEGER: 2593976
UCD-SNMP-MIB::memSwapError.0 = INTEGER: 0
UCD-SNMP-MIB::memSwapErrorMsg.0 = STRING:


ok?


Index: mib.c
===
RCS file: /cvs/src/usr.sbin/snmpd/mib.c,v
retrieving revision 1.54
diff -u -p -r1.54 mib.c
--- mib.c   14 Jun 2012 17:31:32 -  1.54
+++ mib.c   16 Jun 2012 19:29:51 -
@@ -3364,6 +3364,131 @@ mib_ipfroute(struct oid *oid, struct ber
}

/*
+ * Defined in UCD-SNMP-MIB.txt
+ */
+
+intmib_ucdmemory(struct oid *oid, struct ber_oid *o, struct
ber_element **elm);
+
+static struct oid ucdmemory_mib[] = {
+   { MIB(ucdMemory),   OID_MIB },
+   { MIB(memIndex),OID_RD, mib_ucdmemory },
+   { MIB(memErrorName),OID_RD, mib_ucdmemory },
+   { MIB(memTotalSwap),OID_RD, mib_ucdmemory },
+   { MIB(memAvailSwap),OID_RD, mib_ucdmemory },
+   { MIB(memTotalReal),OID_RD, mib_ucdmemory },
+   { MIB(memAvailReal),OID_RD, mib_ucdmemory },
+   { MIB(memTotalFree),OID_RD, mib_ucdmemory },
+   { MIB(memMinimumSwap),  OID_RD, mib_ucdmemory },
+   { MIB(memShared),   OID_RD, mib_ucdmemory },
+   { MIB(memBuffer),   OID_RD, mib_ucdmemory },
+   { MIB(memCached),   OID_RD, mib_ucdmemory },
+   { MIB(memSwapError),OID_RD, mib_ucdmemory },
+   { MIB(memSwapErrorMsg), OID_RD, mib_ucdmemory },
+   { MIBEND }
+};
+
+/* Taken from net-snmp */
+#define DEFAULTMINIMUMSWAP  16000
+
+int
+mib_ucdmemory(struct oid *oid, struct ber_oid *o, struct ber_element **elm)
+{
+   struct ber_element  *ber = *elm;
+   struct bcachestats   bcstats;
+   struct uvmexpuvm;
+   struct vmtotal   vmmeter;
+   u_int64_tphysmem;
+   size_t   len;
+   int  mib[] = { CTL_VM, VM_UVMEXP };
+   int  bcstats_mib[] = { CTL_VFS, VFS_GENERIC, 
VFS_BCACHESTAT };
+   int  size, inuse, total;
+
+   len = sizeof(uvm);
+   if (sysctl(mib, sizeofa(mib), &uvm, &len, NULL, 0) == -1)
+   return (-1);
+
+   mib[1] = VM_METER;
+   len = sizeof(vmmeter);
+   if (sysctl(mib, sizeofa(mib), &vmmeter, &len, NULL, 0) == -1)
+   return (-1);
+
+   mib[0] = CTL_HW;
+   mib[1] = HW_PHYSMEM64;
+   len = sizeof(physmem);
+   if (sysctl(mib, sizeofa(mib), &physmem, &len, NULL, 0) == -1)
+   return (-1);
+
+   len = sizeof(bcstats);
+   if (sysctl(bcstats_mib, sizeofa(bcstats_mib), &bcstats, &len, NULL, 0) 
== -1)
+   return (-1);
+
+#define ptok(p) ((p) * (uvm.pagesize >> 10))
+
+   switch (o->bo_id[OIDIDX_ucdMemory]) {
+   case 1: /* memIndex */
+   ber = ber_add_integer(ber, 0);
+   break;
+   case 2: /* memErrorName */
+   ber = ber_add_string(ber, "swap");
+   break;
+   case 3: /* memTotalSwap */
+   size = ptok(uvm.swpages);
+   ber = ber_add_integer(ber, size);
+   break;
+   case 4: /* memAvailSwap */
+   inuse = ptok(uvm.swpginuse);
+   total = ptok(uvm.swpages);
+   ber = ber_add_integer(ber, total - inuse);
+   break;
+   case 5: /* memTotalReal */
+   size = physmem >> 10;
+   ber = ber_add_integer(ber, size);
+   break;
+   case 6: /* memAvail

Re: relayd should verify config before (re)loading

2011-12-01 Thread Seth Wright
My diff only uses printf() in relayctl.c, not in relayd.c, which from
your explanation seems to be correct.  However, if you think it's
worth it I could fix relayctl.c to use the log_* functions instead.

Thanks for the input,

--
Seth



On Thu, Dec 1, 2011 at 2:40 PM, Henning Brauer
 wrote:
> * Seth Wright  [2011-12-01 19:20]:
>> Hm, okay.  I took the printf() lines almost verbatim from bgpctl.c,
>> which seems to use printf() throughout, as does relayctl.c.
>
> *ctl versus *d.
>
> *ctl -> console
> *d -> daemonizes
>
> that said, the log framwork in these daemons and their ctl ustilities
> does the job just fine for logging to the console, too.
>
> --
> Henning Brauer, h...@bsws.de, henn...@openbsd.org
> BS Web Services, http://bsws.de, Full-Service ISP
> Secure Hosting, Mail and DNS Services. Dedicated Servers, Root to Fully
Managed
> Henning Brauer Consulting, http://henningbrauer.com/



Re: relayd should verify config before (re)loading

2011-12-01 Thread Seth Wright
Hm, okay.  I took the printf() lines almost verbatim from bgpctl.c,
which seems to use printf() throughout, as does relayctl.c.  So, I
just sort of followed the convention that was already there.  Should
they be using the log functions instead?  I can fix my diff (and the
other printf()'s in relayctl.c) if that's the case.

Thanks,

--
Seth



On Thu, Dec 1, 2011 at 6:25 AM, Pierre-Yves Ritschard 
wrote:
> do not use printf, use the log functions this code path might (and
> will) happen in places where there's no stdout.
>
>>case LOAD:
>>imsg_compose(ibuf, IMSG_CTL_RELOAD, 0, 0, -1,
>>res->path, strlen(res->path));
>> +   printf("load request sent.\n");
>>done = 1;
>>break;
>>case RELOAD:
>>imsg_compose(ibuf, IMSG_CTL_RELOAD, 0, 0, -1, NULL, 0);
>> +   printf("reload request sent.\n");
>>done = 1;
>>break;
>>case MONITOR:
>> Index: relayd/relayd.c
>> ===
>> RCS file: /cvs/src/usr.sbin/relayd/relayd.c,v
>> retrieving revision 1.104
>> diff -u -p -r1.104 relayd.c
>> --- relayd/relayd.c 4 Sep 2011 20:26:58 -   1.104
>> +++ relayd/relayd.c 10 Nov 2011 16:53:20 -
>> @@ -335,6 +335,12 @@ parent_reload(struct relayd *env, u_int
>>
>>log_debug("%s: level %d config file %s", __func__, reset,
filename);
>>
>> +   if (parse_config(filename, env) == -1) {
>> +   log_warnx("config file %s has errors, not reloading",
>> +   filename);
>> +   return;
>> +   }
>> +
>>config_purge(env, CONFIG_ALL);
>>
>>if (reset == CONFIG_RELOAD) {



relayd should verify config before (re)loading

2011-11-11 Thread Seth Wright
relayd doesn't verify a config file before it tries to load it, unlike many
of the other daemons (for instance, bgpd).  This leads to all of the relays,
etc., being dropped if you forget to manually check the file with 'relayd
-n' before issuing a reload request.  It looks to be a trivial change to
make it act more like bgpd and stop processing if the config file is bad.

A diff is at the end of this mail.  As trivial as it is, this is my
biggest patch submission so far, so if it's not right let me know how I
can improve it.  Thanks!

Seth

Original:
-
# relayctl show summary
Id  TypeNameAvlblty Status
1   relay   test_exchange_http  active
1   table   test_hubs:80empty
1   host134.126.52.201  0.00%   down
2   host134.126.52.202  0.00%   down
2   relay   www_jmu_edu active
2   table   www:80  active (1 hosts)
3   host134.126.10.50   100.00% up
# relayctl load relayd.conf.bad
# relayctl show summary
Id  TypeNameAvlblty Status
-

Original's logging bits:
-
parent_reload: level 0 config file relayd.conf.bad
relayd.conf.bad:25: macro 'local' not defined
relayd.conf.bad:25: syntax error
relayd.conf.bad:32: macro 'local' not defined
relayd.conf.bad:32: syntax error
warning: macro '1local' not used
no actions, nothing to do
unused protocol: www
unused protocol: owa
parent_reload: failed to load config file relayd.conf.bad
-

Modified:
-
# obj/relayctl show summary
Id  TypeNameAvlblty Status
1   relay   test_exchange_http  active
1   table   test_hubs:80active (2 hosts)
1   host134.126.52.201  100.00% up
2   host134.126.52.202  100.00% up
2   relay   www_jmu_edu active
2   table   www:80  active (1 hosts)
3   host134.126.10.50   100.00% up
# obj/relayctl load relayd.conf.bad
load request sent.
# obj/relayctl show summary
Id  TypeNameAvlblty Status
1   relay   test_exchange_http  active
1   table   test_hubs:80active (2 hosts)
1   host134.126.52.201  100.00% up
2   host134.126.52.202  100.00% up
2   relay   www_jmu_edu active
2   table   www:80  active (1 hosts)
3   host134.126.10.50   100.00% up
-

Modified's logging bits:
-
parent_reload: level 0 config file relayd.conf.bad
relayd.conf.bad:25: macro 'local' not defined
relayd.conf.bad:25: syntax error
relayd.conf.bad:32: macro 'local' not defined
relayd.conf.bad:32: syntax error
config file relayd.conf.bad has errors, not reloading
-

Index: relayctl/relayctl.c
===
RCS file: /cvs/src/usr.sbin/relayctl/relayctl.c,v
retrieving revision 1.45
diff -u -p -r1.45 relayctl.c
--- relayctl/relayctl.c 20 May 2011 09:43:53 -  1.45
+++ relayctl/relayctl.c 11 Nov 2011 15:30:14 -
@@ -182,10 +182,12 @@ main(int argc, char *argv[])
case LOAD:
imsg_compose(ibuf, IMSG_CTL_RELOAD, 0, 0, -1,
res->path, strlen(res->path));
+   printf("load request sent.\n");
done = 1;
break;
case RELOAD:
imsg_compose(ibuf, IMSG_CTL_RELOAD, 0, 0, -1, NULL, 0);
+   printf("reload request sent.\n");
done = 1;
break;
case MONITOR:
Index: relayd/relayd.c
===
RCS file: /cvs/src/usr.sbin/relayd/relayd.c,v
retrieving revision 1.104
diff -u -p -r1.104 relayd.c
--- relayd/relayd.c 4 Sep 2011 20:26:58 -   1.104
+++ relayd/relayd.c 10 Nov 2011 16:53:20 -
@@ -335,6 +335,12 @@ parent_reload(struct relayd *env, u_int

log_debug("%s: level %d config file %s", __func__, reset, filename);

+   if (parse_config(filename, env) == -1) {
+   log_warnx("config file %s has errors, not reloading",
+   filename);
+   return;
+   }
+
config_purge(env, CONFIG_ALL);

if (reset

relayd doesn't send User-Agent string for HTTP 1.1 requests

2011-11-10 Thread Seth Wright
I was testing relayd a while back against a couple of IIS 7.5 servers
serving Exchange 2010.  It looks like IIS 7.5 (included with Windows 2008
R2) really wants HTTP 1.1 requests to include the User-Agent header in the
request; leaving it out generates a "400 Bad Request" response.

The HTTP 1.1 spec[1] says of the User-Agent header, "User agents SHOULD
include this field with requests."  Not a MUST, so maybe Microsoft is doing
it wrong by seemingly requiring it.  But since it's a SHOULD, perhaps relayd
should be sending it anyway for HTTP 1.1 requests?  Either way, it's a quick
fix and makes my relay check statements work:

Index: parse.y
===
RCS file: /cvs/src/usr.sbin/relayd/parse.y,v
retrieving revision 1.159
diff -u -p -r1.159 parse.y
--- parse.y 21 Sep 2011 18:45:40 -  1.159
+++ parse.y 10 Nov 2011 16:53:20 -
@@ -228,7 +228,7 @@ hostname: /* empty */   {
fatal("calloc");
}
| HOST STRING   {
-   if (asprintf(&$$, "Host: %s\r\nConnection: close\r\n",
+   if (asprintf(&$$, "Host: %s\r\nUser-Agent: 
relayd\r\nConnection: close\r\n",
$2) == -1)
fatal("asprintf");
}



Is this useful?

[1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43

--
Seth



Re: Using IPv6 subnets in smtpd.conf rules

2010-04-30 Thread Seth Wright
Hah.  No worries; I'm just glad that I wasn't too terribly off-base.
:-)  I can be available for testing if needed.

Thanks!


--seth



On Fri, Apr 30, 2010 at 2:31 AM, Gilles Chehade  wrote:
> Hi Seth,
>
> It is a known issue, I actually had pulled the code for inet_net_pton()
> from NetBSD many months ago, when I first realized inet6 masks were not
> working in smtpd, but then I got sucked into other stuff and forgot it.
>
> I'll review the diff again ... :-)
>
> Thanks,
> Gilles
>
> On Fri, Apr 30, 2010 at 02:13:11AM -0400, Seth Wright wrote:
>> Okay, I'm officially stumped.  Can someone lend me a clue as to what,
>> if anything, I'm doing wrong in the following scenario?
>>
>> I was playing around with smtpd(8) configuration options the other
>> day, and tried to write an "accept" rule in smtpd.conf for an IPv6
>> subnet.  However, when I tried to verify the config I got an error:
>>
>>
>> s...@fw ~ $ grep 2001 /etc/mail/smtpd.conf
>> accept from 2001:470:8:1ee::/64 for all relay
>> s...@fw ~ $ smtpd -n
>> smtpd: inet_net_pton: Address family not supported by protocol family
>>
>>
>> I tracked down that error to /usr/src/usr.sbin/smtpd/parse.y, where in
>> a few places the code is passing AF_INET6 as the address family
>> argument to the function "inet_net_pton()" when it tries to parse the
>> address/subnet string as an IPv6 entity (seems logical to me).
>> However, in looking at /usr/src/lib/libc/net/inet_net_pton.c, that
>> function does not actually accept AF_INET6 as a valid address family:
>>
>>
>> int
>> inet_net_pton(int af, const char *src, void *dst, size_t size)
>> {
>>   switch (af) {
>>   case AF_INET:
>>   return (inet_net_pton_ipv4(src, dst, size));
>>   default:
>>   errno = EAFNOSUPPORT;
>>   return (-1);
>>   }
>> }
>>
>>
>> I looked around a bit and found that NetBSD does have code to handle
>> the AF_INET6 case, so I borrowed their code as a test (I guess it's
>> actually Paul Vixie's BIND code?), recompiled libc, and now 'smtpd -n'
>> says the configuration is OK.  Great...kind of.  I did have to change
>> the 'accept' rule above to add a zero at the end of the string in
>> order for it to pass inspection for whatever reason:
>>
>>
>> s...@bsd ~ $ grep 2001 /etc/mail/smtpd.conf
>> accept from 2001:470:8:1ee::/64 for all relay
>> s...@bsd ~ $ smtpd -n
>> smtpd: inet_net_pton: No such file or directory
>> [...]
>> s...@bsd ~ $ grep 2001 /etc/mail/smtpd.conf
>> accept from 2001:470:8:1ee::0/64 for all relay
>> s...@bsd ~ $ smtpd -n
>> configuration OK
>>
>>
>> Anyway, I started smtpd up again, did a quick test, and...it still failed:
>>
>>
>> s...@darwin ~ $ telnet bsd.crosse.org 25
>> Trying 2001:470:8:1ee:20c:29ff:fe18:1984...
>> Connected to bsd.crosse.org.
>> Escape character is '^]'.
>> 220 bsd.crosse.org ESMTP OpenSMTPD
>> helo darwin.crosse.org
>> 250 bsd.crosse.org Hello darwin.crosse.org
>> [IPv6:2001:470:8:1ee:5ab0:35ff:fe78:c7a0], pleased to meet you
>> mail from:
>> 250 2.1.0 Sender ok
>> rcpt to:
>> 530 5.0.0 Recipient rejected: s...@crosse.org
>> quit
>> 221 2.0.0 bsd.crosse.org Closing connection
>> Connection closed by foreign host.
>>
>>
>> The smtpd debug output for the session looks like this:
>>
>>
>> s...@bsd /usr/src/usr.sbin/smtpd $ sudo smtpd -dv
>> startup [debug mode]
>> parent_send_config: configuring smtp
>> parent_send_config_client_certs: configuring smtp
>> parent_send_config_ruleset: reloading rules and maps
>> parent_enqueue_offline: path /offline/1272603601.j459NrpVLg
>> smtp_setup_events: listen on IPv6:2001:470:8:1ee:20c:29ff:fe18:1984
>> port 25 flags 0x0 cert "vic0"
>> smtp_setup_events: listen on 192.168.2.24 port 25 flags 0x0 cert "vic0"
>> smtp_setup_events: listen on IPv6:fe80:1::20c:29ff:fe18:1984 port 25
>> flags 0x0 cert "vic0"
>> smtp_setup_events: listen on IPv6:fe80:3::1 port 25 flags 0x0 cert "lo0"
>> smtp_setup_events: listen on IPv6:::1 port 25 flags 0x0 cert "lo0"
>> smtp_setup_events: listen on 127.0.0.1 port 25 flags 0x0 cert "lo0"
>> smtp: will accept at most 244 clients
>> offline message enqueued
>> session_pickup: greeting client
>> command: helo   args: darwin.crosse.org
>> command: mail from  args: 
>> session_rfc5321_ma

Using IPv6 subnets in smtpd.conf rules

2010-04-29 Thread Seth Wright
Okay, I'm officially stumped.  Can someone lend me a clue as to what,
if anything, I'm doing wrong in the following scenario?

I was playing around with smtpd(8) configuration options the other
day, and tried to write an "accept" rule in smtpd.conf for an IPv6
subnet.  However, when I tried to verify the config I got an error:


s...@fw ~ $ grep 2001 /etc/mail/smtpd.conf
accept from 2001:470:8:1ee::/64 for all relay
s...@fw ~ $ smtpd -n
smtpd: inet_net_pton: Address family not supported by protocol family


I tracked down that error to /usr/src/usr.sbin/smtpd/parse.y, where in
a few places the code is passing AF_INET6 as the address family
argument to the function "inet_net_pton()" when it tries to parse the
address/subnet string as an IPv6 entity (seems logical to me).
However, in looking at /usr/src/lib/libc/net/inet_net_pton.c, that
function does not actually accept AF_INET6 as a valid address family:


int
inet_net_pton(int af, const char *src, void *dst, size_t size)
{
switch (af) {
case AF_INET:
return (inet_net_pton_ipv4(src, dst, size));
default:
errno = EAFNOSUPPORT;
return (-1);
}
}


I looked around a bit and found that NetBSD does have code to handle
the AF_INET6 case, so I borrowed their code as a test (I guess it's
actually Paul Vixie's BIND code?), recompiled libc, and now 'smtpd -n'
says the configuration is OK.  Great...kind of.  I did have to change
the 'accept' rule above to add a zero at the end of the string in
order for it to pass inspection for whatever reason:


s...@bsd ~ $ grep 2001 /etc/mail/smtpd.conf
accept from 2001:470:8:1ee::/64 for all relay
s...@bsd ~ $ smtpd -n
smtpd: inet_net_pton: No such file or directory
[...]
s...@bsd ~ $ grep 2001 /etc/mail/smtpd.conf
accept from 2001:470:8:1ee::0/64 for all relay
s...@bsd ~ $ smtpd -n
configuration OK


Anyway, I started smtpd up again, did a quick test, and...it still failed:


s...@darwin ~ $ telnet bsd.crosse.org 25
Trying 2001:470:8:1ee:20c:29ff:fe18:1984...
Connected to bsd.crosse.org.
Escape character is '^]'.
220 bsd.crosse.org ESMTP OpenSMTPD
helo darwin.crosse.org
250 bsd.crosse.org Hello darwin.crosse.org
[IPv6:2001:470:8:1ee:5ab0:35ff:fe78:c7a0], pleased to meet you
mail from:
250 2.1.0 Sender ok
rcpt to:
530 5.0.0 Recipient rejected: s...@crosse.org
quit
221 2.0.0 bsd.crosse.org Closing connection
Connection closed by foreign host.


The smtpd debug output for the session looks like this:


s...@bsd /usr/src/usr.sbin/smtpd $ sudo smtpd -dv
startup [debug mode]
parent_send_config: configuring smtp
parent_send_config_client_certs: configuring smtp
parent_send_config_ruleset: reloading rules and maps
parent_enqueue_offline: path /offline/1272603601.j459NrpVLg
smtp_setup_events: listen on IPv6:2001:470:8:1ee:20c:29ff:fe18:1984
port 25 flags 0x0 cert "vic0"
smtp_setup_events: listen on 192.168.2.24 port 25 flags 0x0 cert "vic0"
smtp_setup_events: listen on IPv6:fe80:1::20c:29ff:fe18:1984 port 25
flags 0x0 cert "vic0"
smtp_setup_events: listen on IPv6:fe80:3::1 port 25 flags 0x0 cert "lo0"
smtp_setup_events: listen on IPv6:::1 port 25 flags 0x0 cert "lo0"
smtp_setup_events: listen on 127.0.0.1 port 25 flags 0x0 cert "lo0"
smtp: will accept at most 244 clients
offline message enqueued
session_pickup: greeting client
command: helo   args: darwin.crosse.org
command: mail from  args: 
session_rfc5321_mail_handler: sending notification to mfa
smtp: got imsg_mfa_mail/rcpt
smtp: imsg_queue_create_message returned
command: rcpt toargs: 
smtp: got imsg_mfa_mail/rcpt
1272604479.ozbOZIoTFKlNu1MN: from=,
relay=darwin.crosse.org [IPv6:2001:470:8:1ee:5ab0:35ff:fe78:c7a0],
stat=LocalError (530 5.0.0 Recipient rejected: s...@crosse.org)
command: quit   args: (null)
session_destroy: killing client: 0x86ce1000


>From my admittedly very limited knowledge of using gdb, I think the
problem is in ruleset.c, in a function called
"ruleset_inet6_match()"--however, I've stared at the code now for an
hour or two and still have no idea what I'm looking at.  So, here's
the big question:  did I overlook something completely obvious and
have now gone off the deep end in searching for a bug that's not
there?  Any hints or suggestions are welcome.  I think I can say with
some level of confidence that this code-path will not work as-is since
OpenBSD's inet_net_pton() only accepts AF_INET as the address family
argument.  Adding the extra functions from NetBSD's code helped, but I
don't know enough about this stuff to know whether the four-odd
functions I added are "enough" or if they are really part of a much
larger undertaking.

Thanks for your time,

Seth

(conf, dmesg, and changes to libc follow)

Note:  this was all done with -current at some point or other.  The
dmesg below is from a VMware guest and shows a kernel from the 4/24
snapshot, but I've been playing with this stuff on a couple of
different machines (all either i386 or amd64).  The other one (real,
not v

Re: bug in tmux(1)'s default status-right option?

2010-02-07 Thread Seth Wright
On Sun, Feb 7, 2010 at 4:47 PM, Seth Wright  wrote:
> Hello,
>
> I noticed with tmux(1) that the default string for the "status-right"
> option produces a right-hand status section that looks like this
> (notice the quotes at the beginning):
>
> "" 11:44 07-Feb-10
>
> I'm thinking that the quoted nothingness ("") is not supposed to be
> there (at least, the man page just says "[b]y default, the date and
> time will be shown" and that's it).  If this is a bug, a diff is
> below.
>
> Thanks,
>
> --seth

...and here's the diff with the whitespace not mangled (hopefully):

Index: tmux.c
===
RCS file: /cvs/src/usr.bin/tmux/tmux.c,v
retrieving revision 1.71
diff -u -p -r1.71 tmux.c
--- tmux.c  6 Feb 2010 18:47:41 -   1.71
+++ tmux.c  7 Feb 2010 21:49:27 -
@@ -374,7 +374,7 @@ main(int argc, char **argv)
options_set_number(so, "status-left-bg", 8);
options_set_number(so, "status-left-fg", 8);
options_set_number(so, "status-left-length", 10);
-   options_set_string(so, "status-right", "\"#22T\" %%H:%%M %%d-%%b-%%y");
+   options_set_string(so, "status-right", "#22T %%H:%%M %%d-%%b-%%y");
options_set_number(so, "status-right-attr", 0);
options_set_number(so, "status-right-bg", 8);
options_set_number(so, "status-right-fg", 8);



bug in tmux(1)'s default status-right option?

2010-02-07 Thread Seth Wright
Hello,

I noticed with tmux(1) that the default string for the "status-right"
option produces a right-hand status section that looks like this
(notice the quotes at the beginning):

"" 11:44 07-Feb-10

I'm thinking that the quoted nothingness ("") is not supposed to be
there (at least, the man page just says "[b]y default, the date and
time will be shown" and that's it).  If this is a bug, a diff is
below.

Thanks,

--seth


Index: tmux.c
===
RCS file: /cvs/src/usr.bin/tmux/tmux.c,v
retrieving revision 1.71
diff -u -p -r1.71 tmux.c
--- tmux.c  6 Feb 2010 18:47:41 -   1.71
+++ tmux.c  7 Feb 2010 21:44:22 -
@@ -374,7 +374,7 @@ main(int argc, char **argv)
options_set_number(so, "status-left-bg", 8);
options_set_number(so, "status-left-fg", 8);
options_set_number(so, "status-left-length", 10);
-   options_set_string(so, "status-right", "\"#22T\" %%H:%%M %%d-%%b-%%y");
+   options_set_string(so, "status-right", "#22T %%H:%%M %%d-%%b-%%y");
options_set_number(so, "status-right-attr", 0);
options_set_number(so, "status-right-bg", 8);
options_set_number(so, "status-right-fg", 8);



some small grammatical and readability corrections in faq11

2010-02-06 Thread Seth Wright
Index: faq11.html
===
RCS file: /cvs/www/faq/faq11.html,v
retrieving revision 1.81
diff -u -p -r1.81 faq11.html
--- faq11.html  16 Oct 2009 19:07:37 -  1.81
+++ faq11.html  7 Feb 2010 01:18:54 -
@@ -92,7 +92,7 @@ computer.
 To get responsive display performance on some platforms, even for just
 text, you will want to run X.
 These platforms, such as sparc and
-sparc64 were intended to be used with a
+sparc64, were intended to be used with a
 graphical interface, and the text console performance is very poor.

 
@@ -583,7 +583,7 @@ Here are some tips.

 
 Read the man page for the X server you are using.
-In our example, the /var/log/Xorg.0.log file, we can see X is
+In our example, in the /var/log/Xorg.0.log file we can see that X is
 using TDFX as the driver, so that would be the
 http://www.openbsd.org/cgi-bin/man.cgi?query=tdfx&sektion=4";>tdfx(4)
 man page.
@@ -605,7 +605,7 @@ on almost all video cards, including tho
 X server drivers will work with.

 Use different hardware.
-If you have choice on the video card to use, try some others.
+If you have a choice on the video card to use, try some others.


 
@@ -665,8 +665,8 @@ A large number of window managers are al
 
 Similar to the the system startup script,
 X has a process it goes through to set up the user environment.
-More accurately, it has more than one process; which is used depends on
-how you start X.
+More accurately, it has more than one process; which process is used
+depends on how you start X.
 Understanding how X starts will help you understand how to customize
 your work environment the way you wish it to be.

@@ -693,7 +693,7 @@ X "client" (applications that use X) pro
 When this script exits, the X server shuts down.
 Generally, most of the programs run by this script should run in the
 background, though the last one should run in the foreground (typically
-the window manager), when it exits, the script will exit, and X will be
+the window manager); when it exits, the script will exit, and X will be
 shutdown.

 
@@ -760,7 +760,7 @@ So, if you wish to change your default w
 Again, any programs you want started with X (for example, maybe three
 xterm(1)s) can be placed here, but all should be backgrounded except
 for your window manager, as again, when that exits, your X session
-will be ended.
+will be ended.)
 In this case, xdm(1) will restart X and bring you back to a login
 screen.

@@ -775,7 +775,7 @@ $ startx /usr/local/bin/fluxbox
 Several window managers (including cwm(1) and fvwm(1)) offer the ability
 to change window managers on the fly, without restarting X or any of
 your applications.
-Your new window manager replaces your old one, exiting the newly loaded
+Your new window manager replaces your old one; exiting the newly-loaded
 window manager terminates X, it does not return you back to your
 previous window manager.
 fvwm(1) allows you to start a different window manager by left clicking
@@ -784,7 +784,7 @@ preferred window manager (however, note
 your alternative window managers to your .fvwmrc file (the
 system-wide default is /usr/X11R6/lib/X11/fvwm/.fvwmrc)).
 cwm(1) allows you to invoke another window manager by hitting
-Ctrl-Alt-w, and typing in the manager you wish to switch to.
+Ctrl-Alt-w, and typing in the manager you wish to try.

 
 Once you have found a window manager you like, you can set it as the final



diff for systat(1) man page

2009-11-14 Thread Seth Wright
I noticed a couple of misspellings in the systat(1) man page the other
day, so I went through the rest of the file and found a couple of
other typographical things that needed to be fixed as well.  Thought
I'd send a diff along.

--seth



Index: usr.bin/systat/systat.1
===
RCS file: /cvs/src/usr.bin/systat/systat.1,v
retrieving revision 1.83
diff -u -p -r1.83 systat.1
--- usr.bin/systat/systat.1 14 Aug 2009 17:05:36 -  1.83
+++ usr.bin/systat/systat.1 15 Nov 2009 03:58:38 -
@@ -180,7 +180,7 @@ Reverse the selected ordering if support
 .It Ic ^A \*(Ba Aq Ic Home
 Jump to the beginning of the current view.
 .It Ic ^B \*(Ba Aq Ic right arrow
-Select previous view.
+Select the previous view.
 .It Ic ^E \*(Ba Aq Ic End
 Jump to the end of the current view.
 .It Ic ^F \*(Ba Aq Ic left arrow
@@ -340,11 +340,11 @@ with each shown symbolically, when possi
 .\".El
 .It Ic nfsclient
 Display statistics about NFS client activity.
-Output ressembles
+Output resembles
 .Cm nfsstat Fl c .
 .It Ic nfsserver
 Display statistics about NFS server activity.
-Output ressembles
+Output resembles
 .Cm nfsstat Fl s .
 .It Ic pf
 Display filter information about
@@ -416,7 +416,7 @@ Areas known to the kernel but not in use
 .It Ic vmstat
 Take over the entire display and show a (rather crowded) compendium
 of statistics related to virtual memory usage, process scheduling,
-device interrupts, system name translation caching, disk I/O etc.
+device interrupts, system name translation caching, disk I/O, etc.
 This view is the default.
 .Pp
 The upper left quadrant of the screen shows the number