diff options
author | ldejing <ldejing@vmware.com> | 2022-08-18 19:11:00 +0800 |
---|---|---|
committer | Alin-Gabriel Serdean <aserdean@ovn.org> | 2022-09-20 02:48:44 +0300 |
commit | b26015c33fe420399fff1c9f35d1e3204c441954 (patch) | |
tree | 7f5ea882a645a452a41da75e4834caf7bfe1fbd0 /datapath-windows/ovsext/Datapath.c | |
parent | 7af5c33c1629b309cbcbe3b6c9c3bd6d3b4c0abf (diff) | |
download | openvswitch-b26015c33fe420399fff1c9f35d1e3204c441954.tar.gz |
datapath-windows: support meter action initial version
This patch implemented meter action, currently, meter only support drop
method and only support one band. The overall implementation is, when a
packet comes in, it will first lookup meter according to the meter id,
then get the band->rates and delta time since last access the same meter
from the meter struct. Add the multiply result(band->rates * delta_time)
to bucket, finally bucket minus the packet size, if the result larger
than zero, allow the packet go through, otherwise deny the packet go
through.
Test case:
1. Setting the size meter size 3M, then the bandwidth was limit
around 3M;
ovs-ofctl -O OpenFlow13 add-meter br-test meter=2,kbps,\
band=type=drop,rate=3000
ovs-ofctl add-flow br-test "table=0,priority=1,ip \
actions=meter:2,normal" -O OpenFlow13
2. Setting the meter size 8M, then the bandwidth was limit
around 8M;
ovs-ofctl -O OpenFlow13 add-meter br-test meter=2,\
kbps,band=type=drop,rate=8000
ovs-ofctl add-flow br-test "table=0,priority=1,ip\
actions=meter:2,normal" -O OpenFlow13
Signed-off-by: ldejing <ldejing@vmware.com>
Signed-off-by: Alin-Gabriel Serdean <aserdean@ovn.org>
Diffstat (limited to 'datapath-windows/ovsext/Datapath.c')
-rw-r--r-- | datapath-windows/ovsext/Datapath.c | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/datapath-windows/ovsext/Datapath.c b/datapath-windows/ovsext/Datapath.c index fa994840a..37db5bd17 100644 --- a/datapath-windows/ovsext/Datapath.c +++ b/datapath-windows/ovsext/Datapath.c @@ -100,7 +100,11 @@ NetlinkCmdHandler OvsGetNetdevCmdHandler, OvsReadPacketCmdHandler, OvsCtDeleteCmdHandler, OvsCtDumpCmdHandler, - OvsCtLimitHandler; + OvsCtLimitHandler, + OvsMeterFeatureProbe, + OvsNewMeterCmdHandler, + OvsMeterDestroy, + OvsMeterGet; static NTSTATUS HandleGetDpTransaction(POVS_USER_PARAMS_CONTEXT usrParamsCtx, UINT32 *replyLen); @@ -307,6 +311,43 @@ NETLINK_FAMILY nlCtFamilyOps = { .opsCount = ARRAY_SIZE(nlCtFamilyCmdOps) }; +/* Netlink Meter family */ +NETLINK_CMD nlMeterFamilyCmdOps[] = { + { .cmd = OVS_METER_CMD_FEATURES, + .handler = OvsMeterFeatureProbe, + .supportedDevOp = OVS_TRANSACTION_DEV_OP | + OVS_WRITE_DEV_OP | OVS_READ_DEV_OP, + .validateDpIndex = FALSE + }, + { .cmd = OVS_METER_CMD_SET, + .handler = OvsNewMeterCmdHandler, + .supportedDevOp = OVS_TRANSACTION_DEV_OP | + OVS_WRITE_DEV_OP | OVS_READ_DEV_OP, + .validateDpIndex = FALSE + }, + { .cmd = OVS_METER_CMD_GET, + .handler = OvsMeterGet, + .supportedDevOp = OVS_TRANSACTION_DEV_OP | + OVS_WRITE_DEV_OP | OVS_READ_DEV_OP, + .validateDpIndex = FALSE + }, + { .cmd = OVS_METER_CMD_DEL, + .handler = OvsMeterDestroy, + .supportedDevOp = OVS_TRANSACTION_DEV_OP | + OVS_WRITE_DEV_OP | OVS_READ_DEV_OP, + .validateDpIndex = FALSE + }, +}; + +NETLINK_FAMILY nlMeterFamilyOps = { + .name = OVS_METER_FAMILY, + .id = OVS_WIN_NL_METER_FAMILY_ID, + .version = OVS_METER_VERSION, + .maxAttr = __OVS_METER_ATTR_MAX, + .cmds = nlMeterFamilyCmdOps, + .opsCount = ARRAY_SIZE(nlMeterFamilyCmdOps) +}; + /* Netlink netdev family. */ NETLINK_CMD nlNetdevFamilyCmdOps[] = { { .cmd = OVS_WIN_NETDEV_CMD_GET, @@ -952,6 +993,9 @@ OvsDeviceControl(PDEVICE_OBJECT deviceObject, case NFNL_TYPE_CT_DEL: nlFamilyOps = &nlCtFamilyOps; break; + case OVS_WIN_NL_METER_FAMILY_ID: + nlFamilyOps = &nlMeterFamilyOps; + break; case OVS_WIN_NL_CTRL_FAMILY_ID: nlFamilyOps = &nlControlFamilyOps; break; |