1
0

macvtap mac_filter support

This patch adds the mac_filter support to the macvtap device.
This commit is contained in:
Stefan Berger 2010-02-19 15:41:30 +01:00 committed by Daniel Veillard
parent 62f4ae153b
commit b3e7890ada
3 changed files with 15 additions and 3 deletions

View File

@ -335,7 +335,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
if (!(driver->ebtables = ebtablesContextNew("qemu"))) { if (!(driver->ebtables = ebtablesContextNew("qemu"))) {
driver->macFilter = 0; driver->macFilter = 0;
virReportSystemError(errno, virReportSystemError(errno,
_("failed to enable mac filter in in '%s'"), _("failed to enable mac filter in '%s'"),
__FILE__); __FILE__);
} }
@ -1432,6 +1432,7 @@ int qemudExtractVersion(struct qemud_driver *driver) {
*/ */
int int
qemudPhysIfaceConnect(virConnectPtr conn, qemudPhysIfaceConnect(virConnectPtr conn,
struct qemud_driver *driver,
virDomainNetDefPtr net, virDomainNetDefPtr net,
char *linkdev, char *linkdev,
int brmode, int brmode,
@ -1441,6 +1442,7 @@ qemudPhysIfaceConnect(virConnectPtr conn,
#if WITH_MACVTAP #if WITH_MACVTAP
char *res_ifname = NULL; char *res_ifname = NULL;
int vnet_hdr = 0; int vnet_hdr = 0;
int err;
if (qemuCmdFlags & QEMUD_CMD_FLAG_VNET_HDR && if (qemuCmdFlags & QEMUD_CMD_FLAG_VNET_HDR &&
net->model && STREQ(net->model, "virtio")) net->model && STREQ(net->model, "virtio"))
@ -1452,12 +1454,21 @@ qemudPhysIfaceConnect(virConnectPtr conn,
VIR_FREE(net->ifname); VIR_FREE(net->ifname);
net->ifname = res_ifname; net->ifname = res_ifname;
} }
if (rc >=0 && driver->macFilter) {
if ((err = networkAllowMacOnPort(driver, net->ifname, net->mac))) {
virReportSystemError(err,
_("failed to add ebtables rule to allow MAC address on '%s'"),
net->ifname);
}
}
#else #else
(void)conn; (void)conn;
(void)net; (void)net;
(void)linkdev; (void)linkdev;
(void)brmode; (void)brmode;
(void)qemuCmdFlags; (void)qemuCmdFlags;
(void)driver;
qemuReportError(VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("No support for macvtap device")); "%s", _("No support for macvtap device"));
rc = -1; rc = -1;
@ -3757,7 +3768,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
if (snprintf(tapfd_name, sizeof(tapfd_name), "%d", tapfd) >= sizeof(tapfd_name)) if (snprintf(tapfd_name, sizeof(tapfd_name), "%d", tapfd) >= sizeof(tapfd_name))
goto no_memory; goto no_memory;
} else if (net->type == VIR_DOMAIN_NET_TYPE_DIRECT) { } else if (net->type == VIR_DOMAIN_NET_TYPE_DIRECT) {
int tapfd = qemudPhysIfaceConnect(conn, net, int tapfd = qemudPhysIfaceConnect(conn, driver, net,
net->data.direct.linkdev, net->data.direct.linkdev,
net->data.direct.mode, net->data.direct.mode,
qemuCmdFlags); qemuCmdFlags);

View File

@ -251,6 +251,7 @@ int qemudNetworkIfaceConnect (virConnectPtr conn,
ATTRIBUTE_NONNULL(1); ATTRIBUTE_NONNULL(1);
int qemudPhysIfaceConnect(virConnectPtr conn, int qemudPhysIfaceConnect(virConnectPtr conn,
struct qemud_driver *driver,
virDomainNetDefPtr net, virDomainNetDefPtr net,
char *linkdev, char *linkdev,
int brmode, int brmode,

View File

@ -5723,7 +5723,7 @@ static int qemudDomainAttachNetDevice(virConnectPtr conn,
return -1; return -1;
} }
if ((tapfd = qemudPhysIfaceConnect(conn, net, if ((tapfd = qemudPhysIfaceConnect(conn, driver, net,
net->data.direct.linkdev, net->data.direct.linkdev,
net->data.direct.mode, net->data.direct.mode,
qemuCmdFlags)) < 0) qemuCmdFlags)) < 0)