svn commit: r365677 - head/sys/arm/broadcom/bcm2835
Author: karels Date: Sat Sep 12 23:49:43 2020 New Revision: 365677 URL: https://svnweb.freebsd.org/changeset/base/365677 Log: bcm2838_pci.c: Respect DMA limits of controller. Fixes for Raspberry Pi 4B PCIe / USB: - Pass through a DMA tag for the controller. - In theory the controller can access the lower 3 GB, but testing found that unreliable. OpenBSD also restricts DMA to the lowest 960 MiB. - Rename some constants to be a bit more meaningful. Submitted by: Robert Crowston, crowston at protonmail.com Reviewed by: mkarels, outside reviewers Differential Revision:https://reviews.freebsd.org/D26344 Modified: head/sys/arm/broadcom/bcm2835/bcm2838_pci.c Modified: head/sys/arm/broadcom/bcm2835/bcm2838_pci.c == --- head/sys/arm/broadcom/bcm2835/bcm2838_pci.c Sat Sep 12 23:23:16 2020 (r365676) +++ head/sys/arm/broadcom/bcm2835/bcm2838_pci.c Sat Sep 12 23:49:43 2020 (r365677) @@ -57,9 +57,6 @@ __FBSDID("$FreeBSD$"); #include "pcib_if.h" #include "msi_if.h" -extern struct bus_space memmap_bus; - -#define BUS_SPACE_3G_MAXADDR 0xc000 #define PCI_ID_VAL30x43c #define CLASS_SHIFT0x10 #define SUBCLASS_SHIFT 0x8 @@ -69,18 +66,18 @@ extern struct bus_space memmap_bus; #define BRIDGE_DISABLE_FLAG0x1 #define BRIDGE_RESET_FLAG 0x2 #define REG_BRIDGE_SERDES_MODE 0x4204 -#define REG_BRIDGE_CONFIG 0x4008 -#define REG_BRIDGE_MEM_WINDOW_LOW 0x4034 -#define REG_BRIDGE_MEM_WINDOW_HIGH 0x4038 -#define REG_BRIDGE_MEM_WINDOW_10x403c +#define REG_DMA_CONFIG 0x4008 +#define REG_DMA_WINDOW_LOW 0x4034 +#define REG_DMA_WINDOW_HIGH0x4038 +#define REG_DMA_WINDOW_1 0x403c #define REG_BRIDGE_GISB_WINDOW 0x402c #define REG_BRIDGE_STATE 0x4068 #define REG_BRIDGE_LINK_STATE 0x00bc -#define REG_BRIDGE_BUS_WINDOW_LOW 0x400c -#define REG_BRIDGE_BUS_WINDOW_HIGH 0x4010 -#define REG_BRIDGE_CPU_WINDOW_LOW 0x4070 -#define REG_BRIDGE_CPU_WINDOW_START_HIGH 0x4080 -#define REG_BRIDGE_CPU_WINDOW_END_HIGH 0x4084 +#define REG_BUS_WINDOW_LOW 0x400c +#define REG_BUS_WINDOW_HIGH0x4010 +#define REG_CPU_WINDOW_LOW 0x4070 +#define REG_CPU_WINDOW_START_HIGH 0x4080 +#define REG_CPU_WINDOW_END_HIGH0x4084 #define REG_MSI_ADDR_LOW 0x4044 #define REG_MSI_ADDR_HIGH 0x4048 @@ -95,12 +92,27 @@ extern struct bus_space memmap_bus; #define REG_EP_CONFIG_DATA 0x8000 /* - * These values were obtained from runtime inspection of a Linux system using a - * JTAG. The very limited documentation I have obtained from Broadcom does not - * explain how to compute them. + * The system memory controller can address up to 16 GiB of physical memory + * (although at time of writing the largest memory size available for purchase + * is 8 GiB). However, the system DMA controller is capable of accessing only a + * limited portion of the address space. Worse, the PCI-e controller has further + * constraints for DMA, and those limitations are not wholly clear to the + * author. NetBSD and Linux allow DMA on the lower 3 GiB of the physical memory, + * but experimentation shows DMA performed above 960 MiB results in data + * corruption with this driver. The limit of 960 MiB is taken from OpenBSD, but + * apparently that value was chosen for satisfying a constraint of an unrelated + * peripheral. + * + * Whatever the true maximum address, 960 MiB works. */ -#define REG_VALUE_4GB_WINDOW 0x11 -#define REG_VALUE_4GB_CONFIG 0x88003000 +#define DMA_HIGH_LIMIT 0x3c00 +#define MAX_MEMORY_LOG20x21 +#define REG_VALUE_DMA_WINDOW_LOW (MAX_MEMORY_LOG2 - 0xf) +#define REG_VALUE_DMA_WINDOW_HIGH 0x0 +#define DMA_WINDOW_ENABLE 0x3000 +#define REG_VALUE_DMA_WINDOW_CONFIG\ +(((MAX_MEMORY_LOG2 - 0xf) << 0x1b) | DMA_WINDOW_ENABLE) + #define REG_VALUE_MSI_CONFIG 0xffe06540 struct bcm_pcib_irqsrc { @@ -112,6 +124,7 @@ struct bcm_pcib_irqsrc { struct bcm_pcib_softc { struct generic_pcie_fdt_softc base; device_tdev; + bus_dma_tag_t dmat; struct mtx config_mtx; struct mtx msi_mtx; struct resource *msi_irq_res; @@ -142,6 +155,15 @@ bcm_pcib_probe(device_t dev) return (BUS_PROBE_DEFAULT); } +static bus_dma_tag_t +bcm_pcib_get_dma_tag(device_t dev, device_t child) +{ + struct bcm_pcib_softc *sc; + + sc = device_get_softc(dev); + return (s
Re: svn commit: r365071 - in head/sys: net net/altq net/route net80211 netgraph netgraph/atm netgraph/atm/ccatm netgraph/atm/sscfu netgraph/atm/sscop netgraph/atm/uni netgraph/bluetooth/common netgrap
> From: Ed Maste > Date: Sat, 5 Sep 2020 17:26:47 -0400 > Subject: Re: svn commit: r365071 - in head/sys: net net/altq net/route > net80211 netgraph netgraph/atm netgraph/atm/ccatm netgraph/atm/sscfu > netgraph/atm/sscop netgraph/atm/uni netgraph/bluetooth/common netgraph... > On Sat, 5 Sep 2020 at 16:41, Warner Losh wrote: > > > >> Fixed: > >> - *_FOREACH now has a space before (, equivalent to for (;;) > > > > Except pretty much everywhere we don't have a space there... > Why not? Why should TAILQ_FOREACH have a different style from a for loop? Because it is a macro, maybe? And all the other invocations are done that way. > > broke all alignment of variables and comments that were done. > > broke purposely outdented code in statistics function > > broke all err() calls to wrap too much > I had all of these under "indifferent" already, or are more examples > of already covered cases (e.g. what seems to be string argument > wrapping). I don't consider those indifferent. > > extra headers still included. > This is probably not the job of a formatter though. > >> - function argument wrapping (see write_glyph_buf) > >> - leading indentation and args-per-line (print_font_info) > > > > An interesting experiment, but there's far more worse after than before. > > The rearranging of carefully aligned elements is an especially galling > > change for some people (myself included). > I disagree this is far worse. If we fixed the wrapping on the second > line of if/for conditions I'd say the benefit of letting tooling take > care of the formatting outweighs the perhaps slightly less appealing > formatting. I'm with Warner on this. I saw a lot to dislike in the changes, and very little actual improvement. If we were starting from scratch, I might be willing to accept the changes to have a formatter (albeit begrudingly), but we are not starting from scratch. The churn would be horrible, and the benefit very little in comparison. Interesting experiment, but let's keep it just an experiment. Mike ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r362353 - in head/sys: arm64/broadcom/genet dev/mii
Author: karels Date: Thu Jun 18 23:57:10 2020 New Revision: 362353 URL: https://svnweb.freebsd.org/changeset/base/362353 Log: Add support for bcm54213PE in brgphy. This chip is used in the Rasperry Pi 4, and is supported by the if_genet driver. Currently we use the ukphy mii driver, this patch switches over to the brgphy mii driver instead. To support the rgmii-rxid phy mode, which is now the default in the Linux dtb, we add support for clock skewing. These changes are taken from OpenBSD and NetBSD, except for the bailout in brgphy_bcm54xx_clock_delay() in rgmii mode, which was found necessary after testing. Submitted by: Robert Crowston, crowston at protomail.com Differential Revision:https://reviews.freebsd.org/D25251 Modified: head/sys/arm64/broadcom/genet/if_genet.c head/sys/dev/mii/brgphy.c head/sys/dev/mii/brgphyreg.h head/sys/dev/mii/miidevs head/sys/dev/mii/miivar.h Modified: head/sys/arm64/broadcom/genet/if_genet.c == --- head/sys/arm64/broadcom/genet/if_genet.cThu Jun 18 23:31:56 2020 (r362352) +++ head/sys/arm64/broadcom/genet/if_genet.cThu Jun 18 23:57:10 2020 (r362353) @@ -237,7 +237,7 @@ gen_attach(device_t dev) { struct ether_addr eaddr; struct gen_softc *sc; - int major, minor, error; + int major, minor, error, mii_flags; bool eaddr_found; sc = device_get_softc(dev); @@ -315,9 +315,24 @@ gen_attach(device_t dev) if_setcapenable(sc->ifp, if_getcapabilities(sc->ifp)); /* Attach MII driver */ + mii_flags = 0; + switch (sc->phy_mode) + { + case MII_CONTYPE_RGMII_ID: + mii_flags |= MIIF_RX_DELAY | MIIF_TX_DELAY; + break; + case MII_CONTYPE_RGMII_RXID: + mii_flags |= MIIF_RX_DELAY; + break; + case MII_CONTYPE_RGMII_TXID: + mii_flags |= MIIF_TX_DELAY; + break; + default: + break; + } error = mii_attach(dev, &sc->miibus, sc->ifp, gen_media_change, gen_media_status, BMSR_DEFCAPMASK, MII_PHY_ANY, MII_OFFSET_ANY, - MIIF_DOPAUSE); + mii_flags); if (error != 0) { device_printf(dev, "cannot attach PHY\n"); goto fail; @@ -371,6 +386,7 @@ gen_get_phy_mode(device_t dev) switch (type) { case MII_CONTYPE_RGMII: + case MII_CONTYPE_RGMII_ID: case MII_CONTYPE_RGMII_RXID: case MII_CONTYPE_RGMII_TXID: sc->phy_mode = type; @@ -791,10 +807,17 @@ gen_init_locked(struct gen_softc *sc) if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) return; - if (sc->phy_mode == MII_CONTYPE_RGMII || - sc->phy_mode == MII_CONTYPE_RGMII_RXID) - WR4(sc, GENET_SYS_PORT_CTRL, - GENET_SYS_PORT_MODE_EXT_GPHY); + switch (sc->phy_mode) + { + case MII_CONTYPE_RGMII: + case MII_CONTYPE_RGMII_ID: + case MII_CONTYPE_RGMII_RXID: + case MII_CONTYPE_RGMII_TXID: + WR4(sc, GENET_SYS_PORT_CTRL, GENET_SYS_PORT_MODE_EXT_GPHY); + break; + default: + WR4(sc, GENET_SYS_PORT_CTRL, 0); + } gen_set_enaddr(sc); @@ -1649,6 +1672,8 @@ gen_update_link_locked(struct gen_softc *sc) val |= GENET_EXT_RGMII_OOB_RGMII_MODE_EN; if (sc->phy_mode == MII_CONTYPE_RGMII) val |= GENET_EXT_RGMII_OOB_ID_MODE_DISABLE; + else + val &= ~GENET_EXT_RGMII_OOB_ID_MODE_DISABLE; WR4(sc, GENET_EXT_RGMII_OOB_CTRL, val); val = RD4(sc, GENET_UMAC_CMD); Modified: head/sys/dev/mii/brgphy.c == --- head/sys/dev/mii/brgphy.c Thu Jun 18 23:31:56 2020(r362352) +++ head/sys/dev/mii/brgphy.c Thu Jun 18 23:57:10 2020(r362353) @@ -115,6 +115,7 @@ static void brgphy_fixup_ber_bug(struct mii_softc *); static voidbrgphy_fixup_crc_bug(struct mii_softc *); static voidbrgphy_fixup_jitter_bug(struct mii_softc *); static voidbrgphy_ethernet_wirespeed(struct mii_softc *); +static voidbrgphy_bcm54xx_clock_delay(struct mii_softc *); static voidbrgphy_jumbo_settings(struct mii_softc *, u_long); static const struct mii_phydesc brgphys[] = { @@ -158,6 +159,7 @@ static const struct mii_phydesc brgphys[] = { MII_PHY_DESC(BROADCOM3, BCM5720C), MII_PHY_DESC(BROADCOM3, BCM57765), MII_PHY_DESC(BROADCOM3, BCM57780), + MII_PHY_DESC(BROADCOM4, BCM54213PE), MII_PHY_DESC(BROADCOM4, BCM5725C), MII_PHY_DESC(xxBROADCOM_ALT1, BCM5906), MII_PHY_END @@ -414,6 +416,12 @@ brgphy_service(struct mii_softc *sc, struct mii_data * break; } break; +
svn commit: r361642 - head/sys/arm64/broadcom/genet
Author: karels Date: Sat May 30 02:09:36 2020 New Revision: 361642 URL: https://svnweb.freebsd.org/changeset/base/361642 Log: genet: workaround for problem with ICMPv6 echo replies The ICMPv6 echo reply is constructed with the IPv6 header too close to the beginning of a packet for an Ethernet header to be prepended, so we end up with an mbuf containing just the Ethernet header. The GENET controller doesn't seem to handle this, with or without transmit checksum offload. At least until we have chip documentation, do a pullup to satisfy the chip. Hopefully this can be fixed properly in the future. Modified: head/sys/arm64/broadcom/genet/if_genet.c Modified: head/sys/arm64/broadcom/genet/if_genet.c == --- head/sys/arm64/broadcom/genet/if_genet.cSat May 30 02:02:34 2020 (r361641) +++ head/sys/arm64/broadcom/genet/if_genet.cSat May 30 02:09:36 2020 (r361642) @@ -76,6 +76,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#define ICMPV6_HACK/* workaround for chip issue */ +#ifdef ICMPV6_HACK +#include +#endif #include "syscon_if.h" #include "miibus_if.h" @@ -968,6 +972,36 @@ gen_encap(struct gen_softc *sc, struct mbuf **mp) q = &sc->tx_queue[DEF_TXQUEUE]; m = *mp; +#ifdef ICMPV6_HACK + /* +* Reflected ICMPv6 packets, e.g. echo replies, tend to get laid +* out with only the Ethernet header in the first mbuf, and this +* doesn't seem to work. +*/ +#define ICMP6_LEN (sizeof(struct ether_header) + sizeof(struct ip6_hdr) + \ + sizeof(struct icmp6_hdr)) + if (m->m_len == sizeof(struct ether_header)) { + int ether_type = mtod(m, struct ether_header *)->ether_type; + if (ntohs(ether_type) == ETHERTYPE_IPV6 && + m->m_next->m_len >= sizeof(struct ip6_hdr)) { + struct ip6_hdr *ip6; + + ip6 = mtod(m->m_next, struct ip6_hdr *); + if (ip6->ip6_nxt == IPPROTO_ICMPV6) { + m = m_pullup(m, + MIN(m->m_pkthdr.len, ICMP6_LEN)); + if (m == NULL) { + if (sc->ifp->if_flags & IFF_DEBUG) + device_printf(sc->dev, + "ICMPV6 pullup fail\n"); + *mp = NULL; + return (ENOMEM); + } + } + } + } +#undef ICMP6_LEN +#endif if ((if_getcapenable(sc->ifp) & (IFCAP_TXCSUM | IFCAP_TXCSUM_IPV6)) != 0) { csum_flags = m->m_pkthdr.csum_flags; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r361641 - head/sys/arm64/broadcom/genet
Author: karels Date: Sat May 30 02:02:34 2020 New Revision: 361641 URL: https://svnweb.freebsd.org/changeset/base/361641 Log: genet: fix issues with transmit checksum offload Fix problem with ICMP echo replies: check only deferred data checksum flags, and not the received checksum status bits, when checking whether a packet has a deferred checksum; otherwise echo replies are corrupted because the received checksum status bits are still present. Fix some unhandled cases in packet shuffling for checksum offload. Modified: head/sys/arm64/broadcom/genet/if_genet.c Modified: head/sys/arm64/broadcom/genet/if_genet.c == --- head/sys/arm64/broadcom/genet/if_genet.cSat May 30 01:48:12 2020 (r361640) +++ head/sys/arm64/broadcom/genet/if_genet.cSat May 30 02:02:34 2020 (r361641) @@ -948,6 +948,9 @@ gen_start(if_t ifp) GEN_UNLOCK(sc); } +/* Test for any delayed checksum */ +#define CSUM_DELAY_ANY (CSUM_TCP | CSUM_UDP | CSUM_IP6_TCP | CSUM_IP6_UDP) + static int gen_encap(struct gen_softc *sc, struct mbuf **mp) { @@ -978,12 +981,11 @@ gen_encap(struct gen_softc *sc, struct mbuf **mp) } offset = gen_parse_tx(m, csum_flags); sb = mtod(m, struct statusblock *); - if (csum_flags != 0) { + if ((csum_flags & CSUM_DELAY_ANY) != 0) { csuminfo = (offset << TXCSUM_OFF_SHIFT) | (offset + csumdata); - if (csum_flags & (CSUM_TCP | CSUM_UDP)) - csuminfo |= TXCSUM_LEN_VALID; - if (csum_flags & CSUM_UDP) + csuminfo |= TXCSUM_LEN_VALID; + if (csum_flags & (CSUM_UDP | CSUM_IP6_UDP)) csuminfo |= TXCSUM_UDP; sb->txcsuminfo = csuminfo; } else @@ -1045,7 +1047,7 @@ gen_encap(struct gen_softc *sc, struct mbuf **mp) if (i == 0) { length_status |= GENET_TX_DESC_STATUS_SOP | GENET_TX_DESC_STATUS_CRC; - if (csum_flags != 0) + if ((csum_flags & CSUM_DELAY_ANY) != 0) length_status |= GENET_TX_DESC_STATUS_CKSUM; } if (i == nsegs - 1) @@ -1087,6 +1089,7 @@ static int gen_parse_tx(struct mbuf *m, int csum_flags) { int offset, off_in_m; + bool copy = false, shift = false; u_char *p, *copy_p = NULL; struct mbuf *m0 = m; uint16_t ether_type; @@ -1098,22 +1101,44 @@ gen_parse_tx(struct mbuf *m, int csum_flags) m = m->m_next; off_in_m = 0; p = mtod(m, u_char *); + copy = true; } else { + /* +* If statusblock is not at beginning of mbuf (likely), +* then remember to move mbuf contents down before copying +* after them. +*/ + if ((m->m_flags & M_EXT) == 0 && m->m_data != m->m_pktdat) + shift = true; p = mtodo(m, sizeof(struct statusblock)); off_in_m = sizeof(struct statusblock); } -/* If headers need to be copied contiguous to statusblock, do so. */ -#define COPY(size) { \ - if (copy_p != NULL) { \ - int hsize = size; \ - bcopy(p, copy_p, hsize);\ - m0->m_len += hsize; \ - m0->m_pkthdr.len += hsize; /* unneeded */ \ - copy_p += hsize;\ - m->m_len -= hsize; \ - m->m_data += hsize; \ - } \ +/* + * If headers need to be copied contiguous to statusblock, do so. + * If copying to the internal mbuf data area, and the status block + * is not at the beginning of that area, shift the status block (which + * is empty) and following data. + */ +#define COPY(size) { \ + int hsize = size; \ + if (copy) { \ + if (shift) {\ + u_char *p0; \ + shift = false; \ + p0 = mtodo(m0, sizeof(struct statusblock)); \ + m0->m_data = m0->m_pktdat; \ + bcopy(p0, mtodo(m0, sizeof(struct
svn commit: r361231 - head/sys/netinet
Author: karels Date: Tue May 19 01:05:13 2020 New Revision: 361231 URL: https://svnweb.freebsd.org/changeset/base/361231 Log: Fix NULL-pointer bug from r361228. Note that in_pcb_lport and in_pcb_lport_dest can be called with a NULL local address for IPv6 sockets; handle it. Found by syzkaller. Reported by: cem MFC after:1 month Modified: head/sys/netinet/in_pcb.c Modified: head/sys/netinet/in_pcb.c == --- head/sys/netinet/in_pcb.c Tue May 19 00:15:19 2020(r361230) +++ head/sys/netinet/in_pcb.c Tue May 19 01:05:13 2020(r361231) @@ -615,6 +615,7 @@ in_pcbbind(struct inpcb *inp, struct sockaddr *nam, st * Assign a local port like in_pcb_lport(), but also used with connect() * and a foreign address and port. If fsa is non-NULL, choose a local port * that is unused with those, otherwise one that is completely unused. + * lsa can be NULL for IPv6. */ int in_pcb_lport_dest(struct inpcb *inp, struct sockaddr *lsa, u_short *lportp, @@ -692,14 +693,17 @@ in_pcb_lport_dest(struct inpcb *inp, struct sockaddr * #ifdef INET laddr.s_addr = INADDR_ANY; if ((inp->inp_vflag & (INP_IPV4|INP_IPV6)) == INP_IPV4) { - laddr = ((struct sockaddr_in *)lsa)->sin_addr; + if (lsa != NULL) + laddr = ((struct sockaddr_in *)lsa)->sin_addr; if (fsa != NULL) faddr = ((struct sockaddr_in *)fsa)->sin_addr; } #endif #ifdef INET6 - if (lsa->sa_family == AF_INET6) { - laddr6 = &((struct sockaddr_in6 *)lsa)->sin6_addr; + laddr6 = NULL; + if ((inp->inp_vflag & INP_IPV6) != 0) { + if (lsa != NULL) + laddr6 = &((struct sockaddr_in6 *)lsa)->sin6_addr; if (fsa != NULL) faddr6 = &((struct sockaddr_in6 *)fsa)->sin6_addr; } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r361228 - in head/sys: netinet netinet6
Author: karels Date: Mon May 18 22:53:12 2020 New Revision: 361228 URL: https://svnweb.freebsd.org/changeset/base/361228 Log: Allow TCP to reuse local port with different destinations Previously, tcp_connect() would bind a local port before connecting, forcing the local port to be unique across all outgoing TCP connections for the address family. Instead, choose a local port after selecting the destination and the local address, requiring only that the tuple is unique and does not match a wildcard binding. Reviewed by: tuexen (rscheff, rrs previous version) MFC after:1 month Sponsored by: Forcepoint LLC Differential Revision:https://reviews.freebsd.org/D24781 Modified: head/sys/netinet/in_pcb.c head/sys/netinet/in_pcb.h head/sys/netinet/tcp_usrreq.c head/sys/netinet6/in6_pcb.c head/sys/netinet6/in6_pcb.h Modified: head/sys/netinet/in_pcb.c == --- head/sys/netinet/in_pcb.c Mon May 18 19:48:38 2020(r361227) +++ head/sys/netinet/in_pcb.c Mon May 18 22:53:12 2020(r361228) @@ -610,13 +610,15 @@ in_pcbbind(struct inpcb *inp, struct sockaddr *nam, st } #endif +#if defined(INET) || defined(INET6) /* - * Select a local port (number) to use. + * Assign a local port like in_pcb_lport(), but also used with connect() + * and a foreign address and port. If fsa is non-NULL, choose a local port + * that is unused with those, otherwise one that is completely unused. */ -#if defined(INET) || defined(INET6) int -in_pcb_lport(struct inpcb *inp, struct in_addr *laddrp, u_short *lportp, -struct ucred *cred, int lookupflags) +in_pcb_lport_dest(struct inpcb *inp, struct sockaddr *lsa, u_short *lportp, +struct sockaddr *fsa, u_short fport, struct ucred *cred, int lookupflags) { struct inpcbinfo *pcbinfo; struct inpcb *tmpinp; @@ -624,8 +626,11 @@ in_pcb_lport(struct inpcb *inp, struct in_addr *laddrp int count, dorandom, error; u_short aux, first, last, lport; #ifdef INET - struct in_addr laddr; + struct in_addr laddr, faddr; #endif +#ifdef INET6 + struct in6_addr *laddr6, *faddr6; +#endif pcbinfo = inp->inp_pcbinfo; @@ -685,15 +690,22 @@ in_pcb_lport(struct inpcb *inp, struct in_addr *laddrp } #ifdef INET - /* Make the compiler happy. */ - laddr.s_addr = 0; + laddr.s_addr = INADDR_ANY; if ((inp->inp_vflag & (INP_IPV4|INP_IPV6)) == INP_IPV4) { - KASSERT(laddrp != NULL, ("%s: laddrp NULL for v4 inp %p", - __func__, inp)); - laddr = *laddrp; + laddr = ((struct sockaddr_in *)lsa)->sin_addr; + if (fsa != NULL) + faddr = ((struct sockaddr_in *)fsa)->sin_addr; } #endif - tmpinp = NULL; /* Make compiler happy. */ +#ifdef INET6 + if (lsa->sa_family == AF_INET6) { + laddr6 = &((struct sockaddr_in6 *)lsa)->sin6_addr; + if (fsa != NULL) + faddr6 = &((struct sockaddr_in6 *)fsa)->sin6_addr; + } +#endif + + tmpinp = NULL; lport = *lportp; if (dorandom) @@ -709,30 +721,62 @@ in_pcb_lport(struct inpcb *inp, struct in_addr *laddrp *lastport = first; lport = htons(*lastport); + if (fsa != NULL) { + +#ifdef INET + if (lsa->sa_family == AF_INET) { + tmpinp = in_pcblookup_hash_locked(pcbinfo, + faddr, fport, laddr, lport, lookupflags, + NULL); + } +#endif #ifdef INET6 - if ((inp->inp_vflag & INP_IPV6) != 0) - tmpinp = in6_pcblookup_local(pcbinfo, - &inp->in6p_laddr, lport, lookupflags, cred); + if (lsa->sa_family == AF_INET6) { + tmpinp = in6_pcblookup_hash_locked(pcbinfo, + faddr6, fport, laddr6, lport, lookupflags, + NULL); + } #endif + } else { +#ifdef INET6 + if ((inp->inp_vflag & INP_IPV6) != 0) + tmpinp = in6_pcblookup_local(pcbinfo, + &inp->in6p_laddr, lport, lookupflags, cred); +#endif #if defined(INET) && defined(INET6) - else + else #endif #ifdef INET - tmpinp = in_pcblookup_local(pcbinfo, laddr, - lport, lookupflags, cred); + tmpinp = in_pcblookup_local(pcbinfo, laddr, + lport, lookupflags, cred); #endif + } } while (tmpinp != NULL); -#ifdef INET - if ((inp->inp_vflag & (INP_IPV4|INP_IPV6)) == INP_IPV4) -
svn commit: r360181 - in head/sys: arm64/broadcom/genet arm64/conf arm64/include conf
Author: karels Date: Wed Apr 22 00:42:10 2020 New Revision: 360181 URL: https://svnweb.freebsd.org/changeset/base/360181 Log: Add genet driver for Raspberry Pi 4B Ethernet Add driver for Broadcom "GENET" version 5, as found in BCM-2711 on Raspberry Pi 4B. The driver is derived in part from the bcmgenet.c driver in NetBSD, along with bcmgenetreg.h. Reviewed by: manu Obtained from:in part from NetBSD Relnotes: yes, note addition Differential Revision:https://reviews.freebsd.org/D24436 Added: head/sys/arm64/broadcom/genet/ head/sys/arm64/broadcom/genet/if_genet.c (contents, props changed) head/sys/arm64/broadcom/genet/if_genetreg.h (contents, props changed) Modified: head/sys/arm64/conf/GENERIC head/sys/arm64/include/bus.h head/sys/conf/files.arm64 Added: head/sys/arm64/broadcom/genet/if_genet.c == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/arm64/broadcom/genet/if_genet.cWed Apr 22 00:42:10 2020 (r360181) @@ -0,0 +1,1678 @@ +/*- + * Copyright (c) 2020 Michael J Karels + * Copyright (c) 2016, 2020 Jared McNeill + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +/* + * RPi4 (BCM 2711) Gigabit Ethernet ("GENET") controller + * + * This driver is derived in large part from bcmgenet.c from NetBSD by + * Jared McNeill. Parts of the structure and other common code in + * this driver have been copied from if_awg.c for the Allwinner EMAC, + * also by Jared McNeill. + */ + +#include "opt_device_polling.h" + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#define __BIT(_x) (1 << (_x)) +#include "if_genetreg.h" + +#include +#include +#include + +#include +#include +#include + +#include "syscon_if.h" +#include "miibus_if.h" +#include "gpio_if.h" + +#defineRD4(sc, reg)bus_read_4((sc)->res[_RES_MAC], (reg)) +#defineWR4(sc, reg, val) bus_write_4((sc)->res[_RES_MAC], (reg), (val)) + +#defineGEN_LOCK(sc)mtx_lock(&(sc)->mtx) +#defineGEN_UNLOCK(sc) mtx_unlock(&(sc)->mtx) +#defineGEN_ASSERT_LOCKED(sc) mtx_assert(&(sc)->mtx, MA_OWNED) +#defineGEN_ASSERT_UNLOCKED(sc) mtx_assert(&(sc)->mtx, MA_NOTOWNED) + +#defineTX_DESC_COUNT GENET_DMA_DESC_COUNT +#defineRX_DESC_COUNT GENET_DMA_DESC_COUNT + +#defineTX_NEXT(n, count) (((n) + 1) & ((count) - 1)) +#defineRX_NEXT(n, count) (((n) + 1) & ((count) - 1)) + + +#defineTX_MAX_SEGS 20 + +/* Maximum number of mbufs to send to if_input */ +static int gen_rx_batch = 16 /* RX_BATCH_DEFAULT */; +TUNABLE_INT("hw.gen.rx_batch", &gen_rx_batch); + +static struct ofw_compat_data compat_data[] = { + { "brcm,genet-v1", 1 }, + { "brcm,genet-v2", 2 }, + { "brcm,genet-v3", 3 }, + { "brcm,genet-v4", 4 }, + { "brcm,genet-v5", 5 }, + { NULL, 0 } +}; + +enum { + _RES_MAC, /* what to call this? */ + _RES_IRQ1, + _RES_IRQ2, + _RES_NITEMS +}; + +static struct resource_spec gen_spec[] = { + { SYS_RES_MEMORY, 0, RF_ACTIVE }, + { SYS_RES_IRQ, 0, RF_ACTIVE }, + { SYS_RES_IRQ, 1, RF_ACTIVE }, + { -1, 0 } +}; + +/* structure per ring entry */ +struct gen_
svn commit: r354633 - head/usr.bin/netstat
Author: karels Date: Tue Nov 12 01:03:08 2019 New Revision: 354633 URL: https://svnweb.freebsd.org/changeset/base/354633 Log: Fix netstat -gs with ip_mroute module and/or vnet The code for "netstat -gs -f inet" failed if the kernel namelist did not include the _mrtstat symbol. However, that symbol is not in a standard kernel even with the ip_mroute module loaded, where the functionality is available. It is also not in a kernel with MROUTING but also VIMAGE, as there can be multiple sets of stats. However, when running the command on a live system, the symbol is not used; a sysctl is used. Go ahead and try the sysctl in any case, and complain that IPv4 MROUTING is not present only if the sysctl fails with ENOENT. Also fail if _mrtstat is not defined when running on a core file; netstat doesn't know about vnets, so can only work if MROUTING was included, and VIMAGE was not. Reviewed by: bz MFC after:1 week Differential Revision:https://reviews.freebsd.org/D22311 Modified: head/usr.bin/netstat/mroute.c Modified: head/usr.bin/netstat/mroute.c == --- head/usr.bin/netstat/mroute.c Tue Nov 12 00:32:33 2019 (r354632) +++ head/usr.bin/netstat/mroute.c Tue Nov 12 01:03:08 2019 (r354633) @@ -409,14 +409,12 @@ mrt_stats() mstaddr = nl[N_MRTSTAT].n_value; - if (mstaddr == 0) { - fprintf(stderr, "No IPv4 MROUTING kernel support.\n"); - return; - } - if (fetch_stats("net.inet.ip.mrtstat", mstaddr, &mrtstat, - sizeof(mrtstat), kread_counters) != 0) + sizeof(mrtstat), kread_counters) != 0) { + if ((live && errno == ENOENT) || (!live && mstaddr == 0)) + fprintf(stderr, "No IPv4 MROUTING kernel support.\n"); return; + } xo_emit("{T:IPv4 multicast forwarding}:\n"); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r352597 - head/lib/libkvm
Author: karels Date: Sun Sep 22 13:56:27 2019 New Revision: 352597 URL: https://svnweb.freebsd.org/changeset/base/352597 Log: Add support for ps -H on corefiles in libkvm Add support for kernel threads in kvm_getprocs() and the underlying kvm_proclist() in libkvm when fetching from a kernel core file. This has been missing/needed for several releases, when kernel threads became normal threads. The loop over the processes now contains a sub-loop for threads, which iterates beyond the first thread only when threads are requested. Also set some fields such as tid that were previously uninitialized. Reviewed by: vangyzen jhb(earlier revision) MFC after:4 days Sponsored by: Forcepoint LLC Differential Revision:https://reviews.freebsd.org/D21461 Modified: head/lib/libkvm/kvm_proc.c Modified: head/lib/libkvm/kvm_proc.c == --- head/lib/libkvm/kvm_proc.c Sun Sep 22 12:33:18 2019(r352596) +++ head/lib/libkvm/kvm_proc.c Sun Sep 22 13:56:27 2019(r352597) @@ -67,6 +67,7 @@ __SCCSID("@(#)kvm_proc.c 8.3 (Berkeley) 9/23/93"); #include #include #include +#include #include #include #include @@ -130,13 +131,16 @@ kvm_proclist(kvm_t *kd, int what, int arg, struct proc struct proc pproc; struct sysentvec sysent; char svname[KI_EMULNAMELEN]; + struct thread *td = NULL; + bool first_thread; kp = &kinfo_proc; kp->ki_structsize = sizeof(kinfo_proc); /* -* Loop on the processes. this is completely broken because we need to be -* able to loop on the threads and merge the ones that are the same process some how. +* Loop on the processes, then threads within the process if requested. */ + if (what == KERN_PROC_ALL) + what |= KERN_PROC_INC_THREAD; for (; cnt < maxcnt && p != NULL; p = LIST_NEXT(&proc, p_list)) { memset(kp, 0, sizeof *kp); if (KREAD(kd, (u_long)p, &proc)) { @@ -145,15 +149,6 @@ kvm_proclist(kvm_t *kd, int what, int arg, struct proc } if (proc.p_state == PRS_NEW) continue; - if (proc.p_state != PRS_ZOMBIE) { - if (KREAD(kd, (u_long)TAILQ_FIRST(&proc.p_threads), - &mtd)) { - _kvm_err(kd, kd->program, - "can't read thread at %p", - TAILQ_FIRST(&proc.p_threads)); - return (-1); - } - } if (KREAD(kd, (u_long)proc.p_ucred, &ucred) == 0) { kp->ki_ruid = ucred.cr_ruid; kp->ki_svuid = ucred.cr_svuid; @@ -222,6 +217,7 @@ kvm_proclist(kvm_t *kd, int what, int arg, struct proc kp->ki_addr = 0;/* XXX uarea */ /* kp->ki_kstack = proc.p_thread.td_kstack; XXXKSE */ kp->ki_args = proc.p_args; + kp->ki_numthreads = proc.p_numthreads; kp->ki_tracep = proc.p_tracevp; kp->ki_textvp = proc.p_textvp; kp->ki_fd = proc.p_fd; @@ -285,9 +281,6 @@ kvm_proclist(kvm_t *kd, int what, int arg, struct proc kp->ki_sid = sess.s_sid; (void)memcpy(kp->ki_login, sess.s_login, sizeof(kp->ki_login)); - kp->ki_kiflag = sess.s_ttyvp ? KI_CTTY : 0; - if (sess.s_leader == p) - kp->ki_kiflag |= KI_SLEADER; if ((proc.p_flag & P_CONTROLT) && sess.s_ttyp != NULL) { if (KREAD(kd, (u_long)sess.s_ttyp, &tty)) { _kvm_err(kd, kd->program, @@ -330,9 +323,6 @@ kvm_proclist(kvm_t *kd, int what, int arg, struct proc nopgrp: kp->ki_tdev = NODEV; } - if ((proc.p_state != PRS_ZOMBIE) && mtd.td_wmesg) - (void)kvm_read(kd, (u_long)mtd.td_wmesg, - kp->ki_wmesg, WMESGLEN); (void)kvm_read(kd, (u_long)proc.p_vmspace, (char *)&vmspace, sizeof(vmspace)); @@ -374,85 +364,127 @@ nopgrp: sizeof(svname)); if (svname[0] != 0) strlcpy(kp->ki_emul, svname, KI_EMULNAMELEN); - if ((proc.p_state != PRS_ZOMBIE) && - (mtd.td_blocked != 0)) { - kp->ki_kiflag |= KI_LOCKBLOCK; - if (mtd.td_lockname) - (void)kvm_read(kd, - (u_long)mtd.td_lockname, - kp->ki_lockname, LOCKNAMELEN); - kp->ki_lockname[LOCKNAMELEN] = 0; - }
svn commit: r351592 - head/usr.bin/w
Author: karels Date: Thu Aug 29 02:44:18 2019 New Revision: 351592 URL: https://svnweb.freebsd.org/changeset/base/351592 Log: Fix address annotation in xml output from w The libxo xml feature of adding an annotation with the "original" address from the utmpx file if it is different than the final "from" field was broken by r351379. This was pointed out by the gcc error that save_p might be used uninitialized. Save the original address as needed in each entry, don't just use the last one from the previous loop. Reviewed by: marcel@ MFC after:1 week Differential Revision:https://reviews.freebsd.org/D21390 Modified: head/usr.bin/w/w.c Modified: head/usr.bin/w/w.c == --- head/usr.bin/w/w.c Wed Aug 28 23:40:57 2019(r351591) +++ head/usr.bin/w/w.c Thu Aug 29 02:44:18 2019(r351592) @@ -118,6 +118,7 @@ static struct entry { char*args; /* arg list of interesting process */ struct kinfo_proc *dkp;/* debug option proc list */ char*from; /* "from": name or addr */ + char*save_from; /* original "from": name or addr */ } *ep, *ehead = NULL, **nextp = &ehead; #definedebugproc(p) *(&((struct kinfo_proc *)p)->ki_udata) @@ -209,7 +210,6 @@ main(int argc, char *argv[]) if (*argv) sel_users = argv; - save_p = NULL; setutxent(); for (nusers = 0; (utmp = getutxent()) != NULL;) { struct addrinfo hints, *res; @@ -312,6 +312,8 @@ main(int argc, char *argv[]) ep->from = strdup(p); if ((i = strlen(p)) > fromwidth) fromwidth = i; + if (save_p != p) + ep->save_from = strdup(save_p); } endutxent(); @@ -451,8 +453,8 @@ main(int argc, char *argv[]) strncmp(ep->utmp.ut_line, "cua", 3) ? ep->utmp.ut_line : ep->utmp.ut_line + 3) : "-"); - if (save_p && save_p != p) - xo_attr("address", "%s", save_p); + if (ep->save_from) + xo_attr("address", "%s", ep->save_from); xo_emit("{:from/%-*.*s/%@**@s} ", fromwidth, fromwidth, ep->from); t = ep->utmp.ut_tv.tv_sec; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r351379 - head/usr.bin/w
Author: karels Date: Thu Aug 22 03:28:31 2019 New Revision: 351379 URL: https://svnweb.freebsd.org/changeset/base/351379 Log: Change w(1) to compute FROM (host) field size dynamically It's nice to be able to display a full IPv6 host address if needed, but it's also nice to display more than 3 characters of a command line. Compute the needed size for the FROM column in an earlier pass, and determine the maximum, then print what fits for the command. Reviewed by: marcel@ (markm@ previous revision) MFC after:1 week Differential Revision:https://reviews.freebsd.org/D21211 Modified: head/usr.bin/w/w.c Modified: head/usr.bin/w/w.c == --- head/usr.bin/w/w.c Thu Aug 22 03:00:55 2019(r351378) +++ head/usr.bin/w/w.c Thu Aug 22 03:28:31 2019(r351379) @@ -96,7 +96,8 @@ static struct winsize ws; static kvm_t *kd; static time_t now;/* the current time of day */ static int ttywidth; /* width of tty */ -static int argwidth; /* width of tty */ +static int fromwidth = 0; /* max width of "from" field */ +static int argwidth; /* width of arguments */ static int header = 1; /* true if -h flag: don't print heading */ static int nflag; /* true if -n flag: don't convert addrs */ static int dflag; /* true if -d flag: output debug info */ @@ -116,13 +117,14 @@ static struct entry { struct kinfo_proc *kp; /* `most interesting' proc */ char*args; /* arg list of interesting process */ struct kinfo_proc *dkp;/* debug option proc list */ + char*from; /* "from": name or addr */ } *ep, *ehead = NULL, **nextp = &ehead; #definedebugproc(p) *(&((struct kinfo_proc *)p)->ki_udata) #defineW_DISPUSERSIZE 10 #defineW_DISPLINESIZE 8 -#defineW_DISPHOSTSIZE 40 +#defineW_MAXHOSTSIZE 40 static void pr_header(time_t *, int); static struct stat *ttystat(char *); @@ -209,6 +211,13 @@ main(int argc, char *argv[]) setutxent(); for (nusers = 0; (utmp = getutxent()) != NULL;) { + struct addrinfo hints, *res; + struct sockaddr_storage ss; + struct sockaddr *sa = (struct sockaddr *)&ss; + struct sockaddr_in *lsin = (struct sockaddr_in *)&ss; + struct sockaddr_in6 *lsin6 = (struct sockaddr_in6 *)&ss; + int isaddr; + if (utmp->ut_type != USER_PROCESS) continue; if (!(stp = ttystat(utmp->ut_line))) @@ -250,9 +259,76 @@ main(int argc, char *argv[]) } if ((ep->idle = now - touched) < 0) ep->idle = 0; + + save_p = p = *ep->utmp.ut_host ? ep->utmp.ut_host : "-"; + if ((x_suffix = strrchr(p, ':')) != NULL) { + if ((dot = strchr(x_suffix, '.')) != NULL && + strchr(dot+1, '.') == NULL) + *x_suffix++ = '\0'; + else + x_suffix = NULL; + } + + isaddr = 0; + memset(&ss, '\0', sizeof(ss)); + if (inet_pton(AF_INET6, p, &lsin6->sin6_addr) == 1) { + lsin6->sin6_len = sizeof(*lsin6); + lsin6->sin6_family = AF_INET6; + isaddr = 1; + } else if (inet_pton(AF_INET, p, &lsin->sin_addr) == 1) { + lsin->sin_len = sizeof(*lsin); + lsin->sin_family = AF_INET; + isaddr = 1; + } + if (nflag == 0) { + /* Attempt to change an IP address into a name */ + if (isaddr && realhostname_sa(fn, sizeof(fn), sa, + sa->sa_len) == HOSTNAME_FOUND) + p = fn; + } else if (!isaddr && nflag > 1) { + /* +* If a host has only one A/ RR, change a +* name into an IP address +*/ + memset(&hints, 0, sizeof(hints)); + hints.ai_flags = AI_PASSIVE; + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + if (getaddrinfo(p, NULL, &hints, &res) == 0) { + if (res->ai_next == NULL && + getnameinfo(res->ai_addr, res->ai_addrlen, + fn, sizeof(fn), NULL, 0, + NI_NUMERICHOST) == 0) + p = fn; + freeaddrinfo(res); +
btoc()/ctob() (was Re: svn commit: r349791 - head/sys/vm)
--- Blind-Carbon-Copy To: a...@freebsd.org cc: b...@optusnet.com.au, a...@feeebsd.org From: Mike Karels Reply-to: m...@karels.net Subject: btoc()/ctob() (was Re: svn commit: r349791 - head/sys/vm) In-reply-to: Your message of Sun, 07 Jul 2019 03:48:54 +1000. <20190707023441.b2...@besplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <60189.156250448...@mail.karels.net> Content-Transfer-Encoding: quoted-printable Date: Sun, 07 Jul 2019 08:04:41 -0500 [I moved my reply/new question to arch@, and bcc'd src-committers@ et al, where the interaction started. Excuse the top post, but the previous message is included just for reference; it need not be included in any replies. Followups to arch@, please.] [Sorry if this topic has been covered before; just let me know. Neither my freebsd.org or Google searches located anything, although I didn't try all that hard.] I am astounded to hear that the btoc() macro still lives on, along with ctob() (bytes to clicks, and clicks to bytes). They don't seem to have suitable MI replacements (at least not in ). For those who don't know/remember: these macros were used to convert physical addresses to values for the segment base registers (PARs) on the PDP-11, where there was no actual "page size" analogous to newer hardware. (A click, the 'c' in btoc/ctob, was 64 bytes, the unit of scaling to keep physical addresses in the hardware registers fitting in 16 bits.) Since then, the macros hav= e been subverted to operate in pages, starting with the VAX in 32/V, rather than coming up with a new, more appropriate name. I am wondering whether it is finally time to deprecate PDP-11-based nomenclature. Clicks have not been a "thing" for many years; but pages are nearly universal (modulo superpages, etc). I see that many architectures have architecture-dependent xxx_btop() and xxx_ptob() macros, which are similar but annoyingly different in details like casts. Unlike btoc(), the xxx_btop() versions do not round. I wonde= r, though, whether it is time to hoist *_btop/*_ptob into a new architecture- independent replacement for btoc/ctob. btop() and ptob() come to mind, although I don't know what Linux (etc) does along these lines. I see just over 100 uses of btoc()/ctob() overall, but of course we would need to keep deprecated versions for a while. Thoughts on changing the KPI here? We'd have to agree on details like rounding and casting, but my first reaction would be no to both. Mike > Date: Sun, 7 Jul 2019 03:48:54 +1000 (EST) > From: Bruce Evans > X-X-Sender: b...@besplex.bde.org > To: Doug Moore > cc: src-committ...@freebsd.org, svn-src-...@freebsd.org, > svn-src-head@freebsd.org > Subject: Re: svn commit: r349791 - head/sys/vm > In-Reply-To: <201907061555.x66ftgsg025...@repo.freebsd.org> > Message-ID: <20190707023441.b2...@besplex.bde.org> > References: <201907061555.x66ftgsg025...@repo.freebsd.org> > MIME-Version: 1.0 > Content-Type: TEXT/PLAIN; charset=3DUS-ASCII; format=3Dflowed > X-Optus-CM-Score: 0 > X-Optus-CM-Analysis: v=3D2.2 cv=3DP6RKvmIu c=3D1 sm=3D1 tr=3D0 cx=3Da_id= p_d > a=3DPalzARQSbocsUSjMRkwAPg=3D=3D:117 a=3DPalzARQSbocsUSjMRkwAPg=3D=3D:1= 7 > a=3DjpOVt7BSZ2e4Z31A5e1TngXxSK0=3D:19 a=3Dkj9zAlcOel0A:10 > a=3Dk1N1_3MYVckZGDfFxwYA:9 a=3DCjuIK1q_8ugA:10 > Precedence: bulk > X-Loop: FreeBSD.org > Sender: owner-src-committ...@freebsd.org > List-Id: FreeBSD mail > X-Rspamd-Queue-Id: 158A46ECA9 > X-Spamd-Bar: -- > Authentication-Results: mx1.freebsd.org > X-Spamd-Result: default: False [-6.98 / 15.00]; >NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; >NEURAL_HAM_SHORT(-0.98)[-0.982,0]; >REPLY(-4.00)[]; >NEURAL_HAM_LONG(-1.00)[-1.000,0] > X-UID: 364675 > Status: RO > X-Keywords: $NotJunk NonJunk= > Content-Length: 5846 > On Sat, 6 Jul 2019, Doug Moore wrote: > > Log: > > Fix style(9) violations involving division by PAGE_SIZE. > It is style violation to even use an explicit division by PAGE_SIZE > instead of the btoc() conversion macro (*). > > Modified: head/sys/vm/swap_pager.c > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > > --- head/sys/vm/swap_pager.cSat Jul 6 15:34:23 2019 > > (r349790) > > +++ head/sys/vm/swap_pager.cSat Jul 6 15:55:16 2019 > > (r349791) > > @@ -523,7 +523,7 @@ swap_pager_swap_init(void) > > * but it isn't very efficient). > > * > > *
svn commit: r340474 - head/sys/net/altq
Author: karels Date: Fri Nov 16 03:42:29 2018 New Revision: 340474 URL: https://svnweb.freebsd.org/changeset/base/340474 Log: Fix flags collision causing inability to enable CBQ in ALTQ The CBQ BORROW flag conflicts with the RMCF_CODEL flag; the two sets of definitions actually define the same things. The symptom is that a kernel with CBQ support and not CODEL fails to load a QoS policy with the obscure error "pfctl: DIOCADDALTQ: Cannot allocate memory." If ALTQ_DEBUG is enabled, the error becomes a little clearer: "rmc_newclass: CODEL not configured for CBQ!" is printed by the kernel. There really shouldn't be two sets of macros that have to be defined consistently, but the include structure isn't right for exporting CBQ flags to altq_rmclass.h. Re-align the definitions, and add CTASSERTs in the kernel to ensure that the definitions are consistent. PR: 215716 Reviewed by: pkelsey MFC after:2 weeks Sponsored by: Forcepoint LLC Differential Revision:https://reviews.freebsd.org/D17758 Modified: head/sys/net/altq/altq_cbq.h head/sys/net/altq/altq_rmclass.h Modified: head/sys/net/altq/altq_cbq.h == --- head/sys/net/altq/altq_cbq.hFri Nov 16 01:27:24 2018 (r340473) +++ head/sys/net/altq/altq_cbq.hFri Nov 16 03:42:29 2018 (r340474) @@ -46,7 +46,7 @@ extern "C" { #defineNULL_CLASS_HANDLE 0 -/* class flags should be same as class flags in rm_class.h */ +/* class flags must be same as class flags in altq_rmclass.h */ #defineCBQCLF_RED 0x0001 /* use RED */ #defineCBQCLF_ECN 0x0002 /* use RED/ECN */ #defineCBQCLF_RIO 0x0004 /* use RIO */ @@ -54,6 +54,15 @@ extern "C" { #defineCBQCLF_CLEARDSCP0x0010 /* clear diffserv codepoint */ #defineCBQCLF_BORROW 0x0020 /* borrow from parent */ #defineCBQCLF_CODEL0x0040 /* use CoDel */ + +#ifdef _KERNEL +CTASSERT(CBQCLF_RED == RMCF_RED); +CTASSERT(CBQCLF_ECN == RMCF_ECN); +CTASSERT(CBQCLF_RIO == RMCF_RIO); +CTASSERT(CBQCLF_FLOWVALVE == RMCF_FLOWVALVE); +CTASSERT(CBQCLF_CLEARDSCP == RMCF_CLEARDSCP); +CTASSERT(CBQCLF_CODEL == RMCF_CODEL); +#endif /* class flags only for root class */ #defineCBQCLF_WRR 0x0100 /* weighted-round robin */ Modified: head/sys/net/altq/altq_rmclass.h == --- head/sys/net/altq/altq_rmclass.hFri Nov 16 01:27:24 2018 (r340473) +++ head/sys/net/altq/altq_rmclass.hFri Nov 16 03:42:29 2018 (r340474) @@ -233,13 +233,13 @@ struct rm_ifdat { }; /* flags for rmc_init and rmc_newclass */ -/* class flags */ +/* class flags; must be the same as class flags in altq_cbq.h */ #defineRMCF_RED0x0001 #defineRMCF_ECN0x0002 #defineRMCF_RIO0x0004 #defineRMCF_FLOWVALVE 0x0008 /* use flowvalve (aka penalty-box) */ #defineRMCF_CLEARDSCP 0x0010 /* clear diffserv codepoint */ -#defineRMCF_CODEL 0x0020 +#defineRMCF_CODEL 0x0040 /* flags for rmc_init */ #defineRMCF_WRR0x0100 ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r330712 - head/bin/ps
Author: karels Date: Sat Mar 10 00:10:47 2018 New Revision: 330712 URL: https://svnweb.freebsd.org/changeset/base/330712 Log: Change ps(1) output width to unlimited if not interactive Apply patch submitted with PR 217159 to make ps use unlimited width when not associated with a terminal (i.e., none of stdout, stdin, or stderr is a tty). Update comments and man page correspondingly. This change was requested to work around lack of -ww in scripts from third-party packages, including Hadoop, and adds a small measure of Linux compatibility. Hopefully few if any non-interactive scripts depend on the old default of 79. PR: 217159 Submitted by: n.deepak at gmail.com Reviewed by: vangyzen jhb Differential Revision:https://reviews.freebsd.org/D14614 Modified: head/bin/ps/ps.1 head/bin/ps/ps.c Modified: head/bin/ps/ps.1 == --- head/bin/ps/ps.1Fri Mar 9 23:37:19 2018(r330711) +++ head/bin/ps/ps.1Sat Mar 10 00:10:47 2018(r330712) @@ -101,6 +101,14 @@ The default output format includes, for each process, controlling terminal, state, CPU time (including both user and system time) and associated command. .Pp +If the +.Nm +process is associated with a terminal, the default output width is that of the +terminal; otherwise the output width is unlimited. +See also the +.Fl w +option. +.Pp The options are as follows: .Bl -tag -width indent .It Fl -libxo @@ -257,13 +265,15 @@ option implies the .Fl m option. .It Fl w -Use 132 columns to display information, instead of the default which -is your window size. +Use at least 132 columns to display information, instead of the default which +is the window size if +.Nm +is associated with a terminal. If the .Fl w option is specified more than once, .Nm -will use as many columns as necessary without regard for your window size. +will use as many columns as necessary without regard for the window size. Note that this option has no effect if the .Dq command column is not the last column displayed. Modified: head/bin/ps/ps.c == --- head/bin/ps/ps.cFri Mar 9 23:37:19 2018(r330711) +++ head/bin/ps/ps.cSat Mar 10 00:10:47 2018(r330712) @@ -202,6 +202,11 @@ main(int argc, char *argv[]) * any of stdout, stderr, or stdin is a terminal. The intent * is that "ps", "ps | more", and "ps | grep" all use the same * default line length unless -w is specified. +* +* If not interactive, the default length was traditionally 79. +* It has been changed to unlimited. This is mostly for the +* benefit of non-interactive scripts, which arguably should +* use -ww, but is compatible with Linux. */ if ((cols = getenv("COLUMNS")) != NULL && *cols != '\0') termwidth = atoi(cols); @@ -209,7 +214,7 @@ main(int argc, char *argv[]) ioctl(STDERR_FILENO, TIOCGWINSZ, (char *)&ws) == -1 && ioctl(STDIN_FILENO, TIOCGWINSZ, (char *)&ws) == -1) || ws.ws_col == 0) - termwidth = 79; + termwidth = UNLIMITED; else termwidth = ws.ws_col - 1; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r330091 - head/bin/ps
Author: karels Date: Wed Feb 28 00:17:08 2018 New Revision: 330091 URL: https://svnweb.freebsd.org/changeset/base/330091 Log: Revert r314685 in ps Revert r314685, and add a comment describing the original behavior and the intent. Reviewed by: dab@ vangyzen@ jhb@ Differential Revision:https://reviews.freebsd.org/D14530 Modified: head/bin/ps/ps.c Modified: head/bin/ps/ps.c == --- head/bin/ps/ps.cTue Feb 27 22:22:23 2018(r330090) +++ head/bin/ps/ps.cWed Feb 28 00:17:08 2018(r330091) @@ -194,10 +194,17 @@ main(int argc, char *argv[]) (void) setlocale(LC_ALL, ""); time(&now); /* Used by routines in print.c. */ + /* +* Compute default output line length before processing options. +* If COLUMNS is set, use it. Otherwise, if this is part of an +* interactive job (i.e. one associated with a terminal), use +* the terminal width. "Interactive" is determined by whether +* any of stdout, stderr, or stdin is a terminal. The intent +* is that "ps", "ps | more", and "ps | grep" all use the same +* default line length unless -w is specified. +*/ if ((cols = getenv("COLUMNS")) != NULL && *cols != '\0') termwidth = atoi(cols); - else if (!isatty(STDOUT_FILENO)) - termwidth = UNLIMITED; else if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&ws) == -1 && ioctl(STDERR_FILENO, TIOCGWINSZ, (char *)&ws) == -1 && ioctl(STDIN_FILENO, TIOCGWINSZ, (char *)&ws) == -1) || ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
ps output line length (was: svn commit: r314685 - head/bin/ps)
Recently, I was investigating an issue with top on -current while doing a "make buildworld", and ran "ps axu|more" for comparison. To my surprise, I got only a few very long lines of output, containing full command lines for compiler runs. This quickly led me to the following commit, which I unfortunately missed at the time, along with the following discussion: > Author: cem > Date: Sat Mar 4 22:38:10 2017 > New Revision: 314685 > URL: https://svnweb.freebsd.org/changeset/base/314685 > Log: > ps(1): Only detect terminal width if stdout is a tty > > If stdout isn't a tty, use unlimited width output rather than truncating to > 79 characters. This is helpful for shell scripts or e.g., 'ps | grep foo'. > > This hardcoded width has some history: In The Beginning of History[0], the > width of ps was hardcoded as 80 bytes. In 1985, Bloom@ added detection > using TIOCGWINSZ on stdin.[1] In 1986, Kirk merged a change to check > stdout's window size instead. In 1990, the fallback checks to stderr and > stdin's TIOCGWINSZ were added by Marc@, with the commit message "new > version."[2] > > OS X Darwin has a very similar modification to ps(1), which simply sets > UNLIMITED for all non-tty outputs.[3] I've chosen to respect COLUMNS > instead of behaving identically to Darwin here, but I don't feel strongly > about that. We could match OS X for parity if that is desired. > > [0]: https://svnweb.freebsd.org/csrg/bin/ps/ps.c?annotate=1065 > [1]: https://svnweb.freebsd.org/csrg/bin/ps/ps.c?r1=18105&r2=18106 > [2]: > https://svnweb.freebsd.org/csrg/bin/ps/ps.c?r1=40675&r2=40674&pathrev=40675 > [3]: > https://opensource.apple.com/source/adv_cmds/adv_cmds-168/ps/ps.c.auto.html > > PR: 217159 > Reported by:Deepak Nagaraj > Modified: > head/bin/ps/ps.c > Modified: head/bin/ps/ps.c > == > --- head/bin/ps/ps.c Sat Mar 4 22:23:59 2017(r314684) > +++ head/bin/ps/ps.c Sat Mar 4 22:38:10 2017(r314685) > @@ -194,6 +194,8 @@ main(int argc, char *argv[]) > > if ((cols = getenv("COLUMNS")) != NULL && *cols != '\0') > termwidth = atoi(cols); > + else if (!isatty(STDOUT_FILENO)) > + termwidth = UNLIMITED; > else if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&ws) == -1 && >ioctl(STDERR_FILENO, TIOCGWINSZ, (char *)&ws) == -1 && >ioctl(STDIN_FILENO, TIOCGWINSZ, (char *)&ws) == -1) || There were several following messages discussing this change, most notably one by Bruce Evans (https://docs.freebsd.org/cgi/getmsg.cgi?fetch=55022+0+archive/2017/svn-src-head/20170312.svn-src-head). I agree with his rational, and disagree with the change. It seems to me that the consensus was that the change was incorrect, although that might just be my opinion. However, I really think that the change needs to be reverted. The rationale for the original code was that, for interactive uses, the output line length should be the same for "ps ...", "ps ...|more", and "ps ... |grep". The -w option exists to make the line longer; there is no option to use the terminal size even if the output is redirected. Hence, the tests for stderr or stdin being a tty. This behavior has been in place since 1990, as noted, and no substantial rationale has been given for changing it other than "it doesn't matter if you use less with side-to-side scrolling." fwiw, I'm sure I discussed that code with Marc at the time. As was stated, scripts that want to use the full line should use -ww. Interactive users have long been used to using -w when they need longer output lines, e.g. to match patterns that don't occur within a screen's width. I propose reverting this change. Mike ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r327512 - head
Author: karels Date: Wed Jan 3 06:41:39 2018 New Revision: 327512 URL: https://svnweb.freebsd.org/changeset/base/327512 Log: Add info about SW_WATCHDOG change to be dynamic in the common case. Modified: head/UPDATING Modified: head/UPDATING == --- head/UPDATING Wed Jan 3 06:22:40 2018(r327511) +++ head/UPDATING Wed Jan 3 06:41:39 2018(r327512) @@ -51,6 +51,12 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12.x IS SLOW: ** SPECIAL WARNING: ** +20180102: + The SW_WATCHDOG option is no longer necessary to enable the + hardclock-based software watchdog if no hardware watchdog is + configured. As before, SW_WATCHDOG will cause the software + watchdog to be enabled even if a hardware watchdog is configured. + 20171215: r326887 fixes the issue described in the 20171214 UPDATING entry. r326888 flips the switch back to building GELI support always. ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r327505 - in head: share/man/man4 sys/conf sys/dev/watchdog sys/kern sys/sys
Author: karels Date: Wed Jan 3 00:56:30 2018 New Revision: 327505 URL: https://svnweb.freebsd.org/changeset/base/327505 Log: make SW_WATCHDOG dynamic Enable the hardclock-based watchdog previously conditional on the SW_WATCHDOG option whenever hardware watchdogs are not found, and watchdogd attempts to enable the watchdog. The SW_WATCHDOG option still causes the sofware watchdog to be enabled even if there is a hardware watchdog. This does not change the other software-based watchdog enabled by the --softtimeout option to watchdogd. Note that the code to reprime the watchdog during kernel core dumps is no longer conditional on SW_WATCHDOG. I think this was previously a bug. Reviewed by: imp alfred bjk MFC after:1 week Relnotes: yes Differential Revision:https://reviews.freebsd.org/D13713 Modified: head/share/man/man4/watchdog.4 head/sys/conf/NOTES head/sys/dev/watchdog/watchdog.c head/sys/kern/kern_clock.c head/sys/kern/kern_dump.c head/sys/sys/watchdog.h Modified: head/share/man/man4/watchdog.4 == --- head/share/man/man4/watchdog.4 Tue Jan 2 23:52:26 2018 (r327504) +++ head/share/man/man4/watchdog.4 Wed Jan 3 00:56:30 2018 (r327505) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 21, 2009 +.Dd January 2, 2018 .Dt WATCHDOG 4 .Os .Sh NAME @@ -40,8 +40,11 @@ facility is used for controlling hardware and software .Pp The device .Pa /dev/fido -responds to a single +supports several optional .Xr ioctl 2 +calls for configuration, and +responds to a single operational +.Xr ioctl call, .Dv WDIOCPATPAT . It takes a single argument which represents a timeout value specified as a @@ -60,12 +63,16 @@ indicates that the will be kept from timing out from the kernel. .Pp The +.Dv WDIOCPATPAT .Xr ioctl 2 call will return success if just one of the available .Xr watchdog 9 implementations supports setting the timeout to the specified timeout. This means that at least one watchdog is armed. +By default, this will be a hardware watchdog if one is present, but if +no hardware watchdog is able to process the request, a default software +watchdog is enabled. If the call fails, for instance if none of .Xr watchdog 9 @@ -77,8 +84,53 @@ To disable the watchdogs pass If disarming the watchdog(s) failed an error is returned. The watchdog might still be armed! +.Pp +The optional configuration +.Xr ioctl +commands are listed here, along with the type of the parameter used. +Examples of their use can be found in +.Xr watchdogd 8 . +.Bl -tag -width "WDIOC_SETSOFTTIMEOUTACT int " +.It Dv WDIOC_SETTIMEOUT Fa int +set/reset the timer +.It Dv WDIOC_GETTIMEOUT Fa int +get total timeout +.It Dv WDIOC_GETTIMELEFT Fa int +get time left +.It Dv WDIOC_GETPRETIMEOUT Fa int +get the pre-timeout +.It Dv WDIOC_SETPRETIMEOUT Fa int +set the pre-timeout +.It Dv WDIOC_SETPRETIMEOUTACT Fa int +Set the action when a pre-timeout occurs (see +.Li WD_SOFT_* +below). +.It Dv WDIOC_SETSOFT Fa int +Use an internal software watchdog instead of hardware. +There is also an external software watchdog, which is used by default +if no hardware watchdog was attached. +.It Dv WDIOC_SETSOFTTIMEOUTACT Fa int +Set the action whan a soft timeout occurs. +.El +.Pp +The actions that may be specified for the pre-timeout or the internal software +watchdog are listed here. +Multiple actions can be specified by ORing values together. +.Bl -tag -width WD_SOFT_PRINT +.It Dv WD_SOFT_PANIC +panic +.It Dv WD_SOFT_DDB +enter debugger +.It Dv WD_SOFT_LOG +log(9) +.It Dv WD_SOFT_PRINT +printf(9) +.El .Sh RETURN VALUES -The ioctl returns zero on success and non-zero on failure. +The +.Dv WDIOCPATPAT +.Xr ioctl +returns zero on success and non-zero on failure. .Bl -tag -width Er .It Bq Er EOPNOTSUPP No watchdog present in the kernel or @@ -89,6 +141,10 @@ Watchdog could not be disabled (timeout value of 0). .It Bq Er EINVAL Invalid flag combination passed. .El +.Pp +The configuration +.Xr ioctl +operations return zero on success and non-zero on failure. .Sh EXAMPLES .Bd -literal -offset indent #include @@ -122,8 +178,10 @@ Enables a watchdog to recover from a potentially freez .Pp .Dl "options SW_WATCHDOG" .Pp -in your kernel config adds a software watchdog in the kernel, dropping to KDB -or panic-ing when firing. +in your kernel config forces a software watchdog in the kernel +to be configured even if a hardware watchdog is configured, +dropping to KDB or panicking when firing, depending +on the KDB and KDB_UNATTENDED kernel configuration options. .Sh SEE ALSO .Xr watchdogd 8 , .Xr watchdog 9 Modified: head/sys/conf/NOTES == --- head/sys/conf/NOTES Tue Jan 2 23:52:26 2018(r327504) +++ head/sys/conf/NOTES Wed Jan 3 00:56:30 2018(r327505) @@ -2609,7 +2609,9 @@ options BOOTP
svn commit: r326734 - head/share/man/man5
Author: karels Date: Sat Dec 9 17:27:36 2017 New Revision: 326734 URL: https://svnweb.freebsd.org/changeset/base/326734 Log: gifconfig_gif0 no longer works, document replacement rc.conf(5) documents the gifconfig_ keyword, which is no longer implemented. Document the replacement, which works with cloned_interfaces as well. Reviewed by: dab Group Reviwers: manpages MFC after:3 days Differential Revision:https://reviews.freebsd.org/D13130 Modified: head/share/man/man5/rc.conf.5 Modified: head/share/man/man5/rc.conf.5 == --- head/share/man/man5/rc.conf.5 Sat Dec 9 15:59:10 2017 (r326733) +++ head/share/man/man5/rc.conf.5 Sat Dec 9 17:27:36 2017 (r326734) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 24, 2017 +.Dd December 9, 2017 .Dt RC.CONF 5 .Os .Sh NAME @@ -1816,21 +1816,40 @@ This variable is deprecated in favor of Set to the list of .Xr gif 4 tunnel interfaces to configure on this host. -A -.Va gifconfig_ Ns Aq Ar interface -variable is assumed to exist for each value of -.Ar interface . +For each +.Xr gif +tunnel interface, set a variable named +.Va ifconfig_ Ns Aq Ar interface +with the parameters for the +.Xr ifconfig 8 +command to configure the link level for +.Ar interface +with the +.Cm tunnel +option. The value of this variable is used to configure the link layer of the -tunnel according to the syntax of the +tunnel using the .Cm tunnel option to -.Xr ifconfig 8 . +.Xr ifconfig . +For example, configure two +.Xr gif +interfaces with: +.Bd -literal -offset indent +gif_interfaces="gif0 gif1" +ifconfig_gif0="tunnel src_addr0 dst_addr0" +ifconfig_gif1="tunnel src_addr1 dst_addr1" +.Ed +.Pp Additionally, this option ensures that each listed interface is created via the .Cm create option to -.Xr ifconfig 8 -before attempting to configure it. +.Xr ifconfig . +This example also works with +.Va cloned_interfaces +instead of +.Va gif_interfaces . .It Va sppp_interfaces .Pq Vt str Set to the list of ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r316065 - head/sys/netinet
Author: karels Date: Mon Mar 27 23:48:36 2017 New Revision: 316065 URL: https://svnweb.freebsd.org/changeset/base/316065 Log: Enable route and LLE (ndp) caching in TCP/IPv6 tcp_output.c was using a route on the stack for IPv6, which does not allow route caching or LLE/ndp caching. Switch to using the route (v6 flavor) in the in_pcb, which was already present, which caches both L3 and L2 lookups. Reviewed by: gnn hiren MFC after:2 weeks Modified: head/sys/netinet/tcp_output.c Modified: head/sys/netinet/tcp_output.c == --- head/sys/netinet/tcp_output.c Mon Mar 27 22:53:36 2017 (r316064) +++ head/sys/netinet/tcp_output.c Mon Mar 27 23:48:36 2017 (r316065) @@ -1377,9 +1377,6 @@ send: */ #ifdef INET6 if (isipv6) { - struct route_in6 ro; - - bzero(&ro, sizeof(ro)); /* * we separately set hoplimit for every segment, since the * user might want to change the value via setsockopt. @@ -1411,13 +1408,13 @@ send: #endif /* TODO: IPv6 IP6TOS_ECT bit on */ - error = ip6_output(m, tp->t_inpcb->in6p_outputopts, &ro, + error = ip6_output(m, tp->t_inpcb->in6p_outputopts, + &tp->t_inpcb->inp_route6, ((so->so_options & SO_DONTROUTE) ? IP_ROUTETOIF : 0), NULL, NULL, tp->t_inpcb); - if (error == EMSGSIZE && ro.ro_rt != NULL) - mtu = ro.ro_rt->rt_mtu; - RO_RTFREE(&ro); + if (error == EMSGSIZE && tp->t_inpcb->inp_route6.ro_rt != NULL) + mtu = tp->t_inpcb->inp_route6.ro_rt->rt_mtu; } #endif /* INET6 */ #if defined(INET) && defined(INET6) ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r315956 - in head/sys: netinet netinet6
Author: karels Date: Sat Mar 25 15:06:28 2017 New Revision: 315956 URL: https://svnweb.freebsd.org/changeset/base/315956 Log: Fix reference count leak with L2 caching. ip_forward, TCP/IPv6, and probably SCTP leaked references to L2 cache entry because they used their own routes on the stack, not in_pcb routes. The original model for route caching was callers that provided a route structure to ip{,6}input() would keep the route, and this model was used for L2 caching as well. Instead, change L2 caching to be done by default only when using a route structure in the in_pcb; the pcb deallocation code frees L2 as well as L3 cacches. A separate change will add route caching to TCP/IPv6. Another suggestion was to have the transport protocols indicate willingness to use L2 caching, but this approach keeps the changes in the network level Reviewed by:ae gnn MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D10059 and those below, will be ignored-- > Description of fields to fill in above: 76 columns --| > PR: If and which Problem Report is related. > Submitted by: If someone else sent in the change. > Reported by: If someone else reported the issue. > Reviewed by: If someone else reviewed your modification. > Approved by: If you needed approval for this commit. > Obtained from:If the change is from a third party. > MFC after:N [day[s]|week[s]|month[s]]. Request a reminder email. > MFH: Ports tree branch name. Request approval for merge. > Relnotes: Set to 'yes' for mention in release notes. > Security: Vulnerability reference (one per line) or description. > Sponsored by: If the change was sponsored by an organization. > Differential Revision:https://reviews.freebsd.org/D### (*full* phabric URL needed). > Empty fields above will be automatically removed. Mnetinet/in_pcb.c Mnetinet/ip_output.c Mnetinet6/ip6_output.c Modified: head/sys/netinet/in_pcb.c head/sys/netinet/ip_output.c head/sys/netinet6/ip6_output.c Modified: head/sys/netinet/in_pcb.c == --- head/sys/netinet/in_pcb.c Sat Mar 25 14:28:20 2017(r315955) +++ head/sys/netinet/in_pcb.c Sat Mar 25 15:06:28 2017(r315956) @@ -328,6 +328,12 @@ in_pcballoc(struct socket *so, struct in #endif inp->inp_gencnt = ++pcbinfo->ipi_gencnt; refcount_init(&inp->inp_refcount, 1); /* Reference from inpcbinfo */ + + /* +* Routes in inpcb's can cache L2 as well; they are guaranteed +* to be cleaned up. +*/ + inp->inp_route.ro_flags = RT_LLE_CACHE; INP_LIST_WUNLOCK(pcbinfo); #if defined(IPSEC) || defined(IPSEC_SUPPORT) || defined(MAC) out: Modified: head/sys/netinet/ip_output.c == --- head/sys/netinet/ip_output.cSat Mar 25 14:28:20 2017 (r315955) +++ head/sys/netinet/ip_output.cSat Mar 25 15:06:28 2017 (r315956) @@ -242,8 +242,7 @@ ip_output(struct mbuf *m, struct mbuf *o if (ro == NULL) { ro = &iproute; bzero(ro, sizeof (*ro)); - } else - ro->ro_flags |= RT_LLE_CACHE; + } #ifdef FLOWTABLE if (ro->ro_rt == NULL) Modified: head/sys/netinet6/ip6_output.c == --- head/sys/netinet6/ip6_output.c Sat Mar 25 14:28:20 2017 (r315955) +++ head/sys/netinet6/ip6_output.c Sat Mar 25 15:06:28 2017 (r315956) @@ -494,8 +494,7 @@ ip6_output(struct mbuf *m0, struct ip6_p if (ro == NULL) { ro = &ip6route; bzero((caddr_t)ro, sizeof(*ro)); - } else - ro->ro_flags |= RT_LLE_CACHE; + } ro_pmtu = ro; if (opt && opt->ip6po_rthdr) ro = &opt->ip6po_route; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r314087 - head/sys/x86/x86
Tangential, but: On 26 Feb 2017, at 6:44, Konstantin Belousov wrote: On Sun, Feb 26, 2017 at 04:43:12AM +1100, Bruce Evans wrote: 2.9 BSD was a port to PDP-11, AFAIK, with 16bit ints. All of the 2BSD systems ran on PDP-11 with 16-bit ints, as did Research versions 1 through 7th Edition. 2.9BSD just happens to be the version for which I was principal developer. I spent a lot of time back-porting from 4BSD (for the VAX), and int vs long was the main issue. Mike ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r304713 - head/sys/netinet6
Author: karels Date: Wed Aug 24 00:52:30 2016 New Revision: 304713 URL: https://svnweb.freebsd.org/changeset/base/304713 Log: Fix L2 caching for UDP over IPv6 ip6_output() was missing cache invalidation code analougous to ip_output.c. r304545 disabled L2 caching for UDP/IPv6 as a workaround. This change adds the missing cache invalidation code and reverts r304545. Reviewed by: gnn Approved by: gnn (mentor) Tested by:peter@, Mike Andrews MFC after:3 weeks Differential Revision:https://reviews.freebsd.org/D7591 Modified: head/sys/netinet6/ip6_output.c head/sys/netinet6/udp6_usrreq.c Modified: head/sys/netinet6/ip6_output.c == --- head/sys/netinet6/ip6_output.c Wed Aug 24 00:02:20 2016 (r304712) +++ head/sys/netinet6/ip6_output.c Wed Aug 24 00:52:30 2016 (r304713) @@ -87,6 +87,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -552,6 +553,9 @@ again: rt = ro->ro_rt; ifp = ro->ro_rt->rt_ifp; } else { + if (ro->ro_lle) + LLE_FREE(ro->ro_lle); /* zeros ro_lle */ + ro->ro_lle = NULL; if (fwd_tag == NULL) { bzero(&dst_sa, sizeof(dst_sa)); dst_sa.sin6_family = AF_INET6; @@ -821,6 +825,9 @@ again: } else { RO_RTFREE(ro); needfiblookup = 1; /* Redo the routing table lookup. */ + if (ro->ro_lle) + LLE_FREE(ro->ro_lle); /* zeros ro_lle */ + ro->ro_lle = NULL; } } /* See if fib was changed by packet filter. */ @@ -829,6 +836,9 @@ again: fibnum = M_GETFIB(m); RO_RTFREE(ro); needfiblookup = 1; + if (ro->ro_lle) + LLE_FREE(ro->ro_lle); /* zeros ro_lle */ + ro->ro_lle = NULL; } if (needfiblookup) goto again; Modified: head/sys/netinet6/udp6_usrreq.c == --- head/sys/netinet6/udp6_usrreq.c Wed Aug 24 00:02:20 2016 (r304712) +++ head/sys/netinet6/udp6_usrreq.c Wed Aug 24 00:52:30 2016 (r304713) @@ -898,7 +898,7 @@ udp6_output(struct inpcb *inp, struct mb UDP_PROBE(send, NULL, inp, ip6, inp, udp6); UDPSTAT_INC(udps_opackets); - error = ip6_output(m, optp, NULL, flags, + error = ip6_output(m, optp, &inp->inp_route6, flags, inp->in6p_moptions, NULL, inp); break; case AF_INET: ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r304545 - head/sys/netinet6
Author: karels Date: Sat Aug 20 20:46:53 2016 New Revision: 304545 URL: https://svnweb.freebsd.org/changeset/base/304545 Log: Disable L2 caching for UDP over IPv6 The ip6_output routine is missing L2 cache invalication as done in ip_output. Even with that code, some problems with UDP over IPv6 have been reported. Diabling L2 cache for that problem works around the problem for now. PR: 211872 211926 Reviewed by: gnn Approved by: gnn (mentor) MFC after:immediate Modified: head/sys/netinet6/udp6_usrreq.c Modified: head/sys/netinet6/udp6_usrreq.c == --- head/sys/netinet6/udp6_usrreq.c Sat Aug 20 20:28:08 2016 (r304544) +++ head/sys/netinet6/udp6_usrreq.c Sat Aug 20 20:46:53 2016 (r304545) @@ -898,7 +898,7 @@ udp6_output(struct inpcb *inp, struct mb UDP_PROBE(send, NULL, inp, ip6, inp, udp6); UDPSTAT_INC(udps_opackets); - error = ip6_output(m, optp, &inp->inp_route6, flags, + error = ip6_output(m, optp, NULL, flags, inp->in6p_moptions, NULL, inp); break; case AF_INET: ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r303978 - head/sys/netinet
Author: karels Date: Thu Aug 11 23:52:24 2016 New Revision: 303978 URL: https://svnweb.freebsd.org/changeset/base/303978 Log: Fix kernel build with TCP_RFC7413 option The current in_pcb.h includes route.h, which includes sockaddr structures. Including should require ; add it in the appropriate place. PR: 211385 Submitted by: Sergey Kandaurov and iron at mail.ua Reviewed by: gnn Approved by: gnn (mentor) MFC after: 1 day Modified: head/sys/netinet/tcp_fastopen.c Modified: head/sys/netinet/tcp_fastopen.c == --- head/sys/netinet/tcp_fastopen.c Thu Aug 11 23:49:55 2016 (r303977) +++ head/sys/netinet/tcp_fastopen.c Thu Aug 11 23:52:24 2016 (r303978) @@ -108,6 +108,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r303171 - in head/sys: netinet netinet6
Author: karels Date: Fri Jul 22 02:11:49 2016 New Revision: 303171 URL: https://svnweb.freebsd.org/changeset/base/303171 Log: Fix per-connection L2 caching in fast path r301217 re-added per-connection L2 caching from a previous change, but it omitted caching in the fast path. Add it. Reviewed By: gallatin Approved by: gnn (mentor) Differential Revision: https://reviews.freebsd.org/D7239 Modified: head/sys/netinet/if_ether.c head/sys/netinet6/nd6.c Modified: head/sys/netinet/if_ether.c == --- head/sys/netinet/if_ether.c Fri Jul 22 01:16:56 2016(r303170) +++ head/sys/netinet/if_ether.c Fri Jul 22 02:11:49 2016(r303171) @@ -607,7 +607,7 @@ arpresolve(struct ifnet *ifp, int is_gw, } IF_AFDATA_RLOCK(ifp); - la = lla_lookup(LLTABLE(ifp), LLE_UNLOCKED, dst); + la = lla_lookup(LLTABLE(ifp), plle ? LLE_EXCLUSIVE : LLE_UNLOCKED, dst); if (la != NULL && (la->r_flags & RLLE_VALID) != 0) { /* Entry found, let's copy lle info */ bcopy(la->r_linkdata, desten, la->r_hdrlen); @@ -619,9 +619,16 @@ arpresolve(struct ifnet *ifp, int is_gw, la->r_skip_req = 0; /* Notify that entry was used */ LLE_REQ_UNLOCK(la); } + if (plle) { + LLE_ADDREF(la); + *plle = la; + LLE_WUNLOCK(la); + } IF_AFDATA_RUNLOCK(ifp); return (0); } + if (plle && la) + LLE_WUNLOCK(la); IF_AFDATA_RUNLOCK(ifp); return (arpresolve_full(ifp, is_gw, la == NULL ? LLE_CREATE : 0, m, dst, Modified: head/sys/netinet6/nd6.c == --- head/sys/netinet6/nd6.c Fri Jul 22 01:16:56 2016(r303170) +++ head/sys/netinet6/nd6.c Fri Jul 22 02:11:49 2016(r303171) @@ -,7 +,8 @@ nd6_resolve(struct ifnet *ifp, int is_gw } IF_AFDATA_RLOCK(ifp); - ln = nd6_lookup(&dst6->sin6_addr, LLE_UNLOCKED, ifp); + ln = nd6_lookup(&dst6->sin6_addr, plle ? LLE_EXCLUSIVE : LLE_UNLOCKED, + ifp); if (ln != NULL && (ln->r_flags & RLLE_VALID) != 0) { /* Entry found, let's copy lle info */ bcopy(ln->r_linkdata, desten, ln->r_hdrlen); @@ -2235,9 +2236,15 @@ nd6_resolve(struct ifnet *ifp, int is_gw ln->lle_hittime = time_uptime; LLE_REQ_UNLOCK(ln); } + if (plle) { + LLE_ADDREF(ln); + *plle = ln; + LLE_WUNLOCK(ln); + } IF_AFDATA_RUNLOCK(ifp); return (0); - } + } else if (plle && ln) + LLE_WUNLOCK(ln); IF_AFDATA_RUNLOCK(ifp); return (nd6_resolve_slow(ifp, 0, m, dst6, desten, pflags, plle)); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r302023 - head/share/misc
Author: karels Date: Sun Jun 19 23:36:40 2016 New Revision: 302023 URL: https://svnweb.freebsd.org/changeset/base/302023 Log: Add Mike Karels as committer, with gnn as mentor. Approved by: gnn (mentor) Approved by: re Modified: head/share/misc/committers-src.dot Modified: head/share/misc/committers-src.dot == --- head/share/misc/committers-src.dot Sun Jun 19 21:29:17 2016 (r302022) +++ head/share/misc/committers-src.dot Sun Jun 19 23:36:40 2016 (r302023) @@ -212,6 +212,7 @@ julian [label="Julian Elischer\njulian@F jwd [label="John De Boskey\n...@freebsd.org\n2000/05/19"] kaiw [label="Kai Wang\nk...@freebsd.org\n2007/09/26"] kan [label="Alexander Kabaev\n...@freebsd.org\n2002/07/21"] +karels [label="Mike Karels\nkar...@freebsd.org\n2016/06/09"] ken [label="Ken Merry\n...@freebsd.org\n1998/09/08"] kensmith [label="Ken Smith\nkensm...@freebsd.org\n2004/01/23"] kevlo [label="Kevin Lo\nke...@freebsd.org\n2006/07/23"] @@ -481,6 +482,7 @@ gnn -> arybchik gnn -> erj gnn -> kp gnn -> jtl +gnn -> karels gonzo -> jmcneill ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"