Opened 2 years ago

Closed 18 months ago

#65666 closed defect (fixed)

folly, wangle: Need TCP_CONNECTION_INFO for <10.11

Reported by: barracuda156 Owned by: catap (Kirill A. Korinsky)
Priority: Normal Milestone:
Component: ports Version: 2.7.2
Keywords: Cc: mascguy (Christopher Nielsen)
Port: folly, wangle

Description

Is there a way to add this for older systems? Need that for folly and wangle, likely other ports too.

For example, wangle fails with:

In file included from /opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_wangle/wangle/work/wangle-v2022.08.08.00/wangle/../wangle/acceptor/AcceptorHandshakeManager.h:26,
                 from /opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_wangle/wangle/work/wangle-v2022.08.08.00/wangle/../wangle/acceptor/EvbHandshakeHelper.h:24,
                 from /opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_wangle/wangle/work/wangle-v2022.08.08.00/wangle/acceptor/EvbHandshakeHelper.cpp:17:
/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_wangle/wangle/work/wangle-v2022.08.08.00/wangle/../wangle/acceptor/TransportInfo.h:118:11: error: 'tcp_connection_info' does not name a type
  118 |   typedef tcp_connection_info tcp_info;
      |           ^~~~~~~~~~~~~~~~~~~
/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_wangle/wangle/work/wangle-v2022.08.08.00/wangle/../wangle/acceptor/TransportInfo.h:125:3: error: 'tcp_info' does not name a type
  125 |   tcp_info tcpinfo{};
      |   ^~~~~~~~
/opt/local/var/macports/build/_opt_PPCRosettaPorts_devel_wangle/wangle/work/wangle-v2022.08.08.00/wangle/../wangle/acceptor/TransportInfo.h:359:27: error: 'tcp_info' has not been declared
  359 |   static bool readTcpInfo(tcp_info* tcpinfo, const folly::AsyncSocket* sock);
      |                           ^~~~~~~~

folly errors: https://github.com/facebook/folly/issues/1835

This is perhaps the one thing remaining to fix, and then the whole set of FB-developed ports build on <10.11. See also: https://github.com/macports/macports-ports/pull/15689

Change History (9)

comment:1 Changed 2 years ago by jmroot (Joshua Root)

You can define the struct easily enough, but it does you no good without kernel support for filling it in.

comment:2 in reply to:  1 ; Changed 2 years ago by barracuda156

Replying to jmroot:

You can define the struct easily enough, but it does you no good without kernel support for filling it in.

Yeah, later xnu has the thing, but I suspected pulling it over won’t work. Do you think it can be emulated somehow, for the specific port or via legacysupport PG?

comment:3 in reply to:  2 Changed 2 years ago by catap (Kirill A. Korinsky)

Replying to barracuda156:

Do you think it can be emulated somehow, for the specific port or via legacysupport PG?

Emulating kernel features like TCP statistics from user-space where legacysupport exists can be vert tricky if possible.

I suggest to try to put a few ifdef and simple switch off TCP statistics, not whole TCP. Maybe it work.

Also, I suggest reassigned the issue to you :)

comment:4 Changed 2 years ago by kencu (Ken)

looking at the commits that brought this into folly last year, they appear to already expect this info to be unavailable for some linux versions, and they work around that by examing the size of the returned struct. Then they only use the info if it is available, I believe.

https://github.com/facebook/folly/commit/68a78d99d10743b54d38a550b2f0ebdc5c872f76

For Macos, they only support versions where the info is available, so don’t do such checks.

So a motivated person might look at how they manage the workaround in linux, and then try to implement something similar for older Macos versions.

comment:5 Changed 2 years ago by mascguy (Christopher Nielsen)

Cc: mascguy added

comment:6 in reply to:  4 Changed 2 years ago by barracuda156

Replying to kencu:

looking at the commits that brought this into folly last year, they appear to already expect this info to be unavailable for some linux versions, and they work around that by examing the size of the returned struct. Then they only use the info if it is available, I believe.

https://github.com/facebook/folly/commit/68a78d99d10743b54d38a550b2f0ebdc5c872f76

For Macos, they only support versions where the info is available, so don’t do such checks.

So a motivated person might look at how they manage the workaround in linux, and then try to implement something similar for older Macos versions.

Thank you!

For now, this worked:

--- folly/net/TcpInfoTypes.h.orig	2022-08-06 08:35:42.000000000 +0700
 +++ folly/net/TcpInfoTypes.h	2022-08-14 19:19:26.000000000 +0700
 @@ -179,7 +179,7 @@
    __u32 tcpi_total_retrans;
  };

 -#elif defined(__APPLE__)
 +#elif defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED > 101003
  #define FOLLY_HAVE_TCP_INFO 1
  using tcp_info = ::tcp_connection_info;
  const int tcp_info_sock_opt = TCP_CONNECTION_INFO;

https://github.com/macports/macports-ports/pull/15689/files

comment:7 Changed 20 months ago by ryandesign (Ryan Carsten Schmidt)

Summary: Need TCP_CONNECTION_INFO for <10.11folly, wangle: Need TCP_CONNECTION_INFO for <10.11

The PR was merged. Does that mean this ticket can be closed as fixed?

comment:8 in reply to:  7 ; Changed 20 months ago by barracuda156

Replying to ryandesign:

The PR was merged. Does that mean this ticket can be closed as fixed?

Since we don’t have a better fix, I guess, yes.

comment:9 in reply to:  8 Changed 18 months ago by mascguy (Christopher Nielsen)

Resolution: fixed
Status: assignedclosed

Replying to barracuda156:

Replying to ryandesign:

The PR was merged. Does that mean this ticket can be closed as fixed?

Since we don’t have a better fix, I guess, yes.

Yep, the port was building back to 10.9, so yes.

Now it's broken due to it being updated by someone other than the maintainer, but that'll be a new/separate ticket...

Note: See TracTickets for help on using tickets.