Anonymous Login
2018-02-23 23:10 CET

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0001998OpenClonkEngine - Networkpublic2018-02-17 13:00
ReporterLuchs 
Assigned ToLuchs 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSFreeBSDOS Version
Product Version8.0 
Target VersionFixed in Version8.1 
Summary0001998: Networking does not work on FreeBSD
DescriptionOn FreeBSD, sizeof(struct sockaddr_in) != sizeof(struct sockaddr_in6). This breaks C4NetIOTCP::Connect() which calls connect(2) with sizeof(C4NetIO::addr_t) which is a union of sockaddr_in and sockaddr_in6.

To fix this, we will need to make that size parameter dependent on the address family stored within.
TagsNo tags attached.
Attached Files
  • patch file icon freebsd.patch (1,263 bytes) 2018-02-13 02:59 -
    From 1e0e2cb46ca66d930bff030e7da9d76f089137f5 Mon Sep 17 00:00:00 2001
    From: Kevin Zheng <kevinz5000@gmail.com>
    Date: Mon, 12 Feb 2018 17:53:51 -0800
    Subject: [PATCH 2/2] Correctly check size of sockaddr_in and sockaddr_in6
    
    ---
     src/network/C4NetIO.cpp | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/src/network/C4NetIO.cpp b/src/network/C4NetIO.cpp
    index 0120fb38e..aaab1a78b 100644
    --- a/src/network/C4NetIO.cpp
    +++ b/src/network/C4NetIO.cpp
    @@ -1195,7 +1195,7 @@ bool C4NetIOTCP::Connect(const C4NetIO::addr_t &addr) // (mt-safe)
     #endif
     
     	// connect (async)
    -	if (::connect(nsock, &addr, sizeof addr) == SOCKET_ERROR)
    +	if (::connect(nsock, &addr, addr.GetFamily() == HostAddress::IPv4 ? sizeof(sockaddr_in) : sizeof(sockaddr_in6)) == SOCKET_ERROR)
     	{
     		if (!HaveWouldBlockError()) // expected
     		{
    @@ -1368,7 +1368,7 @@ C4NetIOTCP::Peer *C4NetIOTCP::Accept(SOCKET nsock, const addr_t &ConnectAddr) //
     	addr_t caddr = ConnectAddr;
     
     	// accept incoming connection?
    -	C4NetIO::addr_t addr; socklen_t iAddrSize = sizeof addr;
    +	C4NetIO::addr_t addr; socklen_t iAddrSize = addr.GetFamily() == HostAddress::IPv4 ? sizeof(sockaddr_in) : sizeof(sockaddr_in6);
     	if (nsock == INVALID_SOCKET)
     	{
     		// accept from listener
    -- 
    2.16.1
    
    patch file icon freebsd.patch (1,263 bytes) 2018-02-13 02:59 +

-Relationships
+Relationships

-Notes

~0006130

Clonkonaut (developer)

Partmedia provided us with this patch to fix the problem!

~0006138

occ (reporter)

Hi! There's been a check-in that references this bug. For more information you can visit the repository browser at this address:
https://git.openclonk.org/openclonk.git/commitdiff/0c8371f113386026bfbd534c7dd341aa7db28fba

Changeset 0c8371f by Kevin Zheng <kevinz5000@gmail.com>
Fix networking on FreeBSD (0001998)

~0006142

Luchs (developer)

I applied the patch.
+Notes

-Issue History
Date Modified Username Field Change
2018-02-12 20:49 Luchs New Issue
2018-02-12 20:49 Luchs Status new => assigned
2018-02-12 20:49 Luchs Assigned To => Luchs
2018-02-13 02:59 Clonkonaut File Added: freebsd.patch
2018-02-13 02:59 Clonkonaut Note Added: 0006130
2018-02-17 12:59 occ Note Added: 0006138
2018-02-17 13:00 Luchs Status assigned => resolved
2018-02-17 13:00 Luchs Resolution open => fixed
2018-02-17 13:00 Luchs Fixed in Version => 8.1
2018-02-17 13:00 Luchs Note Added: 0006142
+Issue History