Re: rt2560 bbp/antenna diff

2012-07-07 Thread Brad Smith
On Sat, Jul 07, 2012 at 04:35:46PM +0200, Stefan Sperling wrote:
> rt2560 is selecting antennas before initialising the baseband
> processor (BBP), however initialising antennas involves tweaking
> of BBP registers.
> 
> The diff below (taken from dragonfly, written by sephe) ensures
> antennas are selected after the BBP has been initialised.
> 
> Part of this diff was committed in r1.26 of rt2560.c and subsequently
> backed out because it caused problems. Apparently the missing piece was
> a busy-wait loop before reading in rt2560_bbp_read(), which has since
> been added to dragonfly:
> 
>commit dd8ea05f8d30bd38ecd334718e4263d8c56ce67a
>Author: Sepherosa Ziehau 
>Date:   Thu Apr 12 12:54:07 2007 +
> 
>When read BBP registers, avoid writing to BBPCSR until it is no longer 
> busy.
>After this bug fixing, TX/RX antenna setup can be safely put after BBP
>initialization, which is a correct place for it, since BBP initialization
>will overwrite RX antenna BBP register with default value.  Before this bug
>fixing, putting TX/RX antenna setup after BBP initailization always results
>in strange TX/RX problems, which I experienced when I fiddled with my ASUS
>WL-107G; and some OpenBSD folks had this problems too, before Damien 
> reverted
>related changes in OpenBSD.
> 
> Tested with an RT2560 cardbus ral which still seems happy.
> 
> Any testers/oks?

I had posted a diff for this and a few other bug fixes here..

http://marc.info/?l=openbsd-tech&m=124139607313719&w=2

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



[patch] wpi(4): add promiscuous mode

2012-07-07 Thread Lazaros Koromilas
Hello all,

I'm resending a diff that enables network cards running with
the wpi driver to enter promiscuous mode.  I have changed
WPI_CMD_ASSOCIATE to WPI_CMD_ASSOCIATED to better designate its
purpose: alter options while in associated state.  I'm running
with this for some time now without problems on a Thinkpad X60s.

Can anyone test?  Comments?

Thanx!
Lazaros.


Index: if_wpi.c
===
RCS file: /cvs/src/sys/dev/pci/if_wpi.c,v
retrieving revision 1.110
diff -u -p -r1.110 if_wpi.c
--- if_wpi.c2 Jun 2011 18:36:53 -   1.110
+++ if_wpi.c7 Jul 2012 18:01:54 -
@@ -120,6 +120,7 @@ int wpi_ioctl(struct ifnet *, u_long, c
 intwpi_cmd(struct wpi_softc *, int, const void *, int, int);
 intwpi_mrr_setup(struct wpi_softc *);
 void   wpi_updateedca(struct ieee80211com *);
+void   wpi_set_promisc(struct wpi_softc *, int);
 void   wpi_set_led(struct wpi_softc *, uint8_t, uint8_t, uint8_t);
 intwpi_set_timing(struct wpi_softc *, struct ieee80211_node *);
 void   wpi_power_calibration(struct wpi_softc *);
@@ -2002,12 +2003,21 @@ wpi_ioctl(struct ifnet *ifp, u_long cmd,
/* FALLTHROUGH */
case SIOCSIFFLAGS:
if (ifp->if_flags & IFF_UP) {
-   if (!(ifp->if_flags & IFF_RUNNING))
+   if (ifp->if_flags & IFF_RUNNING) {
+   if (ifp->if_flags & IFF_PROMISC &&
+   !(sc->sc_if_flags & IFF_PROMISC)) {
+   wpi_set_promisc(sc, 1);
+   } else if (!(ifp->if_flags & IFF_PROMISC) &&
+   sc->sc_if_flags & IFF_PROMISC) {
+   wpi_set_promisc(sc, 0);
+   }
+   } else
error = wpi_init(ifp);
} else {
if (ifp->if_flags & IFF_RUNNING)
wpi_stop(ifp, 1);
}
+   sc->sc_if_flags = ifp->if_flags;
break;
 
case SIOCADDMULTI:
@@ -2206,6 +2216,26 @@ wpi_updateedca(struct ieee80211com *ic)
 }
 
 void
+wpi_set_promisc(struct wpi_softc *sc, int turnon)
+{
+   struct wpi_assoc cmd;
+
+   if (turnon)
+   sc->rxon.filter |= htole32(WPI_FILTER_PROMISC |
+   WPI_FILTER_CTL);
+   else
+   sc->rxon.filter &= ~htole32(WPI_FILTER_PROMISC |
+   WPI_FILTER_CTL);
+
+   memset(&cmd, 0, sizeof cmd);
+   cmd.flags = sc->rxon.flags;
+   cmd.filter = sc->rxon.filter;
+   cmd.ofdm_mask = sc->rxon.ofdm_mask;
+   cmd.cck_mask = sc->rxon.cck_mask;
+   (void)wpi_cmd(sc, WPI_CMD_ASSOCIATED, &cmd, sizeof cmd, 1);
+}
+
+void
 wpi_set_led(struct wpi_softc *sc, uint8_t which, uint8_t off, uint8_t on)
 {
struct wpi_cmd_led led;
@@ -3327,6 +3357,7 @@ wpi_init(struct ifnet *ifp)
 
ifp->if_flags &= ~IFF_OACTIVE;
ifp->if_flags |= IFF_RUNNING;
+   sc->sc_if_flags = ifp->if_flags;
 
if (ic->ic_opmode != IEEE80211_M_MONITOR)
ieee80211_begin_scan(ifp);
Index: if_wpireg.h
===
RCS file: /cvs/src/sys/dev/pci/if_wpireg.h,v
retrieving revision 1.27
diff -u -p -r1.27 if_wpireg.h
--- if_wpireg.h 24 Oct 2009 20:17:17 -  1.27
+++ if_wpireg.h 7 Jul 2012 18:01:54 -
@@ -252,7 +252,7 @@ struct wpi_rx_desc {
 struct wpi_tx_cmd {
uint8_t code;
 #define WPI_CMD_RXON16
-#define WPI_CMD_ASSOCIATE   17
+#define WPI_CMD_ASSOCIATED  17
 #define WPI_CMD_EDCA_PARAMS 19
 #define WPI_CMD_TIMING  20
 #define WPI_CMD_ADD_NODE24
Index: if_wpivar.h
===
RCS file: /cvs/src/sys/dev/pci/if_wpivar.h,v
retrieving revision 1.23
diff -u -p -r1.23 if_wpivar.h
--- if_wpivar.h 7 Sep 2010 16:21:45 -   1.23
+++ if_wpivar.h 7 Jul 2012 18:01:54 -
@@ -144,6 +144,8 @@ struct wpi_softc {
 #define WPI_FLAG_HAS_5GHZ  (1 << 0)
 #define WPI_FLAG_BUSY  (1 << 1)
 
+   int sc_if_flags;
+
/* Shared area. */
struct wpi_dma_info shared_dma;
struct wpi_shared   *shared;



Re: add PCI ID for broadcom BCM43224 chip variant

2012-07-07 Thread Mark Kettenis
> Date: Sat, 7 Jul 2012 23:34:05 +0200
> From: Stefan Sperling 
> 
> My laptop has a chip which the Linux brcm80211 driver calls
> #define BCM43224_D11N_ID_VEN1 0x0576  /* Vendor specific 43224 802.11n db 
> */

The Linux people aren't know for their consistent naming of PCI device
IDs.  So usually not a god place to look for inspiration.

Wonder if this is just a vendor screwup where they programmed the
wrong value in an EEPROM.  Seems to happen all the time :(

> Diff below adds the PCI id. ok?
> 
> pcidump output:
>  1:0:0: Broadcom unknown
>   0x: Vendor ID: 14e4 Product ID: 0576
>   0x0004: Command: 0006 Status ID: 0010
>   0x0008: Class: 02 Subclass: 80 Interface: 00 Revision: 01
>   0x000c: BIST: 00 Header Type: 00 Latency Timer: 00 Cache Line Size: 08
>   0x0010: BAR mem 64bit addr: 0xf020/0x4000
>   0x0018: BAR empty ()
>   0x001c: BAR empty ()
>   0x0020: BAR empty ()
>   0x0024: BAR empty ()
>   0x0028: Cardbus CIS: 
>   0x002c: Subsystem Vendor ID: 14e4 Product ID: 0576
>   0x0030: Expansion ROM Base Address: 
>   0x0038: 
>   0x003c: Interrupt Pin: 01 Line: 0a Min Gnt: 00 Max Lat: 00
>   0x0040: Capability 0x01: Power Management
>   0x0058: Capability 0x09: Vendor Specific
>   0x0048: Capability 0x05: Message Signaled Interrupts (MSI)
>   0x00d0: Capability 0x10: PCI Express
>   Link Speed: 2.5 / 2.5 GT/s Link Width: x1 / x1
> 
> 
> Index: pcidevs
> ===
> RCS file: /cvs/src/sys/dev/pci/pcidevs,v
> retrieving revision 1.1649
> diff -u -p -r1.1649 pcidevs
> --- pcidevs   5 Jul 2012 10:22:08 -   1.1649
> +++ pcidevs   7 Jul 2012 21:25:52 -
> @@ -1652,6 +1652,7 @@ product BROADCOM BCM43220x432b  BCM4322
>  product BROADCOM SERIAL  0x4333  Serial
>  product BROADCOM SERIAL_GC   0x4344  Serial
>  product BROADCOM BCM432240x4353  BCM43224
> +product BROADCOM BCM43224_VEN1   0x0576  BCM43224 
>  product BROADCOM BCM432250x4357  BCM43225
>  product BROADCOM BCM432270x4358  BCM43227
>  product BROADCOM BCM4401 0x4401  BCM4401
> Index: pcidevs.h
> ===
> RCS file: /cvs/src/sys/dev/pci/pcidevs.h,v
> retrieving revision 1.1646
> diff -u -p -r1.1646 pcidevs.h
> --- pcidevs.h 5 Jul 2012 10:23:31 -   1.1646
> +++ pcidevs.h 7 Jul 2012 21:25:53 -
> @@ -1657,6 +1657,7 @@
>  #define  PCI_PRODUCT_BROADCOM_SERIAL 0x4333  /* Serial */
>  #define  PCI_PRODUCT_BROADCOM_SERIAL_GC  0x4344  /* Serial */
>  #define  PCI_PRODUCT_BROADCOM_BCM43224   0x4353  /* BCM43224 */
> +#define  PCI_PRODUCT_BROADCOM_BCM43224_VEN1  0x0576  /* 
> BCM43224 */
>  #define  PCI_PRODUCT_BROADCOM_BCM43225   0x4357  /* BCM43225 */
>  #define  PCI_PRODUCT_BROADCOM_BCM43227   0x4358  /* BCM43227 */
>  #define  PCI_PRODUCT_BROADCOM_BCM44010x4401  /* BCM4401 */
> Index: pcidevs_data.h
> ===
> RCS file: /cvs/src/sys/dev/pci/pcidevs_data.h,v
> retrieving revision 1.1641
> diff -u -p -r1.1641 pcidevs_data.h
> --- pcidevs_data.h5 Jul 2012 10:23:31 -   1.1641
> +++ pcidevs_data.h7 Jul 2012 21:25:53 -
> @@ -4820,6 +4820,10 @@ static const struct pci_known_product pc
>   "BCM43224",
>   },
>   {
> + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM43224_VEN1,
> + "BCM43224",
> + },
> + {
>   PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM43225,
>   "BCM43225",
>   },



Re: add PCI ID for broadcom BCM43224 chip variant

2012-07-07 Thread Martin Pieuchot
On 07/07/12(Sat) 23:34, Stefan Sperling wrote:
> My laptop has a chip which the Linux brcm80211 driver calls
> #define BCM43224_D11N_ID_VEN1 0x0576  /* Vendor specific 43224 802.11n db 
> */
> 
> Diff below adds the PCI id. ok?

Why not simply name it BCM43224_1? Otherwise you should keep the lis
t ordered by ids, then its ok by me.

> 
> pcidump output:
>  1:0:0: Broadcom unknown
>   0x: Vendor ID: 14e4 Product ID: 0576
>   0x0004: Command: 0006 Status ID: 0010
>   0x0008: Class: 02 Subclass: 80 Interface: 00 Revision: 01
>   0x000c: BIST: 00 Header Type: 00 Latency Timer: 00 Cache Line Size: 08
>   0x0010: BAR mem 64bit addr: 0xf020/0x4000
>   0x0018: BAR empty ()
>   0x001c: BAR empty ()
>   0x0020: BAR empty ()
>   0x0024: BAR empty ()
>   0x0028: Cardbus CIS: 
>   0x002c: Subsystem Vendor ID: 14e4 Product ID: 0576
>   0x0030: Expansion ROM Base Address: 
>   0x0038: 
>   0x003c: Interrupt Pin: 01 Line: 0a Min Gnt: 00 Max Lat: 00
>   0x0040: Capability 0x01: Power Management
>   0x0058: Capability 0x09: Vendor Specific
>   0x0048: Capability 0x05: Message Signaled Interrupts (MSI)
>   0x00d0: Capability 0x10: PCI Express
>   Link Speed: 2.5 / 2.5 GT/s Link Width: x1 / x1
> 
> 
> Index: pcidevs
> ===
> RCS file: /cvs/src/sys/dev/pci/pcidevs,v
> retrieving revision 1.1649
> diff -u -p -r1.1649 pcidevs
> --- pcidevs   5 Jul 2012 10:22:08 -   1.1649
> +++ pcidevs   7 Jul 2012 21:25:52 -
> @@ -1652,6 +1652,7 @@ product BROADCOM BCM43220x432b  BCM4322
>  product BROADCOM SERIAL  0x4333  Serial
>  product BROADCOM SERIAL_GC   0x4344  Serial
>  product BROADCOM BCM432240x4353  BCM43224
> +product BROADCOM BCM43224_VEN1   0x0576  BCM43224 
>  product BROADCOM BCM432250x4357  BCM43225
>  product BROADCOM BCM432270x4358  BCM43227
>  product BROADCOM BCM4401 0x4401  BCM4401
> Index: pcidevs.h
> ===
> RCS file: /cvs/src/sys/dev/pci/pcidevs.h,v
> retrieving revision 1.1646
> diff -u -p -r1.1646 pcidevs.h
> --- pcidevs.h 5 Jul 2012 10:23:31 -   1.1646
> +++ pcidevs.h 7 Jul 2012 21:25:53 -
> @@ -1657,6 +1657,7 @@
>  #define  PCI_PRODUCT_BROADCOM_SERIAL 0x4333  /* Serial */
>  #define  PCI_PRODUCT_BROADCOM_SERIAL_GC  0x4344  /* Serial */
>  #define  PCI_PRODUCT_BROADCOM_BCM43224   0x4353  /* BCM43224 */
> +#define  PCI_PRODUCT_BROADCOM_BCM43224_VEN1  0x0576  /* 
> BCM43224 */
>  #define  PCI_PRODUCT_BROADCOM_BCM43225   0x4357  /* BCM43225 */
>  #define  PCI_PRODUCT_BROADCOM_BCM43227   0x4358  /* BCM43227 */
>  #define  PCI_PRODUCT_BROADCOM_BCM44010x4401  /* BCM4401 */
> Index: pcidevs_data.h
> ===
> RCS file: /cvs/src/sys/dev/pci/pcidevs_data.h,v
> retrieving revision 1.1641
> diff -u -p -r1.1641 pcidevs_data.h
> --- pcidevs_data.h5 Jul 2012 10:23:31 -   1.1641
> +++ pcidevs_data.h7 Jul 2012 21:25:53 -
> @@ -4820,6 +4820,10 @@ static const struct pci_known_product pc
>   "BCM43224",
>   },
>   {
> + PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM43224_VEN1,
> + "BCM43224",
> + },
> + {
>   PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM43225,
>   "BCM43225",
>   },



add PCI ID for broadcom BCM43224 chip variant

2012-07-07 Thread Stefan Sperling
My laptop has a chip which the Linux brcm80211 driver calls
#define BCM43224_D11N_ID_VEN1 0x0576  /* Vendor specific 43224 802.11n db */

Diff below adds the PCI id. ok?

pcidump output:
 1:0:0: Broadcom unknown
0x: Vendor ID: 14e4 Product ID: 0576
0x0004: Command: 0006 Status ID: 0010
0x0008: Class: 02 Subclass: 80 Interface: 00 Revision: 01
0x000c: BIST: 00 Header Type: 00 Latency Timer: 00 Cache Line Size: 08
0x0010: BAR mem 64bit addr: 0xf020/0x4000
0x0018: BAR empty ()
0x001c: BAR empty ()
0x0020: BAR empty ()
0x0024: BAR empty ()
0x0028: Cardbus CIS: 
0x002c: Subsystem Vendor ID: 14e4 Product ID: 0576
0x0030: Expansion ROM Base Address: 
0x0038: 
0x003c: Interrupt Pin: 01 Line: 0a Min Gnt: 00 Max Lat: 00
0x0040: Capability 0x01: Power Management
0x0058: Capability 0x09: Vendor Specific
0x0048: Capability 0x05: Message Signaled Interrupts (MSI)
0x00d0: Capability 0x10: PCI Express
Link Speed: 2.5 / 2.5 GT/s Link Width: x1 / x1


Index: pcidevs
===
RCS file: /cvs/src/sys/dev/pci/pcidevs,v
retrieving revision 1.1649
diff -u -p -r1.1649 pcidevs
--- pcidevs 5 Jul 2012 10:22:08 -   1.1649
+++ pcidevs 7 Jul 2012 21:25:52 -
@@ -1652,6 +1652,7 @@ product BROADCOM BCM4322  0x432b  BCM4322
 product BROADCOM SERIAL0x4333  Serial
 product BROADCOM SERIAL_GC 0x4344  Serial
 product BROADCOM BCM43224  0x4353  BCM43224
+product BROADCOM BCM43224_VEN1 0x0576  BCM43224 
 product BROADCOM BCM43225  0x4357  BCM43225
 product BROADCOM BCM43227  0x4358  BCM43227
 product BROADCOM BCM4401   0x4401  BCM4401
Index: pcidevs.h
===
RCS file: /cvs/src/sys/dev/pci/pcidevs.h,v
retrieving revision 1.1646
diff -u -p -r1.1646 pcidevs.h
--- pcidevs.h   5 Jul 2012 10:23:31 -   1.1646
+++ pcidevs.h   7 Jul 2012 21:25:53 -
@@ -1657,6 +1657,7 @@
 #definePCI_PRODUCT_BROADCOM_SERIAL 0x4333  /* Serial */
 #definePCI_PRODUCT_BROADCOM_SERIAL_GC  0x4344  /* Serial */
 #definePCI_PRODUCT_BROADCOM_BCM43224   0x4353  /* BCM43224 */
+#definePCI_PRODUCT_BROADCOM_BCM43224_VEN1  0x0576  /* 
BCM43224 */
 #definePCI_PRODUCT_BROADCOM_BCM43225   0x4357  /* BCM43225 */
 #definePCI_PRODUCT_BROADCOM_BCM43227   0x4358  /* BCM43227 */
 #definePCI_PRODUCT_BROADCOM_BCM44010x4401  /* BCM4401 */
Index: pcidevs_data.h
===
RCS file: /cvs/src/sys/dev/pci/pcidevs_data.h,v
retrieving revision 1.1641
diff -u -p -r1.1641 pcidevs_data.h
--- pcidevs_data.h  5 Jul 2012 10:23:31 -   1.1641
+++ pcidevs_data.h  7 Jul 2012 21:25:53 -
@@ -4820,6 +4820,10 @@ static const struct pci_known_product pc
"BCM43224",
},
{
+   PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM43224_VEN1,
+   "BCM43224",
+   },
+   {
PCI_VENDOR_BROADCOM, PCI_PRODUCT_BROADCOM_BCM43225,
"BCM43225",
},



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;
> +   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_BC

for asus laptop owners

2012-07-07 Thread Paul Irofti
Please test this patch on your machine.

If brightness worked in the passed, does it still work for you now?

Do you see acpiasus(4) attaching in the dmesg?
If not, please paste me the "ASUS? dev foobar" line from your dmesg.

If I get no reports or no regressions with this diff, I'd like to commit
it around the end of next week (or even sooner depending on the feedback
I get).
This fixes an acpivideo(4) panic on boot-up on Asus X52F.

Index: acpi.c
===
RCS file: /cvs/src/sys/dev/acpi/acpi.c,v
retrieving revision 1.233
diff -u -p -r1.233 acpi.c
--- acpi.c  24 May 2012 19:59:22 -  1.233
+++ acpi.c  7 Jul 2012 18:56:13 -
@@ -99,6 +99,7 @@ void  acpi_pbtn_task(void *, int);
 
 intacpi_thinkpad_enabled;
 intacpi_toshiba_enabled;
+intacpi_asus_enabled;
 intacpi_saved_spl;
 intacpi_saved_boothowto;
 intacpi_enabled;
@@ -793,7 +794,8 @@ acpi_attach(struct device *parent, struc
aml_find_node(&aml_root, "GBRT", acpi_foundsony, sc);
 
/* attach video only if this is not a stinkpad or toshiba */
-   if (!acpi_thinkpad_enabled && !acpi_toshiba_enabled)
+   if (!acpi_thinkpad_enabled && !acpi_toshiba_enabled &&
+   !acpi_asus_enabled)
aml_find_node(&aml_root, "_DOS", acpi_foundvideo, sc);
 
/* create list of devices we want to query when APM come in */
@@ -2339,6 +2341,7 @@ acpi_foundhid(struct aml_node *node, voi
aaa.aaa_node = node->parent;
aaa.aaa_dev = dev;
 
+   printf ("ASUS? dev %s\n", dev);
if (!strcmp(dev, ACPI_DEV_AC))
aaa.aaa_name = "acpiac";
else if (!strcmp(dev, ACPI_DEV_CMB))
@@ -2347,9 +2350,10 @@ acpi_foundhid(struct aml_node *node, voi
!strcmp(dev, ACPI_DEV_PBD) ||
!strcmp(dev, ACPI_DEV_SBD))
aaa.aaa_name = "acpibtn";
-   else if (!strcmp(dev, ACPI_DEV_ASUS))
+   else if (!strcmp(dev, ACPI_DEV_ASUS) || !strcmp(dev, ACPI_DEV_ASUS1)) {
aaa.aaa_name = "acpiasus";
-   else if (!strcmp(dev, ACPI_DEV_IBM) ||
+   acpi_asus_enabled = 1;
+   } else if (!strcmp(dev, ACPI_DEV_IBM) ||
!strcmp(dev, ACPI_DEV_LENOVO)) {
aaa.aaa_name = "acpithinkpad";
acpi_thinkpad_enabled = 1;
Index: acpireg.h
===
RCS file: /cvs/src/sys/dev/acpi/acpireg.h,v
retrieving revision 1.27
diff -u -p -r1.27 acpireg.h
--- acpireg.h   7 Jan 2012 20:13:17 -   1.27
+++ acpireg.h   7 Jul 2012 18:56:14 -
@@ -735,6 +735,7 @@ struct acpi_ivrs {
 #define ACPI_DEV_THZ   "THERMALZONE"   /* Thermal Zone */
 #define ACPI_DEV_FFB   "FIXEDBUTTON"   /* Fixed Feature Button */
 #define ACPI_DEV_ASUS  "ASUS010"   /* ASUS Hotkeys */
+#define ACPI_DEV_ASUS1 "ATK0100"   /* ASUS Special Device */
 #define ACPI_DEV_IBM   "IBM0068"   /* IBM ThinkPad support */
 #define ACPI_DEV_LENOVO"LEN0068"   /* Lenovo ThinkPad support */
 #define ACPI_DEV_ASUSAIBOOSTER "ATK0110"   /* ASUSTeK AI Booster */



Re: [s...@cd80.net: Re: rtadvd(8) patch 2/2 : finalize server-side RFC 6106 support]

2012-07-07 Thread Lawrence Teo
On Sat, Jul 07, 2012 at 03:17:30PM +0200, Matthieu Herrb wrote:
> On Sat, Jul 07, 2012 at 12:47:32PM +0200, Peter Hessler wrote:
> > ressurecting an old patch.
> > 
> > OK from me, anyone else?
> 
> With my sysadmin-deplying-IPv6-at-my-dayjob hat, I'd love to see that
> go in, but I can't test it before next week. 
> 
> I only had a quick glance at the code (never looked at rtadvd source
> code before), didn't spot anything dubious...

I can't test the diff, but noticed this while looking through it:

> > +   while ((tmpsl = strsep(&addr, ","))) {
> > +   struct dnssldom *dnsd;
> > +   ssize_t len;
> > +
> > +   len = strlen(tmpsl);

Should len be declared size_t instead of ssize_t?



set { tos ..., prio ... }

2012-07-07 Thread Henning Brauer
so, we have some utter confusion in pf about filter criteria versus
packet modifying options. I propose we move the ones that "write" into
a set block, while the filter criteria remain as they are. for the
moment this diff handles tos (I always disliked set-tos...) and prio.
rdomain/rtable stuff should be done the same way (afterwards).
no backwards compat for prio because i clearly stated it's not the
final syntax all the time.

no manpage bits yet.

"match set { prio 6, tos lowdelay }"
"match set prio 6"

Index: sbin/pfctl/parse.y
===
RCS file: /cvs/src/sbin/pfctl/parse.y,v
retrieving revision 1.614
diff -u -p -r1.614 parse.y
--- sbin/pfctl/parse.y  7 Jul 2012 16:24:32 -   1.614
+++ sbin/pfctl/parse.y  7 Jul 2012 17:09:19 -
@@ -508,6 +508,7 @@ int parseport(char *, struct range *r, i
 %type hfscopts_list hfscopts_item hfsc_opts
 %type  bandwidth
 %type   filter_opts filter_opt filter_opts_l
+%type   filter_sets filter_set filter_sets_l
 %typeantispoof_opts antispoof_opt antispoof_opts_l
 %typequeue_opts queue_opt queue_opts_l
 %typescrub_opts scrub_opt scrub_opts_l
@@ -979,7 +980,7 @@ scrub_opt   : NODF  {
scrub_opts.marker |= FOM_MAXMSS;
scrub_opts.maxmss = $2;
}
-   | SETTOS tos {
+   | SETTOS tos {  /* XXX remove in 5.4-current */
if (scrub_opts.marker & FOM_SETTOS) {
yyerror("set-tos cannot be respecified");
YYERROR;
@@ -2379,7 +2380,21 @@ filter_opt   : USER uids {
}
filter_opts.rcv = $2;
}
-   | prio {
+   | ONCE {
+   filter_opts.marker |= FOM_ONCE;
+   }
+   | filter_sets
+   ;
+
+filter_sets: SET '{' filter_sets_l '}' { $$ = filter_opts; }
+   | SET filter_set{ $$ = filter_opts; }
+   ;
+
+filter_sets_l  : filter_sets_l comma filter_set
+   | filter_set
+   ;
+
+filter_set : prio {
if (filter_opts.marker & FOM_SETPRIO) {
yyerror("prio cannot be redefined");
YYERROR;
@@ -2388,8 +2403,13 @@ filter_opt   : USER uids {
filter_opts.set_prio[0] = $1.b1;
filter_opts.set_prio[1] = $1.b2;
}
-   | ONCE {
-   filter_opts.marker |= FOM_ONCE;
+   | TOS tos {
+   if (filter_opts.marker & FOM_SETTOS) {
+   yyerror("tos cannot be respecified");
+   YYERROR;
+   }
+   filter_opts.marker |= FOM_SETTOS;
+   filter_opts.settos = $2;
}
;
 
Index: sbin/pfctl/pfctl_parser.c
===
RCS file: /cvs/src/sbin/pfctl/pfctl_parser.c,v
retrieving revision 1.285
diff -u -p -r1.285 pfctl_parser.c
--- sbin/pfctl/pfctl_parser.c   7 Jul 2012 16:24:32 -   1.285
+++ sbin/pfctl/pfctl_parser.c   7 Jul 2012 17:08:31 -
@@ -843,6 +843,25 @@ print_rule(struct pf_rule *r, const char
if (r->tos)
printf(" tos 0x%2.2x", r->tos);
 
+   if (r->set_prio[0] != PF_PRIO_NOTSET ||
+   r->scrub_flags & PFSTATE_SETTOS) {
+   char *comma = "";
+   printf(" set {");
+   if (r->set_prio[0] != PF_PRIO_NOTSET) {
+   if (r->set_prio[0] == r->set_prio[1])
+   printf("%s prio %u", comma, r->set_prio[0]);
+   else
+   printf("%s prio(%u, %u)", comma, r->set_prio[0],
+   r->set_prio[1]);
+   comma = ",";
+   }
+   if (r->scrub_flags & PFSTATE_SETTOS) {
+   printf("%s tos 0x%2.2x", comma, r->set_tos);
+   comma = ",";
+   }
+   printf(" }");
+   }
+
ropts = 0;
if (r->max_states || r->max_src_nodes || r->max_src_states)
ropts = 1;
@@ -998,12 +1017,6 @@ print_rule(struct pf_rule *r, const char
printf("min-ttl %d", r->min_ttl);
ropts = 0;
}
-   if (r->scrub_flags & PFSTATE_SETTOS) {
-   if (!ropts)
-   printf(" ");
-   printf("set-tos 0x%2.2x", r->set_tos);
-   ropts = 0;
-   }
if (r->scrub_flags & PFSTATE_SCRUB_TCP) {
if (!ropts)

kill incorrect check in pfctl

2012-07-07 Thread Henning Brauer
kernel side actually handles set-tos for IPvShit - see pf_scrub() in
pf_norm.c 

ok?

Index: sbin/pfctl/parse.y
===
RCS file: /cvs/src/sbin/pfctl/parse.y,v
retrieving revision 1.614
diff -u -p -r1.614 parse.y
--- sbin/pfctl/parse.y  7 Jul 2012 16:24:32 -   1.614
+++ sbin/pfctl/parse.y  7 Jul 2012 17:09:19 -
@@ -4172,9 +4192,9 @@ rule_consistent(struct pf_rule *r, int a
problems++;
}
if (r->af == AF_INET6 && (r->scrub_flags &
-   (PFSTATE_NODF|PFSTATE_RANDOMID|PFSTATE_SETTOS))) {
+   (PFSTATE_NODF|PFSTATE_RANDOMID))) {
yyerror("address family inet6 does not support scrub options "
-   "no-df, random-id, set-tos");
+   "no-df, random-id");
problems++;
}



let usr.sbin/httpd build with SSLv2 disabled

2012-07-07 Thread Stuart Henderson
ok?

Index: src/modules/ssl/ssl_engine_init.c
===
RCS file: /cvs/src/usr.sbin/httpd/src/modules/ssl/ssl_engine_init.c,v
retrieving revision 1.27
diff -u -p -r1.27 ssl_engine_init.c
--- src/modules/ssl/ssl_engine_init.c   9 Feb 2005 12:13:10 -   1.27
+++ src/modules/ssl/ssl_engine_init.c   7 Jul 2012 16:26:58 -
@@ -581,10 +581,7 @@ void ssl_init_ConfigureServer(server_rec
 cp[strlen(cp)-2] = NUL;
 ssl_log(s, SSL_LOG_TRACE,
 "Init: (%s) Creating new SSL context (protocols: %s)", cpVHostID, 
cp);
-if (sc->nProtocol == SSL_PROTOCOL_SSLV2)
-ctx = SSL_CTX_new(SSLv2_server_method());  /* only SSLv2 is left */
-else
-ctx = SSL_CTX_new(SSLv23_server_method()); /* be more flexible */
+ctx = SSL_CTX_new(SSLv23_server_method());
 SSL_CTX_set_options(ctx, SSL_OP_ALL);
 if (!(sc->nProtocol & SSL_PROTOCOL_SSLV2))
 SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2);



Re: mtree(8): add sha256digest support

2012-07-07 Thread Ingo Schwarze
Ingo Schwarze wrote on Sat, Jul 07, 2012 at 05:22:05PM +0200:
> Christian Weisgerber wrote on Sat, Jul 07, 2012 at 03:40:00PM +0200:

>> This adds support for the "sha256digest" keyword to create/compare
>> SHA2-256 digests of files.  In the man page, also replace SHA-1
>> with SHA2-256 in the examples section.

> Looks reasonable to me and survived light testing on i386.

Naddy just pointed out that security(8) and changelist(5)
need love as well.

While here, replace the stupid example.  Sure, Bob was slacking
now and then, but not to the point that tripwiring up his home
directory would have been useful...


Index: man8/security.8
===
RCS file: /cvs/src/share/man/man8/security.8,v
retrieving revision 1.20
diff -u -r1.20 security.8
--- man8/security.8 19 Apr 2011 05:17:24 -  1.20
+++ man8/security.8 7 Jul 2012 15:47:19 -
@@ -79,12 +79,12 @@
 and filenames must have the suffix
 .Dq .secure .
 The following example shows how to create such a list,
-to protect the home directory of user
-.Dq bob :
+to protect the programs in
+.Pa /bin :
 .Bd -literal -offset 4n
-# mtree -cx -p /home/bob -K md5digest,type \*(Gt/etc/mtree/bob.secure
-# chown root:wheel /etc/mtree/bob.secure
-# chmod 600 /etc/mtree/bob.secure
+# mtree -cx -p /bin -K sha256digest,type > /etc/mtree/bin.secure
+# chown root:wheel /etc/mtree/bin.secure
+# chmod 600 /etc/mtree/bin.secure
 .Ed
 .Pp
 .Sy Note:
Index: man5/changelist.5
===
RCS file: /cvs/src/share/man/man5/changelist.5,v
retrieving revision 1.7
diff -u -r1.7 changelist.5
--- man5/changelist.5   18 Apr 2011 23:58:45 -  1.7
+++ man5/changelist.5   7 Jul 2012 15:47:19 -
@@ -85,12 +85,12 @@
 character
 .Pq generally non-text files
 are stored as
-.Xr md5 1
+.Xr sha256 1
 checksums.
 Results are mailed in the following format:
 .Bd -unfilled -offset indent
 ==
-/etc/ssh/ssh_host_key MD5 checksums
+/etc/ssh/ssh_host_key SHA-256 checksums
 ==
 OLD:
 NEW:
@@ -113,7 +113,7 @@
 .El
 .Sh SEE ALSO
 .Xr diff 1 ,
-.Xr md5 1 ,
+.Xr sha256 1 ,
 .Xr daily 8 ,
 .Xr security 8
 .Sh HISTORY



Re: mtree(8): add sha256digest support

2012-07-07 Thread Ingo Schwarze
Hi Naddy,

Christian Weisgerber wrote on Sat, Jul 07, 2012 at 03:40:00PM +0200:

> This adds support for the "sha256digest" keyword to create/compare
> SHA2-256 digests of files.  In the man page, also replace SHA-1
> with SHA2-256 in the examples section.

Looks reasonable to me and survived light testing on i386.

The following slightly improves the formatting:

Index: mtree.8
===
RCS file: /cvs/src/usr.sbin/mtree/mtree.8,v
retrieving revision 1.35
diff -u -r1.35 mtree.8
--- mtree.8 3 Sep 2010 11:22:36 -   1.35
+++ mtree.8 7 Jul 2012 15:19:00 -
@@ -156,7 +156,7 @@
 checks based on it are performed.
 .Pp
 Currently supported keywords are as follows:
-.Bl -tag -width Cm
+.Bl -tag -width sha256digest
 .It Cm cksum
 The checksum of the file using the default algorithm specified by
 the

Here is a security(8) diff to go with it:

Index: security
===
RCS file: /cvs/src/libexec/security/security,v
retrieving revision 1.18
diff -u -p -r1.18 security
--- security17 May 2012 16:06:03 -  1.18
+++ security7 Jul 2012 15:09:58 -
@@ -2,7 +2,7 @@
 
 # $OpenBSD: security,v 1.18 2012/05/17 16:06:03 pascal Exp $
 #
-# Copyright (c) 2011 Ingo Schwarze 
+# Copyright (c) 2011, 2012 Ingo Schwarze 
 # Copyright (c) 2011 Andrew Fresh 
 #
 # Permission to use, copy, modify, and distribute this software for any
@@ -20,7 +20,7 @@
 use warnings;
 use strict;
 
-require Digest::MD5;
+use Digest::SHA qw(sha256_hex);
 use Errno qw(ENOENT);
 use Fcntl qw(:mode);
 use File::Basename qw(basename);
@@ -689,7 +689,7 @@ sub check_disks {
 #
 # Create the mtree tree specifications using:
 #
-#   mtree -cx -p DIR -K md5digest,type >/etc/mtree/DIR.secure
+#   mtree -cx -p DIR -K sha256digest,type > /etc/mtree/DIR.secure
 #   chown root:wheel /etc/mtree/DIR.secure
 #   chmod 600 /etc/mtree/DIR.secure
 #
@@ -764,56 +764,57 @@ sub backup_if_changed {
}
 }
 
-sub backup_md5 {
+sub backup_digest {
my ($orig) = @_;
 
my ($backup) = $orig =~ m{^/?(.*)};
$backup =~ s{/}{_}g;
-   my $current = BACKUP_DIR . "$backup.current.md5";
-   $backup = BACKUP_DIR . "$backup.backup.md5";
+   my $current = BACKUP_DIR . "$backup.current.sha256";
+   $backup = BACKUP_DIR . "$backup.backup.sha256";
 
-   my $md5_new = 0;
+   my $digest_new = 0;
if (-s $orig) {
if (open my $fh, '<', $orig) {
binmode $fh;
-   $md5_new = Digest::MD5->new->addfile($fh)->hexdigest;
+   local $/;
+   $digest_new = sha256_hex(<$fh>);
close $fh;
} else { nag 1, "open: $orig: $!"; }
}
 
-   my $md5_old = 0;
+   my $digest_old = 0;
if (-s $current) {
if (open my $fh, '<', $current) {
-   $md5_old = <$fh>;
+   $digest_old = <$fh>;
close $fh;
-   chomp $md5_old;
+   chomp $digest_old;
} else { nag 1, "open: $current: $!"; }
}
 
-   return if $md5_old eq $md5_new;
+   return if $digest_old eq $digest_new;
 
-   if ($md5_old && $md5_new) {
+   if ($digest_old && $digest_new) {
copy $current, $backup;
chown 0, 0, $backup;
chmod 0600, $backup;
-   } elsif ($md5_old) {
-   $check_title = "==\n$orig removed MD5 checksum\n==";
+   } elsif ($digest_old) {
+   $check_title = "==\n$orig removed SHA-256 checksum\n==";
unlink $current;
-   } elsif ($md5_new) {
-   $check_title = "==\n$orig new MD5 checksum\n==";
+   } elsif ($digest_new) {
+   $check_title = "==\n$orig new SHA-256 checksum\n==";
}
 
-   if ($md5_new) {
+   if ($digest_new) {
if (open my $fh, '>', $current) {
-   print $fh "$md5_new\n";
+   print $fh "$digest_new\n";
close $fh;
} else { nag 1, "open: $current: $!\n"; }
chown 0, 0, $current;
chmod 0600, $current;
}
 
-   nag $md5_old, "OLD: $md5_old";
-   nag $md5_new, "NEW: $md5_new";
+   nag $digest_old, "OLD: $digest_old";
+   nag $digest_new, "NEW: $digest_new";
 }
 
 # List of files that get backed up and checked for any modifications.  Each
@@ -842,8 +843,8 @@ sub check_changelist {
 
if ($plus) {
$check_title =
-   "==\n$_ MD5 checksums\n==";
-   backup_md5 $_;
+   "==\n$_ SHA-256 checksums\n==";
+   backup_digest $

Re: mtree(8): add sha256digest support

2012-07-07 Thread Christian Weisgerber
Christian Weisgerber  wrote:

> --- mtree.8   3 Sep 2010 11:22:36 -   1.35
> +++ mtree.8   7 Jul 2012 13:31:09 -

> +The SHA2-256 message digest of the file.

> +the same SHA2-256 digest as the original.

Actually, NIST usage is "SHA-256" so we should write that and also
fix the sha256.1 page.

-- 
Christian "naddy" Weisgerber  na...@mips.inka.de



rt2560 bbp/antenna diff

2012-07-07 Thread Stefan Sperling
rt2560 is selecting antennas before initialising the baseband
processor (BBP), however initialising antennas involves tweaking
of BBP registers.

The diff below (taken from dragonfly, written by sephe) ensures
antennas are selected after the BBP has been initialised.

Part of this diff was committed in r1.26 of rt2560.c and subsequently
backed out because it caused problems. Apparently the missing piece was
a busy-wait loop before reading in rt2560_bbp_read(), which has since
been added to dragonfly:

   commit dd8ea05f8d30bd38ecd334718e4263d8c56ce67a
   Author: Sepherosa Ziehau 
   Date:   Thu Apr 12 12:54:07 2007 +

   When read BBP registers, avoid writing to BBPCSR until it is no longer busy.
   After this bug fixing, TX/RX antenna setup can be safely put after BBP
   initialization, which is a correct place for it, since BBP initialization
   will overwrite RX antenna BBP register with default value.  Before this bug
   fixing, putting TX/RX antenna setup after BBP initailization always results
   in strange TX/RX problems, which I experienced when I fiddled with my ASUS
   WL-107G; and some OpenBSD folks had this problems too, before Damien reverted
   related changes in OpenBSD.

Tested with an RT2560 cardbus ral which still seems happy.

Any testers/oks?

Index: rt2560.c
===
RCS file: /cvs/src/sys/dev/ic/rt2560.c,v
retrieving revision 1.58
diff -u -p -r1.58 rt2560.c
--- rt2560.c22 Feb 2011 20:05:03 -  1.58
+++ rt2560.c7 Jul 2012 14:23:42 -
@@ -2102,6 +2102,16 @@ rt2560_bbp_read(struct rt2560_softc *sc,
uint32_t val;
int ntries;
 
+   for (ntries = 0; ntries < 100; ntries++) {
+   if (!(RAL_READ(sc, RT2560_BBPCSR) & RT2560_BBP_BUSY))
+   break;
+   DELAY(1);
+   }
+   if (ntries == 100) {
+   printf("%s: could not read from BBP\n", sc->sc_dev.dv_xname);
+   return 0;
+   }
+
val = RT2560_BBP_BUSY | reg << 8;
RAL_WRITE(sc, RT2560_BBPCSR, val);
 
@@ -2626,8 +2636,6 @@ rt2560_init(struct ifnet *ifp)
/* set basic rate set (will be updated later) */
RAL_WRITE(sc, RT2560_ARSP_PLCP_1, 0x153);
 
-   rt2560_set_txantenna(sc, 1);
-   rt2560_set_rxantenna(sc, 1);
rt2560_set_slottime(sc);
rt2560_update_plcp(sc);
rt2560_update_led(sc, 0, 0);
@@ -2639,6 +2647,9 @@ rt2560_init(struct ifnet *ifp)
rt2560_stop(ifp, 1);
return EIO;
}
+
+   rt2560_set_txantenna(sc, 1);
+   rt2560_set_rxantenna(sc, 1);
 
/* set default BSS channel */
ic->ic_bss->ni_chan = ic->ic_ibss_chan;



Re: nc -ul semantics

2012-07-07 Thread Nicholas Marriott
was going to say the same, with either of these, ok nicm


On Sat, Jul 07, 2012 at 04:33:45PM +0300, Lazaros Koromilas wrote:
> On Sat, Jul 07, 2012 at 07:34:28AM -0300, Christiano F. Haesbaert wrote:
> > How about this one ?
> > It's your original idea, but I don't like that extra indentation level,
> > we are already too deep.
> 
> Yes, less identation is always good!  The "multiple hosts" part
> in the manpage could become one of the following, but it's clear
> enough already.
> 
> "[...] and it can receive UDP datagrams from multiple hosts."
> "[...] and it receives all UDP datagrams arriving at the port."
> 
> > 
> > 
> > Index: nc.1
> > ===
> > RCS file: /cvs/src/usr.bin/nc/nc.1,v
> > retrieving revision 1.60
> > diff -d -u -p -r1.60 nc.1
> > --- nc.17 Feb 2012 12:11:43 -   1.60
> > +++ nc.17 Jul 2012 10:30:10 -
> > @@ -119,6 +119,10 @@ is completed.
> >  It is an error to use this option without the
> >  .Fl l
> >  option.
> > +When used together with the
> > +.Fl u
> > +option, the server socket is not connected and it receives UDP datagrams 
> > from
> > +multiple hosts.
> >  .It Fl l
> >  Used to specify that
> >  .Nm
> > Index: netcat.c
> > ===
> > RCS file: /cvs/src/usr.bin/nc/netcat.c,v
> > retrieving revision 1.108
> > diff -d -u -p -r1.108 netcat.c
> > --- netcat.c7 Jul 2012 09:36:30 -   1.108
> > +++ netcat.c7 Jul 2012 10:30:11 -
> > @@ -345,11 +345,17 @@ main(int argc, char *argv[])
> > if (s < 0)
> > err(1, NULL);
> > /*
> > -* For UDP, we will use recvfrom() initially
> > -* to wait for a caller, then use the regular
> > -* functions to talk to the caller.
> > +* For UDP and -k, don't connect the socket, let it
> > +* receive datagrams from multiple socket pairs.
> >  */
> > -   if (uflag) {
> > +   if (uflag && kflag)
> > +   readwrite(s);
> > +   /*
> > +* For UDP and not -k, we will use recvfrom() initially
> > +* to wait for a caller, then use the regular functions
> > +* to talk to the caller.
> > +*/
> > +   else if (uflag && !kflag) {
> > int rv, plen;
> > char buf[16384];
> > struct sockaddr_storage z;



mtree(8): add sha256digest support

2012-07-07 Thread Christian Weisgerber
This adds support for the "sha256digest" keyword to create/compare
SHA2-256 digests of files.  In the man page, also replace SHA-1
with SHA2-256 in the examples section.

ok?

Index: compare.c
===
RCS file: /cvs/src/usr.sbin/mtree/compare.c,v
retrieving revision 1.22
diff -u -p -r1.22 compare.c
--- compare.c   27 Oct 2009 23:59:53 -  1.22
+++ compare.c   7 Jul 2012 12:44:46 -
@@ -39,8 +39,9 @@
 #include 
 #include 
 #include 
-#include 
 #include 
+#include 
+#include 
 #include "mtree.h"
 #include "extern.h"
 
@@ -283,6 +284,22 @@ typeerr:   LABEL;
} else if (strcmp(new_digest, s->sha1digest)) {
LABEL;
printf("%sSHA1 (%s, %s)\n", tab, s->sha1digest,
+  new_digest);
+   tab = "\t";
+   }
+   }
+   if (s->flags & F_SHA256) {
+   char *new_digest, buf[SHA256_DIGEST_STRING_LENGTH];
+
+   new_digest = SHA256File(p->fts_accpath, buf);
+   if (!new_digest) {
+   LABEL;
+   printf("%sSHA256File: %s: %s\n", tab, p->fts_accpath,
+  strerror(errno));
+   tab = "\t";
+   } else if (strcmp(new_digest, s->sha256digest)) {
+   LABEL;
+   printf("%sSHA256 (%s, %s)\n", tab, s->sha256digest,
   new_digest);
tab = "\t";
}
Index: create.c
===
RCS file: /cvs/src/usr.sbin/mtree/create.c,v
retrieving revision 1.26
diff -u -p -r1.26 create.c
--- create.c27 Oct 2009 23:59:53 -  1.26
+++ create.c7 Jul 2012 12:47:05 -
@@ -44,8 +44,9 @@
 #include 
 #include 
 #include 
-#include 
 #include 
+#include 
+#include 
 #include "mtree.h"
 #include "extern.h"
 
@@ -222,6 +223,15 @@ statf(int indent, FTSENT *p)
error("%s: %s", p->fts_accpath, strerror(errno));
else
output(indent, &offset, "sha1digest=%s", sha1digest);
+   }
+   if (keys & F_SHA256 && S_ISREG(p->fts_statp->st_mode)) {
+   char *sha256digest, buf[SHA256_DIGEST_STRING_LENGTH];
+
+   sha256digest = SHA256File(p->fts_accpath,buf);
+   if (!sha256digest)
+   error("%s: %s", p->fts_accpath, strerror(errno));
+   else
+   output(indent, &offset, "sha256digest=%s", 
sha256digest);
}
if (keys & F_SLINK &&
(p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) {
Index: misc.c
===
RCS file: /cvs/src/usr.sbin/mtree/misc.c,v
retrieving revision 1.18
diff -u -p -r1.18 misc.c
--- misc.c  1 Aug 2004 18:32:20 -   1.18
+++ misc.c  7 Jul 2012 12:41:24 -
@@ -64,6 +64,7 @@ static KEY keylist[] = {
{"optional",F_OPT,  0},
{"rmd160digest",F_RMD160,   NEEDVALUE},
{"sha1digest",  F_SHA1, NEEDVALUE},
+   {"sha256digest",F_SHA256,   NEEDVALUE},
{"size",F_SIZE, NEEDVALUE},
{"time",F_TIME, NEEDVALUE},
{"type",F_TYPE, NEEDVALUE},
Index: mtree.8
===
RCS file: /cvs/src/usr.sbin/mtree/mtree.8,v
retrieving revision 1.35
diff -u -p -r1.35 mtree.8
--- mtree.8 3 Sep 2010 11:22:36 -   1.35
+++ mtree.8 7 Jul 2012 13:31:09 -
@@ -193,6 +193,8 @@ not in the file hierarchy.
 The RIPEMD-160 message digest of the file.
 .It Cm sha1digest
 The SHA-1 message digest of the file.
+.It Cm sha256digest
+The SHA2-256 message digest of the file.
 .It Cm size
 The size, in bytes, of the file.
 .It Cm time
@@ -305,21 +307,21 @@ it is recommended
 that
 .Nm mtree
 .Fl cK
-.Cm sha1digest
+.Cm sha256digest
 be run on the file systems, and a copy of the results stored on a different
 machine, or, at least, in encrypted form.
 The output file itself should be digested using the
-.Xr sha1 1
+.Xr sha256 1
 utility.
 Then, periodically,
 .Nm mtree
 and
-.Xr sha1 1
+.Xr sha256 1
 should be run against the on-line specifications.
 While it is possible for the bad guys to change the on-line specifications
 to conform to their modified binaries, it is believed to be
 impractical for them to create a modified specification which has
-the same SHA1 digest as the original.
+the same SHA2-256 digest as the original.
 .Pp
 The
 .Fl d
@@ -336,11 +338,13 @@ distribution.
 .Xr cksum 1 ,
 .Xr md5 1 ,
 .Xr sha1 1 ,
+.Xr sha256 1 ,
 .Xr stat 2 ,
 .Xr fts 3 ,
 .Xr md5 3 ,
 .Xr rmd160 3 ,
 .Xr sha1 3 ,
+.Xr sha2 3 ,
 .Xr hier 7 ,
 .Xr chown 8
 .Sh HISTORY
Index: mtree.h
===
RCS file:

Re: nc -ul semantics

2012-07-07 Thread Lazaros Koromilas
On Sat, Jul 07, 2012 at 07:34:28AM -0300, Christiano F. Haesbaert wrote:
> How about this one ?
> It's your original idea, but I don't like that extra indentation level,
> we are already too deep.

Yes, less identation is always good!  The "multiple hosts" part
in the manpage could become one of the following, but it's clear
enough already.

"[...] and it can receive UDP datagrams from multiple hosts."
"[...] and it receives all UDP datagrams arriving at the port."

> 
> 
> Index: nc.1
> ===
> RCS file: /cvs/src/usr.bin/nc/nc.1,v
> retrieving revision 1.60
> diff -d -u -p -r1.60 nc.1
> --- nc.1  7 Feb 2012 12:11:43 -   1.60
> +++ nc.1  7 Jul 2012 10:30:10 -
> @@ -119,6 +119,10 @@ is completed.
>  It is an error to use this option without the
>  .Fl l
>  option.
> +When used together with the
> +.Fl u
> +option, the server socket is not connected and it receives UDP datagrams from
> +multiple hosts.
>  .It Fl l
>  Used to specify that
>  .Nm
> Index: netcat.c
> ===
> RCS file: /cvs/src/usr.bin/nc/netcat.c,v
> retrieving revision 1.108
> diff -d -u -p -r1.108 netcat.c
> --- netcat.c  7 Jul 2012 09:36:30 -   1.108
> +++ netcat.c  7 Jul 2012 10:30:11 -
> @@ -345,11 +345,17 @@ main(int argc, char *argv[])
>   if (s < 0)
>   err(1, NULL);
>   /*
> -  * For UDP, we will use recvfrom() initially
> -  * to wait for a caller, then use the regular
> -  * functions to talk to the caller.
> +  * For UDP and -k, don't connect the socket, let it
> +  * receive datagrams from multiple socket pairs.
>*/
> - if (uflag) {
> + if (uflag && kflag)
> + readwrite(s);
> + /*
> +  * For UDP and not -k, we will use recvfrom() initially
> +  * to wait for a caller, then use the regular functions
> +  * to talk to the caller.
> +  */
> + else if (uflag && !kflag) {
>   int rv, plen;
>   char buf[16384];
>   struct sockaddr_storage z;



Re: [s...@cd80.net: Re: rtadvd(8) patch 2/2 : finalize server-side RFC 6106 support]

2012-07-07 Thread Matthieu Herrb
On Sat, Jul 07, 2012 at 12:47:32PM +0200, Peter Hessler wrote:
> ressurecting an old patch.
> 
> OK from me, anyone else?

With my sysadmin-deplying-IPv6-at-my-dayjob hat, I'd love to see that
go in, but I can't test it before next week. 

I only had a quick glance at the code (never looked at rtadvd source
code before), didn't spot anything dubious...
> 
> 
> - Forwarded message from "Stephane A. Sezer"  -
> 
> Date: Thu, 23 Feb 2012 21:18:30 -0800
> From: "Stephane A. Sezer" 
> To: tech@openbsd.org
> Subject: Re: rtadvd(8) patch 2/2 : finalize server-side RFC 6106 support
> List-ID: 
> X-Loop: tech@openbsd.org
> 
> On Fri, 27 Jan 2012 15:20:29 +0100
> "Stephane A. Sezer"  wrote:
> 
> > Hello again tech@,
> > 
> > Here's also the updated version of a patch I wrote approx. one year ago
> > to support RFC 6106 in rtadvd(8). J.R. Oldroyd told me there was a bug
> > in the generation of the DNS search list and that the format of the
> > packets generated was not valid.
> > 
> > I fixed that, so here is the patch.
> > 
> > Regards,
> 
> Same thing here: updated patch that applies correctly on -current.
> 
> -- 
> Stephane A. Sezer
> 
> 
> Index: sys/netinet/icmp6.h
> ===
> RCS file: /cvs/src/sys/netinet/icmp6.h,v
> retrieving revision 1.33
> diff -u sys/netinet/icmp6.h
> --- sys/netinet/icmp6.h   22 Mar 2010 12:23:32 -  1.33
> +++ sys/netinet/icmp6.h   22 Feb 2012 03:52:17 -
> @@ -282,6 +282,8 @@
>  #define ND_OPT_PREFIX_INFORMATION3
>  #define ND_OPT_REDIRECTED_HEADER 4
>  #define ND_OPT_MTU   5
> +#define ND_OPT_RDNSS 25
> +#define ND_OPT_DNSSL 31
>  
>  struct nd_opt_prefix_info {  /* prefix information */
>   u_int8_tnd_opt_pi_type;
> @@ -310,6 +312,22 @@
>   u_int8_tnd_opt_mtu_len;
>   u_int16_t   nd_opt_mtu_reserved;
>   u_int32_t   nd_opt_mtu_mtu;
> +} __packed;
> +
> +struct nd_opt_rdnss {/* RDNSS option */
> + u_int8_tnd_opt_rdnss_type;
> + u_int8_tnd_opt_rdnss_len;
> + u_int16_t   nd_opt_rdnss_reserved;
> + u_int32_t   nd_opt_rdnss_lifetime;
> + /* followed by list of recursive DNS servers */
> +} __packed;
> +
> +struct nd_opt_dnssl {/* DNSSL option */
> + u_int8_tnd_opt_dnssl_type;
> + u_int8_tnd_opt_dnssl_len;
> + u_int16_t   nd_opt_dnssl_reserved;
> + u_int32_t   nd_opt_dnssl_lifetime;
> + /* followed by list of DNS search domains */
>  } __packed;
>  
>  /*
> Index: usr.sbin/rtadvd/config.c
> ===
> RCS file: /cvs/src/usr.sbin/rtadvd/config.c,v
> retrieving revision 1.26
> diff -u usr.sbin/rtadvd/config.c
> --- usr.sbin/rtadvd/config.c  23 Apr 2008 10:17:50 -  1.26
> +++ usr.sbin/rtadvd/config.c  22 Feb 2012 03:52:25 -
> @@ -109,6 +109,8 @@
>   fatal("malloc");
>  
>   TAILQ_INIT(&tmp->prefixes);
> + TAILQ_INIT(&tmp->rdnsss);
> + TAILQ_INIT(&tmp->dnssls);
>   SLIST_INIT(&tmp->soliciters);
>  
>   /* check if we are allowed to forward packets (if not determined) */
> @@ -323,6 +325,106 @@
>   if (tmp->pfxs == 0)
>   get_prefix(tmp);
>  
> + tmp->rdnsscnt = 0;
> + for (i = -1; i < MAXRDNSS; ++i) {
> + struct rdnss *rds;
> + char entbuf[256];
> + char *tmpaddr;
> +
> + makeentry(entbuf, sizeof(entbuf), i, "rdnss");
> + addr = agetstr(entbuf, &bp);
> + if (addr == NULL)
> + continue;
> +
> + /* servers are separated by commas in the config file */
> + val = 1;
> + tmpaddr = addr;
> + while (*tmpaddr++)
> + if (*tmpaddr == ',')
> + ++val;
> +
> + rds = malloc(sizeof(struct rdnss) + val * sizeof(struct 
> in6_addr));
> + if (rds == NULL)
> + fatal("malloc");
> +
> + TAILQ_INSERT_TAIL(&tmp->rdnsss, rds, entry);
> + tmp->rdnsscnt++;
> +
> + rds->servercnt = val;
> +
> + makeentry(entbuf, sizeof(entbuf), i, "rdnssltime");
> + MAYHAVE(val, entbuf, (tmp->maxinterval * 3) / 2);
> + if (val < tmp->maxinterval || val > tmp->maxinterval * 2) {
> + log_warnx("%s (%ld) on %s is invalid "
> + "(should be between %d and %d)",
> + entbuf, val, intface, tmp->maxinterval,
> + tmp->maxinterval * 2);
> + }
> + rds->lifetime = val;
> +
> + val = 0;
> + while ((tmpaddr = strsep(&addr, ","))) {
> + if (inet_pton(AF_INET6, tmpaddr, &rds->servers[val]) != 
> 1) {
> + log_warn("inet_pton failed for %s", tmpaddr)

Re: spring clearance: pflog

2012-07-07 Thread Henning Brauer
* Henning Brauer  [2012-07-07 12:21]:
> old M from my tree, now with 50% discount!
> 
> kill the arbitary limit on the # of pflog interfaces and make it all
> dynamic. ok?

now even with free memory saver (allocated a little much for
**pflogifs)

Index: if_pflog.c
===
RCS file: /cvs/src/sys/net/if_pflog.c,v
retrieving revision 1.49
diff -u -p -r1.49 if_pflog.c
--- if_pflog.c  3 Feb 2012 01:57:50 -   1.49
+++ if_pflog.c  7 Jul 2012 12:42:10 -
@@ -80,6 +80,7 @@
 #endif
 
 void   pflogattach(int);
+intpflogifs_resize(size_t);
 intpflogoutput(struct ifnet *, struct mbuf *, struct sockaddr *,
   struct rtentry *);
 intpflogioctl(struct ifnet *, u_long, caddr_t);
@@ -91,16 +92,14 @@ LIST_HEAD(, pflog_softc)pflogif_list;
 struct if_clonepflog_cloner =
 IF_CLONE_INITIALIZER("pflog", pflog_clone_create, pflog_clone_destroy);
 
-struct ifnet   *pflogifs[PFLOGIFS_MAX];/* for fast access */
-struct mbuf*pflog_mhdr = NULL, *pflog_mptr = NULL;
+int  npflogifs = 0;
+struct ifnet   **pflogifs = NULL;  /* for fast access */
+struct mbuf *pflog_mhdr = NULL, *pflog_mptr = NULL;
 
 void
 pflogattach(int npflog)
 {
-   int i;
LIST_INIT(&pflogif_list);
-   for (i = 0; i < PFLOGIFS_MAX; i++)
-   pflogifs[i] = NULL;
if (pflog_mhdr == NULL)
if ((pflog_mhdr = m_get(M_DONTWAIT, MT_HEADER)) == NULL)
panic("pflogattach: no mbuf");
@@ -111,15 +110,39 @@ pflogattach(int npflog)
 }
 
 int
+pflogifs_resize(size_t n)
+{
+   struct ifnet**p;
+   int   i;
+
+   if (n > SIZE_MAX / sizeof(*p))
+   return (EINVAL);
+   if (n == 0)
+   p = NULL;
+   else
+   if ((p = malloc(n * sizeof(*p), M_DEVBUF,
+   M_NOWAIT|M_ZERO)) == NULL)
+   return (ENOMEM);
+   for (i = 0; i < n; i++)
+   if (i < npflogifs)
+   p[i] = pflogifs[i];
+   else
+   p[i] = NULL;
+
+   if (pflogifs)
+   free(pflogifs, M_DEVBUF);
+   pflogifs = p;
+   npflogifs = n;
+   return (0);
+}
+
+int
 pflog_clone_create(struct if_clone *ifc, int unit)
 {
struct ifnet *ifp;
struct pflog_softc *pflogif;
int s;
 
-   if (unit >= PFLOGIFS_MAX)
-   return (EINVAL);
-
if ((pflogif = malloc(sizeof(*pflogif),
M_DEVBUF, M_NOWAIT|M_ZERO)) == NULL)
return (ENOMEM);
@@ -144,6 +167,10 @@ pflog_clone_create(struct if_clone *ifc,
 
s = splnet();
LIST_INSERT_HEAD(&pflogif_list, pflogif, sc_list);
+   if (unit + 1 > npflogifs && pflogifs_resize(unit + 1) != 0) {
+   splx(s);
+   return (ENOMEM);
+   }
pflogifs[unit] = ifp;
splx(s);
 
@@ -154,11 +181,16 @@ int
 pflog_clone_destroy(struct ifnet *ifp)
 {
struct pflog_softc  *pflogif = ifp->if_softc;
-   int  s;
+   int  s, i;
 
s = splnet();
pflogifs[pflogif->sc_unit] = NULL;
LIST_REMOVE(pflogif, sc_list);
+
+   for (i = npflogifs; i > 0 && pflogifs[i - 1] == NULL; i--)
+   ; /* nothing */
+   if (i < npflogifs)
+   pflogifs_resize(i); /* error harmless here */
splx(s);
 
if_detach(ifp);
@@ -225,7 +257,8 @@ pflog_packet(struct pf_pdesc *pd, u_int8
if (rm == NULL || pd == NULL || pd->kif == NULL || pd->m == NULL)
return (-1);
 
-   if ((ifn = pflogifs[rm->logif]) == NULL || !ifn->if_bpf)
+   if (rm->logif >= npflogifs || (ifn = pflogifs[rm->logif]) == NULL ||
+   !ifn->if_bpf)
return (0);
 
bzero(&hdr, sizeof(hdr));
Index: if_pflog.h
===
RCS file: /cvs/src/sys/net/if_pflog.h,v
retrieving revision 1.22
diff -u -p -r1.22 if_pflog.h
--- if_pflog.h  13 Oct 2011 18:23:39 -  1.22
+++ if_pflog.h  7 Jul 2012 12:42:10 -
@@ -29,8 +29,6 @@
 
 #include 
 
-#definePFLOGIFS_MAX16
-
 struct pflog_softc {
struct ifnetsc_if;  /* the interface */
int sc_unit;
Index: pf_ioctl.c
===
RCS file: /cvs/src/sys/net/pf_ioctl.c,v
retrieving revision 1.250
diff -u -p -r1.250 pf_ioctl.c
--- pf_ioctl.c  3 Apr 2012 15:09:03 -   1.250
+++ pf_ioctl.c  7 Jul 2012 12:42:11 -
@@ -2595,8 +2595,6 @@ pf_rule_copyin(struct pf_rule *from, str
 #if NPFLOG > 0
if (!to->log)
to->logif = 0;
-   if (to->logif >= PFLOGIFS_MAX)
-   return (EINVAL);
 #endif
to->quick = from->quick;
to->ifnot = from->ifnot;

-- 
Henning Brauer, h...@bsws.de, henn...@openbsd.org
BS Web Se

[s...@cd80.net: Re: rtadvd(8) patch 2/2 : finalize server-side RFC 6106 support]

2012-07-07 Thread Peter Hessler
ressurecting an old patch.

OK from me, anyone else?


- Forwarded message from "Stephane A. Sezer"  -

Date: Thu, 23 Feb 2012 21:18:30 -0800
From: "Stephane A. Sezer" 
To: tech@openbsd.org
Subject: Re: rtadvd(8) patch 2/2 : finalize server-side RFC 6106 support
List-ID: 
X-Loop: tech@openbsd.org

On Fri, 27 Jan 2012 15:20:29 +0100
"Stephane A. Sezer"  wrote:

> Hello again tech@,
> 
> Here's also the updated version of a patch I wrote approx. one year ago
> to support RFC 6106 in rtadvd(8). J.R. Oldroyd told me there was a bug
> in the generation of the DNS search list and that the format of the
> packets generated was not valid.
> 
> I fixed that, so here is the patch.
> 
> Regards,

Same thing here: updated patch that applies correctly on -current.

-- 
Stephane A. Sezer


Index: sys/netinet/icmp6.h
===
RCS file: /cvs/src/sys/netinet/icmp6.h,v
retrieving revision 1.33
diff -u sys/netinet/icmp6.h
--- sys/netinet/icmp6.h 22 Mar 2010 12:23:32 -  1.33
+++ sys/netinet/icmp6.h 22 Feb 2012 03:52:17 -
@@ -282,6 +282,8 @@
 #define ND_OPT_PREFIX_INFORMATION  3
 #define ND_OPT_REDIRECTED_HEADER   4
 #define ND_OPT_MTU 5
+#define ND_OPT_RDNSS   25
+#define ND_OPT_DNSSL   31
 
 struct nd_opt_prefix_info {/* prefix information */
u_int8_tnd_opt_pi_type;
@@ -310,6 +312,22 @@
u_int8_tnd_opt_mtu_len;
u_int16_t   nd_opt_mtu_reserved;
u_int32_t   nd_opt_mtu_mtu;
+} __packed;
+
+struct nd_opt_rdnss {  /* RDNSS option */
+   u_int8_tnd_opt_rdnss_type;
+   u_int8_tnd_opt_rdnss_len;
+   u_int16_t   nd_opt_rdnss_reserved;
+   u_int32_t   nd_opt_rdnss_lifetime;
+   /* followed by list of recursive DNS servers */
+} __packed;
+
+struct nd_opt_dnssl {  /* DNSSL option */
+   u_int8_tnd_opt_dnssl_type;
+   u_int8_tnd_opt_dnssl_len;
+   u_int16_t   nd_opt_dnssl_reserved;
+   u_int32_t   nd_opt_dnssl_lifetime;
+   /* followed by list of DNS search domains */
 } __packed;
 
 /*
Index: usr.sbin/rtadvd/config.c
===
RCS file: /cvs/src/usr.sbin/rtadvd/config.c,v
retrieving revision 1.26
diff -u usr.sbin/rtadvd/config.c
--- usr.sbin/rtadvd/config.c23 Apr 2008 10:17:50 -  1.26
+++ usr.sbin/rtadvd/config.c22 Feb 2012 03:52:25 -
@@ -109,6 +109,8 @@
fatal("malloc");
 
TAILQ_INIT(&tmp->prefixes);
+   TAILQ_INIT(&tmp->rdnsss);
+   TAILQ_INIT(&tmp->dnssls);
SLIST_INIT(&tmp->soliciters);
 
/* check if we are allowed to forward packets (if not determined) */
@@ -323,6 +325,106 @@
if (tmp->pfxs == 0)
get_prefix(tmp);
 
+   tmp->rdnsscnt = 0;
+   for (i = -1; i < MAXRDNSS; ++i) {
+   struct rdnss *rds;
+   char entbuf[256];
+   char *tmpaddr;
+
+   makeentry(entbuf, sizeof(entbuf), i, "rdnss");
+   addr = agetstr(entbuf, &bp);
+   if (addr == NULL)
+   continue;
+
+   /* servers are separated by commas in the config file */
+   val = 1;
+   tmpaddr = addr;
+   while (*tmpaddr++)
+   if (*tmpaddr == ',')
+   ++val;
+
+   rds = malloc(sizeof(struct rdnss) + val * sizeof(struct 
in6_addr));
+   if (rds == NULL)
+   fatal("malloc");
+
+   TAILQ_INSERT_TAIL(&tmp->rdnsss, rds, entry);
+   tmp->rdnsscnt++;
+
+   rds->servercnt = val;
+
+   makeentry(entbuf, sizeof(entbuf), i, "rdnssltime");
+   MAYHAVE(val, entbuf, (tmp->maxinterval * 3) / 2);
+   if (val < tmp->maxinterval || val > tmp->maxinterval * 2) {
+   log_warnx("%s (%ld) on %s is invalid "
+   "(should be between %d and %d)",
+   entbuf, val, intface, tmp->maxinterval,
+   tmp->maxinterval * 2);
+   }
+   rds->lifetime = val;
+
+   val = 0;
+   while ((tmpaddr = strsep(&addr, ","))) {
+   if (inet_pton(AF_INET6, tmpaddr, &rds->servers[val]) != 
1) {
+   log_warn("inet_pton failed for %s", tmpaddr);
+   exit(1);
+   }
+   val++;
+   }
+   }
+
+   tmp->dnsslcnt = 0;
+   for (i = -1; i < MAXDNSSL; ++i) {
+   struct dnssl *dsl;
+   char entbuf[256];
+   char *tmpsl;
+
+   makeentry(entbuf, sizeof(entbuf), i, "dnssl");
+   addr = agetstr(entbuf, &bp);
+   if (addr == NULL)
+  

Re: nc -ul semantics

2012-07-07 Thread Christiano F. Haesbaert
How about this one ?
It's your original idea, but I don't like that extra indentation level,
we are already too deep.



Index: nc.1
===
RCS file: /cvs/src/usr.bin/nc/nc.1,v
retrieving revision 1.60
diff -d -u -p -r1.60 nc.1
--- nc.17 Feb 2012 12:11:43 -   1.60
+++ nc.17 Jul 2012 10:30:10 -
@@ -119,6 +119,10 @@ is completed.
 It is an error to use this option without the
 .Fl l
 option.
+When used together with the
+.Fl u
+option, the server socket is not connected and it receives UDP datagrams from
+multiple hosts.
 .It Fl l
 Used to specify that
 .Nm
Index: netcat.c
===
RCS file: /cvs/src/usr.bin/nc/netcat.c,v
retrieving revision 1.108
diff -d -u -p -r1.108 netcat.c
--- netcat.c7 Jul 2012 09:36:30 -   1.108
+++ netcat.c7 Jul 2012 10:30:11 -
@@ -345,11 +345,17 @@ main(int argc, char *argv[])
if (s < 0)
err(1, NULL);
/*
-* For UDP, we will use recvfrom() initially
-* to wait for a caller, then use the regular
-* functions to talk to the caller.
+* For UDP and -k, don't connect the socket, let it
+* receive datagrams from multiple socket pairs.
 */
-   if (uflag) {
+   if (uflag && kflag)
+   readwrite(s);
+   /*
+* For UDP and not -k, we will use recvfrom() initially
+* to wait for a caller, then use the regular functions
+* to talk to the caller.
+*/
+   else if (uflag && !kflag) {
int rv, plen;
char buf[16384];
struct sockaddr_storage z;



spring clearance: pflog

2012-07-07 Thread Henning Brauer
old M from my tree, now with 50% discount!

kill the arbitary limit on the # of pflog interfaces and make it all
dynamic. ok?

Index: sys/net/if_pflog.c
===
RCS file: /cvs/src/sys/net/if_pflog.c,v
retrieving revision 1.49
diff -u -p -r1.49 if_pflog.c
--- sys/net/if_pflog.c  3 Feb 2012 01:57:50 -   1.49
+++ sys/net/if_pflog.c  13 Apr 2012 16:26:27 -
@@ -80,6 +80,7 @@
 #endif
 
 void   pflogattach(int);
+intpflogifs_resize(size_t);
 intpflogoutput(struct ifnet *, struct mbuf *, struct sockaddr *,
   struct rtentry *);
 intpflogioctl(struct ifnet *, u_long, caddr_t);
@@ -91,16 +92,14 @@ LIST_HEAD(, pflog_softc)pflogif_list;
 struct if_clonepflog_cloner =
 IF_CLONE_INITIALIZER("pflog", pflog_clone_create, pflog_clone_destroy);
 
-struct ifnet   *pflogifs[PFLOGIFS_MAX];/* for fast access */
-struct mbuf*pflog_mhdr = NULL, *pflog_mptr = NULL;
+int  npflogifs = 0;
+struct ifnet   **pflogifs = NULL;  /* for fast access */
+struct mbuf *pflog_mhdr = NULL, *pflog_mptr = NULL;
 
 void
 pflogattach(int npflog)
 {
-   int i;
LIST_INIT(&pflogif_list);
-   for (i = 0; i < PFLOGIFS_MAX; i++)
-   pflogifs[i] = NULL;
if (pflog_mhdr == NULL)
if ((pflog_mhdr = m_get(M_DONTWAIT, MT_HEADER)) == NULL)
panic("pflogattach: no mbuf");
@@ -111,15 +110,39 @@ pflogattach(int npflog)
 }
 
 int
+pflogifs_resize(size_t n)
+{
+   struct ifnet**p;
+   int   i;
+
+   if (n > SIZE_MAX / sizeof(struct ifnet))
+   return (EINVAL);
+   if (n == 0)
+   p = NULL;
+   else
+   if ((p = malloc(n * sizeof(struct ifnet), M_DEVBUF,
+   M_NOWAIT|M_ZERO)) == NULL)
+   return (ENOMEM);
+   for (i = 0; i < n; i++)
+   if (i < npflogifs)
+   p[i] = pflogifs[i];
+   else
+   p[i] = NULL;
+
+   if (pflogifs)
+   free(pflogifs, M_DEVBUF);
+   pflogifs = p;
+   npflogifs = n;
+   return (0);
+}
+
+int
 pflog_clone_create(struct if_clone *ifc, int unit)
 {
struct ifnet *ifp;
struct pflog_softc *pflogif;
int s;
 
-   if (unit >= PFLOGIFS_MAX)
-   return (EINVAL);
-
if ((pflogif = malloc(sizeof(*pflogif),
M_DEVBUF, M_NOWAIT|M_ZERO)) == NULL)
return (ENOMEM);
@@ -144,6 +167,10 @@ pflog_clone_create(struct if_clone *ifc,
 
s = splnet();
LIST_INSERT_HEAD(&pflogif_list, pflogif, sc_list);
+   if (unit + 1 > npflogifs && pflogifs_resize(unit + 1) != 0) {
+   splx(s);
+   return (ENOMEM);
+   }
pflogifs[unit] = ifp;
splx(s);
 
@@ -154,11 +181,16 @@ int
 pflog_clone_destroy(struct ifnet *ifp)
 {
struct pflog_softc  *pflogif = ifp->if_softc;
-   int  s;
+   int  s, i;
 
s = splnet();
pflogifs[pflogif->sc_unit] = NULL;
LIST_REMOVE(pflogif, sc_list);
+
+   for (i = npflogifs; i > 0 && pflogifs[i - 1] == NULL; i--)
+   ; /* nothing */
+   if (i < npflogifs)
+   pflogifs_resize(i); /* error harmless here */
splx(s);
 
if_detach(ifp);
@@ -225,7 +257,8 @@ pflog_packet(struct pf_pdesc *pd, u_int8
if (rm == NULL || pd == NULL || pd->kif == NULL || pd->m == NULL)
return (-1);
 
-   if ((ifn = pflogifs[rm->logif]) == NULL || !ifn->if_bpf)
+   if (rm->logif >= npflogifs || (ifn = pflogifs[rm->logif]) == NULL ||
+   !ifn->if_bpf)
return (0);
 
bzero(&hdr, sizeof(hdr));
Index: sys/net/if_pflog.h
===
RCS file: /cvs/src/sys/net/if_pflog.h,v
retrieving revision 1.22
diff -u -p -r1.22 if_pflog.h
--- sys/net/if_pflog.h  13 Oct 2011 18:23:39 -  1.22
+++ sys/net/if_pflog.h  7 Jul 2012 09:37:10 -
@@ -29,8 +29,6 @@
 
 #include 
 
-#definePFLOGIFS_MAX16
-
 struct pflog_softc {
struct ifnetsc_if;  /* the interface */
int sc_unit;
Index: sys/net/pf_ioctl.c
===
RCS file: /cvs/src/sys/net/pf_ioctl.c,v
retrieving revision 1.250
diff -u -p -r1.250 pf_ioctl.c
--- sys/net/pf_ioctl.c  3 Apr 2012 15:09:03 -   1.250
+++ sys/net/pf_ioctl.c  11 Apr 2012 10:13:06 -
@@ -2595,8 +2595,6 @@ pf_rule_copyin(struct pf_rule *from, str
 #if NPFLOG > 0
if (!to->log)
to->logif = 0;
-   if (to->logif >= PFLOGIFS_MAX)
-   return (EINVAL);
 #endif
to->quick = from->quick;
to->ifnot = from->ifnot;

- End forwarded message -

-- 
Henning Brauer, h...@bsws.de, henn...@openbsd.org

Re: nc(1): Report incoming connections on nc -v -l

2012-07-07 Thread Christiano F. Haesbaert
Still waiting for another ok.

On Thu, Jun 28, 2012 at 11:36:27PM -0300, Christiano F. Haesbaert wrote:
> This looks good to me, can I get another ok ?
> 
> 
> On Sun, Jun 24, 2012 at 07:07:29AM -0400, Ricky Zhou wrote:
> > On 2012-06-16 02:37:27 PM, Christiano F. Haesbaert wrote:
> > > I guess so, I don't use nc too often but it sounds reasonable to me,
> > > your code has a few notes though, please check inline. 
> > (Sorry for the slow response, was travelling last week)
> > 
> > Thanks for looking at the patch - here's a new one with your fixes
> > included.
> > 
> > Thanks,
> > Ricky
> > 
> > 
> > Index: netcat.c
> > ===
> > RCS file: /cvs/src/usr.bin/nc/netcat.c,v
> > retrieving revision 1.107
> > diff -u netcat.c
> > --- netcat.c1 Apr 2012 02:58:57 -   1.107
> > +++ netcat.c24 Jun 2012 09:51:19 -
> > @@ -106,6 +106,7 @@
> >  intunix_listen(char *);
> >  void   set_common_sockopts(int);
> >  intmap_tos(char *, int *);
> > +void   report_connect(const struct sockaddr *, socklen_t);
> >  void   usage(int);
> >  
> >  int
> > @@ -364,6 +365,9 @@
> > if (rv < 0)
> > err(1, "connect");
> >  
> > +   if (vflag)
> > +   report_connect((struct sockaddr *)&z, 
> > len);
> > +
> > readwrite(s);
> > } else {
> > len = sizeof(cliaddr);
> > @@ -371,6 +375,10 @@
> > &len);
> > if (connfd == -1)
> > err(1, "accept");
> > +
> > +   if (vflag)
> > +   report_connect((struct sockaddr 
> > *)&cliaddr, len);
> > +
> > readwrite(connfd);
> > close(connfd);
> > }
> > @@ -957,6 +965,32 @@
> > }
> >  
> > return (0);
> > +}
> > +
> > +void
> > +report_connect(const struct sockaddr *sa, socklen_t salen)
> > +{
> > +   char remote_host[NI_MAXHOST];
> > +   char remote_port[NI_MAXSERV];
> > +   int herr;
> > +   int flags = NI_NUMERICSERV;
> > +   
> > +   if (nflag)
> > +   flags |= NI_NUMERICHOST;
> > +   
> > +   if ((herr = getnameinfo(sa, salen,
> > +   remote_host, sizeof(remote_host),
> > +   remote_port, sizeof(remote_port),
> > +   flags)) != 0) {
> > +   if (herr == EAI_SYSTEM)
> > +   err(1, "getnameinfo");
> > +   else
> > +   errx(1, "getnameinfo: %s", gai_strerror(herr));
> > +   }
> > +   
> > +   fprintf(stderr,
> > +   "Connection from %s %s "
> > +   "received!\n", remote_host, remote_port);
> >  }
> >  
> >  void