Re: ppp(8) cleanup/fix
Vijay Sankar wrote: Claudio Jeker wrote: So ppp(8) did insane routing message handling in its sysctl handlers. The worst thing about them are that their actually not needed and better replaced with libc functions (getifaddrs and if_nametoindex). This diff is not haevily tested (my last ppp usage is years ago) so I'm hopeing people with ppp(8) issues could give this a whirl and see if it fixes the problems. Hi, I built the kernel and userland from yesterday's cvsync and applied the patch. I tried for the past few hours to get connected to my ISP but unfortunately haven't been able to test the dial up ppp connection completely. However, FWIW here is my feedback. I got a dialup account from my ISP to test this out but I am not able to use a PCMCIA modem -- probably something I am doing is wrong but I don't unfortunately understand how to get over this hurdle. I tried a different server and a different modem puc0 at pci6 dev 0 function 0 "US Robotics 3CP5610" rev 0x01: ports: 1 com com3 at puc0 port 0 apic 2 int 20 (irq 5): ns16550a, 16 byte fifo The patched ppp works!! Thanks very much. PPP ON server10> show phy Name: deflink State: open (with carrier) Device: /dev/cua03 Link Type: interactive Connect Count: 1 Physical outq: 0 Queued Packets: 0 Phone Number:N/A Defaults: Device List: "/dev/cua03" Characteristics: 115200bps, cs8, no parity, CTS/RTS on CD check delay: device specific Connect time: 0:13:58 22886 octets in, 21505 octets out 1548 packets in, 279 packets out overall 52 bytes/sec currently 92 bytes/sec in, 91 bytes/sec out (over the last 5 secs) peak 341 bytes/sec on Thu Jul 2 22:20:55 2009 PPP ON server10> show bundle Phase Network Device:/dev/tun0 Interface: tun0 @ 115200bps, up time 0:13:33 Queued:1 of 30 Defaults: Label: Auth name: vsankar Diagnostic socket: none Choked Timer: 120s Radius config: none (not authenticated) Idle Timer:180s (179s remaining) Filter Decap: disabled ID check: enabled Iface-Alias: disabled IPCP: enabled IPV6CP:enabled Keep-Session: disabled Loopback: enabled PasswdAuth:disabled Proxy: disabled Proxyall: disabled Sticky Routes: enabled TCPMSS Fixup: enabled Throughput:enabled Utmp Logging: enabled NAS-IP-Address:enabled NAS-Identifier:enabled -- Vijay Sankar, M.Eng., P.Eng. ForeTell Technologies Limited 59 Flamingo Avenue, Winnipeg, MB, Canada R3J 0X6 Phone: (204) 885-9535, E-Mail: vsan...@foretell.ca
Re: ppp(8) cleanup/fix
Claudio Jeker wrote: So ppp(8) did insane routing message handling in its sysctl handlers. The worst thing about them are that their actually not needed and better replaced with libc functions (getifaddrs and if_nametoindex). This diff is not haevily tested (my last ppp usage is years ago) so I'm hopeing people with ppp(8) issues could give this a whirl and see if it fixes the problems. Hi, I built the kernel and userland from yesterday's cvsync and applied the patch. I tried for the past few hours to get connected to my ISP but unfortunately haven't been able to test the dial up ppp connection completely. However, FWIW here is my feedback. Before applying the patch, I got load averages: 1.64, 0.78, 0.33 09:41:55 36 processes: 1 running, 33 idle, 2 on processor CPU0 states: 100% user, 0.0% nice, 0.0% system, 0.0% interrupt, 0.0% idle CPU1 states: 100% user, 0.0% nice, 0.0% system, 0.0% interrupt, 0.0% idle Memory: Real: 24M/108M act/tot Free: 2906M Swap: 0K/4636M used/tot PID USERNAME PRI NICE SIZE RES STATE WAIT TIMECPU COMMAND 4421 root 640 784K 1336K run/0 - 3:14 99.12% ppp 14743 root 640 792K 1340K onproc/1 - 0:36 82.76% ppp 5203 _x11 20 6252K 12M sleep/0 select0:02 0.00% Xorg After the patch was applied, load averages: 1.31, 1.09, 0.57 12:45:15 39 processes: 38 idle, 1 on processor CPU0 states: 0.0% user, 0.0% nice, 0.0% system, 0.0% interrupt, 100% idle CPU1 states: 0.0% user, 0.0% nice, 0.0% system, 0.0% interrupt, 100% idle Memory: Real: 25M/111M act/tot Free: 2904M Swap: 0K/4636M used/tot I got a dialup account from my ISP to test this out but I am not able to use a PCMCIA modem -- probably something I am doing is wrong but I don't unfortunately understand how to get over this hurdle. From dmesg .. com3 at pcmcia0 function 0 "MEGAHERTZ, XJ2288, V.34 PCMCIA MODEM" port 0xa3f8/8: ns16550a, 16 byte fifo com3: probed fifo depth: 0 bytes However it used to work long time ago. I get the following in my logs Jul 2 12:42:25 builder ppp[14243]: Phase: Using interface: tun0 Jul 2 12:42:25 builder ppp[14243]: Phase: deflink: Created in closed state Jul 2 12:42:25 builder ppp[14243]: tun0: Command: default: set device /dev/cua03 Jul 2 12:42:25 builder ppp[14243]: tun0: Command: default: set speed 28800 Jul 2 12:42:25 builder ppp[14243]: tun0: Command: default: set dial ABORT BUSY ABORT NO\\sCARRIER TIMEOUT 5 "" AT OK-AT-OK ATE1Q0 OK \\dATDT\\T TIMEOUT 40 CONNECT Jul 2 12:42:25 builder ppp[14243]: tun0: Phase: PPP Started (interactive mode). Jul 2 12:42:46 builder ppp[14243]: tun0: Command: /dev/tty: dial mts Jul 2 12:42:46 builder ppp[14243]: tun0: Command: mts: set phone 2254638 Jul 2 12:42:46 builder ppp[14243]: tun0: Command: mts: set authname vsankar Jul 2 12:42:46 builder ppp[14243]: tun0: Command: mts: set authkey Jul 2 12:42:46 builder ppp[14243]: tun0: Command: mts: set login Jul 2 12:42:46 builder ppp[14243]: tun0: Command: mts: set timeout 120 Jul 2 12:42:46 builder ppp[14243]: tun0: Command: mts: set ifaddr 10.0.0.15/0 10.0.0.2/0 255.255.255.0 0.0.0.0 Jul 2 12:42:46 builder ppp[14243]: tun0: Command: mts: add default HISADDR Jul 2 12:42:46 builder ppp[14243]: tun0: Warning: Add route failed: 0.0.0.0/0 already exists Jul 2 12:42:46 builder ppp[14243]: tun0: Command: mts: enable dns Jul 2 12:42:46 builder ppp[14243]: tun0: Phase: bundle: Establish Jul 2 12:42:46 builder ppp[14243]: tun0: Phase: deflink: closed -> opening Jul 2 12:42:46 builder ppp[14243]: tun0: Phase: deflink: Connected! Jul 2 12:42:46 builder ppp[14243]: tun0: Phase: deflink: opening -> dial Jul 2 12:42:46 builder ppp[14243]: tun0: Chat: Phone: 2254638 Jul 2 12:42:46 builder ppp[14243]: tun0: Chat: deflink: Dial attempt 1 of 1 Jul 2 12:42:46 builder ppp[14243]: tun0: Chat: Send: AT\^M Jul 2 12:42:46 builder ppp[14243]: tun0: Chat: Expect(5): OK Jul 2 12:42:46 builder ppp[14243]: tun0: Chat: Received: AT\^M\^M Jul 2 12:42:46 builder ppp[14243]: tun0: Chat: Received: OK Jul 2 12:42:46 builder ppp[14243]: tun0: Chat: Send: ATE1Q0\^M Jul 2 12:42:46 builder ppp[14243]: tun0: Chat: Expect(5): OK Jul 2 12:42:46 builder ppp[14243]: tun0: Chat: Received: \^M Jul 2 12:42:51 builder ppp[14243]: tun0: Chat: Expect timeout Jul 2 12:42:51 builder ppp[14243]: tun0: Warning: Chat script failed Jul 2 12:42:51 builder ppp[14243]: tun0: Phase: deflink: dial -> hangup Jul 2 12:42:51 builder ppp[14243]: tun0: Phase: deflink: Disconnected! Jul 2 12:42:51 builder ppp[14243]: tun0: Phase: deflink: Connect time: 5 secs: 0 octets in, 0 octets out Jul 2 12:42:51 builder ppp[14243]: tun0: Phase: deflink: 0 packets in, 0 packets out Jul 2 12:42:51 builder ppp[14243]: tun0: Phase: total 0 bytes/sec, peak 0 bytes/sec on Thu Jul 2 12:42:46 2009 Jul 2 12:42:51 builder ppp[14243]: tun0: Phase
Re: ppp(8) cleanup/fix
On Wed, Jul 01, 2009 at 11:23:20AM -0500, Todd T. Fries wrote: > I tested this and it seems ppp in the tree is busted to the point of not > working without this diff. Same here. OpenBSD 4.6 (GENERIC) #40: Wed Jul 1 15:21:52 MDT 2009 dera...@i386.openbsd.org:/usr/src/sys/arch/i386/compile/GENERIC cpu0: Intel(R) Pentium(R) M processor 1.10GHz ("GenuineIntel" 686-class) 1.11 GHz [...] umsm0 at uhub2 port 2 configuration 1 interface 0 "Sierra Wireless, Incorporated Mini Card" rev 1.10/0.01 addr 2 ucom0 at umsm0
Re: ppp(8) cleanup/fix
It works! This is on my W500 Thinkpad with a Motorola V195 modem via usb. I'm happy. I do hope this gets into 4.6. --STeve Andre' On Wednesday 01 July 2009 12:23:20 Todd T. Fries wrote: > Guys, > > I tested this and it seems ppp in the tree is busted to the point of not > working without this diff. > > If you use ppp please test current snaps to confirm it is busted then > apply claudio's diff below and test again. > > If you use ppp and do not test, do not be surprised if it does not work in > the next release. > > Thanks, > > Penned by Claudio Jeker on 20090630 17:05.28, we have: > | So ppp(8) did insane routing message handling in its sysctl handlers. The > | worst thing about them are that their actually not needed and better > | replaced with libc functions (getifaddrs and if_nametoindex). > | > | This diff is not haevily tested (my last ppp usage is years ago) so I'm > | hopeing people with ppp(8) issues could give this a whirl and see if it > | fixes the problems. > | -- > | > | :wq Claudio > | > | Index: ppp/arp.c > | === > | RCS file: /cvs/src/usr.sbin/ppp/ppp/arp.c,v > | retrieving revision 1.15 > | diff -u -p -r1.15 arp.c > | --- ppp/arp.c 6 May 2008 06:34:10 - 1.15 > | +++ ppp/arp.c 30 Jun 2009 14:52:53 - > | @@ -38,6 +38,7 @@ > | #include > | > | #include > | +#include > | #include > | #include > | #include > | @@ -229,93 +230,58 @@ int > | arp_EtherAddr(int s, struct in_addr ipaddr, struct sockaddr_dl *hwaddr, > |int verbose) > | { > | - int mib[6], skip; > | - size_t needed; > | - char *buf, *ptr, *end; > | - struct if_msghdr *ifm; > | - struct ifa_msghdr *ifam; > | - struct sockaddr_dl *dl; > | - struct sockaddr *sa[RTAX_MAX]; > | - > | - mib[0] = CTL_NET; > | - mib[1] = PF_ROUTE; > | - mib[2] = 0; > | - mib[3] = 0; > | - mib[4] = NET_RT_IFLIST; > | - mib[5] = 0; > | - > | - if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) { > | -log_Printf(LogERROR, "arp_EtherAddr: sysctl: estimate: %s\n", > | - strerror(errno)); > | -return 0; > | - } > | - > | - if ((buf = malloc(needed)) == NULL) > | -return 0; > | + struct sockaddr_dl *dl = NULL; > | + struct ifaddrs *ifa, *ifap; > | + int skip = 1; > | > | - if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) { > | -free(buf); > | + if (getifaddrs(&ifap) != 0) { > | +log_Printf(LogERROR, "arp_EtherAddr: getifaddrs: %s\n", > | strerror(errno)); return 0; > |} > | - end = buf + needed; > | > | - ptr = buf; > | - while (ptr < end) { > | -ifm = (struct if_msghdr *)ptr; /* On if_msghdr */ > | -if (ifm->ifm_type != RTM_IFINFO) > | - break; > | -ptr += ifm->ifm_msglen; > | -if (ifm->ifm_version != RTM_VERSION) > | - continue; > | -dl = (struct sockaddr_dl *)(ifm + 1); /* Single _dl at end */ > | -skip = (ifm->ifm_flags & (IFF_UP | IFF_BROADCAST | IFF_POINTOPOINT | > | + for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) { > | +if (ifa->ifa_addr->sa_family == AF_LINK) { > | + dl = (struct sockaddr_dl *)ifa->ifa_addr; > | + skip = (ifa->ifa_flags & (IFF_UP | IFF_BROADCAST | IFF_POINTOPOINT > | | IFF_NOARP | IFF_LOOPBACK)) != (IFF_UP | IFF_BROADCAST); -while (ptr > | < end) { > | - ifam = (struct ifa_msghdr *)ptr; /* Next ifa_msghdr (alias) */ > | - if (ifam->ifam_type != RTM_NEWADDR) /* finished ? */ > | -break; > | - ptr += ifam->ifam_msglen; > | - if (ifam->ifam_version != RTM_VERSION) > | -continue; > | - if (skip || (ifam->ifam_addrs & (RTA_NETMASK|RTA_IFA)) != > | - (RTA_NETMASK|RTA_IFA)) > | -continue; > | - /* Found a candidate. Do the addresses match ? */ > | - if (log_IsKept(LogDEBUG) && > | - ptr == (char *)ifm + ifm->ifm_msglen + ifam->ifam_msglen) > | -log_Printf(LogDEBUG, "%.*s interface is a candidate for > | proxy\n", - dl->sdl_nlen, dl->sdl_data); > | - > | - iface_ParseHdr(ifam, sa); > | - > | - if (sa[RTAX_IFA]->sa_family == AF_INET) { > | -struct sockaddr_in *ifa, *netmask; > | - > | -ifa = (struct sockaddr_in *)sa[RTAX_IFA]; > | -netmask = (struct sockaddr_in *)sa[RTAX_NETMASK]; > | - > | -if (log_IsKept(LogDEBUG)) { > | - char a[16]; > | - > | - strncpy(a, inet_ntoa(netmask->sin_addr), sizeof a - 1); > | - a[sizeof a - 1] = '\0'; > | - log_Printf(LogDEBUG, "Check addr %s, mask %s\n", > | - inet_ntoa(ifa->sin_addr), a); > | -} > | - > | -if ((ifa->sin_addr.s_addr & netmask->sin_addr.s_addr) == > | -(ipaddr.s_addr & netmask->sin_addr.s_addr)) { > | - log_Printf(verbose ? LogPHASE : LogDEBUG, > | - "Found interface %.*s for %s\n", dl->sdl_nlen, > | - dl->sdl_data, inet_ntoa(ipaddr)); > | - memcpy(hwaddr, dl, dl->sdl_len)
Re: ppp(8) cleanup/fix
Sorry, that was i386 and amd64 with a german dsl provider. Dawe wrote: > Same story for me. > Without the patch ppp spins forever and eats all cpu. > With the patch ppp runs fine. > I'm pretty sure it worked for me with the Jun 21 snapshot.
Re: ppp(8) cleanup/fix
Works for me, amd64 to i386 using ppp-over-tcp. Like Claudio I don't use ppp(8) myself any more, but I'm testing it because this fix needs to go in, it would be nice if people who do actually use it test *right now*. Tomorrow may be too late for the fix to make it into 4.6.
Re: ppp(8) cleanup/fix
Same story for me. Without the patch ppp spins forever and eats all cpu. With the patch ppp runs fine. I'm pretty sure it worked for me with the Jun 21 snapshot. Mike Erdely wrote: > With prodding from Todd, I tested the diff on my macppc and my alpha. > Before the diff, running `ppp default` as root would hang before > presenting me with the interactive prompt. With the diff, it > immediately goes into interactive mode and presents me with the prompt. > > Unfortunately, I don't have another way to test. > > -ME > > On Wed, Jul 01, 2009 at 11:23:20AM -0500, Todd T. Fries wrote: >> Guys, >> >> I tested this and it seems ppp in the tree is busted to the point of not >> working without this diff. >> >> If you use ppp please test current snaps to confirm it is busted then >> apply claudio's diff below and test again. >> >> If you use ppp and do not test, do not be surprised if it does not work in >> the next release. >> >> Thanks, >> >> Penned by Claudio Jeker on 20090630 17:05.28, we have: >> | So ppp(8) did insane routing message handling in its sysctl handlers. The >> | worst thing about them are that their actually not needed and better >> | replaced with libc functions (getifaddrs and if_nametoindex). >> | >> | This diff is not haevily tested (my last ppp usage is years ago) so I'm >> | hopeing people with ppp(8) issues could give this a whirl and see if it >> | fixes the problems. >> | -- >> | :wq Claudio >> | >> | Index: ppp/arp.c >> | === >> | RCS file: /cvs/src/usr.sbin/ppp/ppp/arp.c,v >> | retrieving revision 1.15 >> | diff -u -p -r1.15 arp.c >> | --- ppp/arp.c 6 May 2008 06:34:10 - 1.15 >> | +++ ppp/arp.c 30 Jun 2009 14:52:53 - >> | @@ -38,6 +38,7 @@ >> | #include >> | >> | #include >> | +#include >> | #include >> | #include >> | #include >> | @@ -229,93 +230,58 @@ int >> | arp_EtherAddr(int s, struct in_addr ipaddr, struct sockaddr_dl *hwaddr, >> |int verbose) >> | { >> | - int mib[6], skip; >> | - size_t needed; >> | - char *buf, *ptr, *end; >> | - struct if_msghdr *ifm; >> | - struct ifa_msghdr *ifam; >> | - struct sockaddr_dl *dl; >> | - struct sockaddr *sa[RTAX_MAX]; >> | - >> | - mib[0] = CTL_NET; >> | - mib[1] = PF_ROUTE; >> | - mib[2] = 0; >> | - mib[3] = 0; >> | - mib[4] = NET_RT_IFLIST; >> | - mib[5] = 0; >> | - >> | - if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) { >> | -log_Printf(LogERROR, "arp_EtherAddr: sysctl: estimate: %s\n", >> | - strerror(errno)); >> | -return 0; >> | - } >> | - >> | - if ((buf = malloc(needed)) == NULL) >> | -return 0; >> | + struct sockaddr_dl *dl = NULL; >> | + struct ifaddrs *ifa, *ifap; >> | + int skip = 1; >> | >> | - if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) { >> | -free(buf); >> | + if (getifaddrs(&ifap) != 0) { >> | +log_Printf(LogERROR, "arp_EtherAddr: getifaddrs: %s\n", >> strerror(errno)); >> | return 0; >> |} >> | - end = buf + needed; >> | >> | - ptr = buf; >> | - while (ptr < end) { >> | -ifm = (struct if_msghdr *)ptr;/* On if_msghdr */ >> | -if (ifm->ifm_type != RTM_IFINFO) >> | - break; >> | -ptr += ifm->ifm_msglen; >> | -if (ifm->ifm_version != RTM_VERSION) >> | - continue; >> | -dl = (struct sockaddr_dl *)(ifm + 1); /* Single _dl at end */ >> | -skip = (ifm->ifm_flags & (IFF_UP | IFF_BROADCAST | IFF_POINTOPOINT | >> | + for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) { >> | +if (ifa->ifa_addr->sa_family == AF_LINK) { >> | + dl = (struct sockaddr_dl *)ifa->ifa_addr; >> | + skip = (ifa->ifa_flags & (IFF_UP | IFF_BROADCAST | IFF_POINTOPOINT | >> | IFF_NOARP | IFF_LOOPBACK)) != (IFF_UP | IFF_BROADCAST); >> | -while (ptr < end) { >> | - ifam = (struct ifa_msghdr *)ptr;/* Next ifa_msghdr (alias) */ >> | - if (ifam->ifam_type != RTM_NEWADDR) /* finished ? */ >> | -break; >> | - ptr += ifam->ifam_msglen; >> | - if (ifam->ifam_version != RTM_VERSION) >> | -continue; >> | - if (skip || (ifam->ifam_addrs & (RTA_NETMASK|RTA_IFA)) != >> | - (RTA_NETMASK|RTA_IFA)) >> | -continue; >> | - /* Found a candidate. Do the addresses match ? */ >> | - if (log_IsKept(LogDEBUG) && >> | - ptr == (char *)ifm + ifm->ifm_msglen + ifam->ifam_msglen) >> | -log_Printf(LogDEBUG, "%.*s interface is a candidate for proxy\n", >> | - dl->sdl_nlen, dl->sdl_data); >> | - >> | - iface_ParseHdr(ifam, sa); >> | - >> | - if (sa[RTAX_IFA]->sa_family == AF_INET) { >> | -struct sockaddr_in *ifa, *netmask; >> | - >> | -ifa = (struct sockaddr_in *)sa[RTAX_IFA]; >> | -netmask = (struct sockaddr_in *)sa[RTAX_NETMASK]; >> | - >> | -if (log_IsKept(LogDEBUG)) { >> | - char a[16]; >> | - >> | - strncpy(a, inet_ntoa(netmask->sin_addr), sizeof a - 1)
Re: ppp(8) cleanup/fix
With prodding from Todd, I tested the diff on my macppc and my alpha. Before the diff, running `ppp default` as root would hang before presenting me with the interactive prompt. With the diff, it immediately goes into interactive mode and presents me with the prompt. Unfortunately, I don't have another way to test. -ME On Wed, Jul 01, 2009 at 11:23:20AM -0500, Todd T. Fries wrote: > Guys, > > I tested this and it seems ppp in the tree is busted to the point of not > working without this diff. > > If you use ppp please test current snaps to confirm it is busted then > apply claudio's diff below and test again. > > If you use ppp and do not test, do not be surprised if it does not work in > the next release. > > Thanks, > > Penned by Claudio Jeker on 20090630 17:05.28, we have: > | So ppp(8) did insane routing message handling in its sysctl handlers. The > | worst thing about them are that their actually not needed and better > | replaced with libc functions (getifaddrs and if_nametoindex). > | > | This diff is not haevily tested (my last ppp usage is years ago) so I'm > | hopeing people with ppp(8) issues could give this a whirl and see if it > | fixes the problems. > | -- > | :wq Claudio > | > | Index: ppp/arp.c > | === > | RCS file: /cvs/src/usr.sbin/ppp/ppp/arp.c,v > | retrieving revision 1.15 > | diff -u -p -r1.15 arp.c > | --- ppp/arp.c 6 May 2008 06:34:10 - 1.15 > | +++ ppp/arp.c 30 Jun 2009 14:52:53 - > | @@ -38,6 +38,7 @@ > | #include > | > | #include > | +#include > | #include > | #include > | #include > | @@ -229,93 +230,58 @@ int > | arp_EtherAddr(int s, struct in_addr ipaddr, struct sockaddr_dl *hwaddr, > |int verbose) > | { > | - int mib[6], skip; > | - size_t needed; > | - char *buf, *ptr, *end; > | - struct if_msghdr *ifm; > | - struct ifa_msghdr *ifam; > | - struct sockaddr_dl *dl; > | - struct sockaddr *sa[RTAX_MAX]; > | - > | - mib[0] = CTL_NET; > | - mib[1] = PF_ROUTE; > | - mib[2] = 0; > | - mib[3] = 0; > | - mib[4] = NET_RT_IFLIST; > | - mib[5] = 0; > | - > | - if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) { > | -log_Printf(LogERROR, "arp_EtherAddr: sysctl: estimate: %s\n", > | - strerror(errno)); > | -return 0; > | - } > | - > | - if ((buf = malloc(needed)) == NULL) > | -return 0; > | + struct sockaddr_dl *dl = NULL; > | + struct ifaddrs *ifa, *ifap; > | + int skip = 1; > | > | - if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) { > | -free(buf); > | + if (getifaddrs(&ifap) != 0) { > | +log_Printf(LogERROR, "arp_EtherAddr: getifaddrs: %s\n", > strerror(errno)); > | return 0; > |} > | - end = buf + needed; > | > | - ptr = buf; > | - while (ptr < end) { > | -ifm = (struct if_msghdr *)ptr; /* On if_msghdr */ > | -if (ifm->ifm_type != RTM_IFINFO) > | - break; > | -ptr += ifm->ifm_msglen; > | -if (ifm->ifm_version != RTM_VERSION) > | - continue; > | -dl = (struct sockaddr_dl *)(ifm + 1); /* Single _dl at end */ > | -skip = (ifm->ifm_flags & (IFF_UP | IFF_BROADCAST | IFF_POINTOPOINT | > | + for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) { > | +if (ifa->ifa_addr->sa_family == AF_LINK) { > | + dl = (struct sockaddr_dl *)ifa->ifa_addr; > | + skip = (ifa->ifa_flags & (IFF_UP | IFF_BROADCAST | IFF_POINTOPOINT | > | IFF_NOARP | IFF_LOOPBACK)) != (IFF_UP | IFF_BROADCAST); > | -while (ptr < end) { > | - ifam = (struct ifa_msghdr *)ptr; /* Next ifa_msghdr (alias) */ > | - if (ifam->ifam_type != RTM_NEWADDR) /* finished ? */ > | -break; > | - ptr += ifam->ifam_msglen; > | - if (ifam->ifam_version != RTM_VERSION) > | -continue; > | - if (skip || (ifam->ifam_addrs & (RTA_NETMASK|RTA_IFA)) != > | - (RTA_NETMASK|RTA_IFA)) > | -continue; > | - /* Found a candidate. Do the addresses match ? */ > | - if (log_IsKept(LogDEBUG) && > | - ptr == (char *)ifm + ifm->ifm_msglen + ifam->ifam_msglen) > | -log_Printf(LogDEBUG, "%.*s interface is a candidate for proxy\n", > | - dl->sdl_nlen, dl->sdl_data); > | - > | - iface_ParseHdr(ifam, sa); > | - > | - if (sa[RTAX_IFA]->sa_family == AF_INET) { > | -struct sockaddr_in *ifa, *netmask; > | - > | -ifa = (struct sockaddr_in *)sa[RTAX_IFA]; > | -netmask = (struct sockaddr_in *)sa[RTAX_NETMASK]; > | - > | -if (log_IsKept(LogDEBUG)) { > | - char a[16]; > | - > | - strncpy(a, inet_ntoa(netmask->sin_addr), sizeof a - 1); > | - a[sizeof a - 1] = '\0'; > | - log_Printf(LogDEBUG, "Check addr %s, mask %s\n", > | - inet_ntoa(ifa->sin_addr), a); > | -} > | - > | -if ((ifa->sin_addr.s_addr & netmask->sin_addr.s_addr) == > | -(ipaddr.s_addr & netmask->sin_addr.s_addr)) { > | -
Re: ppp(8) cleanup/fix
Guys, I tested this and it seems ppp in the tree is busted to the point of not working without this diff. If you use ppp please test current snaps to confirm it is busted then apply claudio's diff below and test again. If you use ppp and do not test, do not be surprised if it does not work in the next release. Thanks, Penned by Claudio Jeker on 20090630 17:05.28, we have: | So ppp(8) did insane routing message handling in its sysctl handlers. The | worst thing about them are that their actually not needed and better | replaced with libc functions (getifaddrs and if_nametoindex). | | This diff is not haevily tested (my last ppp usage is years ago) so I'm | hopeing people with ppp(8) issues could give this a whirl and see if it | fixes the problems. | -- | :wq Claudio | | Index: ppp/arp.c | === | RCS file: /cvs/src/usr.sbin/ppp/ppp/arp.c,v | retrieving revision 1.15 | diff -u -p -r1.15 arp.c | --- ppp/arp.c 6 May 2008 06:34:10 - 1.15 | +++ ppp/arp.c 30 Jun 2009 14:52:53 - | @@ -38,6 +38,7 @@ | #include | | #include | +#include | #include | #include | #include | @@ -229,93 +230,58 @@ int | arp_EtherAddr(int s, struct in_addr ipaddr, struct sockaddr_dl *hwaddr, |int verbose) | { | - int mib[6], skip; | - size_t needed; | - char *buf, *ptr, *end; | - struct if_msghdr *ifm; | - struct ifa_msghdr *ifam; | - struct sockaddr_dl *dl; | - struct sockaddr *sa[RTAX_MAX]; | - | - mib[0] = CTL_NET; | - mib[1] = PF_ROUTE; | - mib[2] = 0; | - mib[3] = 0; | - mib[4] = NET_RT_IFLIST; | - mib[5] = 0; | - | - if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) { | -log_Printf(LogERROR, "arp_EtherAddr: sysctl: estimate: %s\n", | - strerror(errno)); | -return 0; | - } | - | - if ((buf = malloc(needed)) == NULL) | -return 0; | + struct sockaddr_dl *dl = NULL; | + struct ifaddrs *ifa, *ifap; | + int skip = 1; | | - if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) { | -free(buf); | + if (getifaddrs(&ifap) != 0) { | +log_Printf(LogERROR, "arp_EtherAddr: getifaddrs: %s\n", strerror(errno)); | return 0; |} | - end = buf + needed; | | - ptr = buf; | - while (ptr < end) { | -ifm = (struct if_msghdr *)ptr; /* On if_msghdr */ | -if (ifm->ifm_type != RTM_IFINFO) | - break; | -ptr += ifm->ifm_msglen; | -if (ifm->ifm_version != RTM_VERSION) | - continue; | -dl = (struct sockaddr_dl *)(ifm + 1);/* Single _dl at end */ | -skip = (ifm->ifm_flags & (IFF_UP | IFF_BROADCAST | IFF_POINTOPOINT | | + for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) { | +if (ifa->ifa_addr->sa_family == AF_LINK) { | + dl = (struct sockaddr_dl *)ifa->ifa_addr; | + skip = (ifa->ifa_flags & (IFF_UP | IFF_BROADCAST | IFF_POINTOPOINT | | IFF_NOARP | IFF_LOOPBACK)) != (IFF_UP | IFF_BROADCAST); | -while (ptr < end) { | - ifam = (struct ifa_msghdr *)ptr; /* Next ifa_msghdr (alias) */ | - if (ifam->ifam_type != RTM_NEWADDR)/* finished ? */ | -break; | - ptr += ifam->ifam_msglen; | - if (ifam->ifam_version != RTM_VERSION) | -continue; | - if (skip || (ifam->ifam_addrs & (RTA_NETMASK|RTA_IFA)) != | - (RTA_NETMASK|RTA_IFA)) | -continue; | - /* Found a candidate. Do the addresses match ? */ | - if (log_IsKept(LogDEBUG) && | - ptr == (char *)ifm + ifm->ifm_msglen + ifam->ifam_msglen) | -log_Printf(LogDEBUG, "%.*s interface is a candidate for proxy\n", | - dl->sdl_nlen, dl->sdl_data); | - | - iface_ParseHdr(ifam, sa); | - | - if (sa[RTAX_IFA]->sa_family == AF_INET) { | -struct sockaddr_in *ifa, *netmask; | - | -ifa = (struct sockaddr_in *)sa[RTAX_IFA]; | -netmask = (struct sockaddr_in *)sa[RTAX_NETMASK]; | - | -if (log_IsKept(LogDEBUG)) { | - char a[16]; | - | - strncpy(a, inet_ntoa(netmask->sin_addr), sizeof a - 1); | - a[sizeof a - 1] = '\0'; | - log_Printf(LogDEBUG, "Check addr %s, mask %s\n", | - inet_ntoa(ifa->sin_addr), a); | -} | - | -if ((ifa->sin_addr.s_addr & netmask->sin_addr.s_addr) == | -(ipaddr.s_addr & netmask->sin_addr.s_addr)) { | - log_Printf(verbose ? LogPHASE : LogDEBUG, | - "Found interface %.*s for %s\n", dl->sdl_nlen, | - dl->sdl_data, inet_ntoa(ipaddr)); | - memcpy(hwaddr, dl, dl->sdl_len); | - free(buf); | - return 1; | -} | + continue; | +} | +if (skip) | + /* Skip unusable interface */ | + continue; | + | +/* Found a candidate. Do the addresses match ? */ | +if (log_IsKept(LogDEBUG)) | + log_Printf(LogDEBUG, "%.*s interface is a candidate for proxy\n", | +dl->sdl_nlen, dl->sdl_data); | + | +if (ifa->ifa_addr->sa_family == AF_I
Re: ppp(8) cleanup/fix
Checking through all the per-arch disk drivers to see which are missing DIOCGPDINFO: /sys/arch/hp300/dev/hd.c: case DIOCGPDINFO: /sys/arch/hp300/dev/hd.c: case DIOCGDINFO: no problem. /sys/arch/sparc/dev/fd.c: case DIOCGPDINFO: /sys/arch/sparc/dev/fd.c: case DIOCGDINFO: no problem. /sys/arch/sparc/dev/presto.c: case DIOCGDINFO: missing /sys/arch/sparc/dev/xd.c: case DIOCGDINFO:/* get disk label */ missing /sys/arch/sparc/dev/xy.c: case DIOCGDINFO:/* get disk label */ missing /sys/arch/sparc64/dev/fd.c: case DIOCGPDINFO: /sys/arch/sparc64/dev/fd.c: case DIOCGDINFO: ok /sys/arch/vax/mba/hp.c: caseDIOCGDINFO: missing /sys/arch/vax/mscp/mscp_disk.c: case DIOCGDINFO: /sys/arch/vax/mscp/mscp_disk.c: case DIOCGDINFO: missing /sys/arch/vax/vsa/hdc9224.c:case DIOCGDINFO: missing Basically all of those drivers fetch their labels at the start and keep them, and have not moved to the new mode of having an xxgetdisklabel() function with a 4th argument which indicates spoofing or not. As a result, they also cannot clear their disklabel, I think.
ppp(8) cleanup/fix
So ppp(8) did insane routing message handling in its sysctl handlers. The worst thing about them are that their actually not needed and better replaced with libc functions (getifaddrs and if_nametoindex). This diff is not haevily tested (my last ppp usage is years ago) so I'm hopeing people with ppp(8) issues could give this a whirl and see if it fixes the problems. -- :wq Claudio Index: ppp/arp.c === RCS file: /cvs/src/usr.sbin/ppp/ppp/arp.c,v retrieving revision 1.15 diff -u -p -r1.15 arp.c --- ppp/arp.c 6 May 2008 06:34:10 - 1.15 +++ ppp/arp.c 30 Jun 2009 14:52:53 - @@ -38,6 +38,7 @@ #include #include +#include #include #include #include @@ -229,93 +230,58 @@ int arp_EtherAddr(int s, struct in_addr ipaddr, struct sockaddr_dl *hwaddr, int verbose) { - int mib[6], skip; - size_t needed; - char *buf, *ptr, *end; - struct if_msghdr *ifm; - struct ifa_msghdr *ifam; - struct sockaddr_dl *dl; - struct sockaddr *sa[RTAX_MAX]; - - mib[0] = CTL_NET; - mib[1] = PF_ROUTE; - mib[2] = 0; - mib[3] = 0; - mib[4] = NET_RT_IFLIST; - mib[5] = 0; - - if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) { -log_Printf(LogERROR, "arp_EtherAddr: sysctl: estimate: %s\n", - strerror(errno)); -return 0; - } - - if ((buf = malloc(needed)) == NULL) -return 0; + struct sockaddr_dl *dl = NULL; + struct ifaddrs *ifa, *ifap; + int skip = 1; - if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) { -free(buf); + if (getifaddrs(&ifap) != 0) { +log_Printf(LogERROR, "arp_EtherAddr: getifaddrs: %s\n", strerror(errno)); return 0; } - end = buf + needed; - ptr = buf; - while (ptr < end) { -ifm = (struct if_msghdr *)ptr; /* On if_msghdr */ -if (ifm->ifm_type != RTM_IFINFO) - break; -ptr += ifm->ifm_msglen; -if (ifm->ifm_version != RTM_VERSION) - continue; -dl = (struct sockaddr_dl *)(ifm + 1); /* Single _dl at end */ -skip = (ifm->ifm_flags & (IFF_UP | IFF_BROADCAST | IFF_POINTOPOINT | + for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) { +if (ifa->ifa_addr->sa_family == AF_LINK) { + dl = (struct sockaddr_dl *)ifa->ifa_addr; + skip = (ifa->ifa_flags & (IFF_UP | IFF_BROADCAST | IFF_POINTOPOINT | IFF_NOARP | IFF_LOOPBACK)) != (IFF_UP | IFF_BROADCAST); -while (ptr < end) { - ifam = (struct ifa_msghdr *)ptr; /* Next ifa_msghdr (alias) */ - if (ifam->ifam_type != RTM_NEWADDR) /* finished ? */ -break; - ptr += ifam->ifam_msglen; - if (ifam->ifam_version != RTM_VERSION) -continue; - if (skip || (ifam->ifam_addrs & (RTA_NETMASK|RTA_IFA)) != - (RTA_NETMASK|RTA_IFA)) -continue; - /* Found a candidate. Do the addresses match ? */ - if (log_IsKept(LogDEBUG) && - ptr == (char *)ifm + ifm->ifm_msglen + ifam->ifam_msglen) -log_Printf(LogDEBUG, "%.*s interface is a candidate for proxy\n", - dl->sdl_nlen, dl->sdl_data); - - iface_ParseHdr(ifam, sa); - - if (sa[RTAX_IFA]->sa_family == AF_INET) { -struct sockaddr_in *ifa, *netmask; - -ifa = (struct sockaddr_in *)sa[RTAX_IFA]; -netmask = (struct sockaddr_in *)sa[RTAX_NETMASK]; - -if (log_IsKept(LogDEBUG)) { - char a[16]; - - strncpy(a, inet_ntoa(netmask->sin_addr), sizeof a - 1); - a[sizeof a - 1] = '\0'; - log_Printf(LogDEBUG, "Check addr %s, mask %s\n", - inet_ntoa(ifa->sin_addr), a); -} - -if ((ifa->sin_addr.s_addr & netmask->sin_addr.s_addr) == -(ipaddr.s_addr & netmask->sin_addr.s_addr)) { - log_Printf(verbose ? LogPHASE : LogDEBUG, - "Found interface %.*s for %s\n", dl->sdl_nlen, - dl->sdl_data, inet_ntoa(ipaddr)); - memcpy(hwaddr, dl, dl->sdl_len); - free(buf); - return 1; -} + continue; +} +if (skip) + /* Skip unusable interface */ + continue; + +/* Found a candidate. Do the addresses match ? */ +if (log_IsKept(LogDEBUG)) + log_Printf(LogDEBUG, "%.*s interface is a candidate for proxy\n", +dl->sdl_nlen, dl->sdl_data); + +if (ifa->ifa_addr->sa_family == AF_INET) { + struct sockaddr_in *addr, *netmask; + + addr = (struct sockaddr_in *)ifa->ifa_addr; + netmask = (struct sockaddr_in *)ifa->ifa_netmask; + + if (log_IsKept(LogDEBUG)) { +char a[16]; + +strncpy(a, inet_ntoa(netmask->sin_addr), sizeof a - 1); +a[sizeof a - 1] = '\0'; +log_Printf(LogDEBUG, "Check addr %s, mask %s\n", + inet_ntoa(addr->sin_addr), a); + } + + if ((addr->sin_addr.s_addr & netmask->sin_addr.s_addr) == + (ipaddr.s_addr & netmask->sin_addr.s_addr)) { +log_Printf(verbose ? LogPHASE : LogDEBUG, + "Found inte