Re: sparc64: iommu: unbreak DEBUG build: %lx and time_t
On Mon, Dec 23, 2019 at 04:33:04PM -0800, Philip Guenther wrote: > On Mon, Dec 23, 2019 at 12:42 PM Klemens Nanni wrote: > > > `option DEBUG' builds are broken on sparc64, here's the first step in > > fixing it. > > > > /sys/arch/sparc64/dev/iommu.c: In function 'iommu_strbuf_flush_done': > > /sys/arch/sparc64/dev/iommu.c:582: warning: format '%lx' expects type > > 'long unsigned int', but argument 4 has type 'time_t' > > /sys/arch/sparc64/dev/iommu.c:582: warning: format '%lx' expects type > > 'long unsigned int', but argument 6 has type 'time_t' > > > > time_t is a long unsinged integer, that is As deraadt pointed out, this is wrong (as I've shown below). > > /usr/include/time.h:typedef __time_ttime_t; > > /usr/include/sys/_types.h:typedef __int64_t __time_t; /* > > epoch time */ > > /usr/include/amd64/_types.h:typedef long long __int64_t; > > > > OK? Any better idea? > > > In general, for time_t we've case to (long long) and used %ll, so > that it's consistent across the system. Thanks, not sure why I didn't think of this... here's a diff to use %llx. Compiler is happy without bogus casts. OK? Index: /sys/arch/sparc64/dev/iommu.c === RCS file: /cvs/src/sys/arch/sparc64/dev/iommu.c,v retrieving revision 1.76 diff -u -p -r1.76 iommu.c --- /sys/arch/sparc64/dev/iommu.c 25 Jun 2019 22:30:55 - 1.76 +++ /sys/arch/sparc64/dev/iommu.c 24 Dec 2019 02:18:57 - @@ -581,7 +581,7 @@ iommu_strbuf_flush_done(struct iommu_map DPRINTF(IDB_IOMMU, ("iommu_strbuf_flush_done: flush = %llx pa = %lx " - "now=%lx:%lx until = %lx:%lx\n", + "now=%llx:%lx until = %llx:%lx\n", ldxa(sf->sbf_flushpa, ASI_PHYS_CACHED), sf->sbf_flushpa, cur.tv_sec, cur.tv_usec, flushtimeout.tv_sec, flushtimeout.tv_usec));
Re: sparc64: iommu: unbreak DEBUG build: %lx and time_t
On Mon, Dec 23, 2019 at 12:42 PM Klemens Nanni wrote: > `option DEBUG' builds are broken on sparc64, here's the first step in > fixing it. > > /sys/arch/sparc64/dev/iommu.c: In function 'iommu_strbuf_flush_done': > /sys/arch/sparc64/dev/iommu.c:582: warning: format '%lx' expects type > 'long unsigned int', but argument 4 has type 'time_t' > /sys/arch/sparc64/dev/iommu.c:582: warning: format '%lx' expects type > 'long unsigned int', but argument 6 has type 'time_t' > > time_t is a long unsinged integer, that is > > /usr/include/time.h:typedef __time_ttime_t; > /usr/include/sys/_types.h:typedef __int64_t __time_t; /* > epoch time */ > /usr/include/amd64/_types.h:typedef long long __int64_t; > > OK? Any better idea? In general, for time_t we've case to (long long) and used %ll, so that it's consistent across the system. Philip Guenther
Re: dmesg alloc
On Mon, 23 Dec 2019, Alexander Bluhm wrote: > dmesg(8) allocates a bit too much memory. > > sysctl KERN_MSGBUFSIZE returns msg_bufs. > sysctl KERN_MSGBUF copies out msg_bufs + offsetof(struct msgbuf, > msg_bufc) bytes. > dmesg allocates msg_bufs + sizeof(struct msgbuf) - 1 bytes. > > This is not the same value as struct msgbuf is padded. > struct msgbuf { > ... > longmsg_bufd; /* number of dropped bytes */ > charmsg_bufc[1];/* buffer */ > }; > > Better use the same size algorithm in kernel and userland. > > ok? The first chunk should be replaced with this one: @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include to just pick up the offsetof() supplied for the last 30 years by the C standard. Otherwise, ok.
dmesg alloc
Hi, dmesg(8) allocates a bit too much memory. sysctl KERN_MSGBUFSIZE returns msg_bufs. sysctl KERN_MSGBUF copies out msg_bufs + offsetof(struct msgbuf, msg_bufc) bytes. dmesg allocates msg_bufs + sizeof(struct msgbuf) - 1 bytes. This is not the same value as struct msgbuf is padded. struct msgbuf { ... longmsg_bufd; /* number of dropped bytes */ charmsg_bufc[1];/* buffer */ }; Better use the same size algorithm in kernel and userland. ok? bluhm Index: sbin/dmesg/dmesg.c === RCS file: /data/mirror/openbsd/cvs/src/sbin/dmesg/dmesg.c,v retrieving revision 1.30 diff -u -p -r1.30 dmesg.c --- sbin/dmesg/dmesg.c 15 May 2018 15:15:50 - 1.30 +++ sbin/dmesg/dmesg.c 23 Dec 2019 22:12:44 - @@ -55,6 +55,9 @@ struct nlist nl[] = { void usage(void); +#ifndef offsetof +#define offsetof(s, e) ((size_t)&((s *)0)->e) +#endif #defineKREAD(addr, var) \ kvm_read(kd, addr, &var, sizeof(var)) != sizeof(var) @@ -99,7 +102,7 @@ main(int argc, char *argv[]) err(1, "sysctl: %s", startupmsgs ? "KERN_CONSBUFSIZE" : "KERN_MSGBUFSIZE"); - msgbufsize += sizeof(struct msgbuf) - 1; + msgbufsize += offsetof(struct msgbuf, msg_bufc); allocated = bufdata = calloc(1, msgbufsize); if (bufdata == NULL) errx(1, "couldn't allocate space for buffer data");
ospf6d: type p2p
Hi, this brings support for interface "type p2p" to ospf6d (ospfd got it a few weeks ago). The configuration looks like this: area 0.0.0.0 { interface em0 { type p2p } } OK? Remi Index: ospf6d.conf.5 === RCS file: /cvs/src/usr.sbin/ospf6d/ospf6d.conf.5,v retrieving revision 1.19 diff -u -p -r1.19 ospf6d.conf.5 --- ospf6d.conf.5 26 May 2019 09:27:09 - 1.19 +++ ospf6d.conf.5 5 Oct 2019 14:17:29 - @@ -328,6 +328,9 @@ Router. .It Ic transmit-delay Ar seconds Set the transmit delay. The default value is 1; valid range is 1\-3600 seconds. +.It Ic type p2p +Set the interface type to point to point. +This disables the election of a DR and BDR for the given interface. .El .Sh FILES .Bl -tag -width "/etc/ospf6d.conf" -compact Index: ospf6d.h === RCS file: /cvs/src/usr.sbin/ospf6d/ospf6d.h,v retrieving revision 1.42 diff -u -p -r1.42 ospf6d.h --- ospf6d.h23 Dec 2019 07:33:49 - 1.42 +++ ospf6d.h23 Dec 2019 09:08:23 - @@ -329,6 +329,7 @@ struct iface { u_int8_t if_type; u_int8_t linkstate; u_int8_t priority; + u_int8_t p2p; u_int8_t cflags; #define F_IFACE_PASSIVE0x01 #define F_IFACE_CONFIGURED 0x02 Index: parse.y === RCS file: /cvs/src/usr.sbin/ospf6d/parse.y,v retrieving revision 1.47 diff -u -p -r1.47 parse.y --- parse.y 23 Dec 2019 07:33:49 - 1.47 +++ parse.y 23 Dec 2019 10:40:28 - @@ -126,7 +126,7 @@ typedef struct { %token AREA INTERFACE ROUTERID FIBPRIORITY FIBUPDATE REDISTRIBUTE RTLABEL %token RDOMAIN STUB ROUTER SPFDELAY SPFHOLDTIME EXTTAG -%token METRIC PASSIVE +%token METRIC P2P PASSIVE %token HELLOINTERVAL TRANSMITDELAY %token RETRANSMITINTERVAL ROUTERDEADTIME ROUTERPRIORITY %token SET TYPE @@ -566,6 +566,10 @@ interfaceopts_l: interfaceopts_l interf ; interfaceoptsl : PASSIVE { iface->cflags |= F_IFACE_PASSIVE; } + | TYPE P2P { + iface->p2p = 1; + iface->type = IF_TYPE_POINTOPOINT; + } | DEMOTE STRING { if (strlcpy(iface->demote_group, $2, sizeof(iface->demote_group)) >= @@ -645,6 +649,7 @@ lookup(char *s) {"metric", METRIC}, {"no", NO}, {"on", ON}, + {"p2p", P2P}, {"passive", PASSIVE}, {"rdomain", RDOMAIN}, {"redistribute",REDISTRIBUTE}, Index: printconf.c === RCS file: /cvs/src/usr.sbin/ospf6d/printconf.c,v retrieving revision 1.8 diff -u -p -r1.8 printconf.c --- printconf.c 29 Dec 2018 16:04:31 - 1.8 +++ printconf.c 5 Oct 2019 14:14:19 - @@ -135,6 +135,9 @@ print_iface(struct iface *iface) printf("\t\trouter-priority %d\n", iface->priority); printf("\t\ttransmit-delay %d\n", iface->transmit_delay); + if (iface->p2p) + printf("\t\ttype p2p\n"); + printf("\t}\n"); }
consbuf cleanup
Hi, The console buffer is allocated during startup. initconsbuf() is only called from main(). There allocation must not fail, better use M_WAITOK and remove error handling. It is not a temporary buffer, M_TTYS looks more appropriate. KERN_CONSBUF has no name and result in strange ktrace output. 18846 dmesgCALL sysctl(1.83,0x1e6dbe3b6000,0x7f7eab78,0,0) ok? bluhm Index: kern/subr_log.c === RCS file: /data/mirror/openbsd/cvs/src/sys/kern/subr_log.c,v retrieving revision 1.59 diff -u -p -r1.59 subr_log.c --- kern/subr_log.c 24 Oct 2019 03:31:49 - 1.59 +++ kern/subr_log.c 23 Dec 2019 19:37:36 - @@ -132,15 +132,10 @@ initmsgbuf(caddr_t buf, size_t bufsize) void initconsbuf(void) { - long new_bufs; - /* Set up a buffer to collect /dev/console output */ - consbufp = malloc(CONSBUFSIZE, M_TEMP, M_NOWAIT|M_ZERO); - if (consbufp) { - new_bufs = CONSBUFSIZE - offsetof(struct msgbuf, msg_bufc); - consbufp->msg_magic = MSG_MAGIC; - consbufp->msg_bufs = new_bufs; - } + consbufp = malloc(CONSBUFSIZE, M_TTYS, M_WAITOK | M_ZERO); + consbufp->msg_magic = MSG_MAGIC; + consbufp->msg_bufs = CONSBUFSIZE - offsetof(struct msgbuf, msg_bufc); } void Index: sys/sysctl.h === RCS file: /data/mirror/openbsd/cvs/src/sys/sys/sysctl.h,v retrieving revision 1.198 diff -u -p -r1.198 sysctl.h --- sys/sysctl.h11 Dec 2019 07:30:09 - 1.198 +++ sys/sysctl.h23 Dec 2019 21:14:38 - @@ -274,8 +274,8 @@ struct ctlname { { "proc_nobroadcastkill", CTLTYPE_NODE }, \ { "proc_vmmap", CTLTYPE_NODE }, \ { "global_ptrace", CTLTYPE_INT }, \ - { "gap", 0 }, \ - { "gap", 0 }, \ + { "consbufsize", 0 }, \ + { "consbuf", 0 }, \ { "audio", CTLTYPE_STRUCT }, \ { "cpustats", CTLTYPE_STRUCT }, \ { "pfstatus", CTLTYPE_STRUCT }, \
sparc64: iommu: unbreak DEBUG build: use %lx not %llx for bus_{addr,size}_t
The last diff to fix the build: /sys/arch/sparc64/dev/iommu.c:1389: warning: format '%llx' expects type 'long long unsigned int', but argument 2 has type 'bus_addr_t' /sys/arch/sparc64/dev/iommu.c:1394: warning: format '%llx' expects type 'long long unsigned int', but argument 2 has type 'bus_size_t' /sys/arch/sparc64/dev/iommu.c:1402: warning: format '%llx' expects type 'long long unsigned int', but argument 2 has type 'bus_addr_t' /sys/arch/sparc64/dev/iommu.c:1402: warning: format '%llx' expects type 'long long unsigned int', but argument 3 has type 'bus_size_t' /sys/arch/sparc64/dev/iommu.c:1413: warning: format '%llx' expects type 'long long unsigned int', but argument 3 has type 'bus_addr_t' /sys/arch/sparc64/dev/iommu.c:1413: warning: format '%llx' expects type 'long long unsigned int', but argument 4 has type 'bus_size_t' /sys/arch/sparc64/dev/iommu.c:1413: warning: format '%llx' expects type 'long long unsigned int', but argument 5 has type 'bus_addr_t' /sys/arch/sparc64/dev/iommu.c:1413: warning: format '%llx' expects type 'long long unsigned int', but argument 6 has type 'bus_size_t' /sys/arch/sparc64/dev/iommu.c:1424: warning: format '%llx' expects type 'long long unsigned int', but argument 3 has type 'bus_addr_t' /sys/arch/sparc64/dev/iommu.c:1424: warning: format '%llx' expects type 'long long unsigned int', but argument 4 has type 'bus_size_t' /sys/arch/sparc64/dev/iommu.c:1424: warning: format '%llx' expects type 'long long unsigned int', but argument 5 has type 'bus_addr_t' /sys/arch/sparc64/dev/iommu.c:1424: warning: format '%llx' expects type 'long long unsigned int', but argument 6 has type 'bus_size_t' Both types are u_long which is unsigned long. OK? Index: /sys/arch/sparc64/dev/iommu.c === RCS file: /cvs/src/sys/arch/sparc64/dev/iommu.c,v retrieving revision 1.76 diff -u -p -r1.76 iommu.c --- /sys/arch/sparc64/dev/iommu.c 25 Jun 2019 22:30:55 - 1.76 +++ /sys/arch/sparc64/dev/iommu.c 23 Dec 2019 21:18:02 - @@ -1385,19 +1387,19 @@ iommu_dvmamap_validate_map(bus_dma_tag_t int seg; if (trunc_page(map->_dm_dvmastart) != map->_dm_dvmastart) { - printf(" dvmastart address not page aligned: %llx", + printf(" dvmastart address not page aligned: %lx", map->_dm_dvmastart); err = 1; } if (trunc_page(map->_dm_dvmasize) != map->_dm_dvmasize) { - printf(" dvmasize not a multiple of page size: %llx", + printf(" dvmasize not a multiple of page size: %lx", map->_dm_dvmasize); err = 1; } if (map->_dm_dvmastart < is->is_dvmabase || (round_page(map->_dm_dvmastart + map->_dm_dvmasize) - 1) > is->is_dvmaend) { - printf("dvmaddr %llx len %llx out of range %x - %x\n", + printf("dvmaddr %lx len %lx out of range %x - %x\n", map->_dm_dvmastart, map->_dm_dvmasize, is->is_dvmabase, is->is_dvmaend); err = 1; @@ -1405,8 +1407,8 @@ iommu_dvmamap_validate_map(bus_dma_tag_t for (seg = 0; seg < map->dm_nsegs; seg++) { if (map->dm_segs[seg].ds_addr == 0 || map->dm_segs[seg].ds_len == 0) { - printf("seg %d null segment dvmaddr %llx len %llx for " - "range %llx len %llx\n", + printf("seg %d null segment dvmaddr %lx len %lx for " + "range %lx len %lx\n", seg, map->dm_segs[seg].ds_addr, map->dm_segs[seg].ds_len, @@ -1416,8 +1418,8 @@ iommu_dvmamap_validate_map(bus_dma_tag_t round_page(map->dm_segs[seg].ds_addr + map->dm_segs[seg].ds_len) > map->_dm_dvmastart + map->_dm_dvmasize) { - printf("seg %d dvmaddr %llx len %llx out of " - "range %llx len %llx\n", + printf("seg %d dvmaddr %lx len %lx out of " + "range %lx len %lx\n", seg, map->dm_segs[seg].ds_addr, map->dm_segs[seg].ds_len,
sparc64: iommu: unbreak DEBUG build: do not use undefined pa
Another `option DEBUG' fix for /sys/arch/sparc64/dev/iommu.c: In function 'iommu_dvmamap_insert': /sys/arch/sparc64/dev/iommu.c:1136: error: 'pa' undeclared (first use in this function) /sys/arch/sparc64/dev/iommu.c:1136: error: (Each undeclared identifier is reported only once /sys/arch/sparc64/dev/iommu.c:1136: error: for each function it appears in.) The last commit revision 1.76 date: 2019/06/25 22:30:55; author: dlg; state: Exp; lines: +129 -104; add support for bypassing iommu translation introduced iommu_dvmamap_insert() using an undefined paddr_t pa under DEBUG; since I cannot introduce it, let's remove it from the printf unless someone knowing the code can make it work as intended. Feedback? OK? Index: /sys/arch/sparc64/dev/iommu.c === RCS file: /cvs/src/sys/arch/sparc64/dev/iommu.c,v retrieving revision 1.76 diff -u -p -r1.76 iommu.c --- /sys/arch/sparc64/dev/iommu.c 25 Jun 2019 22:30:55 - 1.76 +++ /sys/arch/sparc64/dev/iommu.c 23 Dec 2019 21:00:21 - @@ -1132,8 +1134,8 @@ iommu_dvmamap_insert(bus_dma_tag_t t, bu #ifdef DEBUG if (trunc_page(sgstart) != trunc_page(sgend)) { printf("append range crossing page boundary! " - "pa %lx length %ld/0x%lx sgstart %lx sgend %lx\n", - pa, length, length, sgstart, sgend); + "length %ld/0x%lx sgstart %lx sgend %lx\n", + length, length, sgstart, sgend); } #endif
Re: sparc64: iommu: unbreak DEBUG build: use %x not %lx with int
On Mon, Dec 23, 2019 at 09:43:20PM +0100, Klemens Nanni wrote: > Second fix for `option DEBUG': len, seg_len and left are all of type int. Jumping the gun: seg_len is bus_size_t, only len and left are int.
sparc64: iommu: unbreak DEBUG build: use %x not %lx with int
Second fix for `option DEBUG': len, seg_len and left are all of type int. /sys/arch/sparc64/dev/iommu.c: In function 'iommu_dvmamap_load_raw': /sys/arch/sparc64/dev/iommu.c:1063: warning: format '%ld' expects type 'long int', but argument 5 has type 'int' /sys/arch/sparc64/dev/iommu.c:1063: warning: format '%lx' expects type 'long unsigned int', but argument 6 has type 'int' /sys/arch/sparc64/dev/iommu.c:1063: warning: format '%ld' expects type 'long int', but argument 7 has type 'int' OK? Index: /sys/arch/sparc64/dev/iommu.c === RCS file: /cvs/src/sys/arch/sparc64/dev/iommu.c,v retrieving revision 1.76 diff -u -p -r1.76 iommu.c --- /sys/arch/sparc64/dev/iommu.c 25 Jun 2019 22:30:55 - 1.76 +++ /sys/arch/sparc64/dev/iommu.c 23 Dec 2019 20:28:28 - @@ -1059,7 +1061,7 @@ iommu_dvmamap_load_raw(bus_dma_tag_t t, int seg_len = MIN(left, len); printf("addr %lx len %ld/0x%lx seg_len " - "%ld/0x%lx left %ld/0xl%x\n", addr, + "%d/0x%x left %d/0x%x\n", addr, len, len, seg_len, seg_len, left, left); left -= seg_len;
sparc64: iommu: unbreak DEBUG build: %lx and time_t
`option DEBUG' builds are broken on sparc64, here's the first step in fixing it. /sys/arch/sparc64/dev/iommu.c: In function 'iommu_strbuf_flush_done': /sys/arch/sparc64/dev/iommu.c:582: warning: format '%lx' expects type 'long unsigned int', but argument 4 has type 'time_t' /sys/arch/sparc64/dev/iommu.c:582: warning: format '%lx' expects type 'long unsigned int', but argument 6 has type 'time_t' time_t is a long unsinged integer, that is /usr/include/time.h:typedef __time_ttime_t; /usr/include/sys/_types.h:typedef __int64_t __time_t; /* epoch time */ /usr/include/amd64/_types.h:typedef long long __int64_t; OK? Any better idea? Index: /sys/arch/sparc64/dev/iommu.c === RCS file: /cvs/src/sys/arch/sparc64/dev/iommu.c,v retrieving revision 1.76 diff -u -p -r1.76 iommu.c --- /sys/arch/sparc64/dev/iommu.c 25 Jun 2019 22:30:55 - 1.76 +++ /sys/arch/sparc64/dev/iommu.c 23 Dec 2019 20:28:28 - @@ -583,8 +583,10 @@ iommu_strbuf_flush_done(struct iommu_map ("iommu_strbuf_flush_done: flush = %llx pa = %lx " "now=%lx:%lx until = %lx:%lx\n", ldxa(sf->sbf_flushpa, ASI_PHYS_CACHED), - sf->sbf_flushpa, cur.tv_sec, cur.tv_usec, - flushtimeout.tv_sec, flushtimeout.tv_usec)); + sf->sbf_flushpa, (long unsigned int)cur.tv_sec, + cur.tv_usec, + (long unsigned int)flushtimeout.tv_sec, + flushtimeout.tv_usec)); } } }
wbsd(4): timeout_add(9) -> timeout_add_msec(9)
hz/4 -> 250ms. ok? Index: w83l518d_sdmmc.c === RCS file: /cvs/src/sys/dev/ic/w83l518d_sdmmc.c,v retrieving revision 1.4 diff -u -p -r1.4 w83l518d_sdmmc.c --- w83l518d_sdmmc.c5 May 2016 11:01:08 - 1.4 +++ w83l518d_sdmmc.c23 Dec 2019 19:25:56 - @@ -578,7 +578,7 @@ wb_sdmmc_intr(struct wb_softc *wb) "\5CRC\6FIFO\7CARD\010PENDING"); if (val & WB_INT_CARD) - timeout_add(&wb->wb_sdmmc_to, hz / 4); + timeout_add_msec(&wb->wb_sdmmc_to, 250); return 1; }
hppa: heartbeat: timeout_add(9) -> timeout_add_usec(9)
1/16 seconds is exactly 62500 microseconds. ok? Index: arch/hppa/hppa/autoconf.c === RCS file: /cvs/src/sys/arch/hppa/hppa/autoconf.c,v retrieving revision 1.62 diff -u -p -r1.62 autoconf.c --- arch/hppa/hppa/autoconf.c 27 Jan 2018 22:55:23 - 1.62 +++ arch/hppa/hppa/autoconf.c 23 Dec 2019 19:21:32 - @@ -110,7 +110,7 @@ heartbeat(v) int toggle, cp_mask, cp_total, cp_idle; struct schedstate_percpu *spc = &(curcpu()->ci_schedstate); - timeout_add(&heartbeat_tmo, hz / 16); + timeout_add_usec(&heartbeat_tmo, 62500);/* 1/16 seconds */ cp_idle = spc->spc_cp_time[CP_IDLE]; cp_total = spc->spc_cp_time[CP_USER] + spc->spc_cp_time[CP_NICE] +
Re: ospf6d: add basic regress tests
On Mon, Dec 23, 2019 at 03:53:23PM +0100, Claudio Jeker wrote: > On Mon, Dec 23, 2019 at 03:24:31PM +0100, Remi Locherer wrote: > > On Sun, Dec 22, 2019 at 08:36:41PM +0100, Denis Fondras wrote: > > > Add basic regress test to ospf6d. > > > > Works for me. OK remi@ > > > > The tests also succeed when I reduce the sleep from 120 to 60. > > A few lines end with a space. I marked them below. > > I would suggest to minimize hold times etc. and reduce the timeout as > much as possible. Regress test should not wait uneccessary long. > Thank you guys. sleep 50s is the best I have come with so far. > > > > > > Index: ospf6d/Makefile > > > === > > > RCS file: ospf6d/Makefile > > > diff -N ospf6d/Makefile > > > --- /dev/null 1 Jan 1970 00:00:00 - > > > +++ ospf6d/Makefile 22 Dec 2019 19:27:27 - > > > @@ -0,0 +1,10 @@ > > > +# $OpenBSD$ > > > + > > > +REGRESS_TARGETS = network_statement > > > + > > > +OSPF6D ?=/usr/sbin/ospf6d > > > + > > > +network_statement: > > > + ${SUDO} ksh ${.CURDIR}/$@.sh ${OSPF6D} ${.CURDIR} 11 12 pair11 pair12 > > > + > > > +.include > > > Index: ospf6d/network_statement.sh > > > === > > > RCS file: ospf6d/network_statement.sh > > > diff -N ospf6d/network_statement.sh > > > --- /dev/null 1 Jan 1970 00:00:00 - > > > +++ ospf6d/network_statement.sh 22 Dec 2019 19:27:27 - > > > @@ -0,0 +1,107 @@ > > > +#!/bin/ksh > > > +#$OpenBSD$ > > > +set -e > > > + > > > +OSPF6D=$1 > > > +OSPF6DCONFIGDIR=$2 > > > +RDOMAIN1=$3 > > > +RDOMAIN2=$4 > > > +PAIR1=$5 > > > +PAIR2=$6 > > > + > > > +RDOMAINS="${RDOMAIN1} ${RDOMAIN2}" > > > +PAIRS="${PAIR1} ${PAIR2}" > > > +PAIR1IP=2001:db8::${RDOMAIN1} > > > +PAIR2IP=2001:db8::${RDOMAIN2} > > > +PAIR1PREFIX=2001:db8:${RDOMAIN1}:: > > > +PAIR2PREFIX=2001:db8:${RDOMAIN2}:: > > > +PAIR2PREFIX2=2001:db8:${RDOMAIN2}:${RDOMAIN2}:: > > > + > > > +error_notify() { > > > + echo cleanup > > > + pkill -T ${RDOMAIN1} ospf6d || true > > > + pkill -T ${RDOMAIN2} ospf6d || true > > > + sleep 1 > > > + ifconfig ${PAIR2} destroy || true > > > + ifconfig ${PAIR1} destroy || true > > > + ifconfig vether${RDOMAIN1} destroy || true > > > + ifconfig vether${RDOMAIN2} destroy || true > > > + route -qn -T ${RDOMAIN1} flush || true > > > + route -qn -T ${RDOMAIN2} flush || true > > > + ifconfig lo${RDOMAIN1} destroy || true > > > + ifconfig lo${RDOMAIN2} destroy || true > > > + rm ospf6d.1.conf ospf6d.2.conf > > > + if [ $1 -ne 0 ]; then > > > + echo FAILED > > > + exit 1 > > > + else > > > + echo SUCCESS > > > + fi > > > +} > > > + > > > +if [ "$(id -u)" -ne 0 ]; then > > ^ > > > > > + echo need root privileges >&2 > > > + exit 1 > > > +fi > > > + > > > +trap 'error_notify $?' EXIT > > > + > > > +echo check if rdomains are busy > > > +for n in ${RDOMAINS}; do > > > + if /sbin/ifconfig | grep -v "^lo${n}:" | grep " rdomain ${n} "; then > > > + echo routing domain ${n} is already used >&2 > > > + exit 1 > > > + fi > > > +done > > > + > > > +echo check if interfaces are busy > > > +for n in ${PAIRS}; do > > > + /sbin/ifconfig "${n}" >/dev/null 2>&1 && \ > > > + ( echo interface ${n} is already used >&2; exit 1 ) > > > +done > > > + > > > +set -x > > > + > > > +echo setup > > > +ifconfig ${PAIR1} inet6 rdomain ${RDOMAIN1} ${PAIR1IP}/64 up > > > +ifconfig ${PAIR2} inet6 rdomain ${RDOMAIN2} ${PAIR2IP}/64 up > > > +ifconfig ${PAIR1} patch ${PAIR2} > > > +ifconfig lo${RDOMAIN1} inet 127.0.0.1/8 > > > +ifconfig lo${RDOMAIN2} inet 127.0.0.1/8 > > > +ifconfig vether${RDOMAIN1} inet6 rdomain ${RDOMAIN1} ${PAIR1PREFIX}/64 up > > > +ifconfig vether${RDOMAIN2} inet6 rdomain ${RDOMAIN2} ${PAIR2PREFIX}/64 up > > > +ifconfig vether${RDOMAIN2} inet6 rdomain ${RDOMAIN2} ${PAIR2PREFIX2}/64 > > > up > > > +sed "s/{RDOMAIN1}/${RDOMAIN1}/g;s/{PAIR1}/${PAIR1}/g" \ > > > +ospf6d.network_statement.rdomain1.conf > ospf6d.1.conf > > > +chmod 0600 ospf6d.1.conf > > > +sed "s/{RDOMAIN2}/${RDOMAIN2}/g;s/{PAIR2}/${PAIR2}/g" \ > > > +ospf6d.network_statement.rdomain2.conf > ospf6d.2.conf > > > +chmod 0600 ospf6d.2.conf > >^ > > > > > + > > > +echo add routes > > > +route -T ${RDOMAIN2} add -inet6 default ${PAIR2PREFIX}1 > > > +route -T ${RDOMAIN2} add 2001:db8:::/126 ${PAIR2PREFIX}2 > > > +route -T ${RDOMAIN2} add 2001:db8:fffe::/64 ${PAIR2PREFIX}3 -label toOSPF > > > + > > > +echo start ospf6d > > > +route -T ${RDOMAIN1} exec ${OSPF6D} \ > > > +-v -f ${OSPF6DCONFIGDIR}/ospf6d.1.conf > > > +route -T ${RDOMAIN2} exec ${OSPF6D} \ > > > +-v -f ${OSPF6DCONFIGDIR}/ospf6d.2.conf > > > + > > > +sleep 120 > > > + > > > +echo tests > > > +route -T ${RDOMAIN1} exec ospf6ctl sh fib > > > +route -T ${RDOMAIN1} exec ospf6ctl sh rib | \ > > > +grep ${PAIR2PREFIX}/64 > > > +route -T ${RDOMAIN1} exec os
Re: ospf6d: add basic regress tests
On Mon, Dec 23, 2019 at 03:24:31PM +0100, Remi Locherer wrote: > On Sun, Dec 22, 2019 at 08:36:41PM +0100, Denis Fondras wrote: > > Add basic regress test to ospf6d. > > Works for me. OK remi@ > > The tests also succeed when I reduce the sleep from 120 to 60. > A few lines end with a space. I marked them below. I would suggest to minimize hold times etc. and reduce the timeout as much as possible. Regress test should not wait uneccessary long. > > > > Index: ospf6d/Makefile > > === > > RCS file: ospf6d/Makefile > > diff -N ospf6d/Makefile > > --- /dev/null 1 Jan 1970 00:00:00 - > > +++ ospf6d/Makefile 22 Dec 2019 19:27:27 - > > @@ -0,0 +1,10 @@ > > +# $OpenBSD$ > > + > > +REGRESS_TARGETS= network_statement > > + > > +OSPF6D ?= /usr/sbin/ospf6d > > + > > +network_statement: > > + ${SUDO} ksh ${.CURDIR}/$@.sh ${OSPF6D} ${.CURDIR} 11 12 pair11 pair12 > > + > > +.include > > Index: ospf6d/network_statement.sh > > === > > RCS file: ospf6d/network_statement.sh > > diff -N ospf6d/network_statement.sh > > --- /dev/null 1 Jan 1970 00:00:00 - > > +++ ospf6d/network_statement.sh 22 Dec 2019 19:27:27 - > > @@ -0,0 +1,107 @@ > > +#!/bin/ksh > > +# $OpenBSD$ > > +set -e > > + > > +OSPF6D=$1 > > +OSPF6DCONFIGDIR=$2 > > +RDOMAIN1=$3 > > +RDOMAIN2=$4 > > +PAIR1=$5 > > +PAIR2=$6 > > + > > +RDOMAINS="${RDOMAIN1} ${RDOMAIN2}" > > +PAIRS="${PAIR1} ${PAIR2}" > > +PAIR1IP=2001:db8::${RDOMAIN1} > > +PAIR2IP=2001:db8::${RDOMAIN2} > > +PAIR1PREFIX=2001:db8:${RDOMAIN1}:: > > +PAIR2PREFIX=2001:db8:${RDOMAIN2}:: > > +PAIR2PREFIX2=2001:db8:${RDOMAIN2}:${RDOMAIN2}:: > > + > > +error_notify() { > > + echo cleanup > > + pkill -T ${RDOMAIN1} ospf6d || true > > + pkill -T ${RDOMAIN2} ospf6d || true > > + sleep 1 > > + ifconfig ${PAIR2} destroy || true > > + ifconfig ${PAIR1} destroy || true > > + ifconfig vether${RDOMAIN1} destroy || true > > + ifconfig vether${RDOMAIN2} destroy || true > > + route -qn -T ${RDOMAIN1} flush || true > > + route -qn -T ${RDOMAIN2} flush || true > > + ifconfig lo${RDOMAIN1} destroy || true > > + ifconfig lo${RDOMAIN2} destroy || true > > + rm ospf6d.1.conf ospf6d.2.conf > > + if [ $1 -ne 0 ]; then > > + echo FAILED > > + exit 1 > > + else > > + echo SUCCESS > > + fi > > +} > > + > > +if [ "$(id -u)" -ne 0 ]; then > ^ > > > + echo need root privileges >&2 > > + exit 1 > > +fi > > + > > +trap 'error_notify $?' EXIT > > + > > +echo check if rdomains are busy > > +for n in ${RDOMAINS}; do > > + if /sbin/ifconfig | grep -v "^lo${n}:" | grep " rdomain ${n} "; then > > + echo routing domain ${n} is already used >&2 > > + exit 1 > > + fi > > +done > > + > > +echo check if interfaces are busy > > +for n in ${PAIRS}; do > > + /sbin/ifconfig "${n}" >/dev/null 2>&1 && \ > > + ( echo interface ${n} is already used >&2; exit 1 ) > > +done > > + > > +set -x > > + > > +echo setup > > +ifconfig ${PAIR1} inet6 rdomain ${RDOMAIN1} ${PAIR1IP}/64 up > > +ifconfig ${PAIR2} inet6 rdomain ${RDOMAIN2} ${PAIR2IP}/64 up > > +ifconfig ${PAIR1} patch ${PAIR2} > > +ifconfig lo${RDOMAIN1} inet 127.0.0.1/8 > > +ifconfig lo${RDOMAIN2} inet 127.0.0.1/8 > > +ifconfig vether${RDOMAIN1} inet6 rdomain ${RDOMAIN1} ${PAIR1PREFIX}/64 up > > +ifconfig vether${RDOMAIN2} inet6 rdomain ${RDOMAIN2} ${PAIR2PREFIX}/64 up > > +ifconfig vether${RDOMAIN2} inet6 rdomain ${RDOMAIN2} ${PAIR2PREFIX2}/64 up > > +sed "s/{RDOMAIN1}/${RDOMAIN1}/g;s/{PAIR1}/${PAIR1}/g" \ > > +ospf6d.network_statement.rdomain1.conf > ospf6d.1.conf > > +chmod 0600 ospf6d.1.conf > > +sed "s/{RDOMAIN2}/${RDOMAIN2}/g;s/{PAIR2}/${PAIR2}/g" \ > > +ospf6d.network_statement.rdomain2.conf > ospf6d.2.conf > > +chmod 0600 ospf6d.2.conf >^ > > > + > > +echo add routes > > +route -T ${RDOMAIN2} add -inet6 default ${PAIR2PREFIX}1 > > +route -T ${RDOMAIN2} add 2001:db8:::/126 ${PAIR2PREFIX}2 > > +route -T ${RDOMAIN2} add 2001:db8:fffe::/64 ${PAIR2PREFIX}3 -label toOSPF > > + > > +echo start ospf6d > > +route -T ${RDOMAIN1} exec ${OSPF6D} \ > > +-v -f ${OSPF6DCONFIGDIR}/ospf6d.1.conf > > +route -T ${RDOMAIN2} exec ${OSPF6D} \ > > +-v -f ${OSPF6DCONFIGDIR}/ospf6d.2.conf > > + > > +sleep 120 > > + > > +echo tests > > +route -T ${RDOMAIN1} exec ospf6ctl sh fib > > +route -T ${RDOMAIN1} exec ospf6ctl sh rib | \ > > +grep ${PAIR2PREFIX}/64 > > +route -T ${RDOMAIN1} exec ospf6ctl sh rib | \ > > +grep ${PAIR2PREFIX2}/64 > > +route -T ${RDOMAIN1} exec ospf6ctl sh rib | \ > > +grep "2001:db8:::/126" > > +route -T ${RDOMAIN1} exec ospf6ctl sh rib | \ > > +grep "::/0" > > +route -T ${RDOMAIN1} exec ospf6ctl sh rib | \ > > +grep "2001:db8:fffe::/64" > > + > > +exit 0 > > Index: ospf6d/ospf6d.network_statement.rdomain1.co
Re: ospf6d: add basic regress tests
On Sun, Dec 22, 2019 at 08:36:41PM +0100, Denis Fondras wrote: > Add basic regress test to ospf6d. Works for me. OK remi@ The tests also succeed when I reduce the sleep from 120 to 60. A few lines end with a space. I marked them below. Remi > > Index: ospf6d/Makefile > === > RCS file: ospf6d/Makefile > diff -N ospf6d/Makefile > --- /dev/null 1 Jan 1970 00:00:00 - > +++ ospf6d/Makefile 22 Dec 2019 19:27:27 - > @@ -0,0 +1,10 @@ > +# $OpenBSD$ > + > +REGRESS_TARGETS = network_statement > + > +OSPF6D ?=/usr/sbin/ospf6d > + > +network_statement: > + ${SUDO} ksh ${.CURDIR}/$@.sh ${OSPF6D} ${.CURDIR} 11 12 pair11 pair12 > + > +.include > Index: ospf6d/network_statement.sh > === > RCS file: ospf6d/network_statement.sh > diff -N ospf6d/network_statement.sh > --- /dev/null 1 Jan 1970 00:00:00 - > +++ ospf6d/network_statement.sh 22 Dec 2019 19:27:27 - > @@ -0,0 +1,107 @@ > +#!/bin/ksh > +#$OpenBSD$ > +set -e > + > +OSPF6D=$1 > +OSPF6DCONFIGDIR=$2 > +RDOMAIN1=$3 > +RDOMAIN2=$4 > +PAIR1=$5 > +PAIR2=$6 > + > +RDOMAINS="${RDOMAIN1} ${RDOMAIN2}" > +PAIRS="${PAIR1} ${PAIR2}" > +PAIR1IP=2001:db8::${RDOMAIN1} > +PAIR2IP=2001:db8::${RDOMAIN2} > +PAIR1PREFIX=2001:db8:${RDOMAIN1}:: > +PAIR2PREFIX=2001:db8:${RDOMAIN2}:: > +PAIR2PREFIX2=2001:db8:${RDOMAIN2}:${RDOMAIN2}:: > + > +error_notify() { > + echo cleanup > + pkill -T ${RDOMAIN1} ospf6d || true > + pkill -T ${RDOMAIN2} ospf6d || true > + sleep 1 > + ifconfig ${PAIR2} destroy || true > + ifconfig ${PAIR1} destroy || true > + ifconfig vether${RDOMAIN1} destroy || true > + ifconfig vether${RDOMAIN2} destroy || true > + route -qn -T ${RDOMAIN1} flush || true > + route -qn -T ${RDOMAIN2} flush || true > + ifconfig lo${RDOMAIN1} destroy || true > + ifconfig lo${RDOMAIN2} destroy || true > + rm ospf6d.1.conf ospf6d.2.conf > + if [ $1 -ne 0 ]; then > + echo FAILED > + exit 1 > + else > + echo SUCCESS > + fi > +} > + > +if [ "$(id -u)" -ne 0 ]; then ^ > + echo need root privileges >&2 > + exit 1 > +fi > + > +trap 'error_notify $?' EXIT > + > +echo check if rdomains are busy > +for n in ${RDOMAINS}; do > + if /sbin/ifconfig | grep -v "^lo${n}:" | grep " rdomain ${n} "; then > + echo routing domain ${n} is already used >&2 > + exit 1 > + fi > +done > + > +echo check if interfaces are busy > +for n in ${PAIRS}; do > + /sbin/ifconfig "${n}" >/dev/null 2>&1 && \ > + ( echo interface ${n} is already used >&2; exit 1 ) > +done > + > +set -x > + > +echo setup > +ifconfig ${PAIR1} inet6 rdomain ${RDOMAIN1} ${PAIR1IP}/64 up > +ifconfig ${PAIR2} inet6 rdomain ${RDOMAIN2} ${PAIR2IP}/64 up > +ifconfig ${PAIR1} patch ${PAIR2} > +ifconfig lo${RDOMAIN1} inet 127.0.0.1/8 > +ifconfig lo${RDOMAIN2} inet 127.0.0.1/8 > +ifconfig vether${RDOMAIN1} inet6 rdomain ${RDOMAIN1} ${PAIR1PREFIX}/64 up > +ifconfig vether${RDOMAIN2} inet6 rdomain ${RDOMAIN2} ${PAIR2PREFIX}/64 up > +ifconfig vether${RDOMAIN2} inet6 rdomain ${RDOMAIN2} ${PAIR2PREFIX2}/64 up > +sed "s/{RDOMAIN1}/${RDOMAIN1}/g;s/{PAIR1}/${PAIR1}/g" \ > +ospf6d.network_statement.rdomain1.conf > ospf6d.1.conf > +chmod 0600 ospf6d.1.conf > +sed "s/{RDOMAIN2}/${RDOMAIN2}/g;s/{PAIR2}/${PAIR2}/g" \ > +ospf6d.network_statement.rdomain2.conf > ospf6d.2.conf > +chmod 0600 ospf6d.2.conf ^ > + > +echo add routes > +route -T ${RDOMAIN2} add -inet6 default ${PAIR2PREFIX}1 > +route -T ${RDOMAIN2} add 2001:db8:::/126 ${PAIR2PREFIX}2 > +route -T ${RDOMAIN2} add 2001:db8:fffe::/64 ${PAIR2PREFIX}3 -label toOSPF > + > +echo start ospf6d > +route -T ${RDOMAIN1} exec ${OSPF6D} \ > +-v -f ${OSPF6DCONFIGDIR}/ospf6d.1.conf > +route -T ${RDOMAIN2} exec ${OSPF6D} \ > +-v -f ${OSPF6DCONFIGDIR}/ospf6d.2.conf > + > +sleep 120 > + > +echo tests > +route -T ${RDOMAIN1} exec ospf6ctl sh fib > +route -T ${RDOMAIN1} exec ospf6ctl sh rib | \ > +grep ${PAIR2PREFIX}/64 > +route -T ${RDOMAIN1} exec ospf6ctl sh rib | \ > +grep ${PAIR2PREFIX2}/64 > +route -T ${RDOMAIN1} exec ospf6ctl sh rib | \ > +grep "2001:db8:::/126" > +route -T ${RDOMAIN1} exec ospf6ctl sh rib | \ > +grep "::/0" > +route -T ${RDOMAIN1} exec ospf6ctl sh rib | \ > +grep "2001:db8:fffe::/64" > + > +exit 0 > Index: ospf6d/ospf6d.network_statement.rdomain1.conf > === > RCS file: ospf6d/ospf6d.network_statement.rdomain1.conf > diff -N ospf6d/ospf6d.network_statement.rdomain1.conf > --- /dev/null 1 Jan 1970 00:00:00 - > +++ ospf6d/ospf6d.network_statement.rdomain1.conf 22 Dec 2019 19:27:27 > - > @@ -0,0 +1,10 @@ > +router-id 1.1.1.1 > +rdomain {RDOMAIN1} > + > +fib-priority 62 > + > +area 10.0.0.1 { > +
Re: attention please: host's IP stack behavior got changed slightly
On Mon, Dec 23, 2019 at 12:10:36AM +0100, Alexandr Nedvedicky wrote: > diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c > index 058b2f038fa..f4114f45045 100644 > --- a/sys/netinet/ip_input.c > +++ b/sys/netinet/ip_input.c > @@ -753,7 +753,8 @@ in_ouraddr(struct mbuf *m, struct ifnet *ifp, struct > rtentry **prt) > } > } > } else if (ipforwarding == 0 && rt->rt_ifidx != ifp->if_index && > - !((ifp->if_flags & IFF_LOOPBACK) || (ifp->if_type == IFT_ENC))) { > + !((ifp->if_flags & IFF_LOOPBACK) || (ifp->if_type == IFT_ENC) || > + (m->m_pkthdr.pf.flags & PF_TAG_TRANSLATE_LOCALHOST))) { This line should be indented 4 spaces to the left. > /* received on wrong interface. */ > #if NCARP > 0 > struct ifnet *out_if; > diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c > index 5404d7ccfb4..62e92d9c46c 100644 > --- a/sys/netinet6/ip6_input.c > +++ b/sys/netinet6/ip6_input.c > @@ -435,7 +435,8 @@ ip6_input_if(struct mbuf **mp, int *offp, int nxt, int > af, struct ifnet *ifp) > > if (ip6_forwarding == 0 && rt->rt_ifidx != ifp->if_index && > !((ifp->if_flags & IFF_LOOPBACK) || > - (ifp->if_type == IFT_ENC))) { > + (ifp->if_type == IFT_ENC)) || > + (m->m_pkthdr.pf.flags & PF_TAG_TRANSLATE_LOCALHOST)) { > /* received on wrong interface */ > #if NCARP > 0 > struct ifnet *out_if; > OK bluhm@
Re: ospf6d: warn when a neighbor changes its source address
On Sun, Dec 22, 2019 at 10:32:12PM +0100, Denis Fondras wrote: > On Sun, Dec 22, 2019 at 10:06:40PM +0100, Remi Locherer wrote: > > this is similar to ospfd's hello.c rev 1.23. > > > > OK? > > > > Remi > > > > > > Index: hello.c > > === > > RCS file: /cvs/src/usr.sbin/ospf6d/hello.c,v > > retrieving revision 1.19 > > diff -u -p -r1.19 hello.c > > --- hello.c 11 Dec 2019 21:33:56 - 1.19 > > +++ hello.c 22 Dec 2019 20:46:01 - > > @@ -173,10 +173,16 @@ recv_hello(struct iface *iface, struct i > > nbr->dr.s_addr = hello.d_rtr; > > nbr->bdr.s_addr = hello.bd_rtr; > > nbr->priority = LSA_24_GETHI(ntohl(hello.opts)); > > + /* XXX neighbor address shouldn't be stored on virtual links */ > > + nbr->addr = *src; > > + } > > + > > + if (memcmp(&nbr->addr, src, sizeof(struct in6_addr)) != 0) { > > Can you use IN6_ARE_ADDR_EQUAL() macro instead of memcmp() to be consistent > with > other address comparison ? Yes, that makes sense. Thank you! > Otherwise OK denis@ > > > + log_warnx("%s: neighbor ID %s changed its address to %s", > > + __func__, inet_ntoa(nbr->id), log_in6addr(src)); > > + nbr->addr = *src; > > } > > > > - /* actually the neighbor address shouldn't be stored on virtual links */ > > - nbr->addr = *src; > > nbr->options = opts; > > > > nbr_fsm(nbr, NBR_EVT_HELLO_RCVD); > > >