Bug 88871 - SO_BINDTODEVICE set sock's sk_bound_dev_if ,but interface's index can chang where interface down and up
Summary: SO_BINDTODEVICE set sock's sk_bound_dev_if ,but interface's index can chang w...
Status: NEW
Alias: None
Product: Networking
Classification: Unclassified
Component: Other (show other bugs)
Hardware: All Linux
: P1 high
Assignee: Stephen Hemminger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-25 06:50 UTC by chris_bt
Modified: 2016-02-15 20:33 UTC (History)
3 users (show)

See Also:
Kernel Version: 3.4
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description chris_bt 2014-11-25 06:50:39 UTC
call setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, iface_brlan, iface_len + 1), the sock's sk_bound_dev_if be set to iface_brlan's index, when i pull out other cab and plug in,  the br-lan's index can changed, the tcp packet to the socket be rest, because the orignal sk_bound_dev_if not match current br-lan's index
Comment 1 Stephen Hemminger 2014-11-25 15:57:10 UTC
When ifindex changes it is a new device. I am not sure what your interface type is. Hardwired devices never change ifindex. Tunnels change ifindex when they are destroyed and recreated.
Comment 2 chris_bt 2014-11-26 05:46:53 UTC
my route is openwrt AA 12.02, kernel is 3.4, below is list of net device:
root@newifi:/etc# ip link list
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN mode DEFAULT 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN mode DEFAULT qlen 1000
    link/ether 20:76:93:27:cb:b8 brd ff:ff:ff:ff:ff:ff
3: gre0: <NOARP> mtu 1476 qdisc noop state DOWN mode DEFAULT 
    link/gre 0.0.0.0 brd 0.0.0.0
4: imq0: <NOARP> mtu 16000 qdisc noop state DOWN mode DEFAULT qlen 11000
    link/void 
5: imq1: <NOARP> mtu 16000 qdisc noop state DOWN mode DEFAULT qlen 11000
    link/void 
6: ra0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br-lan state UNKNOWN mode DEFAULT qlen 1000
    link/ether 20:76:93:27:cb:b8 brd ff:ff:ff:ff:ff:ff
7: rai0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br-lan state UNKNOWN mode DEFAULT qlen 1000
    link/ether 20:76:93:27:cb:ba brd ff:ff:ff:ff:ff:ff
8: wds0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
    link/ether 20:76:93:27:cb:b8 brd ff:ff:ff:ff:ff:ff
9: wds1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
    link/ether 20:76:93:27:cb:b8 brd ff:ff:ff:ff:ff:ff
10: wds2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
    link/ether 20:76:93:27:cb:b8 brd ff:ff:ff:ff:ff:ff
11: wds3: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
    link/ether 20:76:93:27:cb:b8 brd ff:ff:ff:ff:ff:ff
12: apcli0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
    link/ether 22:76:93:26:cb:b8 brd ff:ff:ff:ff:ff:ff
13: apclii0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
    link/ether 22:76:93:26:cb:ba brd ff:ff:ff:ff:ff:ff
14: br-lan: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT 
    link/ether 20:76:93:27:cb:b8 brd ff:ff:ff:ff:ff:ff
15: eth2.1@eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-lan state UP mode DEFAULT 
    link/ether 20:76:93:27:cb:b8 brd ff:ff:ff:ff:ff:ff
16: eth2.2@eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT 
    link/ether 20:76:93:27:cb:bb brd ff:ff:ff:ff:ff:ff

after i pull out and plug in the WAN cab, the br-lan's index is changed:

root@newifi:/etc# ip link list
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN mode DEFAULT 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN mode DEFAULT qlen 1000
    link/ether 20:76:93:27:cb:b8 brd ff:ff:ff:ff:ff:ff
3: gre0: <NOARP> mtu 1476 qdisc noop state DOWN mode DEFAULT 
    link/gre 0.0.0.0 brd 0.0.0.0
4: imq0: <NOARP> mtu 16000 qdisc noop state DOWN mode DEFAULT qlen 11000
    link/void 
5: imq1: <NOARP> mtu 16000 qdisc noop state DOWN mode DEFAULT qlen 11000
    link/void 
6: ra0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN mode DEFAULT qlen 1000
    link/ether 20:76:93:27:cb:b8 brd ff:ff:ff:ff:ff:ff
7: rai0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN mode DEFAULT qlen 1000
    link/ether 20:76:93:27:cb:ba brd ff:ff:ff:ff:ff:ff
8: wds0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
    link/ether 20:76:93:27:cb:b8 brd ff:ff:ff:ff:ff:ff
9: wds1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
    link/ether 20:76:93:27:cb:b8 brd ff:ff:ff:ff:ff:ff
10: wds2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
    link/ether 20:76:93:27:cb:b8 brd ff:ff:ff:ff:ff:ff
11: wds3: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
    link/ether 20:76:93:27:cb:b8 brd ff:ff:ff:ff:ff:ff
12: apcli0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
    link/ether 22:76:93:26:cb:b8 brd ff:ff:ff:ff:ff:ff
13: apclii0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
    link/ether 22:76:93:26:cb:ba brd ff:ff:ff:ff:ff:ff
15: eth2.1@eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-lan state UP mode DEFAULT 
    link/ether 20:76:93:27:cb:b8 brd ff:ff:ff:ff:ff:ff
17: br-lan: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT 
    link/ether 20:76:93:27:cb:b8 brd ff:ff:ff:ff:ff:ff
18: eth2.2@eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT 
    link/ether 20:76:93:27:cb:bb brd ff:ff:ff:ff:ff:ff

the br-lan should be bridgeds device,as you said, it's index should not change, but the index is change from 14 ==> 17
Comment 3 Daniel Borkmann 2014-11-26 09:02:23 UTC
(In reply to chris_bt from comment #2)
> my route is openwrt AA 12.02, kernel is 3.4, below is list of net device:
...
> after i pull out and plug in the WAN cab, the br-lan's index is changed:
...
> the br-lan should be bridgeds device,as you said, it's index should not
> change, but the index is change from 14 ==> 17

OpenWRT doesn't fully use vanilla kernel out of the box, but comes with its own patches and drivers applied on top.

You might want to report this issue to them first as it's currently hard to tell without looking into their non-mainlined patches.

Note You need to log in before you can comment on or make changes to this bug.