netdev: Change netdev_get_mtu() to return an error code.
authorBen Pfaff <blp@nicira.com>
Tue, 28 Jul 2009 20:43:35 +0000 (13:43 -0700)
committerBen Pfaff <blp@nicira.com>
Thu, 30 Jul 2009 23:07:13 +0000 (16:07 -0700)
To make the netdev code more portable, it needs to support returning error
codes from functions that don't have them.  This commit changes
netdev_get_mtu() to return an error code and updates its caller.

(Currently netdev_get_mtu() won't ever return an error, but other future
implementations might.)

CodingStyle
lib/dhcp-client.c
lib/dpif-netdev.c
lib/netdev.c
lib/netdev.h

index 126b45a..69df907 100644 (file)
@@ -168,7 +168,7 @@ prototype:
   Omit parameter names from function prototypes when the names do not
 give useful information, e.g.:
 
-    int netdev_get_mtu(const struct netdev *);
+    int netdev_get_mtu(const struct netdev *, int *mtup);
 
 
 STATEMENTS
index 561562b..a9163c7 100644 (file)
@@ -909,7 +909,7 @@ do_receive_msg(struct dhclient *cli, struct dhcp_msg *msg)
     struct ofpbuf b;
     int mtu;
 
-    mtu = netdev_get_mtu(cli->netdev);
+    netdev_get_mtu(cli->netdev, &mtu);
     ofpbuf_init(&b, mtu + VLAN_ETH_HEADER_LEN);
     netdev_get_etheraddr(cli->netdev, cli_mac);
     for (; cli->received < 50; cli->received++) {
index cae6d23..6bf92f2 100644 (file)
@@ -396,7 +396,7 @@ do_add_port(struct dp_netdev *dp, const char *devname, uint16_t flags,
     port->netdev = netdev;
     port->internal = internal;
 
-    mtu = netdev_get_mtu(netdev);
+    netdev_get_mtu(netdev, &mtu);
     if (mtu > max_mtu) {
         max_mtu = mtu;
     }
index 7b5a330..191ed51 100644 (file)
@@ -706,13 +706,18 @@ netdev_get_name(const struct netdev *netdev)
     return netdev->name;
 }
 
-/* Returns the maximum size of transmitted (and received) packets on 'netdev',
- * in bytes, not including the hardware header; thus, this is typically 1500
- * bytes for Ethernet devices. */
+/* Retrieves the MTU of 'netdev'.  The MTU is the maximum size of transmitted
+ * (and received) packets, in bytes, not including the hardware header; thus,
+ * this is typically 1500 bytes for Ethernet devices.
+ *
+ * If successful, returns 0 and stores the MTU size in '*mtup'.  On failure,
+ * returns a positive errno value and stores ETH_PAYLOAD_MAX (1500) in
+ * '*mtup'. */
 int
-netdev_get_mtu(const struct netdev *netdev
+netdev_get_mtu(const struct netdev *netdev, int *mtup)
 {
-    return netdev->mtu;
+    *mtup = netdev->mtu;
+    return 0;
 }
 
 /* Stores the features supported by 'netdev' into each of '*current',
index fca86a1..6ce28ef 100644 (file)
@@ -86,7 +86,7 @@ void netdev_send_wait(struct netdev *);
 int netdev_set_etheraddr(struct netdev *, const uint8_t mac[6]);
 int netdev_get_etheraddr(const struct netdev *, uint8_t mac[6]);
 const char *netdev_get_name(const struct netdev *);
-int netdev_get_mtu(const struct netdev *);
+int netdev_get_mtu(const struct netdev *, int *mtup);
 int netdev_get_features(struct netdev *,
                         uint32_t *current, uint32_t *advertised,
                         uint32_t *supported, uint32_t *peer);