X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=datapath%2Fdatapath.c;h=6d9a8fe7aab260e63355c8756ba869f4d1edc0d4;hb=fc13a47f4d1895bee8fc293eefa611e7c133e660;hp=2b40e3caa43778418aa0962e5c8007c8d146484a;hpb=0226bbc7422d5844147e879e64a6defda0cbddd3;p=sliver-openvswitch.git diff --git a/datapath/datapath.c b/datapath/datapath.c index 2b40e3caa..6d9a8fe7a 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -41,6 +41,23 @@ #include "compat.h" +/* Strings to describe the manufacturer, hardware, and software. This data + * is queriable through the version stats message. */ +static char mfr_desc[VERSION_STR_LEN] = "Nicira Networks"; +static char hw_desc[VERSION_STR_LEN] = "Reference Linux Kernel Module"; +static char sw_desc[VERSION_STR_LEN] = VERSION; + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) +module_param_string(mfr_desc, mfr_desc, sizeof mfr_desc, 0444); +module_param_string(hw_desc, hw_desc, sizeof hw_desc, 0444); +module_param_string(sw_desc, sw_desc, sizeof sw_desc, 0444); +#else +MODULE_PARM(mfr_desc, "s"); +MODULE_PARM(hw_desc, "s"); +MODULE_PARM(sw_desc, "s"); +#endif + + /* Number of milliseconds between runs of the maintenance thread. */ #define MAINT_SLEEP_MSECS 1000 @@ -554,7 +571,7 @@ int dp_output_port(struct datapath *dp, struct sk_buff *skb, int out_port) case OFPP_IN_PORT: /* Send it out the port it came in on, which is already set in * the skb. */ - if (!skb->dev) { + if (!skb->dev) { if (net_ratelimit()) printk("skb device not set forwarding to in_port\n"); kfree(skb); @@ -1079,6 +1096,24 @@ static struct nla_policy dp_genl_openflow_policy[DP_GENL_A_MAX + 1] = { [DP_GENL_A_DP_IDX] = { .type = NLA_U32 }, }; +static int version_stats_dump(struct datapath *dp, void *state, + void *body, int *body_len) +{ + struct ofp_version_stats *ovs = body; + int n_bytes = sizeof *ovs; + + if (n_bytes > *body_len) { + return -ENOBUFS; + } + *body_len = n_bytes; + + strncpy(ovs->mfr_desc, mfr_desc, sizeof ovs->mfr_desc); + strncpy(ovs->hw_desc, hw_desc, sizeof ovs->hw_desc); + strncpy(ovs->sw_desc, sw_desc, sizeof ovs->sw_desc); + + return 0; +} + struct flow_stats_state { int table_idx; struct sw_table_position position; @@ -1244,11 +1279,11 @@ static int table_stats_dump(struct datapath *dp, void *state, void *body, int *body_len) { struct ofp_table_stats *ots; - int nbytes = dp->chain->n_tables * sizeof *ots; + int n_bytes = dp->chain->n_tables * sizeof *ots; int i; - if (nbytes > *body_len) + if (n_bytes > *body_len) return -ENOBUFS; - *body_len = nbytes; + *body_len = n_bytes; for (i = 0, ots = body; i < dp->chain->n_tables; i++, ots++) { struct sw_table_stats stats; dp->chain->tables[i]->stats(dp->chain->tables[i], &stats); @@ -1299,10 +1334,18 @@ static int port_stats_dump(struct datapath *dp, void *state, stats = p->dev->get_stats(p->dev); ops->port_no = htons(p->port_no); memset(ops->pad, 0, sizeof ops->pad); - ops->rx_count = cpu_to_be64(stats->rx_packets); - ops->tx_count = cpu_to_be64(stats->tx_packets); - ops->drop_count = cpu_to_be64(stats->rx_dropped - + stats->tx_dropped); + ops->rx_packets = cpu_to_be64(stats->rx_packets); + ops->tx_packets = cpu_to_be64(stats->tx_packets); + ops->rx_bytes = cpu_to_be64(stats->rx_bytes); + ops->tx_bytes = cpu_to_be64(stats->tx_bytes); + ops->rx_dropped = cpu_to_be64(stats->rx_dropped); + ops->tx_dropped = cpu_to_be64(stats->tx_dropped); + ops->rx_errors = cpu_to_be64(stats->rx_errors); + ops->tx_errors = cpu_to_be64(stats->tx_errors); + ops->rx_frame_err = cpu_to_be64(stats->rx_frame_errors); + ops->rx_over_err = cpu_to_be64(stats->rx_over_errors); + ops->rx_crc_err = cpu_to_be64(stats->rx_crc_errors); + ops->collisions = cpu_to_be64(stats->collisions); n_ports++; ops++; } @@ -1342,6 +1385,13 @@ struct stats_type { }; static const struct stats_type stats[] = { + [OFPST_VERSION] = { + 0, + 0, + NULL, + version_stats_dump, + NULL + }, [OFPST_FLOW] = { sizeof(struct ofp_flow_stats_request), sizeof(struct ofp_flow_stats_request),