From: Ben Pfaff Date: Wed, 6 Aug 2014 16:43:31 +0000 (-0700) Subject: dpif-netdev: Avoid divide by zero. X-Git-Tag: v2.3~4 X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fovs.git;a=commitdiff_plain;h=dc3a36324c19168b7e39ac6978b4e0fb4225a116 dpif-netdev: Avoid divide by zero. Otherwise creating the first dpif-netdev bridge fails because there are no handlers: Program terminated with signal 8, Arithmetic exception. #0 0x080971e9 in dp_execute_cb (aux_=aux_@entry=0xffcfaa54, packet=packet@entry=0xffcfac54, md=md@entry=0xffcfac84, a=a@entry=0x8f58930, may_steal=false) at ../lib/dpif-netdev.c:2154 #1 0x080b5adb in odp_execute_actions__ (dp=dp@entry=0xffcfaa54, packet=packet@entry=0xffcfac54, steal=steal@entry=false, md=md@entry=0xffcfac84, actions=actions@entry=0x8f58930, actions_len=actions_len@entry=20, dp_execute_action=dp_execute_action@entry=0x8097040 , more_actions=more_actions@entry=false) at ../lib/odp-execute.c:218 #2 0x080b5def in odp_execute_actions (dp=dp@entry=0xffcfaa54, packet=packet@entry=0xffcfac54, steal=steal@entry=false, md=md@entry=0xffcfac84, actions=0x8f58930, actions_len=20, dp_execute_action=dp_execute_action@entry=0x8097040 ) at ../lib/odp-execute.c:285 #3 0x08095098 in dp_netdev_execute_actions (actions_len=, actions=, md=0xffcfac84, may_steal=false, packet=0xffcfac54, key=0xffcfaa5c, dp=) at ../lib/dpif-netdev.c:2227 #4 dpif_netdev_execute (dpif=0x8f59598, execute=0xffcfac78) at ../lib/dpif-netdev.c:1551 #5 0x0809a56c in dpif_execute (dpif=0x8f59598, execute=execute@entry=0xffcfac78) at ../lib/dpif.c:1227 #6 0x08071071 in check_variable_length_userdata (backer=) at ../ofproto/ofproto-dpif.c:1040 #7 open_dpif_backer (backerp=0x8f5834c, type=) at ../ofproto/ofproto-dpif.c:921 #8 construct (ofproto_=0x8f581c0) at ../ofproto/ofproto-dpif.c:1120 #9 0x080675e0 in ofproto_create (datapath_name=0x8f57310 "br0", datapath_type=, ofprotop=ofprotop@entry=0x8f576c8) at ../ofproto/ofproto.c:564 #10 0x080529aa in bridge_reconfigure (ovs_cfg=ovs_cfg@entry=0x8f596d8) at ../vswitchd/bridge.c:572 #11 0x08055e33 in bridge_run () at ../vswitchd/bridge.c:2339 #12 0x0804cdbd in main (argc=9, argv=0xffcfb554) at ../vswitchd/ovs-vswitchd.c:116 This bug was introduced by commit 9bcefb956d8f (ofproto-dpif: fix an ovs crash when dpif_recv_set returns error). CC: Andy Zhou Signed-off-by: Ben Pfaff Acked-by: Justin Pettit --- diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 69e15d7f5..78f863638 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -2150,11 +2150,13 @@ dp_execute_cb(void *aux_, struct ofpbuf *packet, userdata = nl_attr_find_nested(a, OVS_USERSPACE_ATTR_USERDATA); - dp_netdev_output_userspace(aux->dp, packet, - miniflow_hash_5tuple(aux->key, 0) + if (aux->dp->n_handlers > 0) { + dp_netdev_output_userspace(aux->dp, packet, + miniflow_hash_5tuple(aux->key, 0) % aux->dp->n_handlers, - DPIF_UC_ACTION, aux->key, - userdata); + DPIF_UC_ACTION, aux->key, + userdata); + } if (may_steal) { ofpbuf_delete(packet);