在P4中给定以下规则表:
table update_cntr1_t {
reads {
udp.srcport: ternary;
}
actions {
update_cntr1;
nop;
}
default_action: nop;
}
我们希望在bfshell中给它下发一条规则,使得当掩码为0x00ff,匹配值为0x0011的时候执行动作update_cntr1,则可以使用如下命令:
pd update_cntr1_t add_entry update_cntr1 udp_srcport 0x0011 udp_srcport_mask 0x00ff priority 1
其中使用priority关键字的依据是《The P4 Language Specification》(Version 1.0.5,November 26, 2018)的55页的这段话:
ternary: A mask provided with each entry in the table. This mask is ANDed with the field value before a comparison is made. The field value and the table entry value need only agree on the bits set in the entry’s mask. Because of the possibilities of overlapping matches, a priority must be associated with each entry in a table using ternary matches.
来源:CSDN
作者:赵宗义11
链接:https://blog.csdn.net/nankai0912678/article/details/103638192