Skip to content

Commit

Permalink
dpif: Support conntrack zone limit.
Browse files Browse the repository at this point in the history
This patch defines the dpif interface to support conntrack
per zone limit.  Basically, OVS users can use this interface
to set, delete, and get the conntrack per zone limit for various
dpif interfaces.  The following patch will make use of the proposed
interface to implement the feature.

Signed-off-by: Yi-Hung Wei <[email protected]>
Signed-off-by: Justin Pettit <[email protected]>
  • Loading branch information
YiHungWei authored and justinpettit committed Aug 17, 2018
1 parent cb2a548 commit cd015a1
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 0 deletions.
30 changes: 30 additions & 0 deletions lib/ct-dpif.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,36 @@ ct_dpif_get_nconns(struct dpif *dpif, uint32_t *nconns)
: EOPNOTSUPP);
}

int
ct_dpif_set_limits(struct dpif *dpif, const uint32_t *default_limit,
const struct ovs_list *zone_limits)
{
return (dpif->dpif_class->ct_set_limits
? dpif->dpif_class->ct_set_limits(dpif, default_limit,
zone_limits)
: EOPNOTSUPP);
}

int
ct_dpif_get_limits(struct dpif *dpif, uint32_t *default_limit,
const struct ovs_list *zone_limits_in,
struct ovs_list *zone_limits_out)
{
return (dpif->dpif_class->ct_get_limits
? dpif->dpif_class->ct_get_limits(dpif, default_limit,
zone_limits_in,
zone_limits_out)
: EOPNOTSUPP);
}

int
ct_dpif_del_limits(struct dpif *dpif, const struct ovs_list *zone_limits)
{
return (dpif->dpif_class->ct_del_limits
? dpif->dpif_class->ct_del_limits(dpif, zone_limits)
: EOPNOTSUPP);
}

void
ct_dpif_entry_uninit(struct ct_dpif_entry *entry)
{
Expand Down
12 changes: 12 additions & 0 deletions lib/ct-dpif.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,13 @@ struct ct_dpif_dump_state {
struct dpif *dpif;
};

struct ct_dpif_zone_limit {
uint16_t zone;
uint32_t limit; /* Limit on number of entries. */
uint32_t count; /* Current number of entries. */
struct ovs_list node;
};

int ct_dpif_dump_start(struct dpif *, struct ct_dpif_dump_state **,
const uint16_t *zone, int *);
int ct_dpif_dump_next(struct ct_dpif_dump_state *, struct ct_dpif_entry *);
Expand All @@ -200,6 +207,11 @@ int ct_dpif_flush(struct dpif *, const uint16_t *zone,
int ct_dpif_set_maxconns(struct dpif *dpif, uint32_t maxconns);
int ct_dpif_get_maxconns(struct dpif *dpif, uint32_t *maxconns);
int ct_dpif_get_nconns(struct dpif *dpif, uint32_t *nconns);
int ct_dpif_set_limits(struct dpif *dpif, const uint32_t *default_limit,
const struct ovs_list *);
int ct_dpif_get_limits(struct dpif *dpif, uint32_t *default_limit,
const struct ovs_list *, struct ovs_list *);
int ct_dpif_del_limits(struct dpif *dpif, const struct ovs_list *);
void ct_dpif_entry_uninit(struct ct_dpif_entry *);
void ct_dpif_format_entry(const struct ct_dpif_entry *, struct ds *,
bool verbose, bool print_stats);
Expand Down
3 changes: 3 additions & 0 deletions lib/dpif-netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -6825,6 +6825,9 @@ const struct dpif_class dpif_netdev_class = {
dpif_netdev_ct_set_maxconns,
dpif_netdev_ct_get_maxconns,
dpif_netdev_ct_get_nconns,
NULL, /* ct_set_limits */
NULL, /* ct_get_limits */
NULL, /* ct_del_limits */
dpif_netdev_meter_get_features,
dpif_netdev_meter_set,
dpif_netdev_meter_get,
Expand Down
3 changes: 3 additions & 0 deletions lib/dpif-netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -3314,6 +3314,9 @@ const struct dpif_class dpif_netlink_class = {
NULL, /* ct_set_maxconns */
NULL, /* ct_get_maxconns */
NULL, /* ct_get_nconns */
NULL, /* ct_set_limits */
NULL, /* ct_get_limits */
NULL, /* ct_del_limits */
dpif_netlink_meter_get_features,
dpif_netlink_meter_set,
dpif_netlink_meter_get,
Expand Down
29 changes: 29 additions & 0 deletions lib/dpif-provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,35 @@ struct dpif_class {
/* Get number of connections tracked. */
int (*ct_get_nconns)(struct dpif *, uint32_t *nconns);

/* Connection tracking per zone limit */

/* Per zone conntrack limit sets the maximum allowed connections in zones
* to provide resource isolation. If a per zone limit for a particular
* zone is not available in the datapath, it defaults to the default
* per zone limit. Initially, the default per zone limit is
* unlimited (0). */

/* Sets the max connections allowed per zone according to 'zone_limits',
* a list of 'struct ct_dpif_zone_limit' entries (the 'count' member
* is not used when setting limits). If 'default_limit' is not NULL,
* modifies the default limit to '*default_limit'. */
int (*ct_set_limits)(struct dpif *, const uint32_t *default_limit,
const struct ovs_list *zone_limits);

/* Looks up the default per zone limit and stores that in
* 'default_limit'. Look up the per zone limits for all zones in
* the 'zone_limits_in' list of 'struct ct_dpif_zone_limit' entries
* (the 'limit' and 'count' members are not used), and stores the
* reply that includes the zone, the per zone limit, and the number
* of connections in the zone into 'zone_limits_out' list. */
int (*ct_get_limits)(struct dpif *, uint32_t *default_limit,
const struct ovs_list *zone_limits_in,
struct ovs_list *zone_limits_out);

/* Deletes per zone limit of all zones specified in 'zone_limits', a
* list of 'struct ct_dpif_zone_limit' entries. */
int (*ct_del_limits)(struct dpif *, const struct ovs_list *zone_limits);

/* Meters */

/* Queries 'dpif' for supported meter features.
Expand Down

0 comments on commit cd015a1

Please sign in to comment.