To maintain SMB Multichannel, windows client might periodically query with FSCTL_QUERY_NETWORK_INTERFACE_INFO to get SMB server's network information, in my case windows server 2022 would do this every 10 minutes (600 seconds). Consider a scenario: the network information might have changed between these queries, some become link down, new interface is link up, network speed is changed, and etc. So far smbd might not aware of these changes and still report out-of-date network information to windows client, until we manually send a SIGHUP to smbd in order to trigger load_interfaces(): smbd_sig_hup_handler() > reload_services () > load_interfaces() This might be a bit inconvenient because it is hard to decide when should we manually send a SIGHUP to smbd for refreshing network information. This patch adds load_interfaces() at fsctl_network_iface_info(), while smbd received FSCTL_QUERY_NETWORK_INTERFACE_INFO would go through this and refresh local_interfaces, then respond to client with up-to-date network information; also refresh num_ifaces to make sure interfaces count is consistent. patch will follow. gdb shows that how this patch looks like if smbd received the query and refresh local_interfaces to get up-to-date network information, for example, ubuntu 22.04.3 samba-4.19.3, 1. it was only 2 interfaces, ens3 and ens4 2. a new interface ens5 is introduced and link up. 3. smbd received FSCTL_QUERY_NETWORK_INTERFACE_INFO, refresh local_interfaces 4. now smbd aware 3 interfaces are available: ens3, ens4, and ens5 (gdb) watch local_interfaces (gdb) commands bt ilist local_interfaces c end (gdb) c <... cut dummy ...> Hardware watchpoint 1: local_interfaces Old value = (struct interface *) 0x564ef1838ba0 New value = (struct interface *) 0x564ef180b710 add_interface (ifs=0x564ef1858630) at ../../source3/lib/interface.c:344 344 DEBUG(2,("added interface %s ip=%s ", #0 add_interface (ifs=0x564ef1858630) at ../../source3/lib/interface.c:344 #1 0x00007ffa33f11913 in load_interfaces () at ../../source3/lib/interface.c:667 #2 0x00007ffa34114129 in fsctl_network_iface_info (mem_ctx=0x564ef18537f0, ev=0x564ef180dda0, xconn=0x564ef1825ec0, in_input=0x564ef1853808, in_max_output=65536, out_output=0x564ef1853820) at ../../source3/smbd/smb2_ioctl_network_fs.c:403 #3 0x00007ffa34114bb1 in smb2_ioctl_network_fs (ctl_code=1311228, ev=0x564ef180dda0, req=0x564ef1853610, state=0x564ef18537f0) at ../../source3/smbd/smb2_ioctl_network_fs.c:661 #4 0x00007ffa3410ff8b in smbd_smb2_ioctl_send (mem_ctx=0x564ef1853230, ev=0x564ef180dda0, smb2req=0x564ef1853230, fsp=0x0, in_ctl_code=1311228, in_input=..., in_max_output=65536, in_flags=1) at ../../source3/smbd/smb2_ioctl.c:465 #5 0x00007ffa3410f33a in smbd_smb2_request_process_ioctl (req=0x564ef1853230) at ../../source3/smbd/smb2_ioctl.c:224 #6 0x00007ffa340f1e3e in smbd_smb2_request_dispatch (req=0x564ef1853230) at ../../source3/smbd/smb2_server.c:3510 #7 0x00007ffa340f6f31 in smbd_smb2_io_handler (xconn=0x564ef1825ec0, fde_flags=1) at ../../source3/smbd/smb2_server.c:5101 #8 0x00007ffa340f7067 in smbd_smb2_connection_handler (ev=0x564ef180dda0, fde=0x564ef18215c0, flags=1, private_data=0x564ef1825ec0) at ../../source3/smbd/smb2_server.c:5139 #9 0x00007ffa33e231b8 in tevent_common_invoke_fd_handler (fde=0x564ef18215c0, flags=1, removed=0x0) at ../../lib/tevent/tevent_fd.c:158 #10 0x00007ffa33e2ee86 in epoll_event_loop (epoll_ev=0x564ef1823c80, tvalp=0x7ffeb20c5270) at ../../lib/tevent/tevent_epoll.c:730 #11 0x00007ffa33e2f619 in epoll_event_loop_once (ev=0x564ef180dda0, location=0x7ffa341e01e8 "../../source3/smbd/smb2_process.c:2017") at ../../lib/tevent/tevent_epoll.c:946 #12 0x00007ffa33e2bb2e in std_event_loop_once (ev=0x564ef180dda0, location=0x7ffa341e01e8 "../../source3/smbd/smb2_process.c:2017") at ../../lib/tevent/tevent_standard.c:110 #13 0x00007ffa33e21b35 in _tevent_loop_once (ev=0x564ef180dda0, location=0x7ffa341e01e8 "../../source3/smbd/smb2_process.c:2017") at ../../lib/tevent/tevent.c:823 #14 0x00007ffa33e21ebd in tevent_common_loop_wait (ev=0x564ef180dda0, location=0x7ffa341e01e8 "../../source3/smbd/smb2_process.c:2017") at ../../lib/tevent/tevent.c:952 #15 0x00007ffa33e2bbd7 in std_event_loop_wait (ev=0x564ef180dda0, location=0x7ffa341e01e8 "../../source3/smbd/smb2_process.c:2017") at ../../lib/tevent/tevent_standard.c:141 #16 0x00007ffa33e21f64 in _tevent_loop_wait (ev=0x564ef180dda0, location=0x7ffa341e01e8 "../../source3/smbd/smb2_process.c:2017") at ../../lib/tevent/tevent.c:971 #17 0x00007ffa340d7a65 in smbd_process (ev_ctx=0x564ef180dda0, msg_ctx=0x564ef17f9110, sock_fd=34, interactive=false) at ../../source3/smbd/smb2_process.c:2017 #18 0x0000564ef088b27c in smbd_accept_connection (ev=0x564ef180dda0, fde=0x564ef1823670, flags=1, private_data=0x564ef1823bf0) at ../../source3/smbd/server.c:1031 #19 0x00007ffa33e231b8 in tevent_common_invoke_fd_handler (fde=0x564ef1823670, flags=1, removed=0x0) at ../../lib/tevent/tevent_fd.c:158 #20 0x00007ffa33e2ee86 in epoll_event_loop (epoll_ev=0x564ef180dfd0, tvalp=0x7ffeb20c5650) at ../../lib/tevent/tevent_epoll.c:730 #21 0x00007ffa33e2f619 in epoll_event_loop_once (ev=0x564ef180dda0, location=0x564ef08907d8 "../../source3/smbd/server.c:1373") at ../../lib/tevent/tevent_epoll.c:946 #22 0x00007ffa33e2bb2e in std_event_loop_once (ev=0x564ef180dda0, location=0x564ef08907d8 "../../source3/smbd/server.c:1373") at ../../lib/tevent/tevent_standard.c:110 #23 0x00007ffa33e21b35 in _tevent_loop_once (ev=0x564ef180dda0, location=0x564ef08907d8 "../../source3/smbd/server.c:1373") at ../../lib/tevent/tevent.c:823 #24 0x00007ffa33e21ebd in tevent_common_loop_wait (ev=0x564ef180dda0, location=0x564ef08907d8 "../../source3/smbd/server.c:1373") at ../../lib/tevent/tevent.c:952 #25 0x00007ffa33e2bbd7 in std_event_loop_wait (ev=0x564ef180dda0, location=0x564ef08907d8 "../../source3/smbd/server.c:1373") at ../../lib/tevent/tevent_standard.c:141 #26 0x00007ffa33e21f64 in _tevent_loop_wait (ev=0x564ef180dda0, location=0x564ef08907d8 "../../source3/smbd/server.c:1373") at ../../lib/tevent/tevent.c:971 #27 0x0000564ef088c02c in smbd_parent_loop (ev_ctx=0x564ef180dda0, parent=0x564ef180bb40) at ../../source3/smbd/server.c:1373 #28 0x0000564ef088e35f in main (argc=1, argv=0x7ffeb20c5c28) at ../../source3/smbd/server.c:2130 name=ens3, if_index=2, flags=0x11043(IFF_UP=true), speed=1000000000 name=ens5, if_index=4, flags=0x11043(IFF_UP=true), speed=1000000000 name=ens4, if_index=3, flags=0x11043(IFF_UP=true), speed=1000000000 ilist is a gdb define macro to help me understand the local_interfaces. define ilist set var $n = $arg0 while $n printf "name=%s,\tif_index=%d, flags=%#x(IFF_UP=%s), speed=%lld\n", $n->name, $n->if_index, $n->flags, $n->flags&IFF_UP ? "true" : "false", $n->linkspeed set var $n = $n->next end end
merge request: https://gitlab.com/samba-team/samba/-/merge_requests/3469 ci is passed: https://gitlab.com/samba-team/devel/samba/-/pipelines/1126310937
This bug was referenced in samba master: 318fd95d5ea63724798592eb6b4eebaecfa0cbfb
Created attachment 18218 [details] backported patch for 4.19 and 4.18
This bug was referenced in samba v4-18-test: 9f8a73d7cc4bc0662aa527b045bc9925b9b4c71a
This bug was referenced in samba v4-19-test: 50f74d0488438e722eaeb492ae40f07432eb4530
This bug was referenced in samba v4-19-stable (Release samba-4.19.4): 50f74d0488438e722eaeb492ae40f07432eb4530
This bug was referenced in samba v4-18-stable (Release samba-4.18.10): 9f8a73d7cc4bc0662aa527b045bc9925b9b4c71a