Re: net80211: remove redundant assignment to ic_curmode
On Sun, Aug 25, 2019 at 03:11:52PM +0200, Stefan Sperling wrote: > > This assigment to ic_curmode is redundant because it already occurs > inside ieee80211_setmode(), and channel information in selbs and ni > is equivalent after node_copy(). > > ok? ok kevlo@
Re: FAQ: aarch64 stable packages
On Sun, Aug 25, 2019 at 09:09:58PM +0200, Alessandro Gallo wrote: > Hi, > > Looks like stable packages for aarch64 are now available (?): > > https://ftp.openbsd.org/pub/OpenBSD/6.5/packages-stable/aarch64 > > The following diff updates the relevant section of the FAQ: > > Index: faq10.html > === > RCS file: /cvs/www/faq/faq10.html,v > retrieving revision 1.288 > diff -u -p -u -p -r1.288 faq10.html > --- faq10.html14 Aug 2019 13:07:46 - 1.288 > +++ faq10.html25 Aug 2019 19:06:52 - > @@ -90,8 +90,8 @@ there are two options: > new packages will include any security fixes. > Simply call href="https://man.openbsd.org/pkg_add";>pkg_add(1) with > the -u flag to get the new files. > -Note that updated -stable packages are only available for the amd64 and > -i386 architectures. > +Note that updated -stable packages are only available for the amd64, > +i386, and aarch64 architectures. >Use the -stable ports tree > > Fetch (or update) your ports tree, > > Thanks > Indeed, we also provide aarch64 packages now :) Thx for spotting this lack, it's committed.
mg(1): dired: snprintf(), unlike strlcpy(), returns int, not size_t
--- a/src/dired.c +++ b/src/dired.c @@ -478,9 +478,9 @@ d_copy(int f, int n) topath = adjustname(toname, TRUE); if (topath && stat(topath, &statbuf) == 0) { if (S_ISDIR(statbuf.st_mode)) { - off = snprintf(toname, sizeof(toname), "%s/%s", + ret = snprintf(toname, sizeof(toname), "%s/%s", topath, sname); - if (off < 0 || off >= (int)sizeof(toname) - 1) { + if (ret < 0 || ret >= (int)sizeof(toname) - 1) { dobeep(); ewprintf("Directory name too long"); return (FALSE);
mg(1): Strings must be at least 2 chars for terminating NUL character
--- a/src/interpreter.c +++ b/src/interpreter.c @@ -269,7 +269,7 @@ static int foundlist(char *defstr) { struct varentry *vt, *v1 = NULL; - const char e[1] = "e", t[1] = "t"; + const char e[2] = "e", t[2] = "t"; char*p, *vnamep, *vendp = NULL, *valp, *o; int spc;
mg(1): Make sure we don't deref NULL ptr in skipwhite()
--- a/src/interpreter.c +++ b/src/interpreter.c @@ -139,7 +139,10 @@ multiarg(char *funstr) return (dobeep_msgs("Command takes no arguments: ", cmdp)); /* now find the first argument */ - p = fendp + 1; + if (fendp) + p = fendp + 1; + else + p = ""; p = skipwhite(p); if (strlcpy(argbuf, p, sizeof(argbuf)) >= sizeof(argbuf)) return (dobeep_msg("strlcpy error"));
mg(1): strchr() may return NULL
The new Scheme-like interpreter may do a NULL pointer deref. when strchr() fails. Check pointer before NUL terminating. --- a/src/interpreter.c +++ b/src/interpreter.c @@ -122,10 +122,12 @@ multiarg(char *funstr) *fendp = '\0'; return(excline(cmdp)); } + if ((fendp = strchr(cmdp, ' ')) == NULL) fendp = strchr(cmdp, '\t'); + if (fendp) + *fendp = '\0'; - *fendp = '\0'; /* * If no extant mg command found, just return. */
mg(1): Only deref vendp if not NULL
The new Scheme-like interpreter can end up with a NULL pointer dereference if the for-loop exits immediately. --- a/src/interpreter.c +++ b/src/interpreter.c @@ -335,7 +335,10 @@ foundlist(char *defstr) spc = 0; } } - *vendp = '\0'; + + if (vendp) + *vendp = '\0'; + if ((v1->vals = strndup(valp, BUFSIZE)) == NULL) return(dobeep_msg("strndup error"));
FAQ: aarch64 stable packages
Hi, Looks like stable packages for aarch64 are now available (?): https://ftp.openbsd.org/pub/OpenBSD/6.5/packages-stable/aarch64 The following diff updates the relevant section of the FAQ: Index: faq10.html === RCS file: /cvs/www/faq/faq10.html,v retrieving revision 1.288 diff -u -p -u -p -r1.288 faq10.html --- faq10.html 14 Aug 2019 13:07:46 - 1.288 +++ faq10.html 25 Aug 2019 19:06:52 - @@ -90,8 +90,8 @@ there are two options: new packages will include any security fixes. Simply call https://man.openbsd.org/pkg_add";>pkg_add(1) with the -u flag to get the new files. -Note that updated -stable packages are only available for the amd64 and -i386 architectures. +Note that updated -stable packages are only available for the amd64, +i386, and aarch64 architectures. Use the -stable ports tree Fetch (or update) your ports tree, Thanks
Re: net80211: keep nodes cached across scans
On Sun, Aug 25, 2019 at 03:18:46PM +0200, Stefan Sperling wrote: > This has been very stable for me on an iwm(4) client device. > > Has anyone tested this in other contexts? > Could somebody please test this in hostap mode? > > Thanks, > Stefan > i ran this on iwn and athn, both in client mode. saw no issues. jmc > On Sat, Aug 17, 2019 at 12:01:24AM +0200, Stefan Sperling wrote: > > When a scan begins we currently toss away everything we have > > learned about access points in the previous scan iteration. > > This behaviour gets in the way of some things. > > > > For instance, I am working on another diff to show reasons for association > > failures in ifconfig output ("wrong channel", "wrong WPA key", "wrong > > BSSID"). > > Because the scan loop keeps deleting existing nodes it gets in the way of > > such features. Whenever ifconfig wants to read information about an AP we > > have failed to associate to the AP's node has been freed already, and has > > perhaps been re-allocated upon reception of a new beacon. > > > > There are several ways in which nodes will still get freed with this diff: > > > > 1) This diff adds a new way of timing out inactive nodes which don't > > send a beacon within 10 scan iterations. This should get rid of stale > > APs if we're scanning for some time in a changing environment (should > > cover laptops walking around in buildings looking for APs to connect to). > > > > 2) If we fail to associate a few times, the corresponding node is removed. > > This mechanism already exists in -current code and is not changed here. > > See how ni_fails is handled in ieee80211_node_choose_bss(). > > > > 3) If net80211 transitions back to INIT state (e.g. because of a > > user-initiated configuration change) all nodes are removed. > > > > 4) When a background scan starts all nodes will be removed. > > This could be revisited later. I have left it as-is for now. > > Background scan only occurs in RUN state and would be unwise to mix > > such changes into this diff, which aims to fix SCAN state. > > > > > > This isn't a new idea. > > I can recall conversations about this with various people. > > > > My question is whether this diff breaks anything for anyone. > > > > > > diff refs/heads/master refs/heads/keepnodes > > blob - 461f33f2561841520e61dd3de64a857413d1b224 > > blob + 4634efcc61bcc44bea8a44abb4590cd6df303384 > > --- sys/dev/ic/bwfm.c > > +++ sys/dev/ic/bwfm.c > > @@ -2610,7 +2610,7 @@ bwfm_newstate(struct ieee80211com *ic, enum ieee80211_ > > return 0; > > } > > ieee80211_set_link_state(ic, LINK_STATE_DOWN); > > - ieee80211_free_allnodes(ic, 1); > > + ieee80211_node_cleanup(ic, ic->ic_bss); > > ic->ic_state = nstate; > > splx(s); > > return 0; > > blob - 0eb9dc07a0a75583f80579cc2d4c285dd1dc36b2 > > blob + 0caa61779fed20f6e96a337a7ec0278efaaa72b5 > > --- sys/dev/ic/pgt.c > > +++ sys/dev/ic/pgt.c > > @@ -170,7 +170,7 @@ void node_mark_active_ap(void *, struct > > ieee80211_nod > > voidnode_mark_active_adhoc(void *, struct ieee80211_node *); > > voidpgt_watchdog(struct ifnet *); > > int pgt_init(struct ifnet *); > > -voidpgt_update_hw_from_sw(struct pgt_softc *, int, int); > > +voidpgt_update_hw_from_sw(struct pgt_softc *, int); > > voidpgt_hostap_handle_mlme(struct pgt_softc *, uint32_t, > > struct pgt_obj_mlme *); > > voidpgt_update_sw_from_hw(struct pgt_softc *, > > @@ -544,8 +544,7 @@ trying_again: > > sc->sc_flags &= ~flag; > > if (ic->ic_if.if_flags & IFF_RUNNING) > > pgt_update_hw_from_sw(sc, > > - ic->ic_state != IEEE80211_S_INIT, > > - ic->ic_opmode != IEEE80211_M_MONITOR); > > + ic->ic_state != IEEE80211_S_INIT); > > } > > > > ic->ic_if.if_flags &= ~IFF_RUNNING; > > @@ -2015,7 +2014,7 @@ pgt_media_change(struct ifnet *ifp) > > > > error = ieee80211_media_change(ifp); > > if (error == ENETRESET) { > > -pgt_update_hw_from_sw(sc, 0, 0); > > +pgt_update_hw_from_sw(sc, 0); > > error = 0; > > } > > > > @@ -2367,7 +2366,7 @@ pgt_ioctl(struct ifnet *ifp, u_long cmd, caddr_t req) > > } > > > > if (error == ENETRESET) { > > - pgt_update_hw_from_sw(sc, 0, 0); > > + pgt_update_hw_from_sw(sc, 0); > > error = 0; > > } > > splx(s); > > @@ -2501,8 +2500,7 @@ pgt_init(struct ifnet *ifp) > > > > if (!(sc->sc_flags & (SC_DYING | SC_UNINITIALIZED))) > > pgt_update_hw_from_sw(sc, > > - ic->ic_state != IEEE80211_S_INIT, > > - ic->ic_opmode != IEEE80211_M_MONITOR); > > + ic->ic_state != IEEE80211_S_INIT); > > > > ifp->if_flags |= IFF_RUNNING; > > ifq_clr_oactive(&ifp->if_snd); > > @@ -2522,7 +2520,7 @
Re: roaming fix for iwm(4) and iwn(4)
On Sun, Aug 25, 2019 at 02:53:58PM +0200, Stefan Sperling wrote: > I've seen iwm(4) get stuck trying to associate to 2 GHz APs only and > never trying available 5 GHz ones. This happens because net80211 sets > a fixed mode during association attempts (11g in my case). If roaming > fails, the interface remains stuck in that mode (and the mode is never > upgraded to 11n if association fails, so we're now stuck on 2 GHz). > > This patch fixes the problem for me. Below are logs which show the > problematic case: all 5 Ghz APs keep getting rejected because their > channel is not considered part of the active channel set. > > With the fix the interface will roam between both bands as expected. > > OK? > The previous patch broke operation in a fixed user-specified phy mode. E.g. iwm(4) would associate to a 5 GHz AP after 'ifconfig iwm0 mode 11g'. Updated diff with that problem fixed: diff refs/heads/keepnodes refs/heads/roaming blob - 83b42976022d4ed42a9165720139abe5c1508324 blob + 6bca50ffd8bc6cbeba4db35a222e02f35e6b8143 --- sys/dev/pci/if_iwm.c +++ sys/dev/pci/if_iwm.c @@ -5694,6 +5694,13 @@ iwm_scan(struct iwm_softc *sc) return err; } + /* +* The current mode might have been fixed during association. +* Ensure all channels get scanned. +*/ + if (IFM_MODE(ic->ic_media.ifm_cur->ifm_media) == IFM_AUTO) + ieee80211_setmode(ic, IEEE80211_MODE_AUTO); + sc->sc_flags |= IWM_FLAG_SCANNING; if (ifp->if_flags & IFF_DEBUG) printf("%s: %s -> %s\n", ifp->if_xname, blob - ef5f81699e90f2d4c4202b25880c9120907e5ec3 blob + f2f51baa751bc57c3c5fe43eebb55dd68b5283ef --- sys/dev/pci/if_iwn.c +++ sys/dev/pci/if_iwn.c @@ -5199,6 +5199,13 @@ iwn_scan(struct iwn_softc *sc, uint16_t flags, int bgs DPRINTF(("sending scan command nchan=%d\n", hdr->nchan)); error = iwn_cmd(sc, IWN_CMD_SCAN, buf, buflen, 1); if (error == 0) { + /* +* The current mode might have been fixed during association. +* Ensure all channels get scanned. +*/ + if (IFM_MODE(ic->ic_media.ifm_cur->ifm_media) == IFM_AUTO) + ieee80211_setmode(ic, IEEE80211_MODE_AUTO); + sc->sc_flags |= IWN_FLAG_SCANNING; if (bgscan) sc->sc_flags |= IWN_FLAG_BGSCAN; blob - 9424dd2a492f1fb2398b9208d36906d2d2ab71ea blob + f4b8e9f8c0b4072a33514f7abc2ebcb1e0947fe0 --- sys/net80211/ieee80211.c +++ sys/net80211/ieee80211.c @@ -1035,11 +1035,20 @@ ieee80211_next_mode(struct ifnet *ifp) /* * Indicate a wrap-around if we're running in a fixed, user-specified -* phy mode or if the driver scans all bands in one scan iteration. +* phy mode. */ - if (IFM_MODE(ic->ic_media.ifm_cur->ifm_media) != IFM_AUTO || - (ic->ic_caps & IEEE80211_C_SCANALLBAND)) + if (IFM_MODE(ic->ic_media.ifm_cur->ifm_media) != IFM_AUTO) return (IEEE80211_MODE_AUTO); + + /* +* Always scan in AUTO mode if the driver scans all bands. +* The current mode might have changed during association +* so we must reset it here. +*/ + if (ic->ic_caps & IEEE80211_C_SCANALLBAND) { + ieee80211_setmode(ic, IEEE80211_MODE_AUTO); + return (ic->ic_curmode); + } /* * Get the next supported mode; effectively, this alternates between
Re: net80211: keep nodes cached across scans
This has been very stable for me on an iwm(4) client device. Has anyone tested this in other contexts? Could somebody please test this in hostap mode? Thanks, Stefan On Sat, Aug 17, 2019 at 12:01:24AM +0200, Stefan Sperling wrote: > When a scan begins we currently toss away everything we have > learned about access points in the previous scan iteration. > This behaviour gets in the way of some things. > > For instance, I am working on another diff to show reasons for association > failures in ifconfig output ("wrong channel", "wrong WPA key", "wrong BSSID"). > Because the scan loop keeps deleting existing nodes it gets in the way of > such features. Whenever ifconfig wants to read information about an AP we > have failed to associate to the AP's node has been freed already, and has > perhaps been re-allocated upon reception of a new beacon. > > There are several ways in which nodes will still get freed with this diff: > > 1) This diff adds a new way of timing out inactive nodes which don't > send a beacon within 10 scan iterations. This should get rid of stale > APs if we're scanning for some time in a changing environment (should > cover laptops walking around in buildings looking for APs to connect to). > > 2) If we fail to associate a few times, the corresponding node is removed. > This mechanism already exists in -current code and is not changed here. > See how ni_fails is handled in ieee80211_node_choose_bss(). > > 3) If net80211 transitions back to INIT state (e.g. because of a > user-initiated configuration change) all nodes are removed. > > 4) When a background scan starts all nodes will be removed. > This could be revisited later. I have left it as-is for now. > Background scan only occurs in RUN state and would be unwise to mix > such changes into this diff, which aims to fix SCAN state. > > > This isn't a new idea. > I can recall conversations about this with various people. > > My question is whether this diff breaks anything for anyone. > > > diff refs/heads/master refs/heads/keepnodes > blob - 461f33f2561841520e61dd3de64a857413d1b224 > blob + 4634efcc61bcc44bea8a44abb4590cd6df303384 > --- sys/dev/ic/bwfm.c > +++ sys/dev/ic/bwfm.c > @@ -2610,7 +2610,7 @@ bwfm_newstate(struct ieee80211com *ic, enum ieee80211_ > return 0; > } > ieee80211_set_link_state(ic, LINK_STATE_DOWN); > - ieee80211_free_allnodes(ic, 1); > + ieee80211_node_cleanup(ic, ic->ic_bss); > ic->ic_state = nstate; > splx(s); > return 0; > blob - 0eb9dc07a0a75583f80579cc2d4c285dd1dc36b2 > blob + 0caa61779fed20f6e96a337a7ec0278efaaa72b5 > --- sys/dev/ic/pgt.c > +++ sys/dev/ic/pgt.c > @@ -170,7 +170,7 @@ void node_mark_active_ap(void *, struct > ieee80211_nod > void node_mark_active_adhoc(void *, struct ieee80211_node *); > void pgt_watchdog(struct ifnet *); > int pgt_init(struct ifnet *); > -void pgt_update_hw_from_sw(struct pgt_softc *, int, int); > +void pgt_update_hw_from_sw(struct pgt_softc *, int); > void pgt_hostap_handle_mlme(struct pgt_softc *, uint32_t, >struct pgt_obj_mlme *); > void pgt_update_sw_from_hw(struct pgt_softc *, > @@ -544,8 +544,7 @@ trying_again: > sc->sc_flags &= ~flag; > if (ic->ic_if.if_flags & IFF_RUNNING) > pgt_update_hw_from_sw(sc, > - ic->ic_state != IEEE80211_S_INIT, > - ic->ic_opmode != IEEE80211_M_MONITOR); > + ic->ic_state != IEEE80211_S_INIT); > } > > ic->ic_if.if_flags &= ~IFF_RUNNING; > @@ -2015,7 +2014,7 @@ pgt_media_change(struct ifnet *ifp) > > error = ieee80211_media_change(ifp); > if (error == ENETRESET) { > -pgt_update_hw_from_sw(sc, 0, 0); > +pgt_update_hw_from_sw(sc, 0); > error = 0; > } > > @@ -2367,7 +2366,7 @@ pgt_ioctl(struct ifnet *ifp, u_long cmd, caddr_t req) > } > > if (error == ENETRESET) { > - pgt_update_hw_from_sw(sc, 0, 0); > + pgt_update_hw_from_sw(sc, 0); > error = 0; > } > splx(s); > @@ -2501,8 +2500,7 @@ pgt_init(struct ifnet *ifp) > > if (!(sc->sc_flags & (SC_DYING | SC_UNINITIALIZED))) > pgt_update_hw_from_sw(sc, > - ic->ic_state != IEEE80211_S_INIT, > - ic->ic_opmode != IEEE80211_M_MONITOR); > + ic->ic_state != IEEE80211_S_INIT); > > ifp->if_flags |= IFF_RUNNING; > ifq_clr_oactive(&ifp->if_snd); > @@ -2522,7 +2520,7 @@ pgt_init(struct ifnet *ifp) > * back to the BSS had before. > */ > void > -pgt_update_hw_from_sw(struct pgt_softc *sc, int keepassoc, int keepnodes) > +pgt_update_hw_from_sw(struct pgt_softc *sc, int keepassoc) > { > struct ieee80211com *ic = &sc->sc_ic; > struct arpcom *ac = &ic->ic_ac; > @@ -2769,8 +2767,6 @@ badopmode:
net80211: remove redundant assignment to ic_curmode
This assigment to ic_curmode is redundant because it already occurs inside ieee80211_setmode(), and channel information in selbs and ni is equivalent after node_copy(). ok? diff refs/heads/roaming refs/heads/assignment blob - 905396f216158f9497fc28be19737e61595adce3 blob + d41f910439aea2e7c45706e6fe384bd3ccc7269c --- sys/net80211/ieee80211_node.c +++ sys/net80211/ieee80211_node.c @@ -1165,16 +1165,14 @@ ieee80211_node_join_bss(struct ieee80211com *ic, struc mode = ieee80211_chan2mode(ic, selbs->ni_chan); if (mode != ic->ic_curmode) ieee80211_setmode(ic, mode); (*ic->ic_node_copy)(ic, ic->ic_bss, selbs); ni = ic->ic_bss; - ic->ic_curmode = ieee80211_chan2mode(ic, ni->ni_chan); - /* Make sure we send valid rates in an association request. */ if (ic->ic_opmode == IEEE80211_M_STA) ieee80211_fix_rate(ic, ni, IEEE80211_F_DOSORT | IEEE80211_F_DOFRATE | IEEE80211_F_DONEGO | IEEE80211_F_DODEL); if (ic->ic_flags & IEEE80211_F_RSNON)
Re: flex {c,m}alloc() checks
On Sun, Aug 25, 2019 at 08:32:04PM +0800, Michael Mikonos wrote: > Hello, > > I noticed that flex is too trusting and assumes > calloc/malloc will always succeed. Hopefully I > caught all of them. > I tried to follow the existing idiom of > calling flexerror() and passing strings via > the _() macro. OK? Does upstream have anything like this? You could consider using the xmalloc idiom (i.e. have separate functions that do the checks). -Otto > > - Michael > > > Index: dfa.c > === > RCS file: /cvs/src/usr.bin/lex/dfa.c,v > retrieving revision 1.8 > diff -u -p -U4 -r1.8 dfa.c > --- dfa.c 19 Nov 2015 23:20:34 - 1.8 > +++ dfa.c 25 Aug 2019 12:09:54 - > @@ -526,15 +526,19 @@ void ntod () > yynxt_tbl = > (struct yytbl_data *) calloc (1, > sizeof (struct > yytbl_data)); > + if (yynxt_tbl == NULL) > + flexerror(_("calloc failed")); > yytbl_data_init (yynxt_tbl, YYTD_ID_NXT); > yynxt_tbl->td_hilen = 1; > yynxt_tbl->td_lolen = num_full_table_rows; > yynxt_tbl->td_data = yynxt_data = > (flex_int32_t *) calloc (yynxt_tbl->td_lolen * > yynxt_tbl->td_hilen, > sizeof (flex_int32_t)); > + if (yynxt_tbl->td_data == NULL) > + flexerror(_("calloc failed")); > yynxt_curr = 0; > > buf_prints (&yydmap_buf, > "\t{YYTD_ID_NXT, (void**)&yy_nxt, sizeof(%s)},\n", > Index: gen.c > === > RCS file: /cvs/src/usr.bin/lex/gen.c,v > retrieving revision 1.15 > diff -u -p -U4 -r1.15 gen.c > --- gen.c 19 Nov 2015 23:28:03 - 1.15 > +++ gen.c 25 Aug 2019 12:09:55 - > @@ -111,13 +111,17 @@ mkeoltbl(void) > flex_int8_t *tdata = NULL; > struct yytbl_data *tbl; > > tbl = calloc(1, sizeof(struct yytbl_data)); > + if (tbl == NULL) > + flexerror(_("calloc failed")); > yytbl_data_init(tbl, YYTD_ID_RULE_CAN_MATCH_EOL); > tbl->td_flags = YYTD_DATA8; > tbl->td_lolen = num_rules + 1; > tbl->td_data = tdata = > calloc(tbl->td_lolen, sizeof(flex_int8_t)); > + if (tbl->td_data == NULL) > + flexerror(_("calloc failed")); > > for (i = 1; i <= num_rules; i++) > tdata[i] = rule_has_nl[i] ? 1 : 0; > > @@ -223,15 +227,19 @@ mkctbl(void) > ((tblend + numecs + 1) >= INT16_MAX > || long_align) ? "flex_int32_t" : "flex_int16_t"); > > tbl = calloc(1, sizeof(struct yytbl_data)); > + if (tbl == NULL) > + flexerror(_("calloc failed")); > yytbl_data_init(tbl, YYTD_ID_TRANSITION); > tbl->td_flags = YYTD_DATA32 | YYTD_STRUCT; > tbl->td_hilen = 0; > tbl->td_lolen = tblend + numecs + 1;/* number of structs */ > > tbl->td_data = tdata = > calloc(tbl->td_lolen * 2, sizeof(flex_int32_t)); > + if (tbl->td_data == NULL) > + flexerror(_("calloc failed")); > > /* >* We want the transition to be represented as the offset to the next >* state, not the actual state number, which is what it currently is. > @@ -318,15 +326,19 @@ mkssltbl(void) > flex_int32_t *tdata = NULL; > flex_int32_t i; > > tbl = calloc(1, sizeof(struct yytbl_data)); > + if (tbl == NULL) > + flexerror(_("calloc failed")); > yytbl_data_init(tbl, YYTD_ID_START_STATE_LIST); > tbl->td_flags = YYTD_DATA32 | YYTD_PTRANS; > tbl->td_hilen = 0; > tbl->td_lolen = lastsc * 2 + 1; > > tbl->td_data = tdata = > calloc(tbl->td_lolen, sizeof(flex_int32_t)); > + if (tbl->td_data == NULL) > + flexerror(_("calloc failed")); > > for (i = 0; i <= lastsc * 2; ++i) > tdata[i] = base[i]; > > @@ -452,15 +464,19 @@ mkecstbl(void) > struct yytbl_data *tbl = NULL; > flex_int32_t *tdata = NULL; > > tbl = calloc(1, sizeof(struct yytbl_data)); > + if (tbl == NULL) > + flexerror(_("calloc failed")); > yytbl_data_init(tbl, YYTD_ID_EC); > tbl->td_flags |= YYTD_DATA32; > tbl->td_hilen = 0; > tbl->td_lolen = csize; > > tbl->td_data = tdata = > calloc(tbl->td_lolen, sizeof(flex_int32_t)); > + if (tbl->td_data == NULL) > + flexerror(_("calloc failed")); > > for (i = 1; i < csize; ++i) { > ecgroup[i] = ABS(ecgroup[i]); > tdata[i] = ecgroup[i]; > @@ -659,16 +675,19 @@ mkftbl(void) > struct yytbl_data *tbl; > flex_int32_t *tdata = NULL; > > tbl = calloc
roaming fix for iwm(4) and iwn(4)
I've seen iwm(4) get stuck trying to associate to 2 GHz APs only and never trying available 5 GHz ones. This happens because net80211 sets a fixed mode during association attempts (11g in my case). If roaming fails, the interface remains stuck in that mode (and the mode is never upgraded to 11n if association fails, so we're now stuck on 2 GHz). This patch fixes the problem for me. Below are logs which show the problematic case: all 5 Ghz APs keep getting rejected because their channel is not considered part of the active channel set. With the fix the interface will roam between both bands as expected. OK? diff refs/heads/keepnodes refs/heads/roaming blob - 83b42976022d4ed42a9165720139abe5c1508324 blob + 52957c9c49828d6ab2524e33939b5050cc383c24 --- sys/dev/pci/if_iwm.c +++ sys/dev/pci/if_iwm.c @@ -5694,6 +5694,12 @@ iwm_scan(struct iwm_softc *sc) return err; } + /* +* The current mode might have been fixed during association. +* Ensure all channels get scanned. +*/ + ieee80211_setmode(ic, IEEE80211_MODE_AUTO); + sc->sc_flags |= IWM_FLAG_SCANNING; if (ifp->if_flags & IFF_DEBUG) printf("%s: %s -> %s\n", ifp->if_xname, blob - ef5f81699e90f2d4c4202b25880c9120907e5ec3 blob + 316cf49ffbe06e9d1df78e72b23dcb6c2e27abe4 --- sys/dev/pci/if_iwn.c +++ sys/dev/pci/if_iwn.c @@ -5199,6 +5199,11 @@ iwn_scan(struct iwn_softc *sc, uint16_t flags, int bgs DPRINTF(("sending scan command nchan=%d\n", hdr->nchan)); error = iwn_cmd(sc, IWN_CMD_SCAN, buf, buflen, 1); if (error == 0) { + /* +* The current mode might have been fixed during association. +* Ensure all channels get scanned. +*/ + ieee80211_setmode(ic, IEEE80211_MODE_AUTO); sc->sc_flags |= IWN_FLAG_SCANNING; if (bgscan) sc->sc_flags |= IWN_FLAG_BGSCAN; blob - 9424dd2a492f1fb2398b9208d36906d2d2ab71ea blob + f4b8e9f8c0b4072a33514f7abc2ebcb1e0947fe0 --- sys/net80211/ieee80211.c +++ sys/net80211/ieee80211.c @@ -1035,11 +1035,20 @@ ieee80211_next_mode(struct ifnet *ifp) /* * Indicate a wrap-around if we're running in a fixed, user-specified -* phy mode or if the driver scans all bands in one scan iteration. +* phy mode. */ - if (IFM_MODE(ic->ic_media.ifm_cur->ifm_media) != IFM_AUTO || - (ic->ic_caps & IEEE80211_C_SCANALLBAND)) + if (IFM_MODE(ic->ic_media.ifm_cur->ifm_media) != IFM_AUTO) return (IEEE80211_MODE_AUTO); + + /* +* Always scan in AUTO mode if the driver scans all bands. +* The current mode might have changed during association +* so we must reset it here. +*/ + if (ic->ic_caps & IEEE80211_C_SCANALLBAND) { + ieee80211_setmode(ic, IEEE80211_MODE_AUTO); + return (ic->ic_curmode); + } /* * Get the next supported mode; effectively, this alternates between Without fix (5 Ghz channels marked with '!'): Aug 25 12:04:33 jessup /bsd: iwm0: end background scan Aug 25 12:04:33 jessup /bsd: iwm0: - 18:e8:29:c1:e5:02 11 +20 54M ess privacy! no ""! Aug 25 12:04:33 jessup /bsd: iwm0: - 1a:e8:29:c1:e5:02 11 +20 54M ess privacy! no ""! Aug 25 12:04:33 jessup /bsd: iwm0: + 24:de:c6:1e:ca:025 +20 54M ess nono "Camp2019-insecure" Aug 25 12:04:33 jessup /bsd: iwm0: - 24:de:c6:1e:ca:10 132+9 54M ess privacy! no "Camp2019"! Aug 25 12:04:33 jessup /bsd: iwm0: - 24:de:c6:1e:ca:11 132+9 54M ess privacy! no "Camp2019-legacy"! Aug 25 12:04:33 jessup /bsd: iwm0: - 24:de:c6:1e:ca:12 132+8 54M ess privacy! no "Camp2019-things"! Aug 25 12:04:33 jessup /bsd: iwm0: + 24:de:c6:1e:ca:13 132+8 54M ess nono "Camp2019-insecure" Aug 25 12:04:33 jessup /bsd: iwm0: - 30:85:a9:6a:65:74 12 +15 54M ess privacy! no "NAONET"! Aug 25 12:04:33 jessup /bsd: iwm0: - 42:4a:30:1d:46:a91 +17 54M ! nono ""! Aug 25 12:04:33 jessup /bsd: iwm0: - 78:8a:20:71:72:cc6 +24 54M ess privacy! no ""! Aug 25 12:04:33 jessup /bsd: iwm0: - 7a:8a:20:71:72:cc6 +27 54M ess privacy! no ""! Aug 25 12:04:33 jessup /bsd: iwm0: - ac:a3:1e:dd:bd:32 36+7 54M ess privacy! no "Camp2019-things"! Aug 25 12:04:33 jessup /bsd: iwm0: + ac:a3:1e:dd:bd:33 36+8 54M ess nono "Camp2019-insecure" Aug 25 12:04:33 jessup /bsd: iwm0: - b4:5d:50:9f:23:e11 +34 54M ess privacy! no "Camp2019-things"! Aug 25 12:04:33 jessup /bsd: iwm0: + b4:5d:50:9f:23:e21 +34 54M ess nono "Camp2019-insecure" Aug 25 12:04:33 jessup /bsd: iwm0: - b4:5d:50:9f:23:f0 60 +27 54M ess privacy! no "Camp2019"! Aug 25 12:04:33 jessup /bsd: iwm0: - b4:5d:50:9f:23:f1 60 +26 54M ess privacy! no "Camp2019-legacy"! Aug 25 12:04:
flex {c,m}alloc() checks
Hello, I noticed that flex is too trusting and assumes calloc/malloc will always succeed. Hopefully I caught all of them. I tried to follow the existing idiom of calling flexerror() and passing strings via the _() macro. OK? - Michael Index: dfa.c === RCS file: /cvs/src/usr.bin/lex/dfa.c,v retrieving revision 1.8 diff -u -p -U4 -r1.8 dfa.c --- dfa.c 19 Nov 2015 23:20:34 - 1.8 +++ dfa.c 25 Aug 2019 12:09:54 - @@ -526,15 +526,19 @@ void ntod () yynxt_tbl = (struct yytbl_data *) calloc (1, sizeof (struct yytbl_data)); + if (yynxt_tbl == NULL) + flexerror(_("calloc failed")); yytbl_data_init (yynxt_tbl, YYTD_ID_NXT); yynxt_tbl->td_hilen = 1; yynxt_tbl->td_lolen = num_full_table_rows; yynxt_tbl->td_data = yynxt_data = (flex_int32_t *) calloc (yynxt_tbl->td_lolen * yynxt_tbl->td_hilen, sizeof (flex_int32_t)); + if (yynxt_tbl->td_data == NULL) + flexerror(_("calloc failed")); yynxt_curr = 0; buf_prints (&yydmap_buf, "\t{YYTD_ID_NXT, (void**)&yy_nxt, sizeof(%s)},\n", Index: gen.c === RCS file: /cvs/src/usr.bin/lex/gen.c,v retrieving revision 1.15 diff -u -p -U4 -r1.15 gen.c --- gen.c 19 Nov 2015 23:28:03 - 1.15 +++ gen.c 25 Aug 2019 12:09:55 - @@ -111,13 +111,17 @@ mkeoltbl(void) flex_int8_t *tdata = NULL; struct yytbl_data *tbl; tbl = calloc(1, sizeof(struct yytbl_data)); + if (tbl == NULL) + flexerror(_("calloc failed")); yytbl_data_init(tbl, YYTD_ID_RULE_CAN_MATCH_EOL); tbl->td_flags = YYTD_DATA8; tbl->td_lolen = num_rules + 1; tbl->td_data = tdata = calloc(tbl->td_lolen, sizeof(flex_int8_t)); + if (tbl->td_data == NULL) + flexerror(_("calloc failed")); for (i = 1; i <= num_rules; i++) tdata[i] = rule_has_nl[i] ? 1 : 0; @@ -223,15 +227,19 @@ mkctbl(void) ((tblend + numecs + 1) >= INT16_MAX || long_align) ? "flex_int32_t" : "flex_int16_t"); tbl = calloc(1, sizeof(struct yytbl_data)); + if (tbl == NULL) + flexerror(_("calloc failed")); yytbl_data_init(tbl, YYTD_ID_TRANSITION); tbl->td_flags = YYTD_DATA32 | YYTD_STRUCT; tbl->td_hilen = 0; tbl->td_lolen = tblend + numecs + 1;/* number of structs */ tbl->td_data = tdata = calloc(tbl->td_lolen * 2, sizeof(flex_int32_t)); + if (tbl->td_data == NULL) + flexerror(_("calloc failed")); /* * We want the transition to be represented as the offset to the next * state, not the actual state number, which is what it currently is. @@ -318,15 +326,19 @@ mkssltbl(void) flex_int32_t *tdata = NULL; flex_int32_t i; tbl = calloc(1, sizeof(struct yytbl_data)); + if (tbl == NULL) + flexerror(_("calloc failed")); yytbl_data_init(tbl, YYTD_ID_START_STATE_LIST); tbl->td_flags = YYTD_DATA32 | YYTD_PTRANS; tbl->td_hilen = 0; tbl->td_lolen = lastsc * 2 + 1; tbl->td_data = tdata = calloc(tbl->td_lolen, sizeof(flex_int32_t)); + if (tbl->td_data == NULL) + flexerror(_("calloc failed")); for (i = 0; i <= lastsc * 2; ++i) tdata[i] = base[i]; @@ -452,15 +464,19 @@ mkecstbl(void) struct yytbl_data *tbl = NULL; flex_int32_t *tdata = NULL; tbl = calloc(1, sizeof(struct yytbl_data)); + if (tbl == NULL) + flexerror(_("calloc failed")); yytbl_data_init(tbl, YYTD_ID_EC); tbl->td_flags |= YYTD_DATA32; tbl->td_hilen = 0; tbl->td_lolen = csize; tbl->td_data = tdata = calloc(tbl->td_lolen, sizeof(flex_int32_t)); + if (tbl->td_data == NULL) + flexerror(_("calloc failed")); for (i = 1; i < csize; ++i) { ecgroup[i] = ABS(ecgroup[i]); tdata[i] = ecgroup[i]; @@ -659,16 +675,19 @@ mkftbl(void) struct yytbl_data *tbl; flex_int32_t *tdata = NULL; tbl = calloc(1, sizeof(struct yytbl_data)); + if (tbl == NULL) + flexerror(_("calloc failed")); yytbl_data_init(tbl, YYTD_ID_ACCEPT); tbl->td_flags |= YYTD_DATA32; tbl->td_hilen = 0; /* it's a one-dimensional array */ tbl->td_lolen = lastdfa + 1; t
ansify flex
Hello, Upstream flex already updated function declarations to ANSI. The following patch applies this change to the in-tree version. Does it look OK? - Michael Index: ccl.c === RCS file: /cvs/src/usr.bin/lex/ccl.c,v retrieving revision 1.8 diff -u -p -u -r1.8 ccl.c --- ccl.c 19 Nov 2015 22:55:13 - 1.8 +++ ccl.c 25 Aug 2019 08:43:59 - @@ -55,9 +55,7 @@ ccl_contains(const int cclp, const int c /* ccladd - add a single character to a ccl */ void -ccladd(cclp, ch) - int cclp; - int ch; +ccladd(int cclp, int ch) { int ind, len, newpos, i; @@ -190,7 +188,7 @@ ccl_set_union(int a, int b) /* cclinit - return an empty ccl */ int -cclinit() +cclinit(void) { if (++lastccl >= current_maxccls) { current_maxccls += MAX_CCLS_INCREMENT; @@ -231,8 +229,7 @@ cclinit() /* cclnegate - negate the given ccl */ void -cclnegate(cclp) - int cclp; +cclnegate(int cclp) { cclng[cclp] = 1; ccl_has_nl[cclp] = !ccl_has_nl[cclp]; @@ -247,9 +244,7 @@ cclnegate(cclp) */ void -list_character_set(file, cset) - FILE *file; - int cset[]; +list_character_set(FILE *file, int cset[]) { int i; Index: dfa.c === RCS file: /cvs/src/usr.bin/lex/dfa.c,v retrieving revision 1.8 diff -u -p -u -r1.8 dfa.c --- dfa.c 19 Nov 2015 23:20:34 - 1.8 +++ dfa.c 25 Aug 2019 08:43:59 - @@ -51,9 +51,8 @@ int symfollowset PROTO ((int[], int, int * indexed by equivalence class. */ -void check_for_backing_up (ds, state) - int ds; - int state[]; +void +check_for_backing_up(int ds, int state[]) { if ((reject && !dfaacc[ds].dfaacc_set) || (!reject && !dfaacc[ds].dfaacc_state)) { /* state is non-accepting */ ++num_backing_up; @@ -98,10 +97,8 @@ void check_for_backing_up (ds, state) *accset[1 .. nacc] is the list of accepting numbers for the DFA state. */ -void check_trailing_context (nfa_states, num_states, accset, nacc) - int*nfa_states, num_states; - int*accset; - int nacc; +void +check_trailing_context(int *nfa_states, int num_states, int *accset, int nacc) { int i, j; @@ -139,9 +136,8 @@ void check_trailing_context (nfa_states, * and writes a report to the given file. */ -void dump_associated_rules (file, ds) - FILE *file; - int ds; +void +dump_associated_rules(FILE *file, int ds) { int i, j; int num_associated_rules = 0; @@ -189,9 +185,8 @@ void dump_associated_rules (file, ds) * is done to the given file. */ -void dump_transitions (file, state) - FILE *file; - int state[]; +void +dump_transitions(FILE *file, int state[]) { int i, ec; int out_char_set[CSIZE]; @@ -237,8 +232,8 @@ void dump_transitions (file, state) * hashval is the hash value for the dfa corresponding to the state set. */ -int*epsclosure (t, ns_addr, accset, nacc_addr, hv_addr) - int*t, *ns_addr, accset[], *nacc_addr, *hv_addr; +int * +epsclosure(int *t, int *ns_addr, int accset[], int *nacc_addr, int *hv_addr) { int stkpos, ns, tsp; int numstates = *ns_addr, nacc, hashval, transsym, nfaccnum; @@ -353,7 +348,8 @@ ADD_STATE(state); \ /* increase_max_dfas - increase the maximum number of DFAs */ -void increase_max_dfas () +void +increase_max_dfas(void) { current_max_dfas += MAX_DFAS_INCREMENT; @@ -380,7 +376,8 @@ void increase_max_dfas () * dfa starts out in state #1. */ -void ntod () +void +ntod(void) { int*accset, ds, nacc, newds; int sym, hashval, numstates, dsize; @@ -822,8 +819,9 @@ void ntod () * On return, the dfa state number is in newds. */ -int snstods (sns, numstates, accset, nacc, hashval, newds_addr) - int sns[], numstates, accset[], nacc, hashval, *newds_addr; +int +snstods(int sns[], int numstates, int accset[], int nacc, int hashval, + int *newds_addr) { int didsort = 0; int i, j; @@ -944,8 +942,8 @@ int snstods (sns, numstates, accset, nac * int transsym, int nset[current_max_dfa_size] ); */ -int symfollowset (ds, dsize, transsym, nset) - int ds[], dsize, transsym, nset[]; +int +symfollowset(int ds[], int dsize, int transsym, int nset[]) { int ns, tsp, sym, i, j, lenccl, ch, numstates, ccllist; @@ -1022,9 +1020,8 @@ int symfollowset (ds, dsize, transsym, n * int symlist[numecs], int duplist[numecs] ); */ -void sympartition (ds, numstates, symlist, duplist) - int ds[], numstates; - int symlist[], duplist[]; +void +sympartition(int ds[], int numstates, int symlist[], int duplist[]) { int tch, i, j, k, ns, dupfwd[CSIZE + 1], lenccl, cclp, ich; Index: gen.c === RCS