Skip to content

Commit

Permalink
Fixes for build on Fedora
Browse files Browse the repository at this point in the history
fixed build on Fedora 28+(tested on 34) by integration libtirpc as replacement for SunRPC from libc
fixed memory overrun in Watch analyzer for NFS40 and NFS41
removed -Wno-error=address-of-packed-member compiler flag
removed packed attribute from Session::IPAddress.v6 union
  • Loading branch information
pkarneliuk committed Oct 8, 2021
1 parent b220d04 commit 849a019
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
23 changes: 20 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
cmake_minimum_required (VERSION 3.0)
project (nfstrace)
project (nfstrace LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# check compiler and packages ==================================================
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
Expand All @@ -25,12 +28,26 @@ find_library(PCAP_LIBRARY
NAMES pcap
HINTS ${PCAP_ROOT_DIR}/lib)

if ("${PCAP_LIBRARY}" STREQUAL "PCAP_LIBRARY-NOTFOUND")
if (NOT PCAP_LIBRARY)
message (FATAL_ERROR "Could NOT find PCAP")
endif ()

# See: https://fedoraproject.org/wiki/Changes/SunRPCRemoval
find_file (FEDORA_FOUND fedora-release PATHS /etc)
find_file (REDHAT_FOUND redhat-release PATHS /etc)
if (FEDORA_FOUND OR REDHAT_FOUND)
find_library (TIRPC_LIBRARY NAMES tirpc)
find_path (TIRPC_INCLUDE NAMES rpc/rpc.h PATHS /usr/include/tirpc)
if (TIRPC_LIBRARY AND TIRPC_INCLUDE)
include_directories (${TIRPC_INCLUDE})
link_libraries (${TIRPC_LIBRARY})
else ()
message (FATAL_ERROR "${TIRPC_LIBRARY} ${TIRPC_INCLUDE} is required for Fedora/RedHat")
endif ()
endif ()

This comment has been minimized.

Copy link
@andrewshadura

andrewshadura Oct 8, 2021

Contributor

Well, this is wrong, tirpc is required everywhere, not just on Fedora.

This comment has been minimized.

Copy link
@andrewshadura

andrewshadura Oct 8, 2021

Contributor

Sun RPC implementation has been removed from glibc 2.32 (and it’s been deprecated for some time before that).


# build application ============================================================
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -pedantic -Wall -Werror -Wextra -Wno-invalid-offsetof -Wno-error=address-of-packed-member -fPIC -fvisibility=hidden")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Werror -Wextra -Wno-invalid-offsetof -fPIC -fvisibility=hidden")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--export-dynamic")

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND "${INCLUDE_COVERAGE_INFO}")
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
[![Issues](https://img.shields.io/github/issues/epam/nfstrace.svg)](https://github.com/epam/nfstrace/issues?q=is%3Aopen+is%3Aissue)
[![Build Status](https://img.shields.io/travis/epam/nfstrace/master.svg)](https://travis-ci.org/epam/nfstrace)
[![Coverage Status](http://img.shields.io/coveralls/epam/nfstrace/master.svg)](https://coveralls.io/r/epam/nfstrace?branch=master)
NFSTRACE ![NFSTRACE Logo](docs/pictures/logo64.png "Logo")

![NFSTRACE Logo](docs/pictures/logo64.png "Logo") NFSTRACE
========

`nfstrace` is an NFS and CIFS tracing/monitoring/capturing/analyzing tool.
Expand All @@ -25,7 +26,7 @@ following protocols:
`nfstrace` has been tested on the following GNU/Linux and FreeBSD systems:

- Debian Sid [packages](https://packages.debian.org/unstable/main/nfstrace) [build-logs](https://buildd.debian.org/status/logs.php?pkg=nfstrace)
- Fedora 26
- Fedora 34
- OpenSUSE 13.2
- Ubuntu 16.04 LTS
- CentOS 7
Expand Down
4 changes: 2 additions & 2 deletions analyzers/src/watch/watch_analyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ void WatchAnalyzer::get_dir_delegation40(const RPCProcedure* proc,
const struct NFS4::GET_DIR_DELEGATION4args*,
const struct NFS4::GET_DIR_DELEGATION4res* res) { if (res) { account40_op(proc, ProcEnumNFS4::NFSProcedure::GET_DIR_DELEGATION); } }
void WatchAnalyzer::illegal40(const RPCProcedure* proc,
const struct NFS4::ILLEGAL4res* res) { if (res) { account40_op(proc, ProcEnumNFS4::NFSProcedure::ILLEGAL); } }
const struct NFS4::ILLEGAL4res* res) { if (res) { account40_op(proc, /*ProcEnumNFS4::NFSProcedure::ILLEGAL is mapped to 2 index*/ static_cast<ProcEnumNFS4::NFSProcedure>(2)); } }

// NFSv4.1 procedures

Expand Down Expand Up @@ -406,7 +406,7 @@ void WatchAnalyzer::reclaim_complete41(const RPCProcedure* proc,
const struct NFS41::RECLAIM_COMPLETE4args*,
const struct NFS41::RECLAIM_COMPLETE4res* res) { if (res) { account41_op(proc, ProcEnumNFS41::NFSProcedure::RECLAIM_COMPLETE); } }
void WatchAnalyzer::illegal41(const RPCProcedure* proc,
const struct NFS41::ILLEGAL4res* res) { if (res) { account41_op(proc, ProcEnumNFS41::NFSProcedure::ILLEGAL); } }
const struct NFS41::ILLEGAL4res* res) { if (res) { account41_op(proc, /*ProcEnumNFS41::NFSProcedure::ILLEGAL is mapped to 2 index*/ static_cast<ProcEnumNFS41::NFSProcedure>(2)); } }
// CIFS v1
void WatchAnalyzer::createDirectorySMBv1(const SMBv1::CreateDirectoryCommand* /*cmd*/, const SMBv1::CreateDirectoryArgumentType*, const SMBv1::CreateDirectoryResultType*)
{
Expand Down
3 changes: 2 additions & 1 deletion src/api/session.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ struct Session
{
uint8_t addr[2][16];
uint32_t addr_uint32[2][4];
} __attribute__((__packed__)) v6;
} v6;
static_assert(sizeof(v6) == 32, "unexpected sizeof");
} ip;
};

Expand Down
2 changes: 2 additions & 0 deletions tests/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ if ("${GTEST_SOURCE_DIR}" STREQUAL "")
else ()
# Clang and GCC 4.9+ cause errors on GMock/GTest compilation, so we are adding following flags to suppress them
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-field-initializers")
# Suppress warnings from GCC 11
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-copy")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-private-field")
endif ()
Expand Down

0 comments on commit 849a019

Please sign in to comment.