1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 3 #ifndef _LINUX_RSTREASON_H 4 #define _LINUX_RSTREASON_H 5 #include <net/dropreason-core.h> 6 #include <uapi/linux/mptcp.h> 7 8 #define DEFINE_RST_REASON(FN, FNe) \ 9 FN(NOT_SPECIFIED) \ 10 FN(NO_SOCKET) \ 11 FN(MPTCP_RST_EUNSPEC) \ 12 FN(MPTCP_RST_EMPTCP) \ 13 FN(MPTCP_RST_ERESOURCE) \ 14 FN(MPTCP_RST_EPROHIBIT) \ 15 FN(MPTCP_RST_EWQ2BIG) \ 16 FN(MPTCP_RST_EBADPERF) \ 17 FN(MPTCP_RST_EMIDDLEBOX) \ 18 FN(ERROR) \ 19 FNe(MAX) 20 21 /** 22 * enum sk_rst_reason - the reasons of socket reset 23 * 24 * The reasons of sk reset, which are used in DCCP/TCP/MPTCP protocols. 25 * 26 * There are three parts in order: 27 * 1) skb drop reasons: relying on drop reasons for such as passive reset 28 * 2) independent reset reasons: such as active reset reasons 29 * 3) reset reasons in MPTCP: only for MPTCP use 30 */ 31 enum sk_rst_reason { 32 /* Refer to include/net/dropreason-core.h 33 * Rely on skb drop reasons because it indicates exactly why RST 34 * could happen. 35 */ 36 /** @SK_RST_REASON_NOT_SPECIFIED: reset reason is not specified */ 37 SK_RST_REASON_NOT_SPECIFIED, 38 /** @SK_RST_REASON_NO_SOCKET: no valid socket that can be used */ 39 SK_RST_REASON_NO_SOCKET, 40 41 /* Copy from include/uapi/linux/mptcp.h. 42 * These reset fields will not be changed since they adhere to 43 * RFC 8684. So do not touch them. I'm going to list each definition 44 * of them respectively. 45 */ 46 /** 47 * @SK_RST_REASON_MPTCP_RST_EUNSPEC: Unspecified error. 48 * This is the default error; it implies that the subflow is no 49 * longer available. The presence of this option shows that the 50 * RST was generated by an MPTCP-aware device. 51 */ 52 SK_RST_REASON_MPTCP_RST_EUNSPEC, 53 /** 54 * @SK_RST_REASON_MPTCP_RST_EMPTCP: MPTCP-specific error. 55 * An error has been detected in the processing of MPTCP options. 56 * This is the usual reason code to return in the cases where a RST 57 * is being sent to close a subflow because of an invalid response. 58 */ 59 SK_RST_REASON_MPTCP_RST_EMPTCP, 60 /** 61 * @SK_RST_REASON_MPTCP_RST_ERESOURCE: Lack of resources. 62 * This code indicates that the sending host does not have enough 63 * resources to support the terminated subflow. 64 */ 65 SK_RST_REASON_MPTCP_RST_ERESOURCE, 66 /** 67 * @SK_RST_REASON_MPTCP_RST_EPROHIBIT: Administratively prohibited. 68 * This code indicates that the requested subflow is prohibited by 69 * the policies of the sending host. 70 */ 71 SK_RST_REASON_MPTCP_RST_EPROHIBIT, 72 /** 73 * @SK_RST_REASON_MPTCP_RST_EWQ2BIG: Too much outstanding data. 74 * This code indicates that there is an excessive amount of data 75 * that needs to be transmitted over the terminated subflow while 76 * having already been acknowledged over one or more other subflows. 77 * This may occur if a path has been unavailable for a short period 78 * and it is more efficient to reset and start again than it is to 79 * retransmit the queued data. 80 */ 81 SK_RST_REASON_MPTCP_RST_EWQ2BIG, 82 /** 83 * @SK_RST_REASON_MPTCP_RST_EBADPERF: Unacceptable performance. 84 * This code indicates that the performance of this subflow was 85 * too low compared to the other subflows of this Multipath TCP 86 * connection. 87 */ 88 SK_RST_REASON_MPTCP_RST_EBADPERF, 89 /** 90 * @SK_RST_REASON_MPTCP_RST_EMIDDLEBOX: Middlebox interference. 91 * Middlebox interference has been detected over this subflow, 92 * making MPTCP signaling invalid. For example, this may be sent 93 * if the checksum does not validate. 94 */ 95 SK_RST_REASON_MPTCP_RST_EMIDDLEBOX, 96 97 /** @SK_RST_REASON_ERROR: unexpected error happens */ 98 SK_RST_REASON_ERROR, 99 100 /** 101 * @SK_RST_REASON_MAX: Maximum of socket reset reasons. 102 * It shouldn't be used as a real 'reason'. 103 */ 104 SK_RST_REASON_MAX, 105 }; 106 107 /* Convert skb drop reasons to enum sk_rst_reason type */ 108 static inline enum sk_rst_reason 109 sk_rst_convert_drop_reason(enum skb_drop_reason reason) 110 { 111 switch (reason) { 112 case SKB_DROP_REASON_NOT_SPECIFIED: 113 return SK_RST_REASON_NOT_SPECIFIED; 114 case SKB_DROP_REASON_NO_SOCKET: 115 return SK_RST_REASON_NO_SOCKET; 116 default: 117 /* If we don't have our own corresponding reason */ 118 return SK_RST_REASON_NOT_SPECIFIED; 119 } 120 } 121 #endif 122