From: "Daniel P. Berrange" <berrange(a)redhat.com>
Rename ifaceMacvtapLinkAdd to virNetDevMacVLanCreate and
ifaceLinkDel to virNetDevMacVLanDelete. Strictly speaking
the latter isn't restricted to macvlan devices, but that's
the only use libvirt has for it.
* util/interface.c, util/interface.h,
util/virnetdevmacvlan.c: Rename APIs
---
src/libvirt_private.syms | 4 ++--
src/util/interface.c | 41 ++++++++++++++++++-----------------------
src/util/interface.h | 19 +++++++++++--------
src/util/virnetdevmacvlan.c | 12 ++++++------
4 files changed, 37 insertions(+), 39 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 03aa711..dcbc8b8 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -583,8 +583,8 @@ ifaceGetPhysicalFunction;
ifaceGetVirtualFunctionIndex;
ifaceGetVlanID;
ifaceIsVirtualFunction;
-ifaceLinkDel;
-ifaceMacvtapLinkAdd;
+virNetDevMacVLanCreate;
+virNetDevMacVLanDelete;
ifaceMacvtapLinkDump;
ifaceReplaceMacAddress;
ifaceRestoreMacAddress;
diff --git a/src/util/interface.c b/src/util/interface.c
index 63e6bf7..a1c56f5 100644
--- a/src/util/interface.c
+++ b/src/util/interface.c
@@ -313,12 +313,11 @@ ifaceGetIPAddress(const char *ifname ATTRIBUTE_UNUSED,
#endif /* __linux__ */
/**
- * ifaceLinkAdd
+ * virNetDevMacVLanCreate:
*
+ * @ifname: The name the interface is supposed to have; optional parameter
* @type: The type of device, i.e., "macvtap"
* @macaddress: The MAC address of the device
- * @macaddrsize: The size of the MAC address, typically '6'
- * @ifname: The name the interface is supposed to have; optional parameter
* @srcdev: The name of the 'link' device
* @macvlan_mode: The macvlan mode to use
* @retry: Pointer to integer that will be '1' upon return if an interface
@@ -331,12 +330,12 @@ ifaceGetIPAddress(const char *ifname ATTRIBUTE_UNUSED,
*/
#if defined(__linux__) && WITH_MACVTAP
int
-ifaceMacvtapLinkAdd(const char *type,
- const unsigned char *macaddress, int macaddrsize,
- const char *ifname,
- const char *srcdev,
- uint32_t macvlan_mode,
- int *retry)
+virNetDevMacVLanCreate(const char *ifname,
+ const char *type,
+ const unsigned char *macaddress,
+ const char *srcdev,
+ uint32_t macvlan_mode,
+ int *retry)
{
int rc = 0;
struct nlmsghdr *resp;
@@ -366,7 +365,7 @@ ifaceMacvtapLinkAdd(const char *type,
if (nla_put_u32(nl_msg, IFLA_LINK, ifindex) < 0)
goto buffer_too_small;
- if (nla_put(nl_msg, IFLA_ADDRESS, macaddrsize, macaddress) < 0)
+ if (nla_put(nl_msg, IFLA_ADDRESS, VIR_MAC_BUFLEN, macaddress) < 0)
goto buffer_too_small;
if (ifname &&
@@ -458,14 +457,12 @@ buffer_too_small:
#else
-int
-ifaceMacvtapLinkAdd(const char *type ATTRIBUTE_UNUSED,
- const unsigned char *macaddress ATTRIBUTE_UNUSED,
- int macaddrsize ATTRIBUTE_UNUSED,
- const char *ifname ATTRIBUTE_UNUSED,
- const char *srcdev ATTRIBUTE_UNUSED,
- uint32_t macvlan_mode ATTRIBUTE_UNUSED,
- int *retry ATTRIBUTE_UNUSED)
+int virNetDevMacVLanCreate(const char *ifname ATTRIBUTE_UNUSED,
+ const char *type ATTRIBUTE_UNUSED,
+ const unsigned char *macaddress ATTRIBUTE_UNUSED,
+ const char *srcdev ATTRIBUTE_UNUSED,
+ uint32_t macvlan_mode ATTRIBUTE_UNUSED,
+ int *retry ATTRIBUTE_UNUSED)
{
ifaceError(VIR_ERR_INTERNAL_ERROR, "%s",
# if defined(__linux__) && !WITH_MACVTAP
@@ -483,7 +480,7 @@ ifaceMacvtapLinkAdd(const char *type ATTRIBUTE_UNUSED,
/**
- * ifaceLinkDel
+ * virNetDevMacVLanDelete:
*
* @ifname: Name of the interface
*
@@ -492,8 +489,7 @@ ifaceMacvtapLinkAdd(const char *type ATTRIBUTE_UNUSED,
* Returns 0 on success, -1 on fatal error.
*/
#if defined( __linux__) && WITH_MACVTAP
-int
-ifaceLinkDel(const char *ifname)
+int virNetDevMacVLanDelete(const char *ifname)
{
int rc = 0;
struct nlmsghdr *resp;
@@ -572,8 +568,7 @@ buffer_too_small:
#else
-int
-ifaceLinkDel(const char *ifname ATTRIBUTE_UNUSED)
+int virNetDevMacVLanDelete(const char *ifname ATTRIBUTE_UNUSED)
{
ifaceError(VIR_ERR_INTERNAL_ERROR, "%s",
# if defined(__linux__) && !WITH_MACVTAP
diff --git a/src/util/interface.h b/src/util/interface.h
index 4adc601..a62f26a 100644
--- a/src/util/interface.h
+++ b/src/util/interface.h
@@ -39,14 +39,17 @@ int ifaceGetVlanID(const char *vlanifname, int *vlanid);
int ifaceGetIPAddress(const char *ifname, virSocketAddrPtr addr);
-int ifaceMacvtapLinkAdd(const char *type,
- const unsigned char *macaddress, int macaddrsize,
- const char *ifname,
- const char *srcdev,
- uint32_t macvlan_mode,
- int *retry);
-
-int ifaceLinkDel(const char *ifname);
+int virNetDevMacVLanCreate(const char *ifname,
+ const char *type,
+ const unsigned char *macaddress,
+ 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;
int ifaceMacvtapLinkDump(bool nltarget_kernel, const char *ifname, int ifindex,
struct nlattr **tb, unsigned char **recvbuf,
diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
index a322ece..ab552af 100644
--- a/src/util/virnetdevmacvlan.c
+++ b/src/util/virnetdevmacvlan.c
@@ -284,8 +284,8 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *tgifname,
return -1;
}
cr_ifname = tgifname;
- rc = ifaceMacvtapLinkAdd(type, macaddress, 6, tgifname, linkdev,
- macvtapMode, &do_retry);
+ rc = virNetDevMacVLanCreate(tgifname, type, macaddress, linkdev,
+ macvtapMode, &do_retry);
if (rc < 0)
return -1;
} else {
@@ -294,8 +294,8 @@ create_name:
for (c = 0; c < 8192; c++) {
snprintf(ifname, sizeof(ifname), MACVTAP_NAME_PATTERN, c);
if (ifaceGetIndex(false, ifname, &ifindex) == -ENODEV) {
- rc = ifaceMacvtapLinkAdd(type, macaddress, 6, ifname, linkdev,
- macvtapMode, &do_retry);
+ rc = virNetDevMacVLanCreate(ifname, type, macaddress, linkdev,
+ macvtapMode, &do_retry);
if (rc == 0)
break;
@@ -350,7 +350,7 @@ disassociate_exit:
vmOp));
link_del_exit:
- ifaceLinkDel(cr_ifname);
+ ignore_value(virNetDevMacVLanDelete(cr_ifname));
return rc;
}
@@ -385,7 +385,7 @@ int virNetDevMacVLanDeleteWithVPortProfile(const char *ifname,
linkdev,
VIR_NETDEV_VPORT_PROFILE_OP_DESTROY) <
0)
ret = -1;
- if (ifaceLinkDel(ifname) < 0)
+ if (virNetDevMacVLanDelete(ifname) < 0)
ret = -1;
}
return ret;
--
1.7.6.4