Skip to content

Commit

Permalink
northd: Add a new node 'ls_stateful'.
Browse files Browse the repository at this point in the history
This new engine now maintains the load balancer and ACL data of a
logical switch which was earlier part of northd engine node data.
The main inputs to this engine are:
    - northd node
    - Port group node

A record for each logical switch is maintained in the 'ls_statefuls'
hmap table and this record stores the below data which was earlier
part of 'struct ovn_datapath'.

    - bool has_stateful_acl;
    - bool has_lb_vip;
    - bool has_acls;
    - uint64_t max_acl_tier;

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

If a logical switch is configured with
   - DHCP for all or some of its ports
   - stateful ACLs and/or load balancers

ovn-northd was adding flows to commit the DHCP response generated by
ovn-controller to conntrack.  With this patch we don't commit the
DHCP response to conntrack anymore for the following reasons:
  1.  There is no need to actually commit the response.
  2.  Since stateful information is moved to 'ls_stateful' node, it
      becomes ineffecient to access ls_stateful's data
      ('has_lb_vip' and 'has_acls') in build_dhcpv4_options_flows().

Acked-by: Dumitru Ceara <[email protected]>
Signed-off-by: Numan Siddique <[email protected]>
  • Loading branch information
numansiddique committed Feb 2, 2024
1 parent 6547f9f commit 81ef772
Show file tree
Hide file tree
Showing 13 changed files with 792 additions and 181 deletions.
2 changes: 2 additions & 0 deletions lib/stopwatch-names.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@
#define LFLOWS_PORTS_STOPWATCH_NAME "lflows_ports"
#define LFLOWS_LBS_STOPWATCH_NAME "lflows_lbs"
#define LFLOWS_LR_STATEFUL_STOPWATCH_NAME "lflows_lr_stateful"
#define LFLOWS_LS_STATEFUL_STOPWATCH_NAME "lflows_ls_stateful"
#define LFLOWS_IGMP_STOPWATCH_NAME "lflows_igmp"
#define LFLOWS_DP_GROUPS_STOPWATCH_NAME "lflows_dp_groups"
#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"
#define LR_STATEFUL_RUN_STOPWATCH_NAME "lr_stateful"
#define LS_STATEFUL_RUN_STOPWATCH_NAME "ls_stateful"

#endif
2 changes: 2 additions & 0 deletions northd/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ northd_ovn_northd_SOURCES = \
northd/en-lr-nat.h \
northd/en-lr-stateful.c \
northd/en-lr-stateful.h \
northd/en-ls-stateful.c \
northd/en-ls-stateful.h \
northd/inc-proc-northd.c \
northd/inc-proc-northd.h \
northd/ipam.c \
Expand Down
4 changes: 4 additions & 0 deletions northd/en-lflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "en-lflow.h"
#include "en-lr-nat.h"
#include "en-lr-stateful.h"
#include "en-ls-stateful.h"
#include "en-northd.h"
#include "en-meters.h"

Expand All @@ -44,6 +45,8 @@ lflow_get_input_data(struct engine_node *node,
engine_get_input_data("sync_meters", node);
struct ed_type_lr_stateful *lr_stateful_data =
engine_get_input_data("lr_stateful", node);
struct ed_type_ls_stateful *ls_stateful_data =
engine_get_input_data("ls_stateful", node);

lflow_input->nbrec_bfd_table =
EN_OVSDB_GET(engine_get_input("NB_bfd", node));
Expand All @@ -67,6 +70,7 @@ lflow_get_input_data(struct engine_node *node,
lflow_input->lr_ports = &northd_data->lr_ports;
lflow_input->ls_port_groups = &pg_data->ls_port_groups;
lflow_input->lr_stateful_table = &lr_stateful_data->table;
lflow_input->ls_stateful_table = &ls_stateful_data->table;
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
21 changes: 20 additions & 1 deletion northd/en-lr-stateful.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,12 @@ lr_stateful_lb_data_handler(struct engine_node *node, void *data_)
struct hmapx_node *hmapx_node;

HMAPX_FOR_EACH (hmapx_node, &data->trk_data.crupdated) {
lr_stateful_rebuild_vip_nats(hmapx_node->data);
struct lr_stateful_record *lr_stateful_rec = hmapx_node->data;
lr_stateful_rebuild_vip_nats(lr_stateful_rec);
const struct ovn_datapath *od =
ovn_datapaths_find_by_index(input_data.lr_datapaths,
lr_stateful_rec->lr_index);
lr_stateful_rec->has_lb_vip = od_has_lb_vip(od);
}

engine_set_node_state(node, EN_UPDATED);
Expand Down Expand Up @@ -510,11 +515,25 @@ lr_stateful_record_create(struct lr_stateful_table *table,
if (nbr->n_nat) {
lr_stateful_rebuild_vip_nats(lr_stateful_rec);
}
lr_stateful_rec->has_lb_vip = od_has_lb_vip(od);

hmap_insert(&table->entries, &lr_stateful_rec->key_node,
uuid_hash(&lr_stateful_rec->nbr_uuid));

table->array[od->index] = lr_stateful_rec;

/* Load balancers are not supported (yet) if a logical router has multiple
* distributed gateway port. Log a warning. */
if (lr_stateful_rec->has_lb_vip && lr_has_multiple_gw_ports(od)) {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1);
VLOG_WARN_RL(&rl, "Load-balancers are configured on logical "
"router %s, which has %"PRIuSIZE" distributed "
"gateway ports. Load-balancer is not supported "
"yet when there is more than one distributed "
"gateway port on the router.",
od->nbr->name, od->n_l3dgw_ports);
}

return lr_stateful_rec;
}

Expand Down
8 changes: 8 additions & 0 deletions northd/en-lr-stateful.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ struct lr_stateful_record {
/* This lrnat_rec comes from the en_lrnat engine node data. */
const struct lr_nat_record *lrnat_rec;

bool has_lb_vip;

/* Load Balancer vIPs relevant for this datapath. */
struct ovn_lb_ip_set *lb_ips;

Expand Down Expand Up @@ -114,4 +116,10 @@ lr_stateful_has_tracked_data(struct lr_stateful_tracked_data *trk_data)
return !hmapx_is_empty(&trk_data->crupdated);
}

static inline bool
lr_stateful_rec_has_lb_vip(const struct lr_stateful_record *lr_stateful_rec)
{
return lr_stateful_rec && lr_stateful_rec->has_lb_vip;
}

#endif /* EN_lr_stateful_H */
Loading

0 comments on commit 81ef772

Please sign in to comment.