lkml.org 
[lkml]   [2019]   [Feb]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] sysctl: Fix proc_do_large_bitmap for large input buffers
From
Date
Here's a pretty hacky test script to test this code via
ip_local_reserved_ports

-----

#!/bin/bash

# Randomly construct well-formed (sequential, non-overlapping)
# input for ip_local_reserved_ports, feed it to the sysctl,
# then read it back and check for differences.

# Port range to use
PORT_START=1024
PORT_STOP=32768

# Total length of ports string to use
LENGTH=$((4096+$((RANDOM % 16384))))

# String containing our list of ports
PORTS=$PORT_START

# Try 1000 times
for I in `seq 1 1000`; do

# build up the string
while true; do
# Make sure it's discontiguous, skip ahead at least 2
SKIP=$((2 + RANDOM % 10))
PORT_START=$((PORT_START + SKIP))

if [ "$PORT_START" -ge "$PORT_STOP" ]; then
break;
fi

# 14856-14863,14861
# Add a range, or a single port
USERANGE=$((RANDOM % 2))

if [ "$USERANGE" -eq "1" ]; then
RANGE_START=$PORT_START
RANGE_LEN=$((1 + RANDOM % 10))
RANGE_END=$((RANGE_START + RANGE_LEN))
PORTS="${PORTS},${RANGE_START}-${RANGE_END}"
# Break out if we've done enough
if [ "$RANGE_END" -eq "$PORT_STOP" ]; then
break;
fi
PORT_START=$RANGE_END
else
PORTS="${PORTS},${PORT_START}"
fi

if [ "${#PORTS}" -gt "$LENGTH" ]; then
break;
fi

done

# See if we get out what we put in
echo "Trial $I"
echo $PORTS > port_list
cat port_list > /proc/sys/net/ipv4/ip_local_reserved_ports || break
cat /proc/sys/net/ipv4/ip_local_reserved_ports > port_list_out
diff -uq port_list port_list_out || break

done


\
 
 \ /
  Last update: 2019-02-21 00:35    [W:0.219 / U:1.096 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site