Skip to content

Commit 96fbc13

Browse files
azhou-niciradavem330
authored andcommitted
openvswitch: Add meter infrastructure
OVS kernel datapath so far does not support Openflow meter action. This is the first stab at adding kernel datapath meter support. This implementation supports only drop band type. Signed-off-by: Andy Zhou <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9602c01 commit 96fbc13

File tree

5 files changed

+674
-2
lines changed

5 files changed

+674
-2
lines changed

net/openvswitch/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ openvswitch-y := \
1212
flow.o \
1313
flow_netlink.o \
1414
flow_table.o \
15+
meter.o \
1516
vport.o \
1617
vport-internal_dev.o \
1718
vport-netdev.o

net/openvswitch/datapath.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#include "flow.h"
5656
#include "flow_table.h"
5757
#include "flow_netlink.h"
58+
#include "meter.h"
5859
#include "vport-internal_dev.h"
5960
#include "vport-netdev.h"
6061

@@ -174,6 +175,7 @@ static void destroy_dp_rcu(struct rcu_head *rcu)
174175
ovs_flow_tbl_destroy(&dp->table);
175176
free_percpu(dp->stats_percpu);
176177
kfree(dp->ports);
178+
ovs_meters_exit(dp);
177179
kfree(dp);
178180
}
179181

@@ -1572,6 +1574,10 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
15721574
for (i = 0; i < DP_VPORT_HASH_BUCKETS; i++)
15731575
INIT_HLIST_HEAD(&dp->ports[i]);
15741576

1577+
err = ovs_meters_init(dp);
1578+
if (err)
1579+
goto err_destroy_ports_array;
1580+
15751581
/* Set up our datapath device. */
15761582
parms.name = nla_data(a[OVS_DP_ATTR_NAME]);
15771583
parms.type = OVS_VPORT_TYPE_INTERNAL;
@@ -1600,7 +1606,7 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
16001606
ovs_dp_reset_user_features(skb, info);
16011607
}
16021608

1603-
goto err_destroy_ports_array;
1609+
goto err_destroy_meters;
16041610
}
16051611

16061612
err = ovs_dp_cmd_fill_info(dp, reply, info->snd_portid,
@@ -1615,8 +1621,10 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
16151621
ovs_notify(&dp_datapath_genl_family, reply, info);
16161622
return 0;
16171623

1618-
err_destroy_ports_array:
1624+
err_destroy_meters:
16191625
ovs_unlock();
1626+
ovs_meters_exit(dp);
1627+
err_destroy_ports_array:
16201628
kfree(dp->ports);
16211629
err_destroy_percpu:
16221630
free_percpu(dp->stats_percpu);
@@ -2265,6 +2273,7 @@ static struct genl_family * const dp_genl_families[] = {
22652273
&dp_vport_genl_family,
22662274
&dp_flow_genl_family,
22672275
&dp_packet_genl_family,
2276+
&dp_meter_genl_family,
22682277
};
22692278

22702279
static void dp_unregister_genl(int n_families)
@@ -2445,3 +2454,4 @@ MODULE_ALIAS_GENL_FAMILY(OVS_DATAPATH_FAMILY);
24452454
MODULE_ALIAS_GENL_FAMILY(OVS_VPORT_FAMILY);
24462455
MODULE_ALIAS_GENL_FAMILY(OVS_FLOW_FAMILY);
24472456
MODULE_ALIAS_GENL_FAMILY(OVS_PACKET_FAMILY);
2457+
MODULE_ALIAS_GENL_FAMILY(OVS_METER_FAMILY);

net/openvswitch/datapath.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ struct datapath {
9292
u32 user_features;
9393

9494
u32 max_headroom;
95+
96+
/* Switch meters. */
97+
struct hlist_head *meters;
9598
};
9699

97100
/**

0 commit comments

Comments
 (0)