google / gopacket

Provides packet processing capabilities for Go
BSD 3-Clause "New" or "Revised" License
6.35k stars 1.13k forks source link

Out of order interface error while creating new router #830

Open sivachandran opened 4 years ago

sivachandran commented 4 years ago

Getting out of order iface error from routing.New. I can see that the error is coming from this line. But I don't understand why the interface index needs to match with for-loop index.

On my machine the interfaces are listed non-sequentially

$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq qlen 1000
    link/ether dc:a6:32:6a:e3:b0 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.2/29 brd 10.0.0.7 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::dea6:32ff:fe6a:e3b0/64 scope link
       valid_lft forever preferred_lft forever
5: wg0: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1420 qdisc noqueue qlen 1000
    link/[65534]
    inet 10.0.0.1/32 scope global wg0
       valid_lft forever preferred_lft forever

Can someone explain why the implementation expects interface index to be sequential?

sivachandran commented 4 years ago

@gconnell ^

Capstan commented 4 years ago

Possible duplicate of issue #222.

Capstan commented 4 years ago

I get this as well when running in a docker container, where the index 3 interface has an internal index of 5.

gboddin commented 3 years ago

Long time no fix ? What's wrong with the patch ?

gboddin commented 3 years ago

Thx :)

tmatth commented 2 months ago

This would warrant a new release, for now I'm using github.com/google/gopacket v1.1.20-0.20220810144506-32ee38206866