我正在尝试为ICMP数据包设置ACL结构。 为此,我将数据指针设置为指向mbuf中IP src字段的指针,并使用以下结构来定义ACL数组:
struct icmp_acl_tuple {
uint32_t src_ip;
uint32_t dst_ip;
uint8_t type;
uint8_t code;};
static struct rte_acl_field_def icmp_defs[C_NUM_FIELDS_ICMP] = {
{
.type = RTE_ACL_FIELD_TYPE_BITMASK,
.size = sizeof(uint8_t),
.field_index = C_TYPE_FIELD_ICMP,
.input_index = 0,
.offset = offsetof (struct icmp_acl_tuple, type),
},
/* next input field (IPv4 source address) - 4 consecutive bytes. */
{
.type = RTE_ACL_FIELD_TYPE_MASK,
.size = sizeof (uint32_t),
.field_index = C_SRC_FIELD_ICMP,
.input_index = 1,
.offset = offsetof (struct icmp_acl_tuple, src_ip),
},
/* next input field (IPv4 destination address) - 4 consecutive bytes. */
{
.type = RTE_ACL_FIELD_TYPE_MASK,
.size = sizeof (uint32_t),
.field_index = C_DST_FIELD_ICMP,
.input_index = 2,
.offset = offsetof (struct icmp_acl_tuple, dst_ip),
},
/*due to DPDK restrictions, 32bit should be used (although one byte field)*/
{
.type = RTE_ACL_FIELD_TYPE_BITMASK,
.size = sizeof (uint32_t),
.field_index = C_CODE_FIELD_ICMP,
.input_index = 3,
.offset = offsetof (struct icmp_acl_tuple, code),
},};
我的问题在于' Code'场(最后一个)。 我无法得到理想的行动。
我该如何设置此字段的值和掩码? 我用u8,u32,u32尝试了偏移量。没有用。
答案 0 :(得分:0)
最后一个参数C_CODE_FIELD_ICMP
的大小字段应该设置为1
,而不是4
。因为根据DPDK-ACL size The size parameter defines the length of the field in bytes.
。问题与RTE_ACL_FIELD_TYPE_BITMASK
无关。