Table writing method and apparatus for network device, network device system, and storage medium
Patent Information
- Application Number
- PCT/CN2025/078240
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-03-06
- Filing Date
- 2025-02-20
- Publication Date
- 2025-10-02
AI Technical Summary
Due to the differences in the architecture and implementation methods of programmable chips, the same set of P4 code has syntactic differences when compiled into multiple target chips, affecting the portability and platform independence of the P4 code. In particular, the correlation and consistency between table writing and table lookup cannot be guaranteed in table writing operations.
Define the P4 language table writing syntax, extend the P4 syntax to support table writing operations, generate forwarding plane table writing configuration information through the compiler, and load it to the network device to implement table writing operations, maintaining the association and consistency between table writing and table lookup.
It improves the portability and usability of P4 code between different chip architectures, meets the application requirements of table writing code, and ensures the consistency of table writing and table lookup operations.
Smart Images

Figure CN2025078240_02102025_PF_FP_ABST
Abstract
Description
Network device table writing method and device, network device system, and storage medium
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application claims priority to Chinese Patent Application No. 202410261091.8 filed with the China Patent Office on March 6, 2024, the entire contents of which are incorporated herein by reference. Technical Field
[0003] The present application relates to, but is not limited to, the field of communication technology. Background Art
[0004] With the development of the Protocol-Independent Packet Processors (P4) programming language and its supporting P4 compiler technology, programmable chips from multiple manufacturers now support P4 and P4 compilers, enabling users to program the forwarding plane using the high-level network language P4. However, due to differences in programmable chip architectures and implementations, compiling the same P4 code to multiple target chips is difficult. In particular, the functional interfaces not yet clearly defined in the P4 syntax specification lack a standard to rely on, and the syntax generated by each manufacturer's proprietary definitions varies significantly, impacting the portability and platform independence of the P4 code.
[0005] Data plane table writing is a common requirement for programmable chips using different programmable architectures. Therefore, how to improve the portability and platform independence of P4 language table writing code between different chip architectures is a technical problem that needs to be solved urgently. Summary of the Invention
[0006] In a first aspect, an embodiment of the present application provides a table writing method for a network device, comprising: defining a P4 language table writing syntax for supporting table writing operations on P4 table entries; receiving program information written by a user based on the P4 language table writing syntax; calling a compiler to compile and process the program information to obtain forwarding surface table writing configuration information; loading the forwarding surface table writing configuration information to the network device, and enabling the network device to perform table writing operations according to the forwarding surface table writing configuration information.
[0007] In a second aspect, an embodiment of the present application provides a network device system that supports a table writing function, including: a compiler, the compiler being configured to receive program information written by a user based on a P4 language table writing syntax, and to compile and process the program information to obtain forwarding plane table writing configuration information, wherein the P4 language table writing syntax supports table writing operations on P4 table entries; a network device, the network device being configured to perform table writing operations according to the loaded forwarding plane table writing configuration information.
[0008] In a third aspect, an embodiment of the present application provides a table writing device for a network device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, any table writing method described herein is implemented.
[0009] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are used to execute any table writing method described herein.
[0010] In a fifth aspect, an embodiment of the present application provides a computer program product, comprising a computer program or computer instructions, wherein the computer program or the computer instructions are stored in a computer-readable storage medium, a processor of a computer device reads the computer program or the computer instructions from the computer-readable storage medium, and the processor executes the computer program or the computer instructions, so that the computer device performs any table writing method described herein. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] FIG1 is a schematic diagram of an application scenario architecture of a table writing method provided in an embodiment of the present application;
[0012] FIG2 is a schematic diagram of an application of a table writing method provided in an embodiment of the present application in a matching action flow module;
[0013] FIG3 is a schematic diagram of an application of a P4 table writing program in the development of a programmable forwarding chip according to an embodiment of the present application;
[0014] FIG4 is a schematic diagram of a P4 table writing program provided in an embodiment of the present application;
[0015] FIG5 is a flowchart of a table writing method provided in an embodiment of the present application;
[0016] FIG6 is a flow chart of a table writing method provided in an example of the present application;
[0017] Figures 7(a)-7(f) are schematic diagrams of a single action table structure and table writing results provided in an example of the present application;
[0018] FIG8 is an example diagram of a P4 table writing program written based on the P4 single-action table writing syntax provided in an example of the present application;
[0019] FIG9 is a flow chart of a table writing method provided by another example of the present application;
[0020] Figures 10(a)-10(i) are schematic diagrams of a multi-action table structure and table writing results provided in another example of the present application;
[0021] FIG11 is an example diagram of a P4 table writing program written based on the P4 multi-action table writing syntax provided in another example of the present application;
[0022] FIG12 is a table writing apparatus for a network device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0023] In order to make the purpose, technical solutions and advantages of this application more clearly understood, the present application is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the embodiments described herein are only used to explain this application and are not intended to limit this application.
[0024] It should be noted that although the device schematics illustrate functional module divisions and the flowcharts illustrate logical sequences, in certain circumstances, the steps shown or described may be performed in a sequence that differs from the module divisions in the device or the sequence in the flowcharts. The terms "first," "second," and so on, in the specification, claims, and drawings, are used to distinguish similar items and are not necessarily used to describe a specific sequence or precedence.
[0025] In the embodiments of the present application, words such as "exemplarily" are used to indicate examples, illustrations, or descriptions, and should not be interpreted as being more preferred or more advantageous than other embodiments or designs. The use of words such as "exemplarily" is intended to present related concepts in a specific way.
[0026] Traditional fixed-function forwarding chips lack flexibility, and the development cycle and cost of supporting new protocols and features are long and costly. Programmable forwarding chips empower networks with tremendous flexibility, enabling numerous new network applications such as load balancing and network monitoring. This has led to the emergence of numerous data plane programming languages, of which P4 has become the mainstream language for data plane programming. P4 is a general-purpose, high-level network language used to describe the data packet processing behavior of service forwarding interfaces, enabling users to implement coding based on their business processes. P4 is independent of specific chips and network protocols. The compiler shields the underlying chip implementation details, allowing programmers to perform top-down programming based on business scenarios and data packet processing flows. Its design goals are reconfigurability, protocol independence, and platform independence.
[0027] Since its introduction in 2014, the P4 language has rapidly developed, and its accompanying P4 compiler technology has also been widely researched. Currently, newly released programmable chips from multiple manufacturers, including Intel, Cisco, Xilinx, and ZTE, claim to support the P4 language and P4 compiler, enabling users to program the forwarding plane using P4. Some internet companies are also using the high-level network language P4 for forwarding plane programming.
[0028] In the development of programmable chip products, whether based on a Run-To-Completion (RTC) programmable architecture or a Match-Action programmable architecture, adding, deleting, and modifying data-plane flow table entries (i.e., data-plane table writes) is a strong requirement. However, due to differences in programmable chip architectures and implementation methods, compiling the same P4 code to multiple target chips remains challenging. In particular, functional interfaces not yet clearly defined in the P4 syntax specification lack a standard to rely on, and each manufacturer has its own proprietary definitions, resulting in significant syntax differences that affect the portability and platform independence of the P4 code.
[0029] For example, when implementing table writing on the data plane of a programmable chip, if the table writing function is implemented through an extern extended interface or annotation based on the existing P4 syntax, the syntax differences caused by the manufacturer's privately defined extended syntax will affect the portability and platform independence of the P4 code. At the same time, this method cannot guarantee the consistency of the table definition for writing and looking up the same table in terms of syntax characteristics. In most application scenarios, table writing operations need to rely on table lookup operations. For example, before deleting or modifying an entry hit by a table lookup, the old value must be obtained. The table writing and table lookup operations cannot be completely decoupled. The extern extended interface or annotation method cannot express the relationship between table writing and table lookup, and cannot fully meet application requirements.
[0030] Based on this, the embodiments of the present application propose a table writing method for a network device, a table writing device for a network device, and a network device system to fill the gap in the table writing syntax specification in the P4 language. The table writing syntax specification defined by the table writing method is encoded, and the compiler generates a forwarding plane configuration that supports the table writing function and loads it to the programmable forwarding chip on the data plane of the network device system, thereby realizing table writing for the flow table on the data plane, improving the usability of the table writing code, and the portability of the P4 code between different chip architectures.
[0031] It is understandable that the table writing method proposed in the embodiment of the present application is also applicable to new programming languages with higher abstraction levels and better portability in the future, including but not limited to P4ALL, lyra, uP4 languages, etc.
[0032] Figure 1 is a schematic diagram of the application scenario architecture of the table writing method provided by an embodiment of the present application. Among them, Figure 1 takes the programmable switch of the Match-Action architecture as an example. It can be understood that the embodiment of the present application can also be applied to other mainstream programmable architectures such as the RTC programmable architecture. As shown in Figure 1, the fixed function modules of the Very Simple Switch (VSS) include an arbiter module, a demux / queue module, and a parser runtime module; the programmable modules include a parser module, a match action pipeline module, and a deparser module. Among them, user-defined data is transferred between programmable modules, and the intrinsic metadata on the P4 program transmits information between the fixed function module and the programmable module through the data plane interface.
[0033] Taking Figure 1 as an example, a message enters the VSS from the Ethernet port, loopback port, or central processing unit (CPU) port, and is then processed in sequence by the Parser module, Match-Action Pipeline module, and Deparser module before being sent to a special port such as the Ethernet port, CPU port, discard port, or loopback port. The programmable module of the VSS in Figure 1 uses a user-written P4 communication program to set forwarding behavior. Figure 2 is a schematic diagram of the application of the table writing method provided in an embodiment of the present application in the Match-Action Pipeline module, exemplarily illustrating the table writing process in the detailed diagram of the Match-Action Pipeline module.
[0034] FIG3 is a schematic diagram of the application of the P4 table writing program provided in an embodiment of the present application in the development of a programmable forwarding chip product. The P4 code for the device forwarding plane chip is written according to the P4 syntax specification, wherein the P4 code includes the P4 table writing code. The P4 table writing code is compiled by the P4 compiler to generate the chip's underlying forwarding plane configuration and the application programming interface (API) interface function for software configuration, wherein the forwarding plane configuration includes the forwarding plane table writing configuration. The forwarding plane configuration (including the forwarding plane table writing configuration) is loaded into the chip, and a flow table is created through the control plane API, and table entries are downloaded to implement data packet processing.
[0035] FIG4 is a schematic diagram of a P4 table writing program according to an embodiment of the present application. In this embodiment, the P4 table writing program includes, for example, a parser program module 1000 written in the P4 language, a match-action pipeline program module 1100, and a deparser program module 1200. The match-action pipeline program module 1100 includes a table writing program.
[0036] FIG5 is a flow chart of a table writing method provided in an embodiment of the present application. As shown in FIG5 , the table writing method includes but is not limited to steps S100 to S400.
[0037] Step S100: defining a P4 language table writing syntax for supporting table writing operations on P4 table entries.
[0038] It will be appreciated that in step S100, a P4 table write syntax is defined by extending the existing P4 language syntax to support writing to P4 table entries. A P4 table entry may include a primary key field and a target field. The primary key field is used for table lookup, and the target field is used for storing actions. Each P4 table entry consists of one or more table entries, each of which includes a primary key value corresponding to the primary key field and a target value corresponding to the target field. Therefore, table write operations on P4 table entries may include adding, deleting, and modifying P4 table entries.
[0039] In one embodiment, the primary key field of the P4 table entry is the Key field, the target field of the P4 table entry is the Result field, and each table entry includes a Key value and a Result value.
[0040] In one embodiment, a P4 language table writing syntax is defined to support table writing operations on P4 table entries, including but not limited to steps S101 to S103.
[0041] Step S101: Define the P4 language table writing action syntax.
[0042] In one embodiment, a new table write action is added to the P4 table entry definition. The action keyword is followed by the name and parameters of the table write action. In the body of the table write action, the table write source data is assigned to the table write parameters. Table write parameters can be specified as inout types, meaning their values can be modified. Other data types can also be specified for table write parameters based on actual needs.
[0043] In one embodiment, table writing parameters are defined in sequence according to all Result fields in the P4 table entry.
[0044] In another embodiment, table writing parameters are defined according to some Result fields in the P4 table entry, and the table writing parameters can be identified by the compiler during the compilation phase, including but not limited to identifying the table writing parameters according to the field name.
[0045] In another embodiment, the order of table writing parameters may be different from the order of Result fields in the P4 table entry. The table writing parameters may be identified by the compiler during the compilation phase, including but not limited to identifying the table writing parameters based on the field names.
[0046] The following embodiment is described by taking the sequential definition of table writing parameters as an example.
[0047] In one embodiment, the P4 table entry definition includes a table read action definition and a table write action definition, and the table write parameter definition of the table write action must be consistent with the table read parameter definition of the table read action.
[0048] It should be noted that in order to ensure consistency between table writing and table reading, the table writing parameter definition of the table writing action must be consistent with the table reading parameter definition of the table reading action, including but not limited to the number of parameters, parameter names, parameter bit order, parameter bit width, etc.
[0049] In one embodiment, one write table action is defined for a single-action table.
[0050] It should be noted that P4 table entries include single-action tables and multi-action tables. The single-action table in the embodiment of the present application refers to a table that defines a single action with configurable parameters, and the multi-action table refers to a table that defines multiple actions with configurable parameters. The storage format of both single-action tables and multi-action tables includes a Key field and a Result field, where the Key field is used for table lookup and the Result field is the table lookup result, which is used to store the action. The P4 language table writing syntax can support the writing of single-action tables and multi-action tables.
[0051] A single-action table consists of only one table structure. That is, all table entries in the single-action table have the same structure. The number, bit width, and type of Key values in all table entries are identical, as are the number, bit width, and type of Result values. In this embodiment, a single-action table write action is defined. For example, for single-action table t, a table write action, wrt_t, is defined. The table write parameters of the table write action are sequentially defined based on the Result field of single-action table t.
[0052] In another embodiment, at least two table writing actions are defined for the single action table (ie, multiple table writing actions are defined), wherein the multiple table writing actions together implement operations such as adding, modifying, or deleting the single action table.
[0053] In one embodiment, at least two table writing actions are defined for the multi-action table.
[0054] It should be noted that the multi-action table includes at least two different table structures. In the multiple different table structures, the number, bit width, type, field name, etc. of the Key fields are the same, and there is at least one difference in the number, bit width, type, field name, etc. of the Result fields.
[0055] For example, for a multi-action table t that includes two different table structures, table write actions wrt_t_0 and wrt_t_1 are defined for the two different table structures, respectively. The table write parameters of the table write action wrt_t_0 are sequentially defined based on the Result fields of one of the table structures in the multi-action table t, and the table write parameters of the table write action wrt_t_1 are sequentially defined based on the Result fields of the other table structure in the multi-action table t. The two different table structures differ in at least one of the following: the number, bit width, type, and field name of the Result fields.
[0056] In another embodiment, one write table action is defined for a multi-action table.
[0057] It is understandable that a table write action defined for a multi-action table can be used to write a table to one of the table structures in the multi-action table, and other table structures in the multi-action table do not need to be written to.
[0058] Step S102: defining a table writing annotation symbol for representing a table writing action.
[0059] In one embodiment, a table write annotation is added to specify a table write action. In the P4 table entry definition, the table write annotation is used to indicate that the action declared thereafter is a table write action.
[0060] In one embodiment, the table write annotation may consist of an @ symbol and a table write annotation name. For example, the @wrt_tbl annotation is added to specify a table write action, where wrt_tbl is the table write annotation name.
[0061] Step S103: Expanding the P4 language table lookup method to support the P4 language table writing action.
[0062] It should be noted that the existing P4 language table lookup method includes a P4 language table lookup apply method. In one embodiment, the action name of a target action is used as an input parameter of the P4 language table lookup apply method. The action name of the target action is the action name of at least one of a new action, a modified action, and a deleted action. This allows the expanded P4 language table lookup method to support executing at least one of the specified new action, modified action, and deleted action. It is understood that the specified at least one of the new action, modified action, and deleted action is the target action, and its action name is the action name of the target action.
[0063] In one embodiment, the P4 language table lookup method extended to support the P4 language table write action includes using the action name of the update action as an input parameter of the P4 language table lookup apply method, so that the extended P4 language table lookup method supports table lookup and also supports executing new actions or modifying actions based on the table lookup results.
[0064] It should be noted that in this embodiment, the update action includes a new action and a modify action. The new action and the modify action have the same action name, and the new action and the modify action implement different functions under two different table lookup results: a table lookup miss and a table lookup hit, respectively. This method supports performing a table lookup first. If the table lookup is a hit, the method performs a modify action, i.e., modifies the Result field of the hit table entry. If the table lookup is a miss, the method performs a new action, i.e., adds a new table entry.
[0065] For example, the expanded P4 table lookup method is t.apply(wrt_tbl_action_name). This method supports first looking up the table. If a match is found, the method supports modifying the Result field of the matching table entry. If a match is found, the method supports adding a new entry. Here, t is the table name, apply() is the existing P4 table lookup method, and wrt_tbl_action_name supports adding and modifying actions.
[0066] In one embodiment, a P4 language table lookup method extended to support P4 language table write actions includes using the action name of a delete action as an input parameter of a P4 language table lookup apply method, so that the extended P4 language table lookup method supports table lookup, and also supports executing a delete action based on a table lookup hit result, and returning a table write failure or a table lookup miss based on a table lookup miss result.
[0067] For example, the expanded P4 table lookup method is t.apply(delete). This method first looks up the table. If a match is found, it deletes the entry. If a match is found, it returns a write failure or a table miss, leaving the table entry unchanged. Here, t is the table name, apply() is the existing P4 table lookup method, and delete supports deletion.
[0068] In one embodiment, a P4 language table lookup method extended to support P4 language table write actions includes using the action name of the modification action as an input parameter of the P4 language table lookup apply method. The extended P4 language table lookup method supports table lookup, and also supports executing modification actions based on table lookup hit results, and returning table write failure or table lookup miss based on table lookup miss results.
[0069] In one embodiment, a P4 language table lookup method is extended to support a table write action.
[0070] For example, to support a single update action, the P4 table lookup method is extended to t.apply(wrt_t). This allows the extended P4 table lookup method to first look up the table, then write to the single action table based on the lookup result. This write operation includes additions and modifications. Extending the P4 table lookup method to support other write actions is not detailed here; it can be achieved by modifying the input parameters of the table lookup apply method.
[0071] In another embodiment, the P4 language table lookup method is extended to support multiple table writing actions.
[0072] For example, taking the support of two update actions as an example, the P4 language table lookup method is extended to t.apply(wrt_t_0) and t.apply(wrt_t_1), so that the extended P4 language table lookup methods t.apply(wrt_t_0) and t.apply(wrt_t_1) support writing to two different table structures, where t.apply(wrt_t_0) supports writing to one of the table structures, and t.apply(wrt_t_1) supports writing to another different table structure. The extended P4 language table lookup methods t.apply(wrt_t_0) and t.apply(wrt_t_1) support looking up the table first and then writing to the table based on the lookup results. The table writing operations include adding and modifying. The extension of the P4 language table lookup method to support other table writing actions will not be described here in detail, and can be achieved by changing the input parameters of the table lookup apply method.
[0073] Step S200: receiving program information written by a user based on the P4 language table writing syntax.
[0074] In one embodiment, the network device system receives P4 program information written by a user, wherein the P4 program information includes table writing program information written by the user based on the P4 language table writing syntax. It is understandable that the P4 program information also includes other information written based on the P4 language syntax.
[0075] Step S300: calling a compiler to compile the program information to obtain forwarding plane table writing configuration information.
[0076] It should be noted that after receiving the user-written P4 program information, the network device system invokes a compiler to compile the P4 program information to obtain forwarding plane configuration information. Because the user-written P4 program information includes table writing program information written based on the P4 language table writing syntax, the compiler compiles the table writing program information to obtain the forwarding plane table writing configuration information. That is, the forwarding plane configuration information includes the forwarding plane table writing configuration information.
[0077] In one embodiment, calling a compiler to compile the program information to obtain the forwarding plane table writing configuration information includes but is not limited to steps S301 to S305. It is understandable that steps S301 to S305 are not in a fixed order.
[0078] Step S301: compile the action represented by the table writing annotation in the program information into table writing execution action information.
[0079] In one embodiment, the P4 program information received by the network device system includes table writing program information written by a user based on the P4 language table writing syntax. The table writing program information includes a table definition. The compiler compiles actions specified by table writing annotations in the table definition into table writing actions. The compiled information is table writing execution action information. It is understood that the actions declared after the table writing annotations are specified actions.
[0080] Exemplarily, in the program information @wrt_tbl wrt_t(parameter 1, . . . , parameter n), @wrt_tbl is a table write annotation, and wrt_t is an action specified by the table write annotation, which is compiled into a table write action by the compiler.
[0081] Step S302: compile the input primary key parameter in the program information into first position information corresponding to the primary key field in the P4 table entry, where the first position information is used to indicate the target primary key value corresponding to the input primary key parameter stored in the first position.
[0082] In one embodiment, the P4 program information received by the network device system includes table writing program information written by a user based on the P4 language table writing syntax. The table writing program information includes a table definition, and the table definition code defines an input primary key parameter (i.e., an input Key parameter). The compiler compiles the input Key parameter into location information corresponding to the Key field in the P4 table entry. This location information indicates the storage location of the Key value to be written to the table entry. In this embodiment, the target primary key value is the Key value of the table entry to be written.
[0083] Step S303: compile the table writing parameters in the program information into second position information corresponding to the target field in the P4 table entry, where the second position information is used to indicate the target data corresponding to the target field stored in the second position.
[0084] In one embodiment, the storage format of a P4 table entry includes a Key field and a Result field. The Key field is a primary key field used for table lookup, and the Result field is a target field. Each table entry includes a Key value corresponding to the Key field and a Result value corresponding to the Result field. Program information includes table writing program information. The compiler compiles the table writing parameters in the table writing program information to obtain location information corresponding to the Result field in the P4 table entry. This location information indicates the storage location of the Result value to be written to the table entry.
[0085] For example, in the program information action wrt_t (write table parameter 1, ..., write table parameter n), wrt_t is a table write action, the compiler compiles table write parameter 1 to table write parameter n into position information corresponding to the Result field, and assembles the table write data according to the bit sequence of the table write parameters as the Result value of the table entry to be written.
[0086] In one embodiment, the table writing program information includes a program for defining a table writing action, namely action wrt_t (write table parameter 1, ..., write table parameter n), and also includes a program for declaring an action list, namely @wrt_tbl wrt_t (parameter 1, ..., parameter n). The data source of the Result value to be written into the table entry is obtained from parameter 1 to parameter n.
[0087] Step S304: compile the expanded P4 language table lookup method in the program information into table lookup method information that supports the target table writing action.
[0088] In one embodiment, the P4 program information received by the network device system includes table writing program information written by a user based on the P4 language table writing syntax. The table writing program information includes an extended P4 language table lookup method. The compiler compiles the extended P4 language table lookup method to first perform a table lookup and then, based on the table lookup result, execute a table writing action. It is understood that the table writing action includes at least one of the following: adding an action, modifying an action, and deleting an action.
[0089] Exemplarily, the program information includes an extended P4 language table lookup method, t.apply(wrt_tbl_action_name), where wrt_tbl_action_name is an update action in this example, and the update action includes a new action and a modification action. The compiler compiles the extended P4 language table lookup method t.apply(wrt_tbl_action_name) into first performing a table lookup on the P4 table entry t. If the table lookup is a hit, the wrt_tbl_action_name write action is compiled into a modification action, and the value of its output parameter is taken as the Result value of the table entry, replacing the Result value of the hit entry; if the table lookup is not a hit, the wrt_tbl_action_name write action is compiled into a new action, and the value of its output parameter is taken as the Result value of the table entry, and is spliced with the key value of the table lookup to form a complete table entry, and the entry is added to the table; if the wrt_tbl_action_name write action is not defined in the P4 table entry definition, the compiler reports an error. It is understandable that the value of the table lookup Key value is derived from the input Key parameter defined in the table definition code of the program information.
[0090] For example, the program information includes an extended P4 table lookup method, t.apply(delete), where delete in this example represents a delete action. The compiler compiles the extended P4 table lookup method t.apply(delete) to first perform a table lookup on the P4 table entry t. If the table lookup results in a hit, the compiler deletes the hit table entry. If the table lookup results in a miss, the compiler returns a table write failure or a miss, leaving the table data of the P4 table entry unchanged.
[0091] Step S305: The table write execution action information, the first location information, the second location information, and the table lookup method information supporting the target table write action are used as forwarding plane table write configuration information.
[0092] In one embodiment, a table writing function is developed in the compiler to support parsing and compiling the P4 language table writing syntax to obtain forwarding surface table writing configuration information. The forwarding surface table writing configuration information includes but is not limited to table writing execution action information, location information corresponding to the Key field, location information corresponding to the Result field, and table lookup method information supporting the target table writing action.
[0093] It is understood that the compiler compiles the entire P4 program information to obtain the forwarding plane configuration information. The P4 program information includes table writing program information written based on the P4 language table writing syntax, and the obtained forwarding plane configuration information includes forwarding plane table writing configuration information. That is, the forwarding plane table writing configuration information is compiled together with other forwarding plane configuration information.
[0094] Step S400: Loading forwarding plane table writing configuration information to a network device, and enabling the network device to perform a table writing operation according to the forwarding plane table writing configuration information.
[0095] In one embodiment, the forwarding plane configuration information compiled by the compiler is loaded into the chip to complete the control plane table configuration. It is understandable that the forwarding plane configuration information includes the forwarding plane table writing configuration information, which is loaded into the chip together.
[0096] In one embodiment, after the control plane table configuration is implemented, a corresponding service message is constructed and sent to trigger table writing, thereby implementing a table writing operation on the table entries in the P4 table.
[0097] In one embodiment, the table write operation involves comparing the target key value with the original key value of each table entry in the P4 table item to obtain a table lookup result. If the table lookup result is a table lookup hit, the original data corresponding to the original key value in the table is modified to the target data. It is understood that the original key value is the key value of the hit table entry, the original data corresponding to the original key value is the result value of the hit table entry, and the target data is the result value of the table entry to be written. In this embodiment, the table write operation is a modification.
[0098] In another embodiment, the table write operation is to compare the target Key value with the original Key value of each table entry in the P4 table entry to obtain a table lookup result. If the table lookup result is a table lookup hit, the data entry corresponding to the original Key value in the P4 table entry is deleted from the P4 table entry. The data entry includes the original Key value and the original data. It can be understood that the original Key value is the Key value of the hit table entry, and the original data is the Result value of the hit table entry, that is, if the table lookup result is a hit, the entire table entry is deleted; if the table lookup result is a miss, the deletion fails. In this embodiment, the table write operation is deletion.
[0099] In another embodiment, the table write operation is to compare the target key value with the original key value of each table entry in the P4 table entry to obtain a table lookup result. If the table lookup result is a table miss, the target key value and target data are written as a new data entry into the P4 table entry. It is understood that the target key value is the key value of the newly added table entry to be written, the target data is the result value of the newly added table entry to be written, and the target key value and target data are spliced into a complete table entry and written into the table. In this embodiment, the table write operation is to add.
[0100] The network device table writing syntax provided in the embodiment of the present application associates table writing and table lookup, meets the table writing requirements of programmable forwarding chips, and maintains the consistency of table writing and table lookup. The method is simple and easy to use. In addition, it expands on the existing P4 syntax, unifies the table writing syntax from the P4 specification, and improves and enhances the portability of P4 code.
[0101] Example 1
[0102] FIG6 is a flowchart of a table writing method provided by an example of the present application, which supports single-action table writing. As shown in FIG6 , the method includes at least the following steps S1001 to S1006 .
[0103] Step S1001: Extend the P4 syntax and define the P4 single-action table write syntax.
[0104] In this example, the definition of the P4 table write syntax includes: (1) adding a new table write action to the P4 table item definition, and the extended P4 table write syntax supports the table write action definition. The input parameter of the table write action is specified as the inout type, and the table write parameters are defined in sequence in the Result field of the table entry. Figure 7 is a schematic diagram of the single action table structure and table write result provided in an example of this application. As shown in Figure 7(a), the Result field of the single action table includes two fields, and the number of defined table write parameters is also two. It can be understood that the P4 table item definition includes the table write action definition and the table read action definition. When defining the P4 table item, it is necessary to ensure that the table write action and the table read action have the same definition of the table entry field. In addition, the table write annotation symbol @wrt_tbl is added to specify the table write action, and the source data of the table write is bound to the inout table write parameter in the action list definition.
[0105] The following are examples of table read and write definitions. The Result field of a single-action table includes two fields:
[0106] (2) Extend the P4 table lookup apply method to support the execution of specified table write actions. In this example, the extended P4 table lookup method t.apply(wrt_tbl_action_name) supports adding and modifying actions. The corresponding function of t.apply(wrt_tbl_action_name) is to support the execution of the apply method to look up the P4 table item first. If the table lookup is a hit, the wrt_tbl_action_name table write action is executed to rewrite the hit entry; if the table lookup is not a hit, the wrt_tbl_action_name table write action is executed to add a new entry. It can be understood that wrt_tbl_action_name in this example is the name of the table write action. The extended P4 table lookup method t.apply(delete) supports the deletion action. Its corresponding function is to support the execution of the apply method to look up the P4 table item first. If the table lookup is a hit, the hit entry is deleted. If the table lookup is not a hit, the deletion fails.
[0107] Step S1002: The P4 compiler develops a table writing function to support parsing and compiling the table writing syntax of the P4 single action table.
[0108] The P4 compiler develops table write functionality to support: (1) compiling table write actions and table write annotations. For example, taking the following table definition program excerpt as an example, the P4 compiler compiles the action wrt_tbl_action_name specified by the table write annotation @wrt_tbl in the table definition into a table write action; compiles the inout table write parameter 1 and table write parameter 2 of the table write action into the location information corresponding to the Result field in the P4 table entry, with the data source obtained from the intermediate data 1 and intermediate data 2 bound to the table write parameter; and compiles the input primary key parameter (i.e., Key parameter) in the table definition into the location information corresponding to the Key field in the P4 table entry.
[0109] The following is an example of an excerpt from a table definition program:
[0110] (2) Compilation of the extended P4 lookup table syntax.
[0111] In this example, the compiler supports compiling the extended P4 table lookup method t.apply(wrt_tbl_action_name) and compiles it to execute the table lookup first, as shown in Figure 7(b) and Figure 7(c). If the table lookup is a hit, the wrt_tbl_action_name table write action is executed, and the values of its table write parameter 1 and table write parameter 2 are taken as the Result value of the table entry to be written, replacing the Result value of the hit table entry; as shown in Figure 7(d), if the table lookup does not hit, the wrt_tbl_action_name table write action is executed, and the values of its table write parameter 1 and table write parameter 2 are taken as the Result value of the table entry to be written. These values are then concatenated with the value of the Key parameter in the code to form a complete table entry and added to the P4 table entry. If the wrt_tbl_action_name table write action is not defined in the table definition, the compiler reports an error.
[0112] The compiler supports compiling the extended P4 table lookup method t.apply(delete) by first executing the table lookup, as shown in Figure 7(e). If the table lookup results in a hit, the entry is deleted. If the table lookup results in a miss, the deletion fails, and the table entry in the P4 table remains unchanged, as shown in Figure 7(f).
[0113] It is understandable that the compiler supports the compilation of P4 table writing syntax and generates the chip's forwarding plane table writing configuration based on the above rules.
[0114] Step S1003: Write a P4 table writing program based on the P4 single-action table writing syntax.
[0115] In this example, a single-action table write program is written according to the defined P4 single-action table write syntax. If the P4 write program includes definitions for both read and write actions, the write parameters in the write action must be consistent with the read parameters in the read action. That is, both the write and read parameters must be defined sequentially according to the Result field of the single-action table. Figure 8 shows an example of a P4 write program written using the P4 single-action table write syntax.
[0116] It should be noted that the P4 table writing program is part of the complete P4 program. This example only shows the table writing program. The other parts are written based on the existing P4 language syntax and will not be described in detail here.
[0117] Step S1004: The compiler compiles the P4 table writing program to generate a chip forwarding plane table writing configuration.
[0118] It should be noted that the P4 table write program is part of the complete P4 program. The compiler compiles the complete P4 program to generate the chip's underlying forwarding plane configuration (i.e., forwarding unit and P4 table entry allocation configuration) and the API interface functions for software table configuration. The forwarding plane configuration includes the forwarding plane table write configuration.
[0119] Step S1005: The forwarding plane table writing configuration is loaded into the chip, completing the control plane table configuration.
[0120] It should be noted that the forwarding plane configuration compiled from the complete P4 program is loaded into the chip to implement the forwarding function of specific data packets. The forwarding plane configuration includes the forwarding plane table writing configuration, which is also loaded into the chip.
[0121] Step S1006: Construct a service message, trigger the forwarding plane to write a table, and implement table writing of a single action table.
[0122] It should be noted that the write operation of the single action table includes the addition, deletion and modification of table entries. Figure 7(a) shows the storage diagram of the single action table; Figure 7(b) and Figure 7(c) show the modification results of the table entries, where the target primary key value Key=0x1001 in Figure 7(b) is hit in the table lookup, and all Result values are modified. The target primary key value Key=0x1001 in Figure 7(c) is hit in the table lookup, and some Result values are modified. It can be understood that the difference between Figure 7(b) and Figure 7(c) lies in whether the original table entry and the written table entry have the same Result value. Figure 7(b) ) The Result value of the write table entry in the example of Figure 7(c) is 1, 0x8; the target primary key value Key=0x1003 in Figure 7(d) does not hit the table, and a new table entry is added to the single-action table; the target primary key value Key=0x1002 in Figure 7(e) hits the table, showing the result of deleting the hit table entry in the single-action table; the target primary key value Key=0x1003 in Figure 7(f) does not hit the table, and the single-action table remains unchanged.
[0123] Example 2
[0124] FIG9 is a flowchart of a table writing method provided by another example of the present application, which supports multi-action table writing. As shown in FIG9 , the method includes at least the following steps S2001 to S2006 .
[0125] Step S2001: Extend the P4 syntax and define the P4 multi-action table writing syntax.
[0126] In this example, the definition of the P4 table write syntax includes: (1) the definition of a new table write action in the P4 table item, and the extended P4 table write syntax supports the definition of the table write action. The input parameter of the table write action is specified as the inout type, and the table write parameters are defined in order to define the Result field of the table entry. Figure 10 is a schematic diagram of the multi-action table structure and table write results provided by another example of this application. As shown in Figure 10(a), the multi-action table has multiple different table structures. In multiple different table structures, the number, bit width, type, field name, etc. of the Key field are the same, and there is at least one difference in the number, bit width, type, field name, etc. of the Result field. A table write action is defined for each table structure of the multi-action table. This example uses the different number of fields included in the Result field as an example for explanation. It can be understood that the P4 table item definition includes the definition of the table write action and the table read action. When defining the P4 table item, it is necessary to ensure that the table entry field definitions of the table write action and the table read action are consistent.
[0127] In addition, add the table write annotation @wrt_tbl to specify the table write action, and bind the source data of the table write to the inout table write parameter in the action list definition.
[0128] The following are examples of table read and write definitions for a multi-action table. The multi-action table includes two different table structures, and the Result field contains two and three fields respectively:
[0129] (2) Extend the P4 table lookup apply method to support the execution of specified table write actions. In this example, the extended P4 table lookup methods t.apply(wrt_tbl_action_name0) and t.apply(wrt_tbl_action_name1) both support adding and modifying actions. Their functions are to support the execution of the apply method to look up two different table structures of the P4 table items first. If the table lookup is a hit, the wrt_tbl_action_name0 write action or the wrt_tbl_action_name1 write action is executed to rewrite the hit entry; if the table lookup is not a hit, the wrt_tbl_action_name0 write action or the wrt_tbl_action_name1 write action is executed to add a new entry. It can be understood that wrt_tbl_action_name0 and wrt_tbl_action_name1 in this example are both the names of the table write actions. The expanded P4 table lookup method t.apply(delete) supports deletion actions. Its corresponding function is to support the execution of the apply method to look up the P4 table entry first. If the table lookup hits, the hit entry is deleted. If the table lookup does not hit, the deletion fails.
[0130] Step S2002: The P4 compiler develops a table writing function to support parsing and compiling the table writing syntax of the P4 multi-action table.
[0131] The P4 compiler develops table write functionality to support: (1) compiling table write actions and table write annotations. For example, taking the following table definition program excerpt as an example, the P4 compiler compiles the actions wrt_tbl_action_name0 and wrt_tbl_action_name1 specified by the table write annotation @wrt_tbl in the table definition into table write actions; compiles table write parameters 1 and 2 of the table write action wrt_tbl_action_name0 into the location information corresponding to the Result field of one of the table structures in the multi-action table; and compiles table write parameters 1, 2, and 3 of the table write action wrt_tbl_action_name1 into the location information corresponding to the Result field of another table structure in the multi-action table; the data source is obtained from the intermediate data bound to the table write action; and the key parameter in the table definition is compiled into the location information corresponding to the key field in the multi-action table.
[0132] (2) Compilation of the extended P4 lookup table syntax.
[0133] In this example, the compiler supports compiling the extended P4 table lookup methods t.apply(wrt_tbl_action_name0) and t.apply(wrt_tbl_action_name1), and compiles them to execute the table lookup first, as shown in Figure 10(b) to Figure 10(e). If the table entry hit by the table lookup is an entry of table structure 1, where the Result field of table structure 1 includes two fields, the wrt_tbl_action_name0 table write action is executed, and the values of its table write parameter 1 and table write parameter 2 are taken as the Result value of the table entry to be written, replacing the Result value of the hit table entry. If the table entry hit by the table lookup is an entry of table structure 2, where the Result field of table structure 2 includes three fields, the wrt_tbl_action_name1 table write action is executed, and its table write parameter 1, table write parameter 2 and table write parameter 1 are taken. 3 is used as the Result value of the table entry to be written, replacing the Result value of the hit table entry; as shown in Figure 10(f) and Figure 10(g), if the table lookup does not hit, the wrt_tbl_action_name0 table write action is executed, and the values of its table write parameter 1 and table write parameter 2 are taken as the Result value of the table entry to be written, and are spliced with the value of the Key parameter in the table definition code to form a complete table entry, which is added to the P4 table entry, or the wrt_tbl_action_name1 table write action is executed, and the values of its table write parameter 1, table write parameter 2 and table write parameter 3 are taken as the Result value of the table entry to be written, and are spliced with the value of the Key parameter in the table definition code to form a complete table entry, which is added to the P4 table entry; if the wrt_tbl_action_name0 table write action or the wrt_tbl_action_name1 table write action is not defined in the table definition, the compiler will report an error.
[0134] The compiler supports compiling the extended P4 table lookup method t.apply(delete) by first executing the table lookup, as shown in Figure 10(h). If the table lookup results in a hit, the hit entry is deleted. If the table lookup results in a miss, the deletion fails, and the table entry in the multi-action table remains unchanged, as shown in Figure 10(i).
[0135] It is understandable that the compiler supports the compilation of P4 table writing syntax and generates the chip's forwarding plane table writing configuration based on the above rules.
[0136] Step S2003: Write a P4 table writing program based on the P4 multi-action table writing syntax.
[0137] In this example, a multi-action table write program is written according to the defined P4 multi-action table write syntax. If the P4 write program includes definitions for both read and write actions, the write parameters in the write action and the read parameters in the read action must be consistent. That is, both the write and read parameters must be defined sequentially according to the Result field of the multi-action table. Figure 11 shows an example of a P4 write program written using the P4 multi-action table write syntax.
[0138] It should be noted that the P4 table writing program is part of the complete P4 program. This example only shows the table writing program. The other parts are written based on the existing P4 language syntax and will not be described in detail here.
[0139] Step S2004: The compiler compiles the P4 table writing program to generate a chip forwarding plane table writing configuration.
[0140] It should be noted that the P4 table write program is part of the complete P4 program. The compiler compiles the complete P4 program to generate the chip's underlying forwarding plane configuration (i.e., forwarding unit and P4 table entry allocation configuration) and the Application Programming Interface (API) functions used by software to configure the table. The forwarding plane configuration includes the forwarding plane table write configuration.
[0141] Step S2005: The forwarding plane table writing configuration is loaded into the chip, completing the control plane table configuration.
[0142] It should be noted that the forwarding plane configuration compiled from the complete P4 program is loaded into the chip to implement the forwarding function of specific data packets. The forwarding plane configuration includes the forwarding plane table writing configuration, which is also loaded into the chip.
[0143] Step S2006: Construct a service message, trigger the forwarding plane to write a table, and implement table writing of multiple action tables.
[0144] It should be noted that the write operation of the multi-action table includes adding, deleting and modifying table entries. Figure 10(a) shows a schematic diagram of the storage of the multi-action table. The multi-action table in this example includes two different table structures.
[0145] Figures 10(b) to 10(e) show the modification results of the table entries, where the target primary key value Key=0x1001 in Figure 10(b) is hit in the table lookup, and all Result values are modified. The target primary key value Key=0x1001 in Figure 10(c) is hit in the table lookup, and some Result values are modified. It can be understood that the difference between Figures 10(b) and 10(c) lies in whether the original table entry and the written table entry have the same fields. The Result value of the written table entry in the example of Figure 10(b) is 1, 0x1b, while the Result value of the written table entry in the example of Figure 10(c) is 1, 0x8. Figures 10(b) and 10(c) show the modification of one of the table structure entries of the multi-action table. For the modification of another table structure entry of the multi-action table, see Figures 10(d) and 10(e).
[0146] The target primary key value Key=0x1005 in Figure 10(f) and Figure 10(g) is not hit in the table lookup, and a new table entry is added to the multi-action table; the target primary key value Key=0x1002 in Figure 10(h) is hit in the table lookup, and the hit table entry is deleted in the multi-action table; the target primary key value Key=0x1005 in Figure 10(i) is not hit in the table lookup, and there is no change in the multi-action table.
[0147] An embodiment of the present application also provides a network device system that supports a table writing function, including: a compiler configured to receive program information written by a user based on the P4 language table writing syntax, and compile the program information to obtain forwarding plane table writing configuration information, and a network device configured to perform a table writing operation according to the loaded forwarding plane table writing configuration information.
[0148] An embodiment of the present application also provides a table writing device for a network device, as shown in Figure 12, comprising: a memory 2000, a processor 2100, and a computer program stored on the memory 2000 and executable on the processor 2100. When the processor 2100 executes the computer program, the table writing method provided in any embodiment of the present application is implemented.
[0149] An embodiment of the present application further provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are used to execute the table writing method provided in any embodiment of the present application.
[0150] An embodiment of the present application also provides a computer program product, including a computer program or computer instructions, wherein the computer program or computer instructions are stored in a computer-readable storage medium, and a processor of a computer device reads the computer program or computer instructions from the computer-readable storage medium, and the processor executes the computer program or computer instructions, so that the computer device executes the table writing method provided in any embodiment of the present application.
[0151] The system architecture and application scenarios described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of the system architecture and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are equally applicable to similar technical problems.
[0152] Those skilled in the art will appreciate that all or some of the steps in the methods, systems, and functional modules / units in the devices disclosed above may be implemented as software, firmware, hardware, or appropriate combinations thereof.
[0153] In a hardware implementation, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium). As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. Furthermore, as is well known to those skilled in the art, communication media typically embodies computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
[0154] As used in this specification, the terms "component," "module," "system," and the like are used to refer to computer-related entities, hardware, firmware, a combination of hardware and software, software, or software in execution. For example, a component can be, but is not limited to, a process running on a processor, a processor, an object, an executable file, an execution thread, a program, or a computer. By way of illustration, both applications running on a computing device and a computing device can be components. One or more components can reside in a process or execution thread, and a component can be located on a single computer or distributed between two or more computers. In addition, these components can be executed from various computer-readable media having various data structures stored thereon. Components can communicate, for example, through local or remote processes based on signals having one or more data packets (e.g., data from two components interacting with another component on a local system, a distributed system, or a network, such as the Internet interacting with other systems via signals).
[0155] The above description of some embodiments of the present application with reference to the accompanying drawings does not limit the scope of the present invention. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and essence of the present invention shall be within the scope of the present application.
Claims
1. A table writing method for a network device, comprising: Defines the P4 language table writing syntax used to support table writing operations on P4 table entries; Receiving program information written by a user based on the P4 language table writing grammar; Invoking a compiler to compile the program information to obtain forwarding plane table writing configuration information; The forwarding plane table writing configuration information is loaded into the network device, and the network device is enabled to perform a table writing operation according to the forwarding plane table writing configuration information.
2. The table writing method according to claim 1, wherein: The definition is used to support the P4 language table writing syntax for writing table operations on P4 table entries, including: Define a P4 language table write action syntax for supporting one or more P4 language table write actions; Define table writing annotations used to represent table writing actions; A P4 table lookup method that is extended to support one or more P4 table write actions.
3. The table writing method according to claim 2, wherein: The P4 language table write action syntax includes a table write action and table write parameters. The data to be written is assigned to the table write parameters through the table write action. The table write parameters are defined according to the target field in the P4 table entry.
4. The table writing method according to claim 3, wherein: The P4 language table lookup method includes a P4 language table lookup apply method; The extension is used to support a P4 language table lookup method for one or more P4 language table writing actions, including: A P4 language table lookup apply method is extended so that the extended P4 language table lookup apply method supports parameters containing a target action, where the target action includes at least one of an update action and a delete action.
5. The table writing method according to claim 4, wherein: The calling compiler compiles the program information to obtain forwarding plane table writing configuration information, including: Compiling the action represented by the table writing annotation in the program information into table writing execution action information; compiling the input primary key parameter in the program information into first location information, the first location information being used to indicate a target primary key value corresponding to the input primary key parameter stored in a first location; compiling the table write parameter in the program information into second position information corresponding to the target field in the P4 table entry, where the second position information is used to indicate target data corresponding to the target field stored in a second position; Compiling the expanded P4 language table lookup method in the program information into table lookup method information supporting a target table writing action; The table write execution action information, the first location information, the second location information, and the table lookup method information supporting the target table write action are used as the forwarding plane table write configuration information.
6. The table writing method according to claim 5, wherein: The enabling the network device to perform a table writing operation according to the forwarding plane table writing configuration information includes: Compare the target primary key value with each original primary key value corresponding to the primary key field in the P4 table entry to obtain a table lookup result; A table writing operation is performed according to the table lookup result.
7. The table writing method according to claim 6, wherein: The update action includes a modification action or a new addition action, in the case where the target table write action is an update action; The performing a table writing operation according to the table lookup result includes: If the table lookup result is a table lookup hit, executing the modification action in the table writing method; When the table lookup result is a table miss, the newly added action in the table writing method is executed.
8. The table writing method according to claim 6, wherein: In the case where the target table writing action is a delete action; The performing a table writing operation according to the table lookup result includes: If the table lookup result is a table hit, executing the deletion action in the table writing method; In the case where the table lookup result is a table lookup miss, a table write failure or a table lookup miss is returned.
9. The table writing method according to claim 7, wherein: The executing the modification action in the table writing method includes: The original data corresponding to the original primary key value in the P4 table item is modified to the target data.
10. The table writing method according to claim 7, wherein: The newly added actions in executing the table writing method include: The target primary key value and the target data are written into the P4 table entry as new data entries.
11. The table writing method according to claim 8, wherein: The executing the deletion action in the table writing method includes: The data entry corresponding to the original primary key value in the P4 table entry is deleted from the P4 table entry, where the data entry includes the original primary key value and original data.
12. A network device system supporting a table writing function, comprising: A compiler configured to receive program information written by a user based on a P4 language table writing syntax and compile the program information to obtain forwarding plane table writing configuration information, wherein the P4 language table writing syntax supports table writing operations on P4 table entries; A network device is configured to perform a table writing operation according to the loaded forwarding plane table writing configuration information.
13. A network device table writing device, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the table writing method according to any one of claims 1 to 11 when executing the computer program.
14. A computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are used to execute the table writing method according to any one of claims 1 to 11.
15. A computer program product comprising a computer program or computer instructions, wherein: The computer program or the computer instructions are stored in a computer-readable storage medium, and a processor of a computer device reads the computer program or the computer instructions from the computer-readable storage medium. The processor executes the computer program or the computer instructions, so that the computer device executes the table writing method according to any one of claims 1 to 11.