---
title: flexda_custom_construct_attr
description: "构建下发硬件流表attr。"
url: https://www.hikunpeng.com/document/detail/zh/flexda/api/dpak_api029.html
sourcePath: /source/zh/flexda/api/dpak_api029.html
indexId: 1aeea9fbfe27eb9507328124673f08d9e3eb9970d6ba67d473e027987428d44938
---
# flexda_custom_construct_attr

#### 接口功能

构建下发硬件流表attr。


#### 接口格式

int flexda_custom_construct_attr ( void *ctx, const struct flexda_custom_info_t *info, struct rte_flow_attr *attr)


#### 参数说明

| 参数名 | 参数类型 | 入参/出参 | 说明 |
| --- | --- | --- | --- |
| ctx | void \* | 入参 | 自定义上下文的地址。提取的头信息也保存其中。 |
| info | struct flexda\_custom\_info\_t \* | 入参 | dpak\-ovs提供flexda\-ovs读取使用的信息。详情可参见表1。 |
| attr | struct rte\_flow\_attr \* | 入参 | 该接口组装硬件流表attr，目前包含table\_id以及flexda\-dpdk是否开启的标记。 |
| 函数返回值 | int | 出参 | 若函数执行成功则返回0，若函数执行失败则返回错误码。 |


**表1 struct flexda_custom_info_t**

| 属性类型 | 属性名称 | 属性描述 |
| --- | --- | --- |
| uint16\_t | input\_port\_id | 当前OVS卸载报文的源input端口。 |
| dp\_packet \* | pkt | 当前OVS卸载的报文。 |
| rte\_flow\_action \* | src\_actions | 当前OVS卸载的软件流表action。 |


#### 使用实例

```
int flexda_custom_construct_attr(void *ctx, flexda_custom_info_t info, struct rte_flow_attr *attr)
{
struct custom_packet_ctx *custom_ctx = (struct custom_packet_ctx *)ctx;
// 根据自定义上下文，将Hydra table的枚举值赋给attr中的group来指定下发的table
if (custom_ctx->vlan_poped == 1) {
attr->group = HYDRA_TABLE_MYMAINPIPE_VLAN_EXACT;
}
return 0;
}
```
