[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120724095659.5c869511@nehalam.linuxnetplumber.net>
Date: Tue, 24 Jul 2012 09:56:59 -0700
From: Stephen Hemminger <shemminger@...tta.com>
To: Olaf Hering <olaf@...fle.de>
Cc: "K. Y. Srinivasan" <kys@...rosoft.com>, gregkh@...uxfoundation.org,
linux-kernel@...r.kernel.org, devel@...uxdriverproject.org,
virtualization@...ts.osdl.org, apw@...onical.com,
netdev@...r.kernel.org, ben@...adent.org.uk
Subject: Re: [PATCH 10/17] Tools: hv: Gather ipv[4,6] gateway information
On Tue, 24 Jul 2012 18:53:59 +0200
Olaf Hering <olaf@...fle.de> wrote:
> On Tue, Jul 24, Stephen Hemminger wrote:
>
> > On Tue, 24 Jul 2012 09:01:34 -0700
> > "K. Y. Srinivasan" <kys@...rosoft.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
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists