arm64/llvm: default to strict alignment
Hi, currently our clang for ARM64 creates code thinking it can do unaligned access. Which is kinda true, since our kernel does not enforce strict alignment yet. The Pine64 on the other hand enforces strict alignment at least as long as EFI is running. This means efiboot needs to be compiled with strict alignment, while it wouldn't yet matter on kernel or userland. Still, we probably want to make strict alignment the default and then enforce it. This diff makes clang use strict alignment on OpenBSD if it wasn't overridden by any flags. ok? Patrick diff --git a/gnu/llvm/tools/clang/lib/Driver/Tools.cpp b/gnu/llvm/tools/clang/lib/Driver/Tools.cpp index bc7b9a98bb6..2e88668e866 100644 --- a/gnu/llvm/tools/clang/lib/Driver/Tools.cpp +++ b/gnu/llvm/tools/clang/lib/Driver/Tools.cpp @@ -2470,7 +2470,9 @@ getAArch64MicroArchFeaturesFromMcpu(const Driver , StringRef Mcpu, return getAArch64MicroArchFeaturesFromMtune(D, CPU, Args, Features); } -static void getAArch64TargetFeatures(const Driver , const ArgList , +static void getAArch64TargetFeatures(const Driver , + const llvm::Triple , + const ArgList , std::vector ) { Arg *A; bool success = true; @@ -2512,9 +2514,11 @@ static void getAArch64TargetFeatures(const Driver , const ArgList , } if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access, - options::OPT_munaligned_access)) + options::OPT_munaligned_access)) { if (A->getOption().matches(options::OPT_mno_unaligned_access)) Features.push_back("+strict-align"); + } else if (Triple.isOSOpenBSD()) +Features.push_back("+strict-align"); if (Args.hasArg(options::OPT_ffixed_x18)) Features.push_back("+reserve-x18"); @@ -2600,7 +2604,7 @@ static void getTargetFeatures(const ToolChain , const llvm::Triple , break; case llvm::Triple::aarch64: case llvm::Triple::aarch64_be: -getAArch64TargetFeatures(D, Args, Features); +getAArch64TargetFeatures(D, Triple, Args, Features); break; case llvm::Triple::x86: case llvm::Triple::x86_64:
OpenBGPd: expand rib list (updated for r1.295)
Hello, Here is a patch to expand RIB names in rules. When playing with multi-RIBs, it allows to simplify ruleset. Ex : # cat /etc/bgpd.conf [...] peer_ribs = "{ m1, m2, m3 }" deny rib m2 from any allow rib $peer_ribs from any prefix { 2001:db8:1::/48, 2001:db8:2::/48 } # bgpd -dnv [...] deny rib m2 from any allow rib m3 from any prefix 2001:db8:2::/48 allow rib m3 from any prefix 2001:db8:1::/48 allow rib m2 from any prefix 2001:db8:2::/48 allow rib m2 from any prefix 2001:db8:1::/48 allow rib m1 from any prefix 2001:db8:2::/48 allow rib m1 from any prefix 2001:db8:1::/48 Index: parse.y === RCS file: /cvs/src/usr.sbin/bgpd/parse.y,v retrieving revision 1.295 diff -u -p -r1.295 parse.y --- parse.y 18 Jan 2017 04:28:45 - 1.295 +++ parse.y 20 Jan 2017 20:15:20 - @@ -91,6 +91,11 @@ static struct filter_rule*curpeer_filte static struct filter_rule *curgroup_filter[2]; static u_int32_tid; +struct filter_rib_l { + struct filter_rib_l *next; + char name[PEER_DESCR_LEN]; +}; + struct filter_peers_l { struct filter_peers_l *next; struct filter_peers p; @@ -128,8 +133,9 @@ struct rde_rib *find_rib(char *); int get_id(struct peer *); int merge_prefixspec(struct filter_prefix_l *, struct filter_prefixlen *); -int expand_rule(struct filter_rule *, struct filter_peers_l *, - struct filter_match_l *, struct filter_set_head *); +int expand_rule(struct filter_rule *, struct filter_rib_l *, + struct filter_peers_l *, struct filter_match_l *, + struct filter_set_head *); int str2key(char *, char *, size_t); int neighbor_consistent(struct peer *); int merge_filterset(struct filter_set_head *, struct filter_set *); @@ -153,6 +159,7 @@ typedef struct { char*string; struct bgpd_addr addr; u_int8_t u8; + struct filter_rib_l *filter_rib; struct filter_peers_l *filter_peers; struct filter_match_lfilter_match; struct filter_prefix_l *filter_prefix; @@ -203,10 +210,11 @@ typedef struct { %typeasnumber as4number as4number_any optnumber %typeespah family restart origincode nettype %typeyesno inout restricted -%typestring filter_rib +%typestring %type address %typeprefix addrspec %typeaction quick direction delete +%typefilter_rib_h filter_rib_l filter_rib %type filter_peer filter_peer_l filter_peer_h %type filter_match filter_elm filter_match_h %type filter_as filter_as_l filter_as_h @@ -1469,9 +1477,10 @@ encspec : /* nada */{ } ; -filterrule : action quick filter_rib direction filter_peer_h filter_match_h filter_set +filterrule : action quick filter_rib_h direction filter_peer_h filter_match_h filter_set { struct filter_rule r; + struct filter_rib_l *rb, *rbnext; bzero(, sizeof(r)); r.action = $1; @@ -1481,25 +1490,15 @@ filterrule : action quick filter_rib dir if (r.dir != DIR_IN) { yyerror("rib only allowed on \"from\" " "rules."); - free($3); - YYERROR; - } - if (!find_rib($3)) { - yyerror("rib \"%s\" does not exist.", - $3); - free($3); - YYERROR; - } - if (strlcpy(r.rib, $3, sizeof(r.rib)) >= - sizeof(r.rib)) { - yyerror("rib name \"%s\" too long: " - "max %zu", $3, sizeof(r.rib) - 1); - free($3); + + for (rb = $3; rb != NULL; rb = rbnext) { + rbnext = rb->next; + free(rb); + } YYERROR; } - free($3); } - if (expand_rule(, $5, &$6, $7) ==
Re: NET_LOCK() take 2, tests wanted!
On Fri, Jan 20, 2017 at 05:16:50PM +0100, Alexander Bluhm wrote: > I am currently running a full regress test with this diff. > It hangs at /usr/src/regress/lib/libpthread/socket Tests have finished, libpthread was aborted after 1 hour, process socket1 still lives. The machine is running a current kernel with your diff. Userland is still from Tue Jan 17 i386 snapshot. Everything else seems to work fine. bluhm
remove raw_input()
Hi, The function raw_input() gets not called since netiso has been removed in 2004. The comment above rip_input() has been added in 1981, but it is wrong since 1992. pr_input is never called with parameters (*pr_input)(mbuf, sockproto, sockaddr, sockaddr). So I think it is time to retire raw_input(). ok? bluhm Index: kern/uipc_proto.c === RCS file: /data/mirror/openbsd/cvs/src/sys/kern/uipc_proto.c,v retrieving revision 1.9 diff -u -p -r1.9 uipc_proto.c --- kern/uipc_proto.c 5 Sep 2016 15:12:29 - 1.9 +++ kern/uipc_proto.c 20 Jan 2017 18:56:20 - @@ -65,7 +65,7 @@ struct protosw unixsw[] = { 0, 0, 0, 0, }, { 0, 0, 0, 0, - raw_input, 0, 0, 0, + 0, 0, 0, 0, raw_usrreq, raw_init,0, 0, 0, } Index: net/pfkey.c === RCS file: /data/mirror/openbsd/cvs/src/sys/net/pfkey.c,v retrieving revision 1.34 diff -u -p -r1.34 pfkey.c --- net/pfkey.c 13 Jan 2017 08:52:09 - 1.34 +++ net/pfkey.c 20 Jan 2017 18:57:04 - @@ -270,7 +270,7 @@ static struct protosw pfkey_protosw_temp , -1, /* protocol */ PR_ATOMIC | PR_ADDR, - (void *) raw_input, + NULL, /* input */ (void *) pfkey_output, NULL, /* ctlinput */ NULL, /* ctloutput */ Index: net/raw_cb.h === RCS file: /data/mirror/openbsd/cvs/src/sys/net/raw_cb.h,v retrieving revision 1.10 diff -u -p -r1.10 raw_cb.h --- net/raw_cb.h5 Sep 2016 15:12:30 - 1.10 +++ net/raw_cb.h20 Jan 2017 18:57:13 - @@ -62,7 +62,6 @@ intraw_attach(struct socket *, int); voidraw_detach(struct rawcb *); voidraw_disconnect(struct rawcb *); voidraw_init(void); -voidraw_input(struct mbuf *, ...); int raw_usrreq(struct socket *, int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *); #endif /* _KERNEL */ Index: net/raw_usrreq.c === RCS file: /data/mirror/openbsd/cvs/src/sys/net/raw_usrreq.c,v retrieving revision 1.27 diff -u -p -r1.27 raw_usrreq.c --- net/raw_usrreq.c19 Dec 2016 08:36:49 - 1.27 +++ net/raw_usrreq.c20 Jan 2017 18:57:51 - @@ -55,82 +55,6 @@ raw_init(void) LIST_INIT(); } - -/* - * Raw protocol input routine. Find the socket - * associated with the packet(s) and move them over. If - * nothing exists for this packet, drop it. - */ -/* - * Raw protocol interface. - */ -void -raw_input(struct mbuf *m0, ...) -{ - struct rawcb *rp; - struct mbuf *m = m0; - int sockets = 0; - struct socket *last; - va_list ap; - struct sockproto *proto; - struct sockaddr *src, *dst; - - va_start(ap, m0); - proto = va_arg(ap, struct sockproto *); - src = va_arg(ap, struct sockaddr *); - dst = va_arg(ap, struct sockaddr *); - va_end(ap); - - last = 0; - LIST_FOREACH(rp, , rcb_list) { - if (rp->rcb_socket->so_state & SS_CANTRCVMORE) - continue; - if (rp->rcb_proto.sp_family != proto->sp_family) - continue; - if (rp->rcb_proto.sp_protocol && - rp->rcb_proto.sp_protocol != proto->sp_protocol) - continue; - /* -* We assume the lower level routines have -* placed the address in a canonical format -* suitable for a structure comparison. -* -* Note that if the lengths are not the same -* the comparison will fail at the first byte. -*/ -#defineequal(a1, a2) \ - (bcmp((caddr_t)(a1), (caddr_t)(a2), a1->sa_len) == 0) - if (rp->rcb_laddr && !equal(rp->rcb_laddr, dst)) - continue; - if (rp->rcb_faddr && !equal(rp->rcb_faddr, src)) - continue; - if (last) { - struct mbuf *n; - if ((n = m_copym(m, 0, M_COPYALL, M_NOWAIT)) != NULL) { - if (sbappendaddr(>so_rcv, src, - n, (struct mbuf *)NULL) == 0) - /* should notify about lost packet */ - m_freem(n); - else { - sorwakeup(last); - sockets++; - } - } - } - last = rp->rcb_socket; - } - if (last) { - if (sbappendaddr(>so_rcv, src, -
Re: arm64/llvm: default to strict alignment
> Date: Fri, 20 Jan 2017 21:41:37 +1000 > From: Patrick Wildt> > Hi, > > currently our clang for ARM64 creates code thinking it can do unaligned > access. Which is kinda true, since our kernel does not enforce strict > alignment yet. The Pine64 on the other hand enforces strict alignment > at least as long as EFI is running. This means efiboot needs to be > compiled with strict alignment, while it wouldn't yet matter on kernel > or userland. > > Still, we probably want to make strict alignment the default and then > enforce it. This diff makes clang use strict alignment on OpenBSD if > it wasn't overridden by any flags. > > ok? ok kettenis@ Perhaps we should wait upstreaming this for a bit until we're sure it is viable to enforce strict-alignment though. > diff --git a/gnu/llvm/tools/clang/lib/Driver/Tools.cpp > b/gnu/llvm/tools/clang/lib/Driver/Tools.cpp > index bc7b9a98bb6..2e88668e866 100644 > --- a/gnu/llvm/tools/clang/lib/Driver/Tools.cpp > +++ b/gnu/llvm/tools/clang/lib/Driver/Tools.cpp > @@ -2470,7 +2470,9 @@ getAArch64MicroArchFeaturesFromMcpu(const Driver , > StringRef Mcpu, >return getAArch64MicroArchFeaturesFromMtune(D, CPU, Args, Features); > } > > -static void getAArch64TargetFeatures(const Driver , const ArgList , > +static void getAArch64TargetFeatures(const Driver , > + const llvm::Triple , > + const ArgList , > std::vector ) { >Arg *A; >bool success = true; > @@ -2512,9 +2514,11 @@ static void getAArch64TargetFeatures(const Driver , > const ArgList , >} > >if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access, > - options::OPT_munaligned_access)) > + options::OPT_munaligned_access)) { > if (A->getOption().matches(options::OPT_mno_unaligned_access)) >Features.push_back("+strict-align"); > + } else if (Triple.isOSOpenBSD()) > +Features.push_back("+strict-align"); > >if (Args.hasArg(options::OPT_ffixed_x18)) > Features.push_back("+reserve-x18"); > @@ -2600,7 +2604,7 @@ static void getTargetFeatures(const ToolChain , > const llvm::Triple , > break; >case llvm::Triple::aarch64: >case llvm::Triple::aarch64_be: > -getAArch64TargetFeatures(D, Args, Features); > +getAArch64TargetFeatures(D, Triple, Args, Features); > break; >case llvm::Triple::x86: >case llvm::Triple::x86_64: > >
Re: rtsock refactoring
On Fri, Jan 20, 2017 at 02:51:52AM +0100, Claudio Jeker wrote: > I sent this diff out some time ago and would really like to get this in. > This is one step on makeing rtsock.c less of a hornets nest. > This reduces the side effects in route_output and simplifies some other > bits as well. For example route_input is less variadic and simpler. > Here is just the route_input change. Which should be easier to OK. Changed a few things based on input from bluhm@ -- :wq Claudio Index: net/rtsock.c === RCS file: /cvs/src/sys/net/rtsock.c,v retrieving revision 1.214 diff -u -p -r1.214 rtsock.c --- net/rtsock.c20 Jan 2017 08:10:54 - 1.214 +++ net/rtsock.c21 Jan 2017 00:10:16 - @@ -92,7 +92,6 @@ struct sockaddrroute_dst = { 2, PF_ROUTE, }; struct sockaddrroute_src = { 2, PF_ROUTE, }; -struct sockproto route_proto = { PF_ROUTE, }; struct walkarg { int w_op, w_arg, w_given, w_needed, w_tmemsize; @@ -100,7 +99,7 @@ struct walkarg { }; introute_ctloutput(int, struct socket *, int, int, struct mbuf **); -void route_input(struct mbuf *m0, ...); +void route_input(struct mbuf *m0, sa_family_t); introute_arp_conflict(struct rtentry *, struct rt_addrinfo *); introute_cleargateway(struct rtentry *, void *, unsigned int); @@ -332,7 +331,7 @@ rt_senddesync(void *data) } void -route_input(struct mbuf *m0, ...) +route_input(struct mbuf *m0, sa_family_t sa_family) { struct rawcb *rp; struct routecb *rop; @@ -340,15 +339,10 @@ route_input(struct mbuf *m0, ...) struct mbuf *m = m0; int s, sockets = 0; struct socket *last = NULL; - va_list ap; - struct sockproto *proto; struct sockaddr *sosrc, *sodst; - va_start(ap, m0); - proto = va_arg(ap, struct sockproto *); - sosrc = va_arg(ap, struct sockaddr *); - sodst = va_arg(ap, struct sockaddr *); - va_end(ap); + sosrc = _src; + sodst = _dst; /* ensure that we can access the rtm_type via mtod() */ if (m->m_len < offsetof(struct rt_msghdr, rtm_type) + 1) { @@ -359,10 +353,16 @@ route_input(struct mbuf *m0, ...) LIST_FOREACH(rp, , rcb_list) { if (rp->rcb_socket->so_state & SS_CANTRCVMORE) continue; - if (rp->rcb_proto.sp_family != proto->sp_family) + if (rp->rcb_proto.sp_family != PF_ROUTE) continue; - if (rp->rcb_proto.sp_protocol && proto->sp_protocol && - rp->rcb_proto.sp_protocol != proto->sp_protocol) + /* +* If route socket is bound to an address family only send +* messages that match the address family. Address family +* agnostic messages are always send. +*/ + if (rp->rcb_proto.sp_protocol != AF_UNSPEC && + sa_family != AF_UNSPEC && + rp->rcb_proto.sp_protocol != sa_family) continue; /* * We assume the lower level routines have @@ -953,8 +953,6 @@ flush: rtm->rtm_flags |= RTF_DONE; } } - if (info.rti_info[RTAX_DST]) - route_proto.sp_protocol = info.rti_info[RTAX_DST]->sa_family; if (rt) rtfree(rt); @@ -970,9 +968,8 @@ fail: } /* There is another listener, so construct message */ rp = sotorawcb(so); - } - if (rp) rp->rcb_proto.sp_family = 0; /* Avoid us */ + } if (rtm) { if (m_copyback(m, 0, rtm->rtm_msglen, rtm, M_NOWAIT)) { m_freem(m); @@ -982,9 +979,10 @@ fail: free(rtm, M_RTABLE, 0); } if (m) - route_input(m, _proto, _src, _dst); + route_input(m, info.rti_info[RTAX_DST] ? + info.rti_info[RTAX_DST]->sa_family : AF_UNSPEC); if (rp) - rp->rcb_proto.sp_family = PF_ROUTE; + rp->rcb_proto.sp_family = PF_ROUTE; /* Readd us */ return (error); } @@ -1056,7 +1054,6 @@ rt_setmetrics(u_long which, const struct out->rmx_expire = expire; } - /* RTV_PRIORITY handled before */ } void @@ -1258,11 +1255,7 @@ rt_missmsg(int type, struct rt_addrinfo rtm->rtm_tableid = tableid; rtm->rtm_addrs = rtinfo->rti_addrs; rtm->rtm_index = ifidx; - if (sa == NULL) - route_proto.sp_protocol = 0; - else - route_proto.sp_protocol = sa->sa_family; - route_input(m, _proto, _src, _dst); + route_input(m, sa ? sa->sa_family : AF_UNSPEC); } /* @@ -1287,8 +1280,7 @@ rt_ifmsg(struct ifnet *ifp) ifm->ifm_xflags = ifp->if_xflags;
allow 'make obj' for users not belonging to group wobj
Following up on semarie's bug report, only try to chown to the group obj if this call is going to succeed. So that the bsd.prog.mk infrastructure can be used by all users independently of they belong to wobj or not. Index: share/mk/bsd.obj.mk === RCS file: /var/cvs/src/share/mk/bsd.obj.mk,v retrieving revision 1.16 diff -u -p -r1.16 bsd.obj.mk --- share/mk/bsd.obj.mk 19 Nov 2016 14:20:58 - 1.16 +++ share/mk/bsd.obj.mk 21 Jan 2017 03:42:57 - @@ -27,7 +27,7 @@ obj! _SUBDIRUSE }; \ MKDIRS=_mkdirs; \ fi; \ - elif [[ $$here == $$subdir ]]; then \ + elif [[ `id` == *'('${WOBJGROUP}')'* && $$here == $$subdir ]]; then \ SETOWNER="chown :${WOBJGROUP}"; \ else \ SETOWNER=:; \
man.openbsd.org upgraded
Hi, this is merely for your information: I just completed a major cleanup, started about one and a half weeks ago, of both the mandoc(1) -Thtml code itself and the HTML code it generates, both in multiple respects, and installed the new version on man.openbsd.org. If you notice anything odd (other than the fact that in tagged lists, the body always starts on the next line even when the tag is short, which i still don't know how to fix), please do tell me, i'm around to deal with any potential fallout. If the casual user sees no difference, i'm content. But you may want to configure your browser to show you the HTML source code for man.openbsd.org in the future rather than the rendered version, it's quite readable now and contains more information than in the rendered form. =;c) Enjoy, Ingo P.S. Some highlights of what is new: * major features - HTML class attributes now use mdoc(7) macro names - mandoc.css cleaned up and arranged in the same order as the mdoc(7) manual MACRO OVERVIEW section - HTML code is properly indented and broken into 80-character lines for human readability (required some new code to implement) * bugfixes - no more static buffer that can get exhausted while writing HTML attributes - fixed horizontal alignment of headers and footers - .No no longer produces markup - and a number of other markup fixes * HTML code cleanup - in various places, less elements are written - less constant attributes are written, more is now done in the style sheet - no more abuse of * C source code cleanup - much simplified print_otag() internal interface, resulting in a few hundred lines less code in *_html.c - no more struct htmlpair, no more ugly PAIR_*() macros - all text production now done in the validators, none in the formatters, resulting in a better parse tree and also in overall code reduction $ cd /usr/src/usr.bin/mandoc $ cvs diff -Nup -D 2017-01-07 -r HEAD > tmp.patch $ grep -c '^-[^-]' tmp.patch 1861 $ grep -c '^+[^+]' tmp.patch 1701 $ wc tmp.patch 7194 28136 189307 tmp.patch $ grep -c ^Index: tmp.patch 27
Re: sunxi: add Allwinner A64 support for USB and USB clocks
On Sat, Jan 21, 2017 at 10:50:20AM +1000, Patrick Wildt wrote: > Hi, > > so this diff makes the Pine64 work with EHCI. The only not nice thing > is the switch. It would be better if this depends on the compatible > since the A64 and H3 have different numbers (and clock parents) for the > APB2 clock. > > I would still like to go ahead with this version since I don't think > that the switch without the compatible check is going to hurt for now. > > ok? > > Patrick After discussion with kettenis@ and his commit I have updated the diff. I also added the clocks for MMC, which means that we now have a usable USB port and MMC. ok? Patrick diff --git a/sys/arch/armv7/sunxi/sxiccmu.c b/sys/arch/armv7/sunxi/sxiccmu.c index 921b1dd4fe4..e0146cb0164 100644 --- a/sys/arch/armv7/sunxi/sxiccmu.c +++ b/sys/arch/armv7/sunxi/sxiccmu.c @@ -25,8 +25,6 @@ #include #include -#include - #include #include #include @@ -88,6 +86,8 @@ int sxiccmu_ccu_set_frequency(void *, uint32_t *, uint32_t); void sxiccmu_ccu_enable(void *, uint32_t *, int); void sxiccmu_ccu_reset(void *, uint32_t *, int); +uint32_t sxiccmu_a64_get_frequency(struct sxiccmu_softc *, uint32_t); +intsxiccmu_a64_set_frequency(struct sxiccmu_softc *, uint32_t, uint32_t); uint32_t sxiccmu_h3_get_frequency(struct sxiccmu_softc *, uint32_t); intsxiccmu_h3_set_frequency(struct sxiccmu_softc *, uint32_t, uint32_t); @@ -102,12 +102,14 @@ sxiccmu_match(struct device *parent, void *match, void *aux) return (OF_is_compatible(node, "allwinner,sun4i-a10") || OF_is_compatible(node, "allwinner,sun5i-a10s") || OF_is_compatible(node, "allwinner,sun5i-r8") || + OF_is_compatible(node, "allwinner,sun50i-a64") || OF_is_compatible(node, "allwinner,sun7i-a20") || OF_is_compatible(node, "allwinner,sun8i-h3") || OF_is_compatible(node, "allwinner,sun9i-a80")); } - return OF_is_compatible(faa->fa_node, "allwinner,sun8i-h3-ccu"); + return (OF_is_compatible(faa->fa_node, "allwinner,sun50i-a64-ccu") || + OF_is_compatible(faa->fa_node, "allwinner,sun8i-h3-ccu")); } void @@ -124,7 +126,15 @@ sxiccmu_attach(struct device *parent, struct device *self, void *aux) printf("\n"); - if (OF_is_compatible(node, "allwinner,sun8i-h3-ccu")) { + if (OF_is_compatible(node, "allwinner,sun50i-a64-ccu")) { + KASSERT(faa->fa_nreg > 0); + sc->sc_gates = sun50i_a64_gates; + sc->sc_ngates = nitems(sun50i_a64_gates); + sc->sc_resets = sun50i_a64_resets; + sc->sc_nresets = nitems(sun50i_a64_resets); + sc->sc_get_frequency = sxiccmu_a64_get_frequency; + sc->sc_set_frequency = sxiccmu_a64_set_frequency; + } else if (OF_is_compatible(node, "allwinner,sun8i-h3-ccu")) { KASSERT(faa->fa_nreg > 0); sc->sc_gates = sun8i_h3_gates; sc->sc_ngates = nitems(sun8i_h3_gates); @@ -653,6 +663,24 @@ sxiccmu_ccu_get_frequency(void *cookie, uint32_t *cells) } uint32_t +sxiccmu_a64_get_frequency(struct sxiccmu_softc *sc, uint32_t idx) +{ + switch (idx) { + case A64_CLK_PLL_PERIPH0: + /* XXX default value. */ + return 6; + case A64_CLK_PLL_PERIPH0_2X: + return sxiccmu_a64_get_frequency(sc, A64_CLK_PLL_PERIPH0) * 2; + case A64_CLK_APB2: + /* XXX Controlled by a MUX. */ + return 2400; + } + + printf("%s: 0x%08x\n", __func__, idx); + return 0; +} + +uint32_t sxiccmu_h3_get_frequency(struct sxiccmu_softc *sc, uint32_t idx) { switch (idx) { @@ -678,6 +706,28 @@ sxiccmu_ccu_set_frequency(void *cookie, uint32_t *cells, uint32_t freq) } int +sxiccmu_a64_set_frequency(struct sxiccmu_softc *sc, uint32_t idx, uint32_t freq) +{ + struct sxiccmu_clock clock; + uint32_t parent, parent_freq; + + switch (idx) { + case A64_CLK_MMC0: + case A64_CLK_MMC1: + case A64_CLK_MMC2: + clock.sc_iot = sc->sc_iot; + bus_space_subregion(sc->sc_iot, sc->sc_ioh, + sc->sc_gates[idx].reg, 4, _ioh); + parent = A64_CLK_PLL_PERIPH0_2X; + parent_freq = sxiccmu_ccu_get_frequency(sc, ); + return sxiccmu_mmc_do_set_frequency(, freq, parent_freq); + } + + printf("%s: 0x%08x\n", __func__, idx); + return -1; +} + +int sxiccmu_h3_set_frequency(struct sxiccmu_softc *sc, uint32_t idx, uint32_t freq) { struct sxiccmu_clock clock; diff --git a/sys/arch/armv7/sunxi/sxiccmu_clocks.h b/sys/arch/armv7/sunxi/sxiccmu_clocks.h index 84791762035..fdd0282623b 100644 --- a/sys/arch/armv7/sunxi/sxiccmu_clocks.h +++ b/sys/arch/armv7/sunxi/sxiccmu_clocks.h @@ -5,6 +5,57 @@ * Clocks Signals */ +#define
Re: remove raw_input()
On Fri, 20 Jan 2017, Alexander Bluhm wrote: > The function raw_input() gets not called since netiso has been removed > in 2004. The comment above rip_input() has been added in 1981, but it > is wrong since 1992. pr_input is never called with parameters > (*pr_input)(mbuf, sockproto, sockaddr, sockaddr). > > So I think it is time to retire raw_input(). > > ok? Yes, please. I think we can remove that entire last member of unixsw[] in uipc_proto.c, as 'raw' UNIX domain sockets aren't actually usable, with no defined semantics. FreeBSD removed them in 2006, for example. Philip
Re: NET_LOCK() ordering issue
On Thu, Jan 19, 2017 at 07:14:59PM +1000, Martin Pieuchot wrote: > Index: kern/uipc_syscalls.c > === > RCS file: /cvs/src/sys/kern/uipc_syscalls.c,v > retrieving revision 1.144 > diff -u -p -r1.144 uipc_syscalls.c > --- kern/uipc_syscalls.c 29 Dec 2016 12:12:43 - 1.144 > +++ kern/uipc_syscalls.c 19 Jan 2017 09:03:56 - > @@ -278,6 +278,7 @@ doaccept(struct proc *p, int sock, struc > > headfp = fp; > redo: > + fdplock(fdp); > NET_LOCK(s); > head = headfp->f_data; > if (isdnssocket(head) || (head->so_options & SO_ACCEPTCONN) == 0) { ... There we have error = rwsleep(>so_timeo, , PSOCK | PCATCH, "netcon", 0); You release the netlock during sleep but still hold the fdplock. This leads to a deadlock of userland during /usr/src/regress/lib/libpthread/socket/1. 277134 socket1 native0x83accfd8 thrsleep 236121 socket1 native0xff00023eab56 netcon 220469 socket1 native0xff0004d53a98 fdlock ddb{0}> trace /p 0t236121 sleep_finish() at sleep_finish+0xb1 rwsleep() at rwsleep+0x8e doaccept() at doaccept+0x37b syscall() at syscall+0x27b --- syscall (number 30) --- ddb{0}> trace /p 0t220469 sleep_finish() at sleep_finish+0xb1 rw_enter() at rw_enter+0x1cb sys_socket() at sys_socket+0xbf syscall() at syscall+0x27b --- syscall (number 97) --- > @@ -312,11 +313,9 @@ redo: > nflag = flags & SOCK_NONBLOCK_INHERIT ? (headfp->f_flag & FNONBLOCK) > : (flags & SOCK_NONBLOCK ? FNONBLOCK : 0); > > - fdplock(fdp); > error = falloc(p, , ); > if (error == 0 && (flags & SOCK_CLOEXEC)) > fdp->fd_ofileflags[tmpfd] |= UF_EXCLOSE; > - fdpunlock(fdp); > if (error != 0) { > /* >* Probably ran out of file descriptors. Wakeup > @@ -336,7 +335,6 @@ redo: > if (head->so_qlen == 0) { > NET_UNLOCK(s); > m_freem(nam); > - fdplock(fdp); > fdremove(fdp, tmpfd); > closef(fp, p); > fdpunlock(fdp); > @@ -365,7 +363,6 @@ redo: > /* if an error occurred, free the file descriptor */ > NET_UNLOCK(s); > m_freem(nam); > - fdplock(fdp); > fdremove(fdp, tmpfd); > closef(fp, p); > fdpunlock(fdp); > @@ -377,6 +374,7 @@ redo: > m_freem(nam); > bad: > NET_UNLOCK(s); > + fdpunlock(fdp); > out: > FRELE(headfp, p); > return (error);
Re: NET_LOCK() take 2, tests wanted!
On 20/01/17(Fri) 12:04, Martin Pieuchot wrote: > Diff below enables the NET_LOCK(), again. > > What's new? > > - The lock ordering problem with fdplock() should now be fixed. It is >also documented, fdplock() should be taken first if both locks are >needed. > > - Page faults involving NFS, or any other code path already holding the >NET_LOCK(), have been fixed. The recursion is similar to the existing >vnode problem, so I simply added a hack there. > > - I added some NET_ASSERT_UNLOCKED() to help finding other possible >deadlocks. Thanks to all the testers! Updated diff with: - A hack to mark and prevent pflow(4)/pf(4) recursion reported by many - A fix to prevent the deadlock in accept(2) - The introduction of inifioctl to prevent false positive when checking that no unwanted tsleep(9) are done while holding the NET_LOCK(). diff --git sys/kern/kern_rwlock.c sys/kern/kern_rwlock.c index bdaee0c1ae7..9182b42706a 100644 --- sys/kern/kern_rwlock.c +++ sys/kern/kern_rwlock.c @@ -195,6 +195,9 @@ retry: unsigned long set = o | op->wait_set; int do_sleep; + if (panicstr) + return (0); + rw_enter_diag(rwl, flags); if (flags & RW_NOSLEEP) @@ -205,7 +208,7 @@ retry: sleep_setup_signal(, op->wait_prio | PCATCH); do_sleep = !rw_cas(>rwl_owner, o, set); - + NET_ASSERT_UNLOCKED(); sleep_finish(, do_sleep); if ((flags & RW_INTR) && (error = sleep_finish_signal()) != 0) diff --git sys/kern/kern_synch.c sys/kern/kern_synch.c index beeefe06458..68ad163f839 100644 --- sys/kern/kern_synch.c +++ sys/kern/kern_synch.c @@ -111,6 +111,11 @@ tsleep(const volatile void *ident, int priority, const char *wmesg, int timo) int hold_count; #endif +#if 1 + extern int inifioctl; + if (!inifioctl) + NET_ASSERT_UNLOCKED(); +#endif KASSERT((priority & ~(PRIMASK | PCATCH)) == 0); #ifdef MULTIPROCESSOR @@ -170,6 +175,11 @@ msleep(const volatile void *ident, struct mutex *mtx, int priority, int hold_count; #endif +#if 1 + extern int inifioctl; + if (!inifioctl) + NET_ASSERT_UNLOCKED(); +#endif KASSERT((priority & ~(PRIMASK | PCATCH | PNORELOCK)) == 0); KASSERT(mtx != NULL); diff --git sys/kern/sys_socket.c sys/kern/sys_socket.c index 7c8d8f728d1..a3b7db9ab7c 100644 --- sys/kern/sys_socket.c +++ sys/kern/sys_socket.c @@ -121,7 +121,14 @@ soo_ioctl(struct file *fp, u_long cmd, caddr_t data, struct proc *p) */ if (IOCGROUP(cmd) == 'i') { NET_LOCK(s); +#if 1 + extern int inifioctl; + inifioctl = 1; +#endif error = ifioctl(so, cmd, data, p); +#if 1 + inifioctl = 0; +#endif NET_UNLOCK(s); return (error); } diff --git sys/kern/uipc_socket.c sys/kern/uipc_socket.c index 245210e594a..edc419eb937 100644 --- sys/kern/uipc_socket.c +++ sys/kern/uipc_socket.c @@ -256,7 +256,7 @@ soclose(struct socket *so) (so->so_state & SS_NBIO)) goto drop; while (so->so_state & SS_ISCONNECTED) { - error = tsleep(>so_timeo, + error = rwsleep(>so_timeo, , PSOCK | PCATCH, "netcls", so->so_linger * hz); if (error) @@ -615,7 +615,7 @@ sbsync(struct sockbuf *sb, struct mbuf *nextrecord) * followed by an optional mbuf or mbufs containing ancillary data, * and then zero or more mbufs of data. * In order to avoid blocking network for the entire time here, we splx() - * and release NET_LOCK() while doing the actual copy to user space. + * and release ``netlock'' while doing the actual copy to user space. * Although the sockbuf is locked, new data may still be appended, * and thus we must maintain consistency of the sockbuf during that time. * @@ -800,9 +800,13 @@ dontblock: if (controlp) { if (pr->pr_domain->dom_externalize && mtod(cm, struct cmsghdr *)->cmsg_type == - SCM_RIGHTS) - error = (*pr->pr_domain->dom_externalize)(cm, - controllen, flags); + SCM_RIGHTS) { + NET_UNLOCK(s); + error = + (*pr->pr_domain->dom_externalize) + (cm, controllen, flags); + NET_LOCK(s); + }
Re: NET_LOCK() take 2, tests wanted!
On 20/01/17(Fri) 17:16, Alexander Bluhm wrote: > > --- sys/kern/kern_rwlock.c > > +++ sys/kern/kern_rwlock.c > > @@ -195,6 +195,9 @@ retry: > > unsigned long set = o | op->wait_set; > > int do_sleep; > > > > + if (panicstr) > > + return (0); > > + > > rw_enter_diag(rwl, flags); > > > > if (flags & RW_NOSLEEP) > > I guess this is against the problem that ddb reboot does not work > anymore. Could you also check for the variable "db_is_active" > there? After kernel uvm faults or ddb console hotkey you still > cannot reboot from ddb as they do not panic. I'll leave that for latter, it's more complex that it looks like.
Re: NET_LOCK() ordering issue
On 20/01/17(Fri) 22:25, Alexander Bluhm wrote: > On Thu, Jan 19, 2017 at 07:14:59PM +1000, Martin Pieuchot wrote: > > Index: kern/uipc_syscalls.c > > === > > RCS file: /cvs/src/sys/kern/uipc_syscalls.c,v > > retrieving revision 1.144 > > diff -u -p -r1.144 uipc_syscalls.c > > --- kern/uipc_syscalls.c29 Dec 2016 12:12:43 - 1.144 > > +++ kern/uipc_syscalls.c19 Jan 2017 09:03:56 - > > @@ -278,6 +278,7 @@ doaccept(struct proc *p, int sock, struc > > > > headfp = fp; > > redo: > > + fdplock(fdp); > > NET_LOCK(s); > > head = headfp->f_data; > > if (isdnssocket(head) || (head->so_options & SO_ACCEPTCONN) == 0) { > ... > > There we have > error = rwsleep(>so_timeo, , PSOCK | PCATCH, > "netcon", 0); > > You release the netlock during sleep but still hold the fdplock. > This leads to a deadlock of userland during > /usr/src/regress/lib/libpthread/socket/1. > > 277134 socket1 native0x83accfd8 thrsleep > 236121 socket1 native0xff00023eab56 netcon > 220469 socket1 native0xff0004d53a98 fdlock > > ddb{0}> trace /p 0t236121 > sleep_finish() at sleep_finish+0xb1 > rwsleep() at rwsleep+0x8e > doaccept() at doaccept+0x37b > syscall() at syscall+0x27b > --- syscall (number 30) --- > > ddb{0}> trace /p 0t220469 > sleep_finish() at sleep_finish+0xb1 > rw_enter() at rw_enter+0x1cb > sys_socket() at sys_socket+0xbf > syscall() at syscall+0x27b > --- syscall (number 97) --- Here's another way to fix the problem, call falloc() before grabbing the NET_LOCK(). Comments? Index: kern/uipc_syscalls.c === RCS file: /cvs/src/sys/kern/uipc_syscalls.c,v retrieving revision 1.144 diff -u -p -r1.144 uipc_syscalls.c --- kern/uipc_syscalls.c29 Dec 2016 12:12:43 - 1.144 +++ kern/uipc_syscalls.c21 Jan 2017 00:38:18 - @@ -265,7 +265,7 @@ doaccept(struct proc *p, int sock, struc { struct filedesc *fdp = p->p_fd; struct file *fp, *headfp; - struct mbuf *nam; + struct mbuf *nam = NULL; socklen_t namelen; int error, s, tmpfd; struct socket *head, *so; @@ -277,19 +277,35 @@ doaccept(struct proc *p, int sock, struc return (error); headfp = fp; + head = headfp->f_data; + + fdplock(fdp); + error = falloc(p, , ); + if (error == 0 && (flags & SOCK_CLOEXEC)) + fdp->fd_ofileflags[tmpfd] |= UF_EXCLOSE; + fdpunlock(fdp); + if (error != 0) { + /* +* Probably ran out of file descriptors. Wakeup +* so some other process might have a chance at it. +*/ + wakeup_one(>so_timeo); + FRELE(headfp, p); + return (error); + } + redo: NET_LOCK(s); - head = headfp->f_data; if (isdnssocket(head) || (head->so_options & SO_ACCEPTCONN) == 0) { error = EINVAL; - goto bad; + goto out; } if ((head->so_state & SS_NBIO) && head->so_qlen == 0) { if (head->so_state & SS_CANTRCVMORE) error = ECONNABORTED; else error = EWOULDBLOCK; - goto bad; + goto out; } while (head->so_qlen == 0 && head->so_error == 0) { if (head->so_state & SS_CANTRCVMORE) { @@ -298,34 +314,19 @@ redo: } error = tsleep(>so_timeo, PSOCK | PCATCH, "netcon", 0); - if (error) { - goto bad; - } + if (error) + goto out; } if (head->so_error) { error = head->so_error; head->so_error = 0; - goto bad; + goto out; } /* Figure out whether the new socket should be non-blocking. */ nflag = flags & SOCK_NONBLOCK_INHERIT ? (headfp->f_flag & FNONBLOCK) : (flags & SOCK_NONBLOCK ? FNONBLOCK : 0); - fdplock(fdp); - error = falloc(p, , ); - if (error == 0 && (flags & SOCK_CLOEXEC)) - fdp->fd_ofileflags[tmpfd] |= UF_EXCLOSE; - fdpunlock(fdp); - if (error != 0) { - /* -* Probably ran out of file descriptors. Wakeup -* so some other process might have a chance at it. -*/ - wakeup_one(>so_timeo); - goto bad; - } - nam = m_get(M_WAIT, MT_SONAME); /* @@ -360,24 +361,20 @@ redo: error = soaccept(so, nam); if (!error && name != NULL) error = copyaddrout(p, nam, name, namelen, anamelen); - - if (error) { - /* if an error occurred,
sunxi: add Allwinner A64 support for USB and USB clocks
Hi, so this diff makes the Pine64 work with EHCI. The only not nice thing is the switch. It would be better if this depends on the compatible since the A64 and H3 have different numbers (and clock parents) for the APB2 clock. I would still like to go ahead with this version since I don't think that the switch without the compatible check is going to hurt for now. ok? Patrick diff --git a/sys/arch/armv7/sunxi/sxiccmu.c b/sys/arch/armv7/sunxi/sxiccmu.c index 7b67f749ff4..397349cd27a 100644 --- a/sys/arch/armv7/sunxi/sxiccmu.c +++ b/sys/arch/armv7/sunxi/sxiccmu.c @@ -25,8 +25,6 @@ #include #include -#include - #include #include #include @@ -94,12 +92,14 @@ sxiccmu_match(struct device *parent, void *match, void *aux) return (OF_is_compatible(node, "allwinner,sun4i-a10") || OF_is_compatible(node, "allwinner,sun5i-a10s") || OF_is_compatible(node, "allwinner,sun5i-r8") || + OF_is_compatible(node, "allwinner,sun50i-a64") || OF_is_compatible(node, "allwinner,sun7i-a20") || OF_is_compatible(node, "allwinner,sun8i-h3") || OF_is_compatible(node, "allwinner,sun9i-a80")); } - return OF_is_compatible(faa->fa_node, "allwinner,sun8i-h3-ccu"); + return (OF_is_compatible(faa->fa_node, "allwinner,sun50i-a64-ccu") || + OF_is_compatible(faa->fa_node, "allwinner,sun8i-h3-ccu")); } void @@ -116,7 +116,13 @@ sxiccmu_attach(struct device *parent, struct device *self, void *aux) printf("\n"); - if (OF_is_compatible(node, "allwinner,sun8i-h3-ccu")) { + if (OF_is_compatible(node, "allwinner,sun50i-a64-ccu")) { + KASSERT(faa->fa_nreg > 0); + sc->sc_gates = sun50i_a64_gates; + sc->sc_ngates = nitems(sun50i_a64_gates); + sc->sc_resets = sun50i_a64_resets; + sc->sc_nresets = nitems(sun50i_a64_resets); + } else if (OF_is_compatible(node, "allwinner,sun8i-h3-ccu")) { KASSERT(faa->fa_nreg > 0); sc->sc_gates = sun8i_h3_gates; sc->sc_ngates = nitems(sun8i_h3_gates); @@ -643,6 +649,7 @@ sxiccmu_ccu_get_frequency(void *cookie, uint32_t *cells) case H3_CLK_PLL_PERIPH0: /* XXX default value. */ return 6; + case A64_CLK_APB2: case H3_CLK_APB2: /* XXX Controlled by a MUX. */ return 2400; diff --git a/sys/arch/armv7/sunxi/sxiccmu_clocks.h b/sys/arch/armv7/sunxi/sxiccmu_clocks.h index 84791762035..256da5f1f03 100644 --- a/sys/arch/armv7/sunxi/sxiccmu_clocks.h +++ b/sys/arch/armv7/sunxi/sxiccmu_clocks.h @@ -5,6 +5,40 @@ * Clocks Signals */ +#define A64_CLK_APB2 26 + +#define A64_CLK_BUS_EHCI0 42 +#define A64_CLK_BUS_EHCI1 43 +#define A64_CLK_BUS_OHCI0 44 +#define A64_CLK_BUS_OHCI1 45 + +#define A64_CLK_BUS_UART0 67 +#define A64_CLK_BUS_UART1 68 +#define A64_CLK_BUS_UART2 69 +#define A64_CLK_BUS_UART3 70 +#define A64_CLK_BUS_UART4 71 + +#define A64_CLK_USB_OHCI0 91 +#define A64_CLK_USB_OHCI1 93 +#define A64_CLK_USB_PHY0 86 +#define A64_CLK_USB_PHY1 87 + +struct sxiccmu_ccu_bit sun50i_a64_gates[] = { + [A64_CLK_BUS_EHCI0] = { 0x0060, 24 }, + [A64_CLK_BUS_EHCI1] = { 0x0060, 25 }, + [A64_CLK_BUS_OHCI0] = { 0x0060, 28 }, + [A64_CLK_BUS_OHCI1] = { 0x0060, 29 }, + [A64_CLK_BUS_UART0] = { 0x006c, 16, A64_CLK_APB2 }, + [A64_CLK_BUS_UART1] = { 0x006c, 17, A64_CLK_APB2 }, + [A64_CLK_BUS_UART2] = { 0x006c, 18, A64_CLK_APB2 }, + [A64_CLK_BUS_UART3] = { 0x006c, 19, A64_CLK_APB2 }, + [A64_CLK_BUS_UART4] = { 0x006c, 20, A64_CLK_APB2 }, + [A64_CLK_USB_OHCI0] = { 0x00cc, 16 }, + [A64_CLK_USB_OHCI1] = { 0x00cc, 17 }, + [A64_CLK_USB_PHY0] = { 0x00cc, 8 }, + [A64_CLK_USB_PHY1] = { 0x00cc, 9 }, +}; + #define H3_CLK_PLL_PERIPH0 9 #define H3_CLK_APB218 @@ -68,6 +102,23 @@ struct sxiccmu_ccu_bit sun8i_h3_gates[] = { * Reset Signals */ +#define A64_RST_USB_PHY0 0 +#define A64_RST_USB_PHY1 1 + +#define A64_RST_BUS_EHCI0 19 +#define A64_RST_BUS_EHCI1 20 +#define A64_RST_BUS_OHCI0 21 +#define A64_RST_BUS_OHCI1 22 + +struct sxiccmu_ccu_bit sun50i_a64_resets[] = { + [A64_RST_USB_PHY0] = { 0x00cc, 0 }, + [A64_RST_USB_PHY1] = { 0x00cc, 1 }, + [A64_RST_BUS_EHCI0] = { 0x02c0, 24 }, + [A64_RST_BUS_EHCI1] = { 0x02c0, 25 }, + [A64_RST_BUS_OHCI0] = { 0x02c0, 28 }, + [A64_RST_BUS_OHCI1] = { 0x02c0, 29 }, +}; + #define H3_RST_USB_PHY00 #define H3_RST_USB_PHY11 #define H3_RST_USB_PHY22 diff --git a/sys/arch/armv7/sunxi/sxiehci.c b/sys/arch/armv7/sunxi/sxiehci.c index 1b266853bf7..4041318f6b9 100644 --- a/sys/arch/armv7/sunxi/sxiehci.c +++
hook up libcompiler_rt, libcxx(abi) to the build
Hi, now that the Makefiles in libcompiler_rt, libcxx and libcxxabi are guarded to not compile for !CLANG architectures, I am hopefuly that we can simply hook them up to the build. ok? Patrick diff --git a/lib/Makefile b/lib/Makefile index 7bca1e4bf2d..70cade57caa 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -1,7 +1,8 @@ # $OpenBSD: Makefile,v 1.72 2016/09/23 09:18:05 sthen Exp $ # $NetBSD: Makefile,v 1.20.4.1 1996/06/14 17:22:38 cgd Exp $ -SUBDIR=csu libarch libc libcrypto libcurses libedit libevent libexpat \ +SUBDIR=csu libarch libc libcompiler_rt libcrypto libcurses \ + libcxx libcxxabi libedit libevent libexpat \ libform libfuse libkeynote libkvm libl libm libmenu \ libossaudio libpanel libpcap libradius librthread \ librpcsvc libskey libsndio libssl libtls libusbhid \
Re: hook up libcompiler_rt, libcxx(abi) to the build
> Date: Sat, 21 Jan 2017 11:23:07 +1000 > From: Patrick Wildt> > Hi, > > now that the Makefiles in libcompiler_rt, libcxx and libcxxabi are > guarded to not compile for !CLANG architectures, I am hopefuly that > we can simply hook them up to the build. > > ok? ok kettenis@ > diff --git a/lib/Makefile b/lib/Makefile > index 7bca1e4bf2d..70cade57caa 100644 > --- a/lib/Makefile > +++ b/lib/Makefile > @@ -1,7 +1,8 @@ > #$OpenBSD: Makefile,v 1.72 2016/09/23 09:18:05 sthen Exp $ > #$NetBSD: Makefile,v 1.20.4.1 1996/06/14 17:22:38 cgd Exp $ > > -SUBDIR= csu libarch libc libcrypto libcurses libedit libevent libexpat \ > +SUBDIR= csu libarch libc libcompiler_rt libcrypto libcurses \ > + libcxx libcxxabi libedit libevent libexpat \ > libform libfuse libkeynote libkvm libl libm libmenu \ > libossaudio libpanel libpcap libradius librthread \ > librpcsvc libskey libsndio libssl libtls libusbhid \ > >
Re: rtsock refactoring
On Sat, Jan 21, 2017 at 01:28:02AM +0100, Claudio Jeker wrote: > On Fri, Jan 20, 2017 at 02:51:52AM +0100, Claudio Jeker wrote: > > I sent this diff out some time ago and would really like to get this in. > > This is one step on makeing rtsock.c less of a hornets nest. > > This reduces the side effects in route_output and simplifies some other > > bits as well. For example route_input is less variadic and simpler. > > > > Here is just the route_input change. Which should be easier to OK. > Changed a few things based on input from bluhm@ > Next piece of the puzzle. Cleanup the error handling a bit. If the route message is not valid (syntactically or also because it references bad things) fail without broadcasting this message to all listeners. So make sure that until the info struct has been checked we only use goto fail instead of goto flush. While there remove some redundant checks which are not needed. OK? -- :wq Claudio Index: net/rtsock.c === RCS file: /cvs/src/sys/net/rtsock.c,v retrieving revision 1.215 diff -u -p -r1.215 rtsock.c --- net/rtsock.c21 Jan 2017 03:44:46 - 1.215 +++ net/rtsock.c21 Jan 2017 06:23:02 - @@ -488,7 +488,6 @@ route_output(struct mbuf *m, ...) so = va_arg(ap, struct socket *); va_end(ap); - info.rti_info[RTAX_DST] = NULL; /* for error handling (goto flush) */ if (m == NULL || ((m->m_len < sizeof(int32_t)) && (m = m_pullup(m, sizeof(int32_t))) == 0)) return (ENOBUFS); @@ -555,10 +554,10 @@ route_output(struct mbuf *m, ...) if (!rtable_exists(tableid)) { if (rtm->rtm_type == RTM_ADD) { if ((error = rtable_add(tableid)) != 0) - goto flush; + goto fail; } else { error = EINVAL; - goto flush; + goto fail; } } @@ -598,7 +597,7 @@ route_output(struct mbuf *m, ...) info.rti_info[RTAX_GATEWAY]->sa_family >= AF_MAX) || info.rti_info[RTAX_GENMASK] != NULL) { error = EINVAL; - goto flush; + goto fail; } #ifdef MPLS info.rti_mpls = rtm->rtm_mpls; @@ -610,6 +609,11 @@ route_output(struct mbuf *m, ...) info.rti_flags |= RTF_LLINFO; } + /* +* Do not use goto flush before this point since the message itself +* may be not consistent and could cause unexpected behaviour in other +* userland clients. Use goto fail instead. +*/ switch (rtm->rtm_type) { case RTM_ADD: if (info.rti_info[RTAX_GATEWAY] == NULL) { @@ -647,11 +651,6 @@ route_output(struct mbuf *m, ...) } break; case RTM_DELETE: - if (!rtable_exists(tableid)) { - error = EAFNOSUPPORT; - goto flush; - } - rt = rtable_lookup(tableid, info.rti_info[RTAX_DST], info.rti_info[RTAX_NETMASK], info.rti_info[RTAX_GATEWAY], prio); @@ -690,10 +689,6 @@ route_output(struct mbuf *m, ...) goto report; break; case RTM_GET: - if (!rtable_exists(tableid)) { - error = EAFNOSUPPORT; - goto flush; - } rt = rtable_lookup(tableid, info.rti_info[RTAX_DST], info.rti_info[RTAX_NETMASK], info.rti_info[RTAX_GATEWAY], prio); @@ -764,11 +759,6 @@ report: break; case RTM_CHANGE: case RTM_LOCK: - if (!rtable_exists(tableid)) { - error = EAFNOSUPPORT; - goto flush; - } - rt = rtable_lookup(tableid, info.rti_info[RTAX_DST], info.rti_info[RTAX_NETMASK], info.rti_info[RTAX_GATEWAY], prio);
Re: iwm: fix a timeout race
Hi, On 18/01/2017, Stefan Sperlingwrote: > I managed to trigger the following uvm fault by continously switching an > iwm(4) client between two APs on different channels, i.e. a loop that runs: > ifconfig iwm0 chan X; sleep 10; ifconfig iwm chan Y; sleep 10; > > uvm_fault(0x819614a0, 0x7, 0, 2) -> e > kernel: page fault trap, code=0 > Stopped atsoftclock+0x32: movq %rdx,0x8(%rax) > > This diff seems to fix the problem. It cancels mira timeouts from > interrupt context where a state change is scheduled, instead of > cancelling mira timeouts from the process context which performs > the actual state change. If I understand right, the crash is due to calling timeout_set() via ieee80211_mira_node_init() while mira timeouts are active. Now, these timeouts are cancelled on transition from the RUN state (and cannot be cancelled unconditionally). However the guard to detect this transition is unreliable -- the root cause -- as it races against ic->ic_state. This would imply there is a more general problem with identifying state transitions within iwm_newstate_task? That said, I was unable to further simplify your patch, it addresses the immediate issue, and I've tested it on my iwm(4) without problem. ok procter@ best, Richard. iwm0: hw rev 0x210, fw ver 16.242414.0, address xx:xx:xx:xx:xx:xx > Also, cancel mira timeouts when the interface is brought down in > iwm_stop() because this code path does not go through iwm_newstate(). > > ok? > > Note that unless we are in RUN state the timeouts have not been initialized > so timeout_del() inside mira_cancel_timeouts() would panic if we called it. > This can't be done in a different way since mira state can only be > initialized once the node for our AP (ic->ic_bss) is available. > > Index: if_iwm.c > === > RCS file: /cvs/src/sys/dev/pci/if_iwm.c,v > retrieving revision 1.156 > diff -u -p -r1.156 if_iwm.c > --- if_iwm.c 12 Jan 2017 18:06:57 - 1.156 > +++ if_iwm.c 17 Jan 2017 18:59:20 - > @@ -5496,10 +5496,8 @@ iwm_newstate_task(void *psc) > if (ostate == IEEE80211_S_SCAN && nstate != ostate) > iwm_led_blink_stop(sc); > > - if (ostate == IEEE80211_S_RUN && nstate != ostate) { > + if (ostate == IEEE80211_S_RUN && nstate != ostate) > iwm_disable_beacon_filter(sc); > - ieee80211_mira_cancel_timeouts(>in_mn); > - } > > /* Reset the device if moving out of AUTH, ASSOC, or RUN. */ > /* XXX Is there a way to switch states without a full reset? */ > @@ -5632,8 +5630,11 @@ iwm_newstate(struct ieee80211com *ic, en > { > struct ifnet *ifp = IC2IFP(ic); > struct iwm_softc *sc = ifp->if_softc; > + struct iwm_node *in = (void *)ic->ic_bss; > > timeout_del(>sc_calib_to); > + if (ic->ic_state == IEEE80211_S_RUN) > + ieee80211_mira_cancel_timeouts(>in_mn); > > sc->ns_nstate = nstate; > sc->ns_arg = arg; > @@ -6116,6 +6117,8 @@ iwm_stop(struct ifnet *ifp, int disable) > ifq_clr_oactive(>if_snd); > > in->in_phyctxt = NULL; > + if (ic->ic_state == IEEE80211_S_RUN) > + ieee80211_mira_cancel_timeouts(>in_mn); > > task_del(systq, >init_task); > task_del(sc->sc_nswq, >newstate_task); > >
sunxi: clock for PIO
Hi, this diff adds the clock for the Allwinner A64 PIO. ok? Patrick diff --git a/sys/arch/armv7/sunxi/sxiccmu_clocks.h b/sys/arch/armv7/sunxi/sxiccmu_clocks.h index fdd0282623b..5a8f36f9993 100644 --- a/sys/arch/armv7/sunxi/sxiccmu_clocks.h +++ b/sys/arch/armv7/sunxi/sxiccmu_clocks.h @@ -19,6 +19,8 @@ #define A64_CLK_BUS_OHCI0 44 #define A64_CLK_BUS_OHCI1 45 +#define A64_CLK_BUS_PIO58 + #define A64_CLK_BUS_UART0 67 #define A64_CLK_BUS_UART1 68 #define A64_CLK_BUS_UART2 69 @@ -42,6 +44,7 @@ struct sxiccmu_ccu_bit sun50i_a64_gates[] = { [A64_CLK_BUS_EHCI1] = { 0x0060, 25 }, [A64_CLK_BUS_OHCI0] = { 0x0060, 28 }, [A64_CLK_BUS_OHCI1] = { 0x0060, 29 }, + [A64_CLK_BUS_PIO] = { 0x0068, 5 }, [A64_CLK_BUS_UART0] = { 0x006c, 16, A64_CLK_APB2 }, [A64_CLK_BUS_UART1] = { 0x006c, 17, A64_CLK_APB2 }, [A64_CLK_BUS_UART2] = { 0x006c, 18, A64_CLK_APB2 },
Re: NET_LOCK() ordering issue
On Thu, Jan 19, 2017 at 07:14:59PM +1000, Martin Pieuchot wrote: > Turns out that the NET_LOCK() related hang reported by many is a > deadlock. One way to prevent it is to ensure that fdplock() is > always taken before the NET_LOCK() when both have to been hold. > > This generates the diff below. > > Comments, ok? unp_externalize() does mostly file system operations, so it does not need the netlock. But there is one call to unp_discard(). Do we consider unix domain sockets part of the network stack? As all functions are running in syscall context with kernel lock, it does not really matter. There is nothing that has to be protected in unp_discard(). > if (pr->pr_domain->dom_externalize && > mtod(cm, struct cmsghdr *)->cmsg_type == > - SCM_RIGHTS) > -error = (*pr->pr_domain->dom_externalize)(cm, > -controllen, flags); > + SCM_RIGHTS) { > + NET_UNLOCK(s); > + error = (*pr->pr_domain->dom_externalize)( > + cm, controllen, flags); > + NET_LOCK(s); > + } The body of the if block is 4 spaces too much left. That was wrong before, but now the multiline condition and the multiline block should not be on the same level. This way it would still fit in 80 columns. error = (*pr->pr_domain->dom_externalize) (cm, controllen, flags); OK bluhm@
net: constant conversion
Hi, the new clang complains when variables might unintentionally switch from a positive to a negative number. This happens on the MULTICAST flag which sets the uppermost bit. ../../../../net/if.h:#defineIFF_MULTICAST 0x8000 /* supports multicast */ Thus if_flags = IFF_MULTICAST would switch from the positive 0x8000 to something negative. The same happens in the ipoption struct. What should we do? Disable the warning or simply switch the variables to being unsigned? Keep note that this diff is untested, even though I wouldn't expect anything bad to happen by that change... Patrick diff --git a/sys/net/if_var.h b/sys/net/if_var.h index 702fc5539c1..e254744dac8 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -126,7 +126,7 @@ struct ifnet { /* and the entries */ #define if_carpdev if_carp_ptr.carp_d unsigned int if_index; /* numeric abbreviation for this if */ short if_timer; /* time 'til if_watchdog called */ - short if_flags; /* up/down, broadcast, etc. */ + unsigned short if_flags;/* up/down, broadcast, etc. */ int if_xflags; /* extra softnet flags */ struct if_data if_data;/* stats and other data about if */ u_int32_t if_hardmtu; /* maximum MTU device supports */ diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h index 7d1663dc8b3..cabb364cdc4 100644 --- a/sys/netinet/ip_var.h +++ b/sys/netinet/ip_var.h @@ -91,7 +91,7 @@ structipstat { struct ipoption { struct in_addr ipopt_dst; /* first-hop dst if source routed */ - int8_t ipopt_list[MAX_IPOPTLEN]; /* options proper */ + u_int8_t ipopt_list[MAX_IPOPTLEN]; /* options proper */ }; #ifdef _KERNEL
Re: NET_LOCK() take 2, tests wanted!
On 20.1.2017. 3:04, Martin Pieuchot wrote: > Diff below enables the NET_LOCK(), again. > > What's new? > > - The lock ordering problem with fdplock() should now be fixed. It is >also documented, fdplock() should be taken first if both locks are >needed. > > - Page faults involving NFS, or any other code path already holding the >NET_LOCK(), have been fixed. The recursion is similar to the existing >vnode problem, so I simply added a hack there. > > - I added some NET_ASSERT_UNLOCKED() to help finding other possible >deadlocks. I sent this panic to mpi@ and sending here just for reference I have box with: carp pf pfsync isakmpd -K4 sasyncd dhcpd dhcpd sync tcpdump -lnqttti pflog0 pflow ipfix OpenBSD/amd64 (trlababalan) (tty00) login: panic: rw_enter: netlock locking against myself Stopped at Debugger+0x9: leave TIDPIDUID PRFLAGS PFLAGS CPU COMMAND *269805 88868 0 0x14000 0x2002 softnet Debugger() at Debugger+0x9 panic() at panic+0xfe rw_enter() at rw_enter+0x228 sosend() at sosend+0x114 copy_flow_ipfix_4_to_m() at copy_flow_ipfix_4_to_m+0xbd pflow_pack_flow_ipfix() at pflow_pack_flow_ipfix+0x185 export_pflow_if() at export_pflow_if+0x1de export_pflow() at export_pflow+0x63 pf_remove_state() at pf_remove_state+0x55 pfsync_in_del_c() at pfsync_in_del_c+0x49 pfsync_input() at pfsync_input+0x23d ipv4_input() at ipv4_input+0x51d ipintr() at ipintr+0x1e if_netisr() at if_netisr+0x175 end trace frame: 0x80002a157f10, count: 0 https://www.openbsd.org/ddb.html describes the minimum info required in bug reports. Insufficient info makes it difficult to find and fix bugs. ddb{2}> trace Debugger() at Debugger+0x9 panic() at panic+0xfe rw_enter() at rw_enter+0x228 sosend() at sosend+0x114 copy_flow_ipfix_4_to_m() at copy_flow_ipfix_4_to_m+0xbd pflow_pack_flow_ipfix() at pflow_pack_flow_ipfix+0x185 export_pflow_if() at export_pflow_if+0x1de export_pflow() at export_pflow+0x63 pf_remove_state() at pf_remove_state+0x55 pfsync_in_del_c() at pfsync_in_del_c+0x49 pfsync_input() at pfsync_input+0x23d ipv4_input() at ipv4_input+0x51d ipintr() at ipintr+0x1e if_netisr() at if_netisr+0x175 taskq_thread() at taskq_thread+0x6c end trace frame: 0x0, count: -15 ddb{2}> show panic rw_enter: netlock locking against myself ddb{2}> ps PID PPID PGRPUID S FLAGS WAIT COMMAND 253 71076253 0 30x100083 ttyin ksh 71076 35135 71076 1000 30x10008b pause ksh 35135 12657 12657 1000 30x90 selectsshd 12657 66645 12657 0 30x82 poll sshd 87891 89813 12290 0 30x100080 netio tcpdump 3270 1 3270 0 30x100083 ttyin getty 66576 1 66576 0 30x100083 ttyin getty 30959 1 30959 0 30x100083 ttyin getty 62307 1 62307 0 30x100083 ttyin getty 8961 1 8961 0 30x100083 ttyin getty 93977 1 93977 0 30x100083 ttyin getty 68538 12290 12290 0 30x100082 piperdlogger 89813 12290 12290 76 30x100092 bpf tcpdump 12290 90126 12290 0 30x10008a pause sh 90126 80805 80805 0 30x100090 piperdcron 80805 1 80805 0 30x100098 poll cron 45711 48097 16691623 30x90 nanosleep zabbix_agentd 58316 48097 16691623 30x90 selectzabbix_agentd 65495 48097 16691623 30x90 nanosleep zabbix_agentd 48097 1 16691623 30x90 wait zabbix_agentd 84343 48458 48458606 30x90 kqreadladvd 48458 1 48458 0 30x80 kqreadladvd 33980 26552 26552 95 30x100092 kqreadsmtpd 43918 26552 26552103 30x100092 kqreadsmtpd 18812 26552 26552 95 30x100092 kqreadsmtpd 30037 26552 26552 95 30x100092 kqreadsmtpd 25308 26552 26552 95 30x100092 kqreadsmtpd 30148 26552 26552 95 30x100092 kqreadsmtpd 26552 1 26552 0 30x100080 kqreadsmtpd 22016 1 22016 77 30x100090 poll dhcpd 96497 1 96497 0 30x80 kqreadsnmpd 52396 1 52396 91 30x92 kqreadsnmpd 62956 1 62956 91 30x92 kqreadsnmpd 66645 1 66645 0 30x80 selectsshd 45044 35532 34313 83 30x100092 poll ntpd 35532 34313 34313 83 30x100092 poll ntpd 34313 1 34313 0 30x100080 poll ntpd 24235 7637 7637 74 30x100090 bpf pflogd 7637 1 7637 0 30x80 netio pflogd 72492 82652 82652 73 30x100090 kqreadsyslogd 82652
Re: NET_LOCK() take 2, tests wanted!
On Fri, Jan 20, 2017 at 12:04:31PM +1000, Martin Pieuchot wrote: > - Page faults involving NFS, or any other code path already holding the >NET_LOCK(), have been fixed. The recursion is similar to the existing >vnode problem, so I simply added a hack there. It survives my nfs mmap sysctl test. > - I added some NET_ASSERT_UNLOCKED() to help finding other possible >deadlocks. On amd64 qemu with vio(4) I get such traces: starting network splassert: tsleep: want 0 have 1 Starting stack trace... tsleep() at tsleep+0x14e vio_wait_ctrl_done() at vio_wait_ctrl_done+0x40 vio_set_rx_filter() at vio_set_rx_filter+0x214 vio_iff() at vio_iff+0xfb vio_init() at vio_init+0x59 vio_ioctl() at vio_ioctl+0x144 ifioctl() at ifioctl+0x746 soo_ioctl() at soo_ioctl+0x223 sys_ioctl() at sys_ioctl+0x1b1 syscall() at syscall+0x27b --- syscall (number 54) --- splassert: tsleep: want 0 have 1 Starting stack trace... tsleep() at tsleep+0x14e vio_wait_ctrl_done() at vio_wait_ctrl_done+0x40 vio_set_rx_filter() at vio_set_rx_filter+0x214 vio_iff() at vio_iff+0xfb vio_ioctl() at vio_ioctl+0xd3 in6_addmulti() at in6_addmulti+0x131 in6_joingroup() at in6_joingroup+0x4b in6_update_ifa() at in6_update_ifa+0x2ae in6_ifattach_linklocal() at in6_ifattach_linklocal+0x115 in6_ifattach() at in6_ifattach+0xec ifioctl() at ifioctl+0x455 soo_ioctl() at soo_ioctl+0x223 sys_ioctl() at sys_ioctl+0x1b1 syscall() at syscall+0x27b --- syscall (number 54) --- splassert: tsleep: want 0 have 1 Starting stack trace... tsleep() at tsleep+0x14e vio_wait_ctrl_done() at vio_wait_ctrl_done+0x40 vio_set_rx_filter() at vio_set_rx_filter+0x214 vio_iff() at vio_iff+0xfb vio_ioctl() at vio_ioctl+0xd3 in_addmulti() at in_addmulti+0x135 in_ifinit() at in_ifinit+0x20c in_ioctl() at in_ioctl+0x4e8 ifioctl() at ifioctl+0x171 soo_ioctl() at soo_ioctl+0x223 sys_ioctl() at sys_ioctl+0x1b1 syscall() at syscall+0x27b --- syscall (number 54) --- On i386 hardware with em(4) this does not happen. > Please test it as before and report any problem back to me. I am currently running a full regress test with this diff. It hangs at /usr/src/regress/lib/libpthread/socket root@ot2:.../socket# make ===> 1 cc -O2 -pipe -I/usr/src/regress/lib/libpthread/socket/1/../../include -Wall -DSRCDIR='"/usr/src/regress/lib/libpthread/socket/1"' -I/usr/src/regress/lib/libpthread/socket/1/../include -c /usr/src/regress/lib/libpthread/socket/1/socket1.c cc -o socket1 socket1.o -lpthread ./socket1 UID PID PPID CPU PRI NI VSZ RSS WCHAN STAT TT TIME COMMAND 0 99969 69874 0 28 0 808 924 thrslee S p10:00.01 ./socket1 kill -9 99969 does not terminate the process. > --- sys/kern/kern_rwlock.c > +++ sys/kern/kern_rwlock.c > @@ -195,6 +195,9 @@ retry: > unsigned long set = o | op->wait_set; > int do_sleep; > > + if (panicstr) > + return (0); > + > rw_enter_diag(rwl, flags); > > if (flags & RW_NOSLEEP) I guess this is against the problem that ddb reboot does not work anymore. Could you also check for the variable "db_is_active" there? After kernel uvm faults or ddb console hotkey you still cannot reboot from ddb as they do not panic. > @@ -1184,6 +1193,10 @@ uvn_io(struct uvm_vnode *uvn, vm_page_t *pps, int > npages, int flags, int rw) > (flags & PGO_PDFREECLUST) ? IO_NOCACHE : 0, > curproc->p_ucred); > > + if (netlocked) > + rw_enter_write(); > + > + > if ((uvn->u_flags & UVM_VNODE_VNISLOCKED) == 0) > VOP_UNLOCK(vn, curproc); > } Here you added a new line too much. bluhm
unify log.c in daemons [rtadvd]
work on making log.c similar in all daemons: reduce the (mostly whitespace) differences so that log.c's can be diffed easily. need to set verbose in main() when option -d is used. ok? diff --git usr.sbin/rtadvd/log.c usr.sbin/rtadvd/log.c index 9b6c8980590..d3a5ba20727 100644 --- usr.sbin/rtadvd/log.c +++ usr.sbin/rtadvd/log.c @@ -1,3 +1,5 @@ +/* $OpenBSD: log.c,v 1.9 2016/09/02 14:02:48 benno Exp $ */ + /* * Copyright (c) 2003, 2004 Henning Brauer* @@ -14,9 +16,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include #include -#include #include #include #include @@ -27,10 +27,9 @@ #include "log.h" -intdebug; - -void logit(int, const char *, ...); -void vlog(int pri, const char *fmt, va_list ap); +int debug; +int verbose; +const char *log_procname; void log_init(int n_debug) @@ -46,6 +45,12 @@ log_init(int n_debug) } void +log_verbose(int v) +{ + verbose = v; +} + +void logit(int pri, const char *fmt, ...) { va_list ap; @@ -80,12 +85,12 @@ log_warn(const char *emsg, ...) char*nfmt; va_list ap; + /* best effort to even work in out of memory situations */ if (emsg == NULL) logit(LOG_CRIT, "%s", strerror(errno)); else { va_start(ap, emsg); - /* best effort to even work in out of memory situations */ if (asprintf(, "%s: %s", emsg, strerror(errno)) == -1) { /* we tried it... */ vlog(LOG_CRIT, emsg, ap); @@ -123,7 +128,7 @@ log_debug(const char *emsg, ...) { va_list ap; - if (debug) { + if (verbose) { va_start(ap, emsg); vlog(LOG_DEBUG, emsg, ap); va_end(ap); @@ -133,18 +138,16 @@ log_debug(const char *emsg, ...) void fatal(const char *emsg) { - extern char *__progname; - if (emsg == NULL) - logit(LOG_CRIT, "fatal in %s: %s", __progname, + logit(LOG_CRIT, "fatal in %s: %s", log_procname, strerror(errno)); else if (errno) logit(LOG_CRIT, "fatal in %s: %s: %s", - __progname, emsg, strerror(errno)); + log_procname, emsg, strerror(errno)); else logit(LOG_CRIT, "fatal in %s: %s", - __progname, emsg); + log_procname, emsg); exit(1); } diff --git usr.sbin/rtadvd/log.h usr.sbin/rtadvd/log.h index 0b005936327..56f7b9246ac 100644 --- usr.sbin/rtadvd/log.h +++ usr.sbin/rtadvd/log.h @@ -1,5 +1,7 @@ +/* $OpenBSD: log.h,v 1.8 2016/09/02 14:02:48 benno Exp $ */ + /* - * Copyright (c) 20083, 2004 Henning Brauer + * Copyright (c) 2003, 2004 Henning Brauer * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -14,15 +16,30 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef LOG_H +#define LOG_H + #include -void log_init(int); -void logit(int pri, const char *fmt, ...); +extern const char *log_procname; -__dead void fatal(const char*); -__dead void fatalx(const char*); +voidlog_init(int); +voidlog_verbose(int); +voidlogit(int, const char *, ...) + __attribute__((__format__ (printf, 2, 3))); +voidvlog(int, const char *, va_list) + __attribute__((__format__ (printf, 2, 0))); +voidlog_warn(const char *, ...) + __attribute__((__format__ (printf, 1, 2))); +voidlog_warnx(const char *, ...) + __attribute__((__format__ (printf, 1, 2))); +voidlog_info(const char *, ...) + __attribute__((__format__ (printf, 1, 2))); +voidlog_debug(const char *, ...) + __attribute__((__format__ (printf, 1, 2))); +voidfatal(const char *) __dead + __attribute__((__format__ (printf, 1, 0))); +voidfatalx(const char *) __dead + __attribute__((__format__ (printf, 1, 0))); -void log_warn(const char*, ...) __attribute__((format(printf, 1, 2))); -void log_warnx(const char*, ...) __attribute__((format(printf, 1, 2))); -void log_info(const char*, ...) __attribute__((format(printf, 1, 2))); -void log_debug(const char*, ...) __attribute__((format(printf, 1, 2))); +#endif /* LOG_H */ diff --git usr.sbin/rtadvd/rtadvd.c usr.sbin/rtadvd/rtadvd.c index 990d9785c2d..eec7a177242 100644 --- usr.sbin/rtadvd/rtadvd.c +++ usr.sbin/rtadvd/rtadvd.c @@ -163,6 +163,7 @@ main(int argc, char *argv[]) struct event ev_sigusr1; struct rainfo *rai; + log_procname = getprogname(); log_init(1);/* log to stderr until daemonized */ closefrom(3); @@ -192,7 +193,8
Re: iwm: fix a timeout race
Anyone? This could crash all your iwm(4) machines any time you run ifconfig... On Tue, Jan 17, 2017 at 08:22:27PM +0100, Stefan Sperling wrote: > I managed to trigger the following uvm fault by continously switching an > iwm(4) client between two APs on different channels, i.e. a loop that runs: > ifconfig iwm0 chan X; sleep 10; ifconfig iwm chan Y; sleep 10; > > uvm_fault(0x819614a0, 0x7, 0, 2) -> e > kernel: page fault trap, code=0 > Stopped atsoftclock+0x32: movq %rdx,0x8(%rax) > > This diff seems to fix the problem. It cancels mira timeouts from > interrupt context where a state change is scheduled, instead of > cancelling mira timeouts from the process context which performs > the actual state change. > > Also, cancel mira timeouts when the interface is brought down in > iwm_stop() because this code path does not go through iwm_newstate(). > > ok? > > Note that unless we are in RUN state the timeouts have not been initialized > so timeout_del() inside mira_cancel_timeouts() would panic if we called it. > This can't be done in a different way since mira state can only be > initialized once the node for our AP (ic->ic_bss) is available. > > Index: if_iwm.c > === > RCS file: /cvs/src/sys/dev/pci/if_iwm.c,v > retrieving revision 1.156 > diff -u -p -r1.156 if_iwm.c > --- if_iwm.c 12 Jan 2017 18:06:57 - 1.156 > +++ if_iwm.c 17 Jan 2017 18:59:20 - > @@ -5496,10 +5496,8 @@ iwm_newstate_task(void *psc) > if (ostate == IEEE80211_S_SCAN && nstate != ostate) > iwm_led_blink_stop(sc); > > - if (ostate == IEEE80211_S_RUN && nstate != ostate) { > + if (ostate == IEEE80211_S_RUN && nstate != ostate) > iwm_disable_beacon_filter(sc); > - ieee80211_mira_cancel_timeouts(>in_mn); > - } > > /* Reset the device if moving out of AUTH, ASSOC, or RUN. */ > /* XXX Is there a way to switch states without a full reset? */ > @@ -5632,8 +5630,11 @@ iwm_newstate(struct ieee80211com *ic, en > { > struct ifnet *ifp = IC2IFP(ic); > struct iwm_softc *sc = ifp->if_softc; > + struct iwm_node *in = (void *)ic->ic_bss; > > timeout_del(>sc_calib_to); > + if (ic->ic_state == IEEE80211_S_RUN) > + ieee80211_mira_cancel_timeouts(>in_mn); > > sc->ns_nstate = nstate; > sc->ns_arg = arg; > @@ -6116,6 +6117,8 @@ iwm_stop(struct ifnet *ifp, int disable) > ifq_clr_oactive(>if_snd); > > in->in_phyctxt = NULL; > + if (ic->ic_state == IEEE80211_S_RUN) > + ieee80211_mira_cancel_timeouts(>in_mn); > > task_del(systq, >init_task); > task_del(sc->sc_nswq, >newstate_task); >
Re: net: constant conversion
if_flags is in-kernel, so definately this should become unsigned. But what about if_msghdr.ifm_flags? That is exposed to userland, but I'd support moving it to unsigned because the route socket is a less standardized interface. struct ipoption is a little less clear. It is exposed to userland; one example that uses this is libc/rpc/svc_tcp.c. In that instance it is cast to u_char as expected. I wonder whether there is userland code which might be affected by this, however even if there was I would support the trend towards making this unsigned. > the new clang complains when variables might unintentionally switch from > a positive to a negative number. This happens on the MULTICAST flag > which sets the uppermost bit. > > ../../../../net/if.h:#defineIFF_MULTICAST 0x8000 /* supports > multicast */ > > Thus if_flags = IFF_MULTICAST would switch from the positive 0x8000 to > something negative. The same happens in the ipoption struct. > > What should we do? Disable the warning or simply switch the variables > to being unsigned? Keep note that this diff is untested, even though I > wouldn't expect anything bad to happen by that change... > > Patrick > > diff --git a/sys/net/if_var.h b/sys/net/if_var.h > index 702fc5539c1..e254744dac8 100644 > --- a/sys/net/if_var.h > +++ b/sys/net/if_var.h > @@ -126,7 +126,7 @@ struct ifnet {/* and the > entries */ > #define if_carpdev if_carp_ptr.carp_d > unsigned int if_index; /* numeric abbreviation for this if */ > short if_timer; /* time 'til if_watchdog called */ > - short if_flags; /* up/down, broadcast, etc. */ > + unsigned short if_flags;/* up/down, broadcast, etc. */ > int if_xflags; /* extra softnet flags */ > struct if_data if_data;/* stats and other data about if */ > u_int32_t if_hardmtu; /* maximum MTU device supports */ > diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h > index 7d1663dc8b3..cabb364cdc4 100644 > --- a/sys/netinet/ip_var.h > +++ b/sys/netinet/ip_var.h > @@ -91,7 +91,7 @@ struct ipstat { > > struct ipoption { > struct in_addr ipopt_dst; /* first-hop dst if source routed */ > - int8_t ipopt_list[MAX_IPOPTLEN]; /* options proper */ > + u_int8_t ipopt_list[MAX_IPOPTLEN]; /* options proper */ > }; > > #ifdef _KERNEL >