X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=ofproto%2Fofproto-sflow.c;h=04e8347050628eb68d565c3560b79165ccc99b5c;hb=7f7ae89d2477e14b11c1355668366030fc590c64;hp=076bd79c474a9ac21650e67636a50a306b0995e7;hpb=0cc96e48ab2fc573c3b7b69fe5a034bb29dde578;p=openvswitch diff --git a/ofproto/ofproto-sflow.c b/ofproto/ofproto-sflow.c index 076bd79c..04e83470 100644 --- a/ofproto/ofproto-sflow.c +++ b/ofproto/ofproto-sflow.c @@ -1,6 +1,6 @@ /* - * Copyright (c) 2009, 2010 InMon Corp. - * Copyright (c) 2009 Nicira Networks. + * Copyright (c) 2009, 2010 Nicira Networks. + * Copyright (c) 2009 InMon Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,13 +27,14 @@ #include "netdev.h" #include "ofpbuf.h" #include "ofproto.h" +#include "packets.h" #include "poll-loop.h" #include "sflow_api.h" #include "socket-util.h" #include "timeval.h" #include "vlog.h" -VLOG_DEFINE_THIS_MODULE(sflow) +VLOG_DEFINE_THIS_MODULE(sflow); struct ofproto_sflow_port { struct hmap_node hmap_node; /* In struct ofproto_sflow's "ports" hmap. */ @@ -140,7 +141,7 @@ ofproto_sflow_find_port(const struct ofproto_sflow *os, uint16_t odp_port) { struct ofproto_sflow_port *osp; - HMAP_FOR_EACH_IN_BUCKET (osp, struct ofproto_sflow_port, hmap_node, + HMAP_FOR_EACH_IN_BUCKET (osp, hmap_node, hash_int(odp_port, 0), &os->ports) { if (osp->odp_port == odp_port) { return osp; @@ -181,10 +182,8 @@ sflow_agent_get_counters(void *os_, SFLPoller *poller, counters->ifDirection = 0; } if (!netdev_get_flags(osp->netdev, &flags) && flags & NETDEV_UP) { - bool carrier; - counters->ifStatus = 1; /* ifAdminStatus up. */ - if (!netdev_get_carrier(osp->netdev, &carrier) && carrier) { + if (netdev_get_carrier(osp->netdev)) { counters->ifStatus |= 2; /* ifOperStatus us. */ } } else { @@ -297,8 +296,7 @@ ofproto_sflow_destroy(struct ofproto_sflow *os) struct ofproto_sflow_port *osp, *next; ofproto_sflow_clear(os); - HMAP_FOR_EACH_SAFE (osp, next, struct ofproto_sflow_port, hmap_node, - &os->ports) { + HMAP_FOR_EACH_SAFE (osp, next, hmap_node, &os->ports) { ofproto_sflow_del_port__(os, osp); } hmap_destroy(&os->ports); @@ -463,7 +461,7 @@ ofproto_sflow_set_options(struct ofproto_sflow *os, MAX(1, UINT32_MAX / options->sampling_rate)); /* Add samplers and pollers for the currently known ports. */ - HMAP_FOR_EACH (osp, struct ofproto_sflow_port, hmap_node, &os->ports) { + HMAP_FOR_EACH (osp, hmap_node, &os->ports) { ofproto_sflow_add_poller(os, osp, osp->odp_port); ofproto_sflow_add_sampler(os, osp); } @@ -489,8 +487,8 @@ ofproto_sflow_received(struct ofproto_sflow *os, struct odp_msg *msg) const union odp_action *actions; struct ofpbuf payload; size_t n_actions, n_outputs; + struct flow flow; size_t min_size; - flow_t flow; size_t i; /* Get odp_sflow_sample_header. */ @@ -567,6 +565,7 @@ ofproto_sflow_received(struct ofproto_sflow *os, struct odp_msg *msg) n_outputs = 0; for (i = 0; i < n_actions; i++) { const union odp_action *a = &actions[i]; + uint16_t tci; switch (a->type) { case ODPAT_OUTPUT: @@ -574,18 +573,10 @@ ofproto_sflow_received(struct ofproto_sflow *os, struct odp_msg *msg) n_outputs++; break; - case ODPAT_OUTPUT_GROUP: - n_outputs += (a->output_group.group == DP_GROUP_FLOOD ? os->n_flood - : a->output_group.group == DP_GROUP_ALL ? os->n_all - : 0); - break; - - case ODPAT_SET_VLAN_VID: - switchElem.flowType.sw.dst_vlan = ntohs(a->vlan_vid.vlan_vid); - break; - - case ODPAT_SET_VLAN_PCP: - switchElem.flowType.sw.dst_priority = a->vlan_pcp.vlan_pcp; + case ODPAT_SET_DL_TCI: + tci = a->dl_tci.tci; + switchElem.flowType.sw.dst_vlan = vlan_tci_to_vid(tci); + switchElem.flowType.sw.dst_priority = vlan_tci_to_pcp(tci); break; default: @@ -610,14 +601,6 @@ ofproto_sflow_received(struct ofproto_sflow *os, struct odp_msg *msg) sfl_sampler_writeFlowSample(sampler, &fs); } -void -ofproto_sflow_set_group_sizes(struct ofproto_sflow *os, - size_t n_flood, size_t n_all) -{ - os->n_flood = n_flood; - os->n_all = n_all; -} - void ofproto_sflow_run(struct ofproto_sflow *os) {