• Herbert Xu's avatar
    [PKT_SCHED]: Add stateless NAT · b4219952
    Herbert Xu authored
    Stateless NAT is useful in controlled environments where restrictions are
    placed on through traffic such that we don't need connection tracking to
    correctly NAT protocol-specific data.
    
    In particular, this is of interest when the number of flows or the number
    of addresses being NATed is large, or if connection tracking information
    has to be replicated and where it is not practical to do so.
    
    Previously we had stateless NAT functionality which was integrated into
    the IPv4 routing subsystem.  This was a great solution as long as the NAT
    worked on a subnet to subnet basis such that the number of NAT rules was
    relatively small.  The reason is that for SNAT the routing based system
    had to perform a linear scan through the rules.
    
    If the number of rules is large then major renovations would have take
    place in the routing subsystem to make this practical.
    
    For the time being, the least intrusive way of achieving this is to use
    the u32 classifier written by Alexey Kuznetsov along with the actions
    infrastructure implemented by Jamal Hadi Salim.
    
    The following patch is an attempt at this problem by creating a new nat
    action that can be invoked from u32 hash tables which would allow large
    number of stateless NAT rules that can be used/updated in constant time.
    
    The actual NAT code is mostly based on the previous stateless NAT code
    written by Alexey.  In future we might be able to utilise the protocol
    NAT code from netfilter to improve support for other protocols.
    Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    b4219952
act_nat.c 6.99 KB