aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2010-06-20 21:50:09 +0200
committerStefan Richter <stefanr@s5r6.in-berlin.de>2010-09-07 11:27:03 +0200
commit926e9ea3ad43b3db4f5fea96699718677d747bac (patch)
tree2a43298065d0451c993d45080cc7a65be6ef315c
parentd3ace3dfb4a14aea275fda605d2856e307afddc1 (diff)
downloadlibraw1394-926e9ea3ad43b3db4f5fea96699718677d747bac.tar.gz
Filter incoming requests per card
If multiple cards are installed, firewire-core will emit requests from nodes on any of the cards to clients. This is not expected by libraw1394 clients since a raw1394handle_t is bound to a single card alias port. On kernel 2.6.36 and newer we can filter out requests from other cards. Note that we still need to call the response ioctl in order to release kernel resources associated with an inbound transaction. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
-rw-r--r--src/fw.c19
-rw-r--r--src/fw.h1
2 files changed, 17 insertions, 3 deletions
diff --git a/src/fw.c b/src/fw.c
index e5c23d1..03974a2 100644
--- a/src/fw.c
+++ b/src/fw.c
@@ -220,14 +220,14 @@ handle_lost_device(fw_handle_t handle, int i)
struct address_closure {
int (*callback)(raw1394handle_t handle, struct address_closure *ac,
int tcode, unsigned long long offset,
- int source_node_id, unsigned kernel_handle,
+ int source_node_id, int card, unsigned kernel_handle,
size_t length, void *data);
};
static int
handle_fcp_request(raw1394handle_t handle, struct address_closure *ac,
int tcode, unsigned long long offset, int source_node_id,
- unsigned kernel_handle, size_t length, void *data)
+ int card, unsigned kernel_handle, size_t length, void *data)
{
struct fw_cdev_send_response response;
int is_response;
@@ -247,6 +247,9 @@ handle_fcp_request(raw1394handle_t handle, struct address_closure *ac,
FW_CDEV_IOC_SEND_RESPONSE, &response) < 0)
return -1;
+ if (card != handle->mode.fw->card)
+ return 0;
+
if (response.rcode != RCODE_COMPLETE)
return 0;
@@ -315,6 +318,7 @@ handle_device_event(raw1394handle_t handle,
u->request.offset,
/* wild guess, but can't do better */
fwhandle->devices[i].node_id,
+ fwhandle->card,
u->request.handle,
u->request.length, u->request.data);
@@ -324,6 +328,7 @@ handle_device_event(raw1394handle_t handle,
return ac->callback(handle, ac, u->request2.tcode,
u->request2.offset,
u->request2.source_node_id,
+ u->request2.card,
u->request2.handle,
u->request2.length, u->request2.data);
#endif
@@ -673,6 +678,7 @@ int fw_set_port(fw_handle_t handle, int port)
if (reset.node_id == reset.local_node_id)
handle->local_device = &handle->devices[i];
+ handle->card = get_info.card;
handle->generation = reset.generation;
handle->abi_version = get_info.version;
@@ -730,7 +736,7 @@ struct allocation {
static int
handle_arm_request(raw1394handle_t handle, struct address_closure *ac,
int tcode, unsigned long long offset, int source_node_id,
- unsigned kernel_handle, size_t length, void *data)
+ int card, unsigned kernel_handle, size_t length, void *data)
{
fw_handle_t fwhandle = handle->mode.fw;
struct allocation *allocation = (struct allocation *) ac;
@@ -809,6 +815,13 @@ handle_arm_request(raw1394handle_t handle, struct address_closure *ac,
return -1;
}
+ /*
+ * libraw1394 clients do not expect requests from nodes on
+ * a card other than the one set by raw1394_set_port().
+ */
+ if (card != fwhandle->card)
+ return 0;
+
if (!(allocation->notification_options & type))
return 0;
diff --git a/src/fw.h b/src/fw.h
index fe61b20..b0ff169 100644
--- a/src/fw.h
+++ b/src/fw.h
@@ -79,6 +79,7 @@ struct fw_handle {
struct port ports[MAX_PORTS];
int port_count;
int err;
+ int card;
int generation;
int abi_version;
void *userdata;