From nobody Mon Apr 29 08:57:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=126.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1518076301049330.6336914654953; Wed, 7 Feb 2018 23:51:41 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4513D356CC; Thu, 8 Feb 2018 07:51:40 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0F8494D711; Thu, 8 Feb 2018 07:51:40 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A4F9B18033DD; Thu, 8 Feb 2018 07:51:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w187lVOa001244 for ; Thu, 8 Feb 2018 02:47:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id AAE3B2A340; Thu, 8 Feb 2018 07:47:31 +0000 (UTC) Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A44264F31B for ; Thu, 8 Feb 2018 07:47:29 +0000 (UTC) Received: from m15-112.126.com (m15-112.126.com [220.181.15.112]) by mx1.redhat.com (Postfix) with ESMTP id 098955F7B2 for ; Thu, 8 Feb 2018 07:47:27 +0000 (UTC) Received: from localhost.localdomain (unknown [58.213.111.46]) by smtp2 (Coremail) with SMTP id DMmowADnbmeBAHxa+5+kBw--.65372S3; Thu, 08 Feb 2018 15:47:25 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id; bh=JQUx1p4bJKBZDVLqLY kMfqOXUN/6BXkeHW8iYp7B5oU=; b=VtItCXifLqQ5+UYjyIAqhzsigcMSblvuyD Gw1QuBFzMWW22TBjJtfyoa4JMqfRyxfvGH28FIIMyDeRSfTrdep0raeX0uOW5Lu/ jUo/9HZzM67PhoYEZy4Gg5D6um44aXjMSLd7BIHEP3GmUcEDdl/Yup/HZU58RkXD /TpMQfhWw= From: Chen Hanxiao To: libvir-list@redhat.com Date: Thu, 8 Feb 2018 15:47:00 +0800 Message-Id: <20180208074704.19497-2-chen_han_xiao@126.com> In-Reply-To: <20180208074704.19497-1-chen_han_xiao@126.com> References: <20180208074704.19497-1-chen_han_xiao@126.com> X-CM-TRANSID: DMmowADnbmeBAHxa+5+kBw--.65372S3 X-Coremail-Antispam: 1Uf129KBjvJXoWxCr45Zw1fWF17ArWrGw4UArb_yoWrJr45pa 4UK3Zayr4rJr1xuFZIyFyUGFy3ZFnYgr13W3y2kwn7Aw4xAFyUXr1a9ry5uFW5Ar95JFyf tFn09FW0kr45JaUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jjWlkUUUUU= X-Originating-IP: [58.213.111.46] X-CM-SenderInfo: xfkh0spkdqs5xldrqiyswou0bp/1tbiaQ3mrlpD4Jx7cgAAsA X-Greylist: Sender passed SPF test, ACL 227 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 08 Feb 2018 07:47:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 08 Feb 2018 07:47:28 +0000 (UTC) for IP:'220.181.15.112' DOMAIN:'m15-112.126.com' HELO:'m15-112.126.com' FROM:'chen_han_xiao@126.com' RCPT:'' X-RedHat-Spam-Score: 1.99 * (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_PSBL, SPF_PASS, T_RP_MATCHES_RCVD) 220.181.15.112 m15-112.126.com 220.181.15.112 m15-112.126.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Chen Hanxiao Subject: [libvirt] [PATCH v4 1/5] util: introduce virNetlinkGetNeighbor to get neighbor table entry X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 08 Feb 2018 07:51:40 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Chen Hanxiao use RTM_GETNEIGH to query arp table entry by netlink socket Signed-off-by: Chen Hanxiao --- v4: use netlink to get arp table entry src/libvirt_private.syms | 1 + src/util/virnetlink.c | 82 ++++++++++++++++++++++++++++++++++++++++++++= ++++ src/util/virnetlink.h | 2 ++ 3 files changed, 85 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 0bce0bbfb..d90eb3dde 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2367,6 +2367,7 @@ virNetlinkEventServiceStart; virNetlinkEventServiceStop; virNetlinkEventServiceStopAll; virNetlinkGetErrorCode; +virNetlinkGetNeighbor; virNetlinkShutdown; virNetlinkStartup; =20 diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c index d732fe8cf..0f9b0f5d1 100644 --- a/src/util/virnetlink.c +++ b/src/util/virnetlink.c @@ -590,6 +590,88 @@ virNetlinkDelLink(const char *ifname, virNetlinkDelLin= kFallback fallback) goto cleanup; } =20 +/** + * virNetlinkGetNeighbor: + * + * @nlData: Gets a pointer to the raw data from netlink. + MUST BE FREED BY CALLER! + * @src_pid: pid used for nl_pid of the local end of the netlink message + * (0 =3D=3D "use getpid()") + * @dst_pid: pid of destination nl_pid if the kernel + * is not the target of the netlink message but it is to be + * sent to another process (0 if sending to the kernel) + * + * Get neighbor table entry from netlink. + * + * Returns 0 on success, -1 on fatal error. + */ +int +virNetlinkGetNeighbor(void **nlData, uint32_t src_pid, uint32_t dst_pid) +{ + int rc =3D -1; + struct nlmsghdr *resp =3D NULL; + struct nlmsgerr *err; + struct ndmsg ndinfo =3D { + .ndm_family =3D AF_UNSPEC, + }; + unsigned int recvbuflen; + struct nl_msg *nl_msg; + + nl_msg =3D nlmsg_alloc_simple(RTM_GETNEIGH, NLM_F_DUMP | NLM_F_REQUEST= ); + if (!nl_msg) { + virReportOOMError(); + return -1; + } + + if (nlmsg_append(nl_msg, &ndinfo, sizeof(ndinfo), NLMSG_ALIGNTO) < 0) + goto buffer_too_small; + + + if (virNetlinkCommand(nl_msg, &resp, &recvbuflen, + src_pid, dst_pid, NETLINK_ROUTE, 0) < 0) + goto cleanup; + + if (recvbuflen < NLMSG_LENGTH(0) || resp =3D=3D NULL) + goto malformed_resp; + + switch (resp->nlmsg_type) { + case NLMSG_ERROR: + err =3D (struct nlmsgerr *)NLMSG_DATA(resp); + if (resp->nlmsg_len < NLMSG_LENGTH(sizeof(*err))) + goto malformed_resp; + + if (err->error) { + virReportSystemError(-err->error, + "%s", _("error dumping")); + goto cleanup; + } + break; + + case RTM_NEWNEIGH: + break; + + default: + goto malformed_resp; + } + rc =3D recvbuflen; + + cleanup: + nlmsg_free(nl_msg); + if (rc < 0) + VIR_FREE(resp); + *nlData =3D resp; + return rc; + + malformed_resp: + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("malformed netlink response message")); + goto cleanup; + + buffer_too_small: + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("allocated netlink buffer is too small")); + goto cleanup; +} =20 int virNetlinkGetErrorCode(struct nlmsghdr *resp, unsigned int recvbuflen) diff --git a/src/util/virnetlink.h b/src/util/virnetlink.h index 088b01343..2a9de0a57 100644 --- a/src/util/virnetlink.h +++ b/src/util/virnetlink.h @@ -71,6 +71,8 @@ int virNetlinkDumpLink(const char *ifname, int ifindex, void **nlData, struct nlattr **tb, uint32_t src_pid, uint32_t dst_pid) ATTRIBUTE_RETURN_CHECK; +int +virNetlinkGetNeighbor(void **nlData, uint32_t src_pid, uint32_t dst_pid); =20 typedef void (*virNetlinkEventHandleCallback)(struct nlmsghdr *, unsigned int length, --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 08:57:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=126.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1518076309653110.79323686369116; Wed, 7 Feb 2018 23:51:49 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BA4A2C0587DB; Thu, 8 Feb 2018 07:51:48 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 90C942A346; Thu, 8 Feb 2018 07:51:48 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 52C7A18033E1; Thu, 8 Feb 2018 07:51:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w187lXc2001282 for ; Thu, 8 Feb 2018 02:47:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id CF7777E4CE; Thu, 8 Feb 2018 07:47:33 +0000 (UTC) Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C56C67E939 for ; Thu, 8 Feb 2018 07:47:30 +0000 (UTC) Received: from m15-112.126.com (m15-112.126.com [220.181.15.112]) by mx1.redhat.com (Postfix) with ESMTP id 0C6C8C04D2AC for ; Thu, 8 Feb 2018 07:47:27 +0000 (UTC) Received: from localhost.localdomain (unknown [58.213.111.46]) by smtp2 (Coremail) with SMTP id DMmowADnbmeBAHxa+5+kBw--.65372S4; Thu, 08 Feb 2018 15:47:25 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id; bh=ILEIKfFo6Xl91qp0Wd djnSAKnVZv1sI0roblD0UkXNE=; b=krPU819jJdTN5VrUcIHFtBNBBNqWqAHJ1i hjiquSX1LaCchZoxGfv0XaxJ1uM42/vnf8CntipMdqG6dUA31DX5wYHqdbu+onqG ahVtqHbhHkJD9h90d/d1GoWbn0p4AX4W+tUpayYWzaC/xzHBFPAzWAumUHBoyerC WJ87+3C08= From: Chen Hanxiao To: libvir-list@redhat.com Date: Thu, 8 Feb 2018 15:47:01 +0800 Message-Id: <20180208074704.19497-3-chen_han_xiao@126.com> In-Reply-To: <20180208074704.19497-1-chen_han_xiao@126.com> References: <20180208074704.19497-1-chen_han_xiao@126.com> X-CM-TRANSID: DMmowADnbmeBAHxa+5+kBw--.65372S4 X-Coremail-Antispam: 1Uf129KBjvJXoW3Ww4UJr17uF1xur13JFW8JFb_yoW3Cry8pF y5G3Z0qw4rJw1xC3s3KF4FyF13Crs7Wr1xWw1fuw1qyw18JF17Jrn7Kry7KFW8J3y3CF4S 9rs3KFyjkr4kJaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j4FAJUUUUU= X-Originating-IP: [58.213.111.46] X-CM-SenderInfo: xfkh0spkdqs5xldrqiyswou0bp/1tbi6w3mrlpD4qaONAAAsJ X-Greylist: Sender passed SPF test, ACL 227 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 08 Feb 2018 07:47:29 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 08 Feb 2018 07:47:29 +0000 (UTC) for IP:'220.181.15.112' DOMAIN:'m15-112.126.com' HELO:'m15-112.126.com' FROM:'chen_han_xiao@126.com' RCPT:'' X-RedHat-Spam-Score: 1.99 * (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_PSBL, SPF_PASS, T_RP_MATCHES_RCVD) 220.181.15.112 m15-112.126.com 220.181.15.112 m15-112.126.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Chen Hanxiao Subject: [libvirt] [PATCH v4 2/5] util: introduce helper to parse message from RTM_GETNEIGH query X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 08 Feb 2018 07:51:49 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Chen Hanxiao introduce helper to parse RTM_GETNEIGH query message and store it in struct virArpTable. Signed-off-by: Chen Hanxiao --- v4: use netlink query instead of parsing /proc/net/arp v3: s/virGetArpTable/virArpTableGet alloc virArpTable in virArpTableGet return ENOSUPP on none-Linux platform move helpers to virarptable.[ch] po/POTFILES.in | 1 + src/Makefile.am | 1 + src/libvirt_private.syms | 5 ++ src/util/virarptable.c | 182 +++++++++++++++++++++++++++++++++++++++++++= ++++ src/util/virarptable.h | 47 ++++++++++++ 5 files changed, 236 insertions(+) create mode 100644 src/util/virarptable.c create mode 100644 src/util/virarptable.h diff --git a/po/POTFILES.in b/po/POTFILES.in index cbf2accba..0f2ba7490 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -193,6 +193,7 @@ src/uml/uml_conf.c src/uml/uml_driver.c src/util/iohelper.c src/util/viralloc.c +src/util/virarptable.c src/util/viraudit.c src/util/virauth.c src/util/virauthconfig.c diff --git a/src/Makefile.am b/src/Makefile.am index 79adc9ba5..dd79b58e0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -98,6 +98,7 @@ augeastest_DATA =3D UTIL_SOURCES =3D \ util/viralloc.c util/viralloc.h \ util/virarch.h util/virarch.c \ + util/virarptable.h util/virarptable.c \ util/viratomic.h util/viratomic.c \ util/viraudit.c util/viraudit.h \ util/virauth.c util/virauth.h \ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index d90eb3dde..1167220f2 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1346,6 +1346,11 @@ virArchGetWordSize; virArchToString; =20 =20 +# util/virarptable.h +virArpTableFree; +virArpTableGet; + + # util/viraudit.h virAuditClose; virAuditEncode; diff --git a/src/util/virarptable.c b/src/util/virarptable.c new file mode 100644 index 000000000..cbf085403 --- /dev/null +++ b/src/util/virarptable.c @@ -0,0 +1,182 @@ +/* + * virarptable.c Linux ARP table handling + * + * Copyright (C) 2018 Chen Hanxiao + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + * + * Authors: + * Chen Hanxiao + */ + +#include + +#include +#include +#include + +#include "viralloc.h" +#include "virarptable.h" +#include "virfile.h" +#include "virlog.h" +#include "virnetlink.h" +#include "virsocketaddr.h" +#include "virstring.h" + +#define VIR_FROM_THIS VIR_FROM_NONE + +VIR_LOG_INIT("util.arptable"); + +#ifdef __linux__ + +# define NDA_RTA(r) \ + ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ndmsg)))) + +static int +parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len) +{ + memset(tb, 0, sizeof(struct rtattr *) * (max + 1)); + while (RTA_OK(rta, len)) { + if ((rta->rta_type <=3D max) && (!tb[rta->rta_type])) + tb[rta->rta_type] =3D rta; + rta =3D RTA_NEXT(rta, len); + } + + if (len) + VIR_WARN("malformed netlink message: Deficit %d, rta_len=3D%d", + len, rta->rta_len); + return 0; +} + +virArpTablePtr virArpTableGet(void) +{ + int num =3D 0; + int msglen; + void *nlData =3D NULL; + virArpTablePtr table =3D NULL; + char *ipstr =3D NULL; + struct nlmsghdr* nh; + struct rtattr * tb[NDA_MAX+1]; + + msglen =3D virNetlinkGetNeighbor(&nlData, 0, 0); + if (msglen < 0) + return NULL; + + if (VIR_ALLOC(table) < 0) + return NULL; + + nh =3D (struct nlmsghdr*)nlData; + + while (NLMSG_OK(nh, msglen)) { + struct ndmsg *r =3D NLMSG_DATA(nh); + int len =3D nh->nlmsg_len; + void *addr; + + if ((len -=3D NLMSG_LENGTH(sizeof(*nh))) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("wrong nlmsg len")); + goto cleanup; + } + + if (r->ndm_family && (r->ndm_family !=3D AF_INET)) + goto next_nlmsg; + + /* catch stale and reachalbe arp entry only */ + if (r->ndm_state && + (!(r->ndm_state =3D=3D NUD_STALE || r->ndm_state =3D=3D NUD_REAC= HABLE))) { + nh =3D NLMSG_NEXT(nh, msglen); + continue; + } + + if (nh->nlmsg_type =3D=3D NLMSG_DONE) + goto end_of_netlink_messages; + + parse_rtattr(tb, NDA_MAX, NDA_RTA(r), + nh->nlmsg_len - NLMSG_LENGTH(sizeof(*r))); + + if (tb[NDA_DST] =3D=3D NULL || tb[NDA_LLADDR] =3D=3D NULL) + goto next_nlmsg; + + if (tb[NDA_DST]) { + virSocketAddr virAddr; + if (VIR_REALLOC_N(table->t, num + 1) < 0) + goto cleanup; + + table->n =3D num + 1; + + addr =3D RTA_DATA(tb[NDA_DST]); + bzero(&virAddr, sizeof(virAddr)); + virAddr.len =3D sizeof(virAddr.data.inet4); + virAddr.data.inet4.sin_family =3D AF_INET; + virAddr.data.inet4.sin_addr =3D *(struct in_addr *)addr; + ipstr =3D virSocketAddrFormat(&virAddr); + + if (VIR_STRDUP(table->t[num].ipaddr, ipstr) < 0) + goto cleanup; + + VIR_FREE(ipstr); + } + + if (tb[NDA_LLADDR]) { + virMacAddr macaddr; + char ifmac[VIR_MAC_STRING_BUFLEN]; + + addr =3D RTA_DATA(tb[NDA_LLADDR]); + memcpy(macaddr.addr, addr, VIR_MAC_BUFLEN); + macaddr.generated =3D false; + + virMacAddrFormat(&macaddr, ifmac); + + if (VIR_STRDUP(table->t[num].mac, ifmac) < 0) + goto cleanup; + + num++; + } + + next_nlmsg: + nh =3D NLMSG_NEXT(nh, msglen); + } + + end_of_netlink_messages: + VIR_FREE(nlData); + return table; + + cleanup: + VIR_FREE(ipstr); + VIR_FREE(nlData); + return NULL; +} + +#else + +virArpTablePtr virArpTableGet(void) +{ + virReportError(VIR_ERR_NO_SUPPORT, "%s", + _("get arp table not implemented on this platform")); + return NULL; +} + +#endif /* __linux__ */ + +void +virArpTableFree(virArpTablePtr table) +{ + size_t i; + for (i =3D 0; i < table->n; i++) { + VIR_FREE(table->t[i].ipaddr); + VIR_FREE(table->t[i].mac); + } + VIR_FREE(table); +} diff --git a/src/util/virarptable.h b/src/util/virarptable.h new file mode 100644 index 000000000..682919812 --- /dev/null +++ b/src/util/virarptable.h @@ -0,0 +1,47 @@ +/* + * virarptable.h Linux ARP table handling + * + * Copyright (C) 2018 Chen Hanxiao + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + * + * Authors: + * Chen Hanxiao + */ + +#ifndef __VIR_ARPTABLE_H__ +# define __VIR_ARPTABLE_H__ + +# include "internal.h" + +typedef struct _virArpTableEntry virArpTableEntry; +typedef virArpTableEntry *virArpTableEntryPtr; +typedef struct _virArpTable virArpTable; +typedef virArpTable *virArpTablePtr; + +struct _virArpTableEntry{ + char *ipaddr; + char *mac; +}; + +struct _virArpTable { + int n; + virArpTableEntryPtr t; +}; + +virArpTablePtr virArpTableGet(void); +void virArpTableFree(virArpTablePtr table); + +#endif /* __VIR_ARPTABLE_H__ */ --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 08:57:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=126.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1518076209635943.7639123165552; Wed, 7 Feb 2018 23:50:09 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 774EF356D5; Thu, 8 Feb 2018 07:50:08 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 493F8609AA; Thu, 8 Feb 2018 07:50:08 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 011BD4A46D; Thu, 8 Feb 2018 07:50:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w187lVBU001249 for ; Thu, 8 Feb 2018 02:47:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id BF5856E52E; Thu, 8 Feb 2018 07:47:31 +0000 (UTC) Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B6AA56F10E for ; Thu, 8 Feb 2018 07:47:29 +0000 (UTC) Received: from m15-112.126.com (m15-112.126.com [220.181.15.112]) by mx1.redhat.com (Postfix) with ESMTP id 7E791C04FF87 for ; Thu, 8 Feb 2018 07:47:27 +0000 (UTC) Received: from localhost.localdomain (unknown [58.213.111.46]) by smtp2 (Coremail) with SMTP id DMmowADnbmeBAHxa+5+kBw--.65372S5; Thu, 08 Feb 2018 15:47:25 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=hqiDG QuE+EcIF0iSc+/PPUviIDGdH2DovrZDRlTqn0A=; b=Kgas6WaTtvLmj+0ir5BzI GoiAyPUxZZpjvxeRjnpMsVIZQVSnL7Z9yWUITlxWSp7v4iqSeU7X2/ColoY/o7Fn ZToCAn/5b2y6m8+Y2B3G8c5Rsi6ijiTJns8eDDpxQyDfqdVXS7EbybH3GCoFWDt9 7qdGc+bM+NNcoG2iJuPOrE= From: Chen Hanxiao To: libvir-list@redhat.com Date: Thu, 8 Feb 2018 15:47:02 +0800 Message-Id: <20180208074704.19497-4-chen_han_xiao@126.com> In-Reply-To: <20180208074704.19497-1-chen_han_xiao@126.com> References: <20180208074704.19497-1-chen_han_xiao@126.com> MIME-Version: 1.0 X-CM-TRANSID: DMmowADnbmeBAHxa+5+kBw--.65372S5 X-Coremail-Antispam: 1Uf129KBjvJXoWxZryDJrW8Kr4rZrWkAry7Jrb_yoWrZw4kpF WDXFs5trZ5Kr1fCrZxG3W7XF15G3y8KF17Cana9a1vvw1xGr9rXw1Sg342vFyjyr4xZFy7 CF9rKayUWa12qFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j1rWwUUUUU= X-Originating-IP: [58.213.111.46] X-CM-SenderInfo: xfkh0spkdqs5xldrqiyswou0bp/1tbikQ7mrlpD4ySq1gAAs1 X-Greylist: Sender passed SPF test, ACL 227 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 08 Feb 2018 07:47:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 08 Feb 2018 07:47:28 +0000 (UTC) for IP:'220.181.15.112' DOMAIN:'m15-112.126.com' HELO:'m15-112.126.com' FROM:'chen_han_xiao@126.com' RCPT:'' X-RedHat-Spam-Score: 1.99 * (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_PSBL, SPF_PASS, T_RP_MATCHES_RCVD) 220.181.15.112 m15-112.126.com 220.181.15.112 m15-112.126.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Chen Hanxiao Subject: [libvirt] [PATCH v4 3/5] qemu: introduce qemuARPGetInterfaces to get IP from host's arp table X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 08 Feb 2018 07:50:08 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Chen Hanxiao introduce VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_ARP to get ip address of VM from the message of netlink RTM_GETNEIGH Signed-off-by: Chen Hanxiao --- v4=EF=BC=9A remove dummy entry use VIR_APPEND_ELEMENT v3: add docs in virDomainInterfaceAddresses remove error label show network interface which did not match the arp table include/libvirt/libvirt-domain.h | 1 + src/libvirt-domain.c | 7 ++++ src/qemu/qemu_driver.c | 72 ++++++++++++++++++++++++++++++++++++= ++++ 3 files changed, 80 insertions(+) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 4048acf38..38e2d9a3e 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -4665,6 +4665,7 @@ typedef virMemoryParameter *virMemoryParameterPtr; typedef enum { VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE =3D 0, /* Parse DHCP lease fi= le */ VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT =3D 1, /* Query qemu guest ag= ent */ + VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_ARP =3D 2, /* Query ARP tables */ =20 # ifdef VIR_ENUM_SENTINELS VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LAST diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index eaec0979a..1ae83610d 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -11721,6 +11721,13 @@ virDomainFSInfoFree(virDomainFSInfoPtr info) * To match such interface with the one from @dom XML use MAC address or IP * range. * + * If @source is VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_ARP, the /proc/net/arp + * will be check to obtain the interface addresses. + * As the arp cache did not refresh in time, the returned ip address + * may be unreachable. + * As the route config of the guest, the returned mac address + * may be duplicated. + * * @ifaces->name and @ifaces->hwaddr are never NULL. * * The caller *must* free @ifaces when no longer needed. Usual use case diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index bff49e7be..0cec39df6 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -70,6 +70,7 @@ #include "virnetdevopenvswitch.h" #include "capabilities.h" #include "viralloc.h" +#include "virarptable.h" #include "viruuid.h" #include "domain_conf.h" #include "domain_audit.h" @@ -160,6 +161,9 @@ static int qemuGetDHCPInterfaces(virDomainPtr dom, virDomainObjPtr vm, virDomainInterfacePtr **ifaces); =20 +static int qemuARPGetInterfaces(virDomainObjPtr vm, + virDomainInterfacePtr **ifaces); + static virQEMUDriverPtr qemu_driver; =20 =20 @@ -20516,6 +20520,10 @@ qemuDomainInterfaceAddresses(virDomainPtr dom, =20 break; =20 + case VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_ARP: + ret =3D qemuARPGetInterfaces(vm, ifaces); + break; + default: virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, _("Unknown IP address data source %d"), @@ -20626,6 +20634,70 @@ qemuGetDHCPInterfaces(virDomainPtr dom, } =20 =20 +static int +qemuARPGetInterfaces(virDomainObjPtr vm, + virDomainInterfacePtr **ifaces) +{ + size_t i, j; + size_t ifaces_count =3D 0; + int ret =3D -1; + char macaddr[VIR_MAC_STRING_BUFLEN]; + virDomainInterfacePtr *ifaces_ret =3D NULL; + virDomainInterfacePtr iface =3D NULL; + virArpTablePtr table; + + table =3D virArpTableGet(); + if (!table) + goto cleanup; + + for (i =3D 0; i < vm->def->nnets; i++) { + if (vm->def->nets[i]->type !=3D VIR_DOMAIN_NET_TYPE_NETWORK) + continue; + + virMacAddrFormat(&(vm->def->nets[i]->mac), macaddr); + virArpTableEntry entry; + for (j =3D 0; j < table->n; j++) { + entry =3D table->t[j]; + if (STREQ(entry.mac, macaddr)) { + if (VIR_ALLOC(iface) < 0) + goto cleanup; + + iface->naddrs =3D 1; + if (VIR_STRDUP(iface->name, vm->def->nets[i]->ifname) < 0) + goto cleanup; + + if (VIR_STRDUP(iface->hwaddr, macaddr) < 0) + goto cleanup; + + if (VIR_ALLOC_N(iface->addrs, iface->naddrs) < 0) + goto cleanup; + + if (VIR_STRDUP(iface->addrs->addr, entry.ipaddr) < 0) + goto cleanup; + + if (VIR_APPEND_ELEMENT(ifaces_ret, ifaces_count, iface) < = 0) + goto cleanup; + + } + } + } + + VIR_STEAL_PTR(*ifaces, ifaces_ret); + ret =3D ifaces_count; + + cleanup: + virArpTableFree(table); + + if (ifaces_ret) { + for (i =3D 0; i < ifaces_count; i++) + virDomainInterfaceFree(ifaces_ret[i]); + } + VIR_FREE(ifaces_ret); + + return ret; +} + + static int qemuDomainSetUserPassword(virDomainPtr dom, const char *user, --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 08:57:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=126.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1518076207880452.7342340525304; Wed, 7 Feb 2018 23:50:07 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 799D680478; Thu, 8 Feb 2018 07:50:06 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4B36360E39; Thu, 8 Feb 2018 07:50:06 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A47F518033DE; Thu, 8 Feb 2018 07:50:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w187lVJH001245 for ; Thu, 8 Feb 2018 02:47:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id AB6B42A341; Thu, 8 Feb 2018 07:47:31 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A5E474F129 for ; Thu, 8 Feb 2018 07:47:29 +0000 (UTC) Received: from m15-112.126.com (m15-112.126.com [220.181.15.112]) by mx1.redhat.com (Postfix) with ESMTP id 82F578535D for ; Thu, 8 Feb 2018 07:47:27 +0000 (UTC) Received: from localhost.localdomain (unknown [58.213.111.46]) by smtp2 (Coremail) with SMTP id DMmowADnbmeBAHxa+5+kBw--.65372S6; Thu, 08 Feb 2018 15:47:26 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id; bh=Tox3HTIatJomzawNCE SJCC17DqjI3Gg+/npueR+hGa0=; b=MS3dfR/nTsb+6u9mSIKtYRw7dmAaK7yFTp X/hud2bqeNTuqAWFs6ogn/DI70Vy5jwes7CJtYmXRU2Z716vBcVYj2qqmzogRBQS lxR4IF41PteUW2uYapstU/o3u8R70933JK9Q6FtXtxFBEMoV27hbOYniQmJNBbjM ZN6OYu43Y= From: Chen Hanxiao To: libvir-list@redhat.com Date: Thu, 8 Feb 2018 15:47:03 +0800 Message-Id: <20180208074704.19497-5-chen_han_xiao@126.com> In-Reply-To: <20180208074704.19497-1-chen_han_xiao@126.com> References: <20180208074704.19497-1-chen_han_xiao@126.com> X-CM-TRANSID: DMmowADnbmeBAHxa+5+kBw--.65372S6 X-Coremail-Antispam: 1Uf129KBjvJXoW7Kr1kAr13JFWfAw1ktw48tFb_yoW8ur4kpF s3Xay7A3s7Xrn8X3Z5Cw15uFykG3y29r18uan8Xw1jvr45A3WDJr17GFWF9Fn7Cr10v3W0 yrZF9F4DZFs5AF7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jIKZXUUUUU= X-Originating-IP: [58.213.111.46] X-CM-SenderInfo: xfkh0spkdqs5xldrqiyswou0bp/1tbi4w7mrlpD40DzGwAAs3 X-Greylist: Sender passed SPF test, ACL 227 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 08 Feb 2018 07:47:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 08 Feb 2018 07:47:28 +0000 (UTC) for IP:'220.181.15.112' DOMAIN:'m15-112.126.com' HELO:'m15-112.126.com' FROM:'chen_han_xiao@126.com' RCPT:'' X-RedHat-Spam-Score: 1.99 * (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_PSBL, SPF_PASS, T_RP_MATCHES_RCVD) 220.181.15.112 m15-112.126.com 220.181.15.112 m15-112.126.com X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Chen Hanxiao Subject: [libvirt] [PATCH v4 4/5] virsh: add --source arp to domifaddr X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 08 Feb 2018 07:50:07 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Chen Hanxiao We can use: domifaddr f26-cloud --source arp to get the address. Acked-by: Michal Privoznik Signed-off-by: Chen Hanxiao --- tools/virsh-domain-monitor.c | 2 ++ tools/virsh.pod | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 32a42707e..68da11ed5 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -2190,6 +2190,8 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd) source =3D VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE; } else if (STREQ(sourcestr, "agent")) { source =3D VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT; + } else if (STREQ(sourcestr, "arp")) { + source =3D VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_ARP; } else { vshError(ctl, _("Unknown data source '%s'"), sourcestr); goto cleanup; diff --git a/tools/virsh.pod b/tools/virsh.pod index 69cc42338..1dfe2a9b0 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -759,7 +759,7 @@ B (fields appear in the followin= g order): =20 =20 =3Ditem B I [I] [I<--full>] - [I<--source lease|agent>] + [I<--source lease|agent|arp>] =20 Get a list of interfaces of a running domain along with their IP and MAC addresses, or limited output just for one interface if I is @@ -774,8 +774,9 @@ only the interface name and MAC address is displayed fo= r the first name and MAC address with "-" for the others using the same name and MAC address. =20 The I<--source> argument specifies what data source to use for the -addresses, currently one of 'lease' to read DHCP leases, or 'agent' to que= ry -the guest OS via an agent. If unspecified, 'lease' is the default. +addresses, currently 'lease' to read DHCP leases, 'agent' to query +the guest OS via an agent, or 'arp' to get IP from host's arp tables. +If unspecified, 'lease' is the default. =20 =3Ditem B I I =20 --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 08:57:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=126.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1518076304951665.8518557972478; Wed, 7 Feb 2018 23:51:44 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 25D1880474; Thu, 8 Feb 2018 07:51:44 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EF1417E4CF; Thu, 8 Feb 2018 07:51:43 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A524818033E0; Thu, 8 Feb 2018 07:51:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w187lVKC001247 for ; Thu, 8 Feb 2018 02:47:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id BA3AA620D8; Thu, 8 Feb 2018 07:47:31 +0000 (UTC) Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B4313759E5 for ; Thu, 8 Feb 2018 07:47:29 +0000 (UTC) Received: from m15-112.126.com (m15-112.126.com [220.181.15.112]) by mx1.redhat.com (Postfix) with ESMTP id 941D485542 for ; Thu, 8 Feb 2018 07:47:27 +0000 (UTC) Received: from localhost.localdomain (unknown [58.213.111.46]) by smtp2 (Coremail) with SMTP id DMmowADnbmeBAHxa+5+kBw--.65372S7; Thu, 08 Feb 2018 15:47:26 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id; bh=eZ+3O3x7hnvv5MQYjs 4Ts8EBocXl51wSP/HwGZmc51s=; b=drzALKu4rc4HMBY/wJ0ZQQ/5+modv7w+0b GoNdDzPcf1b7rfXDtGbqeEVQ+TIYCZEGMuBf9b2XJHIc97/5z96D2DCDzD4a5k4l qZDnbhVbuR8FvOKf03k8jjKxdXe5RBIov2qW+Edf+cn/Bz4v/iC1a83bEAgA8Hvm pyiugfa7E= From: Chen Hanxiao To: libvir-list@redhat.com Date: Thu, 8 Feb 2018 15:47:04 +0800 Message-Id: <20180208074704.19497-6-chen_han_xiao@126.com> In-Reply-To: <20180208074704.19497-1-chen_han_xiao@126.com> References: <20180208074704.19497-1-chen_han_xiao@126.com> X-CM-TRANSID: DMmowADnbmeBAHxa+5+kBw--.65372S7 X-Coremail-Antispam: 1Uf129KBjvdXoW7XFy5Jw1xGryUtw45Xw4rGrg_yoWxtFX_G3 4xXa48XrW5JF9ayayFqr48ury8uw48Ar1UKwn0kryYq3y8trs5Aas2qa90qr12qFWIyFW3 Arsxta1kGr4xtjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU0VwZ7UUUUU== X-Originating-IP: [58.213.111.46] X-CM-SenderInfo: xfkh0spkdqs5xldrqiyswou0bp/1tbikg7mrlpD4J+LMQAAsI X-Greylist: Sender passed SPF test, ACL 227 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 08 Feb 2018 07:47:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 08 Feb 2018 07:47:28 +0000 (UTC) for IP:'220.181.15.112' DOMAIN:'m15-112.126.com' HELO:'m15-112.126.com' FROM:'chen_han_xiao@126.com' RCPT:'' X-RedHat-Spam-Score: 1.99 * (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_PSBL, SPF_PASS, T_RP_MATCHES_RCVD) 220.181.15.112 m15-112.126.com 220.181.15.112 m15-112.126.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.28 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Chen Hanxiao Subject: [libvirt] [PATCH v4 5/5] news: qemu: use arp table of host to get the IP address of guests X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 08 Feb 2018 07:51:44 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Chen Hanxiao Signed-off-by: Chen Hanxiao --- v3: more verbose description docs/news.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/news.xml b/docs/news.xml index 5a2943a58..5d6a467d3 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -72,6 +72,15 @@ completion data. + + + qemu: use arp table of host to get the IP address of guests + + + Find IP address of a VM by arp table on hosts. + If someone customizing IP address inside VM, it will be helpful. + +
--=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list