aboutsummaryrefslogtreecommitdiffstats
path: root/include/uapi/linux/openvswitch.h
diff options
context:
space:
mode:
authorJarno Rajahalme <jarno@ovn.org>2017-02-09 14:21:59 -0500
committerDavid S. Miller <davem@davemloft.net>2017-02-09 22:59:34 -0500
commit9dd7f8907c3705dc7a7a375d1c6e30b06e6daffc (patch)
tree9330b1d7ffe29ec0f1c06bf8ff73c5c7d1c258ce /include/uapi/linux/openvswitch.h
parent09aa98ad496d6b11a698b258bc64d7f64c55d682 (diff)
openvswitch: Add original direction conntrack tuple to sw_flow_key.
Add the fields of the conntrack original direction 5-tuple to struct sw_flow_key. The new fields are initially marked as non-existent, and are populated whenever a conntrack action is executed and either finds or generates a conntrack entry. This means that these fields exist for all packets that were not rejected by conntrack as untrackable. The original tuple fields in the sw_flow_key are filled from the original direction tuple of the conntrack entry relating to the current packet, or from the original direction tuple of the master conntrack entry, if the current conntrack entry has a master. Generally, expected connections of connections having an assigned helper (e.g., FTP), have a master conntrack entry. The main purpose of the new conntrack original tuple fields is to allow matching on them for policy decision purposes, with the premise that the admissibility of tracked connections reply packets (as well as original direction packets), and both direction packets of any related connections may be based on ACL rules applying to the master connection's original direction 5-tuple. This also makes it easier to make policy decisions when the actual packet headers might have been transformed by NAT, as the original direction 5-tuple represents the packet headers before any such transformation. When using the original direction 5-tuple the admissibility of return and/or related packets need not be based on the mere existence of a conntrack entry, allowing separation of admission policy from the established conntrack state. While existence of a conntrack entry is required for admission of the return or related packets, policy changes can render connections that were initially admitted to be rejected or dropped afterwards. If the admission of the return and related packets was based on mere conntrack state (e.g., connection being in an established state), a policy change that would make the connection rejected or dropped would need to find and delete all conntrack entries affected by such a change. When using the original direction 5-tuple matching the affected conntrack entries can be allowed to time out instead, as the established state of the connection would not need to be the basis for packet admission any more. It should be noted that the directionality of related connections may be the same or different than that of the master connection, and neither the original direction 5-tuple nor the conntrack state bits carry this information. If needed, the directionality of the master connection can be stored in master's conntrack mark or labels, which are automatically inherited by the expected related connections. The fact that neither ARP nor ND packets are trackable by conntrack allows mutual exclusion between ARP/ND and the new conntrack original tuple fields. Hence, the IP addresses are overlaid in union with ARP and ND fields. This allows the sw_flow_key to not grow much due to this patch, but it also means that we must be careful to never use the new key fields with ARP or ND packets. ARP is easy to distinguish and keep mutually exclusive based on the ethernet type, but ND being an ICMPv6 protocol requires a bit more attention. Signed-off-by: Jarno Rajahalme <jarno@ovn.org> Acked-by: Joe Stringer <joe@ovn.org> Acked-by: Pravin B Shelar <pshelar@ovn.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/uapi/linux/openvswitch.h')
-rw-r--r--include/uapi/linux/openvswitch.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/include/uapi/linux/openvswitch.h b/include/uapi/linux/openvswitch.h
index 96aee34ef55f..90af8b8e10f8 100644
--- a/include/uapi/linux/openvswitch.h
+++ b/include/uapi/linux/openvswitch.h
@@ -1,6 +1,6 @@
1 1
2/* 2/*
3 * Copyright (c) 2007-2013 Nicira, Inc. 3 * Copyright (c) 2007-2017 Nicira, Inc.
4 * 4 *
5 * This program is free software; you can redistribute it and/or 5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 2 of the GNU General Public 6 * modify it under the terms of version 2 of the GNU General Public
@@ -331,6 +331,8 @@ enum ovs_key_attr {
331 OVS_KEY_ATTR_CT_ZONE, /* u16 connection tracking zone. */ 331 OVS_KEY_ATTR_CT_ZONE, /* u16 connection tracking zone. */
332 OVS_KEY_ATTR_CT_MARK, /* u32 connection tracking mark */ 332 OVS_KEY_ATTR_CT_MARK, /* u32 connection tracking mark */
333 OVS_KEY_ATTR_CT_LABELS, /* 16-octet connection tracking label */ 333 OVS_KEY_ATTR_CT_LABELS, /* 16-octet connection tracking label */
334 OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV4, /* struct ovs_key_ct_tuple_ipv4 */
335 OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV6, /* struct ovs_key_ct_tuple_ipv6 */
334 336
335#ifdef __KERNEL__ 337#ifdef __KERNEL__
336 OVS_KEY_ATTR_TUNNEL_INFO, /* struct ip_tunnel_info */ 338 OVS_KEY_ATTR_TUNNEL_INFO, /* struct ip_tunnel_info */
@@ -472,6 +474,22 @@ struct ovs_key_ct_labels {
472 474
473#define OVS_CS_F_NAT_MASK (OVS_CS_F_SRC_NAT | OVS_CS_F_DST_NAT) 475#define OVS_CS_F_NAT_MASK (OVS_CS_F_SRC_NAT | OVS_CS_F_DST_NAT)
474 476
477struct ovs_key_ct_tuple_ipv4 {
478 __be32 ipv4_src;
479 __be32 ipv4_dst;
480 __be16 src_port;
481 __be16 dst_port;
482 __u8 ipv4_proto;
483};
484
485struct ovs_key_ct_tuple_ipv6 {
486 __be32 ipv6_src[4];
487 __be32 ipv6_dst[4];
488 __be16 src_port;
489 __be16 dst_port;
490 __u8 ipv6_proto;
491};
492
475/** 493/**
476 * enum ovs_flow_attr - attributes for %OVS_FLOW_* commands. 494 * enum ovs_flow_attr - attributes for %OVS_FLOW_* commands.
477 * @OVS_FLOW_ATTR_KEY: Nested %OVS_KEY_ATTR_* attributes specifying the flow 495 * @OVS_FLOW_ATTR_KEY: Nested %OVS_KEY_ATTR_* attributes specifying the flow