From ac5019d7aadc11fab3bfaae21c3c3ed9bd07ef3b Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Fri, 22 May 2020 15:44:20 +0200 Subject: nat: T2460: fix KeyError: 'sport' --- src/op_mode/show_nat_translations.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/op_mode') diff --git a/src/op_mode/show_nat_translations.py b/src/op_mode/show_nat_translations.py index e888f3509..3af33b78e 100755 --- a/src/op_mode/show_nat_translations.py +++ b/src/op_mode/show_nat_translations.py @@ -117,8 +117,12 @@ def process(data, stats, protocol, pipe, verbose, flowtype=''): if 'layer4' in meta: l4 = meta['layer4'] - sport[direction] = l4[SPORT] - dport[direction] = l4[DPORT] + sp = l4.get(SPORT, '') + dp = l4.get(DPORT, '') + if sp: + sport[direction] = sp + if dp: + dport[direction] = dp proto[direction] = l4.get('@protoname','') if stats and 'counters' in meta: -- cgit v1.2.3