Re: Stream Control Transmission Protocol SCTP RFC4960
On Thu, May 23, 2019 at 19:50 Denis wrote: > > SCTP(4) present in FreeBSD 12.0 > > OpenBSD implementation planned? Nothing planned as far as I know. Out of curiosity - what is your use case? Do you really use it? It doesn’t seem to be a widely used protocol. Kind regards, Job
Re: cp(1) add -l hard link -s symlink options
On Thu, May 23, 2019 at 10:21:34PM +0100, Stuart Henderson wrote: > On 2019/05/23 22:58, Ingo Schwarze wrote: > > Hi Tracey, > > > > Tracey Emery wrote on Thu, May 23, 2019 at 02:35:10PM -0600: > > > > > Attached is a proposed diff for cp(1). It adds the -l (hard link) > > > and -s (symlink) options. > > > > I don't like that. That's exactly what can be done with ln(1) in a > > standard way. There is no value in making every tool do everything - > > quite to that contrary, that only causes gratuitous complication and > > confusion. > > It can be done, but I think the main point of this cp(1) option is that > it works with -r. You can also do that with a combination of ln(1) and > find(1), but it's more awkward, and there's potentially a lot of fork > overhead if copying a deep tree. > > > > These options are available in GNU cp, FreeBSD cp, > > > and the -l option is at least in NetBSD and Dragonfly. > > > > > > I needed the -l option to use the system cp for rsnapshots, instead of > > > their native_cl_al function. Hopefully, this will speed up my backups. > > > > If the rsnapshots uses such options, i think you should send patches > > to the rsnapshots project instead. Tell them to use POSIX features > > instead of relying on pointless GNUisms. > > I don't use rsnapshot but from a quick glance it appears to be a non- > default option that they only suggest using on Linux. (Rather than > modifying /bin/cp, an alternative would be to install coreutils and > point it at gcp). Ah, good idea on gcp, Stuart. Thanks. I wanted to explore the non-native_cp_al option for speed gains. I'll test the gcp route. Hadn't thought that far ahead!
Re: cp(1) add -l hard link -s symlink options
On 2019/05/23 22:58, Ingo Schwarze wrote: > Hi Tracey, > > Tracey Emery wrote on Thu, May 23, 2019 at 02:35:10PM -0600: > > > Attached is a proposed diff for cp(1). It adds the -l (hard link) > > and -s (symlink) options. > > I don't like that. That's exactly what can be done with ln(1) in a > standard way. There is no value in making every tool do everything - > quite to that contrary, that only causes gratuitous complication and > confusion. It can be done, but I think the main point of this cp(1) option is that it works with -r. You can also do that with a combination of ln(1) and find(1), but it's more awkward, and there's potentially a lot of fork overhead if copying a deep tree. > > These options are available in GNU cp, FreeBSD cp, > > and the -l option is at least in NetBSD and Dragonfly. > > > > I needed the -l option to use the system cp for rsnapshots, instead of > > their native_cl_al function. Hopefully, this will speed up my backups. > > If the rsnapshots uses such options, i think you should send patches > to the rsnapshots project instead. Tell them to use POSIX features > instead of relying on pointless GNUisms. I don't use rsnapshot but from a quick glance it appears to be a non- default option that they only suggest using on Linux. (Rather than modifying /bin/cp, an alternative would be to install coreutils and point it at gcp).
Re: New implementation and interface for strlcpy and strlcat
On Thu, 23 May 2019 17:21:19 +0700, Oleg Chumanov wrote: > First of all, > I do not understand why the interface (the return value of these functions) i > s so different. They both do almost the same thing. > > I do not understand, why the return value is the length of source or the sum > of lengths. I think, it is useless. Because having the required length makes it easier to perform error recovery in the caller. For example, the caller may wish to reallocate the buffer and retry. It is also similar to the return value of snprintf(3). There is a common pattern in code similar to this: strcpy(buf, str1); strcat(buf, str2); len = strlen(buf); By returning the sum of the lengths you no longer need to compute the length. E.g. len = strlcpy(buf, str1, sizeof(buf)); if (len >= sizeof(buf)) goto error; len = strlcat(buf, str2, sizeof(buf)); if (len >= sizeof(buf)) goto error; > if we will return the number of truncated characters, it gives us more inform > ation, besides it gives us the better interface: > if return value is zero, everything is OK; otherwise truncation happened. It > is easier and more useful to use, for example: > > if (strlcpy(dst, src, dsize)) > /* truncation, do something*/ > > OR > > size_t n; > if ((n = strlcpy(dst, src, dsize))) > /* if you want to know how many chars you lost exactly */ That would make it a bit harder to do error recovery since you'd need to compute the required length. One of the reasons for strlcpy/strlcat was to avoid needing to compute lengths since that is often a source of bugs. In any event, the strlcpy/strlcat interface has been around for over 20 years now. You can't change an API like that without breaking all the code that uses it. - todd
Re: cp(1) add -l hard link -s symlink options
On Thu, May 23, 2019 at 10:58:15PM +0200, Ingo Schwarze wrote: > Hi Tracey, > > Tracey Emery wrote on Thu, May 23, 2019 at 02:35:10PM -0600: > > > Attached is a proposed diff for cp(1). It adds the -l (hard link) > > and -s (symlink) options. > > I don't like that. That's exactly what can be done with ln(1) in a > standard way. There is no value in making every tool do everything - > quite to that contrary, that only causes gratuitous complication and > confusion. > > > These options are available in GNU cp, FreeBSD cp, > > and the -l option is at least in NetBSD and Dragonfly. > > > > I needed the -l option to use the system cp for rsnapshots, instead of > > their native_cl_al function. Hopefully, this will speed up my backups. > > If the rsnapshots uses such options, i think you should send patches > to the rsnapshots project instead. Tell them to use POSIX features > instead of relying on pointless GNUisms. > > Yours, > Ingo Cool! Thanks. T
ospf6d: allow specifying area by number as well as id
Hi tech@, David sent a diff for ospfd which allows specifying an area by number as well as id. --> https://marc.info/?l=openbsd-tech&m=155650284619263&w=2 This diff does the same for ospf6d and ospf6ctl without modifying any outputs. OK? Remi Index: ospf6d/ospf6d.conf.5 === RCS file: /cvs/src/usr.sbin/ospf6d/ospf6d.conf.5,v retrieving revision 1.18 diff -u -p -r1.18 ospf6d.conf.5 --- ospf6d/ospf6d.conf.529 Dec 2018 16:04:31 - 1.18 +++ ospf6d/ospf6d.conf.522 May 2019 21:04:58 - @@ -237,7 +237,7 @@ Areas are used for grouping interfaces. All interface-specific parameters can be configured per area, overruling the global settings. .Bl -tag -width Ds -.It Ic area Ar address +.It Ic area Ar address Ns | Ns Ar id Specify an area section, grouping one or more interfaces. .Bd -literal -offset indent area 0.0.0.0 { Index: ospf6d/parse.y === RCS file: /cvs/src/usr.sbin/ospf6d/parse.y,v retrieving revision 1.43 diff -u -p -r1.43 parse.y --- ospf6d/parse.y 29 Apr 2019 05:14:38 - 1.43 +++ ospf6d/parse.y 22 May 2019 20:58:26 - @@ -117,6 +117,7 @@ typedef struct { int64_t number; char*string; struct redistribute *redist; + struct in_addr id; } v; int lineno; } YYSTYPE; @@ -139,6 +140,7 @@ typedef struct { %typeyesno no optlist, optlist_l option demotecount %typestring dependon %typeredistribute +%typeareaid %% @@ -456,15 +458,8 @@ comma : ',' | /*empty*/ ; -area : AREA STRING { - struct in_addr id; - if (inet_aton($2, &id) == 0) { - yyerror("error parsing area"); - free($2); - YYERROR; - } - free($2); - area = conf_get_area(id); +area : AREA areaid { + area = conf_get_area($2); memcpy(&areadefs, defs, sizeof(areadefs)); defs = &areadefs; @@ -476,6 +471,23 @@ area : AREA STRING { demotecount: NUMBER{ $$ = $1; } | /*empty*/ { $$ = 1; } + ; + +areaid : NUMBER { + if ($1 < 0 || $1 > 0x) { + yyerror("invalid area id"); + YYERROR; + } + $$.s_addr = htonl($1); + } + | STRING { + if (inet_aton($1, &$$) == 0) { + yyerror("error parsing area"); + free($1); + YYERROR; + } + free($1); + } ; areaopts_l : areaopts_l areaoptsl nl Index: ospf6ctl/ospf6ctl.c === RCS file: /cvs/src/usr.sbin/ospf6ctl/ospf6ctl.c,v retrieving revision 1.49 diff -u -p -r1.49 ospf6ctl.c --- ospf6ctl/ospf6ctl.c 12 Jul 2018 13:45:03 - 1.49 +++ ospf6ctl/ospf6ctl.c 22 May 2019 20:18:45 - @@ -170,7 +170,7 @@ main(int argc, char *argv[]) break; case SHOW_DBBYAREA: imsg_compose(ibuf, IMSG_CTL_SHOW_DATABASE, 0, 0, -1, - &res->addr, sizeof(res->addr)); + &res->area, sizeof(res->area)); break; case SHOW_DBEXT: imsg_compose(ibuf, IMSG_CTL_SHOW_DB_EXT, 0, 0, -1, NULL, 0); Index: ospf6ctl/parser.c === RCS file: /cvs/src/usr.sbin/ospf6ctl/parser.c,v retrieving revision 1.13 diff -u -p -r1.13 parser.c --- ospf6ctl/parser.c 17 Nov 2014 21:53:55 - 1.13 +++ ospf6ctl/parser.c 22 May 2019 20:20:17 - @@ -40,7 +40,8 @@ enum token_type { ADDRESS, FLAG, PREFIX, - IFNAME + IFNAME, + AREA }; struct token { @@ -108,7 +109,7 @@ static const struct token t_show_db[] = }; static const struct token t_show_area[] = { - {ADDRESS, "", NONE, NULL}, + {AREA, "", NONE, NULL}, {ENDTOKEN, "", NONE, NULL} }; @@ -218,6 +219,14 @@ match_token(const char *word, const stru res->action = t->value; } break; + case AREA: + if (parse_area(word, &res->area)) { + match++; + t = &table[i]; +
Re: cp(1) add -l hard link -s symlink options
Hi Tracey, Tracey Emery wrote on Thu, May 23, 2019 at 02:35:10PM -0600: > Attached is a proposed diff for cp(1). It adds the -l (hard link) > and -s (symlink) options. I don't like that. That's exactly what can be done with ln(1) in a standard way. There is no value in making every tool do everything - quite to that contrary, that only causes gratuitous complication and confusion. > These options are available in GNU cp, FreeBSD cp, > and the -l option is at least in NetBSD and Dragonfly. > > I needed the -l option to use the system cp for rsnapshots, instead of > their native_cl_al function. Hopefully, this will speed up my backups. If the rsnapshots uses such options, i think you should send patches to the rsnapshots project instead. Tell them to use POSIX features instead of relying on pointless GNUisms. Yours, Ingo
Re: cp(1) add -l hard link -s symlink options
On Thu, May 23, 2019 at 02:35:10PM -0600, Tracey Emery wrote: > Hello tech@, > > Attached is a proposed diff for cp(1). It adds the -l (hard link) and -s > (symlink) options. These options are available in GNU cp, FreeBSD cp, > and the -l option is at least in NetBSD and Dragonfly. > > I needed the -l option to use the system cp for rsnapshots, instead of > their native_cl_al function. Hopefully, this will speed up my backups. > > Thanks for your consideration, > Tracey > > > Index: bin/cp/cp.1 > === > RCS file: /cvs/src/bin/cp/cp.1,v > retrieving revision 1.40 > diff -u -p -u -r1.40 cp.1 > --- bin/cp/cp.1 28 Jan 2019 18:58:42 - 1.40 > +++ bin/cp/cp.1 23 May 2019 20:28:29 - > @@ -103,6 +103,8 @@ The > option overrides any previous > .Fl f > options. > +.It Fl l > +Create hard links to regular files in a hierarchy instead of copying. > .It Fl L > If the > .Fl R > @@ -128,6 +130,8 @@ If the source file has both its set-user > and either the user ID or group ID cannot be preserved, neither > the set-user-ID nor set-group-ID bits are preserved in the copy's > permissions. > +.It Fl s > +Create symbolic links to regular files in a hirarcy instead of copying. > .It Fl R > If > .Ar source > Index: bin/cp/cp.c > === > RCS file: /cvs/src/bin/cp/cp.c,v > retrieving revision 1.52 > diff -u -p -u -r1.52 cp.c > --- bin/cp/cp.c 28 Jan 2019 18:58:42 - 1.52 > +++ bin/cp/cp.c 23 May 2019 20:28:30 - > @@ -71,7 +71,7 @@ > PATH_T to = { to.p_path, "" }; > > uid_t myuid; > -int Rflag, fflag, iflag, pflag, rflag, vflag; > +int Rflag, fflag, iflag, lflag, pflag, rflag, sflag, vflag; > mode_t myumask; > > enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE }; > @@ -88,7 +88,7 @@ main(int argc, char *argv[]) > char *target; > > Hflag = Lflag = Pflag = Rflag = 0; > - while ((ch = getopt(argc, argv, "HLPRafiprv")) != -1) > + while ((ch = getopt(argc, argv, "HLPRafiprvls")) != -1) > switch (ch) { > case 'H': > Hflag = 1; > @@ -119,12 +119,18 @@ main(int argc, char *argv[]) > iflag = 1; > fflag = 0; > break; > + case 'l': > + lflag = 1; > + break; > case 'p': > pflag = 1; > break; > case 'r': > rflag = 1; > break; > + case 's': > + sflag = 1; > + break; > case 'v': > vflag = 1; > break; > @@ -157,6 +163,8 @@ main(int argc, char *argv[]) > fts_options &= ~FTS_PHYSICAL; > fts_options |= FTS_LOGICAL; > } > + if (lflag && sflag) > + errx(1, "the -l and -s options may not be specified together."); > if (Rflag) { > if (Hflag) > fts_options |= FTS_COMFOLLOW; > @@ -319,7 +327,7 @@ copy(char *argv[], enum op type, int fts > if (type != DIR_TO_DNE) { > p = find_last_component(curr->fts_path); > base = p - curr->fts_path; > - > + > if (!strcmp(&curr->fts_path[base], > "..")) > base += 1; > @@ -435,7 +443,7 @@ copy(char *argv[], enum op type, int fts > break; > case S_IFBLK: > case S_IFCHR: > - if (Rflag) { > + if (Rflag && !sflag) { > if ((cval = copy_special(curr->fts_statp, > !fts_dne(curr))) == 1) > rval = 1; > @@ -448,7 +456,7 @@ copy(char *argv[], enum op type, int fts > cval = 0; > break; > case S_IFIFO: > - if (Rflag) { > + if (Rflag && !sflag) { > if ((cval = copy_fifo(curr->fts_statp, > !fts_dne(curr))) == 1) > rval = 1; > Index: bin/cp/extern.h > === > RCS file: /cvs/src/bin/cp/extern.h,v > retrieving revision 1.15 > diff -u -p -u -r1.15 extern.h > --- bin/cp/extern.h 26 Dec 2015 18:11:43 - 1.15 > +++ bin/cp/extern.h 23 May 2019 20:28:30 - > @@ -40,7 +40,7 @@ typedef struct { > > extern PATH_T to; > extern uid_t myuid; > -extern int fflag, iflag, pflag; > +extern int fflag, iflag, lflag, pflag, sflag; > extern
cp(1) add -l hard link -s symlink options
Hello tech@, Attached is a proposed diff for cp(1). It adds the -l (hard link) and -s (symlink) options. These options are available in GNU cp, FreeBSD cp, and the -l option is at least in NetBSD and Dragonfly. I needed the -l option to use the system cp for rsnapshots, instead of their native_cl_al function. Hopefully, this will speed up my backups. Thanks for your consideration, Tracey Index: bin/cp/cp.1 === RCS file: /cvs/src/bin/cp/cp.1,v retrieving revision 1.40 diff -u -p -u -r1.40 cp.1 --- bin/cp/cp.1 28 Jan 2019 18:58:42 - 1.40 +++ bin/cp/cp.1 23 May 2019 20:28:29 - @@ -103,6 +103,8 @@ The option overrides any previous .Fl f options. +.It Fl l +Create hard links to regular files in a hierarchy instead of copying. .It Fl L If the .Fl R @@ -128,6 +130,8 @@ If the source file has both its set-user and either the user ID or group ID cannot be preserved, neither the set-user-ID nor set-group-ID bits are preserved in the copy's permissions. +.It Fl s +Create symbolic links to regular files in a hirarcy instead of copying. .It Fl R If .Ar source Index: bin/cp/cp.c === RCS file: /cvs/src/bin/cp/cp.c,v retrieving revision 1.52 diff -u -p -u -r1.52 cp.c --- bin/cp/cp.c 28 Jan 2019 18:58:42 - 1.52 +++ bin/cp/cp.c 23 May 2019 20:28:30 - @@ -71,7 +71,7 @@ PATH_T to = { to.p_path, "" }; uid_t myuid; -int Rflag, fflag, iflag, pflag, rflag, vflag; +int Rflag, fflag, iflag, lflag, pflag, rflag, sflag, vflag; mode_t myumask; enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE }; @@ -88,7 +88,7 @@ main(int argc, char *argv[]) char *target; Hflag = Lflag = Pflag = Rflag = 0; - while ((ch = getopt(argc, argv, "HLPRafiprv")) != -1) + while ((ch = getopt(argc, argv, "HLPRafiprvls")) != -1) switch (ch) { case 'H': Hflag = 1; @@ -119,12 +119,18 @@ main(int argc, char *argv[]) iflag = 1; fflag = 0; break; + case 'l': + lflag = 1; + break; case 'p': pflag = 1; break; case 'r': rflag = 1; break; + case 's': + sflag = 1; + break; case 'v': vflag = 1; break; @@ -157,6 +163,8 @@ main(int argc, char *argv[]) fts_options &= ~FTS_PHYSICAL; fts_options |= FTS_LOGICAL; } + if (lflag && sflag) + errx(1, "the -l and -s options may not be specified together."); if (Rflag) { if (Hflag) fts_options |= FTS_COMFOLLOW; @@ -319,7 +327,7 @@ copy(char *argv[], enum op type, int fts if (type != DIR_TO_DNE) { p = find_last_component(curr->fts_path); base = p - curr->fts_path; - + if (!strcmp(&curr->fts_path[base], "..")) base += 1; @@ -435,7 +443,7 @@ copy(char *argv[], enum op type, int fts break; case S_IFBLK: case S_IFCHR: - if (Rflag) { + if (Rflag && !sflag) { if ((cval = copy_special(curr->fts_statp, !fts_dne(curr))) == 1) rval = 1; @@ -448,7 +456,7 @@ copy(char *argv[], enum op type, int fts cval = 0; break; case S_IFIFO: - if (Rflag) { + if (Rflag && !sflag) { if ((cval = copy_fifo(curr->fts_statp, !fts_dne(curr))) == 1) rval = 1; Index: bin/cp/extern.h === RCS file: /cvs/src/bin/cp/extern.h,v retrieving revision 1.15 diff -u -p -u -r1.15 extern.h --- bin/cp/extern.h 26 Dec 2015 18:11:43 - 1.15 +++ bin/cp/extern.h 23 May 2019 20:28:30 - @@ -40,7 +40,7 @@ typedef struct { extern PATH_T to; extern uid_t myuid; -extern int fflag, iflag, pflag; +extern int fflag, iflag, lflag, pflag, sflag; extern mode_t myumask; extern char *__progname; Index: bin/cp/utils.c === RCS file: /cvs/src/bin/cp/utils.c,v retrieving revision 1.47 diff -u -p -u -r1.47 utils.c --- bin/c
Stream Control Transmission Protocol SCTP RFC4960
SCTP(4) present in FreeBSD 12.0 OpenBSD implementation planned?
Re: [PATCH] mg: {beginning,end}-of-buffer don't set marks in Emacs
> Note: I only wanted to point out something that bothered me. I'm not > using mg(1) these days and I don't plan to spend time on this issue. That’s pretty much the modern internet, summarized in two sentences
Re: [PATCH] mg: {beginning,end}-of-buffer don't set marks in Emacs
On Wed, May 22 2019, Jeremie Courreges-Anglas wrote: [...] > So if you're pushing for a change here we'd need a better explanation. Note: I only wanted to point out something that bothered me. I'm not using mg(1) these days and I don't plan to spend time on this issue. -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
Re: New implementation and interface for strlcpy and strlcat
On Thu, May 23, 2019 at 05:21:19PM +0700, Oleg Chumanov wrote: > Hi, there > > First of all, > I do not understand why the interface (the return value of these functions) > is so different. They both do almost the same thing. > > I do not understand, why the return value is the length of source or the sum > of lengths. I think, it is useless. > > if we will return the number of truncated characters, it gives us more > information, besides it gives us the better interface: > if return value is zero, everything is OK; otherwise truncation happened. It > is easier and more useful to use, for example: > > if (strlcpy(dst, src, dsize)) > /* truncation, do something*/ > > OR > > size_t n; > if ((n = strlcpy(dst, src, dsize))) > /* if you want to know how many chars you lost exactly */ > > So, all of this, we can apply to the strlcat. It is as it is. We cannot change the interface without breaking millions of lines of code. -Otto > diff --git lib/libc/string/strlcat.c lib/libc/string/strlcat.c > index aa3db7ab378..fb423cf562d 100644 > --- lib/libc/string/strlcat.c > +++ lib/libc/string/strlcat.c > @@ -23,34 +23,25 @@ > * Appends src to string dst of size dsize (unlike strncat, dsize is the > * full size of dst, not space left). At most dsize-1 characters > * will be copied. Always NUL terminates (unless dsize <= strlen(dst)). > - * Returns strlen(src) + MIN(dsize, strlen(initial dst)). > - * If retval >= dsize, truncation occurred. > + * Returns the number of truncated chars (See strlcpy). > + * If retval > 0, truncation occurred; if retval == 0, everything is OK. > + * > + * Example 1: > + * > + * if (strlcat(dst, src, dsize)) > + * puts("truncation"); > + * > + * Example 2: > + * > + * size_t n; > + * if ((n = strlcat(dst, src, dsize))) > + * printf("truncation: %lu %s\n", n, (n > 1 ? "chars" : "char")); > */ > size_t > strlcat(char *dst, const char *src, size_t dsize) > { > - const char *odst = dst; > - const char *osrc = src; > - size_t n = dsize; > - size_t dlen; > - > - /* Find the end of dst and adjust bytes left but don't go past end. */ > - while (n-- != 0 && *dst != '\0') > - dst++; > - dlen = dst - odst; > - n = dsize - dlen; > - > - if (n-- == 0) > - return(dlen + strlen(src)); > - while (*src != '\0') { > - if (n != 0) { > - *dst++ = *src; > - n--; > - } > - src++; > - } > - *dst = '\0'; > + for (; dsize != 0 && *dst != '\0'; ++dst, --dsize) { } > > - return(dlen + (src - osrc));/* count does not include NUL */ > + return (strlcpy(dst, src, dsize)); > } > DEF_WEAK(strlcat); > diff --git lib/libc/string/strlcpy.c lib/libc/string/strlcpy.c > index 7e3b9aef6f6..7d0ecc7f7cd 100644 > --- lib/libc/string/strlcpy.c > +++ lib/libc/string/strlcpy.c > @@ -22,30 +22,32 @@ > /* > * Copy string src to buffer dst of size dsize. At most dsize-1 > * chars will be copied. Always NUL terminates (unless dsize == 0). > - * Returns strlen(src); if retval >= dsize, truncation occurred. > + * Returns the number of truncated chars. > + * If retval > 0, truncation occurred; if retval == 0, everything is OK. > + * > + * Example 1: > + * > + * if (strlcpy(dst, src, dsize)) > + * puts("truncation"); > + * > + * Example 2: > + * > + * size_t n; > + * if ((n = strlcpy(dst, src, dsize))) > + * printf("truncation: %lu %s\n", n, (n > 1 ? "chars" : "char")); > */ > size_t > strlcpy(char *dst, const char *src, size_t dsize) > { > - const char *osrc = src; > - size_t nleft = dsize; > + const char *sbeg; > > - /* Copy as many bytes as will fit. */ > - if (nleft != 0) { > - while (--nleft != 0) { > - if ((*dst++ = *src++) == '\0') > + if (dsize != 0) > + for (dst[--dsize] = '\0'; dsize-- != 0; ++src) > + if ((*dst++ = *src) == '\0') > break; > - } > - } > > - /* Not enough room in dst, add NUL and traverse rest of src. */ > - if (nleft == 0) { > - if (dsize != 0) > - *dst = '\0';/* NUL-terminate dst */ > - while (*src++) > - ; > - } > + for (sbeg = src; *src != '\0'; ++src) { } > > - return(src - osrc - 1); /* count does not include NUL */ > + return (src - sbeg); > } > DEF_WEAK(strlcpy);
New implementation and interface for strlcpy and strlcat
Hi, there First of all, I do not understand why the interface (the return value of these functions) is so different. They both do almost the same thing. I do not understand, why the return value is the length of source or the sum of lengths. I think, it is useless. if we will return the number of truncated characters, it gives us more information, besides it gives us the better interface: if return value is zero, everything is OK; otherwise truncation happened. It is easier and more useful to use, for example: if (strlcpy(dst, src, dsize)) /* truncation, do something*/ OR size_t n; if ((n = strlcpy(dst, src, dsize))) /* if you want to know how many chars you lost exactly */ So, all of this, we can apply to the strlcat. diff --git lib/libc/string/strlcat.c lib/libc/string/strlcat.c index aa3db7ab378..fb423cf562d 100644 --- lib/libc/string/strlcat.c +++ lib/libc/string/strlcat.c @@ -23,34 +23,25 @@ * Appends src to string dst of size dsize (unlike strncat, dsize is the * full size of dst, not space left). At most dsize-1 characters * will be copied. Always NUL terminates (unless dsize <= strlen(dst)). - * Returns strlen(src) + MIN(dsize, strlen(initial dst)). - * If retval >= dsize, truncation occurred. + * Returns the number of truncated chars (See strlcpy). + * If retval > 0, truncation occurred; if retval == 0, everything is OK. + * + * Example 1: + * + * if (strlcat(dst, src, dsize)) + * puts("truncation"); + * + * Example 2: + * + * size_t n; + * if ((n = strlcat(dst, src, dsize))) + * printf("truncation: %lu %s\n", n, (n > 1 ? "chars" : "char")); */ size_t strlcat(char *dst, const char *src, size_t dsize) { - const char *odst = dst; - const char *osrc = src; - size_t n = dsize; - size_t dlen; - - /* Find the end of dst and adjust bytes left but don't go past end. */ - while (n-- != 0 && *dst != '\0') - dst++; - dlen = dst - odst; - n = dsize - dlen; - - if (n-- == 0) - return(dlen + strlen(src)); - while (*src != '\0') { - if (n != 0) { - *dst++ = *src; - n--; - } - src++; - } - *dst = '\0'; + for (; dsize != 0 && *dst != '\0'; ++dst, --dsize) { } - return(dlen + (src - osrc));/* count does not include NUL */ + return (strlcpy(dst, src, dsize)); } DEF_WEAK(strlcat); diff --git lib/libc/string/strlcpy.c lib/libc/string/strlcpy.c index 7e3b9aef6f6..7d0ecc7f7cd 100644 --- lib/libc/string/strlcpy.c +++ lib/libc/string/strlcpy.c @@ -22,30 +22,32 @@ /* * Copy string src to buffer dst of size dsize. At most dsize-1 * chars will be copied. Always NUL terminates (unless dsize == 0). - * Returns strlen(src); if retval >= dsize, truncation occurred. + * Returns the number of truncated chars. + * If retval > 0, truncation occurred; if retval == 0, everything is OK. + * + * Example 1: + * + * if (strlcpy(dst, src, dsize)) + * puts("truncation"); + * + * Example 2: + * + * size_t n; + * if ((n = strlcpy(dst, src, dsize))) + * printf("truncation: %lu %s\n", n, (n > 1 ? "chars" : "char")); */ size_t strlcpy(char *dst, const char *src, size_t dsize) { - const char *osrc = src; - size_t nleft = dsize; + const char *sbeg; - /* Copy as many bytes as will fit. */ - if (nleft != 0) { - while (--nleft != 0) { - if ((*dst++ = *src++) == '\0') + if (dsize != 0) + for (dst[--dsize] = '\0'; dsize-- != 0; ++src) + if ((*dst++ = *src) == '\0') break; - } - } - /* Not enough room in dst, add NUL and traverse rest of src. */ - if (nleft == 0) { - if (dsize != 0) - *dst = '\0';/* NUL-terminate dst */ - while (*src++) - ; - } + for (sbeg = src; *src != '\0'; ++src) { } - return(src - osrc - 1); /* count does not include NUL */ + return (src - sbeg); } DEF_WEAK(strlcpy);
Re: pledge(2) unbound-checkconf(8)
it must be one of those days... it's ok mestre if you feel like commiting it and doesn't add any burden for you when upgrading unbound. On 13:18 Thu 23 May , Stuart Henderson wrote: > check_mod(cfg, val_get_funcblock()); > > - needs to read the DNSSEC root key, > > check_hints(cfg); > > - needs to read hints files, > > check_auth(cfg); > > - needs to read zones > > I think you could do this, though: > > Index: smallapp/unbound-checkconf.c > === > RCS file: /cvs/src/usr.sbin/unbound/smallapp/unbound-checkconf.c,v > retrieving revision 1.11 > diff -u -p -r1.11 unbound-checkconf.c > --- smallapp/unbound-checkconf.c 8 Feb 2019 10:29:08 - 1.11 > +++ smallapp/unbound-checkconf.c 23 May 2019 12:17:03 - > @@ -587,6 +587,10 @@ morechecks(struct config_file* cfg) > endpwent(); > # endif > } > + > + if (pledge("stdio rpath", NULL) == -1) > + fatal_exit("Could not pledge"); > + > #endif > if(cfg->remote_control_enable && options_remote_is_address(cfg) > && cfg->control_use_cert) { > @@ -724,6 +728,10 @@ int main(int argc, char* argv[]) > if(argc == 1) > f = argv[0]; > elsef = cfgfile; > + > + if (pledge("stdio rpath getpw", NULL) == -1) > + fatal_exit("Could not pledge"); > + > checkconf(f, opt, final); > checklock_stop(); > return 0; >
Re: pledge(2) unbound-checkconf(8)
On 2019/05/23 11:54, Ricardo Mestre wrote: > bonkers my brain must have farted :\ rpath should be dropped after loading the > certs. I just tested it with remote-control with certificates, could you > please let me know if it works for you now? > > Index: unbound-checkconf.c > === > RCS file: /cvs/src/usr.sbin/unbound/smallapp/unbound-checkconf.c,v > retrieving revision 1.11 > diff -u -p -u -r1.11 unbound-checkconf.c > --- unbound-checkconf.c 8 Feb 2019 10:29:08 - 1.11 > +++ unbound-checkconf.c 23 May 2019 10:45:48 - > @@ -602,6 +602,9 @@ morechecks(struct config_file* cfg) > cfg->control_cert_file); > } > > + if (pledge("stdio", NULL) == -1) > + fatal_exit("Could not pledge"); > + > localzonechecks(cfg); > view_and_respipchecks(cfg); > #ifdef CLIENT_SUBNET > @@ -724,6 +727,10 @@ int main(int argc, char* argv[]) > if(argc == 1) > f = argv[0]; > elsef = cfgfile; > + > + if (pledge("stdio rpath getpw", NULL) == -1) > + fatal_exit("Could not pledge"); > + > checkconf(f, opt, final); > checklock_stop(); > return 0; > > On 10:29 Thu 23 May , Stuart Henderson wrote: > > Not ok - if you're using remote-control with certificates (for example, > > to control remote unbound instances over a network connection) it hits the > > following: > > > > unbound-checkcon[21086]: pledge "rpath", syscall 38 > > > > (gdb) bt > > #0 stat () at -:3 > > #1 0x04da8ddd61dc in is_file (fname=0x4dd11e9e3c0 > > "/var/unbound/etc/unbound_server.key") > > at /usr/src/usr.sbin/unbound/smallapp/unbound-checkconf.c:278 > > #2 0x04da8ddd5f10 in check_chroot_string (desc=0x4da8dda7c5d > > "server-key-file", ss=0x4dca3ee33d0, > > chrootdir=0x0, cfg=0x4dca3ee3000) at > > /usr/src/usr.sbin/unbound/smallapp/unbound-checkconf.c:335 > > #3 0x04da8ddd5114 in morechecks (cfg=0x4dca3ee3000) > > at /usr/src/usr.sbin/unbound/smallapp/unbound-checkconf.c:597 > > #4 0x04da8ddd4776 in checkconf (cfgfile=0x4da8dda9506 > > "/var/unbound/etc/unbound.conf", opt=0x0, final=0) > > at /usr/src/usr.sbin/unbound/smallapp/unbound-checkconf.c:674 > > #5 0x04da8ddd44e2 in main (argc=0, argv=0x7f7d1850) > > at /usr/src/usr.sbin/unbound/smallapp/unbound-checkconf.c:735 > > check_mod(cfg, val_get_funcblock()); - needs to read the DNSSEC root key, check_hints(cfg); - needs to read hints files, check_auth(cfg); - needs to read zones I think you could do this, though: Index: smallapp/unbound-checkconf.c === RCS file: /cvs/src/usr.sbin/unbound/smallapp/unbound-checkconf.c,v retrieving revision 1.11 diff -u -p -r1.11 unbound-checkconf.c --- smallapp/unbound-checkconf.c8 Feb 2019 10:29:08 - 1.11 +++ smallapp/unbound-checkconf.c23 May 2019 12:17:03 - @@ -587,6 +587,10 @@ morechecks(struct config_file* cfg) endpwent(); # endif } + + if (pledge("stdio rpath", NULL) == -1) + fatal_exit("Could not pledge"); + #endif if(cfg->remote_control_enable && options_remote_is_address(cfg) && cfg->control_use_cert) { @@ -724,6 +728,10 @@ int main(int argc, char* argv[]) if(argc == 1) f = argv[0]; elsef = cfgfile; + + if (pledge("stdio rpath getpw", NULL) == -1) + fatal_exit("Could not pledge"); + checkconf(f, opt, final); checklock_stop(); return 0;
Re: pledge(2) unbound-checkconf(8)
bonkers my brain must have farted :\ rpath should be dropped after loading the certs. I just tested it with remote-control with certificates, could you please let me know if it works for you now? Index: unbound-checkconf.c === RCS file: /cvs/src/usr.sbin/unbound/smallapp/unbound-checkconf.c,v retrieving revision 1.11 diff -u -p -u -r1.11 unbound-checkconf.c --- unbound-checkconf.c 8 Feb 2019 10:29:08 - 1.11 +++ unbound-checkconf.c 23 May 2019 10:45:48 - @@ -602,6 +602,9 @@ morechecks(struct config_file* cfg) cfg->control_cert_file); } + if (pledge("stdio", NULL) == -1) + fatal_exit("Could not pledge"); + localzonechecks(cfg); view_and_respipchecks(cfg); #ifdef CLIENT_SUBNET @@ -724,6 +727,10 @@ int main(int argc, char* argv[]) if(argc == 1) f = argv[0]; elsef = cfgfile; + + if (pledge("stdio rpath getpw", NULL) == -1) + fatal_exit("Could not pledge"); + checkconf(f, opt, final); checklock_stop(); return 0; On 10:29 Thu 23 May , Stuart Henderson wrote: > Not ok - if you're using remote-control with certificates (for example, > to control remote unbound instances over a network connection) it hits the > following: > > unbound-checkcon[21086]: pledge "rpath", syscall 38 > > (gdb) bt > #0 stat () at -:3 > #1 0x04da8ddd61dc in is_file (fname=0x4dd11e9e3c0 > "/var/unbound/etc/unbound_server.key") > at /usr/src/usr.sbin/unbound/smallapp/unbound-checkconf.c:278 > #2 0x04da8ddd5f10 in check_chroot_string (desc=0x4da8dda7c5d > "server-key-file", ss=0x4dca3ee33d0, > chrootdir=0x0, cfg=0x4dca3ee3000) at > /usr/src/usr.sbin/unbound/smallapp/unbound-checkconf.c:335 > #3 0x04da8ddd5114 in morechecks (cfg=0x4dca3ee3000) > at /usr/src/usr.sbin/unbound/smallapp/unbound-checkconf.c:597 > #4 0x04da8ddd4776 in checkconf (cfgfile=0x4da8dda9506 > "/var/unbound/etc/unbound.conf", opt=0x0, final=0) > at /usr/src/usr.sbin/unbound/smallapp/unbound-checkconf.c:674 > #5 0x04da8ddd44e2 in main (argc=0, argv=0x7f7d1850) > at /usr/src/usr.sbin/unbound/smallapp/unbound-checkconf.c:735 >
build vulkan drivers in Mesa
Build intel and radeon vulkan drivers. As we can't use python in xenocara add phony targets to create the same output as python scripts which create json files for the loader. To use this various vulkan ports are required https://marc.info/?l=openbsd-ports&m=155349407921116&w=2 With intel ivy bridge or newer is required for radeon radeondrm is not supported only amdgpu. This patch is on top of Mesa 19.0.5 which was committed earlier today. Index: Makefile.bsd-wrapper === RCS file: /cvs/xenocara/lib/mesa/Makefile.bsd-wrapper,v retrieving revision 1.26 diff -u -p -r1.26 Makefile.bsd-wrapper --- Makefile.bsd-wrapper23 May 2019 05:33:19 - 1.26 +++ Makefile.bsd-wrapper23 May 2019 07:48:55 - @@ -8,11 +8,13 @@ SHARED_LIBS= EGL 1.1 gbm 0.4 glapi 0.2 G DRI_DRIVERS= swrast GALLIUM_DRIVERS= swrast +VULKAN_DRIVERS=no WITH_LLVM= --disable-llvm .if ${MACHINE} == i386 || ${MACHINE} == amd64 DRI_DRIVERS=swrast,radeon,r200,i915,i965 GALLIUM_DRIVERS=swrast,r300,r600,radeonsi +VULKAN_DRIVERS=intel,radeon WITH_LLVM= --enable-llvm .endif @@ -24,6 +26,7 @@ GALLIUM_DRIVERS=swrast,r300,r600 CONFIGURE_ARGS=--with-dri-drivers=${DRI_DRIVERS} \ --with-gallium-drivers=${GALLIUM_DRIVERS} \ + --with-vulkan-drivers=${VULKAN_DRIVERS} \ --disable-silent-rules \ ${WITH_LLVM} \ --disable-glx-tls \ Index: src/amd/vulkan/Makefile.am === RCS file: /cvs/xenocara/lib/mesa/src/amd/vulkan/Makefile.am,v retrieving revision 1.6 diff -u -p -r1.6 Makefile.am --- src/amd/vulkan/Makefile.am 29 Jan 2019 11:52:06 - 1.6 +++ src/amd/vulkan/Makefile.am 23 May 2019 07:49:38 - @@ -199,6 +199,20 @@ dev_icd.json : radv_extensions.py radv_i radeon_icd.@host_cpu@.json : radv_extensions.py radv_icd.py $(AM_V_GEN)$(PYTHON) $(srcdir)/radv_icd.py \ --lib-path="${libdir}" --out $@ +else +radeon_icd.@host_cpu@.json : + @echo -e "{" > $@ + @echo -e "\"ICD\": {" >> $@ + @echo -e "\"api_version\": \"1.1.70\"," >> $@ + @echo -e "\"library_path\": \"${libdir}/libvulkan_radeon.so\"" >> $@ + @echo -e "}," >> $@ + @echo -e "\"file_format_version\": \"1.0.0\"" >> $@ + @echo -ne "}" >> $@ + +.PHONY: radeon_icd.@host_cpu@.json + +dev_icd.json : radeon_icd.@host_cpu@.json + cp radeon_icd.@host_cpu@.json $@ endif include $(top_srcdir)/install-lib-links.mk Index: src/amd/vulkan/Makefile.in === RCS file: /cvs/xenocara/lib/mesa/src/amd/vulkan/Makefile.in,v retrieving revision 1.11 diff -u -p -r1.11 Makefile.in --- src/amd/vulkan/Makefile.in 23 May 2019 05:33:21 - 1.11 +++ src/amd/vulkan/Makefile.in 23 May 2019 07:49:40 - @@ -1286,6 +1286,19 @@ uninstall-am: uninstall-icdconfDATA unin @REGEN_SOURCES_TRUE@radeon_icd.@host_cpu@.json : radv_extensions.py radv_icd.py @REGEN_SOURCES_TRUE@ $(AM_V_GEN)$(PYTHON) $(srcdir)/radv_icd.py \ @REGEN_SOURCES_TRUE@ --lib-path="${libdir}" --out $@ +@REGEN_SOURCES_FALSE@radeon_icd.@host_cpu@.json : +@REGEN_SOURCES_FALSE@ @echo -e "{" > $@ +@REGEN_SOURCES_FALSE@ @echo -e "\"ICD\": {" >> $@ +@REGEN_SOURCES_FALSE@ @echo -e "\"api_version\": \"1.1.70\"," >> $@ +@REGEN_SOURCES_FALSE@ @echo -e "\"library_path\": \"${libdir}/libvulkan_radeon.so\"" >> $@ +@REGEN_SOURCES_FALSE@ @echo -e "}," >> $@ +@REGEN_SOURCES_FALSE@ @echo -e "\"file_format_version\": \"1.0.0\"" >> $@ +@REGEN_SOURCES_FALSE@ @echo -ne "}" >> $@ + +@REGEN_SOURCES_FALSE@.PHONY: radeon_icd.@host_cpu@.json + +@REGEN_SOURCES_FALSE@dev_icd.json : radeon_icd.@host_cpu@.json +@REGEN_SOURCES_FALSE@ cp radeon_icd.@host_cpu@.json $@ @BUILD_SHARED_TRUE@@HAVE_COMPAT_SYMLINKS_TRUE@all-local : .install-mesa-links Index: src/amd/vulkan/radv_device.c === RCS file: /cvs/xenocara/lib/mesa/src/amd/vulkan/radv_device.c,v retrieving revision 1.9 diff -u -p -r1.9 radv_device.c --- src/amd/vulkan/radv_device.c23 May 2019 05:33:21 - 1.9 +++ src/amd/vulkan/radv_device.c23 May 2019 07:49:43 - @@ -49,6 +49,10 @@ #include "util/debug.h" #include "util/mesa-sha1.h" +#ifndef CLOCK_MONOTONIC_RAW +#define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC +#endif + static int radv_device_get_cache_uuid(enum radeon_family family, void *uuid) { Index: src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c === RCS file: /cvs/xenocara/lib/mesa/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c,v retrieving revision 1.7 diff -u -p -r1.7 radv_amdgpu_cs.c --- src/amd/vulka
Re: pledge(2) unbound-checkconf(8)
On 2019/05/22 14:12, Ricardo Mestre wrote: > Hi, > > unbound-checkconf(8) needs to chdir(2) and then open(2) the config file and > to call getpwnam(3). This means it needs to pledge for rpath and getpw, but > after calling getpwnam(3) the config file was already loaded so we can drop > both promises afterwards. > > Comments? OK? > > Index: unbound-checkconf.c > === > RCS file: /cvs/src/usr.sbin/unbound/smallapp/unbound-checkconf.c,v > retrieving revision 1.11 > diff -u -p -u -r1.11 unbound-checkconf.c > --- unbound-checkconf.c 8 Feb 2019 10:29:08 - 1.11 > +++ unbound-checkconf.c 22 May 2019 12:49:12 - > @@ -588,6 +588,10 @@ morechecks(struct config_file* cfg) > # endif > } > #endif > + > + if (pledge("stdio", NULL) == -1) > + fatal_exit("Could not pledge"); > + > if(cfg->remote_control_enable && options_remote_is_address(cfg) > && cfg->control_use_cert) { > check_chroot_string("server-key-file", &cfg->server_key_file, > @@ -724,6 +728,10 @@ int main(int argc, char* argv[]) > if(argc == 1) > f = argv[0]; > elsef = cfgfile; > + > + if (pledge("stdio rpath getpw", NULL) == -1) > + fatal_exit("Could not pledge"); > + > checkconf(f, opt, final); > checklock_stop(); > return 0; Not ok - if you're using remote-control with certificates (for example, to control remote unbound instances over a network connection) it hits the following: unbound-checkcon[21086]: pledge "rpath", syscall 38 (gdb) bt #0 stat () at -:3 #1 0x04da8ddd61dc in is_file (fname=0x4dd11e9e3c0 "/var/unbound/etc/unbound_server.key") at /usr/src/usr.sbin/unbound/smallapp/unbound-checkconf.c:278 #2 0x04da8ddd5f10 in check_chroot_string (desc=0x4da8dda7c5d "server-key-file", ss=0x4dca3ee33d0, chrootdir=0x0, cfg=0x4dca3ee3000) at /usr/src/usr.sbin/unbound/smallapp/unbound-checkconf.c:335 #3 0x04da8ddd5114 in morechecks (cfg=0x4dca3ee3000) at /usr/src/usr.sbin/unbound/smallapp/unbound-checkconf.c:597 #4 0x04da8ddd4776 in checkconf (cfgfile=0x4da8dda9506 "/var/unbound/etc/unbound.conf", opt=0x0, final=0) at /usr/src/usr.sbin/unbound/smallapp/unbound-checkconf.c:674 #5 0x04da8ddd44e2 in main (argc=0, argv=0x7f7d1850) at /usr/src/usr.sbin/unbound/smallapp/unbound-checkconf.c:735
bgpctl show mrt neighbors
The MRT TABLE_DUMP_V2 format includes a list of all peers at the start of the dump. I find it useful to be able to dump this table independent of the rest. Especially useful if used together with bgpctl show mrt nei to limit the output to a single neighbor. Possible out looks like: view: master BGP ID: 198.18.225.230 Number of peers: 569 Neighbor AS BGP ID 0.0.0.0 0 0.0.0.0 198.18.226.24812491 81.199.12.4 198.18.225.49 8757 185.144.87.251 198.18.226.219 204264185.109.44.1 198.18.227.10728329 186.226.80.251 This only works with the TABLE_DUMP_V2 format, the other table dumps don't include such information. -- :wq Claudio Index: bgpctl/bgpctl.8 === RCS file: /cvs/src/usr.sbin/bgpctl/bgpctl.8,v retrieving revision 1.85 diff -u -p -r1.85 bgpctl.8 --- bgpctl/bgpctl.8 20 Jan 2019 23:30:15 - 1.85 +++ bgpctl/bgpctl.8 23 May 2019 07:13:46 - @@ -285,6 +285,9 @@ Show more detailed output for matching r Limit the output to the given address family. .It Cm file Ar name Read the MRT dump from file +.It Cm neighbors +Print the neighbor table of MRT TABLE_DUMP_V2 dumps. +Using this on other table dumps will only show the neighbor of the first entry. .Ar name instead of using stdin. .El Index: bgpctl/bgpctl.c === RCS file: /cvs/src/usr.sbin/bgpctl/bgpctl.c,v retrieving revision 1.237 diff -u -p -r1.237 bgpctl.c --- bgpctl/bgpctl.c 14 May 2019 16:47:30 - 1.237 +++ bgpctl/bgpctl.c 23 May 2019 08:29:27 - @@ -88,6 +88,8 @@ intshow_rib_memory_msg(struct imsg *) voidsend_filterset(struct imsgbuf *, struct filter_set_head *); const char *get_errstr(u_int8_t, u_int8_t); int show_result(struct imsg *); +voidshow_mrt_dump_neighbors(struct mrt_rib *, struct mrt_peer *, + void *); voidshow_mrt_dump(struct mrt_rib *, struct mrt_peer *, void *); voidnetwork_mrt_dump(struct mrt_rib *, struct mrt_peer *, void *); voidshow_mrt_state(struct mrt_bgp_state *, void *); @@ -180,7 +182,9 @@ main(int argc, char *argv[]) ribreq.flags = res->flags; ribreq.validation_state = res->validation_state; show_mrt.arg = &ribreq; - if (!(res->flags & F_CTL_DETAIL)) + if (res->flags & F_CTL_NEIGHBORS) + show_mrt.dump = show_mrt_dump_neighbors; + else if (!(res->flags & F_CTL_DETAIL)) show_rib_summary_head(); mrt_parse(res->mrtfd, &show_mrt, 1); exit(0); @@ -1972,6 +1976,27 @@ network_bulk(struct parse_result *res) if (ferror(f)) err(1, "getline"); fclose(f); +} + +void +show_mrt_dump_neighbors(struct mrt_rib *mr, struct mrt_peer *mp, void *arg) +{ + struct mrt_peer_entry *p; + struct in_addr ina; + u_int16_t i; + + ina.s_addr = htonl(mp->bgp_id); + printf("view: %s BGP ID: %s Number of peers: %u\n\n", + mp->view, inet_ntoa(ina), mp->npeers); + printf("%-30s %8s %15s\n", "Neighbor", "AS", "BGP ID"); + for (i = 0; i < mp->npeers; i++) { + p = &mp->peers[i]; + ina.s_addr = htonl(p->bgp_id); + printf("%-30s %8u %15s\n", log_addr(&p->addr), p->asnum, + inet_ntoa(ina)); + } + /* we only print the first message */ + exit(0); } void Index: bgpctl/parser.c === RCS file: /cvs/src/usr.sbin/bgpctl/parser.c,v retrieving revision 1.93 diff -u -p -r1.93 parser.c --- bgpctl/parser.c 10 Apr 2019 15:22:18 - 1.93 +++ bgpctl/parser.c 23 May 2019 07:03:18 - @@ -210,8 +210,9 @@ static const struct token t_show_mrt[] = { ASTYPE, "peer-as", AS_PEER,t_show_mrt_as}, { ASTYPE, "empty-as", AS_EMPTY, t_show_mrt}, { FLAG, "detail", F_CTL_DETAIL, t_show_mrt}, - { FLAG, "ssv" , F_CTL_SSV, t_show_mrt}, + { FLAG, "ssv", F_CTL_SSV, t_show_mrt}, { KEYWORD, "neighbor", NONE, t_show_mrt_neigh}, + { FLAG, "neighbors",F_CTL_NEIGHBORS,t_show_mrt}, { KEYWORD, "file", NONE, t_show_mrt_file}, { FAMILY, "", NONE, t_show_mrt}, { PREFIX, "", NONE, t_show_prefix}, Index: bgpd/bgpd.h === RCS file: /cvs/src/usr.sbin/bgpd/bgpd.h,v retrieving revision 1.382 diff -u -p -r1.382 bgpd.h --- bgpd/bgpd.h 8 May 2019 12:41: