* Order of interfaces in output of ip link
@ 2014-09-02 14:27 Ovidiu Mara
2014-09-02 15:04 ` Vadim Kochan
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Ovidiu Mara @ 2014-09-02 14:27 UTC (permalink / raw)
To: netdev
Hi everyone,
The ip command shows the interfaces on this machine in an unnatural order (eth0 followed by eth2 then eth1).
For example:
ip -o link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default \ link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000\ link/ether 2c:59:e5:9a:4c:a4 brd ff:ff:ff:ff:ff:ff
3: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000\ link/ether ac:16:2d:98:9e:d8 brd ff:ff:ff:ff:ff:ff
4: eth1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000\ link/ether 2c:59:e5:9a:4c:a5 brd ff:ff:ff:ff:ff:ff
5: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000\ link/ether ac:16:2d:98:9e:d9 brd ff:ff:ff:ff:ff:ff
6: eth4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000\ link/ether ac:16:2d:98:9e:da brd ff:ff:ff:ff:ff:ff
7: eth5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000\ link/ether ac:16:2d:98:9e:db brd ff:ff:ff:ff:ff:ff
8: eth6: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000\ link/ether a0:36:9f:26:b3:10 brd ff:ff:ff:ff:ff:ff
9: eth7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000\ link/ether a0:36:9f:26:b3:12 brd ff:ff:ff:ff:ff:ff
eth0 and eth1 are two ports on the same network card, so I would expect them to be shown together, as they are numbered. According to the documentation I found here ( http://www.policyrouting.org/iproute2.doc.html#ss9.1.1 ): "The number followed by a colon is the interface index or ifindex. This number uniquely identifies the interface. If you look at the output from cat /proc/net/dev you will see that the network devices are listed in the same order as the numbering you see here."
However in /proc/net/dev they are shown in the natural order:
cat /proc/net/dev
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
eth0: 1000705102 6535806 0 8946 0 0 0 2861813 5252988 39289 0 0 0 0 0 0
eth1: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
eth2: 104506836 257406 0 0 0 0 0 0 648 8 0 0 0 0 0 0
eth3: 104506430 257405 0 0 0 0 0 0 648 8 0 0 0 0 0 0
eth4: 104506430 257405 0 0 0 0 0 0 648 8 0 0 0 0 0 0
eth5: 104505618 257403 0 0 0 0 0 0 648 8 0 0 0 0 0 0
eth6: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
eth7: 396628856508 364243051 0 0 0 0 0 0 398063721522 365214422 0 0 0 0 0 0
lo: 178 2 0 0 0 0 0 0 178 2 0 0 0 0 0 0
I'm using iproute2-3.11.0.
Could you please tell me if there is any workaround for this?
Thanks,
Ovidiu
PS Please CC me in replies.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Order of interfaces in output of ip link
2014-09-02 14:27 Order of interfaces in output of ip link Ovidiu Mara
@ 2014-09-02 15:04 ` Vadim Kochan
2014-09-02 19:30 ` Cong Wang
2014-09-03 5:43 ` Michal Kubecek
2 siblings, 0 replies; 4+ messages in thread
From: Vadim Kochan @ 2014-09-02 15:04 UTC (permalink / raw)
To: Ovidiu Mara; +Cc: netdev
Hi,
Seems ip tool gets interfaces list via rtnetlink from index hash list
but /proc/net/dev gets them from dev name hash list,
hence the different order.
Regards,
On Tue, Sep 2, 2014 at 5:27 PM, Ovidiu Mara <ovidiu.mara@epfl.ch> wrote:
> Hi everyone,
>
> The ip command shows the interfaces on this machine in an unnatural order (eth0 followed by eth2 then eth1).
>
> For example:
>
> ip -o link
> 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default \ link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
> 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000\ link/ether 2c:59:e5:9a:4c:a4 brd ff:ff:ff:ff:ff:ff
> 3: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000\ link/ether ac:16:2d:98:9e:d8 brd ff:ff:ff:ff:ff:ff
> 4: eth1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000\ link/ether 2c:59:e5:9a:4c:a5 brd ff:ff:ff:ff:ff:ff
> 5: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000\ link/ether ac:16:2d:98:9e:d9 brd ff:ff:ff:ff:ff:ff
> 6: eth4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000\ link/ether ac:16:2d:98:9e:da brd ff:ff:ff:ff:ff:ff
> 7: eth5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000\ link/ether ac:16:2d:98:9e:db brd ff:ff:ff:ff:ff:ff
> 8: eth6: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000\ link/ether a0:36:9f:26:b3:10 brd ff:ff:ff:ff:ff:ff
> 9: eth7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000\ link/ether a0:36:9f:26:b3:12 brd ff:ff:ff:ff:ff:ff
>
> eth0 and eth1 are two ports on the same network card, so I would expect them to be shown together, as they are numbered. According to the documentation I found here ( http://www.policyrouting.org/iproute2.doc.html#ss9.1.1 ): "The number followed by a colon is the interface index or ifindex. This number uniquely identifies the interface. If you look at the output from cat /proc/net/dev you will see that the network devices are listed in the same order as the numbering you see here."
>
> However in /proc/net/dev they are shown in the natural order:
>
> cat /proc/net/dev
> Inter-| Receive | Transmit
> face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
> eth0: 1000705102 6535806 0 8946 0 0 0 2861813 5252988 39289 0 0 0 0 0 0
> eth1: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> eth2: 104506836 257406 0 0 0 0 0 0 648 8 0 0 0 0 0 0
> eth3: 104506430 257405 0 0 0 0 0 0 648 8 0 0 0 0 0 0
> eth4: 104506430 257405 0 0 0 0 0 0 648 8 0 0 0 0 0 0
> eth5: 104505618 257403 0 0 0 0 0 0 648 8 0 0 0 0 0 0
> eth6: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> eth7: 396628856508 364243051 0 0 0 0 0 0 398063721522 365214422 0 0 0 0 0 0
> lo: 178 2 0 0 0 0 0 0 178 2 0 0 0 0 0 0
>
> I'm using iproute2-3.11.0.
>
> Could you please tell me if there is any workaround for this?
>
> Thanks,
> Ovidiu
>
> PS Please CC me in replies.
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Order of interfaces in output of ip link
2014-09-02 14:27 Order of interfaces in output of ip link Ovidiu Mara
2014-09-02 15:04 ` Vadim Kochan
@ 2014-09-02 19:30 ` Cong Wang
2014-09-03 5:43 ` Michal Kubecek
2 siblings, 0 replies; 4+ messages in thread
From: Cong Wang @ 2014-09-02 19:30 UTC (permalink / raw)
To: Ovidiu Mara; +Cc: netdev
On Tue, Sep 2, 2014 at 7:27 AM, Ovidiu Mara <ovidiu.mara@epfl.ch> wrote:
> eth0 and eth1 are two ports on the same network card, so I would expect them to be shown together, as they are numbered. According to the documentation I found here ( http://www.policyrouting.org/iproute2.doc.html#ss9.1.1 ): "The number followed by a colon is the interface index or ifindex. This number uniquely identifies the interface. If you look at the output from cat /proc/net/dev you will see that the network devices are listed in the same order as the numbering you see here."
>
You can't rely on the output order to tell if they are the ports
on the same card, you need to dig some other information
for example sysfs.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Order of interfaces in output of ip link
2014-09-02 14:27 Order of interfaces in output of ip link Ovidiu Mara
2014-09-02 15:04 ` Vadim Kochan
2014-09-02 19:30 ` Cong Wang
@ 2014-09-03 5:43 ` Michal Kubecek
2 siblings, 0 replies; 4+ messages in thread
From: Michal Kubecek @ 2014-09-03 5:43 UTC (permalink / raw)
To: netdev; +Cc: Ovidiu Mara
On Tue, Sep 02, 2014 at 04:27:42PM +0200, Ovidiu Mara wrote:
> The ip command shows the interfaces on this machine in an unnatural order (eth0 followed by eth2 then eth1).
> ...
> 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000\ link/ether 2c:59:e5:9a:4c:a4 brd ff:ff:ff:ff:ff:ff
> 3: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000\ link/ether ac:16:2d:98:9e:d8 brd ff:ff:ff:ff:ff:ff
> 4: eth1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000\ link/ether 2c:59:e5:9a:4c:a5 brd ff:ff:ff:ff:ff:ff
> 5: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000\ link/ether ac:16:2d:98:9e:d9 brd ff:ff:ff:ff:ff:ff
> ...
> eth0 and eth1 are two ports on the same network card, so I would
> expect them to be shown together, as they are numbered.
In general, you can't expect that. As drivers can initialize in
parallel, it happens quite often that interfaces are interleaved like
this. Actually, the names are probably misleading here: most likely the
interface with index 3 was named "eth1" by kernel and interface with
index 4 was named eth2 but udev changed the names.
> Could you please tell me if there is any workaround for this?
It depends on what exactly you want to achieve and why. But AFAIK ip
documentation doesn't promise any particular order of the interfaces so
it's wrong to assume any.
Michal Kubecek
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-09-03 5:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-02 14:27 Order of interfaces in output of ip link Ovidiu Mara
2014-09-02 15:04 ` Vadim Kochan
2014-09-02 19:30 ` Cong Wang
2014-09-03 5:43 ` Michal Kubecek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).