import smc-tools-1.6.0-3.git393dd23.el8

This commit is contained in:
CentOS Sources 2021-10-06 09:27:01 -04:00 committed by Stepan Oksanichenko
parent ea0ede6dc8
commit 9911bad3a8
7 changed files with 260 additions and 13 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/smc-tools-71c863a.tar.gz
SOURCES/smc-tools-393dd23.tar.gz

View File

@ -1 +1 @@
9b408cd25de5296889e75ce618d0f8d8c96a8205 SOURCES/smc-tools-71c863a.tar.gz
36bc253cf08f536eb67aa1ec10a4b04daf1fd467 SOURCES/smc-tools-393dd23.tar.gz

View File

@ -0,0 +1,74 @@
From f365663e86fd06075bd5fe2d30bab0a64dc27b18 Mon Sep 17 00:00:00 2001
From: Guvenc Gulce <guvenc@linux.ibm.com>
Date: Fri, 16 Jul 2021 09:54:03 +0200
Subject: [PATCH 1/3] smc-tools: stats: Fix memory overread in
is_data_consistent()
Fix memory overread in is_data_consistent() and merge_cache()
functions.
Signed-off-by: Guvenc Gulce <guvenc@linux.ibm.com>
---
README.md | 1 +
stats.c | 13 +++++++------
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
index 2397475..5047f62 100644
--- a/README.md
+++ b/README.md
@@ -47,6 +47,7 @@ Release History:
- `smc_run`: Add various command-line switches
Bug fixes:
+ - `smcd`/`smcr`: stats: Fix memory overread in is_data_consistent()
- `smc_chk`: Remove 'EXPERIMENTAL' flag
- `smc_chk`: Improve cleanup
- `smc_chk`: Start server with intended port
diff --git a/stats.c b/stats.c
index 2a00e42..d3a814f 100644
--- a/stats.c
+++ b/stats.c
@@ -900,7 +900,7 @@ static int is_data_consistent ()
cache++;
}
- size_fback = size + 2 * SMC_MAX_FBACK_RSN_CNT;
+ size_fback = 2 * SMC_MAX_FBACK_RSN_CNT;
kern_fbck = (struct smc_stats_fback *)&smc_rsn;
for (i = 0; i < size_fback; i++) {
val_err = kern_fbck->fback_code;
@@ -924,8 +924,8 @@ static int is_data_consistent ()
static void merge_cache ()
{
int size, i, size_fback, val_err, cache_cnt;
+ struct smc_stats_fback *kern_fbck;
__u64 *kernel, *cache;
- int *kern_fbck;
if (!is_data_consistent()) {
unlink(cache_file_path);
@@ -938,15 +938,16 @@ static void merge_cache ()
for (i = 0; i < size; i++)
*(kernel++) -= *(cache++);
- size_fback = size + 2 * SMC_MAX_FBACK_RSN_CNT;
- kern_fbck = (int *)&smc_rsn;
+ size_fback = 2 * SMC_MAX_FBACK_RSN_CNT;
+ kern_fbck = (struct smc_stats_fback *)&smc_rsn;
for (i = 0; i < size_fback; i++) {
- val_err = *(kern_fbck++);
+ val_err = kern_fbck->fback_code;
if (i < SMC_MAX_FBACK_RSN_CNT)
cache_cnt = get_fback_err_cache_count(smc_rsn_c.srv, val_err);
else
cache_cnt = get_fback_err_cache_count(smc_rsn_c.clnt, val_err);
- *(kern_fbck++) -= cache_cnt;
+ kern_fbck->count -= cache_cnt;
+ kern_fbck++;
}
smc_rsn.srv_fback_cnt -= smc_rsn_c.srv_fback_cnt;
--
2.25.1

View File

@ -0,0 +1,71 @@
From 96b9a33bc16a1d569fe24c3ab1266a7094f41dcb Mon Sep 17 00:00:00 2001
From: Guvenc Gulce <guvenc@linux.ibm.com>
Date: Fri, 16 Jul 2021 13:47:39 +0200
Subject: [PATCH 2/3] smc-tools: stats: Fix memory and file handle leaks
When exiting the application, make sure that cache
file handle is closed and the memory used for the
cache file path is freed.
Signed-off-by: Guvenc Gulce <guvenc@linux.ibm.com>
---
README.md | 1 +
stats.c | 12 +++++++++---
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index 5047f62..175525d 100644
--- a/README.md
+++ b/README.md
@@ -48,6 +48,7 @@ Release History:
Bug fixes:
- `smcd`/`smcr`: stats: Fix memory overread in is_data_consistent()
+ - `smcd`/`smcr`: stats: Fix memory and file handle leaks
- `smc_chk`: Remove 'EXPERIMENTAL' flag
- `smc_chk`: Improve cleanup
- `smc_chk`: Start server with intended port
diff --git a/stats.c b/stats.c
index d3a814f..4495434 100644
--- a/stats.c
+++ b/stats.c
@@ -45,7 +45,7 @@ struct smc_stats_rsn smc_rsn;
struct smc_stats_rsn smc_rsn_c;
struct smc_stats_rsn smc_rsn_org;
FILE *cache_fp = NULL;
-char *cache_file_path;
+char *cache_file_path = NULL;
static char* j_output[63] = {"SMC_INT_TX_BUF_8K", "SMC_INT_TX_BUF_16K", "SMC_INT_TX_BUF_32K", "SMC_INT_TX_BUF_64K", "SMC_INT_TX_BUF_128K",
"SMC_INT_TX_BUF_256K", "SMC_INT_TX_BUF_512K", "SMC_INT_TX_BUF_1024K", "SMC_INT_TX_BUF_G_1024K",
@@ -1011,8 +1011,6 @@ static void fill_cache_file()
fprintf(cache_fp, "%16llu\n", smc_rsn.srv_fback_cnt);
fprintf(cache_fp, "%16llu\n", smc_rsn.clnt_fback_cnt);
-
- fclose(cache_fp);
}
int invoke_stats(int argc, char **argv, int option_details)
@@ -1044,10 +1042,18 @@ int invoke_stats(int argc, char **argv, int option_details)
print_as_json();
if (reset_cmd) {
unlink(cache_file_path);
+ if (cache_fp) {
+ fclose(cache_fp);
+ cache_fp = NULL;
+ }
+ free(cache_file_path);
+ cache_file_path = NULL;
open_cache_file();
fill_cache_file();
}
errout:
+ if (cache_fp)
+ fclose(cache_fp);
free(cache_file_path);
return 0;
}
--
2.25.1

View File

@ -0,0 +1,48 @@
From d1a690e104e95ea8f35f82d500abb3aff5c77097 Mon Sep 17 00:00:00 2001
From: Guvenc Gulce <guvenc@linux.ibm.com>
Date: Fri, 16 Jul 2021 14:44:02 +0200
Subject: [PATCH 3/3] smc-tools: stats: Use correct fallback counter values
after reset
Fallback counters are using the merged values for the cache
when reset is called. The cache file needs to be filled with
absolute values as a reference point for the reset as the
successive calls will deduct this reference point from the
new absolute value.
Signed-off-by: Guvenc Gulce <guvenc@linux.ibm.com>
---
README.md | 1 +
stats.c | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 175525d..aa80dbd 100644
--- a/README.md
+++ b/README.md
@@ -49,6 +49,7 @@ Release History:
Bug fixes:
- `smcd`/`smcr`: stats: Fix memory overread in is_data_consistent()
- `smcd`/`smcr`: stats: Fix memory and file handle leaks
+ - `smcd`/`smcr`: stats: Use correct fallback counter values after reset
- `smc_chk`: Remove 'EXPERIMENTAL' flag
- `smc_chk`: Improve cleanup
- `smc_chk`: Start server with intended port
diff --git a/stats.c b/stats.c
index 4495434..a74c4cf 100644
--- a/stats.c
+++ b/stats.c
@@ -1009,8 +1009,8 @@ static void fill_cache_file()
fprintf(cache_fp, "%-12d%-16d%-16d\n",i , val_err, val_cnt);
}
- fprintf(cache_fp, "%16llu\n", smc_rsn.srv_fback_cnt);
- fprintf(cache_fp, "%16llu\n", smc_rsn.clnt_fback_cnt);
+ fprintf(cache_fp, "%16llu\n", smc_rsn_org.srv_fback_cnt);
+ fprintf(cache_fp, "%16llu\n", smc_rsn_org.clnt_fback_cnt);
}
int invoke_stats(int argc, char **argv, int option_details)
--
2.25.1

View File

@ -0,0 +1,29 @@
--- a/smc_chk 2021-07-02 12:23:56.000000000 +0200
+++ b/smc_chk 2021-07-16 14:48:40.988000000 +0200
@@ -108,7 +108,7 @@
}
function is_python3_available() {
- if ! which python3 >/dev/null; then
+ if ! which /usr/libexec/platform-python >/dev/null; then
echo "Error: python3 is not available";
signal_handler;
fi
@@ -124,7 +124,7 @@
port6=`get_free_port $(expr $port + 1)`;
srv=`mktemp /tmp/echo-srv.XXXXXX`;
cat <<-EOF > $srv
-#!/usr/bin/env python3
+#!/usr/libexec/platform-python
import argparse
import signal
@@ -171,7 +171,7 @@
is_python3_available;
clt=`mktemp /tmp/echo-clt.XXXXXX`;
cat <<-EOF > $clt
-#!/usr/bin/env python3
+#!/usr/libexec/platform-python
import argparse
import socket

View File

@ -1,6 +1,6 @@
%global forgeurl https://github.com/ibm-s390-tools/smc-tools
%global commitdate 20201203
%global commit 71c863a72165dab03e65022c332c0a8efb6c3b4d
%global commitdate 20210702
%global commit 393dd23a767ab111608a534b4b0d200e45fe04f0
%global shortcommit %(c=%{commit}; echo ${c:0:7})
%forgemeta -i
@ -8,25 +8,35 @@
%define debug_package %{nil}
Name: smc-tools
Version: 1.4.0
Version: 1.6.0
Release: 3%{?dist}
Summary: Shared Memory Communication Tools
License: EPL
URL: https://www.ibm.com/developerworks/linux/linux390/smc-tools.html
Requires: man
BuildRequires: gcc
BuildRequires: libnl3-devel
BuildRequires: bash-completion
Source0: https://github.com/ibm-s390-tools/smc-tools/archive/%{commit}/%{name}-%{shortcommit}.tar.gz
Patch0: smc-tools-1.6.0-smc_chk-py3.patch
Patch1: 0001-smc-tools-stats-Fix-memory-overread-in-is_data_consi.patch
Patch2: 0002-smc-tools-stats-Fix-memory-and-file-handle-leaks.patch
Patch3: 0003-smc-tools-stats-Use-correct-fallback-counter-values-.patch
%description
The Shared Memory Communication Tools (smc-tools) package enables usage of SMC
sockets in Linux.
%prep
%forgesetup
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%build
%make_build CFLAGS="%{build_cflags} -I%{_includedir}/libnl3" LDFLAGS="%{build_ldflags}" V=1
@ -37,14 +47,7 @@ sockets in Linux.
%files
%license LICENSE
%doc README.md
%dir %{_datadir}/bash-completion
%dir %{_datadir}/bash-completion/completions
%{_datadir}/bash-completion/completions/smc
%{_datadir}/bash-completion/completions/smc-tools
%{_datadir}/bash-completion/completions/smc_dbg
%{_datadir}/bash-completion/completions/smc_pnet
%{_datadir}/bash-completion/completions/smc_rnics
%{_datadir}/bash-completion/completions/smcss
%{_datadir}/bash-completion/
%{_mandir}/man7/af_smc.7.gz
%{_mandir}/man8/smc*
%{_bindir}/smc_pnet
@ -52,13 +55,35 @@ sockets in Linux.
%{_bindir}/smcss
%{_bindir}/smcd
%{_bindir}/smcr
%{_bindir}/smc_dbg
%ifarch s390x
%{_bindir}/smc_rnics
%{_bindir}/smc_chk
%endif
%{_bindir}/smc_dbg
%{_libdir}/libsmc-preload.so*
%changelog
* Fri Jul 16 2021 Čestmír Kalina <ckalina@redhat.com> - 1.6.0-3
- Patch stats.c to fix overruns
- Patch stats.c to fix leaks
- Patch stats.c to fix fallback counter values
- Resolves: #1993469
* Fri Jul 16 2021 Čestmír Kalina <ckalina@redhat.com> - 1.6.0-2
- Patch smc_chk to use platform-python
- Resolves: #1981727
* Fri Jul 02 2021 Čestmír Kalina <ckalina@redhat.com> - 1.6.0-1
- Resolves: #1869292 Statistics Support - smc-tools part
- Resolves: #1919225 Add SMC-D Setup Check (smc-tools)
- Resolves: #1919240 Upgrade smc-tools to latest version
* Wed Feb 10 2021 Čestmír Kalina <ckalina@redhat.com> - 1.5.0-2
- Resolves: #1924787
- Add python3/man requires
* Mon Feb 08 2021 Čestmír Kalina <ckalina@redhat.com> - 1.5.0-1
- Resolves: #1924787
- Upgrade to 1.5.0
* Mon Jan 04 2021 Čestmír Kalina <ckalina@redhat.com> - 1.4.0-3
- Resolves: #1879128
- Add bash-completion to build requires