summaryrefslogtreecommitdiffstats
path: root/src/core/interface.c
diff options
context:
space:
mode:
authorMichael Brown2013-11-01 16:52:31 +0100
committerMichael Brown2013-11-01 17:17:28 +0100
commita3346e35877db114d467c55fc14856334d2278ab (patch)
treeebe8cb4d361435133fc5d7286de0c9140bdcaf29 /src/core/interface.c
parent[netdevice] Make all net_driver methods optional (diff)
downloadipxe-a3346e35877db114d467c55fc14856334d2278ab.tar.gz
ipxe-a3346e35877db114d467c55fc14856334d2278ab.tar.xz
ipxe-a3346e35877db114d467c55fc14856334d2278ab.zip
[interface] Default to calling intf_restart() in response to intf_close()
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>
Diffstat (limited to 'src/core/interface.c')
-rw-r--r--src/core/interface.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/core/interface.c b/src/core/interface.c
index 97caac80..62f4621d 100644
--- a/src/core/interface.c
+++ b/src/core/interface.c
@@ -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 );