hrev54113 adds 3 changesets to branch 'master'
old head: e6aa2145277f3c477366bf710dd68ed2460771b6
new head: a03ed4fa08bc9a276a8c52f3ca17aad29bad65ca
overview:
https://git.haiku-os.org/haiku/log/?qt=range&q=a03ed4fa08bc+%5Ee6aa2145277f
----------------------------------------------------------------------------
bf9a85cb018f: udp: fix trace build on x86_64.
add current thread id.
Change-Id: I275dcee5ae27e357c8733a1aab9310e9dbc7a839
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2546
Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>
0424248dcbb8: kernel/fs: allow sendto to be called with a NULL address
POSIX says: If the socket is connection-mode, dest_addr shall be ignored.
Change-Id: Ic75de473173e3795066beeac9a9f2404418d94da
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2547
Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>
a03ed4fa08bc: udp: set is_connected flag on our socket once connected.
Change-Id: Ie5fcc5152af813d74d33c20ed7c3e81f9e828518
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2548
Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>
[ Jérôme Duval <jerome.duval@xxxxxxxxx> ]
----------------------------------------------------------------------------
3 files changed, 37 insertions(+), 21 deletions(-)
src/add-ons/kernel/network/protocols/udp/udp.cpp | 39 ++++++++++++--------
src/add-ons/kernel/network/stack/net_socket.cpp | 5 +++
src/system/kernel/fs/socket.cpp | 14 ++++---
############################################################################
Commit: bf9a85cb018f22962d532ed19101d9a2595109ae
URL: https://git.haiku-os.org/haiku/commit/?id=bf9a85cb018f
Author: Jérôme Duval <jerome.duval@xxxxxxxxx>
Date: Fri May 1 19:28:32 2020 UTC
Committer: waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Sat May 2 00:52:20 2020 UTC
udp: fix trace build on x86_64.
add current thread id.
Change-Id: I275dcee5ae27e357c8733a1aab9310e9dbc7a839
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2546
Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>
----------------------------------------------------------------------------
diff --git a/src/add-ons/kernel/network/protocols/udp/udp.cpp
b/src/add-ons/kernel/network/protocols/udp/udp.cpp
index adcf884e16..9be6d767bb 100644
--- a/src/add-ons/kernel/network/protocols/udp/udp.cpp
+++ b/src/add-ons/kernel/network/protocols/udp/udp.cpp
@@ -44,12 +44,15 @@
# define TRACE_BLOCK(x) dump_block x
// do not remove the space before ', ##args' if you want this
// to compile with gcc 2.95
-# define TRACE_EP(format, args...) dprintf("UDP [%llu] %p " format
"\n", \
- system_time(), this , ##args)
-# define TRACE_EPM(format, args...) dprintf("UDP [%llu] " format
"\n", \
- system_time() , ##args)
-# define TRACE_DOMAIN(format, args...) dprintf("UDP [%llu] (%d) "
format \
- "\n", system_time(), Domain()->family , ##args)
+# define TRACE_EP(format, args...) dprintf("UDP [%" B_PRIu64 ",%" \
+ B_PRIu32 "] %p " format "\n", system_time(), \
+ thread_get_current_thread_id(), this , ##args)
+# define TRACE_EPM(format, args...) dprintf("UDP [%" B_PRIu64 ",%" \
+ B_PRIu32 "] " format "\n", system_time() , \
+ thread_get_current_thread_id() , ##args)
+# define TRACE_DOMAIN(format, args...) dprintf("UDP [%" B_PRIu64 ",%" \
+ B_PRIu32 "] (%d) " format "\n", system_time(), \
+ thread_get_current_thread_id(), Domain()->family , ##args)
#else
# define TRACE_BLOCK(x)
# define TRACE_EP(args...) do { } while (0)
@@ -771,7 +774,7 @@ UdpEndpointManager::ReceiveError(status_t error,
net_buffer* buffer)
status_t
UdpEndpointManager::Deframe(net_buffer* buffer)
{
- TRACE_EPM("Deframe(%p [%ld bytes])", buffer, buffer->size);
+ TRACE_EPM("Deframe(%p [%" B_PRIu32 " bytes])", buffer, buffer->size);
NetBufferHeaderReader<udp_header> bufferHeader(buffer);
if (bufferHeader.Status() != B_OK)
@@ -995,7 +998,8 @@ UdpEndpoint::Free()
status_t
UdpEndpoint::SendRoutedData(net_buffer *buffer, net_route *route)
{
- TRACE_EP("SendRoutedData(%p [%lu bytes], %p)", buffer, buffer->size,
route);
+ TRACE_EP("SendRoutedData(%p [%" B_PRIu32 " bytes], %p)", buffer,
+ buffer->size, route);
if (buffer->size > (0xffff - sizeof(udp_header)))
return EMSGSIZE;
@@ -1029,7 +1033,7 @@ UdpEndpoint::SendRoutedData(net_buffer *buffer, net_route
*route)
status_t
UdpEndpoint::SendData(net_buffer *buffer)
{
- TRACE_EP("SendData(%p [%lu bytes])", buffer, buffer->size);
+ TRACE_EP("SendData(%p [%" B_PRIu32 " bytes])", buffer, buffer->size);
return gDatalinkModule->send_data(this, NULL, buffer);
}
@@ -1050,14 +1054,15 @@ UdpEndpoint::BytesAvailable()
status_t
UdpEndpoint::FetchData(size_t numBytes, uint32 flags, net_buffer **_buffer)
{
- TRACE_EP("FetchData(%ld, 0x%lx)", numBytes, flags);
+ TRACE_EP("FetchData(%" B_PRIuSIZE ", 0x%" B_PRIx32 ")", numBytes,
flags);
status_t status = Dequeue(flags, _buffer);
TRACE_EP(" FetchData(): returned from fifo status: %s",
strerror(status));
if (status != B_OK)
return status;
- TRACE_EP(" FetchData(): returns buffer with %ld bytes",
(*_buffer)->size);
+ TRACE_EP(" FetchData(): returns buffer with %" B_PRIu32 " bytes",
+ (*_buffer)->size);
return B_OK;
}
@@ -1065,7 +1070,7 @@ UdpEndpoint::FetchData(size_t numBytes, uint32 flags,
net_buffer **_buffer)
status_t
UdpEndpoint::StoreData(net_buffer *buffer)
{
- TRACE_EP("StoreData(%p [%ld bytes])", buffer, buffer->size);
+ TRACE_EP("StoreData(%p [%" B_PRIu32 " bytes])", buffer, buffer->size);
return EnqueueClone(buffer);
}
@@ -1074,7 +1079,7 @@ UdpEndpoint::StoreData(net_buffer *buffer)
status_t
UdpEndpoint::DeliverData(net_buffer *_buffer)
{
- TRACE_EP("DeliverData(%p [%ld bytes])", _buffer, _buffer->size);
+ TRACE_EP("DeliverData(%p [%" B_PRIu32 " bytes])", _buffer,
_buffer->size);
net_buffer *buffer = gBufferModule->clone(_buffer, false);
if (buffer == NULL)
@@ -1402,7 +1407,8 @@ err1:
// TODO: shouldn't unregister the protocols here?
delete sUdpEndpointManager;
- TRACE_EPM("init_udp() fails with %lx (%s)", status, strerror(status));
+ TRACE_EPM("init_udp() fails with %" B_PRIx32 " (%s)", status,
+ strerror(status));
return status;
}
############################################################################
Commit: 0424248dcbb8800b71bae807c399812460b094b4
URL: https://git.haiku-os.org/haiku/commit/?id=0424248dcbb8
Author: Jérôme Duval <jerome.duval@xxxxxxxxx>
Date: Fri May 1 21:44:09 2020 UTC
Committer: waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Sat May 2 00:52:20 2020 UTC
kernel/fs: allow sendto to be called with a NULL address
POSIX says: If the socket is connection-mode, dest_addr shall be ignored.
Change-Id: Ic75de473173e3795066beeac9a9f2404418d94da
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2547
Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>
----------------------------------------------------------------------------
diff --git a/src/system/kernel/fs/socket.cpp b/src/system/kernel/fs/socket.cpp
index bbe0dd880f..e4c02f46c9 100644
--- a/src/system/kernel/fs/socket.cpp
+++ b/src/system/kernel/fs/socket.cpp
@@ -1036,25 +1036,27 @@ _user_sendto(int socket, const void *data, size_t
length, int flags,
if (data == NULL || !IS_USER_ADDRESS(data))
return B_BAD_ADDRESS;
- // TODO: If this is a connection-mode socket, the address parameter is
- // supposed to be ignored.
- if (userAddress == NULL || addressLength <= 0
+ if (addressLength <= 0
|| addressLength > MAX_SOCKET_ADDRESS_LENGTH) {
return B_BAD_VALUE;
}
// copy address from userland
char address[MAX_SOCKET_ADDRESS_LENGTH];
- if (!IS_USER_ADDRESS(userAddress)
+ if (userAddress != NULL) {
+ if (!IS_USER_ADDRESS(userAddress)
|| user_memcpy(address, userAddress, addressLength) !=
B_OK) {
- return B_BAD_ADDRESS;
+ return B_BAD_ADDRESS;
+ }
+ } else {
+ addressLength = 0;
}
// sendto()
SyscallRestartWrapper<ssize_t> result;
return result = common_sendto(socket, data, length, flags,
- (sockaddr*)address, addressLength, false);
+ userAddress != NULL ? (sockaddr*)address : NULL, addressLength,
false);
}
############################################################################
Revision: hrev54113
Commit: a03ed4fa08bc9a276a8c52f3ca17aad29bad65ca
URL: https://git.haiku-os.org/haiku/commit/?id=a03ed4fa08bc
Author: Jérôme Duval <jerome.duval@xxxxxxxxx>
Date: Fri May 1 21:53:19 2020 UTC
Committer: waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Sat May 2 00:52:20 2020 UTC
udp: set is_connected flag on our socket once connected.
Change-Id: Ie5fcc5152af813d74d33c20ed7c3e81f9e828518
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2548
Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>
----------------------------------------------------------------------------
diff --git a/src/add-ons/kernel/network/protocols/udp/udp.cpp
b/src/add-ons/kernel/network/protocols/udp/udp.cpp
index 9be6d767bb..8d74e7c6fc 100644
--- a/src/add-ons/kernel/network/protocols/udp/udp.cpp
+++ b/src/add-ons/kernel/network/protocols/udp/udp.cpp
@@ -384,7 +384,10 @@ UdpDomainSupport::ConnectEndpoint(UdpEndpoint *endpoint,
// we need to activate no matter whether or not we have just
disconnected,
// as calling connect() always triggers an implicit bind():
- return _BindEndpoint(endpoint, *endpoint->LocalAddress());
+ status_t status = _BindEndpoint(endpoint, *endpoint->LocalAddress());
+ if (status == B_OK)
+ gSocketModule->set_connected(endpoint->Socket());
+ return status;
}
diff --git a/src/add-ons/kernel/network/stack/net_socket.cpp
b/src/add-ons/kernel/network/stack/net_socket.cpp
index 414acc5e2c..4ca9ebbf20 100644
--- a/src/add-ons/kernel/network/stack/net_socket.cpp
+++ b/src/add-ons/kernel/network/stack/net_socket.cpp
@@ -829,6 +829,11 @@ socket_connected(net_socket* _socket)
TRACE("socket_connected(%p)\n", socket);
+ if (socket->parent == NULL) {
+ socket->is_connected = true;
+ return B_OK;
+ }
+
BReference<net_socket_private> parent = socket->parent.GetReference();
if (parent.Get() == NULL)
return B_BAD_VALUE;