lkml.org 
[lkml]   [2012]   [Jul]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [PATCH 10/17] Tools: hv: Gather ipv[4,6] gateway information
    From
    Date
    On Tue, 2012-07-24 at 09:56 -0700, Stephen Hemminger wrote:
    > On Tue, 24 Jul 2012 18:53:59 +0200
    > Olaf Hering <olaf@aepfle.de> wrote:
    >
    > > On Tue, Jul 24, Stephen Hemminger wrote:
    > >
    > > > On Tue, 24 Jul 2012 09:01:34 -0700
    > > > "K. Y. Srinivasan" <kys@microsoft.com> wrote:
    > > >
    > > > > + memset(cmd, 0, sizeof(cmd));
    > > > > + strcat(cmd, "/sbin/ip -f inet route | grep -w ");
    > > > > + strcat(cmd, if_name);
    > > > > + strcat(cmd, " | awk '/default/ {print $3 }'");
    > > >
    > > >
    > > > Much simpler method:
    > > >
    > > > ip route show match 0/0
    > >
    > > This also has the benefit that ip is not called with absolute path, now
    > > that distros move binaries around.
    > >
    > > Olaf
    >
    > It is also not hard to do the same thing with a little function
    > using libmnl

    Yeah seriously, netlink anyone? You'll even get nicer error reporting
    that way.

    Dan



    \
     
     \ /
      Last update: 2012-07-24 21:21    [W:0.030 / U:0.428 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site