lib/ovsimager/tcpdump.rb in ovsimager-0.0.5 vs lib/ovsimager/tcpdump.rb in ovsimager-0.0.6
- old
+ new
@@ -16,12 +16,13 @@
if @ping
puts "Sending ping from #{@from||'default'} to #{@to} ..."
ping = IO.popen("ping -s #{SIZE} -c 15 #{@from?'-I '+@from:''} #{@to} >/dev/null", "r")
end
- threads = ifaces.map do |(iface, iref)|
+ threads = ifaces.map do |(nn, iref)|
Thread.new do
+ iface = iref[:name]
Thread.current[:iface] = iface
ns = iref[:ns]
nscmd = ns == :root ? '' : "ip netns exec #{ns} "
dump = IO.popen("exec #{nscmd}tcpdump -v -l -n -nn -i #{iface} \\( icmp or udp port 4789 or proto gre \\) and greater #{SIZE} 2>&1", "r")
puts dump.gets
@@ -66,11 +67,12 @@
end
end
puts "Killing tcpdump(#{dump.pid}) on interface #{iface}."
Process.kill('TERM', dump.pid)
dump.close
- result[iface] = [req_from, req_to, rep_from, rep_to, {}]
- result[iface][4][:cap] = cap if cap
+ ifname_netns = iface + (ns == :root ? "" : ":" + ns.to_s)
+ result[ifname_netns] = [req_from, req_to, rep_from, rep_to, {}]
+ result[ifname_netns][4][:cap] = cap if cap
end
end
threads.each {|th| th.join(10)}
if @ping
Process.kill('TERM', ping.pid)