From 0f9d0a73a495b204ea02cf1da28db1bdd0c7e40b Mon Sep 17 00:00:00 2001 From: Gleb Smirnoff Date: Sun, 30 Nov 2014 12:52:33 +0000 Subject: [PATCH 01/94] Merge from projects/sendfile: o Introduce a notion of "not ready" mbufs in socket buffers. These mbufs are now being populated by some I/O in background and are referenced outside. This forces following implications: - An mbuf which is "not ready" can't be taken out of the buffer. - An mbuf that is behind a "not ready" in the queue neither. - If sockbet buffer is flushed, then "not ready" mbufs shouln't be freed. o In struct sockbuf the sb_cc field is split into sb_ccc and sb_acc. The sb_ccc stands for ""claimed character count", or "committed character count". And the sb_acc is "available character count". Consumers of socket buffer API shouldn't already access them directly, but use sbused() and sbavail() respectively. o Not ready mbufs are marked with M_NOTREADY, and ready but blocked ones with M_BLOCKED. o New field sb_fnrdy points to the first not ready mbuf, to avoid linear search. o New function sbready() is provided to activate certain amount of mbufs in a socket buffer. A special note on SCTP: SCTP has its own sockbufs. Unfortunately, FreeBSD stack doesn't yet allow protocol specific sockbufs. Thus, SCTP does some hacks to make itself compatible with FreeBSD: it manages sockbufs on its own, but keeps sb_cc updated to inform the stack of amount of data in them. The new notion of "not ready" data isn't supported by SCTP. Instead, only a mechanical substitute is done: s/sb_cc/sb_ccc/. A proper solution would be to take away struct sockbuf from struct socket and allow protocols to implement their own socket buffers, like SCTP already does. This was discussed with rrs@. Sponsored by: Netflix Sponsored by: Nginx, Inc. --- sys/dev/cxgbe/tom/t4_ddp.c | 3 +- sys/kern/uipc_debug.c | 3 +- sys/kern/uipc_sockbuf.c | 153 ++++++++++++++++++---- sys/kern/uipc_socket.c | 5 +- sys/netinet/sctp_indata.c | 6 +- sys/netinet/sctp_input.c | 2 +- sys/netinet/sctp_os_bsd.h | 2 +- sys/netinet/sctp_output.c | 4 +- sys/netinet/sctp_pcb.c | 6 +- sys/netinet/sctp_pcb.h | 2 +- sys/netinet/sctp_structs.h | 2 +- sys/netinet/sctp_usrreq.c | 8 +- sys/netinet/sctp_var.h | 12 +- sys/netinet/sctputil.c | 52 ++++---- sys/netinet/sctputil.h | 14 +- sys/sys/sockbuf.h | 37 ++++-- usr.bin/bluetooth/btsockstat/btsockstat.c | 16 +-- usr.bin/netstat/inet.c | 5 +- usr.bin/netstat/netgraph.c | 2 +- usr.bin/netstat/unix.c | 3 +- usr.bin/systat/netstat.c | 4 +- 21 files changed, 229 insertions(+), 112 deletions(-) diff --git a/sys/dev/cxgbe/tom/t4_ddp.c b/sys/dev/cxgbe/tom/t4_ddp.c index 89585cf83039..bf0889963306 100644 --- a/sys/dev/cxgbe/tom/t4_ddp.c +++ b/sys/dev/cxgbe/tom/t4_ddp.c @@ -971,8 +971,9 @@ handle_ddp(struct socket *so, struct uio *uio, int flags, int error) */ rc = sbwait(sb); while (toep->ddp_flags & buf_flag) { + /* XXXGL: shouldn't here be sbwait() call? */ sb->sb_flags |= SB_WAIT; - msleep(&sb->sb_cc, &sb->sb_mtx, PSOCK , "sbwait", 0); + msleep(&sb->sb_acc, &sb->sb_mtx, PSOCK , "sbwait", 0); } unwire_ddp_buffer(db); return (rc); diff --git a/sys/kern/uipc_debug.c b/sys/kern/uipc_debug.c index 0f233ecebd69..c3081a497ae6 100644 --- a/sys/kern/uipc_debug.c +++ b/sys/kern/uipc_debug.c @@ -401,7 +401,8 @@ db_print_sockbuf(struct sockbuf *sb, const char *sockbufname, int indent) db_printf("sb_sndptroff: %u\n", sb->sb_sndptroff); db_print_indent(indent); - db_printf("sb_cc: %u ", sb->sb_cc); + db_printf("sb_acc: %u ", sb->sb_acc); + db_printf("sb_ccc: %u ", sb->sb_ccc); db_printf("sb_hiwat: %u ", sb->sb_hiwat); db_printf("sb_mbcnt: %u ", sb->sb_mbcnt); db_printf("sb_mbmax: %u\n", sb->sb_mbmax); diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c index 00ffee326323..b5a5185d46ce 100644 --- a/sys/kern/uipc_sockbuf.c +++ b/sys/kern/uipc_sockbuf.c @@ -68,6 +68,43 @@ static u_long sb_efficiency = 8; /* parameter for sbreserve() */ static struct mbuf *sbcut_internal(struct sockbuf *sb, int len); static void sbflush_internal(struct sockbuf *sb); +/* + * Mark ready "count" mbufs starting with "m". + */ +int +sbready(struct sockbuf *sb, struct mbuf *m, int count) +{ + u_int blocker; + + SOCKBUF_LOCK_ASSERT(sb); + KASSERT(sb->sb_fnrdy != NULL, ("%s: sb %p NULL fnrdy", __func__, sb)); + + blocker = (sb->sb_fnrdy == m) ? M_BLOCKED : 0; + + for (int i = 0; i < count; i++, m = m->m_next) { + KASSERT(m->m_flags & M_NOTREADY, + ("%s: m %p !M_NOTREADY", __func__, m)); + m->m_flags &= ~(M_NOTREADY | blocker); + if (blocker) + sb->sb_acc += m->m_len; + } + + if (!blocker) + return (EINPROGRESS); + + /* This one was blocking all the queue. */ + for (; m && (m->m_flags & M_NOTREADY) == 0; m = m->m_next) { + KASSERT(m->m_flags & M_BLOCKED, + ("%s: m %p !M_BLOCKED", __func__, m)); + m->m_flags &= ~M_BLOCKED; + sb->sb_acc += m->m_len; + } + + sb->sb_fnrdy = m; + + return (0); +} + /* * Adjust sockbuf state reflecting allocation of m. */ @@ -77,7 +114,15 @@ sballoc(struct sockbuf *sb, struct mbuf *m) SOCKBUF_LOCK_ASSERT(sb); - sb->sb_cc += m->m_len; + sb->sb_ccc += m->m_len; + + if (sb->sb_fnrdy == NULL) { + if (m->m_flags & M_NOTREADY) + sb->sb_fnrdy = m; + else + sb->sb_acc += m->m_len; + } else + m->m_flags |= M_BLOCKED; if (m->m_type != MT_DATA && m->m_type != MT_OOBDATA) sb->sb_ctl += m->m_len; @@ -102,7 +147,25 @@ sbfree(struct sockbuf *sb, struct mbuf *m) SOCKBUF_LOCK_ASSERT(sb); #endif - sb->sb_cc -= m->m_len; + sb->sb_ccc -= m->m_len; + + if (!(m->m_flags & M_NOTAVAIL)) + sb->sb_acc -= m->m_len; + + if (m == sb->sb_fnrdy) { + struct mbuf *n; + + KASSERT(m->m_flags & M_NOTREADY, + ("%s: m %p !M_NOTREADY", __func__, m)); + + n = m->m_next; + while (n != NULL && !(n->m_flags & M_NOTREADY)) { + n->m_flags &= ~M_BLOCKED; + sb->sb_acc += n->m_len; + n = n->m_next; + } + sb->sb_fnrdy = n; + } if (m->m_type != MT_DATA && m->m_type != MT_OOBDATA) sb->sb_ctl -= m->m_len; @@ -181,7 +244,7 @@ sbwait(struct sockbuf *sb) SOCKBUF_LOCK_ASSERT(sb); sb->sb_flags |= SB_WAIT; - return (msleep_sbt(&sb->sb_cc, &sb->sb_mtx, + return (msleep_sbt(&sb->sb_acc, &sb->sb_mtx, (sb->sb_flags & SB_NOINTR) ? PSOCK : PSOCK | PCATCH, "sbwait", sb->sb_timeo, 0, 0)); } @@ -238,7 +301,7 @@ sowakeup(struct socket *so, struct sockbuf *sb) sb->sb_flags &= ~SB_SEL; if (sb->sb_flags & SB_WAIT) { sb->sb_flags &= ~SB_WAIT; - wakeup(&sb->sb_cc); + wakeup(&sb->sb_acc); } KNOTE_LOCKED(&sb->sb_sel.si_note, 0); if (sb->sb_upcall != NULL) { @@ -609,12 +672,13 @@ sbappendstream(struct sockbuf *sb, struct mbuf *m) void sbcheck(struct sockbuf *sb, const char *file, int line) { - struct mbuf *m, *n; - u_long cc, mbcnt; + struct mbuf *m, *n, *fnrdy; + u_long acc, ccc, mbcnt; SOCKBUF_LOCK_ASSERT(sb); - cc = mbcnt = 0; + acc = ccc = mbcnt = 0; + fnrdy = NULL; for (m = sb->sb_mb; m; m = n) { n = m->m_nextpkt; @@ -623,15 +687,31 @@ sbcheck(struct sockbuf *sb, const char *file, int line) printf("sb %p empty mbuf %p\n", sb, m); goto fail; } - cc += m->m_len; + if ((m->m_flags & M_NOTREADY) && fnrdy == NULL) { + if (m != sb->sb_fnrdy) { + printf("sb %p: fnrdy %p != m %p\n", + sb, sb->sb_fnrdy, m); + goto fail; + } + fnrdy = m; + } + if (fnrdy) { + if (!(m->m_flags & M_NOTAVAIL)) { + printf("sb %p: fnrdy %p, m %p is avail\n", + sb, sb->sb_fnrdy, m); + goto fail; + } + } else + acc += m->m_len; + ccc += m->m_len; mbcnt += MSIZE; if (m->m_flags & M_EXT) /*XXX*/ /* pretty sure this is bogus */ mbcnt += m->m_ext.ext_size; } } - if (cc != sb->sb_cc || mbcnt != sb->sb_mbcnt) { - printf("cc %ld != %u || mbcnt %ld != %u\n", cc, sb->sb_cc, - mbcnt, sb->sb_mbcnt); + if (acc != sb->sb_acc || ccc != sb->sb_ccc || mbcnt != sb->sb_mbcnt) { + printf("acc %ld/%u ccc %ld/%u mbcnt %ld/%u\n", + acc, sb->sb_acc, ccc, sb->sb_ccc, mbcnt, sb->sb_mbcnt); goto fail; } return; @@ -832,8 +912,8 @@ sbappendcontrol(struct sockbuf *sb, struct mbuf *m0, struct mbuf *control) * * (2) The mbuf may be coalesced -- i.e., data in the mbuf may be copied into * an mbuf already in the socket buffer. This can occur if an - * appropriate mbuf exists, there is room, and no merging of data types - * will occur. + * appropriate mbuf exists, there is room, both mbufs are not marked as + * not ready, and no merging of data types will occur. * * (3) The mbuf may be appended to the end of the existing mbuf chain. * @@ -862,13 +942,17 @@ sbcompress(struct sockbuf *sb, struct mbuf *m, struct mbuf *n) if (n && (n->m_flags & M_EOR) == 0 && M_WRITABLE(n) && ((sb->sb_flags & SB_NOCOALESCE) == 0) && + !(m->m_flags & M_NOTREADY) && + !(n->m_flags & M_NOTREADY) && m->m_len <= MCLBYTES / 4 && /* XXX: Don't copy too much */ m->m_len <= M_TRAILINGSPACE(n) && n->m_type == m->m_type) { bcopy(mtod(m, caddr_t), mtod(n, caddr_t) + n->m_len, (unsigned)m->m_len); n->m_len += m->m_len; - sb->sb_cc += m->m_len; + sb->sb_ccc += m->m_len; + if (sb->sb_fnrdy == NULL) + sb->sb_acc += m->m_len; if (m->m_type != MT_DATA && m->m_type != MT_OOBDATA) /* XXX: Probably don't need.*/ sb->sb_ctl += m->m_len; @@ -905,13 +989,13 @@ sbflush_internal(struct sockbuf *sb) * Don't call sbcut(sb, 0) if the leading mbuf is non-empty: * we would loop forever. Panic instead. */ - if (!sb->sb_cc && (sb->sb_mb == NULL || sb->sb_mb->m_len)) + if (sb->sb_ccc == 0 && (sb->sb_mb == NULL || sb->sb_mb->m_len)) break; - m_freem(sbcut_internal(sb, (int)sb->sb_cc)); + m_freem(sbcut_internal(sb, (int)sb->sb_ccc)); } - if (sb->sb_cc || sb->sb_mb || sb->sb_mbcnt) - panic("sbflush_internal: cc %u || mb %p || mbcnt %u", - sb->sb_cc, (void *)sb->sb_mb, sb->sb_mbcnt); + KASSERT(sb->sb_ccc == 0 && sb->sb_mb == 0 && sb->sb_mbcnt == 0, + ("%s: ccc %u mb %p mbcnt %u", __func__, + sb->sb_ccc, (void *)sb->sb_mb, sb->sb_mbcnt)); } void @@ -937,7 +1021,7 @@ sbflush(struct sockbuf *sb) static struct mbuf * sbcut_internal(struct sockbuf *sb, int len) { - struct mbuf *m, *n, *next, *mfree; + struct mbuf *m, *next, *mfree; next = (m = sb->sb_mb) ? m->m_nextpkt : 0; mfree = NULL; @@ -949,9 +1033,12 @@ sbcut_internal(struct sockbuf *sb, int len) next = m->m_nextpkt; } if (m->m_len > len) { + KASSERT(!(m->m_flags & M_NOTAVAIL), + ("%s: m %p M_NOTAVAIL", __func__, m)); m->m_len -= len; m->m_data += len; - sb->sb_cc -= len; + sb->sb_ccc -= len; + sb->sb_acc -= len; if (sb->sb_sndptroff != 0) sb->sb_sndptroff -= len; if (m->m_type != MT_DATA && m->m_type != MT_OOBDATA) @@ -960,10 +1047,20 @@ sbcut_internal(struct sockbuf *sb, int len) } len -= m->m_len; sbfree(sb, m); - n = m->m_next; - m->m_next = mfree; - mfree = m; - m = n; + /* + * Do not put M_NOTREADY buffers to the free list, they + * are referenced from outside. + */ + if (m->m_flags & M_NOTREADY) + m = m->m_next; + else { + struct mbuf *n; + + n = m->m_next; + m->m_next = mfree; + mfree = m; + m = n; + } } if (m) { sb->sb_mb = m; @@ -1030,8 +1127,8 @@ sbsndptr(struct sockbuf *sb, u_int off, u_int len, u_int *moff) struct mbuf *m, *ret; KASSERT(sb->sb_mb != NULL, ("%s: sb_mb is NULL", __func__)); - KASSERT(off + len <= sb->sb_cc, ("%s: beyond sb", __func__)); - KASSERT(sb->sb_sndptroff <= sb->sb_cc, ("%s: sndptroff broken", __func__)); + KASSERT(off + len <= sb->sb_acc, ("%s: beyond sb", __func__)); + KASSERT(sb->sb_sndptroff <= sb->sb_acc, ("%s: sndptroff broken", __func__)); /* * Is off below stored offset? Happens on retransmits. @@ -1180,7 +1277,7 @@ void sbtoxsockbuf(struct sockbuf *sb, struct xsockbuf *xsb) { - xsb->sb_cc = sb->sb_cc; + xsb->sb_cc = sb->sb_ccc; xsb->sb_hiwat = sb->sb_hiwat; xsb->sb_mbcnt = sb->sb_mbcnt; xsb->sb_mcnt = sb->sb_mcnt; diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 240421f694b2..7433b0e2ad1c 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1706,7 +1706,8 @@ soreceive_generic(struct socket *so, struct sockaddr **psa, struct uio *uio, */ moff = 0; offset = 0; - while (m != NULL && uio->uio_resid > 0 && error == 0) { + while (m != NULL && !(m->m_flags & M_NOTAVAIL) && uio->uio_resid > 0 + && error == 0) { /* * If the type of mbuf has changed since the last mbuf * examined ('type'), end the receive operation. @@ -2044,6 +2045,8 @@ soreceive_stream(struct socket *so, struct sockaddr **psa, struct uio *uio, for (m = sb->sb_mb; m != NULL && m->m_len <= len; m = m->m_next) { + KASSERT(!(m->m_flags & M_NOTAVAIL), + ("%s: m %p not available", __func__, m)); len -= m->m_len; uio->uio_resid -= m->m_len; sbfree(sb, m); diff --git a/sys/netinet/sctp_indata.c b/sys/netinet/sctp_indata.c index 2065bb4fdae4..97ca01338e83 100644 --- a/sys/netinet/sctp_indata.c +++ b/sys/netinet/sctp_indata.c @@ -70,14 +70,14 @@ sctp_calc_rwnd(struct sctp_tcb *stcb, struct sctp_association *asoc) /* * This is really set wrong with respect to a 1-2-m socket. Since - * the sb_cc is the count that everyone as put up. When we re-write + * the sb_ccc is the count that everyone as put up. When we re-write * sctp_soreceive then we will fix this so that ONLY this * associations data is taken into account. */ if (stcb->sctp_socket == NULL) return (calc); - if (stcb->asoc.sb_cc == 0 && + if (stcb->asoc.sb_ccc == 0 && asoc->size_on_reasm_queue == 0 && asoc->size_on_all_streams == 0) { /* Full rwnd granted */ @@ -1363,7 +1363,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, * When we have NO room in the rwnd we check to make sure * the reader is doing its job... */ - if (stcb->sctp_socket->so_rcv.sb_cc) { + if (stcb->sctp_socket->so_rcv.sb_ccc) { /* some to read, wake-up */ #if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) struct socket *so; diff --git a/sys/netinet/sctp_input.c b/sys/netinet/sctp_input.c index 62de260179ad..52ac81e92fb7 100644 --- a/sys/netinet/sctp_input.c +++ b/sys/netinet/sctp_input.c @@ -1032,7 +1032,7 @@ sctp_handle_shutdown_ack(struct sctp_shutdown_ack_chunk *cp SCTP_UNUSED, if (stcb->sctp_socket) { if ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) { - stcb->sctp_socket->so_snd.sb_cc = 0; + stcb->sctp_socket->so_snd.sb_ccc = 0; } sctp_ulp_notify(SCTP_NOTIFY_ASSOC_DOWN, stcb, 0, NULL, SCTP_SO_NOT_LOCKED); } diff --git a/sys/netinet/sctp_os_bsd.h b/sys/netinet/sctp_os_bsd.h index 558d4e18357c..69ecf40655dd 100644 --- a/sys/netinet/sctp_os_bsd.h +++ b/sys/netinet/sctp_os_bsd.h @@ -399,7 +399,7 @@ typedef struct callout sctp_os_timer_t; #define SCTP_SOWAKEUP(so) wakeup(&(so)->so_timeo) /* clear the socket buffer state */ #define SCTP_SB_CLEAR(sb) \ - (sb).sb_cc = 0; \ + (sb).sb_ccc = 0; \ (sb).sb_mb = NULL; \ (sb).sb_mbcnt = 0; diff --git a/sys/netinet/sctp_output.c b/sys/netinet/sctp_output.c index a122325a28e6..3139be08091f 100644 --- a/sys/netinet/sctp_output.c +++ b/sys/netinet/sctp_output.c @@ -7250,7 +7250,7 @@ sctp_move_to_outqueue(struct sctp_tcb *stcb, if ((stcb->sctp_socket != NULL) && \ ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL))) { - atomic_subtract_int(&stcb->sctp_socket->so_snd.sb_cc, sp->length); + atomic_subtract_int(&stcb->sctp_socket->so_snd.sb_ccc, sp->length); } if (sp->data) { sctp_m_freem(sp->data); @@ -11532,7 +11532,7 @@ sctp_send_packet_dropped(struct sctp_tcb *stcb, struct sctp_nets *net, drp->current_onq = htonl(asoc->size_on_reasm_queue + asoc->size_on_all_streams + asoc->my_rwnd_control_len + - stcb->sctp_socket->so_rcv.sb_cc); + stcb->sctp_socket->so_rcv.sb_ccc); } else { /*- * If my rwnd is 0, possibly from mbuf depletion as well as diff --git a/sys/netinet/sctp_pcb.c b/sys/netinet/sctp_pcb.c index 2fa99b9e6243..72c3f042f7de 100644 --- a/sys/netinet/sctp_pcb.c +++ b/sys/netinet/sctp_pcb.c @@ -3397,7 +3397,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from) if ((asoc->asoc.size_on_reasm_queue > 0) || (asoc->asoc.control_pdapi) || (asoc->asoc.size_on_all_streams > 0) || - (so && (so->so_rcv.sb_cc > 0))) { + (so && (so->so_rcv.sb_ccc > 0))) { /* Left with Data unread */ struct mbuf *op_err; @@ -3625,7 +3625,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from) TAILQ_REMOVE(&inp->read_queue, sq, next); sctp_free_remote_addr(sq->whoFrom); if (so) - so->so_rcv.sb_cc -= sq->length; + so->so_rcv.sb_ccc -= sq->length; if (sq->data) { sctp_m_freem(sq->data); sq->data = NULL; @@ -4853,7 +4853,7 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre inp->sctp_flags |= SCTP_PCB_FLAGS_WAS_CONNECTED; if (so) { SOCK_LOCK(so); - if (so->so_rcv.sb_cc == 0) { + if (so->so_rcv.sb_ccc == 0) { so->so_state &= ~(SS_ISCONNECTING | SS_ISDISCONNECTING | SS_ISCONFIRMING | diff --git a/sys/netinet/sctp_pcb.h b/sys/netinet/sctp_pcb.h index c9183b1d8207..25416283f916 100644 --- a/sys/netinet/sctp_pcb.h +++ b/sys/netinet/sctp_pcb.h @@ -369,7 +369,7 @@ struct sctp_inpcb { } ip_inp; - /* Socket buffer lock protects read_queue and of course sb_cc */ + /* Socket buffer lock protects read_queue and of course sb_ccc */ struct sctp_readhead read_queue; LIST_ENTRY(sctp_inpcb) sctp_list; /* lists all endpoints */ diff --git a/sys/netinet/sctp_structs.h b/sys/netinet/sctp_structs.h index 3f6d935ba173..127068145525 100644 --- a/sys/netinet/sctp_structs.h +++ b/sys/netinet/sctp_structs.h @@ -990,7 +990,7 @@ struct sctp_association { uint32_t total_output_queue_size; - uint32_t sb_cc; /* shadow of sb_cc */ + uint32_t sb_ccc; /* shadow of sb_ccc */ uint32_t sb_send_resv; /* amount reserved on a send */ uint32_t my_rwnd_control_len; /* shadow of sb_mbcnt used for rwnd * control */ diff --git a/sys/netinet/sctp_usrreq.c b/sys/netinet/sctp_usrreq.c index e1ad178135e0..9dc7cdced64a 100644 --- a/sys/netinet/sctp_usrreq.c +++ b/sys/netinet/sctp_usrreq.c @@ -586,7 +586,7 @@ sctp_close(struct socket *so) if (((flags & SCTP_PCB_FLAGS_SOCKET_GONE) == 0) && (atomic_cmpset_int(&inp->sctp_flags, flags, (flags | SCTP_PCB_FLAGS_SOCKET_GONE | SCTP_PCB_FLAGS_CLOSE_IP)))) { if (((so->so_options & SO_LINGER) && (so->so_linger == 0)) || - (so->so_rcv.sb_cc > 0)) { + (so->so_rcv.sb_ccc > 0)) { #ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, NULL, 13); #endif @@ -751,7 +751,7 @@ sctp_disconnect(struct socket *so) } if (((so->so_options & SO_LINGER) && (so->so_linger == 0)) || - (so->so_rcv.sb_cc > 0)) { + (so->so_rcv.sb_ccc > 0)) { if (SCTP_GET_STATE(asoc) != SCTP_STATE_COOKIE_WAIT) { /* Left with Data unread */ @@ -916,7 +916,7 @@ sctp_flush(struct socket *so, int how) inp->sctp_flags |= SCTP_PCB_FLAGS_SOCKET_CANT_READ; SCTP_INP_READ_UNLOCK(inp); SCTP_INP_WUNLOCK(inp); - so->so_rcv.sb_cc = 0; + so->so_rcv.sb_ccc = 0; so->so_rcv.sb_mbcnt = 0; so->so_rcv.sb_mb = NULL; } @@ -925,7 +925,7 @@ sctp_flush(struct socket *so, int how) * First make sure the sb will be happy, we don't use these * except maybe the count */ - so->so_snd.sb_cc = 0; + so->so_snd.sb_ccc = 0; so->so_snd.sb_mbcnt = 0; so->so_snd.sb_mb = NULL; diff --git a/sys/netinet/sctp_var.h b/sys/netinet/sctp_var.h index 31d93dd21bd9..bab8a7709dd5 100644 --- a/sys/netinet/sctp_var.h +++ b/sys/netinet/sctp_var.h @@ -82,9 +82,9 @@ extern struct pr_usrreqs sctp_usrreqs; #define sctp_maxspace(sb) (max((sb)->sb_hiwat,SCTP_MINIMAL_RWND)) -#define sctp_sbspace(asoc, sb) ((long) ((sctp_maxspace(sb) > (asoc)->sb_cc) ? (sctp_maxspace(sb) - (asoc)->sb_cc) : 0)) +#define sctp_sbspace(asoc, sb) ((long) ((sctp_maxspace(sb) > (asoc)->sb_ccc) ? (sctp_maxspace(sb) - (asoc)->sb_ccc) : 0)) -#define sctp_sbspace_failedmsgs(sb) ((long) ((sctp_maxspace(sb) > (sb)->sb_cc) ? (sctp_maxspace(sb) - (sb)->sb_cc) : 0)) +#define sctp_sbspace_failedmsgs(sb) ((long) ((sctp_maxspace(sb) > (sb)->sb_ccc) ? (sctp_maxspace(sb) - (sb)->sb_ccc) : 0)) #define sctp_sbspace_sub(a,b) ((a > b) ? (a - b) : 0) @@ -195,10 +195,10 @@ extern struct pr_usrreqs sctp_usrreqs; } #define sctp_sbfree(ctl, stcb, sb, m) { \ - SCTP_SAVE_ATOMIC_DECREMENT(&(sb)->sb_cc, SCTP_BUF_LEN((m))); \ + SCTP_SAVE_ATOMIC_DECREMENT(&(sb)->sb_ccc, SCTP_BUF_LEN((m))); \ SCTP_SAVE_ATOMIC_DECREMENT(&(sb)->sb_mbcnt, MSIZE); \ if (((ctl)->do_not_ref_stcb == 0) && stcb) {\ - SCTP_SAVE_ATOMIC_DECREMENT(&(stcb)->asoc.sb_cc, SCTP_BUF_LEN((m))); \ + SCTP_SAVE_ATOMIC_DECREMENT(&(stcb)->asoc.sb_ccc, SCTP_BUF_LEN((m))); \ SCTP_SAVE_ATOMIC_DECREMENT(&(stcb)->asoc.my_rwnd_control_len, MSIZE); \ } \ if (SCTP_BUF_TYPE(m) != MT_DATA && SCTP_BUF_TYPE(m) != MT_HEADER && \ @@ -207,10 +207,10 @@ extern struct pr_usrreqs sctp_usrreqs; } #define sctp_sballoc(stcb, sb, m) { \ - atomic_add_int(&(sb)->sb_cc,SCTP_BUF_LEN((m))); \ + atomic_add_int(&(sb)->sb_ccc,SCTP_BUF_LEN((m))); \ atomic_add_int(&(sb)->sb_mbcnt, MSIZE); \ if (stcb) { \ - atomic_add_int(&(stcb)->asoc.sb_cc,SCTP_BUF_LEN((m))); \ + atomic_add_int(&(stcb)->asoc.sb_ccc,SCTP_BUF_LEN((m))); \ atomic_add_int(&(stcb)->asoc.my_rwnd_control_len, MSIZE); \ } \ if (SCTP_BUF_TYPE(m) != MT_DATA && SCTP_BUF_TYPE(m) != MT_HEADER && \ diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c index 1e87a17b2cba..e0e0670d5a50 100644 --- a/sys/netinet/sctputil.c +++ b/sys/netinet/sctputil.c @@ -67,9 +67,9 @@ sctp_sblog(struct sockbuf *sb, struct sctp_tcb *stcb, int from, int incr) struct sctp_cwnd_log sctp_clog; sctp_clog.x.sb.stcb = stcb; - sctp_clog.x.sb.so_sbcc = sb->sb_cc; + sctp_clog.x.sb.so_sbcc = sb->sb_ccc; if (stcb) - sctp_clog.x.sb.stcb_sbcc = stcb->asoc.sb_cc; + sctp_clog.x.sb.stcb_sbcc = stcb->asoc.sb_ccc; else sctp_clog.x.sb.stcb_sbcc = 0; sctp_clog.x.sb.incr = incr; @@ -4363,7 +4363,7 @@ sctp_add_to_readq(struct sctp_inpcb *inp, { /* * Here we must place the control on the end of the socket read - * queue AND increment sb_cc so that select will work properly on + * queue AND increment sb_ccc so that select will work properly on * read. */ struct mbuf *m, *prev = NULL; @@ -4489,7 +4489,7 @@ sctp_append_to_readq(struct sctp_inpcb *inp, * the reassembly queue. * * If PDAPI this means we need to add m to the end of the data. - * Increase the length in the control AND increment the sb_cc. + * Increase the length in the control AND increment the sb_ccc. * Otherwise sb is NULL and all we need to do is put it at the end * of the mbuf chain. */ @@ -4701,10 +4701,10 @@ sctp_free_bufspace(struct sctp_tcb *stcb, struct sctp_association *asoc, if (stcb->sctp_socket && (((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) || ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE)))) { - if (stcb->sctp_socket->so_snd.sb_cc >= tp1->book_size) { - stcb->sctp_socket->so_snd.sb_cc -= tp1->book_size; + if (stcb->sctp_socket->so_snd.sb_ccc >= tp1->book_size) { + stcb->sctp_socket->so_snd.sb_ccc -= tp1->book_size; } else { - stcb->sctp_socket->so_snd.sb_cc = 0; + stcb->sctp_socket->so_snd.sb_ccc = 0; } } @@ -5254,11 +5254,11 @@ sctp_sorecvmsg(struct socket *so, in_eeor_mode = sctp_is_feature_on(inp, SCTP_PCB_FLAGS_EXPLICIT_EOR); if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_RECV_RWND_LOGGING_ENABLE) { sctp_misc_ints(SCTP_SORECV_ENTER, - rwnd_req, in_eeor_mode, so->so_rcv.sb_cc, uio->uio_resid); + rwnd_req, in_eeor_mode, so->so_rcv.sb_ccc, uio->uio_resid); } if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_RECV_RWND_LOGGING_ENABLE) { sctp_misc_ints(SCTP_SORECV_ENTERPL, - rwnd_req, block_allowed, so->so_rcv.sb_cc, uio->uio_resid); + rwnd_req, block_allowed, so->so_rcv.sb_ccc, uio->uio_resid); } error = sblock(&so->so_rcv, (block_allowed ? SBL_WAIT : 0)); if (error) { @@ -5277,23 +5277,23 @@ sctp_sorecvmsg(struct socket *so, (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE)) { goto out; } - if ((so->so_rcv.sb_state & SBS_CANTRCVMORE) && (so->so_rcv.sb_cc == 0)) { + if ((so->so_rcv.sb_state & SBS_CANTRCVMORE) && (so->so_rcv.sb_ccc == 0)) { if (so->so_error) { error = so->so_error; if ((in_flags & MSG_PEEK) == 0) so->so_error = 0; goto out; } else { - if (so->so_rcv.sb_cc == 0) { + if (so->so_rcv.sb_ccc == 0) { /* indicate EOF */ error = 0; goto out; } } } - if ((so->so_rcv.sb_cc <= held_length) && block_allowed) { + if ((so->so_rcv.sb_ccc <= held_length) && block_allowed) { /* we need to wait for data */ - if ((so->so_rcv.sb_cc == 0) && + if ((so->so_rcv.sb_ccc == 0) && ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL))) { if ((inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED) == 0) { @@ -5329,7 +5329,7 @@ sctp_sorecvmsg(struct socket *so, } held_length = 0; goto restart_nosblocks; - } else if (so->so_rcv.sb_cc == 0) { + } else if (so->so_rcv.sb_ccc == 0) { if (so->so_error) { error = so->so_error; if ((in_flags & MSG_PEEK) == 0) @@ -5386,11 +5386,11 @@ sctp_sorecvmsg(struct socket *so, SCTP_INP_READ_LOCK(inp); } control = TAILQ_FIRST(&inp->read_queue); - if ((control == NULL) && (so->so_rcv.sb_cc != 0)) { + if ((control == NULL) && (so->so_rcv.sb_ccc != 0)) { #ifdef INVARIANTS panic("Huh, its non zero and nothing on control?"); #endif - so->so_rcv.sb_cc = 0; + so->so_rcv.sb_ccc = 0; } SCTP_INP_READ_UNLOCK(inp); hold_rlock = 0; @@ -5511,11 +5511,11 @@ sctp_sorecvmsg(struct socket *so, } /* * if we reach here, not suitable replacement is available - * fragment interleave is NOT on. So stuff the sb_cc + * fragment interleave is NOT on. So stuff the sb_ccc * into the our held count, and its time to sleep again. */ - held_length = so->so_rcv.sb_cc; - control->held_length = so->so_rcv.sb_cc; + held_length = so->so_rcv.sb_ccc; + control->held_length = so->so_rcv.sb_ccc; goto restart; } /* Clear the held length since there is something to read */ @@ -5812,10 +5812,10 @@ sctp_sorecvmsg(struct socket *so, if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_SB_LOGGING_ENABLE) { sctp_sblog(&so->so_rcv, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBFREE, cp_len); } - atomic_subtract_int(&so->so_rcv.sb_cc, cp_len); + atomic_subtract_int(&so->so_rcv.sb_ccc, cp_len); if ((control->do_not_ref_stcb == 0) && stcb) { - atomic_subtract_int(&stcb->asoc.sb_cc, cp_len); + atomic_subtract_int(&stcb->asoc.sb_ccc, cp_len); } copied_so_far += cp_len; freed_so_far += cp_len; @@ -5960,7 +5960,7 @@ sctp_sorecvmsg(struct socket *so, (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_FRAG_INTERLEAVE))) { goto release; } - if (so->so_rcv.sb_cc <= control->held_length) { + if (so->so_rcv.sb_ccc <= control->held_length) { error = sbwait(&so->so_rcv); if (error) { goto release; @@ -5987,8 +5987,8 @@ sctp_sorecvmsg(struct socket *so, } goto done_with_control; } - if (so->so_rcv.sb_cc > held_length) { - control->held_length = so->so_rcv.sb_cc; + if (so->so_rcv.sb_ccc > held_length) { + control->held_length = so->so_rcv.sb_ccc; held_length = 0; } goto wait_some_more; @@ -6135,13 +6135,13 @@ sctp_sorecvmsg(struct socket *so, freed_so_far, ((uio) ? (slen - uio->uio_resid) : slen), stcb->asoc.my_rwnd, - so->so_rcv.sb_cc); + so->so_rcv.sb_ccc); } else { sctp_misc_ints(SCTP_SORECV_DONE, freed_so_far, ((uio) ? (slen - uio->uio_resid) : slen), 0, - so->so_rcv.sb_cc); + so->so_rcv.sb_ccc); } } stage_left: diff --git a/sys/netinet/sctputil.h b/sys/netinet/sctputil.h index 559daa3764fa..a9e72625c5e3 100644 --- a/sys/netinet/sctputil.h +++ b/sys/netinet/sctputil.h @@ -286,10 +286,10 @@ do { \ } \ if (stcb->sctp_socket && ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || \ (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL))) { \ - if (stcb->sctp_socket->so_snd.sb_cc >= tp1->book_size) { \ - atomic_subtract_int(&((stcb)->sctp_socket->so_snd.sb_cc), tp1->book_size); \ + if (stcb->sctp_socket->so_snd.sb_ccc >= tp1->book_size) { \ + atomic_subtract_int(&((stcb)->sctp_socket->so_snd.sb_ccc), tp1->book_size); \ } else { \ - stcb->sctp_socket->so_snd.sb_cc = 0; \ + stcb->sctp_socket->so_snd.sb_ccc = 0; \ } \ } \ } \ @@ -307,10 +307,10 @@ do { \ } \ if (stcb->sctp_socket && ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || \ (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL))) { \ - if (stcb->sctp_socket->so_snd.sb_cc >= sp->length) { \ - atomic_subtract_int(&stcb->sctp_socket->so_snd.sb_cc,sp->length); \ + if (stcb->sctp_socket->so_snd.sb_ccc >= sp->length) { \ + atomic_subtract_int(&stcb->sctp_socket->so_snd.sb_ccc,sp->length); \ } else { \ - stcb->sctp_socket->so_snd.sb_cc = 0; \ + stcb->sctp_socket->so_snd.sb_ccc = 0; \ } \ } \ } \ @@ -322,7 +322,7 @@ do { \ if ((stcb->sctp_socket != NULL) && \ ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || \ (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL))) { \ - atomic_add_int(&stcb->sctp_socket->so_snd.sb_cc,sz); \ + atomic_add_int(&stcb->sctp_socket->so_snd.sb_ccc,sz); \ } \ } while (0) diff --git a/sys/sys/sockbuf.h b/sys/sys/sockbuf.h index 1cd419f3283a..ec16b2593dd2 100644 --- a/sys/sys/sockbuf.h +++ b/sys/sys/sockbuf.h @@ -89,8 +89,10 @@ struct sockbuf { struct mbuf *sb_lastrecord; /* (c/d) first mbuf of last * record in socket buffer */ struct mbuf *sb_sndptr; /* (c/d) pointer into mbuf chain */ + struct mbuf *sb_fnrdy; /* (c/d) pointer to first not ready buffer */ u_int sb_sndptroff; /* (c/d) byte offset of ptr into chain */ - u_int sb_cc; /* (c/d) actual chars in buffer */ + u_int sb_acc; /* (c/d) available chars in buffer */ + u_int sb_ccc; /* (c/d) claimed chars in buffer */ u_int sb_hiwat; /* (c/d) max actual char count */ u_int sb_mbcnt; /* (c/d) chars of mbufs used */ u_int sb_mcnt; /* (c/d) number of mbufs in buffer */ @@ -120,6 +122,13 @@ struct sockbuf { #define SOCKBUF_LOCK_ASSERT(_sb) mtx_assert(SOCKBUF_MTX(_sb), MA_OWNED) #define SOCKBUF_UNLOCK_ASSERT(_sb) mtx_assert(SOCKBUF_MTX(_sb), MA_NOTOWNED) +/* + * Socket buffer private mbuf(9) flags. + */ +#define M_NOTREADY M_PROTO1 /* m_data not populated yet */ +#define M_BLOCKED M_PROTO2 /* M_NOTREADY in front of m */ +#define M_NOTAVAIL (M_NOTREADY | M_BLOCKED) + void sbappend(struct sockbuf *sb, struct mbuf *m); void sbappend_locked(struct sockbuf *sb, struct mbuf *m); void sbappendstream(struct sockbuf *sb, struct mbuf *m); @@ -165,10 +174,11 @@ int sblock(struct sockbuf *sb, int flags); void sbunlock(struct sockbuf *sb); void sballoc(struct sockbuf *, struct mbuf *); void sbfree(struct sockbuf *, struct mbuf *); +int sbready(struct sockbuf *, struct mbuf *, int); /* * Return how much data is available to be taken out of socket - * bufffer right now. + * buffer right now. */ static inline u_int sbavail(struct sockbuf *sb) @@ -177,7 +187,7 @@ sbavail(struct sockbuf *sb) #if 0 SOCKBUF_LOCK_ASSERT(sb); #endif - return (sb->sb_cc); + return (sb->sb_acc); } /* @@ -191,27 +201,30 @@ sbused(struct sockbuf *sb) #if 0 SOCKBUF_LOCK_ASSERT(sb); #endif - return (sb->sb_cc); + return (sb->sb_ccc); } /* * How much space is there in a socket buffer (so->so_snd or so->so_rcv)? * This is problematical if the fields are unsigned, as the space might - * still be negative (cc > hiwat or mbcnt > mbmax). Should detect - * overflow and return 0. Should use "lmin" but it doesn't exist now. + * still be negative (ccc > hiwat or mbcnt > mbmax). */ -static __inline -long +static inline long sbspace(struct sockbuf *sb) { - long bleft; - long mleft; + long bleft, mleft; + +#if 0 + SOCKBUF_LOCK_ASSERT(sb); +#endif if (sb->sb_flags & SB_STOP) return(0); - bleft = sb->sb_hiwat - sb->sb_cc; + + bleft = sb->sb_hiwat - sb->sb_ccc; mleft = sb->sb_mbmax - sb->sb_mbcnt; - return((bleft < mleft) ? bleft : mleft); + + return ((bleft < mleft) ? bleft : mleft); } #define SB_EMPTY_FIXUP(sb) do { \ diff --git a/usr.bin/bluetooth/btsockstat/btsockstat.c b/usr.bin/bluetooth/btsockstat/btsockstat.c index f63ee1fe5f7a..20f4de8076c8 100644 --- a/usr.bin/bluetooth/btsockstat/btsockstat.c +++ b/usr.bin/bluetooth/btsockstat/btsockstat.c @@ -255,8 +255,8 @@ hcirawpr(kvm_t *kvmd, u_long addr) (unsigned long) pcb.so, (unsigned long) this, pcb.flags, - so.so_rcv.sb_cc, - so.so_snd.sb_cc, + so.so_rcv.sb_ccc, + so.so_snd.sb_ccc, pcb.addr.hci_node); } } /* hcirawpr */ @@ -303,8 +303,8 @@ l2caprawpr(kvm_t *kvmd, u_long addr) "%-8lx %-8lx %6d %6d %-17.17s\n", (unsigned long) pcb.so, (unsigned long) this, - so.so_rcv.sb_cc, - so.so_snd.sb_cc, + so.so_rcv.sb_ccc, + so.so_snd.sb_ccc, bdaddrpr(&pcb.src, NULL, 0)); } } /* l2caprawpr */ @@ -361,8 +361,8 @@ l2cappr(kvm_t *kvmd, u_long addr) fprintf(stdout, "%-8lx %6d %6d %-17.17s/%-5d %-17.17s %-5d %s\n", (unsigned long) this, - so.so_rcv.sb_cc, - so.so_snd.sb_cc, + so.so_rcv.sb_ccc, + so.so_snd.sb_ccc, bdaddrpr(&pcb.src, local, sizeof(local)), pcb.psm, bdaddrpr(&pcb.dst, remote, sizeof(remote)), @@ -467,8 +467,8 @@ rfcommpr(kvm_t *kvmd, u_long addr) fprintf(stdout, "%-8lx %6d %6d %-17.17s %-17.17s %-4d %-4d %s\n", (unsigned long) this, - so.so_rcv.sb_cc, - so.so_snd.sb_cc, + so.so_rcv.sb_ccc, + so.so_snd.sb_ccc, bdaddrpr(&pcb.src, local, sizeof(local)), bdaddrpr(&pcb.dst, remote, sizeof(remote)), pcb.channel, diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index 10d0698e6beb..c22e49f62405 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -137,7 +137,7 @@ pcblist_sysctl(int proto, const char *name, char **bufp, int istcp __unused) static void sbtoxsockbuf(struct sockbuf *sb, struct xsockbuf *xsb) { - xsb->sb_cc = sb->sb_cc; + xsb->sb_cc = sb->sb_ccc; xsb->sb_hiwat = sb->sb_hiwat; xsb->sb_mbcnt = sb->sb_mbcnt; xsb->sb_mcnt = sb->sb_mcnt; @@ -479,7 +479,8 @@ protopr(u_long off, const char *name, int af1, int proto) printf("%6u %6u %6u ", tp->t_sndrexmitpack, tp->t_rcvoopack, tp->t_sndzerowin); } else { - printf("%6u %6u ", so->so_rcv.sb_cc, so->so_snd.sb_cc); + printf("%6u %6u ", + so->so_rcv.sb_cc, so->so_snd.sb_cc); } if (numeric_port) { if (inp->inp_vflag & INP_IPV4) { diff --git a/usr.bin/netstat/netgraph.c b/usr.bin/netstat/netgraph.c index 95578af739fa..9a08b6d282c8 100644 --- a/usr.bin/netstat/netgraph.c +++ b/usr.bin/netstat/netgraph.c @@ -119,7 +119,7 @@ netgraphprotopr(u_long off, const char *name, int af1 __unused, if (Aflag) printf("%8lx ", (u_long) this); printf("%-5.5s %6u %6u ", - name, sockb.so_rcv.sb_cc, sockb.so_snd.sb_cc); + name, sockb.so_rcv.sb_ccc, sockb.so_snd.sb_ccc); /* Get info on associated node */ if (ngpcb.node_id == 0 || csock == -1) diff --git a/usr.bin/netstat/unix.c b/usr.bin/netstat/unix.c index 027e812cf7cd..a5cc037840be 100644 --- a/usr.bin/netstat/unix.c +++ b/usr.bin/netstat/unix.c @@ -287,7 +287,8 @@ unixdomainpr(struct xunpcb *xunp, struct xsocket *so) } else { printf("%8lx %-6.6s %6u %6u %8lx %8lx %8lx %8lx", (long)so->so_pcb, socktype[so->so_type], so->so_rcv.sb_cc, - so->so_snd.sb_cc, (long)unp->unp_vnode, (long)unp->unp_conn, + so->so_snd.sb_cc, (long)unp->unp_vnode, + (long)unp->unp_conn, (long)LIST_FIRST(&unp->unp_refs), (long)LIST_NEXT(unp, unp_reflink)); } diff --git a/usr.bin/systat/netstat.c b/usr.bin/systat/netstat.c index bb1318da37c8..b5938eb9d911 100644 --- a/usr.bin/systat/netstat.c +++ b/usr.bin/systat/netstat.c @@ -333,8 +333,8 @@ enter_kvm(struct inpcb *inp, struct socket *so, int state, const char *proto) struct netinfo *p; if ((p = enter(inp, state, proto)) != NULL) { - p->ni_rcvcc = so->so_rcv.sb_cc; - p->ni_sndcc = so->so_snd.sb_cc; + p->ni_rcvcc = so->so_rcv.sb_ccc; + p->ni_sndcc = so->so_snd.sb_ccc; } } From dcf58f92e2c19a32fc171f763698e711c719badc Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Sun, 30 Nov 2014 13:13:46 +0000 Subject: [PATCH 02/94] Add missing libraries when linking. MFC after: 3 days Sponsored by: Mellanox Technologies --- contrib/ofed/librdmacm/examples/build/cmatose/Makefile | 1 + contrib/ofed/librdmacm/examples/build/mckey/Makefile | 1 + contrib/ofed/librdmacm/examples/build/rping/Makefile | 1 + contrib/ofed/librdmacm/examples/build/udaddy/Makefile | 1 + 4 files changed, 4 insertions(+) diff --git a/contrib/ofed/librdmacm/examples/build/cmatose/Makefile b/contrib/ofed/librdmacm/examples/build/cmatose/Makefile index c4515ac33ebc..31d2ae7f7f6b 100644 --- a/contrib/ofed/librdmacm/examples/build/cmatose/Makefile +++ b/contrib/ofed/librdmacm/examples/build/cmatose/Makefile @@ -6,5 +6,6 @@ PROG= cmatose MAN= SRCS= cmatose.c LDADD+= -libverbs -lrdmacm -lpthread +LDADD+= -lmlx4 .include diff --git a/contrib/ofed/librdmacm/examples/build/mckey/Makefile b/contrib/ofed/librdmacm/examples/build/mckey/Makefile index d4ad2954d52b..4abaf2786d56 100644 --- a/contrib/ofed/librdmacm/examples/build/mckey/Makefile +++ b/contrib/ofed/librdmacm/examples/build/mckey/Makefile @@ -6,5 +6,6 @@ PROG= mckey MAN= SRCS= mckey.c LDADD+= -libverbs -lrdmacm -lpthread +LDADD+= -lmlx4 .include diff --git a/contrib/ofed/librdmacm/examples/build/rping/Makefile b/contrib/ofed/librdmacm/examples/build/rping/Makefile index 05ef562400e9..b167a543c092 100644 --- a/contrib/ofed/librdmacm/examples/build/rping/Makefile +++ b/contrib/ofed/librdmacm/examples/build/rping/Makefile @@ -6,5 +6,6 @@ PROG= rping MAN= SRCS= rping.c LDADD+= -libverbs -lrdmacm -lpthread +LDADD+= -lmlx4 .include diff --git a/contrib/ofed/librdmacm/examples/build/udaddy/Makefile b/contrib/ofed/librdmacm/examples/build/udaddy/Makefile index 16d941974b65..1e325505bc86 100644 --- a/contrib/ofed/librdmacm/examples/build/udaddy/Makefile +++ b/contrib/ofed/librdmacm/examples/build/udaddy/Makefile @@ -6,5 +6,6 @@ PROG= udaddy MAN= SRCS= udaddy.c LDADD+= -libverbs -lrdmacm -lpthread +LDADD+= -lmlx4 .include From 651e4e6a307776b3f5201639e10c4b4d0949dcb0 Mon Sep 17 00:00:00 2001 From: Gleb Smirnoff Date: Sun, 30 Nov 2014 13:24:21 +0000 Subject: [PATCH 03/94] Merge from projects/sendfile: extend protocols API to support sending not ready data: o Add new flag to pru_send() flags - PRUS_NOTREADY. o Add new protocol method pru_ready(). Sponsored by: Nginx, Inc. Sponsored by: Netflix --- sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c | 2 +- sys/dev/cxgbe/tom/t4_cpl_io.c | 4 ++-- sys/dev/cxgbe/tom/t4_ddp.c | 4 ++-- sys/kern/uipc_domain.c | 1 + sys/kern/uipc_mbuf.c | 6 +++--- sys/kern/uipc_sockbuf.c | 10 +++++----- sys/kern/uipc_socket.c | 7 +++++++ sys/netinet/tcp_input.c | 4 ++-- sys/netinet/tcp_reass.c | 2 +- sys/netinet/tcp_usrreq.c | 4 ++-- sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c | 2 +- sys/sys/mbuf.h | 2 +- sys/sys/protosw.h | 3 +++ sys/sys/sockbuf.h | 4 ++-- 14 files changed, 33 insertions(+), 22 deletions(-) diff --git a/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c b/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c index 81a446a64a4f..a4b67088db93 100644 --- a/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c +++ b/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c @@ -1199,7 +1199,7 @@ do_rx_data(struct sge_qset *qs, struct rsp_desc *r, struct mbuf *m) } toep->tp_enqueued += m->m_pkthdr.len; - sbappendstream_locked(so_rcv, m); + sbappendstream_locked(so_rcv, m, 0); sorwakeup_locked(so); SOCKBUF_UNLOCK_ASSERT(so_rcv); diff --git a/sys/dev/cxgbe/tom/t4_cpl_io.c b/sys/dev/cxgbe/tom/t4_cpl_io.c index 29e5fa243be5..5dc843428448 100644 --- a/sys/dev/cxgbe/tom/t4_cpl_io.c +++ b/sys/dev/cxgbe/tom/t4_cpl_io.c @@ -1086,7 +1086,7 @@ do_peer_close(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m) #ifdef USE_DDP_RX_FLOW_CONTROL toep->rx_credits -= m->m_len; /* adjust for F_RX_FC_DDP */ #endif - sbappendstream_locked(sb, m); + sbappendstream_locked(sb, m, 0); toep->sb_cc = sbused(sb); } socantrcvmore_locked(so); /* unlocks the sockbuf */ @@ -1586,7 +1586,7 @@ do_rx_data(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m) ("%s: sb %p has more data (%d) than last time (%d).", __func__, sb, sbused(sb), toep->sb_cc)); toep->rx_credits += toep->sb_cc - sbused(sb); - sbappendstream_locked(sb, m); + sbappendstream_locked(sb, m, 0); toep->sb_cc = sbused(sb); sorwakeup_locked(so); SOCKBUF_UNLOCK_ASSERT(sb); diff --git a/sys/dev/cxgbe/tom/t4_ddp.c b/sys/dev/cxgbe/tom/t4_ddp.c index bf0889963306..17eb071b3cb7 100644 --- a/sys/dev/cxgbe/tom/t4_ddp.c +++ b/sys/dev/cxgbe/tom/t4_ddp.c @@ -231,7 +231,7 @@ insert_ddp_data(struct toepcb *toep, uint32_t n) #ifdef USE_DDP_RX_FLOW_CONTROL toep->rx_credits -= n; /* adjust for F_RX_FC_DDP */ #endif - sbappendstream_locked(sb, m); + sbappendstream_locked(sb, m, 0); toep->sb_cc = sbused(sb); } @@ -466,7 +466,7 @@ handle_ddp_data(struct toepcb *toep, __be32 ddp_report, __be32 rcv_nxt, int len) #ifdef USE_DDP_RX_FLOW_CONTROL toep->rx_credits -= len; /* adjust for F_RX_FC_DDP */ #endif - sbappendstream_locked(sb, m); + sbappendstream_locked(sb, m, 0); toep->sb_cc = sbused(sb); wakeup: KASSERT(toep->ddp_flags & db_flag, diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c index 709cc0eb0569..9eda77c0f2d8 100644 --- a/sys/kern/uipc_domain.c +++ b/sys/kern/uipc_domain.c @@ -152,6 +152,7 @@ protosw_init(struct protosw *pr) DEFAULT(pu->pru_sosend, sosend_generic); DEFAULT(pu->pru_soreceive, soreceive_generic); DEFAULT(pu->pru_sopoll, sopoll_generic); + DEFAULT(pu->pru_ready, pru_ready_notsupp); #undef DEFAULT if (pr->pr_init) (*pr->pr_init)(); diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index 323426898d09..3880456bddf7 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -388,7 +388,7 @@ mb_dupcl(struct mbuf *n, struct mbuf *m) * cleaned too. */ void -m_demote(struct mbuf *m0, int all) +m_demote(struct mbuf *m0, int all, int flags) { struct mbuf *m; @@ -400,7 +400,7 @@ m_demote(struct mbuf *m0, int all) m->m_flags &= ~M_PKTHDR; bzero(&m->m_pkthdr, sizeof(struct pkthdr)); } - m->m_flags = m->m_flags & (M_EXT|M_RDONLY|M_NOFREE); + m->m_flags = m->m_flags & (M_EXT | M_RDONLY | M_NOFREE | flags); } } @@ -997,7 +997,7 @@ m_catpkt(struct mbuf *m, struct mbuf *n) M_ASSERTPKTHDR(n); m->m_pkthdr.len += n->m_pkthdr.len; - m_demote(n, 1); + m_demote(n, 1, 0); m_cat(m, n); } diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c index b5a5185d46ce..537f9c867bf8 100644 --- a/sys/kern/uipc_sockbuf.c +++ b/sys/kern/uipc_sockbuf.c @@ -636,7 +636,7 @@ sbappend(struct sockbuf *sb, struct mbuf *m) * that is, a stream protocol (such as TCP). */ void -sbappendstream_locked(struct sockbuf *sb, struct mbuf *m) +sbappendstream_locked(struct sockbuf *sb, struct mbuf *m, int flags) { SOCKBUF_LOCK_ASSERT(sb); @@ -646,8 +646,8 @@ sbappendstream_locked(struct sockbuf *sb, struct mbuf *m) SBLASTMBUFCHK(sb); /* Remove all packet headers and mbuf tags to get a pure data chain. */ - m_demote(m, 1); - + m_demote(m, 1, flags & PRUS_NOTREADY ? M_NOTREADY : 0); + sbcompress(sb, m, sb->sb_mbtail); sb->sb_lastrecord = sb->sb_mb; @@ -660,11 +660,11 @@ sbappendstream_locked(struct sockbuf *sb, struct mbuf *m) * that is, a stream protocol (such as TCP). */ void -sbappendstream(struct sockbuf *sb, struct mbuf *m) +sbappendstream(struct sockbuf *sb, struct mbuf *m, int flags) { SOCKBUF_LOCK(sb); - sbappendstream_locked(sb, m); + sbappendstream_locked(sb, m, flags); SOCKBUF_UNLOCK(sb); } diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 7433b0e2ad1c..b2091ea28417 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -3178,6 +3178,13 @@ pru_send_notsupp(struct socket *so, int flags, struct mbuf *m, return EOPNOTSUPP; } +int +pru_ready_notsupp(struct socket *so, struct mbuf *m, int count) +{ + + return (EOPNOTSUPP); +} + /* * This isn't really a ``null'' operation, but it's the default one and * doesn't do anything destructive. diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 468f14210565..005ccd05b3fa 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1855,7 +1855,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, newsize, so, NULL)) so->so_rcv.sb_flags &= ~SB_AUTOSIZE; m_adj(m, drop_hdrlen); /* delayed header drop */ - sbappendstream_locked(&so->so_rcv, m); + sbappendstream_locked(&so->so_rcv, m, 0); } /* NB: sorwakeup_locked() does an implicit unlock. */ sorwakeup_locked(so); @@ -2882,7 +2882,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, if (so->so_rcv.sb_state & SBS_CANTRCVMORE) m_freem(m); else - sbappendstream_locked(&so->so_rcv, m); + sbappendstream_locked(&so->so_rcv, m, 0); /* NB: sorwakeup_locked() does an implicit unlock. */ sorwakeup_locked(so); } else { diff --git a/sys/netinet/tcp_reass.c b/sys/netinet/tcp_reass.c index dffee00f9b18..17d9a79eb50d 100644 --- a/sys/netinet/tcp_reass.c +++ b/sys/netinet/tcp_reass.c @@ -262,7 +262,7 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, int *tlenp, struct mbuf *m) m_freem(mq); else { mq->m_nextpkt = NULL; - sbappendstream_locked(&so->so_rcv, mq); + sbappendstream_locked(&so->so_rcv, mq, 0); wakeup = 1; } } diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 965491a5ca33..8b4048c0a1da 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -843,7 +843,7 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, m_freem(control); /* empty control, just free it */ } if (!(flags & PRUS_OOB)) { - sbappendstream(&so->so_snd, m); + sbappendstream(&so->so_snd, m, flags); if (nam && tp->t_state < TCPS_SYN_SENT) { /* * Do implied connect if not yet connected, @@ -901,7 +901,7 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, * of data past the urgent section. * Otherwise, snd_up should be one lower. */ - sbappendstream_locked(&so->so_snd, m); + sbappendstream_locked(&so->so_snd, m, flags); SOCKBUF_UNLOCK(&so->so_snd); if (nam && tp->t_state < TCPS_SYN_SENT) { /* diff --git a/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c b/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c index a6eba64e1622..2e91d8529434 100644 --- a/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c +++ b/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c @@ -889,7 +889,7 @@ sdp_append(struct sdp_sock *ssk, struct sockbuf *sb, struct mbuf *mb, int cnt) m_adj(mb, SDP_HEAD_SIZE); n->m_pkthdr.len += mb->m_pkthdr.len; n->m_flags |= mb->m_flags & (M_PUSH | M_URG); - m_demote(mb, 1); + m_demote(mb, 1, 0); sbcompress(sb, mb, sb->sb_mbtail); return; } diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index 190900c43d22..ac3cfb2d0ced 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -950,7 +950,7 @@ struct mbuf *m_copypacket(struct mbuf *, int); void m_copy_pkthdr(struct mbuf *, struct mbuf *); struct mbuf *m_copyup(struct mbuf *, int, int); struct mbuf *m_defrag(struct mbuf *, int); -void m_demote(struct mbuf *, int); +void m_demote(struct mbuf *, int, int); struct mbuf *m_devget(char *, int, int, struct ifnet *, void (*)(char *, caddr_t, u_int)); struct mbuf *m_dup(struct mbuf *, int); diff --git a/sys/sys/protosw.h b/sys/sys/protosw.h index 2d98a4c25edd..55db0e339699 100644 --- a/sys/sys/protosw.h +++ b/sys/sys/protosw.h @@ -208,6 +208,8 @@ struct pr_usrreqs { #define PRUS_OOB 0x1 #define PRUS_EOF 0x2 #define PRUS_MORETOCOME 0x4 +#define PRUS_NOTREADY 0x8 + int (*pru_ready)(struct socket *so, struct mbuf *m, int count); int (*pru_sense)(struct socket *so, struct stat *sb); int (*pru_shutdown)(struct socket *so); int (*pru_flush)(struct socket *so, int direction); @@ -251,6 +253,7 @@ int pru_rcvd_notsupp(struct socket *so, int flags); int pru_rcvoob_notsupp(struct socket *so, struct mbuf *m, int flags); int pru_send_notsupp(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, struct mbuf *control, struct thread *td); +int pru_ready_notsupp(struct socket *so, struct mbuf *m, int count); int pru_sense_null(struct socket *so, struct stat *sb); int pru_shutdown_notsupp(struct socket *so); int pru_sockaddr_notsupp(struct socket *so, struct sockaddr **nam); diff --git a/sys/sys/sockbuf.h b/sys/sys/sockbuf.h index ec16b2593dd2..5bd9bb556251 100644 --- a/sys/sys/sockbuf.h +++ b/sys/sys/sockbuf.h @@ -131,8 +131,8 @@ struct sockbuf { void sbappend(struct sockbuf *sb, struct mbuf *m); void sbappend_locked(struct sockbuf *sb, struct mbuf *m); -void sbappendstream(struct sockbuf *sb, struct mbuf *m); -void sbappendstream_locked(struct sockbuf *sb, struct mbuf *m); +void sbappendstream(struct sockbuf *sb, struct mbuf *m, int flags); +void sbappendstream_locked(struct sockbuf *sb, struct mbuf *m, int flags); int sbappendaddr(struct sockbuf *sb, const struct sockaddr *asa, struct mbuf *m0, struct mbuf *control); int sbappendaddr_locked(struct sockbuf *sb, const struct sockaddr *asa, From 78328f86e2b2341271b697e3f0604d4836499910 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Sun, 30 Nov 2014 13:27:58 +0000 Subject: [PATCH 04/94] Fix building of some infiniband utilities by updating some header file locations and compiler include directives. MFC after: 3 days Sponsored by: Mellanox Technologies --- .../management/infiniband-diags/src/ibnetdiscover.c | 2 +- .../ofed/management/infiniband-diags/src/ibroute.c | 2 +- .../management/infiniband-diags/src/ibsendtrap.c | 2 +- .../ofed/management/infiniband-diags/src/ibtracert.c | 2 +- .../ofed/management/infiniband-diags/src/saquery.c | 12 ++++++------ .../ofed/management/infiniband-diags/src/smpquery.c | 2 +- contrib/ofed/usr.bin/Makefile.inc | 5 +++++ 7 files changed, 16 insertions(+), 11 deletions(-) diff --git a/contrib/ofed/management/infiniband-diags/src/ibnetdiscover.c b/contrib/ofed/management/infiniband-diags/src/ibnetdiscover.c index 2cfaa8ae55ef..5e092f7b0877 100644 --- a/contrib/ofed/management/infiniband-diags/src/ibnetdiscover.c +++ b/contrib/ofed/management/infiniband-diags/src/ibnetdiscover.c @@ -50,7 +50,7 @@ #include #include #include -#include +#include #include "ibnetdiscover.h" #include "grouping.h" diff --git a/contrib/ofed/management/infiniband-diags/src/ibroute.c b/contrib/ofed/management/infiniband-diags/src/ibroute.c index f2ee170cedc0..9607aa9999a5 100644 --- a/contrib/ofed/management/infiniband-diags/src/ibroute.c +++ b/contrib/ofed/management/infiniband-diags/src/ibroute.c @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include "ibdiag_common.h" diff --git a/contrib/ofed/management/infiniband-diags/src/ibsendtrap.c b/contrib/ofed/management/infiniband-diags/src/ibsendtrap.c index 66620de62e2b..2754dc008dea 100644 --- a/contrib/ofed/management/infiniband-diags/src/ibsendtrap.c +++ b/contrib/ofed/management/infiniband-diags/src/ibsendtrap.c @@ -43,7 +43,7 @@ #include #include -#include +#include #include "ibdiag_common.h" diff --git a/contrib/ofed/management/infiniband-diags/src/ibtracert.c b/contrib/ofed/management/infiniband-diags/src/ibtracert.c index bde0ea795326..f8ecf76483cc 100644 --- a/contrib/ofed/management/infiniband-diags/src/ibtracert.c +++ b/contrib/ofed/management/infiniband-diags/src/ibtracert.c @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include "ibdiag_common.h" diff --git a/contrib/ofed/management/infiniband-diags/src/saquery.c b/contrib/ofed/management/infiniband-diags/src/saquery.c index 97663d1d538f..9f882e73a401 100644 --- a/contrib/ofed/management/infiniband-diags/src/saquery.c +++ b/contrib/ofed/management/infiniband-diags/src/saquery.c @@ -50,12 +50,12 @@ #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include diff --git a/contrib/ofed/management/infiniband-diags/src/smpquery.c b/contrib/ofed/management/infiniband-diags/src/smpquery.c index ed8ec83c9a06..01ccfaf16412 100644 --- a/contrib/ofed/management/infiniband-diags/src/smpquery.c +++ b/contrib/ofed/management/infiniband-diags/src/smpquery.c @@ -50,7 +50,7 @@ #include #include #include -#include +#include #include "ibdiag_common.h" diff --git a/contrib/ofed/usr.bin/Makefile.inc b/contrib/ofed/usr.bin/Makefile.inc index e6a0550b82d3..d05778c68d37 100644 --- a/contrib/ofed/usr.bin/Makefile.inc +++ b/contrib/ofed/usr.bin/Makefile.inc @@ -1,4 +1,9 @@ DIAGPATH= ${.CURDIR}/../../management/infiniband-diags BINDIR?= /usr/bin CFLAGS+= -I${.CURDIR}/../../include/infiniband +CFLAGS+= -I${.CURDIR}/../../include CFLAGS+= -I${.CURDIR}/../../management/opensm/include/ +CFLAGS+= -I${.CURDIR}/../../management/opensm +CFLAGS+= -I${.CURDIR}/../../management/libibcommon/include +CFLAGS+= -I${.CURDIR}/../../management/libibumad/include +CFLAGS+= -I${.CURDIR}/../../management/libibmad/include From c80ea19b38efad3880bbf97a4345cc9a77db301b Mon Sep 17 00:00:00 2001 From: Gleb Smirnoff Date: Sun, 30 Nov 2014 13:40:58 +0000 Subject: [PATCH 05/94] Merge from projects/sendfile: Provide pru_ready for AF_LOCAL sockets. Local sockets sendsdata directly to the receive buffer of the peer, thus pru_ready also works on the peer socket. Sponsored by: Netflix Sponsored by: Nginx, Inc. --- sys/kern/uipc_usrreq.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index 00fd8099c2e4..a540cc0dfa85 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -1047,6 +1047,32 @@ uipc_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, return (error); } +static int +uipc_ready(struct socket *so, struct mbuf *m, int count) +{ + struct unpcb *unp, *unp2; + struct socket *so2; + int error; + + unp = sotounpcb(so); + + UNP_LINK_RLOCK(); + unp2 = unp->unp_conn; + UNP_PCB_LOCK(unp2); + so2 = unp2->unp_socket; + + SOCKBUF_LOCK(&so2->so_rcv); + if ((error = sbready(&so2->so_rcv, m, count)) == 0) + sorwakeup_locked(so2); + else + SOCKBUF_UNLOCK(&so2->so_rcv); + + UNP_PCB_UNLOCK(unp2); + UNP_LINK_RUNLOCK(); + + return (error); +} + static int uipc_sense(struct socket *so, struct stat *sb) { @@ -1161,6 +1187,7 @@ static struct pr_usrreqs uipc_usrreqs_stream = { .pru_peeraddr = uipc_peeraddr, .pru_rcvd = uipc_rcvd, .pru_send = uipc_send, + .pru_ready = uipc_ready, .pru_sense = uipc_sense, .pru_shutdown = uipc_shutdown, .pru_sockaddr = uipc_sockaddr, From 2cbcd3c19841b6b025d9d9a27c09681bd83ae156 Mon Sep 17 00:00:00 2001 From: Gleb Smirnoff Date: Sun, 30 Nov 2014 13:43:52 +0000 Subject: [PATCH 06/94] Merge from projects/sendfile: - Provide pru_ready function for TCP. - Don't call tcp_output() from tcp_usr_send() if no ready data was put into the socket buffer. - In case of dropped connection don't try to m_freem() not ready data. Sponsored by: Nginx, Inc. Sponsored by: Netflix --- sys/netinet/tcp_usrreq.c | 46 +++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 8b4048c0a1da..dee1c33186ab 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -821,7 +821,11 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { if (control) m_freem(control); - if (m) + /* + * In case of PRUS_NOTREADY, tcp_usr_ready() is responsible + * for freeing memory. + */ + if (m && (flags & PRUS_NOTREADY) == 0) m_freem(m); error = ECONNRESET; goto out; @@ -875,7 +879,8 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, socantsendmore(so); tcp_usrclosed(tp); } - if (!(inp->inp_flags & INP_DROPPED)) { + if (!(inp->inp_flags & INP_DROPPED) && + !(flags & PRUS_NOTREADY)) { if (flags & PRUS_MORETOCOME) tp->t_flags |= TF_MORETOCOME; error = tcp_output(tp); @@ -926,9 +931,11 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, tcp_mss(tp, -1); } tp->snd_up = tp->snd_una + sbavail(&so->so_snd); - tp->t_flags |= TF_FORCEDATA; - error = tcp_output(tp); - tp->t_flags &= ~TF_FORCEDATA; + if (!(flags & PRUS_NOTREADY)) { + tp->t_flags |= TF_FORCEDATA; + error = tcp_output(tp); + tp->t_flags &= ~TF_FORCEDATA; + } } out: TCPDEBUG2((flags & PRUS_OOB) ? PRU_SENDOOB : @@ -939,6 +946,33 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, return (error); } +static int +tcp_usr_ready(struct socket *so, struct mbuf *m, int count) +{ + struct inpcb *inp; + struct tcpcb *tp; + int error; + + inp = sotoinpcb(so); + INP_WLOCK(inp); + if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + INP_WUNLOCK(inp); + for (int i = 0; i < count; i++) + m = m_free(m); + return (ECONNRESET); + } + tp = intotcpcb(inp); + + SOCKBUF_LOCK(&so->so_snd); + error = sbready(&so->so_snd, m, count); + SOCKBUF_UNLOCK(&so->so_snd); + if (error == 0) + error = tcp_output(tp); + INP_WUNLOCK(inp); + + return (error); +} + /* * Abort the TCP. Drop the connection abruptly. */ @@ -1073,6 +1107,7 @@ struct pr_usrreqs tcp_usrreqs = { .pru_rcvd = tcp_usr_rcvd, .pru_rcvoob = tcp_usr_rcvoob, .pru_send = tcp_usr_send, + .pru_ready = tcp_usr_ready, .pru_shutdown = tcp_usr_shutdown, .pru_sockaddr = in_getsockaddr, .pru_sosetlabel = in_pcbsosetlabel, @@ -1095,6 +1130,7 @@ struct pr_usrreqs tcp6_usrreqs = { .pru_rcvd = tcp_usr_rcvd, .pru_rcvoob = tcp_usr_rcvoob, .pru_send = tcp_usr_send, + .pru_ready = tcp_usr_ready, .pru_shutdown = tcp_usr_shutdown, .pru_sockaddr = in6_mapped_sockaddr, .pru_sosetlabel = in_pcbsosetlabel, From abec64bc76d27c017ba6db7fd6eb01acd78ac56a Mon Sep 17 00:00:00 2001 From: Bryan Venteicher Date: Sun, 30 Nov 2014 16:36:26 +0000 Subject: [PATCH 07/94] Cleanup and performance improvement of the virtio_blk driver - Add support for GEOM direct completion. Depending on the benchmark, this tends to give a ~30% improvement w.r.t IOPs and BW. - Remove an invariants check in the strategy routine. This assertion is caught later on by an existing panic. - Rename and resort various related functions to make more sense. MFC after: 1 month --- sys/dev/virtio/block/virtio_blk.c | 897 +++++++++++++++--------------- 1 file changed, 451 insertions(+), 446 deletions(-) diff --git a/sys/dev/virtio/block/virtio_blk.c b/sys/dev/virtio/block/virtio_blk.c index b15cb75a3f40..a65e23d37b4c 100644 --- a/sys/dev/virtio/block/virtio_blk.c +++ b/sys/dev/virtio/block/virtio_blk.c @@ -58,7 +58,6 @@ struct vtblk_request { struct virtio_blk_outhdr vbr_hdr; struct bio *vbr_bp; uint8_t vbr_ack; - TAILQ_ENTRY(vtblk_request) vbr_link; }; @@ -132,53 +131,60 @@ static int vtblk_dump(void *, void *, vm_offset_t, off_t, size_t); static void vtblk_strategy(struct bio *); static void vtblk_negotiate_features(struct vtblk_softc *); +static void vtblk_setup_features(struct vtblk_softc *); static int vtblk_maximum_segments(struct vtblk_softc *, struct virtio_blk_config *); static int vtblk_alloc_virtqueue(struct vtblk_softc *); static void vtblk_resize_disk(struct vtblk_softc *, uint64_t); -static void vtblk_set_write_cache(struct vtblk_softc *, int); -static int vtblk_write_cache_enabled(struct vtblk_softc *sc, - struct virtio_blk_config *); -static int vtblk_write_cache_sysctl(SYSCTL_HANDLER_ARGS); static void vtblk_alloc_disk(struct vtblk_softc *, struct virtio_blk_config *); static void vtblk_create_disk(struct vtblk_softc *); -static int vtblk_quiesce(struct vtblk_softc *); -static void vtblk_startio(struct vtblk_softc *); -static struct vtblk_request * vtblk_bio_request(struct vtblk_softc *); -static int vtblk_execute_request(struct vtblk_softc *, +static int vtblk_request_prealloc(struct vtblk_softc *); +static void vtblk_request_free(struct vtblk_softc *); +static struct vtblk_request * + vtblk_request_dequeue(struct vtblk_softc *); +static void vtblk_request_enqueue(struct vtblk_softc *, struct vtblk_request *); - -static void vtblk_vq_intr(void *); - -static void vtblk_stop(struct vtblk_softc *); - -static void vtblk_read_config(struct vtblk_softc *, - struct virtio_blk_config *); -static void vtblk_get_ident(struct vtblk_softc *); -static void vtblk_prepare_dump(struct vtblk_softc *); -static int vtblk_write_dump(struct vtblk_softc *, void *, off_t, size_t); -static int vtblk_flush_dump(struct vtblk_softc *); -static int vtblk_poll_request(struct vtblk_softc *, +static struct vtblk_request * + vtblk_request_next_ready(struct vtblk_softc *); +static void vtblk_request_requeue_ready(struct vtblk_softc *, struct vtblk_request *); +static struct vtblk_request * + vtblk_request_next(struct vtblk_softc *); +static struct vtblk_request * + vtblk_request_bio(struct vtblk_softc *); +static int vtblk_request_execute(struct vtblk_softc *, + struct vtblk_request *); +static int vtblk_request_error(struct vtblk_request *); -static void vtblk_finish_completed(struct vtblk_softc *); +static void vtblk_queue_completed(struct vtblk_softc *, + struct bio_queue *); +static void vtblk_done_completed(struct vtblk_softc *, + struct bio_queue *); static void vtblk_drain_vq(struct vtblk_softc *, int); static void vtblk_drain(struct vtblk_softc *); -static int vtblk_alloc_requests(struct vtblk_softc *); -static void vtblk_free_requests(struct vtblk_softc *); -static struct vtblk_request * vtblk_dequeue_request(struct vtblk_softc *); -static void vtblk_enqueue_request(struct vtblk_softc *, - struct vtblk_request *); +static void vtblk_startio(struct vtblk_softc *); +static void vtblk_bio_done(struct vtblk_softc *, struct bio *, int); -static struct vtblk_request * vtblk_dequeue_ready(struct vtblk_softc *); -static void vtblk_enqueue_ready(struct vtblk_softc *, +static void vtblk_read_config(struct vtblk_softc *, + struct virtio_blk_config *); +static void vtblk_ident(struct vtblk_softc *); +static int vtblk_poll_request(struct vtblk_softc *, struct vtblk_request *); +static int vtblk_quiesce(struct vtblk_softc *); +static void vtblk_vq_intr(void *); +static void vtblk_stop(struct vtblk_softc *); -static int vtblk_request_error(struct vtblk_request *); -static void vtblk_finish_bio(struct bio *, int); +static void vtblk_dump_prepare(struct vtblk_softc *); +static int vtblk_dump_write(struct vtblk_softc *, void *, off_t, size_t); +static int vtblk_dump_flush(struct vtblk_softc *); + +static void vtblk_set_write_cache(struct vtblk_softc *, int); +static int vtblk_write_cache_enabled(struct vtblk_softc *sc, + struct virtio_blk_config *); +static int vtblk_write_cache_sysctl(SYSCTL_HANDLER_ARGS); static void vtblk_setup_sysctl(struct vtblk_softc *); static int vtblk_tunable_int(struct vtblk_softc *, const char *, int); @@ -290,30 +296,18 @@ vtblk_attach(device_t dev) struct virtio_blk_config blkcfg; int error; + virtio_set_feature_desc(dev, vtblk_feature_desc); + sc = device_get_softc(dev); sc->vtblk_dev = dev; - VTBLK_LOCK_INIT(sc, device_get_nameunit(dev)); - bioq_init(&sc->vtblk_bioq); TAILQ_INIT(&sc->vtblk_req_free); TAILQ_INIT(&sc->vtblk_req_ready); - virtio_set_feature_desc(dev, vtblk_feature_desc); - vtblk_negotiate_features(sc); - - if (virtio_with_feature(dev, VIRTIO_RING_F_INDIRECT_DESC)) - sc->vtblk_flags |= VTBLK_FLAG_INDIRECT; - if (virtio_with_feature(dev, VIRTIO_BLK_F_RO)) - sc->vtblk_flags |= VTBLK_FLAG_READONLY; - if (virtio_with_feature(dev, VIRTIO_BLK_F_BARRIER)) - sc->vtblk_flags |= VTBLK_FLAG_BARRIER; - if (virtio_with_feature(dev, VIRTIO_BLK_F_CONFIG_WCE)) - sc->vtblk_flags |= VTBLK_FLAG_WC_CONFIG; - vtblk_setup_sysctl(sc); + vtblk_setup_features(sc); - /* Get local copy of config. */ vtblk_read_config(sc, &blkcfg); /* @@ -352,7 +346,7 @@ vtblk_attach(device_t dev) goto fail; } - error = vtblk_alloc_requests(sc); + error = vtblk_request_prealloc(sc); if (error) { device_printf(dev, "cannot preallocate requests\n"); goto fail; @@ -519,14 +513,14 @@ vtblk_dump(void *arg, void *virtual, vm_offset_t physical, off_t offset, VTBLK_LOCK(sc); if ((sc->vtblk_flags & VTBLK_FLAG_DUMPING) == 0) { - vtblk_prepare_dump(sc); + vtblk_dump_prepare(sc); sc->vtblk_flags |= VTBLK_FLAG_DUMPING; } if (length > 0) - error = vtblk_write_dump(sc, virtual, offset, length); + error = vtblk_dump_write(sc, virtual, offset, length); else if (virtual == NULL && offset == 0) - error = vtblk_flush_dump(sc); + error = vtblk_dump_flush(sc); else { error = EINVAL; sc->vtblk_flags &= ~VTBLK_FLAG_DUMPING; @@ -543,7 +537,7 @@ vtblk_strategy(struct bio *bp) struct vtblk_softc *sc; if ((sc = bp->bio_disk->d_drv1) == NULL) { - vtblk_finish_bio(bp, EINVAL); + vtblk_bio_done(NULL, bp, EINVAL); return; } @@ -553,37 +547,21 @@ vtblk_strategy(struct bio *bp) */ if (sc->vtblk_flags & VTBLK_FLAG_READONLY && (bp->bio_cmd == BIO_WRITE || bp->bio_cmd == BIO_FLUSH)) { - vtblk_finish_bio(bp, EROFS); + vtblk_bio_done(sc, bp, EROFS); return; } -#ifdef INVARIANTS - /* - * Prevent read/write buffers spanning too many segments from - * getting into the queue. This should only trip if d_maxsize - * was incorrectly set. - */ - if (bp->bio_cmd == BIO_READ || bp->bio_cmd == BIO_WRITE) { - int nsegs, max_nsegs; - - nsegs = sglist_count(bp->bio_data, bp->bio_bcount); - max_nsegs = sc->vtblk_max_nsegs - VTBLK_MIN_SEGMENTS; - - KASSERT(nsegs <= max_nsegs, - ("%s: bio %p spanned too many segments: %d, max: %d", - __func__, bp, nsegs, max_nsegs)); - } -#endif - VTBLK_LOCK(sc); - if (sc->vtblk_flags & VTBLK_FLAG_DETACH) - vtblk_finish_bio(bp, ENXIO); - else { - bioq_insert_tail(&sc->vtblk_bioq, bp); - if ((sc->vtblk_flags & VTBLK_FLAG_SUSPEND) == 0) - vtblk_startio(sc); + if (sc->vtblk_flags & VTBLK_FLAG_DETACH) { + VTBLK_UNLOCK(sc); + vtblk_bio_done(sc, bp, ENXIO); + return; } + + bioq_insert_tail(&sc->vtblk_bioq, bp); + vtblk_startio(sc); + VTBLK_UNLOCK(sc); } @@ -599,6 +577,25 @@ vtblk_negotiate_features(struct vtblk_softc *sc) sc->vtblk_features = virtio_negotiate_features(dev, features); } +static void +vtblk_setup_features(struct vtblk_softc *sc) +{ + device_t dev; + + dev = sc->vtblk_dev; + + vtblk_negotiate_features(sc); + + if (virtio_with_feature(dev, VIRTIO_RING_F_INDIRECT_DESC)) + sc->vtblk_flags |= VTBLK_FLAG_INDIRECT; + if (virtio_with_feature(dev, VIRTIO_BLK_F_RO)) + sc->vtblk_flags |= VTBLK_FLAG_READONLY; + if (virtio_with_feature(dev, VIRTIO_BLK_F_BARRIER)) + sc->vtblk_flags |= VTBLK_FLAG_BARRIER; + if (virtio_with_feature(dev, VIRTIO_BLK_F_CONFIG_WCE)) + sc->vtblk_flags |= VTBLK_FLAG_WC_CONFIG; +} + static int vtblk_maximum_segments(struct vtblk_softc *sc, struct virtio_blk_config *blkcfg) @@ -659,59 +656,6 @@ vtblk_resize_disk(struct vtblk_softc *sc, uint64_t new_capacity) } } -static void -vtblk_set_write_cache(struct vtblk_softc *sc, int wc) -{ - - /* Set either writeback (1) or writethrough (0) mode. */ - virtio_write_dev_config_1(sc->vtblk_dev, - offsetof(struct virtio_blk_config, writeback), wc); -} - -static int -vtblk_write_cache_enabled(struct vtblk_softc *sc, - struct virtio_blk_config *blkcfg) -{ - int wc; - - if (sc->vtblk_flags & VTBLK_FLAG_WC_CONFIG) { - wc = vtblk_tunable_int(sc, "writecache_mode", - vtblk_writecache_mode); - if (wc >= 0 && wc < VTBLK_CACHE_MAX) - vtblk_set_write_cache(sc, wc); - else - wc = blkcfg->writeback; - } else - wc = virtio_with_feature(sc->vtblk_dev, VIRTIO_BLK_F_WCE); - - return (wc); -} - -static int -vtblk_write_cache_sysctl(SYSCTL_HANDLER_ARGS) -{ - struct vtblk_softc *sc; - int wc, error; - - sc = oidp->oid_arg1; - wc = sc->vtblk_write_cache; - - error = sysctl_handle_int(oidp, &wc, 0, req); - if (error || req->newptr == NULL) - return (error); - if ((sc->vtblk_flags & VTBLK_FLAG_WC_CONFIG) == 0) - return (EPERM); - if (wc < 0 || wc >= VTBLK_CACHE_MAX) - return (EINVAL); - - VTBLK_LOCK(sc); - sc->vtblk_write_cache = wc; - vtblk_set_write_cache(sc, sc->vtblk_write_cache); - VTBLK_UNLOCK(sc); - - return (0); -} - static void vtblk_alloc_disk(struct vtblk_softc *sc, struct virtio_blk_config *blkcfg) { @@ -728,7 +672,8 @@ vtblk_alloc_disk(struct vtblk_softc *sc, struct virtio_blk_config *blkcfg) dp->d_name = VTBLK_DISK_NAME; dp->d_unit = device_get_unit(dev); dp->d_drv1 = sc; - dp->d_flags = DISKFLAG_CANFLUSHCACHE | DISKFLAG_UNMAPPED_BIO; + dp->d_flags = DISKFLAG_CANFLUSHCACHE | DISKFLAG_UNMAPPED_BIO | + DISKFLAG_DIRECT_COMPLETION; dp->d_hba_vendor = virtio_get_vendor(dev); dp->d_hba_device = virtio_get_device(dev); dp->d_hba_subvendor = virtio_get_subvendor(dev); @@ -789,11 +734,7 @@ vtblk_create_disk(struct vtblk_softc *sc) dp = sc->vtblk_disk; - /* - * Retrieving the identification string must be done after - * the virtqueue interrupt is setup otherwise it will hang. - */ - vtblk_get_ident(sc); + vtblk_ident(sc); device_printf(sc->vtblk_dev, "%juMB (%ju %u byte sectors)\n", (uintmax_t) dp->d_mediasize >> 20, @@ -804,57 +745,107 @@ vtblk_create_disk(struct vtblk_softc *sc) } static int -vtblk_quiesce(struct vtblk_softc *sc) +vtblk_request_prealloc(struct vtblk_softc *sc) { - int error; + struct vtblk_request *req; + int i, nreqs; - error = 0; + nreqs = virtqueue_size(sc->vtblk_vq); - VTBLK_LOCK_ASSERT(sc); + /* + * Preallocate sufficient requests to keep the virtqueue full. Each + * request consumes VTBLK_MIN_SEGMENTS or more descriptors so reduce + * the number allocated when indirect descriptors are not available. + */ + if ((sc->vtblk_flags & VTBLK_FLAG_INDIRECT) == 0) + nreqs /= VTBLK_MIN_SEGMENTS; - while (!virtqueue_empty(sc->vtblk_vq)) { - if (mtx_sleep(&sc->vtblk_vq, VTBLK_MTX(sc), PRIBIO, "vtblkq", - VTBLK_QUIESCE_TIMEOUT) == EWOULDBLOCK) { - error = EBUSY; - break; - } + for (i = 0; i < nreqs; i++) { + req = malloc(sizeof(struct vtblk_request), M_DEVBUF, M_NOWAIT); + if (req == NULL) + return (ENOMEM); + + MPASS(sglist_count(&req->vbr_hdr, sizeof(req->vbr_hdr)) == 1); + MPASS(sglist_count(&req->vbr_ack, sizeof(req->vbr_ack)) == 1); + + sc->vtblk_request_count++; + vtblk_request_enqueue(sc, req); } - return (error); + return (0); } static void -vtblk_startio(struct vtblk_softc *sc) +vtblk_request_free(struct vtblk_softc *sc) { - struct virtqueue *vq; struct vtblk_request *req; - int enq; - vq = sc->vtblk_vq; - enq = 0; + MPASS(TAILQ_EMPTY(&sc->vtblk_req_ready)); - VTBLK_LOCK_ASSERT(sc); - - while (!virtqueue_full(vq)) { - if ((req = vtblk_dequeue_ready(sc)) == NULL) - req = vtblk_bio_request(sc); - if (req == NULL) - break; - - if (vtblk_execute_request(sc, req) != 0) { - vtblk_enqueue_ready(sc, req); - break; - } - - enq++; + while ((req = vtblk_request_dequeue(sc)) != NULL) { + sc->vtblk_request_count--; + free(req, M_DEVBUF); } - if (enq > 0) - virtqueue_notify(vq); + KASSERT(sc->vtblk_request_count == 0, + ("%s: leaked %d requests", __func__, sc->vtblk_request_count)); } static struct vtblk_request * -vtblk_bio_request(struct vtblk_softc *sc) +vtblk_request_dequeue(struct vtblk_softc *sc) +{ + struct vtblk_request *req; + + req = TAILQ_FIRST(&sc->vtblk_req_free); + if (req != NULL) { + TAILQ_REMOVE(&sc->vtblk_req_free, req, vbr_link); + bzero(req, sizeof(struct vtblk_request)); + } + + return (req); +} + +static void +vtblk_request_enqueue(struct vtblk_softc *sc, struct vtblk_request *req) +{ + + TAILQ_INSERT_HEAD(&sc->vtblk_req_free, req, vbr_link); +} + +static struct vtblk_request * +vtblk_request_next_ready(struct vtblk_softc *sc) +{ + struct vtblk_request *req; + + req = TAILQ_FIRST(&sc->vtblk_req_ready); + if (req != NULL) + TAILQ_REMOVE(&sc->vtblk_req_ready, req, vbr_link); + + return (req); +} + +static void +vtblk_request_requeue_ready(struct vtblk_softc *sc, struct vtblk_request *req) +{ + + /* NOTE: Currently, there will be at most one request in the queue. */ + TAILQ_INSERT_HEAD(&sc->vtblk_req_ready, req, vbr_link); +} + +static struct vtblk_request * +vtblk_request_next(struct vtblk_softc *sc) +{ + struct vtblk_request *req; + + req = vtblk_request_next_ready(sc); + if (req != NULL) + return (req); + + return (vtblk_request_bio(sc)); +} + +static struct vtblk_request * +vtblk_request_bio(struct vtblk_softc *sc) { struct bio_queue_head *bioq; struct vtblk_request *req; @@ -865,7 +856,7 @@ vtblk_bio_request(struct vtblk_softc *sc) if (bioq_first(bioq) == NULL) return (NULL); - req = vtblk_dequeue_request(sc); + req = vtblk_request_dequeue(sc); if (req == NULL) return (NULL); @@ -890,11 +881,14 @@ vtblk_bio_request(struct vtblk_softc *sc) panic("%s: bio with unhandled cmd: %d", __func__, bp->bio_cmd); } + if (bp->bio_flags & BIO_ORDERED) + req->vbr_hdr.type |= VIRTIO_BLK_T_BARRIER; + return (req); } static int -vtblk_execute_request(struct vtblk_softc *sc, struct vtblk_request *req) +vtblk_request_execute(struct vtblk_softc *sc, struct vtblk_request *req) { struct virtqueue *vq; struct sglist *sg; @@ -907,26 +901,20 @@ vtblk_execute_request(struct vtblk_softc *sc, struct vtblk_request *req) ordered = 0; writable = 0; - VTBLK_LOCK_ASSERT(sc); - /* - * Wait until the ordered request completes before - * executing subsequent requests. + * Some hosts (such as bhyve) do not implement the barrier feature, + * so we emulate it in the driver by allowing the barrier request + * to be the only one in flight. */ - if (sc->vtblk_req_ordered != NULL) - return (EBUSY); - - if (bp->bio_flags & BIO_ORDERED) { - if ((sc->vtblk_flags & VTBLK_FLAG_BARRIER) == 0) { - /* - * This request will be executed once all - * the in-flight requests are completed. - */ + if ((sc->vtblk_flags & VTBLK_FLAG_BARRIER) == 0) { + if (sc->vtblk_req_ordered != NULL) + return (EBUSY); + if (bp->bio_flags & BIO_ORDERED) { if (!virtqueue_empty(vq)) return (EBUSY); ordered = 1; - } else - req->vbr_hdr.type |= VIRTIO_BLK_T_BARRIER; + req->vbr_hdr.type &= ~VIRTIO_BLK_T_BARRIER; + } } sglist_reset(sg); @@ -935,7 +923,7 @@ vtblk_execute_request(struct vtblk_softc *sc, struct vtblk_request *req) if (bp->bio_cmd == BIO_READ || bp->bio_cmd == BIO_WRITE) { error = sglist_append_bio(sg, bp); if (error || sg->sg_nseg == sg->sg_maxseg) { - panic("%s: data buffer too big bio:%p error:%d", + panic("%s: bio %p data buffer too big %d", __func__, bp, error); } @@ -955,44 +943,156 @@ vtblk_execute_request(struct vtblk_softc *sc, struct vtblk_request *req) return (error); } -static void -vtblk_vq_intr(void *xsc) +static int +vtblk_request_error(struct vtblk_request *req) { - struct vtblk_softc *sc; - struct virtqueue *vq; + int error; - sc = xsc; - vq = sc->vtblk_vq; - -again: - VTBLK_LOCK(sc); - if (sc->vtblk_flags & VTBLK_FLAG_DETACH) { - VTBLK_UNLOCK(sc); - return; + switch (req->vbr_ack) { + case VIRTIO_BLK_S_OK: + error = 0; + break; + case VIRTIO_BLK_S_UNSUPP: + error = ENOTSUP; + break; + default: + error = EIO; + break; } - vtblk_finish_completed(sc); - - if ((sc->vtblk_flags & VTBLK_FLAG_SUSPEND) == 0) - vtblk_startio(sc); - else - wakeup(&sc->vtblk_vq); - - if (virtqueue_enable_intr(vq) != 0) { - virtqueue_disable_intr(vq); - VTBLK_UNLOCK(sc); - goto again; - } - - VTBLK_UNLOCK(sc); + return (error); } static void -vtblk_stop(struct vtblk_softc *sc) +vtblk_queue_completed(struct vtblk_softc *sc, struct bio_queue *queue) +{ + struct vtblk_request *req; + struct bio *bp; + + while ((req = virtqueue_dequeue(sc->vtblk_vq, NULL)) != NULL) { + if (sc->vtblk_req_ordered != NULL) { + MPASS(sc->vtblk_req_ordered == req); + sc->vtblk_req_ordered = NULL; + } + + bp = req->vbr_bp; + bp->bio_error = vtblk_request_error(req); + TAILQ_INSERT_TAIL(queue, bp, bio_queue); + + vtblk_request_enqueue(sc, req); + } +} + +static void +vtblk_done_completed(struct vtblk_softc *sc, struct bio_queue *queue) +{ + struct bio *bp, *tmp; + + TAILQ_FOREACH_SAFE(bp, queue, bio_queue, tmp) { + if (bp->bio_error != 0) + disk_err(bp, "hard error", -1, 1); + vtblk_bio_done(sc, bp, bp->bio_error); + } +} + +static void +vtblk_drain_vq(struct vtblk_softc *sc, int skip_done) +{ + struct virtqueue *vq; + struct vtblk_request *req; + int last; + + vq = sc->vtblk_vq; + last = 0; + + while ((req = virtqueue_drain(vq, &last)) != NULL) { + if (!skip_done) + vtblk_bio_done(sc, req->vbr_bp, ENXIO); + + vtblk_request_enqueue(sc, req); + } + + sc->vtblk_req_ordered = NULL; + KASSERT(virtqueue_empty(vq), ("virtqueue not empty")); +} + +static void +vtblk_drain(struct vtblk_softc *sc) +{ + struct bio_queue queue; + struct bio_queue_head *bioq; + struct vtblk_request *req; + struct bio *bp; + + bioq = &sc->vtblk_bioq; + TAILQ_INIT(&queue); + + if (sc->vtblk_vq != NULL) { + vtblk_queue_completed(sc, &queue); + vtblk_done_completed(sc, &queue); + + vtblk_drain_vq(sc, 0); + } + + while ((req = vtblk_request_next_ready(sc)) != NULL) { + vtblk_bio_done(sc, req->vbr_bp, ENXIO); + vtblk_request_enqueue(sc, req); + } + + while (bioq_first(bioq) != NULL) { + bp = bioq_takefirst(bioq); + vtblk_bio_done(sc, bp, ENXIO); + } + + vtblk_request_free(sc); +} + +static void +vtblk_startio(struct vtblk_softc *sc) +{ + struct virtqueue *vq; + struct vtblk_request *req; + int enq; + + VTBLK_LOCK_ASSERT(sc); + vq = sc->vtblk_vq; + enq = 0; + + if (sc->vtblk_flags & VTBLK_FLAG_SUSPEND) + return; + + while (!virtqueue_full(vq)) { + req = vtblk_request_next(sc); + if (req == NULL) + break; + + if (vtblk_request_execute(sc, req) != 0) { + vtblk_request_requeue_ready(sc, req); + break; + } + + enq++; + } + + if (enq > 0) + virtqueue_notify(vq); +} + +static void +vtblk_bio_done(struct vtblk_softc *sc, struct bio *bp, int error) { - virtqueue_disable_intr(sc->vtblk_vq); - virtio_stop(sc->vtblk_dev); + /* Because of GEOM direct dispatch, we cannot hold any locks. */ + if (sc != NULL) + VTBLK_LOCK_ASSERT_NOTOWNED(sc); + + if (error) { + bp->bio_resid = bp->bio_bcount; + bp->bio_error = error; + bp->bio_flags |= BIO_ERROR; + } + + biodone(bp); } #define VTBLK_GET_CONFIG(_dev, _feature, _field, _cfg) \ @@ -1027,7 +1127,7 @@ vtblk_read_config(struct vtblk_softc *sc, struct virtio_blk_config *blkcfg) #undef VTBLK_GET_CONFIG static void -vtblk_get_ident(struct vtblk_softc *sc) +vtblk_ident(struct vtblk_softc *sc) { struct bio buf; struct disk *dp; @@ -1040,7 +1140,7 @@ vtblk_get_ident(struct vtblk_softc *sc) if (vtblk_tunable_int(sc, "no_ident", vtblk_no_ident) != 0) return; - req = vtblk_dequeue_request(sc); + req = vtblk_request_dequeue(sc); if (req == NULL) return; @@ -1060,7 +1160,7 @@ vtblk_get_ident(struct vtblk_softc *sc) error = vtblk_poll_request(sc, req); VTBLK_UNLOCK(sc); - vtblk_enqueue_request(sc, req); + vtblk_request_enqueue(sc, req); if (error) { device_printf(sc->vtblk_dev, @@ -1068,8 +1168,95 @@ vtblk_get_ident(struct vtblk_softc *sc) } } +static int +vtblk_poll_request(struct vtblk_softc *sc, struct vtblk_request *req) +{ + struct virtqueue *vq; + int error; + + vq = sc->vtblk_vq; + + if (!virtqueue_empty(vq)) + return (EBUSY); + + error = vtblk_request_execute(sc, req); + if (error) + return (error); + + virtqueue_notify(vq); + virtqueue_poll(vq, NULL); + + error = vtblk_request_error(req); + if (error && bootverbose) { + device_printf(sc->vtblk_dev, + "%s: IO error: %d\n", __func__, error); + } + + return (error); +} + +static int +vtblk_quiesce(struct vtblk_softc *sc) +{ + int error; + + VTBLK_LOCK_ASSERT(sc); + error = 0; + + while (!virtqueue_empty(sc->vtblk_vq)) { + if (mtx_sleep(&sc->vtblk_vq, VTBLK_MTX(sc), PRIBIO, "vtblkq", + VTBLK_QUIESCE_TIMEOUT) == EWOULDBLOCK) { + error = EBUSY; + break; + } + } + + return (error); +} + static void -vtblk_prepare_dump(struct vtblk_softc *sc) +vtblk_vq_intr(void *xsc) +{ + struct vtblk_softc *sc; + struct virtqueue *vq; + struct bio_queue queue; + + sc = xsc; + vq = sc->vtblk_vq; + TAILQ_INIT(&queue); + + VTBLK_LOCK(sc); + +again: + if (sc->vtblk_flags & VTBLK_FLAG_DETACH) + goto out; + + vtblk_queue_completed(sc, &queue); + vtblk_startio(sc); + + if (virtqueue_enable_intr(vq) != 0) { + virtqueue_disable_intr(vq); + goto again; + } + + if (sc->vtblk_flags & VTBLK_FLAG_SUSPEND) + wakeup(&sc->vtblk_vq); + +out: + VTBLK_UNLOCK(sc); + vtblk_done_completed(sc, &queue); +} + +static void +vtblk_stop(struct vtblk_softc *sc) +{ + + virtqueue_disable_intr(sc->vtblk_vq); + virtio_stop(sc->vtblk_dev); +} + +static void +vtblk_dump_prepare(struct vtblk_softc *sc) { device_t dev; struct virtqueue *vq; @@ -1097,7 +1284,7 @@ vtblk_prepare_dump(struct vtblk_softc *sc) } static int -vtblk_write_dump(struct vtblk_softc *sc, void *virtual, off_t offset, +vtblk_dump_write(struct vtblk_softc *sc, void *virtual, off_t offset, size_t length) { struct bio buf; @@ -1120,7 +1307,7 @@ vtblk_write_dump(struct vtblk_softc *sc, void *virtual, off_t offset, } static int -vtblk_flush_dump(struct vtblk_softc *sc) +vtblk_dump_flush(struct vtblk_softc *sc) { struct bio buf; struct vtblk_request *req; @@ -1139,241 +1326,59 @@ vtblk_flush_dump(struct vtblk_softc *sc) return (vtblk_poll_request(sc, req)); } -static int -vtblk_poll_request(struct vtblk_softc *sc, struct vtblk_request *req) +static void +vtblk_set_write_cache(struct vtblk_softc *sc, int wc) { - struct virtqueue *vq; - int error; - vq = sc->vtblk_vq; + /* Set either writeback (1) or writethrough (0) mode. */ + virtio_write_dev_config_1(sc->vtblk_dev, + offsetof(struct virtio_blk_config, writeback), wc); +} - if (!virtqueue_empty(vq)) - return (EBUSY); +static int +vtblk_write_cache_enabled(struct vtblk_softc *sc, + struct virtio_blk_config *blkcfg) +{ + int wc; - error = vtblk_execute_request(sc, req); - if (error) + if (sc->vtblk_flags & VTBLK_FLAG_WC_CONFIG) { + wc = vtblk_tunable_int(sc, "writecache_mode", + vtblk_writecache_mode); + if (wc >= 0 && wc < VTBLK_CACHE_MAX) + vtblk_set_write_cache(sc, wc); + else + wc = blkcfg->writeback; + } else + wc = virtio_with_feature(sc->vtblk_dev, VIRTIO_BLK_F_WCE); + + return (wc); +} + +static int +vtblk_write_cache_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct vtblk_softc *sc; + int wc, error; + + sc = oidp->oid_arg1; + wc = sc->vtblk_write_cache; + + error = sysctl_handle_int(oidp, &wc, 0, req); + if (error || req->newptr == NULL) return (error); + if ((sc->vtblk_flags & VTBLK_FLAG_WC_CONFIG) == 0) + return (EPERM); + if (wc < 0 || wc >= VTBLK_CACHE_MAX) + return (EINVAL); - virtqueue_notify(vq); - virtqueue_poll(vq, NULL); - - error = vtblk_request_error(req); - if (error && bootverbose) { - device_printf(sc->vtblk_dev, - "%s: IO error: %d\n", __func__, error); - } - - return (error); -} - -static void -vtblk_finish_completed(struct vtblk_softc *sc) -{ - struct vtblk_request *req; - struct bio *bp; - int error; - - while ((req = virtqueue_dequeue(sc->vtblk_vq, NULL)) != NULL) { - bp = req->vbr_bp; - - if (sc->vtblk_req_ordered != NULL) { - /* This should be the only outstanding request. */ - MPASS(sc->vtblk_req_ordered == req); - sc->vtblk_req_ordered = NULL; - } - - error = vtblk_request_error(req); - if (error) - disk_err(bp, "hard error", -1, 1); - - vtblk_finish_bio(bp, error); - vtblk_enqueue_request(sc, req); - } -} - -static void -vtblk_drain_vq(struct vtblk_softc *sc, int skip_done) -{ - struct virtqueue *vq; - struct vtblk_request *req; - int last; - - vq = sc->vtblk_vq; - last = 0; - - while ((req = virtqueue_drain(vq, &last)) != NULL) { - if (!skip_done) - vtblk_finish_bio(req->vbr_bp, ENXIO); - - vtblk_enqueue_request(sc, req); - } - - sc->vtblk_req_ordered = NULL; - KASSERT(virtqueue_empty(vq), ("virtqueue not empty")); -} - -static void -vtblk_drain(struct vtblk_softc *sc) -{ - struct bio_queue_head *bioq; - struct vtblk_request *req; - struct bio *bp; - - bioq = &sc->vtblk_bioq; - - if (sc->vtblk_vq != NULL) { - vtblk_finish_completed(sc); - vtblk_drain_vq(sc, 0); - } - - while ((req = vtblk_dequeue_ready(sc)) != NULL) { - vtblk_finish_bio(req->vbr_bp, ENXIO); - vtblk_enqueue_request(sc, req); - } - - while (bioq_first(bioq) != NULL) { - bp = bioq_takefirst(bioq); - vtblk_finish_bio(bp, ENXIO); - } - - vtblk_free_requests(sc); -} - -#ifdef INVARIANTS -static void -vtblk_request_invariants(struct vtblk_request *req) -{ - int hdr_nsegs, ack_nsegs; - - hdr_nsegs = sglist_count(&req->vbr_hdr, sizeof(req->vbr_hdr)); - ack_nsegs = sglist_count(&req->vbr_ack, sizeof(req->vbr_ack)); - - KASSERT(hdr_nsegs == 1, ("request header crossed page boundary")); - KASSERT(ack_nsegs == 1, ("request ack crossed page boundary")); -} -#endif - -static int -vtblk_alloc_requests(struct vtblk_softc *sc) -{ - struct vtblk_request *req; - int i, nreqs; - - nreqs = virtqueue_size(sc->vtblk_vq); - - /* - * Preallocate sufficient requests to keep the virtqueue full. Each - * request consumes VTBLK_MIN_SEGMENTS or more descriptors so reduce - * the number allocated when indirect descriptors are not available. - */ - if ((sc->vtblk_flags & VTBLK_FLAG_INDIRECT) == 0) - nreqs /= VTBLK_MIN_SEGMENTS; - - for (i = 0; i < nreqs; i++) { - req = malloc(sizeof(struct vtblk_request), M_DEVBUF, M_NOWAIT); - if (req == NULL) - return (ENOMEM); - -#ifdef INVARIANTS - vtblk_request_invariants(req); -#endif - - sc->vtblk_request_count++; - vtblk_enqueue_request(sc, req); - } + VTBLK_LOCK(sc); + sc->vtblk_write_cache = wc; + vtblk_set_write_cache(sc, sc->vtblk_write_cache); + VTBLK_UNLOCK(sc); return (0); } -static void -vtblk_free_requests(struct vtblk_softc *sc) -{ - struct vtblk_request *req; - - KASSERT(TAILQ_EMPTY(&sc->vtblk_req_ready), - ("%s: ready requests left on queue", __func__)); - - while ((req = vtblk_dequeue_request(sc)) != NULL) { - sc->vtblk_request_count--; - free(req, M_DEVBUF); - } - - KASSERT(sc->vtblk_request_count == 0, - ("%s: leaked %d requests", __func__, sc->vtblk_request_count)); -} - -static struct vtblk_request * -vtblk_dequeue_request(struct vtblk_softc *sc) -{ - struct vtblk_request *req; - - req = TAILQ_FIRST(&sc->vtblk_req_free); - if (req != NULL) - TAILQ_REMOVE(&sc->vtblk_req_free, req, vbr_link); - - return (req); -} - -static void -vtblk_enqueue_request(struct vtblk_softc *sc, struct vtblk_request *req) -{ - - bzero(req, sizeof(struct vtblk_request)); - TAILQ_INSERT_HEAD(&sc->vtblk_req_free, req, vbr_link); -} - -static struct vtblk_request * -vtblk_dequeue_ready(struct vtblk_softc *sc) -{ - struct vtblk_request *req; - - req = TAILQ_FIRST(&sc->vtblk_req_ready); - if (req != NULL) - TAILQ_REMOVE(&sc->vtblk_req_ready, req, vbr_link); - - return (req); -} - -static void -vtblk_enqueue_ready(struct vtblk_softc *sc, struct vtblk_request *req) -{ - - TAILQ_INSERT_HEAD(&sc->vtblk_req_ready, req, vbr_link); -} - -static int -vtblk_request_error(struct vtblk_request *req) -{ - int error; - - switch (req->vbr_ack) { - case VIRTIO_BLK_S_OK: - error = 0; - break; - case VIRTIO_BLK_S_UNSUPP: - error = ENOTSUP; - break; - default: - error = EIO; - break; - } - - return (error); -} - -static void -vtblk_finish_bio(struct bio *bp, int error) -{ - - if (error) { - bp->bio_resid = bp->bio_bcount; - bp->bio_error = error; - bp->bio_flags |= BIO_ERROR; - } - - biodone(bp); -} - static void vtblk_setup_sysctl(struct vtblk_softc *sc) { From da063e9d8cc9130c731a80c27e74011d228b4ed5 Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Sun, 30 Nov 2014 17:27:24 +0000 Subject: [PATCH 08/94] Use llabs when getting the absolute value of a long long. Sponsored by: ABT Ststems Ltd --- contrib/binutils/bfd/elf32-arm.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/contrib/binutils/bfd/elf32-arm.c b/contrib/binutils/bfd/elf32-arm.c index 83acfe564714..47b6566c2e2b 100644 --- a/contrib/binutils/bfd/elf32-arm.c +++ b/contrib/binutils/bfd/elf32-arm.c @@ -4960,7 +4960,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, + input_section->output_offset + rel->r_offset); - value = abs (relocation); + value = llabs (relocation); if (value >= 0x1000) return bfd_reloc_overflow; @@ -4998,7 +4998,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, + input_section->output_offset + rel->r_offset); - value = abs (relocation); + value = llabs (relocation); if (value >= 0x1000) return bfd_reloc_overflow; @@ -5984,7 +5984,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, /* Calculate the value of the relevant G_n, in encoded constant-with-rotation format. */ - g_n = calculate_group_reloc_mask (abs (signed_value), group, + g_n = calculate_group_reloc_mask (llabs (signed_value), group, &residual); /* Check for overflow if required. */ @@ -5998,7 +5998,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, (*_bfd_error_handler) (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"), input_bfd, input_section, - (long) rel->r_offset, abs (signed_value), howto->name); + (long) rel->r_offset, llabs (signed_value), howto->name); return bfd_reloc_overflow; } @@ -6077,7 +6077,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, /* Calculate the value of the relevant G_{n-1} to obtain the residual at that stage. */ - calculate_group_reloc_mask (abs (signed_value), group - 1, &residual); + calculate_group_reloc_mask (llabs (signed_value), group - 1, &residual); /* Check for overflow. */ if (residual >= 0x1000) @@ -6085,7 +6085,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, (*_bfd_error_handler) (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"), input_bfd, input_section, - (long) rel->r_offset, abs (signed_value), howto->name); + (long) rel->r_offset, llabs (signed_value), howto->name); return bfd_reloc_overflow; } @@ -6160,7 +6160,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, /* Calculate the value of the relevant G_{n-1} to obtain the residual at that stage. */ - calculate_group_reloc_mask (abs (signed_value), group - 1, &residual); + calculate_group_reloc_mask (llabs (signed_value), group - 1, &residual); /* Check for overflow. */ if (residual >= 0x100) @@ -6168,7 +6168,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, (*_bfd_error_handler) (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"), input_bfd, input_section, - (long) rel->r_offset, abs (signed_value), howto->name); + (long) rel->r_offset, llabs (signed_value), howto->name); return bfd_reloc_overflow; } @@ -6243,7 +6243,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, /* Calculate the value of the relevant G_{n-1} to obtain the residual at that stage. */ - calculate_group_reloc_mask (abs (signed_value), group - 1, &residual); + calculate_group_reloc_mask (llabs (signed_value), group - 1, &residual); /* Check for overflow. (The absolute value to go in the place must be divisible by four and, after having been divided by four, must @@ -6253,7 +6253,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, (*_bfd_error_handler) (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"), input_bfd, input_section, - (long) rel->r_offset, abs (signed_value), howto->name); + (long) rel->r_offset, llabs (signed_value), howto->name); return bfd_reloc_overflow; } From b4ce9f7856622aae1277eaa14e1fb3939b9d8151 Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Sun, 30 Nov 2014 17:29:49 +0000 Subject: [PATCH 09/94] There is no need to use FUNC_END with aeabi_ldiv0 or aeabi_idiv0 as they are aliases. Sponsored by: ABT Systems Ltd --- contrib/gcc/config/arm/lib1funcs.asm | 2 -- 1 file changed, 2 deletions(-) diff --git a/contrib/gcc/config/arm/lib1funcs.asm b/contrib/gcc/config/arm/lib1funcs.asm index 9245b3ca0c0d..c29f89496cf2 100644 --- a/contrib/gcc/config/arm/lib1funcs.asm +++ b/contrib/gcc/config/arm/lib1funcs.asm @@ -980,8 +980,6 @@ LSYM(Lover12): RET - FUNC_END aeabi_ldiv0 - FUNC_END aeabi_idiv0 FUNC_END div0 #endif /* L_divmodsi_tools */ From 2c6bf3d90bd2751170ff0c3d1af16cf8913cc323 Mon Sep 17 00:00:00 2001 From: "Justin T. Gibbs" Date: Sun, 30 Nov 2014 19:32:00 +0000 Subject: [PATCH 10/94] Remove trailing whitespace. --- sys/kern/subr_taskqueue.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/subr_taskqueue.c b/sys/kern/subr_taskqueue.c index 3a3dbc44c04f..f82e2457b012 100644 --- a/sys/kern/subr_taskqueue.c +++ b/sys/kern/subr_taskqueue.c @@ -661,11 +661,11 @@ taskqueue_thread_enqueue(void *context) TASKQUEUE_DEFINE(swi, taskqueue_swi_enqueue, NULL, swi_add(NULL, "task queue", taskqueue_swi_run, NULL, SWI_TQ, - INTR_MPSAFE, &taskqueue_ih)); + INTR_MPSAFE, &taskqueue_ih)); TASKQUEUE_DEFINE(swi_giant, taskqueue_swi_giant_enqueue, NULL, swi_add(NULL, "Giant taskq", taskqueue_swi_giant_run, - NULL, SWI_TQ_GIANT, 0, &taskqueue_giant_ih)); + NULL, SWI_TQ_GIANT, 0, &taskqueue_giant_ih)); TASKQUEUE_DEFINE_THREAD(thread); From e753a1effbb2fb02b83b001dfd2d052aa1d8ea9c Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sun, 30 Nov 2014 20:12:47 +0000 Subject: [PATCH 11/94] sh: Remove special case for '=' in set -x; always quote it in outqstr(). I plan to make set -x output always printable using $'...'; avoiding quoting words containing '=' is not worth the extra complexity. --- bin/sh/eval.c | 10 +--------- bin/sh/output.c | 3 +-- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/bin/sh/eval.c b/bin/sh/eval.c index c1a9cdbfcd93..d0460a024e3d 100644 --- a/bin/sh/eval.c +++ b/bin/sh/eval.c @@ -774,15 +774,7 @@ xtracecommand(struct arglist *varlist, struct arglist *arglist) for (sp = arglist->list ; sp ; sp = sp->next) { if (sep != 0) out2c(' '); - /* Disambiguate command looking like assignment. */ - if (sp == arglist->list && - strchr(sp->text, '=') != NULL && - strchr(sp->text, '\'') == NULL) { - out2c('\''); - out2str(sp->text); - out2c('\''); - } else - out2qstr(sp->text); + out2qstr(sp->text); sep = ' '; } out2c('\n'); diff --git a/bin/sh/output.c b/bin/sh/output.c index bf8e17d97ece..c6d118f11535 100644 --- a/bin/sh/output.c +++ b/bin/sh/output.c @@ -122,8 +122,7 @@ outqstr(const char *p, struct output *file) outstr("''", file); return; } - /* Caller will handle '=' if necessary */ - if (p[strcspn(p, "|&;<>()$`\\\"' \t\n*?[~#")] == '\0' || + if (p[strcspn(p, "|&;<>()$`\\\"' \t\n*?[~#=")] == '\0' || strcmp(p, "[") == 0) { outstr(p, file); return; From 95c4bf756a1dd903b360530f3787544417152c20 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Sun, 30 Nov 2014 20:20:55 +0000 Subject: [PATCH 12/94] Provide mutual exclusion between zone allocation/destruction and uma_reclaim(). Reclamation code must not see half-constructed or destructed zones. Do this by bracing uma_zcreate() and uma_zdestroy() into a shared-locked sx, and take the sx exclusively in uma_reclaim(). Usually zones are not created/destroyed during the system operation, but tmpfs mounts do cause zone operations and exposed the bug. Another solution could be to only expose a new keg on uma_kegs list after the corresponding zone is fully constructed, and similar treatment for the destruction. But it probably requires more risky code rearrangement as well. Reported and tested by: pho Discussed with: avg Sponsored by: The FreeBSD Foundation MFC after: 2 weeks --- sys/vm/uma_core.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c index 50e66c058268..574eba073f54 100644 --- a/sys/vm/uma_core.c +++ b/sys/vm/uma_core.c @@ -146,6 +146,8 @@ static LIST_HEAD(,uma_slab) uma_boot_pages = /* This mutex protects the boot time pages list */ static struct mtx_padalign uma_boot_pages_mtx; +static struct sx uma_drain_lock; + /* Is the VM done starting up? */ static int booted = 0; #define UMA_STARTUP 1 @@ -1876,6 +1878,7 @@ uma_startup2(void) { booted = UMA_STARTUP2; bucket_enable(); + sx_init(&uma_drain_lock, "umadrain"); #ifdef UMA_DEBUG printf("UMA startup2 complete.\n"); #endif @@ -1930,6 +1933,8 @@ uma_zcreate(const char *name, size_t size, uma_ctor ctor, uma_dtor dtor, { struct uma_zctor_args args; + uma_zone_t res; + bool locked; /* This stuff is essential for the zone ctor */ memset(&args, 0, sizeof(args)); @@ -1943,7 +1948,16 @@ uma_zcreate(const char *name, size_t size, uma_ctor ctor, uma_dtor dtor, args.flags = flags; args.keg = NULL; - return (zone_alloc_item(zones, &args, M_WAITOK)); + if (booted < UMA_STARTUP2) { + locked = false; + } else { + sx_slock(&uma_drain_lock); + locked = true; + } + res = zone_alloc_item(zones, &args, M_WAITOK); + if (locked) + sx_sunlock(&uma_drain_lock); + return (res); } /* See uma.h */ @@ -1953,6 +1967,8 @@ uma_zsecond_create(char *name, uma_ctor ctor, uma_dtor dtor, { struct uma_zctor_args args; uma_keg_t keg; + uma_zone_t res; + bool locked; keg = zone_first_keg(master); memset(&args, 0, sizeof(args)); @@ -1966,8 +1982,17 @@ uma_zsecond_create(char *name, uma_ctor ctor, uma_dtor dtor, args.flags = keg->uk_flags | UMA_ZONE_SECONDARY; args.keg = keg; + if (booted < UMA_STARTUP2) { + locked = false; + } else { + sx_slock(&uma_drain_lock); + locked = true; + } /* XXX Attaches only one keg of potentially many. */ - return (zone_alloc_item(zones, &args, M_WAITOK)); + res = zone_alloc_item(zones, &args, M_WAITOK); + if (locked) + sx_sunlock(&uma_drain_lock); + return (res); } /* See uma.h */ @@ -2085,7 +2110,9 @@ void uma_zdestroy(uma_zone_t zone) { + sx_slock(&uma_drain_lock); zone_free_item(zones, zone, NULL, SKIP_NONE); + sx_sunlock(&uma_drain_lock); } /* See uma.h */ @@ -3205,6 +3232,7 @@ uma_reclaim(void) #ifdef UMA_DEBUG printf("UMA: vm asked us to release pages!\n"); #endif + sx_xlock(&uma_drain_lock); bucket_enable(); zone_foreach(zone_drain); if (vm_page_count_min()) { @@ -3219,6 +3247,7 @@ uma_reclaim(void) zone_drain(slabzone); zone_drain(slabrefzone); bucket_zone_drain(); + sx_xunlock(&uma_drain_lock); } /* See uma.h */ From c5f8185b36cac5c4a1c8e106a526a19a5829c611 Mon Sep 17 00:00:00 2001 From: Gleb Kurtsou Date: Mon, 1 Dec 2014 08:14:25 +0000 Subject: [PATCH 13/94] Update tools/shlib-compat. - Update dwarfdump / compiler support. Use hex instead of decimal for integers. Add boolean and restrict type definitions. Add options for specifing dwarfdump and objdump executables. - Fix reporting missing symbol definitions as matching. - Compare external variable definitions. - Exclude special symbols like _init, _end by default. - Fix test build. --- tools/tools/shlib-compat/shlib-compat.py | 85 ++++++++++++++++++---- tools/tools/shlib-compat/test/Makefile.inc | 2 + tools/tools/shlib-compat/test/regress.sh | 2 +- 3 files changed, 75 insertions(+), 14 deletions(-) diff --git a/tools/tools/shlib-compat/shlib-compat.py b/tools/tools/shlib-compat/shlib-compat.py index 726c53ffb967..ca6f036639d1 100755 --- a/tools/tools/shlib-compat/shlib-compat.py +++ b/tools/tools/shlib-compat/shlib-compat.py @@ -60,6 +60,14 @@ def init(self, outname): origfile = FileConfig() newfile = FileConfig() + exclude_sym_default = [ + '^__bss_start$', + '^_edata$', + '^_end$', + '^_fini$', + '^_init$', + ] + @classmethod def init(cls): cls.version_filter = StrFilter() @@ -338,15 +346,17 @@ class BaseTypeDef(Def): def _pp(self, pp): if self.encoding in self.inttypes: sign = '' if self.encoding == 'DW_ATE_signed' else 'u' - bits = int(self.byte_size) * 8 + bits = int(self.byte_size, 0) * 8 return '%sint%s_t' % (sign, bits) - elif self.encoding == 'DW_ATE_signed_char' and int(self.byte_size) == 1: + elif self.encoding == 'DW_ATE_signed_char' and int(self.byte_size, 0) == 1: return 'char'; + elif self.encoding == 'DW_ATE_boolean' and int(self.byte_size, 0) == 1: + return 'bool'; elif self.encoding == 'DW_ATE_float': - return self._mapval(self.byte_size, { - '16': 'long double', - '8': 'double', - '4': 'float', + return self._mapval(int(self.byte_size, 0), { + 16: 'long double', + 8: 'double', + 4: 'float', }) raise NotImplementedError('Invalid encoding: %s' % self) @@ -374,6 +384,11 @@ class VolatileTypeDef(AnonymousDef): def _pp(self, pp): return 'volatile ' + self.type._pp(pp) +class RestrictTypeDef(AnonymousDef): + _is_alias = True + def _pp(self, pp): + return 'restrict ' + self.type._pp(pp) + class ArrayDef(AnonymousDef): def _pp(self, pp): t = pp.run(self.type) @@ -411,6 +426,11 @@ def _pp(self, pp): t = pp.run(self.type) return "%s %s" % (t, self._name_opt()) +class VariableDef(Def): + def _pp(self, pp): + t = pp.run(self.type) + return "%s %s" % (t, self._name_opt()) + # TODO class StructForwardDef(Def): pass @@ -485,6 +505,10 @@ def build_subprogram(self, raw): result = self._build_optarg_type(raw) return FunctionDef(raw.id, raw.name, params=params, result=result) + def build_variable(self, raw): + type = self._build_optarg_type(raw) + return VariableDef(raw.id, raw.optname, type=type) + def build_subroutine_type(self, raw): params = [ self.build(x) for x in raw.nested ] result = self._build_optarg_type(raw) @@ -547,6 +571,10 @@ def build_volatile_type(self, raw): type = self._build_optarg_type(raw) return VolatileTypeDef(raw.id, type=type) + def build_restrict_type(self, raw): + type = self._build_optarg_type(raw) + return RestrictTypeDef(raw.id, type=type) + def build_enumeration_type(self, raw): # TODO handle DW_TAG_enumerator ??? return EnumerationTypeDef(raw.id, name=raw.optname, @@ -574,7 +602,7 @@ def _get_id(self, id): return int(id) except ValueError: if (id.startswith('<') and id.endswith('>')): - return int(id[1:-1]) + return int(id[1:-1], 0) else: raise ValueError("Invalid dwarf id: %s" % id) @@ -782,7 +810,7 @@ def __init__(self): class Tag(object): def __init__(self, unit, data): self.unit = unit - self.id = int(data['id']) + self.id = int(data['id'], 0) self.level = int(data['level']) self.tag = data['tag'] self.args = {} @@ -816,7 +844,7 @@ def optarg(self, a, default): def __repr__(self): return "Tag(%d, %d, %s)" % (self.level, self.id, self.tag) - re_header = re.compile('<(?P\d+)><(?P\d+\+*\d*)><(?P\w+)>') + re_header = re.compile('<(?P\d+)><(?P[0xX0-9a-fA-F]+(?:\+(0[xX])?[0-9a-fA-F]+)?)><(?P\w+)>') re_argname = re.compile('(?P\w+)<') re_argunknown = re.compile('<[^<>]+>') @@ -827,6 +855,10 @@ def __repr__(self): 'DW_TAG_variable', ]) + external_tags = set([ + 'DW_TAG_variable', + ]) + def __init__(self, libfile): Parser.__init__(self, "%s -di %s" % (Config.dwarfdump, libfile)) self.current_unit = None @@ -888,9 +920,19 @@ def parse_debuginfo(self, line): while args: args = self.parse_arg(tag, args) tag.unit.tags[tag.id] = tag - if tag.args.has_key('DW_AT_low_pc') and \ - tag.tag not in DwarfdumpParser.skip_tags: - offset = int(tag.args['DW_AT_low_pc'], 16) + def parse_offset(tag): + if tag.args.has_key('DW_AT_low_pc'): + return int(tag.args['DW_AT_low_pc'], 16) + elif tag.args.has_key('DW_AT_location'): + location = tag.args['DW_AT_location'] + if location.startswith('DW_OP_addr'): + return int(location.replace('DW_OP_addr', ''), 16) + return None + offset = parse_offset(tag) + if offset is not None and \ + (tag.tag not in DwarfdumpParser.skip_tags or \ + (tag.args.has_key('DW_AT_external') and \ + tag.tag in DwarfdumpParser.external_tags)): if self.offsetmap.has_key(offset): raise ValueError("Dwarf dump parse error: " + "symbol is aleady defined at offset 0x%x" % offset) @@ -963,10 +1005,15 @@ def cmp_symbols(commonver): names.sort() for symname in names: sym = ver.symbols[symname] - match = sym.origsym.definition == sym.newsym.definition + missing = sym.origsym.definition is None or sym.newsym.definition is None + match = not missing and sym.origsym.definition == sym.newsym.definition if not match: App.result_code = 1 if Config.verbose >= 1 or not match: + if missing: + print '%s: missing definition' % \ + (sym.origsym.name_ver,) + continue print '%s: definitions %smatch' % \ (sym.origsym.name_ver, "" if match else "mis") if Config.dump or (not match and not Config.no_dump): @@ -1035,10 +1082,16 @@ def finish(self): help="result output file for original library", metavar="ORIGFILE") parser.add_option('--out-new', action='store', help="result output file for new library", metavar="NEWFILE") + parser.add_option('--dwarfdump', action='store', + help="path to dwarfdump executable", metavar="DWARFDUMP") + parser.add_option('--objdump', action='store', + help="path to objdump executable", metavar="OBJDUMP") parser.add_option('--exclude-ver', action='append', metavar="RE") parser.add_option('--include-ver', action='append', metavar="RE") parser.add_option('--exclude-sym', action='append', metavar="RE") parser.add_option('--include-sym', action='append', metavar="RE") + parser.add_option('--no-exclude-sym-default', action='store_true', + help="don't exclude special symbols like _init, _end, __bss_start") for opt in ['alias', 'cached', 'symbol']: parser.add_option("--w-" + opt, action="store_true", dest="w_" + opt) @@ -1049,6 +1102,10 @@ def finish(self): if len(args) != 2: parser.print_help() sys.exit(-1) + if opts.dwarfdump: + Config.dwarfdump = opts.dwarfdump + if opts.objdump: + Config.objdump = opts.objdump if opts.out_orig: Config.origfile.init(opts.out_orig) if opts.out_new: @@ -1071,6 +1128,8 @@ def finish(self): opt = getattr(opts, a + k) if opt: getattr(v, a).extend(opt) + if not opts.no_exclude_sym_default: + Config.symbol_filter.exclude.extend(Config.exclude_sym_default) Config.version_filter.compile() Config.symbol_filter.compile() for w in ['w_alias', 'w_cached', 'w_symbol']: diff --git a/tools/tools/shlib-compat/test/Makefile.inc b/tools/tools/shlib-compat/test/Makefile.inc index 14aaef6ea956..e1a0719a89f4 100644 --- a/tools/tools/shlib-compat/test/Makefile.inc +++ b/tools/tools/shlib-compat/test/Makefile.inc @@ -11,3 +11,5 @@ DEBUG_FLAGS?= -g VERSION_DEF= ${.CURDIR}/../Versions.def SYMBOL_MAPS= ${.CURDIR}/Symbol.map + +MK_DEBUG_FILES= yes diff --git a/tools/tools/shlib-compat/test/regress.sh b/tools/tools/shlib-compat/test/regress.sh index e113cce87b63..0789fa8b3cf7 100755 --- a/tools/tools/shlib-compat/test/regress.sh +++ b/tools/tools/shlib-compat/test/regress.sh @@ -1,7 +1,7 @@ #!/bin/sh # $FreeBSD$ -run() { ../shlib-compat.py --no-dump -vv libtest$1/libtest$1.so.0.debug libtest$2/libtest$2.so.0.debug; } +run() { ../shlib-compat.py --no-dump -vv libtest$1/libtest$1.so.0.full libtest$2/libtest$2.so.0.full; } echo 1..9 REGRESSION_START($1) REGRESSION_TEST(`1-1', `run 1 1') From 32dbae66199491ee1459130cd905c1eb6b02095e Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Mon, 1 Dec 2014 10:17:23 +0000 Subject: [PATCH 14/94] Face the fact that we have no idea where the ports tree really lives. --- tools/tools/sysbuild/sysbuild.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/tools/sysbuild/sysbuild.sh b/tools/tools/sysbuild/sysbuild.sh index 1a32c60e027e..bb22a697453a 100644 --- a/tools/tools/sysbuild/sysbuild.sh +++ b/tools/tools/sysbuild/sysbuild.sh @@ -226,8 +226,7 @@ ports_build() ( t=`echo $p | sed 's,/usr/ports/,,'` pn=`cd $p && make package-name` - if [ "x$p" == "x/usr/ports/ports-mgmt/pkg" -o \ - "x$p" == "x/freebsd/ports/ports-mgmt/pkg" ] ; then + if [ "x`basename $p`" == "xpkg" ] ; then log_it "Very Special: $t ($pn)" ( From c25290420ee7b9f4a875426380d8ad042a561b9c Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Mon, 1 Dec 2014 11:45:24 +0000 Subject: [PATCH 15/94] Start process of removing the use of the deprecated "M_FLOWID" flag from the FreeBSD network code. The flag is still kept around in the "sys/mbuf.h" header file, but does no longer have any users. Instead the "m_pkthdr.rsstype" field in the mbuf structure is now used to decide the meaning of the "m_pkthdr.flowid" field. To modify the "m_pkthdr.rsstype" field please use the existing "M_HASHTYPE_XXX" macros as defined in the "sys/mbuf.h" header file. This patch introduces new behaviour in the transmit direction. Previously network drivers checked if "M_FLOWID" was set in "m_flags" before using the "m_pkthdr.flowid" field. This check has now now been replaced by checking if "M_HASHTYPE_GET(m)" is different from "M_HASHTYPE_NONE". In the future more hashtypes will be added, for example hashtypes for hardware dedicated flows. "M_HASHTYPE_OPAQUE" indicates that the "m_pkthdr.flowid" value is valid and has no particular type. This change removes the need for an "if" statement in TCP transmit code checking for the presence of a valid flowid value. The "if" statement mentioned above is now a direct variable assignment which is then later checked by the respective network drivers like before. Additional notes: - The SCTP code changes will be committed as a separate patch. - Removal of the "M_FLOWID" flag will also be done separately. - The FreeBSD version has been bumped. MFC after: 1 month Sponsored by: Mellanox Technologies --- sys/dev/bxe/bxe.c | 9 ++++----- sys/dev/cxgb/cxgb_sge.c | 12 +++++++----- sys/dev/cxgbe/t4_main.c | 3 ++- sys/dev/cxgbe/t4_sge.c | 2 +- sys/dev/e1000/if_igb.c | 7 +++---- sys/dev/ixgbe/ixgbe.c | 8 ++++---- sys/dev/ixgbe/ixv.c | 4 ++-- sys/dev/ixl/ixl_txrx.c | 6 +++--- sys/dev/mxge/if_mxge.c | 4 ++-- sys/dev/netmap/netmap_freebsd.c | 4 ++-- sys/dev/oce/oce_if.c | 4 ++-- sys/dev/qlxgbe/ql_isr.c | 4 ++-- sys/dev/qlxgbe/ql_os.c | 3 ++- sys/dev/qlxge/qls_isr.c | 2 +- sys/dev/qlxge/qls_os.c | 3 ++- sys/dev/sfxge/sfxge_rx.c | 4 ++-- sys/dev/sfxge/sfxge_tx.c | 3 ++- sys/dev/virtio/network/if_vtnet.c | 5 +++-- sys/dev/vmware/vmxnet3/if_vmx.c | 5 +++-- sys/dev/vxge/vxge.c | 4 ++-- sys/net/flowtable.c | 4 ++-- sys/net/ieee8023ad_lacp.c | 3 ++- sys/net/if_lagg.c | 7 ++++--- sys/net/if_lagg.h | 4 ++-- sys/net/if_vxlan.c | 1 + sys/net/netisr.c | 5 +++-- sys/netinet/in_pcb.h | 4 ++-- sys/netinet/in_rss.c | 11 +++++------ sys/netinet/ip_input.c | 1 - sys/netinet/ip_output.c | 4 +--- sys/netinet/tcp_input.c | 10 ++++------ sys/netinet/tcp_syncache.c | 4 +--- sys/netinet/udp_usrreq.c | 12 ++++-------- sys/netinet6/in6_pcb.c | 2 +- sys/netinet6/ip6_output.c | 6 +++--- sys/netinet6/udp6_usrreq.c | 1 - sys/ofed/drivers/net/mlx4/en_rx.c | 2 +- sys/ofed/drivers/net/mlx4/en_tx.c | 19 +++++++++---------- sys/sys/param.h | 2 +- 39 files changed, 97 insertions(+), 101 deletions(-) diff --git a/sys/dev/bxe/bxe.c b/sys/dev/bxe/bxe.c index a27b3e7a56bd..3509f2d023df 100644 --- a/sys/dev/bxe/bxe.c +++ b/sys/dev/bxe/bxe.c @@ -3219,7 +3219,7 @@ bxe_tpa_stop(struct bxe_softc *sc, #if __FreeBSD_version >= 800000 /* specify what RSS queue was used for this flow */ m->m_pkthdr.flowid = fp->index; - m->m_flags |= M_FLOWID; + M_HASHTYPE_SET(m, M_HASHTYPE_OPAQUE); #endif if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); @@ -3454,7 +3454,7 @@ bxe_rxeof(struct bxe_softc *sc, #if __FreeBSD_version >= 800000 /* specify what RSS queue was used for this flow */ m->m_pkthdr.flowid = fp->index; - m->m_flags |= M_FLOWID; + M_HASHTYPE_SET(m, M_HASHTYPE_OPAQUE); #endif next_rx: @@ -6037,10 +6037,9 @@ bxe_tx_mq_start(struct ifnet *ifp, fp_index = 0; /* default is the first queue */ - /* change the queue if using flow ID */ - if ((m->m_flags & M_FLOWID) != 0) { + /* check if flowid is set */ + if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) fp_index = (m->m_pkthdr.flowid % sc->num_queues); - } fp = &sc->fp[fp_index]; diff --git a/sys/dev/cxgb/cxgb_sge.c b/sys/dev/cxgb/cxgb_sge.c index a7f39a510109..2b08183b0cd5 100644 --- a/sys/dev/cxgb/cxgb_sge.c +++ b/sys/dev/cxgb/cxgb_sge.c @@ -1733,8 +1733,9 @@ cxgb_transmit(struct ifnet *ifp, struct mbuf *m) m_freem(m); return (0); } - - if (m->m_flags & M_FLOWID) + + /* check if flowid is set */ + if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) qidx = (m->m_pkthdr.flowid % pi->nqsets) + pi->first_qset; qs = &pi->adapter->sge.qs[qidx]; @@ -2899,9 +2900,10 @@ process_responses(adapter_t *adap, struct sge_qset *qs, int budget) eop = get_packet(adap, drop_thresh, qs, mh, r); if (eop) { - if (r->rss_hdr.hash_type && !adap->timestamp) - mh->mh_head->m_flags |= M_FLOWID; - mh->mh_head->m_pkthdr.flowid = rss_hash; + if (r->rss_hdr.hash_type && !adap->timestamp) { + M_HASHTYPE_SET(mh->mh_head, M_HASHTYPE_OPAQUE); + mh->mh_head->m_pkthdr.flowid = rss_hash; + } } ethpad = 2; diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index f9caf2eec1d8..2c384fd0f1a6 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -1440,7 +1440,8 @@ cxgbe_transmit(struct ifnet *ifp, struct mbuf *m) return (ENETDOWN); } - if (m->m_flags & M_FLOWID) + /* check if flowid is set */ + if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) txq += ((m->m_pkthdr.flowid % (pi->ntxq - pi->rsrv_noflowq)) + pi->rsrv_noflowq); br = txq->br; diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c index 499f25205998..58940fe4959c 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -1734,7 +1734,7 @@ t4_eth_rx(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m0) m0->m_data += fl_pktshift; m0->m_pkthdr.rcvif = ifp; - m0->m_flags |= M_FLOWID; + M_HASHTYPE_SET(m0, M_HASHTYPE_OPAQUE); m0->m_pkthdr.flowid = be32toh(rss->hash_val); if (cpl->csum_calc && !cpl->err_vec) { diff --git a/sys/dev/e1000/if_igb.c b/sys/dev/e1000/if_igb.c index 335aa01d95c9..75f0fb419d50 100644 --- a/sys/dev/e1000/if_igb.c +++ b/sys/dev/e1000/if_igb.c @@ -990,7 +990,7 @@ igb_mq_start(struct ifnet *ifp, struct mbuf *m) * If everything is setup correctly, it should be the * same bucket that the current CPU we're on is. */ - if ((m->m_flags & M_FLOWID) != 0) { + if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) { #ifdef RSS if (rss_hash2bucket(m->m_pkthdr.flowid, M_HASHTYPE_GET(m), &bucket_id) == 0) { @@ -5166,7 +5166,6 @@ igb_rxeof(struct igb_queue *que, int count, int *done) /* XXX set flowtype once this works right */ rxr->fmp->m_pkthdr.flowid = le32toh(cur->wb.lower.hi_dword.rss); - rxr->fmp->m_flags |= M_FLOWID; switch (pkt_info & E1000_RXDADV_RSSTYPE_MASK) { case E1000_RXDADV_RSSTYPE_IPV4_TCP: M_HASHTYPE_SET(rxr->fmp, M_HASHTYPE_RSS_TCP_IPV4); @@ -5196,11 +5195,11 @@ igb_rxeof(struct igb_queue *que, int count, int *done) default: /* XXX fallthrough */ - M_HASHTYPE_SET(rxr->fmp, M_HASHTYPE_NONE); + M_HASHTYPE_SET(rxr->fmp, M_HASHTYPE_OPAQUE); } #elif !defined(IGB_LEGACY_TX) rxr->fmp->m_pkthdr.flowid = que->msix; - rxr->fmp->m_flags |= M_FLOWID; + M_HASHTYPE_SET(rxr->fmp, M_HASHTYPE_OPAQUE); #endif sendmp = rxr->fmp; /* Make sure to set M_PKTHDR. */ diff --git a/sys/dev/ixgbe/ixgbe.c b/sys/dev/ixgbe/ixgbe.c index 9ac70eeac5e4..2fd126c5396e 100644 --- a/sys/dev/ixgbe/ixgbe.c +++ b/sys/dev/ixgbe/ixgbe.c @@ -833,7 +833,7 @@ ixgbe_mq_start(struct ifnet *ifp, struct mbuf *m) * If everything is setup correctly, it should be the * same bucket that the current CPU we're on is. */ - if ((m->m_flags & M_FLOWID) != 0) { + if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) { #ifdef RSS if (rss_hash2bucket(m->m_pkthdr.flowid, M_HASHTYPE_GET(m), &bucket_id) == 0) { @@ -4764,7 +4764,6 @@ ixgbe_rxeof(struct ix_queue *que) #ifdef RSS sendmp->m_pkthdr.flowid = le32toh(cur->wb.lower.hi_dword.rss); - sendmp->m_flags |= M_FLOWID; switch (pkt_info & IXGBE_RXDADV_RSSTYPE_MASK) { case IXGBE_RXDADV_RSSTYPE_IPV4_TCP: M_HASHTYPE_SET(sendmp, M_HASHTYPE_RSS_TCP_IPV4); @@ -4795,11 +4794,12 @@ ixgbe_rxeof(struct ix_queue *que) break; default: /* XXX fallthrough */ - M_HASHTYPE_SET(sendmp, M_HASHTYPE_NONE); + M_HASHTYPE_SET(sendmp, M_HASHTYPE_OPAQUE); + break; } #else /* RSS */ sendmp->m_pkthdr.flowid = que->msix; - sendmp->m_flags |= M_FLOWID; + M_HASHTYPE_SET(sendmp, M_HASHTYPE_OPAQUE); #endif /* RSS */ #endif /* FreeBSD_version */ } diff --git a/sys/dev/ixgbe/ixv.c b/sys/dev/ixgbe/ixv.c index 1d77e8b5a27a..edbdfca85920 100644 --- a/sys/dev/ixgbe/ixv.c +++ b/sys/dev/ixgbe/ixv.c @@ -580,7 +580,7 @@ ixv_mq_start(struct ifnet *ifp, struct mbuf *m) int i = 0, err = 0; /* Which queue to use */ - if ((m->m_flags & M_FLOWID) != 0) + if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) i = m->m_pkthdr.flowid % adapter->num_queues; txr = &adapter->tx_rings[i]; @@ -3464,7 +3464,7 @@ ixv_rxeof(struct ix_queue *que, int count) ixv_rx_checksum(staterr, sendmp, ptype); #if __FreeBSD_version >= 800000 sendmp->m_pkthdr.flowid = que->msix; - sendmp->m_flags |= M_FLOWID; + M_HASHTYPE_SET(sendmp, M_HASHTYPE_OPAQUE); #endif } next_desc: diff --git a/sys/dev/ixl/ixl_txrx.c b/sys/dev/ixl/ixl_txrx.c index 6322f2c9fd0e..f36b8318961d 100755 --- a/sys/dev/ixl/ixl_txrx.c +++ b/sys/dev/ixl/ixl_txrx.c @@ -66,8 +66,8 @@ ixl_mq_start(struct ifnet *ifp, struct mbuf *m) struct tx_ring *txr; int err, i; - /* Which queue to use */ - if ((m->m_flags & M_FLOWID) != 0) + /* check if flowid is set */ + if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) i = m->m_pkthdr.flowid % vsi->num_queues; else i = curcpu % vsi->num_queues; @@ -1543,7 +1543,7 @@ ixl_rxeof(struct ixl_queue *que, int count) if ((ifp->if_capenable & IFCAP_RXCSUM) != 0) ixl_rx_checksum(sendmp, status, error, ptype); sendmp->m_pkthdr.flowid = que->msix; - sendmp->m_flags |= M_FLOWID; + M_HASHTYPE_SET(sendmp, M_HASHTYPE_OPAQUE); } next_desc: bus_dmamap_sync(rxr->dma.tag, rxr->dma.map, diff --git a/sys/dev/mxge/if_mxge.c b/sys/dev/mxge/if_mxge.c index e97ae5c7130e..fe8c08a72495 100644 --- a/sys/dev/mxge/if_mxge.c +++ b/sys/dev/mxge/if_mxge.c @@ -2719,7 +2719,7 @@ mxge_rx_done_big(struct mxge_slice_state *ss, uint32_t len, /* flowid only valid if RSS hashing is enabled */ if (sc->num_slices > 1) { m->m_pkthdr.flowid = (ss - sc->ss); - m->m_flags |= M_FLOWID; + M_HASHTYPE_SET(m, M_HASHTYPE_OPAQUE); } /* pass the frame up the stack */ (*ifp->if_input)(ifp, m); @@ -2787,7 +2787,7 @@ mxge_rx_done_small(struct mxge_slice_state *ss, uint32_t len, /* flowid only valid if RSS hashing is enabled */ if (sc->num_slices > 1) { m->m_pkthdr.flowid = (ss - sc->ss); - m->m_flags |= M_FLOWID; + M_HASHTYPE_SET(m, M_HASHTYPE_OPAQUE); } /* pass the frame up the stack */ (*ifp->if_input)(ifp, m); diff --git a/sys/dev/netmap/netmap_freebsd.c b/sys/dev/netmap/netmap_freebsd.c index 322670814553..dd968ca51577 100644 --- a/sys/dev/netmap/netmap_freebsd.c +++ b/sys/dev/netmap/netmap_freebsd.c @@ -204,7 +204,7 @@ netmap_catch_tx(struct netmap_generic_adapter *gna, int enable) * of the transmission does not consume resources. * * On FreeBSD, and on multiqueue cards, we can force the queue using - * if ((m->m_flags & M_FLOWID) != 0) + * if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) * i = m->m_pkthdr.flowid % adapter->num_queues; * else * i = curcpu % adapter->num_queues; @@ -240,7 +240,7 @@ generic_xmit_frame(struct ifnet *ifp, struct mbuf *m, m->m_len = m->m_pkthdr.len = len; // inc refcount. All ours, we could skip the atomic atomic_fetchadd_int(PNT_MBUF_REFCNT(m), 1); - m->m_flags |= M_FLOWID; + M_HASHTYPE_SET(m, M_HASHTYPE_OPAQUE); m->m_pkthdr.flowid = ring_nr; m->m_pkthdr.rcvif = ifp; /* used for tx notification */ ret = NA(ifp)->if_transmit(ifp, m); diff --git a/sys/dev/oce/oce_if.c b/sys/dev/oce/oce_if.c index fe48007e8973..062181b2367b 100644 --- a/sys/dev/oce/oce_if.c +++ b/sys/dev/oce/oce_if.c @@ -563,7 +563,7 @@ oce_multiq_start(struct ifnet *ifp, struct mbuf *m) int queue_index = 0; int status = 0; - if ((m->m_flags & M_FLOWID) != 0) + if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) queue_index = m->m_pkthdr.flowid % sc->nwqs; wq = sc->wq[queue_index]; @@ -1374,7 +1374,7 @@ oce_rx(struct oce_rq *rq, uint32_t rqe_idx, struct oce_nic_rx_cqe *cqe) m->m_pkthdr.flowid = (rq->queue_index - 1); else m->m_pkthdr.flowid = rq->queue_index; - m->m_flags |= M_FLOWID; + M_HASHTYPE_SET(m, M_HASHTYPE_OPAQUE); #endif /* This deternies if vlan tag is Valid */ if (oce_cqe_vtp_valid(sc, cqe)) { diff --git a/sys/dev/qlxgbe/ql_isr.c b/sys/dev/qlxgbe/ql_isr.c index db0029822927..dee8e198e8f4 100644 --- a/sys/dev/qlxgbe/ql_isr.c +++ b/sys/dev/qlxgbe/ql_isr.c @@ -159,7 +159,7 @@ qla_rx_intr(qla_host_t *ha, qla_sgl_rcv_t *sgc, uint32_t sds_idx) if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); mpf->m_pkthdr.flowid = sgc->rss_hash; - mpf->m_flags |= M_FLOWID; + M_HASHTYPE_SET(mpf, M_HASHTYPE_OPAQUE); (*ifp->if_input)(ifp, mpf); @@ -324,7 +324,7 @@ qla_lro_intr(qla_host_t *ha, qla_sgl_lro_t *sgc, uint32_t sds_idx) mpf->m_pkthdr.csum_data = 0xFFFF; mpf->m_pkthdr.flowid = sgc->rss_hash; - mpf->m_flags |= M_FLOWID; + M_HASHTYPE_SET(mpf, M_HASHTYPE_OPAQUE); if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); diff --git a/sys/dev/qlxgbe/ql_os.c b/sys/dev/qlxgbe/ql_os.c index 1684c070fcd8..04fbf7195529 100644 --- a/sys/dev/qlxgbe/ql_os.c +++ b/sys/dev/qlxgbe/ql_os.c @@ -1140,7 +1140,8 @@ qla_send(qla_host_t *ha, struct mbuf **m_headp) QL_DPRINT8(ha, (ha->pci_dev, "%s: enter\n", __func__)); - if (m_head->m_flags & M_FLOWID) + /* check if flowid is set */ + if (M_HASHTYPE_GET(m_head) != M_HASHTYPE_NONE) txr_idx = m_head->m_pkthdr.flowid & (ha->hw.num_tx_rings - 1); tx_idx = ha->hw.tx_cntxt[txr_idx].txr_next; diff --git a/sys/dev/qlxge/qls_isr.c b/sys/dev/qlxge/qls_isr.c index 14b4839be913..03b3a3c52152 100644 --- a/sys/dev/qlxge/qls_isr.c +++ b/sys/dev/qlxge/qls_isr.c @@ -190,7 +190,7 @@ qls_rx_comp(qla_host_t *ha, uint32_t rxr_idx, uint32_t cq_idx, q81_rx_t *cq_e) if ((cq_e->flags1 & Q81_RX_FLAGS1_RSS_MATCH_MASK)) { rxr->rss_int++; mp->m_pkthdr.flowid = cq_e->rss; - mp->m_flags |= M_FLOWID; + M_HASHTYPE_SET(mp, M_HASHTYPE_OPAQUE); } if (cq_e->flags0 & (Q81_RX_FLAGS0_TE | Q81_RX_FLAGS0_NU | Q81_RX_FLAGS0_IE)) { diff --git a/sys/dev/qlxge/qls_os.c b/sys/dev/qlxge/qls_os.c index 4f4097935f0c..1617d24095e1 100644 --- a/sys/dev/qlxge/qls_os.c +++ b/sys/dev/qlxge/qls_os.c @@ -1136,7 +1136,8 @@ qls_send(qla_host_t *ha, struct mbuf **m_headp) QL_DPRINT8((ha->pci_dev, "%s: enter\n", __func__)); - if (m_head->m_flags & M_FLOWID) + /* check if flowid is set */ + if (M_HASHTYPE_GET(m_head) != M_HASHTYPE_NONE) txr_idx = m_head->m_pkthdr.flowid & (ha->num_tx_rings - 1); tx_idx = ha->tx_ring[txr_idx].txr_next; diff --git a/sys/dev/sfxge/sfxge_rx.c b/sys/dev/sfxge/sfxge_rx.c index 66083d832857..ccfdfb023d07 100644 --- a/sys/dev/sfxge/sfxge_rx.c +++ b/sys/dev/sfxge/sfxge_rx.c @@ -302,7 +302,7 @@ sfxge_rx_deliver(struct sfxge_softc *sc, struct sfxge_rx_sw_desc *rx_desc) if (rx_desc->flags & EFX_PKT_TCP) { m->m_pkthdr.flowid = EFX_RX_HASH_VALUE(EFX_RX_HASHALG_TOEPLITZ, mtod(m, uint8_t *)); - m->m_flags |= M_FLOWID; + M_HASHTYPE_SET(m, M_HASHTYPE_OPAQUE); } #endif m->m_data += sc->rx_prefix_size; @@ -353,7 +353,7 @@ sfxge_lro_deliver(struct sfxge_lro_state *st, struct sfxge_lro_conn *c) #ifdef SFXGE_HAVE_MQ m->m_pkthdr.flowid = c->conn_hash; - m->m_flags |= M_FLOWID; + M_HASHTYPE_SET(m, M_HASHTYPE_OPAQUE); #endif m->m_pkthdr.csum_flags = csum_flags; __sfxge_rx_deliver(sc, m); diff --git a/sys/dev/sfxge/sfxge_tx.c b/sys/dev/sfxge/sfxge_tx.c index a12c74756ea5..3fb76d92b6db 100644 --- a/sys/dev/sfxge/sfxge_tx.c +++ b/sys/dev/sfxge/sfxge_tx.c @@ -631,7 +631,8 @@ sfxge_if_transmit(struct ifnet *ifp, struct mbuf *m) if (m->m_pkthdr.csum_flags & (CSUM_DELAY_DATA | CSUM_TSO)) { int index = 0; - if (m->m_flags & M_FLOWID) { + /* check if flowid is set */ + if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) { uint32_t hash = m->m_pkthdr.flowid; index = sc->rx_indir_table[hash % SFXGE_RX_SCALE_MAX]; diff --git a/sys/dev/virtio/network/if_vtnet.c b/sys/dev/virtio/network/if_vtnet.c index 83cb2d79fe25..9fba9bdabe0b 100644 --- a/sys/dev/virtio/network/if_vtnet.c +++ b/sys/dev/virtio/network/if_vtnet.c @@ -1701,7 +1701,7 @@ vtnet_rxq_input(struct vtnet_rxq *rxq, struct mbuf *m, } m->m_pkthdr.flowid = rxq->vtnrx_id; - m->m_flags |= M_FLOWID; + M_HASHTYPE_SET(m, M_HASHTYPE_OPAQUE); /* * BMV: FreeBSD does not have the UNNECESSARY and PARTIAL checksum @@ -2347,7 +2347,8 @@ vtnet_txq_mq_start(struct ifnet *ifp, struct mbuf *m) sc = ifp->if_softc; npairs = sc->vtnet_act_vq_pairs; - if (m->m_flags & M_FLOWID) + /* check if flowid is set */ + if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) i = m->m_pkthdr.flowid % npairs; else i = curcpu % npairs; diff --git a/sys/dev/vmware/vmxnet3/if_vmx.c b/sys/dev/vmware/vmxnet3/if_vmx.c index 1d8c12e2fc9b..5faf716acf4d 100644 --- a/sys/dev/vmware/vmxnet3/if_vmx.c +++ b/sys/dev/vmware/vmxnet3/if_vmx.c @@ -2059,7 +2059,7 @@ vmxnet3_rxq_input(struct vmxnet3_rxqueue *rxq, } #else m->m_pkthdr.flowid = rxq->vxrxq_id; - m->m_flags |= M_FLOWID; + M_HASHTYPE_SET(m, M_HASHTYPE_OPAQUE); #endif if (!rxcd->no_csum) @@ -3002,7 +3002,8 @@ vmxnet3_txq_mq_start(struct ifnet *ifp, struct mbuf *m) sc = ifp->if_softc; ntxq = sc->vmx_ntxqueues; - if (m->m_flags & M_FLOWID) + /* check if flowid is set */ + if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) i = m->m_pkthdr.flowid % ntxq; else i = curcpu % ntxq; diff --git a/sys/dev/vxge/vxge.c b/sys/dev/vxge/vxge.c index b89ba6cca51e..9a3cab654f95 100644 --- a/sys/dev/vxge/vxge.c +++ b/sys/dev/vxge/vxge.c @@ -660,7 +660,7 @@ vxge_mq_send(ifnet_t ifp, mbuf_t m_head) if (vdev->config.tx_steering) { i = vxge_vpath_get(vdev, m_head); - } else if ((m_head->m_flags & M_FLOWID) != 0) { + } else if (M_HASHTYPE_GET(m_head) != M_HASHTYPE_NONE) { i = m_head->m_pkthdr.flowid % vdev->no_of_vpath; } @@ -1070,7 +1070,7 @@ vxge_rx_compl(vxge_hal_vpath_h vpath_handle, vxge_hal_rxd_h rxdh, vxge_rx_checksum(ext_info, mbuf_up); #if __FreeBSD_version >= 800000 - mbuf_up->m_flags |= M_FLOWID; + M_HASHTYPE_SET(mbuf_up, M_HASHTYPE_OPAQUE); mbuf_up->m_pkthdr.flowid = vpath->vp_index; #endif /* Post-Read sync for buffers */ diff --git a/sys/net/flowtable.c b/sys/net/flowtable.c index fe6a52cd3c10..0d584fea3581 100644 --- a/sys/net/flowtable.c +++ b/sys/net/flowtable.c @@ -688,8 +688,8 @@ flowtable_lookup(sa_family_t sa, struct mbuf *m, struct route *ro) if (fle == NULL) return (EHOSTUNREACH); - if (!(m->m_flags & M_FLOWID)) { - m->m_flags |= M_FLOWID; + if (M_HASHTYPE_GET(m) == M_HASHTYPE_NONE) { + M_HASHTYPE_SET(m, M_HASHTYPE_OPAQUE); m->m_pkthdr.flowid = fle->f_hash; } diff --git a/sys/net/ieee8023ad_lacp.c b/sys/net/ieee8023ad_lacp.c index 106df68e807a..75f6366e7888 100644 --- a/sys/net/ieee8023ad_lacp.c +++ b/sys/net/ieee8023ad_lacp.c @@ -835,7 +835,8 @@ lacp_select_tx_port(struct lagg_softc *sc, struct mbuf *m) return (NULL); } - if ((sc->sc_opts & LAGG_OPT_USE_FLOWID) && (m->m_flags & M_FLOWID)) + if ((sc->sc_opts & LAGG_OPT_USE_FLOWID) && + M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) hash = m->m_pkthdr.flowid >> sc->flowid_shift; else hash = lagg_hashmbuf(sc, m, lsc->lsc_hashkey); diff --git a/sys/net/if_lagg.c b/sys/net/if_lagg.c index 5c8b2e1d2bdf..45315b6b3b55 100644 --- a/sys/net/if_lagg.c +++ b/sys/net/if_lagg.c @@ -247,14 +247,14 @@ SYSCTL_INT(_net_link_lagg, OID_AUTO, failover_rx_all, CTLFLAG_RW | CTLFLAG_VNET, &VNET_NAME(lagg_failover_rx_all), 0, "Accept input from any interface in a failover lagg"); -/* Default value for using M_FLOWID */ +/* Default value for using flowid */ static VNET_DEFINE(int, def_use_flowid) = 1; #define V_def_use_flowid VNET(def_use_flowid) SYSCTL_INT(_net_link_lagg, OID_AUTO, default_use_flowid, CTLFLAG_RWTUN, &VNET_NAME(def_use_flowid), 0, "Default setting for using flow id for load sharing"); -/* Default value for using M_FLOWID */ +/* Default value for flowid shift */ static VNET_DEFINE(int, def_flowid_shift) = 16; #define V_def_flowid_shift VNET(def_flowid_shift) SYSCTL_INT(_net_link_lagg, OID_AUTO, default_flowid_shift, CTLFLAG_RWTUN, @@ -2148,7 +2148,8 @@ lagg_lb_start(struct lagg_softc *sc, struct mbuf *m) struct lagg_port *lp = NULL; uint32_t p = 0; - if ((sc->sc_opts & LAGG_OPT_USE_FLOWID) && (m->m_flags & M_FLOWID)) + if ((sc->sc_opts & LAGG_OPT_USE_FLOWID) && + M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) p = m->m_pkthdr.flowid >> sc->flowid_shift; else p = lagg_hashmbuf(sc, m, lb->lb_key); diff --git a/sys/net/if_lagg.h b/sys/net/if_lagg.h index e86ed06fcca7..8d6decd3c069 100644 --- a/sys/net/if_lagg.h +++ b/sys/net/if_lagg.h @@ -143,9 +143,9 @@ struct lagg_reqopts { int ro_opts; /* Option bitmap */ #define LAGG_OPT_NONE 0x00 -#define LAGG_OPT_USE_FLOWID 0x01 /* use M_FLOWID */ +#define LAGG_OPT_USE_FLOWID 0x01 /* enable use of flowid */ /* Pseudo flags which are used in ro_opts but not stored into sc_opts. */ -#define LAGG_OPT_FLOWIDSHIFT 0x02 /* Set flowid */ +#define LAGG_OPT_FLOWIDSHIFT 0x02 /* set flowid shift */ #define LAGG_OPT_FLOWIDSHIFT_MASK 0x1f /* flowid is uint32_t */ #define LAGG_OPT_LACP_STRICT 0x10 /* LACP strict mode */ #define LAGG_OPT_LACP_TXTEST 0x20 /* LACP debug: txtest */ diff --git a/sys/net/if_vxlan.c b/sys/net/if_vxlan.c index 5badf00051fd..59c76ebf4f1b 100644 --- a/sys/net/if_vxlan.c +++ b/sys/net/if_vxlan.c @@ -2236,6 +2236,7 @@ vxlan_pick_source_port(struct vxlan_softc *sc, struct mbuf *m) range = sc->vxl_max_port - sc->vxl_min_port + 1; + /* check if flowid is set and not opaque */ if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE && M_HASHTYPE_GET(m) != M_HASHTYPE_OPAQUE) hash = m->m_pkthdr.flowid; diff --git a/sys/net/netisr.c b/sys/net/netisr.c index 049bbf192b53..178c3cbd1479 100644 --- a/sys/net/netisr.c +++ b/sys/net/netisr.c @@ -682,12 +682,13 @@ netisr_select_cpuid(struct netisr_proto *npp, u_int dispatch_policy, } if (policy == NETISR_POLICY_FLOW) { - if (!(m->m_flags & M_FLOWID) && npp->np_m2flow != NULL) { + if (M_HASHTYPE_GET(m) == M_HASHTYPE_NONE && + npp->np_m2flow != NULL) { m = npp->np_m2flow(m, source); if (m == NULL) return (NULL); } - if (m->m_flags & M_FLOWID) { + if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) { *cpuidp = netisr_default_flow2cpu(m->m_pkthdr.flowid); return (m); diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index 04ed0b0bdf83..606795a69bb0 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -530,8 +530,8 @@ short inp_so_options(const struct inpcb *inp); #define INP_ONESBCAST 0x02000000 /* send all-ones broadcast */ #define INP_DROPPED 0x04000000 /* protocol drop flag */ #define INP_SOCKREF 0x08000000 /* strong socket reference */ -#define INP_SW_FLOWID 0x10000000 /* software generated flow id */ -#define INP_HW_FLOWID 0x20000000 /* hardware generated flow id */ +#define INP_RESERVED_0 0x10000000 /* reserved field */ +#define INP_RESERVED_1 0x20000000 /* reserved field */ #define IN6P_RFC2292 0x40000000 /* used RFC2292 API on the socket */ #define IN6P_MTU 0x80000000 /* receive path MTU */ diff --git a/sys/netinet/in_rss.c b/sys/netinet/in_rss.c index 7a548c2a8d2e..5d4f3c0dd37f 100644 --- a/sys/netinet/in_rss.c +++ b/sys/netinet/in_rss.c @@ -568,6 +568,8 @@ rss_mbuf_software_hash_v4(const struct mbuf *m, int dir, uint32_t *hashval, const struct ip *ip; const struct tcphdr *th; const struct udphdr *uh; + uint32_t flowid; + uint32_t flowtype; uint8_t proto; int iphlen; int is_frag = 0; @@ -617,12 +619,10 @@ rss_mbuf_software_hash_v4(const struct mbuf *m, int dir, uint32_t *hashval, * then we shouldn't just "trust" the 2-tuple hash. We need * a 4-tuple hash. */ - if (m->m_flags & M_FLOWID) { - uint32_t flowid, flowtype; - - flowid = m->m_pkthdr.flowid; - flowtype = M_HASHTYPE_GET(m); + flowid = m->m_pkthdr.flowid; + flowtype = M_HASHTYPE_GET(m); + if (flowtype != M_HASHTYPE_NONE) { switch (proto) { case IPPROTO_UDP: if ((rss_gethashconfig_local() & RSS_HASHTYPE_RSS_UDP_IPV4) && @@ -743,7 +743,6 @@ rss_soft_m2cpuid(struct mbuf *m, uintptr_t source, u_int *cpuid) /* hash was done; update */ m->m_pkthdr.flowid = hash_val; M_HASHTYPE_SET(m, hash_type); - m->m_flags |= M_FLOWID; *cpuid = rss_hash2cpuid(m->m_pkthdr.flowid, M_HASHTYPE_GET(m)); } else { /* ret < 0 */ /* no hash was done */ diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index d0229b2dccd1..7b8127e90dae 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -1196,7 +1196,6 @@ ip_reass(struct mbuf *m) if (rss_mbuf_software_hash_v4(m, 0, &rss_hash, &rss_type) == 0) { m->m_pkthdr.flowid = rss_hash; M_HASHTYPE_SET(m, rss_type); - m->m_flags |= M_FLOWID; } /* diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 5d791e57e99f..611c53c7e941 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -147,11 +147,9 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags, if (inp != NULL) { INP_LOCK_ASSERT(inp); M_SETFIB(m, inp->inp_inc.inc_fibnum); - if (((flags & IP_NODEFAULTFLOWID) == 0) && - inp->inp_flags & (INP_HW_FLOWID|INP_SW_FLOWID)) { + if ((flags & IP_NODEFAULTFLOWID) == 0) { m->m_pkthdr.flowid = inp->inp_flowid; M_HASHTYPE_SET(m, inp->inp_flowtype); - m->m_flags |= M_FLOWID; } } diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 005ccd05b3fa..e19d05ee318c 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -884,12 +884,10 @@ tcp_input(struct mbuf **mp, int *offp, int proto) goto dropwithreset; } INP_WLOCK_ASSERT(inp); - if (!(inp->inp_flags & INP_HW_FLOWID) - && (m->m_flags & M_FLOWID) - && ((inp->inp_socket == NULL) - || !(inp->inp_socket->so_options & SO_ACCEPTCONN))) { - inp->inp_flags |= INP_HW_FLOWID; - inp->inp_flags &= ~INP_SW_FLOWID; + if ((inp->inp_flowtype == M_HASHTYPE_NONE) && + (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) && + ((inp->inp_socket == NULL) || + (inp->inp_socket->so_options & SO_ACCEPTCONN) == 0)) { inp->inp_flowid = m->m_pkthdr.flowid; inp->inp_flowtype = M_HASHTYPE_GET(m); } diff --git a/sys/netinet/tcp_syncache.c b/sys/netinet/tcp_syncache.c index 05c50769531b..c7570e2a26d7 100644 --- a/sys/netinet/tcp_syncache.c +++ b/sys/netinet/tcp_syncache.c @@ -713,9 +713,7 @@ syncache_socket(struct syncache *sc, struct socket *lso, struct mbuf *m) * If there's an mbuf and it has a flowid, then let's initialise the * inp with that particular flowid. */ - if (m != NULL && m->m_flags & M_FLOWID) { - inp->inp_flags |= INP_HW_FLOWID; - inp->inp_flags &= ~INP_SW_FLOWID; + if (m != NULL && M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) { inp->inp_flowid = m->m_pkthdr.flowid; inp->inp_flowtype = M_HASHTYPE_GET(m); } diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index c4ef9f07f708..5fd93b3bcff9 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1106,8 +1106,7 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr, uint8_t pr; uint16_t cscov = 0; uint32_t flowid = 0; - int flowid_type = 0; - int use_flowid = 0; + uint8_t flowtype = M_HASHTYPE_NONE; /* * udp_output() may need to temporarily bind or connect the current @@ -1184,8 +1183,7 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr, error = EINVAL; break; } - flowid_type = *(uint32_t *) CMSG_DATA(cm); - use_flowid = 1; + flowtype = *(uint32_t *) CMSG_DATA(cm); break; #ifdef RSS @@ -1451,10 +1449,9 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr, * Once the UDP code decides to set a flowid some other way, * this allows the flowid to be overridden by userland. */ - if (use_flowid) { - m->m_flags |= M_FLOWID; + if (flowtype != M_HASHTYPE_NONE) { m->m_pkthdr.flowid = flowid; - M_HASHTYPE_SET(m, flowid_type); + M_HASHTYPE_SET(m, flowtype); #ifdef RSS } else { uint32_t hash_val, hash_type; @@ -1477,7 +1474,6 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr, if (rss_proto_software_hash_v4(faddr, laddr, fport, lport, pr, &hash_val, &hash_type) == 0) { m->m_pkthdr.flowid = hash_val; - m->m_flags |= M_FLOWID; M_HASHTYPE_SET(m, hash_type); } #endif diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c index 2a7b9dcf40f5..3b61849d4187 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -1252,7 +1252,7 @@ in6_pcblookup_mbuf(struct inpcbinfo *pcbinfo, struct in6_addr *faddr, * XXXRW: As above, that policy belongs in the pcbgroup code. */ if (in_pcbgroup_enabled(pcbinfo) && - !(M_HASHTYPE_TEST(m, M_HASHTYPE_NONE))) { + M_HASHTYPE_TEST(m, M_HASHTYPE_NONE) == 0) { pcbgroup = in6_pcbgroup_byhash(pcbinfo, M_HASHTYPE_GET(m), m->m_pkthdr.flowid); if (pcbgroup != NULL) diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index 4245a9fdb9e0..74d7483aa947 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -267,10 +267,10 @@ ip6_output(struct mbuf *m0, struct ip6_pktopts *opt, if (inp != NULL) { M_SETFIB(m, inp->inp_inc.inc_fibnum); - if (((flags & IP_NODEFAULTFLOWID) == 0) && - (inp->inp_flags & (INP_HW_FLOWID|INP_SW_FLOWID))) { + if ((flags & IP_NODEFAULTFLOWID) == 0) { + /* unconditionally set flowid */ m->m_pkthdr.flowid = inp->inp_flowid; - m->m_flags |= M_FLOWID; + M_HASHTYPE_SET(m, inp->inp_flowtype); } } diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c index 6c6f27a6e5d3..2b07b8e63fd9 100644 --- a/sys/netinet6/udp6_usrreq.c +++ b/sys/netinet6/udp6_usrreq.c @@ -843,7 +843,6 @@ udp6_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr6, */ #ifdef RSS m->m_pkthdr.flowid = rss_hash_ip6_2tuple(*faddr, *laddr); - m->m_flags |= M_FLOWID; M_HASHTYPE_SET(m, M_HASHTYPE_RSS_IPV6); #endif flags = 0; diff --git a/sys/ofed/drivers/net/mlx4/en_rx.c b/sys/ofed/drivers/net/mlx4/en_rx.c index 320462ec02ad..fa263266d67d 100644 --- a/sys/ofed/drivers/net/mlx4/en_rx.c +++ b/sys/ofed/drivers/net/mlx4/en_rx.c @@ -604,7 +604,7 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud } mb->m_pkthdr.flowid = cq->ring; - mb->m_flags |= M_FLOWID; + M_HASHTYPE_SET(mb, M_HASHTYPE_OPAQUE); mb->m_pkthdr.rcvif = dev; if (be32_to_cpu(cqe->vlan_my_qpn) & MLX4_CQE_VLAN_PRESENT_MASK) { diff --git a/sys/ofed/drivers/net/mlx4/en_tx.c b/sys/ofed/drivers/net/mlx4/en_tx.c index d1931558bcc9..d92677fa5ce3 100644 --- a/sys/ofed/drivers/net/mlx4/en_tx.c +++ b/sys/ofed/drivers/net/mlx4/en_tx.c @@ -720,8 +720,11 @@ u16 mlx4_en_select_queue(struct net_device *dev, struct mbuf *mb) up = (vlan_tag >> 13); } - /* hash mbuf */ - queue_index = mlx4_en_hashmbuf(MLX4_F_HASHL3 | MLX4_F_HASHL4, mb, hashrandom); + /* check if flowid is set */ + if (M_HASHTYPE_GET(mb) != M_HASHTYPE_NONE) + queue_index = mb->m_pkthdr.flowid; + else + queue_index = mlx4_en_hashmbuf(MLX4_F_HASHL3 | MLX4_F_HASHL4, mb, hashrandom); return ((queue_index % rings_p_up) + (up * rings_p_up)); } @@ -1066,15 +1069,11 @@ mlx4_en_transmit(struct ifnet *dev, struct mbuf *m) struct mlx4_en_priv *priv = netdev_priv(dev); struct mlx4_en_tx_ring *ring; struct mlx4_en_cq *cq; - int i = 0, err = 0; + int i, err = 0; + + /* Compute which queue to use */ + i = mlx4_en_select_queue(dev, m); - /* Which queue to use */ - if ((m->m_flags & (M_FLOWID | M_VLANTAG)) == M_FLOWID) { - i = m->m_pkthdr.flowid % (priv->tx_ring_num - 1); - } - else { - i = mlx4_en_select_queue(dev, m); - } ring = priv->tx_ring[i]; if (spin_trylock(&ring->tx_lock)) { diff --git a/sys/sys/param.h b/sys/sys/param.h index 1afd4ea3e920..3d97bef5266b 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1100047 /* Master, propagated to newvers */ +#define __FreeBSD_version 1100048 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From e27961a496322e2590da29f3c5fe710b269e6754 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Mon, 1 Dec 2014 12:17:42 +0000 Subject: [PATCH 16/94] Allow load_rc_config to be called without a service name. MFC after: 1 week --- etc/rc.subr | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/etc/rc.subr b/etc/rc.subr index 6534f6858f65..7b1e38737c10 100644 --- a/etc/rc.subr +++ b/etc/rc.subr @@ -1315,9 +1315,6 @@ load_rc_config() { local _name _rcvar_val _var _defval _v _msg _new _d _name=$1 - if [ -z "$_name" ]; then - err 3 'USAGE: load_rc_config name' - fi if ${_rc_conf_loaded:-false}; then : @@ -1333,20 +1330,24 @@ load_rc_config() _rc_conf_loaded=true fi - for _d in /etc ${local_startup%*/rc.d}; do - if [ -f ${_d}/rc.conf.d/"$_name" ]; then - debug "Sourcing ${_d}/rc.conf.d/$_name" - . ${_d}/rc.conf.d/"$_name" - elif [ -d ${_d}/rc.conf.d/"$_name" ] ; then - local _rc - for _rc in ${_d}/rc.conf.d/"$_name"/* ; do - if [ -f "$_rc" ] ; then - debug "Sourcing $_rc" - . "$_rc" - fi - done - fi - done + # If a service name was specified, attempt to load + # service-specific configuration + if [ -n "$_name" ] ; then + for _d in /etc ${local_startup%*/rc.d}; do + if [ -f ${_d}/rc.conf.d/"$_name" ]; then + debug "Sourcing ${_d}/rc.conf.d/$_name" + . ${_d}/rc.conf.d/"$_name" + elif [ -d ${_d}/rc.conf.d/"$_name" ] ; then + local _rc + for _rc in ${_d}/rc.conf.d/"$_name"/* ; do + if [ -f "$_rc" ] ; then + debug "Sourcing $_rc" + . "$_rc" + fi + done + fi + done + fi # Set defaults if defined. for _var in $rcvar $rcvars; do From cd06771f0c1b1ab57a433c594426b61f124e7ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Mon, 1 Dec 2014 12:29:59 +0000 Subject: [PATCH 17/94] The early-late divider was originally set to mountcritlocal. Since that service does not run in jails, it was necessary to change it to something else when jailed, and NETWORKING was arbitrarily chosen. The divider was later moved to FILESYSTEMS when it was introduced, but the logic to change it to NETWORKING when jailed remained. Remove it, as it no longer serves any purpose. PR: 194975 MFC after: 1 week --- etc/rc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/etc/rc b/etc/rc index 21efc18c8a73..4efc293b6b2b 100644 --- a/etc/rc +++ b/etc/rc @@ -69,19 +69,16 @@ fi # and to make the configuration file variables available to rc itself. # . /etc/rc.subr -load_rc_config 'XXX' +load_rc_config # If we receive a SIGALRM, re-source /etc/rc.conf; this allows rc.d # scripts to perform "boot-time configuration" including enabling and # disabling rc.d scripts which appear later in the boot order. -trap "_rc_conf_loaded=false; load_rc_config 'XXX'" ALRM +trap "_rc_conf_loaded=false; load_rc_config" ALRM skip="-s nostart" if [ `/sbin/sysctl -n security.jail.jailed` -eq 1 ]; then skip="$skip -s nojail" - if [ "$early_late_divider" = "FILESYSTEMS" ]; then - early_late_divider=NETWORKING - fi if [ `/sbin/sysctl -n security.jail.vnet` -ne 1 ]; then skip="$skip -s nojailvnet" fi From 5d083d287bf3fa03e14c5ffcd3fbfe203c6c371f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Mon, 1 Dec 2014 12:59:16 +0000 Subject: [PATCH 18/94] Disable the vxlan code until the people reponsible for it can come up with new command names that don't conflict with existing commands. Pointy hat to: bryanv --- sbin/ifconfig/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbin/ifconfig/Makefile b/sbin/ifconfig/Makefile index 885f8a9922bd..572c0613904c 100644 --- a/sbin/ifconfig/Makefile +++ b/sbin/ifconfig/Makefile @@ -30,7 +30,7 @@ SRCS+= ifmac.c # MAC support SRCS+= ifmedia.c # SIOC[GS]IFMEDIA support SRCS+= iffib.c # non-default FIB support SRCS+= ifvlan.c # SIOC[GS]ETVLAN support -SRCS+= ifvxlan.c # VXLAN support +#SRCS+= ifvxlan.c # VXLAN support SRCS+= ifgre.c # GRE keys etc SRCS+= ifgif.c # GIF reversed header workaround From 7511bd04e4d18a30c52ad52b9f078e148b6ae629 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Mon, 1 Dec 2014 13:55:45 +0000 Subject: [PATCH 19/94] Move ctlfe_onoffline() out of lock to let it sleep when needed. Do some more other polishing while there. MFC after: 2 weeks --- sys/cam/ctl/scsi_ctl.c | 41 +++++++++-------------------------------- 1 file changed, 9 insertions(+), 32 deletions(-) diff --git a/sys/cam/ctl/scsi_ctl.c b/sys/cam/ctl/scsi_ctl.c index 62aa74485ce0..a1f39d287daa 100644 --- a/sys/cam/ctl/scsi_ctl.c +++ b/sys/cam/ctl/scsi_ctl.c @@ -622,6 +622,9 @@ ctlferegister(struct cam_periph *periph, void *arg) "notify CCBs, status 0x%x\n", __func__, status); return (CAM_REQ_CMP_ERR); } + mtx_lock(&bus_softc->lun_softc_mtx); + STAILQ_INSERT_TAIL(&bus_softc->lun_softc_list, softc, links); + mtx_unlock(&bus_softc->lun_softc_mtx); return (CAM_REQ_CMP); } @@ -1573,12 +1576,7 @@ ctlfe_onoffline(void *arg, int online) printf("%s: unable to create path!\n", __func__); return; } - ccb = (union ccb *)malloc(sizeof(*ccb), M_TEMP, M_NOWAIT | M_ZERO); - if (ccb == NULL) { - printf("%s: unable to malloc CCB!\n", __func__); - xpt_free_path(path); - return; - } + ccb = xpt_alloc_ccb(); xpt_setup_ccb(&ccb->ccb_h, path, CAM_PRIORITY_NONE); /* @@ -1711,10 +1709,7 @@ ctlfe_onoffline(void *arg, int online) } xpt_free_path(path); - - free(ccb, M_TEMP); - - return; + xpt_free_ccb(ccb); } static void @@ -1740,14 +1735,7 @@ ctlfe_online(void *arg) return; } - lun_softc = malloc(sizeof(*lun_softc), M_CTLFE, - M_NOWAIT | M_ZERO); - if (lun_softc == NULL) { - xpt_print(path, "%s: unable to allocate softc for " - "wildcard periph\n", __func__); - xpt_free_path(path); - return; - } + lun_softc = malloc(sizeof(*lun_softc), M_CTLFE, M_WAITOK | M_ZERO); xpt_path_lock(path); periph = cam_periph_find(path, "ctl"); @@ -1780,14 +1768,10 @@ ctlfe_online(void *arg) "cam_periph_alloc()\n", __func__, (entry != NULL) ? entry->status_text : "Unknown", status); free(lun_softc, M_CTLFE); - } else { - mtx_lock(&bus_softc->lun_softc_mtx); - STAILQ_INSERT_TAIL(&bus_softc->lun_softc_list, lun_softc, links); - mtx_unlock(&bus_softc->lun_softc_mtx); - ctlfe_onoffline(arg, /*online*/ 1); } xpt_path_unlock(path); + ctlfe_onoffline(arg, /*online*/ 1); xpt_free_path(path); } @@ -1801,6 +1785,8 @@ ctlfe_offline(void *arg) bus_softc = (struct ctlfe_softc *)arg; + ctlfe_onoffline(arg, /*online*/ 0); + /* * Disable the wildcard LUN for this port now that we have taken * the port offline. @@ -1813,14 +1799,9 @@ ctlfe_offline(void *arg) __func__); return; } - xpt_path_lock(path); - - ctlfe_onoffline(arg, /*online*/ 0); - if ((periph = cam_periph_find(path, "ctl")) != NULL) cam_periph_invalidate(periph); - xpt_path_unlock(path); xpt_free_path(path); } @@ -1881,10 +1862,6 @@ ctlfe_lun_enable(void *arg, struct ctl_id targ_id, int lun_id) "cam_periph_alloc()\n", __func__, (entry != NULL) ? entry->status_text : "Unknown", status); free(softc, M_CTLFE); - } else { - mtx_lock(&bus_softc->lun_softc_mtx); - STAILQ_INSERT_TAIL(&bus_softc->lun_softc_list, softc, links); - mtx_unlock(&bus_softc->lun_softc_mtx); } xpt_path_unlock(path); From 15ad7a7c3965edfdaf06028724740340ecef2ca6 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Mon, 1 Dec 2014 15:02:49 +0000 Subject: [PATCH 20/94] Pull in r209785 from upstream libc++ trunk (by Marshall Clow): Fix a problem exposed by r208825, which caused bind (and other bits of libc++) to stop working. And tests This fix is needed to support clang 3.5.0 and higher, which are more strict about forming pointer-to-function types with cv-qualifiers or ref-qualifiers. See also the upstream PR and Reported by: amdmi3 MFC after: 3 days --- contrib/libc++/include/type_traits | 66 ++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 7 deletions(-) diff --git a/contrib/libc++/include/type_traits b/contrib/libc++/include/type_traits index 00492b1e87c2..0f31e9371c25 100644 --- a/contrib/libc++/include/type_traits +++ b/contrib/libc++/include/type_traits @@ -439,8 +439,26 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_function // is_member_function_pointer -template struct __libcpp_is_member_function_pointer : public false_type {}; -template struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {}; +// template struct __libcpp_is_member_function_pointer : public false_type {}; +// template struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {}; +// + +template +struct __member_pointer_traits_imp +{ // forward declaration; specializations later +}; + + +namespace __libcpp_is_member_function_pointer_imp { + template + char __test(typename std::__member_pointer_traits_imp<_Tp, true, false>::_FnType *); + + template + std::__two __test(...); +}; + +template struct __libcpp_is_member_function_pointer + : public integral_constant(nullptr)) == 1> {}; template struct _LIBCPP_TYPE_VIS_ONLY is_member_function_pointer : public __libcpp_is_member_function_pointer::type> {}; @@ -1593,11 +1611,6 @@ __decay_copy(const _Tp& __t) #endif -template -struct __member_pointer_traits_imp -{ -}; - #ifndef _LIBCPP_HAS_NO_VARIADICS template @@ -1605,6 +1618,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false> { typedef _Class _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param...); }; template @@ -1612,6 +1626,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false { typedef _Class const _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param...); }; template @@ -1619,6 +1634,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, fa { typedef _Class volatile _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param...); }; template @@ -1626,6 +1642,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, tr { typedef _Class const volatile _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param...); }; #if __has_feature(cxx_reference_qualified_functions) @@ -1635,6 +1652,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false> { typedef _Class& _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param...); }; template @@ -1642,6 +1660,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, fals { typedef _Class const& _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param...); }; template @@ -1649,6 +1668,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, f { typedef _Class volatile& _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param...); }; template @@ -1656,6 +1676,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, t { typedef _Class const volatile& _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param...); }; template @@ -1663,6 +1684,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false> { typedef _Class&& _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param...); }; template @@ -1670,6 +1692,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, fal { typedef _Class const&& _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param...); }; template @@ -1677,6 +1700,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, { typedef _Class volatile&& _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param...); }; template @@ -1684,6 +1708,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, { typedef _Class const volatile&& _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param...); }; #endif // __has_feature(cxx_reference_qualified_functions) @@ -1695,6 +1720,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false> { typedef _Class _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (); }; template @@ -1702,6 +1728,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false> { typedef _Class _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0); }; template @@ -1709,6 +1736,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false> { typedef _Class _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0, _P1); }; template @@ -1716,6 +1744,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false> { typedef _Class _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0, _P1, _P2); }; template @@ -1723,6 +1752,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false> { typedef _Class const _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (); }; template @@ -1730,6 +1760,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false> { typedef _Class const _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0); }; template @@ -1737,6 +1768,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false> { typedef _Class const _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0, _P1); }; template @@ -1744,6 +1776,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, f { typedef _Class const _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0, _P1, _P2); }; template @@ -1751,6 +1784,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false> { typedef _Class volatile _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (); }; template @@ -1758,6 +1792,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false> { typedef _Class volatile _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0); }; template @@ -1765,6 +1800,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, fal { typedef _Class volatile _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0, _P1); }; template @@ -1772,6 +1808,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true { typedef _Class volatile _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0, _P1, _P2); }; template @@ -1779,6 +1816,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false { typedef _Class const volatile _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (); }; template @@ -1786,6 +1824,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, fa { typedef _Class const volatile _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0); }; template @@ -1793,6 +1832,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, tru { typedef _Class const volatile _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0, _P1); }; template @@ -1800,6 +1840,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile { typedef _Class const volatile _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0, _P1, _P2); }; #endif // _LIBCPP_HAS_NO_VARIADICS @@ -1819,6 +1860,7 @@ struct __member_pointer_traits { // typedef ... _ClassType; // typedef ... _ReturnType; +// typedef ... _FnType; }; // result_of @@ -2526,6 +2568,15 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible // is_nothrow_constructible +#if 0 +template +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible + : public integral_constant +{ +}; + +#else + #ifndef _LIBCPP_HAS_NO_VARIADICS #if __has_feature(cxx_noexcept) @@ -2664,6 +2715,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&, }; #endif // _LIBCPP_HAS_NO_VARIADICS +#endif // __has_feature(is_nothrow_constructible) // is_nothrow_default_constructible From fa91cabfbd3a35907c57f7207046398ae91d994a Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Mon, 1 Dec 2014 15:21:54 +0000 Subject: [PATCH 21/94] When passing LUN IDs through treat ASCII values as fixed-length, not interpreating NULLs as EOLs, but converting them to spaces. SPC-4 does not tell that T10-based IDs should be NULL-terminated/padded. And while it tells that it should include only ASCII chars (0x20-0x7F), there are some USB sticks (SanDisk Ultra Fit), that have NULLs inside the value. Treating NULLs as EOLs there made those LUN IDs non-unique. MFC after: 1 week --- sys/cam/cam_xpt.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c index 3a3ccc74edbc..36f22145146e 100644 --- a/sys/cam/cam_xpt.c +++ b/sys/cam/cam_xpt.c @@ -1136,8 +1136,15 @@ xpt_getattr(char *buf, size_t len, const char *attr, struct cam_path *path) if (idd == NULL) goto out; ret = 0; - if ((idd->proto_codeset & SVPD_ID_CODESET_MASK) == SVPD_ID_CODESET_ASCII || - (idd->proto_codeset & SVPD_ID_CODESET_MASK) == SVPD_ID_CODESET_UTF8) { + if ((idd->proto_codeset & SVPD_ID_CODESET_MASK) == SVPD_ID_CODESET_ASCII) { + if (idd->length < len) { + for (l = 0; l < idd->length; l++) + buf[l] = idd->identifier[l] ? + idd->identifier[l] : ' '; + buf[l] = 0; + } else + ret = EFAULT; + } else if ((idd->proto_codeset & SVPD_ID_CODESET_MASK) == SVPD_ID_CODESET_UTF8) { l = strnlen(idd->identifier, idd->length); if (l < len) { bcopy(idd->identifier, buf, l); From 50f69bfbd6ffaf716d0822c0e47354c3319a83c2 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Mon, 1 Dec 2014 16:07:31 +0000 Subject: [PATCH 22/94] Fix elftoolchain tools in-tree build * make variables static * add header for uint*_t typedefs --- contrib/elftoolchain/elfcopy/ascii.c | 1 + contrib/elftoolchain/elfcopy/segments.c | 1 + contrib/elftoolchain/libelftc/libelftc_dem_gnu3.c | 2 +- contrib/elftoolchain/nm/nm.c | 2 +- contrib/elftoolchain/strings/strings.c | 6 +++--- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/contrib/elftoolchain/elfcopy/ascii.c b/contrib/elftoolchain/elfcopy/ascii.c index 968e5c667f63..261180eb67d2 100644 --- a/contrib/elftoolchain/elfcopy/ascii.c +++ b/contrib/elftoolchain/elfcopy/ascii.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include diff --git a/contrib/elftoolchain/elfcopy/segments.c b/contrib/elftoolchain/elfcopy/segments.c index c54cbfcbb07a..853c728e8f37 100644 --- a/contrib/elftoolchain/elfcopy/segments.c +++ b/contrib/elftoolchain/elfcopy/segments.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include diff --git a/contrib/elftoolchain/libelftc/libelftc_dem_gnu3.c b/contrib/elftoolchain/libelftc/libelftc_dem_gnu3.c index bd54f549ddb8..0179890d264d 100644 --- a/contrib/elftoolchain/libelftc/libelftc_dem_gnu3.c +++ b/contrib/elftoolchain/libelftc/libelftc_dem_gnu3.c @@ -156,7 +156,7 @@ static int vector_type_qualifier_init(struct vector_type_qualifier *); static int vector_type_qualifier_push(struct vector_type_qualifier *, enum type_qualifier); -int cpp_demangle_gnu3_push_head; +static int cpp_demangle_gnu3_push_head; /** * @brief Decode the input string by IA-64 C++ ABI style. diff --git a/contrib/elftoolchain/nm/nm.c b/contrib/elftoolchain/nm/nm.c index 6c10e0dbf586..906a50c309f1 100644 --- a/contrib/elftoolchain/nm/nm.c +++ b/contrib/elftoolchain/nm/nm.c @@ -65,7 +65,7 @@ typedef void (*fn_sym_print)(const GElf_Sym *); typedef int (*fn_filter)(char, const GElf_Sym *, const char *); /* output filter list */ -SLIST_HEAD(filter_head, filter_entry) nm_out_filter = +static SLIST_HEAD(filter_head, filter_entry) nm_out_filter = SLIST_HEAD_INITIALIZER(nm_out_filter); struct filter_entry { diff --git a/contrib/elftoolchain/strings/strings.c b/contrib/elftoolchain/strings/strings.c index c936d5c5374f..e8972e7b5ab4 100644 --- a/contrib/elftoolchain/strings/strings.c +++ b/contrib/elftoolchain/strings/strings.c @@ -75,9 +75,9 @@ enum encoding_style { (encoding == ENCODING_8BIT && (c) > 127))) -int encoding_size, entire_file, min_len, show_filename, show_loc; -enum encoding_style encoding; -enum radix_style radix; +static int encoding_size, entire_file, min_len, show_filename, show_loc; +static enum encoding_style encoding; +static enum radix_style radix; static struct option strings_longopts[] = { { "all", no_argument, NULL, 'a'}, From 310b1572efcc0e12e6c548c2fb9b928e145e5150 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Mon, 1 Dec 2014 16:10:03 +0000 Subject: [PATCH 23/94] Temporarily disable non-FreeBSD NT_ note types --- contrib/elftoolchain/size/size.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/contrib/elftoolchain/size/size.c b/contrib/elftoolchain/size/size.c index c5c5b64cb0d0..0d4de422b65d 100644 --- a/contrib/elftoolchain/size/size.c +++ b/contrib/elftoolchain/size/size.c @@ -269,7 +269,7 @@ handle_core_note(Elf *elf, GElf_Ehdr *elfhdr, GElf_Phdr *phdr, static pid_t pid; uintptr_t ver; Elf32_Nhdr *nhdr, nhdr_l; - static int reg_pseudo = 0, reg2_pseudo = 0, regxfp_pseudo = 0; + static int reg_pseudo = 0, reg2_pseudo = 0 /*, regxfp_pseudo = 0*/; char buf[BUF_SIZE], *data, *name; if (elf == NULL || elfhdr == NULL || phdr == NULL) @@ -360,6 +360,7 @@ handle_core_note(Elf *elf, GElf_Ehdr *elfhdr, GElf_Phdr *phdr, text_size_total += nhdr_l.n_descsz; } break; +#if 0 case NT_AUXV: if (style == STYLE_SYSV) { tbl_append(); @@ -390,6 +391,7 @@ handle_core_note(Elf *elf, GElf_Ehdr *elfhdr, GElf_Phdr *phdr, } break; case NT_PSINFO: +#endif case NT_PRPSINFO: { /* FreeBSD 64-bit */ if (nhdr_l.n_descsz == 0x78 && @@ -415,8 +417,10 @@ handle_core_note(Elf *elf, GElf_Ehdr *elfhdr, GElf_Phdr *phdr, } break; } +#if 0 case NT_PSTATUS: case NT_LWPSTATUS: +#endif default: break; } From 257d0dda42c3ee988dd310dae5801bc0ff443538 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Mon, 1 Dec 2014 16:10:44 +0000 Subject: [PATCH 24/94] Track libarchive API change --- contrib/elftoolchain/elfcopy/archive.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/contrib/elftoolchain/elfcopy/archive.c b/contrib/elftoolchain/elfcopy/archive.c index a4f8017989ba..3fd2e857d3d0 100644 --- a/contrib/elftoolchain/elfcopy/archive.c +++ b/contrib/elftoolchain/elfcopy/archive.c @@ -350,12 +350,12 @@ ac_detect_ar(int ifd) r = -1; if ((a = archive_read_new()) == NULL) return (0); - archive_read_support_compression_none(a); + archive_read_support_filter_none(a); archive_read_support_format_ar(a); if (archive_read_open_fd(a, ifd, 10240) == ARCHIVE_OK) r = archive_read_next_header(a, &entry); archive_read_close(a); - archive_read_finish(a); + archive_read_free(a); return (r == ARCHIVE_OK); } @@ -386,7 +386,7 @@ ac_read_objs(struct elfcopy *ecp, int ifd) err(EXIT_FAILURE, "lseek failed"); if ((a = archive_read_new()) == NULL) errx(EXIT_FAILURE, "%s", archive_error_string(a)); - archive_read_support_compression_none(a); + archive_read_support_filter_none(a); archive_read_support_format_ar(a); AC(archive_read_open_fd(a, ifd, 10240)); for(;;) { @@ -435,7 +435,7 @@ ac_read_objs(struct elfcopy *ecp, int ifd) } } AC(archive_read_close(a)); - ACV(archive_read_finish(a)); + ACV(archive_read_free(a)); } static void @@ -449,7 +449,7 @@ ac_write_objs(struct elfcopy *ecp, int ofd) if ((a = archive_write_new()) == NULL) errx(EXIT_FAILURE, "%s", archive_error_string(a)); archive_write_set_format_ar_svr4(a); - archive_write_set_compression_none(a); + archive_write_add_filter_none(a); AC(archive_write_open_fd(a, ofd)); /* Write the archive symbol table, even if it's empty. */ @@ -491,7 +491,7 @@ ac_write_objs(struct elfcopy *ecp, int ofd) } AC(archive_write_close(a)); - ACV(archive_write_finish(a)); + ACV(archive_write_free(a)); } static void From 6afb32fc67fa07a0cae683ef3fffe318e1e983df Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Mon, 1 Dec 2014 17:36:10 +0000 Subject: [PATCH 25/94] Disable recursion for the process spinlock. Tested by: pho Discussed with: jhb Sponsored by: The FreeBSD Foundation MFC after: 1 month --- sys/kern/kern_mutex.c | 2 +- sys/kern/kern_proc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c index e1469b7a00c9..d21be50c3c95 100644 --- a/sys/kern/kern_mutex.c +++ b/sys/kern/kern_mutex.c @@ -968,7 +968,7 @@ mutex_init(void) mtx_init(&blocked_lock, "blocked lock", NULL, MTX_SPIN); blocked_lock.mtx_lock = 0xdeadc0de; /* Always blocked. */ mtx_init(&proc0.p_mtx, "process lock", NULL, MTX_DEF | MTX_DUPOK); - mtx_init(&proc0.p_slock, "process slock", NULL, MTX_SPIN | MTX_RECURSE); + mtx_init(&proc0.p_slock, "process slock", NULL, MTX_SPIN); mtx_init(&proc0.p_statmtx, "pstatl", NULL, MTX_SPIN); mtx_init(&proc0.p_itimmtx, "pitiml", NULL, MTX_SPIN); mtx_init(&proc0.p_profmtx, "pprofl", NULL, MTX_SPIN); diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index 009ccceb79e0..b6ac876ab597 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -227,7 +227,7 @@ proc_init(void *mem, int size, int flags) p->p_sched = (struct p_sched *)&p[1]; bzero(&p->p_mtx, sizeof(struct mtx)); mtx_init(&p->p_mtx, "process lock", NULL, MTX_DEF | MTX_DUPOK); - mtx_init(&p->p_slock, "process slock", NULL, MTX_SPIN | MTX_RECURSE); + mtx_init(&p->p_slock, "process slock", NULL, MTX_SPIN); mtx_init(&p->p_statmtx, "pstatl", NULL, MTX_SPIN); mtx_init(&p->p_itimmtx, "pitiml", NULL, MTX_SPIN); mtx_init(&p->p_profmtx, "pprofl", NULL, MTX_SPIN); From 31942939034ecc9586d0e44f1c9ce30d0816dca9 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Mon, 1 Dec 2014 17:49:42 +0000 Subject: [PATCH 26/94] Build infrastructure for elftoolchain tools Set WITH_ELFTOOLCHAIN_TOOLS in src.conf to use the elftoolchain version of the following tools: * addr2line * elfcopy (strip / mcs) * nm * size * strings Reviewed by: bapt (earlier version) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D1224 --- Makefile.inc1 | 12 +++++++++ gnu/usr.bin/binutils/Makefile | 20 ++++++++++---- lib/Makefile | 5 ++++ lib/libelftc/Makefile | 30 +++++++++++++++++++++ lib/libelftc/elftc_version.c | 10 +++++++ share/mk/src.libnames.mk | 5 ++++ share/mk/src.opts.mk | 1 + tools/build/options/WITH_ELFTOOLCHAIN_TOOLS | 9 +++++++ usr.bin/Makefile | 15 ++++++++++- usr.bin/addr2line/Makefile | 16 +++++++++++ usr.bin/elfcopy/Makefile | 24 +++++++++++++++++ usr.bin/nm/Makefile | 16 +++++++++++ usr.bin/size/Makefile | 16 +++++++++++ usr.bin/strings/Makefile | 15 +++++++++++ 14 files changed, 188 insertions(+), 6 deletions(-) create mode 100644 lib/libelftc/Makefile create mode 100644 lib/libelftc/elftc_version.c create mode 100644 tools/build/options/WITH_ELFTOOLCHAIN_TOOLS create mode 100644 usr.bin/addr2line/Makefile create mode 100644 usr.bin/elfcopy/Makefile create mode 100644 usr.bin/nm/Makefile create mode 100644 usr.bin/size/Makefile create mode 100644 usr.bin/strings/Makefile diff --git a/Makefile.inc1 b/Makefile.inc1 index 7d828ec9d081..ee7fc519bcf4 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -1415,6 +1415,14 @@ _kgzip= usr.sbin/kgzip # If we're given an XAS, don't build binutils. .if ${XAS:M/*} == "" && ${MK_BINUTILS_BOOTSTRAP} != "no" _binutils= gnu/usr.bin/binutils +.if ${MK_ELFTOOLCHAIN_TOOLS} != "no" +_elftctools= lib/libelftc \ + usr.bin/addr2line \ + usr.bin/elfcopy \ + usr.bin/nm \ + usr.bin/size \ + usr.bin/strings +.endif .endif # If an full path to an external cross compiler is given, don't build @@ -1434,6 +1442,7 @@ cross-tools: .MAKE ${_clang_libs} \ ${_clang} \ ${_binutils} \ + ${_elftctools} \ ${_cc} \ usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \ ${_btxld} \ @@ -1491,6 +1500,7 @@ native-xtools: .MAKE ${_clang_tblgen} \ usr.bin/ar \ ${_binutils} \ + ${_elftctools} \ ${_cc} \ ${_gcc_tools} \ ${_clang_libs} \ @@ -2045,6 +2055,7 @@ _xb-build-tools: _xb-cross-tools: .for _tool in \ ${_binutils} \ + ${_elftctools} \ usr.bin/ar \ ${_clang_libs} \ ${_clang} \ @@ -2077,6 +2088,7 @@ _xi-cross-tools: @echo "_xi-cross-tools" .for _tool in \ ${_binutils} \ + ${_elftctools} \ usr.bin/ar \ ${_clang_libs} \ ${_clang} \ diff --git a/gnu/usr.bin/binutils/Makefile b/gnu/usr.bin/binutils/Makefile index a544bc54b32d..9dac24403520 100644 --- a/gnu/usr.bin/binutils/Makefile +++ b/gnu/usr.bin/binutils/Makefile @@ -1,19 +1,29 @@ # $FreeBSD$ +.include + SUBDIR= libiberty \ libbfd \ libopcodes \ libbinutils \ - addr2line \ + ${_addr2line} \ as \ ld \ - nm \ + ${_nm} \ objcopy \ objdump \ readelf \ - size \ - strings \ - strip \ + ${_size} \ + ${_strings} \ + ${_strip} \ doc + +.if ${MK_ELFTOOLCHAIN_TOOLS} == "no" +_addr2line= addr2line +_nm= nm +_size= size +_strings= strings +_strip= strip +.endif .include diff --git a/lib/Makefile b/lib/Makefile index d87b32e91883..8bd565385ef0 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -45,6 +45,7 @@ SUBDIR= ${SUBDIR_ORDERED} \ libdpv \ libdwarf \ libedit \ + ${_libelftc} \ ${_libevent} \ libexecinfo \ libexpat \ @@ -190,6 +191,10 @@ _clang= clang _cuse= libcuse .endif +.if ${MK_ELFTOOLCHAIN_TOOLS} != "no" +_libelftc= libelftc +.endif + .if ${MK_GPIB} != "no" _libgpib= libgpib .endif diff --git a/lib/libelftc/Makefile b/lib/libelftc/Makefile new file mode 100644 index 000000000000..ccae1a554313 --- /dev/null +++ b/lib/libelftc/Makefile @@ -0,0 +1,30 @@ +# $FreeBSD$ +.include + +INTERNALLIB= + +ELFTCDIR= ${.CURDIR}/../../contrib/elftoolchain + +.PATH: ${ELFTCDIR}/libelftc + +LIB= elftc + +SRCS= elftc_bfdtarget.c \ + elftc_copyfile.c \ + elftc_demangle.c \ + elftc_set_timestamps.c \ + elftc_string_table.c \ + elftc_version.c \ + libelftc_bfdtarget.c \ + libelftc_dem_arm.c \ + libelftc_dem_gnu2.c \ + libelftc_dem_gnu3.c \ + libelftc_hash.c \ + libelftc_vstr.c + +INCS= libelftc.h +CFLAGS+=-I${ELFTCDIR}/libelftc -I${ELFTCDIR}/common + +NO_MAN= yes + +.include diff --git a/lib/libelftc/elftc_version.c b/lib/libelftc/elftc_version.c new file mode 100644 index 000000000000..f04781fe2b2c --- /dev/null +++ b/lib/libelftc/elftc_version.c @@ -0,0 +1,10 @@ +/* $FreeBSD$ */ + +#include +#include + +const char * +elftc_version(void) +{ + return "libelftc r2974"; +} diff --git a/share/mk/src.libnames.mk b/share/mk/src.libnames.mk index 094897d06a1f..60f395bc2c47 100644 --- a/share/mk/src.libnames.mk +++ b/share/mk/src.libnames.mk @@ -27,6 +27,7 @@ _INTERNALIBS= \ amu \ bsnmptools \ cron \ + elftc \ event \ fifolog \ ipf \ @@ -286,6 +287,10 @@ LIBATF_CXX?= ${LIBATF_CXXDIR}/libatf-c++.a LIBBSDSTATDIR= ${ROOTOBJDIR}/lib/libbsdstat LIBBSDSTAT?= ${LIBBSDSTATDIR}/libbsdstat.a +LIBELFTCDIR= ${ROOTOBJDIR}/lib/libelftc +LDELFTC?= ${LIBELFTCDIR}/libelftc.a +LIBELFTC?= ${LIBELFTCDIR}/libelftc.a + LIBEVENTDIR= ${ROOTOBJDIR}/lib/libevent LIBEVENT?= ${LIBEVENTDIR}/libevent.a diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index 87c0f9998cd7..024bb9165f84 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -160,6 +160,7 @@ __DEFAULT_NO_OPTIONS = \ BSD_GREP \ CLANG_EXTRAS \ EISA \ + ELFTOOLCHAIN_TOOLS \ FMAKE \ HESIOD \ LLDB \ diff --git a/tools/build/options/WITH_ELFTOOLCHAIN_TOOLS b/tools/build/options/WITH_ELFTOOLCHAIN_TOOLS new file mode 100644 index 000000000000..1d6197851d7f --- /dev/null +++ b/tools/build/options/WITH_ELFTOOLCHAIN_TOOLS @@ -0,0 +1,9 @@ +.\" $FreeBSD$ +Set to use +.Xr addr2line 1 , +.Xr nm 1 , +.Xr size 1 , +.Xr strings 1 , +and +.Xr strip 1 +from the elftoolchain project instead of GNU binutils. diff --git a/usr.bin/Makefile b/usr.bin/Makefile index 298903e5e5b9..88628fb0611d 100644 --- a/usr.bin/Makefile +++ b/usr.bin/Makefile @@ -9,7 +9,8 @@ # Moved to secure: bdes # -SUBDIR= alias \ +SUBDIR= ${_addr2line} \ + alias \ apply \ asa \ awk \ @@ -41,6 +42,7 @@ SUBDIR= alias \ du \ ee \ elf2aout \ + ${_elfcopy} \ elfdump \ enigma \ env \ @@ -119,6 +121,7 @@ SUBDIR= alias \ nfsstat \ nice \ nl \ + ${_nm} \ nohup \ opieinfo \ opiekey \ @@ -150,12 +153,14 @@ SUBDIR= alias \ seq \ shar \ showmount \ + ${_size} \ sockstat \ soeliminate \ sort \ split \ stat \ stdbuf \ + ${_strings} \ su \ systat \ tabs \ @@ -236,6 +241,14 @@ SUBDIR+= calendar _clang= clang .endif +.if ${MK_ELFTOOLCHAIN_TOOLS} != "no" +_addr2line= addr2line +_elfcopy= elfcopy +_nm= nm +_size= size +_strings= strings +.endif + .if ${MK_FMAKE} != "no" SUBDIR+= make .endif diff --git a/usr.bin/addr2line/Makefile b/usr.bin/addr2line/Makefile new file mode 100644 index 000000000000..918707a7e7e1 --- /dev/null +++ b/usr.bin/addr2line/Makefile @@ -0,0 +1,16 @@ +# $FreeBSD$ + +.include + +ELFTCDIR= ${.CURDIR}/../../contrib/elftoolchain +ADDR2LINEDIR= ${ELFTCDIR}/addr2line + +.PATH: ${ADDR2LINEDIR} + +PROG= addr2line + +LIBADD= elftc dwarf elf + +CFLAGS+=-I${ELFTCDIR}/libelftc -I${ELFTCDIR}/common + +.include diff --git a/usr.bin/elfcopy/Makefile b/usr.bin/elfcopy/Makefile new file mode 100644 index 000000000000..8e7f31d2b9bd --- /dev/null +++ b/usr.bin/elfcopy/Makefile @@ -0,0 +1,24 @@ +# $FreeBSD$ + +.include + +ELFTCDIR= ${.CURDIR}/../../contrib/elftoolchain +ELFCOPYDIR= ${ELFTCDIR}/elfcopy + +.PATH: ${ELFCOPYDIR} + +PROG= elfcopy + +SRCS= archive.c ascii.c binary.c main.c sections.c segments.c symbols.c + +WARNS?= 5 + +LIBADD= archive elftc elf + +CFLAGS+=-I${ELFTCDIR}/libelftc -I${ELFTCDIR}/common + +MAN= elfcopy.1 strip.1 + +LINKS= ${BINDIR}/elfcopy ${BINDIR}/strip + +.include diff --git a/usr.bin/nm/Makefile b/usr.bin/nm/Makefile new file mode 100644 index 000000000000..5078e1030069 --- /dev/null +++ b/usr.bin/nm/Makefile @@ -0,0 +1,16 @@ +# $FreeBSD$ + +.include + +ELFTCDIR= ${.CURDIR}/../../contrib/elftoolchain +NMDIR= ${ELFTCDIR}/nm + +.PATH: ${NMDIR} + +PROG= nm + +LIBADD= dwarf elftc elf + +CFLAGS+=-I${ELFTCDIR}/libelftc -I${ELFTCDIR}/common + +.include diff --git a/usr.bin/size/Makefile b/usr.bin/size/Makefile new file mode 100644 index 000000000000..6aba73da0c88 --- /dev/null +++ b/usr.bin/size/Makefile @@ -0,0 +1,16 @@ +# $FreeBSD$ + +.include + +ELFTCDIR= ${.CURDIR}/../../contrib/elftoolchain +SIZEDIR= ${ELFTCDIR}/size + +.PATH: ${SIZEDIR} + +PROG= size + +LIBADD= elftc elf + +CFLAGS+=-I${ELFTCDIR}/libelftc -I${ELFTCDIR}/common + +.include diff --git a/usr.bin/strings/Makefile b/usr.bin/strings/Makefile new file mode 100644 index 000000000000..8543dcf435fe --- /dev/null +++ b/usr.bin/strings/Makefile @@ -0,0 +1,15 @@ +# $FreeBSD$ + +.include + +ELFTCDIR= ${.CURDIR}/../../contrib/elftoolchain + +.PATH: ${ELFTCDIR}/strings + +PROG= strings + +LIBADD= elftc elf + +CFLAGS+=-I${ELFTCDIR}/libelftc -I${ELFTCDIR}/common + +.include From 238e75e50521d8455404403d2fab311e67d623b5 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Mon, 1 Dec 2014 17:51:16 +0000 Subject: [PATCH 27/94] Document ISP 2532 support and hint.isp.0.vports tunable. MFC after: 1 week --- share/man/man4/isp.4 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/share/man/man4/isp.4 b/share/man/man4/isp.4 index 23fd4b1f2442..cf1fa12d9b06 100644 --- a/share/man/man4/isp.4 +++ b/share/man/man4/isp.4 @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 28, 2007 +.Dd December 1, 2014 .Dt ISP 4 .Os .Sh NAME @@ -136,6 +136,8 @@ Dell Branded version of the QLogic 2312 Fibre Channel PCI cards. Qlogic 2422 Optical Fibre Channel PCI cards (4 Gigabit) .It Qlogic 2432 Qlogic 2432 Optical Fibre Channel PCIe cards (4 Gigabit) +.It Qlogic 2432 +Qlogic 2532 Optical Fibre Channel PCIe cards (8 Gigabit) .El .Sh CONFIGURATION OPTIONS Target mode support may be enabled with the @@ -197,6 +199,8 @@ A hint to define default role for isp instance (target, initiator, both). A hint value for a driver debug level (see the file .Pa /usr/src/sys/dev/isp/ispvar.h for the values. +.It Va hint.isp.0.vports +A hint to create specified number of additional virtual ports. .El .Sh SYSCTL OPTIONS .Bl -tag -width indent From afe2c756941134e2add3ea7ba904be6fca76b062 Mon Sep 17 00:00:00 2001 From: Rui Paulo Date: Mon, 1 Dec 2014 19:48:23 +0000 Subject: [PATCH 28/94] Allow multiple devices to mmap. It's impossible to prevent this with checks on the open/close functions. MFC after: 1 week --- sys/arm/ti/ti_pruss.c | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/sys/arm/ti/ti_pruss.c b/sys/arm/ti/ti_pruss.c index f7f7fbd10269..55838d2d908c 100644 --- a/sys/arm/ti/ti_pruss.c +++ b/sys/arm/ti/ti_pruss.c @@ -67,7 +67,6 @@ static device_attach_t ti_pruss_attach; static device_detach_t ti_pruss_detach; static void ti_pruss_intr(void *); static d_open_t ti_pruss_open; -static d_close_t ti_pruss_close; static d_mmap_t ti_pruss_mmap; static void ti_pruss_kq_read_detach(struct knote *); static int ti_pruss_kq_read_event(struct knote *, long); @@ -83,14 +82,12 @@ struct ti_pruss_softc { bus_space_handle_t sc_bh; struct cdev *sc_pdev; struct selinfo sc_selinfo; - uint32_t sc_inuse; }; static struct cdevsw ti_pruss_cdevsw = { .d_version = D_VERSION, .d_name = "ti_pruss", .d_open = ti_pruss_open, - .d_close = ti_pruss_close, .d_mmap = ti_pruss_mmap, .d_kqfilter = ti_pruss_kqfilter, }; @@ -187,11 +184,11 @@ ti_pruss_attach(device_t dev) for (i = 0; i < TI_PRUSS_IRQS; i++) { ti_pruss_irq_args[i].irq = i; ti_pruss_irq_args[i].sc = sc; - if (bus_setup_intr(dev, sc->sc_irq_res[i], + if (bus_setup_intr(dev, sc->sc_irq_res[i], INTR_MPSAFE | INTR_TYPE_MISC, - NULL, ti_pruss_intr, &ti_pruss_irq_args[i], + NULL, ti_pruss_intr, &ti_pruss_irq_args[i], &sc->sc_intr[i]) != 0) { - device_printf(dev, + device_printf(dev, "unable to setup the interrupt handler\n"); ti_pruss_detach(dev); return (ENXIO); @@ -220,7 +217,7 @@ ti_pruss_detach(device_t dev) if (sc->sc_intr[i]) bus_teardown_intr(dev, sc->sc_irq_res[i], sc->sc_intr[i]); if (sc->sc_irq_res[i]) - bus_release_resource(dev, SYS_RES_IRQ, + bus_release_resource(dev, SYS_RES_IRQ, rman_get_rid(sc->sc_irq_res[i]), sc->sc_irq_res[i]); } @@ -246,25 +243,9 @@ ti_pruss_intr(void *arg) } static int -ti_pruss_open(struct cdev *cdev, int oflags, int devtype, struct thread *td) +ti_pruss_open(struct cdev *cdev __unused, int oflags __unused, + int devtype __unused, struct thread *td __unused) { - device_t dev = cdev->si_drv1; - struct ti_pruss_softc *sc = device_get_softc(dev); - - if (atomic_cmpset_32(&sc->sc_inuse, 0, 1) == 0) - return (EBUSY); - else - return (0); -} - -static int -ti_pruss_close(struct cdev *cdev, int fflag, int devtype, struct thread *td) -{ - device_t dev = cdev->si_drv1; - struct ti_pruss_softc *sc = device_get_softc(dev); - - sc->sc_inuse = 0; - return (0); } From 689c8e8b46e4f75ecb99487ec742a5964f8d70b0 Mon Sep 17 00:00:00 2001 From: Xin LI Date: Mon, 1 Dec 2014 20:51:01 +0000 Subject: [PATCH 29/94] Fix inverted logic introduced in r272154. Noticed by: trasz MFC after: 2 weeks --- sbin/sysctl/sysctl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c index a6ea9f9891a5..6849b9e5f9e3 100644 --- a/sbin/sysctl/sysctl.c +++ b/sbin/sysctl/sysctl.c @@ -679,15 +679,18 @@ strIKtoi(const char *str, char **endptrp) p = &str[len - 1]; if (*p == 'C' || *p == 'F') { temp = strtof(str, endptrp); - if (*endptrp != str && *endptrp == p && errno != 0) { + if (*endptrp != str && *endptrp == p && errno == 0) { if (*p == 'F') temp = (temp - 32) * 5 / 9; + *endptrp = NULL; return (temp * 10 + 2732); } } else { kelv = (int)strtol(str, endptrp, 10); - if (*endptrp != str && *endptrp == p && errno != 0) + if (*endptrp != str && *endptrp == p && errno == 0) { + *endptrp = NULL; return (kelv); + } } errno = ERANGE; From 7f9b314ff2ffb784dfe43eb0daa565a4da22809a Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Mon, 1 Dec 2014 21:04:26 +0000 Subject: [PATCH 30/94] Pull in the NetBSD global offset table handling code. Clang 3.5 creates relocations the linker complains about. Obtained from: NetBSD MFC after: 1 Week --- sys/arm/include/asm.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sys/arm/include/asm.h b/sys/arm/include/asm.h index bd4b6361f3cd..73b7355130c9 100644 --- a/sys/arm/include/asm.h +++ b/sys/arm/include/asm.h @@ -112,10 +112,16 @@ ldr x, [x, got] #define GOT_INIT(got,gotsym,pclabel) \ ldr got, gotsym; \ - add got, got, pc; \ - pclabel: + pclabel: add got, got, pc +#ifdef __thumb__ #define GOT_INITSYM(gotsym,pclabel) \ - gotsym: .word _C_LABEL(_GLOBAL_OFFSET_TABLE_) + (. - (pclabel+4)) + .align 0; \ + gotsym: .word _C_LABEL(_GLOBAL_OFFSET_TABLE_) - (pclabel+4) +#else +#define GOT_INITSYM(gotsym,pclabel) \ + .align 0; \ + gotsym: .word _C_LABEL(_GLOBAL_OFFSET_TABLE_) - (pclabel+8) +#endif #ifdef __STDC__ #define PIC_SYM(x,y) x ## ( ## y ## ) From a10327789172fd631f3ce82a4b84e081630270d6 Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Mon, 1 Dec 2014 21:07:36 +0000 Subject: [PATCH 31/94] Set the correct architecture when targeting ARMv7 MFC after: 1 Week Sponsored by: ABT Systems Ltd --- share/mk/bsd.cpu.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/mk/bsd.cpu.mk b/share/mk/bsd.cpu.mk index f786109cdfd3..a3b9c1fd016d 100644 --- a/share/mk/bsd.cpu.mk +++ b/share/mk/bsd.cpu.mk @@ -99,7 +99,7 @@ _CPUCFLAGS = -march=armv5te -D__XSCALE__ . elif ${CPUTYPE} == "armv6" _CPUCFLAGS = -march=${CPUTYPE} -DARM_ARCH_6=1 . elif ${CPUTYPE} == "cortexa" -_CPUCFLAGS = -DARM_ARCH_6=1 -mfpu=vfp +_CPUCFLAGS = -march=armv7 -DARM_ARCH_6=1 -mfpu=vfp . else _CPUCFLAGS = -mcpu=${CPUTYPE} . endif From f9867ad74d31b2c69a2ef60c2d9994165fb5d13f Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Mon, 1 Dec 2014 21:13:47 +0000 Subject: [PATCH 32/94] Use the floating-point instruction on ARMv7 as the clang 3.5 integrated assembler doesn't allow these two instructions to use co-processor 11. MFC after: 1 Week Sponsored by: ABT Systems Ltd --- contrib/gcc/config/arm/libunwind.S | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/contrib/gcc/config/arm/libunwind.S b/contrib/gcc/config/arm/libunwind.S index 81e4236f6970..8b1e2f3722e4 100644 --- a/contrib/gcc/config/arm/libunwind.S +++ b/contrib/gcc/config/arm/libunwind.S @@ -26,6 +26,13 @@ the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include + +/* Allow the use of VFP instructions */ +#if __ARM_ARCH >= 7 +.fpu vfp +#endif + #ifndef __symbian__ #include "lib1funcs.asm" @@ -66,14 +73,22 @@ ARM_FUNC_START restore_core_regs ARM_FUNC_START gnu_Unwind_Restore_VFP /* Use the generic coprocessor form so that gas doesn't complain on soft-float targets. */ +#if __ARM_ARCH >= 7 + fldmiax r0, {d0-d15} +#else ldc p11,cr0,[r0],{0x21} /* fldmiax r0, {d0-d15} */ +#endif RET /* Store VFR regsters d0-d15 to the address in r0. */ ARM_FUNC_START gnu_Unwind_Save_VFP /* Use the generic coprocessor form so that gas doesn't complain on soft-float targets. */ +#if __ARM_ARCH >= 7 + fstmiax r0, {d0-d15} +#else stc p11,cr0,[r0],{0x21} /* fstmiax r0, {d0-d15} */ +#endif RET /* Wrappers to save core registers, then call the real routine. */ From 52db98331db9fe97f4b42d5113bd9f2fe1b356b7 Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Mon, 1 Dec 2014 22:39:35 +0000 Subject: [PATCH 33/94] Make this work with pkgng, and allow PORTS_OPTS to be passed in --- tools/tools/nanobsd/fill_pkg.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/tools/nanobsd/fill_pkg.sh b/tools/tools/nanobsd/fill_pkg.sh index 8ee953ea10ec..be240a3bf66f 100644 --- a/tools/tools/nanobsd/fill_pkg.sh +++ b/tools/tools/nanobsd/fill_pkg.sh @@ -57,8 +57,8 @@ ports_recurse() ( else ( cd $d - rd=`make -V RUN_DEPENDS` - ld=`make -V LIB_DEPENDS` + rd=`make -V RUN_DEPENDS ${PORTS_OPTS}` + ld=`make -V LIB_DEPENDS ${PORTS_OPTS}` for x in $rd $ld do @@ -84,8 +84,8 @@ done for i in `cat $PL` do p=`(cd $i && make -V PKGNAME)` - if [ -f $NANO_PKG_DUMP/$p.tbz ] ; then - ln -s $NANO_PKG_DUMP/$p.tbz $NANO_PACKAGE_DIR + if [ -f $NANO_PKG_DUMP/$p.t[bx]z ] ; then + ln -s $NANO_PKG_DUMP/$p.t[bx]z $NANO_PACKAGE_DIR else echo "Package $p misssing in $NANO_PKG_DUMP" 1>&2 exit 1 From e3ef75f1ea455f636b4a5dd94827a2381cb02758 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Tue, 2 Dec 2014 00:23:26 +0000 Subject: [PATCH 34/94] Sync the svn template with the one from ports --- contrib/subversion/subversion/svn/util.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/contrib/subversion/subversion/svn/util.c b/contrib/subversion/subversion/svn/util.c index 2353df6a8580..9a16d3a64e4d 100644 --- a/contrib/subversion/subversion/svn/util.c +++ b/contrib/subversion/subversion/svn/util.c @@ -333,11 +333,13 @@ truncate_buffer_at_prefix(apr_size_t *new_len, static const char *prefixes[] = { "PR:", + "Differential Revision:", "Submitted by:", "Reviewed by:", "Approved by:", "Obtained from:", "MFC after:", + "MFH:", "Relnotes:", "Security:", "Sponsored by:" @@ -404,11 +406,13 @@ svn_cl__get_log_message(const char **log_msg, default_msg = svn_stringbuf_create(APR_EOL_STR, pool); svn_stringbuf_appendcstr(default_msg, APR_EOL_STR); svn_stringbuf_appendcstr(default_msg, "PR:\t\t" APR_EOL_STR); + svn_stringbuf_appendcstr(default_msg, "Differential Revision:\t" APR_EOL_STR); svn_stringbuf_appendcstr(default_msg, "Submitted by:\t" APR_EOL_STR); svn_stringbuf_appendcstr(default_msg, "Reviewed by:\t" APR_EOL_STR); svn_stringbuf_appendcstr(default_msg, "Approved by:\t" APR_EOL_STR); svn_stringbuf_appendcstr(default_msg, "Obtained from:\t" APR_EOL_STR); svn_stringbuf_appendcstr(default_msg, "MFC after:\t" APR_EOL_STR); + svn_stringbuf_appendcstr(default_msg, "MFH:\t\t" APR_EOL_STR); svn_stringbuf_appendcstr(default_msg, "Relnotes:\t" APR_EOL_STR); svn_stringbuf_appendcstr(default_msg, "Security:\t" APR_EOL_STR); svn_stringbuf_appendcstr(default_msg, "Sponsored by:\t" @@ -419,15 +423,17 @@ svn_cl__get_log_message(const char **log_msg, svn_stringbuf_appendcstr(default_msg, EDITOR_EOF_PREFIX); svn_stringbuf_appendcstr(default_msg, APR_EOL_STR); svn_stringbuf_appendcstr(default_msg, "> Description of fields to fill in above: 76 columns --|" APR_EOL_STR); - svn_stringbuf_appendcstr(default_msg, "> PR: If a Bugzilla PR is affected by the change." APR_EOL_STR); - svn_stringbuf_appendcstr(default_msg, "> Submitted by: If someone else sent in the change." APR_EOL_STR); - svn_stringbuf_appendcstr(default_msg, "> Reviewed by: If someone else reviewed your modification." APR_EOL_STR); - svn_stringbuf_appendcstr(default_msg, "> Approved by: If you needed approval for this commit." APR_EOL_STR); - svn_stringbuf_appendcstr(default_msg, "> Obtained from: If the change is from a third party." APR_EOL_STR); - svn_stringbuf_appendcstr(default_msg, "> MFC after: N [day[s]|week[s]|month[s]]. Request a reminder email." APR_EOL_STR); - svn_stringbuf_appendcstr(default_msg, "> Relnotes: Set to 'yes' for mention in release notes." APR_EOL_STR); - svn_stringbuf_appendcstr(default_msg, "> Security: Vulnerability reference (one per line) or description." APR_EOL_STR); - svn_stringbuf_appendcstr(default_msg, "> Sponsored by: If the change was sponsored by an organization." APR_EOL_STR); + svn_stringbuf_appendcstr(default_msg, "> PR: If a Bugzilla PR is affected by the change." APR_EOL_STR); + svn_stringbuf_appendcstr(default_msg, "> Differential Revision: https://reviews.freebsd.org/D### (*full* phabric URL needed)." APR_EOL_STR); + svn_stringbuf_appendcstr(default_msg, "> Submitted by: If someone else sent in the change." APR_EOL_STR); + svn_stringbuf_appendcstr(default_msg, "> Reviewed by: If someone else reviewed your modification." APR_EOL_STR); + svn_stringbuf_appendcstr(default_msg, "> Approved by: If you needed approval for this commit." APR_EOL_STR); + svn_stringbuf_appendcstr(default_msg, "> Obtained from: If the change is from a third party." APR_EOL_STR); + svn_stringbuf_appendcstr(default_msg, "> MFC after: N [day[s]|week[s]|month[s]]. Request a reminder email." APR_EOL_STR); + svn_stringbuf_appendcstr(default_msg, "> MFH: Ports tree branch name. Request approval for merge." APR_EOL_STR); + svn_stringbuf_appendcstr(default_msg, "> Relnotes: Set to 'yes' for mention in release notes." APR_EOL_STR); + svn_stringbuf_appendcstr(default_msg, "> Security: Vulnerability reference (one per line) or description." APR_EOL_STR); + svn_stringbuf_appendcstr(default_msg, "> Sponsored by: If the change was sponsored by an organization." APR_EOL_STR); svn_stringbuf_appendcstr(default_msg, "> Empty fields above will be automatically removed." APR_EOL_STR); svn_stringbuf_appendcstr(default_msg, APR_EOL_STR); From 2d764cca51416946397763993b148d6a047c955f Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Tue, 2 Dec 2014 01:30:53 +0000 Subject: [PATCH 35/94] Let GNU ld be less obscure about missing symbols and DSOs. If the BFD object looks like a typical shared library, suggest adding '-l', where has the 'lib' prefix and '.so' or '.a' suffix removed. Otherwise, suggest adding '-l:', where is the full DT_SONAME. Submitted by: Conrad Meyer Sponsored by: EMC / Isilon storage division Reviewed by: emaste PR: 194296 MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D1152 --- contrib/binutils/bfd/elflink.c | 33 +++++++++++++++++++++++++++++++-- contrib/binutils/bfd/po/bfd.pot | 4 ++-- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/contrib/binutils/bfd/elflink.c b/contrib/binutils/bfd/elflink.c index e80f8ee3f22e..f1e50def8b52 100644 --- a/contrib/binutils/bfd/elflink.c +++ b/contrib/binutils/bfd/elflink.c @@ -4356,9 +4356,38 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) --no-add-needed is used. */ if ((elf_dyn_lib_class (abfd) & DYN_NO_NEEDED) != 0) { + bfd_boolean looks_soish; + const char *print_name; + int print_len; + size_t len, lend = 0; + + looks_soish = FALSE; + print_name = soname; + print_len = strlen(soname); + if (strncmp(soname, "lib", 3) == 0) + { + len = print_len; + if (len > 5 && strcmp(soname + len - 2, ".a") == 0) + lend = len - 5; + else + { + while (len > 6 && (ISDIGIT(soname[len - 1]) || + soname[len - 1] == '.')) + len--; + if (strncmp(soname + len - 3, ".so", 3) == 0) + lend = len - 6; + } + if (lend != 0) + { + print_name = soname + 3; + print_len = lend; + looks_soish = TRUE; + } + } + (*_bfd_error_handler) - (_("%B: invalid DSO for symbol `%s' definition"), - abfd, name); + (_("undefined reference to symbol `%s' (try adding -l%s%.*s)"), + name, looks_soish? "" : ":", print_len, print_name); bfd_set_error (bfd_error_bad_value); goto error_free_vers; } diff --git a/contrib/binutils/bfd/po/bfd.pot b/contrib/binutils/bfd/po/bfd.pot index e5282389a1ab..e436b184f31a 100644 --- a/contrib/binutils/bfd/po/bfd.pot +++ b/contrib/binutils/bfd/po/bfd.pot @@ -2438,9 +2438,9 @@ msgstr "" msgid "Warning: size of symbol `%s' changed from %lu in %B to %lu in %B" msgstr "" -#: elflink.c:4309 +#: elflink.c:4389 #, c-format -msgid "%B: invalid DSO for symbol `%s' definition" +msgid "undefined reference to symbol `%s' (try adding -l%s%.*s)" msgstr "" #: elflink.c:5535 From 18e8f946ec28bb550e5bcb72d1b6b19a09f59721 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Tue, 2 Dec 2014 02:11:09 +0000 Subject: [PATCH 36/94] Add elfcopy and man page to OptionalObsoleteFiles --- tools/build/mk/OptionalObsoleteFiles.inc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index fa643a80916b..0f72659f7661 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -1198,6 +1198,11 @@ OLD_FILES+=usr/share/dict/words OLD_DIRS+=usr/share/dict .endif +.if ${MK_ELFTOOLCHAIN_TOOLS} == no +OLD_FILES+=usr/bin/elfcopy +OLD_FILES+=usr/share/man/man1/elfcopy.1.gz +.endif + #.if ${MK_EXAMPLES} == no # to be filled in #.endif From 9a2a38462374a96bfbcc1ee8a9bba0da57afd2ef Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Tue, 2 Dec 2014 02:16:30 +0000 Subject: [PATCH 37/94] Regenerate src.conf(5) after r275373 --- share/man/man5/src.conf.5 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/share/man/man5/src.conf.5 b/share/man/man5/src.conf.5 index 83c180833451..4232141b46f8 100644 --- a/share/man/man5/src.conf.5 +++ b/share/man/man5/src.conf.5 @@ -1,7 +1,7 @@ .\" DO NOT EDIT-- this file is automatically generated. .\" from FreeBSD: head/tools/build/options/makeman 255964 2013-10-01 07:22:04Z des .\" $FreeBSD$ -.Dd November 26, 2014 +.Dd December 1, 2014 .Dt SRC.CONF 5 .Os .Sh NAME @@ -383,6 +383,16 @@ without support for encryption/decryption. .It Va WITH_EISA .\" from FreeBSD: head/tools/build/options/WITH_EISA 264654 2014-04-18 16:53:06Z imp Set to build EISA kernel modules. +.It Va WITH_ELFTOOLCHAIN_TOOLS +.\" from FreeBSD: head/tools/build/options/WITH_ELFTOOLCHAIN_TOOLS 275373 2014-12-01 17:49:42Z emaste +Set to use +.Xr addr2line 1 , +.Xr nm 1 , +.Xr size 1 , +.Xr strings 1 , +and +.Xr strip 1 +from the elftoolchain project instead of GNU binutils. .It Va WITHOUT_EXAMPLES .\" from FreeBSD: head/tools/build/options/WITHOUT_EXAMPLES 156938 2006-03-21 09:06:24Z ru Set to avoid installing examples to From 0e23cc372d64be31a02010f2626810af46104710 Mon Sep 17 00:00:00 2001 From: "Andrey V. Elsukov" Date: Tue, 2 Dec 2014 02:32:28 +0000 Subject: [PATCH 38/94] Remove unused declartations. Sponsored by: Yandex LLC --- sys/netipsec/ipsec6.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/sys/netipsec/ipsec6.h b/sys/netipsec/ipsec6.h index 38198e1846e1..c9c32e49f3ce 100644 --- a/sys/netipsec/ipsec6.h +++ b/sys/netipsec/ipsec6.h @@ -59,23 +59,13 @@ VNET_DECLARE(int, ip6_ipsec_ecn); #define V_ip6_ipsec_ecn VNET(ip6_ipsec_ecn) struct inpcb; - extern int ipsec6_in_reject __P((struct mbuf *, struct inpcb *)); -struct ip6_hdr; -extern const char *ipsec6_logpacketstr __P((struct ip6_hdr *, u_int32_t)); - struct m_tag; extern int ipsec6_common_input(struct mbuf **mp, int *offp, int proto); extern int ipsec6_common_input_cb(struct mbuf *m, struct secasvar *sav, int skip, int protoff, struct m_tag *mt); extern void esp6_ctlinput(int, struct sockaddr *, void *); - -struct ipsec_output_state; -extern int ipsec6_output_trans __P((struct ipsec_output_state *, u_char *, - struct mbuf *, struct secpolicy *, int, int *)); -extern int ipsec6_output_tunnel __P((struct ipsec_output_state *, - struct secpolicy *, int)); extern int ipsec6_process_packet(struct mbuf *, struct ipsecrequest *); #endif /*_KERNEL*/ From 1fea1b0889ffe8e42cc315484bafceee21c6ccf4 Mon Sep 17 00:00:00 2001 From: "Andrey V. Elsukov" Date: Tue, 2 Dec 2014 02:41:44 +0000 Subject: [PATCH 39/94] Remove unused structure declarations. Sponsored by: Yandex LLC --- sys/netipsec/ipsec.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/sys/netipsec/ipsec.h b/sys/netipsec/ipsec.h index fcb85f3bcf0a..bb8a047f8730 100644 --- a/sys/netipsec/ipsec.h +++ b/sys/netipsec/ipsec.h @@ -263,17 +263,6 @@ struct ipsecstat { #ifdef _KERNEL #include -struct ipsec_output_state { - struct mbuf *m; - struct route *ro; - struct sockaddr *dst; -}; - -struct ipsec_history { - int ih_proto; - u_int32_t ih_spi; -}; - VNET_DECLARE(int, ipsec_debug); #define V_ipsec_debug VNET(ipsec_debug) From 2d957916efd3c2be453b37e949d668d7d9a5fb49 Mon Sep 17 00:00:00 2001 From: "Andrey V. Elsukov" Date: Tue, 2 Dec 2014 04:20:50 +0000 Subject: [PATCH 40/94] Remove route chaching support from ipsec code. It isn't used for some time. * remove sa_route_union declaration and route_cache member from struct secashead; * remove key_sa_routechange() call from ICMP and ICMPv6 code; * simplify ip_ipsec_mtu(); * remove #include ; Sponsored by: Yandex LLC --- sys/netinet/ip_icmp.c | 8 -------- sys/netinet/ip_ipsec.c | 31 +------------------------------ sys/netinet6/icmp6.c | 9 --------- sys/netinet6/ip6_ipsec.c | 1 - sys/netipsec/ipsec.c | 1 - sys/netipsec/ipsec.h | 4 ++++ sys/netipsec/ipsec_input.c | 1 - sys/netipsec/ipsec_mbuf.c | 3 --- sys/netipsec/ipsec_output.c | 1 - sys/netipsec/key.c | 25 ------------------------- sys/netipsec/key.h | 1 - sys/netipsec/key_debug.c | 1 - sys/netipsec/keydb.h | 8 -------- sys/netipsec/keysock.c | 1 - sys/netipsec/xform_ah.c | 1 - sys/netipsec/xform_esp.c | 1 - sys/netipsec/xform_ipcomp.c | 1 - sys/netipsec/xform_ipip.c | 1 - sys/netipsec/xform_tcp.c | 1 - 19 files changed, 5 insertions(+), 95 deletions(-) diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c index 845c6ec9bb23..d134a2ec3bd3 100644 --- a/sys/netinet/ip_icmp.c +++ b/sys/netinet/ip_icmp.c @@ -33,7 +33,6 @@ __FBSDID("$FreeBSD$"); #include "opt_inet.h" -#include "opt_ipsec.h" #include #include @@ -65,10 +64,6 @@ __FBSDID("$FreeBSD$"); #include #ifdef INET -#ifdef IPSEC -#include -#include -#endif #include @@ -619,9 +614,6 @@ icmp_input(struct mbuf **mp, int *offp, int proto) (struct sockaddr *)&icmpgw, fibnum); } pfctlinput(PRC_REDIRECT_HOST, (struct sockaddr *)&icmpsrc); -#ifdef IPSEC - key_sa_routechange((struct sockaddr *)&icmpsrc); -#endif break; /* diff --git a/sys/netinet/ip_ipsec.c b/sys/netinet/ip_ipsec.c index 4e23c34bff8d..c1ca94ab01e3 100644 --- a/sys/netinet/ip_ipsec.c +++ b/sys/netinet/ip_ipsec.c @@ -46,7 +46,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include @@ -206,35 +205,7 @@ ip_ipsec_mtu(struct mbuf *m, int mtu) * tunnel MTU = if MTU - sizeof(IP) - ESP/AH hdrsiz * XXX quickhack!!! */ - struct secpolicy *sp = NULL; - int ipsecerror; - int ipsechdr; - struct route *ro; - sp = ipsec_getpolicybyaddr(m, - IPSEC_DIR_OUTBOUND, - IP_FORWARDING, - &ipsecerror); - if (sp != NULL) { - /* count IPsec header size */ - ipsechdr = ipsec_hdrsiz(m, IPSEC_DIR_OUTBOUND, NULL); - - /* - * find the correct route for outer IPv4 - * header, compute tunnel MTU. - */ - if (sp->req != NULL && - sp->req->sav != NULL && - sp->req->sav->sah != NULL) { - ro = &sp->req->sav->sah->route_cache.sa_route; - if (ro->ro_rt && ro->ro_rt->rt_ifp) { - mtu = ro->ro_rt->rt_mtu ? ro->ro_rt->rt_mtu : - ro->ro_rt->rt_ifp->if_mtu; - mtu -= ipsechdr; - } - } - KEY_FREESP(&sp); - } - return mtu; + return (mtu - ipsec_hdrsiz(m, IPSEC_DIR_OUTBOUND, NULL)); } /* diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c index 84a1bc039e2b..0105479dcf54 100644 --- a/sys/netinet6/icmp6.c +++ b/sys/netinet6/icmp6.c @@ -67,7 +67,6 @@ __FBSDID("$FreeBSD$"); #include "opt_inet.h" #include "opt_inet6.h" -#include "opt_ipsec.h" #include #include @@ -110,11 +109,6 @@ __FBSDID("$FreeBSD$"); #include #include -#ifdef IPSEC -#include -#include -#endif - extern struct domain inet6domain; VNET_PCPUSTAT_DEFINE(struct icmp6stat, icmp6stat); @@ -2472,9 +2466,6 @@ icmp6_redirect_input(struct mbuf *m, int off) sdst.sin6_len = sizeof(struct sockaddr_in6); bcopy(&reddst6, &sdst.sin6_addr, sizeof(struct in6_addr)); pfctlinput(PRC_REDIRECT_HOST, (struct sockaddr *)&sdst); -#ifdef IPSEC - key_sa_routechange((struct sockaddr *)&sdst); -#endif /* IPSEC */ } freeit: diff --git a/sys/netinet6/ip6_ipsec.c b/sys/netinet6/ip6_ipsec.c index 3e6d4df71ac1..78840edbe397 100644 --- a/sys/netinet6/ip6_ipsec.c +++ b/sys/netinet6/ip6_ipsec.c @@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include diff --git a/sys/netipsec/ipsec.c b/sys/netipsec/ipsec.c index e5ca8d26eb4f..bce64e7fe028 100644 --- a/sys/netipsec/ipsec.c +++ b/sys/netipsec/ipsec.c @@ -56,7 +56,6 @@ #include #include -#include #include #include diff --git a/sys/netipsec/ipsec.h b/sys/netipsec/ipsec.h index bb8a047f8730..a4f81c03fb2b 100644 --- a/sys/netipsec/ipsec.h +++ b/sys/netipsec/ipsec.h @@ -47,6 +47,10 @@ #ifdef _KERNEL +#include +#include +#include + #define IPSEC_ASSERT(_c,_m) KASSERT(_c, _m) #define IPSEC_IS_PRIVILEGED_SO(_so) \ diff --git a/sys/netipsec/ipsec_input.c b/sys/netipsec/ipsec_input.c index 06364a3ab38f..2c133c797fe7 100644 --- a/sys/netipsec/ipsec_input.c +++ b/sys/netipsec/ipsec_input.c @@ -58,7 +58,6 @@ #include #include #include -#include #include #include diff --git a/sys/netipsec/ipsec_mbuf.c b/sys/netipsec/ipsec_mbuf.c index fb105d438edb..8e68ffb41c6f 100644 --- a/sys/netipsec/ipsec_mbuf.c +++ b/sys/netipsec/ipsec_mbuf.c @@ -37,11 +37,8 @@ #include #include -#include #include - #include - #include /* diff --git a/sys/netipsec/ipsec_output.c b/sys/netipsec/ipsec_output.c index 885326c55316..b159f2d3d2dd 100644 --- a/sys/netipsec/ipsec_output.c +++ b/sys/netipsec/ipsec_output.c @@ -46,7 +46,6 @@ #include #include #include -#include #include #include diff --git a/sys/netipsec/key.c b/sys/netipsec/key.c index 1034f234aa7f..88b2dc56cad9 100644 --- a/sys/netipsec/key.c +++ b/sys/netipsec/key.c @@ -59,7 +59,6 @@ #include #include -#include #include #include @@ -2770,10 +2769,6 @@ key_delsah(sah) /* remove from tree of SA index */ if (__LIST_CHAINED(sah)) LIST_REMOVE(sah, chain); - if (sah->route_cache.sa_route.ro_rt) { - RTFREE(sah->route_cache.sa_route.ro_rt); - sah->route_cache.sa_route.ro_rt = (struct rtentry *)NULL; - } free(sah, M_IPSEC_SAH); } } @@ -7898,26 +7893,6 @@ key_sa_recordxfer(sav, m) return; } -/* dumb version */ -void -key_sa_routechange(dst) - struct sockaddr *dst; -{ - struct secashead *sah; - struct route *ro; - - SAHTREE_LOCK(); - LIST_FOREACH(sah, &V_sahtree, chain) { - ro = &sah->route_cache.sa_route; - if (ro->ro_rt && dst->sa_len == ro->ro_dst.sa_len - && bcmp(dst, &ro->ro_dst, dst->sa_len) == 0) { - RTFREE(ro->ro_rt); - ro->ro_rt = (struct rtentry *)NULL; - } - } - SAHTREE_UNLOCK(); -} - static void key_sa_chgstate(struct secasvar *sav, u_int8_t state) { diff --git a/sys/netipsec/key.h b/sys/netipsec/key.h index 2a8c19e509d0..f2062d0269c6 100644 --- a/sys/netipsec/key.h +++ b/sys/netipsec/key.h @@ -106,7 +106,6 @@ extern void key_init __P((void)); extern void key_destroy(void); #endif extern void key_sa_recordxfer __P((struct secasvar *, struct mbuf *)); -extern void key_sa_routechange __P((struct sockaddr *)); extern void key_sa_stir_iv __P((struct secasvar *)); #ifdef IPSEC_NAT_T u_int16_t key_portfromsaddr(struct sockaddr *); diff --git a/sys/netipsec/key_debug.c b/sys/netipsec/key_debug.c index 81a9a2f30ad6..a16dd9553537 100644 --- a/sys/netipsec/key_debug.c +++ b/sys/netipsec/key_debug.c @@ -45,7 +45,6 @@ #endif #include -#include #include #include diff --git a/sys/netipsec/keydb.h b/sys/netipsec/keydb.h index 7494f5f4f3f9..63e38b7e0206 100644 --- a/sys/netipsec/keydb.h +++ b/sys/netipsec/keydb.h @@ -85,12 +85,6 @@ struct seclifetime { u_int64_t usetime; }; -union sa_route_union { - struct route sa_route; - struct route sin_route; /* Duplicate for consistency. */ - struct route_in6 sin6_route; -}; - /* Security Association Data Base */ struct secashead { LIST_ENTRY(secashead) chain; @@ -105,8 +99,6 @@ struct secashead { LIST_HEAD(_satree, secasvar) savtree[SADB_SASTATE_MAX+1]; /* SA chain */ /* The first of this list is newer SA */ - - union sa_route_union route_cache; }; struct xformsw; diff --git a/sys/netipsec/keysock.c b/sys/netipsec/keysock.c index b72ada297696..f642674aa2d8 100644 --- a/sys/netipsec/keysock.c +++ b/sys/netipsec/keysock.c @@ -54,7 +54,6 @@ #include #include #include -#include #include diff --git a/sys/netipsec/xform_ah.c b/sys/netipsec/xform_ah.c index 42083dba0094..cb69cb385765 100644 --- a/sys/netipsec/xform_ah.c +++ b/sys/netipsec/xform_ah.c @@ -58,7 +58,6 @@ #include #include -#include #include #include #include diff --git a/sys/netipsec/xform_esp.c b/sys/netipsec/xform_esp.c index 8fae36a1fd19..4230b64bea73 100644 --- a/sys/netipsec/xform_esp.c +++ b/sys/netipsec/xform_esp.c @@ -58,7 +58,6 @@ #include #include -#include #include #include #include diff --git a/sys/netipsec/xform_ipcomp.c b/sys/netipsec/xform_ipcomp.c index 1096c99cf243..5ef52465acff 100644 --- a/sys/netipsec/xform_ipcomp.c +++ b/sys/netipsec/xform_ipcomp.c @@ -48,7 +48,6 @@ #include #include -#include #include #include diff --git a/sys/netipsec/xform_ipip.c b/sys/netipsec/xform_ipip.c index 67b86edbcd56..5167b9661b9c 100644 --- a/sys/netipsec/xform_ipip.c +++ b/sys/netipsec/xform_ipip.c @@ -54,7 +54,6 @@ #include #include #include -#include #include #include diff --git a/sys/netipsec/xform_tcp.c b/sys/netipsec/xform_tcp.c index a5edb15dcf2c..267e3777bfdd 100644 --- a/sys/netipsec/xform_tcp.c +++ b/sys/netipsec/xform_tcp.c @@ -47,7 +47,6 @@ #include #include -#include #include #include From bd766f3425efbc8bdb407152038d129e25e18f7a Mon Sep 17 00:00:00 2001 From: "Andrey V. Elsukov" Date: Tue, 2 Dec 2014 05:28:40 +0000 Subject: [PATCH 41/94] Remove unneded check. No need to do m_pullup to the size that we prepended. Sponsored by: Yandex LLC --- sys/netipsec/keysock.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sys/netipsec/keysock.c b/sys/netipsec/keysock.c index f642674aa2d8..45b04259cf36 100644 --- a/sys/netipsec/keysock.c +++ b/sys/netipsec/keysock.c @@ -148,8 +148,6 @@ key_sendup0(rp, m, promisc) struct sadb_msg *pmsg; M_PREPEND(m, sizeof(struct sadb_msg), M_NOWAIT); - if (m && m->m_len < sizeof(struct sadb_msg)) - m = m_pullup(m, sizeof(struct sadb_msg)); if (!m) { PFKEYSTAT_INC(in_nomem); m_freem(m); From 2dfcd0ae9d9b78d5f0d861a3f85f20a96ec62793 Mon Sep 17 00:00:00 2001 From: "Andrey V. Elsukov" Date: Tue, 2 Dec 2014 05:41:03 +0000 Subject: [PATCH 42/94] Remove unneded check. No need to do m_pullup to the size that we prepended. MFC after: 1 week Sponsored by: Yandex LLC --- sys/net/if_stf.c | 2 -- sys/netinet6/icmp6.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c index 00e34a236a99..f3a604255ddd 100644 --- a/sys/net/if_stf.c +++ b/sys/net/if_stf.c @@ -482,8 +482,6 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, } M_PREPEND(m, sizeof(struct ip), M_NOWAIT); - if (m && m->m_len < sizeof(struct ip)) - m = m_pullup(m, sizeof(struct ip)); if (m == NULL) { if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return ENOBUFS; diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c index 0105479dcf54..6ef0d445b402 100644 --- a/sys/netinet6/icmp6.c +++ b/sys/netinet6/icmp6.c @@ -363,8 +363,6 @@ icmp6_error(struct mbuf *m, int type, int code, int param) preplen = sizeof(struct ip6_hdr) + sizeof(struct icmp6_hdr); M_PREPEND(m, preplen, M_NOWAIT); /* FIB is also copied over. */ - if (m && m->m_len < preplen) - m = m_pullup(m, preplen); if (m == NULL) { nd6log((LOG_DEBUG, "ENOBUFS in icmp6_error %d\n", __LINE__)); return; From 244c371d25209c8f894f2ead3f3779a5722c5648 Mon Sep 17 00:00:00 2001 From: Rui Paulo Date: Tue, 2 Dec 2014 06:11:32 +0000 Subject: [PATCH 43/94] Rewrite parts of gpioctl(8) to use the gpio(3) library. --- usr.sbin/gpioctl/Makefile | 5 ++ usr.sbin/gpioctl/gpioctl.c | 106 ++++++++++++++++--------------------- 2 files changed, 50 insertions(+), 61 deletions(-) diff --git a/usr.sbin/gpioctl/Makefile b/usr.sbin/gpioctl/Makefile index 997f0c7c8d2b..d4804e90951b 100644 --- a/usr.sbin/gpioctl/Makefile +++ b/usr.sbin/gpioctl/Makefile @@ -3,4 +3,9 @@ PROG= gpioctl MAN= gpioctl.8 +CFLAGS+= -I${.CURDIR}/../../lib/libgpio + +DPADD+= ${LIBGPIO} +LDADD+= -lgpio + .include diff --git a/usr.sbin/gpioctl/gpioctl.c b/usr.sbin/gpioctl/gpioctl.c index e4708a414ec2..ac2c291bfdad 100644 --- a/usr.sbin/gpioctl/gpioctl.c +++ b/usr.sbin/gpioctl/gpioctl.c @@ -1,5 +1,6 @@ /*- * Copyright (c) 2009, Oleksandr Tymoshenko + * Copyright (c) 2014, Rui Paulo * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -37,7 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include struct flag_desc { const char *name; @@ -100,7 +101,7 @@ str2cap(const char *str) /* * Our handmade function for converting string to number */ -static int +static int str2int(const char *s, int *ok) { char *endptr; @@ -132,44 +133,35 @@ print_caps(int caps) } static void -dump_pins(int fd, int verbose) +dump_pins(gpio_handle_t handle, int verbose) { - int i, maxpin; - struct gpio_pin pin; - struct gpio_req req; + int i, maxpin, pinv; + gpio_config_t *cfgs; + gpio_config_t *pin; - if (ioctl(fd, GPIOMAXPIN, &maxpin) < 0) { - perror("ioctl(GPIOMAXPIN)"); + maxpin = gpio_pin_list(handle, &cfgs); + if (maxpin < 0) { + perror("gpio_pin_list"); exit(1); } for (i = 0; i <= maxpin; i++) { - pin.gp_pin = i; - if (ioctl(fd, GPIOGETCONFIG, &pin) < 0) - /* For some reason this pin is inaccessible */ - continue; + pin = cfgs + i; + pinv = gpio_pin_get(handle, pin->g_pin); + printf("pin %02d:\t%d\t%s", pin->g_pin, pinv, + pin->g_name); - req.gp_pin = i; - if (ioctl(fd, GPIOGET, &req) < 0) { - /* Now, that's wrong */ - perror("ioctl(GPIOGET)"); - exit(1); - } - - printf("pin %02d:\t%d\t%s", pin.gp_pin, req.gp_value, - pin.gp_name); - - print_caps(pin.gp_flags); + print_caps(pin->g_flags); if (verbose) { printf(", caps:"); - print_caps(pin.gp_caps); + print_caps(pin->g_caps); } printf("\n"); } } -static void +static void fail(const char *fmt, ...) { va_list ap; @@ -180,15 +172,14 @@ fail(const char *fmt, ...) exit(1); } -int +int main(int argc, char **argv) { int i; - struct gpio_pin pin; - struct gpio_req req; - char defctlfile[] = _PATH_DEVGPIOC "0"; + gpio_config_t pin; + gpio_handle_t handle; char *ctlfile = NULL; - int pinn, pinv, fd, ch; + int pinn, pinv, ch; int flags, flag, ok; int config, toggle, verbose, list; @@ -228,17 +219,17 @@ main(int argc, char **argv) printf("%d/%s\n", i, argv[i]); if (ctlfile == NULL) - ctlfile = defctlfile; - - fd = open(ctlfile, O_RDONLY); - if (fd < 0) { - perror("open"); + handle = gpio_open(0); + else + handle = gpio_open_device(ctlfile); + if (handle == GPIO_INVALID_HANDLE) { + perror("gpio_open"); exit(1); } if (list) { - dump_pins(fd, verbose); - close(fd); + dump_pins(handle, verbose); + gpio_close(handle); exit(0); } @@ -246,19 +237,16 @@ main(int argc, char **argv) /* * -t pin assumes no additional arguments */ - if(argc > 0) { + if (argc > 0) { usage(); exit(1); } - - req.gp_pin = pinn; - if (ioctl(fd, GPIOTOGGLE, &req) < 0) { - perror("ioctl(GPIOTOGGLE)"); + if (gpio_pin_toggle(handle, pinn) < 0) { + perror("gpio_pin_toggle"); exit(1); } - - close(fd); - exit (0); + gpio_close(handle); + exit(0); } if (config) { @@ -269,14 +257,12 @@ main(int argc, char **argv) fail("Invalid flag: %s\n", argv[i]); flags |= flag; } - - pin.gp_pin = pinn; - pin.gp_flags = flags; - if (ioctl(fd, GPIOSETCONFIG, &pin) < 0) { - perror("ioctl(GPIOSETCONFIG)"); + pin.g_pin = pinn; + pin.g_flags = flags; + if (gpio_pin_set_flags(handle, &pin) < 0) { + perror("gpio_pin_set_flags"); exit(1); } - exit(0); } @@ -296,13 +282,13 @@ main(int argc, char **argv) * Read pin value */ if (argc == 1) { - req.gp_pin = pinn; - if (ioctl(fd, GPIOGET, &req) < 0) { - perror("ioctl(GPIOGET)"); + pinv = gpio_pin_get(handle, pinn); + if (pinv < 0) { + perror("gpio_pin_get"); exit(1); } - printf("%d\n", req.gp_value); - exit (0); + printf("%d\n", pinv); + exit(0); } /* Is it valid number (0 or 1) ? */ @@ -313,13 +299,11 @@ main(int argc, char **argv) /* * Set pin value */ - req.gp_pin = pinn; - req.gp_value = pinv; - if (ioctl(fd, GPIOSET, &req) < 0) { - perror("ioctl(GPIOSET)"); + if (gpio_pin_set(handle, pinn, pinv) < 0) { + perror("gpio_pin_set"); exit(1); } - close(fd); + gpio_close(handle); exit(0); } From e852010c3961bf29d526d115d1cb2c0d988bb22d Mon Sep 17 00:00:00 2001 From: Rui Paulo Date: Tue, 2 Dec 2014 06:24:45 +0000 Subject: [PATCH 44/94] Fix an off-by-one in gpio_pin_list(). Coverity CID: 1256495 --- lib/libgpio/gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libgpio/gpio.c b/lib/libgpio/gpio.c index d22b3cf5392c..8eb68712057a 100644 --- a/lib/libgpio/gpio.c +++ b/lib/libgpio/gpio.c @@ -89,7 +89,7 @@ gpio_pin_list(gpio_handle_t handle, gpio_config_t **pcfgs) errno = EINVAL; return (-1); } - cfgs = calloc(maxpins, sizeof(*cfgs)); + cfgs = calloc(maxpins + 1, sizeof(*cfgs)); if (cfgs == NULL) return (-1); for (i = 0; i <= maxpins; i++) { From 81bffeeaab8522951713b1d92166c2c877ceedc3 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Tue, 2 Dec 2014 07:34:06 +0000 Subject: [PATCH 45/94] Import CVS version of mandoc as of 20141201 --- INSTALL | 93 +-- LICENSE | 8 +- Makefile | 194 ++---- Makefile.depend | 60 +- NEWS | 5 +- TODO | 176 ++++- apropos.1 | 133 +++- apropos.c | 123 ---- arch.in | 112 --- att.c | 22 +- att.in | 40 -- cgi.c | 133 ++-- chars.c | 53 +- chars.in | 230 +++---- compat_fgetln.c | 7 +- compat_fts.c | 826 +++++++++++++++++++++++ compat_fts.h | 106 +++ compat_getsubopt.c | 14 +- compat_ohash.c | 6 +- compat_reallocarray.c | 4 +- compat_sqlite3_errstr.c | 4 +- compat_strcasestr.c | 4 +- compat_strlcat.c | 4 +- compat_strlcpy.c | 4 +- compat_strsep.c | 4 +- config.h.post | 42 -- config.h.pre | 9 - configure | 390 ++++++++++- configure.local.example | 189 ++++++ demandoc.1 | 6 +- demandoc.c | 11 +- eqn.7 | 250 ++++++- eqn.c | 1388 +++++++++++++++++++++----------------- eqn_html.c | 189 ++++-- eqn_term.c | 87 ++- example.style.css | 9 +- html.c | 159 ++--- html.h | 43 +- lib.c | 6 +- libman.h | 24 +- libmandoc.h | 31 +- libmdoc.h | 44 +- libroff.h | 28 +- main.c | 539 +++++++++++++-- main.h | 15 +- makewhatis.8 | 6 +- man.1 | 402 +++++++++++ man.c | 246 +++---- man.cgi.8 | 12 +- man.h | 3 +- man_hash.c | 4 +- man_html.c | 63 +- man_macro.c | 171 +++-- man_term.c | 77 ++- man_validate.c | 113 ++-- mandoc.1 | 254 +++++-- mandoc.3 | 89 ++- mandoc.c | 37 +- mandoc.db.5 | 23 +- mandoc.h | 68 +- mandoc_aux.c | 4 +- mandoc_escape.3 | 34 +- mandocdb.c | 184 +++-- manpage.c | 11 +- manpath.c | 55 +- mansearch.c | 104 +-- mansearch.h | 36 +- mansearch_const.c | 5 +- mchars_alloc.3 | 15 +- mdoc.7 | 175 +++-- mdoc.c | 229 ++----- mdoc_argv.c | 214 +++--- mdoc_hash.c | 4 +- mdoc_html.c | 181 ++--- mdoc_macro.c | 1170 ++++++++++++-------------------- mdoc_man.c | 99 ++- mdoc_term.c | 274 ++++---- mdoc_validate.c | 835 +++++++++++------------ msec.c | 6 +- msec.in | 6 +- out.c | 80 ++- out.h | 8 +- preconv.1 | 157 ----- preconv.c | 460 ++----------- read.c | 430 ++++++++---- roff.7 | 27 +- roff.c | 509 ++++++++------ st.c | 6 +- st.in | 9 +- style.css | 9 +- tbl.7 | 62 +- tbl.c | 6 +- tbl_data.c | 6 +- tbl_html.c | 8 +- tbl_layout.c | 111 ++- tbl_opts.c | 10 +- tbl_term.c | 30 +- term.c | 190 +++--- term.h | 12 +- term_ascii.c | 171 +++-- term_ps.c | 296 ++++++-- test-dirent-namlen.c | 10 + test-fts.c | 42 ++ test-getsubopt.c | 23 +- arch.c => test-sqlite3.c | 44 +- test-wchar.c | 63 ++ tree.c | 73 +- vol.c | 36 - vol.in | 35 - 109 files changed, 8344 insertions(+), 5612 deletions(-) delete mode 100644 apropos.c delete mode 100644 arch.in delete mode 100644 att.in create mode 100644 compat_fts.c create mode 100644 compat_fts.h delete mode 100644 config.h.post delete mode 100644 config.h.pre create mode 100644 configure.local.example create mode 100644 man.1 delete mode 100644 preconv.1 create mode 100644 test-dirent-namlen.c create mode 100644 test-fts.c rename arch.c => test-sqlite3.c (50%) create mode 100644 test-wchar.c delete mode 100644 vol.c delete mode 100644 vol.in diff --git a/INSTALL b/INSTALL index da8eeab9dd4e..31ffaf00c008 100644 --- a/INSTALL +++ b/INSTALL @@ -1,4 +1,4 @@ -$Id: INSTALL,v 1.2 2014/08/10 17:22:26 schwarze Exp $ +$Id: INSTALL,v 1.5 2014/08/18 13:27:47 kristaps Exp $ About mdocml, the portable mandoc distribution ---------------------------------------------- @@ -34,19 +34,52 @@ latest bundled and ported versions of mandoc for various operating systems is maintained at . If mandoc is installed, you can check the version by running "mandoc -V". -The version contained in this distribution tarball is listed near -the beginning of the file "Makefile". +You can find the version contained in this distribution tarball +by running "./configure". Regarding how packages and ports are maintained for your operating system, please consult your operating system documentation. To install mandoc manually, the following steps are needed: -1. Decide whether you want to build the base tools mandoc(1), -preconv(1) and demandoc(1) only or whether you also want to build the -database tools apropos(1) and makewhatis(8). For the latter, -the following dependencies are required: +1. If you want to build the CGI program, man.cgi(8), too, run the +command "echo BUILD_CGI=1 > configure.local". Then run "cp +cgi.h.examples cgi.h" and edit cgi.h as desired. -1.1. The SQLite database system, see . +2. Run "./configure". +This script attempts autoconfiguration of mandoc for your system. +Read both its standard output and the file "Makefile.local" it +generates. If anything looks wrong or different from what you +wish, read the file "configure.local.example", create and edit +a file "configure.local", and re-run "./configure" until the +result seems right to you. + +3. Run "make". +Any POSIX-compatible make, in particular both BSD make and GNU make, +should work. If the build fails, look at "configure.local.example" +and go back to step 2. + +4. Run "make -n install" and check whether everything will be +installed to the intended places. Otherwise, put some *DIR variables +into "configure.local" and go back to step 2. + +5. Run "sudo make install". If you intend to build a binary +package using some kind of fake root mechanism, you may need a +command like "make DESTDIR=... install". Read the *-install targets +in the "Makefile" to understand how DESTDIR is used. + +6. To set up a man.cgi(8) server, read its manual page. + +7. To use mandoc(1) as your man(1) formatter, read the "Deployment" +section below. + + +Understanding mandoc dependencies +--------------------------------- +The mandoc(1), preconv(1), and demandoc(1) utilities have no external +dependencies. However, makewhatis(8) and apropos(1) depend on the +following software: + +1. The SQLite database system, see . The recommended version of SQLite is 3.8.4.3 or newer. The mandoc toolset is known to work with version 3.7.5 or newer. Versions older than 3.8.3 may not achieve full performance due to the @@ -57,47 +90,16 @@ problems, apropos(1) is fully usable with SQLite 3.7.5. Versions older than 3.7.5 may or may not work, they have not been tested. 1.2. The fts(3) directory traversion functions. -A compatibility version will be bundled for 1.13.2 but is not available -yet. If you want apropos(1) and makewhatis(8) but do not have fts(3), -please stay with mandoc 1.12.3 for now and upgrade first to 1.12.4, -then to 1.13.2 when these versionns are released. Be careful: the +If your system does not have them, the bundled compatibility version +will be used, so you need not worry in that case. But be careful: the glibc version of fts(3) is known to be broken on 32bit platforms, see . +If you run into that problem, set "HAVE_FTS=0" in configure.local. 1.3. Marc Espie's ohash(3) library. If your system does not have it, the bundled compatibility version will be used, so you probably need not worry about it. -2. If you choose to build the database tools, too, decide whether -you also want to build the CGI program, man.cgi(8). - -3. Read the beginning of the file "Makefile" from "USER SETTINGS" -to "END OF USER SETTINGS" and edit it as required. In particular, -disable "BUILD_TARGETS += db-build" if you do not want database -support or enable "BUILD_TARGETS += cgi-build" if you do want -the CGI program. - -4. Run "make". No separate "./configure" or "make depend" steps -are needed. The former is run automatically by "make". The latter -is a maintainer target. If you merely want to build the released -version as opposed to doing active development, there is no need -to regenerate the dependency specifications. Any POSIX-compatible -make, in particular both BSD make and GNU make, should work. - -5. Run "make -n install" and check whether everything will be -installed to the intended places. Otherwise, edit the *DIR variables -in the Makefile until it is. - -6. Run "sudo make install". If you intend to build a binary -package using some kind of fake root mechanism, you may need a -command like "make DESTDIR=... install". Read the *-install targets -in the "Makefile" to understand how DESTDIR is used. - -7. To set up a man.cgi(8) server, read its manual page. - -8. To use mandoc(1) as your man(1) formatter, read the "Deployment" -section below. - Checking autoconfiguration quality ---------------------------------- @@ -130,9 +132,9 @@ please report whatever is missing on your platform. The following steps can be used to manually check the automatic configuration on your platform: -1. Run "make clean". +1. Run "make distclean". -2. Run "make config.h" +2. Run "./configure" 3. Read the file "config.log". It shows the compiler commands used to test the libraries installed on your system and the standard @@ -140,8 +142,7 @@ output and standard error output these commands produce. Watch out for unexpected failures. Those are most likely to happen if headers or libraries are installed in unusual places or interfaces defined in unusual headers. You can also look at the file "config.h" and -check that no expected "#define HAVE_*" lines are missing. The -list of tests run can be found in the file "configure". +check that no "#define HAVE_*" differ from your expectations. Deployment diff --git a/LICENSE b/LICENSE index 35072fb2d1ba..db26171c9de9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -$Id: LICENSE,v 1.2 2014/04/23 21:06:41 schwarze Exp $ +$Id: LICENSE,v 1.4 2014/08/21 00:42:38 schwarze Exp $ With the exceptions noted below, all code and documentation contained in the mdocml toolkit is protected by the Copyright @@ -37,8 +37,10 @@ The following files included from outside sources are protected by other people's Copyright and are distributed under a 3-clause BSD license; see these individual files for details. -compat_getsubopt.c, compat_strcasestr.c, compat_strsep.c: -Copyright (c) 1990, 1993 The Regents of the University of California +compat_fts.c, compat_fts.h, +compat_getsubopt.c, compat_strcasestr.c, compat_strsep.c, +man.1: +Copyright (c) 1989,1990,1993,1994 The Regents of the University of California compat_fgetln.c: Copyright (c) 1998 The NetBSD Foundation, Inc. diff --git a/Makefile b/Makefile index 47f37a7dffc9..a8255fecc824 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.435 2014/08/10 02:45:04 schwarze Exp $ +# $Id: Makefile,v 1.448 2014/11/28 18:57:31 schwarze Exp $ # # Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons # Copyright (c) 2011, 2013, 2014 Ingo Schwarze @@ -15,126 +15,31 @@ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -VERSION = 1.13.1 - -# === USER SETTINGS ==================================================== - -# --- user settings relevant for all builds ---------------------------- - -# Specify this if you want to hard-code the operating system to appear -# in the lower-left hand corner of -mdoc manuals. -# -# CFLAGS += -DOSNAME="\"OpenBSD 5.5\"" - -# IFF your system supports multi-byte functions (setlocale(), wcwidth(), -# putwchar()) AND has __STDC_ISO_10646__ (that is, wchar_t is simply a -# UCS-4 value) should you define USE_WCHAR. If you define it and your -# system DOESN'T support this, -Tlocale will produce garbage. -# If you don't define it, -Tlocale is a synonym for -Tacsii. -# -CFLAGS += -DUSE_WCHAR - -CFLAGS += -g -DHAVE_CONFIG_H -CFLAGS += -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wwrite-strings -PREFIX = /usr/local -BINDIR = $(PREFIX)/bin -INCLUDEDIR = $(PREFIX)/include/mandoc -LIBDIR = $(PREFIX)/lib/mandoc -MANDIR = $(PREFIX)/man -EXAMPLEDIR = $(PREFIX)/share/examples/mandoc - -INSTALL = install -INSTALL_PROGRAM = $(INSTALL) -m 0555 -INSTALL_DATA = $(INSTALL) -m 0444 -INSTALL_LIB = $(INSTALL) -m 0444 -INSTALL_SOURCE = $(INSTALL) -m 0644 -INSTALL_MAN = $(INSTALL_DATA) - -# --- user settings related to database support ------------------------ - -# Building apropos(1) and makewhatis(8) requires both SQLite3 and fts(3). -# To avoid those dependencies, comment the following line. -# Be careful: the fts(3) implementation in glibc is broken on 32bit -# machines, see: https://sourceware.org/bugzilla/show_bug.cgi?id=15838 -# -BUILD_TARGETS += db-build - -# The remaining settings in this section -# are only relevant if db-build is enabled. -# Otherwise, they have no effect either way. - -# If your system has manpath(1), uncomment this. This is most any -# system that's not OpenBSD or NetBSD. If uncommented, apropos(1) -# and makewhatis(8) will use manpath(1) to get the MANPATH variable. -# -#CFLAGS += -DUSE_MANPATH - -# On some systems, SQLite3 may be installed below /usr/local. -# In that case, uncomment the following two lines. -# -#CFLAGS += -I/usr/local/include -#DBLIB += -L/usr/local/lib - -# OpenBSD has the ohash functions in libutil. -# Comment the following line if your system doesn't. -# -DBLIB += -lutil - -SBINDIR = $(PREFIX)/sbin - -# --- user settings related to man.cgi --------------------------------- - -# To build man.cgi, copy cgi.h.example to cgi.h, edit it, -# and enable the following line. -# Obviously, this requires that db-build is enabled, too. -# -#BUILD_TARGETS += cgi-build - -# The remaining settings in this section -# are only relevant if cgi-build is enabled. -# Otherwise, they have no effect either way. - -# If your system does not support static binaries, comment this, -# for example on Mac OS X. -# -STATIC = -static - -# Linux requires -pthread for statical linking. -# -#STATIC += -pthread - -WWWPREFIX = /var/www -HTDOCDIR = $(WWWPREFIX)/htdocs -CGIBINDIR = $(WWWPREFIX)/cgi-bin - -# === END OF USER SETTINGS ============================================= - -INSTALL_TARGETS = $(BUILD_TARGETS:-build=-install) - -BASEBIN = mandoc preconv demandoc -DBBIN = apropos makewhatis +BASEBIN = mandoc demandoc +DBBIN = makewhatis CGIBIN = man.cgi -DBLIB += -lsqlite3 - -TESTSRCS = test-fgetln.c \ +TESTSRCS = test-dirent-namlen.c \ + test-fgetln.c \ + test-fts.c \ test-getsubopt.c \ test-mmap.c \ test-ohash.c \ test-reallocarray.c \ + test-sqlite3.c \ test-sqlite3_errstr.c \ test-strcasestr.c \ test-strlcat.c \ test-strlcpy.c \ test-strptime.c \ - test-strsep.c + test-strsep.c \ + test-wchar.c -SRCS = apropos.c \ - arch.c \ - att.c \ +SRCS = att.c \ cgi.c \ chars.c \ compat_fgetln.c \ + compat_fts.c \ compat_getsubopt.c \ compat_ohash.c \ compat_reallocarray.c \ @@ -187,7 +92,6 @@ SRCS = apropos.c \ term_ascii.c \ term_ps.c \ tree.c \ - vol.c \ $(TESTSRCS) DISTFILES = INSTALL \ @@ -197,14 +101,12 @@ DISTFILES = INSTALL \ NEWS \ TODO \ apropos.1 \ - arch.in \ - att.in \ cgi.h.example \ chars.in \ + compat_fts.h \ compat_ohash.h \ - config.h.post \ - config.h.pre \ configure \ + configure.local.example \ demandoc.1 \ eqn.7 \ example.style.css \ @@ -218,6 +120,7 @@ DISTFILES = INSTALL \ main.h \ makewhatis.8 \ man-cgi.css \ + man.1 \ man.7 \ man.cgi.8 \ man.h \ @@ -238,7 +141,6 @@ DISTFILES = INSTALL \ mdoc.h \ msec.in \ out.h \ - preconv.1 \ predefs.in \ roff.7 \ st.in \ @@ -246,7 +148,6 @@ DISTFILES = INSTALL \ tbl.3 \ tbl.7 \ term.h \ - vol.in \ $(SRCS) LIBMAN_OBJS = man.o \ @@ -254,16 +155,14 @@ LIBMAN_OBJS = man.o \ man_macro.o \ man_validate.o -LIBMDOC_OBJS = arch.o \ - att.o \ +LIBMDOC_OBJS = att.o \ lib.o \ mdoc.o \ mdoc_argv.o \ mdoc_hash.o \ mdoc_macro.o \ mdoc_validate.o \ - st.o \ - vol.o + st.o LIBROFF_OBJS = eqn.o \ roff.o \ @@ -279,9 +178,11 @@ LIBMANDOC_OBJS = $(LIBMAN_OBJS) \ mandoc.o \ mandoc_aux.o \ msec.o \ + preconv.o \ read.o COMPAT_OBJS = compat_fgetln.o \ + compat_fts.o \ compat_getsubopt.o \ compat_ohash.o \ compat_reallocarray.o \ @@ -314,11 +215,11 @@ MANDOC_OBJS = $(MANDOC_HTML_OBJS) \ out.o \ tree.o +MAN_OBJS = $(MANDOC_OBJS) + MAKEWHATIS_OBJS = mandocdb.o mansearch_const.o manpath.o -PRECONV_OBJS = preconv.o - -APROPOS_OBJS = apropos.o mansearch.o mansearch_const.o manpath.o +APROPOS_OBJS = mansearch.o mansearch_const.o manpath.o CGI_OBJS = $(MANDOC_HTML_OBJS) \ cgi.o \ @@ -332,8 +233,8 @@ DEMANDOC_OBJS = demandoc.o WWW_MANS = apropos.1.html \ demandoc.1.html \ + man.1.html \ mandoc.1.html \ - preconv.1.html \ mandoc.3.html \ mandoc_escape.3.html \ mandoc_html.3.html \ @@ -360,9 +261,13 @@ WWW_MANS = apropos.1.html \ WWW_OBJS = mdocml.tar.gz \ mdocml.sha256 +include Makefile.local + +INSTALL_TARGETS = $(BUILD_TARGETS:-build=-install) + # === DEPENDENCY HANDLING ============================================== -all: base-build $(BUILD_TARGETS) +all: base-build $(BUILD_TARGETS) Makefile.local base-build: $(BASEBIN) @@ -374,20 +279,22 @@ install: base-install $(INSTALL_TARGETS) www: $(WWW_OBJS) $(WWW_MANS) +$(WWW_MANS): mandoc + include Makefile.depend # === TARGETS CONTAINING SHELL COMMANDS ================================ +distclean: clean + rm -f Makefile.local config.h config.h.old config.log config.log.old + clean: - rm -f libmandoc.a $(LIBMANDOC_OBJS) - rm -f apropos $(APROPOS_OBJS) + rm -f libmandoc.a $(LIBMANDOC_OBJS) $(COMPAT_OBJS) + rm -f mandoc $(MANDOC_OBJS) $(APROPOS_OBJS) rm -f makewhatis $(MAKEWHATIS_OBJS) - rm -f preconv $(PRECONV_OBJS) rm -f man.cgi $(CGI_OBJS) rm -f manpage $(MANPAGE_OBJS) rm -f demandoc $(DEMANDOC_OBJS) - rm -f mandoc $(MANDOC_OBJS) - rm -f config.h config.log $(COMPAT_OBJS) rm -f $(WWW_MANS) $(WWW_OBJS) rm -rf *.dSYM @@ -403,7 +310,8 @@ base-install: base-build $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR) $(INSTALL_LIB) man.h mandoc.h mandoc_aux.h mdoc.h \ $(DESTDIR)$(INCLUDEDIR) - $(INSTALL_MAN) mandoc.1 preconv.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1 + $(INSTALL_MAN) man.1 mandoc.1 demandoc.1 \ + $(DESTDIR)$(MANDIR)/man1 $(INSTALL_MAN) mandoc.3 mandoc_escape.3 mandoc_malloc.3 \ mchars_alloc.3 tbl.3 $(DESTDIR)$(MANDIR)/man3 $(INSTALL_MAN) man.7 mdoc.7 roff.7 eqn.7 tbl.7 mandoc_char.7 \ @@ -417,8 +325,8 @@ db-install: db-build mkdir -p $(DESTDIR)$(MANDIR)/man3 mkdir -p $(DESTDIR)$(MANDIR)/man5 mkdir -p $(DESTDIR)$(MANDIR)/man8 - $(INSTALL_PROGRAM) apropos $(DESTDIR)$(BINDIR) - ln -f $(DESTDIR)$(BINDIR)/apropos $(DESTDIR)$(BINDIR)/whatis + ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/apropos + ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/whatis $(INSTALL_PROGRAM) makewhatis $(DESTDIR)$(SBINDIR) $(INSTALL_MAN) apropos.1 $(DESTDIR)$(MANDIR)/man1 ln -f $(DESTDIR)$(MANDIR)/man1/apropos.1 \ @@ -447,30 +355,29 @@ www-install: www $(INSTALL_DATA) mdocml.sha256 \ $(DESTDIR)$(HTDOCDIR)/snapshots/mdocml-$(VERSION).sha256 +Makefile.local config.h: configure ${TESTSRCS} + @echo "$@ is out of date; please run ./configure" + @exit 1 + depend: config.h mkdep -f Makefile.depend $(CFLAGS) $(SRCS) perl -e 'undef $$/; $$_ = <>; s|/usr/include/\S+||g; \ - s|\\\n||g; s| +| |g; print;' Makefile.depend > Makefile.tmp + s|\\\n||g; s| +| |g; s| $$||mg; print;' \ + Makefile.depend > Makefile.tmp mv Makefile.tmp Makefile.depend libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS) $(AR) rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS) -mandoc: $(MANDOC_OBJS) libmandoc.a - $(CC) $(LDFLAGS) -o $@ $(MANDOC_OBJS) libmandoc.a +mandoc: $(MAN_OBJS) libmandoc.a + $(CC) $(LDFLAGS) -o $@ $(MAN_OBJS) libmandoc.a $(DBLIB) makewhatis: $(MAKEWHATIS_OBJS) libmandoc.a $(CC) $(LDFLAGS) -o $@ $(MAKEWHATIS_OBJS) libmandoc.a $(DBLIB) -preconv: $(PRECONV_OBJS) - $(CC) $(LDFLAGS) -o $@ $(PRECONV_OBJS) - manpage: $(MANPAGE_OBJS) libmandoc.a $(CC) $(LDFLAGS) -o $@ $(MANPAGE_OBJS) libmandoc.a $(DBLIB) -apropos: $(APROPOS_OBJS) libmandoc.a - $(CC) $(LDFLAGS) -o $@ $(APROPOS_OBJS) libmandoc.a $(DBLIB) - man.cgi: $(CGI_OBJS) libmandoc.a $(CC) $(LDFLAGS) $(STATIC) -o $@ $(CGI_OBJS) libmandoc.a $(DBLIB) @@ -482,18 +389,13 @@ mdocml.sha256: mdocml.tar.gz mdocml.tar.gz: $(DISTFILES) mkdir -p .dist/mdocml-$(VERSION)/ - $(INSTALL_SOURCE) $(DISTFILES) .dist/mdocml-$(VERSION) + $(INSTALL) -m 0644 $(DISTFILES) .dist/mdocml-$(VERSION) chmod 755 .dist/mdocml-$(VERSION)/configure ( cd .dist/ && tar zcf ../$@ mdocml-$(VERSION) ) rm -rf .dist/ -config.h: configure config.h.pre config.h.post $(TESTSRCS) - rm -f config.log - CC="$(CC)" CFLAGS="$(CFLAGS)" DBLIB="$(DBLIB)" \ - VERSION="$(VERSION)" ./configure - .PHONY: base-install cgi-install db-install install www-install -.PHONY: clean depend +.PHONY: clean distclean depend .SUFFIXES: .1 .3 .5 .7 .8 .h .SUFFIXES: .1.html .3.html .5.html .7.html .8.html .h.html diff --git a/Makefile.depend b/Makefile.depend index dc49310e5222..d3c13e09cf5e 100644 --- a/Makefile.depend +++ b/Makefile.depend @@ -1,24 +1,23 @@ -apropos.o: apropos.c config.h manpath.h mansearch.h -arch.o: arch.c config.h mdoc.h libmdoc.h arch.in -att.o: att.c config.h mdoc.h libmdoc.h att.in +att.o: att.c config.h mdoc.h libmdoc.h cgi.o: cgi.c config.h mandoc.h mandoc_aux.h main.h manpath.h mansearch.h cgi.h chars.o: chars.c config.h mandoc.h mandoc_aux.h libmandoc.h chars.in -compat_fgetln.o: compat_fgetln.c config.h -compat_getsubopt.o: compat_getsubopt.c config.h -compat_ohash.o: compat_ohash.c config.h -compat_reallocarray.o: compat_reallocarray.c config.h -compat_sqlite3_errstr.o: compat_sqlite3_errstr.c config.h -compat_strcasestr.o: compat_strcasestr.c config.h -compat_strlcat.o: compat_strlcat.c config.h -compat_strlcpy.o: compat_strlcpy.c config.h -compat_strsep.o: compat_strsep.c config.h +compat_fgetln.o: compat_fgetln.c config.h +compat_fts.o: compat_fts.c config.h compat_fts.h +compat_getsubopt.o: compat_getsubopt.c config.h +compat_ohash.o: compat_ohash.c config.h compat_ohash.h +compat_reallocarray.o: compat_reallocarray.c config.h +compat_sqlite3_errstr.o: compat_sqlite3_errstr.c config.h +compat_strcasestr.o: compat_strcasestr.c config.h +compat_strlcat.o: compat_strlcat.c config.h +compat_strlcpy.o: compat_strlcpy.c config.h +compat_strsep.o: compat_strsep.c config.h demandoc.o: demandoc.c config.h man.h mdoc.h mandoc.h eqn.o: eqn.c config.h mandoc.h mandoc_aux.h libmandoc.h libroff.h eqn_html.o: eqn_html.c config.h mandoc.h out.h html.h eqn_term.o: eqn_term.c config.h mandoc.h out.h term.h html.o: html.c config.h mandoc.h mandoc_aux.h libmandoc.h out.h html.h main.h lib.o: lib.c config.h mdoc.h libmdoc.h lib.in -main.o: main.c config.h mandoc.h mandoc_aux.h main.h mdoc.h man.h +main.o: main.c config.h mandoc.h mandoc_aux.h main.h mdoc.h man.h manpath.h mansearch.h man.o: man.c config.h man.h mandoc.h mandoc_aux.h libman.h libmandoc.h man_hash.o: man_hash.c config.h man.h mandoc.h libman.h man_html.o: man_html.c config.h mandoc.h mandoc_aux.h out.h html.h man.h main.h @@ -27,10 +26,10 @@ man_term.o: man_term.c config.h mandoc.h mandoc_aux.h out.h man.h term.h main.h man_validate.o: man_validate.c config.h man.h mandoc.h mandoc_aux.h libman.h libmandoc.h mandoc.o: mandoc.c config.h mandoc.h mandoc_aux.h libmandoc.h mandoc_aux.o: mandoc_aux.c config.h mandoc.h mandoc_aux.h -mandocdb.o: mandocdb.c config.h mdoc.h man.h mandoc.h mandoc_aux.h manpath.h mansearch.h +mandocdb.o: mandocdb.c config.h compat_fts.h compat_ohash.h mdoc.h man.h mandoc.h mandoc_aux.h manpath.h mansearch.h manpage.o: manpage.c config.h manpath.h mansearch.h manpath.o: manpath.c config.h mandoc_aux.h manpath.h -mansearch.o: mansearch.c config.h mandoc.h mandoc_aux.h manpath.h mansearch.h +mansearch.o: mansearch.c config.h compat_ohash.h mandoc.h mandoc_aux.h manpath.h mansearch.h mansearch_const.o: mansearch_const.c config.h manpath.h mansearch.h mdoc.o: mdoc.c config.h mdoc.h mandoc.h mandoc_aux.h libmdoc.h libmandoc.h mdoc_argv.o: mdoc_argv.c config.h mdoc.h mandoc.h mandoc_aux.h libmdoc.h libmandoc.h @@ -42,9 +41,9 @@ mdoc_term.o: mdoc_term.c config.h mandoc.h mandoc_aux.h out.h term.h mdoc.h main mdoc_validate.o: mdoc_validate.c config.h mdoc.h mandoc.h mandoc_aux.h libmdoc.h libmandoc.h msec.o: msec.c config.h mandoc.h libmandoc.h msec.in out.o: out.c config.h mandoc_aux.h mandoc.h out.h -preconv.o: preconv.c config.h +preconv.o: preconv.c config.h mandoc.h libmandoc.h read.o: read.c config.h mandoc.h mandoc_aux.h libmandoc.h mdoc.h man.h main.h -roff.o: roff.c config.h mandoc.h mandoc_aux.h libroff.h libmandoc.h predefs.in +roff.o: roff.c config.h mandoc.h mandoc_aux.h libmandoc.h libroff.h predefs.in st.o: st.c config.h mdoc.h libmdoc.h st.in tbl.o: tbl.c config.h mandoc.h mandoc_aux.h libmandoc.h libroff.h tbl_data.o: tbl_data.c config.h mandoc.h mandoc_aux.h libmandoc.h libroff.h @@ -56,15 +55,18 @@ term.o: term.c config.h mandoc.h mandoc_aux.h out.h term.h main.h term_ascii.o: term_ascii.c config.h mandoc.h mandoc_aux.h out.h term.h main.h term_ps.o: term_ps.c config.h mandoc.h mandoc_aux.h out.h main.h term.h tree.o: tree.c config.h mandoc.h mdoc.h man.h main.h -vol.o: vol.c config.h mdoc.h libmdoc.h vol.in -test-fgetln.o: test-fgetln.c -test-getsubopt.o: test-getsubopt.c -test-mmap.o: test-mmap.c -test-ohash.o: test-ohash.c -test-reallocarray.o: test-reallocarray.c -test-sqlite3_errstr.o: test-sqlite3_errstr.c -test-strcasestr.o: test-strcasestr.c -test-strlcat.o: test-strlcat.c -test-strlcpy.o: test-strlcpy.c -test-strptime.o: test-strptime.c -test-strsep.o: test-strsep.c +test-dirent-namlen.o: test-dirent-namlen.c +test-fgetln.o: test-fgetln.c +test-fts.o: test-fts.c +test-getsubopt.o: test-getsubopt.c +test-mmap.o: test-mmap.c +test-ohash.o: test-ohash.c +test-reallocarray.o: test-reallocarray.c +test-sqlite3.o: test-sqlite3.c +test-sqlite3_errstr.o: test-sqlite3_errstr.c +test-strcasestr.o: test-strcasestr.c +test-strlcat.o: test-strlcat.c +test-strlcpy.o: test-strlcpy.c +test-strptime.o: test-strptime.c +test-strsep.o: test-strsep.c +test-wchar.o: test-wchar.c diff --git a/NEWS b/NEWS index 61006b5ee117..f47a807dadc5 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -$Id: NEWS,v 1.5 2014/08/10 16:32:57 schwarze Exp $ +$Id: NEWS,v 1.6 2014/08/11 01:39:00 schwarze Exp $ This file lists the most important changes in the mdocml.bsd.lv distribution. @@ -7,9 +7,6 @@ Changes in version 1.13.1, released on August 10, 2014 --- MAJOR NEW FEATURES --- * A complete apropos(1)/makewhatis(8)/man.cgi(8) suite based on SQLite3 is now included. - CAVEAT: This also requires a working fts(3) implementation. - If your system lacks that *and* you want apropos(1)/makewhatis(8), - stay with 1.12.3 for now, then go to 1.12.4 and 1.13.2. * The roff(7) parser now provides an almost complete implementation of numerical expressions. * Warning and error messages have been improved in many ways. diff --git a/TODO b/TODO index a41df2988270..98cb687eaa2b 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,37 @@ ************************************************************************ * Official mandoc TODO. -* $Id: TODO,v 1.176 2014/08/09 14:24:53 schwarze Exp $ +* $Id: TODO,v 1.189 2014/11/26 21:40:17 schwarze Exp $ ************************************************************************ +Many issues are annotated for difficulty as follows: + + - loc = locality of the issue + * single file issue, affects file only, or very few + ** single module issue, affects several files of one module + *** cross-module issue, significantly impacts multiple modules + and may require substantial changes to internal interfaces + - exist = difficulty of the existing code in this area + * affected code is straightforward and easy to read and change + ** affected code is somewhat complex, but once you understand + the design, not particularly difficult to understand + *** affected code uses a special, exceptionally tricky design + - algo = difficulty of the new algorithm to be written + * the required logic and code is straightforward + ** the required logic is somewhat complex and needs a careful design + *** the required logic is exceptionally tricky, + maybe an approach to solve that is not even known yet + - size = the amount of code to be written or changed + * a small number of lines (at most 100, usually much less) + ** a considerable amount of code (several dozen to a few hundred) + *** a large amount of code (many hundreds, maybe thousands) + - imp = importance of the issue + * mostly for completeness + ** would be nice to have + *** issue causes considerable inconvenience + +Obviously, as the issues have not been solved yet, these annotations +are mere guesses, and some may be wrong. + ************************************************************************ * crashes ************************************************************************ @@ -10,6 +39,7 @@ - The abort() in bufcat(), html.c, can be triggered via buffmt_includes() by running -Thtml -Oincludes on a file containing a long .In argument. Fixing this will probably require reworking the whole bufcat() concept. + loc ** exist * algo * size ** imp ** ************************************************************************ * missing features @@ -25,49 +55,62 @@ .na -- temporarily disable adjustment without changing the mode .ad -- re-enable adjustment without changing the mode Adjustment mode is ignored while in no-fill mode (.nf). + loc *** exist *** algo ** size ** imp ** (parser reorg would help) - .fc (field control) found by naddy@ in xloadimage(1) + loc ** exist *** algo * size * imp * - .nr third argument (auto-increment step size, requires \n+) found by bentley@ in sbcl(1) Mon, 9 Dec 2013 18:36:57 -0700 + loc * exist * algo * size * imp ** - .ns (no-space mode) occurs in xine-config(1) reported by brad@ Sat, 15 Jan 2011 15:45:23 -0500 + loc *** exist *** algo *** size ** imp * - .ta (tab settings) occurs in ircbug(1) and probably gnats(1) reported by brad@ Sat, 15 Jan 2011 15:50:51 -0500 also Tcl_NewStringObj(3) via wiz@ Wed, 5 Mar 2014 22:27:43 +0100 + loc ** exist *** algo ** size ** imp ** - .ti (temporary indent) found by naddy@ in xloadimage(1) found by bentley@ in nmh(1) Mon, 23 Apr 2012 13:38:28 -0600 + loc ** exist ** algo ** size * imp ** (parser reorg helps a lot) - .while and .shift found by jca@ in ratpoison(1) Sun, 30 Jun 2013 12:01:09 +0200 + loc * exist ** algo ** size ** imp ** - \c (interrupted text) should prevent the line break even inside .Bd literal; that occurs in chat(8) also found in cclive(1) - DocBook output + loc ** exist *** algo ** size * imp * - \h horizontal move found in cclive(1) DocBook output Anthony J. Bentley on discuss@ Sat, 21 Sep 2013 22:29:34 -0600 + loc ** exist ** algo ** size * imp ** (parser reorg helps a lot) - \n+ and \n- numerical register increment and decrement found by bentley@ in sbcl(1) Mon, 9 Dec 2013 18:36:57 -0700 + loc * exist * algo * size * imp ** -- \w'' width measurements +- \w'' improve width measurements would not be very useful without an expression parser, see below needed for Tcl_NewStringObj(3) via wiz@ Wed, 5 Mar 2014 22:27:43 +0100 + loc ** exist *** algo *** size * imp *** - using undefined strings or macros defines them to be empty wl@ Mon, 14 Nov 2011 14:37:01 +0000 + loc * exist * algo * size * imp * --- missing mdoc features ---------------------------------------------- - fix bad block nesting involving multiple identical explicit blocks see the OpenBSD mdoc_macro.c 1.47 commit message + loc * exist *** algo *** size * imp ** - .Bl -column .Xo support is missing ultimate goal: @@ -75,10 +118,12 @@ lib/libc/compat-43/sigvec.3 lib/libc/gen/signal.3 lib/libc/sys/sigaction.2 + loc * exist *** algo *** size * imp ** - edge case: decide how to deal with blk_full bad nesting, e.g. .Sh .Nm .Bk .Nm .Ek .Sh found by jmc@ in ssh-keygen(1) from jmc@ Wed, 14 Jul 2010 18:10:32 +0100 + loc * exist *** algo *** size ** imp ** - \\ is now implemented correctly * when defining strings and macros using .ds and .de @@ -92,18 +137,22 @@ we don't have either. Besides, groff has bug causing text right *before* .Bd -centered to be centered as well. + loc *** exist *** algo ** size ** imp ** (parser reorg would help) - .Bd -filled should not be the same as .Bd -ragged, but align both the left and right margin. In groff, it is implemented in terms of .ad b, which we don't have either. Found in cksum(1). + loc *** exist *** algo ** size ** imp ** (parser reorg would help) - implement blank `Bl -column', such as .Bl -column .It foo Ta bar .El + loc * exist *** algo *** size * imp * - explicitly disallow nested `Bl -column', which would clobber internal flags defined for struct mdoc_macro + loc * exist * algo * size * imp ** - In .Bl -column .It, the end of the line probably has to be regarded as an implicit .Ta, if there could be one, see the following mildly @@ -114,6 +163,7 @@ Default search path. reported by Michal Mazurek via jmc@ Thu, 7 Apr 2011 16:00:53 +0059 + loc * exist *** algo ** size * imp ** - inside `.Bl -column' phrases, punctuation is handled like normal text, e.g. `.Bl -column .It Fl x . Ta ...' should give "-x -." @@ -123,11 +173,14 @@ but should give "ab ." - set a meaningful default if no `Bl' list type is assigned + loc * exist * algo * size * imp ** (already done?) - have a blank `It' head for `Bl -tag' not puke + loc * exist * algo * size * imp ** (already done?) - check whether it is correct that `D1' uses INDENT+1; does it need its own constant? + loc * exist ** algo ** size * imp ** - prohibit `Nm' from having non-text HEAD children (e.g., NetBSD mDNSShared/dns-sd.1) @@ -138,6 +191,7 @@ that one uses NOMBRE because it is spanish... deraadt tends to think that section-dependent macro behaviour is a bad idea in the first place, so this may be irrelevant + loc ** exist ** algo ** size * imp ** - When there is free text in the SYNOPSIS and that free text contains the .Nm macro, groff somehow understands to treat the .Nm as an in-line @@ -146,6 +200,7 @@ should be, needs investigation. uqs@ Thu, 2 Jun 2011 11:03:51 +0200 uqs@ Thu, 2 Jun 2011 11:33:35 +0200 + loc * exist ** algo *** size * imp ** --- missing man features ----------------------------------------------- @@ -155,18 +210,36 @@ - look at the POSIX manuals in the books/man-pages-posix port, they use some unsupported tbl(7) features. + loc * exist ** algo ** size ** imp *** -- investigate tbl(1) errors in sox(1) - see also naddy@ Sat, 16 Oct 2010 23:51:57 +0200 +- use Unicode U+2500 to U+256C for table borders + in tbl(7) -Tutf-8 output + suggested by bentley@ Tue, 14 Oct 2014 04:10:55 -0600 + loc * exist ** algo * size * imp ** - allow standalone `.' to be interpreted as an end-of-layout delimiter instead of being thrown away as a no-op roff line reported by Yuri Pankov, Wed 18 May 2011 11:34:59 CEST + loc ** exist ** algo ** size * imp ** + +--- missing eqn features ----------------------------------------------- + +- The "size" keyword is parsed, but ignored by the formatter. + loc * exist * algo * size * imp * + +- The spacing characters `~', `^', and tab are currently ignored, + see User's Guide (Second Edition) page 2 section 4. + loc * exist * algo ** size * imp ** + +- Mark and lineup are parsed and ignored, + see User's Guide (Second Edition) page 5 section 15. + loc ** exist ** algo ** size ** imp ** --- missing misc features ---------------------------------------------- - italic correction (\/) in PostScript mode Werner LEMBERG on groff at gnu dot org Sun, 10 Nov 2013 12:47:46 + loc ** exist ** algo * size * imp * - When makewhatis(8) encounters a FATAL parse error, it silently treats the file as formatted, which makes no sense @@ -174,13 +247,16 @@ what the manual says at the end of the description. The end result will be ENOENT for file names returned by mansearch() in manpage.file. + loc * exist * algo * size * imp ** - makewhatis(8) for preformatted pages: parse the section number from the header line and compare to the section number from the directory name + loc * exist * algo * size * imp ** - Does makewhatis(8) detect missing NAME sections, missing names, and missing descriptions in all the file formats? + loc * exist * algo * size * imp *** - clean up escape sequence handling, creating three classes: (1) fully implemented, or parsed and ignored without loss of content @@ -188,8 +264,10 @@ or serious mangling of formatting (e.g. \n) -> ERROR see textproc/mgdiff(1) for nice examples (3) undefined, just output the character -> perhaps WARNING + loc *** exist ** algo ** size ** imp *** (parser reorg helps) - kettenis wants base roff, ms, and me Fri, 1 Jan 2010 22:13:15 +0100 (CET) + loc ** exist ** algo ** size *** imp * --- compatibility checks ----------------------------------------------- @@ -199,6 +277,10 @@ - compare output to Heirloom roff, Solaris roff, and http://repo.or.cz/w/neatroff.git http://litcave.rudi.ir/ +- look at AT&T DWB http://www2.research.att.com/sw/download + Carsten Kunze has patches + Mon, 4 Aug 2014 17:01:28 +0200 + - look at pages generated from reStructeredText, e.g. devel/mercurial hg(1) These are a weird mixture of man(7) and custom autogenerated low-level roff stuff. Figure out to what extent we can cope. @@ -224,6 +306,11 @@ - check compatibility with the man(7) formatter https://raw.githubusercontent.com/rofl0r/hardcore-utils/master/man.c +- check compatibility with + http://ikiwiki.info/plugins/contrib/mandoc/ + https://github.com/schmonz/ikiwiki/compare/mandoc + Amitai Schlair Mon, 19 May 2014 14:05:53 -0400 + ************************************************************************ * formatting issues: ugly output ************************************************************************ @@ -236,10 +323,12 @@ ought to render "Key Length" with emphasis, too, see OpenBSD iked.conf(5). reported again Nicolas Joly via wiz@ Wed, 12 Oct 2011 00:20:00 +0200 + loc * exist *** algo *** size ** imp *** - empty phrases in .Bl column produce too few blanks try e.g. .Bl -column It Ta Ta reported by millert Fri, 02 Apr 2010 16:13:46 -0400 + loc * exist *** algo *** size * imp ** - .%T can have trailing punctuation. Currently, it puts the trailing punctuation into a trailing MDOC_TEXT element inside its own scope. @@ -249,11 +338,13 @@ slurp all arguments into one single text element - and one feature of in_line() - put trailing punctuation out of scope. Found in mount_nfs(8) and exports(5), search for "Appendix". + loc ** exist ** algo *** size * imp ** - Trailing punctuation after .%T triggers EOS spacing, at least outside .Rs (eek!). Simply setting ARGSFL_DELIM for .%T is not the right solution, it sends mandoc into an endless loop. reported by Nicolas Joly Sat, 17 Nov 2012 11:49:54 +0100 + loc * exist ** algo ** size * imp ** - global variables in the SYNOPSIS of section 3 pages .Vt vs .Vt/.Va vs .Ft/.Va vs .Ft/.Fa ... @@ -261,6 +352,7 @@ - in enclosures, mandoc sometimes fancies a bogus end of sentence reminded by jmc@ Thu, 23 Sep 2010 18:13:39 +0059 + loc * exist ** algo *** size * imp *** - formatting /usr/local/man/man1/latex2man.1 with groff and mandoc reveals lots of bugs both in groff and mandoc... @@ -273,6 +365,10 @@ Search the text "Routing tables". Also check what PostScript mode does when fixing this. reported by juanfra@ Wed, 04 Jun 2014 21:44:58 +0200 + instructions from juanfra@ Wed, 11 Jun 2014 02:21:01 +0200 + add a new <> block to the PDF files with /BaseFont /Courier + and change the /Name from /F0 to the new font (/F5 (?)). + loc * exist ** algo ** size * imp ** --- HTML issues -------------------------------------------------------- @@ -280,6 +376,20 @@ hints are easy to find on the web, e.g. http://stackoverflow.com/questions/1713048/ see also matthew@ Fri, 18 Jul 2014 19:25:12 -0700 + loc * exist * algo ** size * imp *** + +- jsg on icb, Nov 3, 2014: + try to guess Xr in man(7) for hyperlinking + +- The tables used to render the three-part page headers actually force + the width of the to the max-width given for . + Not yet sure how to fix that... + Observed by an Anonymous Coward on undeadly.org: + http://undeadly.org/cgi?action=article&sid=20140925064244&pid=1 + loc * exist * algo ** size * imp *** + +- consider whether can be used for Ar Dv Er Ev Fa Va. + from bentley@ Wed, 13 Aug 2014 09:17:55 -0600 - check https://github.com/trentm/mdocml @@ -287,42 +397,57 @@ * formatting issues: gratuitous differences ************************************************************************ +- .Fn reopens a new scope after punctuation in mandoc, + but closes its scope for good in groff. + Do we want to change mandoc or groff? + Steffen Nurpmeso Sat, 08 Nov 2014 13:34:59 +0100 + loc * exist ** algo ** size * imp ** + - .Rv (and probably .Ex) print different text if an `Nm' has been named or not (run a manual without `Nm blah' to see this). I'm not sure that this exists in the wild, but it's still an error. + loc * exist * algo * size * imp * (already done?) - In .Bl -bullet, the groff bullet is "+\b+\bo\bo", the mandoc bullet - is just "o\bo". + is just "o\bo". The problem is to not break ps/pdf when fixing. see for example OpenBSD ksh(1) + loc ** exist ** algo ** size * imp ** - In .Bl -enum -width 0n, groff continues one the same line after the number, mandoc breaks the line. mail to kristaps@ Mon, 20 Jul 2009 02:21:39 +0200 + loc * exist ** algo ** size * imp ** - .Pp between two .It in .Bl -column should produce one, not two blank lines, see e.g. login.conf(5). reported by jmc@ Sun, 17 Apr 2011 14:04:58 +0059 reported again by sthen@ Wed, 18 Jan 2012 02:09:39 +0000 (UTC) + loc * exist *** algo ** size * imp ** - If the *first* line after .It is .Pp, break the line right after the tag, do not pad with space characters before breaking. See the description of the a, c, and i commands in sed(1). + loc * exist ** algo ** size * imp ** - If the first line after .It is .D1, do not assert a blank line in between, see for example tmux(1). reported by nicm@ 13 Jan 2011 00:18:57 +0000 + loc * exist ** algo ** size * imp ** - Trailing punctuation after .It should trigger EOS spacing. reported by Nicolas Joly Sat, 17 Nov 2012 11:49:54 +0100 Probably, this should be fixed somewhere in termp_it_pre(), not sure. + loc * exist ** algo ** size * imp ** - .Nx 1.0a should be "NetBSD 1.0A", not "NetBSD 1.0a", see OpenBSD ccdconfig(8). + loc * exist * algo * size * imp ** - In .Bl -tag, if a tag exceeds the right margin and must be continued on the next line, it must be indented by -width, not width+1; see "rule block|pass" in OpenBSD ifconfig(8). + loc * exist *** algo ** size * imp ** - When the -width string contains macros, the macros must be rendered before measuring the width, for example @@ -332,17 +457,21 @@ The same applies to .Bl -column column widths; reported again by Nicolas Joly Thu, 1 Mar 2012 13:41:26 +0100 via wiz@ 5 Mar reported again by Franco Fichtner Fri, 27 Sep 2013 21:02:28 +0200 + loc *** exist *** algo *** size ** imp *** An easy partial fix would be to just skip the first word if it starts with a dot, including any following white space, when measuring. + loc * exist * algo * size * imp *** - The \& zero-width character counts as output. That is, when it is alone on a line between two .Pp, we want three blank lines, not two as in mandoc. + loc ** exist ** algo ** size * imp ** - Header lines of excessive length: Port OpenBSD man_term.c rev. 1.25 to mdoc_term.c and document it in mdoc(7) and man(7) COMPATIBILITY found while talking to Chris Bennett + loc * exist * algo * size * imp * - trailing whitespace must be ignored even when followed by a font escape, see for example @@ -350,6 +479,7 @@ \fBdig \fR operate in batch mode in dig(1). + loc ** exist ** algo ** size * imp ** ************************************************************************ * warning issues @@ -361,17 +491,29 @@ to refer to fill mode, not literal mode See the mail from Werner LEMBERG on the groff list, Fri, 14 Feb 2014 18:54:42 +0100 (CET) + loc * exist ** algo ** size * imp ** + +- warn about attempts to call non-callable macros + Steffen Nurpmeso Tue, 11 Nov 2014 22:55:16 +0100 + Note that formatting is inconsistent in groff. + .Fn Po prints "Po()", .Ar Sh prints "file ..." and no "Sh". + Relatively hard because the relevant code is scattered + all over mdoc_macro.c and all subtly different. + loc ** exist ** algo ** size ** imp ** - warn about "new sentence, new line" + loc ** exist ** algo *** size * imp ** - mandoc_special does not really check the escape sequence, but just the overall format + loc ** exist ** algo *** size ** imp ** - integrate mdoclint into mandoc ("end-of-line whitespace" thread) from jmc@ Mon, 13 Jul 2009 17:12:09 +0100 from kristaps@ Mon, 13 Jul 2009 18:34:53 +0200 from jmc@ Mon, 13 Jul 2009 17:45:37 +0059 from kristaps@ Mon, 13 Jul 2009 19:02:03 +0200 + (mostly done, check what remains) - -Tlint parser errors and warnings to stdout to tech@mdocml, naddy@ Wed, 28 Sep 2011 11:21:46 +0200 @@ -395,6 +537,9 @@ - mention /usr/share/misc/mdoc.template in mdoc(7)? +- Is all the content from http://www.std.com/obi/BSD/doc/usd/28.tbl/tbl + covered in tbl(7)? + ************************************************************************ * performance issues ************************************************************************ @@ -413,11 +558,15 @@ Several areas can be cleaned up to make mandoc even faster. These are - instead of re-initialising the roff predefined-strings set before each parse, create a read-only version the first time and copy it + loc * exist ** algo ** size * imp ** ************************************************************************ * structural issues ************************************************************************ +- Use libz directly instead of forking gunzip(1). + Suggested by bapt at FreeBSD among others. + - We use the input line number at several places to distinguish same-line from different-line input. That plainly doesn't work with user-defined macros, leading to random breakage. @@ -430,8 +579,25 @@ Several areas can be cleaned up to make mandoc even faster. These are Update both mdoc(7) and man(7) documentation. Triggered by Tim van der Molen Tue, 22 Feb 2011 20:30:45 +0100 +- struct mparse refactoring + Steffen Nurpmeso Thu, 04 Sep 2014 12:50:00 +0200 + - Consider creating some views that will make the database more readable from the sqlite3 shell. Consider using them to abstract from the database structure, too. suggested by espie@ Sat, 19 Apr 2014 14:52:57 +0200 +************************************************************************ +* CGI issues +************************************************************************ + + - Enable HTTP compression by detecting gzip encoding and filtering + output through libz. + - Sandbox (see OpenSSH). + - Enable caching support via HTTP 304 and If-Modified-Since. + - Allow for cgi.h to be overridden by CGI environment variables. + Otherwise, binary distributions will inherit the compile-time + behaviour, which is not optimal. + - Have Mac OSX systems automatically disable -static compilation of the + CGI: -static isn't supported. + diff --git a/apropos.1 b/apropos.1 index 14682420ff00..e2075349f553 100644 --- a/apropos.1 +++ b/apropos.1 @@ -1,4 +1,4 @@ -.\" $Id: apropos.1,v 1.29 2014/04/24 00:28:19 schwarze Exp $ +.\" $Id: apropos.1,v 1.36 2014/10/25 01:03:52 schwarze Exp $ .\" .\" Copyright (c) 2011, 2012 Kristaps Dzonsons .\" Copyright (c) 2011, 2012, 2014 Ingo Schwarze @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: April 24 2014 $ +.Dd $Mdocdate: October 25 2014 $ .Dt APROPOS 1 .Os .Sh NAME @@ -24,6 +24,7 @@ .Nd search manual page databases .Sh SYNOPSIS .Nm +.Op Fl acfhklVw .Op Fl C Ar file .Op Fl M Ar path .Op Fl m Ar path @@ -41,7 +42,7 @@ utilities query manual page databases generated by evaluating .Ar expression for each file in each database. -By default, it displays the names, section numbers, and description lines +By default, they display the names, section numbers, and description lines of all matching manuals. .Pp By default, @@ -56,17 +57,82 @@ over manual names and descriptions .Pq the Li \&Nm No and Li \&Nd No macro keys . Multiple terms imply pairwise .Fl o . -.Nm whatis -maps terms only to case-sensitive manual names. .Pp -Its arguments are as follows: +.Nm whatis +is a synonym for +.Nm +.Fl f . +.Pp +The options are as follows: .Bl -tag -width Ds +.It Fl a +Instead of showing only the title lines, show the complete manual pages, +just like +.Xr man 1 +.Fl a +would. +If the standard output is a terminal device and +.Fl c +is not specified, use +.Xr more 1 +to paginate them. +In +.Fl a +mode, the options +.Fl IKOTW +described in the +.Xr mandoc 1 +manual are also available. .It Fl C Ar file Specify an alternative configuration .Ar file in .Xr man.conf 5 format. +.It Fl c +In +.Fl a +mode, copy the formatted manual pages to the standard output without using +.Xr more 1 +to paginate them. +.It Fl f +Search for all words in +.Ar expression +in manual page names only. +The search is case insensitive and matches whole words only. +In this mode, macro keys, comparison operators, and logical operators +are not available. +This overrides any earlier +.Fl k +and +.Fl l +options. +.It Fl h +Instead of showing the title lines, show the SYNOPSIS sections, just like +.Xr man 1 +.Fl h +would. +.It Fl k +Support the full +.Ar expression +syntax. +This overrides any earlier +.Fl f +and +.Fl l +options. +It is the default for +.Nm . +.It Fl l +An alias for +.Xr mandoc 1 +.Fl a . +This overrides any earlier +.Fl f , +.Fl k , +and +.Fl w +options. .It Fl M Ar path Use the colon-separated path instead of the default list of paths searched for @@ -96,6 +162,14 @@ By default, pages from all sections are shown. See .Xr man 1 for a listing of sections. +.It Fl V +Print version and exit. +.It Fl w +Instead of showing title lines, show the pathnames of the matching +manual pages, just like +.Xr man 1 +.Fl w +would. .El .Pp An @@ -165,11 +239,6 @@ is evaluated case-insensitively. Has no effect on substring terms. .El .Pp -.Nm whatis -considers an -.Ar expression -to consist of an opaque keyword. -.Pp Results are sorted by manual sections and names, with output formatted as .Pp .D1 name[, name...](sec) \- description @@ -270,7 +339,12 @@ Text production: .It Li \&Dx Ta Dx No version reference .El .Sh ENVIRONMENT -.Bl -tag -width MANPATH +.Bl -tag -width MANPAGER +.It Ev MANPAGER +Any non-empty value of the environment variable +.Ev MANPAGER +will be used instead of the standard pagination program, +.Xr more 1 . .It Ev MANPATH The standard search path used by .Xr man 1 @@ -288,6 +362,13 @@ or if it contains two adjacent colons, the standard search path is inserted between the colons. If none of these conditions are met, it overrides the standard search path. +.It Ev PAGER +Specifies the pagination program to use when +.Ev MANPAGER +is not defined. +If neither PAGER nor MANPAGER is defined, +.Pa /usr/bin/more Fl s +will be used. .El .Sh FILES .Bl -tag -width "/etc/man.conf" -compact @@ -349,11 +430,19 @@ The following two invocations are equivalent: .Xr re_format 7 , .Xr makewhatis 8 .Sh HISTORY -An +Part of the functionality of +.Nm whatis +was already provided by the former +.Nm manwhere +utility in +.Bx 1 . +The .Nm -utility first appeared in +and +.Nm whatis +utilities first appeared in .Bx 2 . -It was rewritten from scratch for +They were rewritten from scratch for .Ox 5.6 . .Pp The @@ -373,13 +462,23 @@ and and .Fl s in -.Ox 4.5 . +.Ox 4.5 +for +.Nm +and in +.Ox 5.6 +for +.Nm whatis . .Sh AUTHORS .An -nosplit .An Bill Joy -wrote the original +wrote +.Nm manwhere +in 1977 and the original .Bx .Nm +and +.Nm whatis in February 1979. The current version was written by .An Kristaps Dzonsons Aq Mt kristaps@bsd.lv diff --git a/apropos.c b/apropos.c deleted file mode 100644 index 80b6bc6d036e..000000000000 --- a/apropos.c +++ /dev/null @@ -1,123 +0,0 @@ -/* $Id: apropos.c,v 1.39 2014/04/20 16:46:04 schwarze Exp $ */ -/* - * Copyright (c) 2012 Kristaps Dzonsons - * Copyright (c) 2013 Ingo Schwarze - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "manpath.h" -#include "mansearch.h" - - -int -main(int argc, char *argv[]) -{ - int ch, whatis; - struct mansearch search; - size_t i, sz; - struct manpage *res; - struct manpaths paths; - char *defpaths, *auxpaths; - char *conf_file; - char *progname; - const char *outkey; - extern char *optarg; - extern int optind; - - progname = strrchr(argv[0], '/'); - if (progname == NULL) - progname = argv[0]; - else - ++progname; - - whatis = (0 == strncmp(progname, "whatis", 6)); - - memset(&paths, 0, sizeof(struct manpaths)); - memset(&search, 0, sizeof(struct mansearch)); - - auxpaths = defpaths = NULL; - conf_file = NULL; - outkey = "Nd"; - - while (-1 != (ch = getopt(argc, argv, "C:M:m:O:S:s:"))) - switch (ch) { - case 'C': - conf_file = optarg; - break; - case 'M': - defpaths = optarg; - break; - case 'm': - auxpaths = optarg; - break; - case 'O': - outkey = optarg; - break; - case 'S': - search.arch = optarg; - break; - case 's': - search.sec = optarg; - break; - default: - goto usage; - } - - argc -= optind; - argv += optind; - - if (0 == argc) - goto usage; - - search.deftype = whatis ? TYPE_Nm : TYPE_Nm | TYPE_Nd; - search.flags = whatis ? MANSEARCH_WHATIS : 0; - - manpath_parse(&paths, conf_file, defpaths, auxpaths); - mansearch_setup(1); - ch = mansearch(&search, &paths, argc, argv, outkey, &res, &sz); - manpath_free(&paths); - - if (0 == ch) - goto usage; - - for (i = 0; i < sz; i++) { - printf("%s - %s\n", res[i].names, - NULL == res[i].output ? "" : res[i].output); - free(res[i].file); - free(res[i].names); - free(res[i].output); - } - - free(res); - mansearch_setup(0); - return(sz ? EXIT_SUCCESS : EXIT_FAILURE); -usage: - fprintf(stderr, "usage: %s [-C file] [-M path] [-m path] " - "[-O outkey] " - "[-S arch] [-s section]%s ...\n", progname, - whatis ? " name" : "\n expression"); - return(EXIT_FAILURE); -} diff --git a/arch.in b/arch.in deleted file mode 100644 index a22ffd58ba7b..000000000000 --- a/arch.in +++ /dev/null @@ -1,112 +0,0 @@ -/* $Id: arch.in,v 1.15 2014/04/27 22:42:15 schwarze Exp $ */ -/* - * Copyright (c) 2009 Kristaps Dzonsons - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* - * This file defines the architecture token of the .Dt prologue macro. - * All architectures that your system supports (or the manuals of your - * system) should be included here. The right-hand-side is the - * formatted output. - * - * Be sure to escape strings. - * - * REMEMBER TO ADD NEW ARCHITECTURES TO MDOC.7! - */ - -LINE("acorn26", "Acorn26") -LINE("acorn32", "Acorn32") -LINE("algor", "Algor") -LINE("alpha", "Alpha") -LINE("amd64", "AMD64") -LINE("amiga", "Amiga") -LINE("amigappc", "AmigaPPC") -LINE("arc", "ARC") -LINE("arm", "ARM") -LINE("arm26", "ARM26") -LINE("arm32", "ARM32") -LINE("armish", "ARMISH") -LINE("armv7", "ARMv7") -LINE("aviion", "AViiON") -LINE("atari", "ATARI") -LINE("bebox", "BeBox") -LINE("cats", "cats") -LINE("cesfic", "CESFIC") -LINE("cobalt", "Cobalt") -LINE("dreamcast", "Dreamcast") -LINE("emips", "EMIPS") -LINE("evbarm", "evbARM") -LINE("evbmips", "evbMIPS") -LINE("evbppc", "evbPPC") -LINE("evbsh3", "evbSH3") -LINE("ews4800mips", "EWS4800MIPS") -LINE("hp300", "HP300") -LINE("hp700", "HP700") -LINE("hpcarm", "HPCARM") -LINE("hpcmips", "HPCMIPS") -LINE("hpcsh", "HPCSH") -LINE("hppa", "HPPA") -LINE("hppa64", "HPPA64") -LINE("ia64", "ia64") -LINE("i386", "i386") -LINE("ibmnws", "IBMNWS") -LINE("iyonix", "Iyonix") -LINE("landisk", "LANDISK") -LINE("loongson", "Loongson") -LINE("luna68k", "LUNA68K") -LINE("luna88k", "LUNA88K") -LINE("m68k", "m68k") -LINE("mac68k", "Mac68k") -LINE("macppc", "MacPPC") -LINE("mips", "MIPS") -LINE("mips64", "MIPS64") -LINE("mipsco", "MIPSCo") -LINE("mmeye", "mmEye") -LINE("mvme68k", "MVME68k") -LINE("mvme88k", "MVME88k") -LINE("mvmeppc", "MVMEPPC") -LINE("netwinder", "NetWinder") -LINE("news68k", "NeWS68k") -LINE("newsmips", "NeWSMIPS") -LINE("next68k", "NeXT68k") -LINE("octeon", "OCTEON") -LINE("ofppc", "OFPPC") -LINE("palm", "Palm") -LINE("pc532", "PC532") -LINE("playstation2", "PlayStation2") -LINE("pmax", "PMAX") -LINE("pmppc", "pmPPC") -LINE("powerpc", "PowerPC") -LINE("prep", "PReP") -LINE("rs6000", "RS6000") -LINE("sandpoint", "Sandpoint") -LINE("sbmips", "SBMIPS") -LINE("sgi", "SGI") -LINE("sgimips", "SGIMIPS") -LINE("sh3", "SH3") -LINE("shark", "Shark") -LINE("socppc", "SOCPPC") -LINE("solbourne", "Solbourne") -LINE("sparc", "SPARC") -LINE("sparc64", "SPARC64") -LINE("sun2", "Sun2") -LINE("sun3", "Sun3") -LINE("tahoe", "Tahoe") -LINE("vax", "VAX") -LINE("x68k", "X68k") -LINE("x86", "x86") -LINE("x86_64", "x86_64") -LINE("xen", "Xen") -LINE("zaurus", "Zaurus") diff --git a/att.c b/att.c index 059639af37aa..a1703ebcc662 100644 --- a/att.c +++ b/att.c @@ -1,4 +1,4 @@ -/* $Id: att.c,v 1.11 2014/04/20 16:46:04 schwarze Exp $ */ +/* $Id: att.c,v 1.13 2014/11/28 18:57:31 schwarze Exp $ */ /* * Copyright (c) 2009 Kristaps Dzonsons * @@ -14,24 +14,36 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_CONFIG_H #include "config.h" -#endif +#include #include #include "mdoc.h" #include "libmdoc.h" #define LINE(x, y) \ - if (0 == strcmp(p, x)) return(y); + if (0 == strcmp(p, x)) return(y) const char * mdoc_a2att(const char *p) { -#include "att.in" + LINE("v1", "Version\\~1 AT&T UNIX"); + LINE("v2", "Version\\~2 AT&T UNIX"); + LINE("v3", "Version\\~3 AT&T UNIX"); + LINE("v4", "Version\\~4 AT&T UNIX"); + LINE("v5", "Version\\~5 AT&T UNIX"); + LINE("v6", "Version\\~6 AT&T UNIX"); + LINE("v7", "Version\\~7 AT&T UNIX"); + LINE("32v", "Version\\~32V AT&T UNIX"); + LINE("III", "AT&T System\\~III UNIX"); + LINE("V", "AT&T System\\~V UNIX"); + LINE("V.1", "AT&T System\\~V Release\\~1 UNIX"); + LINE("V.2", "AT&T System\\~V Release\\~2 UNIX"); + LINE("V.3", "AT&T System\\~V Release\\~3 UNIX"); + LINE("V.4", "AT&T System\\~V Release\\~4 UNIX"); return(NULL); } diff --git a/att.in b/att.in deleted file mode 100644 index b4ef822158f8..000000000000 --- a/att.in +++ /dev/null @@ -1,40 +0,0 @@ -/* $Id: att.in,v 1.8 2011/07/31 17:30:33 schwarze Exp $ */ -/* - * Copyright (c) 2009 Kristaps Dzonsons - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* - * This file defines the AT&T versions of the .At macro. This probably - * isn't going to change. The right-hand side is the formatted string. - * - * Be sure to escape strings. - * The non-breaking blanks prevent ending an output line right before - * a number. Groff prevent line breaks at the same places. - */ - -LINE("v1", "Version\\~1 AT&T UNIX") -LINE("v2", "Version\\~2 AT&T UNIX") -LINE("v3", "Version\\~3 AT&T UNIX") -LINE("v4", "Version\\~4 AT&T UNIX") -LINE("v5", "Version\\~5 AT&T UNIX") -LINE("v6", "Version\\~6 AT&T UNIX") -LINE("v7", "Version\\~7 AT&T UNIX") -LINE("32v", "Version\\~32V AT&T UNIX") -LINE("III", "AT&T System\\~III UNIX") -LINE("V", "AT&T System\\~V UNIX") -LINE("V.1", "AT&T System\\~V Release\\~1 UNIX") -LINE("V.2", "AT&T System\\~V Release\\~2 UNIX") -LINE("V.3", "AT&T System\\~V Release\\~3 UNIX") -LINE("V.4", "AT&T System\\~V Release\\~4 UNIX") diff --git a/cgi.c b/cgi.c index 1e38e3d872a5..65064ab2ad6c 100644 --- a/cgi.c +++ b/cgi.c @@ -1,4 +1,4 @@ -/* $Id: cgi.c,v 1.92 2014/08/05 15:29:30 schwarze Exp $ */ +/* $Id: cgi.c,v 1.102 2014/11/26 17:55:27 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2014 Ingo Schwarze @@ -15,9 +15,10 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_CONFIG_H #include "config.h" -#endif + +#include +#include #include #include @@ -91,14 +92,14 @@ static const char *const sec_names[] = { "All Sections", "1 - General Commands", "2 - System Calls", - "3 - Subroutines", - "3p - Perl Subroutines", - "4 - Special Files", + "3 - Library Functions", + "3p - Perl Library", + "4 - Device Drivers", "5 - File Formats", "6 - Games", - "7 - Macros and Conventions", - "8 - Maintenance Commands", - "9 - Kernel Interface" + "7 - Miscellaneous Information", + "8 - System Manager\'s Manual", + "9 - Kernel Developer\'s Manual" }; static const int sec_MAX = sizeof(sec_names) / sizeof(char *); @@ -162,8 +163,7 @@ http_printquery(const struct req *req, const char *sep) printf("%sarch=", sep); http_print(req->q.arch); } - if (NULL != req->q.manpath && - strcmp(req->q.manpath, req->p[0])) { + if (strcmp(req->q.manpath, req->p[0])) { printf("%smanpath=", sep); http_print(req->q.manpath); } @@ -297,11 +297,6 @@ http_parse(struct req *req, const char *qs) if (*qs != '\0') qs++; } - - /* Fall back to the default manpath. */ - - if (req->q.manpath == NULL) - req->q.manpath = mandoc_strdup(req->p[0]); } static void @@ -375,13 +370,10 @@ resp_begin_html(int code, const char *msg) resp_begin_http(code, msg); - printf("\n" + printf("\n" "\n" "\n" - "\n" + "\n" "\n" ""); for (i = 0; i < (int)req->psz; i++) { printf("