diff options
Diffstat (limited to 'net/openvswitch/flow.h')
-rw-r--r-- | net/openvswitch/flow.h | 62 |
1 files changed, 48 insertions, 14 deletions
diff --git a/net/openvswitch/flow.h b/net/openvswitch/flow.h index 4962bee81a11..543b358ee57f 100644 --- a/net/openvswitch/flow.h +++ b/net/openvswitch/flow.h | |||
@@ -37,8 +37,8 @@ struct sk_buff; | |||
37 | 37 | ||
38 | /* Used to memset ovs_key_ipv4_tunnel padding. */ | 38 | /* Used to memset ovs_key_ipv4_tunnel padding. */ |
39 | #define OVS_TUNNEL_KEY_SIZE \ | 39 | #define OVS_TUNNEL_KEY_SIZE \ |
40 | (offsetof(struct ovs_key_ipv4_tunnel, ipv4_ttl) + \ | 40 | (offsetof(struct ovs_key_ipv4_tunnel, tp_dst) + \ |
41 | FIELD_SIZEOF(struct ovs_key_ipv4_tunnel, ipv4_ttl)) | 41 | FIELD_SIZEOF(struct ovs_key_ipv4_tunnel, tp_dst)) |
42 | 42 | ||
43 | struct ovs_key_ipv4_tunnel { | 43 | struct ovs_key_ipv4_tunnel { |
44 | __be64 tun_id; | 44 | __be64 tun_id; |
@@ -47,6 +47,8 @@ struct ovs_key_ipv4_tunnel { | |||
47 | __be16 tun_flags; | 47 | __be16 tun_flags; |
48 | u8 ipv4_tos; | 48 | u8 ipv4_tos; |
49 | u8 ipv4_ttl; | 49 | u8 ipv4_ttl; |
50 | __be16 tp_src; | ||
51 | __be16 tp_dst; | ||
50 | } __packed __aligned(4); /* Minimize padding. */ | 52 | } __packed __aligned(4); /* Minimize padding. */ |
51 | 53 | ||
52 | struct ovs_tunnel_info { | 54 | struct ovs_tunnel_info { |
@@ -64,27 +66,59 @@ struct ovs_tunnel_info { | |||
64 | FIELD_SIZEOF(struct sw_flow_key, tun_opts) - \ | 66 | FIELD_SIZEOF(struct sw_flow_key, tun_opts) - \ |
65 | opt_len)) | 67 | opt_len)) |
66 | 68 | ||
67 | static inline void ovs_flow_tun_info_init(struct ovs_tunnel_info *tun_info, | 69 | static inline void __ovs_flow_tun_info_init(struct ovs_tunnel_info *tun_info, |
68 | const struct iphdr *iph, | 70 | __be32 saddr, __be32 daddr, |
69 | __be64 tun_id, __be16 tun_flags, | 71 | u8 tos, u8 ttl, |
70 | struct geneve_opt *opts, | 72 | __be16 tp_src, |
71 | u8 opts_len) | 73 | __be16 tp_dst, |
74 | __be64 tun_id, | ||
75 | __be16 tun_flags, | ||
76 | struct geneve_opt *opts, | ||
77 | u8 opts_len) | ||
72 | { | 78 | { |
73 | tun_info->tunnel.tun_id = tun_id; | 79 | tun_info->tunnel.tun_id = tun_id; |
74 | tun_info->tunnel.ipv4_src = iph->saddr; | 80 | tun_info->tunnel.ipv4_src = saddr; |
75 | tun_info->tunnel.ipv4_dst = iph->daddr; | 81 | tun_info->tunnel.ipv4_dst = daddr; |
76 | tun_info->tunnel.ipv4_tos = iph->tos; | 82 | tun_info->tunnel.ipv4_tos = tos; |
77 | tun_info->tunnel.ipv4_ttl = iph->ttl; | 83 | tun_info->tunnel.ipv4_ttl = ttl; |
78 | tun_info->tunnel.tun_flags = tun_flags; | 84 | tun_info->tunnel.tun_flags = tun_flags; |
79 | 85 | ||
80 | /* clear struct padding. */ | 86 | /* For the tunnel types on the top of IPsec, the tp_src and tp_dst of |
81 | memset((unsigned char *)&tun_info->tunnel + OVS_TUNNEL_KEY_SIZE, 0, | 87 | * the upper tunnel are used. |
82 | sizeof(tun_info->tunnel) - OVS_TUNNEL_KEY_SIZE); | 88 | * E.g: GRE over IPSEC, the tp_src and tp_port are zero. |
89 | */ | ||
90 | tun_info->tunnel.tp_src = tp_src; | ||
91 | tun_info->tunnel.tp_dst = tp_dst; | ||
92 | |||
93 | /* Clear struct padding. */ | ||
94 | if (sizeof(tun_info->tunnel) != OVS_TUNNEL_KEY_SIZE) | ||
95 | memset((unsigned char *)&tun_info->tunnel + OVS_TUNNEL_KEY_SIZE, | ||
96 | 0, sizeof(tun_info->tunnel) - OVS_TUNNEL_KEY_SIZE); | ||
83 | 97 | ||
84 | tun_info->options = opts; | 98 | tun_info->options = opts; |
85 | tun_info->options_len = opts_len; | 99 | tun_info->options_len = opts_len; |
86 | } | 100 | } |
87 | 101 | ||
102 | static inline void ovs_flow_tun_info_init(struct ovs_tunnel_info *tun_info, | ||
103 | const struct iphdr *iph, | ||
104 | __be16 tp_src, | ||
105 | __be16 tp_dst, | ||
106 | __be64 tun_id, | ||
107 | __be16 tun_flags, | ||
108 | struct geneve_opt *opts, | ||
109 | u8 opts_len) | ||
110 | { | ||
111 | __ovs_flow_tun_info_init(tun_info, iph->saddr, iph->daddr, | ||
112 | iph->tos, iph->ttl, | ||
113 | tp_src, tp_dst, | ||
114 | tun_id, tun_flags, | ||
115 | opts, opts_len); | ||
116 | } | ||
117 | |||
118 | #define OVS_SW_FLOW_KEY_METADATA_SIZE \ | ||
119 | (offsetof(struct sw_flow_key, recirc_id) + \ | ||
120 | FIELD_SIZEOF(struct sw_flow_key, recirc_id)) | ||
121 | |||
88 | struct sw_flow_key { | 122 | struct sw_flow_key { |
89 | u8 tun_opts[255]; | 123 | u8 tun_opts[255]; |
90 | u8 tun_opts_len; | 124 | u8 tun_opts_len; |