#include <net/ipv6.h>
 #include <net/tcp.h>
 #include <linux/sock_diag.h>
+#include <net/rstreason.h>
 
 /*
  * tcp event with arguments sk and skb
        TP_ARGS(sk, skb)
 );
 
+#undef FN
+#define FN(reason)     TRACE_DEFINE_ENUM(SK_RST_REASON_##reason);
+DEFINE_RST_REASON(FN, FN)
+
+#undef FN
+#undef FNe
+#define FN(reason)     { SK_RST_REASON_##reason, #reason },
+#define FNe(reason)    { SK_RST_REASON_##reason, #reason }
+
 /*
  * skb of trace_tcp_send_reset is the skb that caused RST. In case of
  * active reset, skb should be NULL
  */
 TRACE_EVENT(tcp_send_reset,
 
-       TP_PROTO(const struct sock *sk, const struct sk_buff *skb),
+       TP_PROTO(const struct sock *sk,
+                const struct sk_buff *skb,
+                const enum sk_rst_reason reason),
 
-       TP_ARGS(sk, skb),
+       TP_ARGS(sk, skb, reason),
 
        TP_STRUCT__entry(
                __field(const void *, skbaddr)
                __field(const void *, skaddr)
                __field(int, state)
+               __field(enum sk_rst_reason, reason)
                __array(__u8, saddr, sizeof(struct sockaddr_in6))
                __array(__u8, daddr, sizeof(struct sockaddr_in6))
        ),
                         */
                        TP_STORE_ADDR_PORTS_SKB(skb, th, entry->daddr, entry->saddr);
                }
+               __entry->reason = reason;
        ),
 
-       TP_printk("skbaddr=%p skaddr=%p src=%pISpc dest=%pISpc state=%s",
+       TP_printk("skbaddr=%p skaddr=%p src=%pISpc dest=%pISpc state=%s reason=%s",
                  __entry->skbaddr, __entry->skaddr,
                  __entry->saddr, __entry->daddr,
-                 __entry->state ? show_tcp_state_name(__entry->state) : "UNKNOWN")
+                 __entry->state ? show_tcp_state_name(__entry->state) : "UNKNOWN",
+                 __print_symbolic(__entry->reason, DEFINE_RST_REASON(FN, FNe)))
 );
 
+#undef FN
+#undef FNe
+
 /*
  * tcp event with arguments sk
  *
 
                        label = ip6_flowlabel(ipv6h);
        }
 
-       trace_tcp_send_reset(sk, skb);
+       trace_tcp_send_reset(sk, skb, reason);
 
        tcp_v6_send_response(sk, skb, seq, ack_seq, 0, 0, 0, oif, 1,
                             ipv6_get_dsfield(ipv6h), label, priority, txhash,