netdev-linux: Cache error code from mtu ioctl.
[sliver-openvswitch.git] / lib / rtnetlink-link.c
index eef07d6..d14f0e3 100644 (file)
@@ -45,6 +45,7 @@ rtnetlink_link_parse(struct ofpbuf *buf,
     static const struct nl_policy policy[] = {
         [IFLA_IFNAME] = { .type = NL_A_STRING, .optional = false },
         [IFLA_MASTER] = { .type = NL_A_U32,    .optional = true },
+        [IFLA_MTU]    = { .type = NL_A_U32,    .optional = true },
     };
 
     static struct nlattr *attrs[ARRAY_SIZE(policy)];
@@ -63,9 +64,14 @@ rtnetlink_link_parse(struct ofpbuf *buf,
         change->nlmsg_type     = nlmsg->nlmsg_type;
         change->ifi_index      = ifinfo->ifi_index;
         change->ifname         = nl_attr_get_string(attrs[IFLA_IFNAME]);
+        change->ifi_flags      = ifinfo->ifi_flags;
         change->master_ifindex = (attrs[IFLA_MASTER]
                                   ? nl_attr_get_u32(attrs[IFLA_MASTER])
                                   : 0);
+        change->mtu            = (attrs[IFLA_MTU]
+                                  ? nl_attr_get_u32(attrs[IFLA_MTU])
+                                  : 0);
+
     }
 
     return parsed;
@@ -85,25 +91,24 @@ rtnetlink_link_parse_cb(struct ofpbuf *buf, void *change)
  * using dpif_port_poll() or netdev_change_seq(), which unlike this function
  * are not Linux-specific.
  *
- * Returns 0 if successful, otherwise a positive errno value. */
-int
-rtnetlink_link_notifier_register(struct nln_notifier *notifier,
-                                 rtnetlink_link_notify_func *cb, void *aux)
+ * Returns an initialized nln_notifier if successful, NULL otherwise. */
+struct nln_notifier *
+rtnetlink_link_notifier_create(rtnetlink_link_notify_func *cb, void *aux)
 {
     if (!nln) {
         nln = nln_create(NETLINK_ROUTE, RTNLGRP_LINK, rtnetlink_link_parse_cb,
                          &rtn_change);
     }
 
-    return nln_notifier_register(nln, notifier, (nln_notify_func *) cb, aux);
+    return nln_notifier_create(nln, (nln_notify_func *) cb, aux);
 }
 
-/* Cancels notification on 'notifier', which must have previously been
- * registered with rtnetlink_link_notifier_register(). */
+/* Destroys 'notifier', which must have previously been created with
+ * rtnetlink_link_notifier_register(). */
 void
-rtnetlink_link_notifier_unregister(struct nln_notifier *notifier)
+rtnetlink_link_notifier_destroy(struct nln_notifier *notifier)
 {
-    nln_notifier_unregister(nln, notifier);
+    nln_notifier_destroy(notifier);
 }
 
 /* Calls all of the registered notifiers, passing along any as-yet-unreported