kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amos Kong <akong@redhat.com>
To: lmr@redhat.com
Cc: jasowang@redhat.com, kvm@vger.kernel.org
Subject: [Autotest PATCH] virt: Only update macaddr cache when capture dhcp ACK packet
Date: Thu, 29 Sep 2011 17:57:19 +0800	[thread overview]
Message-ID: <20110929095719.20712.71205.stgit@t> (raw)

Currently, tcpdump can capture both dhcp Offer and ACK packets,
macaddr cache will be updated in those to condition,
dhcp Offer packet doesn't mean the IP is already allocated to
dhcp client.

Signed-off-by: Amos Kong <akong@redhat.com>
---
 client/virt/virt_env_process.py |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/client/virt/virt_env_process.py b/client/virt/virt_env_process.py
index 51c7e8a..a7621bb 100644
--- a/client/virt/virt_env_process.py
+++ b/client/virt/virt_env_process.py
@@ -403,14 +403,20 @@ def _update_address_cache(address_cache, line):
             address_cache["last_seen"] = matches[0]
     if re.search("Client.Ethernet.Address", line, re.IGNORECASE):
         matches = re.findall(r"\w*:\w*:\w*:\w*:\w*:\w*", line)
-        if matches and address_cache.get("last_seen"):
-            mac_address = matches[0].lower()
+        if matches:
+            address_cache["last_mac"] = matches[0]
+    if re.search("DHCP-Message", line, re.IGNORECASE):
+        matches = re.findall(r"ACK", line)
+        if matches and address_cache.get("last_seen") and address_cache.get(
+                                                                 "last_mac"):
+            mac_address = address_cache.get("last_mac").lower()
             if time.time() - address_cache.get("time_%s" % mac_address, 0) > 5:
                 logging.debug("(address cache) Adding cache entry: %s ---> %s",
                               mac_address, address_cache.get("last_seen"))
             address_cache[mac_address] = address_cache.get("last_seen")
             address_cache["time_%s" % mac_address] = time.time()
             del address_cache["last_seen"]
+            del address_cache["last_mac"]
 
 
 def _take_screendumps(test, params, env):


             reply	other threads:[~2011-09-29  9:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-29  9:57 Amos Kong [this message]
2011-10-01  3:30 ` ethtool pradeep
2011-10-03  2:16   ` ethtool Lucas Meneghel Rodrigues

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110929095719.20712.71205.stgit@t \
    --to=akong@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=lmr@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).