1. A networking device, comprising: a plurality of physical network interfaces; and a packet processor, configured to: receive a network packet via one of the physical network interfaces; determine a packet header modification for the network packet; access different locations in a memory identified for the packet header modification corresponding to a traversal of a dependency graph stored in the memory for the packet header modification, wherein at least one of the different locations is determined from a prior entry of the dependency graph, to obtain: an operation to apply the packet header modification; and one or more dependent operations to update respective fields of the network packet that store values to be changed as a result of the packet header modification; for each access in the memory according to the traversal of the dependency graph, perform the operation to apply the packet header modification or one of the one or more dependent operations; and upon completion of the traversal of the dependency graph, transmit the modified network packet via one of the physical network interfaces.