History

net: openvswitch: Support masked set actions.

OVS userspace already probes the openvswitch kernel module for OVS_ACTION_ATTR_SET_MASKED support. This patch adds the kernel module implementation of masked set actions. The existing set action sets many fields at once. When only a subset of the IP header fields, for example, should be modified, all the IP fields need to be exact matched so that the other field values can be copied to the set action. A masked set action allows modification of an arbitrary subset of the supported header bits without requiring the rest to be matched. Masked set action is now supported for all writeable key types, except for the tunnel key. The set tunnel action is an exception as any input tunnel info is cleared before action processing starts, so there is no tunnel info to mask. The kernel module converts all (non-tunnel) set actions to masked set actions. This makes action processing more uniform, and results in less branching and duplicating the action processing code. When returning actions to userspace, the fully masked set actions are converted back to normal set actions. We use a kernel internal action code to be able to tell the userspace provided and converted masked set actions apart.

Jarno Rajahalme committed 11 years ago

Commit 83d2b9b1 parent 2150f983 files · +383 −173Browse files

Showing the changes to include/uapi/linux (1 of 3 files). Show all

Unified · Split

include/uapi/linux/openvswitch.h+21−1
@@ -599,6 +599,12 @@ struct ovs_action_hash { · 598 unmodified lines
599599 * @OVS_ACTION_ATTR_SET: Replaces the contents of an existing header. The
600600 * single nested %OVS_KEY_ATTR_* attribute specifies a header to modify and its
601601 * value.
602+ * @OVS_ACTION_ATTR_SET_MASKED: Replaces the contents of an existing header. A
603+ * nested %OVS_KEY_ATTR_* attribute specifies a header to modify, its value,
604+ * and a mask. For every bit set in the mask, the corresponding bit value
605+ * is copied from the value to the packet header field, rest of the bits are
606+ * left unchanged. The non-masked value bits must be passed in as zeroes.
607+ * Masking is not supported for the %OVS_KEY_ATTR_TUNNEL attribute.
602608 * @OVS_ACTION_ATTR_PUSH_VLAN: Push a new outermost 802.1Q header onto the
603609 * packet.
604610 * @OVS_ACTION_ATTR_POP_VLAN: Pop the outermost 802.1Q header off the packet.
@@ -617,6 +623,9 @@ struct ovs_action_hash { · 12 unmodified lines
617623 * Only a single header can be set with a single %OVS_ACTION_ATTR_SET. Not all
618624 * fields within a header are modifiable, e.g. the IPv4 protocol and fragment
619625 * type may not be changed.
626+ *
627+ * @OVS_ACTION_ATTR_SET_TO_MASKED: Kernel internal masked set action translated
628+ * from the @OVS_ACTION_ATTR_SET.
620629 */
621630
622631 enum ovs_action_attr {
@@ -631,8 +640,19 @@ enum ovs_action_attr { · 8 unmodified lines
631640 OVS_ACTION_ATTR_HASH, /* struct ovs_action_hash. */
632641 OVS_ACTION_ATTR_PUSH_MPLS, /* struct ovs_action_push_mpls. */
633642 OVS_ACTION_ATTR_POP_MPLS, /* __be16 ethertype. */
643+ OVS_ACTION_ATTR_SET_MASKED, /* One nested OVS_KEY_ATTR_* including
644+ * data immediately followed by a mask.
645+ * The data must be zero for the unmasked
646+ * bits. */
647+
648+ __OVS_ACTION_ATTR_MAX, /* Nothing past this will be accepted
649+ * from userspace. */
634650
635− __OVS_ACTION_ATTR_MAX
651+#ifdef __KERNEL__
652+ OVS_ACTION_ATTR_SET_TO_MASKED, /* Kernel module internal masked
653+ * set action converted from
654+ * OVS_ACTION_ATTR_SET. */
655+#endif
636656 };
637657
638658 #define OVS_ACTION_ATTR_MAX (__OVS_ACTION_ATTR_MAX - 1)