History

net: openvswitch: Add a new action check_pkt_len

This patch adds a new action - 'check_pkt_len' which checks the packet length and executes a set of actions if the packet length is greater than the specified length or executes another set of actions if the packet length is lesser or equal to. This action takes below nlattrs * OVS_CHECK_PKT_LEN_ATTR_PKT_LEN - 'pkt_len' to check for * OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_GREATER - Nested actions to apply if the packet length is greater than the specified 'pkt_len' * OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_LESS_EQUAL - Nested actions to apply if the packet length is lesser or equal to the specified 'pkt_len'. The main use case for adding this action is to solve the packet drops because of MTU mismatch in OVN virtual networking solution. When a VM (which belongs to a logical switch of OVN) sends a packet destined to go via the gateway router and if the nic which provides external connectivity, has a lesser MTU, OVS drops the packet if the packet length is greater than this MTU. With the help of this action, OVN will check the packet length and if it is greater than the MTU size, it will generate an ICMP packet (type 3, code 4) and includes the next hop mtu in it so that the sender can fragment the packets.

Numan Siddique committed 7 years ago

Commit 4d5ec891 parent d7aa0333 files · +261 −0Browse files

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

Unified · Split

include/uapi/linux/openvswitch.h+42−0
@@ -798,6 +798,44 @@ struct ovs_action_push_eth { · 797 unmodified lines
798 struct ovs_key_ethernet addresses;798 struct ovs_key_ethernet addresses;
799};799};
800 800
801/*
802 * enum ovs_check_pkt_len_attr - Attributes for %OVS_ACTION_ATTR_CHECK_PKT_LEN.
803 *
804 * @OVS_CHECK_PKT_LEN_ATTR_PKT_LEN: u16 Packet length to check for.
805 * @OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_GREATER: Nested OVS_ACTION_ATTR_*
806 * actions to apply if the packer length is greater than the specified
807 * length in the attr - OVS_CHECK_PKT_LEN_ATTR_PKT_LEN.
808 * @OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_LESS_EQUAL - Nested OVS_ACTION_ATTR_*
809 * actions to apply if the packer length is lesser or equal to the specified
810 * length in the attr - OVS_CHECK_PKT_LEN_ATTR_PKT_LEN.
811 */
812enum ovs_check_pkt_len_attr {
813 OVS_CHECK_PKT_LEN_ATTR_UNSPEC,
814 OVS_CHECK_PKT_LEN_ATTR_PKT_LEN,
815 OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_GREATER,
816 OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_LESS_EQUAL,
817 __OVS_CHECK_PKT_LEN_ATTR_MAX,
818
819#ifdef __KERNEL__
820 OVS_CHECK_PKT_LEN_ATTR_ARG /* struct check_pkt_len_arg */
821#endif
822};
823
824#define OVS_CHECK_PKT_LEN_ATTR_MAX (__OVS_CHECK_PKT_LEN_ATTR_MAX - 1)
825
826#ifdef __KERNEL__
827struct check_pkt_len_arg {
828 u16 pkt_len; /* Same value as OVS_CHECK_PKT_LEN_ATTR_PKT_LEN'. */
829 bool exec_for_greater; /* When true, actions in IF_GREATER will
830 * not change flow keys. False otherwise.
831 */
832 bool exec_for_lesser_equal; /* When true, actions in IF_LESS_EQUAL
833 * will not change flow keys. False
834 * otherwise.
835 */
836};
837#endif
838
801/**839/**
802 * enum ovs_action_attr - Action types.840 * enum ovs_action_attr - Action types.
803 *841 *
@@ -842,6 +880,9 @@ struct ovs_action_push_eth { · 38 unmodified lines
842 * packet, or modify the packet (e.g., change the DSCP field).880 * packet, or modify the packet (e.g., change the DSCP field).
843 * @OVS_ACTION_ATTR_CLONE: make a copy of the packet and execute a list of881 * @OVS_ACTION_ATTR_CLONE: make a copy of the packet and execute a list of
844 * actions without affecting the original packet and key.882 * actions without affecting the original packet and key.
883 * @OVS_ACTION_ATTR_CHECK_PKT_LEN: Check the packet length and execute a set
884 * of actions if greater than the specified packet length, else execute
885 * another set of actions.
845 *886 *
846 * Only a single header can be set with a single %OVS_ACTION_ATTR_SET. Not all887 * Only a single header can be set with a single %OVS_ACTION_ATTR_SET. Not all
847 * fields within a header are modifiable, e.g. the IPv4 protocol and fragment888 * fields within a header are modifiable, e.g. the IPv4 protocol and fragment
@@ -876,6 +917,7 @@ enum ovs_action_attr { · 28 unmodified lines
876 OVS_ACTION_ATTR_POP_NSH, /* No argument. */917 OVS_ACTION_ATTR_POP_NSH, /* No argument. */
877 OVS_ACTION_ATTR_METER, /* u32 meter ID. */918 OVS_ACTION_ATTR_METER, /* u32 meter ID. */
878 OVS_ACTION_ATTR_CLONE, /* Nested OVS_CLONE_ATTR_*. */919 OVS_ACTION_ATTR_CLONE, /* Nested OVS_CLONE_ATTR_*. */
920 OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */
879 921
880 __OVS_ACTION_ATTR_MAX, /* Nothing past this will be accepted922 __OVS_ACTION_ATTR_MAX, /* Nothing past this will be accepted
881 * from userspace. */923 * from userspace. */