Sfoglia il codice sorgente

[interface] Allow for non-pass-through interface methods

xfer_vredirect() should not be allowed to propagate to a pass-through
interface.  For example, when an HTTPS connection is opened, the
redirect message should cause the TLS layer to reopen the TCP socket,
rather than causing the HTTP layer to disconnect from the TLS layer.

Fix by allowing for non-pass-through interface methods, and setting
xfer_vredirect() to be one such method.

This is slightly ugly, in that it complicates the notion of an
interface method call by adding a "pass-through" / "non-pass-through"
piece of metadata.  However, the only current user of xfer_vredirect()
is iscsi.c, which uses it only because we don't yet have an
ioctl()-style call for retrieving the underlying socket address.
The new interface infrastructure allows for such a call to be created,
at which time this sole user of xfer_vredirect() can be removed,
xfer_vredirect() can cease to be an interface method and become simply
a wrapper around xfer_vreopen(), and the concept of a non-pass-through
interface method can be reverted.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 14 anni fa
parent
commit
65bc070b05
3 ha cambiato i file con 46 aggiunte e 10 eliminazioni
  1. 30
    9
      src/core/interface.c
  2. 1
    1
      src/core/xfer.c
  3. 15
    0
      src/include/ipxe/interface.h

+ 30
- 9
src/core/interface.c Vedi File

@@ -151,29 +151,50 @@ static struct interface * intf_get_passthru ( struct interface *intf ) {
151 151
 }
152 152
 
153 153
 /**
154
- * Get object interface destination and operation method
154
+ * Get object interface destination and operation method (without pass-through)
155 155
  *
156 156
  * @v intf		Object interface
157 157
  * @v type		Operation type
158 158
  * @ret dest		Destination interface
159 159
  * @ret func		Implementing method, or NULL
160 160
  */
161
-void * intf_get_dest_op_untyped ( struct interface *intf, void *type,
162
-				  struct interface **dest ) {
161
+void * intf_get_dest_op_no_passthru_untyped ( struct interface *intf,
162
+					      void *type,
163
+					      struct interface **dest ) {
163 164
 	struct interface_descriptor *desc;
164 165
 	struct interface_operation *op;
165 166
 	unsigned int i;
166 167
 
168
+	*dest = intf_get ( intf->dest );
169
+	desc = (*dest)->desc;
170
+	for ( i = desc->num_op, op = desc->op ; i ; i--, op++ ) {
171
+		if ( op->type == type )
172
+			return op->func;
173
+	}
174
+
175
+	return NULL;
176
+}
177
+
178
+/**
179
+ * Get object interface destination and operation method
180
+ *
181
+ * @v intf		Object interface
182
+ * @v type		Operation type
183
+ * @ret dest		Destination interface
184
+ * @ret func		Implementing method, or NULL
185
+ */
186
+void * intf_get_dest_op_untyped ( struct interface *intf, void *type,
187
+				  struct interface **dest ) {
188
+	void *func;
189
+
167 190
 	while ( 1 ) {
191
+
168 192
 		/* Search for an implementing method provided by the
169 193
 		 * current destination interface.
170 194
 		 */
171
-		*dest = intf_get ( intf->dest );
172
-		desc = (*dest)->desc;
173
-		for ( i = desc->num_op, op = desc->op ; i ; i--, op++ ) {
174
-			if ( op->type == type )
175
-				return op->func;
176
-		}
195
+		func = intf_get_dest_op_no_passthru_untyped( intf, type, dest );
196
+		if ( func )
197
+			return func;
177 198
 
178 199
 		/* Pass through to the underlying interface, if applicable */
179 200
 		if ( ! ( intf = intf_get_passthru ( *dest ) ) )

+ 1
- 1
src/core/xfer.c Vedi File

@@ -56,7 +56,7 @@ static struct xfer_metadata dummy_metadata;
56 56
 int xfer_vredirect ( struct interface *intf, int type, va_list args ) {
57 57
 	struct interface *dest;
58 58
 	xfer_vredirect_TYPE ( void * ) *op =
59
-		intf_get_dest_op ( intf, xfer_vredirect, &dest );
59
+		intf_get_dest_op_no_passthru ( intf, xfer_vredirect, &dest );
60 60
 	void *object = intf_object ( dest );
61 61
 	int rc;
62 62
 

+ 15
- 0
src/include/ipxe/interface.h Vedi File

@@ -132,6 +132,9 @@ extern void intf_nullify ( struct interface *intf );
132 132
 extern struct interface * intf_get ( struct interface *intf );
133 133
 extern void intf_put ( struct interface *intf );
134 134
 extern void * __attribute__ (( pure )) intf_object ( struct interface *intf );
135
+extern void * intf_get_dest_op_no_passthru_untyped ( struct interface *intf,
136
+						     void *type,
137
+						     struct interface **dest );
135 138
 extern void * intf_get_dest_op_untyped ( struct interface *intf, void *type,
136 139
 					 struct interface **dest );
137 140
 
@@ -171,6 +174,18 @@ static inline void intf_init ( struct interface *intf,
171 174
 		.desc = &(descriptor),		\
172 175
 	}
173 176
 
177
+/**
178
+ * Get object interface destination and operation method (without pass-through)
179
+ *
180
+ * @v intf		Object interface
181
+ * @v type		Operation type
182
+ * @ret dest		Destination interface
183
+ * @ret func		Implementing method, or NULL
184
+ */
185
+#define intf_get_dest_op_no_passthru( intf, type, dest )		\
186
+	( ( type ## _TYPE ( void * ) * )				\
187
+	  intf_get_dest_op_no_passthru_untyped ( intf, type, dest ) )
188
+
174 189
 /**
175 190
  * Get object interface destination and operation method
176 191
  *

Loading…
Annulla
Salva