Re: horribly slow fsck_ffs pass1 performance
On Sat, Apr 02, 2011 at 01:45:36PM -0500, Amit Kulkarni wrote: > Hi, > > I am replying in a single email. > > I do a fsck once in a while, not regular. In the last 6-8 months I > might have done it about 5 times. And I did it multi-user the few > times I did it, but plan on doing it single user in future and I do > plan to do it monthly. After seeing the messages when you fsck, it is > better to do it monthly. FreeBSD which is the origin of FFS does a > background fsck, and if Kirk McCusick feels so strongly I will do it > too. (I remember somebody talking about having background fsck here on > a openbsd list, but I forgot who it was). Couple of misconceptions here. 1. A fsck on a rw mounted filesystem does not give ANY useful information. You can have both false positives and false negatives. 2. FFS didn't originate form FreeBSD. It was originally released in BSD 4.2, and further development continued --until this day-- in all BSD derivatives. Of course major work has been done by McCusick in FreeBSD. On a side note, background fsck isn't exactly the holy grail. See for eample http://lists.freebsd.org/pipermail/freebsd-fs/2010-July/008955.html Even McKusick says that isn't enough to depend on it, and a regular fsck is needed afterwards. Note the background fscks are only run on filesystems that were unclean on boot. -Otto
A solo 2 meses de la Cumbre de Especialidades Juveniles Argentina
Mail para ser visto con conexisn, si no puede verlo, click aqum [IMAGE] FeedBack [IMAGE] FeedBack Feedback, comunicacion en serio [IMAGE] [IMAGE] Mas Info: Email: i...@especialidadesjuveniles.com Web Site: www.especialidadesjuveniles.com Facebook: Especialidades Juveniles Argentina[IMAGE] Prensa Cumbre Nacional de Lmderes de Jsvenes Leonel Rossi, Agencia Feedback. bl Agencia de Prensa y Noticias, servicio de Mailing y Publicidad email: veron...@agenciafeedback.com.ar | website: www.agenciafeedback.com.ar bt Si usted no esta interesado en recibir mas informacion proporcionada por Feedback, Agencia de Prensa, envmenos un e-mail indicando en el asunto la palabra "Eliminar" a prensafeedback@gmail y sera dado de baja automaticamente. Para subscribirse o por algun tercero que desee hacerlo, tambien envienos a la misma direccion de email resaltando en el asunto la palabra "Registro". Nuevamente disculpe por las molestias que le pudimos haber ocasionado.
Re: Adding support for AI_FQDN to getaddrinfo(3)?
On Sat, 2 Apr 2011, Damien Miller wrote: > AI_FQDN solves these problems quite nicely. It is also useful for web > browsers that face a similar problem (e.g. https://intranet/) but > getting them to adopt it might be more tricky. I'd love to see this get > deployed so we can use it in OpenSSH (which we can change quickly) ... and here is a diff to do it: (NB. this diff doesn't include any backwards compatibility so hosts that are known only by unqualified names might trigger "new hostkey" messages) Index: ssh.c === RCS file: /cvs/src/usr.bin/ssh/ssh.c,v retrieving revision 1.356 diff -u -p -r1.356 ssh.c --- ssh.c 6 Jan 2011 22:23:53 - 1.356 +++ ssh.c 3 Apr 2011 01:44:37 - @@ -571,9 +571,9 @@ main(int ac, char **av) usage(); options.user = p; *cp = '\0'; - host = ++cp; + host = xstrdup(++cp); } else - host = *av; + host = xstrdup(*av); if (ac > 1) { optind = optreset = 1; goto again; @@ -739,7 +739,7 @@ main(int ac, char **av) timeout_ms = options.connection_timeout * 1000; /* Open a connection to the remote host. */ - if (ssh_connect(host, &hostaddr, options.port, + if (ssh_connect(&host, &hostaddr, options.port, options.address_family, options.connection_attempts, &timeout_ms, options.tcp_keep_alive, original_effective_uid == 0 && options.use_privileged_port, Index: sshconnect.c === RCS file: /cvs/src/usr.bin/ssh/sshconnect.c,v retrieving revision 1.232 diff -u -p -r1.232 sshconnect.c --- sshconnect.c16 Jan 2011 11:50:36 - 1.232 +++ sshconnect.c3 Apr 2011 01:44:37 - @@ -324,7 +324,7 @@ timeout_connect(int sockfd, const struct * the daemon. */ int -ssh_connect(const char *host, struct sockaddr_storage * hostaddr, +ssh_connect(char **host, struct sockaddr_storage * hostaddr, u_short port, int family, int connection_attempts, int *timeout_ms, int want_keepalive, int needpriv, const char *proxy_command) { @@ -338,17 +338,20 @@ ssh_connect(const char *host, struct soc /* If a proxy command is given, connect using it. */ if (proxy_command != NULL) - return ssh_proxy_connect(host, port, proxy_command); + return ssh_proxy_connect(*host, port, proxy_command); /* No proxy command. */ memset(&hints, 0, sizeof(hints)); hints.ai_family = family; hints.ai_socktype = SOCK_STREAM; +#ifdef AI_FQDN + hints.ai_flags = AI_FQDN; +#endif snprintf(strport, sizeof strport, "%u", port); - if ((gaierr = getaddrinfo(host, strport, &hints, &aitop)) != 0) + if ((gaierr = getaddrinfo(*host, strport, &hints, &aitop)) != 0) fatal("%s: Could not resolve hostname %.100s: %s", __progname, - host, ssh_gai_strerror(gaierr)); + *host, ssh_gai_strerror(gaierr)); for (attempt = 0; attempt < connection_attempts; attempt++) { if (attempt > 0) { @@ -370,7 +373,7 @@ ssh_connect(const char *host, struct soc continue; } debug("Connecting to %.200s [%.100s] port %s.", - host, ntop, strport); + *host, ntop, strport); /* Create a socket for connecting. */ sock = ssh_create_socket(needpriv, ai); @@ -382,6 +385,15 @@ ssh_connect(const char *host, struct soc timeout_ms) >= 0) { /* Successful connection. */ memcpy(hostaddr, ai->ai_addr, ai->ai_addrlen); +#ifdef AI_FQDN + if (ai->ai_canonname != NULL || + strcmp(*host, ai->ai_canonname) != 0) { + debug3("%s: canonicalised %s => %s", + __func__, *host, ai->ai_canonname); + free(*host); + *host = xstrdup(ai->ai_canonname); + } +#endif break; } else { debug("connect to address %s port %s: %s", @@ -399,7 +411,7 @@ ssh_connect(const char *host, struct soc /* Return failure if we didn't get a successful connection. */ if (sock == -1) { error("ssh: connect to host %s port %s: %s", - host, strport, strerror(errno)); + *host, strport, strerror(errno));
Re: relax gcc -Wsentinel checking
> Date: Sat, 2 Apr 2011 11:13:05 + > From: Miod Vallat > > The -Wsentinel warning is supposed to complain when the last argument in > a call to a function which has __attribute__((sentinel)) is not a NULL > pointer. > > However, the current implementation of the check in gcc 3 and gcc 4 will > warn if the last argument is not explicitely declared as a pointer type, > i.e. > execl(foo, bar, (const char *)NULL) > will not warn, but > execl(foo, bar, NULL) > will cause a false warning, because NULL is defined as 0L for non-C++ > code. > > The following diff relaxes the check to let it accept either a pointer > or an integer type of the same width as a pointer (i.e. on a 64 bit > platform, using 0L will compile silently, but using 0 will). > > Ok? (note that this has only been tested on gcc 4, the gcc 3 version is > similar but has not even been checked to compile yet) Not really ok. Given the way the ISO C standard is formulated, not casting NULL in this case is a genuine bug. One can argue though, that defining NULL in such a way that it is not usable as a sentinel value would be really really silly, and that it is not our job to catch missing casts like this. In that case though, I'd propose that we change our definition of NULL to #define NULL ((void *)0) instead of modifying our compilers. > Index: gnu/gcc/gcc/c-common.c > === > RCS file: /cvs/src/gnu/gcc/gcc/c-common.c,v > retrieving revision 1.3 > diff -u -p -r1.3 c-common.c > --- gnu/gcc/gcc/c-common.c12 May 2010 13:35:20 - 1.3 > +++ gnu/gcc/gcc/c-common.c2 Apr 2011 11:04:49 - > @@ -5498,15 +5498,17 @@ check_function_sentinel (tree attrs, tre > } > > /* Validate the sentinel. */ > - if ((!POINTER_TYPE_P (TREE_TYPE (TREE_VALUE (sentinel))) > -|| !integer_zerop (TREE_VALUE (sentinel))) > + sentinel = TREE_VALUE (sentinel); > + if ((!(POINTER_TYPE_P (TREE_TYPE (sentinel)) > + || (TREE_CODE (sentinel) == INTEGER_CST > + && TYPE_PRECISION (TREE_TYPE (sentinel)) == POINTER_SIZE)) > +|| !integer_zerop (sentinel)) > /* Although __null (in C++) is only an integer we allow it >nevertheless, as we are guaranteed that it's exactly >as wide as a pointer, and we don't want to force >users to cast the NULL they have written there. >We warn with -Wstrict-null-sentinel, though. */ > - && (warn_strict_null_sentinel > - || null_node != TREE_VALUE (sentinel))) > + && (warn_strict_null_sentinel || null_node != sentinel)) > warning (OPT_Wformat, "missing sentinel in function call"); > } > } > Index: gnu/usr.bin/gcc/gcc/c-common.c > === > RCS file: /cvs/src/gnu/usr.bin/gcc/gcc/c-common.c,v > retrieving revision 1.6 > diff -u -p -r1.6 c-common.c > --- gnu/usr.bin/gcc/gcc/c-common.c16 Oct 2009 12:22:07 - 1.6 > +++ gnu/usr.bin/gcc/gcc/c-common.c2 Apr 2011 11:04:50 - > @@ -6502,8 +6502,11 @@ check_function_sentinel (attrs, params) > } > > /* Validate the sentinel. */ > - if (!POINTER_TYPE_P (TREE_TYPE (TREE_VALUE (sentinel))) > - || !integer_zerop (TREE_VALUE (sentinel))) > + sentinel = TREE_VALUE (sentinel); > + if (!(POINTER_TYPE_P (TREE_TYPE (sentinel)) > + || (TREE_CODE (sentinel) == INTEGER_CST > + && TYPE_PRECISION (TREE_TYPE (sentinel)) == POINTER_SIZE)) > +|| !integer_zerop (sentinel)) > warning ("missing sentinel in function call"); > } > }
Re: horribly slow fsck_ffs pass1 performance
On Sat, 02 Apr 2011 17:46:51 +0200 Benny Lofgren wrote: > It must mean they don't trust their own file > systems, which frankly I find a bit unsettling... I'd rather use a file > system that's been field proven for decades than use something thats > just come out of the experimenting shop. Hopefully they're just trying to highlight that windows seems to skip checks 70% of the time after unsafe shutdowns.
Re: horribly slow fsck_ffs pass1 performance
On 2011/04/02 13:45, Amit Kulkarni wrote: > > I do a fsck once in a while, not regular. In the last 6-8 months I > might have done it about 5 times. And I did it multi-user the few > times I did it, but plan on doing it single user in future and I do > plan to do it monthly. After seeing the messages when you fsck, it is > better to do it monthly. FreeBSD which is the origin of FFS does a ^^ hmm? > background fsck, and if Kirk McCusick feels so strongly I will do it > too. (I remember somebody talking about having background fsck here on > a openbsd list, but I forgot who it was). the background fsck there isn't done every time, just after unclean shutdown (and a right pain it was too last time I experienced it, fsck can use a lot of RAM ...)
Re: horribly slow fsck_ffs pass1 performance
Hi, I am replying in a single email. I do a fsck once in a while, not regular. In the last 6-8 months I might have done it about 5 times. And I did it multi-user the few times I did it, but plan on doing it single user in future and I do plan to do it monthly. After seeing the messages when you fsck, it is better to do it monthly. FreeBSD which is the origin of FFS does a background fsck, and if Kirk McCusick feels so strongly I will do it too. (I remember somebody talking about having background fsck here on a openbsd list, but I forgot who it was). FS code in OpenBSD is mature and appears to be better than on FreeBSD. Linux has a problem with fsync() on ext3 (maybe even ext4), that is why they do it so often. I read that they go for more speed and pay less attention to data integrity. I was new to OpenBSD since about 6-8 months, so I will try it out. I don't have anything important on that OpenBSD machine, everything is backed up safely. Once I am fully satisfied I won't do it monthly, maybe less or most likely never. I will be experimenting with fsck since that new code change by Otto at least for the next few months. You guys know the limits and capabilities. So *you* don't, some others might or might not. But I am learning and wanting to be on a stable virus free, trojan free, crapware free machine. The choice for me is one of the BSD's. What is a new guy to know? Thanks, amit On Sat, Apr 2, 2011 at 10:46 AM, Benny Lofgren wrote: > On 2011-04-01 19.03, Amit Kulkarni wrote: >> Thank you Arthur and the team for a very fast turnaround! Thank you >> for reducing the pain. I will schedule a fsck every month or so, >> knowing it won't screw up anything and be done really quick. > > Why "schedule" fsck runs at all? The file system code is very mature and > although of course it would be unwise to declare it bug free, I see very > little reason to run fsck on a file system unless there have been some > problem like an unclean shutdown to prompt it (in which case of course, > the system does it for you automatically when rebooting). > > I've noticed that some (all?) linux systems do uncalled-for file system > checks at boot if no check have been made recently, but I've never > understood this practice. It must mean they don't trust their own file > systems, which frankly I find a bit unsettling... I'd rather use a file > system that's been field proven for decades than use something thats > just come out of the experimenting shop. > > > Regards, > /Benny > > -- > internetlabbet.se / work: +46 8 551 124 80 / "Words must > Benny Lvfgren/ mobile: +46 70 718 11 90 / be weighed, >/ fax:+46 8 551 124 89/not counted." > /email: benny -at- internetlabbet.se
Re: remove bufqs from vnds
On Sat, Apr 02, 2011 at 01:58:22PM +, Thordur Bjornsson wrote: > Hi, > > So, it doesn't make sense to have a bufq for vnds. > > The disk that stores the image backing the vnd has it's own bufq > ofcourse and what happens is that vnd puts a buf on it's bufq, > which is promptly removed when we call vndstart, followed by a call > to strategy so the buf ends up almost immediately on the bufq > on the underlaying disk. > > Tested on vnd/svnd (and with the image on NFS. vnd is broken on nfs!). > > OK? > Makes sense to me. ok krw@. Ken > > Index: vnd.c > === > RCS file: /home/thib/cvs/src/sys/dev/vnd.c,v > retrieving revision 1.107 > diff -u -p -r1.107 vnd.c > --- vnd.c 15 Feb 2011 20:02:11 - 1.107 > +++ vnd.c 2 Apr 2011 11:34:38 - > @@ -127,8 +127,6 @@ struct vnd_softc { > struct disk sc_dk; > char sc_dk_name[16]; > > - struct bufq sc_bufq; > - > char sc_file[VNDNLEN]; /* file we're covering */ > int sc_flags; /* flags */ > size_t sc_size; /* size of vnd in sectors */ > @@ -159,7 +157,7 @@ int numvnd = 0; > void vndattach(int); > > void vndclear(struct vnd_softc *); > -void vndstart(struct vnd_softc *); > +void vndstart(struct vnd_softc *, struct buf *); > int vndsetcred(struct vnd_softc *, struct ucred *); > void vndiodone(struct buf *); > void vndshutdown(void); > @@ -445,64 +443,50 @@ vndstrategy(struct buf *bp) > > /* No bypassing of buffer cache? */ > if (vndsimple(bp->b_dev)) { > - /* Loop until all queued requests are handled. */ > - for (;;) { > - int part = DISKPART(bp->b_dev); > - daddr64_t off = DL_SECTOBLK(vnd->sc_dk.dk_label, > - > DL_GETPOFFSET(&vnd->sc_dk.dk_label->d_partitions[part])); > - aiov.iov_base = bp->b_data; > - auio.uio_resid = aiov.iov_len = bp->b_bcount; > - auio.uio_iov = &aiov; > - auio.uio_iovcnt = 1; > - auio.uio_offset = dbtob((off_t)(bp->b_blkno + off)); > - auio.uio_segflg = UIO_SYSSPACE; > - auio.uio_procp = p; > - > - vn_lock(vnd->sc_vp, LK_EXCLUSIVE | LK_RETRY, p); > - if (bp->b_flags & B_READ) { > - auio.uio_rw = UIO_READ; > - bp->b_error = VOP_READ(vnd->sc_vp, &auio, 0, > - vnd->sc_cred); > - if (vnd->sc_keyctx) > - vndencrypt(vnd, bp->b_data, > -bp->b_bcount, bp->b_blkno, 0); > - } else { > - if (vnd->sc_keyctx) > - vndencrypt(vnd, bp->b_data, > -bp->b_bcount, bp->b_blkno, 1); > - auio.uio_rw = UIO_WRITE; > - /* > - * Upper layer has already checked I/O for > - * limits, so there is no need to do it again. > - */ > - bp->b_error = VOP_WRITE(vnd->sc_vp, &auio, > - IO_NOLIMIT, vnd->sc_cred); > - /* Data in buffer cache needs to be in clear */ > - if (vnd->sc_keyctx) > - vndencrypt(vnd, bp->b_data, > -bp->b_bcount, bp->b_blkno, 0); > - } > - VOP_UNLOCK(vnd->sc_vp, 0, p); > - if (bp->b_error) > - bp->b_flags |= B_ERROR; > - bp->b_resid = auio.uio_resid; > - s = splbio(); > - biodone(bp); > - splx(s); > - > - /* If nothing more is queued, we are done. */ > - if (!bufq_peek(&vnd->sc_bufq)) > - return; > - > + int part = DISKPART(bp->b_dev); > + daddr64_t off = DL_SECTOBLK(vnd->sc_dk.dk_label, > + DL_GETPOFFSET(&vnd->sc_dk.dk_label->d_partitions[part])); > + aiov.iov_base = bp->b_data; > + auio.uio_resid = aiov.iov_len = bp->b_bcount; > + auio.uio_iov = &aiov; > + auio.uio_iovcnt = 1; > + auio.uio_offset = dbtob((off_t)(bp->b_blkno + off)); > + auio.uio_segflg = UIO_SYSSPACE; > + auio.uio_procp = p; > + > + vn_lock(vnd->sc_vp, LK_EXCLUSIVE | LK_RETRY, p); > + if (bp->b_flags & B_READ) { > + auio.uio_rw = UIO_READ; > +
ata.c dma_alloc()
Yet another driver that probably wouldn't like big mem. ok? Ken Index: dev/ata/ata.c === RCS file: /cvs/src/sys/dev/ata/ata.c,v retrieving revision 1.30 diff -u -p -r1.30 ata.c --- dev/ata/ata.c 23 Jul 2010 07:47:12 - 1.30 +++ dev/ata/ata.c 2 Apr 2011 16:23:15 - @@ -32,6 +32,7 @@ #include #include #include +#include #include @@ -85,7 +86,7 @@ ata_get_params(struct ata_drive_datas *d return CMD_ERR; } - tb = malloc(ATAPARAMS_SIZE, M_DEVBUF, M_NOWAIT | M_ZERO); /* XXX dma reachable */ + tb = dma_alloc(ATAPARAMS_SIZE, PR_NOWAIT | PR_ZERO); if (tb == NULL) return CMD_AGAIN; wdc_c.flags = AT_READ | flags; @@ -95,7 +96,7 @@ ata_get_params(struct ata_drive_datas *d if ((ret = wdc_exec_command(drvp, &wdc_c)) != WDC_COMPLETE) { WDCDEBUG_PRINT(("%s: wdc_exec_command failed: %d\n", __func__, ret), DEBUG_PROBE); - free(tb, M_DEVBUF); + dma_free(tb, ATAPARAMS_SIZE); return CMD_AGAIN; } @@ -103,7 +104,7 @@ ata_get_params(struct ata_drive_datas *d WDCDEBUG_PRINT(("%s: IDENTIFY failed: 0x%x\n", __func__, wdc_c.flags), DEBUG_PROBE); - free(tb, M_DEVBUF); + dma_free(tb, ATAPARAMS_SIZE); return CMD_ERR; } else { #if BYTE_ORDER == BIG_ENDIAN @@ -150,7 +151,7 @@ ata_get_params(struct ata_drive_datas *d *p = swap16(*p); } - free(tb, M_DEVBUF); + dma_free(tb, ATAPARAMS_SIZE); return CMD_OK; } }
mbuf diff that affects IPSEC setups
Clean up the mbuf code a bit by collecting common code to split an individual mbuf, and rework those functions that need that to be wrappers around that. This impacts almost exclusively IPSEC mbuf usage, so if you have these setups, please ensure that this doesn't break those. - Bret Index: kern/uipc_mbuf.c === RCS file: /cvs/src/sys/kern/uipc_mbuf.c,v retrieving revision 1.149 diff -u -p -r1.149 uipc_mbuf.c --- kern/uipc_mbuf.c29 Jan 2011 13:15:39 - 1.149 +++ kern/uipc_mbuf.c2 Apr 2011 14:07:10 - @@ -110,6 +110,8 @@ struct pool mclpools[MCLPOOLS]; intm_clpool(u_int); +struct mbuf *m_split_mbuf(struct mbuf *, int, int, struct mbuf *); + int max_linkhdr; /* largest link-level header */ int max_protohdr; /* largest protocol header */ int max_hdr; /* largest link+protocol header */ @@ -1079,130 +1081,114 @@ m_getptr(struct mbuf *m, int loc, int *o } /* - * Inject a new mbuf chain of length siz in mbuf chain m0 at - * position len0. Returns a pointer to the first injected mbuf, or - * NULL on failure (m0 is left undisturbed). Note that if there is - * enough space for an object of size siz in the appropriate position, + * Inject a new mbuf chain of length siz in mbuf chain m at + * position off. Returns a pointer to the first injected mbuf, or + * NULL on failure (m is left undisturbed). Note that if there is + * enough space for an object of size len in the appropriate position, * no memory will be allocated. Also, there will be no data movement in - * the first len0 bytes (pointers to that will remain valid). + * the first off bytes (pointers to that will remain valid). * - * XXX It is assumed that siz is less than the size of an mbuf at the moment. + * XXX It is assumed that len is less than the size of an mbuf at the moment. */ struct mbuf * -m_inject(struct mbuf *m0, int len0, int siz, int wait) +m_inject(struct mbuf *m, int off, int len, int wait) { - struct mbuf *m, *n, *n2 = NULL, *n3; - unsigned len = len0, remain; + struct mbuf *n, *o, *p; + int off1; - if ((siz >= MHLEN) || (len0 <= 0)) - return (NULL); - for (m = m0; m && len > m->m_len; m = m->m_next) - len -= m->m_len; - if (m == NULL) + if (len > MHLEN || len <= 0) + return (NULL); + + if ((n = m_getptr(m, off, &off1)) == NULL) + return (NULL); + + if ((o = m_get(wait, MT_DATA)) == NULL) return (NULL); - remain = m->m_len - len; - if (remain == 0) { - if ((m->m_next) && (M_LEADINGSPACE(m->m_next) >= siz)) { - m->m_next->m_len += siz; - if (m0->m_flags & M_PKTHDR) - m0->m_pkthdr.len += siz; - m->m_next->m_data -= siz; - return m->m_next; - } - } else { - n2 = m_copym2(m, len, remain, wait); - if (n2 == NULL) - return (NULL); - } - MGET(n, wait, MT_DATA); - if (n == NULL) { - if (n2) - m_freem(n2); + if ((p = m_split_mbuf(n, off1, wait, NULL)) == NULL) { + m_freem(o); return (NULL); } - n->m_len = siz; - if (m0->m_flags & M_PKTHDR) - m0->m_pkthdr.len += siz; - m->m_len -= remain; /* Trim */ - if (n2) { - for (n3 = n; n3->m_next != NULL; n3 = n3->m_next) - ; - n3->m_next = n2; - } else - n3 = n; - for (; n3->m_next != NULL; n3 = n3->m_next) - ; - n3->m_next = m->m_next; - m->m_next = n; - return n; + o->m_len = len; + o->m_next = p; + n->m_next = o; + + if (m->m_flags & M_PKTHDR) + m->m_pkthdr.len += len; + + return (o); } /* - * Partition an mbuf chain in two pieces, returning the tail -- - * all but the first len0 bytes. In case of failure, it returns NULL and - * attempts to restore the chain to its original state. + * Split a single mbuf, leaving the chain intact. */ struct mbuf * -m_split(struct mbuf *m0, int len0, int wait) +m_split_mbuf(struct mbuf *m, int off, int wait, struct mbuf *mhdr) { - struct mbuf *m, *n; - unsigned len = len0, remain, olen; + struct mbuf *n; + int copyhdr; - for (m = m0; m && len > m->m_len; m = m->m_next) - len -= m->m_len; - if (m == NULL) + if (off > m->m_len) return (NULL); - remain = m->m_len - len; - if (m0->m_flags & M_PKTHDR) { - MGETHDR(n, wait, m0->m_type); - if (n == NULL) - return (NULL); - if (m_dup_pkthdr(n, m0)) { - m_freem(n); + +
Re: horribly slow fsck_ffs pass1 performance
On 2011-04-01 19.03, Amit Kulkarni wrote: > Thank you Arthur and the team for a very fast turnaround! Thank you > for reducing the pain. I will schedule a fsck every month or so, > knowing it won't screw up anything and be done really quick. Why "schedule" fsck runs at all? The file system code is very mature and although of course it would be unwise to declare it bug free, I see very little reason to run fsck on a file system unless there have been some problem like an unclean shutdown to prompt it (in which case of course, the system does it for you automatically when rebooting). I've noticed that some (all?) linux systems do uncalled-for file system checks at boot if no check have been made recently, but I've never understood this practice. It must mean they don't trust their own file systems, which frankly I find a bit unsettling... I'd rather use a file system that's been field proven for decades than use something thats just come out of the experimenting shop. Regards, /Benny -- internetlabbet.se / work: +46 8 551 124 80 / "Words must Benny Lvfgren/ mobile: +46 70 718 11 90 / be weighed, / fax:+46 8 551 124 89/not counted." /email: benny -at- internetlabbet.se
Re: atascsi dma_alloc() - make atascsi play nicer with bigmem
On Sat, Apr 02, 2011 at 09:15:37AM -0400, Kenneth R Westerback wrote: > Another driver malloc'ing and passing potentially dma unsafe memory > to do i/o into. > > ok? yub > > Ken > > Index: atascsi.c > === > RCS file: /cvs/src/sys/dev/ata/atascsi.c,v > retrieving revision 1.101 > diff -u -p -r1.101 atascsi.c > --- atascsi.c 3 Feb 2011 21:22:19 - 1.101 > +++ atascsi.c 2 Apr 2011 13:03:58 - > @@ -26,6 +26,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -335,8 +336,8 @@ atascsi_probe(struct scsi_link *link) > xa = scsi_io_get(&ahp->ahp_iopool, SCSI_NOSLEEP); > if (xa == NULL) > panic("no free xfers on a new port"); > - /* XXX dma reachable */ > - identify = malloc(sizeof(*identify), M_TEMP, M_WAITOK); > + identify = dma_alloc(sizeof(*identify), > + PR_WAITOK | PR_ZERO); > xa->pmp_port = ap->ap_pmp_port; > xa->data = identify; > xa->datalen = sizeof(*identify); > @@ -353,10 +354,10 @@ atascsi_probe(struct scsi_link *link) > if (rv == 0) { > bcopy(identify, &ap->ap_identify, > sizeof(ap->ap_identify)); > - free(identify, M_TEMP); > + dma_free(identify, sizeof(*identify)); > break; > } > - free(identify, M_TEMP); > + dma_free(identify, sizeof(*identify)); > delay(500); > } while (count--);
Re: horribly slow fsck_ffs pass1 performance
On 2011-04-01 21.48, Amit Kulkarni wrote: >> And jumping up and down after a first successful test is not a sound >> engineering principle either. [...stuff deleted...] > It turns out that I had extracted into the default firefox download > location (/home/amit/downloads I forgot exactly where) all kinds of > files. There was sources for gdb 6.3, 6.6, 6.7, 6.8. GCC 3.3, 3.4.6, > 4.5 etc, LLVM + Clang 2.8. Still more that I forget. This is a 20 Gb > fs and I was totally unaware I was abusing my fs so much. The day this > happened, I had updated src,ports,xenocara,www from cvs. I immediately > did a plain "fsck" right after this operation. I typed fsck in the > same window while it was updating ports. On hindsight, I might have > waited till it had finished writing the cache to disk. The fsck > proceeded well until it encountered the gazillion files in /home. I have to ask: From your description I get the impression that you're fsck'ing mounted file systems, and you seem to be doing this on a more or less regular basis? Why? Regards, /Benny -- internetlabbet.se / work: +46 8 551 124 80 / "Words must Benny Lvfgren/ mobile: +46 70 718 11 90 / be weighed, / fax:+46 8 551 124 89/not counted." /email: benny -at- internetlabbet.se
fast local address lookup in ip_input
so now that the loopback link1 crap is out of the way - use the rb tree for local address lookup in ip_input instead of traversing the list of interfaces traversing the list of addresses on them linearily. this needs heavy testing. last not least somebody please throw this on his rarpd server and netboot a sparc against it so that the compat hack for classful broadcast is tested. otherwise, just stuff binding to local addresses and make sure you can reach it from another box. the printf is not to stay of course, but useful while testing. Index: netinet/in_pcb.c === RCS file: /cvs/src/sys/netinet/in_pcb.c,v retrieving revision 1.113 diff -u -p -r1.113 in_pcb.c --- netinet/in_pcb.c3 Jul 2010 04:44:51 - 1.113 +++ netinet/in_pcb.c2 Apr 2011 15:30:10 - @@ -276,8 +276,7 @@ in_pcbbind(v, nam, p) } else if (sin->sin_addr.s_addr != INADDR_ANY) { sin->sin_port = 0; /* yech... */ if (!(so->so_options & SO_BINDANY) && - in_iawithaddr(sin->sin_addr, NULL, - inp->inp_rtableid) == 0) + !ifa_ifwithaddr(sintosa(sin), inp->inp_rtableid)) return (EADDRNOTAVAIL); } if (lport) { Index: netinet/ip_input.c === RCS file: /cvs/src/sys/netinet/ip_input.c,v retrieving revision 1.187 diff -u -p -r1.187 ip_input.c --- netinet/ip_input.c 2 Apr 2011 14:38:09 - 1.187 +++ netinet/ip_input.c 2 Apr 2011 15:30:11 - @@ -144,6 +144,9 @@ struct pool ipq_pool; struct ipstat ipstat; +struct in_ifaddr * +in_iawithaddr(struct in_addr, struct mbuf *, u_int); + char * inet_ntoa(ina) struct in_addr ina; @@ -682,30 +685,33 @@ bad: struct in_ifaddr * in_iawithaddr(struct in_addr ina, struct mbuf *m, u_int rdomain) { - struct in_ifaddr *ia; + struct in_ifaddr*ia; + struct sockaddr_in sin; - rdomain = rtable_l2(rdomain); - TAILQ_FOREACH(ia, &in_ifaddr, ia_list) { - if (ia->ia_ifp->if_rdomain != rdomain) - continue; - if (ina.s_addr == ia->ia_addr.sin_addr.s_addr) - return ia; - /* check ancient classful too, e. g. for rarp-based netboot */ - if (((ip_directedbcast == 0) || (m && ip_directedbcast && - ia->ia_ifp == m->m_pkthdr.rcvif)) && - (ia->ia_ifp->if_flags & IFF_BROADCAST)) { - if (ina.s_addr == ia->ia_broadaddr.sin_addr.s_addr || + bzero(&sin, sizeof(sin)); + sin.sin_len = sizeof(sin); + sin.sin_family = AF_INET; + sin.sin_addr = ina; + ia = (struct in_ifaddr *)ifa_ifwithaddr(sintosa(&sin), rdomain); +printf("in_iawithaddr ina=%s: %s\n", inet_ntoa(ina), ia ? "yay" : "rotten shark"); + + /* check ancient classful, e. g. for rarp-based netboot */ + if (ia == NULL && m->m_flags | M_BCAST && + IN_CLASSFULBROADCAST(ina.s_addr, ina.s_addr)) { + TAILQ_FOREACH(ia, &in_ifaddr, ia_list) { + if (ia->ia_ifp->if_rdomain != rdomain) + continue; + if (((ip_directedbcast == 0) || + (m && ip_directedbcast && + ia->ia_ifp == m->m_pkthdr.rcvif)) && + (ia->ia_ifp->if_flags & IFF_BROADCAST) && IN_CLASSFULBROADCAST(ina.s_addr, - ia->ia_addr.sin_addr.s_addr)) { - /* Make sure M_BCAST is set */ - if (m) - m->m_flags |= M_BCAST; - return ia; - } + ia->ia_addr.sin_addr.s_addr)) + return (ia); } } - return NULL; + return (ia); } /* Index: netinet/ip_var.h === RCS file: /cvs/src/sys/netinet/ip_var.h,v retrieving revision 1.39 diff -u -p -r1.39 ip_var.h --- netinet/ip_var.h5 Jun 2009 00:05:22 - 1.39 +++ netinet/ip_var.h2 Apr 2011 15:30:11 - @@ -172,8 +172,6 @@ int ip_pcbopts(struct mbuf **, struct m struct mbuf * ip_reass(struct ipqent *, struct ipq *); struct in_ifaddr * -in_iawithaddr(struct in_addr, struct mbuf *, u_int); -struct in_ifaddr * ip_rtaddr(struct in_addr, u_int); u_int16_t ip_randomid(void); Index: netinet/raw_ip.c === RCS file: /cvs/src/sys/netinet/raw_ip.c,v retrieving revision 1.50 diff -u -p -r1.50 raw_ip.c --- netinet/raw_ip.c8 Sep 2010 08:34:42 -
Re: remove bufqs from vnds
ok On 02/04/2011, at 11:58 PM, Thordur Bjornsson wrote: > Hi, > > So, it doesn't make sense to have a bufq for vnds. > > The disk that stores the image backing the vnd has it's own bufq > ofcourse and what happens is that vnd puts a buf on it's bufq, > which is promptly removed when we call vndstart, followed by a call > to strategy so the buf ends up almost immediately on the bufq > on the underlaying disk. > > Tested on vnd/svnd (and with the image on NFS. vnd is broken on nfs!). > > OK? > > > Index: vnd.c > === > RCS file: /home/thib/cvs/src/sys/dev/vnd.c,v > retrieving revision 1.107 > diff -u -p -r1.107 vnd.c > --- vnd.c 15 Feb 2011 20:02:11 - 1.107 > +++ vnd.c 2 Apr 2011 11:34:38 - > @@ -127,8 +127,6 @@ struct vnd_softc { > struct disk sc_dk; > char sc_dk_name[16]; > > - struct bufq sc_bufq; > - > char sc_file[VNDNLEN]; /* file we're covering */ > int sc_flags; /* flags */ > size_t sc_size; /* size of vnd in sectors */ > @@ -159,7 +157,7 @@ int numvnd = 0; > void vndattach(int); > > void vndclear(struct vnd_softc *); > -void vndstart(struct vnd_softc *); > +void vndstart(struct vnd_softc *, struct buf *); > int vndsetcred(struct vnd_softc *, struct ucred *); > void vndiodone(struct buf *); > void vndshutdown(void); > @@ -445,64 +443,50 @@ vndstrategy(struct buf *bp) > > /* No bypassing of buffer cache? */ > if (vndsimple(bp->b_dev)) { > - /* Loop until all queued requests are handled. */ > - for (;;) { > - int part = DISKPART(bp->b_dev); > - daddr64_t off = DL_SECTOBLK(vnd->sc_dk.dk_label, > - > DL_GETPOFFSET(&vnd->sc_dk.dk_label->d_partitions[part])); > - aiov.iov_base = bp->b_data; > - auio.uio_resid = aiov.iov_len = bp->b_bcount; > - auio.uio_iov = &aiov; > - auio.uio_iovcnt = 1; > - auio.uio_offset = dbtob((off_t)(bp->b_blkno + off)); > - auio.uio_segflg = UIO_SYSSPACE; > - auio.uio_procp = p; > - > - vn_lock(vnd->sc_vp, LK_EXCLUSIVE | LK_RETRY, p); > - if (bp->b_flags & B_READ) { > - auio.uio_rw = UIO_READ; > - bp->b_error = VOP_READ(vnd->sc_vp, &auio, 0, > - vnd->sc_cred); > - if (vnd->sc_keyctx) > - vndencrypt(vnd, bp->b_data, > -bp->b_bcount, bp->b_blkno, 0); > - } else { > - if (vnd->sc_keyctx) > - vndencrypt(vnd, bp->b_data, > -bp->b_bcount, bp->b_blkno, 1); > - auio.uio_rw = UIO_WRITE; > - /* > - * Upper layer has already checked I/O for > - * limits, so there is no need to do it again. > - */ > - bp->b_error = VOP_WRITE(vnd->sc_vp, &auio, > - IO_NOLIMIT, vnd->sc_cred); > - /* Data in buffer cache needs to be in clear */ > - if (vnd->sc_keyctx) > - vndencrypt(vnd, bp->b_data, > -bp->b_bcount, bp->b_blkno, 0); > - } > - VOP_UNLOCK(vnd->sc_vp, 0, p); > - if (bp->b_error) > - bp->b_flags |= B_ERROR; > - bp->b_resid = auio.uio_resid; > - s = splbio(); > - biodone(bp); > - splx(s); > - > - /* If nothing more is queued, we are done. */ > - if (!bufq_peek(&vnd->sc_bufq)) > - return; > - > + int part = DISKPART(bp->b_dev); > + daddr64_t off = DL_SECTOBLK(vnd->sc_dk.dk_label, > + DL_GETPOFFSET(&vnd->sc_dk.dk_label->d_partitions[part])); > + aiov.iov_base = bp->b_data; > + auio.uio_resid = aiov.iov_len = bp->b_bcount; > + auio.uio_iov = &aiov; > + auio.uio_iovcnt = 1; > + auio.uio_offset = dbtob((off_t)(bp->b_blkno + off)); > + auio.uio_segflg = UIO_SYSSPACE; > + auio.uio_procp = p; > + > + vn_lock(vnd->sc_vp, LK_EXCLUSIVE | LK_RETRY, p); > + if (bp->b_flags & B_READ) { > + auio.uio_rw = UIO_READ; > + bp->b_error = VOP_READ(vnd->sc_vp, &auio, 0, >
remove bufqs from vnds
Hi, So, it doesn't make sense to have a bufq for vnds. The disk that stores the image backing the vnd has it's own bufq ofcourse and what happens is that vnd puts a buf on it's bufq, which is promptly removed when we call vndstart, followed by a call to strategy so the buf ends up almost immediately on the bufq on the underlaying disk. Tested on vnd/svnd (and with the image on NFS. vnd is broken on nfs!). OK? Index: vnd.c === RCS file: /home/thib/cvs/src/sys/dev/vnd.c,v retrieving revision 1.107 diff -u -p -r1.107 vnd.c --- vnd.c 15 Feb 2011 20:02:11 - 1.107 +++ vnd.c 2 Apr 2011 11:34:38 - @@ -127,8 +127,6 @@ struct vnd_softc { struct disk sc_dk; char sc_dk_name[16]; - struct bufq sc_bufq; - char sc_file[VNDNLEN]; /* file we're covering */ int sc_flags; /* flags */ size_t sc_size; /* size of vnd in sectors */ @@ -159,7 +157,7 @@ int numvnd = 0; void vndattach(int); void vndclear(struct vnd_softc *); -void vndstart(struct vnd_softc *); +void vndstart(struct vnd_softc *, struct buf *); intvndsetcred(struct vnd_softc *, struct ucred *); void vndiodone(struct buf *); void vndshutdown(void); @@ -445,64 +443,50 @@ vndstrategy(struct buf *bp) /* No bypassing of buffer cache? */ if (vndsimple(bp->b_dev)) { - /* Loop until all queued requests are handled. */ - for (;;) { - int part = DISKPART(bp->b_dev); - daddr64_t off = DL_SECTOBLK(vnd->sc_dk.dk_label, - DL_GETPOFFSET(&vnd->sc_dk.dk_label->d_partitions[part])); - aiov.iov_base = bp->b_data; - auio.uio_resid = aiov.iov_len = bp->b_bcount; - auio.uio_iov = &aiov; - auio.uio_iovcnt = 1; - auio.uio_offset = dbtob((off_t)(bp->b_blkno + off)); - auio.uio_segflg = UIO_SYSSPACE; - auio.uio_procp = p; - - vn_lock(vnd->sc_vp, LK_EXCLUSIVE | LK_RETRY, p); - if (bp->b_flags & B_READ) { - auio.uio_rw = UIO_READ; - bp->b_error = VOP_READ(vnd->sc_vp, &auio, 0, - vnd->sc_cred); - if (vnd->sc_keyctx) - vndencrypt(vnd, bp->b_data, - bp->b_bcount, bp->b_blkno, 0); - } else { - if (vnd->sc_keyctx) - vndencrypt(vnd, bp->b_data, - bp->b_bcount, bp->b_blkno, 1); - auio.uio_rw = UIO_WRITE; - /* -* Upper layer has already checked I/O for -* limits, so there is no need to do it again. -*/ - bp->b_error = VOP_WRITE(vnd->sc_vp, &auio, - IO_NOLIMIT, vnd->sc_cred); - /* Data in buffer cache needs to be in clear */ - if (vnd->sc_keyctx) - vndencrypt(vnd, bp->b_data, - bp->b_bcount, bp->b_blkno, 0); - } - VOP_UNLOCK(vnd->sc_vp, 0, p); - if (bp->b_error) - bp->b_flags |= B_ERROR; - bp->b_resid = auio.uio_resid; - s = splbio(); - biodone(bp); - splx(s); - - /* If nothing more is queued, we are done. */ - if (!bufq_peek(&vnd->sc_bufq)) - return; - + int part = DISKPART(bp->b_dev); + daddr64_t off = DL_SECTOBLK(vnd->sc_dk.dk_label, + DL_GETPOFFSET(&vnd->sc_dk.dk_label->d_partitions[part])); + aiov.iov_base = bp->b_data; + auio.uio_resid = aiov.iov_len = bp->b_bcount; + auio.uio_iov = &aiov; + auio.uio_iovcnt = 1; + auio.uio_offset = dbtob((off_t)(bp->b_blkno + off)); + auio.uio_segflg = UIO_SYSSPACE; + auio.uio_procp = p; + + vn_lock(vnd->sc_vp, LK_EXCLUSIVE | LK_RETRY, p); + if (bp->b_flags & B_READ) { + auio.uio_rw = UIO_READ; + bp->b_error = VOP_READ(vnd->sc_vp, &auio, 0, + vnd->sc_cred); + if (vnd->sc_keyctx) +
Re: atascsi dma_alloc() - make atascsi play nicer with bigmem
ok. On 02/04/2011, at 11:15 PM, Kenneth R Westerback wrote: > Another driver malloc'ing and passing potentially dma unsafe memory > to do i/o into. > > ok? > > Ken > > Index: atascsi.c > === > RCS file: /cvs/src/sys/dev/ata/atascsi.c,v > retrieving revision 1.101 > diff -u -p -r1.101 atascsi.c > --- atascsi.c 3 Feb 2011 21:22:19 - 1.101 > +++ atascsi.c 2 Apr 2011 13:03:58 - > @@ -26,6 +26,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -335,8 +336,8 @@ atascsi_probe(struct scsi_link *link) > xa = scsi_io_get(&ahp->ahp_iopool, SCSI_NOSLEEP); > if (xa == NULL) > panic("no free xfers on a new port"); > - /* XXX dma reachable */ > - identify = malloc(sizeof(*identify), M_TEMP, M_WAITOK); > + identify = dma_alloc(sizeof(*identify), > + PR_WAITOK | PR_ZERO); > xa->pmp_port = ap->ap_pmp_port; > xa->data = identify; > xa->datalen = sizeof(*identify); > @@ -353,10 +354,10 @@ atascsi_probe(struct scsi_link *link) > if (rv == 0) { > bcopy(identify, &ap->ap_identify, > sizeof(ap->ap_identify)); > - free(identify, M_TEMP); > + dma_free(identify, sizeof(*identify)); > break; > } > - free(identify, M_TEMP); > + dma_free(identify, sizeof(*identify)); > delay(500); > } while (count--);
pf and the ip checksum
pf keep updating the dreaded ip checksum. which is entirely pointless (except the quoted ip packet and its csum inside an icmp err) since we uncondtionally recalculate the checksum anyway in ip_output as well as in the bridge and the *&^%$(* pf route-to. so don't. Index: pf.c === RCS file: /cvs/src/sys/net/pf.c,v retrieving revision 1.730 diff -u -p -r1.730 pf.c --- pf.c24 Mar 2011 20:09:44 - 1.730 +++ pf.c2 Apr 2011 14:20:19 - @@ -145,8 +145,8 @@ void pf_add_threshold(struct pf_thres int pf_check_threshold(struct pf_threshold *); voidpf_change_ap(struct pf_addr *, u_int16_t *, - u_int16_t *, u_int16_t *, struct pf_addr *, - u_int16_t, u_int8_t, sa_family_t); + u_int16_t *, struct pf_addr *, u_int16_t, + u_int8_t, sa_family_t); int pf_modulate_sack(struct mbuf *, int, struct pf_pdesc *, struct tcphdr *, struct pf_state_peer *); #ifdef INET6 @@ -158,7 +158,7 @@ int pf_icmp_mapping(struct pf_pdesc * voidpf_change_icmp(struct pf_addr *, u_int16_t *, struct pf_addr *, struct pf_addr *, u_int16_t, u_int16_t *, u_int16_t *, u_int16_t *, - u_int16_t *, u_int8_t, sa_family_t); + u_int8_t, sa_family_t); voidpf_send_tcp(const struct pf_rule *, sa_family_t, const struct pf_addr *, const struct pf_addr *, u_int16_t, u_int16_t, u_int32_t, u_int32_t, @@ -1523,7 +1523,7 @@ pf_cksum_fixup(u_int16_t cksum, u_int16_ } void -pf_change_ap(struct pf_addr *a, u_int16_t *p, u_int16_t *ic, u_int16_t *pc, +pf_change_ap(struct pf_addr *a, u_int16_t *p, u_int16_t *pc, struct pf_addr *an, u_int16_t pn, u_int8_t u, sa_family_t af) { struct pf_addr ao; @@ -1536,10 +1536,6 @@ pf_change_ap(struct pf_addr *a, u_int16_ switch (af) { #ifdef INET case AF_INET: - *ic = pf_cksum_fixup(pf_cksum_fixup(*ic, - ao.addr16[0], an->addr16[0], 0), - ao.addr16[1], an->addr16[1], 0); - *p = pn; *pc = pf_cksum_fixup(pf_cksum_fixup(pf_cksum_fixup(*pc, ao.addr16[0], an->addr16[0], u), ao.addr16[1], an->addr16[1], u), @@ -1574,8 +1570,9 @@ pf_change_a(void *a, u_int16_t *c, u_int memcpy(&ao, a, sizeof(ao)); memcpy(a, &an, sizeof(u_int32_t)); - *c = pf_cksum_fixup(pf_cksum_fixup(*c, ao / 65536, an / 65536, u), - ao % 65536, an % 65536, u); + if (c != NULL) + *c = pf_cksum_fixup(pf_cksum_fixup(*c, ao / 65536, an / 65536, + u), ao % 65536, an % 65536, u); } #ifdef INET6 @@ -1790,7 +1787,7 @@ pf_icmp_mapping(struct pf_pdesc *pd, u_i void pf_change_icmp(struct pf_addr *ia, u_int16_t *ip, struct pf_addr *oa, struct pf_addr *na, u_int16_t np, u_int16_t *pc, u_int16_t *h2c, -u_int16_t *ic, u_int16_t *hc, u_int8_t u, sa_family_t af) +u_int16_t *ic, u_int8_t u, sa_family_t af) { struct pf_addr oia, ooa; @@ -1819,6 +1816,7 @@ pf_change_icmp(struct pf_addr *ia, u_int case AF_INET: { u_int32_toh2c = *h2c; + /* XXX just in_cksum() */ *h2c = pf_cksum_fixup(pf_cksum_fixup(*h2c, oia.addr16[0], ia->addr16[0], 0), oia.addr16[1], ia->addr16[1], 0); @@ -1845,19 +1843,11 @@ pf_change_icmp(struct pf_addr *ia, u_int break; #endif /* INET6 */ } - /* Outer ip address, fix outer ip or icmpv6 checksum, if necessary. */ + /* Outer ip address, fix outer icmpv6 checksum, if necessary. */ if (oa) { PF_ACPY(oa, na, af); - switch (af) { -#ifdef INET - case AF_INET: - *hc = pf_cksum_fixup(pf_cksum_fixup(*hc, - ooa.addr16[0], oa->addr16[0], 0), - ooa.addr16[1], oa->addr16[1], 0); - break; -#endif /* INET */ #ifdef INET6 - case AF_INET6: + if (af == AF_INET6) *ic = pf_cksum_fixup(pf_cksum_fixup(pf_cksum_fixup( pf_cksum_fixup(pf_cksum_fixup(pf_cksum_fixup( pf_cksum_fixup(pf_cksum_fixup(*ic, @@ -1869,9 +1859,7 @@ pf_change_icmp(struct pf_addr *ia, u_int ooa.addr16[5], oa->addr16[5], u), ooa.addr16[6], oa->addr16[6], u), ooa.addr16[7], oa->addr16[7], u); - break; #endif /* INET6 */ - } } } @@
atascsi dma_alloc() - make atascsi play nicer with bigmem
Another driver malloc'ing and passing potentially dma unsafe memory to do i/o into. ok? Ken Index: atascsi.c === RCS file: /cvs/src/sys/dev/ata/atascsi.c,v retrieving revision 1.101 diff -u -p -r1.101 atascsi.c --- atascsi.c 3 Feb 2011 21:22:19 - 1.101 +++ atascsi.c 2 Apr 2011 13:03:58 - @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -335,8 +336,8 @@ atascsi_probe(struct scsi_link *link) xa = scsi_io_get(&ahp->ahp_iopool, SCSI_NOSLEEP); if (xa == NULL) panic("no free xfers on a new port"); - /* XXX dma reachable */ - identify = malloc(sizeof(*identify), M_TEMP, M_WAITOK); + identify = dma_alloc(sizeof(*identify), + PR_WAITOK | PR_ZERO); xa->pmp_port = ap->ap_pmp_port; xa->data = identify; xa->datalen = sizeof(*identify); @@ -353,10 +354,10 @@ atascsi_probe(struct scsi_link *link) if (rv == 0) { bcopy(identify, &ap->ap_identify, sizeof(ap->ap_identify)); - free(identify, M_TEMP); + dma_free(identify, sizeof(*identify)); break; } - free(identify, M_TEMP); + dma_free(identify, sizeof(*identify)); delay(500); } while (count--);
Re: relax gcc -Wsentinel checking
On Sat, Apr 02, 2011 at 11:13:05AM +, Miod Vallat wrote: > The -Wsentinel warning is supposed to complain when the last argument in > a call to a function which has __attribute__((sentinel)) is not a NULL > pointer. > > However, the current implementation of the check in gcc 3 and gcc 4 will > warn if the last argument is not explicitely declared as a pointer type, > i.e. > execl(foo, bar, (const char *)NULL) > will not warn, but > execl(foo, bar, NULL) > will cause a false warning, because NULL is defined as 0L for non-C++ > code. Heh, had the same problem with the new binutils. This will remove some of the MI modifications I've made that fixed compiling with -Werror. > The following diff relaxes the check to let it accept either a pointer > or an integer type of the same width as a pointer (i.e. on a 64 bit > platform, using 0L will compile silently, but using 0 will). I think you meant: but using 0 will not. > > Ok? (note that this has only been tested on gcc 4, the gcc 3 version is > similar but has not even been checked to compile yet) This reads okay to me. > > Index: gnu/gcc/gcc/c-common.c > === > RCS file: /cvs/src/gnu/gcc/gcc/c-common.c,v > retrieving revision 1.3 > diff -u -p -r1.3 c-common.c > --- gnu/gcc/gcc/c-common.c12 May 2010 13:35:20 - 1.3 > +++ gnu/gcc/gcc/c-common.c2 Apr 2011 11:04:49 - > @@ -5498,15 +5498,17 @@ check_function_sentinel (tree attrs, tre > } > > /* Validate the sentinel. */ > - if ((!POINTER_TYPE_P (TREE_TYPE (TREE_VALUE (sentinel))) > -|| !integer_zerop (TREE_VALUE (sentinel))) > + sentinel = TREE_VALUE (sentinel); > + if ((!(POINTER_TYPE_P (TREE_TYPE (sentinel)) > + || (TREE_CODE (sentinel) == INTEGER_CST > + && TYPE_PRECISION (TREE_TYPE (sentinel)) == POINTER_SIZE)) > +|| !integer_zerop (sentinel)) > /* Although __null (in C++) is only an integer we allow it >nevertheless, as we are guaranteed that it's exactly >as wide as a pointer, and we don't want to force >users to cast the NULL they have written there. >We warn with -Wstrict-null-sentinel, though. */ > - && (warn_strict_null_sentinel > - || null_node != TREE_VALUE (sentinel))) > + && (warn_strict_null_sentinel || null_node != sentinel)) > warning (OPT_Wformat, "missing sentinel in function call"); > } > } > Index: gnu/usr.bin/gcc/gcc/c-common.c > === > RCS file: /cvs/src/gnu/usr.bin/gcc/gcc/c-common.c,v > retrieving revision 1.6 > diff -u -p -r1.6 c-common.c > --- gnu/usr.bin/gcc/gcc/c-common.c16 Oct 2009 12:22:07 - 1.6 > +++ gnu/usr.bin/gcc/gcc/c-common.c2 Apr 2011 11:04:50 - > @@ -6502,8 +6502,11 @@ check_function_sentinel (attrs, params) > } > > /* Validate the sentinel. */ > - if (!POINTER_TYPE_P (TREE_TYPE (TREE_VALUE (sentinel))) > - || !integer_zerop (TREE_VALUE (sentinel))) > + sentinel = TREE_VALUE (sentinel); > + if (!(POINTER_TYPE_P (TREE_TYPE (sentinel)) > + || (TREE_CODE (sentinel) == INTEGER_CST > + && TYPE_PRECISION (TREE_TYPE (sentinel)) == POINTER_SIZE)) > +|| !integer_zerop (sentinel)) > warning ("missing sentinel in function call"); > } > }
Re: netinet6 bread crumbs
On Sat, Apr 02, 2011 at 02:13:45PM +0200, Stefan Sperling wrote: > Feel free to ack or reject these individually. > > > Kill redundant offsetof definitions. All of these files include sys/param.h. Those look fine. > Index: in6.c > === > RCS file: /cvs/src/sys/netinet6/in6.c,v > retrieving revision 1.89 > diff -u -p -r1.89 in6.c > --- in6.c 7 Oct 2010 22:07:06 - 1.89 > +++ in6.c 2 Apr 2011 12:02:04 - > @@ -910,14 +910,7 @@ in6_update_ifa(struct ifnet *ifp, struct >*/ > if (ia == NULL) { > hostIsNew = 1; > - /* > - * When in6_update_ifa() is called in a process of a received > - * RA, it is called under an interrupt context. So, we should > - * call malloc with M_NOWAIT. > - */ > - ia = malloc(sizeof(*ia), M_IFADDR, M_NOWAIT | M_ZERO); > - if (ia == NULL) > - return (ENOBUFS); > + ia = malloc(sizeof(*ia), M_IFADDR, M_WAITOK | M_ZERO); This is a little bit suspect. But people who know the call path should look at this. typos look ok, but mah spjellingk is not vry good. (:
Re: kill loopback link1 wankery
On Sat, Apr 02, 2011 at 10:56:06PM +1000, David Gwynne wrote: > all the things i can imagine using this for, i can do with pf features. > > ok. > Fine with me. > On 02/04/2011, at 10:49 PM, Henning Brauer wrote: > > > lo has that link1 wankery where it kind of replies to all addresses in > > the subnet, except that it doesn't really - it is very halfbaked and > > gets in the way. unless somebody has a VERY convincing reason to keep > > this it'll be gone in a few. > > we'll be able to use the fast rb tree lookup in in_aiwithaddr after > > this. > > > > Index: sys/netinet/ip_input.c > > === > > RCS file: /cvs/src/sys/netinet/ip_input.c,v > > retrieving revision 1.186 > > diff -u -p -r1.186 ip_input.c > > --- sys/netinet/ip_input.c 11 Feb 2011 12:16:30 - 1.186 > > +++ sys/netinet/ip_input.c 2 Apr 2011 12:44:12 - > > @@ -688,10 +688,7 @@ in_iawithaddr(struct in_addr ina, struct > > TAILQ_FOREACH(ia, &in_ifaddr, ia_list) { > > if (ia->ia_ifp->if_rdomain != rdomain) > > continue; > > - if ((ina.s_addr == ia->ia_addr.sin_addr.s_addr) || > > - ((ia->ia_ifp->if_flags & (IFF_LOOPBACK|IFF_LINK1)) == > > - (IFF_LOOPBACK|IFF_LINK1) && > > -ia->ia_net == (ina.s_addr & ia->ia_netmask))) > > + if (ina.s_addr == ia->ia_addr.sin_addr.s_addr) > > return ia; > > /* check ancient classful too, e. g. for rarp-based netboot */ > > if (((ip_directedbcast == 0) || (m && ip_directedbcast && > > Index: share/man/man4/lo.4 > > === > > RCS file: /cvs/src/share/man/man4/lo.4,v > > retrieving revision 1.26 > > diff -u -p -r1.26 lo.4 > > --- share/man/man4/lo.4 31 May 2007 19:19:50 - 1.26 > > +++ share/man/man4/lo.4 2 Apr 2011 12:44:12 - > > @@ -70,33 +70,6 @@ The loopback should > > .Em never > > be configured first unless no hardware > > interfaces exist. > > -.Pp > > -Configuring a loopback interface for > > -.Xr inet 4 > > -with the > > -.Em link1 > > -flag set will make the interface answer to the whole set of > > -addresses identified as being in super-net which is specified > > -by the address and netmask. > > -Obviously you should not set the > > -.Em link1 > > -flag on interface > > -.Nm lo0 , > > -but instead use another interface like > > -.Nm lo1 . > > -.Sh EXAMPLES > > -.Bd -literal > > -# ifconfig lo1 create > > -# ifconfig lo1 inet 192.168.1.1 netmask 255.255.255.0 link1 > > -.Ed > > -.Pp > > -is equivalent to: > > -.Bd -literal > > -# ifconfig lo1 create > > -# awk 'BEGIN {for(i=1;i<255;i++) \e > > - print "ifconfig lo1 inet 192.168.1."i" netmask 255.255.255.255 alias"}'| > \e > > - sh > > -.Ed > > .Sh DIAGNOSTICS > > .Bl -diag > > .It lo%d: can't handle af%d. > > @@ -116,16 +89,8 @@ The > > .Nm > > device appeared in > > .Bx 4.2 . > > -.Pp > > -The wildcard functionality first appeared in > > -.Ox 2.3 . > > .Sh BUGS > > Previous versions of the system enabled the loopback interface > > automatically, using a non-standard Internet address (127.1). > > Use of that address is now discouraged; a reserved host address > > for the local network should be used instead. > > -.Pp > > -Care should be taken when using NAT with interfaces that have the > > -.Em link1 > > -flag set, because it may believe the packets are coming from a > > -loopback address. > > > > > > -- > > Henning Brauer, h...@bsws.de, henn...@openbsd.org > > BS Web Services, http://bsws.de > > Full-Service ISP - Secure Hosting, Mail and DNS Services > > Dedicated Servers, Rootservers, Application Hosting > -- :wq Claudio
Re: kill loopback link1 wankery
all the things i can imagine using this for, i can do with pf features. ok. On 02/04/2011, at 10:49 PM, Henning Brauer wrote: > lo has that link1 wankery where it kind of replies to all addresses in > the subnet, except that it doesn't really - it is very halfbaked and > gets in the way. unless somebody has a VERY convincing reason to keep > this it'll be gone in a few. > we'll be able to use the fast rb tree lookup in in_aiwithaddr after > this. > > Index: sys/netinet/ip_input.c > === > RCS file: /cvs/src/sys/netinet/ip_input.c,v > retrieving revision 1.186 > diff -u -p -r1.186 ip_input.c > --- sys/netinet/ip_input.c11 Feb 2011 12:16:30 - 1.186 > +++ sys/netinet/ip_input.c2 Apr 2011 12:44:12 - > @@ -688,10 +688,7 @@ in_iawithaddr(struct in_addr ina, struct > TAILQ_FOREACH(ia, &in_ifaddr, ia_list) { > if (ia->ia_ifp->if_rdomain != rdomain) > continue; > - if ((ina.s_addr == ia->ia_addr.sin_addr.s_addr) || > - ((ia->ia_ifp->if_flags & (IFF_LOOPBACK|IFF_LINK1)) == > - (IFF_LOOPBACK|IFF_LINK1) && > - ia->ia_net == (ina.s_addr & ia->ia_netmask))) > + if (ina.s_addr == ia->ia_addr.sin_addr.s_addr) > return ia; > /* check ancient classful too, e. g. for rarp-based netboot */ > if (((ip_directedbcast == 0) || (m && ip_directedbcast && > Index: share/man/man4/lo.4 > === > RCS file: /cvs/src/share/man/man4/lo.4,v > retrieving revision 1.26 > diff -u -p -r1.26 lo.4 > --- share/man/man4/lo.4 31 May 2007 19:19:50 - 1.26 > +++ share/man/man4/lo.4 2 Apr 2011 12:44:12 - > @@ -70,33 +70,6 @@ The loopback should > .Em never > be configured first unless no hardware > interfaces exist. > -.Pp > -Configuring a loopback interface for > -.Xr inet 4 > -with the > -.Em link1 > -flag set will make the interface answer to the whole set of > -addresses identified as being in super-net which is specified > -by the address and netmask. > -Obviously you should not set the > -.Em link1 > -flag on interface > -.Nm lo0 , > -but instead use another interface like > -.Nm lo1 . > -.Sh EXAMPLES > -.Bd -literal > -# ifconfig lo1 create > -# ifconfig lo1 inet 192.168.1.1 netmask 255.255.255.0 link1 > -.Ed > -.Pp > -is equivalent to: > -.Bd -literal > -# ifconfig lo1 create > -# awk 'BEGIN {for(i=1;i<255;i++) \e > - print "ifconfig lo1 inet 192.168.1."i" netmask 255.255.255.255 alias"}'| \e > - sh > -.Ed > .Sh DIAGNOSTICS > .Bl -diag > .It lo%d: can't handle af%d. > @@ -116,16 +89,8 @@ The > .Nm > device appeared in > .Bx 4.2 . > -.Pp > -The wildcard functionality first appeared in > -.Ox 2.3 . > .Sh BUGS > Previous versions of the system enabled the loopback interface > automatically, using a non-standard Internet address (127.1). > Use of that address is now discouraged; a reserved host address > for the local network should be used instead. > -.Pp > -Care should be taken when using NAT with interfaces that have the > -.Em link1 > -flag set, because it may believe the packets are coming from a > -loopback address. > > > -- > Henning Brauer, h...@bsws.de, henn...@openbsd.org > BS Web Services, http://bsws.de > Full-Service ISP - Secure Hosting, Mail and DNS Services > Dedicated Servers, Rootservers, Application Hosting
kill loopback link1 wankery
lo has that link1 wankery where it kind of replies to all addresses in the subnet, except that it doesn't really - it is very halfbaked and gets in the way. unless somebody has a VERY convincing reason to keep this it'll be gone in a few. we'll be able to use the fast rb tree lookup in in_aiwithaddr after this. Index: sys/netinet/ip_input.c === RCS file: /cvs/src/sys/netinet/ip_input.c,v retrieving revision 1.186 diff -u -p -r1.186 ip_input.c --- sys/netinet/ip_input.c 11 Feb 2011 12:16:30 - 1.186 +++ sys/netinet/ip_input.c 2 Apr 2011 12:44:12 - @@ -688,10 +688,7 @@ in_iawithaddr(struct in_addr ina, struct TAILQ_FOREACH(ia, &in_ifaddr, ia_list) { if (ia->ia_ifp->if_rdomain != rdomain) continue; - if ((ina.s_addr == ia->ia_addr.sin_addr.s_addr) || - ((ia->ia_ifp->if_flags & (IFF_LOOPBACK|IFF_LINK1)) == - (IFF_LOOPBACK|IFF_LINK1) && -ia->ia_net == (ina.s_addr & ia->ia_netmask))) + if (ina.s_addr == ia->ia_addr.sin_addr.s_addr) return ia; /* check ancient classful too, e. g. for rarp-based netboot */ if (((ip_directedbcast == 0) || (m && ip_directedbcast && Index: share/man/man4/lo.4 === RCS file: /cvs/src/share/man/man4/lo.4,v retrieving revision 1.26 diff -u -p -r1.26 lo.4 --- share/man/man4/lo.4 31 May 2007 19:19:50 - 1.26 +++ share/man/man4/lo.4 2 Apr 2011 12:44:12 - @@ -70,33 +70,6 @@ The loopback should .Em never be configured first unless no hardware interfaces exist. -.Pp -Configuring a loopback interface for -.Xr inet 4 -with the -.Em link1 -flag set will make the interface answer to the whole set of -addresses identified as being in super-net which is specified -by the address and netmask. -Obviously you should not set the -.Em link1 -flag on interface -.Nm lo0 , -but instead use another interface like -.Nm lo1 . -.Sh EXAMPLES -.Bd -literal -# ifconfig lo1 create -# ifconfig lo1 inet 192.168.1.1 netmask 255.255.255.0 link1 -.Ed -.Pp -is equivalent to: -.Bd -literal -# ifconfig lo1 create -# awk 'BEGIN {for(i=1;i<255;i++) \e - print "ifconfig lo1 inet 192.168.1."i" netmask 255.255.255.255 alias"}'| \e - sh -.Ed .Sh DIAGNOSTICS .Bl -diag .It lo%d: can't handle af%d. @@ -116,16 +89,8 @@ The .Nm device appeared in .Bx 4.2 . -.Pp -The wildcard functionality first appeared in -.Ox 2.3 . .Sh BUGS Previous versions of the system enabled the loopback interface automatically, using a non-standard Internet address (127.1). Use of that address is now discouraged; a reserved host address for the local network should be used instead. -.Pp -Care should be taken when using NAT with interfaces that have the -.Em link1 -flag set, because it may believe the packets are coming from a -loopback address. -- Henning Brauer, h...@bsws.de, henn...@openbsd.org BS Web Services, http://bsws.de Full-Service ISP - Secure Hosting, Mail and DNS Services Dedicated Servers, Rootservers, Application Hosting
Un-suscribe
Un-suscribe
netinet6 bread crumbs
Feel free to ack or reject these individually. Kill redundant offsetof definitions. All of these files include sys/param.h. Index: frag6.c === RCS file: /cvs/src/sys/netinet6/frag6.c,v retrieving revision 1.32 diff -u -p -r1.32 frag6.c --- frag6.c 6 Mar 2011 19:55:54 - 1.32 +++ frag6.c 19 Mar 2011 12:53:43 - @@ -124,10 +124,6 @@ do { \ #defineIP6Q_UNLOCK() ip6q_unlock() -#ifndef offsetof /* XXX */ -#defineoffsetof(type, member) ((size_t)(&((type *)0)->member)) -#endif - /* * Initialise reassembly queue and fragment identifier. */ Index: icmp6.c === RCS file: /cvs/src/sys/netinet6/icmp6.c,v retrieving revision 1.113 diff -u -p -r1.113 icmp6.c --- icmp6.c 9 Jul 2010 15:44:20 - 1.113 +++ icmp6.c 2 Apr 2011 11:46:06 - @@ -1181,9 +1181,6 @@ icmp6_mtudisc_update(struct ip6ctlparam * - joins NI group address at in6_ifattach() time only, does not cope * with hostname changes by sethostname(3) */ -#ifndef offsetof /* XXX */ -#defineoffsetof(type, member) ((size_t)(&((type *)0)->member)) -#endif struct mbuf * ni6_input(struct mbuf *m, int off) { Index: in6_gif.c === RCS file: /cvs/src/sys/netinet6/in6_gif.c,v retrieving revision 1.29 diff -u -p -r1.29 in6_gif.c --- in6_gif.c 11 May 2010 09:36:07 - 1.29 +++ in6_gif.c 2 Apr 2011 11:45:41 - @@ -69,10 +69,6 @@ #include #endif -#ifndef offsetof -#define offsetof(s, e) ((int)&((s *)0)->e) -#endif - /* * family - family of the packet to be encapsulate. */ As of r1.54 of nd6_rtr.c we don't add addresses in interrupt context anymore. So this allocation can now wait: Index: in6.c === RCS file: /cvs/src/sys/netinet6/in6.c,v retrieving revision 1.89 diff -u -p -r1.89 in6.c --- in6.c 7 Oct 2010 22:07:06 - 1.89 +++ in6.c 2 Apr 2011 12:02:04 - @@ -910,14 +910,7 @@ in6_update_ifa(struct ifnet *ifp, struct */ if (ia == NULL) { hostIsNew = 1; - /* -* When in6_update_ifa() is called in a process of a received -* RA, it is called under an interrupt context. So, we should -* call malloc with M_NOWAIT. -*/ - ia = malloc(sizeof(*ia), M_IFADDR, M_NOWAIT | M_ZERO); - if (ia == NULL) - return (ENOBUFS); + ia = malloc(sizeof(*ia), M_IFADDR, M_WAITOK | M_ZERO); LIST_INIT(&ia->ia6_memberships); /* Initialize the address and masks, and put time stamp */ ia->ia_ifa.ifa_addr = (struct sockaddr *)&ia->ia_addr; Typos in comments: Index: ip6_input.c === RCS file: /cvs/src/sys/netinet6/ip6_input.c,v retrieving revision 1.98 diff -u -p -r1.98 ip6_input.c --- ip6_input.c 9 Sep 2010 09:46:13 - 1.98 +++ ip6_input.c 17 Dec 2010 21:54:45 - @@ -974,8 +974,8 @@ ip6_process_hopopts(struct mbuf *m, u_in /* * Unknown option processing. * The third argument `off' is the offset from the IPv6 header to the option, - * which is necessary if the IPv6 header the and option header and IPv6 header - * is not continuous in order to return an ICMPv6 error. + * which allows returning an ICMPv6 error even if the IPv6 header and the + * option header are not continuous. */ int ip6_unknown_opt(u_int8_t *optp, struct mbuf *m, int off) Index: nd6.h === RCS file: /cvs/src/sys/netinet6/nd6.h,v retrieving revision 1.27 diff -u -p -r1.27 nd6.h --- nd6.h 6 Apr 2010 14:12:10 - 1.27 +++ nd6.h 24 Oct 2010 12:04:13 - @@ -267,7 +267,7 @@ struct nd_prefix { /* list of routers that advertise the prefix: */ LIST_HEAD(pr_rtrhead, nd_pfxrouter) ndpr_advrtrs; u_char ndpr_plen; - int ndpr_refcnt;/* reference couter from addresses */ + int ndpr_refcnt;/* reference counter from addresses */ }; #define ndpr_next ndpr_entry.le_next
Re: relax gcc -Wsentinel checking
yes please! the casting of a NULL pointer is a pain in the butt and ugly. On Sat, Apr 02, 2011 at 11:13:05AM +, Miod Vallat wrote: > The -Wsentinel warning is supposed to complain when the last argument in > a call to a function which has __attribute__((sentinel)) is not a NULL > pointer. > > However, the current implementation of the check in gcc 3 and gcc 4 will > warn if the last argument is not explicitely declared as a pointer type, > i.e. > execl(foo, bar, (const char *)NULL) > will not warn, but > execl(foo, bar, NULL) > will cause a false warning, because NULL is defined as 0L for non-C++ > code. > > The following diff relaxes the check to let it accept either a pointer > or an integer type of the same width as a pointer (i.e. on a 64 bit > platform, using 0L will compile silently, but using 0 will). > > Ok? (note that this has only been tested on gcc 4, the gcc 3 version is > similar but has not even been checked to compile yet) > > Index: gnu/gcc/gcc/c-common.c > === > RCS file: /cvs/src/gnu/gcc/gcc/c-common.c,v > retrieving revision 1.3 > diff -u -p -r1.3 c-common.c > --- gnu/gcc/gcc/c-common.c12 May 2010 13:35:20 - 1.3 > +++ gnu/gcc/gcc/c-common.c2 Apr 2011 11:04:49 - > @@ -5498,15 +5498,17 @@ check_function_sentinel (tree attrs, tre > } > > /* Validate the sentinel. */ > - if ((!POINTER_TYPE_P (TREE_TYPE (TREE_VALUE (sentinel))) > -|| !integer_zerop (TREE_VALUE (sentinel))) > + sentinel = TREE_VALUE (sentinel); > + if ((!(POINTER_TYPE_P (TREE_TYPE (sentinel)) > + || (TREE_CODE (sentinel) == INTEGER_CST > + && TYPE_PRECISION (TREE_TYPE (sentinel)) == POINTER_SIZE)) > +|| !integer_zerop (sentinel)) > /* Although __null (in C++) is only an integer we allow it >nevertheless, as we are guaranteed that it's exactly >as wide as a pointer, and we don't want to force >users to cast the NULL they have written there. >We warn with -Wstrict-null-sentinel, though. */ > - && (warn_strict_null_sentinel > - || null_node != TREE_VALUE (sentinel))) > + && (warn_strict_null_sentinel || null_node != sentinel)) > warning (OPT_Wformat, "missing sentinel in function call"); > } > } > Index: gnu/usr.bin/gcc/gcc/c-common.c > === > RCS file: /cvs/src/gnu/usr.bin/gcc/gcc/c-common.c,v > retrieving revision 1.6 > diff -u -p -r1.6 c-common.c > --- gnu/usr.bin/gcc/gcc/c-common.c16 Oct 2009 12:22:07 - 1.6 > +++ gnu/usr.bin/gcc/gcc/c-common.c2 Apr 2011 11:04:50 - > @@ -6502,8 +6502,11 @@ check_function_sentinel (attrs, params) > } > > /* Validate the sentinel. */ > - if (!POINTER_TYPE_P (TREE_TYPE (TREE_VALUE (sentinel))) > - || !integer_zerop (TREE_VALUE (sentinel))) > + sentinel = TREE_VALUE (sentinel); > + if (!(POINTER_TYPE_P (TREE_TYPE (sentinel)) > + || (TREE_CODE (sentinel) == INTEGER_CST > + && TYPE_PRECISION (TREE_TYPE (sentinel)) == POINTER_SIZE)) > +|| !integer_zerop (sentinel)) > warning ("missing sentinel in function call"); > } > }
Fw: Segue em anexo relatorio orcamento.
[IMAGE] 1 anexos Relatorio-orcamento.pdf (142,0 kb) Segue em anexo o relatorio para orgamento. tenha um bom dia. __
Re: printf(1) null escape
#include #define CMD "/usr/bin/printf" int main(void) { execle(CMD, CMD, "\\", NULL, (char *[]){"BROKEN", NULL}); } On Sat, Apr 2, 2011 at 4:48 AM, Andres Perera wrote: > > print_escape returns 1 even if it's on null, and the rest of the > prog just ignores null literals > > $ env -i sh -c '/usr/bin/printf \\' > printf: unknown escape sequence `\' > PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin just to be absolutely clear, printf(1) is the one overstepping into environ[] because of how it badly handles escapes, not the shell #include #define CMD "/usr/bin/printf" int main(void) { execle(CMD, CMD, "\\", NULL, (char *[]){"BROKEN"}); } here's the plain bug: $ (./a.out; echo) | vis -l printf: unknown escape sequence `\' \^@BROKEN\$ > > diff -u -r1.17 printf.c > --- printf.c B B 27 Oct 2009 23:59:41 - B B B 1.17 > +++ printf.c B B 2 Apr 2011 18:44:36 - > @@ -351,6 +351,11 @@ > B B B B B B B B putchar('\v'); > B B B B B B B B break; > > + B B B case '\0': > + B B B B B B B warnx("null escape sequence"); > + B B B B B B B rval = 1; > + B B B B B B B return 0; > + > B B B B default: > B B B B B B B B putchar(*str); > B B B B B B B B warnx("unknown escape sequence `\\%c'", *str);
relax gcc -Wsentinel checking
The -Wsentinel warning is supposed to complain when the last argument in a call to a function which has __attribute__((sentinel)) is not a NULL pointer. However, the current implementation of the check in gcc 3 and gcc 4 will warn if the last argument is not explicitely declared as a pointer type, i.e. execl(foo, bar, (const char *)NULL) will not warn, but execl(foo, bar, NULL) will cause a false warning, because NULL is defined as 0L for non-C++ code. The following diff relaxes the check to let it accept either a pointer or an integer type of the same width as a pointer (i.e. on a 64 bit platform, using 0L will compile silently, but using 0 will). Ok? (note that this has only been tested on gcc 4, the gcc 3 version is similar but has not even been checked to compile yet) Index: gnu/gcc/gcc/c-common.c === RCS file: /cvs/src/gnu/gcc/gcc/c-common.c,v retrieving revision 1.3 diff -u -p -r1.3 c-common.c --- gnu/gcc/gcc/c-common.c 12 May 2010 13:35:20 - 1.3 +++ gnu/gcc/gcc/c-common.c 2 Apr 2011 11:04:49 - @@ -5498,15 +5498,17 @@ check_function_sentinel (tree attrs, tre } /* Validate the sentinel. */ - if ((!POINTER_TYPE_P (TREE_TYPE (TREE_VALUE (sentinel))) - || !integer_zerop (TREE_VALUE (sentinel))) + sentinel = TREE_VALUE (sentinel); + if ((!(POINTER_TYPE_P (TREE_TYPE (sentinel)) +|| (TREE_CODE (sentinel) == INTEGER_CST +&& TYPE_PRECISION (TREE_TYPE (sentinel)) == POINTER_SIZE)) + || !integer_zerop (sentinel)) /* Although __null (in C++) is only an integer we allow it nevertheless, as we are guaranteed that it's exactly as wide as a pointer, and we don't want to force users to cast the NULL they have written there. We warn with -Wstrict-null-sentinel, though. */ - && (warn_strict_null_sentinel - || null_node != TREE_VALUE (sentinel))) + && (warn_strict_null_sentinel || null_node != sentinel)) warning (OPT_Wformat, "missing sentinel in function call"); } } Index: gnu/usr.bin/gcc/gcc/c-common.c === RCS file: /cvs/src/gnu/usr.bin/gcc/gcc/c-common.c,v retrieving revision 1.6 diff -u -p -r1.6 c-common.c --- gnu/usr.bin/gcc/gcc/c-common.c 16 Oct 2009 12:22:07 - 1.6 +++ gnu/usr.bin/gcc/gcc/c-common.c 2 Apr 2011 11:04:50 - @@ -6502,8 +6502,11 @@ check_function_sentinel (attrs, params) } /* Validate the sentinel. */ - if (!POINTER_TYPE_P (TREE_TYPE (TREE_VALUE (sentinel))) - || !integer_zerop (TREE_VALUE (sentinel))) + sentinel = TREE_VALUE (sentinel); + if (!(POINTER_TYPE_P (TREE_TYPE (sentinel)) + || (TREE_CODE (sentinel) == INTEGER_CST + && TYPE_PRECISION (TREE_TYPE (sentinel)) == POINTER_SIZE)) + || !integer_zerop (sentinel)) warning ("missing sentinel in function call"); } }
printf(1) null escape
print_escape returns 1 even if it's on null, and the rest of the prog just ignores null literals $ env -i sh -c '/usr/bin/printf \\' printf: unknown escape sequence `\' PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin diff -u -r1.17 printf.c --- printf.c27 Oct 2009 23:59:41 - 1.17 +++ printf.c2 Apr 2011 18:44:36 - @@ -351,6 +351,11 @@ putchar('\v'); break; + case '\0': + warnx("null escape sequence"); + rval = 1; + return 0; + default: putchar(*str); warnx("unknown escape sequence `\\%c'", *str);