looks OK to me, but are routing domains only supported for IPv4?
If so, please mention that they don't work for IPv6.

-d

On Mon, 10 Aug 2009, Claudio Jeker wrote:

> On Sat, Aug 08, 2009 at 05:08:45PM -0300, Christiano Farina Haesbaert wrote:
> > I've discovered that my patch reads the wrong tcp table entry, as soon
> > as I fix this I'll mail the final patch.
> > 
> 
> I had to add rdomain support to tcpbench so that I can use it in my
> test setup. Diff is attached, I hope it does not conflict too much with
> the rewrite comming up.
> 
> If possible I would like to commit this soon.
> -- 
> :wq Claudio
> 
> Index: tcpbench.1
> ===================================================================
> RCS file: /cvs/src/usr.bin/tcpbench/tcpbench.1,v
> retrieving revision 1.5
> diff -u -p -r1.5 tcpbench.1
> --- tcpbench.1        26 Jun 2008 07:05:56 -0000      1.5
> +++ tcpbench.1        10 Aug 2009 10:04:43 -0000
> @@ -31,6 +31,7 @@
>  .Op Fl p Ar port
>  .Op Fl r Ar rate
>  .Op Fl S Ar space
> +.Op Fl V Ar rdomain
>  .Ar hostname
>  .Nm
>  .Fl s
> @@ -40,6 +41,7 @@
>  .Op Fl p Ar port
>  .Op Fl r Ar rate
>  .Op Fl S Ar space
> +.Op Fl V Ar rdomain
>  .Sh DESCRIPTION
>  .Nm
>  is a small tool that performs throughput benchmarking and concurrent
> @@ -94,6 +96,9 @@ Place
>  .Nm
>  in server mode, where it will listen on all interfaces for incoming
>  connections.
> +.It Fl V Ar rdomain
> +Set the routing domain.
> +The default is 0.
>  .It Fl v
>  Display verbose output.
>  If specified more than once, increase the detail of information displayed.
> Index: tcpbench.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/tcpbench/tcpbench.c,v
> retrieving revision 1.8
> diff -u -p -r1.8 tcpbench.c
> --- tcpbench.c        18 Sep 2008 10:23:33 -0000      1.8
> +++ tcpbench.c        9 Aug 2009 10:30:38 -0000
> @@ -54,6 +54,8 @@
>  sig_atomic_t done = 0;
>  sig_atomic_t print_stats = 0;
>  
> +u_int rdomain;
> +
>  struct statctx {
>       struct timeval t_start, t_last, t_cur;
>       unsigned long long bytes;
> @@ -113,10 +115,10 @@ usage(void)
>       fprintf(stderr,
>           "usage: tcpbench -l\n"
>           "       tcpbench [-v] [-B buf] [-k kvars] [-n connections]"
> -         " [-p port] [-r rate]\n"
> +         " [-p port] [-r rate] [-V rdomain]\n"
>           "                [-S space] hostname\n"
>           "       tcpbench -s [-v] [-B buf] [-k kvars] [-p port] [-r rate]"
> -         " [-S space]\n");
> +         " [-S space] [-V rdomain]\n");
>       exit(1);
>  }
>  
> @@ -500,6 +502,11 @@ serverloop(kvm_t *kvmh, u_long ktcbtab, 
>                               warn("socket");
>                       continue;
>               }
> +             if (rdomain && ai->ai_family == AF_INET) {
> +                     if (setsockopt(sock, IPPROTO_IP, SO_RDOMAIN,
> +                         &rdomain, sizeof(rdomain)) == -1)
> +                             err(1, "setsockopt SO_RDOMAIN");
> +             }
>               if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
>                   &on, sizeof(on)) == -1)
>                       warn("reuse port");
> @@ -646,6 +653,11 @@ clientloop(kvm_t *kvmh, u_long ktcbtab, 
>                                       warn("socket");
>                               continue;
>                       }
> +                     if (rdomain && ai->ai_family == AF_INET) {
> +                             if (setsockopt(sock, IPPROTO_IP, SO_RDOMAIN,
> +                                 &rdomain, sizeof(rdomain)) == -1)
> +                                     err(1, "setsockopt SO_RDOMAIN");
> +                     }
>                       if (Sflag) {
>                               if (setsockopt(sock, SOL_SOCKET, SO_SNDBUF,
>                                   &Sflag, sizeof(Sflag)) == -1)
> @@ -757,7 +769,7 @@ main(int argc, char **argv)
>  
>       struct nlist nl[] = { { "_tcbtable" }, { "" } };
>  
> -     while ((ch = getopt(argc, argv, "B:hlk:n:p:r:sS:v")) != -1) {
> +     while ((ch = getopt(argc, argv, "B:hlk:n:p:r:sS:vV:")) != -1) {
>               switch (ch) {
>               case 'l':
>                       list_kvars();
> @@ -797,6 +809,13 @@ main(int argc, char **argv)
>                       break;
>               case 'v':
>                       vflag++;
> +                     break;
> +             case 'V':
> +                     rdomain = (unsigned int)strtonum(optarg, 0,
> +                         RT_TABLEID_MAX, &errstr);
> +                     if (errstr)
> +                             errx(1, "rdomain value is %s: %s",
> +                                 errstr, optarg);
>                       break;
>               case 'n':
>                       nconn = strtonum(optarg, 0, 65535, &errstr);

Reply via email to