Blame view

net/openvswitch/conntrack.h 2.83 KB
7f8a436ea   Joe Stringer   openvswitch: Add ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  /*
   * Copyright (c) 2015 Nicira, Inc.
   *
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of version 2 of the GNU General Public
   * License as published by the Free Software Foundation.
   *
   * This program is distributed in the hope that it will be useful, but
   * WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   * General Public License for more details.
   */
  
  #ifndef OVS_CONNTRACK_H
  #define OVS_CONNTRACK_H 1
  
  #include "flow.h"
  
  struct ovs_conntrack_info;
  enum ovs_key_attr;
f88f69dd1   Joe Stringer   openvswitch: Remo...
21
  #if IS_ENABLED(CONFIG_NF_CONNTRACK)
c2ac66735   Joe Stringer   openvswitch: Allo...
22
23
24
  void ovs_ct_init(struct net *);
  void ovs_ct_exit(struct net *);
  bool ovs_ct_verify(struct net *, enum ovs_key_attr attr);
7f8a436ea   Joe Stringer   openvswitch: Add ...
25
26
27
28
29
30
31
32
33
  int ovs_ct_copy_action(struct net *, const struct nlattr *,
  		       const struct sw_flow_key *, struct sw_flow_actions **,
  		       bool log);
  int ovs_ct_action_to_attr(const struct ovs_conntrack_info *, struct sk_buff *);
  
  int ovs_ct_execute(struct net *, struct sk_buff *, struct sw_flow_key *,
  		   const struct ovs_conntrack_info *);
  
  void ovs_ct_fill_key(const struct sk_buff *skb, struct sw_flow_key *key);
9dd7f8907   Jarno Rajahalme   openvswitch: Add ...
34
35
  int ovs_ct_put_key(const struct sw_flow_key *swkey,
  		   const struct sw_flow_key *output, struct sk_buff *skb);
7f8a436ea   Joe Stringer   openvswitch: Add ...
36
  void ovs_ct_free_action(const struct nlattr *a);
6f2259524   Joe Stringer   openvswitch: Reje...
37

9e384715e   Joe Stringer   openvswitch: Reje...
38
39
  #define CT_SUPPORTED_MASK (OVS_CS_F_NEW | OVS_CS_F_ESTABLISHED | \
  			   OVS_CS_F_RELATED | OVS_CS_F_REPLY_DIR | \
05752523e   Jarno Rajahalme   openvswitch: Inte...
40
41
  			   OVS_CS_F_INVALID | OVS_CS_F_TRACKED | \
  			   OVS_CS_F_SRC_NAT | OVS_CS_F_DST_NAT)
7f8a436ea   Joe Stringer   openvswitch: Add ...
42
43
  #else
  #include <linux/errno.h>
c2ac66735   Joe Stringer   openvswitch: Allo...
44
45
46
47
48
  static inline void ovs_ct_init(struct net *net) { }
  
  static inline void ovs_ct_exit(struct net *net) { }
  
  static inline bool ovs_ct_verify(struct net *net, int attr)
7f8a436ea   Joe Stringer   openvswitch: Add ...
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
  {
  	return false;
  }
  
  static inline int ovs_ct_copy_action(struct net *net, const struct nlattr *nla,
  				     const struct sw_flow_key *key,
  				     struct sw_flow_actions **acts, bool log)
  {
  	return -ENOTSUPP;
  }
  
  static inline int ovs_ct_action_to_attr(const struct ovs_conntrack_info *info,
  					struct sk_buff *skb)
  {
  	return -ENOTSUPP;
  }
  
  static inline int ovs_ct_execute(struct net *net, struct sk_buff *skb,
  				 struct sw_flow_key *key,
  				 const struct ovs_conntrack_info *info)
  {
74c166181   Joe Stringer   openvswitch: Fix ...
70
  	kfree_skb(skb);
7f8a436ea   Joe Stringer   openvswitch: Add ...
71
72
73
74
75
76
  	return -ENOTSUPP;
  }
  
  static inline void ovs_ct_fill_key(const struct sk_buff *skb,
  				   struct sw_flow_key *key)
  {
316d4d78c   Jarno Rajahalme   openvswitch: Pack...
77
78
  	key->ct_state = 0;
  	key->ct_zone = 0;
182e3042e   Joe Stringer   openvswitch: Allo...
79
  	key->ct.mark = 0;
33db4125e   Joe Stringer   openvswitch: Rena...
80
  	memset(&key->ct.labels, 0, sizeof(key->ct.labels));
316d4d78c   Jarno Rajahalme   openvswitch: Pack...
81
  	/* Clear 'ct_orig_proto' to mark the non-existence of original
9dd7f8907   Jarno Rajahalme   openvswitch: Add ...
82
83
  	 * direction key fields.
  	 */
316d4d78c   Jarno Rajahalme   openvswitch: Pack...
84
  	key->ct_orig_proto = 0;
7f8a436ea   Joe Stringer   openvswitch: Add ...
85
  }
9dd7f8907   Jarno Rajahalme   openvswitch: Add ...
86
87
  static inline int ovs_ct_put_key(const struct sw_flow_key *swkey,
  				 const struct sw_flow_key *output,
7f8a436ea   Joe Stringer   openvswitch: Add ...
88
89
90
91
92
93
  				 struct sk_buff *skb)
  {
  	return 0;
  }
  
  static inline void ovs_ct_free_action(const struct nlattr *a) { }
9e384715e   Joe Stringer   openvswitch: Reje...
94
95
  
  #define CT_SUPPORTED_MASK 0
f88f69dd1   Joe Stringer   openvswitch: Remo...
96
  #endif /* CONFIG_NF_CONNTRACK */
7f8a436ea   Joe Stringer   openvswitch: Add ...
97
  #endif /* ovs_conntrack.h */