---
title: flexda_custom_update_ctx
description: "用户更新自定义上下文。"
url: https://www.hikunpeng.com/document/detail/zh/flexda/api/dpak_api025.html
sourcePath: /source/zh/flexda/api/dpak_api025.html
indexId: 66ff79da977254c4e02e8aa5acb2e8dfee21caf2f1c20fd31b9865e1c12a1fc738
---
# flexda_custom_update_ctx

#### 接口功能

用户更新自定义上下文。


#### 接口格式

int flexda_custom_update_ctx(void *ctx, const struct flexda_custom_info_t *info)


#### 参数说明

| 参数名 | 参数类型 | 入参/出参 | 说明 |
| --- | --- | --- | --- |
| ctx | void \* | 入参 | 自定义上下文的地址。 |
| info | const struct flexda\_custom\_info\_t \* | 入参 | dpak\-ovs提供flexda\-ovs读取使用的信息。详情可参见表1。 |
| 函数返回值 | 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_update_ctx(void *ctx, flexda_custom_info_t info)
{
// 根据当前软件流表的action更新自定义上下文，例如存在POP_VLAN时将自定义上下文中的vlan_poped标志位置1
struct custom_packet_ctx *custom_ctx = (struct custom_packet_ctx *)ctx;
struct rte_flow_action *actions = info.src_actions;
for (int i = 0; i < 15; i++) {
switch (action[i].type) {
case RTE_FLOW_ACTION_TYPE_OF_POP_VLAN:
custom_ctx->vlan_poped = 1;
break;
default:
break;
}
}
return 0;
}
```
