Skip to content

Commit

Permalink
netdev-dummy: Drop "nobody listened" reply from netdev-dummy/receive.
Browse files Browse the repository at this point in the history
Ethan pointed out that this wasn't very useful.

Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
blp committed May 28, 2013
1 parent 2273ea5 commit 323cc92
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 31 deletions.
18 changes: 3 additions & 15 deletions lib/netdev-dummy.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,32 +435,26 @@ eth_from_packet_or_flow(const char *s)
return packet;
}

static int
static void
netdev_dummy_queue_packet(struct netdev_dummy *dummy,
const void *data, size_t size)
{
struct netdev_rx_dummy *rx;
int n_listeners;

n_listeners = 0;
LIST_FOR_EACH (rx, node, &dummy->rxes) {
if (rx->recv_queue_len < NETDEV_DUMMY_MAX_QUEUE) {
struct ofpbuf *copy = ofpbuf_clone_data(data, size);
list_push_back(&rx->recv_queue, &copy->list_node);
rx->recv_queue_len++;
n_listeners++;
}
}

return n_listeners;
}

static void
netdev_dummy_receive(struct unixctl_conn *conn,
int argc, const char *argv[], void *aux OVS_UNUSED)
{
struct netdev_dummy *dummy_dev;
int n_listeners;
int i;

dummy_dev = shash_find_data(&dummy_netdevs, argv[1]);
Expand All @@ -469,7 +463,6 @@ netdev_dummy_receive(struct unixctl_conn *conn,
return;
}

n_listeners = 0;
for (i = 2; i < argc; i++) {
struct ofpbuf *packet;

Expand All @@ -482,16 +475,11 @@ netdev_dummy_receive(struct unixctl_conn *conn,
dummy_dev->stats.rx_packets++;
dummy_dev->stats.rx_bytes += packet->size;

n_listeners += netdev_dummy_queue_packet(dummy_dev,
packet->data, packet->size);
netdev_dummy_queue_packet(dummy_dev, packet->data, packet->size);
ofpbuf_delete(packet);
}

if (!n_listeners) {
unixctl_command_reply(conn, "packets queued but nobody listened");
} else {
unixctl_command_reply(conn, "success");
}
unixctl_command_reply(conn, NULL);
}

static void
Expand Down
24 changes: 8 additions & 16 deletions tests/ofproto-dpif.at
Original file line number Diff line number Diff line change
Expand Up @@ -1986,8 +1986,7 @@ AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0],
# flow stats updates are mainly what implements the fin_timeout
# feature, we warp forward a couple of times to ensure that flow stats
# run before re-checking the flow table.)
AT_CHECK([ovs-appctl netdev-dummy/receive br0 0021853763af0026b98cb0f908004500003c2e2440004006465dac11370dac11370b828b0016751e267b00000000a00216d017360000020405b40402080a2d25085f0000000001030307], [0], [success
])
AT_CHECK([ovs-appctl netdev-dummy/receive br0 0021853763af0026b98cb0f908004500003c2e2440004006465dac11370dac11370b828b0016751e267b00000000a00216d017360000020405b40402080a2d25085f0000000001030307])
AT_CHECK([ovs-appctl time/warp 1000 && ovs-appctl time/warp 1000], [0], [warped
warped
])
Expand All @@ -1996,8 +1995,7 @@ AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0],
n_packets=1, n_bytes=74, idle_timeout=60, actions=fin_timeout(idle_timeout=5)
])
# Check that a TCP FIN packet does change the timeout.
AT_CHECK([ovs-appctl netdev-dummy/receive br0 0021853763af0026b98cb0f90800451000342e3e40004006463bac11370dac11370b828b0016751e319dfc96399b801100717ae800000101080a2d250a9408579588], [0], [success
])
AT_CHECK([ovs-appctl netdev-dummy/receive br0 0021853763af0026b98cb0f90800451000342e3e40004006463bac11370dac11370b828b0016751e319dfc96399b801100717ae800000101080a2d250a9408579588])
AT_CHECK([ovs-appctl time/warp 1000 && ovs-appctl time/warp 1000], [0], [warped
warped
])
Expand Down Expand Up @@ -2059,12 +2057,9 @@ OVS_VSWITCHD_START([add-br br1 -- \
ADD_OF_PORTS([br0], [1], [2])
ADD_OF_PORTS([br1], [3])

AT_CHECK([ovs-appctl netdev-dummy/receive p1 'in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'], [0], [success
])
AT_CHECK([ovs-appctl netdev-dummy/receive p2 'in_port(2),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:05),eth_type(0x0800),ipv4(src=192.168.0.2,dst=192.168.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=0,code=0)'], [0], [success
])
AT_CHECK([ovs-appctl netdev-dummy/receive p3 'in_port(3),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'], [0], [success
])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 'in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
AT_CHECK([ovs-appctl netdev-dummy/receive p2 'in_port(2),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:05),eth_type(0x0800),ipv4(src=192.168.0.2,dst=192.168.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=0,code=0)'])
AT_CHECK([ovs-appctl netdev-dummy/receive p3 'in_port(3),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])

AT_CHECK([ovs-appctl dpif/dump-flows br0 | sort | STRIP_USED], [0], [dnl
in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0), packets:0, bytes:0, used:0.0s, actions:userspace(pid=0,slow_path(controller))
Expand All @@ -2084,12 +2079,9 @@ OVS_VSWITCHD_START([add-br br1 -- \
ADD_OF_PORTS([br0], [1], [2])
ADD_OF_PORTS([br1], [3])

AT_CHECK([ovs-appctl netdev-dummy/receive p1 'in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'], [0], [success
])
AT_CHECK([ovs-appctl netdev-dummy/receive p2 'in_port(2),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:05),eth_type(0x0800),ipv4(src=192.168.0.2,dst=192.168.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=0,code=0)'], [0], [success
])
AT_CHECK([ovs-appctl netdev-dummy/receive p3 'in_port(3),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'], [0], [success
])
AT_CHECK([ovs-appctl netdev-dummy/receive p1 'in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
AT_CHECK([ovs-appctl netdev-dummy/receive p2 'in_port(2),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:05),eth_type(0x0800),ipv4(src=192.168.0.2,dst=192.168.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=0,code=0)'])
AT_CHECK([ovs-appctl netdev-dummy/receive p3 'in_port(3),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])

AT_CHECK([ovs-appctl dpif/dump-flows br0 | sort | STRIP_USED], [0], [dnl
in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0), packets:0, bytes:0, used:0.0s, actions:userspace(pid=0,slow_path(controller))
Expand Down

0 comments on commit 323cc92

Please sign in to comment.