]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Expose MTU management APIs
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 2 Nov 2011 12:57:41 +0000 (12:57 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Wed, 9 Nov 2011 16:33:39 +0000 (16:33 +0000)
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
src/util/bridge.h

index 3d3ce0ed636fb6b149dd68972b1af9969ed76232..a9e9bb2a3dd2ad253d1bd0b575eccffe5f128fff 100644 (file)
@@ -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)
index c4e8d3f6d9bf0a657ffcdbdc03528210cfe636a3..d83fbd0a5d52e90d4534a9f787a16f48d6236016 100644 (file)
@@ -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 */