From: Andre Przywara <andre.przywara@amd.com>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: xen-devel <xen-devel@lists.xensource.com>,
Keir Fraser <keir.fraser@eu.citrix.com>
Subject: [PATCH] xl: improve vif2 parsing
Date: Fri, 20 Aug 2010 14:03:44 +0200 [thread overview]
Message-ID: <4C6E6F20.3090405@amd.com> (raw)
In-Reply-To: <4C6E6E84.5020704@amd.com>
[-- Attachment #1: Type: text/plain, Size: 594 bytes --]
Andre Przywara wrote:
> Hi,
>
> vif2 parsing relies on counted strncmp() statements. Replace this
> with a more robust automatic version.
No, I didn't want to leave this as an exercise to the reader, I am just
spoiled by git send-email, so forgot to attach the patch. Sorry!
>
> Signed-off-by: Andre Przywara <andre.przywara@amd.com>
>
> Regards,
> Andre.
>
> P.S. If you like this, I have seen at least two more instances of the
> same issue that could be improved this way.
>
--
Andre Przywara
AMD-Operating System Research Center (OSRC), Dresden, Germany
Tel: +49 351 448-3567-12
[-- Attachment #2: xl-improve-vif2-parsing.patch --]
[-- Type: text/x-patch, Size: 3468 bytes --]
>From 7b34567697aaf8b8acf251d63519d08a5fb7b646 Mon Sep 17 00:00:00 2001
From: Andre Przywara <andre.przywara@amd.com>
Date: Fri, 20 Aug 2010 01:01:43 +0200
Subject: [PATCH 3/4] xl: improve vif2 parsing
vif2 parsing relies on counted strncmp() statements. Replace this
with a more robust automatic version.
Signed-off-by: Andre Przywara <andre.przywara@amd.com>
---
tools/libxl/xl_cmdimpl.c | 45 +++++++++++++++++++++++++--------------------
1 files changed, 25 insertions(+), 20 deletions(-)
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index c291879..1ddaab9 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -860,28 +860,33 @@ skip:
init_net2_info(net2, d_config->num_vif2s);
for (p = strtok(buf2, ","); p; p = strtok(NULL, ",")) {
+ char* val;
while (isblank(*p))
p++;
- if (!strncmp("front_mac=", p, 10)) {
- libxl_strtomac(p + 10, net2->front_mac);
- } else if (!strncmp("back_mac=", p, 9)) {
- libxl_strtomac(p + 9, net2->back_mac);
- } else if (!strncmp("backend=", p, 8)) {
- domain_qualifier_to_domid(p + 8, &net2->backend_domid, 0);
- } else if (!strncmp("trusted=", p, 8)) {
- net2->trusted = (*(p + 8) == '1');
- } else if (!strncmp("back_trusted=", p, 13)) {
- net2->back_trusted = (*(p + 13) == '1');
- } else if (!strncmp("bridge=", p, 7)) {
- net2->bridge = strdup(p + 13);
- } else if (!strncmp("filter_mac=", p, 11)) {
- net2->filter_mac = (*(p + 11) == '1');
- } else if (!strncmp("front_filter_mac=", p, 17)) {
- net2->front_filter_mac = (*(p + 17) == '1');
- } else if (!strncmp("pdev=", p, 5)) {
- net2->pdev = strtoul(p + 5, NULL, 10);
- } else if (!strncmp("max_bypasses=", p, 13)) {
- net2->max_bypasses = strtoul(p + 13, NULL, 10);
+ val = strchr(p, '=');
+ if (val == NULL)
+ continue;
+ *val++ = 0;
+ if (!strcmp("front_mac", p)) {
+ libxl_strtomac(val, net2->front_mac);
+ } else if (!strcmp("back_mac", p)) {
+ libxl_strtomac(val, net2->back_mac);
+ } else if (!strcmp("backend", p)) {
+ domain_qualifier_to_domid(val, &net2->backend_domid, 0);
+ } else if (!strcmp("trusted", p)) {
+ net2->trusted = (*val == '1');
+ } else if (!strcmp("back_trusted", p)) {
+ net2->back_trusted = (*val == '1');
+ } else if (!strcmp("bridge", p)) {
+ net2->bridge = strdup(val);
+ } else if (!strcmp("filter_mac", p)) {
+ net2->filter_mac = (*val == '1');
+ } else if (!strcmp("front_filter_mac", p)) {
+ net2->front_filter_mac = (*val == '1');
+ } else if (!strcmp("pdev", p)) {
+ net2->pdev = strtoul(val, NULL, 10);
+ } else if (!strcmp("max_bypasses", p)) {
+ net2->max_bypasses = strtoul(val, NULL, 10);
}
}
free(buf2);
--
1.6.4
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
next prev parent reply other threads:[~2010-08-20 12:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-20 12:01 [PATCH] xl: improve vif2 parsing Andre Przywara
2010-08-20 12:03 ` Andre Przywara [this message]
2010-08-20 12:41 ` Gianni Tedesco
2010-08-20 12:58 ` Andre Przywara
2010-08-20 13:34 ` Gianni Tedesco
2010-08-20 14:28 ` Christoph Egger
2010-08-20 14:30 ` Gianni Tedesco
2010-08-20 16:22 ` Stefano Stabellini
2010-08-20 16:16 ` Ian Jackson
2010-08-22 22:55 ` Andre Przywara
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=4C6E6F20.3090405@amd.com \
--to=andre.przywara@amd.com \
--cc=keir.fraser@eu.citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xensource.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.