mirror of
https://github.com/openvswitch/ovs
synced 2025-10-25 15:07:05 +00:00
sFlow: Genericize/simplify kernel sFlow implementation
Following patch adds sampling action which takes probability and set of actions as arguments. When probability is hit, actions are executed for given packet. USERSPACE action's userdata (u64) is used to store struct user_action_cookie as cookie. CONTROLLER action is fixed accordingly. Now we can remove sFlow code from kernel and implement sFlow generically as SAMPLE action. sFlow is defined as SAMPLE Action with probability (sFlow sampling rate) and USERSPACE action as argument. USERSPACE action's data is used as cookie. sFlow uses this cookie to store output-port, number of output ports and vlan-id. sample-pool is calculated by using vport stats. Signed-off-by: Pravin Shelar <pshelar@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
@@ -99,4 +99,22 @@ int odp_flow_key_from_string(const char *s, struct ofpbuf *);
|
||||
void odp_flow_key_from_flow(struct ofpbuf *, const struct flow *);
|
||||
int odp_flow_key_to_flow(const struct nlattr *, size_t, struct flow *);
|
||||
|
||||
enum user_action_cookie_type {
|
||||
USER_ACTION_COOKIE_UNSPEC,
|
||||
USER_ACTION_COOKIE_CONTROLLER, /* Packet for controller. */
|
||||
USER_ACTION_COOKIE_SFLOW, /* Packet for sFlow sampling. */
|
||||
};
|
||||
|
||||
/* user_action_cookie is passed as argument to OVS_ACTION_ATTR_USERSPACE.
|
||||
* Since is it passed to kernel as u64, its size has to be 8 bytes. */
|
||||
struct user_action_cookie {
|
||||
uint8_t type; /* enum user_action_cookie_type. */
|
||||
uint8_t n_output; /* No of output ports. used by sflow. */
|
||||
ovs_be16 vlan_tci; /* Used by sFlow */
|
||||
uint32_t data; /* Data is len for OFPP_CONTROLLER action.
|
||||
For sFlow it is port_ifindex. */
|
||||
};
|
||||
|
||||
BUILD_ASSERT_DECL(sizeof(struct user_action_cookie) == 8);
|
||||
|
||||
#endif /* odp-util.h */
|
||||
|
||||
Reference in New Issue
Block a user