summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-05-22 15:44:20 +0200
committerChristian Poessinger <christian@poessinger.com>2020-05-22 15:44:22 +0200
commitac5019d7aadc11fab3bfaae21c3c3ed9bd07ef3b (patch)
treea177f8dff1bc8606f77fa822cef9d4d776599e31 /src
parent62b86071c6b549ca13c828ecf2619e2ba7750d7b (diff)
downloadvyos-1x-ac5019d7aadc11fab3bfaae21c3c3ed9bd07ef3b.tar.gz
vyos-1x-ac5019d7aadc11fab3bfaae21c3c3ed9bd07ef3b.zip
nat: T2460: fix KeyError: 'sport'
Diffstat (limited to 'src')
-rwxr-xr-xsrc/op_mode/show_nat_translations.py8
1 files changed, 6 insertions, 2 deletions
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: