]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[interface] Default to calling intf_restart() in response to intf_close()
authorMichael Brown <mcb30@ipxe.org>
Fri, 1 Nov 2013 15:52:31 +0000 (15:52 +0000)
committerMichael Brown <mcb30@ipxe.org>
Fri, 1 Nov 2013 16:17:28 +0000 (16:17 +0000)
If an object interface does not provide an intf_close() method, then
default to calling intf_restart().  This allows static objects to
safely ignore intf_close(), without needing to add code solely to
ensure that the interface gets unplugged.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/core/interface.c

index 97caac8049d32326ec2182e4a7e9b047bea086ea..62f4621db182fb362f639c8f7f77f7d355094bbe 100644 (file)
@@ -34,8 +34,24 @@ FILE_LICENCE ( GPL2_OR_LATER );
  *
  */
 
+/**
+ * Close null interface
+ *
+ * @v intf             Null interface
+ * @v rc               Reason for close
+ */
+static void null_intf_close ( struct interface *intf __unused,
+                             int rc __unused ) {
+
+       /* Do nothing.  In particular, do not call intf_restart(),
+        * since that would result in an infinite loop.
+        */
+}
+
 /** Null interface operations */
-static struct interface_operation null_intf_op[] = {};
+static struct interface_operation null_intf_op[] = {
+       INTF_OP ( intf_close, struct interface *, null_intf_close ),
+};
 
 /** Null interface descriptor */
 struct interface_descriptor null_intf_desc =
@@ -233,7 +249,8 @@ void intf_close ( struct interface *intf, int rc ) {
        if ( op ) {
                op ( object, rc );
        } else {
-               /* Default is to ignore intf_close() */
+               /* Default is to restart the interface */
+               intf_restart ( dest, rc );
        }
 
        intf_put ( dest );