@@ -216,14 +216,15 @@ cdef class DrActionDestAttr(PyverbsCM):
216216 super ().__init__()
217217 self .dest_reformat = NULL
218218 self .action_dest_attr = NULL
219- if action_type == mlx5dv_dr_action_dest_type.MLX5DV_DR_ACTION_DEST:
220- self .action_dest_attr = < dv.mlx5dv_dr_action_dest_attr * > calloc(
219+ self .dest = dest
220+ self .reformat = None
221+ self .action_dest_attr = < dv.mlx5dv_dr_action_dest_attr * > calloc(
221222 1 , sizeof(dv.mlx5dv_dr_action_dest_attr))
222- if self .action_dest_attr == NULL :
223- raise PyverbsRDMAErrno(' Memory allocation for DrActionDestAttr failed.' )
224- self .action_dest_attr.type = action_type
223+ if self .action_dest_attr == NULL :
224+ raise PyverbsRDMAErrno(' Memory allocation for DrActionDestAttr failed.' )
225+ self .action_dest_attr.type = action_type
226+ if action_type == mlx5dv_dr_action_dest_type.MLX5DV_DR_ACTION_DEST:
225227 self .action_dest_attr.dest = dest.action
226- self .dest = dest
227228 elif action_type == mlx5dv_dr_action_dest_type.MLX5DV_DR_ACTION_DEST_REFORMAT:
228229 self .dest_reformat = < dv.mlx5dv_dr_action_dest_reformat * > calloc(
229230 1 , sizeof(dv.mlx5dv_dr_action_dest_reformat))
@@ -232,6 +233,7 @@ cdef class DrActionDestAttr(PyverbsCM):
232233 self .action_dest_attr.dest_reformat = self .dest_reformat
233234 self .action_dest_attr.dest_reformat.reformat = reformat.action
234235 self .action_dest_attr.dest_reformat.dest = dest.action
236+ self .reformat = reformat
235237 else :
236238 raise PyverbsError(' Unsupported action type is provided.' )
237239
@@ -248,6 +250,8 @@ cdef class DrActionDestAttr(PyverbsCM):
248250 if self .dest_reformat != NULL :
249251 free(self .dest_reformat)
250252 self .dest_reformat = NULL
253+ self .dest = None
254+ self .reformat = None
251255
252256
253257cdef class DrActionDestArray(DrAction):
@@ -280,6 +284,11 @@ cdef class DrActionDestArray(DrAction):
280284 raise PyverbsRDMAErrno(' DrActionDestArray creation failed.' )
281285 free(ptr_list)
282286 domain.dr_actions.add(self )
287+ for action in dest_actions:
288+ temp_attr = < DrActionDestAttr> action
289+ temp_attr.dest.add_ref(self )
290+ if temp_attr.reformat:
291+ temp_attr.reformat.add_ref(self )
283292
284293 def __dealloc__ (self ):
285294 self .close()
0 commit comments