2010-02-15 15:58:13 +00:00
|
|
|
/*
|
2016-01-19 19:20:54 +00:00
|
|
|
* Copyright (C) 2011, 2013, 2016 Red Hat, Inc.
|
2010-02-15 15:58:13 +00:00
|
|
|
* Copyright (C) 2010 IBM Corporation
|
|
|
|
*
|
|
|
|
* 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
|
2012-09-20 22:30:55 +00:00
|
|
|
* License along with this library. If not, see
|
2012-07-21 10:06:23 +00:00
|
|
|
* <http://www.gnu.org/licenses/>.
|
2010-02-15 15:58:13 +00:00
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Stefan Berger <stefanb@us.ibm.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __UTIL_MACVTAP_H__
|
2010-03-09 18:22:22 +00:00
|
|
|
# define __UTIL_MACVTAP_H__
|
2010-02-15 15:58:13 +00:00
|
|
|
|
Split src/util/network.{c,h} into 5 pieces
The src/util/network.c file is a dumping ground for many different
APIs. Split it up into 5 pieces, along functional lines
- src/util/virnetdevbandwidth.c: virNetDevBandwidth type & helper APIs
- src/util/virnetdevvportprofile.c: virNetDevVPortProfile type & helper APIs
- src/util/virsocketaddr.c: virSocketAddr and APIs
- src/conf/netdev_bandwidth_conf.c: XML parsing / formatting
for virNetDevBandwidth
- src/conf/netdev_vport_profile_conf.c: XML parsing / formatting
for virNetDevVPortProfile
* src/util/network.c, src/util/network.h: Split into 5 pieces
* src/conf/netdev_bandwidth_conf.c, src/conf/netdev_bandwidth_conf.h,
src/conf/netdev_vport_profile_conf.c, src/conf/netdev_vport_profile_conf.h,
src/util/virnetdevbandwidth.c, src/util/virnetdevbandwidth.h,
src/util/virnetdevvportprofile.c, src/util/virnetdevvportprofile.h,
src/util/virsocketaddr.c, src/util/virsocketaddr.h: New pieces
* daemon/libvirtd.h, daemon/remote.c, src/conf/domain_conf.c,
src/conf/domain_conf.h, src/conf/network_conf.c,
src/conf/network_conf.h, src/conf/nwfilter_conf.h,
src/esx/esx_util.h, src/network/bridge_driver.c,
src/qemu/qemu_conf.c, src/rpc/virnetsocket.c,
src/rpc/virnetsocket.h, src/util/dnsmasq.h, src/util/interface.h,
src/util/iptables.h, src/util/macvtap.c, src/util/macvtap.h,
src/util/virnetdev.h, src/util/virnetdevtap.c,
tools/virsh.c: Update include files
2011-11-02 15:40:08 +00:00
|
|
|
# include "internal.h"
|
2012-07-17 12:07:59 +00:00
|
|
|
# include "virmacaddr.h"
|
Split src/util/network.{c,h} into 5 pieces
The src/util/network.c file is a dumping ground for many different
APIs. Split it up into 5 pieces, along functional lines
- src/util/virnetdevbandwidth.c: virNetDevBandwidth type & helper APIs
- src/util/virnetdevvportprofile.c: virNetDevVPortProfile type & helper APIs
- src/util/virsocketaddr.c: virSocketAddr and APIs
- src/conf/netdev_bandwidth_conf.c: XML parsing / formatting
for virNetDevBandwidth
- src/conf/netdev_vport_profile_conf.c: XML parsing / formatting
for virNetDevVPortProfile
* src/util/network.c, src/util/network.h: Split into 5 pieces
* src/conf/netdev_bandwidth_conf.c, src/conf/netdev_bandwidth_conf.h,
src/conf/netdev_vport_profile_conf.c, src/conf/netdev_vport_profile_conf.h,
src/util/virnetdevbandwidth.c, src/util/virnetdevbandwidth.h,
src/util/virnetdevvportprofile.c, src/util/virnetdevvportprofile.h,
src/util/virsocketaddr.c, src/util/virsocketaddr.h: New pieces
* daemon/libvirtd.h, daemon/remote.c, src/conf/domain_conf.c,
src/conf/domain_conf.h, src/conf/network_conf.c,
src/conf/network_conf.h, src/conf/nwfilter_conf.h,
src/esx/esx_util.h, src/network/bridge_driver.c,
src/qemu/qemu_conf.c, src/rpc/virnetsocket.c,
src/rpc/virnetsocket.h, src/util/dnsmasq.h, src/util/interface.h,
src/util/iptables.h, src/util/macvtap.c, src/util/macvtap.h,
src/util/virnetdev.h, src/util/virnetdevtap.c,
tools/virsh.c: Update include files
2011-11-02 15:40:08 +00:00
|
|
|
# include "virsocketaddr.h"
|
|
|
|
# include "virnetdevbandwidth.h"
|
|
|
|
# include "virnetdevvportprofile.h"
|
2016-05-04 17:18:16 +00:00
|
|
|
# include "virnetdevvlan.h"
|
2010-02-15 15:58:13 +00:00
|
|
|
|
2011-06-20 16:08:41 +00:00
|
|
|
/* the mode type for macvtap devices */
|
2014-04-27 00:15:22 +00:00
|
|
|
typedef enum {
|
Rename Macvtap management APIs
In preparation for code re-organization, rename the Macvtap
management APIs to have the following patterns
virNetDevMacVLanXXXXX - macvlan/macvtap interface management
virNetDevVPortProfileXXXX - virtual port profile management
* src/util/macvtap.c, src/util/macvtap.h: Rename APIs
* src/conf/domain_conf.c, src/network/bridge_driver.c,
src/qemu/qemu_command.c, src/qemu/qemu_command.h,
src/qemu/qemu_driver.c, src/qemu/qemu_hotplug.c,
src/qemu/qemu_migration.c, src/qemu/qemu_process.c,
src/qemu/qemu_process.h: Update for renamed APIs
2011-11-02 16:51:01 +00:00
|
|
|
VIR_NETDEV_MACVLAN_MODE_VEPA,
|
|
|
|
VIR_NETDEV_MACVLAN_MODE_PRIVATE,
|
|
|
|
VIR_NETDEV_MACVLAN_MODE_BRIDGE,
|
|
|
|
VIR_NETDEV_MACVLAN_MODE_PASSTHRU,
|
2011-06-20 16:08:41 +00:00
|
|
|
|
Rename Macvtap management APIs
In preparation for code re-organization, rename the Macvtap
management APIs to have the following patterns
virNetDevMacVLanXXXXX - macvlan/macvtap interface management
virNetDevVPortProfileXXXX - virtual port profile management
* src/util/macvtap.c, src/util/macvtap.h: Rename APIs
* src/conf/domain_conf.c, src/network/bridge_driver.c,
src/qemu/qemu_command.c, src/qemu/qemu_command.h,
src/qemu/qemu_driver.c, src/qemu/qemu_hotplug.c,
src/qemu/qemu_migration.c, src/qemu/qemu_process.c,
src/qemu/qemu_process.h: Update for renamed APIs
2011-11-02 16:51:01 +00:00
|
|
|
VIR_NETDEV_MACVLAN_MODE_LAST,
|
2014-04-27 00:15:22 +00:00
|
|
|
} virNetDevMacVLanMode;
|
2011-11-02 17:11:02 +00:00
|
|
|
VIR_ENUM_DECL(virNetDevMacVLanMode)
|
2010-12-01 14:43:40 +00:00
|
|
|
|
2014-08-27 14:34:13 +00:00
|
|
|
typedef enum {
|
|
|
|
VIR_NETDEV_MACVLAN_CREATE_NONE = 0,
|
|
|
|
/* Create with a tap device */
|
|
|
|
VIR_NETDEV_MACVLAN_CREATE_WITH_TAP = 1 << 0,
|
2014-09-16 20:50:53 +00:00
|
|
|
/* Bring the interface up */
|
|
|
|
VIR_NETDEV_MACVLAN_CREATE_IFUP = 1 << 1,
|
2015-12-03 10:33:55 +00:00
|
|
|
/* Enable VNET_HDR */
|
|
|
|
VIR_NETDEV_MACVLAN_VNET_HDR = 1 << 2,
|
2014-08-27 14:34:13 +00:00
|
|
|
} virNetDevMacVLanCreateFlags;
|
|
|
|
|
2016-01-19 19:20:54 +00:00
|
|
|
int virNetDevMacVLanReserveName(const char *name, bool quietfail);
|
|
|
|
int virNetDevMacVLanReleaseName(const char *name);
|
|
|
|
|
2011-11-02 17:34:41 +00:00
|
|
|
int virNetDevMacVLanCreate(const char *ifname,
|
|
|
|
const char *type,
|
2013-10-05 19:41:44 +00:00
|
|
|
const virMacAddr *macaddress,
|
2011-11-02 17:34:41 +00:00
|
|
|
const char *srcdev,
|
|
|
|
uint32_t macvlan_mode,
|
|
|
|
int *retry)
|
|
|
|
ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4)
|
|
|
|
ATTRIBUTE_RETURN_CHECK;
|
|
|
|
|
|
|
|
int virNetDevMacVLanDelete(const char *ifname)
|
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
|
|
|
|
|
2011-11-02 17:19:48 +00:00
|
|
|
int virNetDevMacVLanCreateWithVPortProfile(const char *ifname,
|
2013-10-05 19:41:44 +00:00
|
|
|
const virMacAddr *macaddress,
|
2011-11-02 17:19:48 +00:00
|
|
|
const char *linkdev,
|
2014-04-27 00:15:22 +00:00
|
|
|
virNetDevMacVLanMode mode,
|
2016-05-04 17:18:16 +00:00
|
|
|
virNetDevVlanPtr vlan,
|
2011-11-02 17:19:48 +00:00
|
|
|
const unsigned char *vmuuid,
|
|
|
|
virNetDevVPortProfilePtr virtPortProfile,
|
|
|
|
char **res_ifname,
|
2014-04-27 00:15:22 +00:00
|
|
|
virNetDevVPortProfileOp vmop,
|
2011-11-02 17:19:48 +00:00
|
|
|
char *stateDir,
|
2015-12-04 10:31:17 +00:00
|
|
|
int *tapfd,
|
|
|
|
size_t tapfdSize,
|
2014-08-27 14:34:13 +00:00
|
|
|
unsigned int flags)
|
2016-05-04 17:18:16 +00:00
|
|
|
ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(6)
|
|
|
|
ATTRIBUTE_NONNULL(8) ATTRIBUTE_NONNULL(10) ATTRIBUTE_RETURN_CHECK;
|
2010-02-15 15:58:13 +00:00
|
|
|
|
2011-11-02 17:19:48 +00:00
|
|
|
int virNetDevMacVLanDeleteWithVPortProfile(const char *ifname,
|
2013-10-05 19:41:44 +00:00
|
|
|
const virMacAddr *macaddress,
|
2011-11-02 17:19:48 +00:00
|
|
|
const char *linkdev,
|
|
|
|
int mode,
|
|
|
|
virNetDevVPortProfilePtr virtPortProfile,
|
|
|
|
char *stateDir)
|
Rename Macvtap management APIs
In preparation for code re-organization, rename the Macvtap
management APIs to have the following patterns
virNetDevMacVLanXXXXX - macvlan/macvtap interface management
virNetDevVPortProfileXXXX - virtual port profile management
* src/util/macvtap.c, src/util/macvtap.h: Rename APIs
* src/conf/domain_conf.c, src/network/bridge_driver.c,
src/qemu/qemu_command.c, src/qemu/qemu_command.h,
src/qemu/qemu_driver.c, src/qemu/qemu_hotplug.c,
src/qemu/qemu_migration.c, src/qemu/qemu_process.c,
src/qemu/qemu_process.h: Update for renamed APIs
2011-11-02 16:51:01 +00:00
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
|
|
|
|
ATTRIBUTE_NONNULL(6) ATTRIBUTE_RETURN_CHECK;
|
2010-02-15 15:58:13 +00:00
|
|
|
|
2012-03-27 12:38:33 +00:00
|
|
|
int virNetDevMacVLanRestartWithVPortProfile(const char *cr_ifname,
|
2013-10-05 19:41:44 +00:00
|
|
|
const virMacAddr *macaddress,
|
2012-03-27 12:38:33 +00:00
|
|
|
const char *linkdev,
|
|
|
|
const unsigned char *vmuuid,
|
|
|
|
virNetDevVPortProfilePtr virtPortProfile,
|
2014-04-27 00:15:22 +00:00
|
|
|
virNetDevVPortProfileOp vmOp)
|
2012-03-27 12:38:33 +00:00
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
|
util: fix crash when starting macvtap interfaces
This patch resolves https://bugzilla.redhat.com/show_bug.cgi?id=815270
The function virNetDevMacVLanVPortProfileRegisterCallback() takes an
arg "virtPortProfile", and was checking it for non-NULL before using
it. However, the prototype for
virNetDevMacVLanPortProfileRegisterCallback had marked that arg with
ATTRIBUTE_NONNULL(). Contrary to what one may think,
ATTRIBUTE_NONNULL() does not provide any guarantee that an arg marked
as such really is always non-null; the only effect to the code
generated by gcc, is that gcc *assumes* it is non-NULL; this results
in, for example, the check for a non-NULL value being optimized out.
(Unfortunately, this code removal only occurs when optimization is
enabled, and I am in the habit of doing local builds with optimization
off to ease debugging, so the bug didn't show up in my earlier local
testing).
In general, virPortProfile might always be NULL, so it shouldn't be
marked as ATTRIBUTE_NONNULL. One other function prototype made this
same error, so this patch fixes it as well.
2012-04-25 19:49:44 +00:00
|
|
|
ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
|
2012-03-27 12:38:33 +00:00
|
|
|
|
2012-03-29 11:15:00 +00:00
|
|
|
int virNetDevMacVLanVPortProfileRegisterCallback(const char *ifname,
|
2013-10-05 19:41:44 +00:00
|
|
|
const virMacAddr *macaddress,
|
2012-03-29 11:15:00 +00:00
|
|
|
const char *linkdev,
|
|
|
|
const unsigned char *vmuuid,
|
|
|
|
virNetDevVPortProfilePtr virtPortProfile,
|
2014-04-27 00:15:22 +00:00
|
|
|
virNetDevVPortProfileOp vmOp)
|
2012-03-29 11:15:00 +00:00
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
|
util: fix crash when starting macvtap interfaces
This patch resolves https://bugzilla.redhat.com/show_bug.cgi?id=815270
The function virNetDevMacVLanVPortProfileRegisterCallback() takes an
arg "virtPortProfile", and was checking it for non-NULL before using
it. However, the prototype for
virNetDevMacVLanPortProfileRegisterCallback had marked that arg with
ATTRIBUTE_NONNULL(). Contrary to what one may think,
ATTRIBUTE_NONNULL() does not provide any guarantee that an arg marked
as such really is always non-null; the only effect to the code
generated by gcc, is that gcc *assumes* it is non-NULL; this results
in, for example, the check for a non-NULL value being optimized out.
(Unfortunately, this code removal only occurs when optimization is
enabled, and I am in the habit of doing local builds with optimization
off to ease debugging, so the bug didn't show up in my earlier local
testing).
In general, virPortProfile might always be NULL, so it shouldn't be
marked as ATTRIBUTE_NONNULL. One other function prototype made this
same error, so this patch fixes it as well.
2012-04-25 19:49:44 +00:00
|
|
|
ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
|
2010-02-15 15:58:13 +00:00
|
|
|
#endif /* __UTIL_MACVTAP_H__ */
|