Commit 10c24eb2 authored by Ioana Ciornei's avatar Ioana Ciornei Committed by David S. Miller
Browse files

devlink: add parser error drop packet traps



Add parser error drop packet traps, so that capable device driver could
register them with devlink. The new packet trap group holds any drops of
packets which were marked by the device as erroneous during header
parsing. Add documentation for every added packet trap and packet trap
group.

Signed-off-by: default avatarIoana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 34ad9377
Loading
Loading
Loading
Loading
+70 −0
Original line number Diff line number Diff line
@@ -409,6 +409,73 @@ be added to the following table:
     - ``drop``
     - Traps packets dropped due to the RED (Random Early Detection) algorithm
       (i.e., early drops)
   * - ``vxlan_parsing``
     - ``drop``
     - Traps packets dropped due to an error in the VXLAN header parsing which
       might be because of packet truncation or the I flag is not set.
   * - ``llc_snap_parsing``
     - ``drop``
     - Traps packets dropped due to an error in the LLC+SNAP header parsing
   * - ``vlan_parsing``
     - ``drop``
     - Traps packets dropped due to an error in the VLAN header parsing. Could
       include unexpected packet truncation.
   * - ``pppoe_ppp_parsing``
     - ``drop``
     - Traps packets dropped due to an error in the PPPoE+PPP header parsing.
       This could include finding a session ID of 0xFFFF (which is reserved and
       not for use), a PPPoE length which is larger than the frame received or
       any common error on this type of header
   * - ``mpls_parsing``
     - ``drop``
     - Traps packets dropped due to an error in the MPLS header parsing which
       could include unexpected header truncation
   * - ``arp_parsing``
     - ``drop``
     - Traps packets dropped due to an error in the ARP header parsing
   * - ``ip_1_parsing``
     - ``drop``
     - Traps packets dropped due to an error in the first IP header parsing.
       This packet trap could include packets which do not pass an IP checksum
       check, a header length check (a minimum of 20 bytes), which might suffer
       from packet truncation thus the total length field exceeds the received
       packet length etc
   * - ``ip_n_parsing``
     - ``drop``
     - Traps packets dropped due to an error in the parsing of the last IP
       header (the inner one in case of an IP over IP tunnel). The same common
       error checking is performed here as for the ip_1_parsing trap
   * - ``gre_parsing``
     - ``drop``
     - Traps packets dropped due to an error in the GRE header parsing
   * - ``udp_parsing``
     - ``drop``
     - Traps packets dropped due to an error in the UDP header parsing.
       This packet trap could include checksum errorrs, an improper UDP
       length detected (smaller than 8 bytes) or detection of header
       truncation.
   * - ``tcp_parsing``
     - ``drop``
     - Traps packets dropped due to an error in the TCP header parsing.
       This could include TCP checksum errors, improper combination of SYN, FIN
       and/or RESET etc.
   * - ``ipsec_parsing``
     - ``drop``
     - Traps packets dropped due to an error in the IPSEC header parsing
   * - ``sctp_parsing``
     - ``drop``
     - Traps packets dropped due to an error in the SCTP header parsing.
       This would mean that port number 0 was used or that the header is
       truncated.
   * - ``dccp_parsing``
     - ``drop``
     - Traps packets dropped due to an error in the DCCP header parsing
   * - ``gtp_parsing``
     - ``drop``
     - Traps packets dropped due to an error in the GTP header parsing
   * - ``esp_parsing``
     - ``drop``
     - Traps packets dropped due to an error in the ESP header parsing

Driver-specific Packet Traps
============================
@@ -509,6 +576,9 @@ narrow. The description of these groups must be added to the following table:
   * - ``acl_trap``
     - Contains packet traps for packets that were trapped (logged) by the
       device during ACL processing
   * - ``parser_error_drops``
     - Contains packet traps for packets that were marked by the device during
       parsing as erroneous

Packet Trap Policers
====================
+52 −0
Original line number Diff line number Diff line
@@ -784,6 +784,22 @@ enum devlink_trap_generic_id {
	DEVLINK_TRAP_GENERIC_ID_FLOW_ACTION_SAMPLE,
	DEVLINK_TRAP_GENERIC_ID_FLOW_ACTION_TRAP,
	DEVLINK_TRAP_GENERIC_ID_EARLY_DROP,
	DEVLINK_TRAP_GENERIC_ID_VXLAN_PARSING,
	DEVLINK_TRAP_GENERIC_ID_LLC_SNAP_PARSING,
	DEVLINK_TRAP_GENERIC_ID_VLAN_PARSING,
	DEVLINK_TRAP_GENERIC_ID_PPPOE_PPP_PARSING,
	DEVLINK_TRAP_GENERIC_ID_MPLS_PARSING,
	DEVLINK_TRAP_GENERIC_ID_ARP_PARSING,
	DEVLINK_TRAP_GENERIC_ID_IP_1_PARSING,
	DEVLINK_TRAP_GENERIC_ID_IP_N_PARSING,
	DEVLINK_TRAP_GENERIC_ID_GRE_PARSING,
	DEVLINK_TRAP_GENERIC_ID_UDP_PARSING,
	DEVLINK_TRAP_GENERIC_ID_TCP_PARSING,
	DEVLINK_TRAP_GENERIC_ID_IPSEC_PARSING,
	DEVLINK_TRAP_GENERIC_ID_SCTP_PARSING,
	DEVLINK_TRAP_GENERIC_ID_DCCP_PARSING,
	DEVLINK_TRAP_GENERIC_ID_GTP_PARSING,
	DEVLINK_TRAP_GENERIC_ID_ESP_PARSING,

	/* Add new generic trap IDs above */
	__DEVLINK_TRAP_GENERIC_ID_MAX,
@@ -819,6 +835,7 @@ enum devlink_trap_group_generic_id {
	DEVLINK_TRAP_GROUP_GENERIC_ID_PTP_GENERAL,
	DEVLINK_TRAP_GROUP_GENERIC_ID_ACL_SAMPLE,
	DEVLINK_TRAP_GROUP_GENERIC_ID_ACL_TRAP,
	DEVLINK_TRAP_GROUP_GENERIC_ID_PARSER_ERROR_DROPS,

	/* Add new generic trap group IDs above */
	__DEVLINK_TRAP_GROUP_GENERIC_ID_MAX,
@@ -974,6 +991,39 @@ enum devlink_trap_group_generic_id {
	"flow_action_trap"
#define DEVLINK_TRAP_GENERIC_NAME_EARLY_DROP \
	"early_drop"
#define DEVLINK_TRAP_GENERIC_NAME_VXLAN_PARSING \
	"vxlan_parsing"
#define DEVLINK_TRAP_GENERIC_NAME_LLC_SNAP_PARSING \
	"llc_snap_parsing"
#define DEVLINK_TRAP_GENERIC_NAME_VLAN_PARSING \
	"vlan_parsing"
#define DEVLINK_TRAP_GENERIC_NAME_PPPOE_PPP_PARSING \
	"pppoe_ppp_parsing"
#define DEVLINK_TRAP_GENERIC_NAME_MPLS_PARSING \
	"mpls_parsing"
#define DEVLINK_TRAP_GENERIC_NAME_ARP_PARSING \
	"arp_parsing"
#define DEVLINK_TRAP_GENERIC_NAME_IP_1_PARSING \
	"ip_1_parsing"
#define DEVLINK_TRAP_GENERIC_NAME_IP_N_PARSING \
	"ip_n_parsing"
#define DEVLINK_TRAP_GENERIC_NAME_GRE_PARSING \
	"gre_parsing"
#define DEVLINK_TRAP_GENERIC_NAME_UDP_PARSING \
	"udp_parsing"
#define DEVLINK_TRAP_GENERIC_NAME_TCP_PARSING \
	"tcp_parsing"
#define DEVLINK_TRAP_GENERIC_NAME_IPSEC_PARSING \
	"ipsec_parsing"
#define DEVLINK_TRAP_GENERIC_NAME_SCTP_PARSING \
	"sctp_parsing"
#define DEVLINK_TRAP_GENERIC_NAME_DCCP_PARSING \
	"dccp_parsing"
#define DEVLINK_TRAP_GENERIC_NAME_GTP_PARSING \
	"gtp_parsing"
#define DEVLINK_TRAP_GENERIC_NAME_ESP_PARSING \
	"esp_parsing"


#define DEVLINK_TRAP_GROUP_GENERIC_NAME_L2_DROPS \
	"l2_drops"
@@ -1025,6 +1075,8 @@ enum devlink_trap_group_generic_id {
	"acl_sample"
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_ACL_TRAP \
	"acl_trap"
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_PARSER_ERROR_DROPS \
	"parser_error_drops"

#define DEVLINK_TRAP_GENERIC(_type, _init_action, _id, _group_id,	      \
			     _metadata_cap)				      \
+17 −0
Original line number Diff line number Diff line
@@ -8925,6 +8925,22 @@ static const struct devlink_trap devlink_trap_generic[] = {
	DEVLINK_TRAP(FLOW_ACTION_SAMPLE, CONTROL),
	DEVLINK_TRAP(FLOW_ACTION_TRAP, CONTROL),
	DEVLINK_TRAP(EARLY_DROP, DROP),
	DEVLINK_TRAP(VXLAN_PARSING, DROP),
	DEVLINK_TRAP(LLC_SNAP_PARSING, DROP),
	DEVLINK_TRAP(VLAN_PARSING, DROP),
	DEVLINK_TRAP(PPPOE_PPP_PARSING, DROP),
	DEVLINK_TRAP(MPLS_PARSING, DROP),
	DEVLINK_TRAP(ARP_PARSING, DROP),
	DEVLINK_TRAP(IP_1_PARSING, DROP),
	DEVLINK_TRAP(IP_N_PARSING, DROP),
	DEVLINK_TRAP(GRE_PARSING, DROP),
	DEVLINK_TRAP(UDP_PARSING, DROP),
	DEVLINK_TRAP(TCP_PARSING, DROP),
	DEVLINK_TRAP(IPSEC_PARSING, DROP),
	DEVLINK_TRAP(SCTP_PARSING, DROP),
	DEVLINK_TRAP(DCCP_PARSING, DROP),
	DEVLINK_TRAP(GTP_PARSING, DROP),
	DEVLINK_TRAP(ESP_PARSING, DROP),
};

#define DEVLINK_TRAP_GROUP(_id)						      \
@@ -8959,6 +8975,7 @@ static const struct devlink_trap_group devlink_trap_group_generic[] = {
	DEVLINK_TRAP_GROUP(PTP_GENERAL),
	DEVLINK_TRAP_GROUP(ACL_SAMPLE),
	DEVLINK_TRAP_GROUP(ACL_TRAP),
	DEVLINK_TRAP_GROUP(PARSER_ERROR_DROPS),
};

static int devlink_trap_generic_verify(const struct devlink_trap *trap)