#define pr_fmt(fmt) …
#include "flow.h"
#include "datapath.h"
#include <linux/uaccess.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/if_ether.h>
#include <linux/if_vlan.h>
#include <net/llc_pdu.h>
#include <linux/kernel.h>
#include <linux/jhash.h>
#include <linux/jiffies.h>
#include <linux/llc.h>
#include <linux/module.h>
#include <linux/in.h>
#include <linux/rcupdate.h>
#include <linux/if_arp.h>
#include <linux/ip.h>
#include <linux/ipv6.h>
#include <linux/sctp.h>
#include <linux/tcp.h>
#include <linux/udp.h>
#include <linux/icmp.h>
#include <linux/icmpv6.h>
#include <linux/rculist.h>
#include <net/geneve.h>
#include <net/ip.h>
#include <net/ipv6.h>
#include <net/ndisc.h>
#include <net/mpls.h>
#include <net/vxlan.h>
#include <net/tun_proto.h>
#include <net/erspan.h>
#include "drop.h"
#include "flow_netlink.h"
struct ovs_len_tbl { … };
#define OVS_ATTR_NESTED …
#define OVS_ATTR_VARIABLE …
#define OVS_COPY_ACTIONS_MAX_DEPTH …
static bool actions_may_change_flow(const struct nlattr *actions)
{ … }
static void update_range(struct sw_flow_match *match,
size_t offset, size_t size, bool is_mask)
{ … }
#define SW_FLOW_KEY_PUT(match, field, value, is_mask) …
#define SW_FLOW_KEY_MEMCPY_OFFSET(match, offset, value_p, len, is_mask) …
#define SW_FLOW_KEY_MEMCPY(match, field, value_p, len, is_mask) …
#define SW_FLOW_KEY_MEMSET_FIELD(match, field, value, is_mask) …
#define SW_FLOW_KEY_BITMAP_COPY(match, field, value_p, nbits, is_mask) …
static bool match_validate(const struct sw_flow_match *match,
u64 key_attrs, u64 mask_attrs, bool log)
{ … }
size_t ovs_tun_key_attr_size(void)
{ … }
static size_t ovs_nsh_key_attr_size(void)
{ … }
size_t ovs_key_attr_size(void)
{ … }
static const struct ovs_len_tbl ovs_vxlan_ext_key_lens[OVS_VXLAN_EXT_MAX + 1] = …;
static const struct ovs_len_tbl ovs_tunnel_key_lens[OVS_TUNNEL_KEY_ATTR_MAX + 1] = …;
static const struct ovs_len_tbl
ovs_nsh_key_attr_lens[OVS_NSH_KEY_ATTR_MAX + 1] = …;
static const struct ovs_len_tbl ovs_key_lens[OVS_KEY_ATTR_MAX + 1] = …;
static bool check_attr_len(unsigned int attr_len, unsigned int expected_len)
{ … }
static bool is_all_zero(const u8 *fp, size_t size)
{ … }
static int __parse_flow_nlattrs(const struct nlattr *attr,
const struct nlattr *a[],
u64 *attrsp, bool log, bool nz)
{ … }
static int parse_flow_mask_nlattrs(const struct nlattr *attr,
const struct nlattr *a[], u64 *attrsp,
bool log)
{ … }
int parse_flow_nlattrs(const struct nlattr *attr, const struct nlattr *a[],
u64 *attrsp, bool log)
{ … }
static int genev_tun_opt_from_nlattr(const struct nlattr *a,
struct sw_flow_match *match, bool is_mask,
bool log)
{ … }
static int vxlan_tun_opt_from_nlattr(const struct nlattr *attr,
struct sw_flow_match *match, bool is_mask,
bool log)
{ … }
static int erspan_tun_opt_from_nlattr(const struct nlattr *a,
struct sw_flow_match *match, bool is_mask,
bool log)
{ … }
static int ip_tun_from_nlattr(const struct nlattr *attr,
struct sw_flow_match *match, bool is_mask,
bool log)
{ … }
static int vxlan_opt_to_nlattr(struct sk_buff *skb,
const void *tun_opts, int swkey_tun_opts_len)
{ … }
static int __ip_tun_to_nlattr(struct sk_buff *skb,
const struct ip_tunnel_key *output,
const void *tun_opts, int swkey_tun_opts_len,
unsigned short tun_proto, u8 mode)
{ … }
static int ip_tun_to_nlattr(struct sk_buff *skb,
const struct ip_tunnel_key *output,
const void *tun_opts, int swkey_tun_opts_len,
unsigned short tun_proto, u8 mode)
{ … }
int ovs_nla_put_tunnel_info(struct sk_buff *skb,
struct ip_tunnel_info *tun_info)
{ … }
static int encode_vlan_from_nlattrs(struct sw_flow_match *match,
const struct nlattr *a[],
bool is_mask, bool inner)
{ … }
static int validate_vlan_from_nlattrs(const struct sw_flow_match *match,
u64 key_attrs, bool inner,
const struct nlattr **a, bool log)
{ … }
static int validate_vlan_mask_from_nlattrs(const struct sw_flow_match *match,
u64 key_attrs, bool inner,
const struct nlattr **a, bool log)
{ … }
static int __parse_vlan_from_nlattrs(struct sw_flow_match *match,
u64 *key_attrs, bool inner,
const struct nlattr **a, bool is_mask,
bool log)
{ … }
static int parse_vlan_from_nlattrs(struct sw_flow_match *match,
u64 *key_attrs, const struct nlattr **a,
bool is_mask, bool log)
{ … }
static int parse_eth_type_from_nlattrs(struct sw_flow_match *match,
u64 *attrs, const struct nlattr **a,
bool is_mask, bool log)
{ … }
static int metadata_from_nlattrs(struct net *net, struct sw_flow_match *match,
u64 *attrs, const struct nlattr **a,
bool is_mask, bool log)
{ … }
int nsh_hdr_from_nlattr(const struct nlattr *attr,
struct nshhdr *nh, size_t size)
{ … }
int nsh_key_from_nlattr(const struct nlattr *attr,
struct ovs_key_nsh *nsh, struct ovs_key_nsh *nsh_mask)
{ … }
static int nsh_key_put_from_nlattr(const struct nlattr *attr,
struct sw_flow_match *match, bool is_mask,
bool is_push_nsh, bool log)
{ … }
static int ovs_key_from_nlattrs(struct net *net, struct sw_flow_match *match,
u64 attrs, const struct nlattr **a,
bool is_mask, bool log)
{ … }
static void nlattr_set(struct nlattr *attr, u8 val,
const struct ovs_len_tbl *tbl)
{ … }
static void mask_set_nlattr(struct nlattr *attr, u8 val)
{ … }
int ovs_nla_get_match(struct net *net, struct sw_flow_match *match,
const struct nlattr *nla_key,
const struct nlattr *nla_mask,
bool log)
{ … }
static size_t get_ufid_len(const struct nlattr *attr, bool log)
{ … }
bool ovs_nla_get_ufid(struct sw_flow_id *sfid, const struct nlattr *attr,
bool log)
{ … }
int ovs_nla_get_identifier(struct sw_flow_id *sfid, const struct nlattr *ufid,
const struct sw_flow_key *key, bool log)
{ … }
u32 ovs_nla_get_ufid_flags(const struct nlattr *attr)
{ … }
int ovs_nla_get_flow_metadata(struct net *net,
const struct nlattr *a[OVS_KEY_ATTR_MAX + 1],
u64 attrs, struct sw_flow_key *key, bool log)
{ … }
static int ovs_nla_put_vlan(struct sk_buff *skb, const struct vlan_head *vh,
bool is_mask)
{ … }
static int nsh_key_to_nlattr(const struct ovs_key_nsh *nsh, bool is_mask,
struct sk_buff *skb)
{ … }
static int __ovs_nla_put_key(const struct sw_flow_key *swkey,
const struct sw_flow_key *output, bool is_mask,
struct sk_buff *skb)
{ … }
int ovs_nla_put_key(const struct sw_flow_key *swkey,
const struct sw_flow_key *output, int attr, bool is_mask,
struct sk_buff *skb)
{ … }
int ovs_nla_put_identifier(const struct sw_flow *flow, struct sk_buff *skb)
{ … }
int ovs_nla_put_masked_key(const struct sw_flow *flow, struct sk_buff *skb)
{ … }
int ovs_nla_put_mask(const struct sw_flow *flow, struct sk_buff *skb)
{ … }
#define MAX_ACTIONS_BUFSIZE …
static struct sw_flow_actions *nla_alloc_flow_actions(int size)
{ … }
static void ovs_nla_free_nested_actions(const struct nlattr *actions, int len);
static void ovs_nla_free_check_pkt_len_action(const struct nlattr *action)
{ … }
static void ovs_nla_free_clone_action(const struct nlattr *action)
{ … }
static void ovs_nla_free_dec_ttl_action(const struct nlattr *action)
{ … }
static void ovs_nla_free_sample_action(const struct nlattr *action)
{ … }
static void ovs_nla_free_set_action(const struct nlattr *a)
{ … }
static void ovs_nla_free_nested_actions(const struct nlattr *actions, int len)
{ … }
void ovs_nla_free_flow_actions(struct sw_flow_actions *sf_acts)
{ … }
static void __ovs_nla_free_flow_actions(struct rcu_head *head)
{ … }
void ovs_nla_free_flow_actions_rcu(struct sw_flow_actions *sf_acts)
{ … }
static struct nlattr *reserve_sfa_size(struct sw_flow_actions **sfa,
int attr_len, bool log)
{ … }
static struct nlattr *__add_action(struct sw_flow_actions **sfa,
int attrtype, void *data, int len, bool log)
{ … }
int ovs_nla_add_action(struct sw_flow_actions **sfa, int attrtype, void *data,
int len, bool log)
{ … }
static inline int add_nested_action_start(struct sw_flow_actions **sfa,
int attrtype, bool log)
{ … }
static inline void add_nested_action_end(struct sw_flow_actions *sfa,
int st_offset)
{ … }
static int __ovs_nla_copy_actions(struct net *net, const struct nlattr *attr,
const struct sw_flow_key *key,
struct sw_flow_actions **sfa,
__be16 eth_type, __be16 vlan_tci,
u32 mpls_label_count, bool log,
u32 depth);
static int validate_and_copy_sample(struct net *net, const struct nlattr *attr,
const struct sw_flow_key *key,
struct sw_flow_actions **sfa,
__be16 eth_type, __be16 vlan_tci,
u32 mpls_label_count, bool log, bool last,
u32 depth)
{ … }
static int validate_and_copy_dec_ttl(struct net *net,
const struct nlattr *attr,
const struct sw_flow_key *key,
struct sw_flow_actions **sfa,
__be16 eth_type, __be16 vlan_tci,
u32 mpls_label_count, bool log,
u32 depth)
{ … }
static int validate_and_copy_clone(struct net *net,
const struct nlattr *attr,
const struct sw_flow_key *key,
struct sw_flow_actions **sfa,
__be16 eth_type, __be16 vlan_tci,
u32 mpls_label_count, bool log, bool last,
u32 depth)
{ … }
void ovs_match_init(struct sw_flow_match *match,
struct sw_flow_key *key,
bool reset_key,
struct sw_flow_mask *mask)
{ … }
static int validate_geneve_opts(struct sw_flow_key *key)
{ … }
static int validate_and_copy_set_tun(const struct nlattr *attr,
struct sw_flow_actions **sfa, bool log)
{ … }
static bool validate_nsh(const struct nlattr *attr, bool is_mask,
bool is_push_nsh, bool log)
{ … }
static bool validate_masked(u8 *data, int len)
{ … }
static int validate_set(const struct nlattr *a,
const struct sw_flow_key *flow_key,
struct sw_flow_actions **sfa, bool *skip_copy,
u8 mac_proto, __be16 eth_type, bool masked, bool log)
{ … }
static int validate_userspace(const struct nlattr *attr)
{ … }
static const struct nla_policy cpl_policy[OVS_CHECK_PKT_LEN_ATTR_MAX + 1] = …;
static int validate_and_copy_check_pkt_len(struct net *net,
const struct nlattr *attr,
const struct sw_flow_key *key,
struct sw_flow_actions **sfa,
__be16 eth_type, __be16 vlan_tci,
u32 mpls_label_count,
bool log, bool last, u32 depth)
{ … }
static int validate_psample(const struct nlattr *attr)
{ … }
static int copy_action(const struct nlattr *from,
struct sw_flow_actions **sfa, bool log)
{ … }
static int __ovs_nla_copy_actions(struct net *net, const struct nlattr *attr,
const struct sw_flow_key *key,
struct sw_flow_actions **sfa,
__be16 eth_type, __be16 vlan_tci,
u32 mpls_label_count, bool log,
u32 depth)
{ … }
int ovs_nla_copy_actions(struct net *net, const struct nlattr *attr,
const struct sw_flow_key *key,
struct sw_flow_actions **sfa, bool log)
{ … }
static int sample_action_to_attr(const struct nlattr *attr,
struct sk_buff *skb)
{ … }
static int clone_action_to_attr(const struct nlattr *attr,
struct sk_buff *skb)
{ … }
static int check_pkt_len_action_to_attr(const struct nlattr *attr,
struct sk_buff *skb)
{ … }
static int dec_ttl_action_to_attr(const struct nlattr *attr,
struct sk_buff *skb)
{ … }
static int set_action_to_attr(const struct nlattr *a, struct sk_buff *skb)
{ … }
static int masked_set_action_to_set_action_attr(const struct nlattr *a,
struct sk_buff *skb)
{ … }
int ovs_nla_put_actions(const struct nlattr *attr, int len, struct sk_buff *skb)
{ … }