|
|
97e186 |
From c6ed1e1af9356cdce1eaa652061dd6e4eb32d283 Mon Sep 17 00:00:00 2001
|
|
|
97e186 |
From: Junliang Li <lijunliang.dna@gmail.com>
|
|
|
97e186 |
Date: Thu, 13 Feb 2014 10:39:53 +0800
|
|
|
97e186 |
Subject: [PATCH 23/32] add abrt suppport for rasdaemon
|
|
|
97e186 |
|
|
|
97e186 |
Adds abrt as another error mechanism for the rasdaemon.
|
|
|
97e186 |
This patch does:
|
|
|
97e186 |
|
|
|
97e186 |
1) read ras event (mc,mce and aer)
|
|
|
97e186 |
|
|
|
97e186 |
2) setup a abrt-server unix socket
|
|
|
97e186 |
|
|
|
97e186 |
3) write messages follow ABRT server protocol, set event
|
|
|
97e186 |
info into backtrace zone.
|
|
|
97e186 |
|
|
|
97e186 |
4) commit report.
|
|
|
97e186 |
|
|
|
97e186 |
For now, it depends on ABRT to limit flood reports.
|
|
|
97e186 |
|
|
|
97e186 |
Signed-off-by: Junliang Li <lijunliang.dna@gmail.com>
|
|
|
97e186 |
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
|
|
|
97e186 |
---
|
|
|
97e186 |
Makefile.am | 5 +-
|
|
|
97e186 |
configure.ac | 9 +
|
|
|
97e186 |
ras-aer-handler.c | 6 +
|
|
|
97e186 |
ras-events.h | 3 +
|
|
|
97e186 |
ras-mc-handler.c | 7 +
|
|
|
97e186 |
ras-mce-handler.c | 6 +
|
|
|
97e186 |
ras-report.c | 429 +++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
97e186 |
ras-report.h | 39 +++++
|
|
|
97e186 |
8 files changed, 503 insertions(+), 1 deletions(-)
|
|
|
97e186 |
create mode 100644 ras-report.c
|
|
|
97e186 |
create mode 100644 ras-report.h
|
|
|
97e186 |
|
|
|
97e186 |
diff --git a/Makefile.am b/Makefile.am
|
|
|
97e186 |
index 473ce98..c1668b4 100644
|
|
|
97e186 |
--- a/Makefile.am
|
|
|
97e186 |
+++ b/Makefile.am
|
|
|
97e186 |
@@ -17,10 +17,13 @@ if WITH_MCE
|
|
|
97e186 |
mce-intel-dunnington.c mce-intel-tulsa.c \
|
|
|
97e186 |
mce-intel-sb.c mce-intel-ivb.c
|
|
|
97e186 |
endif
|
|
|
97e186 |
+if WITH_ABRT_REPORT
|
|
|
97e186 |
+ rasdaemon_SOURCES += ras-report.c
|
|
|
97e186 |
+endif
|
|
|
97e186 |
rasdaemon_LDADD = -lpthread $(SQLITE3_LIBS) libtrace/libtrace.a
|
|
|
97e186 |
|
|
|
97e186 |
include_HEADERS = config.h ras-events.h ras-logger.h ras-mc-handler.h \
|
|
|
97e186 |
- ras-aer-handler.h ras-mce-handler.h ras-record.h bitfield.h
|
|
|
97e186 |
+ ras-aer-handler.h ras-mce-handler.h ras-record.h bitfield.h ras-report.h
|
|
|
97e186 |
|
|
|
97e186 |
# This rule can't be called with more than one Makefile job (like make -j8)
|
|
|
97e186 |
# I can't figure out a way to fix that
|
|
|
97e186 |
diff --git a/configure.ac b/configure.ac
|
|
|
97e186 |
index 4fe6ef2..0ea962e 100644
|
|
|
97e186 |
--- a/configure.ac
|
|
|
97e186 |
+++ b/configure.ac
|
|
|
97e186 |
@@ -53,6 +53,15 @@ AS_IF([test "x$enable_mce" = "xyes"], [
|
|
|
97e186 |
])
|
|
|
97e186 |
AM_CONDITIONAL([WITH_MCE], [test x$enable_mce = xyes])
|
|
|
97e186 |
|
|
|
97e186 |
+AC_ARG_ENABLE([abrt_report],
|
|
|
97e186 |
+ AS_HELP_STRING([--enable-abrt-report], [enable report event to ABRT (currently experimental)]))
|
|
|
97e186 |
+
|
|
|
97e186 |
+AS_IF([test "x$enable_abrt_report" = "xyes"], [
|
|
|
97e186 |
+ AC_DEFINE(HAVE_ABRT_REPORT,1,"have report event to ABRT")
|
|
|
97e186 |
+ AC_SUBST([WITH_ABRT_REPORT])
|
|
|
97e186 |
+])
|
|
|
97e186 |
+AM_CONDITIONAL([WITH_ABRT_REPORT], [test x$enable_abrt_report = xyes])
|
|
|
97e186 |
+
|
|
|
97e186 |
test "$sysconfdir" = '${prefix}/etc' && sysconfdir=/etc
|
|
|
97e186 |
|
|
|
97e186 |
CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wstrict-prototypes"
|
|
|
97e186 |
diff --git a/ras-aer-handler.c b/ras-aer-handler.c
|
|
|
97e186 |
index e5abaca..50526af 100644
|
|
|
97e186 |
--- a/ras-aer-handler.c
|
|
|
97e186 |
+++ b/ras-aer-handler.c
|
|
|
97e186 |
@@ -24,6 +24,7 @@
|
|
|
97e186 |
#include "ras-record.h"
|
|
|
97e186 |
#include "ras-logger.h"
|
|
|
97e186 |
#include "bitfield.h"
|
|
|
97e186 |
+#include "ras-report.h"
|
|
|
97e186 |
|
|
|
97e186 |
static const char *aer_errors[32] = {
|
|
|
97e186 |
/* Correctable errors */
|
|
|
97e186 |
@@ -115,5 +116,10 @@ int ras_aer_event_handler(struct trace_seq *s,
|
|
|
97e186 |
ras_store_aer_event(ras, &ev;;
|
|
|
97e186 |
#endif
|
|
|
97e186 |
|
|
|
97e186 |
+#ifdef HAVE_ABRT_REPORT
|
|
|
97e186 |
+ /* Report event to ABRT */
|
|
|
97e186 |
+ ras_report_aer_event(ras, &ev;;
|
|
|
97e186 |
+#endif
|
|
|
97e186 |
+
|
|
|
97e186 |
return 0;
|
|
|
97e186 |
}
|
|
|
97e186 |
diff --git a/ras-events.h b/ras-events.h
|
|
|
97e186 |
index 554a95e..64e045a 100644
|
|
|
97e186 |
--- a/ras-events.h
|
|
|
97e186 |
+++ b/ras-events.h
|
|
|
97e186 |
@@ -47,6 +47,9 @@ struct ras_events {
|
|
|
97e186 |
|
|
|
97e186 |
/* For the mce handler */
|
|
|
97e186 |
struct mce_priv *mce_priv;
|
|
|
97e186 |
+
|
|
|
97e186 |
+ /* For ABRT socket*/
|
|
|
97e186 |
+ int socketfd;
|
|
|
97e186 |
};
|
|
|
97e186 |
|
|
|
97e186 |
struct pthread_data {
|
|
|
97e186 |
diff --git a/ras-mc-handler.c b/ras-mc-handler.c
|
|
|
97e186 |
index 5c24f65..ffb3805 100644
|
|
|
97e186 |
--- a/ras-mc-handler.c
|
|
|
97e186 |
+++ b/ras-mc-handler.c
|
|
|
97e186 |
@@ -23,6 +23,7 @@
|
|
|
97e186 |
#include "ras-mc-handler.h"
|
|
|
97e186 |
#include "ras-record.h"
|
|
|
97e186 |
#include "ras-logger.h"
|
|
|
97e186 |
+#include "ras-report.h"
|
|
|
97e186 |
|
|
|
97e186 |
int ras_mc_event_handler(struct trace_seq *s,
|
|
|
97e186 |
struct pevent_record *record,
|
|
|
97e186 |
@@ -189,6 +190,12 @@ int ras_mc_event_handler(struct trace_seq *s,
|
|
|
97e186 |
/* Insert data into the SGBD */
|
|
|
97e186 |
|
|
|
97e186 |
ras_store_mc_event(ras, &ev;;
|
|
|
97e186 |
+
|
|
|
97e186 |
+#ifdef HAVE_ABRT_REPORT
|
|
|
97e186 |
+ /* Report event to ABRT */
|
|
|
97e186 |
+ ras_report_mc_event(ras, &ev;;
|
|
|
97e186 |
+#endif
|
|
|
97e186 |
+
|
|
|
97e186 |
return 0;
|
|
|
97e186 |
|
|
|
97e186 |
parse_error:
|
|
|
97e186 |
diff --git a/ras-mce-handler.c b/ras-mce-handler.c
|
|
|
97e186 |
index 59e8d05..1431049 100644
|
|
|
97e186 |
--- a/ras-mce-handler.c
|
|
|
97e186 |
+++ b/ras-mce-handler.c
|
|
|
97e186 |
@@ -26,6 +26,7 @@
|
|
|
97e186 |
#include "ras-mce-handler.h"
|
|
|
97e186 |
#include "ras-record.h"
|
|
|
97e186 |
#include "ras-logger.h"
|
|
|
97e186 |
+#include "ras-report.h"
|
|
|
97e186 |
|
|
|
97e186 |
/*
|
|
|
97e186 |
* The code below were adapted from Andi Kleen/Intel/SuSe mcelog code,
|
|
|
97e186 |
@@ -401,5 +402,10 @@ int ras_mce_event_handler(struct trace_seq *s,
|
|
|
97e186 |
ras_store_mce_record(ras, &e);
|
|
|
97e186 |
#endif
|
|
|
97e186 |
|
|
|
97e186 |
+#ifdef HAVE_ABRT_REPORT
|
|
|
97e186 |
+ /* Report event to ABRT */
|
|
|
97e186 |
+ ras_report_mce_event(ras, &e);
|
|
|
97e186 |
+#endif
|
|
|
97e186 |
+
|
|
|
97e186 |
return 0;
|
|
|
97e186 |
}
|
|
|
97e186 |
diff --git a/ras-report.c b/ras-report.c
|
|
|
97e186 |
new file mode 100644
|
|
|
97e186 |
index 0000000..d3e4a79
|
|
|
97e186 |
--- /dev/null
|
|
|
97e186 |
+++ b/ras-report.c
|
|
|
97e186 |
@@ -0,0 +1,429 @@
|
|
|
97e186 |
+#include <stdio.h>
|
|
|
97e186 |
+#include <string.h>
|
|
|
97e186 |
+#include <unistd.h>
|
|
|
97e186 |
+#include <sys/types.h>
|
|
|
97e186 |
+#include <sys/utsname.h>
|
|
|
97e186 |
+#include <sys/socket.h>
|
|
|
97e186 |
+#include <sys/un.h>
|
|
|
97e186 |
+
|
|
|
97e186 |
+#include "ras-report.h"
|
|
|
97e186 |
+
|
|
|
97e186 |
+static int setup_report_socket(void){
|
|
|
97e186 |
+ int sockfd = -1;
|
|
|
97e186 |
+ int rc = -1;
|
|
|
97e186 |
+ struct sockaddr_un addr;
|
|
|
97e186 |
+
|
|
|
97e186 |
+ sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
|
|
|
97e186 |
+ if (sockfd < 0){
|
|
|
97e186 |
+ return -1;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ memset(&addr, 0, sizeof(struct sockaddr_un));
|
|
|
97e186 |
+ addr.sun_family = AF_UNIX;
|
|
|
97e186 |
+ strncpy(addr.sun_path, ABRT_SOCKET, strlen(ABRT_SOCKET));
|
|
|
97e186 |
+
|
|
|
97e186 |
+ rc = connect(sockfd, (struct sockaddr *)&addr, sizeof(struct sockaddr_un));
|
|
|
97e186 |
+ if (rc < 0){
|
|
|
97e186 |
+ return -1;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ return sockfd;
|
|
|
97e186 |
+}
|
|
|
97e186 |
+
|
|
|
97e186 |
+static int commit_report_basic(int sockfd){
|
|
|
97e186 |
+ char buf[INPUT_BUFFER_SIZE];
|
|
|
97e186 |
+ struct utsname un;
|
|
|
97e186 |
+ int rc = -1;
|
|
|
97e186 |
+
|
|
|
97e186 |
+ if(sockfd < 0){
|
|
|
97e186 |
+ return rc;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ memset(buf, 0, INPUT_BUFFER_SIZE);
|
|
|
97e186 |
+ memset(&un, 0, sizeof(struct utsname));
|
|
|
97e186 |
+
|
|
|
97e186 |
+ rc = uname(&un;;
|
|
|
97e186 |
+ if(rc < 0){
|
|
|
97e186 |
+ return rc;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ /*
|
|
|
97e186 |
+ * ABRT server protocol
|
|
|
97e186 |
+ */
|
|
|
97e186 |
+ sprintf(buf, "PUT / HTTP/1.1\r\n\r\n");
|
|
|
97e186 |
+ rc = write(sockfd, buf, strlen(buf) + 1);
|
|
|
97e186 |
+ if(rc < strlen(buf) + 1){
|
|
|
97e186 |
+ return -1;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ sprintf(buf, "PID=%d", (int)getpid());
|
|
|
97e186 |
+ rc = write(sockfd, buf, strlen(buf) + 1);
|
|
|
97e186 |
+ if(rc < strlen(buf) + 1){
|
|
|
97e186 |
+ return -1;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ sprintf(buf, "EXECUTABLE=/boot/vmlinuz-%s", un.release);
|
|
|
97e186 |
+ rc = write(sockfd, buf, strlen(buf) + 1);
|
|
|
97e186 |
+ if(rc < strlen(buf) + 1){
|
|
|
97e186 |
+ return -1;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ sprintf(buf, "BASENAME=%s", "rasdaemon");
|
|
|
97e186 |
+ rc = write(sockfd, buf, strlen(buf) + 1);
|
|
|
97e186 |
+ if(rc < strlen(buf) + 1){
|
|
|
97e186 |
+ return -1;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ return 0;
|
|
|
97e186 |
+}
|
|
|
97e186 |
+
|
|
|
97e186 |
+/*
|
|
|
97e186 |
+ * add "DONE" string to finish message.
|
|
|
97e186 |
+ */
|
|
|
97e186 |
+static int commit_report_done(int sockfd){
|
|
|
97e186 |
+ int rc = -1;
|
|
|
97e186 |
+
|
|
|
97e186 |
+ if(sockfd < 0){
|
|
|
97e186 |
+ return -1;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ rc = write(sockfd, "DONE\0", strlen("DONE\0"));
|
|
|
97e186 |
+ if(rc < strlen("DONE\0")){
|
|
|
97e186 |
+ return -1;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ return 0;
|
|
|
97e186 |
+}
|
|
|
97e186 |
+
|
|
|
97e186 |
+static int set_mc_event_backtrace(char *buf, struct ras_mc_event *ev){
|
|
|
97e186 |
+ char bt_buf[MAX_BACKTRACE_SIZE];
|
|
|
97e186 |
+
|
|
|
97e186 |
+ if(!buf || !ev)
|
|
|
97e186 |
+ return -1;
|
|
|
97e186 |
+
|
|
|
97e186 |
+ sprintf(bt_buf, "BACKTRACE= " \
|
|
|
97e186 |
+ "timestamp=%s\n" \
|
|
|
97e186 |
+ "error_count=%d\n" \
|
|
|
97e186 |
+ "error_type=%s\n" \
|
|
|
97e186 |
+ "msg=%s\n" \
|
|
|
97e186 |
+ "label=%s\n" \
|
|
|
97e186 |
+ "mc_index=%c\n" \
|
|
|
97e186 |
+ "top_layer=%c\n" \
|
|
|
97e186 |
+ "middle_layer=%c\n" \
|
|
|
97e186 |
+ "lower_layer=%c\n" \
|
|
|
97e186 |
+ "address=%llu\n" \
|
|
|
97e186 |
+ "grain=%llu\n" \
|
|
|
97e186 |
+ "syndrome=%llu\n" \
|
|
|
97e186 |
+ "driver_detail=%s\n", \
|
|
|
97e186 |
+ ev->timestamp, \
|
|
|
97e186 |
+ ev->error_count, \
|
|
|
97e186 |
+ ev->error_type, \
|
|
|
97e186 |
+ ev->msg, \
|
|
|
97e186 |
+ ev->label, \
|
|
|
97e186 |
+ ev->mc_index, \
|
|
|
97e186 |
+ ev->top_layer, \
|
|
|
97e186 |
+ ev->middle_layer, \
|
|
|
97e186 |
+ ev->lower_layer, \
|
|
|
97e186 |
+ ev->address, \
|
|
|
97e186 |
+ ev->grain, \
|
|
|
97e186 |
+ ev->syndrome, \
|
|
|
97e186 |
+ ev->driver_detail);
|
|
|
97e186 |
+
|
|
|
97e186 |
+ strcat(buf, bt_buf);
|
|
|
97e186 |
+
|
|
|
97e186 |
+ return 0;
|
|
|
97e186 |
+}
|
|
|
97e186 |
+
|
|
|
97e186 |
+static int set_mce_event_backtrace(char *buf, struct mce_event *ev){
|
|
|
97e186 |
+ char bt_buf[MAX_BACKTRACE_SIZE];
|
|
|
97e186 |
+
|
|
|
97e186 |
+ if(!buf || !ev)
|
|
|
97e186 |
+ return -1;
|
|
|
97e186 |
+
|
|
|
97e186 |
+ sprintf(bt_buf, "BACKTRACE=" \
|
|
|
97e186 |
+ "timestamp=%s\n" \
|
|
|
97e186 |
+ "bank_name=%s\n" \
|
|
|
97e186 |
+ "error_msg=%s\n" \
|
|
|
97e186 |
+ "mcgstatus_msg=%s\n" \
|
|
|
97e186 |
+ "mcistatus_msg=%s\n" \
|
|
|
97e186 |
+ "mcastatus_msg=%s\n" \
|
|
|
97e186 |
+ "user_action=%s\n" \
|
|
|
97e186 |
+ "mc_location=%s\n" \
|
|
|
97e186 |
+ "mcgcap=%lu\n" \
|
|
|
97e186 |
+ "mcgstatus=%lu\n" \
|
|
|
97e186 |
+ "status=%lu\n" \
|
|
|
97e186 |
+ "addr=%lu\n" \
|
|
|
97e186 |
+ "misc=%lu\n" \
|
|
|
97e186 |
+ "ip=%lu\n" \
|
|
|
97e186 |
+ "tsc=%lu\n" \
|
|
|
97e186 |
+ "walltime=%lu\n" \
|
|
|
97e186 |
+ "cpu=%u\n" \
|
|
|
97e186 |
+ "cpuid=%u\n" \
|
|
|
97e186 |
+ "apicid=%u\n" \
|
|
|
97e186 |
+ "socketid=%u\n" \
|
|
|
97e186 |
+ "cs=%d\n" \
|
|
|
97e186 |
+ "bank=%d\n" \
|
|
|
97e186 |
+ "cpuvendor=%d\n", \
|
|
|
97e186 |
+ ev->timestamp, \
|
|
|
97e186 |
+ ev->bank_name, \
|
|
|
97e186 |
+ ev->error_msg, \
|
|
|
97e186 |
+ ev->mcgstatus_msg, \
|
|
|
97e186 |
+ ev->mcistatus_msg, \
|
|
|
97e186 |
+ ev->mcastatus_msg, \
|
|
|
97e186 |
+ ev->user_action, \
|
|
|
97e186 |
+ ev->mc_location, \
|
|
|
97e186 |
+ ev->mcgcap, \
|
|
|
97e186 |
+ ev->mcgstatus, \
|
|
|
97e186 |
+ ev->status, \
|
|
|
97e186 |
+ ev->addr, \
|
|
|
97e186 |
+ ev->misc, \
|
|
|
97e186 |
+ ev->ip, \
|
|
|
97e186 |
+ ev->tsc, \
|
|
|
97e186 |
+ ev->walltime, \
|
|
|
97e186 |
+ ev->cpu, \
|
|
|
97e186 |
+ ev->cpuid, \
|
|
|
97e186 |
+ ev->apicid, \
|
|
|
97e186 |
+ ev->socketid, \
|
|
|
97e186 |
+ ev->cs, \
|
|
|
97e186 |
+ ev->bank, \
|
|
|
97e186 |
+ ev->cpuvendor);
|
|
|
97e186 |
+
|
|
|
97e186 |
+ strcat(buf, bt_buf);
|
|
|
97e186 |
+
|
|
|
97e186 |
+ return 0;
|
|
|
97e186 |
+}
|
|
|
97e186 |
+
|
|
|
97e186 |
+static int set_aer_event_backtrace(char *buf, struct ras_aer_event *ev){
|
|
|
97e186 |
+ char bt_buf[MAX_BACKTRACE_SIZE];
|
|
|
97e186 |
+
|
|
|
97e186 |
+ if(!buf || !ev)
|
|
|
97e186 |
+ return -1;
|
|
|
97e186 |
+
|
|
|
97e186 |
+ sprintf(bt_buf, "BACKTRACE=" \
|
|
|
97e186 |
+ "timestamp=%s\n" \
|
|
|
97e186 |
+ "error_type=%s\n" \
|
|
|
97e186 |
+ "dev_name=%s\n" \
|
|
|
97e186 |
+ "msg=%s\n", \
|
|
|
97e186 |
+ ev->timestamp, \
|
|
|
97e186 |
+ ev->error_type, \
|
|
|
97e186 |
+ ev->dev_name, \
|
|
|
97e186 |
+ ev->msg);
|
|
|
97e186 |
+
|
|
|
97e186 |
+ strcat(buf, bt_buf);
|
|
|
97e186 |
+
|
|
|
97e186 |
+ return 0;
|
|
|
97e186 |
+}
|
|
|
97e186 |
+
|
|
|
97e186 |
+static int commit_report_backtrace(int sockfd, int type, void *ev){
|
|
|
97e186 |
+ char buf[MAX_BACKTRACE_SIZE];
|
|
|
97e186 |
+ char *pbuf = buf;
|
|
|
97e186 |
+ int rc = -1;
|
|
|
97e186 |
+ int buf_len = 0;
|
|
|
97e186 |
+
|
|
|
97e186 |
+ if(sockfd < 0 || !ev){
|
|
|
97e186 |
+ return -1;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ memset(buf, 0, MAX_BACKTRACE_SIZE);
|
|
|
97e186 |
+
|
|
|
97e186 |
+ switch(type){
|
|
|
97e186 |
+ case MC_EVENT:
|
|
|
97e186 |
+ rc = set_mc_event_backtrace(buf, (struct ras_mc_event *)ev);
|
|
|
97e186 |
+ break;
|
|
|
97e186 |
+ case AER_EVENT:
|
|
|
97e186 |
+ rc = set_aer_event_backtrace(buf, (struct ras_aer_event *)ev);
|
|
|
97e186 |
+ break;
|
|
|
97e186 |
+ case MCE_EVENT:
|
|
|
97e186 |
+ rc = set_mce_event_backtrace(buf, (struct mce_event *)ev);
|
|
|
97e186 |
+ break;
|
|
|
97e186 |
+ default:
|
|
|
97e186 |
+ return -1;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ if(rc < 0){
|
|
|
97e186 |
+ return -1;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ buf_len = strlen(buf);
|
|
|
97e186 |
+
|
|
|
97e186 |
+ for(;buf_len > INPUT_BUFFER_SIZE - 1; buf_len -= (INPUT_BUFFER_SIZE - 1)){
|
|
|
97e186 |
+ rc = write(sockfd, pbuf, INPUT_BUFFER_SIZE - 1);
|
|
|
97e186 |
+ if(rc < INPUT_BUFFER_SIZE - 1){
|
|
|
97e186 |
+ return -1;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ pbuf = pbuf + INPUT_BUFFER_SIZE - 1;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ rc = write(sockfd, pbuf, buf_len + 1);
|
|
|
97e186 |
+ if(rc < buf_len){
|
|
|
97e186 |
+ return -1;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ return 0;
|
|
|
97e186 |
+}
|
|
|
97e186 |
+
|
|
|
97e186 |
+int ras_report_mc_event(struct ras_events *ras, struct ras_mc_event *ev){
|
|
|
97e186 |
+ char buf[MAX_MESSAGE_SIZE];
|
|
|
97e186 |
+ int sockfd = -1;
|
|
|
97e186 |
+ int done = 0;
|
|
|
97e186 |
+ int rc = -1;
|
|
|
97e186 |
+
|
|
|
97e186 |
+ memset(buf, 0, sizeof(buf));
|
|
|
97e186 |
+
|
|
|
97e186 |
+ sockfd = setup_report_socket();
|
|
|
97e186 |
+ if(sockfd < 0){
|
|
|
97e186 |
+ return -1;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ rc = commit_report_basic(sockfd);
|
|
|
97e186 |
+ if(rc < 0){
|
|
|
97e186 |
+ goto mc_fail;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ rc = commit_report_backtrace(sockfd, MC_EVENT, ev);
|
|
|
97e186 |
+ if(rc < 0){
|
|
|
97e186 |
+ goto mc_fail;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ sprintf(buf, "ANALYZER=%s", "rasdaemon-mc");
|
|
|
97e186 |
+ rc = write(sockfd, buf, strlen(buf) + 1);
|
|
|
97e186 |
+ if(rc < strlen(buf) + 1){
|
|
|
97e186 |
+ goto mc_fail;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ sprintf(buf, "REASON=%s", "EDAC driver report problem");
|
|
|
97e186 |
+ rc = write(sockfd, buf, strlen(buf) + 1);
|
|
|
97e186 |
+ if(rc < strlen(buf) + 1){
|
|
|
97e186 |
+ goto mc_fail;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ rc = commit_report_done(sockfd);
|
|
|
97e186 |
+ if(rc < 0){
|
|
|
97e186 |
+ goto mc_fail;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ done = 1;
|
|
|
97e186 |
+
|
|
|
97e186 |
+mc_fail:
|
|
|
97e186 |
+
|
|
|
97e186 |
+ if(sockfd > 0){
|
|
|
97e186 |
+ close(sockfd);
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ if(done){
|
|
|
97e186 |
+ return 0;
|
|
|
97e186 |
+ }else{
|
|
|
97e186 |
+ return -1;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+}
|
|
|
97e186 |
+
|
|
|
97e186 |
+int ras_report_aer_event(struct ras_events *ras, struct ras_aer_event *ev){
|
|
|
97e186 |
+ char buf[MAX_MESSAGE_SIZE];
|
|
|
97e186 |
+ int sockfd = 0;
|
|
|
97e186 |
+ int done = 0;
|
|
|
97e186 |
+ int rc = -1;
|
|
|
97e186 |
+
|
|
|
97e186 |
+ memset(buf, 0, sizeof(buf));
|
|
|
97e186 |
+
|
|
|
97e186 |
+ sockfd = setup_report_socket();
|
|
|
97e186 |
+ if(sockfd < 0){
|
|
|
97e186 |
+ return -1;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ rc = commit_report_basic(sockfd);
|
|
|
97e186 |
+ if(rc < 0){
|
|
|
97e186 |
+ goto aer_fail;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ rc = commit_report_backtrace(sockfd, AER_EVENT, ev);
|
|
|
97e186 |
+ if(rc < 0){
|
|
|
97e186 |
+ goto aer_fail;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ sprintf(buf, "ANALYZER=%s", "rasdaemon-aer");
|
|
|
97e186 |
+ rc = write(sockfd, buf, strlen(buf) + 1);
|
|
|
97e186 |
+ if(rc < strlen(buf) + 1){
|
|
|
97e186 |
+ goto aer_fail;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ sprintf(buf, "REASON=%s", "PCIe AER driver report problem");
|
|
|
97e186 |
+ rc = write(sockfd, buf, strlen(buf) + 1);
|
|
|
97e186 |
+ if(rc < strlen(buf) + 1){
|
|
|
97e186 |
+ goto aer_fail;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ rc = commit_report_done(sockfd);
|
|
|
97e186 |
+ if(rc < 0){
|
|
|
97e186 |
+ goto aer_fail;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ done = 1;
|
|
|
97e186 |
+
|
|
|
97e186 |
+aer_fail:
|
|
|
97e186 |
+
|
|
|
97e186 |
+ if(sockfd > 0){
|
|
|
97e186 |
+ close(sockfd);
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ if(done){
|
|
|
97e186 |
+ return 0;
|
|
|
97e186 |
+ }else{
|
|
|
97e186 |
+ return -1;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+}
|
|
|
97e186 |
+
|
|
|
97e186 |
+int ras_report_mce_event(struct ras_events *ras, struct mce_event *ev){
|
|
|
97e186 |
+ char buf[MAX_MESSAGE_SIZE];
|
|
|
97e186 |
+ int sockfd = 0;
|
|
|
97e186 |
+ int done = 0;
|
|
|
97e186 |
+ int rc = -1;
|
|
|
97e186 |
+
|
|
|
97e186 |
+ memset(buf, 0, sizeof(buf));
|
|
|
97e186 |
+
|
|
|
97e186 |
+ sockfd = setup_report_socket();
|
|
|
97e186 |
+ if(sockfd < 0){
|
|
|
97e186 |
+ return -1;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ rc = commit_report_basic(sockfd);
|
|
|
97e186 |
+ if(rc < 0){
|
|
|
97e186 |
+ goto mce_fail;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ rc = commit_report_backtrace(sockfd, MCE_EVENT, ev);
|
|
|
97e186 |
+ if(rc < 0){
|
|
|
97e186 |
+ goto mce_fail;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ sprintf(buf, "ANALYZER=%s", "rasdaemon-mce");
|
|
|
97e186 |
+ rc = write(sockfd, buf, strlen(buf) + 1);
|
|
|
97e186 |
+ if(rc < strlen(buf) + 1){
|
|
|
97e186 |
+ goto mce_fail;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ sprintf(buf, "REASON=%s", "Machine Check driver report problem");
|
|
|
97e186 |
+ rc = write(sockfd, buf, strlen(buf) + 1);
|
|
|
97e186 |
+ if(rc < strlen(buf) + 1){
|
|
|
97e186 |
+ goto mce_fail;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ rc = commit_report_done(sockfd);
|
|
|
97e186 |
+ if(rc < 0){
|
|
|
97e186 |
+ goto mce_fail;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ done = 1;
|
|
|
97e186 |
+
|
|
|
97e186 |
+mce_fail:
|
|
|
97e186 |
+
|
|
|
97e186 |
+ if(sockfd > 0){
|
|
|
97e186 |
+ close(sockfd);
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+
|
|
|
97e186 |
+ if(done){
|
|
|
97e186 |
+ return 0;
|
|
|
97e186 |
+ }else{
|
|
|
97e186 |
+ return -1;
|
|
|
97e186 |
+ }
|
|
|
97e186 |
+}
|
|
|
97e186 |
diff --git a/ras-report.h b/ras-report.h
|
|
|
97e186 |
new file mode 100644
|
|
|
97e186 |
index 0000000..7920cdf
|
|
|
97e186 |
--- /dev/null
|
|
|
97e186 |
+++ b/ras-report.h
|
|
|
97e186 |
@@ -0,0 +1,39 @@
|
|
|
97e186 |
+#ifndef __RAS_REPORT_H
|
|
|
97e186 |
+#define __RAS_REPORT_H
|
|
|
97e186 |
+
|
|
|
97e186 |
+#include "ras-record.h"
|
|
|
97e186 |
+#include "ras-events.h"
|
|
|
97e186 |
+#include "ras-mc-handler.h"
|
|
|
97e186 |
+#include "ras-mce-handler.h"
|
|
|
97e186 |
+#include "ras-aer-handler.h"
|
|
|
97e186 |
+
|
|
|
97e186 |
+/* Maximal length of backtrace. */
|
|
|
97e186 |
+#define MAX_BACKTRACE_SIZE (1024*1024)
|
|
|
97e186 |
+/* Amount of data received from one client for a message before reporting error. */
|
|
|
97e186 |
+#define MAX_MESSAGE_SIZE (4*MAX_BACKTRACE_SIZE)
|
|
|
97e186 |
+/* Maximal number of characters read from socket at once. */
|
|
|
97e186 |
+#define INPUT_BUFFER_SIZE (8*1024)
|
|
|
97e186 |
+/* ABRT socket file */
|
|
|
97e186 |
+#define ABRT_SOCKET "/var/run/abrt/abrt.socket"
|
|
|
97e186 |
+
|
|
|
97e186 |
+enum {
|
|
|
97e186 |
+ MC_EVENT,
|
|
|
97e186 |
+ MCE_EVENT,
|
|
|
97e186 |
+ AER_EVENT
|
|
|
97e186 |
+};
|
|
|
97e186 |
+
|
|
|
97e186 |
+#ifdef HAVE_ABRT_REPORT
|
|
|
97e186 |
+
|
|
|
97e186 |
+int ras_report_mc_event(struct ras_events *ras, struct ras_mc_event *ev);
|
|
|
97e186 |
+int ras_report_aer_event(struct ras_events *ras, struct ras_aer_event *ev);
|
|
|
97e186 |
+int ras_report_mce_event(struct ras_events *ras, struct mce_event *ev);
|
|
|
97e186 |
+
|
|
|
97e186 |
+#else
|
|
|
97e186 |
+
|
|
|
97e186 |
+static inline int ras_report_mc_event(struct ras_events *ras, struct ras_mc_event *ev) { return 0; };
|
|
|
97e186 |
+static inline int ras_report_aer_event(struct ras_events *ras, struct ras_aer_event *ev) { return 0; };
|
|
|
97e186 |
+static inline int ras_report_mce_event(struct ras_events *ras, struct mce_event *ev) { return 0; };
|
|
|
97e186 |
+
|
|
|
97e186 |
+#endif
|
|
|
97e186 |
+
|
|
|
97e186 |
+#endif
|
|
|
97e186 |
--
|
|
|
97e186 |
1.7.1
|
|
|
97e186 |
|