Re: I have a mirror testing program for you. - Mirror down
The real reason I wrote this is to have an automated way to set up the pkg_add mirrors especially for folks that don't care to set them up manually (Afterall, that's what computers are for!). Before I wrote this, I had a PKG_PATH mirror go down and I didn't know what was going on. At least this could get some failover that would work for everyone running the release or older at least. I put in a minor edit that kills ftp and sed if the buffer gets too full, as well as exiting. > > > >> > > I have a 500 line program I wrote that reads openbsd.org.ftp.html and >> >> Here's a simple alternative that will often be good enough. >> >> ftp -o- -V http://www.openbsd.org/cgi-bin/ftplist.cgi | >> sed -e 's, .*,/%m/,' -e 's,^,pkgpath = ,' -e q >> >> The C program is too trusting with its fixed-size buffers and unchecked >> mallocs etc, it's not something to run as root as-is. >> > > /* * Copyright (c) 2016 Luke N. Small * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* Special thanks to Dan Mclaughlin for the ftp to sed idea * * ftp -o - http://www.openbsd.org/ftp.html | \ * sed -n \ * -e 's: \([^<]*\)<.*:\1 :p' \ * -e 's:^\( [hfr].*\):\1:p' */ #define EVENT_NOPOLL #define EVENT_NOSELECT #include #include #include #include #include #include #include #include struct mirror_st { char * countryTitle; char * mirror; char * installPath; double diff; struct mirror_st * next; }; int ftp_cmp (const void * a, const void * b) { struct mirror_st **one = (struct mirror_st **)a; struct mirror_st **two = (struct mirror_st **)b; if( (*one)->diff < (*two)->diff ) return -1; if( (*one)->diff > (*two)->diff ) return 1; return 0; } int country_cmp (const void * a, const void * b) { struct mirror_st **one = (struct mirror_st **)a; struct mirror_st **two = (struct mirror_st **)b; // list the USA mirrors first, it will subsort correctly int8_t temp = !strncmp("USA", (*one)->countryTitle, 3); if(temp != !strncmp("USA", (*two)->countryTitle, 3)) { if(temp) return -1; return 1; } return strcmp( (*one)->countryTitle, (*two)->countryTitle ) ; } double getTimeDiff(struct timeval a, struct timeval b) { long sec; long usec; sec = b.tv_sec - a.tv_sec; usec = b.tv_usec - a.tv_usec; if (usec < 0) { --sec; usec += 100; } return sec + ((double)usec / 100.0); } int main() { pid_t ftpPid, sedPid; int ftpToSed[2]; int sedToParent[2]; int unameToParent[2]; char unameR[5], unameM[20]; int i = 0, c; register int position, num; FILE *input; pipe(unameToParent); // "uname -rm" returns version and architecture like: "5.8 amd64" to standard out if(fork() == (pid_t) 0) { /* uname child */ close(unameToParent[0]); dup2(unameToParent[1], STDOUT_FILENO); /*attaching to pipe(s)*/ execl("/usr/bin/uname","/usr/bin/uname", "-rm", NULL); err(1, "execl() failed\n"); } close(unameToParent[1]); input = fdopen (unameToParent[0], "r"); num = 0; position = -1; while ((c = getc(input)) != EOF) { if(num == 0) { if(position >= 5) err(1, "unameR[] got too long!\n"); if(c != ' ') unameR[++position] = c; else { unameR[position + 1] = '\0'; num = 1; position = -1; } } else { if(position >= 20) err(1, "unameM[] got too long!\n"); if(c != '\n') unameM[++position] = c; else unameM[position + 1] = '\0'; } } fclose (input); close(unameToParent[0]); pipe(ftpToSed); /*make pipes*/ struct kevent ke[2]; int kq = kqueue(); if (kq == -1) err(1, "kq!"); int kqProc = kqueue(); if (kqProc == -1) err(1, "kqProc!"); ftpPid = fork(); if(ftpPid == (pid_t) 0) { /*ftp child*/ close(ftpToSed[0]); dup2(ftpToSed[1], STDOUT_FILENO); /*attaching to pipe(s)*/ execl("/usr/bin/ftp","ftp", "-Vo", "-", "http://www.openbsd.org/ftp.html;, NULL); err(1, "execl() failed\n"); } EV_SET(ke, ftpPid, EVFILT_PROC, EV_ADD | EV_ONESHOT, NOTE_EXIT, 0, ); if (kevent(kqProc, ke, 1, NULL, 0, NULL) == -1) err(1, "kevent register fail."); close(ftpToSed[1]); pipe(sedToParent); sedPid = fork(); if(sedPid == (pid_t) 0) { /* sed child */ close(sedToParent[0]); dup2(ftpToSed[0], STDIN_FILENO); /*attaching to pipe(s)*/
Re: keep track of HT protection in 11n mode
On Wed, Jan 20, 2016 at 10:16:53PM +0100, Stefan Sperling wrote: > On Wed, Jan 20, 2016 at 10:04:11PM +0100, Stefan Sperling wrote: > > This diff makes us keep track of changes in the network's HT protection > > settings. These settings are advertised in beacons and change dynamically > > based on the nature of clients associated to an AP at a given moment. > > > > Tracking these changes is rather important. > > If a non-11n client associates to an AP which previously had 11n clients > > only, we must update our wireless device's configuration accordingly or > > the new client might damage frames we send out. > > This diff still has issues on iwn(4). Don't test there yet, please... This diff works fine for me with both iwm(4) and iwn(4). I couldn't figure out how to make proper use of iwn's RXON_ASSOC command. Linux uses this command to avoid having to restore a lot of state in firmware when changing RXON flags. In my case sending RXON_ASSOC always broke Tx. I'm now using an implementation which uses RXON but works. Index: dev/pci/if_iwm.c === RCS file: /cvs/src/sys/dev/pci/if_iwm.c,v retrieving revision 1.75 diff -u -p -r1.75 if_iwm.c --- dev/pci/if_iwm.c7 Jan 2016 23:08:38 - 1.75 +++ dev/pci/if_iwm.c21 Jan 2016 00:31:38 - @@ -294,6 +294,8 @@ int iwm_nvm_read_section(struct iwm_soft uint16_t *); void iwm_init_channel_map(struct iwm_softc *, const uint16_t * const); void iwm_setup_ht_rates(struct iwm_softc *); +void iwm_htprot_task(void *); +void iwm_update_htprot(struct ieee80211com *, struct ieee80211_node *); intiwm_ampdu_rx_start(struct ieee80211com *, struct ieee80211_node *, uint8_t); void iwm_ampdu_rx_stop(struct ieee80211com *, @@ -2602,6 +2604,34 @@ iwm_mvm_sta_rx_agg(struct iwm_softc *sc, } void +iwm_htprot_task(void *arg) +{ + struct iwm_softc *sc = arg; + struct ieee80211com *ic = >sc_ic; + struct iwm_node *in = (void *)ic->ic_bss; + int error; + + /* This call updates HT protection based on in->in_ni.ni_htop1. */ + error = iwm_mvm_mac_ctxt_changed(sc, in); + if (error != 0) + printf("%s: could not change HT protection: error %d\n", + DEVNAME(sc), error); +} + +/* + * This function is called by upper layer when HT protection settings in + * beacons have changed. + */ +void +iwm_update_htprot(struct ieee80211com *ic, struct ieee80211_node *ni) +{ + struct iwm_softc *sc = ic->ic_softc; + + /* assumes that ni == ic->ic_bss */ + task_add(systq, >htprot_task); +} + +void iwm_ba_task(void *arg) { struct iwm_softc *sc = arg; @@ -5878,6 +5908,7 @@ iwm_stop(struct ifnet *ifp, int disable) task_del(sc->sc_eswq, >sc_eswk); task_del(systq, >setrates_task); task_del(systq, >ba_task); + task_del(systq, >htprot_task); sc->sc_newstate(ic, IEEE80211_S_INIT, -1); @@ -6586,6 +6617,7 @@ iwm_preinit(struct iwm_softc *sc) /* Override 802.11 state transition machine. */ sc->sc_newstate = ic->ic_newstate; ic->ic_newstate = iwm_newstate; + ic->ic_update_htprot = iwm_update_htprot; ic->ic_ampdu_rx_start = iwm_ampdu_rx_start; ic->ic_ampdu_rx_stop = iwm_ampdu_rx_stop; #ifdef notyet @@ -6822,6 +6854,7 @@ iwm_attach(struct device *parent, struct task_set(>newstate_task, iwm_newstate_task, sc); task_set(>setrates_task, iwm_setrates_task, sc); task_set(>ba_task, iwm_ba_task, sc); + task_set(>htprot_task, iwm_htprot_task, sc); /* * We cannot read the MAC address without loading the Index: dev/pci/if_iwmvar.h === RCS file: /cvs/src/sys/dev/pci/if_iwmvar.h,v retrieving revision 1.15 diff -u -p -r1.15 if_iwmvar.h --- dev/pci/if_iwmvar.h 5 Jan 2016 18:41:15 - 1.15 +++ dev/pci/if_iwmvar.h 20 Jan 2016 17:37:06 - @@ -376,6 +376,9 @@ struct iwm_softc { int ba_tid; uint16_tba_ssn; + /* Task for HT protection updates. */ + struct task htprot_task; + bus_space_tag_t sc_st; bus_space_handle_t sc_sh; bus_size_t sc_sz; Index: dev/pci/if_iwn.c === RCS file: /cvs/src/sys/dev/pci/if_iwn.c,v retrieving revision 1.157 diff -u -p -r1.157 if_iwn.c --- dev/pci/if_iwn.c13 Jan 2016 14:39:35 - 1.157 +++ dev/pci/if_iwn.c21 Jan 2016 00:42:59 - @@ -226,6 +226,8 @@ int iwn_set_key(struct ieee80211com *, struct ieee80211_key *); void iwn_delete_key(struct ieee80211com *, struct ieee80211_node *, struct ieee80211_key *); +void iwn_update_htprot(struct ieee80211com *, + struct ieee80211_node *); int
Re: vmx: vmxnet3_load_mbuf will still do the wrong thing
Hi, On Tue, Jan 19, 2016 at 04:31:56PM +0100, Mike Belopuhov wrote: > Hi, > > We've just run into a vmx panic and code inspection revealed > that my previous diff contained a mistake, the pullup operation > is called on a wrong mbuf chain. > > I apologize for overlooking this issue. > > We're not 100% certain that this fixes our exact problem yet > since we can't reproduce it at will, but the diff appears > correct to us. Please test and report any problems. > > Thanks! > > diff --git sys/dev/pci/if_vmx.c sys/dev/pci/if_vmx.c > index 2a3367c..7710987 100644 > --- sys/dev/pci/if_vmx.c > +++ sys/dev/pci/if_vmx.c > @@ -1121,11 +1121,11 @@ vmxnet3_load_mbuf(struct vmxnet3_softc *sc, struct > vmxnet3_txring *ring, > return (-1); > > ip = (struct ip *)(n->m_data + offp); > hlen += ip->ip_hl << 2; > > - *mp = m_pullup(m, hlen + csum_off + 2); > + *mp = m_pullup(n, hlen + csum_off + 2); > if (*mp == NULL) > return (-1); > m = *mp; > } > > This doesn't look correct. As discussed with mikeb@ already, - n, as returned by m_pulldown(), can be a mbuf further down the chain. - *mp, as returned by m_pullup(), can be a new mbuf with n as a m_next pointer. - replacing the m pointer with *mp will a) leak the original m and b) seek to a new mbuf further down the chain, skipping the headers, and putting an mbuf with missing ethernet headers on the ring. The manpage doesn't explain the return values of m_pulldown() very well and it doesn't explain the return value of m_pullup() at all. We had to consult itojun's paper to verify what it does. Reyk
Re: audio: expose real device name
On Wed, Jan 20, 2016 at 11:50:43AM +0100, Mark Kettenis wrote: > > Date: Wed, 20 Jan 2016 09:13:53 +0100 > > From: Alexandre Ratchov> > > > This diff makes audioctl(1) display the device name (ex. > > "azalia0", "cmpci0", etc) in the "name" attribute. This way > > audioctl(1) output could be correlated with dmesg output. This > > seems more useful than strings like "HD-Audio" or "CMI8338A". > > > > OK? > > There is a small chance that something in ports uses these strings as > keys to store values. This change would introduce a flag day for such > applications, but in the long run using the driver instance name would > help. Except for hotplugging multiple uaudio(4) devices of course... > > Anyway, I think this is ok. > > But you should probably remove the ops->getdev() driver callback if > this sticks. Sure. I leave this for the next time we make changes in the driver API as they tend to be very time consuming (too many archs to test).
Re: keep track of HT protection in 11n mode
On Wed, Jan 20, 2016 at 10:04:11PM +0100, Stefan Sperling wrote: > This diff makes us keep track of changes in the network's HT protection > settings. These settings are advertised in beacons and change dynamically > based on the nature of clients associated to an AP at a given moment. > > Tracking these changes is rather important. > If a non-11n client associates to an AP which previously had 11n clients > only, we must update our wireless device's configuration accordingly or > the new client might damage frames we send out. This diff still has issues on iwn(4). Don't test there yet, please...
keep track of HT protection in 11n mode
This diff makes us keep track of changes in the network's HT protection settings. These settings are advertised in beacons and change dynamically based on the nature of clients associated to an AP at a given moment. Tracking these changes is rather important. If a non-11n client associates to an AP which previously had 11n clients only, we must update our wireless device's configuration accordingly or the new client might damage frames we send out. Index: dev/pci/if_iwm.c === RCS file: /cvs/src/sys/dev/pci/if_iwm.c,v retrieving revision 1.75 diff -u -p -r1.75 if_iwm.c --- dev/pci/if_iwm.c7 Jan 2016 23:08:38 - 1.75 +++ dev/pci/if_iwm.c20 Jan 2016 20:42:23 - @@ -294,6 +294,8 @@ int iwm_nvm_read_section(struct iwm_soft uint16_t *); void iwm_init_channel_map(struct iwm_softc *, const uint16_t * const); void iwm_setup_ht_rates(struct iwm_softc *); +void iwm_htprot_task(void *); +void iwm_update_htprot(struct ieee80211com *, const struct ieee80211_node *); intiwm_ampdu_rx_start(struct ieee80211com *, struct ieee80211_node *, uint8_t); void iwm_ampdu_rx_stop(struct ieee80211com *, @@ -2602,6 +2604,34 @@ iwm_mvm_sta_rx_agg(struct iwm_softc *sc, } void +iwm_htprot_task(void *arg) +{ + struct iwm_softc *sc = arg; + struct ieee80211com *ic = >sc_ic; + struct iwm_node *in = (void *)ic->ic_bss; + int error; + + /* This call updates HT protection based on in->in_ni.ni_htop1. */ + error = iwm_mvm_mac_ctxt_changed(sc, in); + if (error != 0) + printf("%s: could not change HT protection: error %d\n", + DEVNAME(sc), error); +} + +/* + * This function is called by upper layer when HT protection settings in + * beacons have changed. + */ +void +iwm_update_htprot(struct ieee80211com *ic, const struct ieee80211_node *ni) +{ + struct iwm_softc *sc = ic->ic_softc; + + /* assumes that ni == ic->ic_bss */ + task_add(systq, >htprot_task); +} + +void iwm_ba_task(void *arg) { struct iwm_softc *sc = arg; @@ -5878,6 +5908,7 @@ iwm_stop(struct ifnet *ifp, int disable) task_del(sc->sc_eswq, >sc_eswk); task_del(systq, >setrates_task); task_del(systq, >ba_task); + task_del(systq, >htprot_task); sc->sc_newstate(ic, IEEE80211_S_INIT, -1); @@ -6586,6 +6617,7 @@ iwm_preinit(struct iwm_softc *sc) /* Override 802.11 state transition machine. */ sc->sc_newstate = ic->ic_newstate; ic->ic_newstate = iwm_newstate; + ic->ic_update_htprot = iwm_update_htprot; ic->ic_ampdu_rx_start = iwm_ampdu_rx_start; ic->ic_ampdu_rx_stop = iwm_ampdu_rx_stop; #ifdef notyet @@ -6822,6 +6854,7 @@ iwm_attach(struct device *parent, struct task_set(>newstate_task, iwm_newstate_task, sc); task_set(>setrates_task, iwm_setrates_task, sc); task_set(>ba_task, iwm_ba_task, sc); + task_set(>htprot_task, iwm_htprot_task, sc); /* * We cannot read the MAC address without loading the Index: dev/pci/if_iwmvar.h === RCS file: /cvs/src/sys/dev/pci/if_iwmvar.h,v retrieving revision 1.15 diff -u -p -r1.15 if_iwmvar.h --- dev/pci/if_iwmvar.h 5 Jan 2016 18:41:15 - 1.15 +++ dev/pci/if_iwmvar.h 20 Jan 2016 17:37:06 - @@ -376,6 +376,9 @@ struct iwm_softc { int ba_tid; uint16_tba_ssn; + /* Task for HT protection updates. */ + struct task htprot_task; + bus_space_tag_t sc_st; bus_space_handle_t sc_sh; bus_size_t sc_sz; Index: dev/pci/if_iwn.c === RCS file: /cvs/src/sys/dev/pci/if_iwn.c,v retrieving revision 1.157 diff -u -p -r1.157 if_iwn.c --- dev/pci/if_iwn.c13 Jan 2016 14:39:35 - 1.157 +++ dev/pci/if_iwn.c20 Jan 2016 20:45:40 - @@ -226,6 +226,8 @@ int iwn_set_key(struct ieee80211com *, struct ieee80211_key *); void iwn_delete_key(struct ieee80211com *, struct ieee80211_node *, struct ieee80211_key *); +void iwn_update_htprot(struct ieee80211com *, + const struct ieee80211_node *); intiwn_ampdu_rx_start(struct ieee80211com *, struct ieee80211_node *, uint8_t); void iwn_ampdu_rx_stop(struct ieee80211com *, @@ -515,6 +517,7 @@ iwn_attach(struct device *parent, struct ic->ic_updateedca = iwn_updateedca; ic->ic_set_key = iwn_set_key; ic->ic_delete_key = iwn_delete_key; + ic->ic_update_htprot = iwn_update_htprot; ic->ic_ampdu_rx_start = iwn_ampdu_rx_start; ic->ic_ampdu_rx_stop = iwn_ampdu_rx_stop; #ifdef notyet @@ -5009,6 +5012,44 @@ iwn_delete_key(struct ieee80211com
udf uiomove() conversion
Below the conversion to uiomove() for isofs/udf/. Note that converting size to size_t is not possible in udf_read(), as udf_readatoffset() requires a pointer to an integer variable. Changing that would cause a lot of code churn, so i chose to truncate uio_resid to INT_MAX instead. udf_readatoffset() wouldn't transfer more than MAXBSIZE bytes anyway. Index: udf_vnops.c === RCS file: /cvs/src/sys/isofs/udf/udf_vnops.c,v retrieving revision 1.61 diff -u -p -u -r1.61 udf_vnops.c --- udf_vnops.c 23 Sep 2015 15:37:26 - 1.61 +++ udf_vnops.c 20 Jan 2016 08:54:21 - @@ -445,13 +445,12 @@ udf_read(void *v) while (uio->uio_offset < fsize && uio->uio_resid > 0) { offset = uio->uio_offset; - if (uio->uio_resid + offset <= fsize) - size = uio->uio_resid; - else + size = ulmin(uio->uio_resid, INT_MAX); + if (size > fsize - offset) size = fsize - offset; error = udf_readatoffset(up, , offset, , ); if (error == 0) - error = uiomovei(data, size, uio); + error = uiomove(data, (size_t)size, uio); if (bp != NULL) { brelse(bp); bp = NULL; @@ -543,7 +542,7 @@ struct udf_uiodir { static int udf_uiodir(struct udf_uiodir *uiodir, struct uio *uio, long off) { - int de_size = DIRENT_SIZE(uiodir->dirent); + size_t de_size = DIRENT_SIZE(uiodir->dirent); if (uio->uio_resid < de_size) { uiodir->eofflag = 0; @@ -552,7 +551,7 @@ udf_uiodir(struct udf_uiodir *uiodir, st uiodir->dirent->d_off = off; uiodir->dirent->d_reclen = de_size; - return (uiomovei(uiodir->dirent, de_size, uio)); + return (uiomove(uiodir->dirent, de_size, uio)); } static struct udf_dirstream * cheers, natano
audio: expose real device name
This diff makes audioctl(1) display the device name (ex. "azalia0", "cmpci0", etc) in the "name" attribute. This way audioctl(1) output could be correlated with dmesg output. This seems more useful than strings like "HD-Audio" or "CMI8338A". OK? Index: audio.c === RCS file: /cvs/src/sys/dev/audio.c,v retrieving revision 1.142 diff -u -p -u -p -r1.142 audio.c --- audio.c 20 Jan 2016 07:59:55 - 1.142 +++ audio.c 20 Jan 2016 08:04:29 - @@ -1584,7 +1584,11 @@ audio_ioctl(struct audio_softc *sc, unsi error = audio_getinfo(sc, (struct audio_info *)addr); break; case AUDIO_GETDEV: - error = sc->ops->getdev(sc->arg, (audio_device_t *)addr); + memset(addr, 0, sizeof(struct audio_device)); + if (sc->dev.dv_parent) + strlcpy(((struct audio_device *)addr)->name, + sc->dev.dv_parent->dv_xname, + MAX_AUDIO_DEV_LEN); break; case AUDIO_GETENC: error = sc->ops->query_encoding(sc->arg,
Re: I have a mirror testing program for you. - Mirror down
Important thing first, the mirror http://openbsd.cs.fau.de/pub/OpenBSD/ seems to be down. On Tue, 19 Jan 2016 22:19:42 -0600 Luke Smallwrote: > I have a 500 line program I wrote that reads openbsd.org.ftp.html and > scraps off the html and ftp mirrors, records them all without redundancies > as http mirrors in memory and downloads the appropriate version and machine > architecture's SHA256 in the package folder. It tests all the mirrors for > time, one at a time and uses kqueue to kill any laggy ftp calls. It uses > ftp() calls for all its networking, so it shouldn't be too much of a > security issue I'd guess. It writes the top 8 mirrors into /etc/pkg.conf it > erases all the installpath entries while leaving everything else in the > file. It can run as an unprivileged user, but of course it won't rewrite > /etc/pkg.conf > -Luke N Small My quick-n-dirty script[1] tells me as long as I use a mirror geographically close to me, I'll be fine. - time diff in same country between different mirrors <=10% - time diff same server tested multiple times <=10% - time diff local vs. halfway around the earth >100% to <300% [1] pkg_ping.sh #!/bin/sh #usage: ./pkg_ping.sh uk #to test all the uk servers. TMPFILE=/tmp/pkg_ping.tmp SHATMP=/tmp/pkg_ping.sha if [ ! -f ${TMPFILE} ] then ftp -o - http://www.openbsd.org/build/mirrors.dat |\ grep -e ^GZ -e ^UH |\ grep -B1 -e ^UH |\ grep -e ^GZ -e ^UH |\ cut -f 2- > ${TMPFILE} fi grep -A1 -e "^$1" ${TMPFILE} | grep http |\ while read line do echo trying ${line} time ftp -o ${SHATMP} ${line}/snapshots/packages/amd64/SHA256 done
Re: I have a mirror testing program for you. - Mirror down
On 2016/01/20 10:38, Benjamin Baier wrote: > Important thing first, the mirror http://openbsd.cs.fau.de/pub/OpenBSD/ > seems to be down. +cc maintainer, could you take a look please Simon? Down for v4+v6, traceroute stops at informatik.gate.uni-erlangen.de (131.188.20.38 / 2001:638:a000::3341:41) with !A on v6. > On Tue, 19 Jan 2016 22:19:42 -0600 > Luke Smallwrote: > > > I have a 500 line program I wrote that reads openbsd.org.ftp.html and Here's a simple alternative that will often be good enough. ftp -o- -V http://www.openbsd.org/cgi-bin/ftplist.cgi | sed -e 's, .*,/%m/,' -e 's,^,pkgpath = ,' -e q The C program is too trusting with its fixed-size buffers and unchecked mallocs etc, it's not something to run as root as-is.
Re: audio: expose real device name
> Date: Wed, 20 Jan 2016 09:13:53 +0100 > From: Alexandre Ratchov> > This diff makes audioctl(1) display the device name (ex. > "azalia0", "cmpci0", etc) in the "name" attribute. This way > audioctl(1) output could be correlated with dmesg output. This > seems more useful than strings like "HD-Audio" or "CMI8338A". > > OK? There is a small chance that something in ports uses these strings as keys to store values. This change would introduce a flag day for such applications, but in the long run using the driver instance name would help. Except for hotplugging multiple uaudio(4) devices of course... Anyway, I think this is ok. But you should probably remove the ops->getdev() driver callback if this sticks. > Index: audio.c > === > RCS file: /cvs/src/sys/dev/audio.c,v retrieving revision 1.142 diff > -u -p -u -p -r1.142 audio.c --- audio.c 20 Jan 2016 07:59:55 - > 1.142 +++ audio.c 20 Jan 2016 08:04:29 - @@ -1584,7 +1584,11 @@ > audio_ioctl(struct audio_softc *sc, unsi error = audio_getinfo(sc, > (struct audio_info *)addr); break; case AUDIO_GETDEV: - error = > sc->ops->getdev(sc->arg, (audio_device_t *)addr); + memset(addr, 0, > sizeof(struct audio_device)); + if (sc->dev.dv_parent) + > strlcpy(((struct audio_device *)addr)->name, + > sc->dev.dv_parent->dv_xname, + MAX_AUDIO_DEV_LEN); break; case > AUDIO_GETENC: error = sc->ops->query_encoding(sc->arg, > >
Re: in{,6}_hasmulti() for MP
On 15/01/16(Fri) 12:00, Martin Pieuchot wrote: > One of the checks missing to have an unlocked forwarding path is related > to multicast. We must ensure that the list of multicast groups attached > to an ifp is not modified when the CPU processing a packet is traversing > it. > > In order to prepare for such change the diff below introduces a new > function to abstract the list traversal. > > It is a simple refactoring but multiples reviews are more than welcome > at this stage of the release cycle. > > ok? I'm still looking for reviews. > Index: netinet/in.c > === > RCS file: /cvs/src/sys/netinet/in.c,v > retrieving revision 1.125 > diff -u -p -r1.125 in.c > --- netinet/in.c 3 Dec 2015 21:57:59 - 1.125 > +++ netinet/in.c 15 Jan 2016 10:33:36 - > @@ -880,6 +880,21 @@ in_delmulti(struct in_multi *inm) > } > } > > +/* > + * Return 1 if the multicast group represented by ``ap'' has been > + * joined by interface ``ifp'', 0 otherwise. > + */ > +int > +in_hasmulti(struct in_addr *ap, struct ifnet *ifp) > +{ > + struct in_multi *inm; > + int joined; > + > + IN_LOOKUP_MULTI(*ap, ifp, inm); > + joined = (inm != NULL); > + > + return (joined); > +} > > void > in_ifdetach(struct ifnet *ifp) > Index: netinet/in_var.h > === > RCS file: /cvs/src/sys/netinet/in_var.h,v > retrieving revision 1.37 > diff -u -p -r1.37 in_var.h > --- netinet/in_var.h 3 Dec 2015 21:57:59 - 1.37 > +++ netinet/in_var.h 15 Jan 2016 10:34:02 - > @@ -154,6 +154,7 @@ int in_ifinit(struct ifnet *, > struct in_ifaddr *, struct sockaddr_in *, int); > struct in_multi *in_addmulti(struct in_addr *, struct ifnet *); > void in_delmulti(struct in_multi *); > +int in_hasmulti(struct in_addr *, struct ifnet *); > void in_ifscrub(struct ifnet *, struct in_ifaddr *); > int in_control(struct socket *, u_long, caddr_t, struct ifnet *); > void in_prefixlen2mask(struct in_addr *, int); > Index: netinet/ip_carp.c > === > RCS file: /cvs/src/sys/netinet/ip_carp.c,v > retrieving revision 1.285 > diff -u -p -r1.285 ip_carp.c > --- netinet/ip_carp.c 12 Jan 2016 09:22:01 - 1.285 > +++ netinet/ip_carp.c 15 Jan 2016 10:47:19 - > @@ -1809,17 +1809,13 @@ carp_addr_updated(void *v) > > /* We received address changes from if_addrhooks callback */ > if (new_naddrs != sc->sc_naddrs || new_naddrs6 != sc->sc_naddrs6) { > - struct in_addr mc_addr; > - struct in_multi *inm; > > sc->sc_naddrs = new_naddrs; > sc->sc_naddrs6 = new_naddrs6; > > /* Re-establish multicast membership removed by in_control */ > if (IN_MULTICAST(sc->sc_peer.s_addr)) { > - mc_addr.s_addr = sc->sc_peer.s_addr; > - IN_LOOKUP_MULTI(mc_addr, >sc_if, inm); > - if (inm == NULL) { > + if (!in_hasmulti(>sc_peer, >sc_if)) { > struct in_multi **imm = > sc->sc_imo.imo_membership; > u_int16_t maxmem = > Index: netinet/ip_input.c > === > RCS file: /cvs/src/sys/netinet/ip_input.c,v > retrieving revision 1.265 > diff -u -p -r1.265 ip_input.c > --- netinet/ip_input.c3 Dec 2015 21:11:53 - 1.265 > +++ netinet/ip_input.c15 Jan 2016 10:34:30 - > @@ -346,8 +346,6 @@ ipv4_input(struct mbuf *m) > } > > if (IN_MULTICAST(ip->ip_dst.s_addr)) { > - struct in_multi *inm; > - > /* >* Make sure M_MCAST is set. It should theoretically >* already be there, but let's play safe because upper > @@ -402,8 +400,7 @@ ipv4_input(struct mbuf *m) >* See if we belong to the destination multicast group on the >* arrival interface. >*/ > - IN_LOOKUP_MULTI(ip->ip_dst, ifp, inm); > - if (inm == NULL) { > + if (!in_hasmulti(>ip_dst, ifp)) { > ipstat.ips_notmember++; > if (!IN_LOCAL_GROUP(ip->ip_dst.s_addr)) > ipstat.ips_cantforward++; > Index: netinet/ip_output.c > === > RCS file: /cvs/src/sys/netinet/ip_output.c,v > retrieving revision 1.316 > diff -u -p -r1.316 ip_output.c > --- netinet/ip_output.c 13 Jan 2016 09:38:36 - 1.316 > +++ netinet/ip_output.c 15 Jan 2016 10:43:47 - > @@ -241,7 +241,6 @@ reroute: > > if (IN_MULTICAST(ip->ip_dst.s_addr) || > (ip->ip_dst.s_addr == INADDR_BROADCAST)) { > - struct in_multi *inm; > >
Re: Quoting ${CC} expansion in libiberty Makefile
On 20/01/16(Wed) 06:28, Andreas Kusalananda Kähäri wrote: > Previously sent to misc@, but I was told to send it here instead. ok mpi@ > > Cheers, > Andreas > > - Forwarded message from Andreas Kusalananda Kähäri >- > > Date: Mon, 18 Jan 2016 16:33:34 +0100 > From: Andreas Kusalananda Kähäri > To: openbsd-misc > Subject: Quoting ${CC} expansion in libiberty Makefile > > Hi, > > I tried running the base system build with CC="ccache cc" and it broke > while compiling libiberty due to an unquoted expansion of ${CC} in the > Makefile ("${MAKE} ${GNUCFLAGS} CC=${CC} needed-list"). > > I know I won't save much time by using ccache since the compiler is > rebuilt during the process, but I assume that a similar problem would > arise if one tried to use CC="distcc cc", for example. Also, other > Makefiles in the tree quotes ${CC}, and this is *almost* the sole > instance where it's not quoted. Other instances are > lib/libcrypto/crypto/arch/{mips64,sparc64}/Makefile.inc > > Patch: > > Index: Makefile.bsd-wrapper > === > RCS file: /cvs/src/gnu/lib/libiberty/Makefile.bsd-wrapper,v > retrieving revision 1.15 > diff -u -p -u -r1.15 Makefile.bsd-wrapper > --- Makefile.bsd-wrapper 31 Aug 2014 01:02:48 - 1.15 > +++ Makefile.bsd-wrapper 18 Jan 2016 15:28:44 - > @@ -32,7 +32,7 @@ CLEANFILES+=Makefile config.cache confi > depend: needed-list > > needed-list: config.status > - ${MAKE} ${GNUCFLAGS} CC=${CC} needed-list > + ${MAKE} ${GNUCFLAGS} CC="${CC}" needed-list > > config.status: Makefile.in configure > PATH="/bin:/usr/bin:/sbin:/usr/sbin" \ > > > > -- > Andreas Kusalananda Kähäri, Bioinformatics Developer, Uppsala, Sweden > OpenPGP: url=https://db.tt/2zaB1E7y; id=46082BDF > > > > > - End forwarded message - > > -- > Andreas Kusalananda Kähäri, Bioinformatics Developer, Uppsala, Sweden > OpenPGP: url=https://db.tt/2zaB1E7y; id=46082BDF >
ntpd: really enable debug messages
Since the relatively recent logging unification, log_init needs a debug level > 1 in order for log_debug to print anything. This change makes it so 'ntpd -d' stays in the foreground but doesn't log much (the current behavior, different than previous releases though), 'ntpd -dd' actually prints more verbose debug messages. Index: ntpd.8 === RCS file: /cvs/src/usr.sbin/ntpd/ntpd.8,v retrieving revision 1.40 diff -u -p -u -p -r1.40 ntpd.8 --- ntpd.8 30 Oct 2015 16:41:53 - 1.40 +++ ntpd.8 20 Jan 2016 12:31:16 - @@ -50,6 +50,7 @@ If this option is specified, .Nm will run in the foreground and log to .Em stderr . +It may be specified again to enable more verbose debug logs. .It Fl f Ar file Use .Ar file Index: ntpd.c === RCS file: /cvs/src/usr.sbin/ntpd/ntpd.c,v retrieving revision 1.103 diff -u -p -u -p -r1.103 ntpd.c --- ntpd.c 11 Jan 2016 15:30:56 - 1.103 +++ ntpd.c 20 Jan 2016 12:31:16 - @@ -137,7 +137,7 @@ main(int argc, char *argv[]) while ((ch = getopt(argc, argv, "df:nsSv")) != -1) { switch (ch) { case 'd': - lconf.debug = 1; + lconf.debug++; log_verbose(1); break; case 'f':
Re: I have a mirror testing program for you.
< The C program is too trusting with its fixed-size buffers and unchecked < mallocs etc, it's not something to run as root as-is. I realize I got a little lazy with no checking the mallocs, but that is fixed. I wrote this to be resource-light and thorough. No half-ass bullshit. If somebody wants to not update their system for over a year, it will find the remaining mirrors, no matter where they are.I got rid of the fixed size buffers with the "totalLength" integer. I also made the mirrors that instantly give an error have a larger diff than the ones that merely took too long, just in case those are the only ones available. Maybe I could enable an argument to increase the timeout beyond 7 seconds. /* * Copyright (c) 2016 Luke N. Small * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* Special thanks to Dan Mclaughlin for the ftp to sed idea * * ftp -o - http://www.openbsd.org/ftp.html | \ * sed -n \ * -e 's: \([^<]*\)<.*:\1 :p' \ * -e 's:^\( [hfr].*\):\1:p' */ #define EVENT_NOPOLL #define EVENT_NOSELECT #include #include #include #include #include #include #include #include struct mirror_st { char * countryTitle; char * mirror; char * installPath; double diff; struct mirror_st * next; }; int ftp_cmp (const void * a, const void * b) { struct mirror_st **one = (struct mirror_st **)a; struct mirror_st **two = (struct mirror_st **)b; if( (*one)->diff < (*two)->diff ) return -1; if( (*one)->diff > (*two)->diff ) return 1; return 0; } int country_cmp (const void * a, const void * b) { struct mirror_st **one = (struct mirror_st **)a; struct mirror_st **two = (struct mirror_st **)b; // list the USA mirrors first, it will subsort correctly int8_t temp = !strncmp("USA", (*one)->countryTitle, 3); if(temp != !strncmp("USA", (*two)->countryTitle, 3)) { if(temp) return -1; return 1; } return strcmp( (*one)->countryTitle, (*two)->countryTitle ) ; } double getTimeDiff(struct timeval a, struct timeval b) { long sec; long usec; sec = b.tv_sec - a.tv_sec; usec = b.tv_usec - a.tv_usec; if (usec < 0) { --sec; usec += 100; } return sec + ((double)usec / 100.0); } int main() { pid_t ftpPid, sedPid; int ftpToSed[2]; int sedToParent[2]; int unameToParent[2]; char unameR[5], unameM[20]; int i = 0, c; register int position, num; FILE *input; pipe(unameToParent); // "uname -rm" returns version and architecture like: "5.8 amd64" to standard out if(fork() == (pid_t) 0) { /* uname child */ close(unameToParent[0]); dup2(unameToParent[1], STDOUT_FILENO); /*attaching to pipe(s)*/ execl("/usr/bin/uname","/usr/bin/uname", "-rm", NULL); err(1, "execl() failed\n"); } close(unameToParent[1]); input = fdopen (unameToParent[0], "r"); num = 0; position = -1; while ((c = getc(input)) != EOF) { if(num == 0) { if(c != ' ') unameR[++position] = c; else { unameR[position + 1] = '\0'; num = 1; position = -1; } } else { if(c != '\n') unameM[++position] = c; else unameM[position + 1] = '\0'; } } fclose (input); close(unameToParent[0]); pipe(ftpToSed); /*make pipes*/ struct kevent ke[2]; int kq = kqueue(); if (kq == -1) err(1, "kq!"); int kqProc = kqueue(); if (kqProc == -1) err(1, "kqProc!"); ftpPid = fork(); if(ftpPid == (pid_t) 0) { /*ftp child*/ close(ftpToSed[0]); dup2(ftpToSed[1], STDOUT_FILENO); /*attaching to pipe(s)*/ execl("/usr/bin/ftp","ftp", "-Vo", "-", "http://www.openbsd.org/ftp.html;, NULL); err(1, "execl() failed\n"); } EV_SET(ke, ftpPid, EVFILT_PROC, EV_ADD | EV_ONESHOT, NOTE_EXIT, 0, ); if (kevent(kqProc, ke, 1, NULL, 0, NULL) == -1) err(1, "kevent register fail."); close(ftpToSed[1]); pipe(sedToParent); sedPid = fork(); if(sedPid == (pid_t) 0) { /* sed child */ close(sedToParent[0]); dup2(ftpToSed[0], STDIN_FILENO); /*attaching to pipe(s)*/ dup2(sedToParent[1], STDOUT_FILENO); execl("/usr/bin/sed","sed","-n","-e", "s:\t\\([^<]*\\)<.*:\\1 :p", "-e", "s:^\\(\t[hfr].*\\):\\1:p", NULL); kill(ftpPid, SIGKILL); err(1, "execl() failed\n"); } EV_SET(ke, sedPid, EVFILT_PROC, EV_ADD | EV_ONESHOT, NOTE_EXIT, 0, ); if
Re: I have a mirror testing program for you. - Mirror down
OK, there, I put in error checks, so that the index used to write into the arrays can't get too big. -Luke On Wed, Jan 20, 2016 at 4:27 AM, Stuart Hendersonwrote: > On 2016/01/20 10:38, Benjamin Baier wrote: > > Important thing first, the mirror http://openbsd.cs.fau.de/pub/OpenBSD/ > > seems to be down. > > +cc maintainer, could you take a look please Simon? Down for v4+v6, > traceroute stops at informatik.gate.uni-erlangen.de (131.188.20.38 / > 2001:638:a000::3341:41) with !A on v6. > > > On Tue, 19 Jan 2016 22:19:42 -0600 > > Luke Small wrote: > > > > > I have a 500 line program I wrote that reads openbsd.org.ftp.html and > > Here's a simple alternative that will often be good enough. > > ftp -o- -V http://www.openbsd.org/cgi-bin/ftplist.cgi | > sed -e 's, .*,/%m/,' -e 's,^,pkgpath = ,' -e q > > The C program is too trusting with its fixed-size buffers and unchecked > mallocs etc, it's not something to run as root as-is. > /* * Copyright (c) 2016 Luke N. Small * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* Special thanks to Dan Mclaughlin for the ftp to sed idea * * ftp -o - http://www.openbsd.org/ftp.html | \ * sed -n \ * -e 's: \([^<]*\)<.*:\1 :p' \ * -e 's:^\( [hfr].*\):\1:p' */ #define EVENT_NOPOLL #define EVENT_NOSELECT #include #include #include #include #include #include #include #include struct mirror_st { char * countryTitle; char * mirror; char * installPath; double diff; struct mirror_st * next; }; int ftp_cmp (const void * a, const void * b) { struct mirror_st **one = (struct mirror_st **)a; struct mirror_st **two = (struct mirror_st **)b; if( (*one)->diff < (*two)->diff ) return -1; if( (*one)->diff > (*two)->diff ) return 1; return 0; } int country_cmp (const void * a, const void * b) { struct mirror_st **one = (struct mirror_st **)a; struct mirror_st **two = (struct mirror_st **)b; // list the USA mirrors first, it will subsort correctly int8_t temp = !strncmp("USA", (*one)->countryTitle, 3); if(temp != !strncmp("USA", (*two)->countryTitle, 3)) { if(temp) return -1; return 1; } return strcmp( (*one)->countryTitle, (*two)->countryTitle ) ; } double getTimeDiff(struct timeval a, struct timeval b) { long sec; long usec; sec = b.tv_sec - a.tv_sec; usec = b.tv_usec - a.tv_usec; if (usec < 0) { --sec; usec += 100; } return sec + ((double)usec / 100.0); } int main() { pid_t ftpPid, sedPid; int ftpToSed[2]; int sedToParent[2]; int unameToParent[2]; char unameR[5], unameM[20]; int i = 0, c; register int position, num; FILE *input; pipe(unameToParent); // "uname -rm" returns version and architecture like: "5.8 amd64" to standard out if(fork() == (pid_t) 0) { /* uname child */ close(unameToParent[0]); dup2(unameToParent[1], STDOUT_FILENO); /*attaching to pipe(s)*/ execl("/usr/bin/uname","/usr/bin/uname", "-rm", NULL); err(1, "execl() failed\n"); } close(unameToParent[1]); input = fdopen (unameToParent[0], "r"); num = 0; position = -1; while ((c = getc(input)) != EOF) { if(num == 0) { if(position >= 5) err(1, "unameR got too long!\n"); if(c != ' ') unameR[++position] = c; else { unameR[position + 1] = '\0'; num = 1; position = -1; } } else { if(position >= 20) err(1, "unameM got too long!\n"); if(c != '\n') unameM[++position] = c; else unameM[position + 1] = '\0'; } } fclose (input); close(unameToParent[0]); pipe(ftpToSed); /*make pipes*/ struct kevent ke[2]; int kq = kqueue(); if (kq == -1) err(1, "kq!"); int kqProc = kqueue(); if (kqProc == -1) err(1, "kqProc!"); ftpPid = fork(); if(ftpPid == (pid_t) 0) { /*ftp child*/ close(ftpToSed[0]); dup2(ftpToSed[1], STDOUT_FILENO); /*attaching to pipe(s)*/ execl("/usr/bin/ftp","ftp", "-Vo", "-", "http://www.openbsd.org/ftp.html;, NULL); err(1, "execl() failed\n"); } EV_SET(ke, ftpPid, EVFILT_PROC, EV_ADD | EV_ONESHOT, NOTE_EXIT, 0, ); if (kevent(kqProc, ke, 1, NULL, 0, NULL) == -1) err(1, "kevent register fail."); close(ftpToSed[1]); pipe(sedToParent); sedPid = fork(); if(sedPid == (pid_t) 0) { /* sed child
Re: ntpd: really enable debug messages
in relayd we use -v for that, so you need to run -d to get lots of output. check main() there? i think thats more intuitive, but maybe i'm just used to it. Brent Cook(bust...@gmail.com) on 2016.01.20 06:31:44 -0600: > Since the relatively recent logging unification, log_init needs a > debug level > 1 in order for log_debug to print anything. This change > makes it so 'ntpd -d' stays in the foreground but doesn't log much > (the current behavior, different than previous releases though), 'ntpd > -dd' actually prints more verbose debug messages. > > Index: ntpd.8 > === > RCS file: /cvs/src/usr.sbin/ntpd/ntpd.8,v > retrieving revision 1.40 > diff -u -p -u -p -r1.40 ntpd.8 > --- ntpd.8 30 Oct 2015 16:41:53 - 1.40 > +++ ntpd.8 20 Jan 2016 12:31:16 - > @@ -50,6 +50,7 @@ If this option is specified, > .Nm > will run in the foreground and log to > .Em stderr . > +It may be specified again to enable more verbose debug logs. > .It Fl f Ar file > Use > .Ar file > Index: ntpd.c > === > RCS file: /cvs/src/usr.sbin/ntpd/ntpd.c,v > retrieving revision 1.103 > diff -u -p -u -p -r1.103 ntpd.c > --- ntpd.c 11 Jan 2016 15:30:56 - 1.103 > +++ ntpd.c 20 Jan 2016 12:31:16 - > @@ -137,7 +137,7 @@ main(int argc, char *argv[]) > while ((ch = getopt(argc, argv, "df:nsSv")) != -1) { > switch (ch) { > case 'd': > - lconf.debug = 1; > + lconf.debug++; > log_verbose(1); > break; > case 'f': > --