Re: Introduce if_rtrequest()

2015-10-25 Thread Claudio Jeker
On Sat, Oct 24, 2015 at 06:22:10PM +0200, Martin Pieuchot wrote:
> On 24/10/15(Sat) 18:01, Martin Pieuchot wrote:
> > Revamping the network stack design continue here at u2k15... 
> > 
> > This times it's about the L2 resolution mechanism plugged into the
> > routing table.  While discussing with Alexander we figured out that
> > the actual ifa_rtrequest() is always called with a valid ``ifp''...
> > 
> > So this diff change this function into a per-ifp one an pass an ifp
> > pointer as first argument.  This makes obvious that if_get/if_put is
> > not needed there.
> > 
> > As a side effect arp_ifinit() can now die since every Ethernet driver
> > initialize if_rtrequest in ether_ifattach().
> 
> Now with a dummy function as suggested by Claudio.
> 
> ok?

I like this. Two comments inline.
Anyway, OK claudio
 
> Index: net/if.c
> ===
> RCS file: /cvs/src/sys/net/if.c,v
> retrieving revision 1.394
> diff -u -p -r1.394 if.c
> --- net/if.c  24 Oct 2015 10:52:05 -  1.394
> +++ net/if.c  24 Oct 2015 16:19:49 -
> @@ -520,6 +520,7 @@ if_attach_common(struct ifnet *ifp)
>   M_TEMP, M_WAITOK);
>   TAILQ_INIT(ifp->if_detachhooks);
>  
> + ifp->if_rtrequest = if_rtrequest_dummy;
>   ifp->if_slowtimo = malloc(sizeof(*ifp->if_slowtimo), M_TEMP,
>   M_WAITOK|M_ZERO);
>   ifp->if_watchdogtask = malloc(sizeof(*ifp->if_watchdogtask),
> @@ -1273,14 +1274,18 @@ ifaof_ifpforaddr(struct sockaddr *addr, 
>   return (ifa_maybe);
>  }
>  
> +void
> +if_rtrequest_dummy(struct ifnet *ifp, int req, struct rtentry *rt)
> +{
> +}
> +
>  /*
>   * Default action when installing a local route on a point-to-point
>   * interface.
>   */
>  void
> -p2p_rtrequest(int req, struct rtentry *rt)
> +p2p_rtrequest(struct ifnet *ifp, int req, struct rtentry *rt)
>  {
> - struct ifnet *ifp = rt->rt_ifp;
>   struct ifaddr *ifa, *lo0ifa;
>  
>   switch (req) {
> Index: net/if_ethersubr.c
> ===
> RCS file: /cvs/src/sys/net/if_ethersubr.c,v
> retrieving revision 1.229
> diff -u -p -r1.229 if_ethersubr.c
> --- net/if_ethersubr.c22 Oct 2015 15:37:47 -  1.229
> +++ net/if_ethersubr.c24 Oct 2015 16:19:49 -
> @@ -161,6 +161,23 @@ ether_ioctl(struct ifnet *ifp, struct ar
>   return (error);
>  }
>  
> +
> +void
> +ether_rtrequest(struct ifnet *ifp, int req, struct rtentry *rt)
> +{
> + switch (rt_key(rt)->sa_family) {
> + case AF_INET:
> + arp_rtrequest(ifp, req, rt);
> + break;
> +#ifdef INET6
> + case AF_INET6:
> + nd6_rtrequest(ifp, req, rt);
> + break;
> +#endif
> + default:
> + break;
> + }
> +}
>  /*
>   * Ethernet output routine.
>   * Encapsulate a packet of type family for the local net.
> @@ -505,6 +522,7 @@ ether_ifattach(struct ifnet *ifp)
>   ifp->if_hdrlen = ETHER_HDR_LEN;
>   ifp->if_mtu = ETHERMTU;
>   ifp->if_output = ether_output;
> + ifp->if_rtrequest = ether_rtrequest;
>  
>   if_ih_insert(ifp, ether_input, NULL);
>  
> Index: net/if_gif.c
> ===
> RCS file: /cvs/src/sys/net/if_gif.c,v
> retrieving revision 1.80
> diff -u -p -r1.80 if_gif.c
> --- net/if_gif.c  28 Sep 2015 08:32:05 -  1.80
> +++ net/if_gif.c  24 Oct 2015 16:19:49 -
> @@ -120,6 +120,7 @@ gif_clone_create(struct if_clone *ifc, i
>   sc->gif_if.if_ioctl  = gif_ioctl;
>   sc->gif_if.if_start  = gif_start;
>   sc->gif_if.if_output = gif_output;
> + sc->gif_if.if_rtrequest = p2p_rtrequest;
>   sc->gif_if.if_type   = IFT_GIF;
>   IFQ_SET_MAXLEN(>gif_if.if_snd, IFQ_MAXLEN);
>   IFQ_SET_READY(>gif_if.if_snd);
> @@ -326,7 +327,6 @@ gif_ioctl(struct ifnet *ifp, u_long cmd,
>  {
>   struct gif_softc *sc  = (struct gif_softc*)ifp;
>   struct ifreq *ifr = (struct ifreq *)data;
> - struct ifaddr*ifa = (struct ifaddr *)data;
>   int error = 0, size;
>   struct sockaddr *dst, *src;
>   struct sockaddr *sa;
> @@ -335,7 +335,6 @@ gif_ioctl(struct ifnet *ifp, u_long cmd,
>  
>   switch (cmd) {
>   case SIOCSIFADDR:
> - ifa->ifa_rtrequest = p2p_rtrequest;
>   break;
>  
>   case SIOCSIFDSTADDR:
> Index: net/if_gre.c
> ===
> RCS file: /cvs/src/sys/net/if_gre.c,v
> retrieving revision 1.75
> diff -u -p -r1.75 if_gre.c
> --- net/if_gre.c  16 Jul 2015 16:12:15 -  1.75
> +++ net/if_gre.c  24 Oct 2015 16:19:49 -
> @@ -132,6 +132,7 @@ gre_clone_create(struct if_clone *ifc, i
>   sc->sc_if.if_flags = IFF_POINTOPOINT|IFF_MULTICAST;
>   sc->sc_if.if_output = gre_output;
>   sc->sc_if.if_ioctl = gre_ioctl;
> + sc->sc_if.if_rtrequest = p2p_rtrequest;
>   sc->sc_if.if_collisions = 0;
>   sc->sc_if.if_ierrors = 

Re: rt_missmsg takes interface index

2015-10-25 Thread Claudio Jeker
On Sat, Oct 24, 2015 at 07:04:52PM +0200, Alexander Bluhm wrote:
> Hi,
> 
> Instead of doing the the if_get() dance for rt_missmsg(), change the
> function to take an interface index.
> 
> ok?

Yes
 
> bluhm
> 
> Index: net/route.c
> ===
> RCS file: /data/mirror/openbsd/cvs/src/sys/net/route.c,v
> retrieving revision 1.260
> diff -u -p -r1.260 route.c
> --- net/route.c   24 Oct 2015 11:58:46 -  1.260
> +++ net/route.c   24 Oct 2015 16:55:36 -
> @@ -235,7 +235,7 @@ rtalloc(struct sockaddr *dst, int flags,
>   rtstat.rts_unreach++;
>  miss:
>   if (ISSET(flags, RT_REPORT))
> - rt_missmsg(RTM_MISS, , 0, NULL, error, tableid);
> + rt_missmsg(RTM_MISS, , 0, 0, error, tableid);
>   }
>   KERNEL_UNLOCK();
>   splx(s);
> @@ -398,7 +398,7 @@ rt_sendmsg(struct rtentry *rt, int cmd, 
>   info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr;
>   }
>  
> - rt_missmsg(cmd, , rt->rt_flags, ifp, 0, rtableid);
> + rt_missmsg(cmd, , rt->rt_flags, rt->rt_ifidx, 0, rtableid);
>   if_put(ifp);
>  }
>  
> @@ -431,7 +431,7 @@ rtredirect(struct sockaddr *dst, struct 
>   u_int32_t   *stat = NULL;
>   struct rt_addrinfo   info;
>   struct ifaddr   *ifa;
> - struct ifnet*ifp = NULL;
> + unsigned int ifidx;
>  
>   splsoftassert(IPL_SOFTNET);
>  
> @@ -440,7 +440,7 @@ rtredirect(struct sockaddr *dst, struct 
>   error = ENETUNREACH;
>   goto out;
>   }
> - ifp = ifa->ifa_ifp;
> + ifidx = ifa->ifa_ifp->if_index;
>   rt = rtalloc(dst, 0, rdomain);
>   /*
>* If the redirect isn't from our current router for this dst,
> @@ -521,7 +521,7 @@ out:
>   info.rti_info[RTAX_GATEWAY] = gateway;
>   info.rti_info[RTAX_NETMASK] = netmask;
>   info.rti_info[RTAX_AUTHOR] = src;
> - rt_missmsg(RTM_REDIRECT, , flags, ifp, error, rdomain);
> + rt_missmsg(RTM_REDIRECT, , flags, ifidx, error, rdomain);
>  }
>  
>  /*
> @@ -532,7 +532,7 @@ rtdeletemsg(struct rtentry *rt, u_int ta
>  {
>   int error;
>   struct rt_addrinfo  info;
> - struct ifnet*ifp;
> + unsigned intifidx;
>  
>   /*
>* Request the new route so that the entry is not actually
> @@ -544,12 +544,11 @@ rtdeletemsg(struct rtentry *rt, u_int ta
>   info.rti_info[RTAX_NETMASK] = rt_mask(rt);
>   info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
>   info.rti_flags = rt->rt_flags;
> - ifp = if_get(rt->rt_ifidx);
> + ifidx = rt->rt_ifidx;
>   error = rtrequest1(RTM_DELETE, , rt->rt_priority, , tableid);
> - rt_missmsg(RTM_DELETE, , info.rti_flags, ifp, error, tableid);
> + rt_missmsg(RTM_DELETE, , info.rti_flags, ifidx, error, tableid);
>   if (error == 0)
>   rtfree(rt);
> - if_put(ifp);
>   return (error);
>  }
>  
> Index: net/route.h
> ===
> RCS file: /data/mirror/openbsd/cvs/src/sys/net/route.h,v
> retrieving revision 1.116
> diff -u -p -r1.116 route.h
> --- net/route.h   24 Oct 2015 11:47:07 -  1.116
> +++ net/route.h   24 Oct 2015 16:38:15 -
> @@ -357,8 +357,7 @@ void   rt_maskedcopy(struct sockaddr *,
>   struct sockaddr *, struct sockaddr *);
>  void  rt_sendmsg(struct rtentry *, int, u_int);
>  void  rt_sendaddrmsg(struct rtentry *, int);
> -void  rt_missmsg(int, struct rt_addrinfo *, int, struct ifnet *, int,
> - u_int);
> +void  rt_missmsg(int, struct rt_addrinfo *, int, u_int, int, u_int);
>  int   rt_setgate(struct rtentry *, struct sockaddr *, unsigned int);
>  int   rt_checkgate(struct ifnet *, struct rtentry *, struct sockaddr *,
>   unsigned int, struct rtentry **);
> Index: net/rtsock.c
> ===
> RCS file: /data/mirror/openbsd/cvs/src/sys/net/rtsock.c,v
> retrieving revision 1.176
> diff -u -p -r1.176 rtsock.c
> --- net/rtsock.c  24 Oct 2015 11:58:47 -  1.176
> +++ net/rtsock.c  24 Oct 2015 16:37:27 -
> @@ -1075,8 +1075,8 @@ again:
>   * destination.
>   */
>  void
> -rt_missmsg(int type, struct rt_addrinfo *rtinfo, int flags,
> -struct ifnet *ifp, int error, u_int tableid)
> +rt_missmsg(int type, struct rt_addrinfo *rtinfo, int flags, u_int ifidx,
> +int error, u_int tableid)
>  {
>   struct rt_msghdr*rtm;
>   struct mbuf *m;
> @@ -1092,8 +1092,7 @@ rt_missmsg(int type, struct rt_addrinfo 
>   rtm->rtm_errno = error;
>   rtm->rtm_tableid = tableid;
>   rtm->rtm_addrs = rtinfo->rti_addrs;
> - if (ifp != NULL)
> - rtm->rtm_index = ifp->if_index;
> + rtm->rtm_index = ifidx;
>   if (sa == NULL)
>   route_proto.sp_protocol = 0;
>   else
> Index: 

Re: telnet: kill dead IP source route

2015-10-25 Thread Philip Guenther
On Sat, Oct 24, 2015 at 9:08 AM, Jérémie Courrèges-Anglas
 wrote:
> until today I did not know that some of our code did check for IP SSRR
> and LSRR IP options in incoming packets.
>
> That made me look for software that tried to use these options in
> outgoing packets.  That code, in telnet(1), has been broken since 1998,
> says cvs log.  I doubt that anyone will miss it.
>
> Also stop mentioning source route in the manpage.
>
> ok?

ok guenther@



documenting multiple standards

2015-10-25 Thread Anthony J. Bentley
>From wcrtomb(3):

 The wcrtomb() function conforms to ISO/IEC 9899/AMD1:1995 (``ISO C90,
 Amendment 1'').  The restrict qualifier is added at ISO/IEC 9899/1999
 (``ISO C99'').

This wording is confusing. Is it implying that we don't use a restrict
qualifier? (We do.)

If a standard changes, do we have to document how the old standard
differs from what we currently follow? That seems awfully complicated.
Can we just document the latest standard, or "the earliest standard
that doesn't appreciably differ from the latest standard"?

What's the guiding practice here?



Re: documenting multiple standards

2015-10-25 Thread Philip Guenther
On Sun, Oct 25, 2015 at 12:58 AM, Anthony J. Bentley  wrote:
> From wcrtomb(3):
>
>  The wcrtomb() function conforms to ISO/IEC 9899/AMD1:1995 (``ISO C90,
>  Amendment 1'').  The restrict qualifier is added at ISO/IEC 9899/1999
>  (``ISO C99'').
>
> This wording is confusing. Is it implying that we don't use a restrict
> qualifier? (We do.)
>
> If a standard changes, do we have to document how the old standard
> differs from what we currently follow? That seems awfully complicated.
> Can we just document the latest standard, or "the earliest standard
> that doesn't appreciably differ from the latest standard"?
>
> What's the guiding practice here?

I agree.



Re: documenting multiple standards

2015-10-25 Thread Jason McIntyre
On Sun, Oct 25, 2015 at 01:58:21AM -0600, Anthony J. Bentley wrote:
> >From wcrtomb(3):
> 
>  The wcrtomb() function conforms to ISO/IEC 9899/AMD1:1995 (``ISO C90,
>  Amendment 1'').  The restrict qualifier is added at ISO/IEC 9899/1999
>  (``ISO C99'').
> 
> This wording is confusing. Is it implying that we don't use a restrict
> qualifier? (We do.)
> 
> If a standard changes, do we have to document how the old standard
> differs from what we currently follow? That seems awfully complicated.
> Can we just document the latest standard, or "the earliest standard
> that doesn't appreciably differ from the latest standard"?
> 
> What's the guiding practice here?
> 

common sense ;)

we have a very consistent text for STANDARDS in userland. but the stuff
in sections 2 and 3 have been added bit by bit, so there's a lot of
differences.

in the text for wcrtomb.3, it does look like DESCRIPTION needs updating
to document "restrict". but the text in STANDARDS is not trying to say
restrict was added later but unsupported by us. you could look at
changing that text, but it'd be best if it were done consistently across
sections 2 and 3, not just for one page.

there is no attempt to document differences in previous standards.
really you just want to note whether something is relevant to a (recent)
standard, broadly whether our implementation conforms, and broadly how
our implementation differs. it's a time consuming exercise.

jmc



Re: documenting multiple standards

2015-10-25 Thread Theo de Raadt
>>From wcrtomb(3):
>
> The wcrtomb() function conforms to ISO/IEC 9899/AMD1:1995 (``ISO C90,
> Amendment 1'').  The restrict qualifier is added at ISO/IEC 9899/1999
> (``ISO C99'').
>
>This wording is confusing. Is it implying that we don't use a restrict
>qualifier? (We do.)
>
>If a standard changes, do we have to document how the old standard
>differs from what we currently follow? That seems awfully complicated.
>Can we just document the latest standard, or "the earliest standard
>that doesn't appreciably differ from the latest standard"?
>
>What's the guiding practice here?

Man pages should documnet what people need, trying to avoid ambiguity
or overpreciseness.  True or false:

The wcrtomb() function conforms to ISO/IEC 9899/1999 (``ISO C99'').



Re: [patch] tcpdump - better BGP UPDATE AS_PATH size calculations

2015-10-25 Thread Claudio Jeker
On Sat, Oct 24, 2015 at 12:37:44PM -0600, Kevin Reay wrote:
> Adopt an updated version of the tcpdump.org ASN size calculation for
> BGP UPDATE message AS_PATHs. This corrects some bad behaviour due to
> incorrect ASN size calculations.
> 
> I believe that the current way of calculating the ASN size for an
> UPDATE AS_PATH attribute is flawed.
> 
> Currently, the ASN length (2 or 4 bytes) is calculated by dividing the
> total length of the AS_PATH attribute by the number of ASNs (p[1]) in
> the *first set encountered*:
> 
>   asn_bytes = (len-2)/p[1];
> 
> The assumption that this first segment length describes the entire
> attribute is incorrect; there could be multiple path segment lengths
> in the attribute. The current method only uses the first encountered
> segment length (while using the entire attribute's byte length).
> 
> This very often works fine, and when the calculation is incorrect the
> printf code only prints the first 2 bytes due to the way the if
> statements are structured, so it usually appears to work. 
> 
> (Sometimes the calculated ASN length isn't even 2 or 4 bytes, often
> causing 2 separate ASNs to be printed together as one ASN in ASDOT
> notation.)
> 
> Example: here's the original OpenBSD output for a 2-byte encoded
> AS_PATH:
>   (AS_PATH[T] 30)
> here's tcpdump.org 4.5.1 on Linux:
>   AS Path (2), length: 10, Flags [T]: 30 { 10 20 }
> and here's OpenBSD with the changes in this patch:
>   (AS_PATH[T] 30 {10 20})
> 
> A comment in the original code claims:
>  ...
>  * To identify which is the case, compare the length of the path
>  * segment value in bytes, with the path segment length from the
>  * message (counted in # of AS)
> 
> This incorrectly describes the calculation being performed; the length
> being compared isn't just the length of the "path segment value" but of
> the entire attribute.
> 
> I've attached an updated version of the upstream's heuristics function
> for calculating the ASN size: bgp_attr_get_as_size(). The updated
> version contains style(9) changes, simplifications, an additional
> validity check (non-zero segment lengths), and comment re-writes.
> 
> I'm interested in hearing any feedback. I'm also interested if anyone
> with experience using tcpdump with BGP packets can report seeing the
> incorrect behaviour described here in the past.
> 

> Index: print-bgp.c
> ===
> RCS file: /cvs/src/usr.sbin/tcpdump/print-bgp.c,v
> retrieving revision 1.18
> diff -u -p -r1.18 print-bgp.c
> --- print-bgp.c   20 Oct 2015 11:29:07 -  1.18
> +++ print-bgp.c   24 Oct 2015 18:21:55 -
> @@ -140,6 +140,9 @@ struct bgp_attr {
>  #define BGP_CONFED_AS_SEQUENCE 3 /* draft-ietf-idr-rfc3065bis-01 */
>  #define BGP_CONFED_AS_SET  4 /* draft-ietf-idr-rfc3065bis-01  */
>  
> +#define BGP_AS_SEG_TYPE_MINBGP_AS_SET
> +#define BGP_AS_SEG_TYPE_MAXBGP_CONFED_AS_SET
> +
>  static struct tok bgp_as_path_segment_open_values[] = {
>   { BGP_AS_SET,   " {" },
>   { BGP_AS_SEQUENCE,  " " },
> @@ -400,6 +403,55 @@ trunc:
>  }
>  #endif
>  
> +/*
> + * Try to determine the size of the ASs encoded in an AS-path. It is
> + * not obvious as both speaker types exchange AS-paths with the same
> + * path-attribute type.
> + */
> +static int
> +bgp_attr_get_as_size(u_int8_t bgpa_type, const u_char *dat, int len)
> +{
> + const u_char *p;
> +
> + p = dat;
> +
> + /* AS4 path types are always encoded in 4-byte format */
> + if (bgpa_type == BGPTYPE_AS4_PATH) {
> + return 4;
> + }
> +
> + /*
> +  * Start by assuming 2-byte ASs. Iterate through the path data using the
> +  * segment length values. Switch to 4-bytes if we encounter an invalid
> +  * field value/if the AS-Path length is invalid for the assumed size.
> +  */

I wonder if it would not be smarter to check the other way around. As in
start with 4 byte and see if we overflow. I would guess that this would
happen in most cases on the first segment for 2 byte AS pathes.

> + while (p < dat + len) {
> + TCHECK(p[0]);
> +
> + /* check segment type: invalid value means wrong size */
> + if (p[0] < BGP_AS_SEG_TYPE_MIN || p[0] > BGP_AS_SEG_TYPE_MAX)
> + goto trunc;
> +
> + TCHECK(p[1]);
> +
> + /* check segment length: invalid indicates wrong size */
> + if (p[1] == 0)
> + goto trunc;
> +
> + p += 2 + p[1] * 2;
> + }
> +
> + /* matching length: it's very likely the ASs were encoded as 2-bytes */
> + if (p == dat + len)
> + return 2;
> +trunc:
> + /*
> +  * Either there was not enough data or we tried to decode 4-byte ASs
> +  * with an incorrect size of 2-bytes.
> +  */
> + return 4;
> +}
> +
>  static int
>  bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)

Re: inteldrm(4) diff that needs testing

2015-10-25 Thread Philip Guenther
On Sat, Oct 24, 2015 at 2:48 PM, Mark Kettenis  wrote:
> The diff below makes inteldrm(4) attach directly to pci(4) instead of
> vga(1).  Because inteldrm(4) depends on intagp(4), this also make
> intagp(4) a child of inteldrm(4).  Ultimately I'd like to integrate
> intagp(4) into inteldrm(4), but that's going to be a bit more work.
>
> This diff is needed to make inteldrm(4) work when OpenBSD gets booted
> by UEFI firmware.  It will also make inteldrm(4) work on machines with
> discrete graphics.
>
> This diff needs to be tested on a wide range of hardware.  So if you
> have a machine with inteldrm(4), please give it a shot.  I'm
> particularly interested in testing on an x40.

dmesg from Thinkpad Yoga12, booting in compat mode (not UEFI), below.
I didn't save a dmesg from immediately before, but at least back in
June intagp was reported as "intagp at vga1 not configured".  If you
need a dmesg from kernel without this, let me know...

Philip Guenther


OpenBSD 5.8-current (LOCAL) #26: Sat Oct 24 23:19:11 PDT 2015
guenther@corwin.local:/usr/src/sys-clean/arch/amd64/compile/LOCAL
RTC BIOS diagnostic error 80
real mem = 8204083200 (7824MB)
avail mem = 7951233024 (7582MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.7 @ 0xccbfd000 (63 entries)
bios0: vendor LENOVO version "JEET58WW (1.07 )" date 02/02/2015
bios0: LENOVO 20DL003AUS
acpi0 at bios0: rev 2
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP SLIC ASF! HPET APIC MCFG WDAT SSDT SSDT SSDT
SSDT SSDT SSDT PCCT SSDT TCPA SSDT UEFI MSDM BATB FPDT UEFI
acpi0: wakeup devices PEGP(S4) PEG0(S4) PEGP(S4) PEG1(S4) PEGP(S4)
PEG2(S4) GLAN(S4) EHC1(S3) EHC2(S3) XHC_(S3) HDEF(S4) PXSX(S4)
RP01(S4) PXSX(S4) RP02(S4) PXSX(S4) [...]
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpihpet0 at acpi0: 14318179 Hz
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz, 2494.62 MHz
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,BMI1,HLE,AVX2,SMEP,BMI2,ERMS,INVPCID,RTM,RDSEED,ADX,SMAP,SENSOR,ARAT
cpu0: 256KB 64b/line 8-way L2 cache
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 10 var ranges, 88 fixed ranges
cpu0: apic clock running at 99MHz
cpu0: mwait min=64, max=64, C-substates=0.2.1.2.4.1.1.1, IBE
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz, 2494.23 MHz
cpu1: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,BMI1,HLE,AVX2,SMEP,BMI2,ERMS,INVPCID,RTM,RDSEED,ADX,SMAP,SENSOR,ARAT
cpu1: 256KB 64b/line 8-way L2 cache
cpu1: smt 1, core 0, package 0
cpu2 at mainbus0: apid 2 (application processor)
cpu2: Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz, 2494.23 MHz
cpu2: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,BMI1,HLE,AVX2,SMEP,BMI2,ERMS,INVPCID,RTM,RDSEED,ADX,SMAP,SENSOR,ARAT
cpu2: 256KB 64b/line 8-way L2 cache
cpu2: smt 0, core 1, package 0
cpu3 at mainbus0: apid 3 (application processor)
cpu3: Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz, 2494.23 MHz
cpu3: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,BMI1,HLE,AVX2,SMEP,BMI2,ERMS,INVPCID,RTM,RDSEED,ADX,SMAP,SENSOR,ARAT
cpu3: 256KB 64b/line 8-way L2 cache
cpu3: smt 1, core 1, package 0
ioapic0 at mainbus0: apid 2 pa 0xfec0, version 20, 40 pins
acpimcfg0 at acpi0 addr 0xf800, bus 0-63
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus -1 (PEG0)
acpiprt2 at acpi0: bus -1 (PEG1)
acpiprt3 at acpi0: bus -1 (PEG2)
acpiprt4 at acpi0: bus 2 (RP01)
acpiprt5 at acpi0: bus -1 (RP02)
acpiprt6 at acpi0: bus 4 (RP03)
acpiprt7 at acpi0: bus 5 (RP04)
acpiprt8 at acpi0: bus -1 (RP05)
acpiprt9 at acpi0: bus -1 (RP06)
acpiprt10 at acpi0: bus -1 (RP07)
acpiprt11 at acpi0: bus -1 (RP08)
acpiec0 at acpi0: not present
acpiec1 at acpi0
acpicpu0 at acpi0: C3(200@506 mwait.1@0x60), C2(200@148 mwait.1@0x33),
C1(1000@1 mwait.1), PSS
acpicpu1 at 

ld.so crash second attempt

2015-10-25 Thread Peter Hajdu
Hi,

I try to give it one more attempt with a bit more description about the
bug.

After calling dlclose in _dl_notify_unload_shlib_ group reference counts
are decreased by following the object's grpref-list.  Unfortunately the
references are removed from the list during the graph traversal.

dlclose will run all destructors of the unused objects and tries to
unload all objects reachable from the closed object's child and
grpref-list.  Since the grpref-list references were removed, the unused
destructed object stays in memory as garbage.  Next time when this
object is loaded it is found in the memory and crashes during load.

This patch unloads all unused objects instead of following the closed
object's child and grpref list.

Best regards,
Peter Hajdu

Index: dlfcn.c
===
RCS file: /cvs/src/libexec/ld.so/dlfcn.c,v
retrieving revision 1.91
diff -u -p -r1.91 dlfcn.c
--- dlfcn.c 19 Sep 2015 20:56:47 -  1.91
+++ dlfcn.c 21 Oct 2015 13:52:46 -
@@ -302,7 +302,7 @@ _dl_real_close(void *handle)
object->opencount--;
_dl_notify_unload_shlib(object);
_dl_run_all_dtors();
-   _dl_unload_shlib(object);
+   _dl_unload_unused();
_dl_cleanup_objects();
return (0);
 }
Index: library.c
===
RCS file: /cvs/src/libexec/ld.so/library.c,v
retrieving revision 1.71
diff -u -p -r1.71 library.c
--- library.c   16 Jan 2015 16:18:07 -  1.71
+++ library.c   21 Oct 2015 13:52:46 -
@@ -74,6 +74,22 @@ _dl_unload_shlib(elf_object_t *object)
}
 }
 
+void
+_dl_unload_unused(void)
+{
+   elf_object_t *obj, *next;
+
+   for (obj = _dl_objects->next; obj != NULL; obj = next) {
+   next = obj->next;
+   if (OBJECT_REF_CNT(obj) != 0 || obj->status & STAT_UNLOADED)
+   continue;
+   obj->status |= STAT_UNLOADED;
+   _dl_load_list_free(obj->load_list);
+   _dl_munmap((void *)obj->load_base, obj->load_size);
+   _dl_remove_object(obj);
+   }
+}
+
 elf_object_t *
 _dl_tryload_shlib(const char *libname, int type, int flags)
 {
Index: library_mquery.c
===
RCS file: /cvs/src/libexec/ld.so/library_mquery.c,v
retrieving revision 1.49
diff -u -p -r1.49 library_mquery.c
--- library_mquery.c22 Jan 2015 05:48:17 -  1.49
+++ library_mquery.c21 Oct 2015 13:52:46 -
@@ -79,6 +79,20 @@ _dl_unload_shlib(elf_object_t *object)
}
 }
 
+void
+_dl_unload_unused(void)
+{
+   elf_object_t *obj, *next;
+
+   for (obj = _dl_objects->next; obj != NULL; obj = next) {
+   next = obj->next;
+   if (OBJECT_REF_CNT(obj) != 0 || obj->status & STAT_UNLOADED)
+   continue;
+   obj->status |= STAT_UNLOADED;
+   _dl_load_list_free(obj->load_list);
+   _dl_remove_object(obj);
+   }
+}
 
 elf_object_t *
 _dl_tryload_shlib(const char *libname, int type, int flags)
Index: resolve.h
===
RCS file: /cvs/src/libexec/ld.so/resolve.h,v
retrieving revision 1.73
diff -u -p -r1.73 resolve.h
--- resolve.h   19 Sep 2015 20:56:47 -  1.73
+++ resolve.h   21 Oct 2015 13:52:46 -
@@ -223,6 +223,7 @@ void _dl_unlink_dlopen(elf_object_t *dep
 void _dl_notify_unload_shlib(elf_object_t *object);
 void _dl_unload_shlib(elf_object_t *object);
 void _dl_unload_dlopen(void);
+void _dl_unload_unused(void);
 
 void _dl_run_all_dtors(void);
 


Re: inteldrm(4) diff that needs testing

2015-10-25 Thread Stefan Sperling
On Sat, Oct 24, 2015 at 11:48:01PM +0200, Mark Kettenis wrote:
> The diff below makes inteldrm(4) attach directly to pci(4) instead of
> vga(1).  Because inteldrm(4) depends on intagp(4), this also make
> intagp(4) a child of inteldrm(4).  Ultimately I'd like to integrate
> intagp(4) into inteldrm(4), but that's going to be a bit more work.
> 
> This diff is needed to make inteldrm(4) work when OpenBSD gets booted
> by UEFI firmware.  It will also make inteldrm(4) work on machines with
> discrete graphics.
> 
> This diff needs to be tested on a wide range of hardware.  So if you
> have a machine with inteldrm(4), please give it a shot.  I'm
> particularly interested in testing on an x40.
> 

No apparent regression on my Thinkpad x201i.

vga1 at pci0 dev 2 function 0 "Intel HD Graphics" rev 0x02
intagp0 at vga1
agp0 at intagp0: aperture at 0xd000, size 0x1000
inteldrm0 at vga1
drm0 at inteldrm0
inteldrm0: msi
inteldrm0: 1280x800

 0:2:0: Intel HD Graphics
 0x: Vendor ID: 8086 Product ID: 0046



Re: utf8 hack for ls

2015-10-25 Thread Ted Unangst
Ted Unangst wrote:
> Christian Weisgerber wrote:
> > On 2015-10-23, "Ted Unangst"  wrote:
> > 
> > >> To what degree should tools like ls protect terminals from escape codes?
> > >
> > > I think this is beyond the scope of what ls should care about. du doesn't 
> > > have
> > > such a check. Does the shell perform a check before tab completing?
> > 
> > Our ksh, bash, and tcsh all escape unprintable characters.
> 
> well, if this is a blocking issue, the putchar line is now changed to print ?
> instead of any control characters.
> 
>   putchar(c >= ' ' ? c : '?');

The very latest and greatest. Not much changed. We could use a u8width()
function analog of wcswidth, but len seems to do alright for the simple cases.

Index: ls.c
===
RCS file: /cvs/src/bin/ls/ls.c,v
retrieving revision 1.43
diff -u -p -r1.43 ls.c
--- ls.c9 Oct 2015 01:37:06 -   1.43
+++ ls.c23 Oct 2015 12:39:52 -
@@ -410,6 +410,8 @@ traverse(int argc, char *argv[], int opt
fts_close(ftsp);
 }
 
+extern size_t u8len(char *);
+
 /*
  * Display() takes a linked list of FTSENT structures and passes the list
  * along with any other necessary information to the print function.  P
@@ -474,8 +476,8 @@ display(FTSENT *p, FTSENT *list)
continue;
}
}
-   if (cur->fts_namelen > maxlen)
-   maxlen = cur->fts_namelen;
+   if (u8len(cur->fts_name) > maxlen)
+   maxlen = u8len(cur->fts_name);
if (needstats) {
sp = cur->fts_statp;
if (sp->st_blocks > maxblock)
Index: util.c
===
RCS file: /cvs/src/bin/ls/util.c,v
retrieving revision 1.16
diff -u -p -r1.16 util.c
--- util.c  21 Nov 2013 15:54:45 -  1.16
+++ util.c  24 Oct 2015 11:49:56 -
@@ -46,12 +46,34 @@
 #include "extern.h"
 
 int
+isu8cont(unsigned char c)
+{
+   return ((c & (0x80 | 0x40)) == 0x80);
+}
+size_t
+u8len(const char *s)
+{
+   size_t len = 0;
+
+   for (; *s; s++)
+   if (!isu8cont(*s))
+   len++;
+   return len;
+}
+
+int
 putname(char *name)
 {
int len;
 
-   for (len = 0; *name; len++, name++)
-   putchar((!isprint((unsigned char)*name) && f_nonprint) ? '?' : 
*name);
+   for (len = 0; *name; name++) {
+   unsigned char c = *name;
+   if (!isu8cont(c))
+   len++;
+   if (isascii(c) && !isprint(c))
+   c = '?';
+   putchar(c);
+   }
return len;
 }
 



Re: inteldrm(4) diff that needs testing

2015-10-25 Thread Sebastien Marie
On Sat, Oct 24, 2015 at 11:48:01PM +0200, Mark Kettenis wrote:
> The diff below makes inteldrm(4) attach directly to pci(4) instead of
> vga(1).  Because inteldrm(4) depends on intagp(4), this also make
> intagp(4) a child of inteldrm(4).  Ultimately I'd like to integrate
> intagp(4) into inteldrm(4), but that's going to be a bit more work.
> 
> This diff is needed to make inteldrm(4) work when OpenBSD gets booted
> by UEFI firmware.  It will also make inteldrm(4) work on machines with
> discrete graphics.
> 
> This diff needs to be tested on a wide range of hardware.  So if you
> have a machine with inteldrm(4), please give it a shot.  I'm
> particularly interested in testing on an x40.
> 

With the patch, under i386, the machine panic.

As I don't have serial on the machine, and "boot dump" don't work this
time, I transcribe a small part of it, but I could provide all the
backtrace on demand:

wsdisplay at inteldrm0 not configured
panic: vga_common_setup: can't map vga i/o
Stopped at  Debuffer+0x7:   leave

The panic() call is in vga_init() at dev/ic/vga.c:482.

The dmesg of the machine without the patch provided below.

Regards
-- 
Sebastien Marie

OpenBSD 5.8-current (GENERIC.MP) #36: Sun Oct 25 12:36:42 CET 2015
root@bert.local:/usr/src/sys/arch/i386/compile/GENERIC.MP
cpu0: Genuine Intel(R) CPU T2400 @ 1.83GHz ("GenuineIntel" 686-class) 1.83 GHz
cpu0: 
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,NXE,SSE3,MWAIT,VMX,EST,TM2,xTPR,PDCM,PERF,SENSOR
real mem  = 2137354240 (2038MB)
avail mem = 2083864576 (1987MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: date 06/13/07, BIOS32 rev. 0 @ 0xffa10, SMBIOS rev. 2.4 @ 
0xf7980 (44 entries)
bios0: vendor Dell Inc. version "A17" date 06/13/2007
bios0: Dell Inc. MM061
acpi0 at bios0: rev 0
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP HPET APIC MCFG SLIC BOOT SSDT
acpi0: wakeup devices LID_(S3) PBTN(S4) MBTN(S5) PCI0(S3) USB0(S0) USB1(S0) 
USB2(S0) USB3(S0) EHCI(S0) AZAL(S3) PCIE(S4) RP01(S4) RP02(S3) RP03(S3) 
RP04(S3) RP05(S3) [...]
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpihpet0 at acpi0: 14318179 Hz
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
cpu0: apic clock running at 166MHz
cpu0: mwait min=64, max=64, C-substates=0.2.2.2.2, IBE
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Genuine Intel(R) CPU T2400 @ 1.83GHz ("GenuineIntel" 686-class) 1.83 GHz
cpu1: 
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,NXE,SSE3,MWAIT,VMX,EST,TM2,xTPR,PDCM,PERF,SENSOR
ioapic0 at mainbus0: apid 2 pa 0xfec0, version 20, 24 pins
ioapic0: misconfigured as apic 0, remapped to apid 2
acpimcfg0 at acpi0 addr 0xf000, bus 0-63
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus -1 (AGP_)
acpiprt2 at acpi0: bus 3 (PCIE)
acpiprt3 at acpi0: bus 11 (RP01)
acpiprt4 at acpi0: bus -1 (RP02)
acpiprt5 at acpi0: bus -1 (RP03)
acpiprt6 at acpi0: bus 12 (RP04)
acpiprt7 at acpi0: bus -1 (RP05)
acpiprt8 at acpi0: bus -1 (RP06)
acpicpu0 at acpi0: !C3(250@85 io@0x1015), !C2(500@1 io@0x1014), C1(1000@1 
halt), PSS
acpicpu1 at acpi0: !C3(250@85 io@0x1015), !C2(500@1 io@0x1014), C1(1000@1 
halt), PSS
acpitz0 at acpi0: critical temperature is 126 degC
acpiac0 at acpi0: AC unit online
acpibat0 at acpi0: BAT0 model " DELLUD2649" serial 878 type LION oem "Sanyo"
acpibtn0 at acpi0: LID_
acpibtn1 at acpi0: PBTN
acpibtn2 at acpi0: SBTN
acpivideo0 at acpi0: VID_
acpivideo1 at acpi0: VID_
acpivout0 at acpivideo1: LCD_
acpivideo2 at acpi0: VID2
bios0: ROM list: 0xc/0xe800! 0xce800/0x1800
cpu0: Enhanced SpeedStep 1829 MHz: speeds: 1833, 1333, 1000 MHz
pci0 at mainbus0 bus 0: configuration mode 1 (bios)
pchb0 at pci0 dev 0 function 0 "Intel 82945GM Host" rev 0x03
vga1 at pci0 dev 2 function 0 "Intel 82945GM Video" rev 0x03
intagp0 at vga1
agp0 at intagp0: aperture at 0xd000, size 0x1000
inteldrm0 at vga1
drm0 at inteldrm0
inteldrm0: apic 2 int 16
inteldrm0: 1280x800
wsdisplay0 at vga1 mux 1: console (std, vt100 emulation)
wsdisplay0: screen 1-5 added (std, vt100 emulation)
"Intel 82945GM Video" rev 0x03 at pci0 dev 2 function 1 not configured
azalia0 at pci0 dev 27 function 0 "Intel 82801GB HD Audio" rev 0x01: msi
azalia0: codecs: Sigmatel STAC9200, Conexant/0x2bfa, using Sigmatel STAC9200
audio0 at azalia0
ppb0 at pci0 dev 28 function 0 "Intel 82801GB PCIE" rev 0x01: apic 2 int 16
pci1 at ppb0 bus 11
wpi0 at pci1 dev 0 function 0 "Intel PRO/Wireless 3945ABG" rev 0x02: msi, MoW2, 
address 00:13:02:2e:8b:46
ppb1 at pci0 dev 28 function 3 "Intel 82801GB PCIE" rev 0x01: apic 2 int 19
pci2 at ppb1 bus 12
uhci0 at pci0 dev 29 function 0 "Intel 82801GB USB" rev 0x01: apic 2 int 20
uhci1 at pci0 dev 29 function 1 "Intel 82801GB USB" rev 0x01: apic 2 int 21
uhci2 at pci0 dev 29 function 2 "Intel 82801GB 

Re: pledge(2) in quiz(6)

2015-10-25 Thread Ted Unangst
Jan Stary wrote:
> Any comments/OK?
> 
> On Oct 22 13:49:28, h...@stare.cz wrote:
> > games/quiz.c popen()s a PAGER to display the help message.
> > Throw that away and let the use pipe into a PAGER if needed.
> > Then we can just pledge "stdio rpath".

yeah, works for me.



Re: The router doesn't know the size of the internet...

2015-10-25 Thread Todd C. Miller
On Sat, 24 Oct 2015 18:15:48 +0200, Sebastian Benoit wrote:

> > s/size/diameter/ to quote RFC 2461 correctly
> > 
> > The value should be set to that current diameter of the Internet.
> 
> who measures that and tells me what to set there?

Every sys/netinet hacker should own a set of internet calipers.

 - todd



ftpd banner

2015-10-25 Thread Ted Unangst
unifdef some foolishness. note that BSD is not currently defined when this
file is built.


Index: ftpcmd.y
===
RCS file: /cvs/src/libexec/ftpd/ftpcmd.y,v
retrieving revision 1.60
diff -u -p -r1.60 ftpcmd.y
--- ftpcmd.y18 Aug 2015 17:35:59 -  1.60
+++ ftpcmd.y25 Oct 2015 21:29:45 -
@@ -1,4 +1,4 @@
-/* $OpenBSD: ftpcmd.y,v 1.60 2015/08/18 17:35:59 deraadt Exp $ */
+/* $OpenBSD: ftpcmd.y,v 1.59 2015/03/17 19:31:30 millert Exp $ */
 /* $NetBSD: ftpcmd.y,v 1.7 1996/04/08 19:03:11 jtc Exp $   */
 
 /*
@@ -574,16 +574,7 @@ cmd
| SYST check_login CRLF
{
if ($2)
-#ifdef unix
-#ifdef BSD
-   reply(215, "UNIX Type: L%d Version: BSD-%d",
-   NBBY, BSD);
-#else /* BSD */
reply(215, "UNIX Type: L%d", NBBY);
-#endif /* BSD */
-#else /* unix */
-   reply(215, "UNKNOWN Type: L%d", NBBY);
-#endif /* unix */
}
 
/*



route6d: another pidfile() removal

2015-10-25 Thread Jérémie Courrèges-Anglas

Following the recent discussions, here's another pidfile(3) removal.
route6d(8) doesn't document it.

ok?

Index: Makefile
===
RCS file: /cvs/src/usr.sbin/route6d/Makefile,v
retrieving revision 1.7
diff -u -p -r1.7 Makefile
--- Makefile19 Dec 2006 15:06:10 -  1.7
+++ Makefile25 Oct 2015 22:12:00 -
@@ -2,7 +2,5 @@
 
 PROG=  route6d
 MAN=   route6d.8
-LDADD+=-lutil
-DPADD+=${LIBUTIL}
 
 .include 
Index: route6d.c
===
RCS file: /cvs/src/usr.sbin/route6d/route6d.c,v
retrieving revision 1.70
diff -u -p -r1.70 route6d.c
--- route6d.c   18 Oct 2015 14:35:36 -  1.70
+++ route6d.c   25 Oct 2015 22:12:22 -
@@ -372,8 +372,6 @@ main(int argc, char *argv[])
if (dflag)
ifrtdump(0);
 
-   pidfile(NULL);
-
if ((ripbuf = malloc(RIP6_MAXMTU)) == NULL) {
fatal("malloc");
/*NOTREACHED*/


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: route6d: another pidfile() removal

2015-10-25 Thread Sebastian Benoit
ok!

J??r??mie Courr??ges-Anglas(j...@wxcvbn.org) on 2015.10.25 23:15:12 +0100:
> 
> Following the recent discussions, here's another pidfile(3) removal.
> route6d(8) doesn't document it.
> 
> ok?
> 
> Index: Makefile
> ===
> RCS file: /cvs/src/usr.sbin/route6d/Makefile,v
> retrieving revision 1.7
> diff -u -p -r1.7 Makefile
> --- Makefile  19 Dec 2006 15:06:10 -  1.7
> +++ Makefile  25 Oct 2015 22:12:00 -
> @@ -2,7 +2,5 @@
>  
>  PROG=route6d
>  MAN= route6d.8
> -LDADD+=  -lutil
> -DPADD+=  ${LIBUTIL}
>  
>  .include 
> Index: route6d.c
> ===
> RCS file: /cvs/src/usr.sbin/route6d/route6d.c,v
> retrieving revision 1.70
> diff -u -p -r1.70 route6d.c
> --- route6d.c 18 Oct 2015 14:35:36 -  1.70
> +++ route6d.c 25 Oct 2015 22:12:22 -
> @@ -372,8 +372,6 @@ main(int argc, char *argv[])
>   if (dflag)
>   ifrtdump(0);
>  
> - pidfile(NULL);
> -
>   if ((ripbuf = malloc(RIP6_MAXMTU)) == NULL) {
>   fatal("malloc");
>   /*NOTREACHED*/
> 
> 
> -- 
> jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE
> 

-- 



Re: support for malloc allocation canaries

2015-10-25 Thread Ted Unangst
Daniel Micay wrote:
> This patch adds an opt-in malloc configuration option placing canaries after
> small allocations to detect heap overflows on free(...). It's intended to be
> used alongside guard pages for large allocations. Since it's essentially
> adding extra padding to all small allocations, a small heap overflow will be
> rendered harmless.

This is all very cool. I'd like to look more at it sometime soon. 



slist remove invalidate

2015-10-25 Thread Alexander Bluhm
Hi,

This diff that makes SLIST_REMOVE invalidate pointer more paranoid.
I am running it for a while now without problems.

ok to put in in?

bluhm

Index: sys/queue.h
===
RCS file: /data/mirror/openbsd/cvs/src/sys/sys/queue.h,v
retrieving revision 1.38
diff -u -p -r1.38 queue.h
--- sys/queue.h 3 Jul 2013 15:05:21 -   1.38
+++ sys/queue.h 19 Feb 2015 21:29:54 -
@@ -157,8 +157,8 @@ struct {
\
curelm = curelm->field.sle_next;\
curelm->field.sle_next =\
curelm->field.sle_next->field.sle_next; \
-   _Q_INVALIDATE((elm)->field.sle_next);   \
}   \
+   _Q_INVALIDATE((elm)->field.sle_next);   \
 } while (0)
 
 /*



Re: support for malloc allocation canaries

2015-10-25 Thread Daniel Micay
On 25/10/15 06:20 PM, Ted Unangst wrote:
> Daniel Micay wrote:
>> This patch adds an opt-in malloc configuration option placing canaries after
>> small allocations to detect heap overflows on free(...). It's intended to be
>> used alongside guard pages for large allocations. Since it's essentially
>> adding extra padding to all small allocations, a small heap overflow will be
>> rendered harmless.
> 
> This is all very cool. I'd like to look more at it sometime soon. 

Probably worth looking at the use-after-free detection patch first since it's
simpler. And it's worth noting that the 2 features conflict with each other,
a small change is required to make them compatible:

diff --git a/libc/bionic/omalloc.c b/libc/bionic/omalloc.c
index 91ae559..dd39117 100644
--- a/libc/bionic/omalloc.c
+++ b/libc/bionic/omalloc.c
@@ -1371,6 +1371,8 @@ ofree(void *p)
size_t byte;
r = find(pool, p);
REALSIZE(sz, r);
+   if (sz > 0 && sz <= MALLOC_MAXCHUNK)
+   sz -= mopts.malloc_canaries;
for (byte = 0; byte < sz; byte++) {
if (((char *)p)[byte] != SOME_FREEJUNK) 
{
wrterror("use after free", p);



PF_KEY socket data sensitivity

2015-10-25 Thread Michael McConville
There are a few daemons in base that make a point of zeroing all data
read from PF_KEY sockets. However, Benjamin Baier and I have looked into
it a litle (RFC 2367 et al.) and it seems that this may only be
metadata. To those with PF_KEY experience: is it worth zeroing?



Re: telnet: low-delay traffic class for IPv6 connections

2015-10-25 Thread Todd C. Miller
On Sun, 25 Oct 2015 17:18:28 +0100, =?utf-8?Q?J=C3=A9r=C3=A9mie_Courr=C3=A8ges-
Anglas?= wrote:

> While here, there is no option to pass a different tos, and no other use
> of the "tos" variable out of tn(), so move the "tos" variable in tn()
> and assign it the right value from the start.

OK millert@

 - todd



Re: sed: better error message

2015-10-25 Thread Michael McConville
Jérémie Courrèges-Anglas wrote:
> Tobias Stoeckmann  writes:
> 
> > $ sed s/a/b/ /nofile
> > sed: 0: /nofile: /nofile
> >
> > That message doesn't tell me a lot, let's better write
> > strerror(errno) if fopen returns NULL:
> >
> > $ ./sed s/a/b/ /nofile
> > sed: 0: /nofile: No such file or directory
> 
> That's much nicer, ok jca@
> 
> (misc.c:err() already prints the file name)

Yikes. I was initially confused because err(3) automatically appends the
errno. Then I realized that sed redefines err.

As guenther@ (and/or millert@?) has been working on lately, redefining
stdlib functions is risky. sed contains examples such as the pledge()
calls in which the programmer definitely seems to think they're using
err(3).

It looks like it can be pretty easily replaced with calls to err(3),
errx(3), warn(3), warnx(3), etc. However, it'd be easiest to rename the
function to error() first.

Thoughts?


Index: compile.c
===
RCS file: /cvs/src/usr.bin/sed/compile.c,v
retrieving revision 1.38
diff -u -p -r1.38 compile.c
--- compile.c   23 Jun 2015 22:52:55 -  1.38
+++ compile.c   25 Oct 2015 22:43:40 -
@@ -153,7 +153,7 @@ compile_stream(struct s_command **link)
for (;;) {
if ((p = cu_fgets(, )) == NULL) {
if (stack != 0)
-   err(COMPILE, "unexpected EOF (pending }'s)");
+   sed_err(COMPILE, "unexpected EOF (pending 
}'s)");
return (link);
}
 
@@ -193,15 +193,15 @@ semicolon:EATSPACE();
 
 nonsel:/* Now parse the command */
if (!*p)
-   err(COMPILE, "command expected");
+   sed_err(COMPILE, "command expected");
cmd->code = *p;
for (fp = cmd_fmts; fp->code; fp++)
if (fp->code == *p)
break;
if (!fp->code)
-   err(COMPILE, "invalid command code %c", *p);
+   sed_err(COMPILE, "invalid command code %c", *p);
if (naddr > fp->naddr)
-   err(COMPILE,
+   sed_err(COMPILE,
"command %c expects up to %d address(es), found %d",
*p, fp->naddr, naddr);
switch (fp->args) {
@@ -226,7 +226,7 @@ nonsel: /* Now parse the command */
 */
cmd->nonsel = 1;
if (stack == 0)
-   err(COMPILE, "unexpected }");
+   sed_err(COMPILE, "unexpected }");
cmd2 = stack;
stack = cmd2->next;
cmd2->next = cmd;
@@ -240,19 +240,19 @@ nonsel:   /* Now parse the command */
goto semicolon;
}
if (*p)
-   err(COMPILE,
+   sed_err(COMPILE,
 "extra characters at the end of %c command", cmd->code);
break;
case TEXT:  /* a c i */
p++;
EATSPACE();
if (*p != '\\')
-   err(COMPILE, "command %c expects \\ followed by"
+   sed_err(COMPILE, "command %c expects \\ 
followed by"
" text", cmd->code);
p++;
EATSPACE();
if (*p)
-   err(COMPILE, "extra characters after \\ at the"
+   sed_err(COMPILE, "extra characters after \\ at 
the"
" end of %c command", cmd->code);
cmd->t = compile_text();
break;
@@ -262,14 +262,14 @@ nonsel:   /* Now parse the command */
p++;
EATSPACE();
if (*p == '\0')
-   err(COMPILE, "filename expected");
+   sed_err(COMPILE, "filename expected");
cmd->t = duptoeol(p, "w command", NULL);
if (aflag)
cmd->u.fd = -1;
else if ((cmd->u.fd = open(p,
O_WRONLY|O_APPEND|O_CREAT|O_TRUNC,
DEFFILEMODE)) == -1)
-   err(FATAL, "%s: %s", p, strerror(errno));
+   sed_err(FATAL, "%s: %s", p, strerror(errno));
break;
case RFILE: /* r */
p++;
@@ -293,7 +293,7 @@ nonsel: /* Now 

Re: sed: better error message

2015-10-25 Thread Michael McConville
Jérémie Courrèges-Anglas wrote:
> Michael McConville  writes:
> > It looks like it can be pretty easily replaced with calls to err(3),
> > errx(3), warn(3), warnx(3), etc.
> 
> Not sure about this, you'd have to repeat the same code over and over to
> print the line number and file name.

Good point. I'll look at the code more.

> > However, it'd be easiest to rename the function to error() first.
> >
> > Thoughts?
> 
> Makes sense to me.
> 
> However, using "error" instead of "sed_err" would save you two
> characters and avoid some of the >80 chars long lines introduced by your
> diff.  Those should be fixed.

'error' seemed a little too general. ok for s_err?



Re: sed: better error message

2015-10-25 Thread Jérémie Courrèges-Anglas
Michael McConville  writes:

> Jérémie Courrèges-Anglas wrote:
>> Tobias Stoeckmann  writes:
>> 
>> > $ sed s/a/b/ /nofile
>> > sed: 0: /nofile: /nofile
>> >
>> > That message doesn't tell me a lot, let's better write
>> > strerror(errno) if fopen returns NULL:
>> >
>> > $ ./sed s/a/b/ /nofile
>> > sed: 0: /nofile: No such file or directory
>> 
>> That's much nicer, ok jca@
>> 
>> (misc.c:err() already prints the file name)
>
> Yikes. I was initially confused because err(3) automatically appends the
> errno. Then I realized that sed redefines err.
>
> As guenther@ (and/or millert@?) has been working on lately, redefining
> stdlib functions is risky. sed contains examples such as the pledge()
> calls in which the programmer definitely seems to think they're using
> err(3).
>
> It looks like it can be pretty easily replaced with calls to err(3),
> errx(3), warn(3), warnx(3), etc.

Not sure about this, you'd have to repeat the same code over and over to
print the line number and file name.

> However, it'd be easiest to rename the
> function to error() first.
>
> Thoughts?

Makes sense to me.

However, using "error" instead of "sed_err" would save you two
characters and avoid some of the >80 chars long lines introduced by your
diff.  Those should be fixed.

[...]

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: ftpd banner

2015-10-25 Thread Jérémie Courrèges-Anglas
"Ted Unangst"  writes:

> unifdef some foolishness. note that BSD is not currently defined when this
> file is built.

ok jca@

[...]

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: inteldrm(4) diff that needs testing

2015-10-25 Thread Jonathan Gray
On Sun, Oct 25, 2015 at 09:38:14PM +0100, Mark Kettenis wrote:
> > Date: Sun, 25 Oct 2015 15:51:54 +1100
> > From: Jonathan Gray 
> > 
> > On Sat, Oct 24, 2015 at 11:48:01PM +0200, Mark Kettenis wrote:
> > > The diff below makes inteldrm(4) attach directly to pci(4) instead of
> > > vga(1).  Because inteldrm(4) depends on intagp(4), this also make
> > > intagp(4) a child of inteldrm(4).  Ultimately I'd like to integrate
> > > intagp(4) into inteldrm(4), but that's going to be a bit more work.
> > > 
> > > This diff is needed to make inteldrm(4) work when OpenBSD gets booted
> > > by UEFI firmware.  It will also make inteldrm(4) work on machines with
> > > discrete graphics.
> > > 
> > > This diff needs to be tested on a wide range of hardware.  So if you
> > > have a machine with inteldrm(4), please give it a shot.  I'm
> > > particularly interested in testing on an x40.
> > 
> > after with serial console:
> > 
> > inteldrm0 at pci0 dev 2 function 0 "Intel 82855GM Video" rev 0x02
> > intagp0 at inteldrm0
> > agp0 at intagp0: aperture at 0xe000, size 0x800
> > drm0 at inteldrm0
> > inteldrm0: can't map mmio space
> > inteldrm1 at pci0 dev 2 function 1 "Intel 82855GM Video" rev 0x02
> > intagp at inteldrm1 not configured
> > drm1 at inteldrm1
> > inteldrm1: couldn't map interrupt
> > Memory manager not clean. Delaying takedown
> 
> The diff below should fix the issue on the x40 and similar machines
> with 2nd generation Intel graphics.

With that the screen goes black on attaching inteldrm and hangs.

When booting with serial the last output is:

inteldrm0 at pci0 dev 2 function 0 "Intel 82855GM Video" rev 0x02
intagp0 at inteldrm0
agp0 at intagp0: aperture at 0xe000, size 0x800
drm0 at inteldrm0
inteldrm0: apic 1 int 16

It looks like we need to map more than 64, the i815 registers
are documented to go up to 512/0x8
"Cursor, Display, and Pixel Pipe Registers (7h-7h)"

When trying to map 512 with the attach diff it seems
pci_mapreg_map() fails in it's bus_space_map() call

bus_space_map_failed base 0xd000 size 0x8 flags 0x0



Kill rtable_mpath_conflict

2015-10-25 Thread Martin Pieuchot
Instead of having a separate function to check for MPATH conflicts
simply pass the gateway to rtable_insert().  Some regress tests
outputs will need an update as we're now doing one more rtalloc(9)
call in RTM_ADD. 

This is a step towards MPATH by default.

ok?

Index: net/route.c
===
RCS file: /cvs/src/sys/net/route.c,v
retrieving revision 1.262
diff -u -p -r1.262 route.c
--- net/route.c 25 Oct 2015 11:58:11 -  1.262
+++ net/route.c 25 Oct 2015 14:14:28 -
@@ -837,15 +837,6 @@ rtrequest1(int req, struct rt_addrinfo *
else
memcpy(ndst, info->rti_info[RTAX_DST], dlen);
 
-#ifndef SMALL_KERNEL
-   /* Do not permit exactly the same dst/mask/gw pair. */
-   if (rtable_mpath_conflict(tableid, ndst,
-   info->rti_info[RTAX_NETMASK], info->rti_info[RTAX_GATEWAY],
-   prio, info->rti_flags & RTF_MPATH)) {
-   free(ndst, M_RTABLE, dlen);
-   return (EEXIST);
-   }
-#endif
rt = pool_get(_pool, PR_NOWAIT | PR_ZERO);
if (rt == NULL) {
free(ndst, M_RTABLE, dlen);
@@ -953,13 +944,15 @@ rtrequest1(int req, struct rt_addrinfo *
}
 
error = rtable_insert(tableid, ndst,
-   info->rti_info[RTAX_NETMASK], rt->rt_priority, rt);
+   info->rti_info[RTAX_NETMASK], info->rti_info[RTAX_GATEWAY],
+   rt->rt_priority, rt);
if (error != 0 && (crt = rtalloc(ndst, 0, tableid)) != NULL) {
/* overwrite cloned route */
if ((crt->rt_flags & RTF_CLONED) != 0) {
rtdeletemsg(crt, tableid);
error = rtable_insert(tableid, ndst,
info->rti_info[RTAX_NETMASK],
+   info->rti_info[RTAX_GATEWAY],
rt->rt_priority, rt);
}
rtfree(crt);
Index: net/rtable.c
===
RCS file: /cvs/src/sys/net/rtable.c,v
retrieving revision 1.14
diff -u -p -r1.14 rtable.c
--- net/rtable.c22 Oct 2015 17:19:38 -  1.14
+++ net/rtable.c25 Oct 2015 14:13:57 -
@@ -292,7 +292,8 @@ rtable_match(unsigned int rtableid, stru
 
 int
 rtable_insert(unsigned int rtableid, struct sockaddr *dst,
-struct sockaddr *mask, uint8_t prio, struct rtentry *rt)
+struct sockaddr *mask, struct sockaddr *gateway, uint8_t prio,
+struct rtentry *rt)
 {
struct radix_node_head  *rnh;
struct radix_node   *rn = (struct radix_node *)rt;
@@ -301,6 +302,15 @@ rtable_insert(unsigned int rtableid, str
if (rnh == NULL)
return (EAFNOSUPPORT);
 
+#ifndef SMALL_KERNEL
+   if (rnh->rnh_multipath) {
+   /* Do not permit exactly the same dst/mask/gw pair. */
+   if (rt_mpath_conflict(rnh, dst, mask, gateway, prio,
+   ISSET(rt->rt_flags, RTF_MPATH)))
+   return (EEXIST);
+   }
+#endif
+
rn = rn_addroute(dst, mask, rnh, rn, prio);
if (rn == NULL)
return (ESRCH);
@@ -382,22 +392,6 @@ rtable_mpath_match(unsigned int rtableid
return (rt);
 }
 
-int
-rtable_mpath_conflict(unsigned int rtableid, struct sockaddr *dst,
-struct sockaddr *mask, struct sockaddr *gateway, uint8_t prio, int mpathok)
-{
-   struct radix_node_head  *rnh;
-
-   rnh = rtable_get(rtableid, dst->sa_family);
-   if (rnh == NULL)
-   return (EAFNOSUPPORT);
-
-   if (rnh->rnh_multipath == 0)
-   return (0);
-
-   return (rt_mpath_conflict(rnh, dst, mask, gateway, prio, mpathok));
-}
-
 /* Gateway selection by Hash-Threshold (RFC 2992) */
 struct rtentry *
 rtable_mpath_select(struct rtentry *rt, uint32_t hash)
@@ -526,7 +520,8 @@ rtable_match(unsigned int rtableid, stru
 
 int
 rtable_insert(unsigned int rtableid, struct sockaddr *dst,
-struct sockaddr *mask, uint8_t prio, struct rtentry *rt)
+struct sockaddr *mask, struct sockaddr *gateway, uint8_t prio,
+struct rtentry *rt)
 {
 #ifndef SMALL_KERNEL
struct rtentry  *mrt;
@@ -545,6 +540,29 @@ rtable_insert(unsigned int rtableid, str
if (plen == -1)
return (EINVAL);
 
+#ifndef SMALL_KERNEL
+   /* Do not permit exactly the same dst/mask/gw pair. */
+   an = art_lookup(ar, addr, plen);
+   if (an != NULL && an->an_plen == plen &&
+   !memcmp(an->an_dst, dst, dst->sa_len)) {
+   struct rtentry  *mrt;
+   int  mpathok = ISSET(rt->rt_flags, RTF_MPATH);
+
+   LIST_FOREACH(mrt, >an_rtlist, rt_next) {
+   if (prio != RTP_ANY &&
+ 

Re: Kill rtable_mpath_match

2015-10-25 Thread Sebastian Benoit
Martin Pieuchot(m...@openbsd.org) on 2015.10.25 16:14:27 +0100:
> Diff below merges the guts of rtable_mpath_match() into rtable_lookup().
> As for the previous rtable_mpath_* diff this is a step towards MPATH by
> default.
> 
> This diff introduces a behavior change for RTM_GET.  If multiple route
> exists a gateway MUST be specified and the first one in the tree won't
> be automagically selected by the kernel.
> 
> Example:
> 
>   # route -n show -inet |grep 192.168.178/24
>   192.168.178/24 192.168.178.1  UGSP   1  230 - 8 
> vio0 
>   192.168.178/24 192.168.178.2  UGSP   00 - 8 
> vio0 

greping through 500k routes isnt really nice.

>   # route -n get 192.168.178/24
>   route: writing to routing socket: No such process

the error msg is misleading, something like "multiple routes available" or
so would be nice. Otherwise i am lead to think there is no route.

>   # route -n get 192.168.178/24 192.168.178.1
>  route to: 192.168.178.0
>   destination: 192.168.178.0
>  mask: 255.255.255.0
>   gateway: 192.168.178.1
> interface: vio0
>if address: 192.168.178.5
>  priority: 8 (static)
> flags: 
>use   mtuexpire
>326 0 0 
> 
> 
> Is it acceptable?
> 
> Index: net/if.c
> ===
> RCS file: /cvs/src/sys/net/if.c,v
> retrieving revision 1.397
> diff -u -p -r1.397 if.c
> --- net/if.c  25 Oct 2015 13:52:45 -  1.397
> +++ net/if.c  25 Oct 2015 15:06:44 -
> @@ -2360,7 +2360,7 @@ if_group_egress_build(void)
>   bzero(_in, sizeof(sa_in));
>   sa_in.sin_len = sizeof(sa_in);
>   sa_in.sin_family = AF_INET;
> - rt0 = rtable_lookup(0, sintosa(_in), sintosa(_in));
> + rt0 = rtable_lookup(0, sintosa(_in), sintosa(_in), NULL, RTP_ANY);
>   if (rt0 != NULL) {
>   rt = rt0;
>   do {
> @@ -2377,7 +2377,8 @@ if_group_egress_build(void)
>  
>  #ifdef INET6
>   bcopy(_any, _in6, sizeof(sa_in6));
> - rt0 = rtable_lookup(0, sin6tosa(_in6), sin6tosa(_in6));
> + rt0 = rtable_lookup(0, sin6tosa(_in6), sin6tosa(_in6), NULL,
> + RTP_ANY);
>   if (rt0 != NULL) {
>   rt = rt0;
>   do {
> Index: net/route.c
> ===
> RCS file: /cvs/src/sys/net/route.c,v
> retrieving revision 1.263
> diff -u -p -r1.263 route.c
> --- net/route.c   25 Oct 2015 14:48:51 -  1.263
> +++ net/route.c   25 Oct 2015 15:06:45 -
> @@ -733,25 +733,10 @@ rtrequest1(int req, struct rt_addrinfo *
>   switch (req) {
>   case RTM_DELETE:
>   rt = rtable_lookup(tableid, info->rti_info[RTAX_DST],
> - info->rti_info[RTAX_NETMASK]);
> + info->rti_info[RTAX_NETMASK], info->rti_info[RTAX_GATEWAY],
> + prio );
>   if (rt == NULL)
>   return (ESRCH);
> -#ifndef SMALL_KERNEL
> - rt = rtable_mpath_match(tableid, rt,
> - info->rti_info[RTAX_GATEWAY], prio);
> - if (rt == NULL)
> - return (ESRCH);
> -
> - /*
> -  * If we got multipath routes, we require users to specify
> -  * a matching gateway.
> -  */
> - if ((rt->rt_flags & RTF_MPATH) &&
> - info->rti_info[RTAX_GATEWAY] == NULL) {
> - rtfree(rt);
> - return (ESRCH);
> - }
> -#endif
>  
>   /*
>* Since RTP_LOCAL cannot be set by userland, make
> Index: net/rtable.c
> ===
> RCS file: /cvs/src/sys/net/rtable.c,v
> retrieving revision 1.15
> diff -u -p -r1.15 rtable.c
> --- net/rtable.c  25 Oct 2015 14:48:51 -  1.15
> +++ net/rtable.c  25 Oct 2015 15:06:45 -
> @@ -249,7 +249,7 @@ rtable_free(unsigned int rtableid)
>  
>  struct rtentry *
>  rtable_lookup(unsigned int rtableid, struct sockaddr *dst,
> -struct sockaddr *mask)
> +struct sockaddr *mask, struct sockaddr *gateway, uint8_t prio)
>  {
>   struct radix_node_head  *rnh;
>   struct radix_node   *rn;
> @@ -264,6 +264,22 @@ rtable_lookup(unsigned int rtableid, str
>   return (NULL);
>  
>   rt = ((struct rtentry *)rn);
> +
> +#ifndef SMALL_KERNEL
> + if (rnh->rnh_multipath) {
> + rt = rt_mpath_matchgate(rt, gateway, prio);
> + if (rt == NULL)
> + return (NULL);
> + }
> +
> + /*
> +  * If we got multipath routes, we require users to specify
> +  * a matching gateway.
> +  */
> + if (ISSET(rt->rt_flags, RTF_MPATH) && gateway == NULL)
> + return (NULL);
> +#endif /* !SMALL_KERNEL */
> +
>   rtref(rt);
>  
>   return (rt);
> @@ -372,26 +388,6 @@ 

Re: inteldrm(4) diff that needs testing

2015-10-25 Thread Mark Kettenis
> Date: Sun, 25 Oct 2015 15:51:54 +1100
> From: Jonathan Gray 
> 
> On Sat, Oct 24, 2015 at 11:48:01PM +0200, Mark Kettenis wrote:
> > The diff below makes inteldrm(4) attach directly to pci(4) instead of
> > vga(1).  Because inteldrm(4) depends on intagp(4), this also make
> > intagp(4) a child of inteldrm(4).  Ultimately I'd like to integrate
> > intagp(4) into inteldrm(4), but that's going to be a bit more work.
> > 
> > This diff is needed to make inteldrm(4) work when OpenBSD gets booted
> > by UEFI firmware.  It will also make inteldrm(4) work on machines with
> > discrete graphics.
> > 
> > This diff needs to be tested on a wide range of hardware.  So if you
> > have a machine with inteldrm(4), please give it a shot.  I'm
> > particularly interested in testing on an x40.
> 
> after with serial console:
> 
> inteldrm0 at pci0 dev 2 function 0 "Intel 82855GM Video" rev 0x02
> intagp0 at inteldrm0
> agp0 at intagp0: aperture at 0xe000, size 0x800
> drm0 at inteldrm0
> inteldrm0: can't map mmio space
> inteldrm1 at pci0 dev 2 function 1 "Intel 82855GM Video" rev 0x02
> intagp at inteldrm1 not configured
> drm1 at inteldrm1
> inteldrm1: couldn't map interrupt
> Memory manager not clean. Delaying takedown

The diff below should fix the issue on the x40 and similar machines
with 2nd generation Intel graphics.


Index: arch/amd64/conf/GENERIC
===
RCS file: /cvs/src/sys/arch/amd64/conf/GENERIC,v
retrieving revision 1.398
diff -u -p -r1.398 GENERIC
--- arch/amd64/conf/GENERIC 30 Sep 2015 12:24:44 -  1.398
+++ arch/amd64/conf/GENERIC 9 Oct 2015 20:40:52 -
@@ -300,15 +300,16 @@ wsdisplay0at vga? console 1
 wskbd* at pckbd? mux 1
 wsmouse*   at pms? mux 0
 
-intagp*at vga? # intel integrated graphics
 #mmuagp*   at pchb?# amd64 mmu agp.
-
-agp*   at intagp?
 #agp*  at mmuagp?
 
-inteldrm*  at vga? # Intel i915, i945 DRM driver
+inteldrm*  at pci? # Intel i915, i945 DRM driver
+intagp*at inteldrm?
+agp*   at intagp?
 drm0   at inteldrm? console 1
 drm*   at inteldrm?
+wsdisplay0 at inteldrm? console 1
+wsdisplay* at inteldrm?
 radeondrm* at pci? # ATI Radeon DRM driver
 drm0   at radeondrm? console 1
 drm*   at radeondrm?
Index: arch/amd64/conf/files.amd64
===
RCS file: /cvs/src/sys/arch/amd64/conf/files.amd64,v
retrieving revision 1.81
diff -u -p -r1.81 files.amd64
--- arch/amd64/conf/files.amd64 4 Sep 2015 23:22:56 -   1.81
+++ arch/amd64/conf/files.amd64 9 Oct 2015 16:36:41 -
@@ -133,7 +133,7 @@ attach  amas at pci
 file   dev/pci/amas.c  amas
 
 # AGP bridge support. most attach at pchb
-file   arch/amd64/pci/agp_machdep.cagp
+file   arch/amd64/pci/agp_machdep.cagp | inteldrm
 
 #
 # CARDBUS
Index: arch/i386/conf/GENERIC
===
RCS file: /cvs/src/sys/arch/i386/conf/GENERIC,v
retrieving revision 1.807
diff -u -p -r1.807 GENERIC
--- arch/i386/conf/GENERIC  25 Oct 2015 19:32:33 -  1.807
+++ arch/i386/conf/GENERIC  25 Oct 2015 20:21:06 -
@@ -358,7 +358,6 @@ wsdisplay0  at pcdisplay? console 1
 wskbd* at pckbd? mux 1
 wsmouse*   at pms? mux 0
 
-intagp*at vga? # intel integrated graphics agp
 aliagp*at pchb?
 amdagp*at pchb?
 intelagp*  at pchb?
@@ -366,7 +365,6 @@ sisagp* at pchb?
 viaagp*at pchb?
 #mmuagp*   at pchb?
 
-agp*   at intagp?  # AGP bridges
 agp*   at aliagp?  # AGP bridges
 agp*   at amdagp?  # AGP bridges
 agp*   at intelagp?# AGP bridges
@@ -374,9 +372,13 @@ agp*   at sisagp?  # AGP bridges
 agp*   at viaagp?  # AGP bridges
 #agp*  at mmuagp?  
 
-inteldrm*  at vga? # Intel i915, i945 DRM driver
+inteldrm*  at pci? # Intel i915, i945 DRM driver
+intagp*at inteldrm?
+agp*   at intagp?
 drm0   at inteldrm? console 1
 drm*   at inteldrm?
+wsdisplay0 at inteldrm? console 1
+wsdisplay* at inteldrm?
 radeondrm* at pci? # ATI Radeon DRM driver
 drm0   at radeondrm? console 1
 drm*   at radeondrm?
Index: arch/i386/conf/files.i386
===
RCS file: /cvs/src/sys/arch/i386/conf/files.i386,v
retrieving revision 1.226
diff -u -p -r1.226 files.i386
--- arch/i386/conf/files.i386   20 Aug 2015 04:41:46 -  1.226
+++ arch/i386/conf/files.i386   24 Oct 2015 21:28:00 -
@@ -113,7 +113,7 @@ attach  amas at pci
 filedev/pci/amas.c amas
 
 # AGP bridge support. 

Re: inteldrm(4) diff that needs testing

2015-10-25 Thread Stefan Sperling
On Sat, Oct 24, 2015 at 11:48:01PM +0200, Mark Kettenis wrote:
> The diff below makes inteldrm(4) attach directly to pci(4) instead of
> vga(1).  Because inteldrm(4) depends on intagp(4), this also make
> intagp(4) a child of inteldrm(4).  Ultimately I'd like to integrate
> intagp(4) into inteldrm(4), but that's going to be a bit more work.
> 
> This diff is needed to make inteldrm(4) work when OpenBSD gets booted
> by UEFI firmware.  It will also make inteldrm(4) work on machines with
> discrete graphics.

On the Thinkpad Helix 2 (UEFI only machine) inteldrm now attaches.
However, it crashes shortly after:

inteldrm0 at pci0 dev 2 function 0 "Intel HD Graphics 5300" rev 0x09
drm1 at inteldrm
inteldrm0: msi
inteldrm0: 1920x1080
wsdisplay1 at inteldrm0 mux 1
uvm_fault(0x81928280, 0x20, 0, 2) -> e
kernel: page fault trap code = 0
Stopped at   rasops_doswitch+0x76: mvol$0x1,0x20(%r14)
ddb>

Keyboard is unresponsive.

Also, the screen is shifted left such that most lines start on the right
half of the screen and flow back in on the left hand side.
So the above actually appears like this on the screen:

  inteldrm0 at pci0 dev 2 function 0
"Intel HD Graphics 5300" rev 0x09
  drm1 at inteldrm
  inteldrm0: msi
  inteldrm0: 1920x1080
  wsdisplay1 at inteldrm0 mux 1
  uvm_fault(0x81928280, 0x20
, 0, 2) -> e
  kernel: page fault trap code = 0
  Stopped at   rasops_doswitch+0x
76: mvol$0x1,0x20(%r14)
ddb>



Re: inteldrm(4) diff that needs testing

2015-10-25 Thread Norman Golisz
On Sat Oct 24 2015 23:48, Mark Kettenis wrote:
> This diff needs to be tested on a wide range of hardware.  So if you
> have a machine with inteldrm(4), please give it a shot.  I'm
> particularly interested in testing on an x40.

No problems on my Thinkpad T400 (also running X11).


OpenBSD 5.8-current (GENERIC.MP) #0: Sun Oct 25 14:55:23 CET 2015
nor...@theos.my.domain:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 4166717440 (3973MB)
avail mem = 4036304896 (3849MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.4 @ 0xe0010 (80 entries)
bios0: vendor LENOVO version "7UET94WW (3.24 )" date 10/17/2012
bios0: LENOVO 6475BE3
acpi0 at bios0: rev 2
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP SSDT ECDT APIC MCFG HPET SLIC BOOT ASF! SSDT TCPA DMAR 
SSDT SSDT SSDT
acpi0: wakeup devices LID_(S3) SLPB(S3) UART(S3) IGBE(S4) EXP0(S4) EXP1(S4) 
EXP2(S4) EXP3(S4) EXP4(S4) PCI1(S4) USB0(S3) USB3(S3) USB5(S3) EHC0(S3) 
EHC1(S3) HDEF(S4)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpiec0 at acpi0
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM)2 Duo CPU P8400 @ 2.26GHz, 2261.36 MHz
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,SSE4.1,NXE,LONG,LAHF,PERF,SENSOR
cpu0: 3MB 64b/line 8-way L2 cache
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 7 var ranges, 88 fixed ranges
cpu0: apic clock running at 265MHz
cpu0: mwait min=64, max=64, C-substates=0.2.2.2.2.1.3, IBE
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Intel(R) Core(TM)2 Duo CPU P8400 @ 2.26GHz, 2261.00 MHz
cpu1: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,SSE4.1,NXE,LONG,LAHF,PERF,SENSOR
cpu1: 3MB 64b/line 8-way L2 cache
cpu1: smt 0, core 1, package 0
ioapic0 at mainbus0: apid 1 pa 0xfec0, version 20, 24 pins
ioapic0: misconfigured as apic 2, remapped to apid 1
acpimcfg0 at acpi0 addr 0xe000, bus 0-63
acpihpet0 at acpi0: 14318179 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus -1 (AGP_)
acpiprt2 at acpi0: bus 2 (EXP0)
acpiprt3 at acpi0: bus 3 (EXP1)
acpiprt4 at acpi0: bus -1 (EXP2)
acpiprt5 at acpi0: bus 5 (EXP3)
acpiprt6 at acpi0: bus 13 (EXP4)
acpiprt7 at acpi0: bus 21 (PCI1)
acpicpu0 at acpi0: !C3(250@17 mwait.3@0x20), !C2(500@1 mwait.1@0x10), C1(1000@1 
mwait.1), PSS
acpicpu1 at acpi0: !C3(250@17 mwait.3@0x20), !C2(500@1 mwait.1@0x10), C1(1000@1 
mwait.1), PSS
acpipwrres0 at acpi0: PUBS, resource for USB0, USB3, USB5, EHC0, EHC1
acpitz0 at acpi0: critical temperature is 127 degC
acpitz1 at acpi0: critical temperature is 100 degC
acpibtn0 at acpi0: LID_
acpibtn1 at acpi0: SLPB
acpibat0 at acpi0: BAT0 model "42T5264" serial  3499 type LION oem "Panasonic"
acpibat1 at acpi0: BAT1 not present
acpiac0 at acpi0: AC unit online
acpithinkpad0 at acpi0
acpidock0 at acpi0: GDCK docked (15)
cpu0: Enhanced SpeedStep 2261 MHz: speeds: 2267, 2266, 1600, 800 MHz
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 "Intel GM45 Host" rev 0x07
inteldrm0 at pci0 dev 2 function 0 "Intel GM45 Video" rev 0x07
intagp0 at inteldrm0
agp0 at intagp0: aperture at 0xd000, size 0x1000
drm0 at inteldrm0
inteldrm0: msi
inteldrm0: 1440x900
wsdisplay0 at inteldrm0 mux 1: console (std, vt100 emulation)
wsdisplay0: screen 1-5 added (std, vt100 emulation)
"Intel GM45 Video" rev 0x07 at pci0 dev 2 function 1 not configured
"Intel GM45 HECI" rev 0x07 at pci0 dev 3 function 0 not configured
em0 at pci0 dev 25 function 0 "Intel ICH9 IGP M AMT" rev 0x03: msi, address 
00:1c:25:95:39:e7
uhci0 at pci0 dev 26 function 0 "Intel 82801I USB" rev 0x03: apic 1 int 20
uhci1 at pci0 dev 26 function 1 "Intel 82801I USB" rev 0x03: apic 1 int 21
uhci2 at pci0 dev 26 function 2 "Intel 82801I USB" rev 0x03: apic 1 int 22
ehci0 at pci0 dev 26 function 7 "Intel 82801I USB" rev 0x03: apic 1 int 23
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 "Intel EHCI root hub" rev 2.00/1.00 addr 1
azalia0 at pci0 dev 27 function 0 "Intel 82801I HD Audio" rev 0x03: msi
azalia0: codecs: Conexant CX20561
audio0 at azalia0
ppb0 at pci0 dev 28 function 0 "Intel 82801I PCIE" rev 0x03: msi
pci1 at ppb0 bus 2
ppb1 at pci0 dev 28 function 1 "Intel 82801I PCIE" rev 0x03: msi
pci2 at ppb1 bus 3
iwn0 at pci2 dev 0 function 0 "Intel WiFi Link 5300" rev 0x00: msi, MIMO 3T3R, 
MoW, address 00:16:ea:b3:62:e8
ppb2 at pci0 dev 28 function 3 "Intel 82801I PCIE" rev 0x03: msi
pci3 at ppb2 bus 5
ppb3 at pci0 dev 28 function 4 "Intel 82801I PCIE" rev 0x03: msi
pci4 at ppb3 bus 13
uhci3 at pci0 dev 29 function 0 "Intel 82801I USB" rev 0x03: apic 1 int 16
uhci4 at pci0 dev 29 function 1 "Intel 82801I USB" rev 0x03: apic 1 int 17
uhci5 at pci0 dev 29 function 2 "Intel 82801I USB" rev 0x03: apic 1 

telnet: low-delay traffic class for IPv6 connections

2015-10-25 Thread Jérémie Courrèges-Anglas

While here, there is no option to pass a different tos, and no other use
of the "tos" variable out of tn(), so move the "tos" variable in tn()
and assign it the right value from the start.

ok?

Index: commands.c
===
RCS file: /cvs/src/usr.bin/telnet/commands.c,v
retrieving revision 1.73
diff -u -p -p -u -r1.73 commands.c
--- commands.c  25 Oct 2015 14:42:02 -  1.73
+++ commands.c  25 Oct 2015 16:11:17 -
@@ -54,8 +54,6 @@
 #define PATH_SKEY  "/usr/bin/skey"
 #endif
 
-int tos = -1;
-
 char   *hostname;
 
 typedef struct {
@@ -1850,7 +1848,7 @@ tn(int argc, char *argv[])
 struct addrinfo hints, *res, *res0;
 char *cmd, *hostp = 0, *portp = 0, *user = 0, *aliasp = 0;
 int error, retry;
-const int niflags = NI_NUMERICHOST;
+const int niflags = NI_NUMERICHOST, tos = IPTOS_LOWDELAY;
 
 if (connected) {
printf("?Already connected to %s\r\n", hostname);
@@ -1973,13 +1971,18 @@ tn(int argc, char *argv[])
 }
freeaddrinfo(ares);
}
-   if (res->ai_family == AF_INET) {
-   if (tos < 0)
-   tos = IPTOS_LOWDELAY;   /* Low Delay bit */
-   if (tos
-   && (setsockopt(net, IPPROTO_IP, IP_TOS, , sizeof(int)) < 0)
-   && (errno != ENOPROTOOPT))
-   perror("telnet: setsockopt (IP_TOS) (ignored)");
+
+   switch (res->ai_family) {
+   case AF_INET:
+   if (setsockopt(net, IPPROTO_IP, IP_TOS, , sizeof(tos)) < 0
+   && errno != ENOPROTOOPT)
+   perror("telnet: setsockopt (IP_TOS) (ignored)");
+   break;
+   case AF_INET6:
+   if (setsockopt(net, IPPROTO_IPV6, IPV6_TCLASS, ,
+   sizeof(tos)) < 0 && errno != ENOPROTOOPT)
+   perror("telnet: setsockopt (IPV6_TCLASS) (ignored)");
+   break;
}
 
if (debug) {


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: Kill rtable_mpath_conflict

2015-10-25 Thread Claudio Jeker
On Sun, Oct 25, 2015 at 03:22:51PM +0100, Martin Pieuchot wrote:
> Instead of having a separate function to check for MPATH conflicts
> simply pass the gateway to rtable_insert().  Some regress tests
> outputs will need an update as we're now doing one more rtalloc(9)
> call in RTM_ADD. 
> 
> This is a step towards MPATH by default.
> 
> ok?

Looks good to me. We still return EEXIST so there should be no visible
change because of this.

 
> Index: net/route.c
> ===
> RCS file: /cvs/src/sys/net/route.c,v
> retrieving revision 1.262
> diff -u -p -r1.262 route.c
> --- net/route.c   25 Oct 2015 11:58:11 -  1.262
> +++ net/route.c   25 Oct 2015 14:14:28 -
> @@ -837,15 +837,6 @@ rtrequest1(int req, struct rt_addrinfo *
>   else
>   memcpy(ndst, info->rti_info[RTAX_DST], dlen);
>  
> -#ifndef SMALL_KERNEL
> - /* Do not permit exactly the same dst/mask/gw pair. */
> - if (rtable_mpath_conflict(tableid, ndst,
> - info->rti_info[RTAX_NETMASK], info->rti_info[RTAX_GATEWAY],
> - prio, info->rti_flags & RTF_MPATH)) {
> - free(ndst, M_RTABLE, dlen);
> - return (EEXIST);
> - }
> -#endif
>   rt = pool_get(_pool, PR_NOWAIT | PR_ZERO);
>   if (rt == NULL) {
>   free(ndst, M_RTABLE, dlen);
> @@ -953,13 +944,15 @@ rtrequest1(int req, struct rt_addrinfo *
>   }
>  
>   error = rtable_insert(tableid, ndst,
> - info->rti_info[RTAX_NETMASK], rt->rt_priority, rt);
> + info->rti_info[RTAX_NETMASK], info->rti_info[RTAX_GATEWAY],
> + rt->rt_priority, rt);
>   if (error != 0 && (crt = rtalloc(ndst, 0, tableid)) != NULL) {
>   /* overwrite cloned route */
>   if ((crt->rt_flags & RTF_CLONED) != 0) {
>   rtdeletemsg(crt, tableid);
>   error = rtable_insert(tableid, ndst,
>   info->rti_info[RTAX_NETMASK],
> + info->rti_info[RTAX_GATEWAY],
>   rt->rt_priority, rt);
>   }
>   rtfree(crt);
> Index: net/rtable.c
> ===
> RCS file: /cvs/src/sys/net/rtable.c,v
> retrieving revision 1.14
> diff -u -p -r1.14 rtable.c
> --- net/rtable.c  22 Oct 2015 17:19:38 -  1.14
> +++ net/rtable.c  25 Oct 2015 14:13:57 -
> @@ -292,7 +292,8 @@ rtable_match(unsigned int rtableid, stru
>  
>  int
>  rtable_insert(unsigned int rtableid, struct sockaddr *dst,
> -struct sockaddr *mask, uint8_t prio, struct rtentry *rt)
> +struct sockaddr *mask, struct sockaddr *gateway, uint8_t prio,
> +struct rtentry *rt)
>  {
>   struct radix_node_head  *rnh;
>   struct radix_node   *rn = (struct radix_node *)rt;
> @@ -301,6 +302,15 @@ rtable_insert(unsigned int rtableid, str
>   if (rnh == NULL)
>   return (EAFNOSUPPORT);
>  
> +#ifndef SMALL_KERNEL
> + if (rnh->rnh_multipath) {
> + /* Do not permit exactly the same dst/mask/gw pair. */
> + if (rt_mpath_conflict(rnh, dst, mask, gateway, prio,
> + ISSET(rt->rt_flags, RTF_MPATH)))
> + return (EEXIST);
> + }
> +#endif
> +
>   rn = rn_addroute(dst, mask, rnh, rn, prio);
>   if (rn == NULL)
>   return (ESRCH);
> @@ -382,22 +392,6 @@ rtable_mpath_match(unsigned int rtableid
>   return (rt);
>  }
>  
> -int
> -rtable_mpath_conflict(unsigned int rtableid, struct sockaddr *dst,
> -struct sockaddr *mask, struct sockaddr *gateway, uint8_t prio, int 
> mpathok)
> -{
> - struct radix_node_head  *rnh;
> -
> - rnh = rtable_get(rtableid, dst->sa_family);
> - if (rnh == NULL)
> - return (EAFNOSUPPORT);
> -
> - if (rnh->rnh_multipath == 0)
> - return (0);
> -
> - return (rt_mpath_conflict(rnh, dst, mask, gateway, prio, mpathok));
> -}
> -
>  /* Gateway selection by Hash-Threshold (RFC 2992) */
>  struct rtentry *
>  rtable_mpath_select(struct rtentry *rt, uint32_t hash)
> @@ -526,7 +520,8 @@ rtable_match(unsigned int rtableid, stru
>  
>  int
>  rtable_insert(unsigned int rtableid, struct sockaddr *dst,
> -struct sockaddr *mask, uint8_t prio, struct rtentry *rt)
> +struct sockaddr *mask, struct sockaddr *gateway, uint8_t prio,
> +struct rtentry *rt)
>  {
>  #ifndef SMALL_KERNEL
>   struct rtentry  *mrt;
> @@ -545,6 +540,29 @@ rtable_insert(unsigned int rtableid, str
>   if (plen == -1)
>   return (EINVAL);
>  
> +#ifndef SMALL_KERNEL
> + /* Do not permit exactly the same dst/mask/gw pair. */
> + an = art_lookup(ar, addr, plen);
> + if (an != NULL && 

Re: inteldrm(4) diff that needs testing

2015-10-25 Thread Gregor Best
On Sun, Oct 25, 2015 at 08:20:50AM -0700, Philip Guenther wrote:
> [...]
> This looks like the result of applying the diff but not running config
> [...]



Thanks for the clue bat. It's working fine on a Thinkpad T400.

-- 
Gregor



Re: inteldrm(4) diff that needs testing

2015-10-25 Thread Sebastien Marie
On Sun, Oct 25, 2015 at 08:20:50AM -0700, Philip Guenther wrote:
> On Sun, Oct 25, 2015 at 5:43 AM, Gregor Best  wrote:
> > Hi Mark,
> >
> > On Sat, Oct 24, 2015 at 11:48:01PM +0200, Mark Kettenis wrote:
> >> [...]
> >> This diff needs to be tested on a wide range of hardware.  So if you
> >> have a machine with inteldrm(4), please give it a shot.  I'm
> >> particularly interested in testing on an x40.
> >> [...]
> >
> 
> This looks like the result of applying the diff but not running config
> (such as by doing "make config" inside your kernel build directory)
> before recompiling.  No shame: I made that mistake got a panic and
> started to write it up before saying "wait a moment" and having it
> work with a reconfigured kernel.
> 
> (Sebastien, your panic looks close to the one I got when I made that
> very mistake, so verify you ran config...)

Hey, you are right !

running config before rebuilding help a lot: I see no more problem.
-- 
Sebastien Marie



Re: inteldrm(4) diff that needs testing

2015-10-25 Thread Mark Kettenis
> Date: Sat, 24 Oct 2015 23:48:01 +0200 (CEST)
> From: Mark Kettenis 
> 
> The diff below makes inteldrm(4) attach directly to pci(4) instead of
> vga(1).  Because inteldrm(4) depends on intagp(4), this also make
> intagp(4) a child of inteldrm(4).  Ultimately I'd like to integrate
> intagp(4) into inteldrm(4), but that's going to be a bit more work.
> 
> This diff is needed to make inteldrm(4) work when OpenBSD gets booted
> by UEFI firmware.  It will also make inteldrm(4) work on machines with
> discrete graphics.
> 
> This diff needs to be tested on a wide range of hardware.  So if you
> have a machine with inteldrm(4), please give it a shot.  I'm
> particularly interested in testing on an x40.

Several people reported that the diff crashed their system.  It looks
like those people forgot to reconfig their kernel before building.
Please try again and run "make config" before rebuilding your kernel.



Re: inteldrm(4) diff that needs testing

2015-10-25 Thread Ralf Horstmann
* Jonathan Gray  [2015-10-25 05:51]:
> On Sat, Oct 24, 2015 at 11:48:01PM +0200, Mark Kettenis wrote:
> > The diff below makes inteldrm(4) attach directly to pci(4) instead of
> > vga(1).  Because inteldrm(4) depends on intagp(4), this also make
> > intagp(4) a child of inteldrm(4).  Ultimately I'd like to integrate
> > intagp(4) into inteldrm(4), but that's going to be a bit more work.
> > 
> > This diff is needed to make inteldrm(4) work when OpenBSD gets booted
> > by UEFI firmware.  It will also make inteldrm(4) work on machines with
> > discrete graphics.
> > 
> > This diff needs to be tested on a wide range of hardware.  So if you
> > have a machine with inteldrm(4), please give it a shot.  I'm
> > particularly interested in testing on an x40.
> 
> x40 before the diff:
> 
> vga1 at pci0 dev 2 function 0 "Intel 82855GM Video" rev 0x02
> intagp0 at vga1
> agp0 at intagp0: aperture at 0xe000, size 0x800
> inteldrm0 at vga1
> drm0 at inteldrm0
> inteldrm0: apic 1 int 16
> inteldrm0: 1024x768
> wsdisplay0 at vga1 mux 1: console (std, vt100 emulation)
> wsdisplay0: screen 1-5 added (std, vt100 emulation)
> "Intel 82855GM Video" rev 0x02 at pci0 dev 2 function 1 not configured
> 
> after with serial console:
> 
> inteldrm0 at pci0 dev 2 function 0 "Intel 82855GM Video" rev 0x02
> intagp0 at inteldrm0
> agp0 at intagp0: aperture at 0xe000, size 0x800
> drm0 at inteldrm0
> inteldrm0: can't map mmio space
> inteldrm1 at pci0 dev 2 function 1 "Intel 82855GM Video" rev 0x02
> intagp at inteldrm1 not configured
> drm1 at inteldrm1
> inteldrm1: couldn't map interrupt
> Memory manager not clean. Delaying takedown
> 
> video mode doesn't switch and can't change to vt, goes multiuser and can
> login via ssh.
> 
> With glass console it hangs after "root on wd0a" with no mode switch.

I see similar behaviour on an Asus i386 laptop with 855GM. It stops after
"root on wd0a". No video mode switch during boot and no ssh login possible, but
ddb still works. See dmesg below without and with patch applied.

Regards,
Ralf

OpenBSD 5.8-current (GENERIC) #1278: Tue Oct 20 09:46:53 MDT 2015
dera...@i386.openbsd.org:/usr/src/sys/arch/i386/compile/GENERIC
cpu0: Intel(R) Pentium(R) M processor 1400MHz ("GenuineIntel" 686-class) 1.41 
GHz
cpu0: 
FPU,V86,DE,PSE,TSC,MSR,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,TM,PBE,EST,TM2,PERF
real mem  = 527187968 (502MB)
avail mem = 504582144 (481MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: date 03/08/04, SMBIOS rev. 2.3 @ 0xf5620 (37 entries)
bios0: vendor American Megatrends Inc. version "0208" date 03/08/2004
bios0: ASUSTeK Computer Inc. M2N
acpi0 at bios0: rev 0
acpi0: sleep states S0 S1 S3 S4 S5
acpi0: tables DSDT FACP OEMB
acpi0: wakeup devices P0P1(S4) LAN0(S4) CBS0(S3) CBS1(S3) P394(S3) MODM(S3) 
USB1(S3) USB2(S3) USB3(S3) EHCI(S3) SLPB(S4)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpi0: WARNING EC not initialized
acpi0: WARNING EC not initialized
acpi0: WARNING EC not initialized
acpi0: WARNING EC not initialized
acpi0: WARNING EC not initialized
acpi0: WARNING EC not initialized
acpi0: WARNING EC not initialized
acpi0: WARNING EC not initialized
acpi0: WARNING EC not initialized
acpi0: WARNING EC not initialized
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 1 (P0P1)
acpiec0 at acpi0
acpicpu0 at acpi0: !C3(@101 io@0xe415), !C2(@1 io@0xe414), C1(@1 halt!), PSS
acpitz0 at acpi0: critical temperature is 110 degC
acpipwrres0 at acpi0: GFAN, resource for SBRG, FN00
acpiac0 at acpi0: AC unit online
acpibat0 at acpi0: BAT0 model "M2N" serial   type LIon oem "ASUSTEK"
acpibtn0 at acpi0: SLPB
acpibtn1 at acpi0: LID_
acpiasus at acpi0 not configured
bios0: ROM list: 0xc/0xd200! 0xcd800/0x1000
cpu0 at mainbus0: (uniprocessor)
mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
cpu0: Enhanced SpeedStep 1401 MHz: speeds: 1400, 1400, 1400, 1400, 1400, 1400, 
1200, 1000, 800, 600 MHz
pci0 at mainbus0 bus 0: configuration mode 1 (bios)
pchb0 at pci0 dev 0 function 0 "Intel 82855GM Host" rev 0x02
"Intel 82855GM Memory" rev 0x02 at pci0 dev 0 function 1 not configured
"Intel 82855GM Config" rev 0x02 at pci0 dev 0 function 3 not configured
vga1 at pci0 dev 2 function 0 "Intel 82855GM Video" rev 0x02
intagp0 at vga1
agp0 at intagp0: aperture at 0xf000, size 0x800
inteldrm0 at vga1
drm0 at inteldrm0
inteldrm0: irq 5
inteldrm0: 1024x768
wsdisplay0 at vga1 mux 1: console (std, vt100 emulation)
wsdisplay0: screen 1-5 added (std, vt100 emulation)
"Intel 82855GM Video" rev 0x02 at pci0 dev 2 function 1 not configured
uhci0 at pci0 dev 29 function 0 "Intel 82801DB USB" rev 0x03: irq 5
uhci1 at pci0 dev 29 function 1 "Intel 82801DB USB" rev 0x03: irq 5
uhci2 at pci0 dev 29 function 2 "Intel 82801DB USB" rev 0x03: irq 5
ehci0 at pci0 dev 29 function 7 "Intel 82801DB USB" rev 0x03: irq 4
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 "Intel EHCI root hub" rev 2.00/1.00 addr 1
ppb0 at 

sed: better error message

2015-10-25 Thread Tobias Stoeckmann
$ sed s/a/b/ /nofile
sed: 0: /nofile: /nofile

That message doesn't tell me a lot, let's better write
strerror(errno) if fopen returns NULL:

$ ./sed s/a/b/ /nofile
sed: 0: /nofile: No such file or directory

Index: main.c
===
RCS file: /cvs/src/usr.bin/sed/main.c,v
retrieving revision 1.27
diff -u -p -u -p -r1.27 main.c
--- main.c  10 Oct 2015 20:18:30 -  1.27
+++ main.c  25 Oct 2015 20:01:19 -
@@ -389,7 +389,7 @@ mf_fgets(SPACE *sp, enum e_spflag spflag
outfname = "stdout";
}
if ((infile = fopen(fname, "r")) == NULL) {
-   err(WARNING, "%s", fname);
+   err(WARNING, "%s", strerror(errno));
rval = 1;
continue;
}



Re: inteldrm(4) diff that needs testing

2015-10-25 Thread Mark Kettenis
> Date: Sun, 25 Oct 2015 15:50:51 +0100
> From: Stefan Sperling 
> 
> On Sat, Oct 24, 2015 at 11:48:01PM +0200, Mark Kettenis wrote:
> > The diff below makes inteldrm(4) attach directly to pci(4) instead of
> > vga(1).  Because inteldrm(4) depends on intagp(4), this also make
> > intagp(4) a child of inteldrm(4).  Ultimately I'd like to integrate
> > intagp(4) into inteldrm(4), but that's going to be a bit more work.
> > 
> > This diff is needed to make inteldrm(4) work when OpenBSD gets booted
> > by UEFI firmware.  It will also make inteldrm(4) work on machines with
> > discrete graphics.
> 
> On the Thinkpad Helix 2 (UEFI only machine) inteldrm now attaches.
> However, it crashes shortly after:

Yes.  This diff is only a step towards properly supporting UEFI.



Re: inteldrm(4) diff that needs testing

2015-10-25 Thread Matthieu Herrb
On Sat, Oct 24, 2015 at 11:48:01PM +0200, Mark Kettenis wrote:
> The diff below makes inteldrm(4) attach directly to pci(4) instead of
> vga(1).  Because inteldrm(4) depends on intagp(4), this also make
> intagp(4) a child of inteldrm(4).  Ultimately I'd like to integrate
> intagp(4) into inteldrm(4), but that's going to be a bit more work.
> 
> This diff is needed to make inteldrm(4) work when OpenBSD gets booted
> by UEFI firmware.  It will also make inteldrm(4) work on machines with
> discrete graphics.
> 
> This diff needs to be tested on a wide range of hardware.  So if you
> have a machine with inteldrm(4), please give it a shot.  I'm
> particularly interested in testing on an x40.

Works for me on my X240. Dmesg below. Same result as jsg@ on the X40
(hangs at root on  ...

OpenBSD 5.8-current (GENERIC.MP) #126: Sun Oct 25 19:44:49 CET 2015
matth...@nebraska.herrb.net:/usr/obj/GENERIC.MP
real mem = 8246276096 (7864MB)
avail mem = 7992229888 (7621MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.7 @ 0xdcd3d000 (60 entries)
bios0: vendor LENOVO version "GIET73WW (2.23 )" date 04/10/2014
bios0: LENOVO 20ALCTO1WW
acpi0 at bios0: rev 2
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP SLIC DBGP ECDT HPET APIC MCFG SSDT SSDT SSDT SSDT SSDT 
SSDT SSDT SSDT PCCT SSDT TCPA UEFI MSDM ASF! BATB FPDT UEFI SSDT DMAR
acpi0: wakeup devices LID_(S4) SLPB(S3) IGBE(S4) EXP2(S4) XHCI(S3) EHC1(S3)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpiec0 at acpi0
acpihpet0 at acpi0: 14318179 Hz
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM) i7-4600U CPU @ 2.10GHz, 798.29 MHz
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,ABM,PERF,ITSC,FSGSBASE,BMI1,HLE,AVX2,SMEP,BMI2,ERMS,INVPCID,RTM,SENSOR,ARAT
cpu0: 256KB 64b/line 8-way L2 cache
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 10 var ranges, 88 fixed ranges
cpu0: apic clock running at 99MHz
cpu0: mwait min=64, max=64, C-substates=0.2.1.2.4.1.1.1, IBE
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Intel(R) Core(TM) i7-4600U CPU @ 2.10GHz, 798.16 MHz
cpu1: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,ABM,PERF,ITSC,FSGSBASE,BMI1,HLE,AVX2,SMEP,BMI2,ERMS,INVPCID,RTM,SENSOR,ARAT
cpu1: 256KB 64b/line 8-way L2 cache
cpu1: smt 1, core 0, package 0
cpu2 at mainbus0: apid 2 (application processor)
cpu2: Intel(R) Core(TM) i7-4600U CPU @ 2.10GHz, 798.16 MHz
cpu2: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,ABM,PERF,ITSC,FSGSBASE,BMI1,HLE,AVX2,SMEP,BMI2,ERMS,INVPCID,RTM,SENSOR,ARAT
cpu2: 256KB 64b/line 8-way L2 cache
cpu2: smt 0, core 1, package 0
cpu3 at mainbus0: apid 3 (application processor)
cpu3: Intel(R) Core(TM) i7-4600U CPU @ 2.10GHz, 798.16 MHz
cpu3: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,LONG,LAHF,ABM,PERF,ITSC,FSGSBASE,BMI1,HLE,AVX2,SMEP,BMI2,ERMS,INVPCID,RTM,SENSOR,ARAT
cpu3: 256KB 64b/line 8-way L2 cache
cpu3: smt 1, core 1, package 0
ioapic0 at mainbus0: apid 2 pa 0xfec0, version 20, 40 pins
acpimcfg0 at acpi0 addr 0xf800, bus 0-63
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus -1 (PEG_)
acpiprt2 at acpi0: bus 2 (EXP1)
acpiprt3 at acpi0: bus 3 (EXP2)
acpiprt4 at acpi0: bus -1 (EXP3)
acpicpu0 at acpi0: C3(200@506 mwait.1@0x60), C2(200@148 mwait.1@0x33), 
C1(1000@1 mwait.1), PSS
acpicpu1 at acpi0: C3(200@506 mwait.1@0x60), C2(200@148 mwait.1@0x33), 
C1(1000@1 mwait.1), PSS
acpicpu2 at acpi0: C3(200@506 mwait.1@0x60), C2(200@148 mwait.1@0x33), 
C1(1000@1 mwait.1), PSS
acpicpu3 at acpi0: C3(200@506 mwait.1@0x60), C2(200@148 mwait.1@0x33), 
C1(1000@1 mwait.1), PSS
acpipwrres0 at acpi0: PUBS, resource for XHCI, EHC1
acpitz0 at acpi0: critical temperature is 200 degC
acpibtn0 at acpi0: LID_
acpibtn1 at acpi0: SLPB
acpibat0 at acpi0: BAT0 model "45N1773" serial 16792 type LION oem "SANYO"
acpibat1 at acpi0: BAT1 model "45N1738" serial  3066 type LION oem "LGC"
acpiac0 at acpi0: AC unit offline
acpithinkpad0 at acpi0
cpu0: Enhanced SpeedStep 798 MHz: speeds: 

rtadvd: pledge() and pidfile() are in a boat

2015-10-25 Thread Jérémie Courrèges-Anglas

So I took look at which pledge requests rtadvd could use.

Turns out it can't call pledge early, because it attempts to retrieve
IPV6CTL_FORWARDING and pledge currently denies it.  rtadvd is the only
user of IPV6CTL_FORWARDING in base, so IMO it doesn't call for a change
in kern_pledge.c.  There are other exotic setsockopt calls that would
probably prevent early pledge calls.

Another minor issue is that pidfile(3) installs an atexit(3) handler
that calls unlink(2).  It makes little sense to have rtadvd slaughtered
when it tries to unlink /var/run/rtadvd.pid, especially as that path
isn't reachable anymore (rtadvd runs privdrop, chrooted).  And it makes
little sense to add "cpath" to the pledge request, just to have rtadvd
exit properly.  Let's not just write down a pid file.

Thus, this diff does two things:
- remove the use of pidfile(3).  rc.d doesn't need this.
- introduce a single, minimal pledge(2) request just before the main
  loop

I'll probably commit the pidfile() removal and the pledge request in
separate commits.

Comments / oks?

Index: Makefile
===
RCS file: /cvs/src/usr.sbin/rtadvd/Makefile,v
retrieving revision 1.6
diff -u -p -r1.6 Makefile
--- Makefile21 Apr 2008 20:40:55 -  1.6
+++ Makefile25 Oct 2015 19:35:27 -
@@ -4,8 +4,6 @@ PROG=   rtadvd
 SRCS=  rtadvd.c rrenum.c advcap.c if.c config.c timer.c dump.c log.c
 
 CFLAGS+=-Wall
-LDADD+=-lutil
-DPADD+=${LIBUTIL}
 MAN=   rtadvd.8 rtadvd.conf.5
 
 .include 
Index: rtadvd.c
===
RCS file: /cvs/src/usr.sbin/rtadvd/rtadvd.c,v
retrieving revision 1.55
diff -u -p -r1.55 rtadvd.c
--- rtadvd.c20 Aug 2015 22:39:29 -  1.55
+++ rtadvd.c25 Oct 2015 19:36:38 -
@@ -55,7 +55,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include "rtadvd.h"
@@ -224,10 +223,6 @@ main(argc, argv)
 
sock_open();
 
-   /* record the current PID */
-   if (pidfile(NULL) < 0)
-   log_warnx("failed to open the pid log file, run anyway.");
-
if (sflag == 0) {
rtsock_open();
}
@@ -242,6 +237,9 @@ main(argc, argv)
setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) ||
setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid))
fatal("cannot drop privileges");
+
+   if (pledge("stdio inet route", NULL) == -1)
+   err(1, "pledge");
 
npfd = 1;
pfd[0].fd = sock;


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE