u1.close()
return socket.fromfd(fds[0], *sock_args)
+def check_info(socks):
+ """
+ Check all rds info pages for errors
+
+ :param socks: list of sockets to check
+ """
+
+ # the Python socket module doesn't know these
+ rds_info_first = 10000
+ rds_info_last = 10017
+
+ nr_success = 0
+ nr_error = 0
+
+ for sock in socks:
+ for optname in range(rds_info_first, rds_info_last + 1):
+ # Sigh, the Python socket module doesn't allow us to pass
+ # buffer lengths greater than 1024 for some reason. RDS
+ # wants multiple pages.
+ try:
+ sock.getsockopt(socket.SOL_RDS, optname, 1024)
+ nr_success = nr_success + 1
+ except OSError as e:
+ nr_error = nr_error + 1
+ if e.errno == errno.ENOSPC:
+ # ignore
+ pass
+
+ ksft_pr(f"getsockopt(): {nr_success}/{nr_error}")
+
def stop_pcaps():
"""Stop tcpdump processes.
ksft_pr("done", nr_send, nr_recv)
-# the Python socket module doesn't know these
-RDS_INFO_FIRST = 10000
-RDS_INFO_LAST = 10017
-
-nr_success = 0
-nr_error = 0
-
-for s in sockets:
- for optname in range(RDS_INFO_FIRST, RDS_INFO_LAST + 1):
- # Sigh, the Python socket module doesn't allow us to pass
- # buffer lengths greater than 1024 for some reason. RDS
- # wants multiple pages.
- try:
- s.getsockopt(socket.SOL_RDS, optname, 1024)
- nr_success = nr_success + 1
- except OSError as e:
- nr_error = nr_error + 1
- if e.errno == errno.ENOSPC:
- # ignore
- pass
-
-ksft_pr(f"getsockopt(): {nr_success}/{nr_error}")
+check_info(sockets)
# cancel timeout
signal.alarm(0)