<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi,<br>
    <div class="moz-cite-prefix">On 08/25/2017 02:44 AM, Petr Vorel
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:20170824234436.18145-2-pvorel@suse.cz">
      <pre wrap="">Signed-off-by: Petr Vorel <a class="moz-txt-link-rfc2396E" href="mailto:pvorel@suse.cz"><pvorel@suse.cz></a>
---
 testcases/lib/test_net.sh | 66 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 65 insertions(+), 1 deletion(-)
</pre>
    </blockquote>
    <blockquote type="cite"
      cite="mid:20170824234436.18145-2-pvorel@suse.cz">
      <pre wrap="">...
+
+       [ "$TST_IPV6" ] && max_net_id=65535 || max_net_id=255
+
+       if [ $# -eq 0 -o "$1" = "lhost" -o "$1" = "rhost" ]; then
+               [ -z "$counter" ] && counter=1
+               [ $counter -lt 1 ] && counter=1
+               type="${1:-lhost}"
+               max_host_id=$((max_net_id - 1))
+               tmp=$((counter * 2))
+               [ "$type" = "rhost" ] && tmp=$((tmp - 1))
+
+               host_id=$((tmp % max_host_id))
+               net_id=$((tmp / max_host_id))
+
+               if [ $host_id -eq 0 ]; then
+                       host_id=$max_host_id
+                       net_id=$((net_id - 1))
+               fi
+       else
+               net_id="$1"
+               host_id="${2:-0}"
+               max_host_id=$max_net_id
+               if [ "$TST_IPV6" ]; then
+                       net_id=$(printf %d $net_id)
+                       host_id=$(printf %d $host_id)
+               fi
+               [ $net_id -lt 0 ] && net_id=0
+               [ $host_id -lt 0 ] && host_id=1
+       fi
+
+       net_id=$((net_id % max_net_id))
+       host_id=$((host_id % max_host_id))</pre>
    </blockquote>
    <br>
    <tt>Changed to 'max_net_id' here and applied, otherwise we would
      have host_id 0 if counter = 254.<br>
    </tt><br>
    Thanks,<br>
    Alexey<br>
    <br>
  </body>
</html>