Skip to content

Commit 91b7514

Browse files
Pravin B Shelarjessegross
authored andcommitted
openvswitch: Unify vport error stats handling.
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>
1 parent cbd531b commit 91b7514

3 files changed

Lines changed: 11 additions & 6 deletions

File tree

‎net/openvswitch/vport-netdev.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ static int netdev_send(struct vport *vport, struct sk_buff *skb)
170170
net_warn_ratelimited("%s: dropped over-mtu packet: %d > %d\n",
171171
netdev_vport->dev->name,
172172
packet_length(skb), mtu);
173-
goto error;
173+
goto drop;
174174
}
175175

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

180180
return len;
181181

182-
error:
182+
drop:
183183
kfree_skb(skb);
184-
ovs_vport_record_error(vport, VPORT_E_TX_DROPPED);
185184
return 0;
186185
}
187186

‎net/openvswitch/vport.c‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ int ovs_vport_send(struct vport *vport, struct sk_buff *skb)
351351
{
352352
int sent = vport->ops->send(vport, skb);
353353

354-
if (likely(sent)) {
354+
if (likely(sent > 0)) {
355355
struct pcpu_tstats *stats;
356356

357357
stats = this_cpu_ptr(vport->percpu_stats);
@@ -360,7 +360,12 @@ int ovs_vport_send(struct vport *vport, struct sk_buff *skb)
360360
stats->tx_packets++;
361361
stats->tx_bytes += sent;
362362
u64_stats_update_end(&stats->syncp);
363-
}
363+
} else if (sent < 0) {
364+
ovs_vport_record_error(vport, VPORT_E_TX_ERROR);
365+
kfree_skb(skb);
366+
} else
367+
ovs_vport_record_error(vport, VPORT_E_TX_DROPPED);
368+
364369
return sent;
365370
}
366371

‎net/openvswitch/vport.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ struct vport_parms {
123123
* existing vport to a &struct sk_buff. May be %NULL for a vport that does not
124124
* have any configuration.
125125
* @get_name: Get the device's name.
126-
* @send: Send a packet on the device. Returns the length of the packet sent.
126+
* @send: Send a packet on the device. Returns the length of the packet sent,
127+
* zero for dropped packets or negative for error.
127128
*/
128129
struct vport_ops {
129130
enum ovs_vport_type type;

0 commit comments

Comments
 (0)