A method for processing a packet in a software-defined network, SDN, wherein the method is performed by a forwarder, and the method comprises: receiving an input packet; determining a flow to which the input packet belongs according to the input packet; and determining a context identifier set corresponding to the flow to which the input packet belongs according to a first correspondence between flows and context identifier sets, wherein a context identifier set corresponding to each flow in the first correspondence comprises at least one context identifier; the method being characterized in that it further comprises: determining a context corresponding to one of the at least one context identifier according to a second correspondence between context identifiers and contexts, wherein one of the at least one context identifier is used to uniquely identify the context, and wherein each context comprises at least one type indicating a function to apply to packets and comprises for each of its types at least a constraint to apply to the function indicated by the type; processing the input packet according to the context corresponding to the one context identifier; receiving a flow deletion message sent by the controller, wherein the flow deletion message comprises information about a to-be-deleted flow; and deleting, from the first correspondence, the information about the to-be-deleted flow, and a context identifier set corresponding to the to-be-deleted flow. receiving an input packet; determining a flow to which the input packet belongs according to the input packet; and determining a context identifier set corresponding to the flow to which the input packet belongs according to a first correspondence between flows and context identifier sets, wherein a context identifier set corresponding to each flow in the first correspondence comprises at least one context identifier; the method being characterized in that it further comprises: determining a context corresponding to one of the at least one context identifier according to a second correspondence between context identifiers and contexts, wherein one of the at least one context identifier is used to uniquely identify the context, and wherein each context comprises at least one type indicating a function to apply to packets and comprises for each of its types at least a constraint to apply to the function indicated by the type; processing the input packet according to the context corresponding to the one context identifier; receiving a flow deletion message sent by the controller, wherein the flow deletion message comprises information about a to-be-deleted flow; and deleting, from the first correspondence, the information about the to-be-deleted flow, and a context identifier set corresponding to the to-be-deleted flow. determining a context corresponding to one of the at least one context identifier according to a second correspondence between context identifiers and contexts, wherein one of the at least one context identifier is used to uniquely identify the context, and wherein each context comprises at least one type indicating a function to apply to packets and comprises for each of its types at least a constraint to apply to the function indicated by the type; processing the input packet according to the context corresponding to the one context identifier; receiving a flow deletion message sent by the controller, wherein the flow deletion message comprises information about a to-be-deleted flow; and deleting, from the first correspondence, the information about the to-be-deleted flow, and a context identifier set corresponding to the to-be-deleted flow. <EOS>