From: Ben Pfaff Date: Tue, 1 Jul 2008 17:52:34 +0000 (-0700) Subject: Drop "benchmark" netlink message and "benchmark-nl" dpctl command. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=88df6edbfaa4d4943e9f74f79973225c1c53297f;p=openvswitch Drop "benchmark" netlink message and "benchmark-nl" dpctl command. The new OFPT_ECHO_REQUEST and OFPT_ECHO_REPLY OpenFlow messages have the same functionality and are more general (in that they are not Netlink-specific). --- diff --git a/datapath/Modules.mk b/datapath/Modules.mk index 099be0e4..23e54da7 100644 --- a/datapath/Modules.mk +++ b/datapath/Modules.mk @@ -5,7 +5,6 @@ openflow_sources = \ chain.c \ crc32.c \ datapath.c \ - datapath_t.c \ dp_dev.c \ flow.c \ forward.c \ @@ -18,7 +17,6 @@ openflow_headers = \ compat.h \ crc32.h \ datapath.h \ - datapath_t.h \ dp_dev.h \ flow.h \ forward.h \ diff --git a/datapath/datapath.c b/datapath/datapath.c index 55c2c612..a4c6a2de 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -36,7 +36,6 @@ #include "dp_dev.h" #include "forward.h" #include "flow.h" -#include "datapath_t.h" #include "compat.h" @@ -1489,20 +1488,6 @@ static struct genl_ops dp_genl_ops_openflow = { .dumpit = dp_genl_openflow_dumpit, }; -static struct nla_policy dp_genl_benchmark_policy[DP_GENL_A_MAX + 1] = { - [DP_GENL_A_DP_IDX] = { .type = NLA_U32 }, - [DP_GENL_A_NPACKETS] = { .type = NLA_U32 }, - [DP_GENL_A_PSIZE] = { .type = NLA_U32 }, -}; - -static struct genl_ops dp_genl_ops_benchmark_nl = { - .cmd = DP_GENL_C_BENCHMARK_NL, - .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ - .policy = dp_genl_benchmark_policy, - .doit = dp_genl_benchmark_nl, - .dumpit = NULL, -}; - static struct genl_ops *dp_genl_all_ops[] = { /* Keep this operation first. Generic Netlink dispatching * looks up operations with linear search, so we want it at the @@ -1514,7 +1499,6 @@ static struct genl_ops *dp_genl_all_ops[] = { &dp_genl_ops_query_dp, &dp_genl_ops_add_port, &dp_genl_ops_del_port, - &dp_genl_ops_benchmark_nl, }; static int dp_init_netlink(void) diff --git a/datapath/datapath_t.c b/datapath/datapath_t.c deleted file mode 100644 index 33a64a60..00000000 --- a/datapath/datapath_t.c +++ /dev/null @@ -1,118 +0,0 @@ -#include "datapath_t.h" -#include -#include -#include -#include -#include -#include - -#include "datapath.h" - -static struct sk_buff * -gen_sk_buff(struct datapath *dp, uint32_t packet_size) -{ - int in_port; - struct sk_buff *skb; - struct ethhdr *eh; - struct iphdr *ih; - struct udphdr *uh; - - for (in_port = 0; in_port < OFPP_MAX; in_port++) { - if (dp->ports[in_port] != NULL) - break; - } - - if (in_port == OFPP_MAX) { - printk("benchmark: no in_port to send packets as\n"); - return NULL; - } - - skb = alloc_skb(packet_size, GFP_ATOMIC); - if (!skb) { - printk("benchmark: cannot allocate skb for benchmark\n"); - return NULL; - } - - skb_put(skb, packet_size); - skb_set_mac_header(skb, 0); - eh = eth_hdr(skb); - memcpy(eh->h_dest, "\x12\x34\x56\x78\x9a\xbc", ETH_ALEN); - memcpy(eh->h_source, "\xab\xcd\xef\x12\x34\x56", ETH_ALEN); - eh->h_proto = htons(ETH_P_IP); - skb_set_network_header(skb, sizeof(*eh)); - ih = ip_hdr(skb); - ih->ihl = 5; - ih->version = IPVERSION; - ih->tos = 0; - ih->tot_len = htons(packet_size - sizeof(*eh)); - ih->id = htons(12345); - ih->frag_off = 0; - ih->ttl = IPDEFTTL; - ih->protocol = IPPROTO_UDP; - ih->check = 0; /* want this to be right?! */ - ih->saddr = 0x12345678; - ih->daddr = 0x1234abcd; - skb_set_transport_header(skb, sizeof(*eh) + sizeof(*ih)); - uh = udp_hdr(skb); - uh->source = htons(1234); - uh->dest = htons(5678); - uh->len = htons(packet_size - sizeof(*eh) - sizeof(*ih)); - uh->check = 0; - if (dp_set_origin(dp, in_port, skb)) { - printk("benchmark: could not set origin\n"); - kfree_skb(skb); - return NULL; - } - - return skb; -} - -int -dp_genl_benchmark_nl(struct sk_buff *skb, struct genl_info *info) -{ - struct datapath *dp; - uint32_t num_packets = 0; - int i, err = 0; - struct sk_buff *skb2; - - if (!info->attrs[DP_GENL_A_DP_IDX] || !info->attrs[DP_GENL_A_NPACKETS] - || !info->attrs[DP_GENL_A_PSIZE]) - return -EINVAL; - - num_packets = nla_get_u32((info->attrs[DP_GENL_A_NPACKETS])); - - rcu_read_lock(); - dp = dp_get(nla_get_u32((info->attrs[DP_GENL_A_DP_IDX]))); - if (!dp) - err = -ENOENT; - else { - if (num_packets == 0) - goto benchmark_unlock; - - skb2 = gen_sk_buff(dp, nla_get_u32((info->attrs[DP_GENL_A_PSIZE]))); - if (skb2 == NULL) { - err = -ENOMEM; - goto benchmark_unlock; - } - - for (i = 0; i < num_packets; i++) { - struct sk_buff *copy = skb_get(skb2); - if (copy == NULL) { - printk("benchmark: skb_get failed\n"); - err = -ENOMEM; - break; - } - if ((err = dp_output_control(dp, copy, -1, - 0, OFPR_ACTION))) - { - printk("benchmark: output control ret %d on iter %d\n", err, i); - break; - } - } - kfree_skb(skb2); - } - -benchmark_unlock: - rcu_read_unlock(); - return err; -} diff --git a/datapath/datapath_t.h b/datapath/datapath_t.h deleted file mode 100644 index 868e734d..00000000 --- a/datapath/datapath_t.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef DATAPATH_T_H -#define DATAPATH_T_H 1 - -#include -#include -#include -#include -#include "openflow-netlink.h" - -int dp_genl_benchmark_nl(struct sk_buff *, struct genl_info *); - -#endif diff --git a/datapath/linux-2.4/.gitignore b/datapath/linux-2.4/.gitignore index af45ff28..a503159f 100644 --- a/datapath/linux-2.4/.gitignore +++ b/datapath/linux-2.4/.gitignore @@ -7,7 +7,6 @@ /flow.c /forward.c /forward_t.c -/datapath_t.c /table-hash.c /table-linear.c /table-mac.c diff --git a/datapath/linux-2.6/.gitignore b/datapath/linux-2.6/.gitignore index eee68d01..20b48299 100644 --- a/datapath/linux-2.6/.gitignore +++ b/datapath/linux-2.6/.gitignore @@ -5,7 +5,6 @@ /crc32.c /crc_t.c /datapath.c -/datapath_t.c /dp_dev.c /flow.c /forward.c diff --git a/include/dpif.h b/include/dpif.h index 4f806d7a..122c64d8 100644 --- a/include/dpif.h +++ b/include/dpif.h @@ -60,6 +60,5 @@ int dpif_add_dp(struct dpif *); int dpif_del_dp(struct dpif *); int dpif_add_port(struct dpif *, const char *netdev); int dpif_del_port(struct dpif *, const char *netdev); -int dpif_benchmark_nl(struct dpif *, uint32_t, uint32_t); #endif /* dpif.h */ diff --git a/include/openflow-netlink.h b/include/openflow-netlink.h index 7774cd58..0b67c990 100644 --- a/include/openflow-netlink.h +++ b/include/openflow-netlink.h @@ -61,8 +61,6 @@ enum dp_genl_command { DP_GENL_C_DEL_PORT, /* Remove port from datapath. */ DP_GENL_C_OPENFLOW, /* Encapsulated OpenFlow protocol. */ - DP_GENL_C_BENCHMARK_NL, /* Benchmark netlink connection */ - __DP_GENL_C_MAX, DP_GENL_C_MAX = __DP_GENL_C_MAX - 1 }; diff --git a/lib/dpif.c b/lib/dpif.c index 506efe3d..5d9c33c6 100644 --- a/lib/dpif.c +++ b/lib/dpif.c @@ -269,25 +269,6 @@ dpif_del_port(struct dpif *dp, const char *netdev) { return send_mgmt_command(dp, DP_GENL_C_DEL_PORT, netdev); } - -/* Tells dp to send num_packets up through netlink for benchmarking*/ -int -dpif_benchmark_nl(struct dpif *dp, uint32_t num_packets, uint32_t packet_size) -{ - struct buffer request; - int retval; - - buffer_init(&request, 0); - nl_msg_put_genlmsghdr(&request, dp->sock, 0, openflow_family, - NLM_F_REQUEST, DP_GENL_C_BENCHMARK_NL, 1); - nl_msg_put_u32(&request, DP_GENL_A_DP_IDX, dp->dp_idx); - nl_msg_put_u32(&request, DP_GENL_A_NPACKETS, num_packets); - nl_msg_put_u32(&request, DP_GENL_A_PSIZE, packet_size); - retval = nl_sock_send(dp->sock, &request, true); - buffer_uninit(&request); - - return retval; -} static const struct nl_policy openflow_multicast_policy[] = { [DP_GENL_A_DP_IDX] = { .type = NL_A_U32 }, diff --git a/utilities/dpctl.8 b/utilities/dpctl.8 index 1a714d2c..34d887a7 100644 --- a/utilities/dpctl.8 +++ b/utilities/dpctl.8 @@ -85,12 +85,6 @@ Prints to the console all OpenFlow packets sent by datapath \fIdp_idx\fR to its controller, where \fIdp_idx\fR is the ID of an existing datapath. -.TP -\fBbenchmark-nl nl:\fIdp_idx n size\fR -Checks the netlink performance between the kernel and userspace. -This is done by sending \fIN\fR packets of \fIsize\fR bytes from -the kernel module to dpctl. - .PP The following commands can be used regardless of the connection method. diff --git a/utilities/dpctl.c b/utilities/dpctl.c index 526b1bd8..804071af 100644 --- a/utilities/dpctl.c +++ b/utilities/dpctl.c @@ -167,7 +167,6 @@ usage(void) " addif nl:DP_ID IFACE add IFACE as a port on DP_ID\n" " delif nl:DP_ID IFACE delete IFACE as a port on DP_ID\n" " monitor nl:DP_ID print packets received\n" - " benchmark-nl nl:DP_ID N SIZE send N packets of SIZE bytes\n" #endif "\nCommands that apply to local datapaths and remote switches:\n" " show SWITCH show information\n" @@ -280,44 +279,6 @@ static void do_monitor(int argc UNUSED, char *argv[]) buffer_delete(b); } } - -#define BENCHMARK_INCR 100 - -static void do_benchmark_nl(int argc UNUSED, char *argv[]) -{ - struct dpif dp; - uint32_t num_packets, i, milestone; - struct timeval start, end; - - open_nl_vconn(argv[1], false, &dp); - num_packets = atoi(argv[2]); - milestone = BENCHMARK_INCR; - run(dpif_benchmark_nl(&dp, num_packets, atoi(argv[3])), "benchmark_nl"); - if (gettimeofday(&start, NULL) == -1) { - run(errno, "gettimeofday"); - } - for (i = 0; i < num_packets;i++) { - struct buffer *b; - run(dpif_recv_openflow(&dp, &b, true), "dpif_recv_openflow"); - if (i == milestone) { - gettimeofday(&end, NULL); - printf("%u packets received in %f ms\n", - BENCHMARK_INCR, - (1000*(double)(end.tv_sec - start.tv_sec)) - + (.001*(end.tv_usec - start.tv_usec))); - milestone += BENCHMARK_INCR; - start = end; - } - buffer_delete(b); - } - gettimeofday(&end, NULL); - printf("%u packets received in %f ms\n", - i - (milestone - BENCHMARK_INCR), - (1000*(double)(end.tv_sec - start.tv_sec)) - + (.001*(end.tv_usec - start.tv_usec))); - - dpif_close(&dp); -} #endif /* HAVE_NETLINK */ /* Generic commands. */ @@ -918,7 +879,6 @@ static struct command all_commands[] = { { "deldp", 1, 1, do_del_dp }, { "addif", 2, 2, do_add_port }, { "delif", 2, 2, do_del_port }, - { "benchmark-nl", 3, 3, do_benchmark_nl }, #endif { "show", 1, 1, do_show },