-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Dung Man <[email protected]>
- Loading branch information
Showing
30 changed files
with
3,008 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# DANOS Dataplane flowstat plugin | ||
|
||
A plugin for dataplane allow viewing flow statistics. | ||
|
||
# Tests | ||
Setup and build test environment | ||
```sh | ||
meson build | ||
ninja -C build | ||
``` | ||
Run tests | ||
``` | ||
cd build | ||
meson test -v | ||
``` | ||
|
||
## Architecture | ||
```sh | ||
+------------+ +----------+ +--------------+ | ||
| Dataplane | --> | wfcqueue | --> | flowstat.log | | ||
+------------+ +----------+ +--------------+ | ||
| | ||
v | ||
+------------+ +-------------+ +-----------+ | ||
| op command | --> | flowstat.db | <-- | flowstatd | | ||
+------------+ +-------------+ +-----------+ | ||
``` | ||
- Session info was collected by session watch, and stored in a wait free queue. | ||
- A thread dequeue session info from queue and flush to a log file (rotated by logrotate). | ||
- A daemon called flowstatd will read log from log file then save statistics into a sqlite3 db `flowstat.db`. | ||
- OP command will query statistics directly from `flowstat.db`. | ||
- There 4 period time | ||
- now: statistics were calculated by session table of dataplane | ||
- 5m/1h/1d: statistics from `flowstatd.db` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
tmp/ | ||
build/ | ||
.debhelper/ | ||
dataplane-flowstat-plugin/ | ||
libdataplane-flowstat-plugin-proto-support/ | ||
files | ||
*.log | ||
*.substvars | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
dataplane-flowstat-plugin (1.0.0) UNRELEASED; urgency=medium | ||
|
||
* Initial release. | ||
|
||
-- Dung Man <[email protected]> Thu, 25 Mar 2021 10:46:02 +0000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
Source: dataplane-flowstat-plugin | ||
Section: contrib/net | ||
Priority: optional | ||
Maintainer: Dung Man <[email protected]> | ||
Build-Depends: meson, | ||
check <!nocheck>, | ||
debhelper (>= 9.20160709), | ||
dh-exec, | ||
libczmq-dev, | ||
libdpdk-dev (>= 19.11.4-0vyatta7), | ||
libgoogle-protocolbuffers-perl, | ||
libprotobuf-c-dev, | ||
liburcu-dev (>= 0.8.0), | ||
pkg-config, | ||
protobuf-c-compiler, | ||
python3, | ||
vyatta-dataplane-dev, | ||
vyatta-dataplane-test | ||
Standards-Version: 4.3.0 | ||
Homepage: | ||
|
||
Package: dataplane-flowstat-plugin | ||
Section: contrib/net | ||
Architecture: any | ||
Depends: ${misc:Depends}, | ||
${shlibs:Depends} | ||
Description: Vyatta dataplane flow stat plugin library. | ||
A pipeline plugin for Vyatta dataplane that view | ||
flow statistics. | ||
|
||
Package: libdataplane-flowstat-plugin-proto-support | ||
Section: contrib/net | ||
Architecture: all | ||
Depends: ${misc:Depends} | ||
Description: Vyatta dataplane flowstat plugin protocol buffer files and support | ||
Set of files defining message formats accepted by the dataplane |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ | ||
|
||
Files: * | ||
Copyright: 2021, SafePoint. | ||
License: Apache-2.0 | ||
|
||
Files: src/flowstat.c | ||
tests/src/dp_test_lib_tcp.h | ||
tests/src/dp_test_npf_lib.h | ||
tests/src/dp_test_pipeline_flowstat.c | ||
tests/src/dp_test_session_internal_lib.h | ||
tests/src/util.h | ||
Copyright: 2011-2016, Brocade Communications Systems, Inc. | ||
2015, Brocade Communications Systems, Inc. | ||
2015-2017, Brocade Communications Systems, Inc. | ||
2016, Brocade Communications Systems, Inc. | ||
2017, Brocade Communications Systems, Inc. | ||
2017-2020, AT&T Intellectual Property. | ||
2017-2021, AT&T Intellectual Property. | ||
2018-2020, AT&T Intellectual Property. | ||
2021, SafePoint. | ||
License: LGPL-2.1-only | ||
|
||
Files: meson.build | ||
protobuf/FlowStatFeatConfig.proto | ||
protobuf/FlowStatFeatOp.proto | ||
protobuf/meson.build | ||
tests/meson.build | ||
Copyright: 2018-2019, AT&T Intellectual Property. | ||
2020, AT&T Intellectual Property. | ||
2020-2021, AT&T Intellectual Property. | ||
2021, SafePoint. | ||
License: LGPL-2.1-only | ||
|
||
Files: src/flowstat.h | ||
tests/src/pcap/gen_pkt.py | ||
Copyright: 2021, SafePoint. | ||
License: Apache-2.0 | ||
|
||
License: Apache-2.0 | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
. | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
. | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
. | ||
On Debian systems, the complete text of the Apache License 2.0 can | ||
be found in "/usr/share/common-licenses/Apache-2.0" | ||
|
||
License: LGPL-2.1-only | ||
This package is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
License as published by the Free Software Foundation; | ||
version 2.1 | ||
. | ||
This package is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Lesser General Public License for more details. | ||
. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
. | ||
On Debian systems, the complete text of the GNU Lesser General | ||
Public License can be found in "/usr/share/common-licenses/LGPL-2.1". |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
usr/lib/*/vyatta-dataplane/pipeline/plugins/flowstat_plugin.so |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
usr/share/vyatta-dataplane/protobuf/* | ||
usr/share/perl5/vyatta/proto/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/make -f | ||
# You must remove unused comment lines for the released package. | ||
# export DH_VERBOSE = 1 | ||
export DEB_BUILD_MAINT_OPTIONS=hardening=+format,-fortify,-stackprotector,+relro,+bindnow | ||
export DEB_CFLAGS_MAINT_APPEND = -O2 | ||
# export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed | ||
|
||
%: | ||
dh $@ --builddirectory=build --parallel --buildsystem=meson | ||
|
||
override_dh_auto_install: | ||
dh_auto_install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.0 (native) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# SPDX-License-Identifier: LGPL-2.1-only | ||
# Copyright (c) 2021, SafePoint <[email protected]>. All rights reserved. | ||
# Copyright (c) 2020, AT&T Intellectual Property. All rights reserved. | ||
|
||
project('vyatta-flowstat-plugin', ['c', 'cpp'], | ||
default_options: [ | ||
'debug=true', | ||
'optimization=3', | ||
'werror=true', | ||
'warning_level=2', | ||
'c_std=gnu11', | ||
'b_lto=true' | ||
] | ||
) | ||
|
||
cc = meson.get_compiler('c') | ||
|
||
add_project_arguments( | ||
'-D_GNU_SOURCE', | ||
cc.get_supported_arguments([ | ||
'-Wno-deprecated-declarations', | ||
'-Wno-stringop-overflow', | ||
'-Wno-stringop-truncation', | ||
'-Wno-format-truncation' | ||
]), | ||
language: 'c' | ||
) | ||
|
||
with_tests = get_option('with_tests').enabled() | ||
|
||
check_dep = dependency('check', required: with_tests) | ||
dp_dep = dependency('vyatta-dataplane-dev', required: true) | ||
dl_dep = cc.find_library('dl', required : true) | ||
dpdk_dep = dependency('libdpdk', version: '>= 19.11') | ||
proto_c_dep = dependency('libprotobuf-c', version: '>= 1.0.0') | ||
threads_dep = dependency('threads') | ||
urcu_cds_dep = dependency('liburcu-cds', version: '>= 0.8.0') | ||
urcu_dep = dependency('liburcu', version: '>= 0.8.0') | ||
urcu_qsbr_dep = dependency('liburcu-qsbr', version: '>= 0.8.0') | ||
|
||
subdir('protobuf') | ||
|
||
flowstat_plugin_sources = files( | ||
'src/flowstat.c' | ||
) | ||
|
||
flowstat_plugin = shared_module('flowstat_plugin', | ||
sources: [flowstat_plugin_sources, flowstat_generated_protobuf_c], | ||
dependencies: [dp_dep, dl_dep, dpdk_dep, proto_c_dep, threads_dep, urcu_cds_dep, urcu_dep, urcu_qsbr_dep], | ||
include_directories: [], | ||
name_prefix: '', | ||
install: true, | ||
install_dir: get_option('prefix') / get_option('libdir') / 'vyatta-dataplane' / 'pipeline' / 'plugins' | ||
) | ||
|
||
flowstat_plugin_dep = declare_dependency( | ||
include_directories: [include_directories('src')], | ||
sources: [flowstat_plugin_sources, flowstat_generated_protobuf_c] | ||
) | ||
|
||
subdir('tests') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
option('with_tests', type : 'feature', value : 'enabled') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (c) 2021, SafePoint <[email protected]>. All rights reserved. | ||
// Copyright (c) 2018-2019, AT&T Intellectual Property. All rights reserved. | ||
// | ||
// SPDX-License-Identifier: LGPL-2.1-only | ||
// | ||
|
||
syntax="proto2"; | ||
|
||
message FlowStatFeatConfig { | ||
optional bool is_active = 1; | ||
optional string if_name = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) 2021, SafePoint <[email protected]>. All rights reserved. | ||
// Copyright (c) 2018-2019, AT&T Intellectual Property. All rights reserved. | ||
// | ||
// SPDX-License-Identifier: LGPL-2.1-only | ||
// | ||
|
||
syntax="proto2"; | ||
|
||
message FlowStatOpReq { | ||
//empty | ||
} | ||
|
||
message FlowStatOpResp { | ||
optional uint32 count = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# SPDX-License-Identifier: LGPL-2.1-only | ||
# Copyright (c) 2021, SafePoint <[email protected]>. All rights reserved. | ||
# Copyright (c) 2020, AT&T Intellectual Property. All rights reserved. | ||
|
||
|
||
flowstat_protobuf_sources = [ | ||
'FlowStatFeatConfig.proto', | ||
'FlowStatFeatOp.proto', | ||
] | ||
|
||
install_data(flowstat_protobuf_sources, | ||
install_dir: get_option('datadir') / 'vyatta-dataplane' / 'protobuf' | ||
) | ||
|
||
protoc = find_program('protoc-c') | ||
perl_protobuf_generator = files('../scripts/vyatta-generate-pb-perl.pl') | ||
|
||
protobuf_generated_perl = [] | ||
flowstat_generated_protobuf_c = [] | ||
flowstat_generated_protobuf_c_headers = [] | ||
foreach protobuf_definition : flowstat_protobuf_sources | ||
generated_c = custom_target('c_' + protobuf_definition, | ||
command: [protoc, '--proto_path=@CURRENT_SOURCE_DIR@', '--c_out=@OUTDIR@', '@INPUT@'], | ||
input: protobuf_definition, | ||
output: ['@[email protected]', '@[email protected]'], | ||
) | ||
flowstat_generated_protobuf_c += generated_c | ||
flowstat_generated_protobuf_c_headers += generated_c[1] | ||
|
||
protobuf_generated_perl += custom_target('pl_' + protobuf_definition, | ||
command: [perl_protobuf_generator, '@INPUT@', '@OUTDIR@', '@CURRENT_SOURCE_DIR@'], | ||
input: protobuf_definition, | ||
output: '@[email protected]', | ||
install: true, | ||
install_dir: 'share/perl5/vyatta/proto' | ||
) | ||
endforeach |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#! /usr/bin/perl | ||
|
||
use warnings; | ||
use strict; | ||
|
||
use Carp; | ||
|
||
use MIME::Base64; | ||
use Google::ProtocolBuffers; | ||
|
||
my @arg0 = split(/\//, $ARGV[0]); | ||
my $proto_dir = $arg0[$#arg0 - 1]; | ||
my $proto_file = $arg0[$#arg0]; | ||
|
||
my $target_dir = $ARGV[1]; | ||
|
||
if (substr($proto_file, -6) eq ".proto") { | ||
|
||
my %options; | ||
$options{include_dir} = "../$proto_dir"; | ||
|
||
my $pb_pm = substr($proto_file, 0, length($proto_file) - 6) . ".pm"; | ||
$options{generate_code} = $target_dir . "/$pb_pm"; | ||
|
||
printf("writing out to: " . $target_dir . "/$pb_pm" . "\n"); | ||
|
||
$options{create_accessors} = 1; | ||
$options{follow_best_practice} = 1; | ||
Google::ProtocolBuffers->parsefile($ARGV[0], \%options); | ||
} | ||
|
||
exit 0; |
Oops, something went wrong.