diff options
author | Ali Volkan ATLI <volkan.atli@argela.com.tr> | 2017-09-27 18:33:57 +0300 |
---|---|---|
committer | Andy Zhou <azhou@ovn.org> | 2017-09-27 10:39:24 -0700 |
commit | eb078f4435be357e752121e07c7d4693cc6c9cf8 (patch) | |
tree | a10dc0d47381664a8dffb1016f868026d139f028 | |
parent | 45c7b48f96c617fd97df40d7e83c5dc768e7aa2e (diff) | |
download | openvswitch-eb078f4435be357e752121e07c7d4693cc6c9cf8.tar.gz |
dpif-netdev: Fix a zero-rate bug for meter
Open vSwitch daemon crashes (by receiving signal SIGFPE,
Arithmetic exception) when a controller tries to send
a meter-mod message with zero rate.
Signed-off-by: Ali Volkan ATLI <volkan.atli@argela.com.tr>
Signed-off-by: Andy Zhou <azhou@ovn.org>
-rw-r--r-- | lib/dpif-netdev.c | 9 | ||||
-rw-r--r-- | ofproto/ofproto-dpif.c | 2 |
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 17e166622..e8934629b 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -4077,10 +4077,19 @@ dpif_netdev_meter_set(struct dpif *dpif, ofproto_meter_id *meter_id, !(config->flags & (OFPMF13_KBPS | OFPMF13_PKTPS))) { return EBADF; /* Unsupported flags set */ } + /* Validate bands */ if (config->n_bands == 0 || config->n_bands > MAX_BANDS) { return EINVAL; /* Too many bands */ } + + /* Validate rates */ + for (i = 0; i < config->n_bands; i++) { + if (config->bands[i].rate == 0) { + return EBADRQC; /* rate must be non-zero */ + } + } + for (i = 0; i < config->n_bands; ++i) { switch (config->bands[i].type) { case OFPMBT13_DROP: diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 1a8e829e5..d99dc9d88 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -5695,6 +5695,8 @@ meter_set(struct ofproto *ofproto_, ofproto_meter_id *meter_id, return OFPERR_OFPMMFC_OUT_OF_BANDS; case ENODEV: /* Unsupported band type */ return OFPERR_OFPMMFC_BAD_BAND; + case EBADRQC: /* Rate must be non-zero */ + return OFPERR_OFPMMFC_BAD_RATE; default: return OFPERR_OFPMMFC_UNKNOWN; } |