Signed-off-by: Shi Lei <shi_lei(a)massclouds.com>
---
src/util/virnetlink.c | 14 ++++++++++++++
src/util/virnetlink.h | 1 +
2 files changed, 15 insertions(+)
diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c
index fdd3a6a4..8625b896 100644
--- a/src/util/virnetlink.c
+++ b/src/util/virnetlink.c
@@ -24,6 +24,7 @@
#include <config.h>
#include <unistd.h>
+#include <linux/veth.h>
#include "virnetlink.h"
#include "virnetdev.h"
@@ -535,6 +536,19 @@ virNetlinkNewLink(const char *ifname,
NETLINK_MSG_NEST_END(nl_msg, infodata);
}
+ if (STREQ(type, "veth") && extra_args &&
extra_args->veth_peer) {
+ struct nlattr *infoveth = NULL;
+
+ NETLINK_MSG_NEST_START(nl_msg, infodata, IFLA_INFO_DATA);
+ NETLINK_MSG_NEST_START(nl_msg, infoveth, VETH_INFO_PEER);
+ nlmsg_reserve(nl_msg, sizeof(struct ifinfomsg), 0);
+ NETLINK_MSG_PUT(nl_msg, IFLA_IFNAME,
+ (strlen(extra_args->veth_peer) + 1),
+ extra_args->veth_peer);
+ NETLINK_MSG_NEST_END(nl_msg, infoveth);
+ NETLINK_MSG_NEST_END(nl_msg, infodata);
+ }
+
NETLINK_MSG_NEST_END(nl_msg, linkinfo);
if (extra_args) {
diff --git a/src/util/virnetlink.h b/src/util/virnetlink.h
index 7121eac4..7c4ed202 100644
--- a/src/util/virnetlink.h
+++ b/src/util/virnetlink.h
@@ -84,6 +84,7 @@ struct _virNetlinkNewLinkData {
const int *ifindex; /* The index for the 'link' device */
const virMacAddr *mac; /* The MAC address of the device */
const uint32_t *macvlan_mode; /* The mode of macvlan */
+ const char *veth_peer; /* The peer name for veth */
};
int virNetlinkNewLink(const char *ifname,
--
2.25.1