Execution of a command within a conditional command received in a data packet
A mechanism is disclosed for implementing conditional commands carried by network data packets. A data flow including a data packet is received. The data packet includes a conditional command. A condition and a command are obtained from the conditional command. The mechanism determines that the condition is satisfied. Based on the determination that the condition is satisfied, the command is executed to alter handling of the data flow, alter handling of the data packet, or alter a context for the data flow.
1 . A network device comprising:
a receiver configured to receive a data packet including a conditional command block located between a data link header and a transport header of the data packet, the conditional command block comprising a conditional instruction set header indicating a number of conditional command fields in the conditional command block, a conditional command field comprising at least one command and at least one condition;
a memory storing instructions; and
at least one processor coupled to the receiver and the memory, the at least one processor configured, upon execution of the instructions, to perform the following steps:
obtain a conditional command from the command block;
obtain a condition from the conditional command field of the conditional command;
determine that the condition is satisfied; and
execute the command based on the determination that the condition is satisfied.
2 . The network device of claim 1 , wherein the conditional command field further includes one or more command parameters, a command parameter of the command parameters including an input value for the command.
3 . The network device of claim 1 , wherein the conditional command field further including a condition parameter, the condition parameter including data indicating a value to support evaluation of the condition.
4 . The network device of claim 1 , wherein the command is a complementary command executed in addition to the stored routing instructions.
5 . The network device of claim 1 , wherein the command is an override command executed instead of the stored routing instructions.
6 . The network device of claim 1 , wherein the command instructs the network device to perform at least one of: modifying a resource allocation for the data flow, modifying a chosen next hop for the data flow, or updating a flow context for the data flow.
7 . The network device of claim 1 , wherein the command instructs the network device to perform at least one of: modifying data in the data packet, modifying a chosen next hop for the data packet, modifying a priority for the data packet, dropping the data packet, buffering the data packet, or modifying metadata in the data packet.
8 . The network device of claim 1 , wherein determining the condition is satisfied includes performing at least one of: parsing data from the data packet, checking a flow context of a data flow including the data packet, checking a state of the network device, comparing data items, or checking an identity of the network device.
9 . A method comprising:
receiving, at a receiver in a network device, a data packet including a conditional command block located between a data link header and a transport header of the data packet, the conditional command block comprising a conditional instruction set header indicating a number of conditional command fields in the conditional command block, a conditional command field comprising at least one command and at least one condition;
obtaining, by a processor in the network device, a command from the command block;
obtaining, by the processor, a condition from the conditional command field of the conditional command;
determining, by the processor, that the condition is satisfied; and
executing, by the processor, the command based on the determination that the condition is satisfied.
10 . The method of claim 9 , wherein the conditional command field further includes one or more command parameters, a command parameter of the command parameters including an input value for the command.
11 . The method of claim 9 , wherein the conditional command field further including a condition parameter, the condition parameter including data indicating a value to support evaluation of the condition.
12 . The method of claim 9 , wherein the conditional command field further including a global parameter, the data packet comprises at least one other conditional command, and the global parameter contains data indicating a value to support evaluation of at least two conditional commands in the data packet.
13 . The method of claim 9 , wherein the command is a complementary command executed in addition to the stored routing instructions.
14 . The method of claim 9 , wherein the command is an override command executed instead of the stored routing instructions.
15 . The method of claim 9 , wherein the command instructs the network device to perform at least one of: modifying at least one of a resource allocation for the data flow, modifying a chosen next hop for the data flow, or updating a flow context for the data flow.
16 . The method of claim 9 , wherein the command instructs the network device to perform at least one of: modifying data in the data packet, modifying a chosen next hop for the data packet, modifying a priority for the data packet, dropping the data packet, buffering the data packet, or modifying metadata in the data packet.
17 . The method of claim 9 , wherein determining the condition is satisfied includes performing at least one of: parsing data from the data packet, checking a flow context of a data flow including the data packet, checking a state of the method, comparing data items, or checking an identity of the method.
18 . A non-transitory computer readable media storing computer instructions for use by a network device, that configure at least one processor, upon execution of the instructions, to perform the following steps:
receive a data packet including a conditional command block located between a data link header and a transport header of the data packet, the conditional command block comprising a conditional instruction set header indicating a number of conditional command fields in the conditional command block, a conditional command field comprising at least one command and at least one condition;
obtain a conditional command from the command block;
obtain a condition from the conditional command field of the conditional command;
determine that the condition is satisfied; and
execute the command based on the determination that the condition is satisfied.