summaryrefslogtreecommitdiff
path: root/source3/lib/interface.c
AgeCommit message (Collapse)AuthorFilesLines
2025-05-15lib: Save lines by avoiding explicit ZERO_STRUCTP callsVolker Lendecke1-3/+1
SMB_CALLOC_ARRAY(..., 1) does this. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2025-03-12s3/lib: fix matching interfaces with multiple assigned IPsRalph Boehme1-1/+4
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15823 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Björn Jacke <bjacke@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net> Autobuild-User(master): Martin Schwenke <martins@samba.org> Autobuild-Date(master): Wed Mar 12 01:32:30 UTC 2025 on atb-devel-224
2024-04-16lib-interface: Change API for interface 'options'Vinit Agnihotri1-4/+4
Signed-off-by: Vinit Agnihotri <vagnihotri@ddn.com> Reviewed-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2024-04-16lib-interface: Add parsing for interface 'options'Vinit Agnihotri1-3/+31
Signed-off-by: Vinit Agnihotri <vagnihotri@ddn.com> Reviewed-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2024-04-16lib-interface: Add new API to validate interface info for given interface indexVinit Agnihotri1-0/+17
Signed-off-by: Vinit Agnihotri <vagnihotri@ddn.com> Reviewed-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-07-13s3:lib: Fix code spellingAndreas Schneider1-1/+1
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
2020-10-14interface: fix if_index is not parsed correctlyJones Syue1-1/+1
Replace probed_ifaces[i] with ifs. 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). Quote Metze: https://gitlab.com/samba-team/devel/samba/-/commit/6cadb55d975a6348a417caed8b3258f5be2acba4#note_419181789 This looks good, I think that also explains the possible memory corruption/crash I mentioned in the bug report. As 'i' is most likely the same as 'total_probed' and probed_ifaces[i] is not valid, so we overwrite unrelated memory. Later I see 'realloc(): invalid pointer' and this backtrace: BACKTRACE: #0 log_stack_trace + 0x29 [ip=0x7f2f1b6fffa9] [sp=0x7ffcd0ab53e0] #1 smb_panic + 0x11 [ip=0x7f2f1b700301] [sp=0x7ffcd0ab5d10] #2 sig_fault + 0x54 [ip=0x7f2f1b7004f4] [sp=0x7ffcd0ab5e20] #3 funlockfile + 0x50 [ip=0x7f2f17ce6dd0] [sp=0x7ffcd0ab5ec0] #4 gsignal + 0x10f [ip=0x7f2f1794970f] [sp=0x7ffcd0ab6b90] #5 abort + 0x127 [ip=0x7f2f17933b25] [sp=0x7ffcd0ab6cb0] #6 __libc_message + 0x297 [ip=0x7f2f1798c897] [sp=0x7ffcd0ab6de0] #7 malloc_printerr + 0x1c [ip=0x7f2f17992fdc] [sp=0x7ffcd0ab6ef0] #8 realloc + 0x23a [ip=0x7f2f17997f6a] [sp=0x7ffcd0ab6f00] #9 _talloc_realloc + 0xee [ip=0x7f2f1a365d2e] [sp=0x7ffcd0ab6f50] #10 messaging_filtered_read_send + 0x18c [ip=0x7f2f1a10f54c] [sp=0x7ffcd0ab6fb0] #11 messaging_read_send + 0x55 [ip=0x7f2f1a10f705] [sp=0x7ffcd0ab7000] #12 smb2srv_session_table_init + 0x83 [ip=0x7f2f1b3a6cd3] [sp=0x7ffcd0ab7040] #13 smbXsrv_connection_init_tables + 0x2d [ip=0x7f2f1b373f4d] [sp=0x7ffcd0ab7060] #14 smbd_smb2_request_process_negprot + 0x827 [ip=0x7f2f1b38cb47] [sp=0x7ffcd0ab7080] #15 smbd_smb2_request_dispatch + 0x19db [ip=0x7f2f1b38921b] [sp=0x7ffcd0ab71d0] #16 smbd_smb2_process_negprot + 0x298 [ip=0x7f2f1b38bb38] [sp=0x7ffcd0ab7260] #17 process_smb + 0x2ca [ip=0x7f2f1b37537a] [sp=0x7ffcd0ab72b0] #18 smbd_server_connection_read_handler + 0xd0 [ip=0x7f2f1b376420] [sp=0x7ffcd0ab7350] BUG: https://bugzilla.samba.org/show_bug.cgi?id=14514 Signed-off-by: Jones Syue <jonessyue@qnap.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2020-08-03lib: relicense smb_strtoul(l) under LGPLv3Ralph Boehme1-0/+1
Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Mon Aug 3 22:21:04 UTC 2020 on sn-devel-184
2020-05-07interface: clarify the quoting for advanced "interfaces" optionsStefan Metzmacher1-1/+7
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2020-05-07interface: allow overriding speed/cap/if_index for named interfacesSteven Noonan1-11/+20
Signed-off-by: Steven Noonan <steven@uplinklabs.net> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2019-06-30source3: Update all consumers of strtoul_err(), strtoull_err() to new APISwen Schillig1-5/+12
Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
2019-04-11lib: Update error check for new string conversion wrapperSwen Schillig1-1/+1
The new string conversion wrappers detect and flag errors which occured during the string to integer conversion. Those modifications required an update of the callees error checks. Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
2019-03-01lib: Use wrapper for string to integer conversionSwen Schillig1-4/+14
In order to detect an value overflow error during the string to integer conversion with strtoul/strtoull, the errno variable must be set to zero before the execution and checked after the conversion is performed. This is achieved by using the wrapper function strtoul_err and strtoull_err. Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Ralph Böhme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2016-01-26s3:lib: extend interpret_interface() to optionally read speed, caps, and ↵Michael Adam1-0/+105
index from config New syntax for interfaces parameter: interfaces = address[;key=value[,key=value[,...]]] - keys can be 'speed', 'capability', and 'if_index'. - speed is in bits per second. - capability can be RSS and RDMA. - if_index should be used with care, because these indexes should not conicide with indexes the kernel sets... Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2016-01-26s3:lib: remove an unmotivated comment from interpret_interface()Michael Adam1-1/+0
This seems to be a left-over from historic code. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2016-01-26s3:lib: copy speed, cap, and index in add_interface()Michael Adam1-0/+3
Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2015-09-30s3:lib:interface: break an overly long lineMichael Adam1-1/+3
Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2014-04-16lib-util: rename memdup to smb_memdup and fix all callersBjörn Baumbach1-2/+2
Signed-off-by: Björn Baumbach <bb@sernet.de> Reviewed-by: Volker Lendecke <vl@samba.org>
2011-05-08s3-lib Use common lib/socket code for get_interfaces() et alAndrew Bartlett1-1/+1
2011-05-05More const fixes for compiler warnings from the waf build.Jeremy Allison1-1/+1
2011-03-16s3-interfaces: only include interfaces.h where needed.Günther Deschner1-0/+1
Guenther
2009-11-18s3:load_interfaces(): use function gfree_interfaces() that we have.Michael Adam1-9/+1
To reduce code duplication. Michael
2009-05-18Fix bug 5681: Do not limit the number of network interfacesVolker Lendecke1-6/+9
Jeremy as far as I can see there is no real technical reason to limit the number of interfaces. If you like this patch, can you please merge it to 3.4? If you don't please tell me :-) Thanks, Volker
2009-02-04Have nmbd check all available interfaces for WINS before failingAravind Srinivasan1-2/+5
When nmbd is acting as WINS, it picks the first interface's IP as WINS server's IP. If the first interface's IP is zero, we will just quit (even though we might have other interfaces with valid IPs). This patch makes nmbd look at all interfaces and pick the first interface with a valid IP as the WINS server's IP.
2008-12-03s3: Change sockaddr util function names for consistencyTim Prouty1-6/+6
Also eliminates name conflicts with OneFS system libraries
2008-10-23Fix prototype for set_sockaddr_port.Jelmer Vernooij1-1/+1
2008-10-23Use sockaddr_storage only where we rely on the size, use sockaddrJelmer Vernooij1-19/+22
otherwise (to clarify we can also pass in structs smaller than sockaddr_storage, such as sockaddr_in).
2008-08-19Fix bug 5697 nmbd spins in reload_interfaces when only loopback has an IPv4 ↵Jeremy Allison1-2/+5
address reported by Ted Percival <ted@midg3t.net>. Jeremy. (This used to be commit ab06efccf31fbc899536d2681a2076e6dfd65b9e)
2008-07-02Remove worrying warning message when safe_strcpy tries to copy a pseaudo ↵Jeremy Allison1-1/+1
interface name that's too long. Reported by James Kosin <JKosin@intcomgrp.com>. Jeremy. (This used to be commit 3a7542fd495223c3a504571a52e2d00551fea0e2)
2007-10-25Fix bug in writing names into gencacheJeremy Allison1-8/+0
as well as 2 typos where AF_INET6 was mistypes as AF_INET. JERRY YOU NEED THESE FIXES. Fixes smbclient -L localhost -U% Bugs reported by Kukks (thanks kukks). Jeremy. (This used to be commit f109f82622ca30ae2360e8300152e90b9587ffd8)
2007-10-25Fix resolve name to resolve IPv6 addresses of link-local%ifaddrJeremy Allison1-94/+23
Jeremy. (This used to be commit e6609cab732d5cd5cc9a5ae50aee15147f2ec6ec)
2007-10-24This is a large patch (sorry). Migrate from struct in_addrJeremy Allison1-9/+5
to struct sockaddr_storage in most places that matter (ie. not the nmbd and NetBIOS lookups). This passes make test on an IPv4 box, but I'll have to do more work/testing on IPv6 enabled boxes. This should now give us a framework for testing and finishing the IPv6 migration. It's at the state where someone with a working IPv6 setup should (theorecically) be able to type : smbclient //ipv6-address/share and have it work. Jeremy. (This used to be commit 98e154c3125d5732c37a72d74b0eb5cd7b6155fd)
2007-10-19Add test for "struct in6_addr" to the HAVE_IPV6 configure test.Gerald (Jerry) Carter1-2/+2
Also make use of "if defined(HAVE_IPV6)" rather than testing for AF_INET6 since this is not sufficient on HP-UX 11.11 to ensure a working IPv6 implementation. (This used to be commit 620785df4e57b72471ff0315e22e0d2f28a2b1a5)
2007-10-16Fix access control code to be IPv6/v4 protocol independent.Jeremy Allison1-1/+1
Make unix_wild_match() talloc, not pstring based. Next will be name resolution code, and client code. Jeremy. (This used to be commit f6a01b82c5a47957659df08ea84e335dfbba1826)
2007-10-15Move to protocol independent code in most of lib/util_sock.cJeremy Allison1-3/+3
We don't use gethostbyname any more except in one case where we're looking for host aliases (I don't know how to do that with getaddrinfo yet). New function should be getaddrinfo(). Next step will be fixing lib/access.c, and then changing libsmb/namequery.c to cope with IPv6 address returns. Jeremy. (This used to be commit 4a56b697b6adcf095e25895c4a9ba3192ed34124)
2007-10-14Fix one more place for IFF_LOOPBACKVolker Lendecke1-1/+1
(This used to be commit add1294562b76c38d5e471f280ca1167b4d8a93d)
2007-10-13Fix a segfault with an unknown interfaceVolker Lendecke1-1/+7
"interfaces = foo" with "foo" not being a known interface segfaulted for me. (This used to be commit 556c33702ce6d6c7cde43ddfe965c78ebc2963d3)
2007-10-10Add start of IPv6 implementation. Currently most of this is avoidingJeremy Allison1-185/+459
IPv6 in winbindd, but moves most of the socket functions that were wrongly in lib/util.c into lib/util_sock.c and provides generic IPv4/6 independent versions of most things. Still lots of work to do, but now I can see how I'll fix the access check code. Nasty part that remains is the name resolution code which is used to returning arrays of in_addr structs. Jeremy. (This used to be commit 3f6bd0e1ec5cc6670f3d08f76fc2cd94c9cd1a08)
2007-10-10r25508: Reformatting.Jeremy Allison1-55/+69
Jeremy. (This used to be commit b412ba6fb3e526f5cd83e6cabd952ad7c303c346)
2007-10-10r25472: Fix the interfaces code to detect IPv6 interfaces, using theJeremy Allison1-13/+14
new standard getifaddrs() and freeifaddrs() interfaces. Currently we only return IPv4 af_families. Needs fixing for binds to IPv6 but this has to be careful work. Jeremy. (This used to be commit 327875182c9219aeba687e10aaea93546d9a70ea)
2007-10-10r23784: use the GPLv3 boilerplate as recommended by the FSF and the license textAndrew Tridgell1-2/+1
(This used to be commit b0132e94fc5fef936aa766fb99a306b3628e9f07)
2007-10-10r23779: Change from v2 or later to v3 or later.Jeremy Allison1-1/+1
Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3)
2007-10-10r21854: Add gfree_interfaces() to gfree_all().Günther Deschner1-0/+12
Guenther (This used to be commit eb34ebd9e76061417200a286c2831394be04529b)
2007-10-10r17334: Some C++ warningsVolker Lendecke1-1/+1
(This used to be commit 8ae7ed1f3cecbb5285313d17b5f9511e2e622f0b)
2007-10-10r16582: Fix Klocwork #1997 and all generic class of problemsJeremy Allison1-0/+4
where we don't correctly check the return from memdup. Jeremy. (This used to be commit ce14daf51c7ee2f9c68c77f7f4674e6f0e35c9ca)
2007-10-10r5163: Fix bugzilla 2062:Jim McDonough1-1/+6
turn off broadcast for all 390 NICs. (This used to be commit d159a5013e96a1188599a3fa0bff108fa6f6679b)
2007-10-10r4088: Get medieval on our ass about malloc.... :-). Take control of all our ↵Jeremy Allison1-2/+2
allocation functions so we can funnel through some well known functions. Should help greatly with malloc checking. HEAD patch to follow. Jeremy. (This used to be commit 620f2e608f70ba92f032720c031283d295c5c06a)
2007-10-10r1248: Fix from Nick Wellnhofer <wellnhofer@aevum.de> to preventJeremy Allison1-4/+8
lp_interfaces() list from being corrupted. Jeremy. (This used to be commit c892545960a9c3206b5a1f73e98ea924c802c17c)
2002-11-12Removed global_myworkgroup, global_myname, global_myscope. Added liberalJeremy Allison1-2/+2
dashes of const. This is a rather large check-in, some things may break. It does compile though :-). Jeremy. (This used to be commit f755711df8f74f9b8e8c1a2b0d07d02a931eeb89)
2002-07-15updated the 3.0 branch from the head branch - ready for alpha18Andrew Tridgell1-39/+7
(This used to be commit 03ac082dcb375b6f3ca3d810a6a6367542bc23ce)