All of lore.kernel.org
 help / color / mirror / Atom feed
* getting a list of naked interface names from iproute2
@ 2015-02-17  0:07 Matthew Thode
  2015-02-17 15:23 ` Stephen Hemminger
  0 siblings, 1 reply; 4+ messages in thread
From: Matthew Thode @ 2015-02-17  0:07 UTC (permalink / raw)
  To: netdev

[-- Attachment #1: Type: text/plain, Size: 700 bytes --]

iproute2 seems to like to add @ and : info to it's output.  This makes
parsing it hard for things like neutron (openstack).  I have a patch to
slightly update it (still missing some things, I'll link it at the end
if interested).  Is there a better way of getting interface names from
iproute2 without having to strip out at characters like '@' and ':'?

changeset in neutron: https://review.openstack.org/#/c/154128/
link to current code:
https://github.com/openstack/neutron/blob/master/neutron/agent/linux/ip_lib.py#L110-L131

I'd appreciate your help, I'd rather not have to go through each link
type to pull it's delimiter, but if needed I guess it's needed.

-- 
Matthew Thode


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: getting a list of naked interface names from iproute2
  2015-02-17  0:07 getting a list of naked interface names from iproute2 Matthew Thode
@ 2015-02-17 15:23 ` Stephen Hemminger
  2015-02-18  4:45   ` Matthew Thode
  0 siblings, 1 reply; 4+ messages in thread
From: Stephen Hemminger @ 2015-02-17 15:23 UTC (permalink / raw)
  To: Matthew Thode; +Cc: netdev

On Mon, 16 Feb 2015 18:07:12 -0600
Matthew Thode <mthode@mthode.org> wrote:

> iproute2 seems to like to add @ and : info to it's output.  This makes
> parsing it hard for things like neutron (openstack).  I have a patch to
> slightly update it (still missing some things, I'll link it at the end
> if interested).  Is there a better way of getting interface names from
> iproute2 without having to strip out at characters like '@' and ':'?
> 
> changeset in neutron: https://review.openstack.org/#/c/154128/
> link to current code:
> https://github.com/openstack/neutron/blob/master/neutron/agent/linux/ip_lib.py#L110-L131
> 
> I'd appreciate your help, I'd rather not have to go through each link
> type to pull it's delimiter, but if needed I guess it's needed.
> 

Stop screenscraping, and use a real API.
All of the above would work better:
  1. Libc if_nameindex
  2. Legacy ioctl(SIOCGIFCONF)
  3. Netlink  NLMMSG_REQ (RTM_GETLINK)
  4. Sysfs /sys/class/net

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: getting a list of naked interface names from iproute2
  2015-02-17 15:23 ` Stephen Hemminger
@ 2015-02-18  4:45   ` Matthew Thode
  2015-02-18 18:55     ` Cong Wang
  0 siblings, 1 reply; 4+ messages in thread
From: Matthew Thode @ 2015-02-18  4:45 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev

[-- Attachment #1: Type: text/plain, Size: 1287 bytes --]

On 02/17/2015 09:23 AM, Stephen Hemminger wrote:
> On Mon, 16 Feb 2015 18:07:12 -0600
> Matthew Thode <mthode@mthode.org> wrote:
> 
>> iproute2 seems to like to add @ and : info to it's output.  This makes
>> parsing it hard for things like neutron (openstack).  I have a patch to
>> slightly update it (still missing some things, I'll link it at the end
>> if interested).  Is there a better way of getting interface names from
>> iproute2 without having to strip out at characters like '@' and ':'?
>>
>> changeset in neutron: https://review.openstack.org/#/c/154128/
>> link to current code:
>> https://github.com/openstack/neutron/blob/master/neutron/agent/linux/ip_lib.py#L110-L131
>>
>> I'd appreciate your help, I'd rather not have to go through each link
>> type to pull it's delimiter, but if needed I guess it's needed.
>>
> 
> Stop screenscraping, and use a real API.
> All of the above would work better:
>   1. Libc if_nameindex
>   2. Legacy ioctl(SIOCGIFCONF)
>   3. Netlink  NLMMSG_REQ (RTM_GETLINK)
>   4. Sysfs /sys/class/net
> 
Do you happen to know a way to request it for a specific namespace?
going over the links in /sys/class/net only gets you the current
namespace (was the easiest method to do in python2.7).

-- 
Matthew Thode


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: getting a list of naked interface names from iproute2
  2015-02-18  4:45   ` Matthew Thode
@ 2015-02-18 18:55     ` Cong Wang
  0 siblings, 0 replies; 4+ messages in thread
From: Cong Wang @ 2015-02-18 18:55 UTC (permalink / raw)
  To: mthode; +Cc: Stephen Hemminger, netdev

On Tue, Feb 17, 2015 at 8:45 PM, Matthew Thode <mthode@mthode.org> wrote:
> Do you happen to know a way to request it for a specific namespace?
> going over the links in /sys/class/net only gets you the current
> namespace (was the easiest method to do in python2.7).

The interface is not friendly. You need to open an fd which points to the
netns proc file or the pid of a task inside the namespace, take a look at how
`ip netns exec` is implemented.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-02-18 18:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-17  0:07 getting a list of naked interface names from iproute2 Matthew Thode
2015-02-17 15:23 ` Stephen Hemminger
2015-02-18  4:45   ` Matthew Thode
2015-02-18 18:55     ` Cong Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.