xref: /OK3568_Linux_fs/kernel/net/openvswitch/flow_netlink.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-only */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Copyright (c) 2007-2013 Nicira, Inc.
4*4882a593Smuzhiyun  */
5*4882a593Smuzhiyun 
6*4882a593Smuzhiyun 
7*4882a593Smuzhiyun #ifndef FLOW_NETLINK_H
8*4882a593Smuzhiyun #define FLOW_NETLINK_H 1
9*4882a593Smuzhiyun 
10*4882a593Smuzhiyun #include <linux/kernel.h>
11*4882a593Smuzhiyun #include <linux/netlink.h>
12*4882a593Smuzhiyun #include <linux/openvswitch.h>
13*4882a593Smuzhiyun #include <linux/spinlock.h>
14*4882a593Smuzhiyun #include <linux/types.h>
15*4882a593Smuzhiyun #include <linux/rcupdate.h>
16*4882a593Smuzhiyun #include <linux/if_ether.h>
17*4882a593Smuzhiyun #include <linux/in6.h>
18*4882a593Smuzhiyun #include <linux/jiffies.h>
19*4882a593Smuzhiyun #include <linux/time.h>
20*4882a593Smuzhiyun 
21*4882a593Smuzhiyun #include <net/inet_ecn.h>
22*4882a593Smuzhiyun #include <net/ip_tunnels.h>
23*4882a593Smuzhiyun 
24*4882a593Smuzhiyun #include "flow.h"
25*4882a593Smuzhiyun 
26*4882a593Smuzhiyun size_t ovs_tun_key_attr_size(void);
27*4882a593Smuzhiyun size_t ovs_key_attr_size(void);
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun void ovs_match_init(struct sw_flow_match *match,
30*4882a593Smuzhiyun 		    struct sw_flow_key *key, bool reset_key,
31*4882a593Smuzhiyun 		    struct sw_flow_mask *mask);
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun int ovs_nla_put_key(const struct sw_flow_key *, const struct sw_flow_key *,
34*4882a593Smuzhiyun 		    int attr, bool is_mask, struct sk_buff *);
35*4882a593Smuzhiyun int parse_flow_nlattrs(const struct nlattr *attr, const struct nlattr *a[],
36*4882a593Smuzhiyun 		       u64 *attrsp, bool log);
37*4882a593Smuzhiyun int ovs_nla_get_flow_metadata(struct net *net,
38*4882a593Smuzhiyun 			      const struct nlattr *a[OVS_KEY_ATTR_MAX + 1],
39*4882a593Smuzhiyun 			      u64 attrs, struct sw_flow_key *key, bool log);
40*4882a593Smuzhiyun 
41*4882a593Smuzhiyun int ovs_nla_put_identifier(const struct sw_flow *flow, struct sk_buff *skb);
42*4882a593Smuzhiyun int ovs_nla_put_masked_key(const struct sw_flow *flow, struct sk_buff *skb);
43*4882a593Smuzhiyun int ovs_nla_put_mask(const struct sw_flow *flow, struct sk_buff *skb);
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun int ovs_nla_get_match(struct net *, struct sw_flow_match *,
46*4882a593Smuzhiyun 		      const struct nlattr *key, const struct nlattr *mask,
47*4882a593Smuzhiyun 		      bool log);
48*4882a593Smuzhiyun 
49*4882a593Smuzhiyun int ovs_nla_put_tunnel_info(struct sk_buff *skb,
50*4882a593Smuzhiyun 			    struct ip_tunnel_info *tun_info);
51*4882a593Smuzhiyun 
52*4882a593Smuzhiyun bool ovs_nla_get_ufid(struct sw_flow_id *, const struct nlattr *, bool log);
53*4882a593Smuzhiyun int ovs_nla_get_identifier(struct sw_flow_id *sfid, const struct nlattr *ufid,
54*4882a593Smuzhiyun 			   const struct sw_flow_key *key, bool log);
55*4882a593Smuzhiyun u32 ovs_nla_get_ufid_flags(const struct nlattr *attr);
56*4882a593Smuzhiyun 
57*4882a593Smuzhiyun int ovs_nla_copy_actions(struct net *net, const struct nlattr *attr,
58*4882a593Smuzhiyun 			 const struct sw_flow_key *key,
59*4882a593Smuzhiyun 			 struct sw_flow_actions **sfa, bool log);
60*4882a593Smuzhiyun int ovs_nla_add_action(struct sw_flow_actions **sfa, int attrtype,
61*4882a593Smuzhiyun 		       void *data, int len, bool log);
62*4882a593Smuzhiyun int ovs_nla_put_actions(const struct nlattr *attr,
63*4882a593Smuzhiyun 			int len, struct sk_buff *skb);
64*4882a593Smuzhiyun 
65*4882a593Smuzhiyun void ovs_nla_free_flow_actions(struct sw_flow_actions *);
66*4882a593Smuzhiyun void ovs_nla_free_flow_actions_rcu(struct sw_flow_actions *);
67*4882a593Smuzhiyun 
68*4882a593Smuzhiyun int nsh_key_from_nlattr(const struct nlattr *attr, struct ovs_key_nsh *nsh,
69*4882a593Smuzhiyun 			struct ovs_key_nsh *nsh_mask);
70*4882a593Smuzhiyun int nsh_hdr_from_nlattr(const struct nlattr *attr, struct nshhdr *nh,
71*4882a593Smuzhiyun 			size_t size);
72*4882a593Smuzhiyun 
73*4882a593Smuzhiyun #endif /* flow_netlink.h */
74