Skip to content

Commit

Permalink
openvswitch: Unify vport error stats handling.
Browse files Browse the repository at this point in the history
Following patch changes vport->send return type so that vport
layer can do error accounting.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
  • Loading branch information
Pravin B Shelar authored and Jesse Gross committed Jun 14, 2013
1 parent cbd531b commit 91b7514
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 2 additions & 3 deletions net/openvswitch/vport-netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ static int netdev_send(struct vport *vport, struct sk_buff *skb)
net_warn_ratelimited("%s: dropped over-mtu packet: %d > %d\n",
netdev_vport->dev->name,
packet_length(skb), mtu);
goto error;
goto drop;
}

skb->dev = netdev_vport->dev;
Expand All @@ -179,9 +179,8 @@ static int netdev_send(struct vport *vport, struct sk_buff *skb)

return len;

error:
drop:
kfree_skb(skb);
ovs_vport_record_error(vport, VPORT_E_TX_DROPPED);
return 0;
}

Expand Down
9 changes: 7 additions & 2 deletions net/openvswitch/vport.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ int ovs_vport_send(struct vport *vport, struct sk_buff *skb)
{
int sent = vport->ops->send(vport, skb);

if (likely(sent)) {
if (likely(sent > 0)) {
struct pcpu_tstats *stats;

stats = this_cpu_ptr(vport->percpu_stats);
Expand All @@ -360,7 +360,12 @@ int ovs_vport_send(struct vport *vport, struct sk_buff *skb)
stats->tx_packets++;
stats->tx_bytes += sent;
u64_stats_update_end(&stats->syncp);
}
} else if (sent < 0) {
ovs_vport_record_error(vport, VPORT_E_TX_ERROR);
kfree_skb(skb);
} else
ovs_vport_record_error(vport, VPORT_E_TX_DROPPED);

return sent;
}

Expand Down
3 changes: 2 additions & 1 deletion net/openvswitch/vport.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ struct vport_parms {
* existing vport to a &struct sk_buff. May be %NULL for a vport that does not
* have any configuration.
* @get_name: Get the device's name.
* @send: Send a packet on the device. Returns the length of the packet sent.
* @send: Send a packet on the device. Returns the length of the packet sent,
* zero for dropped packets or negative for error.
*/
struct vport_ops {
enum ovs_vport_type type;
Expand Down

0 comments on commit 91b7514

Please sign in to comment.