All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next v3 0/8] openvswitch: NAT support.
@ 2015-11-26  0:08 Jarno Rajahalme
  2015-11-26  0:08 ` [PATCH net-next v3 2/8] netfilter: Factor out nf_ct_get_info() Jarno Rajahalme
                   ` (4 more replies)
  0 siblings, 5 replies; 17+ messages in thread
From: Jarno Rajahalme @ 2015-11-26  0:08 UTC (permalink / raw)
  To: netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: dev-yBygre7rU0TnMu66kgdUjQ, netfilter-devel-u79uwXL29TY76Z2rM5mHXA

This series adds NAT support to openvswitch kernel module.  A few
changes are needed to the netfilter code to facilitate this (patches
1-3/8).  Patches 4-7 make the openvswitch kernel module ready for the
patch 8 that adds the NAT support by calling into netfilter NAT code
from the openvswitch conntrack action.

The OVS master now has the corresponding OVS userspace support to use
and test the NAT features.  Below if a walk through of a simple use
case.

In this case ports 1 and 2 are in different namespaces.  The OpenFlow
table below only allows IPv4 connections initiated from port 1, and
applies source NAT to those connections:

   in_port=1,ip,action=ct(commit,zone=1,nat(src=10.1.1.240-10.1.1.255)),2
   in_port=2,ct_state=-trk,ip,action=ct(table=0,zone=1,nat)
   in_port=2,ct_state=+est,ct_zone=1,ip,action=1

This flow table matches all IPv4 traffic from port 1, runs them
through conntrack in zone 1 and NATs them.  The NAT is initialized to
do source IP mapping to the given range for the first packet of each
connection, after which the new connection is committed (confirmed).
For further packets of already tracked connections NAT is done
according to the connection state and the commit is a no-op.  Each
packet that is not flagged as a drop by the CT action is forwarded to
port 2.  The CT action does an implicit fragmentation reassembly, so
that only complete packets are run through conntrack.  Reassembled
packets are re-fragmented on output.

The IPv4 traffic coming from port 2 is first matched for the
non-tracked state (-trk), which means that the packet has not been
through a CT action yet.  Such traffic is run trough the conntrack in
zone 1 and all packets associated with a NATted connection are NATted
also in the return direction.  After the packet has been through
conntrack it is recirculated back to OpenFlow table 0 (which is the
default table, so all the rules above are in table 0).  The CT action
changes the 'trk' flag to being set, so the packets after
recirculation no longer match the second rule.  The third rule then
matches the recirculated packets that were marked as established by
conntrack (+est), and the packet is output on port 1.  Matching on
ct_zone is not strictly needed, but in this test case it verifies that
the ct_zone key attribute is properly set by the conntrack action.

A full test case requires rules for ARP handling not shown here.

The flow table above is an OpenFlow table, and the rules therein
are translated to kernel flow entries on-demand by ovs-vswitchd.


Jarno Rajahalme (8):
  netfilter: Remove IP_CT_NEW_REPLY definition.
  netfilter: Factor out nf_ct_get_info().
  netfilter: Allow calling into nat helper without skb_dst.
  openvswitch: Update the CT state key only after nf_conntrack_in().
  openvswitch: Find existing conntrack entry after upcall.
  openvswitch: Handle NF_REPEAT in conntrack action.
  openvswitch: Delay conntrack helper call for new connections.
  openvswitch: Interface with NAT.

 include/net/netfilter/nf_conntrack.h               |  15 +
 include/uapi/linux/netfilter/nf_conntrack_common.h |  12 +-
 include/uapi/linux/openvswitch.h                   |  47 ++
 net/ipv4/netfilter/nf_nat_l3proto_ipv4.c           |  29 +-
 net/ipv6/netfilter/nf_nat_l3proto_ipv6.c           |  29 +-
 net/netfilter/nf_conntrack_core.c                  |  22 +-
 net/openvswitch/conntrack.c                        | 632 +++++++++++++++++++--
 net/openvswitch/conntrack.h                        |   3 +-
 8 files changed, 686 insertions(+), 103 deletions(-)

-- 
2.1.4

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2015-12-04 23:45 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-26  0:08 [PATCH net-next v3 0/8] openvswitch: NAT support Jarno Rajahalme
2015-11-26  0:08 ` [PATCH net-next v3 2/8] netfilter: Factor out nf_ct_get_info() Jarno Rajahalme
2015-11-26  6:18   ` [ovs-dev] " Simon Horman
     [not found] ` <1448496501-109561-1-git-send-email-jarno-LZ6Gd1LRuIk@public.gmane.org>
2015-11-26  0:08   ` [PATCH net-next v3 1/8] netfilter: Remove IP_CT_NEW_REPLY definition Jarno Rajahalme
2015-11-26  5:41     ` [ovs-dev] " Simon Horman
     [not found]       ` <20151126054100.GB21626-IxS8c3vjKQDk1uMJSBkQmQ@public.gmane.org>
2015-11-30 18:16         ` Jarno Rajahalme
     [not found]           ` <391067B3-D60E-43BC-B669-2DD45924E5D8-LZ6Gd1LRuIk@public.gmane.org>
2015-12-01  2:46             ` Jarno Rajahalme
2015-11-26  0:08   ` [PATCH net-next v3 3/8] netfilter: Allow calling into nat helper without skb_dst Jarno Rajahalme
2015-12-01 20:51     ` [PATCH net-next v3 3/8] netfilter: Allow calling into nat helper without skb_dst.g Pablo Neira Ayuso
2015-12-04 23:45       ` [ovs-dev] " Pravin Shelar
2015-11-26  0:08   ` [PATCH net-next v3 4/8] openvswitch: Update the CT state key only after nf_conntrack_in() Jarno Rajahalme
2015-11-26  0:08   ` [PATCH net-next v3 5/8] openvswitch: Find existing conntrack entry after upcall Jarno Rajahalme
2015-11-26  0:08 ` [PATCH net-next v3 6/8] openvswitch: Handle NF_REPEAT in conntrack action Jarno Rajahalme
2015-11-26  0:08 ` [PATCH net-next v3 7/8] openvswitch: Delay conntrack helper call for new connections Jarno Rajahalme
2015-11-26  0:08 ` [PATCH net-next v3 8/8] openvswitch: Interface with NAT Jarno Rajahalme
2015-11-26  2:39   ` kbuild test robot
2015-11-26  4:19   ` kbuild test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.