Re: bgpd: print AS range

2016-06-04 Thread Peter Hessler
This didn't quite work, as log_as will override itself when used twice
in the same printf.

I also fixed some knf bits.

On 2016 Jun 04 (Sat) at 22:13:07 +0200 (+0200), Denis Fondras wrote:
:With the support of AS range filtering, we need to print the configuration
:accordingly.
:
:Before :
:# bgpd -dnv
:[...]
:deny from any AS 0
:deny from any AS 0 
:deny from any AS 65535
:deny from any AS 0
:deny from any AS 0
:deny from any AS 0
:deny from any AS 4294967295 
:
:After :
:# bgpd -dnv
:[...]
:deny from any AS 64496 - 64496 
:deny from any AS 64512 - 64512 
:deny from any AS 65535 
:deny from any AS 65536 - 65536 
:deny from any AS 65552 - 65552 
:deny from any AS 42 - 42 
:deny from any AS 4294967295 
:

After:
# bgpd -nvv
[...]
deny from any AS 23456 
deny from any AS 64496 - 64511 
deny from any AS 64512 - 65534 
deny from any AS 65535 
deny from any AS 65536 - 65551 
deny from any AS 65552 - 131071 
deny from any AS 42 - 4294967294 
deny from any AS 4294967295 



Index: printconf.c
===
RCS file: /cvs/openbsd/src/usr.sbin/bgpd/printconf.c,v
retrieving revision 1.96
diff -u -p -u -p -r1.96 printconf.c
--- printconf.c 21 Sep 2015 09:47:15 -  1.96
+++ printconf.c 4 Jun 2016 21:11:46 -
@@ -41,6 +41,7 @@ void   print_peer(struct peer_config *, 
 const char *print_auth_alg(u_int8_t);
 const char *print_enc_alg(u_int8_t);
 voidprint_announce(struct peer_config *, const char *);
+voidprint_as(struct filter_rule *);
 voidprint_rule(struct peer *, struct filter_rule *);
 const char *mrt_type(enum mrt_type);
 voidprint_mrt(struct bgpd_config *, u_int32_t, u_int32_t,
@@ -507,6 +508,27 @@ print_announce(struct peer_config *p, co
 }
 
 void
+print_as(struct filter_rule *r)
+{
+   switch(r->match.as.op) {
+   case OP_RANGE:
+   printf("%s - ", log_as(r->match.as.as_min));
+   printf("%s ", log_as(r->match.as.as_max));
+   break;
+   case OP_XRANGE:
+   printf("%s >< ", log_as(r->match.as.as_min));
+   printf("%s ", log_as(r->match.as.as_max));
+   break;
+   case OP_NE:
+   printf("!= %s ", log_as(r->match.as.as));
+   break;
+   default:
+   printf("%s ", log_as(r->match.as.as));
+   break;
+   }
+}
+
+void
 print_rule(struct peer *peer_l, struct filter_rule *r)
 {
struct peer *p;
@@ -577,15 +599,16 @@ print_rule(struct peer *peer_l, struct f
 
if (r->match.as.type) {
if (r->match.as.type == AS_ALL)
-   printf("AS %s ", log_as(r->match.as.as));
+   printf("AS ");
else if (r->match.as.type == AS_SOURCE)
-   printf("source-as %s ", log_as(r->match.as.as));
+   printf("source-as ");
else if (r->match.as.type == AS_TRANSIT)
-   printf("transit-as %s ", log_as(r->match.as.as));
+   printf("transit-as ");
else if (r->match.as.type == AS_PEER)
-   printf("peer-as %s ", log_as(r->match.as.as));
+   printf("peer-as ");
else
-   printf("unfluffy-as %s ", log_as(r->match.as.as));
+   printf("unfluffy-as ");
+   print_as(r);
}
 
if (r->match.aslen.type) {


-- 
Join in the new game that's sweeping the country.  It's called
"Bureaucracy".  Everybody stands in a circle.  The first person to do
anything loses.



Re: bgpd: print AS range

2016-06-04 Thread Stuart Henderson
On 2016/06/04 22:13, Denis Fondras wrote:
> With the support of AS range filtering, we need to print the configuration
> accordingly.

OK sthen@

>   if (r->match.as.type) {
>   if (r->match.as.type == AS_ALL)
> - printf("AS %s ", log_as(r->match.as.as));
> + printf("AS ");
>   else if (r->match.as.type == AS_SOURCE)
> - printf("source-as %s ", log_as(r->match.as.as));
> + printf("source-as ");
>   else if (r->match.as.type == AS_TRANSIT)
> - printf("transit-as %s ", log_as(r->match.as.as));
> + printf("transit-as ");
>   else if (r->match.as.type == AS_PEER)
> - printf("peer-as %s ", log_as(r->match.as.as));
> + printf("peer-as ");
>   else
> - printf("unfluffy-as %s ", log_as(r->match.as.as));
> + printf("unfluffy-as ");

makes a change from king bula :)



bgpd: print AS range

2016-06-04 Thread Denis Fondras
With the support of AS range filtering, we need to print the configuration
accordingly.

Before :
# bgpd -dnv
[...]
deny from any AS 0
deny from any AS 0 
deny from any AS 65535
deny from any AS 0
deny from any AS 0
deny from any AS 0
deny from any AS 4294967295 

After :
# bgpd -dnv
[...]
deny from any AS 64496 - 64496 
deny from any AS 64512 - 64512 
deny from any AS 65535 
deny from any AS 65536 - 65536 
deny from any AS 65552 - 65552 
deny from any AS 42 - 42 
deny from any AS 4294967295 


Index: printconf.c
===
RCS file: /cvs/src/usr.sbin/bgpd/printconf.c,v
retrieving revision 1.96
diff -u -p -r1.96 printconf.c
--- printconf.c 21 Sep 2015 09:47:15 -  1.96
+++ printconf.c 4 Jun 2016 20:06:52 -
@@ -41,6 +41,7 @@ void   print_peer(struct peer_config *, 
 const char *print_auth_alg(u_int8_t);
 const char *print_enc_alg(u_int8_t);
 voidprint_announce(struct peer_config *, const char *);
+voidprint_as(struct filter_rule *);
 voidprint_rule(struct peer *, struct filter_rule *);
 const char *mrt_type(enum mrt_type);
 voidprint_mrt(struct bgpd_config *, u_int32_t, u_int32_t,
@@ -506,6 +507,26 @@ print_announce(struct peer_config *p, co
printf("%s\tannounce %s\n", c, aid2str(aid));
 }
 
+void print_as(struct filter_rule *r)
+{
+   switch(r->match.as.op) {
+   case OP_RANGE:
+printf("%s - %s ", log_as(r->match.as.as_min),
+   log_as(r->match.as.as_max));
+break;  
+case OP_XRANGE:
+printf("%s >< %s ", log_as(r->match.as.as_min),
+   log_as(r->match.as.as_max));
+break;
+case OP_NE:
+printf("!= %s ", log_as(r->match.as.as));
+break;
+default:
+printf("%s ", log_as(r->match.as.as));
+break;
+   }
+}
+
 void
 print_rule(struct peer *peer_l, struct filter_rule *r)
 {
@@ -577,15 +598,16 @@ print_rule(struct peer *peer_l, struct f
 
if (r->match.as.type) {
if (r->match.as.type == AS_ALL)
-   printf("AS %s ", log_as(r->match.as.as));
+   printf("AS ");
else if (r->match.as.type == AS_SOURCE)
-   printf("source-as %s ", log_as(r->match.as.as));
+   printf("source-as ");
else if (r->match.as.type == AS_TRANSIT)
-   printf("transit-as %s ", log_as(r->match.as.as));
+   printf("transit-as ");
else if (r->match.as.type == AS_PEER)
-   printf("peer-as %s ", log_as(r->match.as.as));
+   printf("peer-as ");
else
-   printf("unfluffy-as %s ", log_as(r->match.as.as));
+   printf("unfluffy-as ");
+   print_as(r);
}
 
if (r->match.aslen.type) {



Re: more continue loops

2016-06-04 Thread Marcus Glocker
On Fri, Jun 03, 2016 at 08:20:57PM -0400, Ted Unangst wrote:

> this is in sbin. i left csh and ksh in bin for some other brave soul.

ok mglocker 
 
> Index: dump/main.c
> ===
> RCS file: /cvs/src/sbin/dump/main.c,v
> retrieving revision 1.57
> diff -u -p -r1.57 main.c
> --- dump/main.c   20 Aug 2015 22:02:20 -  1.57
> +++ dump/main.c   4 Jun 2016 00:19:31 -
> @@ -769,7 +769,7 @@ obsolete(int *argcp, char **argvp[])
>  
>   /* Copy remaining arguments. */
>   while ((*nargv++ = *argv++))
> - ;
> + continue;
>  
>   /* Update argument count. */
>   *argcp = nargv - *argvp - 1;
> Index: fsdb/fsdb.c
> ===
> RCS file: /cvs/src/sbin/fsdb/fsdb.c,v
> retrieving revision 1.29
> diff -u -p -r1.29 fsdb.c
> --- fsdb/fsdb.c   20 Jan 2015 18:22:21 -  1.29
> +++ fsdb/fsdb.c   4 Jun 2016 00:16:30 -
> @@ -451,7 +451,7 @@ CMDFUNCSTART(focusname)
>   }
>   for (p = argv[1]; p != NULL;) {
>   while ((val = strsep(&p, "/")) != NULL && *val == '\0')
> - ;
> + continue;
>   if (val) {
>   printf("component `%s': ", val);
>   fflush(stdout);
> Index: nfsd/nfsd.c
> ===
> RCS file: /cvs/src/sbin/nfsd/nfsd.c,v
> retrieving revision 1.35
> diff -u -p -r1.35 nfsd.c
> --- nfsd/nfsd.c   16 Jan 2015 06:40:00 -  1.35
> +++ nfsd/nfsd.c   4 Jun 2016 00:16:35 -
> @@ -342,6 +342,6 @@ reapchild(int signo)
>   int save_errno = errno;
>  
>   while (wait3(NULL, WNOHANG, NULL) > 0)
> - ;
> + continue;
>   errno = save_errno;
>  }
> Index: restore/main.c
> ===
> RCS file: /cvs/src/sbin/restore/main.c,v
> retrieving revision 1.23
> diff -u -p -r1.23 main.c
> --- restore/main.c20 Jan 2015 18:22:21 -  1.23
> +++ restore/main.c4 Jun 2016 00:16:43 -
> @@ -88,7 +88,7 @@ main(int argc, char *argv[])
>   if ((tmpdir = strdup(tmpdir)) == NULL)
>   err(1, NULL);
>   for (p = tmpdir + strlen(tmpdir) - 1; p >= tmpdir && *p == '/'; p--)
> - ;
> + continue;
>   obsolete(&argc, &argv);
>   while ((ch = getopt(argc, argv, "b:cdf:himNRrs:tvxy")) != -1)
>   switch(ch) {
> @@ -344,7 +344,7 @@ obsolete(int *argcp, char **argvp[])
>  
>   /* Copy remaining arguments. */
>   while ((*nargv++ = *argv++))
> - ;
> + continue;
>  
>   /* Update argument count. */
>   *argcp = nargv - *argvp - 1;
> Index: route/route.c
> ===
> RCS file: /cvs/src/sbin/route/route.c,v
> retrieving revision 1.182
> diff -u -p -r1.182 route.c
> --- route/route.c 3 Dec 2015 08:00:49 -   1.182
> +++ route/route.c 4 Jun 2016 00:16:49 -
> @@ -763,7 +763,7 @@ inet_makenetandmask(u_int32_t net, struc
>   sin->sin_family = 0;
>   cp = (char *)(&sin->sin_addr + 1);
>   while (*--cp == '\0' && cp > (char *)sin)
> - ;
> + continue;
>   sin->sin_len = 1 + cp - (char *)sin;
>  }
>  
> Index: scsi/scsi.c
> ===
> RCS file: /cvs/src/sbin/scsi/scsi.c,v
> retrieving revision 1.29
> diff -u -p -r1.29 scsi.c
> --- scsi/scsi.c   20 Nov 2014 15:22:39 -  1.29
> +++ scsi/scsi.c   4 Jun 2016 00:16:55 -
> @@ -442,11 +442,11 @@ skipwhite(FILE *f)
>  skip_again:
>  
>   while (isspace(c = getc(f)))
> - ;
> + continue;
>  
>   if (c == '#') {
>   while ((c = getc(f)) != '\n' && c != EOF)
> - ;
> + continue;
>   goto skip_again;
>   }
>  
> 



Re: ospf6d: add format attributes

2016-06-04 Thread Stefan Sperling
On Sat, Jun 04, 2016 at 06:51:37PM +0200, Sebastian Benoit wrote:
> In ospf6d, add format attributes to the proper functions and then fix the
> warning in rde.c
> 
> ok?

yup

> 
> diff --git log.h log.h
> index 0cc7403..8cccd8f 100644
> --- log.h
> +++ log.h
> @@ -23,14 +23,22 @@
>  
>  void  log_init(int);
>  void  log_verbose(int);
> -void  logit(int, const char *, ...);
> -void  vlog(int, const char *, va_list);
> -void  log_warn(const char *, ...);
> -void  log_warnx(const char *, ...);
> -void  log_info(const char *, ...);
> -void  log_debug(const char *, ...);
> -void  fatal(const char *) __dead;
> -void  fatalx(const char *) __dead;
> +void  logit(int, const char *, ...)
> + __attribute__((__format__ (printf, 2, 3)));
> +void  vlog(int, const char *, va_list)
> + __attribute__((__format__ (printf, 2, 0)));
> +void  log_warn(const char *, ...)
> + __attribute__((__format__ (printf, 1, 2)));
> +void  log_warnx(const char *, ...)
> + __attribute__((__format__ (printf, 1, 2)));
> +void  log_info(const char *, ...)
> + __attribute__((__format__ (printf, 1, 2)));
> +void  log_debug(const char *, ...)
> + __attribute__((__format__ (printf, 1, 2)));
> +void  fatal(const char *) __dead
> + __attribute__((__format__ (printf, 1, 0)));
> +void  fatalx(const char *) __dead
> + __attribute__((__format__ (printf, 1, 0)));
>  
>  const char   *log_in6addr(const struct in6_addr *);
>  const char   *log_in6addr_scope(const struct in6_addr *, unsigned int);
> diff --git rde.c rde.c
> index 1de5d14..1d4b426 100644
> --- rde.c
> +++ rde.c
> @@ -356,7 +356,7 @@ rde_dispatch_imsg(int fd, short event, void *bula)
>   }
>   }
>   if (l != 0)
> - log_warnx("rde_dispatch_imsg: peerid %lu, "
> + log_warnx("rde_dispatch_imsg: peerid %u, "
>   "trailing garbage in Database Description "
>   "packet", imsg.hdr.peerid);
>  
> @@ -387,7 +387,7 @@ rde_dispatch_imsg(int fd, short event, void *bula)
>   ntohs(v->lsa->hdr.len));
>   }
>   if (l != 0)
> - log_warnx("rde_dispatch_imsg: peerid %lu, "
> + log_warnx("rde_dispatch_imsg: peerid %u, "
>   "trailing garbage in LS Request "
>   "packet", imsg.hdr.peerid);
>   break;
> 



Re: ospfd: add format attributes

2016-06-04 Thread Stefan Sperling
On Sat, Jun 04, 2016 at 06:45:53PM +0200, Sebastian Benoit wrote:
> In ospfd, add format attributes to the proper functions and then fix the
> warning in rde.c.
> 
> ok?

ok with me

> 
> diff --git log.h log.h
> index e0034e8..a682f67 100644
> --- log.h
> +++ log.h
> @@ -23,13 +23,21 @@
>  
>  void log_init(int);
>  void log_verbose(int);
> -void logit(int, const char *, ...);
> -void vlog(int, const char *, va_list);
> -void log_warn(const char *, ...);
> -void log_warnx(const char *, ...);
> -void log_info(const char *, ...);
> -void log_debug(const char *, ...);
> -void fatal(const char *) __dead;
> -void fatalx(const char *) __dead;
> +void logit(int, const char *, ...)
> + __attribute__((__format__ (printf, 2, 3)));
> +void vlog(int, const char *, va_list)
> + __attribute__((__format__ (printf, 2, 0)));
> +void log_warn(const char *, ...)
> + __attribute__((__format__ (printf, 1, 2)));
> +void log_warnx(const char *, ...)
> + __attribute__((__format__ (printf, 1, 2)));
> +void log_info(const char *, ...)
> + __attribute__((__format__ (printf, 1, 2)));
> +void log_debug(const char *, ...)
> + __attribute__((__format__ (printf, 1, 2)));
> +void fatal(const char *) __dead
> + __attribute__((__format__ (printf, 1, 0)));
> +void fatalx(const char *) __dead
> + __attribute__((__format__ (printf, 1, 0)));
>  
>  #endif /* _LOG_H_ */
> diff --git rde.c rde.c
> index 6d53eb3..eca497a 100644
> --- rde.c
> +++ rde.c
> @@ -374,7 +374,7 @@ rde_dispatch_imsg(int fd, short event, void *bula)
>   }
>   }
>   if (l != 0 && !error)
> - log_warnx("rde_dispatch_imsg: peerid %lu, "
> + log_warnx("rde_dispatch_imsg: peerid %u, "
>   "trailing garbage in Database Description "
>   "packet", imsg.hdr.peerid);
>  
> @@ -411,7 +411,7 @@ rde_dispatch_imsg(int fd, short event, void *bula)
>   ntohs(v->lsa->hdr.len));
>   }
>   if (l != 0)
> - log_warnx("rde_dispatch_imsg: peerid %lu, "
> + log_warnx("rde_dispatch_imsg: peerid %u, "
>   "trailing garbage in LS Request "
>   "packet", imsg.hdr.peerid);
>   break;
> 



continue merging rtwn and urtwn

2016-06-04 Thread Stefan Sperling
Another step on the long road towards merging these drivers.

Copy r88e support code into ic/rtwn.c. This can't be tested until the
USB driver starts making use of the shared rtwn.c file, but it's pretty
straightforward.

It turns out some functions won't benefit a lot from merging, mostly
where register access patterns differ between PCI and USB drivers.
Put them back into the PCI part of the driver. There's still some
overlap that could be partly avoided, but let's deal with that later.

No regressions in rtwn(4) as far as I can see.

ok?

Index: ic/rtwn.c
===
RCS file: /cvs/src/sys/dev/ic/rtwn.c,v
retrieving revision 1.7
diff -u -p -r1.7 rtwn.c
--- ic/rtwn.c   13 Apr 2016 10:49:26 -  1.7
+++ ic/rtwn.c   4 Jun 2016 17:32:12 -
@@ -51,10 +51,6 @@
 #include 
 #include 
 
-#include 
-#include 
-#include 
-
 #include 
 #include 
 
@@ -84,10 +80,16 @@ uint32_trtwn_rf_read(struct rtwn_softc 
 void   rtwn_cam_write(struct rtwn_softc *, uint32_t, uint32_t);
 uint8_trtwn_efuse_read_1(struct rtwn_softc *, uint16_t);
 void   rtwn_efuse_read(struct rtwn_softc *);
+void   rtwn_efuse_switch_power(struct rtwn_softc *);
 intrtwn_read_chipid(struct rtwn_softc *, uint32_t);
 void   rtwn_read_rom(struct rtwn_softc *);
+void   rtwn_r88e_read_rom(struct rtwn_softc *);
 intrtwn_media_change(struct ifnet *);
 intrtwn_ra_init(struct rtwn_softc *);
+intrtwn_r92c_ra_init(struct rtwn_softc *, u_int8_t, u_int32_t,
+   int, uint32_t, int);
+intrtwn_r88e_ra_init(struct rtwn_softc *, u_int8_t, u_int32_t,
+   int, uint32_t, int);
 void   rtwn_tsf_sync_enable(struct rtwn_softc *);
 void   rtwn_set_led(struct rtwn_softc *, int, int);
 intrtwn_newstate(struct ieee80211com *, enum ieee80211_state, int);
@@ -97,16 +99,14 @@ int rtwn_set_key(struct ieee80211com *,
 void   rtwn_delete_key(struct ieee80211com *,
struct ieee80211_node *, struct ieee80211_key *);
 void   rtwn_update_avgrssi(struct rtwn_softc *, int, int8_t);
-int8_t rtwn_get_rssi(struct rtwn_softc *, int, void *);
+int8_t rtwn_r88e_get_rssi(struct rtwn_softc *, int, void *);
 void   rtwn_start(struct ifnet *);
 void   rtwn_watchdog(struct ifnet *);
 intrtwn_ioctl(struct ifnet *, u_long, caddr_t);
-intrtwn_power_on(struct rtwn_softc *);
 void   rtwn_fw_reset(struct rtwn_softc *);
+void   rtwn_r88e_fw_reset(struct rtwn_softc *);
 intrtwn_fw_loadpage(struct rtwn_softc *, int, uint8_t *, int);
 intrtwn_load_firmware(struct rtwn_softc *);
-void   rtwn_mac_init(struct rtwn_softc *);
-void   rtwn_bb_init(struct rtwn_softc *);
 void   rtwn_rf_init(struct rtwn_softc *);
 void   rtwn_cam_init(struct rtwn_softc *);
 void   rtwn_pa_bias_init(struct rtwn_softc *);
@@ -116,6 +116,9 @@ voidrtwn_write_txpower(struct rtwn_sof
 void   rtwn_get_txpower(struct rtwn_softc *, int,
struct ieee80211_channel *, struct ieee80211_channel *,
uint16_t[]);
+void   rtwn_r88e_get_txpower(struct rtwn_softc *, int,
+   struct ieee80211_channel *,
+   struct ieee80211_channel *, uint16_t[]);
 void   rtwn_set_txpower(struct rtwn_softc *,
struct ieee80211_channel *, struct ieee80211_channel *);
 void   rtwn_set_chan(struct rtwn_softc *,
@@ -168,11 +171,17 @@ rtwn_attach(struct device *pdev, struct 
sc->ntxchains = 1;
sc->nrxchains = 1;
}
-   rtwn_read_rom(sc);
+
+   if (sc->chip & RTWN_CHIP_88E)
+   rtwn_r88e_read_rom(sc);
+   else
+   rtwn_read_rom(sc);
 
printf("%s: MAC/BB RTL%s, RF 6052 %dT%dR, address %s\n",
sc->sc_pdev->dv_xname,
-   (sc->chip & RTWN_CHIP_92C) ? "8192CE" : "8188CE",
+   (sc->chip & RTWN_CHIP_92C) ? "8192CE" :
+   (sc->chip & RTWN_CHIP_88E) ? "8188EE" :
+   "8188CE",
sc->ntxchains, sc->nrxchains,
ether_sprintf(ic->ic_myaddr));
 
@@ -358,9 +367,15 @@ rtwn_fw_cmd(struct rtwn_softc *sc, uint8
 void
 rtwn_rf_write(struct rtwn_softc *sc, int chain, uint8_t addr, uint32_t val)
 {
+   uint32_t param_addr;
+
+   if (sc->chip & RTWN_CHIP_88E)
+   param_addr = SM(R88E_LSSI_PARAM_ADDR, addr);
+   else
+   param_addr = SM(R92C_LSSI_PARAM_ADDR, addr);
+
rtwn_bb_write(sc, R92C_LSSI_PARAM(chain),
-   SM(R92C_LSSI_PARAM_ADDR, addr) |
-   SM(R92C_LSSI_PARAM_DATA, val));
+   param_addr | SM(R92C_LSSI_PARAM_DATA, val));
 }
 
 uint32_t
@@ -432,22 +447,8 @@ rtwn_efuse_read(struct rtwn_softc *sc)
uint8_t off, msk;
int i;

ospf6d: add format attributes

2016-06-04 Thread Sebastian Benoit
In ospf6d, add format attributes to the proper functions and then fix the
warning in rde.c

ok?

diff --git log.h log.h
index 0cc7403..8cccd8f 100644
--- log.h
+++ log.h
@@ -23,14 +23,22 @@
 
 voidlog_init(int);
 voidlog_verbose(int);
-voidlogit(int, const char *, ...);
-voidvlog(int, const char *, va_list);
-voidlog_warn(const char *, ...);
-voidlog_warnx(const char *, ...);
-voidlog_info(const char *, ...);
-voidlog_debug(const char *, ...);
-voidfatal(const char *) __dead;
-voidfatalx(const char *) __dead;
+voidlogit(int, const char *, ...)
+   __attribute__((__format__ (printf, 2, 3)));
+voidvlog(int, const char *, va_list)
+   __attribute__((__format__ (printf, 2, 0)));
+voidlog_warn(const char *, ...)
+   __attribute__((__format__ (printf, 1, 2)));
+voidlog_warnx(const char *, ...)
+   __attribute__((__format__ (printf, 1, 2)));
+voidlog_info(const char *, ...)
+   __attribute__((__format__ (printf, 1, 2)));
+voidlog_debug(const char *, ...)
+   __attribute__((__format__ (printf, 1, 2)));
+voidfatal(const char *) __dead
+   __attribute__((__format__ (printf, 1, 0)));
+voidfatalx(const char *) __dead
+   __attribute__((__format__ (printf, 1, 0)));
 
 const char *log_in6addr(const struct in6_addr *);
 const char *log_in6addr_scope(const struct in6_addr *, unsigned int);
diff --git rde.c rde.c
index 1de5d14..1d4b426 100644
--- rde.c
+++ rde.c
@@ -356,7 +356,7 @@ rde_dispatch_imsg(int fd, short event, void *bula)
}
}
if (l != 0)
-   log_warnx("rde_dispatch_imsg: peerid %lu, "
+   log_warnx("rde_dispatch_imsg: peerid %u, "
"trailing garbage in Database Description "
"packet", imsg.hdr.peerid);
 
@@ -387,7 +387,7 @@ rde_dispatch_imsg(int fd, short event, void *bula)
ntohs(v->lsa->hdr.len));
}
if (l != 0)
-   log_warnx("rde_dispatch_imsg: peerid %lu, "
+   log_warnx("rde_dispatch_imsg: peerid %u, "
"trailing garbage in LS Request "
"packet", imsg.hdr.peerid);
break;



ospfd: add format attributes

2016-06-04 Thread Sebastian Benoit
In ospfd, add format attributes to the proper functions and then fix the
warning in rde.c.

ok?

diff --git log.h log.h
index e0034e8..a682f67 100644
--- log.h
+++ log.h
@@ -23,13 +23,21 @@
 
 void   log_init(int);
 void   log_verbose(int);
-void   logit(int, const char *, ...);
-void   vlog(int, const char *, va_list);
-void   log_warn(const char *, ...);
-void   log_warnx(const char *, ...);
-void   log_info(const char *, ...);
-void   log_debug(const char *, ...);
-void   fatal(const char *) __dead;
-void   fatalx(const char *) __dead;
+void   logit(int, const char *, ...)
+   __attribute__((__format__ (printf, 2, 3)));
+void   vlog(int, const char *, va_list)
+   __attribute__((__format__ (printf, 2, 0)));
+void   log_warn(const char *, ...)
+   __attribute__((__format__ (printf, 1, 2)));
+void   log_warnx(const char *, ...)
+   __attribute__((__format__ (printf, 1, 2)));
+void   log_info(const char *, ...)
+   __attribute__((__format__ (printf, 1, 2)));
+void   log_debug(const char *, ...)
+   __attribute__((__format__ (printf, 1, 2)));
+void   fatal(const char *) __dead
+   __attribute__((__format__ (printf, 1, 0)));
+void   fatalx(const char *) __dead
+   __attribute__((__format__ (printf, 1, 0)));
 
 #endif /* _LOG_H_ */
diff --git rde.c rde.c
index 6d53eb3..eca497a 100644
--- rde.c
+++ rde.c
@@ -374,7 +374,7 @@ rde_dispatch_imsg(int fd, short event, void *bula)
}
}
if (l != 0 && !error)
-   log_warnx("rde_dispatch_imsg: peerid %lu, "
+   log_warnx("rde_dispatch_imsg: peerid %u, "
"trailing garbage in Database Description "
"packet", imsg.hdr.peerid);
 
@@ -411,7 +411,7 @@ rde_dispatch_imsg(int fd, short event, void *bula)
ntohs(v->lsa->hdr.len));
}
if (l != 0)
-   log_warnx("rde_dispatch_imsg: peerid %lu, "
+   log_warnx("rde_dispatch_imsg: peerid %u, "
"trailing garbage in LS Request "
"packet", imsg.hdr.peerid);
break;



bgpd: add format attributes

2016-06-04 Thread Sebastian Benoit
Add format attributes to the proper functions and then fix the warning in
session.c.

ok?

diff --git bgpd.h bgpd.h
index 5fa046e..eaf93e6 100644
--- bgpd.h
+++ bgpd.h
@@ -989,15 +989,24 @@ struct in6_addr   *prefixlen2mask6(u_int8_t prefixlen);
 /* log.c */
 voidlog_init(int);
 voidlog_verbose(int);
-voidlogit(int, const char *, ...);
-voidvlog(int, const char *, va_list);
-voidlog_peer_warn(const struct peer_config *, const char *, ...);
-voidlog_peer_warnx(const struct peer_config *, const char *, ...);
-voidlog_warn(const char *, ...);
-voidlog_warnx(const char *, ...);
-voidlog_info(const char *, ...);
-voidlog_debug(const char *, ...);
-voidfatal(const char *, ...) __dead;
+voidlogit(int, const char *, ...)
+   __attribute__((__format__ (printf, 2, 3)));
+voidvlog(int, const char *, va_list)
+   __attribute__((__format__ (printf, 2, 0)));
+voidlog_peer_warn(const struct peer_config *, const char *, ...)
+   __attribute__((__format__ (printf, 2, 3)));
+voidlog_peer_warnx(const struct peer_config *, const char *, ...)
+   __attribute__((__format__ (printf, 2, 3)));
+voidlog_warn(const char *, ...)
+   __attribute__((__format__ (printf, 1, 2)));
+voidlog_warnx(const char *, ...)
+   __attribute__((__format__ (printf, 1, 2)));
+voidlog_info(const char *, ...)
+   __attribute__((__format__ (printf, 1, 2)));
+voidlog_debug(const char *, ...)
+   __attribute__((__format__ (printf, 1, 2)));
+voidfatal(const char *, ...) __dead
+   __attribute__((__format__ (printf, 1, 2)));
 voidfatalx(const char *) __dead;
 
 /* mrt.c */
diff --git session.c session.c
index 8c853a1..e736b76 100644
--- session.c
+++ session.c
@@ -2017,7 +2017,7 @@ parse_open(struct peer *peer)
 
/* check bgpid for validity - just disallow 0 */
if (ntohl(bgpid) == 0) {
-   log_peer_warnx(&peer->conf, "peer BGPID %lu unacceptable",
+   log_peer_warnx(&peer->conf, "peer BGPID %u unacceptable",
ntohl(bgpid));
session_notification(peer, ERR_OPEN, ERR_OPEN_BGPID,
NULL, 0);




OpenCVS bug on ssh 'broken pipe' error

2016-06-04 Thread Dongsheng Song
When ssh 'broken pipe' error occurred, cvs quit exit error 0.

Here is my test script:

# cat opencvs.sh
#!/bin/ksh

cd /usr/src
echo "[`/bin/date "+%Y-%m-%dT%H:%M:%S%z"`] start cvs update /usr/src/"
while true; do
cvs -q -d anon...@anoncvs.comstyle.com:/cvs up -Pd
rc=$?
echo $rc
if [ "$rc" -eq "0" ]; then
break;
fi
echo "[`/bin/date "+%Y-%m-%dT%H:%M:%S%z"`] retry cvs update"
done
echo "[`/bin/date "+%Y-%m-%dT%H:%M:%S%z"`] done cvs update"

# ksh opencvs.sh
[2016-05-21T01:16:47+0800] start cvs update /usr/src/
P bin/pax/ar_io.c
P bin/pax/ftree.c
P bin/rmdir/rmdir.c
P distrib/armv7/ramdisk/install.md
P distrib/sets/lists/man/mi
P etc/examples/bgpd.conf
P share/man/man4/Makefile
U share/man/man4/utvfu.4
P sys/dev/pci/if_iwm.c
P sys/dev/pci/if_iwn.c
P sys/kern/kern_sched.c
P sys/ufs/ext2fs/ext2fs_alloc.c
P sys/ufs/ext2fs/ext2fs_balloc.c
P usr.sbin/bgpctl/bgpctl.c
P usr.sbin/bgpd/bgpd.conf.5
P usr.sbin/bgpd/bgpd.h
P usr.sbin/bgpd/parse.y
P usr.sbin/bgpd/rde.c
P usr.sbin/bgpd/rde_filter.c
P usr.sbin/bgpd/util.c
P usr.sbin/pstat/pstat.8
P usr.sbin/pstat/pstat.c
packet_write_wait: Connection to 206.51.28.2 port 22: Broken pipe
0
[2016-05-21T01:26:28+0800] done cvs update



HEADS UP: important tweaks in proot(1)

2016-06-04 Thread Marc Espie
By default, it now does unpopulate_light. I'm now reasonably confident
the avoidance mechanisms for not deleting important stuff are good enough,
so it will wipe chroots of anything that doesn't belong there.

See the man page which was updated accordingly. Some fringe case scenarios
may need to use preserve  if they have chroot data that's not accounted
for otherwise.

In general, it should have little impact on current users of proot I know
of, most of which actually use unpopulate* already.



Re: kern continue

2016-06-04 Thread Marcus Glocker
On Fri, Jun 03, 2016 at 09:31:27PM -0400, Ted Unangst wrote:

> a few more here and there.
 
ok mglocker
 
> Index: ddb/db_examine.c
> ===
> RCS file: /cvs/src/sys/ddb/db_examine.c,v
> retrieving revision 1.21
> diff -u -p -r1.21 db_examine.c
> --- ddb/db_examine.c  19 Apr 2016 12:23:25 -  1.21
> +++ ddb/db_examine.c  4 Jun 2016 01:28:06 -
> @@ -277,7 +277,7 @@ db_strlcpy(char *dst, const char *src, s
>   if (siz != 0)
>   *d = '\0';  /* NUL-terminate dst */
>   while (*s++)
> - ;
> + continue;
>   }
>  
>   return(s - src - 1);/* count does not include NUL */
> Index: dev/hotplug.c
> ===
> RCS file: /cvs/src/sys/dev/hotplug.c,v
> retrieving revision 1.15
> diff -u -p -r1.15 hotplug.c
> --- dev/hotplug.c 14 Mar 2015 03:38:46 -  1.15
> +++ dev/hotplug.c 4 Jun 2016 01:28:12 -
> @@ -134,7 +134,7 @@ hotplugclose(dev_t dev, int flag, int mo
>   struct hotplug_event he;
>  
>   while (hotplug_get_event(&he) == 0)
> - ;
> + continue;
>   opened = 0;
>   return (0);
>  }
> Index: dev/ipmi.c
> ===
> RCS file: /cvs/src/sys/dev/ipmi.c,v
> retrieving revision 1.96
> diff -u -p -r1.96 ipmi.c
> --- dev/ipmi.c27 Mar 2016 12:45:47 -  1.96
> +++ dev/ipmi.c4 Jun 2016 01:28:16 -
> @@ -640,7 +640,7 @@ kcs_wait(struct ipmi_softc *sc, u_int8_t
>   if ((v & KCS_STATE_MASK) == KCS_ERROR_STATE) {
>   bmc_write(sc, _KCS_COMMAND_REGISTER, KCS_GET_STATUS);
>   while (bmc_read(sc, _KCS_STATUS_REGISTER) & KCS_IBF)
> - ;
> + continue;
>   printf("%s: error code: %x\n", DEVNAME(sc),
>   bmc_read(sc, _KCS_DATAIN_REGISTER));
>   }
> Index: kern/kern_pledge.c
> ===
> RCS file: /cvs/src/sys/kern/kern_pledge.c,v
> retrieving revision 1.167
> diff -u -p -r1.167 kern_pledge.c
> --- kern/kern_pledge.c27 May 2016 16:33:55 -  1.167
> +++ kern/kern_pledge.c4 Jun 2016 01:28:21 -
> @@ -1601,7 +1601,7 @@ canonpath(const char *input, char *buf, 
>   p += 3;
>   if (q != buf)   /* "/../" at start of buf */
>   while (*--q != '/')
> - ;
> + continue;
>  
>   } else {
>   *q++ = *p++;
> Index: kern/kgdb_stub.c
> ===
> RCS file: /cvs/src/sys/kern/kgdb_stub.c,v
> retrieving revision 1.10
> diff -u -p -r1.10 kgdb_stub.c
> --- kern/kgdb_stub.c  7 Mar 2016 18:43:59 -   1.10
> +++ kern/kgdb_stub.c  4 Jun 2016 01:28:26 -
> @@ -240,7 +240,7 @@ kgdb_recv(u_char *bp, int maxlen)
>   p = bp;
>   csum = len = 0;
>   while ((c = GETC()) != KGDB_START)
> - ;
> + continue;
>  
>   while ((c = GETC()) != KGDB_END && len < maxlen) {
>   c &= 0x7f;
> Index: kern/vfs_bio.c
> ===
> RCS file: /cvs/src/sys/kern/vfs_bio.c,v
> retrieving revision 1.174
> diff -u -p -r1.174 vfs_bio.c
> --- kern/vfs_bio.c17 Mar 2016 03:57:51 -  1.174
> +++ kern/vfs_bio.c4 Jun 2016 01:28:32 -
> @@ -908,7 +908,7 @@ geteblk(int size)
>   struct buf *bp;
>  
>   while ((bp = buf_get(NULL, 0, size)) == NULL)
> - ;
> + continue;
>  
>   return (bp);
>  }
> @@ -1319,7 +1319,7 @@ bufcache_adjust(void)
>   &cleancache[i].warmbufpages) ||
>   chillbufs(&cleancache[i], &cleancache[i].hotqueue,
>   &cleancache[i].hotbufpages))
> - ;
> + continue;
>   }
>  }
>  
> Index: net/pf.c
> ===
> RCS file: /cvs/src/sys/net/pf.c,v
> retrieving revision 1.974
> diff -u -p -r1.974 pf.c
> --- net/pf.c  31 May 2016 07:35:36 -  1.974
> +++ net/pf.c  4 Jun 2016 01:28:57 -
> @@ -3867,7 +3867,7 @@ pf_tcp_track_full(struct pf_pdesc *pd, s
>   if (dst->seqdiff && !src->seqdiff) {
>   /* use random iss for the TCP server */
>   while ((src->seqdiff = arc4random() - seq) == 0)
> - ;
> + continue;
>   ack = ntohl(th->th_ack) - dst->seqdiff;
>   pf_change_a(pd, &th->th_seq, htonl(seq + src->seqdiff));
>   pf_change_a(pd, &th->th_ack, htonl(ack));
> Index: n