Bug 14514 - if_index is not parsed correctly if interfaces = "$ip/$mask;if_index=$id"
Summary: if_index is not parsed correctly if interfaces = "$ip/$mask;if_index=$id"
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: File services (show other bugs)
Version: 4.10.17
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Karolin Seeger
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks: 14534
  Show dependency treegraph
 
Reported: 2020-09-26 10:09 UTC by Jones Syue
Modified: 2021-01-14 08:34 UTC (History)
3 users (show)

See Also:


Attachments
IF_INDEX is 4294967295 (65.58 KB, image/png)
2020-09-26 10:09 UTC, Jones Syue
no flags Details
Patch for v4-13-test (3.73 KB, text/plain)
2020-10-21 11:00 UTC, Stefan Metzmacher
slow: review+
Details
Patch for v4-12-test (3.73 KB, patch)
2020-10-21 11:01 UTC, Stefan Metzmacher
slow: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jones Syue 2020-09-26 10:09:07 UTC
Created attachment 16262 [details]
IF_INDEX is 4294967295

In SDC 2020 SMB3 Virtual IO Lab,
run Windows Protocol Test Suite to test FileServer multichannel test cases.
Samba server has 2 virtual interfaces for VPN connection:
> name=tun2001, ip/mask=192.168.144.9/22
> name=tun2002, ip/mask=192.168.144.10/22
test suite client can ping these 2 ip addresses and browse shares.
Then client try to use IOCTL FSCTL_QUERY_NETWORK_INTERFACE_INFO to get the 
virtual ip addresses of samba server, but samba server responded it 
without the virtual ip addresses. My VPN setup is point-to-point and the
virtual interfaces 'tun2001' & 'tun2002' are without flag IFF_BROADCAST. 
So edit smb.conf and add 
"interfaces = ${virtual_ip}/${mask_length};if_index=${id}", like this:
> interfaces = eth4 eth8 eth11 eth10 qvs0 "192.168.144.9/22;if_index=50" "192.168.144.10/22;if_index=51"
then samba server IOCTL response could return the virtual ip addresses, 
but found a issue:
the interface index of virtual ip addresses is always 4294967295 
(0xFFFFFFFF, -1).

* Steps to reproduce
1. Setup VPN and get 2 virtual interfaces: tun2001 and tun2002.
> # ifconfig | grep -B1 "inet\s" | grep -E "[0-9]|lo"
> eth10     Link encap:Ethernet  HWaddr 24:5E:BE:2A:98:D2
>           inet addr:67.30.1.2  Bcast:67.30.1.255  Mask:255.255.255.0
> eth11     Link encap:Ethernet  HWaddr 24:5E:BE:2A:98:D1
>           inet addr:67.30.2.2  Bcast:67.30.2.255  Mask:255.255.255.0
> eth4      Link encap:Ethernet  HWaddr 24:5E:BE:35:7D:91
>           inet addr:67.55.1.2  Bcast:67.55.1.255  Mask:255.255.255.0
> eth8      Link encap:Ethernet  HWaddr 24:5E:BE:26:E8:02
>           inet addr:67.55.2.2  Bcast:67.55.2.255  Mask:255.255.255.0
> lo        Link encap:Local Loopback
>           inet addr:127.0.0.1  Mask:255.0.0.0
> qvs0      Link encap:Ethernet  HWaddr 24:5E:BE:2B:FA:45
>           inet addr:10.19.250.195  Bcast:10.19.255.255  Mask:255.255.0.0
> tun2001   Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
>           inet addr:192.168.144.9  P-t-P:192.168.144.9  Mask:255.255.252.0
> tun2002   Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
>           inet addr:192.168.144.10  P-t-P:192.168.144.10  Mask:255.255.252.0
> # ip address | grep -B2 "inet\s" | grep -E "[0-9]|lo|link"
> ... <cut> ...
> 50: tun2001: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 100
>     link/none
>     inet 192.168.144.9/22 brd 192.168.147.255 scope global tun2001
> 51: tun2002: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 100
>     link/none
>     inet 192.168.144.10/22 brd 192.168.147.255 scope global tun2002
2. Add virtual ip address, mask, and if_index into smb.conf
> > interfaces = eth4 eth8 eth11 eth10 qvs0 "192.168.144.9/22;if_index=50" "192.168.144.10/22;if_index=51"
3. Check the IOCTL FSCTL_QUERY_NETWORK_INTERFACE_INFO response.

* Actual result
The interface index of virtual interfaces is always 4294967295.

* Expected result.
The interface index of virtual interfaces should follow 'if_index' setup.
Comment 1 Stefan Metzmacher 2020-09-26 10:14:20 UTC
I also saw this and also a panic when if_index=1,capability=RSS was specified.
Comment 2 Jones Syue 2020-09-26 10:23:32 UTC
CI is in progress, patch against master:
https://gitlab.com/samba-team/devel/samba/-/pipelines/194817199
Comment 3 Jones Syue 2020-09-26 10:25:35 UTC
(In reply to Stefan Metzmacher from comment #1)

ohh not noticed my test only apply if_index,
will test this combination: if_index=1,capability=RSS
Comment 4 Stefan Metzmacher 2020-09-26 10:39:03 UTC
(In reply to Jones Syue from comment #3)

I'm not 100% sure, I'll have to take a closer look at some log files/backtraces
next week.
Comment 5 Jones Syue 2020-09-28 01:05:23 UTC
Before apply the patch, 'local_interfaces' does not list the virtual ip 
addresses: 192.168.144.9 & 192.168.144.10

(gdb) set $i=0
set $end=8
while ($i < $end)
printf "name=%s,\tflags=%#x(IFF_BROADCAST=%s), if_index=%d, speed=%lld, capability=%d\n", probed_ifaces[$i]->name, probed_ifaces[$i]->flags, probed_ifaces[$i]->flags&IFF_BROADCAST ? "true" : "false", probed_ifaces[$i]->if_index, probed_ifaces[$i]->linkspeed, probed_ifaces[$i]->capability
set $i=$i+1
end
name=eth11,     flags=0x11043(IFF_BROADCAST=true), if_index=12, speed=10000000000, capability=1
name=eth4,      flags=0x11043(IFF_BROADCAST=true), if_index=6, speed=10000000000, capability=1
name=eth8,      flags=0x11043(IFF_BROADCAST=true), if_index=8, speed=10000000000, capability=1
name=lo,        flags=0x10049(IFF_BROADCAST=false), if_index=1, speed=1000000000, capability=0
name=tun2001,   flags=0x110d1(IFF_BROADCAST=false), if_index=50, speed=10000000, capability=0
name=tun2002,   flags=0x110d1(IFF_BROADCAST=false), if_index=51, speed=10000000, capability=0
name=qvs0,      flags=0x11043(IFF_BROADCAST=true), if_index=27, speed=1000000000, capability=0
name=eth10,     flags=0x11043(IFF_BROADCAST=true), if_index=13, speed=10000000000, capability=1
(gdb)
(gdb) define plist
  set var $n = $arg0
  while $n
    printf "name=%s,\t\tflags=%#x(IFF_BROADCAST=%s), if_index=%d, speed=%lld, capability=%d\n", $n->name, $n->flags, $n->flags&IFF_BROADCAST ? "true" : "false", $n->if_index, $n->linkspeed, $n->capability
    set var $n = $n->next
  end
end
(gdb) plist local_interfaces
name=eth10,             flags=0x11043(IFF_BROADCAST=true), if_index=13, speed=10000000000, capability=1
name=qvs0,              flags=0x11043(IFF_BROADCAST=true), if_index=27, speed=1000000000, capability=0
name=eth8,              flags=0x11043(IFF_BROADCAST=true), if_index=8, speed=10000000000, capability=1
name=eth4,              flags=0x11043(IFF_BROADCAST=true), if_index=6, speed=10000000000, capability=1
name=eth11,             flags=0x11043(IFF_BROADCAST=true), if_index=12, speed=10000000000, capability=1
(gdb)
Comment 6 Jones Syue 2020-09-28 01:06:32 UTC
After apply the patch, 'local_interfaces' could list the virtual ip 
addresses: 192.168.144.9 & 192.168.144.10

(gdb) plist local_interfaces
name=192.168.144.10/,           flags=0x2(IFF_BROADCAST=true), if_index=0, speed=1000000000, capability=0
name=192.168.144.9/2,           flags=0x2(IFF_BROADCAST=true), if_index=0, speed=1000000000, capability=0
name=qvs0,              flags=0x11043(IFF_BROADCAST=true), if_index=27, speed=1000000000, capability=0
name=eth10,             flags=0x11043(IFF_BROADCAST=true), if_index=13, speed=10000000000, capability=1
name=eth11,             flags=0x11043(IFF_BROADCAST=true), if_index=12, speed=10000000000, capability=1
name=eth8,              flags=0x11043(IFF_BROADCAST=true), if_index=8, speed=10000000000, capability=1
name=eth4,              flags=0x11043(IFF_BROADCAST=true), if_index=6, speed=10000000000, capability=1
(gdb)
Comment 7 Jones Syue 2020-09-28 01:24:59 UTC
patch v2 against master,
add Metze comments (stack trace) from GitLab into git log, no change code,
CI is in progress:
https://gitlab.com/samba-team/devel/samba/-/commit/ac3f22a88c3dbbdef1e2a326f800a3ed418e3b3f
Comment 8 Jones Syue 2020-09-28 01:27:23 UTC
(In reply to Jones Syue from comment #7)

CI is in progress:
https://gitlab.com/samba-team/devel/samba/-/pipelines/195132757
Comment 9 Jones Syue 2020-09-28 01:37:17 UTC
(In reply to Jones Syue from comment #6, comment #5)

Wrong comment, please skip.
Comment 10 Jones Syue 2020-09-28 01:42:45 UTC
probed_interfaces can list the virtual ip addresses: 
192.168.144.9 & 192.168.144.10
Before apply patch, local_interfaces found the if_index of virtual ip is 0,
fsctl_network_iface_info() will translate 0 to UINT32_MAX (4294967295) and
return to client.

(gdb) set $i=0
set $end=8
while ($i < $end)
printf "name=%s,\tflags=%#x(IFF_BROADCAST=%s), if_index=%d, speed=%lld, capability=%d\n", probed_ifaces[$i]->name, probed_ifaces[$i]->flags, probed_ifaces[$i]->flags&IFF_BROADCAST ? "true" : "false", probed_ifaces[$i]->if_index, probed_ifaces[$i]->linkspeed, probed_ifaces[$i]->capability
set $i=$i+1
end
name=eth11,     flags=0x11043(IFF_BROADCAST=true), if_index=12, speed=10000000000, capability=1
name=eth4,      flags=0x11043(IFF_BROADCAST=true), if_index=6, speed=10000000000, capability=1
name=eth8,      flags=0x11043(IFF_BROADCAST=true), if_index=8, speed=10000000000, capability=1
name=lo,        flags=0x10049(IFF_BROADCAST=false), if_index=1, speed=1000000000, capability=0
name=tun2001,   flags=0x110d1(IFF_BROADCAST=false), if_index=50, speed=10000000, capability=0
name=tun2002,   flags=0x110d1(IFF_BROADCAST=false), if_index=51, speed=10000000, capability=0
name=qvs0,      flags=0x11043(IFF_BROADCAST=true), if_index=27, speed=1000000000, capability=0
name=eth10,     flags=0x11043(IFF_BROADCAST=true), if_index=13, speed=10000000000, capability=1
(gdb)
(gdb) define plist
  set var $n = $arg0
  while $n
    printf "name=%s,\t\tflags=%#x(IFF_BROADCAST=%s), if_index=%d, speed=%lld, capability=%d\n", $n->name, $n->flags, $n->flags&IFF_BROADCAST ? "true" : "false", $n->if_index, $n->linkspeed, $n->capability
    set var $n = $n->next
  end
end
(gdb) plist local_interfaces
name=192.168.144.10/,           flags=0x2(IFF_BROADCAST=true), if_index=0, speed=1000000000, capability=0
name=192.168.144.9/2,           flags=0x2(IFF_BROADCAST=true), if_index=0, speed=1000000000, capability=0
name=qvs0,              flags=0x11043(IFF_BROADCAST=true), if_index=27, speed=1000000000, capability=0
name=eth10,             flags=0x11043(IFF_BROADCAST=true), if_index=13, speed=10000000000, capability=1
name=eth11,             flags=0x11043(IFF_BROADCAST=true), if_index=12, speed=10000000000, capability=1
name=eth8,              flags=0x11043(IFF_BROADCAST=true), if_index=8, speed=10000000000, capability=1
name=eth4,              flags=0x11043(IFF_BROADCAST=true), if_index=6, speed=10000000000, capability=1
(gdb)

> fsctl_network_iface_info
>		cur->ifindex = iface->if_index;
>		if (cur->ifindex == 0) {
>			/*
>			 * Did not get interface index from kernel,
>			 * nor from the config. ==> Apply a common
>			 * default value for these cases.
>			 */
>			cur->ifindex = UINT32_MAX;
>		}
Comment 11 Jones Syue 2020-09-28 01:44:05 UTC
After patch,
if_index can be parsed correctly, and fsctl_network_iface_info() can return
expected if_index to client.

(gdb) plist local_interfaces

name=192.168.144.10/,           flags=0x2(IFF_BROADCAST=true), if_index=51, speed=1000000000, capability=0
name=192.168.144.9/2,           flags=0x2(IFF_BROADCAST=true), if_index=50, speed=1000000000, capability=0
name=qvs0,              flags=0x11043(IFF_BROADCAST=true), if_index=27, speed=1000000000, capability=0
name=eth10,             flags=0x11043(IFF_BROADCAST=true), if_index=13, speed=10000000000, capability=1
name=eth11,             flags=0x11043(IFF_BROADCAST=true), if_index=12, speed=10000000000, capability=1
name=eth8,              flags=0x11043(IFF_BROADCAST=true), if_index=8, speed=10000000000, capability=1
name=eth4,              flags=0x11043(IFF_BROADCAST=true), if_index=6, speed=10000000000, capability=1
Comment 12 Jones Syue 2020-09-28 03:03:22 UTC
add bug id into git commit log, CI is in progress:
https://gitlab.com/samba-team/devel/samba/-/pipelines/195149340
Comment 14 Samba QA Contact 2020-10-14 12:30:05 UTC
This bug was referenced in samba master:

b78ff5717654064c8a4facc54a8e9833e5843c21
Comment 15 Stefan Metzmacher 2020-10-21 11:00:57 UTC
Created attachment 16292 [details]
Patch for v4-13-test
Comment 16 Stefan Metzmacher 2020-10-21 11:01:23 UTC
Created attachment 16293 [details]
Patch for v4-12-test
Comment 17 Ralph Böhme 2020-11-06 13:06:22 UTC
Reassigning to Karolin for inclusion in 4.12 and 4.13.
Comment 18 Karolin Seeger 2020-11-19 09:49:09 UTC
(In reply to Ralph Böhme from comment #17)
Pushed to autobuild-v4-{13,12}-test.
Comment 19 Samba QA Contact 2020-11-19 11:25:14 UTC
This bug was referenced in samba v4-13-test:

68f19debb7453a83d1837c4a0595f7d433b562c0
Comment 20 Samba QA Contact 2020-11-19 14:10:23 UTC
This bug was referenced in samba v4-12-test:

4873f377e75d5104b4ca2afbc36783b850463eb0
Comment 21 Karolin Seeger 2020-11-24 11:19:39 UTC
Pushed to both branches.
Closing out bug report.

Thanks!
Comment 22 Samba QA Contact 2020-12-16 12:21:52 UTC
This bug was referenced in samba v4-13-stable (Release samba-4.13.3):

68f19debb7453a83d1837c4a0595f7d433b562c0
Comment 23 Samba QA Contact 2021-01-14 08:34:02 UTC
This bug was referenced in samba v4-12-stable (Release samba-4.12.11):

4873f377e75d5104b4ca2afbc36783b850463eb0