Datera / rtslib

The Linux SCSI Target API
http://linux-iscsi.org
Apache License 2.0
19 stars 17 forks source link

list_eth_names does not enumerate IPv6-only interfaces #17

Open nivex opened 8 years ago

nivex commented 8 years ago

utils.py:616

def list_eth_names(max_eth=1024):
    '''
    List the max_eth first local ethernet interfaces names from SIOCGIFCONF
    struct.
    '''
SIOCGIFCONF = 0x8912

Per https://linux.die.net/man/7/netdevice : SIOCGIFCONF Return a list of interface (transport layer) addresses. This currently means only addresses of the AF_INET (IPv4) family for compatibility. ...

My interfaces:

$ ip addr
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    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:  mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:21:85:10:77:49 brd ff:ff:ff:ff:ff:ff
    inet 172.31.3.4/24 brd 172.31.3.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 2606:a000:a449:5900::4/64 scope global
       valid_lft forever preferred_lft forever
    inet6 fe80::221:85ff:fe10:7749/64 scope link
       valid_lft forever preferred_lft forever
3: eth0.121@eth0:  mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:21:85:10:77:49 brd ff:ff:ff:ff:ff:ff
    inet6 fd60:e0:a0f4:121::4/64 scope global
       valid_lft forever preferred_lft forever
    inet6 fe80::221:85ff:fe10:7749/64 scope link
       valid_lft forever preferred_lft forever

Resulting enumeration:

$ python
>>> import rtslib.utils
>>> rtslib.utils.list_eth_names()
['lo', 'eth0']

Ran headlong into this when trying to create a portal in targetcli.