I've not been able to test the diff yet, but I'm certainly interested
in that functionality.

On Tue, Jul 26, 2011 at 2:33 PM, Claudio Jeker <cje...@diehard.n-r-g.com>
wrote:
> On Thu, Jul 21, 2011 at 10:20:38PM +0200, Claudio Jeker wrote:
>> On Thu, Jul 21, 2011 at 01:57:10PM -0500, Josh Hoppes wrote:
>> > Thanks for the help and for the better understanding of routing
>> > domains and tables. In the end I was over thinking the problem and
>> > didn't actually need the additional routing table.
>> >
>> > On Thu, Jul 21, 2011 at 10:17 AM, Claudio Jeker
>> > <cje...@diehard.n-r-g.com> wrote:
>> > > On Thu, Jul 21, 2011 at 09:40:44AM +0300, Gregory Edigarov wrote:
>> > >> Josh,
>> > >>
>> > >> the table needs to be created and an interface need to be assigned to
>> > >> the rdomain like:
>> > >>
>> > >> ifconfig  em0 a.b.c.d/24 rdomain 1
>> > >>
>> > >> then you can use it like, just for example, this:
>> > >> route -T 1 add e.f.g.h/24 a.b.c.x
>> > >>
>> > >> that does the trick.
>> > >
>> > > Nope. Something sneaked in that makes it impossible to create
alternative
>> > > tables. I will have a look.
>> > >
>> > > --
>> > > :wq Claudio
>> >
>>
>> Still here is a diff to fix the porblem. route(8) was failing too early.
>> Maybe someone has a better idea on how to solve the gettable() issue in a
>> nicer way.
>>
>
> Is nobody interested in this?
>
> route -T 1 add 127.0.0.1 127.0.0.1 should work. This is how routing tables
> are supposed to be created. It would suck to be unable to do this.
>
> Sending it to tech@ as well.
> --
> :wq Claudio
>
> Index: route.c
> ===================================================================
> RCS file: /cvs/src/sbin/route/route.c,v
> retrieving revision 1.155
> diff -u -p -r1.155 route.c
> --- route.c     4 Jul 2011 22:48:31 -0000       1.155
> +++ route.c     21 Jul 2011 20:16:45 -0000
> @@ -102,7 +102,7 @@ void         set_metric(char *, int);
>  void    inet_makenetandmask(u_int32_t, struct sockaddr_in *, int);
>  void    interfaces(void);
>  void    getlabel(char *);
> -void    gettable(const char *);
> +int     gettable(const char *);
>  int     rdomain(int, char **);
>
>  __dead void
> @@ -130,6 +130,7 @@ main(int argc, char **argv)
>        int ch;
>        int rval = 0;
>        int kw;
> +       int Terr = 0;
>
>        if (argc < 2)
>                usage(NULL);
> @@ -150,7 +151,7 @@ main(int argc, char **argv)
>                        tflag = 1;
>                        break;
>                case 'T':
> -                       gettable(optarg);
> +                       Terr = gettable(optarg);
>                        Tflag = 1;
>                        break;
>                case 'd':
> @@ -169,6 +170,10 @@ main(int argc, char **argv)
>                usage(NULL);
>
>        kw = keyword(*argv);
> +       if (Tflag && Terr != 0 && kw != K_ADD) {
> +               errno = Terr;
> +               err(1, "routing table %i", tableid);
> +       }
>        switch (kw) {
>        case K_EXEC:
>                break;
> @@ -183,7 +188,8 @@ main(int argc, char **argv)
>                if (s == -1)
>                        err(1, "socket");
>                /* force socket onto table user requested */
> -               if (Tflag && setsockopt(s, AF_ROUTE, ROUTE_TABLEFILTER,
> +               if (Tflag == 1 && Terr == 0 &&
> +                   setsockopt(s, AF_ROUTE, ROUTE_TABLEFILTER,
>                    &tableid, sizeof(tableid)) == -1)
>                        err(1, "setsockopt(ROUTE_TABLEFILTER)");
>                break;
> @@ -1630,7 +1636,7 @@ getlabel(char *name)
>        rtm_addrs |= RTA_LABEL;
>  }
>
> -void
> +int
>  gettable(const char *s)
>  {
>        const char              *errstr;
> @@ -1651,7 +1657,9 @@ gettable(const char *s)
>
>        len = sizeof(info);
>        if (sysctl(mib, 6, &info, &len, NULL, 0) == -1)
> -               err(1, "routing table %i", tableid);
> +               return (errno);
> +       else
> +               return (0);
>  }
>
>  int

Reply via email to