claudiodangelis/qrcp

picks the wrong interface if it is aliased

Sfinx opened this issue · 8 comments

Sfinx commented

Tried to use v0.9.1 but it always picks wrong interface. I have

br0 with 10.x.x.x
br0:0 with 192.168.x.x

It lists only br0 with 192.168.x.x IP which is definitely wrong.

Thanks for reporting!
Will have a look at it after holidays,
Claudio

@Sfinx can you please paste the output of ip a | grep br so I can try to reproduce?

Nevermind, I don't really need that,
Thanks

Sfinx commented

Please see below. To reproduce just add alias:

ifconfig br0:0 ip_addr/mask
ip a | grep br
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master br0 state UP group default qlen 1000
    link/ether d8:c4:97:7d:67:7c brd ff:ff:ff:ff:ff:ff
    link/ether 9c:da:3e:f2:0a:c1 brd ff:ff:ff:ff:ff:ff
4: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether f6:da:83:28:c9:e1 brd ff:ff:ff:ff:ff:ff
    inet 10.1.1.203/24 brd 10.1.1.255 scope global br0
    inet 192.168.0.10/24 brd 192.168.0.255 scope global br0:0
5: virbr2: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 52:54:00:46:e9:a8 brd ff:ff:ff:ff:ff:ff
    inet 192.168.42.1/24 brd 192.168.42.255 scope global virbr2
6: br-89843508955a: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:c1:05:b6:38 brd ff:ff:ff:ff:ff:ff
    inet 172.21.0.1/16 brd 172.21.255.255 scope global br-89843508955a
    link/ether 02:42:c8:f3:d3:61 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
8: br-ff10821ca939: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:cb:bb:4f:b0 brd ff:ff:ff:ff:ff:ff
    inet 172.18.0.1/16 brd 172.18.255.255 scope global br-ff10821ca939
    link/ether 02:4b:77:22:51:13 brd ff:ff:ff:ff:ff:ff link-netnsid 0

Edited: wrong server ;)

Surprisingly, I can't find a way of retrieving the alias name.
I'm considering adding a bind configuration parameter where you can just set the bind address to overcome this wrong interface address issue.
What do you think?

Configuration file:

bind: 10.20.30.40

Command line:

qrcp --bind 10.20.30.40 /some/file
Sfinx commented

I guess rta_type must be IFLA_IFALIAS (man rtnetlink). Bind approach will work too

The thing is that the current approach is based on the name of the interface as set in the configuration file.
The issue is that by using Go's standard library I can't retrieve the actual name of the alias, i.e. br0:0.
I can correctly get the aliased address, but not its name.

If you have ideas, please feel free to share!

It's ready for testing, if you want to give it a try:

git fetch -a
git checkout feat-add-bind-config
go build
./qrcp --bind 10.x.x.x /some/file
Sfinx commented

Thank you, but I do not use your app as it took an half year for this issue fix. Sorry, this is too long for me