Skip to content

Commit

Permalink
dpif-netdev: Fix a zero-rate bug for meter
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Andy Zhou <[email protected]>
  • Loading branch information
Ali Volkan ATLI authored and azhou-nicira committed Sep 27, 2017
1 parent 1193857 commit 2029ce9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/dpif-netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -4276,10 +4276,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:
Expand Down
2 changes: 2 additions & 0 deletions ofproto/ofproto-dpif.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 2029ce9

Please sign in to comment.