Skip to content

Commit

Permalink
northd: Add a new engine 'lr_nat' to manage lr NAT data.
Browse files Browse the repository at this point in the history
This new engine now maintains the NAT related data for each
logical router which was earlier maintained by the northd
engine node in the 'struct ovn_datapath'.  The input to
this engine node is 'northd'.

A record for each logical router (lr_nat_record) is maintained
in the 'lr_nats' hmap table which stores the lr's NAT dat.

'northd' engine now reports logical routers changed due to NATs
in its tracking data.  'lr_nat' engine node makes use of
this tracked data in its northd change handler to update the
NAT data.

This engine node becomes an input to 'lflow' node.

Acked-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Numan Siddique <numans@ovn.org>
(cherry picked from commit de42956)
  • Loading branch information
numansiddique committed Feb 2, 2024
1 parent dee3708 commit 2c37d7e
Show file tree
Hide file tree
Showing 14 changed files with 866 additions and 378 deletions.
8 changes: 7 additions & 1 deletion lib/ovn-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,11 +385,17 @@ extract_sbrec_binding_first_mac(const struct sbrec_port_binding *binding,
}

bool
lport_addresses_is_empty(struct lport_addresses *laddrs)
lport_addresses_is_empty(const struct lport_addresses *laddrs)
{
return !laddrs->n_ipv4_addrs && !laddrs->n_ipv6_addrs;
}

void
init_lport_addresses(struct lport_addresses *laddrs)
{
*laddrs = (struct lport_addresses) { 0 };
}

void
destroy_lport_addresses(struct lport_addresses *laddrs)
{
Expand Down
3 changes: 2 additions & 1 deletion lib/ovn-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ bool extract_sbrec_binding_first_mac(const struct sbrec_port_binding *binding,
bool extract_lrp_networks__(char *mac, char **networks, size_t n_networks,
struct lport_addresses *laddrs);

bool lport_addresses_is_empty(struct lport_addresses *);
bool lport_addresses_is_empty(const struct lport_addresses *);
void init_lport_addresses(struct lport_addresses *);
void destroy_lport_addresses(struct lport_addresses *);
const char *find_lport_address(const struct lport_addresses *laddrs,
const char *ip_s);
Expand Down
1 change: 1 addition & 0 deletions lib/stopwatch-names.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@
#define LFLOWS_TO_SB_STOPWATCH_NAME "lflows_to_sb"
#define PORT_GROUP_RUN_STOPWATCH_NAME "port_group_run"
#define SYNC_METERS_RUN_STOPWATCH_NAME "sync_meters_run"
#define LR_NAT_RUN_STOPWATCH_NAME "lr_nat_run"

#endif
2 changes: 2 additions & 0 deletions northd/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ northd_ovn_northd_SOURCES = \
northd/en-sync-from-sb.h \
northd/en-lb-data.c \
northd/en-lb-data.h \
northd/en-lr-nat.c \
northd/en-lr-nat.h \
northd/inc-proc-northd.c \
northd/inc-proc-northd.h \
northd/ipam.c \
Expand Down
5 changes: 5 additions & 0 deletions northd/en-lflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <stdio.h>

#include "en-lflow.h"
#include "en-lr-nat.h"
#include "en-northd.h"
#include "en-meters.h"

Expand All @@ -40,6 +41,9 @@ lflow_get_input_data(struct engine_node *node,
engine_get_input_data("port_group", node);
struct sync_meters_data *sync_meters_data =
engine_get_input_data("sync_meters", node);
struct ed_type_lr_nat_data *lr_nat_data =
engine_get_input_data("lr_nat", node);

lflow_input->nbrec_bfd_table =
EN_OVSDB_GET(engine_get_input("NB_bfd", node));
lflow_input->sbrec_bfd_table =
Expand All @@ -61,6 +65,7 @@ lflow_get_input_data(struct engine_node *node,
lflow_input->ls_ports = &northd_data->ls_ports;
lflow_input->lr_ports = &northd_data->lr_ports;
lflow_input->ls_port_groups = &pg_data->ls_port_groups;
lflow_input->lr_nats = &lr_nat_data->lr_nats;
lflow_input->meter_groups = &sync_meters_data->meter_groups;
lflow_input->lb_datapaths_map = &northd_data->lb_datapaths_map;
lflow_input->svc_monitor_map = &northd_data->svc_monitor_map;
Expand Down

0 comments on commit 2c37d7e

Please sign in to comment.