P4

P4程序,缺少调试手段来确保自己写的代码正确


目前P4缺少像单步执行、gdb等调试手段,可以对存在的功能问题进行调试解决,P4需要解决可调试性的问题,才会更好发展。
已邀请:

dingrui37

赞同来自: Cool


@Cool 不能直接截图,将就看吧。但是目前只支持基于thirft的bmv2,在gRPC的bmv2上没法使用,估计后续应该会支持。我也只是试用了下,但是没有想象中那么牛逼,没有gdb那么直观方便。
Introducing a P4 debugger
- bmv2 supports a GDB-like P4 debugger
- Lets you block packet processing and print information about packet headers
/ metadata / match-action tables
- Because of the bmv2 threading model, multiple packets can exist in the
switch simultaneously; each packet is identified by a unique id
- We tried to give the debugger a “GDB feel” with familiar commands:
- w sets a watchpoint on a header field
- b sets a breakpoint on a P4 object (e.g. parse state, table)
- p prints the value of a header field for a given packet
- bt prints the backtrace of P4 objects entered by a packet
- c starts / resumes packet processing

Wasdns

赞同来自: Cool


除了丁老师说的gdb debugger,一个简单判断代码结构是否正确的方法是使用p4-validate your_p4_code.p4
Debug确实是一个问题,我个人遇见的一般来说不是code的问题,是规则的问题,你需要根据交换机的行为来判断你的P4规则有没有写对。

dingrui37

赞同来自:


bmv2 supports a GDB-like P4 debugger

Cool - SDN&P4程序猿

赞同来自:


@dingrui37 ,多谢了,你目前调试P4代码住要方法就是P4 debugeer吗,使用方法哪里有说明能发一下吗,多谢了

Cool - SDN&P4程序猿

赞同来自:


@dingrui37@Wasdns

多谢!

Debug确实是一个问题,我个人遇见的一般来说不是code的问题,是规则的问题,你需要根据交换机的行为来判断你的P4规则有没有写对。
----现在P4的作用有点像传统交换机上下发的配置信息,要确认配置对错只能通过流量功能验证,但是在写P4代码时往往没有足够的组网环境来验证自己的程序功能,这会导致P4功能验证反而比传统交换机配置信息的验证更困难,而且硬件表象大部分是没发用软件仿真的,这个问题估计不好解决

要回复问题请先登录注册