diff options
author | Pravin B Shelar <pshelar@nicira.com> | 2014-12-22 04:53:02 -0800 |
---|---|---|
committer | Pravin B Shelar <pshelar@nicira.com> | 2014-12-23 16:36:49 -0800 |
commit | 93258bd717fe8d08711bca6bfc12a7825287f213 (patch) | |
tree | d48c0889d3b883f01223aeb19396b5ba25ba3bec /datapath/vport-gre.c | |
parent | b1b3fb138f4d5c942b69dd948963f978ee180a8f (diff) | |
download | openvswitch-93258bd717fe8d08711bca6bfc12a7825287f213.tar.gz |
datapath: Simplify vport_send() error handling.
Today vport-send has complex error handling because it involves
freeing skb and updating stats depending on return value from
vport send implementation.
This can be simplified by delegating responsibility of freeing
skb to the vport implementation for all cases. So that
vport-send needs just update stats.
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
Diffstat (limited to 'datapath/vport-gre.c')
-rw-r--r-- | datapath/vport-gre.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/datapath/vport-gre.c b/datapath/vport-gre.c index 41c025db4..daf7fc348 100644 --- a/datapath/vport-gre.c +++ b/datapath/vport-gre.c @@ -72,7 +72,7 @@ static struct sk_buff *__build_header(struct sk_buff *skb, tun_key = &OVS_CB(skb)->egress_tun_info->tunnel; skb = gre_handle_offloads(skb, !!(tun_key->tun_flags & TUNNEL_CSUM)); if (IS_ERR(skb)) - return NULL; + return skb; tpi.flags = filter_tnl_flags(tun_key->tun_flags) | gre64_flag; @@ -179,6 +179,7 @@ static int __send(struct vport *vport, struct sk_buff *skb, skb->vlan_proto, vlan_tx_tag_get(skb)))) { err = -ENOMEM; + skb = NULL; goto err_free_rt; } vlan_set_tci(skb, 0); @@ -186,8 +187,9 @@ static int __send(struct vport *vport, struct sk_buff *skb, /* Push Tunnel header. */ skb = __build_header(skb, tunnel_hlen, seq, gre64_flag); - if (unlikely(!skb)) { - err = 0; + if (IS_ERR(skb)) { + err = PTR_ERR(skb); + skb = NULL; goto err_free_rt; } @@ -201,6 +203,7 @@ static int __send(struct vport *vport, struct sk_buff *skb, err_free_rt: ip_rt_put(rt); error: + kfree_skb(skb); return err; } @@ -286,8 +289,10 @@ static int gre_send(struct vport *vport, struct sk_buff *skb) { int hlen; - if (unlikely(!OVS_CB(skb)->egress_tun_info)) + if (unlikely(!OVS_CB(skb)->egress_tun_info)) { + kfree_skb(skb); return -EINVAL; + } hlen = ip_gre_calc_hlen(OVS_CB(skb)->egress_tun_info->tunnel.tun_flags); @@ -370,8 +375,10 @@ static int gre64_send(struct vport *vport, struct sk_buff *skb) GRE_HEADER_SECTION; /* GRE SEQ */ __be32 seq; - if (unlikely(!OVS_CB(skb)->egress_tun_info)) + if (unlikely(!OVS_CB(skb)->egress_tun_info)) { + kfree_skb(skb); return -EINVAL; + } if (OVS_CB(skb)->egress_tun_info->tunnel.tun_flags & TUNNEL_CSUM) hlen += GRE_HEADER_SECTION; |