3 # For now, this just tests the addition and removal of 1000 VLAN interfaces on eth0
6 # graph Generate a graph.
7 # clean Remove interfaces.
13 if ($ARGV[0] eq "graph") {
20 open(IPNH
, ">/tmp/ip_rpt_no_hash.txt") || die("Can't open /tmp/ip_rpt_no_hash.txt\n");
21 open(IFCFGNH
, ">/tmp/ifconfig_rpt_no_hash.txt") || die("Can't open /tmp/ifconfig_rpt_no_hash.txt\n");
22 open(IP
, ">/tmp/ip_rpt.txt") || die("Can't open /tmp/ip_rpt.txt\n");
23 open(IFCFG
, ">/tmp/ifconfig_rpt.txt") || die("Can't open /tmp/ifconfig_rpt.txt\n");
26 my $no_hash = $ARGV[2];
33 #print "LINE: -:$ln:-\n";
35 if ($ln =~ /Doing ip addr show for (\S+)/) {
39 elsif ($ln =~ /Doing ifconfig -a for (\S+)/) {
43 elsif ($ln =~ /^real (\S+)/) {
46 elsif ($ln =~ /^user (\S+)/) {
49 elsif ($ln =~ /^sys (\S+)/) {
51 #print "prog: $prog $dev_cnt\t$user\t$system\t$real\n";
53 print IPNH
"$dev_cnt\t$user\t$system\t$real\n";
56 print IFCFGNH
"$dev_cnt\t$user\t$system\t$real\n";
60 #print "INFO: Didn't match anything -:$ln:-\n";
73 #print "LINE: -:$ln:-\n";
75 if ($ln =~ /Doing ip addr show for (\S+)/) {
79 elsif ($ln =~ /Doing ifconfig -a for (\S+)/) {
83 elsif ($ln =~ /^real (\S+)/) {
86 elsif ($ln =~ /^user (\S+)/) {
89 elsif ($ln =~ /^sys (\S+)/) {
91 #print "prog: $prog $dev_cnt\t$user\t$system\t$real\n";
93 print IP
"$dev_cnt\t$user\t$system\t$real\n";
96 print IFCFG
"$dev_cnt\t$user\t$system\t$real\n";
100 #print "INFO: Didn't match anything -:$ln:-\n";
107 my $plot_cmd = "set title \"ip addr show V/S ifconfig -a\"
108 set terminal png color
109 set output \"ip_addr_show.png\"
111 set xlabel \"Interface Count\"
112 set ylabel \"Seconds\"
114 plot \'/tmp/ip_rpt.txt\' using 1:3 title \"ip_system\" with lines, \\
115 \'/tmp/ip_rpt.txt\' using 1:2 title \"ip_user\" with lines, \\
116 \'/tmp/ifconfig_rpt.txt\' using 1:3 title \"ifconfig_system\" with lines, \\
117 \'/tmp/ifconfig_rpt.txt\' using 1:2 title \"ifconfig_user\" with lines, \\
118 \'/tmp/ip_rpt_no_hash.txt\' using 1:3 title \"ip_system_no_hash\" with lines, \\
119 \'/tmp/ip_rpt_no_hash.txt\' using 1:2 title \"ip_user_no_hash\" with lines, \\
120 \'/tmp/ifconfig_rpt_no_hash.txt\' using 1:3 title \"ifconfig_system_no_hash\" with lines, \\
121 \'/tmp/ifconfig_rpt_no_hash.txt\' using 1:2 title \"ifconfig_user_no_hash\" with lines";
122 print "Plotting with cmd -:$plot_cmd:-\n";
124 open(GP
, "| gnuplot") or die ("Can't open gnuplot pipe(2).\n");
125 print GP
"$plot_cmd";
133 `/usr/local/bin/vconfig set_name_type VLAN_PLUS_VID_NO_PAD`;
138 if ($ARGV[0] ne "clean") {
141 print "Adding VLAN interfaces 1 through $num_if\n";
143 print "Turnning off /sbin/hotplug";
144 `echo > /proc/sys/kernel/hotplug`;
147 for ($i = 1; $i<=$num_if; $i++) {
148 `/usr/local/bin/vconfig add eth0 $i`;
149 #`ip address flush dev vlan$i`;
150 `ip address add 192.168.$c.$c/24 dev vlan$i`;
151 `ip link set dev vlan$i up`;
153 if (($i <= 4000) && (($i % 50) == 0)) {
154 #print "Doing ifconfig -a for $i devices.\n";
155 #`time -p ifconfig -a > /tmp/vlan_test_ifconfig_a_$i.txt`;
156 print "Doing ip addr show for $i devices.\n";
157 `time -p ip addr show > /tmp/vlan_test_ip_addr_$i.txt`;
169 print "Done adding $num_if VLAN interfaces in $diff seconds.\n";
174 print "Removing VLAN interfaces 1 through $num_if\n";
179 for ($i = 1; $i<=$num_if; $i++) {
180 `/usr/local/bin/vconfig rem vlan$i`;
190 print "Done deleting $num_if VLAN interfaces in $diff seconds.\n";
195 if ($ARGV[0] ne "clean") {
197 my $tmp = $num_if / 4;
198 print "\nGoing to add and remove 2 interfaces $tmp times.\n";
202 for ($i = 1; $i<=$tmp; $i++) {
203 `/usr/local/bin/vconfig add eth0 1`;
204 `ifconfig vlan1 192.168.200.200`;
206 `ifconfig vlan1 down`;
208 `/usr/local/bin/vconfig add eth0 2`;
209 `ifconfig vlan2 192.168.202.202`;
211 `ifconfig vlan2 down`;
213 `/usr/local/bin/vconfig rem vlan2`;
214 `/usr/local/bin/vconfig rem vlan1`;
218 print "Done adding/removing 2 VLAN interfaces $tmp times in $diff seconds.\n";
221 print "Re-installing /sbin/hotplug";
222 `echo /sbin/hotplug > /proc/sys/kernel/hotplug`;