提交 b228b43c 编写于 作者: B Bryan O'Sullivan 提交者: Roland Dreier

IB/ipath: don't modify QP if changes fail

Make sure modify_qp won't modify the QP if any of the changes failed.
Signed-off-by: NBryan O'Sullivan <bos@pathscale.com>
Signed-off-by: NRoland Dreier <rolandd@cisco.com>
上级 ebac3800
...@@ -427,6 +427,7 @@ static void ipath_error_qp(struct ipath_qp *qp) ...@@ -427,6 +427,7 @@ static void ipath_error_qp(struct ipath_qp *qp)
int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
int attr_mask) int attr_mask)
{ {
struct ipath_ibdev *dev = to_idev(ibqp->device);
struct ipath_qp *qp = to_iqp(ibqp); struct ipath_qp *qp = to_iqp(ibqp);
enum ib_qp_state cur_state, new_state; enum ib_qp_state cur_state, new_state;
unsigned long flags; unsigned long flags;
...@@ -443,6 +444,19 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, ...@@ -443,6 +444,19 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
attr_mask)) attr_mask))
goto inval; goto inval;
if (attr_mask & IB_QP_AV)
if (attr->ah_attr.dlid == 0 ||
attr->ah_attr.dlid >= IPS_MULTICAST_LID_BASE)
goto inval;
if (attr_mask & IB_QP_PKEY_INDEX)
if (attr->pkey_index >= ipath_layer_get_npkeys(dev->dd))
goto inval;
if (attr_mask & IB_QP_MIN_RNR_TIMER)
if (attr->min_rnr_timer > 31)
goto inval;
switch (new_state) { switch (new_state) {
case IB_QPS_RESET: case IB_QPS_RESET:
ipath_reset_qp(qp); ipath_reset_qp(qp);
...@@ -457,13 +471,8 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, ...@@ -457,13 +471,8 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
} }
if (attr_mask & IB_QP_PKEY_INDEX) { if (attr_mask & IB_QP_PKEY_INDEX)
struct ipath_ibdev *dev = to_idev(ibqp->device);
if (attr->pkey_index >= ipath_layer_get_npkeys(dev->dd))
goto inval;
qp->s_pkey_index = attr->pkey_index; qp->s_pkey_index = attr->pkey_index;
}
if (attr_mask & IB_QP_DEST_QPN) if (attr_mask & IB_QP_DEST_QPN)
qp->remote_qpn = attr->dest_qp_num; qp->remote_qpn = attr->dest_qp_num;
...@@ -479,12 +488,8 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, ...@@ -479,12 +488,8 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
if (attr_mask & IB_QP_ACCESS_FLAGS) if (attr_mask & IB_QP_ACCESS_FLAGS)
qp->qp_access_flags = attr->qp_access_flags; qp->qp_access_flags = attr->qp_access_flags;
if (attr_mask & IB_QP_AV) { if (attr_mask & IB_QP_AV)
if (attr->ah_attr.dlid == 0 ||
attr->ah_attr.dlid >= IPS_MULTICAST_LID_BASE)
goto inval;
qp->remote_ah_attr = attr->ah_attr; qp->remote_ah_attr = attr->ah_attr;
}
if (attr_mask & IB_QP_PATH_MTU) if (attr_mask & IB_QP_PATH_MTU)
qp->path_mtu = attr->path_mtu; qp->path_mtu = attr->path_mtu;
...@@ -499,11 +504,8 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, ...@@ -499,11 +504,8 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
qp->s_rnr_retry_cnt = qp->s_rnr_retry; qp->s_rnr_retry_cnt = qp->s_rnr_retry;
} }
if (attr_mask & IB_QP_MIN_RNR_TIMER) { if (attr_mask & IB_QP_MIN_RNR_TIMER)
if (attr->min_rnr_timer > 31)
goto inval;
qp->s_min_rnr_timer = attr->min_rnr_timer; qp->s_min_rnr_timer = attr->min_rnr_timer;
}
if (attr_mask & IB_QP_QKEY) if (attr_mask & IB_QP_QKEY)
qp->qkey = attr->qkey; qp->qkey = attr->qkey;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册