From a4a6414c901e255c331bd38d3f202b9221c058dd Mon Sep 17 00:00:00 2001 From: DmitriyEshenko Date: Thu, 24 Dec 2020 19:33:50 +0000 Subject: wanloadbalance: T3152: Change conntrack statistics file location --- scripts/vyatta-wlb-connection.pl | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/scripts/vyatta-wlb-connection.pl b/scripts/vyatta-wlb-connection.pl index 2f59545..b034821 100644 --- a/scripts/vyatta-wlb-connection.pl +++ b/scripts/vyatta-wlb-connection.pl @@ -29,9 +29,11 @@ use lib "/opt/vyatta/share/perl5/"; if (!open($CONFFILE, "<", "/var/run/load-balance/wlb.conf")) { return; } +$nat_source_disabled = 0; $_ = <$CONFFILE>; if (/disable-source-nat/) { - if (!open($FILE, "<", "/proc/net/ip_conntrack")) { + $nat_source_disabled = 1; + if (!open($FILE, "<", "/proc/net/nf_conntrack")) { return; } } else { @@ -48,11 +50,20 @@ foreach (@line) { my $proto,$tmp,$state,$src,$dst,$sport,$dport,$pkts,$bytes; - if (/tcp/) { - ($proto,$tmp,$tmp,$state,$src,$dst,$sport,$dport,$pkts,$bytes) = split(' ',$_); - } elsif (/udp/) { - $state = ""; - ($proto,$tmp,$tmp,$src,$dst,$sport,$dport,$pkts,$bytes) = split(' ',$_); + if($nat_source_disabled){ + if (/tcp/) { + ($tmp,$tmp,$proto,$tmp,$tmp,$state,$src,$dst,$sport,$dport,$pkts,$bytes) = split(' ',$_); + } elsif (/udp/) { + $state = ""; + ($tmp,$tmp,$proto,$tmp,$tmp,$src,$dst,$sport,$dport,$pkts,$bytes) = split(' ',$_); + } + } else { + if (/tcp/) { + ($proto,$tmp,$tmp,$state,$src,$dst,$sport,$dport,$pkts,$bytes) = split(' ',$_); + } elsif (/udp/) { + $state = ""; + ($proto,$tmp,$tmp,$src,$dst,$sport,$dport,$pkts,$bytes) = split(' ',$_); + } } ($tmp,$src) = split('=',$src); -- cgit v1.2.3 From 6f1baf6a2adb6fb986b28b8b7ee739cd66322aff Mon Sep 17 00:00:00 2001 From: DmitriyEshenko Date: Thu, 24 Dec 2020 19:34:47 +0000 Subject: wanloadbalance: T3152: Enable conntrack counters --- scripts/vyatta-wanloadbalance.pl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/vyatta-wanloadbalance.pl b/scripts/vyatta-wanloadbalance.pl index a64d494..f476ac2 100644 --- a/scripts/vyatta-wanloadbalance.pl +++ b/scripts/vyatta-wanloadbalance.pl @@ -319,6 +319,9 @@ my $conf_file = '/var/run/load-balance/wlb.conf'; my $conf_lck_file = '/var/run/load-balance/wlb.conf.lck'; `sudo mkdir -p /var/run/load-balance`; +# Enable conntrack counters +`sudo sysctl -w net.netfilter.nf_conntrack_acct=1`; + ####are we just validating? if (defined $nexthop) { my $rc = Vyatta::TypeChecker::validateType('ipv4', $nexthop, 1); -- cgit v1.2.3