Commit Graph

541 Commits

Author SHA1 Message Date
Klement Sekera
e506fbc9fe nat: ICMP handling fixes
If ICMP comes from a router on path, source address must not be
rewritten in o2i path to avoid getting wrong checksum.

Fix ICMP checksum computations.

Type: fix
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Change-Id: I035debccf966d7dbd63c364cb1e43380d641f708
2021-06-23 17:18:35 +00:00
Klement Sekera
79699b00c1 nat: don't drop packet with ttl=1 if output feature
TTL was already decremented in ip4-rewrite so it's okay if it's 1.

Type: fix
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Change-Id: I587dc343737c15247eb62837a06d5e44c0d11acc
2021-06-22 13:23:38 +00:00
Alexander Chernavin
d52a8921b8 nat: test all intf addrs in is_interface_addr()
Type: fix

Currently, is_interface_addr() tests if a given IPv4 address belongs to
an interface by a given sw_if_index. However, there are several issues:
 * only the first found address on the interface is actually tested,
 * sw_if_index is always cached even if the interface hasn't been
   assigned any addresses yet.

With this change, is_interface_addr() tests all IPv4 addresses on an
interface by a given sw_if_index and caches sw_if_index only if there
are addresses present.

Signed-off-by: Alexander Chernavin <achernavin@netgate.com>
Change-Id: If1acc4a534647a5f0ce8e9b565b867c92a016dc3
2021-06-16 07:58:39 +00:00
Alexander Chernavin
b862f1dd52 nat: fix crash when translate unknown proto packets
Type: fix

Currently, there might be a crash in NAT ED mode:
 * if a session for an unknown proto packet cannot be created in2out,
 * if a session for an unknown proto packet cannot be found out2in.

With this change, translate packets only if a session is given in NAT
ED mode.

Signed-off-by: Alexander Chernavin <achernavin@netgate.com>
Change-Id: Iafb332db1ae9a3e76435964ad636037d1b8a51e8
2021-06-16 07:58:17 +00:00
Ruslan Babayev
90f7008dc0 nat: fix broken nat44-ed cli
snat_set_frame_queue_nelts has been replaced with
nat44_ed_set_frame_queue_nelts.

Type: fix
Signed-off-by: Ruslan Babayev <ruslan@babayev.com>
Change-Id: I8d970be71376fdbb2bfd383d4d5824a8def93bb3
2021-05-31 20:23:57 -07:00
Klement Sekera
2de7e96e6f nat: add thread index assertions
Add extra assertions to debug build.

Type: improvement
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Change-Id: Ib20130365e8f9dbb556fcbb4321dd184c7eff603
2021-05-26 07:38:01 +00:00
Matthew Smith
01930f568a nat: report correct EI per-user session limit
Type: fix

When enabling the endpoint independent NAT44 plugin, user_sessions
determines the maximum number of translations that can be active for
a single inside address. If 0 is passed in, a default value is used
but 0 is still stored in the field that is used to populate reply
messages to nat44_ei_show_running_config,

At the time of enabling the plugin, if user_sessions is 0, update the
field which is used by nat44_ei_show_running_config to contain the
default per-user limit which gets used by the EI nodes.

Change-Id: I6b060d85bcd42d91db879b95a8b07c6844bcd2a5
Signed-off-by: Matthew Smith <mgsmith@netgate.com>
2021-05-25 13:12:01 +00:00
Ole Troan
92a8d761c4 nat: add maximum configured sessions to stat segment
Add /nat44-ed/max-cfg-sessions gauge.
Reflects the configured value for configured sessions (per thread).

Type: improvement
Signed-off-by: Ole Troan <ot@cisco.com>
Change-Id: I618c8aa0daab0981399cfe9273d191fa1990ef60
Signed-off-by: Ole Troan <ot@cisco.com>
2021-05-21 16:49:30 +00:00
Damjan Marion
9e7a0b48fe vlib: pass node runtime to vlib_buffer_enqueue_to_thread()
Mechanical change for patch following this one...

Type: improvement
Change-Id: Iee12f3a8851f35569e6c039494a94fc36e83d20f
Signed-off-by: Damjan Marion <damarion@cisco.com>
2021-05-14 15:56:44 +00:00
Dave Wallace
eddd8e3588 tests: move test source to vpp/test
- Generate copyright year and version
  instead of using hard-coded data

Type: refactor

Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
Change-Id: I6058f5025323b3aa483f5df4a2c4371e27b5914e
2021-05-13 09:33:06 +00:00
Ole Troan
2c4acdd8d4 vlib: rename vl_counter_t to vlib_error_desc_t
Type: improvement
Signed-off-by: Ole Troan <ot@cisco.com>
Change-Id: I368b0410db2d633d3c52199c840e24d21952c1b4
2021-05-06 14:19:55 +00:00
Ole Troan
ec34fb7723 pnat: coverity errors
Type: fix
Signed-off-by: Ole Troan <ot@cisco.com>
Change-Id: Ic38cfbdcab86172bad6ec6cb4c66c83f8deed64f
Signed-off-by: Ole Troan <ot@cisco.com>
2021-05-06 13:47:20 +02:00
Filip Varga
9d91e0271f nat: cli commands parsing fix
Newline get's ignored when parsing configuration file.

Type: fix

Signed-off-by: Filip Varga <fivarga@cisco.com>
Change-Id: Ib4f86177150dfe3bc085231a9268cf730490ea81
2021-05-05 13:23:50 +00:00
Filip Varga
ae80aba3b0 nat: fixing cfg file parsing cli issues
Type: fix

Change-Id: I35012bb2f7af1996c954641af40f3223bc7f37e4
Signed-off-by: Filip Varga <fivarga@cisco.com>
2021-05-05 13:21:24 +00:00
Benoît Ganne
f89bbbe300 vlib: refactor trajectory trace debug feature
trajectory trace has been broken for a while because we used to save the
buffer trajectory in a vector pointed to in opaque2. This does not work
well when opaque2 is copied (eg. because of a clone) as 2 buffers end up
sharing the same vector.
This dedicates a full cacheline in the buffer metadata instead when
trajectory is compiled in. No dynamic allocation, no sharing, no tears.

Type: refactor

Change-Id: I6a028ca1b48d38f393a36979e5e452c2dd48ad3f
Signed-off-by: Benoît Ganne <bganne@cisco.com>
2021-05-01 11:42:37 +00:00
Matthew Smith
e3f078fcfc nat: fix byte order on ipfix message fields
Type: fix

The code for quota exceeded events is a u32 and was being copied
into ipfix packets in host byte order. Same for the limit field.

Swap the order before copying into packet buffer.

This change was applied once before but had to be reverted. This was
because between the time the change was uploaded/reviewed and the
time it was merged, a different patch was merged which activated a
NAT ipfix unit test that had formerly only been run as part of the
extended tests. The test was expecting the values to be in host byte
order so it failed with this patch applied. This time around, that
test has also been updated to expect network byte order.

Change-Id: If5413b1f806d664f6786e56ba13c3eee573c26d2
Signed-off-by: Matthew Smith <mgsmith@netgate.com>
2021-04-28 06:30:36 +00:00
Klement Sekera
1ca6c65e51 nat: correct detection of icmp bypass presence
Type: fix
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Change-Id: Iead167e7497e0779c440f7fb243014a06ae2b452
2021-04-23 19:59:27 +00:00
Klement Sekera
1fbf034e3e nat: fix multi worker scenarios
Properly select worker from hash table in out2in direction, increase
number of worker threads in MW test to 4 to test these cases.

Type: fix
Change-Id: I76eda5761ff497b85b031dd913a64b7fcb53b33a
Signed-off-by: Klement Sekera <ksekera@cisco.com>
2021-04-21 09:24:50 +00:00
Filip Varga
f9e02772bc nat: fixing cli bug for nat44-ei and nat44-ed
Removing obsolete optional parameters.

Type: fix

Change-Id: I135eb4767979ab81636da16e91752a2ad80e0a45
Signed-off-by: Filip Varga <fivarga@cisco.com>
2021-04-20 17:05:10 +00:00
Filip Varga
3b3cbfb1c0 nat: nat44-ed i2o & o2i trace fix
If cache used than we don't print in trace session index.

Type: fix

Change-Id: Ib965cd8632b5217f8b2dd8b6cc6af3286c747582
Signed-off-by: Filip Varga <fivarga@cisco.com>
2021-04-20 16:01:48 +00:00
Filip Varga
bdd6149cc4 nat: test dynamic translation between two vrfs
Adding test for NAT44-ED subplugin.

Type: test

Change-Id: I10ce3d3ca8cb976ee9879efe77cb600df0102147
Signed-off-by: Filip Varga <fivarga@cisco.com>
2021-04-14 12:52:15 +00:00
Klement Sekera
3887be7d37 tests: remove wrappers
Improve the code by removing another kind of wrappers.

Type: improvement
Change-Id: I5292ef6c1761e3c6c2edd15f2aa625dac26c3732
Signed-off-by: Klement Sekera <ksekera@cisco.com>
2021-04-06 18:37:40 +02:00
Klement Sekera
acc665a9de nat: fix ordering of feature nodes
Fix ordering of feature nodes so that ACL runs after NAT in in2out
direction so it can properly track stuff like ports after NAT rewrite.

Type: fix
Change-Id: I2c689b64765628e9bc77108914f74c6c801d8ce2
Signed-off-by: Klement Sekera <ksekera@cisco.com>
2021-04-01 13:44:52 +00:00
Klement Sekera
5dffd84188 nat: enable multiworker tests
Type: fix
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Change-Id: I4a5d52d54aa2748008e896888bfeabb18a1088bb
2021-03-31 20:32:37 +00:00
Klement Sekera
b2da6d6602 nat: fix test for multi-worker scenario
Type: fix
Change-Id: I170f9d8c685f59b7ccf6f9ee7fdc1dcdf2a54fe1
Signed-off-by: Klement Sekera <ksekera@cisco.com>
2021-03-31 15:42:58 +00:00
Klement Sekera
17bd30384c nat: correct thread index usage
Use actual thread index from hash table instead of doing calculation.
Calculated index might be different and could lead to crash.

Type: fix
Change-Id: Iede9a67fbe541cb44eccd0d6ddf4e2c51eb35423
Signed-off-by: Klement Sekera <ksekera@cisco.com>
2021-03-31 13:40:05 +00:00
Klement Sekera
68b493ff2f nat: avoid creating negative zero checksum
Type: fix
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Change-Id: Ibbb72e77c751b7e775620cfb160b52ceff2da86b
2021-03-31 11:46:54 +00:00
Filip Varga
8f76064716 nat: NAT44-ED unused value removal
Type: fix

Coverity scan issue fix.

Change-Id: I9036fade15fd381da9c1e6b575f250fdcb21f876
Signed-off-by: Filip Varga <fivarga@cisco.com>
2021-03-31 11:46:42 +00:00
Filip Varga
ed2ee5e57b nat: NAT66 plugin enable&disable calls update
Type: improvement

Adding support for enable&disable calls
(dynamic plugin configuration).
API (nat66_plugin_enable_disable) and
CLI (nat66 plugin enable/nat66 plugin disable) with support for
outside_vrf id configuration.

Change-Id: I5637ff1621d6662adc3b7c6f7f8176d84a4b492b
Signed-off-by: Filip Varga <fivarga@cisco.com>
2021-03-31 11:46:05 +00:00
Klement Sekera
eafb5db63f nat: fix HA multi-worker issues
Use correct vlib_main() in various code parts. Fix tests.

Type: fix
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Change-Id: Ia379f3b686599532dedaafad2278c4097a3f03f3
2021-03-30 12:26:25 +00:00
Damjan Marion
fd8deb48c7 vlib: split vlib_main_t into global and per-thread
Type: refactor
Change-Id: I8b273bc3bf16aa360f031f1b2692f766e5fc4613
Signed-off-by: Damjan Marion <damarion@cisco.com>
2021-03-26 16:33:42 +01:00
Damjan Marion
6ffb7c6189 vlib: introduce vlib_get_main_by_index(), vlib_get_n_threads()
Type: improvement
Change-Id: If3da7d4338470912f37ff1794620418d928fb77f
Signed-off-by: Damjan Marion <damarion@cisco.com>
2021-03-26 16:33:21 +01:00
Klement Sekera
418bf6aaef nat: allocate enough space for full port usage
Type: fix
Change-Id: I068bfeaf22b9e6cce967c27acdd46d4b8541bdf8
Signed-off-by: Klement Sekera <ksekera@cisco.com>
2021-03-25 19:48:40 +00:00
Klement Sekera
403f9b5430 nat: fix bihash kvp print
Type: fix
Change-Id: I392d348b1a38affac8761b0614b117cd991958d7
Signed-off-by: Klement Sekera <ksekera@cisco.com>
2021-03-25 18:34:57 +00:00
Klement Sekera
c294c5057d nat: prevent usage of ED nodes in EI code
Type: fix
Change-Id: I84d511c30eb5878a1867f5e9d2207a39d4f0926c
Signed-off-by: Klement Sekera <ksekera@cisco.com>
2021-03-25 09:40:02 +00:00
Klement Sekera
07bc8bb1ed nat: fix vnet_feature_next in source hairpinning
Avoid erroneous double vnet_feature_next if routing buffer manually.

Type: fix
Change-Id: I3f56c12bf57f59a1e5ddad63a2565fa195934cf6
Signed-off-by: Klement Sekera <ksekera@cisco.com>
2021-03-25 09:37:13 +00:00
Klement Sekera
8d8150262b tests: add support for worker awareness
VppTestCase now has vpp_worker_count property set to number of workers.
This can be overriden by child classes. Also overriden by
VPP_WORKER_CONFIG variable for legacy reasons.

Type: improvement
Change-Id: Ic328bacb9003ddf9e92815767653bd362aa7f086
Signed-off-by: Klement Sekera <ksekera@cisco.com>
2021-03-20 01:14:20 +00:00
Klement Sekera
3a5bd85476 nat: get rid of worker selection callbacks
Make code easier to read and debug.

Type: improvement
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Change-Id: Ib52a4cdd3bcdcc475053aa32af3964c00859e1cd
2021-03-15 22:07:43 +01:00
Andrew Yourtchenko
ab3151c52e nat: pnat copy and clear byte instructions
Type: feature
Signed-off-by: Ole Troan <ot@cisco.com>
Change-Id: I8e48bdcc4c311717e067bb0a4e0b409a2eb8e83d
Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
Signed-off-by: Ole Troan <ot@cisco.com>
2021-03-15 17:53:05 +00:00
Klement Sekera
350771de79 nat: remove unused parameter
Type: refactor
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Change-Id: Ifb4a9c52fd2c5dd9f3f5cf41214aa1851f6d7acd
2021-03-15 16:36:35 +01:00
Klement Sekera
0ac8d857a5 nat: remove unused import
Type: style
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Change-Id: I66b7ed03f784f3992a910ad6a52ed89116a39297
2021-03-12 13:46:16 +00:00
Andrew Yourtchenko
4e4864112a tests: re-enable the rest of NAT44ED tests for multiworker
Type: test
Change-Id: I37a12e3580c3631582f366944fe30f325b46f366
Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
2021-03-09 18:43:11 +01:00
Klement Sekera
d2b6997573 nat: fix dst nat thread issues
Make sure packet lands on the right thread for dst nat case.

Type: fix
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Change-Id: I0ec4e4c2bb3fa80ff73fac588c36d36420ba68fa
2021-03-09 17:54:22 +01:00
Ole Troan
d01caf7fa2 pnat: coverity fixes
Type: fix
Signed-off-by: Ole Troan <ot@cisco.com>
Change-Id: Ia1cfdbd39ed458cb3fffd29a8b6d6eff64644de8
2021-03-09 10:11:57 +00:00
Klement Sekera
e3416e307e nat: replace main vlib with per-thread vlib
Fix incorrect vlib main usage.

Type: fix
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Change-Id: Ic5304ca844f1b27756818eb6995b1d9c08412674
2021-03-07 23:39:25 +00:00
Klement Sekera
76401c5767 nat: fix worker selection
Use correct ports from SVR. Perform lookup of existing session for all
cases to pick any created bypasses and derive correct thread indexes.

Type: fix
Change-Id: I1e3814c9e13cd4d9b8d65f514f7e9ab42df3c22e
Signed-off-by: Klement Sekera <ksekera@cisco.com>
2021-03-07 17:57:32 +00:00
Klement Sekera
e79bbe918b nat: test - add show trace
Add missing show trace.

Type: improvement
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Change-Id: I2f216bfc1bc70ebcbf5593214d46601f44f0b6e2
2021-03-07 17:56:51 +00:00
Klement Sekera
46353f0693 nat: use correct node indexes for queues
Type: fix
Change-Id: I30b847acc4653fea9d609fc0d5875c3fda0824ef
Signed-off-by: Klement Sekera <ksekera@cisco.com>
2021-03-06 17:29:25 +00:00
Klement Sekera
2c0b6b462b nat: avoid crash if plugin not enabled
Avoid crash if nat pool not allocated when issuing "show nat44 summary".

Type: fix
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Change-Id: I55661cf699bab04f4673e9d471fe12486e972067
2021-03-01 20:26:00 +01:00
Klement Sekera
dc243ee2bc nat: pick outside addr based on local addr
Use outside addresses more evenly by using local address to pick from
pool of addresses. This ensures stability from POV of remote host -
an internal host always gets translated using the same outside address,
so it doesn't appear to be "hopping". Also, this avoids all hosts
being translated using the first address, which helps avoid needless
recaptchas and the like.

Exact assignment depends on internal ordering of addresses - local address
is used to pick an offset into internal vector. If that address cannot be
used, a linear search is performed as a fallback mechanism to find a possible
translation.

Type: improvement
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Change-Id: I7ccb1da1dda5537f5d30d2f4cb48024f4b51c1a4
2021-03-01 13:03:20 +01:00