flow.h (8f0aad6f35f7e8b3118b7b8a65e8e76b135cc4cb) flow.h (12eb18f7115884b0c1513dda31b0051121116b3a)
1/*
2 * Copyright (c) 2007-2014 Nicira, Inc.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of version 2 of the GNU General Public
6 * License as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but

--- 39 unchanged lines hidden (view full) ---

48 u8 ipv4_tos;
49 u8 ipv4_ttl;
50 __be16 tp_src;
51 __be16 tp_dst;
52} __packed __aligned(4); /* Minimize padding. */
53
54struct ovs_tunnel_info {
55 struct ovs_key_ipv4_tunnel tunnel;
1/*
2 * Copyright (c) 2007-2014 Nicira, Inc.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of version 2 of the GNU General Public
6 * License as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but

--- 39 unchanged lines hidden (view full) ---

48 u8 ipv4_tos;
49 u8 ipv4_ttl;
50 __be16 tp_src;
51 __be16 tp_dst;
52} __packed __aligned(4); /* Minimize padding. */
53
54struct ovs_tunnel_info {
55 struct ovs_key_ipv4_tunnel tunnel;
56 struct geneve_opt *options;
56 const struct geneve_opt *options;
57 u8 options_len;
58};
59
60/* Store options at the end of the array if they are less than the
61 * maximum size. This allows us to get the benefits of variable length
62 * matching for small options.
63 */
64#define GENEVE_OPTS(flow_key, opt_len) \
65 ((struct geneve_opt *)((flow_key)->tun_opts + \
66 FIELD_SIZEOF(struct sw_flow_key, tun_opts) - \
67 opt_len))
68
69static inline void __ovs_flow_tun_info_init(struct ovs_tunnel_info *tun_info,
70 __be32 saddr, __be32 daddr,
71 u8 tos, u8 ttl,
72 __be16 tp_src,
73 __be16 tp_dst,
74 __be64 tun_id,
75 __be16 tun_flags,
57 u8 options_len;
58};
59
60/* Store options at the end of the array if they are less than the
61 * maximum size. This allows us to get the benefits of variable length
62 * matching for small options.
63 */
64#define GENEVE_OPTS(flow_key, opt_len) \
65 ((struct geneve_opt *)((flow_key)->tun_opts + \
66 FIELD_SIZEOF(struct sw_flow_key, tun_opts) - \
67 opt_len))
68
69static inline void __ovs_flow_tun_info_init(struct ovs_tunnel_info *tun_info,
70 __be32 saddr, __be32 daddr,
71 u8 tos, u8 ttl,
72 __be16 tp_src,
73 __be16 tp_dst,
74 __be64 tun_id,
75 __be16 tun_flags,
76 struct geneve_opt *opts,
76 const struct geneve_opt *opts,
77 u8 opts_len)
78{
79 tun_info->tunnel.tun_id = tun_id;
80 tun_info->tunnel.ipv4_src = saddr;
81 tun_info->tunnel.ipv4_dst = daddr;
82 tun_info->tunnel.ipv4_tos = tos;
83 tun_info->tunnel.ipv4_ttl = ttl;
84 tun_info->tunnel.tun_flags = tun_flags;

--- 15 unchanged lines hidden (view full) ---

100}
101
102static 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,
77 u8 opts_len)
78{
79 tun_info->tunnel.tun_id = tun_id;
80 tun_info->tunnel.ipv4_src = saddr;
81 tun_info->tunnel.ipv4_dst = daddr;
82 tun_info->tunnel.ipv4_tos = tos;
83 tun_info->tunnel.ipv4_ttl = ttl;
84 tun_info->tunnel.tun_flags = tun_flags;

--- 15 unchanged lines hidden (view full) ---

100}
101
102static 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,
108 const 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}

--- 122 unchanged lines hidden (view full) ---

239 /* Ethernet+IPv4 specific members. */
240 unsigned char ar_sha[ETH_ALEN]; /* sender hardware address */
241 unsigned char ar_sip[4]; /* sender IP address */
242 unsigned char ar_tha[ETH_ALEN]; /* target hardware address */
243 unsigned char ar_tip[4]; /* target IP address */
244} __packed;
245
246void ovs_flow_stats_update(struct sw_flow *, __be16 tcp_flags,
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}

--- 122 unchanged lines hidden (view full) ---

239 /* Ethernet+IPv4 specific members. */
240 unsigned char ar_sha[ETH_ALEN]; /* sender hardware address */
241 unsigned char ar_sip[4]; /* sender IP address */
242 unsigned char ar_tha[ETH_ALEN]; /* target hardware address */
243 unsigned char ar_tip[4]; /* target IP address */
244} __packed;
245
246void ovs_flow_stats_update(struct sw_flow *, __be16 tcp_flags,
247 struct sk_buff *);
247 const struct sk_buff *);
248void ovs_flow_stats_get(const struct sw_flow *, struct ovs_flow_stats *,
249 unsigned long *used, __be16 *tcp_flags);
250void ovs_flow_stats_clear(struct sw_flow *);
251u64 ovs_flow_used_time(unsigned long flow_jiffies);
252
253int ovs_flow_key_update(struct sk_buff *skb, struct sw_flow_key *key);
248void ovs_flow_stats_get(const struct sw_flow *, struct ovs_flow_stats *,
249 unsigned long *used, __be16 *tcp_flags);
250void ovs_flow_stats_clear(struct sw_flow *);
251u64 ovs_flow_used_time(unsigned long flow_jiffies);
252
253int ovs_flow_key_update(struct sk_buff *skb, struct sw_flow_key *key);
254int ovs_flow_key_extract(struct ovs_tunnel_info *tun_info, struct sk_buff *skb,
254int ovs_flow_key_extract(const struct ovs_tunnel_info *tun_info,
255 struct sk_buff *skb,
255 struct sw_flow_key *key);
256/* Extract key from packet coming from userspace. */
257int ovs_flow_key_extract_userspace(const struct nlattr *attr,
258 struct sk_buff *skb,
259 struct sw_flow_key *key);
260
261#endif /* flow.h */
256 struct sw_flow_key *key);
257/* Extract key from packet coming from userspace. */
258int ovs_flow_key_extract_userspace(const struct nlattr *attr,
259 struct sk_buff *skb,
260 struct sw_flow_key *key);
261
262#endif /* flow.h */