arp(8) create / delete arp entries on rdomain not 0

2011-04-26 Thread Laurent Ghigonis
It seems like something like that is missing :)

As previously, it does not behave correctly when you run it with route 
-T$rdomain exec
and do not specify arp -V$rdomain, but that should not be used that way.

Index: arp.c
===
RCS file: /cvs/src/usr.sbin/arp/arp.c,v
retrieving revision 1.50
diff -u -r1.50 arp.c
--- arp.c   11 Jan 2011 16:34:20 -  1.50
+++ arp.c   25 Apr 2011 23:28:00 -
@@ -242,6 +242,10 @@
s = socket(PF_ROUTE, SOCK_RAW, 0);
if (s < 0)
err(1, "socket");
+   if (rdomain != 0)
+   if (setsockopt(s, AF_ROUTE, ROUTE_TABLEFILTER,
+   &rdomain, sizeof(rdomain)) < 0)
+   err(1, "setsockopt(ROUTE_TABLEFILTER)");
 }
 
 struct sockaddr_in so_mask = { 8, 0, 0, { 0x } };



Re: ral(4) diff

2011-03-11 Thread Laurent Ghigonis
On Thu, Mar 10, 2011 at 10:07:09PM +0100, Tim van der Molen wrote:
> I have the following ral(4):
>
> ral0 at pci0 dev 13 function 0 "Ralink RT2561S" rev 0x00: irq 5, address
00:1d:7d:49:28:92
> ral0: MAC/BBP RT2561C, RF RT2527
>
> After a commit from August 2010 (see
> http://marc.info/?l=openbsd-cvs&m=128095139804862) the ral stopped
> working: clients could not associate with it in hostap mode and it could
> not detect other APs with "ifconfig scan".
>
> After a hint from damien@ I came up with the following diff which brings
> back some of the code that was removed by the commit mentioned above.
>
> damien@ suggested I post the diff here. If you have an RT2561 or RT2661,
> please test it.

I have the same card as you, and your patch fixes it.

Previously it would only obey the first ifconfig command after boot,
now it works normaly.

Thank you :)


OpenBSD 4.9-current (GENERIC) #18: Fri Mar 11 17:35:48 CET 2011
k...@gouloum.lan.gouloum:/usr/src/sys/arch/amd64/compile/GENERIC
real mem = 1071841280 (1022MB)
avail mem = 1029304320 (981MB)
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.3 @ 0xf0520 (61 entries)
bios0: vendor American Megatrends Inc. version "1004.002" date 08/03/2004
bios0: ASUSTeK Computer Inc. K8V-X
acpi0 at bios0: rev 2
acpi0: sleep states S0 S1 S3 S4 S5
acpi0: tables DSDT FACP OEMB
acpi0: wakeup devices PCI0(S4) PS2K(S4) PS2M(S4) UAR1(S4) AC97(S4) USB1(S4)
USB2(S4) USB3(S4) USB4(S4) EHCI(S4) PWRB(S4) SLPB(S4)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpiprt0 at acpi0: bus 0 (PCI0)
acpicpu0 at acpi0: PSS
acpibtn0 at acpi0: PWRB
acpibtn1 at acpi0: SLPB
cpu0 at mainbus0: (uniprocessor)
cpu0: AMD Athlon(tm) 64 Processor 2800+, 1802.57 MHz
cpu0:
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUS
H,MMX,FXSR,SSE,SSE2,NXE,MMXX,LONG,3DNOW2,3DNOW
cpu0: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 512KB 64b/line
16-way L2 cache
cpu0: ITLB 32 4KB entries fully associative, 8 4MB entries fully associative
cpu0: DTLB 32 4KB entries fully associative, 8 4MB entries fully associative
cpu0: AMD errata 89, 97 present, BIOS upgrade may be required
cpu0: Cool'n'Quiet K8 1802 MHz: speeds: 1800 1000 MHz
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 "VIA K8HTB Host" rev 0x01
agp at pchb0 not configured
ppb0 at pci0 dev 1 function 0 "VIA K8HTB AGP" rev 0x00
pci1 at ppb0 bus 1
vga1 at pci1 dev 0 function 0 "NVIDIA GeForce2 MX" rev 0xb2
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
rl0 at pci0 dev 9 function 0 "Realtek 8139" rev 0x10: irq 11, address
00:08:a1:88:39:c2
rlphy0 at rl0 phy 0: RTL internal PHY
skc0 at pci0 dev 10 function 0 "Marvell Yukon 88E8001/8003/8010" rev 0x13,
Yukon Lite rev. A3 (0x7): irq 10
sk0 at skc0 port A: address 00:11:2f:b4:a4:31
eephy0 at sk0 phy 0: 88E1011 Gigabit PHY, rev. 5
ral0 at pci0 dev 11 function 0 "Ralink RT2561S" rev 0x00: irq 11, address
00:08:d3:28:16:ad
ral0: MAC/BBP RT2561C, RF RT2527
ral1 at pci0 dev 12 function 0 "Ralink RT2561S" rev 0x00: irq 10, address
00:08:d3:28:a5:21
ral1: MAC/BBP RT2561C, RF RT2527
emu0 at pci0 dev 13 function 0 "Creative Labs SoundBlaster Live" rev 0x07: irq
5
ac97: codec id 0x54524123 (TriTech Microelectronics TR28602)
audio0 at emu0
"Creative Labs PCI Gameport Joystick" rev 0x07 at pci0 dev 13 function 1 not
configured
ral2 at pci0 dev 14 function 0 "Ralink RT2561S" rev 0x00: irq 3, address
00:08:d3:28:d6:e4
ral2: MAC/BBP RT2561C, RF RT2527
pciide0 at pci0 dev 15 function 0 "VIA VT6420 SATA" rev 0x80: DMA
pciide0: using irq 10 for native-PCI interrupt
wd0 at pciide0 channel 0 drive 0: 
wd0: 16-sector PIO, LBA48, 70911MB, 145226112 sectors
wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 6
wd1 at pciide0 channel 1 drive 0: 
wd1: 16-sector PIO, LBA48, 305245MB, 625142448 sectors
wd1(pciide0:1:0): using PIO mode 4, Ultra-DMA mode 6
pciide1 at pci0 dev 15 function 1 "VIA VT82C571 IDE" rev 0x06: ATA133, channel
0 configured to compatibility, channel 1 configured to compatibility
atapiscsi0 at pciide1 channel 0 drive 1
scsibus0 at atapiscsi0: 2 targets
cd0 at scsibus0 targ 0 lun 0:  ATAPI 5/cdrom
removable
cd0(pciide1:0:1): using PIO mode 4, Ultra-DMA mode 2
pciide1: channel 1 disabled (no drives)
uhci0 at pci0 dev 16 function 0 "VIA VT83C572 USB" rev 0x81: irq 11
uhci1 at pci0 dev 16 function 1 "VIA VT83C572 USB" rev 0x81: irq 11
uhci2 at pci0 dev 16 function 2 "VIA VT83C572 USB" rev 0x81: irq 10
uhci3 at pci0 dev 16 function 3 "VIA VT83C572 USB" rev 0x81: irq 10
ehci0 at pci0 dev 16 function 4 "VIA VT6202 USB" rev 0x86: irq 5
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 "VIA EHCI root hub" rev 2.00/1.00 addr 1
viapm0 at pci0 dev 17 function 0 "VIA VT8237 ISA" rev 0x00
iic0 at viapm0
iic0: addr 0x4a 00=3f 01=03 02=7f 03=07 05=30 06=c0 07=90 08=3f 09=03 0a=7f
0b=07 0d=30 0e=c0 0f=90 10=3f 11=03 12=7f 13=07 15=30 16=c0 17=90 18=3f 19=03
1a=7f 1b=07 1d=30 1e=c0 1f=90 20=3f 21=03 22=7f 23=07 25=30 26=c0 27=90 28=3f
29=03 2a=7f 

Re: ssh -V double print

2011-01-31 Thread Laurent Ghigonis
On Mon, Jan 31, 2011 at 02:27:31PM +1100, Damien Miller wrote:
> On Sun, 30 Jan 2011, Laurent Ghigonis wrote:
> I can't replicate this. Do you have a shell alias ssh="ssh -v" or something?

Yes, and on all the tested machines ... sorry for the noise.
Btw it doesn't seem to break -v.



ssh -V double print

2011-01-30 Thread Laurent Ghigonis
Hello,

When you do ssh -V on -current it outputs
OpenSSH_5.7, OpenSSL 1.0.0a 1 Jun 2010
OpenSSH_5.7, OpenSSL 1.0.0a 1 Jun 2010

That fixes it, but maybe i miss some cases before or after again: ?

Index: ssh.c
===
RCS file: /cvs/src/usr.bin/ssh/ssh.c,v
retrieving revision 1.356
diff -u -r1.356 ssh.c
--- ssh.c   6 Jan 2011 22:23:53 -   1.356
+++ ssh.c   30 Jan 2011 08:12:08 -
@@ -389,10 +389,11 @@
}
/* FALLTHROUGH */
case 'V':
-   fprintf(stderr, "%s, %s\n",
-   SSH_VERSION, SSLeay_version(SSLEAY_VERSION));
-   if (opt == 'V')
+   if (opt == 'V') {
+   fprintf(stderr, "%s, %s\n",
+   SSH_VERSION, 
SSLeay_version(SSLEAY_VERSION));
exit(0);
+   }
break;
case 'w':
if (options.tun_open == -1)



axe(4) patch for some AX88772 phy

2010-08-28 Thread Laurent Ghigonis
Hello :)

After posting about a problem i had with my Linksys USB300M axe(4) adapter
(AX88772 based, phy not working correctly, cannot send anything)
http://marc.info/?l=openbsd-misc&m=128050785229742&w=2
and reading from another similar problem
(adapter detected but not working)
http://marc.info/?l=openbsd-misc&m=126869721215023&w=2
i adapted the FreeBSD patch linked by jsg@
http://people.freebsd.org/~yongari/axe.88178.patch4
to OpenBSD.

It makes my adapter work, so thanks jsg@ for your post :)
Here it is, hope it can help someone else.
But it is very probable that i did not made things correctly,
so if someone has time to correct me, i'd be happy.

Index: if_axe.c
===
RCS file: /cvs/src/sys/dev/usb/if_axe.c,v
retrieving revision 1.96
diff -u -r1.96 if_axe.c
--- if_axe.c9 Jan 2010 05:33:08 -   1.96
+++ if_axe.c29 Aug 2010 00:11:53 -
@@ -272,6 +272,7 @@
struct axe_softc*sc = (void *)dev;
usbd_status err;
uWord   val;
+   int ival;
 
if (sc->axe_dying) {
DPRINTF(("axe: dying\n"));
@@ -292,7 +293,7 @@
if (sc->axe_phyaddrs[1] != AXE_NOPHY && phy != sc->axe_phyaddrs[1])
return (0);
 #endif
-   if (sc->axe_phyaddrs[0] != 0xFF && sc->axe_phyaddrs[0] != phy)
+   if (sc->axe_phyno != phy)
return (0);
 
USETW(val, 0);
@@ -310,10 +311,18 @@
DPRINTF(("axe_miibus_readreg: phy 0x%x reg 0x%x val 0x%x\n",
phy, reg, UGETW(val)));
 
-   if (UGETW(val) && UGETW(val) != 0x)
-   sc->axe_phyaddrs[0] = phy;
+   ival = UGETW(val);
+   if ((sc->axe_flags & AX772) != 0 && reg == MII_BMSR) {
+  /*
+   * BMSR of AX88772 indicates that it supports extended
+   * capability but the extended status register is
+   * revered for embedded ethernet PHY. So clear the
+   * extended capability bit of BMSR.
+   */
+  ival &= ~BMSR_EXTCAP;
+   }
 
-   return (UGETW(val));
+   return (ival);
 }
 
 void
@@ -325,6 +334,8 @@
 
if (sc->axe_dying)
return;
+   if (sc->axe_phyno != phy)
+   return;
 
USETW(uval, val);
 
@@ -345,6 +356,7 @@
 {
struct axe_softc*sc = (void *)dev;
struct mii_data *mii = GET_MII(sc);
+   struct ifnet*ifp;
int val, err;
 
if ((mii->mii_media_active & IFM_GMASK) == IFM_FDX)
@@ -352,8 +364,41 @@
else
val = 0;
 
+   ifp = GET_IFP(sc);
+   if (mii == NULL || ifp == NULL ||
+   (ifp->if_flags & IFF_RUNNING) == 0)
+   return;
+
+   sc->axe_link = 0;
+   if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) ==
+   (IFM_ACTIVE | IFM_AVALID)) {
+   switch (IFM_SUBTYPE(mii->mii_media_active)) {
+   case IFM_10_T:
+   case IFM_100_TX:
+   sc->axe_link++;
+   break;
+   case IFM_1000_T:
+   if ((sc->axe_flags & AX178) == 0)
+   break;
+   sc->axe_link++;
+   break;
+   default:
+   break;
+   }
+   }
+
+   /* Lost link, do nothing. */
+   if (sc->axe_link == 0)
+   return;
+
+   val = 0;
+   if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) != 0)
+   val |= AXE_MEDIA_FULL_DUPLEX;
+
if (sc->axe_flags & AX178 || sc->axe_flags & AX772) {
val |= (AXE_178_MEDIA_RX_EN | AXE_178_MEDIA_MAGIC);
+   if (sc->axe_flags & AX178)
+   val |= AXE_178_MEDIA_ENCK;
 
switch (IFM_SUBTYPE(mii->mii_media_active)) {
case IFM_1000_T:
@@ -385,7 +430,6 @@
struct axe_softc*sc = ifp->if_softc;
struct mii_data *mii = GET_MII(sc);
 
-   sc->axe_link = 0;
if (mii->mii_instance) {
struct mii_softc*miisc;
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
@@ -530,7 +574,7 @@
axe_cmd(sc, AXE_CMD_WRITE_GPIO, 0, 0x00b0, NULL);
usbd_delay_ms(sc->axe_udev, 40);
 
-   if (sc->axe_phyaddrs[1] == AXE_INTPHY) {
+   if (sc->axe_phyno == AXE_PHY_NO_AX772_EPHY) {
/* ask for the embedded PHY */
axe_cmd(sc, AXE_CMD_SW_PHY_SELECT, 0, 0x01, NULL);
usbd_delay_ms(sc->axe_udev, 10);
@@ -564,6 +608,30 @@
axe_cmd(sc, AXE_CMD_RXCTL_WRITE, 0, 0, NULL);
 }
 
+static int
+axe_get_phyno(struct axe_softc *sc, int sel)
+{
+   int phyno;
+
+   phyno = -1;
+   switch (AXE_PHY_TYPE(sc->axe_phyaddrs[sel])) {
+   case PHY_TYPE_100_HOME:
+   case PHY_TYPE_GIG:
+  

typo in faq current config(8) entry

2010-05-26 Thread Laurent Ghigonis
Index: faq/current.html
===
RCS file: /cvs/www/faq/current.html,v
retrieving revision 1.216
diff -u -r1.216 current.html
--- faq/current.html26 May 2010 07:01:51 -  1.216
+++ faq/current.html26 May 2010 09:16:34 -
@@ -188,7 +188,7 @@
 Rebuild it using
 
 cd /usr/src/usr.sbin/config
-make obj && make depend && make obj && make install
+make obj && make depend && make && make install
 
 
 



Re: routing domains support for dhclient

2010-04-18 Thread Laurent Ghigonis
On Sun, Feb 28, 2010 at 10:19:36AM +0100, Laurent Ghigonis wrote:
> hello,
> 
> here is a patch that makes dhclient modify the routes on the routing table 
> corresponding to the routing domain of the interface it is working on.
> does it looks like something correct ?
> 
> the routing domain could be fetched directly from the dhclient-script, but i 
> don't know how to do that with the tools avalaible in /bin and /sbin. and the 
> current dhclient-script behavior is only to execute orders, not to fetch 
> data, so maybe its cleaner ?

Sorry to respond to myself, but nobody is interested ?
Maybe most of the routing domain users are doing it on static links, where 
dhclient is not used. I find it usefull on untrusted wireless networks, so that 
there is no way data will be transmitted to that interface, except the vpn i 
start explicitely on it.

laurent



routing domains support for dhclient

2010-02-28 Thread Laurent Ghigonis
hello,

here is a patch that makes dhclient modify the routes on the routing table 
corresponding to the routing domain of the interface it is working on.
does it looks like something correct ?

the routing domain could be fetched directly from the dhclient-script, but i 
don't know how to do that with the tools avalaible in /bin and /sbin. and the 
current dhclient-script behavior is only to execute orders, not to fetch data, 
so maybe its cleaner ?

laurent

Index: dhclient-script
===
RCS file: /cvs/src/sbin/dhclient/dhclient-script,v
retrieving revision 1.15
diff -u -r1.15 dhclient-script
--- dhclient-script 3 Jun 2009 05:12:51 -   1.15
+++ dhclient-script 28 Feb 2010 08:14:48 -
@@ -24,7 +24,7 @@
 delete_old_address() {
if [ -n "$old_ip_address" ]; then
ifconfig $interface inet $old_ip_address delete $medium
-   route delete "$old_ip_address" 127.0.0.1 >/dev/null 2>&1
+   route -T $rt delete "$old_ip_address" 127.0.0.1 >/dev/null 2>&1
fi
 }
 
@@ -36,14 +36,14 @@
$medium
 
# XXX Original TIMEOUT code did not do this unless $new_routers was set?
-   route add $new_ip_address 127.0.0.1 >/dev/null 2>&1
+   route -T $rt add $new_ip_address 127.0.0.1 >/dev/null 2>&1
 }
 
 delete_old_alias() {
if [ -n "$alias_ip_address" ]; then
ifconfig $interface \
inet $alias_ip_address delete > /dev/null 2>&1
-   route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
+   route -T $rt delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
fi
 }
 
@@ -51,19 +51,19 @@
if [ -n "$alias_ip_address" ]; then
ifconfig $interface inet $alias_ip_address alias netmask \
$alias_subnet_mask
-   route add $alias_ip_address 127.0.0.1
+   route -T $rt add $alias_ip_address 127.0.0.1
fi
 }
 
 delete_old_routes() {
# Delete existing default route. We only allow one, so no need to
# process $old_routers list.
-   route -n flush -inet -iface $interface >/dev/null 2>&1
+   route -T $rt -n flush -inet -iface $interface >/dev/null 2>&1
 
if [ -n "$old_static_routes" ]; then
set $old_static_routes
while [ $# -gt 1 ]; do
-   route delete "$1" "$2"
+   route -T $rt delete "$1" "$2"
shift; shift
done
fi
@@ -72,12 +72,12 @@
 }
 
 add_new_routes() {
-   route -n flush -inet -iface $interface >/dev/null 2>&1
+   route -T $rt -n flush -inet -iface $interface >/dev/null 2>&1
for router in $new_routers; do
if [ "$new_ip_address" = "$router" ]; then
-   route add default -iface $router >/dev/null 2>&1
+   route -T $rt add default -iface $router >/dev/null 2>&1
else
-   route add default $router >/dev/null 2>&1
+   route -T $rt add default $router >/dev/null 2>&1
fi
# 2nd and subsequent default routers error out, so explicitly
# stop processing the list after the first one.
@@ -87,7 +87,7 @@
if [ -n "$new_static_routes" ]; then
set $new_static_routes
while [ $# -gt 1 ]; do
-   route add $1 $2
+   route -T $rt add $1 $2
shift; shift
done
fi
Index: dhclient.c
===
RCS file: /cvs/src/sbin/dhclient/dhclient.c,v
retrieving revision 1.132
diff -u -r1.132 dhclient.c
--- dhclient.c  12 Nov 2009 14:18:45 -  1.132
+++ dhclient.c  28 Feb 2010 08:14:49 -
@@ -1589,6 +1589,8 @@
 void
 priv_script_init(char *reason, char *medium)
 {
+   char tbuf[128];
+
client->scriptEnvsize = 100;
if (client->scriptEnv == NULL)
client->scriptEnv =
@@ -1606,6 +1608,9 @@
 
if (medium)
script_set_env("", "medium", medium);
+
+   snprintf(tbuf, sizeof(tbuf), "%d", (u_int)ifi->rdomain);
+   script_set_env("", "rt", tbuf);
 
script_set_env("", "reason", reason);
 }
Index: dhcpd.h
===
RCS file: /cvs/src/sbin/dhclient/dhcpd.h,v
retrieving revision 1.69
diff -u -r1.69 dhcpd.h
--- dhcpd.h 6 Jun 2009 04:02:42 -   1.69
+++ dhcpd.h 28 Feb 2010 08:14:49 -
@@ -191,6 +191,7 @@
int  errors;
u_int16_tindex;
int  linkstat;
+   u_intrdomain;
 };
 
 struct timeout {
Index: dispatch.c
===
RCS file: /cvs/src/sbin/dhclient/dispatch.c,v
retriev

usr.bin/cut errx correctness

2010-01-20 Thread Laurent Ghigonis
the -b option can cause those messages too

Index: usr.bin/cut/cut.c
===
RCS file: /cvs/src/usr.bin/cut/cut.c,v
retrieving revision 1.14
diff -u -r1.14 cut.c
--- usr.bin/cut/cut.c   27 Oct 2009 23:59:37 -  1.14
+++ usr.bin/cut/cut.c   20 Jan 2010 21:03:48 -
@@ -154,11 +154,11 @@
}
}
if (*p)
-   errx(1, "[-cf] list: illegal list value");
+   errx(1, "[-bcf] list: illegal list value");
if (!stop || !start)
-   errx(1, "[-cf] list: values may not include zero");
+   errx(1, "[-bcf] list: values may not include zero");
if (stop > _POSIX2_LINE_MAX)
-   errx(1, "[-cf] list: %d too large (max %d)",
+   errx(1, "[-bcf] list: %d too large (max %d)",
stop, _POSIX2_LINE_MAX);
if (maxval < stop)
maxval = stop;



faq13 little correction for aucat start at boot

2010-01-11 Thread Laurent Ghigonis
Index: faq13.html
===
RCS file: /cvs/www/faq/faq13.html,v
retrieving revision 1.134
diff -u faq13.html
--- faq13.html  30 Nov 2009 12:50:27 -  1.134
+++ faq13.html  11 Jan 2010 13:11:41 -
@@ -601,7 +601,7 @@
 for instance:
 
 
-nice -n -20 su -m mylogin aucat -l
+nice -n -20 su -m mylogin -c "aucat -l"
 
 
 The aucat(1) process cannot be shared between multiple users.



typo pf.conf.5

2009-05-29 Thread Laurent Ghigonis
Hi here :)

i guess i found a typo in the pf.conf man page, syntax section.

anyway, keep up the great work devs !
clean and simple ... love it

laurent


Index: share/man/man5/pf.conf.5
===
RCS file: /cvs/src/share/man/man5/pf.conf.5,v
retrieving revision 1.442
diff -u -r1.442 pf.conf.5
--- share/man/man5/pf.conf.51 May 2009 09:01:26 -   1.442
+++ share/man/man5/pf.conf.529 May 2009 20:40:25 -
@@ -2695,7 +2695,7 @@
 bandwidth-spec = "number" ( "b" | "Kb" | "Mb" | "Gb" | "%" )
 
 action = "pass" | "match" | "block" [ return ]
-return = "drop" | "return" | "return-rst" [ "( ttl" number ")" ] |
+return = "drop" | "return" | "return-rst" [ "(" ttl number ")" ] |
  "return-icmp" [ "(" icmpcode [ [ "," ] icmp6code ] ")" ] |
  "return-icmp6" [ "(" icmp6code ")" ]
 icmpcode   = ( icmp-code-name | icmp-code-number )