[libvirt] [PATCH 05/33] Expose MTU management APIs

Daniel P. Berrange berrange at redhat.com
Thu Nov 3 17:30:01 UTC 2011


From: "Daniel P. Berrange" <berrange at redhat.com>

The MTU management APIs are useful to other code inside libvirt,
so should be exposed as non-static APIs.

* src/util/bridge.c, src/util/bridge.h: Expose virNetDevSetMTU,
  virNetDevSetMTUFromDevice & virNetDevGetMTU
---
 src/util/bridge.c |   18 +++++++++---------
 src/util/bridge.h |    8 ++++++++
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/src/util/bridge.c b/src/util/bridge.c
index 1584052..247ce93 100644
--- a/src/util/bridge.c
+++ b/src/util/bridge.c
@@ -365,7 +365,7 @@ cleanup:
  *
  * Returns the MTU value in case of success, or -1 on failure.
  */
-static int virNetDevGetMTU(const char *ifname)
+int virNetDevGetMTU(const char *ifname)
 {
     int fd = -1;
     int ret = -1;
@@ -398,7 +398,7 @@ cleanup:
  *
  * Returns 0 in case of success, or -1 on failure
  */
-static int virNetDevSetMTU(const char *ifname, int mtu)
+int virNetDevSetMTU(const char *ifname, int mtu)
 {
     int fd = -1;
     int ret = -1;
@@ -424,18 +424,18 @@ cleanup:
 }
 
 /**
- * brSetInterfaceMtu
- * @brname: name of the bridge interface
+ * virNetDevSetMTUFromDevice:
  * @ifname: name of the interface whose MTU we want to set
+ * @otherifname: name of the interface whose MTU we want to copy
  *
- * Sets the interface mtu to the same MTU of the bridge
+ * Sets the interface mtu to the same MTU as another interface
  *
  * Returns 0 in case of success, or -1 on failure
  */
-static int virNetDevSetMTUFromDevice(const char *brname,
-                                     const char *ifname)
+int virNetDevSetMTUFromDevice(const char *ifname,
+                              const char *otherifname)
 {
-    int mtu = virNetDevGetMTU(brname);
+    int mtu = virNetDevGetMTU(otherifname);
 
     if (mtu < 0)
         return -1;
@@ -543,7 +543,7 @@ int virNetDevTapCreateInBridgePort(const char *brname,
      * to the bridge, because the bridge will have its
      * MTU adjusted automatically when we add the new interface.
      */
-    if (virNetDevSetMTUFromDevice(brname, *ifname) < 0)
+    if (virNetDevSetMTUFromDevice(*ifname, brname) < 0)
         goto error;
 
     if (virNetDevBridgeAddPort(brname, *ifname) < 0)
diff --git a/src/util/bridge.h b/src/util/bridge.h
index 2de7259..0cc89c0 100644
--- a/src/util/bridge.h
+++ b/src/util/bridge.h
@@ -112,6 +112,14 @@ int virNetDevTapCreate(char **ifname,
 int virNetDevSetMAC(const char *ifname,
                     const unsigned char *macaddr)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
+int virNetDevSetMTU(const char *ifname,
+                    int mtu)
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
+int virNetDevSetMTUFromDevice(const char *ifname,
+                              const char *otherifname)
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
+int virNetDevGetMTU(const char *ifname)
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
 
 # endif /* WITH_BRIDGE */
 
-- 
1.7.6.4




More information about the libvir-list mailing list