nat: test all intf addrs in is_interface_addr() 53/32453/4
authorAlexander Chernavin <achernavin@netgate.com>
Wed, 26 May 2021 13:55:42 +0000 (09:55 -0400)
committerOle Tr�an <otroan@employees.org>
Wed, 16 Jun 2021 07:58:39 +0000 (07:58 +0000)
commitd52a8921b85057682f2cf5bae7d6353142ba279a
treebce1ea4c27b7106a34d1f316e6975925cbaa2959
parentb862f1dd52b0f5318d67b4463be90562e57f8278
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
src/plugins/nat/nat44-ed/nat44_ed.h
src/plugins/nat/nat44-ed/nat44_ed_inlines.h
src/plugins/nat/nat44-ei/nat44_ei.h
src/plugins/nat/nat44-ei/nat44_ei_inlines.h