2015-08-27 02:31:48 +08:00
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
|
2015-09-05 04:07:40 +08:00
|
|
|
#if IS_ENABLED(CONFIG_NF_CONNTRACK)
|
2015-08-27 02:31:52 +08:00
|
|
|
void ovs_ct_init(struct net *);
|
|
|
|
void ovs_ct_exit(struct net *);
|
|
|
|
bool ovs_ct_verify(struct net *, enum ovs_key_attr attr);
|
2015-08-27 02:31:48 +08:00
|
|
|
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);
|
|
|
|
int ovs_ct_put_key(const struct sw_flow_key *key, struct sk_buff *skb);
|
|
|
|
void ovs_ct_free_action(const struct nlattr *a);
|
2015-10-07 01:59:59 +08:00
|
|
|
|
2015-10-07 02:00:00 +08:00
|
|
|
static inline bool ovs_ct_state_supported(u32 state)
|
2015-10-07 01:59:59 +08:00
|
|
|
{
|
|
|
|
return !(state & ~(OVS_CS_F_NEW | OVS_CS_F_ESTABLISHED |
|
|
|
|
OVS_CS_F_RELATED | OVS_CS_F_REPLY_DIR |
|
|
|
|
OVS_CS_F_INVALID | OVS_CS_F_TRACKED));
|
|
|
|
}
|
2015-08-27 02:31:48 +08:00
|
|
|
#else
|
|
|
|
#include <linux/errno.h>
|
|
|
|
|
2015-08-27 02:31:52 +08:00
|
|
|
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)
|
2015-08-27 02:31:48 +08:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-10-07 02:00:00 +08:00
|
|
|
static inline bool ovs_ct_state_supported(u32 state)
|
2015-10-07 01:59:59 +08:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-08-27 02:31:48 +08:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
return -ENOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void ovs_ct_fill_key(const struct sk_buff *skb,
|
|
|
|
struct sw_flow_key *key)
|
|
|
|
{
|
|
|
|
key->ct.state = 0;
|
|
|
|
key->ct.zone = 0;
|
2015-08-27 02:31:49 +08:00
|
|
|
key->ct.mark = 0;
|
2015-10-02 06:00:37 +08:00
|
|
|
memset(&key->ct.labels, 0, sizeof(key->ct.labels));
|
2015-08-27 02:31:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int ovs_ct_put_key(const struct sw_flow_key *key,
|
|
|
|
struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void ovs_ct_free_action(const struct nlattr *a) { }
|
2015-09-05 04:07:40 +08:00
|
|
|
#endif /* CONFIG_NF_CONNTRACK */
|
2015-08-27 02:31:48 +08:00
|
|
|
#endif /* ovs_conntrack.h */
|