diff options
| author | Ben Pfaff <blp@nicira.com> | 2009-11-23 12:25:08 -0800 |
|---|---|---|
| committer | Ben Pfaff <blp@nicira.com> | 2009-11-23 12:25:08 -0800 |
| commit | 9ab3d9a3c24ee7132d85f5874f35ea5cb98b1588 (patch) | |
| tree | 2af341a808770638be8ae9e123b7de6f53ff2290 /lib/netdev-linux.c | |
| parent | d161c099279e9ab564636c72423268e6da69f795 (diff) | |
| download | openvswitch-9ab3d9a3c24ee7132d85f5874f35ea5cb98b1588.tar.gz | |
netdev: New function netdev_get_ifindex().
sFlow needs the ifindex of an interface, so this commit adds a function
to retrieve it.
Diffstat (limited to 'lib/netdev-linux.c')
| -rw-r--r-- | lib/netdev-linux.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index 3ccd6be93..b8e8015d4 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -548,6 +548,17 @@ netdev_linux_get_mtu(const struct netdev *netdev_, int *mtup) return 0; } +/* Returns the ifindex of 'netdev', if successful, as a positive number. + * On failure, returns a negative errno value. */ +static int +netdev_linux_get_ifindex(const struct netdev *netdev) +{ + int ifindex, error; + + error = get_ifindex(netdev, &ifindex); + return error ? -error : ifindex; +} + static int netdev_linux_get_carrier(const struct netdev *netdev_, bool *carrier) { @@ -1388,6 +1399,7 @@ const struct netdev_class netdev_linux_class = { netdev_linux_set_etheraddr, netdev_linux_get_etheraddr, netdev_linux_get_mtu, + netdev_linux_get_ifindex, netdev_linux_get_carrier, netdev_linux_get_stats, @@ -1432,6 +1444,7 @@ const struct netdev_class netdev_tap_class = { netdev_linux_set_etheraddr, netdev_linux_get_etheraddr, netdev_linux_get_mtu, + netdev_linux_get_ifindex, netdev_linux_get_carrier, netdev_linux_get_stats, |
