<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Hi,</p>
<p>when using the TST_GET_UNUSED_PORT macro you sometimes get ports
lower than 1024 which would require a testcase to have the
CAP_NET_BIND_SERVICE capability (or simply run as root).</p>
<p>Of course you could write a wrapper like the following to avoid
that issue, but in my opinion it would be nice to have the option
to get non-root ports directly from the library.</p>
<p><font color="#3366ff">/* Wrapper to to get a non-root port if
necessary */<br>
static int get_port(uid_t uid)<br>
{<br>
static int count = 10;<br>
int port;<br>
<br>
port = TST_GET_UNUSED_PORT(AF_INET, SOCK_STREAM);<br>
if (port < 1000 && uid != 0) {<br>
if (!count)<br>
tst_brk(TBROK, "Could not get fitting
port");<br>
count--;<br>
return get_port(uid);<br>
}<br>
return port;<br>
}</font><br>
</p>
<p>Kind regards,</p>
<p>Christian<br>
</p>
<p><br>
</p>
</body>
</html>