axppmic803, more sensors
Hi, I'm trying to improve Pinebook experience on OpenBSD. I added a few more sensors to axppmic 803. I have two boards I tested this patch on: - Pinebook: axppmic0 at sxirsb0 addr 0x3a3: AXP803 $ sysctl hw.sensors.axppmic0 hw.sensors.axppmic0.temp0=42.55 degC hw.sensors.axppmic0.volt0=3.85 VDC (battery voltage) hw.sensors.axppmic0.current0=0.00 A (battery charging current) hw.sensors.axppmic0.current1=0.98 A (battery discharging current) hw.sensors.axppmic0.amphour0=0.00 Ah (battery maximum capacity), WARNING hw.sensors.axppmic0.amphour1=0.00 Ah (battery current capacity), WARNING hw.sensors.axppmic0.indicator0=Off (ACIN) hw.sensors.axppmic0.indicator1=Off (VBUS) hw.sensors.axppmic0.indicator2=On (battery present), OK hw.sensors.axppmic0.indicator3=Off (battery charging) hw.sensors.axppmic0.percent0=74.00% (battery percent), OK - A64+: axppmic0 at sxirsb0 addr 0x3a3: AXP803 $ sysctl hw.sensors.axppmic0 hw.sensors.axppmic0.temp0=49.14 degC hw.sensors.axppmic0.volt0=0.00 VDC (battery voltage) hw.sensors.axppmic0.current0=0.00 A (battery charging current) hw.sensors.axppmic0.current1=0.00 A (battery discharging current) hw.sensors.axppmic0.amphour0=0.00 Ah (battery maximum capacity), WARNING hw.sensors.axppmic0.amphour1=0.00 Ah (battery current capacity), WARNING hw.sensors.axppmic0.indicator0=On (ACIN), OK hw.sensors.axppmic0.indicator1=Off (VBUS) hw.sensors.axppmic0.indicator2=Off (battery present) hw.sensors.axppmic0.indicator3=Off (battery charging) hw.sensors.axppmic0.percent0=100.00% (battery percent), WARNING Unfortunately, I wasn't able to test hw.sensors.axppmic0.amphours. WARNING is presented when specific bit for given field marks the value as invalid - this follow existing implementation. And hw.sensors.axppmic0.percent0 also sets WARN and CRIT when "warn" and "shut" thresholds are met. -- Krystian Index: sys/dev/fdt/axppmic.c === RCS file: /cvs/src/sys/dev/fdt/axppmic.c,v retrieving revision 1.6 diff -u -p -r1.6 axppmic.c --- sys/dev/fdt/axppmic.c 10 Feb 2018 22:32:01 - 1.6 +++ sys/dev/fdt/axppmic.c 8 Aug 2019 13:46:17 - @@ -36,6 +36,15 @@ extern void (*powerdownfn)(void); #define AXP209_ADC_EN1_ACIN (3 << 4) #define AXP209_ADC_EN1_VBUS (3 << 2) +#define AXP803_BAT_CAP_WARN0xe6 +#define AXP803_BAT_CAP_WARN_LV1 0xf0 +#define AXP803_BAT_CAP_WARN_LV1BASE 5 +#define AXP803_BAT_CAP_WARN_LV2 0x0f +#define AXP803_BAT_MAX_CAP 0xe0 +#define AXP803_BAT_CUR_CAP 0xe2 +#define AXP803_BAT_CAP_VALID (1 << 7) +#define AXP803_BAT_CAP 0xb9 + #define AXP806_REG_ADDR_EXT0xff #define AXP806_REG_ADDR_EXT_MASTER_MODE (0 << 4) #define AXP806_REG_ADDR_EXT_SLAVE_MODE(1 << 4) @@ -225,7 +234,7 @@ struct axppmic_regdata axp809_regdata[] /* Sensors for AXP209 and AXP221/AXP809. */ -#define AXPPMIC_NSENSORS 8 +#define AXPPMIC_NSENSORS 12 struct axppmic_sensdata { const char *name; @@ -256,6 +265,14 @@ struct axppmic_sensdata axp221_sensdata[ struct axppmic_sensdata axp803_sensdata[] = { { "ACIN", SENSOR_INDICATOR, 0x00, (1 << 7), (1 << 6) }, { "VBUS", SENSOR_INDICATOR, 0x00, (1 << 5), (1 << 4) }, + { "battery present", SENSOR_INDICATOR, 0x01, (1 << 5), (1 << 4) }, + { "battery charging", SENSOR_INDICATOR, 0x01, (1 << 6), (1 << 6) }, + { "battery percent", SENSOR_PERCENT, AXP803_BAT_CAP, ( 0x7f ), (1 << 7) }, + { "battery voltage", SENSOR_VOLTS_DC, 0x78, 0x00, 1100 }, + { "battery charging current", SENSOR_AMPS, 0x7a, 0x00, 1000 }, + { "battery discharging current", SENSOR_AMPS, 0x7c, 0x00, 1000 }, + { "battery maximum capacity", SENSOR_AMPHOUR, AXP803_BAT_MAX_CAP, 0x00, 1456 }, + { "battery current capacity", SENSOR_AMPHOUR, AXP803_BAT_CUR_CAP, 0x00, 1456 }, { "", SENSOR_TEMP, 0x56, 545, 106250 }, { NULL } }; @@ -302,6 +319,8 @@ struct axppmic_softc { struct ksensor sc_sensor[AXPPMIC_NSENSORS]; struct ksensordev sc_sensordev; + + uint8_t warn_thres, shut_thres; }; inline uint8_t @@ -487,6 +506,16 @@ axppmic_attach_common(struct axppmic_sof axppmic_write_reg(sc, AXP209_ADC_EN1, reg); } + /* Read battery warning level */ + if(strcmp(name, "x-powers,axp803") == 0) { + uint8_t value; + + value = axppmic_read_reg(sc, AXP803_BAT_CAP_WARN); + sc->warn_thres = ((value & AXP803_BAT_CAP_WARN_LV1) >> 4); + sc->warn_thres += AXP803_BAT_CAP_WARN_LV1BASE; + sc->shut_thres = (value & AXP803_BAT_CAP_WARN_LV2); + } + if (sc->sc_regdata) axppmic_attach_regulators(sc, node); @@ -629,6 +658,7 @@ axppmic_enable(void *cookie, int on) void axppmic_update_sensors(void *); void axppmic_update_indicator(struct axppmic_softc *, int); +void
Re: bgpd more O_CLOEXEC
On Thu, Aug 08, 2019 at 01:40:06PM +0200, Claudio Jeker wrote: > Just use O_CLOEXEC or SOCK_CLOEXEC on everything. There is no reason to > keep any kind of file descriptor over an exec call. At least this way > I'm sure that no fds will leak into the childs. > > OK? OK bluhm@ > Index: carp.c > === > RCS file: /cvs/src/usr.sbin/bgpd/carp.c,v > retrieving revision 1.9 > diff -u -p -r1.9 carp.c > --- carp.c24 Jan 2017 04:22:42 - 1.9 > +++ carp.c8 Aug 2019 11:33:37 - > @@ -108,7 +108,7 @@ carp_demote_get(char *group) > int s; > struct ifgroupreq ifgr; > > - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { > + if ((s = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0)) == -1) { > log_warn("carp_demote_get: socket"); > return (-1); > } > @@ -162,7 +162,7 @@ carp_demote_ioctl(char *group, int demot > int s, res; > struct ifgroupreq ifgr; > > - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { > + if ((s = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0)) == -1) { > log_warn("%s: socket", __func__); > return (-1); > } > Index: control.c > === > RCS file: /cvs/src/usr.sbin/bgpd/control.c,v > retrieving revision 1.97 > diff -u -p -r1.97 control.c > --- control.c 27 May 2019 09:14:32 - 1.97 > +++ control.c 8 Aug 2019 11:33:37 - > @@ -47,7 +47,7 @@ control_check(char *path) > sun.sun_family = AF_UNIX; > strlcpy(sun.sun_path, path, sizeof(sun.sun_path)); > > - if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { > + if ((fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0)) == -1) { > log_warn("%s: socket", __func__); > return (-1); > } > Index: kroute.c > === > RCS file: /cvs/src/usr.sbin/bgpd/kroute.c,v > retrieving revision 1.237 > diff -u -p -r1.237 kroute.c > --- kroute.c 23 Jul 2019 06:26:44 - 1.237 > +++ kroute.c 8 Aug 2019 11:33:37 - > @@ -2886,7 +2886,7 @@ get_mpe_config(const char *name, u_int * > *label = 0; > *rdomain = 0; > > - s = socket(AF_INET, SOCK_DGRAM, 0); > + s = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0); > if (s == -1) > return (-1); > > Index: mrt.c > === > RCS file: /cvs/src/usr.sbin/bgpd/mrt.c,v > retrieving revision 1.99 > diff -u -p -r1.99 mrt.c > --- mrt.c 24 Jul 2019 08:58:24 - 1.99 > +++ mrt.c 8 Aug 2019 11:33:38 - > @@ -908,7 +908,7 @@ mrt_open(struct mrt *mrt, time_t now) > } > > fd = open(MRT2MC(mrt)->file, > - O_WRONLY|O_NONBLOCK|O_CREAT|O_TRUNC, 0644); > + O_WRONLY|O_NONBLOCK|O_CREAT|O_TRUNC|O_CLOEXEC, 0644); > if (fd == -1) { > log_warn("mrt_open %s", MRT2MC(mrt)->file); > return (1); > Index: pftable.c > === > RCS file: /cvs/src/usr.sbin/bgpd/pftable.c,v > retrieving revision 1.13 > diff -u -p -r1.13 pftable.c > --- pftable.c 28 Jun 2019 13:32:47 - 1.13 > +++ pftable.c 8 Aug 2019 11:33:38 - > @@ -63,7 +63,7 @@ pftable_change(struct pf_table *pft) > if (pft->naddrs == 0 || pft->what == 0) > return (0); > > - if (devpf == -1 && ((devpf = open("/dev/pf", O_RDWR)) == -1)) > + if (devpf == -1 && ((devpf = open("/dev/pf", O_RDWR|O_CLOEXEC)) == -1)) > fatal("open(/dev/pf)"); > > bzero(, sizeof(tio)); > @@ -90,7 +90,7 @@ pftable_clear(const char *name) > { > struct pfioc_table tio; > > - if (devpf == -1 && ((devpf = open("/dev/pf", O_RDWR)) == -1)) > + if (devpf == -1 && ((devpf = open("/dev/pf", O_RDWR|O_CLOEXEC)) == -1)) > fatal("open(/dev/pf)"); > > bzero(, sizeof(tio)); > @@ -111,7 +111,7 @@ pftable_exists(const char *name) > struct pfioc_table tio; > struct pfr_astats dummy; > > - if (devpf == -1 && ((devpf = open("/dev/pf", O_RDWR)) == -1)) > + if (devpf == -1 && ((devpf = open("/dev/pf", O_RDWR|O_CLOEXEC)) == -1)) > fatal("open(/dev/pf)"); > > bzero(, sizeof(tio));
Re: openrsync --address option
On 2019/08/08 15:42, Claudio Jeker wrote: > I need to be able to control the bind address for openrsync connections. > This implements this but it only works for connections to an rsync daemon. > For rsync over ssh you need to use -e 'ssh -b address' instead. Works as expected for IPv4. For IPv6 it only works if you use a hostname that only has a v6 address and not also a v4 address. In this situation GPL rsync prints a warning (unless you also use -6), but then moves onto a v6 destination address. (Maybe openrsync works if you use an IPv6 literal address as the destination, but I didn't see a way to do that). OK for now, but as rpki-client may well end up used in places with fiddly addressing requirements (which is why you're adding it in the first place ;) it would be good to improve v6 as a later step. > -- > :wq Claudio > > Index: extern.h > === > RCS file: /cvs/src/usr.bin/rsync/extern.h,v > retrieving revision 1.31 > diff -u -p -r1.31 extern.h > --- extern.h 2 Jun 2019 17:36:48 - 1.31 > +++ extern.h 8 Aug 2019 13:41:02 - > @@ -120,6 +120,7 @@ structopts { > char*rsync_path;/* --rsync-path */ > char*ssh_prog; /* --rsh or -e */ > char*port; /* --port */ > + char*address; /* --address */ > }; > > /* > Index: main.c > === > RCS file: /cvs/src/usr.bin/rsync/main.c,v > retrieving revision 1.47 > diff -u -p -r1.47 main.c > --- main.c3 Jun 2019 15:37:48 - 1.47 > +++ main.c8 Aug 2019 13:41:02 - > @@ -307,6 +307,7 @@ main(int argc, char *argv[]) > { "no-times", no_argument,_times, 0 }, > { "verbose",no_argument,, 1 }, > { "no-verbose", no_argument,, 0 }, > + { "address",required_argument, NULL,4 }, > { NULL, 0, NULL, 0 }}; > > /* Global pledge. */ > @@ -380,6 +381,9 @@ main(int argc, char *argv[]) > case 3: > opts.port = optarg; > break; > + case 4: > + opts.address = optarg; > + break; > case 'h': > default: > goto usage; > @@ -505,9 +509,9 @@ main(int argc, char *argv[]) > exit(rc); > usage: > fprintf(stderr, "usage: %s" > - " [-aDglnoprtvx] [-e program] [--del] [--numeric-ids]\n" > - "\t[--port=portnumber] [--rsync-path=program] [--version]\n" > - "\tsource ... directory\n", > + " [-aDglnoprtvx] [-e program] [--address=bind_address] [--del]\n" > + "\t[--numeric-ids] [--port=portnumber] [--rsync-path=program]\n" > + "\t[--version] source ... directory\n", > getprogname()); > exit(1); > } > Index: rsync.1 > === > RCS file: /cvs/src/usr.bin/rsync/rsync.1,v > retrieving revision 1.18 > diff -u -p -r1.18 rsync.1 > --- rsync.1 6 May 2019 15:44:34 - 1.18 > +++ rsync.1 8 Aug 2019 13:41:02 - > @@ -24,6 +24,7 @@ > .Nm openrsync > .Op Fl aDglnoprtvx > .Op Fl e Ar program > +.Op Fl -address Ns = Ns Ar bind_address > .Op Fl -del > .Op Fl -numeric-ids > .Op Fl -port Ns = Ns Ar service > @@ -50,6 +51,12 @@ The arguments are as follows: > .It Fl a , -archive > Shorthand for > .Fl Dgloprt . > +.It Fl -address Ns = Ns Ar bind_address > +Use > +.Ar bind_address > +on the local machine as the source address of the connection. > +Only useful when connecting to an rsync daemon and on systems with more than > +one address. > .It Fl D > Also transfer device and special files. > Shorthand for > Index: socket.c > === > RCS file: /cvs/src/usr.bin/rsync/socket.c,v > retrieving revision 1.25 > diff -u -p -r1.25 socket.c > --- socket.c 3 Jun 2019 15:37:48 - 1.25 > +++ socket.c 8 Aug 2019 13:41:02 - > @@ -46,11 +46,34 @@ structsource { > }; > > /* > + * Try to bind to a local IP address matching the addres family passed. > + * Return -1 on failure to bind to any address, 0 on success. > + */ > +static int > +inet_bind(int s, sa_family_t af, const struct source *bsrc, size_t bsrcsz) > +{ > + size_t i; > + > + if (bsrc == NULL) > + return 0; > + for (i = 0; i < bsrcsz; i++) { > + if (bsrc[i].family != af) > + continue; > + if (bind(s, (const struct sockaddr *)[i].sa, > + bsrc[i].salen) == -1) > + continue; > + return 0; > + } > + return -1; > +} > + > +/* > * Connect to an IP address representing a host. > * Return <0 on
Re: openrsync --address option
On Thu, Aug 08, 2019 at 11:06:30PM +0100, Stuart Henderson wrote: > On 2019/08/08 15:42, Claudio Jeker wrote: > > I need to be able to control the bind address for openrsync connections. > > This implements this but it only works for connections to an rsync daemon. > > For rsync over ssh you need to use -e 'ssh -b address' instead. > > Works as expected for IPv4. For IPv6 it only works if you use a hostname that > only has a v6 address and not also a v4 address. In this situation GPL rsync > prints a warning (unless you also use -6), but then moves onto a v6 > destination > address. > > (Maybe openrsync works if you use an IPv6 literal address as the destination, > but I didn't see a way to do that). > > OK for now, but as rpki-client may well end up used in places with fiddly > addressing requirements (which is why you're adding it in the first place ;) > it would be good to improve v6 as a later step. > I think this has also to do with the way the host (aka destination) lookup happens. My assumption is that you first try to connect to a IPv4 address and so there is no binding to the IPv6 address happening. To be honest, the GPL rsync way of doing things is also not entierly clear to me. It may be necessary to add -4 and -6 support or maybe force the address family to match bind_address and destination (or error out if they mismatch) would be enough. I will commit this tomorrow morning so that improvements can happen in tree. -- :wq Claudio > > Index: extern.h > > === > > RCS file: /cvs/src/usr.bin/rsync/extern.h,v > > retrieving revision 1.31 > > diff -u -p -r1.31 extern.h > > --- extern.h2 Jun 2019 17:36:48 - 1.31 > > +++ extern.h8 Aug 2019 13:41:02 - > > @@ -120,6 +120,7 @@ struct opts { > > char*rsync_path;/* --rsync-path */ > > char*ssh_prog; /* --rsh or -e */ > > char*port; /* --port */ > > + char*address; /* --address */ > > }; > > > > /* > > Index: main.c > > === > > RCS file: /cvs/src/usr.bin/rsync/main.c,v > > retrieving revision 1.47 > > diff -u -p -r1.47 main.c > > --- main.c 3 Jun 2019 15:37:48 - 1.47 > > +++ main.c 8 Aug 2019 13:41:02 - > > @@ -307,6 +307,7 @@ main(int argc, char *argv[]) > > { "no-times", no_argument,_times, 0 }, > > { "verbose",no_argument,, 1 }, > > { "no-verbose", no_argument,, 0 }, > > + { "address",required_argument, NULL,4 }, > > { NULL, 0, NULL, 0 }}; > > > > /* Global pledge. */ > > @@ -380,6 +381,9 @@ main(int argc, char *argv[]) > > case 3: > > opts.port = optarg; > > break; > > + case 4: > > + opts.address = optarg; > > + break; > > case 'h': > > default: > > goto usage; > > @@ -505,9 +509,9 @@ main(int argc, char *argv[]) > > exit(rc); > > usage: > > fprintf(stderr, "usage: %s" > > - " [-aDglnoprtvx] [-e program] [--del] [--numeric-ids]\n" > > - "\t[--port=portnumber] [--rsync-path=program] [--version]\n" > > - "\tsource ... directory\n", > > + " [-aDglnoprtvx] [-e program] [--address=bind_address] [--del]\n" > > + "\t[--numeric-ids] [--port=portnumber] [--rsync-path=program]\n" > > + "\t[--version] source ... directory\n", > > getprogname()); > > exit(1); > > } > > Index: rsync.1 > > === > > RCS file: /cvs/src/usr.bin/rsync/rsync.1,v > > retrieving revision 1.18 > > diff -u -p -r1.18 rsync.1 > > --- rsync.1 6 May 2019 15:44:34 - 1.18 > > +++ rsync.1 8 Aug 2019 13:41:02 - > > @@ -24,6 +24,7 @@ > > .Nm openrsync > > .Op Fl aDglnoprtvx > > .Op Fl e Ar program > > +.Op Fl -address Ns = Ns Ar bind_address > > .Op Fl -del > > .Op Fl -numeric-ids > > .Op Fl -port Ns = Ns Ar service > > @@ -50,6 +51,12 @@ The arguments are as follows: > > .It Fl a , -archive > > Shorthand for > > .Fl Dgloprt . > > +.It Fl -address Ns = Ns Ar bind_address > > +Use > > +.Ar bind_address > > +on the local machine as the source address of the connection. > > +Only useful when connecting to an rsync daemon and on systems with more > > than > > +one address. > > .It Fl D > > Also transfer device and special files. > > Shorthand for > > Index: socket.c > > === > > RCS file: /cvs/src/usr.bin/rsync/socket.c,v > > retrieving revision 1.25 > > diff -u -p -r1.25 socket.c > > --- socket.c3 Jun 2019 15:37:48 - 1.25 > > +++ socket.c8 Aug 2019 13:41:02 -
Re: Removing the kernel timezone: config(8): drop timezone support
Hello, On Wed, 7 Aug 2019 21:41:17 -0500 Scott Cheloha wrote: > Drop config(8) support for getting/setting the kernel timezone. I'm using this. Is there any alternative or discussion? I think PCs are still shipped with their firmware configured to the local time. > ok? > > Index: cmd.c > === > RCS file: /cvs/src/usr.sbin/config/cmd.c,v > retrieving revision 1.20 > diff -u -p -r1.20 cmd.c > --- cmd.c 23 Nov 2013 17:38:15 - 1.20 > +++ cmd.c 8 Aug 2019 02:39:33 - > @@ -26,7 +26,6 @@ > > #include > #include > -#include > > #include > #include > @@ -57,7 +56,6 @@ cmd_table_t cmd_table[] = { > {"show", Xshow, "[attr [val]]", "Show attribute"}, > {"exit", Xexit, "", "Exit, without saving changes"}, > {"quit", Xquit, "", "Quit, saving current changes"}, > - {"timezone", Xtimezone, "[mins [dst]]", "Show/change timezone"}, > {"bufcachepercent", Xbufcachepct, "[number]", >"Show/change BUFCACHEPERCENT"}, > {"nkmempg", Xnkmempg, "[number]", "Show/change NKMEMPAGES"}, > @@ -245,37 +243,6 @@ Xexit(cmd_t *cmd) > { > /* Nothing to do here */ > return (CMD_EXIT); > -} > - > -int > -Xtimezone(cmd_t *cmd) > -{ > - struct timezone *tz; > - int num; > - char*c; > - > - ukc_mod_kernel = 1; > - tz = (struct timezone *)adjust((caddr_t)(nl[TZ_TZ].n_value)); > - > - if (strlen(cmd->args) == 0) { > - printf("timezone = %d, dst = %d\n", > - tz->tz_minuteswest, tz->tz_dsttime); > - } else { > - if (number(cmd->args, ) == 0) { > - tz->tz_minuteswest = num; > - c = cmd->args; > - while ((*c != '\0') && !isspace((unsigned char)*c)) > - c++; > - while (isspace((unsigned char)*c)) > - c++; > - if (strlen(c) != 0 && number(c, ) == 0) > - tz->tz_dsttime = num; > - printf("timezone = %d, dst = %d\n", > - tz->tz_minuteswest, tz->tz_dsttime); > - } else > - printf("Unknown argument\n"); > - } > - return (CMD_CONT); > } > > void > Index: ukcutil.c > === > RCS file: /cvs/src/usr.sbin/config/ukcutil.c,v > retrieving revision 1.24 > diff -u -p -r1.24 ukcutil.c > --- ukcutil.c 14 May 2019 13:44:25 - 1.24 > +++ ukcutil.c 8 Aug 2019 02:39:33 - > @@ -25,7 +25,6 @@ > */ > > #include > -#include > #include > > #include > @@ -1398,7 +1397,6 @@ process_history(int len, char *buf) > char *c; > int devno, newno; > short unit, state; > - struct timezone *tz; > > if (len == 0) { > printf("History is empty\n"); > @@ -1468,21 +1466,6 @@ process_history(int len, char *buf) > while (*c != '\n') > c++; > c++; > - break; > - case 't': > - c++; > - c++; > - tz = (struct timezone *)adjust((caddr_t)nl[TZ_TZ]. > - n_value); > - tz->tz_minuteswest = atoi(c); > - while (*c != ' ') > - c++; > - c++; > - tz->tz_dsttime = atoi(c); > - while (*c != '\n') > - c++; > - c++; > - ukc_mod_kernel = 1; > break; > case 'q': > while (*c != '\0') > Index: ukc.h > === > RCS file: /cvs/src/usr.sbin/config/ukc.h,v > retrieving revision 1.14 > diff -u -p -r1.14 ukc.h > --- ukc.h 27 Sep 2017 15:14:52 - 1.14 > +++ ukc.h 8 Aug 2019 02:39:33 - > @@ -41,14 +41,13 @@ > #define I_TEXTRALOC 11 > #define I_HISTLEN 12 > #define CA_HISTORY 13 > -#define TZ_TZ14 > -#define P_PDEVNAMES 15 > -#define I_PDEVSIZE 16 > -#define S_PDEVINIT 17 > -#define I_NMBCLUSTERS18 > -#define I_BUFCACHEPCT19 > -#define I_NKMEMPG20 > -#define NLENTRIES21 > +#define P_PDEVNAMES 14 > +#define I_PDEVSIZE 15 > +#define S_PDEVINIT 16 > +#define I_NMBCLUSTERS17 > +#define I_BUFCACHEPCT18 > +#define I_NKMEMPG19 > +#define NLENTRIES20 > > #ifdef UKC_MAIN > struct nlist nl[] = { > @@ -66,7 +65,6 @@ struct nlist nl[] = { > { "_textraloc" }, > { "_userconf_histlen" }, > { "_userconf_history" }, > - { "_tz" }, > { "_pdevnames" }, > { "_pdevnames_size" }, > { "_pdevinit" }, > @@ -90,7 +88,6
Re: Removing the kernel timezone: config(8): drop timezone support
YASUOKA Masahiko wrote: > Hello, > > On Wed, 7 Aug 2019 21:41:17 -0500 > Scott Cheloha wrote: > > Drop config(8) support for getting/setting the kernel timezone. > > I'm using this. Is there any alternative or discussion? > > I think PCs are still shipped with their firmware configured to the > local time. How are you using this? By deactivating KARL I assume? That's a pretty bad tradeoff. My view is that localtime-offset of a PC doesn't matter unless you run another operating system, and frankly why has that become our problem instead of their problem? To my amusement this supporting code was added on January 8, 2000.
pms: add extra ic type for elantech ps/2 touchpads
Hi, The change below adds ic type 13 as an elantech v4 device and causes the touchpad in a thinkpad x380 yoga to work as described in wsmouse(4). Two finger scrolling works and the three mouse button areas are defined as described. Before the touchpad and trackpoint were attached as a single generic ps/2 mouse. See also https://marc.info/?l=openbsd-tech=152620756114509=2 The following new lines appear in the dmesg output pms0: Elantech Clickpad, version 4, firmware 0x4d1f00 wsmouse1 at pms0 mux 0 and wsconsctl gives mouse.type=elantech mouse.rawmode=0 mouse.scale=0,2745,0,1627,0,0,0 mouse.tp.tapping=0 mouse.tp.scaling=0.288 mouse.tp.swapsides=0 mouse.tp.disable=0 mouse.tp.edges=0.0,5.0,10.0,5.0 mouse1.type=ps2 Hope something like this can be added to openbsd. Kind regards, Alexander Index: pms.c === RCS file: /cvs/src/sys/dev/pckbc/pms.c,v retrieving revision 1.88 diff -u -p -r1.88 pms.c --- pms.c 26 Jan 2019 11:57:21 - 1.88 +++ pms.c 2 Aug 2019 09:46:50 - @@ -1947,6 +1947,7 @@ elantech_get_hwinfo_v4(struct pms_softc if ((fw_version & 0x0f) >> 16 != 6 && (fw_version & 0x0f) >> 16 != 8 + && (fw_version & 0x0f) >> 16 != 13 && (fw_version & 0x0f) >> 16 != 15) return (-1);
bgpd more O_CLOEXEC
Just use O_CLOEXEC or SOCK_CLOEXEC on everything. There is no reason to keep any kind of file descriptor over an exec call. At least this way I'm sure that no fds will leak into the childs. OK? -- :wq Claudio ? obj Index: carp.c === RCS file: /cvs/src/usr.sbin/bgpd/carp.c,v retrieving revision 1.9 diff -u -p -r1.9 carp.c --- carp.c 24 Jan 2017 04:22:42 - 1.9 +++ carp.c 8 Aug 2019 11:33:37 - @@ -108,7 +108,7 @@ carp_demote_get(char *group) int s; struct ifgroupreq ifgr; - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { + if ((s = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0)) == -1) { log_warn("carp_demote_get: socket"); return (-1); } @@ -162,7 +162,7 @@ carp_demote_ioctl(char *group, int demot int s, res; struct ifgroupreq ifgr; - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { + if ((s = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0)) == -1) { log_warn("%s: socket", __func__); return (-1); } Index: control.c === RCS file: /cvs/src/usr.sbin/bgpd/control.c,v retrieving revision 1.97 diff -u -p -r1.97 control.c --- control.c 27 May 2019 09:14:32 - 1.97 +++ control.c 8 Aug 2019 11:33:37 - @@ -47,7 +47,7 @@ control_check(char *path) sun.sun_family = AF_UNIX; strlcpy(sun.sun_path, path, sizeof(sun.sun_path)); - if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { + if ((fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0)) == -1) { log_warn("%s: socket", __func__); return (-1); } Index: kroute.c === RCS file: /cvs/src/usr.sbin/bgpd/kroute.c,v retrieving revision 1.237 diff -u -p -r1.237 kroute.c --- kroute.c23 Jul 2019 06:26:44 - 1.237 +++ kroute.c8 Aug 2019 11:33:37 - @@ -2886,7 +2886,7 @@ get_mpe_config(const char *name, u_int * *label = 0; *rdomain = 0; - s = socket(AF_INET, SOCK_DGRAM, 0); + s = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0); if (s == -1) return (-1); Index: mrt.c === RCS file: /cvs/src/usr.sbin/bgpd/mrt.c,v retrieving revision 1.99 diff -u -p -r1.99 mrt.c --- mrt.c 24 Jul 2019 08:58:24 - 1.99 +++ mrt.c 8 Aug 2019 11:33:38 - @@ -908,7 +908,7 @@ mrt_open(struct mrt *mrt, time_t now) } fd = open(MRT2MC(mrt)->file, - O_WRONLY|O_NONBLOCK|O_CREAT|O_TRUNC, 0644); + O_WRONLY|O_NONBLOCK|O_CREAT|O_TRUNC|O_CLOEXEC, 0644); if (fd == -1) { log_warn("mrt_open %s", MRT2MC(mrt)->file); return (1); Index: pftable.c === RCS file: /cvs/src/usr.sbin/bgpd/pftable.c,v retrieving revision 1.13 diff -u -p -r1.13 pftable.c --- pftable.c 28 Jun 2019 13:32:47 - 1.13 +++ pftable.c 8 Aug 2019 11:33:38 - @@ -63,7 +63,7 @@ pftable_change(struct pf_table *pft) if (pft->naddrs == 0 || pft->what == 0) return (0); - if (devpf == -1 && ((devpf = open("/dev/pf", O_RDWR)) == -1)) + if (devpf == -1 && ((devpf = open("/dev/pf", O_RDWR|O_CLOEXEC)) == -1)) fatal("open(/dev/pf)"); bzero(, sizeof(tio)); @@ -90,7 +90,7 @@ pftable_clear(const char *name) { struct pfioc_table tio; - if (devpf == -1 && ((devpf = open("/dev/pf", O_RDWR)) == -1)) + if (devpf == -1 && ((devpf = open("/dev/pf", O_RDWR|O_CLOEXEC)) == -1)) fatal("open(/dev/pf)"); bzero(, sizeof(tio)); @@ -111,7 +111,7 @@ pftable_exists(const char *name) struct pfioc_table tio; struct pfr_astats dummy; - if (devpf == -1 && ((devpf = open("/dev/pf", O_RDWR)) == -1)) + if (devpf == -1 && ((devpf = open("/dev/pf", O_RDWR|O_CLOEXEC)) == -1)) fatal("open(/dev/pf)"); bzero(, sizeof(tio));
bgpd fail before daemonizing on config errors
Hi, With the introduction of re-exec of the childs the config parsing happened after bgpd demonized. This is super annoying and therefor this diff changes that. It will make bgpd fail on startup if there is an issue with the config file. I could not move the control socket setup before daemonizing since that call will send out imsgs and so the childs need to be up and running. To change this more refactoring is needed but this is already a good first step. OK? -- :wq Claudio Index: bgpd.c === RCS file: /cvs/src/usr.sbin/bgpd/bgpd.c,v retrieving revision 1.224 diff -u -p -r1.224 bgpd.c --- bgpd.c 5 Aug 2019 08:46:55 - 1.224 +++ bgpd.c 8 Aug 2019 09:30:36 - @@ -43,6 +43,7 @@ int main(int, char *[]); pid_t start_child(enum bgpd_process, char *, int, int, int); intsend_filterset(struct imsgbuf *, struct filter_set_head *); intreconfigure(char *, struct bgpd_config *); +intsend_config(struct bgpd_config *); intdispatch_imsg(struct imsgbuf *, int, struct bgpd_config *); intcontrol_setup(struct bgpd_config *); static voidgetsockpair(int [2]); @@ -195,6 +196,14 @@ main(int argc, char *argv[]) if (getpwnam(BGPD_USER) == NULL) errx(1, "unknown user %s", BGPD_USER); + if ((conf = parse_config(conffile, NULL)) == NULL) { + log_warnx("config file %s has errors", conffile); + exit(1); + } + + if (prepare_listeners(conf) == -1) + exit(1); + log_init(debug, LOG_DAEMON); log_setverbose(cmd_opts & BGPD_OPT_VERBOSE); @@ -250,8 +259,11 @@ BROKEN if (pledge("stdio rpath wpath cpa if (imsg_send_sockets(ibuf_se, ibuf_rde)) fatal("could not establish imsg links"); - conf = new_config(); - quit = reconfigure(conffile, conf); + /* control setup needs to happen late since it sends imsgs */ + if (control_setup(conf) == -1) + quit = 1; + if (send_config(conf) != 0) + quit = 1; if (pftable_clear_all() != 0) quit = 1; @@ -325,9 +337,12 @@ BROKEN if (pledge("stdio rpath wpath cpa error = 0; break; case 2: + log_info("previous reload still running"); error = CTL_RES_PENDING; break; default:/* parse error */ + log_warnx("config file %s has errors, " + "not reloading", conffile); error = CTL_RES_PARSE_ERROR; break; } @@ -456,39 +471,40 @@ int reconfigure(char *conffile, struct bgpd_config *conf) { struct bgpd_config *new_conf; - struct peer *p; - struct filter_rule *r; - struct listen_addr *la; - struct rde_rib *rr; - struct l3vpn*vpn; - struct as_set *aset; - struct prefixset*ps; - struct prefixset_item *psi, *npsi; - if (reconfpending) { - log_info("previous reload still running"); + if (reconfpending) return (2); - } - reconfpending = 2; /* one per child */ log_info("rereading config"); - if ((new_conf = parse_config(conffile, >peers)) == NULL) { - log_warnx("config file %s has errors, not reloading", - conffile); - reconfpending = 0; + if ((new_conf = parse_config(conffile, >peers)) == NULL) return (1); - } + merge_config(conf, new_conf); if (prepare_listeners(conf) == -1) { - reconfpending = 0; return (1); } if (control_setup(conf) == -1) { - reconfpending = 0; return (1); } + + return send_config(conf); +} + +int +send_config(struct bgpd_config *conf) +{ + struct peer *p; + struct filter_rule *r; + struct listen_addr *la; + struct rde_rib *rr; + struct l3vpn*vpn; + struct as_set *aset; + struct prefixset*ps; + struct prefixset_item *psi, *npsi; + + reconfpending = 2; /* one per child */ expand_networks(conf); Index: parse.y === RCS file: /cvs/src/usr.sbin/bgpd/parse.y,v retrieving revision 1.399 diff -u -p -r1.399 parse.y --- parse.y 7 Aug 2019 10:26:41 - 1.399 +++ parse.y 8 Aug 2019 09:22:48 - @@ -592,6 +592,7 @@ conf_main : AS as4number {
Re: bgpd fail before daemonizing on config errors
OK kn
openrsync --address option
I need to be able to control the bind address for openrsync connections. This implements this but it only works for connections to an rsync daemon. For rsync over ssh you need to use -e 'ssh -b address' instead. -- :wq Claudio Index: extern.h === RCS file: /cvs/src/usr.bin/rsync/extern.h,v retrieving revision 1.31 diff -u -p -r1.31 extern.h --- extern.h2 Jun 2019 17:36:48 - 1.31 +++ extern.h8 Aug 2019 13:41:02 - @@ -120,6 +120,7 @@ struct opts { char*rsync_path;/* --rsync-path */ char*ssh_prog; /* --rsh or -e */ char*port; /* --port */ + char*address; /* --address */ }; /* Index: main.c === RCS file: /cvs/src/usr.bin/rsync/main.c,v retrieving revision 1.47 diff -u -p -r1.47 main.c --- main.c 3 Jun 2019 15:37:48 - 1.47 +++ main.c 8 Aug 2019 13:41:02 - @@ -307,6 +307,7 @@ main(int argc, char *argv[]) { "no-times", no_argument,_times, 0 }, { "verbose",no_argument,, 1 }, { "no-verbose", no_argument,, 0 }, + { "address",required_argument, NULL,4 }, { NULL, 0, NULL, 0 }}; /* Global pledge. */ @@ -380,6 +381,9 @@ main(int argc, char *argv[]) case 3: opts.port = optarg; break; + case 4: + opts.address = optarg; + break; case 'h': default: goto usage; @@ -505,9 +509,9 @@ main(int argc, char *argv[]) exit(rc); usage: fprintf(stderr, "usage: %s" - " [-aDglnoprtvx] [-e program] [--del] [--numeric-ids]\n" - "\t[--port=portnumber] [--rsync-path=program] [--version]\n" - "\tsource ... directory\n", + " [-aDglnoprtvx] [-e program] [--address=bind_address] [--del]\n" + "\t[--numeric-ids] [--port=portnumber] [--rsync-path=program]\n" + "\t[--version] source ... directory\n", getprogname()); exit(1); } Index: rsync.1 === RCS file: /cvs/src/usr.bin/rsync/rsync.1,v retrieving revision 1.18 diff -u -p -r1.18 rsync.1 --- rsync.1 6 May 2019 15:44:34 - 1.18 +++ rsync.1 8 Aug 2019 13:41:02 - @@ -24,6 +24,7 @@ .Nm openrsync .Op Fl aDglnoprtvx .Op Fl e Ar program +.Op Fl -address Ns = Ns Ar bind_address .Op Fl -del .Op Fl -numeric-ids .Op Fl -port Ns = Ns Ar service @@ -50,6 +51,12 @@ The arguments are as follows: .It Fl a , -archive Shorthand for .Fl Dgloprt . +.It Fl -address Ns = Ns Ar bind_address +Use +.Ar bind_address +on the local machine as the source address of the connection. +Only useful when connecting to an rsync daemon and on systems with more than +one address. .It Fl D Also transfer device and special files. Shorthand for Index: socket.c === RCS file: /cvs/src/usr.bin/rsync/socket.c,v retrieving revision 1.25 diff -u -p -r1.25 socket.c --- socket.c3 Jun 2019 15:37:48 - 1.25 +++ socket.c8 Aug 2019 13:41:02 - @@ -46,11 +46,34 @@ struct source { }; /* + * Try to bind to a local IP address matching the addres family passed. + * Return -1 on failure to bind to any address, 0 on success. + */ +static int +inet_bind(int s, sa_family_t af, const struct source *bsrc, size_t bsrcsz) +{ + size_t i; + + if (bsrc == NULL) + return 0; + for (i = 0; i < bsrcsz; i++) { + if (bsrc[i].family != af) + continue; + if (bind(s, (const struct sockaddr *)[i].sa, + bsrc[i].salen) == -1) + continue; + return 0; + } + return -1; +} + +/* * Connect to an IP address representing a host. * Return <0 on failure, 0 on try another address, >0 on success. */ static int -inet_connect(int *sd, const struct source *src, const char *host) +inet_connect(int *sd, const struct source *src, const char *host, +const struct source *bsrc, size_t bsrcsz) { int c, flags; @@ -64,6 +87,11 @@ inet_connect(int *sd, const struct sourc return -1; } + if (inet_bind(*sd, src->family, bsrc, bsrcsz) == -1) { + ERR("bind"); + return -1; + } + /* * Initiate blocking connection. * We use the blocking connect() instead of passing NONBLOCK to @@ -102,11 +130,12 @@ inet_connect(int *sd, const struct sourc * in this case). */ static struct source *
Re: bgpd fail before daemonizing on config errors
On Thu, Aug 08, 2019 at 11:48:08AM +0200, Claudio Jeker wrote: > With the introduction of re-exec of the childs the config parsing happened > after bgpd demonized. This is super annoying and therefor this diff > changes that. It will make bgpd fail on startup if there is an issue with > the config file. I could not move the control socket setup before > daemonizing since that call will send out imsgs and so the childs need to > be up and running. To change this more refactoring is needed but this is > already a good first step. > > OK? OK job@