[openib-general] [PATCH] user_mad: Fix handling of non request TIDs in ib_umad_write
Hal Rosenstock
halr at voltaire.com
Thu Dec 23 14:21:13 PST 2004
user_mad: Fix handling of non request TIDs in ib_umad_write
Add "mad_is_solicit" function and its invocation from ib_umad_write.
This is required to avoid trashing non request TIDs.
Index: user_mad.c
===================================================================
--- user_mad.c (revision 1377)
+++ user_mad.c (working copy)
@@ -183,6 +183,17 @@
ib_free_recv_mad(mad_recv_wc);
}
+static int mad_is_solicit(struct ib_mad_hdr *madhdr)
+{
+ int method = madhdr->method;
+
+ // filter only request methods according to IB spec V1.2 13.4.5 and C13-6
+ return (method < IB_MGMT_METHOD_RESP &&
+ method != IB_MGMT_METHOD_SEND &&
+ method != IB_MGMT_METHOD_TRAP &&
+ method != IB_MGMT_METHOD_TRAP_REPRESS);
+}
+
static ssize_t ib_umad_read(struct file *filp, char __user *buf,
size_t count, loff_t *pos)
{
@@ -263,10 +274,12 @@
goto err_up;
}
- ((struct ib_mad_hdr *) packet->mad.data)->tid =
- cpu_to_be64(((u64) agent->hi_tid) << 32 |
- (be64_to_cpu(((struct ib_mad_hdr *) packet->mad.data)->tid) &
- 0xffffffff));
+ if (mad_is_solicit((struct ib_mad_hdr *)packet->mad.data)) {
+ ((struct ib_mad_hdr *) packet->mad.data)->tid =
+ cpu_to_be64(((u64) agent->hi_tid) << 32 |
+ (be64_to_cpu(((struct ib_mad_hdr *) packet->mad.data)->tid) &
+ 0xffffffff));
+ }
memset(&ah_attr, 0, sizeof ah_attr);
ah_attr.dlid = be16_to_cpu(packet->mad.lid);
More information about the general
mailing list